[Messaging] addDraftMessage - working for email
authorRobert Karolak <r.karolak@samsung.com>
Tue, 16 Dec 2014 15:34:58 +0000 (16:34 +0100)
committerRobert Karolak <r.karolak@samsung.com>
Wed, 17 Dec 2014 09:09:51 +0000 (10:09 +0100)
[Verification] Code compiles and working well

[Feature] It is possible to add draft email message from
nodejs console

Change-Id: Ib9818785e3fdc47493805b80615bcf3e8e8c28c5
Signed-off-by: Robert Karolak <r.karolak@samsung.com>
17 files changed:
src/common/callback_user_data.h
src/messaging/email_manager.cc
src/messaging/email_manager.h
src/messaging/message.cc
src/messaging/message_callback_user_data.cc [new file with mode: 0644]
src/messaging/message_callback_user_data.h [new file with mode: 0644]
src/messaging/message_email.cc
src/messaging/message_service_email.cc
src/messaging/message_storage.h
src/messaging/message_storage_email.cc
src/messaging/message_storage_email.h
src/messaging/messaging.gyp
src/messaging/messaging_api.js
src/messaging/messaging_instance.cc
src/messaging/messaging_manager.cc
src/messaging/messaging_util.cc
src/messaging/messaging_util.h

index b29abaa106041a3c580446b067235ea7df5f4d6f..d921f6174f4d4e116649ca83676ff15524c0880d 100644 (file)
@@ -53,11 +53,13 @@ public:
     void setJson(std::shared_ptr<picojson::value> json);
     std::shared_ptr<picojson::value> getJson() const;
 
+protected:
+    std::shared_ptr<picojson::value> m_json;
+
 private:
 //    JSContextRef m_context;
 //    MultiCallbackUserData* m_impl;
     bool m_is_act;
-    std::shared_ptr<picojson::value> m_json;
 };
 
 } // Common
index c23912fa4064f474d72233c61b29ca3378218394..9f2ca1c378eb207a064fed6d8529159bc3a2ac4a 100644 (file)
@@ -114,7 +114,7 @@ EmailManager::EmailManager()
 //                                        DBus::Proxy::DBUS_PATH_NETWORK_STATUS,
 //                                        DBus::Proxy::DBUS_IFACE_NETWORK_STATUS);
 //    if (!m_proxy_load_body) {
-//        LOGE("Load body proxy is null");
+//        LoggerE("Load body proxy is null");
 //        throw Common::UnknownException("Load body proxy is null");
 //    }
 //    m_proxy_load_body->signalSubscribe();
@@ -123,21 +123,21 @@ EmailManager::EmailManager()
 //                                        DBus::Proxy::DBUS_PATH_NETWORK_STATUS,
 //                                        DBus::Proxy::DBUS_IFACE_NETWORK_STATUS);
 //    if (!m_proxy_load_attachment) {
-//        LOGE("Load attachment proxy is null");
+//        LoggerE("Load attachment proxy is null");
 //        throw Common::UnknownException("Load attachment proxy is null");
 //    }
 //    m_proxy_load_attachment->signalSubscribe();
 //
 //    m_proxy_messageStorage = std::make_shared<DBus::MessageProxy>();
 //    if (!m_proxy_messageStorage) {
-//        LOGE("Message proxy is null");
+//        LoggerE("Message proxy is null");
 //        throw Common::UnknownException("Message proxy is null");
 //    }
 //    m_proxy_messageStorage->signalSubscribe();
 //
 //    m_proxy_send = std::make_shared<DBus::SendProxy>();
 //    if (!m_proxy_send) {
-//        LOGE("Send proxy is null");
+//        LoggerE("Send proxy is null");
 //        throw Common::UnknownException("Send proxy is null");
 //    }
 //    m_proxy_send->signalSubscribe();
@@ -148,11 +148,12 @@ EmailManager::~EmailManager()
     LoggerD("Entered");
 }
 
-//void EmailManager::addDraftMessagePlatform(int account_id,
-//    std::shared_ptr<Message> message)
-//{
-//    addMessagePlatform(account_id, message, EMAIL_MAILBOX_TYPE_DRAFT);
-//}
+void EmailManager::addDraftMessagePlatform(int account_id,
+    std::shared_ptr<Message> message)
+{
+    LoggerD("Entered");
+    addMessagePlatform(account_id, message, EMAIL_MAILBOX_TYPE_DRAFT);
+}
 //
 //void EmailManager::addOutboxMessagePlatform(int account_id,
 //    std::shared_ptr<Message> message)
@@ -160,203 +161,193 @@ EmailManager::~EmailManager()
 //    addMessagePlatform(account_id, message, EMAIL_MAILBOX_TYPE_OUTBOX);
 //}
 //
-//void EmailManager::addMessagePlatform(int account_id,
-//    std::shared_ptr<Message> message, email_mailbox_type_e mailbox_type)
-//{
-//    email_mail_data_t* mail_data = NULL;
-//    email_mail_data_t* mail_data_final = NULL;
-//    int err = EMAIL_ERROR_NONE;
-//
-//    mail_data = Message::convertPlatformEmail(message);
-//
-//    mail_data->account_id = account_id;
-//
-//    //Adding "from" email address
-//    email_account_t* account = NULL;
-//    err = email_get_account(account_id, EMAIL_ACC_GET_OPT_FULL_DATA, &account);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("email_get_account failed. [%d]\n",err);
-//        err = email_free_mail_data(&mail_data,1);
-//        if(EMAIL_ERROR_NONE != err) {
-//            LOGE("Failed to free mail data memory");
-//        }
-//        throw UnknownException("Cannot retrieve email account information");
-//    }
-//    LOGE("FROM %s", account->user_email_address);
-//    std::stringstream ss;
-//    ss << "<" << account->user_email_address << ">";
-//    std::string address_from;
-//    ss >> address_from;
-//    mail_data->full_address_from = strdup(address_from.c_str());
-//    LOGE("FROM %s", mail_data->full_address_from);
-//    err = email_free_account(&account,1);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("Failed to free account data memory");
-//    }
-//    //Setting mailbox id
-//    email_mailbox_t *mailbox_data = NULL;
-//    err = email_get_mailbox_by_mailbox_type(account_id, mailbox_type,
-//            &mailbox_data);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGD("email_get_mailbox_by_mailbox_type failed. [%d]\n",err);
-//        err = email_free_mail_data(&mail_data,1);
-//        if(EMAIL_ERROR_NONE != err) {
-//            LOGE("Failed to free mail data memory");
-//        }
-//        throw UnknownException("Cannot retrieve draft mailbox");
-//    }
-//    else {
-//        LOGD("email_get_mailbox_by_mailbox_type success.\n");
-//        mail_data->mailbox_id = mailbox_data->mailbox_id;
-//        mail_data->mailbox_type = mailbox_data->mailbox_type;
-//    }
-//
-//    mail_data->report_status = EMAIL_MAIL_REPORT_NONE;
-//    mail_data->save_status = EMAIL_MAIL_STATUS_SAVED;
-//    mail_data->flags_draft_field = 1;
-//
-//    //adding email without attachments
-//    err = email_add_mail(mail_data, NULL, 0, NULL, 0);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGD("email_add_mail failed. [%d]\n",err);
-//        err = email_free_mail_data(&mail_data,1);
-//        if(EMAIL_ERROR_NONE != err) {
-//            LOGE("Failed to free mail data memory");
-//        }
-//        err = email_free_mailbox(&mailbox_data, 1);
-//        if (EMAIL_ERROR_NONE != err) {
-//            LOGE("Failed to destroy mailbox");
-//        }
-//        throw UnknownException("Couldn't add message to draft mailbox");
-//    }
-//    else {
-//        LOGD("email_add_mail success.\n");
-//    }
-//
-//    LOGD("saved mail without attachments id = [%d]\n", mail_data->mail_id);
-//
-//    message->setId(mail_data->mail_id);
-//    message->setMessageStatus(MessageStatus::STATUS_DRAFT);
-//
-//    //Adding attachments
+void EmailManager::addMessagePlatform(int account_id,
+    std::shared_ptr<Message> message, email_mailbox_type_e mailbox_type)
+{
+    LoggerD("Entered");
+    email_mail_data_t* mail_data = NULL;
+    email_mail_data_t* mail_data_final = NULL;
+    int err = EMAIL_ERROR_NONE;
+
+    mail_data = Message::convertPlatformEmail(message);
+
+    mail_data->account_id = account_id;
+
+    //Adding "from" email address
+    email_account_t* account = NULL;
+    err = email_get_account(account_id, EMAIL_ACC_GET_OPT_FULL_DATA, &account);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerE("email_get_account failed. [%d]\n",err);
+        err = email_free_mail_data(&mail_data,1);
+        if(EMAIL_ERROR_NONE != err) {
+            LoggerE("Failed to free mail data memory");
+        }
+        throw common::UnknownException("Cannot retrieve email account information");
+    }
+    LoggerE("FROM %s", account->user_email_address);
+    std::stringstream ss;
+    ss << "<" << account->user_email_address << ">";
+    std::string address_from;
+    ss >> address_from;
+    mail_data->full_address_from = strdup(address_from.c_str());
+    LoggerE("FROM %s", mail_data->full_address_from);
+    err = email_free_account(&account,1);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerE("Failed to free account data memory");
+    }
+    //Setting mailbox id
+    email_mailbox_t *mailbox_data = NULL;
+    err = email_get_mailbox_by_mailbox_type(account_id, mailbox_type,
+            &mailbox_data);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerD("email_get_mailbox_by_mailbox_type failed. [%d]\n",err);
+        err = email_free_mail_data(&mail_data,1);
+        if(EMAIL_ERROR_NONE != err) {
+            LoggerE("Failed to free mail data memory");
+        }
+        throw common::UnknownException("Cannot retrieve draft mailbox");
+    }
+    else {
+        LoggerD("email_get_mailbox_by_mailbox_type success.\n");
+        mail_data->mailbox_id = mailbox_data->mailbox_id;
+        mail_data->mailbox_type = mailbox_data->mailbox_type;
+    }
+
+    mail_data->report_status = EMAIL_MAIL_REPORT_NONE;
+    mail_data->save_status = EMAIL_MAIL_STATUS_SAVED;
+    mail_data->flags_draft_field = 1;
+
+    //adding email without attachments
+    err = email_add_mail(mail_data, NULL, 0, NULL, 0);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerD("email_add_mail failed. [%d]\n",err);
+        err = email_free_mail_data(&mail_data,1);
+        if(EMAIL_ERROR_NONE != err) {
+            LoggerE("Failed to free mail data memory");
+        }
+        err = email_free_mailbox(&mailbox_data, 1);
+        if (EMAIL_ERROR_NONE != err) {
+            LoggerE("Failed to destroy mailbox");
+        }
+        throw common::UnknownException("Couldn't add message to draft mailbox");
+    }
+    else {
+        LoggerD("email_add_mail success.\n");
+    }
+
+    LoggerD("saved mail without attachments id = [%d]\n", mail_data->mail_id);
+
+    message->setId(mail_data->mail_id);
+    message->setMessageStatus(MessageStatus::STATUS_DRAFT);
+
+//    TODO Adding attachments
 //    if (message->getHasAttachment()){
 //        Message::addEmailAttachments(message);
 //    }
