From e669ef4d7a3b0db756043b32ad407f80711e2c1c Mon Sep 17 00:00:00 2001 From: Michal Michalski Date: Wed, 4 Dec 2019 14:45:51 +0100 Subject: [PATCH] [messaging] Remove MessageFolder(email_mailbox_t) constructor. + Conversion from email_mailbox_t to MessageFolder is now performed inside native function wrappers. [Verification] In progress. Signed-off-by: Michal Michalski Change-Id: If4ea326eaf9b3242d7c72285e6ba0f4db247d553 --- src/messaging/DBus/MessageProxy.cpp | 36 ++++++++++-------------------------- src/messaging/message_folder.cc | 23 ----------------------- src/messaging/message_folder.h | 1 - 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/src/messaging/DBus/MessageProxy.cpp b/src/messaging/DBus/MessageProxy.cpp index a52bd62..8ae3eb2 100644 --- a/src/messaging/DBus/MessageProxy.cpp +++ b/src/messaging/DBus/MessageProxy.cpp @@ -16,13 +16,13 @@ // #include "MessageProxy.h" +#include "../change_listener_container.h" +#include "../email_manager.h" #include "../message.h" #include "../message_conversation.h" #include "../message_email.h" +#include "../messaging_native.h" #include "common/logger.h" -//#include -#include "../change_listener_container.h" -#include "../email_manager.h" #include "messaging/DBus/DBusTypes.h" namespace extension { @@ -251,32 +251,16 @@ PlatformResult MessageProxy::handleMailboxEvent(int account_id, int mailbox_id, EventFolders* eventFolder = new EventFolders(); eventFolder->service_type = MessageType::EMAIL; eventFolder->service_id = account_id; - std::shared_ptr folder; - if (event == NOTI_MAILBOX_DELETE) { - // this event is triggered after mailbox is removed - // so we just create folder with id - folder.reset(new MessageFolder(std::to_string(mailbox_id), - "", // parent_id - "", // service_id - "", // content_type - "", // name - "", // path - "", // type - false)); - } else { - email_mailbox_t* mail_box = NULL; - int ntv_ret = email_get_mailbox_by_mailbox_id(mailbox_id, &mail_box); - if (EMAIL_ERROR_NONE != ntv_ret) { + auto folder = + std::make_shared(std::to_string(mailbox_id), "", "", "", "", "", "", false); + if (event != NOTI_MAILBOX_DELETE) { + auto ret = native::EmailGetMailboxById(mailbox_id, *folder); + if (ret.IsError()) { delete eventFolder; - return LogAndCreateResult( - ErrorCode::UNKNOWN_ERR, "Failed to load mailbox", - ("email_get_mailbox_by_mailbox_id error: %d (%s)", ntv_ret, get_error_message(ntv_ret))); - } - folder.reset(new MessageFolder(*mail_box)); - if (EMAIL_ERROR_NONE != email_free_mailbox(&mail_box, 1)) { - LoggerD("Failed to free email_free_mailbox"); + return ret; } } + eventFolder->items.push_back(folder); switch (event) { case NOTI_MAILBOX_ADD: diff --git a/src/messaging/message_folder.cc b/src/messaging/message_folder.cc index 88c5783..98418e1 100644 --- a/src/messaging/message_folder.cc +++ b/src/messaging/message_folder.cc @@ -38,22 +38,6 @@ const char* MESSAGE_FOLDER_ATTRIBUTE_PATH = "path"; const char* MESSAGE_FOLDER_ATTRIBUTE_TYPE = "type"; const char* MESSAGE_FOLDER_ATTRIBUTE_SYNCHRONIZABLE = "synchronizable"; -std::string convertPlatformFolderType(email_mailbox_type_e folderType) { - ScopeLogger(); - switch (folderType) { - case EMAIL_MAILBOX_TYPE_INBOX: - return MessageFolderTypeStr[MESSAGE_FOLDER_TYPE_INBOX]; - case EMAIL_MAILBOX_TYPE_SENTBOX: - return MessageFolderTypeStr[MESSAGE_FOLDER_TYPE_SENTBOX]; - case EMAIL_MAILBOX_TYPE_DRAFT: - return MessageFolderTypeStr[MESSAGE_FOLDER_TYPE_DRAFTS]; - case EMAIL_MAILBOX_TYPE_OUTBOX: - return MessageFolderTypeStr[MESSAGE_FOLDER_TYPE_OUTBOX]; - default: - return ""; - } -} - } // namespace MessageFolder::MessageFolder(const std::string& id, const std::string& parent_id, @@ -71,13 +55,6 @@ MessageFolder::MessageFolder(const std::string& id, const std::string& parent_id attributes[MESSAGE_FOLDER_ATTRIBUTE_SYNCHRONIZABLE] = picojson::value(synchronizable); } -MessageFolder::MessageFolder(email_mailbox_t mailbox) - : MessageFolder(std::to_string(mailbox.mailbox_id), "", std::to_string(mailbox.account_id), - MessagingUtil::messageTypeToString(EMAIL), mailbox.alias, mailbox.mailbox_name, - convertPlatformFolderType(mailbox.mailbox_type), mailbox.local == 0) { - ScopeLogger("from email_mailbox_t"); -} - MessageFolder::MessageFolder(const picojson::value& json) { ScopeLogger("from json"); attributes = json.get(); diff --git a/src/messaging/message_folder.h b/src/messaging/message_folder.h index ede4914..7f8e140 100644 --- a/src/messaging/message_folder.h +++ b/src/messaging/message_folder.h @@ -44,7 +44,6 @@ class MessageFolder : public tizen::FilterableObject { const std::string& content_type, const std::string& name, const std::string& path, const std::string& type, bool synchronizable); - MessageFolder(email_mailbox_t mailbox); MessageFolder(const picojson::value& json); virtual bool isMatchingAttribute(const std::string& attribute_name, -- 2.7.4