From bc031c18989849a839678c3326537a8ccb8ac208 Mon Sep 17 00:00:00 2001
From: Pawel Andruszkiewicz
Date: Thu, 28 May 2015 09:01:45 +0200
Subject: [PATCH] [MessagingEmail] Remove all sync callbacks in destructor of
MessageServiceEmail.
[Verification] TCT pass rate 309/305/1/3/0 (98.71%) - with email-service fixed.
Change-Id: I64f753e80071d7a59f2d0e96642c3b98c8e2a5ed
Signed-off-by: Pawel Andruszkiewicz
---
src/messaging/message_service_email.cc | 14 +++++++++++---
src/messaging/message_service_email.h | 5 +++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/messaging/message_service_email.cc b/src/messaging/message_service_email.cc
index 705c94f..9c5ee86 100755
--- a/src/messaging/message_service_email.cc
+++ b/src/messaging/message_service_email.cc
@@ -33,9 +33,14 @@ MessageServiceEmail::MessageServiceEmail(int id, std::string name)
LoggerD("Entered");
}
-MessageServiceEmail::~MessageServiceEmail()
-{
- LoggerD("Entered");
+MessageServiceEmail::~MessageServiceEmail() {
+ LoggerD("Entered");
+
+ for (auto id : registered_callbacks_) {
+ // this may internally fail, because we don't have information about
+ // callbacks which already have fired
+ EmailManager::getInstance().RemoveSyncCallback(id);
+ }
}
static gboolean sendMessageTask(void* data)
@@ -182,6 +187,7 @@ PlatformResult MessageServiceEmail::sync(SyncCallbackData *callback, long* opera
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
}
*operation_id = op_id;
+ registered_callbacks_.insert(op_id);
return PlatformResult(ErrorCode::NO_ERROR);
}
@@ -218,6 +224,7 @@ PlatformResult MessageServiceEmail::syncFolder(SyncFolderCallbackData *callback,
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
}
*operation_id = op_id;
+ registered_callbacks_.insert(op_id);
return PlatformResult(ErrorCode::NO_ERROR);
}
@@ -242,6 +249,7 @@ PlatformResult MessageServiceEmail::stopSync(long op_id)
{
LoggerD("Entered");
+ registered_callbacks_.erase(op_id);
long* data = new long(op_id);
guint id = g_idle_add(stopSyncTask, static_cast(data));
diff --git a/src/messaging/message_service_email.h b/src/messaging/message_service_email.h
index cf769c0..e78801b 100755
--- a/src/messaging/message_service_email.h
+++ b/src/messaging/message_service_email.h
@@ -19,6 +19,8 @@
#include "message_service.h"
+#include
+
namespace extension {
namespace messaging {
@@ -33,6 +35,9 @@ public:
virtual common::PlatformResult sync(SyncCallbackData *callback, long* operation_id);
virtual common::PlatformResult syncFolder(SyncFolderCallbackData *callback, long* operation_id);
virtual common::PlatformResult stopSync(long op_id);
+
+private:
+ std::unordered_set registered_callbacks_;
};
} // messaging
--
2.7.4