-//
-//    err = email_get_mail_data(message->getId(), &mail_data_final);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("Failed to retrieve added mail data");
-//        throw UnknownException("Couldn't retrieve added mail data");
-//    }
-//
-//    message->updateEmailMessage(*mail_data_final);
-//
-//    err = email_free_mail_data(&mail_data_final,1);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("Failed to free mail data final memory");
-//    }
-//
-//    err = email_free_mail_data(&mail_data,1);
-//    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("Failed to free mail data memory");
-//    }
-//
-//    err = email_free_mailbox(&mailbox_data, 1);
-//    if (EMAIL_ERROR_NONE != err) {
-//        LOGE("Failed to destroy mailbox");
-//    }
-//}
-//
-//static gboolean addDraftMessageCompleteCB(void *data)
-//{
-//    MessageCallbackUserData* callback =
-//        static_cast<MessageCallbackUserData *>(data);
-//    if (!callback) {
-//        LOGE("Callback is null");
-//        return false;
-//    }
-//    JSContextRef context = callback->getContext();
-//    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
-//        delete callback;
-//        callback = NULL;
-//        return false;
-//    }
-//
-//    try {
-//        if (callback->isError()) {
-//            LOGD("Calling error callback");
-//            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
-//                    callback->getErrorName(),
-//                    callback->getErrorMessage());
-//            callback->callErrorCallback(errobj);
-//            callback->getMessage()->setMessageStatus(MessageStatus::STATUS_FAILED);
-//        } else {
-//            LOGD("Calling success callback");
-//            callback->callSuccessCallback();
-//        }
-//    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
-//        JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context, err);
-//        callback->callErrorCallback(errobj);
-//    } catch (...) {
-//        LOGE("Message add draft failed");
-//        JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
-//                JSWebAPIErrorFactory::UNKNOWN_ERROR, "Message add draft failed");
-//        callback->callErrorCallback(errobj);
-//    }
-//
-//    delete callback;
-//    callback = NULL;
-//
-//    return false;
-//}
-//
-//void EmailManager::addDraftMessage(MessageCallbackUserData* callback)
-//{
-//    LOGD("Entered");
-//
-//    if(!callback){
-//        LOGE("Callback is null");
-//        return;
-//    }
-//
-//    try {
-//        std::lock_guard<std::mutex> lock(m_mutex);
-//        std::shared_ptr<Message> message = callback->getMessage();
-//        addDraftMessagePlatform(callback->getAccountId(), message);
-//    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
-//        callback->setError(err.getName(), err.getMessage());
-//    } catch (...) {
-//        LOGE("Message add draft failed");
-//        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Message add draft failed");
-//    }
-//
-//    //Complete task
-//    if (!g_idle_add(addDraftMessageCompleteCB, static_cast<void *>(callback))) {
-//        LOGE("g_idle addition failed");
-//        delete callback;
-//        callback = NULL;
-//    }
-//}
-//
-//
+
+    err = email_get_mail_data(message->getId(), &mail_data_final);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerE("Failed to retrieve added mail data");
+        throw common::UnknownException("Couldn't retrieve added mail data");
+    }
+
+    message->updateEmailMessage(*mail_data_final);
+
+    err = email_free_mail_data(&mail_data_final,1);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerE("Failed to free mail data final memory");
+    }
+
+    err = email_free_mail_data(&mail_data,1);
+    if(EMAIL_ERROR_NONE != err) {
+        LoggerE("Failed to free mail data memory");
+    }
+
+    err = email_free_mailbox(&mailbox_data, 1);
+    if (EMAIL_ERROR_NONE != err) {
+        LoggerE("Failed to destroy mailbox");
+    }
+}
+
+static gboolean addDraftMessageCompleteCB(void *data)
+{
+    MessageCallbackUserData* callback =
+        static_cast<MessageCallbackUserData *>(data);
+    if (!callback) {
+        LoggerE("Callback is null");
+        return false;
+    }
+
+    try {
+        if (callback->isError()) {
+            LoggerD("Calling error callback");
+            MessagingInstance::getInstance().PostMessage(callback->getJson()->serialize().c_str());
+            callback->getMessage()->setMessageStatus(MessageStatus::STATUS_FAILED);
+        } else {
+            LoggerD("Calling success callback");
+            auto json = callback->getJson();
+            picojson::object& obj = json->get<picojson::object>();
+            obj[JSON_ACTION] = picojson::value(JSON_CALLBACK_SUCCCESS);
+            MessagingInstance::getInstance().PostMessage(json->serialize().c_str());
+        }
+    } catch (const common::PlatformException& err) {
+        LoggerE("%s (%s)", (err.name()).c_str(), (err.message()).c_str());
+        callback->getMessage()->setMessageStatus(MessageStatus::STATUS_FAILED);
+    } catch (...) {
+        LoggerE("Message add draft failed");
+        callback->getMessage()->setMessageStatus(MessageStatus::STATUS_FAILED);
+    }
+
+    delete callback;
+    callback = NULL;
+
+    return false;
+}
+
+void EmailManager::addDraftMessage(MessageCallbackUserData* callback)
+{
+    LoggerD("Entered");
+
+    if(!callback){
+        LoggerE("Callback is null");
+        return;
+    }
+
+    try {
+        std::lock_guard<std::mutex> lock(m_mutex);
+        std::shared_ptr<Message> message = callback->getMessage();
+        addDraftMessagePlatform(callback->getAccountId(), message);
+    } catch (const common::PlatformException& err) {
+        LoggerE("%s (%s)", (err.name()).c_str(), (err.message()).c_str());
+        callback->setError(err.name(), err.message());
+    } catch (...) {
+        LoggerE("Message add draft failed");
+        callback->setError("UnknownError", "Message add draft failed");
+    }
+
+    //Complete task
+    if (!g_idle_add(addDraftMessageCompleteCB, static_cast<void *>(callback))) {
+        LoggerE("g_idle addition failed");
+        delete callback;
+        callback = NULL;
+    }
+}
+
 ////**** sending email ****
 //static gboolean sendEmailCompleteCB(void* data)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //
 //    MessageRecipientsCallbackData* callback =
 //            static_cast<MessageRecipientsCallbackData*>(data);
 //    if (!callback) {
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return false;
 //    }
 //
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return false;
@@ -378,10 +369,10 @@ EmailManager::~EmailManager()
 //        }
 //    }
 //    catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //    }
 //    catch (...) {
-//        LOGE("Unknown error when calling send message callback");
+//        LoggerE("Unknown error when calling send message callback");
 //    }
 //
 //    delete callback;
@@ -392,19 +383,19 @@ EmailManager::~EmailManager()
 //
 //void EmailManager::sendMessage(MessageRecipientsCallbackData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    int err = EMAIL_ERROR_NONE;
 //    email_mail_data_t *mail_data = NULL;
 //
 //    try{
 //        if(!callback){
-//            LOGE("Callback is null");
+//            LoggerE("Callback is null");
 //            throw UnknownException("Callback is null");
 //        }
 //
 //        std::shared_ptr<Message> message = callback->getMessage();
 //        if(!message) {
-//            LOGE("Message is null");
+//            LoggerE("Message is null");
 //            throw UnknownException("Message is null");
 //        }
 //
@@ -414,11 +405,11 @@ EmailManager::~EmailManager()
 //
 //        err = email_get_mail_data(message->getId(),&mail_data);
 //        if(EMAIL_ERROR_NONE != err) {
-//            LOGE("email_get_mail_data failed. [%d]\n",err);
+//            LoggerE("email_get_mail_data failed. [%d]\n",err);
 //            throw UnknownException("Failed to get platform email structure");
 //        }
 //
-//        LOGD("email_get_mail_data success.\n");
+//        LoggerD("email_get_mail_data success.\n");
 //
 //        //Sending EMAIL
 //        mail_data->save_status = EMAIL_MAIL_STATUS_SENDING;
@@ -426,26 +417,26 @@ EmailManager::~EmailManager()
 //        int req_id = 0;
 //        err = email_send_mail(mail_data->mail_id, &req_id);
 //        if (EMAIL_ERROR_NONE != err) {
-//            LOGE("Failed to send message %d", err);
+//            LoggerE("Failed to send message %d", err);
 //            throw UnknownException("Failed to send message");
 //        }
-//        LOGD("req_id: %d", req_id);
+//        LoggerD("req_id: %d", req_id);
 //        callback->getMessage()->setMessageStatus(MessageStatus::STATUS_SENDING);
 //        m_sendRequests[req_id] = callback;
 //
 //    } catch (const BasePlatformException& ex) {
-//         LOGE("%s (%s)", (ex.getName()).c_str(), (ex.getMessage()).c_str());
+//         LoggerE("%s (%s)", (ex.getName()).c_str(), (ex.getMessage()).c_str());
 //         callback->setError(ex.getName(), ex.getMessage());
 //         if (!g_idle_add(sendEmailCompleteCB, static_cast<void*>(callback))) {
-//             LOGE("g_idle addition failed");
+//             LoggerE("g_idle addition failed");
 //             delete callback;
 //             callback = NULL;
 //         }
 //    }catch (...) {
-//        LOGE("Message send failed");
+//        LoggerE("Message send failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Message send failed");
 //        if (!g_idle_add(sendEmailCompleteCB, static_cast<void*>(callback))) {
-//            LOGE("g_idle addition failed");
+//            LoggerE("g_idle addition failed");
 //            delete callback;
 //            callback = NULL;
 //        }
@@ -453,7 +444,7 @@ EmailManager::~EmailManager()
 //
 //    err = email_free_mail_data(&mail_data,1);
 //    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("Failed to free mail data memory");
+//        LoggerE("Failed to free mail data memory");
 //    }
 //
 //    return;
@@ -463,18 +454,18 @@ EmailManager::~EmailManager()
 //        email_noti_on_network_event status,
 //        int error_code)
 //{
-//    LOGD("Enter");
+//    LoggerD("Enter");
 //
 //    std::lock_guard<std::mutex> lock(m_mutex);
 //    //find first request for this mail_id
 //    SendReqMapIterator it = getSendRequest(mail_id);
 //    if (it != m_sendRequests.end()) {
-//        LOGD("Found request");
+//        LoggerD("Found request");
 //        MessageRecipientsCallbackData* callback = it->second;
 //        m_sendRequests.erase(it);
 //
 //        if (NOTI_SEND_FAIL == status) {
-//            LOGD("Failed to send message, set proper error");
+//            LoggerD("Failed to send message, set proper error");
 //            switch (error_code) {
 //                case EMAIL_ERROR_NO_SIM_INSERTED:
 //                case EMAIL_ERROR_SOCKET_FAILURE:
@@ -484,26 +475,26 @@ EmailManager::~EmailManager()
 //                case EMAIL_ERROR_NETWORK_NOT_AVAILABLE:
 //                case EMAIL_ERROR_INVALID_STREAM:
 //                case EMAIL_ERROR_NO_RESPONSE:
-//                    LOGE("Network error %d", error_code);
+//                    LoggerE("Network error %d", error_code);
 //                    callback->setError(JSWebAPIErrorFactory::NETWORK_ERROR,
 //                            "Failed to send message");
 //                    break;
 //                default:
-//                    LOGE("Unknown error %d", error_code);
+//                    LoggerE("Unknown error %d", error_code);
 //                    callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR,
 //                            "Failed to send message");
 //            }
 //        } else if (NOTI_SEND_FINISH == status) {
-//            LOGD("Message sent successfully");
+//            LoggerD("Message sent successfully");
 //        }
 //
 //        if (!g_idle_add(sendEmailCompleteCB, static_cast<void*>(callback))) {
-//            LOGE("g_idle addition failed");
+//            LoggerE("g_idle addition failed");
 //            delete callback;
 //            callback = NULL;
 //        }
 //    } else {
-//        LOGW("No matching request found");
+//        LoggerW("No matching request found");
 //    }
 //}
 //
@@ -513,9 +504,9 @@ EmailManager::~EmailManager()
 //    int err = EMAIL_ERROR_NONE;
 //    err = email_get_mail_data(msg_id, &mail_data);
 //    if (EMAIL_ERROR_NONE != err) {
-//        LOGE("email_get_mail_data failed. [%d]", err);
+//        LoggerE("email_get_mail_data failed. [%d]", err);
 //    } else {
-//        LOGD("email_get_mail_data success.");
+//        LoggerD("email_get_mail_data success.");
 //    }
 //    return mail_data;
 //}
@@ -538,20 +529,20 @@ EmailManager::~EmailManager()
 //
 //    int err = email_free_mail_data(&mail_data,1);
 //    if(EMAIL_ERROR_NONE != err) {
-//        LOGE("Could not free mail data!");
+//        LoggerE("Could not free mail data!");
 //    }
 //}
 //
 //void EmailManager::loadMessageBody(MessageBodyCallbackData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    if(!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
 //    if(!callback->getMessage()) {
-//        LOGE("Callback's message is null");
+//        LoggerE("Callback's message is null");
 //        return;
 //    }
 //
@@ -563,7 +554,7 @@ EmailManager::~EmailManager()
 //    int op_handle = -1;
 //    err = email_download_body(mailId, 0, &op_handle);
 //    if(EMAIL_ERROR_NONE != err){
-//        LOGE("Email download body failed, %d", err);
+//        LoggerE("Email download body failed, %d", err);
 //        m_proxy_load_body->removeCallback(callback);
 //        return;
 //    }
@@ -572,18 +563,18 @@ EmailManager::~EmailManager()
 //
 //void EmailManager::loadMessageAttachment(MessageAttachmentCallbackData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    if(!callback) {
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        throw Common::InvalidValuesException("Callback is null");
 //    }
 //    if(!callback->getMessageAttachment()) {
-//        LOGE("Callback's message attachment is null");
+//        LoggerE("Callback's message attachment is null");
 //        throw Common::InvalidValuesException("Callback's message attachment is null");
 //    }
 //
 //    std::shared_ptr<MessageAttachment> msgAttachment = callback->getMessageAttachment();
-//    LOGD("attachmentId:%d mailId:%d", msgAttachment->getId(),
+//    LoggerD("attachmentId:%d mailId:%d", msgAttachment->getId(),
 //            msgAttachment->getMessageId());
 //
 //    struct ScopedEmailMailData {
@@ -597,13 +588,13 @@ EmailManager::~EmailManager()
 //        std::stringstream err_ss;
 //        err_ss << "Couldn't get email_mail_data_t for messageId:"
 //                << msgAttachment->getMessageId();
-//        LOGE("%s",err_ss.str().c_str());
+//        LoggerE("%s",err_ss.str().c_str());
 //        throw Common::UnknownException(err_ss.str().c_str());
 //    }
 //
 //    AttachmentPtrVector attachments = Message::convertEmailToMessageAttachment(
 //            *mail_data_holder.data);
-//    LOGD("Mail:%d contain:%d attachments", msgAttachment->getMessageId(),
+//    LoggerD("Mail:%d contain:%d attachments", msgAttachment->getMessageId(),
 //        attachments.size());
 //
 //    AttachmentPtrVector::iterator it = attachments.begin();
@@ -618,11 +609,11 @@ EmailManager::~EmailManager()
 //    if(attachmentIndex < 0) {
 //        std::stringstream err_ss;
 //        err_ss << "Attachment with id:" << msgAttachment->getId() << "not found";
-//        LOGE("%s",err_ss.str().c_str());
+//        LoggerE("%s",err_ss.str().c_str());
 //        throw Common::UnknownException(err_ss.str().c_str());
 //    }
 //
-//    LOGD("Attachment with id:%d is located at index:%d", msgAttachment->getId(),
+//    LoggerD("Attachment with id:%d is located at index:%d", msgAttachment->getId(),
 //            attachmentIndex);
 //
 //    int op_handle = -1;
