From: Maciek Blim Date: Mon, 22 Dec 2014 14:34:51 +0000 (+0100) Subject: [Messasging] removeChangeListener (for emails) X-Git-Tag: submit/tizen_mobile/20150603.064609~1^2~658^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf2acd6caaedf72f81c9833277bb9b63b8108d7d;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Messasging] removeChangeListener (for emails) Change-Id: I2ba149529ecc4c99364be46696a45ba2e4331bd5 Signed-off-by: Maciek Blim --- diff --git a/src/messaging/change_listener_container.cc b/src/messaging/change_listener_container.cc index 4110353..b79b58a 100644 --- a/src/messaging/change_listener_container.cc +++ b/src/messaging/change_listener_container.cc @@ -139,10 +139,10 @@ void ChangeListenerContainer::removeChangeListener(long id) m_email_conversation_callbacks, id)) { LoggerD("Email conversation listener with id: %d removed", id); } - //else if (removeCallbackIfExists( - //context, m_email_folder_callbacks,id)) { - //LoggerD("Email folder listener with id: %d removed", id); - //} + else if (removeCallbackIfExists( + m_email_folder_callbacks,id)) { + LoggerD("Email folder listener with id: %d removed", id); + } else { LoggerW("WatchId %d not found", id); } diff --git a/src/messaging/message_storage.cc b/src/messaging/message_storage.cc index 9006744..d5abfe5 100644 --- a/src/messaging/message_storage.cc +++ b/src/messaging/message_storage.cc @@ -55,9 +55,10 @@ long MessageStorage::addFoldersChangeListener(std::shared_ptr callback); long addConversationsChangeListener(std::shared_ptr callback); long addFoldersChangeListener(std::shared_ptr callback); - void removeChangeListener(); + void removeChangeListener(long watchId); protected: int m_id; diff --git a/src/messaging/messaging_api.js b/src/messaging/messaging_api.js index 1e0ab73..0d588fd 100644 --- a/src/messaging/messaging_api.js +++ b/src/messaging/messaging_api.js @@ -1054,6 +1054,7 @@ MessageStorage.prototype.addMessagesChangeListener = function () { } }); + bridge.attach(cid, 'watchId', result); return result; }; @@ -1106,6 +1107,7 @@ MessageStorage.prototype.addConversationsChangeListener = function () { } }); + bridge.attach(cid, 'watchId', result); return result; }; @@ -1158,6 +1160,7 @@ MessageStorage.prototype.addFoldersChangeListener = function () { } }); + bridge.attach(cid, 'watchId', result); return result; }; @@ -1166,12 +1169,20 @@ MessageStorage.prototype.removeChangeListener = function () { {name: 'watchId', type: types_.LONG} ]); - bridge.sync({ + var self = this; + + var result = bridge.sync({ cmd: 'MessageStorage_removeChangeListener', args: { - watchId: args.watchId + watchId: args.watchId, + serviceId: self.service.id } }); + + bridge.find('watchId', args.watchId).forEach(function (e) { + bridge.remove(e.id); + }); + return result; }; function MessageConversation(data) { diff --git a/src/messaging/messaging_instance.cc b/src/messaging/messaging_instance.cc index 336a41a..cca250c 100644 --- a/src/messaging/messaging_instance.cc +++ b/src/messaging/messaging_instance.cc @@ -625,6 +625,15 @@ void MessagingInstance::MessageStorageRemoveChangeListener(const picojson::value picojson::object& out) { LoggerD("Entered"); + picojson::object data = args.get(JSON_DATA).get(); + const long watchId = static_cast( + data.at(REMOVE_CHANGE_LISTENER_ARGS_WATCHID).get()); + + int serviceId = static_cast(data.at(FUNCTIONS_HIDDEN_ARGS_SERVICE_ID).get()); + auto service = MessagingManager::getInstance().getMessageServiceEmail(serviceId); + + service->getMsgStorage()->removeChangeListener(watchId); + ReportSuccess(out); } } // namespace messaging