| 1 |
/* |
| 2 |
* meego-handset-sms - Meego Handset SMS application |
| 3 |
* |
| 4 |
* Copyright (c) 2010, Intel Corporation. |
| 5 |
* |
| 6 |
* This program is licensed under the terms and conditions of the |
| 7 |
* Apache License, version 2.0. The full text of the Apache License is at |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
*/ |
| 11 |
|
| 12 |
#include <MMessageBox> |
| 13 |
|
| 14 |
#include "smsapplication.h" |
| 15 |
#include "util.h" |
| 16 |
#include "settingspage.h" |
| 17 |
|
| 18 |
SmsApplication::SmsApplication(int &argc, char **argv) |
| 19 |
: MApplication(argc, argv) |
| 20 |
{ |
| 21 |
mWindow = new MApplicationWindow(); |
| 22 |
mWindow->show(); |
| 23 |
mBackend = new Backend(); |
| 24 |
mInboxpage = new InboxPage(mBackend); |
| 25 |
connect(mInboxpage, SIGNAL(startDialog(QString)), |
| 26 |
this, SLOT(showdialogpage(QString))); |
| 27 |
connect(mInboxpage, SIGNAL(startNewMessage()), |
| 28 |
this, SLOT(shownewmessagepage())); |
| 29 |
connect(mInboxpage, SIGNAL(deleteAllThreads()), |
| 30 |
this, SLOT(deleteAllThreads())); |
| 31 |
connect(mInboxpage, SIGNAL(openSettings()), |
| 32 |
this, SLOT(openSettings())); |
| 33 |
connect(this, SIGNAL(aboutToQuit()), |
| 34 |
this, SLOT(cleanExit())); |
| 35 |
} |
| 36 |
|
| 37 |
SmsApplication *SmsApplication::instance() |
| 38 |
{ |
| 39 |
return qobject_cast<SmsApplication*>(MApplication::instance()); |
| 40 |
} |
| 41 |
|
| 42 |
Backend *SmsApplication::backend() |
| 43 |
{ |
| 44 |
return mBackend; |
| 45 |
} |
| 46 |
|
| 47 |
void SmsApplication::showinboxpage() |
| 48 |
{ |
| 49 |
if (!mWindow->currentPage()) { |
| 50 |
mInboxpage->appear(); |
| 51 |
} else if (mWindow->currentPage() == mDialogpage) { |
| 52 |
mDialogpage->dismiss(); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
void SmsApplication::showdialogpage(QString phone, QString message) |
| 57 |
{ |
| 58 |
if (mWindow->currentPage() && mWindow->currentPage() == mDialogpage) { |
| 59 |
mDialogpage->dismiss(); |
| 60 |
} |
| 61 |
mDialogpage = new DialogPage(mBackend, phone, message); |
| 62 |
connect(mDialogpage, SIGNAL(backButtonClicked()), |
| 63 |
this, SLOT(showinboxpage())); |
| 64 |
connect(mDialogpage, SIGNAL(deleteThread(QString)), |
| 65 |
this, SLOT(deleteThread(QString))); |
| 66 |
mDialogpage->appear(MSceneWindow::DestroyWhenDismissed); |
| 67 |
} |
| 68 |
|
| 69 |
void SmsApplication::shownewmessagepage() |
| 70 |
{ |
| 71 |
if (mWindow->currentPage() && mWindow->currentPage() == mDialogpage) { |
| 72 |
mDialogpage->dismiss(); |
| 73 |
} |
| 74 |
mDialogpage = new DialogPage(mBackend); |
| 75 |
connect(mDialogpage, SIGNAL(backButtonClicked()), |
| 76 |
this, SLOT(showinboxpage())); |
| 77 |
connect(mDialogpage, SIGNAL(deleteThread(QString)), |
| 78 |
this, SLOT(deleteThread(QString))); |
| 79 |
mDialogpage->appear(MSceneWindow::DestroyWhenDismissed); |
| 80 |
} |
| 81 |
|
| 82 |
void SmsApplication::openSettings() |
| 83 |
{ |
| 84 |
SettingsPage *settings = new SettingsPage(mBackend); |
| 85 |
settings->appear(MSceneWindow::DestroyWhenDismissed); |
| 86 |
} |
| 87 |
|
| 88 |
void SmsApplication::deleteThread(QString phone) |
| 89 |
{ |
| 90 |
mBackend->deleteThread(phone); |
| 91 |
} |
| 92 |
|
| 93 |
void SmsApplication::deleteAllThreads() |
| 94 |
{ |
| 95 |
mBackend->deleteAllThreads(); |
| 96 |
} |
| 97 |
|
| 98 |
void SmsApplication::cleanExit() |
| 99 |
{ |
| 100 |
//Save the text as Draft if any. |
| 101 |
if (mWindow->currentPage() == mDialogpage) { |
| 102 |
delete mDialogpage; |
| 103 |
} |
| 104 |
} |