+ Removed MessageFolder constructor from attributes.
+ MessageFolder(json) constructor is used to create folders.
+ Add createMessageFolder() -> json function.
[Verification] tct-messaging-*-tizen-tests 100% pass.
Signed-off-by: Michal Michalski <m.michalski2@partner.samsung.com>
Change-Id: I17442348d4f91c8ac275787adfe7ca8fb8ae88ff
EventFolders* eventFolder = new EventFolders();
eventFolder->service_type = MessageType::EMAIL;
eventFolder->service_id = account_id;
- auto folder =
- std::make_shared<MessageFolder>(std::to_string(mailbox_id), "", "", "", "", "", "", false);
+
+ auto jsonFolder = createMessageFolder(std::to_string(mailbox_id));
+ auto folder = std::make_shared<MessageFolder>(jsonFolder);
+
if (event != NOTI_MAILBOX_DELETE) {
auto ret = native::EmailGetMailboxById(mailbox_id, *folder);
if (ret.IsError()) {
* limitations under the License.
*/
-//#include <JSWebAPIErrorFactory.h>
-//#include <JSWebAPIError.h>
-//#include <JSUtil.h>
#include <chrono>
#include <list>
#include <memory>
#include "common/logger.h"
#include "common/platform_exception.h"
#include "common/scope_exit.h"
-//#include <GlobalContextManager.h>
#include "MsgCommon/AbstractFilter.h"
#include <email-api-mailbox.h>
#include <email-api-network.h>
+#include "conversation_callback_data.h"
#include "email_manager.h"
+#include "find_msg_callback_user_data.h"
#include "message.h"
#include "message_conversation.h"
-#include "message_service.h"
-#include "messaging_util.h"
-//#include "MessageCallbackUserData.h"
-//#include "MessagesCallbackUserData.h"
-#include "conversation_callback_data.h"
-#include "find_msg_callback_user_data.h"
#include "message_email.h"
+#include "message_service.h"
#include "messaging_database_manager.h"
-
-//#include "JSMessage.h"
-//#include "JSMessageConversation.h"
-//#include "JSMessageFolder.h"
+#include "messaging_util.h"
#include <email-api.h>
#include <vconf.h>
-//#include "DBus/SyncProxy.h"
#include "DBus/LoadBodyProxy.h"
-//#include "DBus/LoadAttachmentProxy.h"
#include <sstream>
}
m_proxy_load_body->signalSubscribe();
- // ret = DBus::LoadAttachmentProxy::create(DBus::Proxy::DBUS_PATH_NETWORK_STATUS,
- // DBus::Proxy::DBUS_IFACE_NETWORK_STATUS,
- // &m_proxy_load_attachment);
- // CHECK_ERROR(ret, "create load attachment proxy failed");
- // if (!m_proxy_load_attachment) {
- // LoggerE("Load attachment proxy is null");
- // return PlatformResult(ErrorCode::UNKNOWN_ERR, "Load attachment proxy is null");
- // }
- // m_proxy_load_attachment->signalSubscribe();
-
ret = DBus::MessageProxy::create(*this, &m_proxy_messageStorage);
CHECK_ERROR(ret, "create message proxy failed");
if (!m_proxy_messageStorage) {
"INBOX", "OUTBOX", "DRAFTS", "SENTBOX",
};
-namespace {
-
const char* MESSAGE_FOLDER_ATTRIBUTE_ID = "id";
const char* MESSAGE_FOLDER_ATTRIBUTE_PARENT_ID = "parentId";
const char* MESSAGE_FOLDER_ATTRIBUTE_SERVICE_ID = "serviceId";
const char* MESSAGE_FOLDER_ATTRIBUTE_TYPE = "type";
const char* MESSAGE_FOLDER_ATTRIBUTE_SYNCHRONIZABLE = "synchronizable";
-} // namespace
-
-MessageFolder::MessageFolder(const std::string& id, const std::string& parent_id,
- const std::string& service_id, const std::string& content_type,
- const std::string& name, const std::string& path,
- const std::string& type, bool synchronizable) {
- ScopeLogger();
- attributes[MESSAGE_FOLDER_ATTRIBUTE_ID] = picojson::value(id);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_PARENT_ID] = picojson::value(parent_id);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_SERVICE_ID] = picojson::value(service_id);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_CONTENT_TYPE] = picojson::value(content_type);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_NAME] = picojson::value(name);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_PATH] = picojson::value(path);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_TYPE] = picojson::value(type);
- attributes[MESSAGE_FOLDER_ATTRIBUTE_SYNCHRONIZABLE] = picojson::value(synchronizable);
+picojson::value createMessageFolder(const std::string& id, const std::string& name,
+ const std::string& service_id, const std::string& content_type,
+ const std::string& type, bool synchronizable,
+ const std::string& path, const std::string& parent_id) {
+ auto json = picojson::value(picojson::object());
+ auto& folder = json.get<picojson::object>();
+ folder[MESSAGE_FOLDER_ATTRIBUTE_ID] = picojson::value(id);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_PARENT_ID] = picojson::value(parent_id);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_SERVICE_ID] = picojson::value(service_id);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_CONTENT_TYPE] = picojson::value(content_type);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_NAME] = picojson::value(name);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_PATH] = picojson::value(path);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_TYPE] = picojson::value(type);
+ folder[MESSAGE_FOLDER_ATTRIBUTE_SYNCHRONIZABLE] = picojson::value(synchronizable);
+ return json;
}
MessageFolder::MessageFolder(const picojson::value& json) {
};
extern const char* MessageFolderTypeStr[MESSAGE_FOLDER_TYPE_NOTSTANDARD];
+picojson::value createMessageFolder(const std::string& id, const std::string& name = "",
+ const std::string& service_id = "",
+ const std::string& content_type = "",
+ const std::string& type = "", bool synchronizable = false,
+ const std::string& path = "",
+ const std::string& parent_id = "");
+
struct MessageFolder {
- MessageFolder(const std::string& id, const std::string& parent_id, const std::string& service_id,
- const std::string& content_type, const std::string& name, const std::string& path,
- const std::string& type, bool synchronizable);
MessageFolder(const picojson::value& json);
picojson::object attributes;
};
ScopeLogger();
std::unique_ptr<FindFoldersTaskParams> params(static_cast<FindFoldersTaskParams*>(data));
- std::string content_type = params->message_type;
- picojson::object response;
-
picojson::array array;
for (std::string type : MessageFolderTypeStr) {
auto id = std::to_string(array.size() + 1);
auto service_id = std::to_string(params->account_id);
- MessageFolder folder(id, "", service_id, content_type, type, "", type, false);
- if (params->filter->isMatching(picojson::value(folder.attributes))) {
- array.push_back(picojson::value(folder.attributes));
+ auto json = createMessageFolder(id, type, service_id, params->message_type, type);
+ if (params->filter->isMatching(json)) {
+ array.push_back(json);
}
}
- response[JSON_CALLBACK_ID] = picojson::value(static_cast<double>(params->callback_id));
- ReportSuccess(picojson::value(array), response);
- Instance::PostMessage(params->instance, picojson::value(response));
+ auto response = picojson::value(picojson::object());
+ auto& responseObj = response.get<picojson::object>();
+
+ responseObj[JSON_CALLBACK_ID] = picojson::value(static_cast<double>(params->callback_id));
+ ReportSuccess(picojson::value(array), responseObj);
+
+ Instance::PostMessage(params->instance, response);
return FALSE;
}
#include <string>
#include <vector>
-using extension::messaging::MessageFolder;
-using extension::messaging::MessagingUtil;
-using extension::messaging::MESSAGE_FOLDER_TYPE_INBOX;
-using extension::messaging::MESSAGE_FOLDER_TYPE_SENTBOX;
-using extension::messaging::MESSAGE_FOLDER_TYPE_DRAFTS;
-using extension::messaging::MESSAGE_FOLDER_TYPE_OUTBOX;
-using extension::messaging::EMAIL;
-using extension::messaging::MessageFolderTypeStr;
+namespace extension {
+namespace messaging {
+
using common::PlatformResult;
using common::ErrorCode;
}
}
-MessageFolder createMessageFolderFromMailbox(email_mailbox_t mailbox) {
+picojson::value ConvertMailboxToJson(email_mailbox_t mailbox) {
ScopeLogger();
- return 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);
+ return createMessageFolder(
+ std::to_string(mailbox.mailbox_id), mailbox.alias, std::to_string(mailbox.account_id),
+ MessagingUtil::messageTypeToString(EMAIL), convertPlatformFolderType(mailbox.mailbox_type),
+ mailbox.local == 0, mailbox.mailbox_name);
}
} // namespace
}
PlatformResult EmailGetMailboxList(int account_id, std::vector<MessageFolder>& folders) {
+ ScopeLogger();
email_mailbox_t* mailboxes = nullptr;
int count = 0;
}
for (int i = 0; i < count; ++i) {
- folders.push_back(createMessageFolderFromMailbox(mailboxes[i]));
+ auto json = ConvertMailboxToJson(mailboxes[i]);
+ folders.push_back(MessageFolder(json));
}
return PlatformResult();
return PlatformResult(ErrorCode::UNKNOWN_ERR, "email_get_mailbox_by_mailbox_id() failed.");
}
- folder = createMessageFolderFromMailbox(*mailbox);
+ folder = MessageFolder(ConvertMailboxToJson(*mailbox));
if (EMAIL_ERROR_NONE != email_free_mailbox(&mailbox, 1)) {
LoggerW("Calling email_free_mailbox() failed.");
}
}
} // namespace native
+} // namespace messaging
+} // namespace extension
#include "common/platform_result.h"
#include "message_folder.h"
-using extension::messaging::MessageFolder;
-
+namespace extension {
+namespace messaging {
namespace native {
common::PlatformResult EmailGetMailboxList(int account_id, std::vector<MessageFolder>& folders);
common::PlatformResult EmailGetMailboxById(int mailbox_id, MessageFolder& folder);
} // namespace native
+} // namespace messaging
+} // namespace extension
#endif // MESSAGING_NATIVE_H_