emailuis/nmailuiengine/src/nmuiengine.cpp
changeset 53 bf7eb7911fc5
parent 30 759dc5235cdb
child 47 f83bd4ae1fe3
equal deleted inserted replaced
30:759dc5235cdb 53:bf7eb7911fc5
    25 */
    25 */
    26 
    26 
    27 NmUiEngine *NmUiEngine::mInstance;
    27 NmUiEngine *NmUiEngine::mInstance;
    28 int NmUiEngine::mReferenceCount;
    28 int NmUiEngine::mReferenceCount;
    29 
    29 
    30 const QString syncIndicatorName = "com.nokia.hb.nmsyncindicator/1.0";
    30 const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0";
    31 
    31 
    32 /*!
    32 /*!
    33     Constructor
    33     Constructor
    34 */
    34 */
    35 NmUiEngine::NmUiEngine() 
    35 NmUiEngine::NmUiEngine() 
    37   mInboxListModel(NULL),
    37   mInboxListModel(NULL),
    38   mMessageListModel(NULL),
    38   mMessageListModel(NULL),
    39   mMessageSearchListModel(NULL),
    39   mMessageSearchListModel(NULL),
    40   mSendOperation(NULL),
    40   mSendOperation(NULL),
    41   mRemoveDraftOperation(NULL),
    41   mRemoveDraftOperation(NULL),
    42   mSaveDraftOperation(NULL)
    42   mSaveDraftOperation(NULL),
       
    43   mDraftMessage(NULL)
    43 {
    44 {
    44     NM_FUNCTION;
    45     NM_FUNCTION;
    45     
    46     
    46     mPluginFactory = NmDataPluginFactory::instance();
    47     mPluginFactory = NmDataPluginFactory::instance();
    47     mDataManager = new NmDataManager();
    48     mDataManager = new NmDataManager();
    85 */
    86 */
    86 NmUiEngine::~NmUiEngine()
    87 NmUiEngine::~NmUiEngine()
    87 {
    88 {
    88     NM_FUNCTION;
    89     NM_FUNCTION;
    89     
    90     
       
    91     HbIndicator indicator;
       
    92     indicator.deactivate(syncIndicatorName, QVariant());
       
    93     
    90     if (mMessageSearchListModel) {
    94     if (mMessageSearchListModel) {
    91         delete mMessageSearchListModel;
    95         delete mMessageSearchListModel;
    92         mMessageSearchListModel = NULL;
    96         mMessageSearchListModel = NULL;
    93     }
    97     }
    94     if (mInboxListModel) {
    98     if (mInboxListModel) {
   122     if(mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
   126     if(mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
   123         mRemoveDraftOperation->cancelOperation();        
   127         mRemoveDraftOperation->cancelOperation();        
   124     }
   128     }
   125     if(mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
   129     if(mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
   126         mSaveDraftOperation->cancelOperation();
   130         mSaveDraftOperation->cancelOperation();
       
   131     }
       
   132     if(mDraftMessage) {
       
   133         delete mDraftMessage;
       
   134         mDraftMessage = NULL;
   127     }
   135     }
   128 }
   136 }
   129 
   137 
   130 /*!
   138 /*!
   131 
   139 
   785             // to be on the safer side:
   793             // to be on the safer side:
   786             // we shouldn't even be here if mSaveDraftOperation != NULL
   794             // we shouldn't even be here if mSaveDraftOperation != NULL
   787             if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
   795             if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
   788                 mSaveDraftOperation->cancelOperation();
   796                 mSaveDraftOperation->cancelOperation();
   789             }
   797             }
   790             // ownership of message changes
   798             
   791             mSaveDraftOperation = plugin->saveMessageWithSubparts(*message);
   799             mSaveDraftOperation = plugin->saveMessageWithSubparts(*message);
   792             // don't put this to mOperations as we need to handle this
   800             
   793             // operation separately
       
   794             if (mSaveDraftOperation) {
   801             if (mSaveDraftOperation) {
       
   802                 // Ownership of message changes but saveMessageWithSubparts operation only makes a 
       
   803                 // copy so we handle the msg object deletion in engine. mDraftMessage is deleted
       
   804                 // in handleCompletedSaveDraftOperation once operation finishes. 
       
   805                 if(mDraftMessage) {
       
   806                     delete mDraftMessage;
       
   807                     mDraftMessage = NULL;
       
   808                 }
       
   809                 mDraftMessage = message;
       
   810                 message = NULL;
       
   811                 
   795                 for (int i(0); i < preliminaryOperations.count(); i++ ) {
   812                 for (int i(0); i < preliminaryOperations.count(); i++ ) {
   796                     QPointer<NmOperation> op = preliminaryOperations[i];
   813                     QPointer<NmOperation> op = preliminaryOperations[i];
   797                     mSaveDraftOperation->addPreliminaryOperation(op);
   814                     mSaveDraftOperation->addPreliminaryOperation(op);
   798                 }
   815                 }
   799                 
   816                 
   800                 connect(mSaveDraftOperation, 
   817                 connect(mSaveDraftOperation, 
   801                         SIGNAL(operationCompleted(int)), 
   818                         SIGNAL(operationCompleted(int)), 
   802                         this, 
   819                         this, 
   803                         SLOT(handleCompletedSaveDraftOperation()));
   820                         SLOT(handleCompletedSaveDraftOperation()));
   804                 
   821                 
   805                 // message object is not needed any more, so delete it
       
   806                 delete message;
       
   807                 message = NULL;
       
   808             }
   822             }
   809         }
   823         }
   810     }
   824     }
   811 }
   825 }
   812 
   826 
  1077 */
  1091 */
  1078 void NmUiEngine::handleCompletedSaveDraftOperation()
  1092 void NmUiEngine::handleCompletedSaveDraftOperation()
  1079 {
  1093 {
  1080     NM_FUNCTION;
  1094     NM_FUNCTION;
  1081     
  1095     
  1082     // draft message saving observing not yet implemented...
  1096     // delete message object since it's not needed anymore
       
  1097     if(mDraftMessage) {
       
  1098         delete mDraftMessage;
       
  1099         mDraftMessage = NULL;
       
  1100     }
  1083 }
  1101 }
  1084 
  1102 
  1085 /*!
  1103 /*!
  1086     Handles synch operation related events
  1104     Handles synch operation related events
  1087  */
  1105  */