20 #include <QLocale> |
20 #include <QLocale> |
21 #include <QFile> |
21 #include <QFile> |
22 #include "debugtraces.h" |
22 #include "debugtraces.h" |
23 #include <QDateTime> |
23 #include <QDateTime> |
24 #include <QPointer> |
24 #include <QPointer> |
|
25 #include <HbSplashScreen> |
25 |
26 |
26 #include "msgmainwindow.h" |
27 #include "msgmainwindow.h" |
|
28 #include "msgactivityhandler.h" |
27 |
29 |
28 //Localised constants |
30 //Localised constants |
29 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
31 #define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
30 |
32 |
31 const QString debugFileName("c:/art2_app_log.txt"); |
33 const QString debugFileName("c:/art2_app_log.txt"); |
|
34 const QString activityParam("-activity"); |
|
35 const int INVALID_MSGID = -1; |
|
36 |
32 #ifdef _DEBUG_TRACES_ |
37 #ifdef _DEBUG_TRACES_ |
33 void debugInit(QtMsgType type, const char *msg) |
38 void debugInit(QtMsgType type, const char *msg) |
34 { |
39 { |
35 |
40 |
36 QFile ofile(debugFileName); |
41 QFile ofile(debugFileName); |
72 } |
77 } |
73 |
78 |
74 #endif |
79 #endif |
75 int main(int argc, char *argv[]) |
80 int main(int argc, char *argv[]) |
76 { |
81 { |
|
82 |
|
83 QCRITICAL_WRITE("MsgApp start."); |
|
84 |
|
85 QString firstArg(argv[1]); |
|
86 bool serviceRequest = false; |
|
87 // check for argc is greater than 1 and its not from activity |
|
88 if(argc >1 && firstArg != activityParam ) |
|
89 { |
|
90 serviceRequest = true; |
|
91 HbSplashScreen::setScreenId("dummy"); |
|
92 } |
|
93 else |
|
94 { |
|
95 HbSplashScreen::setScreenId("clv"); |
|
96 } |
|
97 |
77 // Application |
98 // Application |
78 HbApplication app(argc, argv); |
99 HbApplication app(argc, argv); |
79 |
100 |
80 //TODO: Uncomment the lines when actual translation files are available in sdk and remove loading locally. |
101 //TODO: Uncomment the lines when actual translation files are available in sdk and remove loading locally. |
81 QString locale = QLocale::system().name(); |
102 QString locale = QLocale::system().name(); |
82 QString path = "z:/resource/qt/translations/"; |
103 QString path = "z:/resource/qt/translations/"; |
83 QTranslator translator; |
104 QTranslator translator; |
84 //QTranslator translator_comm; |
105 QTranslator translator_comm; |
85 //translator.load(path + QString("messaging_") + locale); |
106 translator.load(path + QString("messaging_") + locale); |
86 //translator_comm.load(path + QString("common_") + locale); |
107 translator_comm.load(path + QString("common_") + locale); |
87 translator.load( "messaging_en_GB", ":/translations" ); |
|
88 app.installTranslator(&translator); |
108 app.installTranslator(&translator); |
89 //app.installTranslator(&translator_comm); |
109 app.installTranslator(&translator_comm); |
90 |
110 |
91 app.setApplicationName(LOC_TITLE); |
111 app.setApplicationName(LOC_TITLE); |
92 |
112 |
93 #ifdef _DEBUG_TRACES_ |
113 #ifdef _DEBUG_TRACES_ |
94 //Debug Logs |
114 //Debug Logs |
97 { |
117 { |
98 ofile.remove(debugFileName); |
118 ofile.remove(debugFileName); |
99 } |
119 } |
100 qInstallMsgHandler(debugInit); |
120 qInstallMsgHandler(debugInit); |
101 #endif |
121 #endif |
102 bool serviceRequest = false; |
122 |
103 if(argc >1) |
123 |
104 { |
124 |
105 serviceRequest = true; |
125 MsgActivityHandler* activityHandler = new MsgActivityHandler(&app); |
|
126 // connect to aboutToQuit signal to save activity |
|
127 QObject::connect(&app, SIGNAL(aboutToQuit()), |
|
128 activityHandler, SLOT(saveActivity())); |
|
129 |
|
130 int activityMsgId = INVALID_MSGID; |
|
131 if(app.activateReason() == Hb::ActivationReasonActivity) { |
|
132 // restoring an activity, not a fresh startup or a service |
|
133 QVariant data = app.activateData(); |
|
134 activityMsgId = activityHandler->parseActivityData(data); |
|
135 // set service request to false , since its a activity launch |
|
136 serviceRequest = false; |
106 } |
137 } |
|
138 // clear the old activities |
|
139 activityHandler->clearActivities(); |
|
140 |
107 // Main window |
141 // Main window |
108 QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest); |
142 QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest,activityMsgId); |
|
143 // Set the main window pointer to activity handler. |
|
144 activityHandler->setMainWindow(mainWindow); |
109 mainWindow->show(); |
145 mainWindow->show(); |
110 |
146 |
111 // Event loop |
147 // Event loop |
112 int error = app.exec(); |
148 int error = app.exec(); |
113 |
149 HbApplication::processEvents(); |
|
150 |
114 // delete main window and return error |
151 // delete main window and return error |
115 delete mainWindow; |
152 delete mainWindow; |
|
153 |
116 return error; |
154 return error; |
117 } |
155 } |
118 |
156 |
119 // End of file |
157 // End of file |