From 026ffd49773cec5bb6bbf1ef22eba0e98c514a4e Mon Sep 17 00:00:00 2001 From: Michal Michalski Date: Mon, 9 Dec 2019 15:36:27 +0100 Subject: [PATCH] [messaging] Make MessageFolder.attributes a picojson::value. Previously attributes were picojson::object. I decided to switch to picojson::value to make the removal of MessageFolder class more straightforward. [Verification] tct-messaging-*-tizen-tests 100% pass. Signed-off-by: Michal Michalski Change-Id: Icb5bcb51469819420bb2e7b5071e0ada04594a14 --- src/messaging/DBus/MessageProxy.cpp | 2 +- src/messaging/email_manager.cc | 2 +- src/messaging/message_folder.cc | 8 ++++---- src/messaging/message_folder.h | 2 +- src/messaging/messaging_instance.cc | 2 +- src/messaging/messaging_native.cc | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/messaging/DBus/MessageProxy.cpp b/src/messaging/DBus/MessageProxy.cpp index 25fe9e6..9297c13 100644 --- a/src/messaging/DBus/MessageProxy.cpp +++ b/src/messaging/DBus/MessageProxy.cpp @@ -253,7 +253,7 @@ PlatformResult MessageProxy::handleMailboxEvent(int account_id, int mailbox_id, eventFolder->service_id = account_id; auto folder = std::make_shared(); - folder->attributes = createMessageFolder(std::to_string(mailbox_id)).get(); + folder->attributes = createMessageFolder(std::to_string(mailbox_id)); if (event != NOTI_MAILBOX_DELETE) { auto ret = native::EmailGetMailboxById(mailbox_id, *folder); diff --git a/src/messaging/email_manager.cc b/src/messaging/email_manager.cc index dd5dedf..efa2b57 100644 --- a/src/messaging/email_manager.cc +++ b/src/messaging/email_manager.cc @@ -730,7 +730,7 @@ void EmailManager::syncFolder(SyncFolderCallbackData* callback) { email_mailbox_t* mailbox = NULL; const std::string folder_id_str = - callback->getMessageFolder()->attributes.at("id").get(); + callback->getMessageFolder()->attributes.get("id").get(); int folder_id = 0; std::istringstream(folder_id_str) >> folder_id; diff --git a/src/messaging/message_folder.cc b/src/messaging/message_folder.cc index b2e7cc7..f33e64e 100644 --- a/src/messaging/message_folder.cc +++ b/src/messaging/message_folder.cc @@ -65,13 +65,13 @@ FolderPtrVector filterFolders(tizen::AbstractFilterPtr filter, for (const auto& fp : source_folders) { if (filter->isMatching(picojson::value(fp->attributes))) { LoggerD("folder id: %s, folder name: %s, match: yes", - fp->attributes.at("id").get().c_str(), - fp->attributes.at(MESSAGE_FOLDER_ATTRIBUTE_NAME).get().c_str()); + fp->attributes.get(MESSAGE_FOLDER_ATTRIBUTE_ID).get().c_str(), + fp->attributes.get(MESSAGE_FOLDER_ATTRIBUTE_NAME).get().c_str()); filtered_folders.push_back(fp); } else { LoggerD("folder id: %s, folder name: %s, match: no", - fp->attributes.at("id").get().c_str(), - fp->attributes.at(MESSAGE_FOLDER_ATTRIBUTE_NAME).get().c_str()); + fp->attributes.get(MESSAGE_FOLDER_ATTRIBUTE_ID).get().c_str(), + fp->attributes.get(MESSAGE_FOLDER_ATTRIBUTE_NAME).get().c_str()); } } diff --git a/src/messaging/message_folder.h b/src/messaging/message_folder.h index 5932617..461c87a 100644 --- a/src/messaging/message_folder.h +++ b/src/messaging/message_folder.h @@ -46,7 +46,7 @@ picojson::value createMessageFolder(const std::string& id, const std::string& na const std::string& parent_id = ""); struct MessageFolder { - picojson::object attributes; + picojson::value attributes; }; typedef std::vector> FolderPtrVector; diff --git a/src/messaging/messaging_instance.cc b/src/messaging/messaging_instance.cc index cbc3be2..1a2aa1e 100644 --- a/src/messaging/messaging_instance.cc +++ b/src/messaging/messaging_instance.cc @@ -346,7 +346,7 @@ void MessagingInstance::MessageServiceSyncFolder(const picojson::value& args, SyncFolderCallbackData* callback = new SyncFolderCallbackData(queue_, callbackId, *this); callback->setAccountId(id); auto folder_ptr = std::make_shared(); - folder_ptr->attributes = v_folder.get(); + folder_ptr->attributes = v_folder; callback->setMessageFolder(folder_ptr); callback->setLimit(limit); diff --git a/src/messaging/messaging_native.cc b/src/messaging/messaging_native.cc index 25c455c..5154193 100644 --- a/src/messaging/messaging_native.cc +++ b/src/messaging/messaging_native.cc @@ -88,7 +88,7 @@ PlatformResult EmailGetMailboxList(int account_id, std::vector& f for (int i = 0; i < count; ++i) { MessageFolder folder; - folder.attributes = ConvertMailboxToJson(mailboxes[i]).get(); + folder.attributes = ConvertMailboxToJson(mailboxes[i]); folders.push_back(folder); } @@ -104,7 +104,7 @@ PlatformResult EmailGetMailboxById(int mailbox_id, MessageFolder& folder) { return PlatformResult(ErrorCode::UNKNOWN_ERR, "email_get_mailbox_by_mailbox_id() failed."); } - folder.attributes = ConvertMailboxToJson(*mailbox).get(); + folder.attributes = ConvertMailboxToJson(*mailbox); if (EMAIL_ERROR_NONE != email_free_mailbox(&mailbox, 1)) { LoggerW("Calling email_free_mailbox() failed."); } -- 2.7.4