messagingapp/msgui/msgapp/src/main.cpp
changeset 76 60a8a215b0ec
parent 73 ecf6a73a9186
--- a/messagingapp/msgui/msgapp/src/main.cpp	Tue Oct 05 13:58:47 2010 +0530
+++ b/messagingapp/msgui/msgapp/src/main.cpp	Tue Oct 19 11:30:16 2010 +0530
@@ -23,8 +23,11 @@
 #include <QDateTime>
 #include <QPointer>
 #include <HbSplashScreen>
+#include <HbApplication>
 
 #include "msgmainwindow.h"
+#include "msgviewmanager.h"
+#include "msgactivityhandler.h"
 #include "msgapplication.h"
 
 //Localised constants
@@ -32,7 +35,6 @@
 
 const QString debugFileName("c:/art2_app_log.txt");
 const QString activityParam("-activity");
-const int INVALID_MSGID = -1;
 
 #ifdef _DEBUG_TRACES_
 void debugInit(QtMsgType type, const char *msg)
@@ -94,13 +96,16 @@
     {
         HbSplashScreen::setScreenId("clv");   
     }
-    
+        
     // Application
     //MsgApplication class dervied from HbApplication is create in order to 
     //emit applicationReady signal for Matti tool
-    MsgApplication app(argc, argv);
+    MsgApplication app(argc, argv);     
     
-
+	//TODO pass this flag to viewmanager to prevent saving of activity 
+	//if this is set
+    //bool preloaded = HbApplication::startedToBackground();
+    
     //TODO: Uncomment the lines when actual translation files are available in sdk and remove loading locally.
     QString locale = QLocale::system().name();
     QString path = "z:/resource/qt/translations/";
@@ -122,11 +127,22 @@
     }
     qInstallMsgHandler(debugInit);
 #endif
-    
+           
+    MsgActivityHandler* activityHandler = new MsgActivityHandler(&app);     
     // Main window
-    QPointer<MsgMainWindow> mainWindow = 
-            new MsgMainWindow(serviceRequest);
-    app.initViewReady();    
+    QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest,
+        activityHandler);
+    app.initViewReady();
+    // Set the main window pointer to activity handler.
+    activityHandler->setMainWindow(mainWindow);
+
+    //Install event filter on app
+    app.installEventFilter(mainWindow);
+    
+    // connect to aboutToQuit signal to save activity
+    QObject::connect(&app, SIGNAL(closeEvent()), 
+            mainWindow->viewManager(), SLOT(handleSendToBackGround()));
+        
     mainWindow->show();
 
     // Event loop