messagingapp/msgui/msgapp/src/main.cpp
changeset 34 84197e66a4bd
parent 23 238255e8b033
child 43 35b64624a9e7
equal deleted inserted replaced
31:ebfee66fde93 34:84197e66a4bd
    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 
    32 #ifdef _DEBUG_TRACES_
    36 #ifdef _DEBUG_TRACES_
    33 void debugInit(QtMsgType type, const char *msg)
    37 void debugInit(QtMsgType type, const char *msg)
    34 {
    38 {
    35 
    39 
    36     QFile ofile(debugFileName);
    40     QFile ofile(debugFileName);
    72 }
    76 }
    73 
    77 
    74 #endif
    78 #endif
    75 int main(int argc, char *argv[])
    79 int main(int argc, char *argv[])
    76 {
    80 {
       
    81     
       
    82     QCRITICAL_WRITE("MsgApp start.");
       
    83     
       
    84     QString firstArg(argv[1]);
       
    85     bool serviceRequest = false;
       
    86     // check for argc is greater than 1 and its not from activity
       
    87     if(argc >1 && firstArg != activityParam )
       
    88     {
       
    89         serviceRequest = true;
       
    90         HbSplashScreen::setScreenId("dummy");
       
    91     }
       
    92     else
       
    93     {
       
    94         HbSplashScreen::setScreenId("clv");   
       
    95     }
       
    96     
    77     // Application
    97     // Application
    78     HbApplication app(argc, argv);
    98     HbApplication app(argc, argv);
    79 
    99 
    80     //TODO: Uncomment the lines when actual translation files are available in sdk and remove loading locally.
   100     //TODO: Uncomment the lines when actual translation files are available in sdk and remove loading locally.
    81     QString locale = QLocale::system().name();
   101     QString locale = QLocale::system().name();
    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      // clear the old activities
       
   127      activityHandler->clearActivities();
       
   128      
       
   129      // connect to aboutToQuit signal to save activity
       
   130      QObject::connect(&app, SIGNAL(aboutToQuit()), 
       
   131                       activityHandler, SLOT(saveActivity()));
       
   132     
       
   133     if(app.activateReason() == Hb::ActivationReasonActivity) {
       
   134           // restoring an activity, not a fresh startup or a service
       
   135           QVariant data = app.activateData();
       
   136           activityHandler->handleActivity(data);
       
   137           // set service request to false , since its a activity launch
       
   138           serviceRequest = false; 
   106         }
   139         }
       
   140     
   107     // Main window
   141     // Main window
   108     QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest);
   142     QPointer<MsgMainWindow> mainWindow = new MsgMainWindow(serviceRequest);
       
   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