@@ -633,10 +624,10 @@ EmailManager::~EmailManager()
 //    if (EMAIL_ERROR_NONE != err) {
 //        std::stringstream err_ss;
 //        err_ss << "Download email attachment failed with error: " << err;
-//        LOGE("%s",err_ss.str().c_str());
+//        LoggerE("%s",err_ss.str().c_str());
 //        throw Common::UnknownException(err_ss.str().c_str());
 //    } else  {
-//        LOGD("email_download_attachment returned handle:%d",op_handle);
+//        LoggerD("email_download_attachment returned handle:%d",op_handle);
 //        callback->setOperationHandle(op_handle);
 //        m_proxy_load_attachment->addCallback(callback);
 //    }
@@ -689,9 +680,9 @@ void EmailManager::sync(void* data)
 //
 //void EmailManager::syncFolder(SyncFolderCallbackData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    if(!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -700,7 +691,7 @@ void EmailManager::sync(void* data)
 //
 //    if(!callback->getMessageFolder())
 //    {
-//        LOGE("Callback's messageFolder is null");
+//        LoggerE("Callback's messageFolder is null");
 //        m_proxy_sync->removeCallback(op_id);
 //        return;
 //    }
@@ -715,7 +706,7 @@ void EmailManager::sync(void* data)
 //
 //    err = email_get_mailbox_by_mailbox_id(folder_id, &mailbox);
 //    if (EMAIL_ERROR_NONE != err || NULL == mailbox) {
-//        LOGE("Couldn't get mailbox, error code: %d", err);
+//        LoggerE("Couldn't get mailbox, error code: %d", err);
 //        m_proxy_sync->removeCallback(op_id);
 //        return;
 //    }
@@ -733,7 +724,7 @@ void EmailManager::sync(void* data)
 //
 //        err = email_set_mail_slot_size(0, 0, slot_size);
 //        if(EMAIL_ERROR_NONE != err){
-//            LOGE("Email set slot size failed, %d", err);
+//            LoggerE("Email set slot size failed, %d", err);
 //            throw UnknownException("Email set slot size failed");
 //        }
 //
@@ -741,21 +732,21 @@ void EmailManager::sync(void* data)
 //        const int account_id = callback->getAccountId();
 //        err = email_sync_header(account_id, mailbox->mailbox_id, &op_handle);
 //        if(EMAIL_ERROR_NONE != err) {
-//            LOGE("Email sync header failed, %d", err);
+//            LoggerE("Email sync header failed, %d", err);
 //            m_proxy_sync->removeCallback(op_id);
 //            throw UnknownException("Email sync header failed");
 //        }
 //        callback->setOperationHandle(op_handle);
 //    }
 //    catch (const BasePlatformException& e) {
-//        LOGE("Exception in syncFolder");
+//        LoggerE("Exception in syncFolder");
 //    }
 //
 //    if (NULL != mailbox)
 //    {
 //        err = email_free_mailbox(&mailbox , 1);
 //        if  (EMAIL_ERROR_NONE !=  err) {
-//            LOGD("Failed to email_free_mailbox - err:%d ", err);
+//            LoggerD("Failed to email_free_mailbox - err:%d ", err);
 //        }
 //        mailbox = NULL;
 //    }
@@ -767,17 +758,17 @@ void EmailManager::sync(void* data)
 //
 //void EmailManager::stopSync(long op_id)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    SyncCallbackData* callback = NULL;
 //    try {
 //        callback = dynamic_cast<SyncCallbackData*>(
 //                m_proxy_sync->getCallback(op_id));
 //    }
 //    catch (const BasePlatformException& e) {
-//        LOGE("Could not get callback");
+//        LoggerE("Could not get callback");
 //    }
 //    if(!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -785,7 +776,7 @@ void EmailManager::sync(void* data)
 //    err = email_cancel_job(callback->getAccountId(), callback->getOperationHandle(),
 //            EMAIL_CANCELED_BY_USER);
 //    if(EMAIL_ERROR_NONE != err){
-//        LOGE("Email cancel job failed, %d", err);
+//        LoggerE("Email cancel job failed, %d", err);
 //    }
 //    JSObjectRef err_obj =
 //            JSWebAPIErrorFactory::makeErrorObject(callback->getContext(),
@@ -799,15 +790,15 @@ void EmailManager::sync(void* data)
 //
 //void removeEmailCompleteCB(MessagesCallbackUserData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    if (!callback) {
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return;
@@ -815,20 +806,20 @@ void EmailManager::sync(void* data)
 //
 //    try {
 //        if (callback->isError()) {
-//            LOGD("Calling error callback");
+//            LoggerD("Calling error callback");
 //            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
 //                    callback->getErrorName(),
 //                    callback->getErrorMessage());
 //            callback->callErrorCallback(errobj);
 //        } else {
