emailuis/nmailuiengine/src/nmuiengine.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 47 f83bd4ae1fe3
--- a/emailuis/nmailuiengine/src/nmuiengine.cpp	Fri May 28 13:56:43 2010 +0300
+++ b/emailuis/nmailuiengine/src/nmuiengine.cpp	Thu Jun 10 16:14:05 2010 +0300
@@ -27,7 +27,7 @@
 NmUiEngine *NmUiEngine::mInstance;
 int NmUiEngine::mReferenceCount;
 
-const QString syncIndicatorName = "com.nokia.hb.nmsyncindicator/1.0";
+const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0";
 
 /*!
     Constructor
@@ -39,7 +39,8 @@
   mMessageSearchListModel(NULL),
   mSendOperation(NULL),
   mRemoveDraftOperation(NULL),
-  mSaveDraftOperation(NULL)
+  mSaveDraftOperation(NULL),
+  mDraftMessage(NULL)
 {
     NM_FUNCTION;
     
@@ -87,6 +88,9 @@
 {
     NM_FUNCTION;
     
+    HbIndicator indicator;
+    indicator.deactivate(syncIndicatorName, QVariant());
+    
     if (mMessageSearchListModel) {
         delete mMessageSearchListModel;
         mMessageSearchListModel = NULL;
@@ -125,6 +129,10 @@
     if(mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
         mSaveDraftOperation->cancelOperation();
     }
+    if(mDraftMessage) {
+        delete mDraftMessage;
+        mDraftMessage = NULL;
+    }
 }
 
 /*!
@@ -787,11 +795,20 @@
             if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
                 mSaveDraftOperation->cancelOperation();
             }
-            // ownership of message changes
+            
             mSaveDraftOperation = plugin->saveMessageWithSubparts(*message);
-            // don't put this to mOperations as we need to handle this
-            // operation separately
+            
             if (mSaveDraftOperation) {
+                // Ownership of message changes but saveMessageWithSubparts operation only makes a 
+                // copy so we handle the msg object deletion in engine. mDraftMessage is deleted
+                // in handleCompletedSaveDraftOperation once operation finishes. 
+                if(mDraftMessage) {
+                    delete mDraftMessage;
+                    mDraftMessage = NULL;
+                }
+                mDraftMessage = message;
+                message = NULL;
+                
                 for (int i(0); i < preliminaryOperations.count(); i++ ) {
                     QPointer<NmOperation> op = preliminaryOperations[i];
                     mSaveDraftOperation->addPreliminaryOperation(op);
@@ -802,9 +819,6 @@
                         this, 
                         SLOT(handleCompletedSaveDraftOperation()));
                 
-                // message object is not needed any more, so delete it
-                delete message;
-                message = NULL;
             }
         }
     }
@@ -1079,7 +1093,11 @@
 {
     NM_FUNCTION;
     
-    // draft message saving observing not yet implemented...
+    // delete message object since it's not needed anymore
+    if(mDraftMessage) {
+        delete mDraftMessage;
+        mDraftMessage = NULL;
+    }
 }
 
 /*!