emailuis/nmailuiengine/src/nmuiengine.cpp
changeset 54 997a02608b3a
parent 53 bf7eb7911fc5
child 51 d845db10c0d4
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
    80     }
    80     }
    81 }
    81 }
    82 
    82 
    83 
    83 
    84 /*!
    84 /*!
    85     Destructor
    85     Class destructor.
    86 */
    86 */
    87 NmUiEngine::~NmUiEngine()
    87 NmUiEngine::~NmUiEngine()
    88 {
    88 {
    89     NM_FUNCTION;
    89     NM_FUNCTION;
    90     
    90     
    93     
    93     
    94     if (mMessageSearchListModel) {
    94     if (mMessageSearchListModel) {
    95         delete mMessageSearchListModel;
    95         delete mMessageSearchListModel;
    96         mMessageSearchListModel = NULL;
    96         mMessageSearchListModel = NULL;
    97     }
    97     }
       
    98 
    98     if (mInboxListModel) {
    99     if (mInboxListModel) {
    99         delete mInboxListModel;
   100         delete mInboxListModel;
   100         mInboxListModel = NULL;
   101         mInboxListModel = NULL;
   101     }  
   102     }
       
   103 
   102     if (mMessageListModel) {
   104     if (mMessageListModel) {
   103         delete mMessageListModel;
   105         delete mMessageListModel;
   104         mMessageListModel = NULL;
   106         mMessageListModel = NULL;
   105     }
   107     }
       
   108 
   106     if (mMailboxListModel) {
   109     if (mMailboxListModel) {
   107         delete mMailboxListModel;
   110         delete mMailboxListModel;
   108         mMailboxListModel = NULL;
   111         mMailboxListModel = NULL;
   109     }
   112     }
   110     // do the unsubscriptions
   113 
       
   114     // Do the unsubscriptions.
   111     QList<NmId> mailboxIdList;
   115     QList<NmId> mailboxIdList;
   112     mDataManager->listMailboxIds(mailboxIdList);
   116     mDataManager->listMailboxIds(mailboxIdList);
       
   117 
   113     for (int i(0); i < mailboxIdList.count(); i++) {
   118     for (int i(0); i < mailboxIdList.count(); i++) {
   114         NmId id = mailboxIdList[i];
   119         NmId id = mailboxIdList[i];
   115         NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(id);
   120         NmDataPluginInterface *pluginInterface =
       
   121             mPluginFactory->interfaceInstance(id);
       
   122 
   116         if (pluginInterface) {
   123         if (pluginInterface) {
   117             pluginInterface->unsubscribeMailboxEvents(id);
   124             pluginInterface->unsubscribeMailboxEvents(id);
   118         }
   125         }
   119     }
   126     }
       
   127 
   120     mailboxIdList.clear();
   128     mailboxIdList.clear();
       
   129 
   121     NmDataPluginFactory::releaseInstance(mPluginFactory);
   130     NmDataPluginFactory::releaseInstance(mPluginFactory);
       
   131 
   122     delete mDataManager;
   132     delete mDataManager;
       
   133 
       
   134     // Cancel all operations.
   123     if (mSendOperation && mSendOperation->isRunning()) {
   135     if (mSendOperation && mSendOperation->isRunning()) {
   124         mSendOperation->cancelOperation();
   136         mSendOperation->cancelOperation();
   125     }
   137     }
   126     if(mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
   138 
       
   139     if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
   127         mRemoveDraftOperation->cancelOperation();        
   140         mRemoveDraftOperation->cancelOperation();        
   128     }
   141     }
   129     if(mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
   142 
       
   143     if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
   130         mSaveDraftOperation->cancelOperation();
   144         mSaveDraftOperation->cancelOperation();
   131     }
   145     }
       
   146 
       
   147     // Call processEvents() to ensure that the cancelled operations get the time
       
   148     // they need to destroy themselves.
       
   149     qApp->processEvents();
       
   150 
   132     if(mDraftMessage) {
   151     if(mDraftMessage) {
   133         delete mDraftMessage;
   152         delete mDraftMessage;
   134         mDraftMessage = NULL;
   153         mDraftMessage = NULL;
   135     }
   154     }
   136 }
   155 }
       
   156 
   137 
   157 
   138 /*!
   158 /*!
   139 
   159 
   140 */
   160 */
   141 NmUiEngine *NmUiEngine::instance()
   161 NmUiEngine *NmUiEngine::instance()
  1233     if ( connectState == Disconnected && errorCode!= NmNoError ) {
  1253     if ( connectState == Disconnected && errorCode!= NmNoError ) {
  1234         NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; 
  1254         NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; 
  1235         emit operationCompleted(event);
  1255         emit operationCompleted(event);
  1236     }
  1256     }
  1237 }
  1257 }
       
  1258 
       
  1259 /*!
       
  1260     returns full mailbox id from plain account id
       
  1261 */
       
  1262 NmId NmUiEngine::getPluginIdByMailboxId(quint32 accountId)
       
  1263 {
       
  1264     NM_FUNCTION;
       
  1265     
       
  1266     NmId fullId = NULL;
       
  1267     fullId.setId32(accountId);
       
  1268     QList<NmId> mailboxList;
       
  1269     if(mDataManager){
       
  1270         mDataManager->listMailboxIds(mailboxList);
       
  1271         for(int i=0;i<mailboxList.count();i++){
       
  1272             if(mailboxList.at(i).id32() == accountId)
       
  1273                 fullId.setPluginId32(mailboxList.at(i).pluginId32());
       
  1274             }
       
  1275         }
       
  1276     return fullId;
       
  1277 }