-//            LOGD("Calling success callback");
+//            LoggerD("Calling success callback");
 //            callback->callSuccessCallback();
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("Error while calling removeEmail callback: %s (%s)",
+//        LoggerE("Error while calling removeEmail callback: %s (%s)",
 //                (err.getName()).c_str(), (err.getMessage()).c_str());
 //    } catch (...) {
-//        LOGE("Unknown error when calling removeEmail callback.");
+//        LoggerE("Unknown error when calling removeEmail callback.");
 //    }
 //
 //    delete callback;
@@ -854,18 +845,18 @@ void EmailManager::sync(void* data)
 //void EmailManager::removeStatusCallback(const std::vector<int> &ids,
 //            email_noti_on_storage_event status)
 //{
-//    LOGD("Enter");
+//    LoggerD("Enter");
 //    std::lock_guard<std::mutex> lock(m_mutex);
 //    DeleteReqVector::iterator it = getDeleteRequest(ids);
 //    if (it != m_deleteRequests.end()) {
-//        LOGD("Found request");
+//        LoggerD("Found request");
 //        if (NOTI_MAIL_DELETE_FINISH == status) {
-//            LOGD("Successfully removed %d mails", ids.size());
+//            LoggerD("Successfully removed %d mails", ids.size());
 //            it->messagesDeleted += ids.size();
 //        }
 //        MessagesCallbackUserData* callback = it->callback;
 //        if (NOTI_MAIL_DELETE_FAIL == status) {
-//            LOGD("Failed to remove mail");
+//            LoggerD("Failed to remove mail");
 //            callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Messages remove failed");
 //        }
 //        //if one of mails failed, call error callback
@@ -873,24 +864,24 @@ void EmailManager::sync(void* data)
 //        // >= is used in case of duplicated dbus messages
 //        if (NOTI_MAIL_DELETE_FAIL == status ||
 //                static_cast<unsigned int>(it->messagesDeleted) >= it->callback->getMessages().size()) {
-//            LOGD("Calling callback");
+//            LoggerD("Calling callback");
 //            m_deleteRequests.erase(it);
 //            m_mutex.unlock();
 //            removeEmailCompleteCB(callback);
 //        } else {
-//            LOGD("Not all messages are removed, waiting for next callback");
+//            LoggerD("Not all messages are removed, waiting for next callback");
 //        }
 //    } else {
-//        LOGD("Request not found, ignoring");
+//        LoggerD("Request not found, ignoring");
 //    }
 //}
 //
 //void EmailManager::removeMessages(MessagesCallbackUserData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //
 //    if (!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -903,14 +894,14 @@ void EmailManager::sync(void* data)
 //        MessageType type = callback->getMessageServiceType();
 //        for(auto it = messages.begin() ; it != messages.end(); ++it) {
 //            if((*it)->getType() != type) {
-//                LOGE("Invalid message type");
+//                LoggerE("Invalid message type");
 //                throw TypeMismatchException("Error while deleting email");
 //            }
 //        }
 //        for (auto it = messages.begin() ; it != messages.end(); ++it) {
 //            error = email_get_mail_data((*it)->getId(), &mail);
 //            if (EMAIL_ERROR_NONE != error) {
-//                LOGE("Couldn't retrieve mail data");
+//                LoggerE("Couldn't retrieve mail data");
 //                throw UnknownException("Error while deleting mail");
 //            }
 //
@@ -918,7 +909,7 @@ void EmailManager::sync(void* data)
 //            error = email_delete_mail(mail->mailbox_id, &mail->mail_id, 1, 0);
 //            if (EMAIL_ERROR_NONE != error) {
 //                email_free_mail_data(&mail, 1);
-//                LOGE("Error while deleting mail");
+//                LoggerE("Error while deleting mail");
 //                throw UnknownException("Error while deleting mail");
 //            }
 //            email_free_mail_data(&mail, 1);
@@ -929,11 +920,11 @@ void EmailManager::sync(void* data)
 //        request.messagesDeleted = 0;
 //        m_deleteRequests.push_back(request);
 //    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //        callback->setError(err.getName(), err.getMessage());
 //        removeEmailCompleteCB(callback);
 //    } catch (...) {
-//        LOGE("Messages remove failed");
+//        LoggerE("Messages remove failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Messages remove failed");
 //        removeEmailCompleteCB(callback);
 //    }
@@ -941,10 +932,10 @@ void EmailManager::sync(void* data)
 //
 //void EmailManager::updateMessages(MessagesCallbackUserData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //
 //    if (!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -957,7 +948,7 @@ void EmailManager::sync(void* data)
 //        MessageType type = callback->getMessageServiceType();
 //        for (auto it = messages.begin() ; it != messages.end(); ++it) {
 //            if ((*it)->getType() != type) {
-//                LOGE("Invalid message type");
+//                LoggerE("Invalid message type");
 //                throw TypeMismatchException("Error while updating message");
 //            }
 //        }
@@ -967,7 +958,7 @@ void EmailManager::sync(void* data)
 //
 //            if((*it)->getHasAttachment())
 //            {
-//                LOGD("Message has attachments. Workaround need to be used.");
+//                LoggerD("Message has attachments. Workaround need to be used.");
 //                //Update of mail on server using function email_update_mail() is not possible.
 //                //Attachment is updated only locally (can't be later loaded from server),
 //                //so use of workaround is needed:
@@ -976,22 +967,22 @@ void EmailManager::sync(void* data)
 //
 //                //adding message again after changes
 //                addDraftMessagePlatform(mail->account_id, (*it));
-//                LOGD("mail added - new id = [%d]\n", (*it)->getId());
+//                LoggerD("mail added - new id = [%d]\n", (*it)->getId());
 //
 //                //deleting old mail
-//                LOGD("mail deleted = [%d]\n", mail->mail_id);
+//                LoggerD("mail deleted = [%d]\n", mail->mail_id);
 //                error = email_delete_mail(mail->mailbox_id,&mail->mail_id,1,1);
 //                if (EMAIL_ERROR_NONE != error) {
 //                    email_free_mail_data(&mail, 1);
-//                    LOGE("Error while deleting old mail on update: %d", error);
+//                    LoggerE("Error while deleting old mail on update: %d", error);
 //                    throw Common::UnknownException("Error while deleting old mail on update");
 //                }
 //            } else {
-//                LOGD("There are no attachments, updating only email data.");
+//                LoggerD("There are no attachments, updating only email data.");
 //                error = email_update_mail(mail, NULL, 0, NULL, 0);
 //                if (EMAIL_ERROR_NONE != error) {
 //                    email_free_mail_data(&mail, 1);
-//                    LOGE("Error while updating mail");
+//                    LoggerE("Error while updating mail");
 //                    throw UnknownException("Error while updating mail");
 //                }
 //            }
@@ -1000,17 +991,17 @@ void EmailManager::sync(void* data)
 //        }
 //
 //    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //        callback->setError(err.getName(), err.getMessage());
 //    } catch (...) {
-//        LOGE("Messages update failed");
+//        LoggerE("Messages update failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Messages update failed");
 //    }
 //
 //    //Complete task
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return;
@@ -1018,20 +1009,20 @@ void EmailManager::sync(void* data)
 //
 //    try {
 //        if (callback->isError()) {
-//            LOGD("Calling error callback");
+//            LoggerD("Calling error callback");
 //            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
 //                    callback->getErrorName(),
 //                    callback->getErrorMessage());
 //            callback->callErrorCallback(errobj);
 //        } else {
-//            LOGD("Calling success callback");
+//            LoggerD("Calling success callback");
 //            callback->callSuccessCallback();
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("Error while calling updateEmail callback: %s (%s)",
+//        LoggerE("Error while calling updateEmail callback: %s (%s)",
 //                (err.getName()).c_str(), (err.getMessage()).c_str());
 //    } catch (...) {
-//        LOGE("Unknown error when calling updateEmail callback.");
+//        LoggerE("Unknown error when calling updateEmail callback.");
 //    }
 //
 //    delete callback;
@@ -1041,10 +1032,10 @@ void EmailManager::sync(void* data)
 //
 //void EmailManager::findMessages(FindMsgCallbackUserData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //
 //    if(!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -1055,7 +1046,7 @@ void EmailManager::sync(void* data)
 //        std::pair<int, email_mail_data_t*> emails =
 //                MessagingDatabaseManager::getInstance().findEmails(callback);
 //        mailListCount = emails.first;
-//        LOGD("Found %d mails", mailListCount);
+//        LoggerD("Found %d mails", mailListCount);
 //
 //        mailList = emails.second;
 //        email_mail_data_t* nth_email = mailList;
@@ -1067,26 +1058,26 @@ void EmailManager::sync(void* data)
 //            nth_email++;
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //        callback->setError(err.getName(), err.getMessage());
 //    } catch (...) {
-//        LOGE("Message find failed");
+//        LoggerE("Message find failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Message find failed");
 //    }
 //
 //    if (mailListCount > 0 && mailList != NULL) {
 //        if (EMAIL_ERROR_NONE != email_free_mail_data(&mailList, mailListCount)) {
-//            LOGW("Failed to free mailList");
+//            LoggerW("Failed to free mailList");
 //        }
 //    }
 //
 //    //Complete task
-//    LOGD("callback: %p error:%d messages.size()=%d", callback, callback->isError(),
+//    LoggerD("callback: %p error:%d messages.size()=%d", callback, callback->isError(),
 //            callback->getMessages().size());
 //
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return;
@@ -1094,21 +1085,21 @@ void EmailManager::sync(void* data)
 //
 //    try {
 //        if (callback->isError()) {
-//            LOGD("Calling error callback");
+//            LoggerD("Calling error callback");
 //            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
 //                    callback->getErrorName(),
 //                    callback->getErrorMessage());
 //            callback->callErrorCallback(errobj);
 //        } else {
-//            LOGD("Calling success callback");
+//            LoggerD("Calling success callback");
 //            callback->callSuccessCallback(JSMessage::messageVectorToJSObjectArray(context,
 //                    callback->getMessages()));
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("Error while calling findMessages callback: %s (%s)",
+//        LoggerE("Error while calling findMessages callback: %s (%s)",
 //                (err.getName()).c_str(), (err.getMessage()).c_str());
 //    } catch (...) {
-//        LOGE("Failed to call findMessages callback.");
+//        LoggerE("Failed to call findMessages callback.");
 //    }
 //
 //    delete callback;
@@ -1117,10 +1108,10 @@ void EmailManager::sync(void* data)
 //
 //void EmailManager::findConversations(ConversationCallbackData* callback)
 //{
-//    LOGE("Entered");
+//    LoggerE("Entered");
 //
 //    if(!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -1130,7 +1121,7 @@ void EmailManager::sync(void* data)
 //        std::vector<EmailConversationInfo> conversationsInfo =
 //                MessagingDatabaseManager::getInstance().findEmailConversations(callback);
 //        convListCount = conversationsInfo.size();
-//        LOGD("Found %d conversations", convListCount);
+//        LoggerD("Found %d conversations", convListCount);
 //
 //        for (int i = 0; i < convListCount; ++i) {
 //            std::shared_ptr<MessageConversation> conversation =
@@ -1139,20 +1130,20 @@ void EmailManager::sync(void* data)
 //            callback->addConversation(conversation);
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //        callback->setError(err.getName(), err.getMessage());
 //    } catch (...) {
-//        LOGE("Conversation find failed");
+//        LoggerE("Conversation find failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Conversation find failed");
 //    }
 //
 //    //Complete task
-//    LOGD("callback: %p error:%d conversations.size()=%d", callback, callback->isError(),
+//    LoggerD("callback: %p error:%d conversations.size()=%d", callback, callback->isError(),
 //            callback->getConversations().size());
 //
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return;
@@ -1160,23 +1151,23 @@ void EmailManager::sync(void* data)
 //
 //    try {
 //        if (callback->isError()) {
-//            LOGD("Calling error callback");
+//            LoggerD("Calling error callback");
 //            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
 //                    callback->getErrorName(),
 //                    callback->getErrorMessage());
 //            callback->callErrorCallback(errobj);
 //        } else {
-//            LOGD("Calling success callback");
+//            LoggerD("Calling success callback");
 //            callback->callSuccessCallback(
 //                    MessagingUtil::vectorToJSObjectArray<ConversationPtr,
 //                    JSMessageConversation>(context,
 //                            callback->getConversations()));
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("Error while calling findConversations callback: %s (%s)",
+//        LoggerE("Error while calling findConversations callback: %s (%s)",
 //                (err.getName()).c_str(), (err.getMessage()).c_str());
 //    } catch (...) {
-//        LOGE("Failed to call findConversations callback.");
+//        LoggerE("Failed to call findConversations callback.");
 //    }
 //
 //    delete callback;
@@ -1195,10 +1186,10 @@ long EmailManager::getUniqueOpId()
 
 //void EmailManager::findFolders(FoldersCallbackData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //
 //    if (!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -1213,7 +1204,7 @@ long EmailManager::getUniqueOpId()
 //
 //        Tizen::AbstractFilterPtr filter = callback->getFilter();
 //        if (!filter) {
-//            LOGE("Filter not provided");
+//            LoggerE("Filter not provided");
 //            throw UnknownException("Filter not provided");
 //        }
 //
@@ -1222,7 +1213,7 @@ long EmailManager::getUniqueOpId()
 //            if(FIS_COMPOSITE_START == it.getState()) {
 //                CompositeFilterPtr cf = castToCompositeFilter((*it));
 //                if(cf && INTERSECTION != cf->getType()) {
-//                    LOGE("[ERROR] >>> invalid Filter type: %d", cf->getType());
+//                    LoggerE("[ERROR] >>> invalid Filter type: %d", cf->getType());
 //                    throw TypeMismatchException("Invalid Filter Type");
 //                }
 //            }
@@ -1233,30 +1224,30 @@ long EmailManager::getUniqueOpId()
 //                    if (FIND_FOLDERS_ATTRIBUTE_ACCOUNTID_NAME == attr_name) {
 //                        account_id = static_cast<int>(attrf->getMatchValue()->toLong());
 //                    } else {
-//                        LOGE("The attribute name: %s is invalid", attr_name.c_str());
+//                        LoggerE("The attribute name: %s is invalid", attr_name.c_str());
 //                        throw InvalidValuesException("The attribute name is invalid");
 //                    }
 //                }
 //            }
 //        }
 //
-//        LOGD("Listing folders for account ID: %d", account_id);
+//        LoggerD("Listing folders for account ID: %d", account_id);
 //        if (account_id > 0) {
 //            ret = email_get_mailbox_list(account_id,
 //                    -1,
 //                    &mailboxes,
 //                    &mailboxes_count);
 //            if (EMAIL_ERROR_NONE != ret || !mailboxes) {
-//                LOGE("Cannot get folders: %d", ret);
+//                LoggerE("Cannot get folders: %d", ret);
 //                throw Common::UnknownException(
 //                        "Platform error, cannot get folders");
 //            }
 //
 //            if (mailboxes_count <= 0) {
-//                LOGD("Empty mailboxes");
+//                LoggerD("Empty mailboxes");
 //            }
 //            else {
-//                LOGD("Founded mailboxes: %d", mailboxes_count);
+//                LoggerD("Founded mailboxes: %d", mailboxes_count);
 //
 //                nth_mailbox = mailboxes;
 //                for (int i = 0; i < mailboxes_count; ++i) {
@@ -1268,10 +1259,10 @@ long EmailManager::getUniqueOpId()
 //            }
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //        callback->setError(err.getName(), err.getMessage());
 //    } catch (...) {
-//        LOGE("Messages update failed");
+//        LoggerE("Messages update failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR,
 //                "Messages update failed");
 //    }
@@ -1279,17 +1270,17 @@ long EmailManager::getUniqueOpId()
 //    if (mailboxes != NULL) {
 //        if (EMAIL_ERROR_NONE != email_free_mailbox(&mailboxes,
 //                mailboxes_count)) {
-//            LOGW("Free mailboxes failed: %d", ret);
+//            LoggerW("Free mailboxes failed: %d", ret);
 //        }
 //    }
 //
 //    //Complete task
-//    LOGD("callback: %p error:%d folders.size()=%d", callback, callback->isError(),
+//    LoggerD("callback: %p error:%d folders.size()=%d", callback, callback->isError(),
 //            callback->getFolders().size());
 //
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return;
@@ -1297,22 +1288,22 @@ long EmailManager::getUniqueOpId()
 //
 //    try {
 //        if (callback->isError()) {
-//            LOGD("Calling error callback");
+//            LoggerD("Calling error callback");
 //            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
 //                    callback->getErrorName(),
 //                    callback->getErrorMessage());
 //            callback->callErrorCallback(errobj);
 //        } else {
-//            LOGD("Calling success callback");
+//            LoggerD("Calling success callback");
 //            JSObjectRef js_obj = MessagingUtil::vectorToJSObjectArray<FolderPtr,
 //                    JSMessageFolder>(context, callback->getFolders());
 //            callback->callSuccessCallback(js_obj);
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("Error while calling findFolders callback: %s (%s)",
+//        LoggerE("Error while calling findFolders callback: %s (%s)",
 //                (err.getName()).c_str(), (err.getMessage()).c_str());
 //    } catch (...) {
-//        LOGE("Unknown error when calling findFolders callback.");
+//        LoggerE("Unknown error when calling findFolders callback.");
 //    }
 //
 //    delete callback;
@@ -1321,10 +1312,10 @@ long EmailManager::getUniqueOpId()
 //
 //void EmailManager::removeConversations(ConversationCallbackData* callback)
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //
 //    if (!callback){
-//        LOGE("Callback is null");
+//        LoggerE("Callback is null");
 //        return;
 //    }
 //
@@ -1338,7 +1329,7 @@ long EmailManager::getUniqueOpId()
 //        int thread_id = 0;
 //        for(auto it = conversations.begin() ; it != conversations.end(); ++it) {
 //            if((*it)->getType() != type) {
-//                LOGE("Invalid message type");
+//                LoggerE("Invalid message type");
 //                throw TypeMismatchException("Error while deleting email conversation");
 //            }
 //        }
@@ -1347,7 +1338,7 @@ long EmailManager::getUniqueOpId()
 //            thread_id = (*it)->getConversationId();
 //            error = email_delete_thread(thread_id, false);
 //            if (EMAIL_ERROR_NONE != error) {
-//                LOGE("Couldn't delete conversation data");
+//                LoggerE("Couldn't delete conversation data");
 //                throw UnknownException("Error while deleting mail conversation");
 //            }
 //
@@ -1356,7 +1347,7 @@ long EmailManager::getUniqueOpId()
 //            email_mail_data_t *thread_info = NULL;
 //            do {
 //                usleep(300 * 1000);
-//                LOGD("Waiting to delete this email thread...");
+//                LoggerD("Waiting to delete this email thread...");
 //                error = email_get_thread_information_by_thread_id(
 //                    thread_id, &thread_info);
 //
@@ -1367,16 +1358,16 @@ long EmailManager::getUniqueOpId()
 //            } while (error != EMAIL_ERROR_MAIL_NOT_FOUND);
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
+//        LoggerE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str());
 //        callback->setError(err.getName(), err.getMessage());
 //    } catch (...) {
-//        LOGE("Messages remove failed");
+//        LoggerE("Messages remove failed");
 //        callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, "Messages remove failed");
 //    }
 //
 //    JSContextRef context = callback->getContext();
 //    if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) {
-//        LOGE("context was closed");
+//        LoggerE("context was closed");
 //        delete callback;
 //        callback = NULL;
 //        return;
@@ -1384,20 +1375,20 @@ long EmailManager::getUniqueOpId()
 //
 //    try {
 //        if (callback->isError()) {
-//            LOGD("Calling error callback");
+//            LoggerD("Calling error callback");
 //            JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context,
 //                    callback->getErrorName(),
 //                    callback->getErrorMessage());
 //            callback->callErrorCallback(errobj);
 //        } else {
-//            LOGD("Calling success callback");
+//            LoggerD("Calling success callback");
 //            callback->callSuccessCallback();
 //        }
 //    } catch (const BasePlatformException& err) {
-//        LOGE("Error while calling removeConversations callback: %s (%s)",
+//        LoggerE("Error while calling removeConversations callback: %s (%s)",
 //                (err.getName()).c_str(), (err.getMessage()).c_str());
 //    } catch (...) {
-//        LOGE("Unknown error when calling removeConversations callback.");
+//        LoggerE("Unknown error when calling removeConversations callback.");
 //    }
 //
 //    delete callback;
index cb7e4433672d59ecf989b43c675313f7b28ebf68..48087313d32aecd69c9416da2c7bfda023234bfa 100644 (file)
@@ -58,7 +58,7 @@ class EmailManager {
 public:
     static EmailManager& getInstance();
 
-//    void addDraftMessage(MessageCallbackUserData* callback);
+    void addDraftMessage(MessageCallbackUserData* callback);
 //    void removeMessages(MessagesCallbackUserData* callback);
 //    void updateMessages(MessagesCallbackUserData* callback);
 //    void findMessages(FindMsgCallbackUserData* callback);
@@ -94,12 +94,12 @@ private:
     EmailManager(const EmailManager &);
     void operator=(const EmailManager &);
     virtual ~EmailManager();
-//    void addDraftMessagePlatform(int account_id,
-//        std::shared_ptr<Message> message);
+    void addDraftMessagePlatform(int account_id,
+        std::shared_ptr<Message> message);
 //    void addOutboxMessagePlatform(int account_id,
 //        std::shared_ptr<Message> message);
-//    void addMessagePlatform(int account_id, std::shared_ptr<Message> message,
-//        email_mailbox_type_e mailbox_type);
+    void addMessagePlatform(int account_id, std::shared_ptr<Message> message,
+        email_mailbox_type_e mailbox_type);
 //
 //    typedef std::map<int, MessageRecipientsCallbackData*> SendReqMap;
 //    typedef SendReqMap::iterator SendReqMapIterator;
index e77a1539ac171753222b16badea5d8379d1a6d77..8947868e4906a4b2dd6abbf662087c7d059fce67 100644 (file)
@@ -29,12 +29,12 @@ Message::Message():
     m_service_id_set(false), m_status(STATUS_UNDEFINED),
     m_sim_index(TAPI_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN)
 {
-    LOGD("Message constructor (%p)", this);
+    LoggerD("Message constructor (%p)", this);
 }
 
 Message::~Message()
 {
-    LOGD("Message destructor (%p)", this);
+    LoggerD("Message destructor (%p)", this);
 }
 
 // *** attribute getters
@@ -175,7 +175,7 @@ void Message::setTO(std::vector<std::string> &to)
     m_to = to;
 
     if(m_to.empty()) {
-        LOGD("Recipient's list cleared");
+        LoggerD("Recipient's list cleared");
         return;
     }
 }
@@ -308,11 +308,11 @@ std::string saveToTempFile(const std::string &data)
     umask(old_mask);
 
     if (NULL == file) {
-        LOGE("Failed to create file");
+        LoggerE("Failed to create file");
         throw common::UnknownException("Failed to create file");
     }
     if (fprintf(file, "%s", data.c_str()) < 0) {
-        LOGE("Failed to write data into file");
+        LoggerE("Failed to write data into file");
         throw common::UnknownException("Failed to write data into file");
     }
     fflush(file);
@@ -322,7 +322,7 @@ std::string saveToTempFile(const std::string &data)
 
 std::string copyFileToTemp(const std::string& sourcePath)
 {
-    LOGD("Entered");
+    LoggerD("Entered");
     char buf[] = "XXXXXX";
     std::string dirPath, fileName, attPath, tmpPath;
 
@@ -352,7 +352,7 @@ std::string copyFileToTemp(const std::string& sourcePath)
 //    fileName = attPath.substr(slashPos + 1);
 //    tmpPath = dirPath + "/" + fileName;
 //
-//    LOGD("attPath: %s, tmpPath: %s", attPath.c_str(), tmpPath.c_str());
+//    LoggerD("attPath: %s, tmpPath: %s", attPath.c_str(), tmpPath.c_str());
 //    if(EINA_TRUE != ecore_file_mkdir(dirPath.c_str())) {
 //        throw common::UnknownException("Unknown error while creating temp directory.");
 //    }
@@ -375,7 +375,7 @@ void removeDirFromTemp(const std::string& dirPath)
 email_mail_data_t* Message::convertPlatformEmail(std::shared_ptr<Message> message)
 {
     if(EMAIL != message->getType()) {
-        LOGE("Invalid type");
+        LoggerE("Invalid type");
         throw common::InvalidValuesException("Invalid type.");
     }
 
@@ -422,7 +422,7 @@ email_mail_data_t* Message::convertPlatformEmail(std::shared_ptr<Message> messag
             mail_data->file_path_plain = strdup(body_file_path.c_str());
             if(!mail_data->file_path_plain)
             {
-                LOGE("Plain Body file is NULL.");
+                LoggerE("Plain Body file is NULL.");
                 free(mail_data);
                 mail_data = NULL;
                 throw common::UnknownException("Plain Body file is NULL.");
@@ -434,7 +434,7 @@ email_mail_data_t* Message::convertPlatformEmail(std::shared_ptr<Message> messag
             mail_data->file_path_html = strdup(html_file_path.c_str());
             if(!mail_data->file_path_html)
             {
-                LOGE("Html Body file is NULL.");
+                LoggerE("Html Body file is NULL.");
                 free(mail_data);
                 mail_data = NULL;
                 throw common::UnknownException("Html Body file is NULL.");
@@ -445,7 +445,7 @@ email_mail_data_t* Message::convertPlatformEmail(std::shared_ptr<Message> messag
             mail_data->file_path_html = strdup(html_file_path.c_str());
             if(!mail_data->file_path_html)
             {
-                LOGE("Plain Body file is NULL.");
+                LoggerE("Plain Body file is NULL.");
                 free(mail_data);
                 mail_data = NULL;
                 throw common::UnknownException("Plain Body file is NULL.");
@@ -479,7 +479,7 @@ void addSingleEmailAttachment(std::shared_ptr<Message> message,
     int id = message->getId();
     int err = email_add_attachment(id, tmp);
     if(EMAIL_ERROR_NONE != err) {
-        LOGE("Error while adding attachment %d", err);
+        LoggerE("Error while adding attachment %d", err);
         err = email_free_attachment_data(&tmp, 1);
         if (EMAIL_ERROR_NONE != err) {
             LOGW("Failed to free attachment data");
@@ -499,7 +499,7 @@ void addSingleEmailAttachment(std::shared_ptr<Message> message,
 
 void Message::addEmailAttachments(std::shared_ptr<Message> message)
 {
-    LOGD("Entered");
+    LoggerD("Entered");
 
     int attachment_data_count = 0, error;
     email_mail_data_t *mail = NULL;
@@ -509,9 +509,9 @@ void Message::addEmailAttachments(std::shared_ptr<Message> message)
 
     AttachmentPtrVector attachments = message->getMessageAttachments();
     AttachmentPtrVector inlineAttachments = message->getBody()->getInlineAttachments();
-    LOGD("Attachments size: %d", attachments.size());
-    LOGD("Inline attachments size: %d", inlineAttachments.size());
-    LOGD("Adding attachments for mail id = [%d]\n", message->getId());
+    LoggerD("Attachments size: %d", attachments.size());
+    LoggerD("Inline attachments size: %d", inlineAttachments.size());
+    LoggerD("Adding attachments for mail id = [%d]\n", message->getId());
     for (auto it = attachments.begin(); it != attachments.end(); ++it) {
         addSingleEmailAttachment(message, *it, AttachmentType::EXTERNAL);
     }
@@ -532,7 +532,7 @@ void Message::addEmailAttachments(std::shared_ptr<Message> message)
     if (EMAIL_ERROR_NONE != error) {
         email_free_mail_data(&mail, 1);
         email_free_attachment_data(&attachment_data_list,attachment_data_count);
-        LOGE("Error while adding attachments. Failed to get attachment list.");
+        LoggerE("Error while adding attachments. Failed to get attachment list.");
         throw common::UnknownException("Error while adding attachments. Failed to get attachment list.");
     }
 
@@ -544,10 +544,10 @@ void Message::addEmailAttachments(std::shared_ptr<Message> message)
     if (EMAIL_ERROR_NONE != error) {
         email_free_mail_data(&mail, 1);
         email_free_attachment_data(&attachment_data_list,attachment_data_count);
-        LOGE("Error while re-adding mail: %d", error);
+        LoggerE("Error while re-adding mail: %d", error);
         throw common::UnknownException("Error while re-adding mail");
     }
-    LOGD("mail added - new id = [%d]\n", mail->mail_id);
+    LoggerD("mail added - new id = [%d]\n", mail->mail_id);
 
     //refresh message object
     message->setId(mail->mail_id);
@@ -564,7 +564,7 @@ void Message::addEmailAttachments(std::shared_ptr<Message> message)
     error = email_delete_mail(mail->mailbox_id,&tmp_id,1,1);
     if (EMAIL_ERROR_NONE != error) {
         email_free_mail_data(&mail, 1);
-        LOGE("Error while deleting mail from server: %d", error);
+        LoggerE("Error while deleting mail from server: %d", error);
         throw common::UnknownException("Error while deleting mail from server");
     }
     email_free_mail_data(&mail, 1);
@@ -577,7 +577,7 @@ void Message::addSMSRecipientsToStruct(const std::vector<std::string> &recipient
     for (unsigned int i = 0; i < size; ++i) {
         char *address = const_cast<char *>(recipients.at(i).c_str());
 
-        LOGD("[%d] address:[%s]", i, address);
+        LoggerD("[%d] address:[%s]", i, address);
         msg_struct_t tmpAddr = NULL;
         if (MSG_SUCCESS
                 == msg_list_add_item(msg, MSG_MESSAGE_ADDR_LIST_HND, &tmpAddr)) {
@@ -589,7 +589,7 @@ void Message::addSMSRecipientsToStruct(const std::vector<std::string> &recipient
                     address, strlen(address));
         }
         else {
-            LOGE("failed to add address[%d] %s", i, address);
+            LoggerE("failed to add address[%d] %s", i, address);
             throw common::UnknownException("failed to add address");
         }
     }
@@ -609,7 +609,7 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
         }
 
         char *address = const_cast<char *>(recipients.at(i).c_str());
-        LOGD("[%d] address:[%s] address_type:%d type:%d", i, address, address_type, type);
+        LoggerD("[%d] address:[%s] address_type:%d type:%d", i, address, address_type, type);
 
         int error = msg_list_add_item(msg, MSG_MESSAGE_ADDR_LIST_HND, &tmpAddr);
         if (MSG_SUCCESS == error) {
@@ -621,7 +621,7 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
                     address, strlen(address));
         }
         else {
-            LOGE("[%d] failed to add address: [%s], error: %d", i, address, error);
+            LoggerE("[%d] failed to add address: [%s], error: %d", i, address, error);
             throw common::UnknownException("failed to add address");
         }
     }
@@ -630,7 +630,7 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 //void Message::addMMSBodyAndAttachmentsToStruct(const AttachmentPtrVector attach,
 //        msg_struct_t &mms_struct, Message* message)
 //{
-//    LOGD("Entered with %d attachments", attach.size());
+//    LoggerD("Entered with %d attachments", attach.size());
 //
 //    int size = attach.size();
 //    for (int i = 0; i < size; i++) {
@@ -647,7 +647,7 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 //            // set file path, file name, file size
 //            if (attach.at(i)->isFilePathSet()) {
 //                std::string filepath = attach.at(i)->getFilePath();
-//                LOGD("att[%d]: org filepath: %s", i, filepath.c_str());
+//                LoggerD("att[%d]: org filepath: %s", i, filepath.c_str());
 //                if(Filesystem::External::isVirtualPath(filepath)) {
 //                    // TODO
 //                    // When introducing below line fromVirtualPath() function
@@ -655,7 +655,7 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 //                    // context pointer. If it appears to need a real context
 //                    // it will need a fix here.
 //                    filepath = Filesystem::External::fromVirtualPath(filepath);
-//                    LOGD("att[%d]: org virtual filepath: %s", i, filepath.c_str());
+//                    LoggerD("att[%d]: org virtual filepath: %s", i, filepath.c_str());
 //                }
 //                msg_set_str_value(tmpAtt, MSG_MMS_ATTACH_FILEPATH_STR,
 //                        const_cast<char*>(filepath.c_str()), filepath.size());
@@ -664,16 +664,16 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 //                    filepath.erase(0, last_slash_idx + 1);
 //                }
 //
-//                LOGD("att[%d] filename: %s", i, filepath.c_str());
+//                LoggerD("att[%d] filename: %s", i, filepath.c_str());
 //                msg_set_str_value(tmpAtt, MSG_MMS_ATTACH_FILENAME_STR,
 //                        const_cast<char*>(filepath.c_str()), filepath.size());
 //                struct stat st;
 //                if (stat(const_cast<char*>(filepath.c_str()), &st)) {
-//                    LOGE("Stat error");
+//                    LoggerE("Stat error");
 //                }
 //                const int fsize = st.st_size;
 //                msg_set_int_value(tmpAtt, MSG_MMS_ATTACH_FILESIZE_INT, fsize);
-//                LOGD("att[%d]: filesize: %d", i,fsize);
+//                LoggerD("att[%d]: filesize: %d", i,fsize);
 //            }
 //
 //            //-------------------------------------------------------------------------
@@ -687,11 +687,11 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 //                                    MSG_MSG_ID_LEN);
 //
 //
-//                LOGD("att[%d]: setting mime type:0x%x (orignal:%s)", i, type,
+//                LoggerD("att[%d]: setting mime type:0x%x (orignal:%s)", i, type,
 //                    attach.at(i)->getMimeType().c_str());
 //            }
 //        } else {
-//            LOGE("att[%d]: failed to add attachment");
+//            LoggerE("att[%d]: failed to add attachment");
 //            throw common::UnknownException("failed to add attachment");
 //        }
 //    }
@@ -700,10 +700,10 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         msg_handle_t handle)
 {
-    LOGD("Entered");
+    LoggerD("Entered");
 
     if (message->getType() != SMS && message->getType() != MMS) {
-        LOGD("Invalid type");
+        LoggerD("Invalid type");
         throw common::InvalidValuesException("Invalid type");
     }
 
@@ -717,10 +717,10 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         if (err != MSG_SUCCESS) {
             msg_release_struct(&sendOpt);
             msg_release_struct(&msg);
-            LOGD("msg_get_message() Fail [%d]", err);
+            LoggerD("msg_get_message() Fail [%d]", err);
             throw common::UnknownException("msg_get_message() Fail");
         }
-        LOGD("Using existing msg for id: %d", id);
+        LoggerD("Using existing msg for id: %d", id);
     } else { // id is not set - the message does not exist in database
         MessageType msgType = message->getType();
         if (msgType == MessageType::SMS) {
@@ -729,7 +729,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
                     != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS)) {
                 msg_release_struct(&sendOpt);
                 msg_release_struct(&msg);
-                LOGE("Set SMS type error");
+                LoggerE("Set SMS type error");
                 throw common::UnknownException("Set SMS type error");
             }
         } else {
@@ -738,7 +738,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
                     != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)) {
                 msg_release_struct(&sendOpt);
                 msg_release_struct(&msg);
-                LOGE("Set MMS type error");
+                LoggerE("Set MMS type error");
                 throw common::UnknownException("Set MMS type error");
             }
         }
@@ -747,7 +747,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
 
     int type;
     msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &type);
-    LOGD("Message(%p): MSG_MESSAGE_TYPE = %d", message, type);
+    LoggerD("Message(%p): MSG_MESSAGE_TYPE = %d", message, type);
 
     if (type == MSG_TYPE_SMS) {
         // Set SMS message body text
@@ -761,7 +761,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         // Reset SMS recipients
         int error = msg_list_clear(msg, MSG_MESSAGE_ADDR_LIST_HND);
         if( MSG_SUCCESS != error) {
-            LOGE("Failed to clear address list, error: %d", error);
+            LoggerE("Failed to clear address list, error: %d", error);
             throw common::UnknownException("Failed to clear address list");
         }
 
@@ -775,13 +775,13 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         // Set message type to MMS
         if (MSG_SUCCESS
                 != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)) {
-            LOGE("Message(%p): Set MMS type error", message);
+            LoggerE("Message(%p): Set MMS type error", message);
             throw common::UnknownException("Set MMS type error");
         }
         // Create MMS data
         msg_struct_t mms_data = msg_create_struct(MSG_STRUCT_MMS);
         if (mms_data == NULL) {
-            LOGE("Message(%p): Set MMS data error", message);
+            LoggerE("Message(%p): Set MMS data error", message);
             throw common::UnknownException("Set MMS data error");
         }
         // Set MMS message subject
@@ -790,7 +790,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
             int r = msg_set_str_value(msg, MSG_MESSAGE_SUBJECT_STR,
                     const_cast<char*>(subject.c_str()), subject.size());
             if (r != MSG_SUCCESS) {
-                LOGE("Message(%p): Set MMS subject error: %d", message, r);
+                LoggerE("Message(%p): Set MMS subject error: %d", message, r);
                 throw common::UnknownException("Set MMS subject error");
             }
         }
@@ -798,7 +798,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
 //        std::shared_ptr<MessageBody> body;
 //        body = message->getBody();
 //        if (!body->getPlainBody().empty()) {
-//            LOGD("Message(%p): PlainBody is NOT empty", message);
+//            LoggerD("Message(%p): PlainBody is NOT empty", message);
 //
 //            static const int ROOT_LAYOUT_WIDTH = 100;
 //            static const int ROOT_LAYOUT_HEIGHT = 100;
@@ -844,7 +844,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
 //                    const_cast<char*>(body_file_path.c_str()),
 //                    body_file_path.size());
 //            if (error != MSG_SUCCESS) {
-//                LOGE("Message(%p): Failed to set mms body filepath", message);
+//                LoggerE("Message(%p): Failed to set mms body filepath", message);
 //                throw common::UnknownException("Failed to set mms body filepath");
 //            }
 //            msg_set_str_value(media, MSG_MMS_MEDIA_CONTENT_TYPE_STR,
@@ -859,11 +859,11 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
 //                    MMS_SMIL_FONT_SIZE_NORMAL);
 //            msg_set_bool_value(smil_text, MSG_MMS_SMIL_TEXT_BOLD_BOOL, true);
 //        } else {
-//            LOGD("Message(%p): PlainBody is EMPTY", message);
+//            LoggerD("Message(%p): PlainBody is EMPTY", message);
 //        }
 //        // Set MMS attachments
 //        AttachmentPtrVector attach_list = message->getMessageAttachments();
-//        LOGD("Message(%p): id:%d subject:[%s] plainBody:[%s] contains %d attachments",
+//        LoggerD("Message(%p): id:%d subject:[%s] plainBody:[%s] contains %d attachments",
 //                message, message->getId(), message->getSubject().c_str(),
 //                message->getBody()->getPlainBody().c_str(), attach_list.size());
 //
@@ -875,7 +875,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         // Set MMS body
         int r = msg_set_mms_struct(msg, mms_data);
         if (r != MSG_SUCCESS) {
-            LOGE("Message(%p): Set MMS body error: %d", message, r);
+            LoggerE("Message(%p): Set MMS body error: %d", message, r);
             throw common::UnknownException("Set MMS body error");
         }
         msg_release_struct(&mms_data);
@@ -894,7 +894,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
     }
     else {
         msg_release_struct(&msg);
-        LOGE("Message(%p): Invalid message type", message);
+        LoggerE("Message(%p): Invalid message type", message);
         throw common::InvalidValuesException("Invalid message type");
     }
 
@@ -928,7 +928,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         int error =
             msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, sim_index+1);
         if ( MSG_SUCCESS != error) {
-            LOGE("Failed to set sim index, error: %d", error);
+            LoggerE("Failed to set sim index, error: %d", error);
             throw common::UnknownException("Failed to set sim index");
         }
     }
@@ -936,7 +936,7 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
     // Set message if is read
     msg_set_bool_value(msg, MSG_MESSAGE_READ_BOOL, message->getIsRead());
 
-    LOGD("End");
+    LoggerD("End");
     return msg;
 }
 
@@ -947,7 +947,7 @@ std::string Message::getShortMsgSenderFromStruct(msg_struct_t &msg)
 
     char str_phone_number[MAX_ADDRESS_VAL_LEN];
     const int count = msg_list_length(addr_list);
-    LOGD("Number of addresses: %d", count);
+    LoggerD("Number of addresses: %d", count);
 
     for (int i = 0; i < count; ++i)
     {
@@ -961,13 +961,13 @@ std::string Message::getShortMsgSenderFromStruct(msg_struct_t &msg)
             msg_get_str_value(cur_addr_info, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR,
                     str_phone_number, MAX_ADDRESS_VAL_LEN);
 
-            LOGD("[%d/%d] is TYPE_MT, phone number is: %s", i, count, str_phone_number);
+            LoggerD("[%d/%d] is TYPE_MT, phone number is: %s", i, count, str_phone_number);
 
             if(0 != str_phone_number[0]) {
                 return std::string(str_phone_number);
             }
         } else {
-            LOGD("[%d/%d] is NOT of TYPE_MT skipping, is:%d", i, count, type);
+            LoggerD("[%d/%d] is NOT of TYPE_MT skipping, is:%d", i, count, type);
         }
     }
 
@@ -992,7 +992,7 @@ std::vector<std::string> Message::getSMSRecipientsFromStruct(msg_struct_t &msg)
             address.push_back(std::string(infoStr));
         }
     } else {
-        LOGE("failed to get recipients");
+        LoggerE("failed to get recipients");
         throw common::UnknownException("failed to add recipients");
     }
     return address;
@@ -1022,7 +1022,7 @@ std::vector<std::string> Message::getMMSRecipientsFromStruct(msg_struct_t &msg,
             }
         }
     } else {
-        LOGE("failed to get recipients");
+        LoggerE("failed to get recipients");
         throw common::UnknownException("failed to add recipients");
     }
     return address;
@@ -1031,14 +1031,14 @@ std::vector<std::string> Message::getMMSRecipientsFromStruct(msg_struct_t &msg,
 void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
         msg_struct_t &msg)
 {
-    LOGD("Entered message(%p)", message);
+    LoggerD("Entered message(%p)", message);
     int tempInt = 0;
     char infoStr[MSG_FILEPATH_LEN_MAX + 1];
 
     msg_struct_t mms_struct = msg_create_struct(MSG_STRUCT_MMS);
     int error = msg_get_mms_struct(msg, mms_struct);
     if (MSG_SUCCESS != error) {
-        LOGE("Cannot get mms struct, error:%d", error);
+        LoggerE("Cannot get mms struct, error:%d", error);
         msg_release_struct(&mms_struct);
         throw common::UnknownException("cannot get mms struct");
     }
@@ -1049,12 +1049,12 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
     error = msg_get_list_handle(mms_struct, MSG_MMS_PAGE_LIST_HND, (void **) &page_list);
     if (MSG_SUCCESS == error) {
         int pageLen = msg_list_length(page_list);
-        LOGD("MSG_MMS_PAGE_LIST length:%d", pageLen);
+        LoggerD("MSG_MMS_PAGE_LIST length:%d", pageLen);
 
         for (int p = 0; p < pageLen; ++p) {
             msg_struct_t page = (msg_struct_t) msg_list_nth_data(page_list, p);
             if (!page) {
-                LOGE("returned page is null, continue");
+                LoggerE("returned page is null, continue");
                 continue;
             }
 
@@ -1063,12 +1063,12 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
                     (void **) &media_list);
             if (MSG_SUCCESS == error) {
                 int mediaLen = msg_list_length(media_list);
-                LOGD("[p:%d] MSG_MMS_PAGE_MEDIA_LIST length:%d", p, mediaLen);
+                LoggerD("[p:%d] MSG_MMS_PAGE_MEDIA_LIST length:%d", p, mediaLen);
 
                 for (int m = 0; m < mediaLen; ++m) {
                     msg_struct_t media = (msg_struct_t) msg_list_nth_data(media_list, m);
                     if (NULL == media) {
-                        LOGE("returned media is null, continue");
+                        LoggerE("returned media is null, continue");
                         continue;
                     }
                     // add media from pages to attachments vector
@@ -1076,38 +1076,38 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
                     memset(infoStr, 0, MSG_FILEPATH_LEN_MAX + 1);
                     msg_get_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, infoStr,
                             MSG_FILEPATH_LEN_MAX);
-                    LOGD("[p:%d, m:%d] attachment file path:%s", p, m, infoStr);
+                    LoggerD("[p:%d, m:%d] attachment file path:%s", p, m, infoStr);
 
                     msg_get_int_value(media, MSG_MMS_MEDIA_TYPE_INT, &tempInt);
                     const int msg_media_type = tempInt;
                     std::string msg_media_type_str =
                             MessageAttachment::MIMETypeEnumToString(msg_media_type);
 
-                    LOGD("[p:%d, m:%d] MSG_MMS_MEDIA_TYPE: %d (%s)", p, m, msg_media_type,
+                    LoggerD("[p:%d, m:%d] MSG_MMS_MEDIA_TYPE: %d (%s)", p, m, msg_media_type,
                             msg_media_type_str.c_str());
 
                     //According to old implementation
                     // "text value on first page goes to body attribute"
                     if ((0 == p) && (MMS_SMIL_MEDIA_TEXT == msg_media_type)) {
-                        LOGD("Loading body from file: %s ", infoStr);
+                        LoggerD("Loading body from file: %s ", infoStr);
 
                         try {
                             message->getBody()->setPlainBody(
                                     MessagingUtil::loadFileContentToString(infoStr));
                             body_has_been_set = true;
 
-                            LOGD("Loaded body: %s",
+                            LoggerD("Loaded body: %s",
                                     message->getBody()->getPlainBody().c_str());
 
                         } catch(const common::PlatformException& exception) {
-                            LOGE("Unhandled exception: %s (%s)!",
+                            LoggerE("Unhandled exception: %s (%s)!",
                                  (exception.name()).c_str(),
                                  (exception.message()).c_str());
-                            LOGD("[p:%d, m:%d] body is not set", p, m);
+                            LoggerD("[p:%d, m:%d] body is not set", p, m);
                         }
                         catch (...) {
-                            LOGE("Unknown exception occured during plain body loading");
-                            LOGD("[p:%d, m:%d] body is not set", p, m);
+                            LoggerE("Unknown exception occured during plain body loading");
+                            LoggerD("[p:%d, m:%d] body is not set", p, m);
                         }
 
                     } else {
@@ -1127,7 +1127,7 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
                         ma->setMimeType(msg_media_type_str);
 
                         MessageAttachment* att = ma.get();
-                        LOGD("[p:%d, m:%d] added attachment: %p "
+                        LoggerD("[p:%d, m:%d] added attachment: %p "
                                 "(mime:0x%x mime:%s messageId:%d)", p, m, att,
                                 msg_media_type, msg_media_type_str.c_str(),
                                 ma->getMessageId());
@@ -1137,14 +1137,14 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
                 }
             } else {
                 msg_release_struct(&mms_struct);
-                LOGE("failed to get attachment");
+                LoggerE("failed to get attachment");
                 throw common::UnknownException("failed to get attachment");
             }
             msg_release_struct(&page);
         }
     } else {
         msg_release_struct(&mms_struct);
-        LOGE("failed to get attachment");
+        LoggerE("failed to get attachment");
         throw common::UnknownException("failed to get attachment");
     }
 
@@ -1152,7 +1152,7 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
         LOGW("Warning: body has not been set!");
     }
 
-    LOGD("after MSG_MMS_PAGE_LIST attachments count is:%d",
+    LoggerD("after MSG_MMS_PAGE_LIST attachments count is:%d",
             message->m_attachments.size());
 
     // if there are some other attachments add it to attachments vector
@@ -1162,7 +1162,7 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
     if (MSG_SUCCESS == error) {
 
         unsigned size = msg_list_length(attach_list);
-        LOGD("MSG_MMS_ATTACH_LIST length:%d", size);
+        LoggerD("MSG_MMS_ATTACH_LIST length:%d", size);
 
         for (unsigned int i = 0; i < size; i++) {
             msg_struct_t attach_info = NULL;
@@ -1192,7 +1192,7 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
             ma->setMimeType(type);
 
             MessageAttachment* att = ma.get();
-            LOGD("[att:%d] added attachement: %p (mime:0x%x mime:%s path:%s id:%d)",
+            LoggerD("[att:%d] added attachement: %p (mime:0x%x mime:%s path:%s id:%d)",
                 i, att, tempInt, type.c_str(), infoStr, ma->getId());
 
             message->m_attachments.push_back(ma);
@@ -1202,11 +1202,11 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
         }
     } else {
         msg_release_struct(&mms_struct);
-        LOGE("failed to get attachment");
+        LoggerE("failed to get attachment");
         throw common::UnknownException("failed to add attachment");
     }
 
-//    LOGD("after MSG_MMS_ATTACH_LIST attachments count is:%d",
+//    LoggerD("after MSG_MMS_ATTACH_LIST attachments count is:%d",
 //            message->m_attachments.size());
     msg_release_struct(&mms_struct);
 }
@@ -1243,12 +1243,12 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
 //            int error = msg_get_str_value(msg, MSG_MESSAGE_MMS_TEXT_STR,
 //                    mms_body_str.get(), mms_body_length);
 //            if(MSG_SUCCESS != error) {
-//                LOGE("Error:%d occured during: "
+//                LoggerE("Error:%d occured during: "
 //                        "msg_get_str_value(...,MSG_MESSAGE_MMS_TEXT_STR,...)", error);
 //            } else {
 //                //Check if fetched string is not empty
 //                if((mms_body_str.get())[0] != 0) {
-//                    LOGD("Fetched plain body (with MSG_MESSAGE_MMS_TEXT_STR):"
+//                    LoggerD("Fetched plain body (with MSG_MESSAGE_MMS_TEXT_STR):"
 //                            "[%s] length:%d", mms_body_str.get(), mms_body_length);
 //
 //                    std::shared_ptr<MessageBody> body (new MessageBody());
@@ -1261,7 +1261,7 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
 //                            "despite reported length is:%d!", mms_body_length);
 //                }
 //
-//                LOGD("Set plain body: [%s]", message->getBody()->getPlainBody().c_str());
+//                LoggerD("Set plain body: [%s]", message->getBody()->getPlainBody().c_str());
 //            }
 //        } else {
 //            LOGW("Warning: mms plain body length is 0!");
@@ -1282,7 +1282,7 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
 //        //set attachments
 //        setMMSBodyAndAttachmentsFromStruct(message, msg);
     } else {
-        LOGE("Invalid Message type: %d", infoInt);
+        LoggerE("Invalid Message type: %d", infoInt);
         throw common::InvalidValuesException("Invalid Message type");
     }
 
@@ -1301,10 +1301,10 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
     // get from
     const std::string& from = Message::getShortMsgSenderFromStruct(msg);
     message->setFrom(from);
-    LOGD("Message(%p) from is: %s", message, message->getFrom().c_str());
+    LoggerD("Message(%p) from is: %s", message, message->getFrom().c_str());
     // get if is in response
     msg_get_int_value(msg, MSG_MESSAGE_DIRECTION_INT, &infoInt);
-    LOGD("Message(%p) direction is: %d", message, infoInt);
+    LoggerD("Message(%p) direction is: %d", message, infoInt);
     message->setInResponseTo(infoInt);
     // get is read
     msg_get_bool_value(msg, MSG_MESSAGE_READ_BOOL, &infoBool);
@@ -1327,12 +1327,12 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
         }
         message->setMessageStatus(msg_status);
 
-        LOGD("MSG_MESSAGE_FOLDER_ID:%d -> messageStatus:%s", infoInt,
+        LoggerD("MSG_MESSAGE_FOLDER_ID:%d -> messageStatus:%s", infoInt,
                 MessagingUtil::messageStatusToString(msg_status).c_str());
     }
     else
     {
-        LOGE("Couldn't get MSG_MESSAGE_FOLDER_ID_INT, error:%d", error);
+        LoggerE("Couldn't get MSG_MESSAGE_FOLDER_ID_INT, error:%d", error);
         error = msg_get_int_value(msg, MSG_SENT_STATUS_NETWORK_STATUS_INT, &infoInt);
 
         if(MSG_SUCCESS == error) {
@@ -1351,10 +1351,10 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
             }
             message->setMessageStatus(msg_status);
 
-            LOGD("MSG_SENT_STATUS_NETWORK_STATUS:%d MessageStatus:%s", infoInt,
+            LoggerD("MSG_SENT_STATUS_NETWORK_STATUS:%d MessageStatus:%s", infoInt,
                 MessagingUtil::messageStatusToString(msg_status).c_str());
         } else {
-            LOGE("Couldn't get MSG_SENT_STATUS_NETWORK_STATUS_INT, error:%d", error);
+            LoggerE("Couldn't get MSG_SENT_STATUS_NETWORK_STATUS_INT, error:%d", error);
 
             if(0 == message->getId()) {
                 LOGW("Both MSG_SENT_STATUS_NETWORK_STATUS_INT and "
@@ -1365,7 +1365,7 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
         }
     }
 
-    LOGD("End");
+    LoggerD("End");
     return message;
 }
 
@@ -1406,7 +1406,7 @@ std::vector<std::string> Message::getEmailRecipientsFromStruct(const char *recip
 std::shared_ptr<MessageBody> Message::convertEmailToMessageBody(
         email_mail_data_t& mail)
 {
-    LOGD("Enter");
+    LoggerD("Enter");
     std::shared_ptr<MessageBody> body (new MessageBody());
     body->updateBody(mail);
     return body;
@@ -1414,7 +1414,7 @@ std::shared_ptr<MessageBody> Message::convertEmailToMessageBody(
 
 AttachmentPtrVector Message::convertEmailToMessageAttachment(email_mail_data_t& mail)
 {
-    LOGD("Enter");
+    LoggerD("Enter");
     email_attachment_data_t* attachment = NULL;
     int attachmentCount = 0;
 
@@ -1439,7 +1439,7 @@ AttachmentPtrVector Message::convertEmailToMessageAttachment(email_mail_data_t&
 std::shared_ptr<Message> Message::convertPlatformEmailToObject(
         email_mail_data_t& mail)
 {
-    LOGD("Enter");
+    LoggerD("Enter");
     std::shared_ptr<Message> message(new MessageEmail());
     message->updateEmailMessage(mail);
     return message;
@@ -1497,9 +1497,9 @@ const std::string SUBJECT = MESSAGE_ATTRIBUTE_SUBJECT;
 //            const FilterMatchFlag match_flag,
 //            AnyPtr match_value) const
 //{
-//    LOGD("Entered");
+//    LoggerD("Entered");
 //    auto key = match_value->toString();
-//    LOGD("attribute_name:%s match_flag:%d matchValue:%s", attribute_name.c_str(),
+//    LoggerD("attribute_name:%s match_flag:%d matchValue:%s", attribute_name.c_str(),
 //            match_flag, key.c_str());
 //
 //    using namespace MESSAGE_FILTER_ATTRIBUTE;
@@ -1558,7 +1558,7 @@ const std::string SUBJECT = MESSAGE_ATTRIBUTE_SUBJECT;
 //        return FilterUtils::isStringMatching(key, getSubject(), match_flag);
 //    }
 //    else {
-//        LOGD("attribute:%s is NOT SUPPORTED", attribute_name.c_str());
+//        LoggerD("attribute:%s is NOT SUPPORTED", attribute_name.c_str());
 //    }
 //
 //    return false;
@@ -1568,7 +1568,7 @@ const std::string SUBJECT = MESSAGE_ATTRIBUTE_SUBJECT;
 //            AnyPtr initial_value,
 //            AnyPtr end_value) const
 //{
-//    LOGD("Entered attribute_name: %s", attribute_name.c_str());
+//    LoggerD("Entered attribute_name: %s", attribute_name.c_str());
 //
 //    using namespace MESSAGE_FILTER_ATTRIBUTE;
 //    if(TIMESTAMP == attribute_name) {
@@ -1576,7 +1576,7 @@ const std::string SUBJECT = MESSAGE_ATTRIBUTE_SUBJECT;
 //                end_value);
 //    }
 //    else {
-//        LOGD("attribute:%s is NOT SUPPORTED", attribute_name.c_str());
+//        LoggerD("attribute:%s is NOT SUPPORTED", attribute_name.c_str());
 //    }
 //
 //    return false;
diff --git a/src/messaging/message_callback_user_data.cc b/src/messaging/message_callback_user_data.cc
new file mode 100644 (file)
index 0000000..0282673
--- /dev/null
@@ -0,0 +1,73 @@
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "message_callback_user_data.h"
+#include "messaging_util.h"
+
+namespace extension {
+namespace messaging {
+
+MessageCallbackUserData::MessageCallbackUserData():
+        common::CallbackUserData(),
+        m_is_error(false)
+{
+}
+
+MessageCallbackUserData::~MessageCallbackUserData() {
+}
+
+void MessageCallbackUserData::setMessage(std::shared_ptr<Message> message) {
+    m_message = message;
+}
+
+std::shared_ptr<Message> MessageCallbackUserData::getMessage() const {
+    return m_message;
+}
+
+void MessageCallbackUserData::setAccountId(int account_id){
+    m_account_id = account_id;
+}
+
+int MessageCallbackUserData::getAccountId() const
+{
+    return m_account_id;
+}
+
+void MessageCallbackUserData::setError(const std::string& err_name,
+        const std::string& err_message)
+{
+    // keep only first error in chain
+    if (!m_is_error) {
+        picojson::object& obj = m_json->get<picojson::object>();
+        obj[JSON_ACTION] = picojson::value(JSON_CALLBACK_ERROR);
+        auto objData = picojson::object();
+
+        objData[JSON_RET_ERR_NAME] = picojson::value(err_name);
+        objData[JSON_RET_ERR_MESSAGE] = picojson::value(err_message);
+
+        obj[JSON_RET_DATA] = picojson::value(objData);
+
+        m_is_error = true;
+        m_err_name = err_name;
+        m_err_message = err_message;
+    }
+}
+
+bool MessageCallbackUserData::isError() const
+{
+    return m_is_error;
+}
+
+std::string MessageCallbackUserData::getErrorName() const
+{
+    return m_err_name;
+}
+
+std::string MessageCallbackUserData::getErrorMessage() const
+{
+    return m_err_message;
+}
+
+}//messaging
+}//extension
diff --git a/src/messaging/message_callback_user_data.h b/src/messaging/message_callback_user_data.h
new file mode 100644 (file)
index 0000000..b96eed0
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MESSAGING_MESSAGE_CALLBACK_USER_DATA_H_
+#define MESSAGING_MESSAGE_CALLBACK_USER_DATA_H_
+
+#include "common/callback_user_data.h"
+
+#include <memory>
+#include <string>
+
+namespace extension {
+namespace messaging {
+
+class Message;
+
+class MessageCallbackUserData: public common::CallbackUserData {
+public:
+    MessageCallbackUserData();
+    virtual ~MessageCallbackUserData();
+
+    void setMessage(std::shared_ptr<Message> message);
+    std::shared_ptr<Message> getMessage() const;
+
+    void setAccountId(int account_id);
+    int getAccountId() const;
+
+    void setError(const std::string& err_name,
+            const std::string& err_message);
+    bool isError() const;
+    std::string getErrorName() const;
+    std::string getErrorMessage() const;
+
+private:
+    bool m_is_error;
+    std::string m_err_name;
+    std::string m_err_message;
+    std::shared_ptr<Message> m_message;
+    int m_account_id;
+};
+
+}//messaging
+}//extension
+
+#endif /* MESSAGING_MESSAGE_CALLBACK_USER_DATA_H_ */
+
index 0db471946ff671166f12346285f4817b2294476e..9f4bcc2a14da290f99e42a958e95df9dc8ee8c4e 100644 (file)
@@ -12,13 +12,13 @@ namespace messaging {
 MessageEmail::MessageEmail():
     Message()
 {
-    LOGD("MessageEmail constructor.");
+    LoggerD("MessageEmail constructor.");
     this->m_type = MessageType(EMAIL);
 }
 
 MessageEmail::~MessageEmail()
 {
-    LOGD("MessageEmail destructor.");
+    LoggerD("MessageEmail destructor.");
 }
 
 // *** overrided methods
@@ -28,7 +28,7 @@ void MessageEmail::setCC(std::vector<std::string> &cc)
     m_cc = cc;
 
     if(m_cc.empty()) {
-        LOGD("Recipient's list cleared");
+        LoggerD("Recipient's list cleared");
         return;
     }
 }
@@ -39,7 +39,7 @@ void MessageEmail::setBCC(std::vector<std::string> &bcc)
     m_bcc = bcc;
 
     if(m_bcc.empty()) {
-        LOGD("Recipient's list cleared");
+        LoggerD("Recipient's list cleared");
         return;
     }
 }
@@ -60,28 +60,25 @@ void MessageEmail::setMessageAttachments(AttachmentPtrVector &attachments)
 
     m_has_attachment = true;
     if(m_attachments.empty()) {
-        LOGD("Recipient's list cleared");
+        LoggerD("Recipient's list cleared");
         m_has_attachment = false;
     }
 }
 
 bool MessageEmail::getHasAttachment() const
 {
-    LOGD("MessageEmail::getHasAttachment()");
+    LoggerD("MessageEmail::getHasAttachment()");
     return m_has_attachment || !m_body->getInlineAttachments().empty();
 }
 
 void MessageEmail::updateEmailMessage(email_mail_data_t& mail)
 {
-    LOGD("Enter");
-    std::vector<std::string> recp_list;
+    LoggerD("Enter");
 
+    std::vector<std::string> recp_list;
     setId(mail.mail_id);
-
     setFolderId(mail.mailbox_id);
-
     setConversationId(mail.thread_id);
-
     if(mail.full_address_from) {
         setFrom(MessagingUtil::extractSingleEmailAddress(mail.full_address_from));
     }
@@ -102,19 +99,18 @@ void MessageEmail::updateEmailMessage(email_mail_data_t& mail)
     }
 
     setTimeStamp(mail.date_time);
-
     setIsRead(mail.flags_seen_field);
-
     setIsHighPriority((EMAIL_MAIL_PRIORITY_HIGH == mail.priority) ? true : false);
 
     if (mail.subject == NULL) {
         LOGW("Subject is null");
     } else {
-        LOGD("Subject: %s", mail.subject);
+        LoggerD("Subject: %s", mail.subject);
         setSubject(mail.subject);
     }
 
-    getBody()->updateBody(mail);
+//    TODO fix when MesageBody will be available
+//    getBody()->updateBody(mail);
 
     if (mail.mail_id != mail.thread_id) {
         setInResponseTo(mail.thread_id);
@@ -138,10 +134,10 @@ void MessageEmail::updateEmailMessage(email_mail_data_t& mail)
             setMessageStatus(MessageStatus::STATUS_UNDEFINED);
         break;
     }
-
-    AttachmentPtrVector att = convertEmailToMessageAttachment(mail);
-
-    setMessageAttachments(att);
+//    TODO fix when Attachment will be available
+//    AttachmentPtrVector att = convertEmailToMessageAttachment(mail);
+//
+//    setMessageAttachments(att);
 }
 
 } // messaging
index e560182274d9498419d8ac9863d25906d0184ae6..2ff3f2cc50fa231cd84d63c9371b919865f7ecf4 100644 (file)
@@ -68,7 +68,6 @@ long MessageServiceEmail::sync(SyncCallbackData *callback)
 
     long op_id = EmailManager::getInstance().getUniqueOpId();
     callback->setOpId(op_id);
-    //callback->setAccountId(m_id);
 
     guint id = g_idle_add(syncTask, static_cast<void*>(callback));
     if (!id) {
index 430407f94694547ac7015ac29a0c43a6869d1083..d4c1ee8542aca489b6b70d55dbc1538699f400f3 100644 (file)
 #include "common/logger.h"
 
 #include "messaging_util.h"
+#include "message_callback_user_data.h"
 
 namespace extension {
 namespace messaging {
 
-
 class MessageStorage;
 typedef std::shared_ptr<MessageStorage> MessageStoragePtr;
 
@@ -26,7 +26,7 @@ public:
     virtual int getMsgServiceId() const;
     virtual MessageType getMsgServiceType() const;
 
-    virtual void addDraftMessage() = 0;
+    virtual void addDraftMessage(MessageCallbackUserData* callback) = 0;
     virtual void removeMessages() = 0;
     virtual void updateMessages() = 0;
     virtual void findMessages() = 0;
index 2cc03896527e1f2762425f509d53f2b742f56a57..2bc68aa28e9dd6c3ee931fbd7ab4b93bec3129e7 100644 (file)
@@ -1,9 +1,15 @@
 // Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
-
 #include "message_storage_email.h"
 
+#include <glib.h>
+
+#include "common/platform_exception.h"
+
+#include "email_manager.h"
+#include "message.h"
+
 namespace extension {
 namespace messaging {
 
@@ -18,10 +24,59 @@ MessageStorageEmail::~MessageStorageEmail()
     LoggerD("Entered");
 }
 
-void MessageStorageEmail::addDraftMessage()
+static gboolean addDraftMessageTask(void* data)
 {
     LoggerD("Entered");
-    //TODO add implementation
+
+    MessageCallbackUserData *callback = static_cast<MessageCallbackUserData*>(data);
+    EmailManager::getInstance().addDraftMessage(callback);
+
+    return FALSE;
+}
+
+static gboolean callError(void* data)
+{
+    LoggerD("Entered");
+    MessageCallbackUserData* callback =
+           static_cast<MessageCallbackUserData*>(data);
+    if (!callback) {
+       LoggerE("Callback is null");
+       return FALSE;
+    }
+
+    MessagingInstance::getInstance().PostMessage(callback->getJson()->serialize().c_str());
+
+    return FALSE;
+}
+
+void MessageStorageEmail::addDraftMessage(MessageCallbackUserData* callback) {
+    LoggerD("Entered");
+
+    if (!callback) {
+        LoggerE("Callback is null");
+        throw common::UnknownException("Callback is null");
+    }
+
+    if (m_msg_type != callback->getMessage()->getType()) {
+       LoggerE("Incorrect message type");
+       callback->setError("UnknownError", "Incorrect message type");
+       guint id = g_idle_add(callError, static_cast<void*>(callback));
+       if (!id) {
+           LoggerE("g_idle_add failed");
+           delete callback;
+           callback = NULL;
+       }
+       return;
+    }
+
+    callback->setAccountId(m_id);
+
+    guint id = g_idle_add(addDraftMessageTask, static_cast<void*>(callback));
+    if (!id) {
+        LoggerE("g_idle_add failed");
+        delete callback;
+        callback = NULL;
+    }
 }
 
 void MessageStorageEmail::removeMessages()
index 49ee8591a8f945afea9af9106ee02a69dcb817d0..842180fb14e494e9af61824ff8e2270e9d5f50fc 100644 (file)
@@ -15,7 +15,7 @@ public:
     MessageStorageEmail(int id);
     virtual ~MessageStorageEmail();
 
-    virtual void addDraftMessage();
+    virtual void addDraftMessage(MessageCallbackUserData* callback);
     virtual void removeMessages();
     virtual void updateMessages();
     virtual void findMessages();
index 7ba4641687b9879d8693500549681f2b3932d188..e4afa9dcbc46ad8972dd8930edbe8f14c676d9ad 100644 (file)
@@ -62,6 +62,8 @@
         #'DBus/SendProxy.h',
         'DBus/SyncProxy.cpp',
         'DBus/SyncProxy.h',
+        'message_callback_user_data.cc',
+        'message_callback_user_data.h'
       ],
       'includes': [
         '../common/pkg-config.gypi',
index fa29e9e447e9e3fceab4159cc566f480afafb922..9614b6319cc4e8521d31ba01e6a2aaab9d2e80c8 100644 (file)
@@ -290,7 +290,7 @@ function MessageService(data) {
     propertyFactory_(this, 'id', data.id, Property.E);
     propertyFactory_(this, 'type', data.type, Property.E);
     propertyFactory_(this, 'name', data.name, Property.E);
-    propertyFactory_(this, 'messageStorage', new MessageStorage(data.messageStorage), Property.E);
+    propertyFactory_(this, 'messageStorage', new MessageStorage(this), Property.E);
 };
 
 MessageService.prototype.sendMessage = function () {
@@ -459,7 +459,9 @@ MessageService.prototype.stopSync = function () {
     });
 };
 
-function MessageStorage() {};
+function MessageStorage(service) {
+    propertyFactory_(this, 'service', service);
+};
 
 MessageStorage.prototype.addDraftMessage = function () {
     var args = validator_.validateArgs(arguments, [
@@ -471,7 +473,8 @@ MessageStorage.prototype.addDraftMessage = function () {
     bridge.async({
         cmd: 'MessageStorage_addDraftMessage',
         args: {
-            message: args.message
+            message: args.message,
+            serviceId: this.service.id
         }
     }).then({
         success: function () {
index 2d02f6294d30d02a9b0240bc6e9f70ecb30edd23..62f032c92eeff7b24e029360664ef25053193f0a 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "messaging_manager.h"
 #include "messaging_util.h"
+#include "message_storage.h"
+#include "message.h"
 
 namespace extension {
 namespace messaging {
@@ -32,7 +34,6 @@ const char* LOAD_MESSAGE_ATTACHMENT_ARGS_ATTACHMENT = "attachment";
 const char* FUN_MESSAGE_SERVICE_SYNC = "MessageService_sync";
 const char* SERVICE_SYNC_ARGS_ID = "id";
 const char* SERVICE_SYNC_ARGS_LIMIT = "limit";
-const char* CMD_MESSAGE_SERVICE_SYNC = "sync";
 
 const char* FUN_MESSAGE_SERVICE_SYNC_FOLDER = "MessageService_syncFolder";
 const char* SYNC_FOLDER_ARGS_FOLDER = "folder";
@@ -89,6 +90,8 @@ const char* ADD_FOLDER_CHANGE_LISTENER_ARGS_FILTER = "filter";
 
 const char* FUN_MESSAGE_STORAGE_REMOVE_CHANGE_LISTENER = "MessageStorage_removeChangeListener";
 const char* REMOVE_CHANGE_LISTENER_ARGS_WATCHID = "watchId";
+
+const char* FUNCTIONS_HIDDEN_ARGS_SERVICE_ID = "serviceId";
 }
 
 MessagingInstance& MessagingInstance::getInstance()
@@ -181,7 +184,6 @@ void MessagingInstance::MessageServiceSync(const picojson::value& args,
     auto json = std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
     picojson::object& obj = json->get<picojson::object>();
     obj[JSON_CALLBACK_ID] = picojson::value(callbackId);
-    obj[JSON_CMD] = picojson::value(CMD_MESSAGE_SERVICE_SYNC);
 
     SyncCallbackData *callback = new SyncCallbackData();
     callback->setJson(json);
@@ -234,7 +236,21 @@ void MessagingInstance::MessageStorageAddDraft(const picojson::value& args,
 
     picojson::object data = args.get(JSON_DATA).get<picojson::object>();
     picojson::value v_message = data.at(ADD_DRAFT_MESSAGE_ARGS_MESSAGE);
-    LoggerD("%s", v_message.serialize().c_str());
+    const double callbackId = args.get(JSON_CALLBACK_ID).get<double>();
+
+    MessageCallbackUserData* callback = new MessageCallbackUserData();
+    callback->setMessage(MessagingUtil::jsonToMessage(v_message));
+
+    auto serviceId = static_cast<int>(data.at(FUNCTIONS_HIDDEN_ARGS_SERVICE_ID).get<double>());
+    callback->setAccountId(serviceId);
+
+    auto json = std::shared_ptr<picojson::value>(new picojson::value(picojson::object()));
+    picojson::object& obj = json->get<picojson::object>();
+    obj[JSON_CALLBACK_ID] = picojson::value(callbackId);
+    callback->setJson(json);
+
+    auto service = MessagingManager::getInstance().getMessageServiceEmail(serviceId);
+    service->getMsgStorage()->addDraftMessage(callback);
 }
 
 void MessagingInstance::MessageStorageFindMessages(const picojson::value& args,
index 6875fedaa06ad7abfda6bfa9b7259eef2e5bdd76..5b7498a27b14c4c6763d4c5564a10a6b146a9735 100755 (executable)
 namespace extension {
 namespace messaging {
 
-namespace{
-const char* CMD_GET_MSG_SERVICE = "getMessageServices";
-}
-
 MessagingManager::MessagingManager()
 {
     LoggerD("Entered");
@@ -73,7 +69,6 @@ static void* getMsgServicesThread(const std::shared_ptr<MsgManagerCallbackData>&
 
     std::shared_ptr<picojson::value> response = user_data->json;
     picojson::object& obj = response->get<picojson::object>();
-    obj[JSON_CMD] = picojson::value(CMD_GET_MSG_SERVICE);
     MessageType type = MessageType::UNDEFINED;
     try {
         type = MessagingUtil::stringToMessageType(response->get(JSON_DATA).get<std::string>());
index d7cbf1143d24b15ac1e22cd21e5902412bb8f967..b09199374df1e02aa735d1d0baac978720fbf174 100644 (file)
@@ -19,7 +19,6 @@
 namespace extension {
 namespace messaging {
 
-const char* JSON_CMD = "cmd";
 const char* JSON_ACTION = "action";
 const char* JSON_CALLBACK_ID = "cid";
 const char* JSON_CALLBACK_SUCCCESS = "success";
@@ -28,6 +27,10 @@ const char* JSON_CALLBACK_PROGRESS = "progress";
 const char* JSON_CALLBACK_KEEP = "keep";
 const char* JSON_DATA = "args";
 
+const char* JSON_RET_DATA = "data";
+const char* JSON_RET_ERR_MESSAGE = "message";
+const char* JSON_RET_ERR_NAME = "name";
+
 const char* MESSAGE_ATTRIBUTE_ID = "id";
 const char* MESSAGE_ATTRIBUTE_CONVERSATION_ID = "conversationId";
 const char* MESSAGE_ATTRIBUTE_FOLDER_ID = "folderId";
index c620e008321f20d1efa18b0d58e139d1e1984818..4c62b78c7f4733fcb3ada417d0c7b0f00ce79f7b 100644 (file)
@@ -14,7 +14,6 @@
 namespace extension {
 namespace messaging {
 
-extern const char* JSON_CMD;
 extern const char* JSON_ACTION;
 extern const char* JSON_CALLBACK_ID;
 extern const char* JSON_CALLBACK_SUCCCESS;
@@ -41,6 +40,10 @@ extern const char* MESSAGE_ATTRIBUTE_MESSAGE_STATUS;
 extern const char* MESSAGE_ATTRIBUTE_ATTACHMENTS;
 extern const char* MESSAGE_ATTRIBUTE_HAS_ATTACHMENT;
 
+extern const char* JSON_RET_DATA;
+extern const char* JSON_RET_ERR_MESSAGE;
+extern const char* JSON_RET_ERR_NAME;
+
 enum MessageType {
     UNDEFINED = 0,
     SMS,