messagingapp/msgui/msgapp/src/main.cpp
changeset 34 84197e66a4bd
parent 23 238255e8b033
child 43 35b64624a9e7
--- a/messagingapp/msgui/msgapp/src/main.cpp	Fri Jun 04 10:25:39 2010 +0100
+++ b/messagingapp/msgui/msgapp/src/main.cpp	Fri Jun 11 13:35:48 2010 +0300
@@ -22,13 +22,17 @@
 #include "debugtraces.h"
 #include <QDateTime>
 #include <QPointer>
+#include <HbSplashScreen>
 
 #include "msgmainwindow.h"
+#include "msgactivityhandler.h"
 
 //Localised constants
 #define LOC_TITLE hbTrId("txt_messaging_title_messaging")
 
 const QString debugFileName("c:/art2_app_log.txt");
+const QString activityParam("-activity");
+
 #ifdef _DEBUG_TRACES_
 void debugInit(QtMsgType type, const char *msg)
 {
@@ -74,6 +78,22 @@
 #endif
 int main(int argc, char *argv[])
 {
+    
+    QCRITICAL_WRITE("MsgApp start.");
+    
+    QString firstArg(argv[1]);
+    bool serviceRequest = false;
+    // check for argc is greater than 1 and its not from activity
+    if(argc >1 && firstArg != activityParam )
+    {
+        serviceRequest = true;
+        HbSplashScreen::setScreenId("dummy");
+    }
+    else
+    {
+        HbSplashScreen::setScreenId("clv");   
+    }
+    
     // Application
     HbApplication app(argc, argv);
 
@@ -99,20 +119,38 @@
     }
     qInstallMsgHandler(debugInit);
 #endif
-    bool serviceRequest = false;
-    if(argc >1)
-        {
-        serviceRequest = true;
+    
+   
+    
+     MsgActivityHandler* activityHandler = new MsgActivityHandler(&app);
+     // clear the old activities
+     activityHandler->clearActivities();
+     
+     // connect to aboutToQuit signal to save activity
+     QObject::connect(&app, SIGNAL(aboutToQuit()), 
+                      activityHandler, SLOT(saveActivity()));
+    
+    if(app.activateReason() == Hb::ActivationReasonActivity) {
+          // restoring an activity, not a fresh startup or a service
+          QVariant data = app.activateData();
+          activityHandler->handleActivity(data);
+          // set service request to false , since its a activity launch
+          serviceRequest = false; 
         }
+    
     // Main window
     QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest);
+    // Set the main window pointer to activity handler.
+    activityHandler->setMainWindow(mainWindow);
     mainWindow->show();
 
     // Event loop
     int error = app.exec();
-
+    HbApplication::processEvents();
+    
     // delete main window and return error
     delete mainWindow;
+    
     return error;
 }