emailuis/nmailui/src/nmapplication.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 47 f83bd4ae1fe3
child 54 997a02608b3a
equal deleted inserted replaced
43:99bcbff212ad 44:c2d07d913565
    96 
    96 
    97     if (mQueryDialog){
    97     if (mQueryDialog){
    98         delete mQueryDialog;
    98         delete mQueryDialog;
    99         mQueryDialog=NULL;
    99         mQueryDialog=NULL;
   100     }
   100     }
   101     
   101 
   102 #ifndef NM_WINS_ENV
   102 #ifndef NM_WINS_ENV
   103 	delete mSendServiceInterface;
   103 	delete mSendServiceInterface;
   104 	delete mSendServiceInterface2;
   104 	delete mSendServiceInterface2;
   105 	delete mUriServiceInterface;
   105 	delete mUriServiceInterface;
   106 	delete mMailboxServiceInterface;
   106 	delete mMailboxServiceInterface;
   121     delete mNetManager;
   121     delete mNetManager;
   122     mNetManager=NULL;
   122     mNetManager=NULL;
   123     }
   123     }
   124     // Effects needs to be deleted before MainWindow.
   124     // Effects needs to be deleted before MainWindow.
   125     delete mEffects;
   125     delete mEffects;
       
   126     if (mMainWindow) {
       
   127         // workaround: assert failure may happen otherwise
       
   128         mMainWindow->close();
       
   129     }
   126     delete mMainWindow;
   130     delete mMainWindow;
   127     delete mAttaManager;
   131     delete mAttaManager;
   128     delete mSettingsViewLauncher;
   132     delete mSettingsViewLauncher;
   129 }
   133 }
   130 
   134 
   355         // If view was started as service, move the app now
   359         // If view was started as service, move the app now
   356         // to the background, unless it was started when the app
   360         // to the background, unless it was started when the app
   357         // was already in foreground..
   361         // was already in foreground..
   358         if (mServiceViewId == topViewId) {
   362         if (mServiceViewId == topViewId) {
   359             mServiceViewId = NmUiViewNone;
   363             mServiceViewId = NmUiViewNone;
   360 
   364             NM_COMMENT("Returned from service view");
   361             // if started as embedded, do not hide the app
   365 
       
   366             // if started as embedded or while the app was in foreground,
       
   367             // do not hide the app
   362             if (!XQServiceUtil::isEmbedded() &&
   368             if (!XQServiceUtil::isEmbedded() &&
   363                 !mForegroundService) {
   369                 !mForegroundService) {
   364                 XQServiceUtil::toBackground(true);
   370                 XQServiceUtil::toBackground(true);
   365             }
   371             }
   366         }
   372         }
   407 
   413 
   408         if (startParam->service() && mMainWindow) {
   414         if (startParam->service() && mMainWindow) {
   409 			// When the message list is started as a service previous views are removed
   415 			// When the message list is started as a service previous views are removed
   410 			// from the stack. Open editors are not closed.
   416 			// from the stack. Open editors are not closed.
   411 			// Also if the view is same than the new one, keep it open (reload the content).
   417 			// Also if the view is same than the new one, keep it open (reload the content).
       
   418 
       
   419 
       
   420 		    // reset the foreground service flag while popping the views
       
   421 		    bool previousForegroundService = mForegroundService;
       
   422 		    mForegroundService = true;
   412 
   423 
   413 		    // at least one view must remain in the stack
   424 		    // at least one view must remain in the stack
   414 			while (mViewStack->count()>1) {
   425 			while (mViewStack->count()>1) {
   415 			    NmUiViewId topId = mViewStack->top()->nmailViewId();
   426 			    NmUiViewId topId = mViewStack->top()->nmailViewId();
   416 			    if (topId!=NmUiViewMessageEditor &&
   427 			    if (topId!=NmUiViewMessageEditor &&
   421 			    else {
   432 			    else {
   422 			        // Editor or mailbox list in the top. Stop the loop.
   433 			        // Editor or mailbox list in the top. Stop the loop.
   423 			        break;
   434 			        break;
   424 			    }
   435 			    }
   425 			}
   436 			}
       
   437 			mForegroundService = previousForegroundService;
   426         }
   438         }
   427 
   439 
   428         // Check whether requested view is already active
   440         // Check whether requested view is already active
   429         // and if so, ask it to reload contents with new start parameter data
   441         // and if so, ask it to reload contents with new start parameter data
   430         // Do not reuse the view if started as service to editor view (ShareUI)
   442         // Do not reuse the view if started as service to editor view (ShareUI)
   489                     delete startParam;
   501                     delete startParam;
   490                     startParam=NULL;
   502                     startParam=NULL;
   491                     resetViewStack();
   503                     resetViewStack();
   492                     break;
   504                     break;
   493             }
   505             }
   494 
   506         }
   495             if (startParam && startParam->service()) {
   507 
   496 				// Store the view id that was launched as service
   508         if (startParam && startParam->service()) {
   497         		mServiceViewId = mActiveViewId;
   509             // Store the view id that was launched as service
   498 			}
   510             mServiceViewId = mActiveViewId;
   499         }
   511 		}
   500     }
   512     }
   501 }
   513 }
   502 
   514 
   503 /*!
   515 /*!
   504     Function can be used from views to exit the application
   516     Function can be used from views to exit the application
   615             if (mQueryDialog){
   627             if (mQueryDialog){
   616                 delete mQueryDialog;
   628                 delete mQueryDialog;
   617                 mQueryDialog=NULL;
   629                 mQueryDialog=NULL;
   618             }
   630             }
   619             mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_address_or_password_incorrect"),
   631             mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_address_or_password_incorrect"),
   620                                                     this, SLOT(launchSettings(HbAction*)));                        
   632                                                     this, SLOT(launchSettings(HbAction*)));
   621         }
   633         }
   622         if(event.mOperationType == Synch && event.mCompletionCode == NmServerConnectionError) {
   634         if(event.mOperationType == Synch && event.mCompletionCode == NmServerConnectionError) {
   623             mLastOperationMailbox=event.mMailboxId;
   635             mLastOperationMailbox=event.mMailboxId;
   624             if (mQueryDialog){
   636             if (mQueryDialog){
   625                 delete mQueryDialog;
   637                 delete mQueryDialog;
   626                 mQueryDialog=NULL;
   638                 mQueryDialog=NULL;
   627             }
   639             }
   628             mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_server_settings_incorrect"),
   640             mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_server_settings_incorrect"),
   629                                                     this, SLOT(launchSettings(HbAction*)));                
   641                                                     this, SLOT(launchSettings(HbAction*)));
   630         }
   642         }
   631         // following applies to all operation/event types
   643         // following applies to all operation/event types
   632         if(event.mCompletionCode == NmConnectionError) {
   644         if(event.mCompletionCode == NmConnectionError) {
   633             NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_mail_connection_error"));
   645             NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_mail_connection_error"));
   634         }
   646         }
   639     launches settings view of the specified mailbox
   651     launches settings view of the specified mailbox
   640 */
   652 */
   641 void NmApplication::launchSettings(HbAction* action)
   653 void NmApplication::launchSettings(HbAction* action)
   642 {
   654 {
   643     NM_FUNCTION;
   655     NM_FUNCTION;
   644     
   656 
   645     // Check whether yes button was pressed
   657     // Check whether yes button was pressed
   646     if (mQueryDialog&& action == mQueryDialog->actions().at(0)) {
   658     if (mQueryDialog&& action == mQueryDialog->actions().at(0)) {
   647         // create settingslauncher if doesn't exist
   659         // create settingslauncher if doesn't exist
   648         if(!mSettingsViewLauncher) {
   660         if(!mSettingsViewLauncher) {
   649             mSettingsViewLauncher = new NmSettingsViewLauncher();
   661             mSettingsViewLauncher = new NmSettingsViewLauncher();
   650             }
   662             }
   651     
   663 
   652         if(mSettingsViewLauncher) {
   664         if(mSettingsViewLauncher) {
   653             // mailboxname required
   665             // mailboxname required
   654             NmMailboxMetaData *mailboxMetaData = mUiEngine->mailboxById(mLastOperationMailbox); // no ownership
   666             NmMailboxMetaData *mailboxMetaData = mUiEngine->mailboxById(mLastOperationMailbox); // no ownership
   655             if( mailboxMetaData ) {
   667             if( mailboxMetaData ) {
   656                 // launch
   668                 // launch
   657                 mSettingsViewLauncher->launchSettingsView(mLastOperationMailbox, mailboxMetaData->name());
   669                 mSettingsViewLauncher->launchSettingsView(mLastOperationMailbox, mailboxMetaData->name());
   658             }
   670             }
   659         }     
   671         }
   660     }    
   672     }
   661 }
   673 }
   662 
   674 
   663 /*!
   675 /*!
   664 	Stores the visibility state, e.g. when the service was launched.
   676 	Stores the visibility state, e.g. when the service was launched.
   665 	\return true if the app was visible
   677 	\return true if the app was visible