[Messaging] Add support for MMS messages, changes LOG to LOGGER in
authorRobert Karolak <r.karolak@samsung.com>
Tue, 13 Jan 2015 13:33:56 +0000 (14:33 +0100)
committerRobert Karolak <r.karolak@samsung.com>
Wed, 14 Jan 2015 09:48:07 +0000 (10:48 +0100)
whole messaging plugin

[Verification] Code compiles without errors, 233/309 tests passes

Change-Id: I637d250b531059683822945db68fcda4c29e9473
Signed-off-by: Robert Karolak <r.karolak@samsung.com>
16 files changed:
src/messaging/DBus/Connection.cpp
src/messaging/DBus/EmailSignalProxy.cpp
src/messaging/DBus/Proxy.cpp
src/messaging/DBus/SyncProxy.cpp
src/messaging/MsgCommon/AbstractFilter.cpp
src/messaging/MsgCommon/CompositeFilter.cpp
src/messaging/message.cc
src/messaging/message_attachment.cc
src/messaging/message_body.cc
src/messaging/message_email.cc
src/messaging/message_mms.cc [new file with mode: 0644]
src/messaging/message_mms.h [new file with mode: 0644]
src/messaging/message_service_email.cc
src/messaging/message_sms.cc
src/messaging/messaging.gyp
src/messaging/messaging_util.cc

index 6eed492685653678fcd48eacb3c2957c1b59e330..c39d01bd06e5cd1cd7c0aec1c136c283c015f449 100644 (file)
@@ -28,7 +28,7 @@ namespace DBus {
 
 Connection& Connection::getInstance()
 {
-    LOGD("Entered");
+    LoggerD("Entered");
     static Connection instance;
     return instance;
 }
index b11254bb3d5fab61856267571b593d7bf338dd4d..8f8739d51c264aba182ef4c569a38aaa4f283298 100644 (file)
@@ -64,7 +64,7 @@ void EmailSignalProxy::signalCallback(GDBusConnection* connection,
         //It is better to log this only when subclass is responsible of handling
         //passed signal (usually determined by status value).
         //
-        //LOGD("email:\n  status: %d\n  mail_id: %d\n  "
+        //LoggerD("email:\n  status: %d\n  mail_id: %d\n  "
         //        "source: %s\n  op_handle: %d\n  error_code: %d",
         //        status, mail_id, source, op_handle, error_code);
 
index fc5c6c5785d26f54467ade7e39e04350eadfa149..c7c817e2f5dc520212eb45c37e3d5108985546f8 100644 (file)
@@ -93,7 +93,7 @@ void Proxy::signalCallbackProxy(GDBusConnection *connection,
     try {
         //It is better to log this only when subclass is responsible of handling
         //passed signal. If you need it put it into your signalCallback(...) method
-        //LOGD("signal: %s from: %s path: %s interface: %s",
+        //LoggerD("signal: %s from: %s path: %s interface: %s",
         //        signal_name, sender_name, object_path, interface_name);
 
         this_ptr->signalCallback(connection, sender_name, object_path, interface_name,
index 6fd99f9f3e9d1662361c1458afae7ab49a67e92d..adc0cc858449d6a43e347191a36bbb84b1900f83 100644 (file)
@@ -104,7 +104,7 @@ void SyncProxy::handleEmailSignal(const int status,
         callback_it =  findSyncCallbackByOpHandle(op_handle);
         callback = callback_it->second;
         if (!callback) {
-            LOGE("Callback is null");
+            LoggerE("Callback is null");
             throw common::UnknownException("Callback is null");
         }
 
index 7352b10ed46473909427ccdf9d06dce8849a79f1..dd9df7b468ff060abcd8b118c3bc13a0c13233cd 100644 (file)
@@ -43,56 +43,6 @@ FilterType AbstractFilter::getFilterType() const
     return m_filter_type;
 }
 
-//JSValueRef AbstractFilter::makeJSValue(JSContextRef context,
-//        AbstractFilterPtr native)
-//{
-//    LOGD("Entered");
-//
-//    if (!native) {
-//        LOGE("Native is null");
-//        throw UnknownException("Native is null");
-//    }
-//
-//    switch (native->getFilterType()) {
-//        case ATTRIBUTE_FILTER:
-//            return JSAttributeFilter::makeJSObject(context, native);
-//        case ATTRIBUTE_RANGE_FILTER:
-//            return JSAttributeRangeFilter::makeJSObject(context, native);
-//        case COMPOSITE_FILTER:
-//            return JSCompositeFilter::makeJSObject(context, native);
-//        default:
-//            LOGE("Unsupported filter type");
-//            throw UnknownException("Unsupported filter type");
-//    }
-//}
-//
-//AbstractFilterPtr AbstractFilter::getPrivateObject(JSContextRef context,
-//        JSValueRef value)
-//{
-//    JSObjectRef object = JSUtil::JSValueToObject(context, value);
-//
-//    if (!JSValueIsObjectOfClass(context, value, JSAttributeFilter::getClassRef()) &&
-//        !JSValueIsObjectOfClass(context, value, JSAttributeRangeFilter::getClassRef()) &&
-//        !JSValueIsObjectOfClass(context, value, JSCompositeFilter::getClassRef())) {
-//        LOGE("JSObjectRef:%p - Object type is not JSAttributeFilter, "
-//                "JSAttributeRangeFilter nor JSCompositeFilter", object);
-//        throw TypeMismatchException("Object type is not valid filter");
-//    }
-//
-//    AbstractFilterHolder* priv =
-//            static_cast<AbstractFilterHolder*>(JSObjectGetPrivate(object));
-//    if (!priv) {
-//        LOGE("Holder is null");
-//        throw UnknownException("Holder is null");
-//    }
-//    if (!(priv->ptr)) {
-//        LOGE("Priv is null");
-//        throw UnknownException("Priv is null");
-//    }
-//    return priv->ptr;
-//}
-
-
 bool AbstractFilter::isMatching(const FilterableObject* const tested_object) const
 {
     LoggerE("Calling isMatching on AbstractFilter!");
index 1c4fa4e4397173b6f76c3750569bfdb59b79fa82..5ecac84d7e16d7e9ace3684dd74b191aadc43742 100644 (file)
@@ -70,7 +70,7 @@ const AbstractFilterPtrVector& CompositeFilter::getFilters() const
 //JSFilterArray CompositeFilter::getJSFilters(JSContextRef global_ctx)
 //{
 //    if (!m_context && !global_ctx) {
-//        LOGE("Context is not set");
+//        LoggerE("Context is not set");
 //        throw Common::UnknownException("Context is not set");
 //    }
 //    else if (!m_context && global_ctx) {
@@ -79,7 +79,7 @@ const AbstractFilterPtrVector& CompositeFilter::getFilters() const
 //
 //    if (!Common::GlobalContextManager::getInstance()->isAliveGlobalContext(
 //            m_context)) {
-//        LOGE("Context is not alive");
+//        LoggerE("Context is not alive");
 //        throw Common::UnknownException("Context is not alive");
 //    }
 //    else if (!m_js_filters) {
index 4a774218233d7319c6d627c042b5b73029f3693a..ac3bb480808b3a478fccf345ed0e84c3875d1b49 100644 (file)
@@ -14,6 +14,7 @@
 #include "Ecore_File.h"
 #include "message_email.h"
 #include "message_sms.h"
+#include "message_mms.h"
 #include "short_message_manager.h"
 #include "messaging_util.h"
 
@@ -332,7 +333,7 @@ std::string copyFileToTemp(const std::string& sourcePath)
     mode_t mask = umask(S_IWGRP | S_IWOTH);
     int err = mkstemp(buf);
     if (-1 == err) {
-        LOGW("Failed to create unique filename");
+        LoggerW("Failed to create unique filename");
     }
 
     umask(mask);
@@ -485,7 +486,7 @@ void addSingleEmailAttachment(std::shared_ptr<Message> message,
         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");
+            LoggerW("Failed to free attachment data");
         }
         throw common::UnknownException("Unknown error while adding attachment");
     }
@@ -494,7 +495,7 @@ void addSingleEmailAttachment(std::shared_ptr<Message> message,
     att->setMessageId(id);
     err = email_free_attachment_data(&tmp, 1);
     if (EMAIL_ERROR_NONE != err) {
-        LOGW("Failed to free attachment data");
+        LoggerW("Failed to free attachment data");
     }
 
     removeDirFromTemp(dirPath);
@@ -630,27 +631,28 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
     }
 }
 
-//void Message::addMMSBodyAndAttachmentsToStruct(const AttachmentPtrVector attach,
-//        msg_struct_t &mms_struct, Message* message)
-//{
-//    LoggerD("Entered with %d attachments", attach.size());
-//
-//    int size = attach.size();
-//    for (int i = 0; i < size; i++) {
-//
-//        msg_struct_t tmpAtt = NULL;
-//        int error = msg_list_add_item(mms_struct, MSG_STRUCT_MMS_ATTACH, &tmpAtt);
-//        if (MSG_SUCCESS == error) {
-//
-//            //Ensure we have right id set
-//            attach[i]->setId(i+1);
-//            attach[i]->setMessageId(message->getId());
-//
-//            //-------------------------------------------------------------------------
-//            // set file path, file name, file size
-//            if (attach.at(i)->isFilePathSet()) {
-//                std::string filepath = attach.at(i)->getFilePath();
-//                LoggerD("att[%d]: org filepath: %s", i, filepath.c_str());
+void Message::addMMSBodyAndAttachmentsToStruct(const AttachmentPtrVector attach,
+        msg_struct_t &mms_struct, Message* message)
+{
+    LoggerD("Entered with %d attachments", attach.size());
+
+    int size = attach.size();
+    for (int i = 0; i < size; i++) {
+
+        msg_struct_t tmpAtt = NULL;
+        int error = msg_list_add_item(mms_struct, MSG_STRUCT_MMS_ATTACH, &tmpAtt);
+        if (MSG_SUCCESS == error) {
+
+            //Ensure we have right id set
+            attach[i]->setId(i+1);
+            attach[i]->setMessageId(message->getId());
+
+            //-------------------------------------------------------------------------
+            // set file path, file name, file size
+            if (attach.at(i)->isFilePathSet()) {
+                std::string filepath = attach.at(i)->getFilePath();
+                LoggerD("att[%d]: org filepath: %s", i, filepath.c_str());
+// TODO uncomment when filesystem will be available
 //                if(Filesystem::External::isVirtualPath(filepath)) {
 //                    // TODO
 //                    // When introducing below line fromVirtualPath() function
@@ -660,45 +662,45 @@ void Message::addMMSRecipientsToStruct(const std::vector<std::string> &recipient
 //                    filepath = Filesystem::External::fromVirtualPath(filepath);
 //                    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());
-//                const size_t last_slash_idx = filepath.find_last_of("\\/");
-//                if (std::string::npos != last_slash_idx) {
-//                    filepath.erase(0, last_slash_idx + 1);
-//                }
-//
-//                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)) {
-//                    LoggerE("Stat error");
-//                }
-//                const int fsize = st.st_size;
-//                msg_set_int_value(tmpAtt, MSG_MMS_ATTACH_FILESIZE_INT, fsize);
-//                LoggerD("att[%d]: filesize: %d", i,fsize);
-//            }
-//
-//            //-------------------------------------------------------------------------
-//            //set mime type
-//            if (attach.at(i)->isMimeTypeSet()) {
-//                unsigned int type = MessageAttachment::MIMETypeStringToEnum(
-//                        attach.at(i)->getMimeType());
-//                msg_set_int_value(tmpAtt, MSG_MMS_ATTACH_MIME_TYPE_INT, type);
-//                msg_set_str_value(tmpAtt, MSG_MMS_ATTACH_CONTENT_TYPE_STR,
-//                                    const_cast<char*>(attach.at(i)->getMimeType().c_str()),
-//                                    MSG_MSG_ID_LEN);
-//
-//
-//                LoggerD("att[%d]: setting mime type:0x%x (orignal:%s)", i, type,
-//                    attach.at(i)->getMimeType().c_str());
-//            }
-//        } else {
-//            LoggerE("att[%d]: failed to add attachment");
-//            throw common::UnknownException("failed to add attachment");
-//        }
-//    }
-//}
+                msg_set_str_value(tmpAtt, MSG_MMS_ATTACH_FILEPATH_STR,
+                        const_cast<char*>(filepath.c_str()), filepath.size());
+                const size_t last_slash_idx = filepath.find_last_of("\\/");
+                if (std::string::npos != last_slash_idx) {
+                    filepath.erase(0, last_slash_idx + 1);
+                }
+
+                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)) {
+                    LoggerE("Stat error");
+                }
+                const int fsize = st.st_size;
+                msg_set_int_value(tmpAtt, MSG_MMS_ATTACH_FILESIZE_INT, fsize);
+                LoggerD("att[%d]: filesize: %d", i,fsize);
+            }
+
+            //-------------------------------------------------------------------------
+            //set mime type
+            if (attach.at(i)->isMimeTypeSet()) {
+                unsigned int type = MessageAttachment::MIMETypeStringToEnum(
+                        attach.at(i)->getMimeType());
+                msg_set_int_value(tmpAtt, MSG_MMS_ATTACH_MIME_TYPE_INT, type);
+                msg_set_str_value(tmpAtt, MSG_MMS_ATTACH_CONTENT_TYPE_STR,
+                                    const_cast<char*>(attach.at(i)->getMimeType().c_str()),
+                                    MSG_MSG_ID_LEN);
+
+
+                LoggerD("att[%d]: setting mime type:0x%x (orignal:%s)", i, type,
+                    attach.at(i)->getMimeType().c_str());
+            }
+        } else {
+            LoggerE("att[%d]: failed to add attachment");
+            throw common::UnknownException("failed to add attachment");
+        }
+    }
+}
 
 msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
         msg_handle_t handle)
@@ -798,83 +800,83 @@ msg_struct_t Message::convertPlatformShortMessageToStruct(Message* message,
             }
         }
         // Set MMS message text
-//        std::shared_ptr<MessageBody> body;
-//        body = message->getBody();
-//        if (!body->getPlainBody().empty()) {
-//            LoggerD("Message(%p): PlainBody is NOT empty", message);
-//
-//            static const int ROOT_LAYOUT_WIDTH = 100;
-//            static const int ROOT_LAYOUT_HEIGHT = 100;
-//            static const int WHITE_COLOR = 0xffffff;
-//            static const int BLACK_COLOR = 0x000000;
-//
-//            //----------------------------------------------------------------------------
-//            //Region
-//            msg_struct_t region;
-//            msg_list_add_item(mms_data, MSG_STRUCT_MMS_REGION, &region);
-//            msg_set_str_value(region, MSG_MMS_REGION_ID_STR, const_cast<char*>("Text"), 4);
-//
-//            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0);
-//            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0);
-//            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_WIDTH_INT,
-//                    ROOT_LAYOUT_WIDTH);
-//            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT,
-//                    ROOT_LAYOUT_HEIGHT);
-//            msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, WHITE_COLOR);
-//
-//            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true);
-//            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true);
-//            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true);
-//            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true);
-//
-//            //----------------------------------------------------------------------------
-//            //Page
-//            msg_struct_t page;
-//            msg_list_add_item(mms_data, MSG_STRUCT_MMS_PAGE, &page);
-//            msg_set_int_value(page, MSG_MMS_PAGE_PAGE_DURATION_INT, 0);
-//
-//            //----------------------------------------------------------------------------
-//            //Media
-//            msg_struct_t media;
-//            msg_list_add_item(page, MSG_STRUCT_MMS_MEDIA, &media);
-//            msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_TEXT);
-//            msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR,
-//                    const_cast<char*>("Text"), 4);
-//
-//            std::string body_file_path = saveToTempFile(body->getPlainBody());
-//            int error = msg_set_str_value(media,
-//                    MSG_MMS_MEDIA_FILEPATH_STR,
-//                    const_cast<char*>(body_file_path.c_str()),
-//                    body_file_path.size());
-//            if (error != MSG_SUCCESS) {
-//                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,
-//                "text/plain", 10);
-//
-//            //----------------------------------------------------------------------------
-//            //Smile text
-//            msg_struct_t smil_text;
-//            msg_get_struct_handle(media, MSG_MMS_MEDIA_SMIL_TEXT_HND, &smil_text);
-//            msg_set_int_value(smil_text, MSG_MMS_SMIL_TEXT_COLOR_INT, BLACK_COLOR);
-//            msg_set_int_value(smil_text, MSG_MMS_SMIL_TEXT_SIZE_INT,
-//                    MMS_SMIL_FONT_SIZE_NORMAL);
-//            msg_set_bool_value(smil_text, MSG_MMS_SMIL_TEXT_BOLD_BOOL, true);
-//        } else {
-//            LoggerD("Message(%p): PlainBody is EMPTY", message);
-//        }
-//        // Set MMS attachments
-//        AttachmentPtrVector attach_list = message->getMessageAttachments();
-//        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());
-//
-//        msg_set_int_value(mms_data, MSG_MESSAGE_ATTACH_COUNT_INT,
-//                attach_list.size());
-//        if (!attach_list.empty()) {
-//            addMMSBodyAndAttachmentsToStruct(attach_list, mms_data, message);
-//        }
+        std::shared_ptr<MessageBody> body;
+        body = message->getBody();
+        if (!body->getPlainBody().empty()) {
+            LoggerD("Message(%p): PlainBody is NOT empty", message);
+
+            static const int ROOT_LAYOUT_WIDTH = 100;
+            static const int ROOT_LAYOUT_HEIGHT = 100;
+            static const int WHITE_COLOR = 0xffffff;
+            static const int BLACK_COLOR = 0x000000;
+
+            //----------------------------------------------------------------------------
+            //Region
+            msg_struct_t region;
+            msg_list_add_item(mms_data, MSG_STRUCT_MMS_REGION, &region);
+            msg_set_str_value(region, MSG_MMS_REGION_ID_STR, const_cast<char*>("Text"), 4);
+
+            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0);
+            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0);
+            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_WIDTH_INT,
+                    ROOT_LAYOUT_WIDTH);
+            msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT,
+                    ROOT_LAYOUT_HEIGHT);
+            msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, WHITE_COLOR);
+
+            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true);
+            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true);
+            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true);
+            msg_set_bool_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true);
+
+            //----------------------------------------------------------------------------
+            //Page
+            msg_struct_t page;
+            msg_list_add_item(mms_data, MSG_STRUCT_MMS_PAGE, &page);
+            msg_set_int_value(page, MSG_MMS_PAGE_PAGE_DURATION_INT, 0);
+
+            //----------------------------------------------------------------------------
+            //Media
+            msg_struct_t media;
+            msg_list_add_item(page, MSG_STRUCT_MMS_MEDIA, &media);
+            msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_TEXT);
+            msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR,
+                    const_cast<char*>("Text"), 4);
+
+            std::string body_file_path = saveToTempFile(body->getPlainBody());
+            int error = msg_set_str_value(media,
+                    MSG_MMS_MEDIA_FILEPATH_STR,
+                    const_cast<char*>(body_file_path.c_str()),
+                    body_file_path.size());
+            if (error != MSG_SUCCESS) {
+                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,
+                "text/plain", 10);
+
+            //----------------------------------------------------------------------------
+            //Smile text
+            msg_struct_t smil_text;
+            msg_get_struct_handle(media, MSG_MMS_MEDIA_SMIL_TEXT_HND, &smil_text);
+            msg_set_int_value(smil_text, MSG_MMS_SMIL_TEXT_COLOR_INT, BLACK_COLOR);
+            msg_set_int_value(smil_text, MSG_MMS_SMIL_TEXT_SIZE_INT,
+                    MMS_SMIL_FONT_SIZE_NORMAL);
+            msg_set_bool_value(smil_text, MSG_MMS_SMIL_TEXT_BOLD_BOOL, true);
+        } else {
+            LoggerD("Message(%p): PlainBody is EMPTY", message);
+        }
+        // Set MMS attachments
+        AttachmentPtrVector attach_list = message->getMessageAttachments();
+        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());
+
+        msg_set_int_value(mms_data, MSG_MESSAGE_ATTACH_COUNT_INT,
+                attach_list.size());
+        if (!attach_list.empty()) {
+            addMMSBodyAndAttachmentsToStruct(attach_list, mms_data, message);
+        }
         // Set MMS body
         int r = msg_set_mms_struct(msg, mms_data);
         if (r != MSG_SUCCESS) {
@@ -1152,7 +1154,7 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
     }
 
     if(false == body_has_been_set) {
-        LOGW("Warning: body has not been set!");
+        LoggerW("Warning: body has not been set!");
     }
 
     LoggerD("after MSG_MMS_PAGE_LIST attachments count is:%d",
@@ -1171,7 +1173,7 @@ void Message::setMMSBodyAndAttachmentsFromStruct(Message* message,
             msg_struct_t attach_info = NULL;
             attach_info = (msg_struct_t) msg_list_nth_data(attach_list, i);
             if(!attach_info) {
-                LOGW("[att:%d] attach_info is NULL!", i);
+                LoggerW("[att:%d] attach_info is NULL!", i);
                 continue;
             }
 
@@ -1233,57 +1235,57 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
         std::vector<std::string> recp_list = message->getSMSRecipientsFromStruct(msg);
         message->setTO(recp_list);
     } else if (infoInt == MSG_TYPE_MMS) {
-//        message = new MessageMMS();
-//
-//        // get MMS body
-//        msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &infoInt);
-//        const int mms_body_length = infoInt;
-//
-//        if(mms_body_length > 0) {
-//            std::unique_ptr<char[]> mms_body_str(new char[mms_body_length + 1]);
-//            memset(mms_body_str.get(), 0, (mms_body_length + 1) * sizeof(char));
-//
-//            int error = msg_get_str_value(msg, MSG_MESSAGE_MMS_TEXT_STR,
-//                    mms_body_str.get(), mms_body_length);
-//            if(MSG_SUCCESS != error) {
-//                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) {
-//                    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());
-//                    std::string infoString;
-//                    infoString.assign(mms_body_str.get());
-//                    body->setPlainBody(infoString);
-//                    message->setBody(body);
-//                } else {
-//                    LOGW("Warning: fetched plain body is empty "
-//                            "despite reported length is:%d!", mms_body_length);
-//                }
-//
-//                LoggerD("Set plain body: [%s]", message->getBody()->getPlainBody().c_str());
-//            }
-//        } else {
-//            LOGW("Warning: mms plain body length is 0!");
-//        }
-//
-//        // get recipients
-//        std::vector<std::string> recp_list = getMMSRecipientsFromStruct(msg,
-//                MSG_RECIPIENTS_TYPE_TO);
-//        message->setTO(recp_list);
-//        recp_list = getMMSRecipientsFromStruct(msg, MSG_RECIPIENTS_TYPE_CC);
-//        message->setCC(recp_list);
-//        recp_list = getMMSRecipientsFromStruct(msg, MSG_RECIPIENTS_TYPE_BCC);
-//        message->setBCC(recp_list);
-//        // get subject
-//        memset(infoStr, 0, MAX_ADDRESS_VAL_LEN + 1);
-//        msg_get_str_value(msg, MSG_MESSAGE_SUBJECT_STR, infoStr, MAX_SUBJECT_LEN);
-//        message->setSubject(infoStr);
-//        //set attachments
-//        setMMSBodyAndAttachmentsFromStruct(message, msg);
+        message = new MessageMMS();
+
+        // get MMS body
+        msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &infoInt);
+        const int mms_body_length = infoInt;
+
+        if(mms_body_length > 0) {
+            std::unique_ptr<char[]> mms_body_str(new char[mms_body_length + 1]);
+            memset(mms_body_str.get(), 0, (mms_body_length + 1) * sizeof(char));
+
+            int error = msg_get_str_value(msg, MSG_MESSAGE_MMS_TEXT_STR,
+                    mms_body_str.get(), mms_body_length);
+            if(MSG_SUCCESS != error) {
+                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) {
+                    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());
+                    std::string infoString;
+                    infoString.assign(mms_body_str.get());
+                    body->setPlainBody(infoString);
+                    message->setBody(body);
+                } else {
+                    LoggerW("Warning: fetched plain body is empty "
+                            "despite reported length is:%d!", mms_body_length);
+                }
+
+                LoggerD("Set plain body: [%s]", message->getBody()->getPlainBody().c_str());
+            }
+        } else {
+            LoggerW("Warning: mms plain body length is 0!");
+        }
+
+        // get recipients
+        std::vector<std::string> recp_list = getMMSRecipientsFromStruct(msg,
+                MSG_RECIPIENTS_TYPE_TO);
+        message->setTO(recp_list);
+        recp_list = getMMSRecipientsFromStruct(msg, MSG_RECIPIENTS_TYPE_CC);
+        message->setCC(recp_list);
+        recp_list = getMMSRecipientsFromStruct(msg, MSG_RECIPIENTS_TYPE_BCC);
+        message->setBCC(recp_list);
+        // get subject
+        memset(infoStr, 0, MAX_ADDRESS_VAL_LEN + 1);
+        msg_get_str_value(msg, MSG_MESSAGE_SUBJECT_STR, infoStr, MAX_SUBJECT_LEN);
+        message->setSubject(infoStr);
+        //set attachments
+        setMMSBodyAndAttachmentsFromStruct(message, msg);
     } else {
         LoggerE("Invalid Message type: %d", infoInt);
         throw common::InvalidValuesException("Invalid Message type");
@@ -1349,7 +1351,7 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
             } else if (infoInt == MSG_NETWORK_NOT_SEND) {
                 msg_status = MessageStatus::STATUS_DRAFT;
             } else {
-                LOGW("warning undefined messageStatus: %d!", infoInt);
+                LoggerW("warning undefined messageStatus: %d!", infoInt);
                 msg_status = MessageStatus::STATUS_UNDEFINED;
             }
             message->setMessageStatus(msg_status);
@@ -1360,7 +1362,7 @@ Message* Message::convertPlatformShortMessageToObject(msg_struct_t msg){
             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 "
+                LoggerW("Both MSG_SENT_STATUS_NETWORK_STATUS_INT and "
                         "MSG_MESSAGE_FOLDER_ID_INT failed, messageId == 0 ASSUMING that"
                         "this message is in DRAFT");
                 message->setMessageStatus(MessageStatus::STATUS_DRAFT);
@@ -1459,7 +1461,7 @@ std::shared_ptr<Message> Message::convertPlatformEmailToObject(
 
 void Message::updateEmailMessage(email_mail_data_t& mail)
 {
-    LOGW("This should be called on MessageEmail instance");
+    LoggerW("This should be called on MessageEmail instance");
 }
 
 /**
index be4111a195c6e155e09fa0d0bdf7d4ddcdd2aa9f..d529af09cc53b96d7644a504091ff8433e9bd0cd 100755 (executable)
@@ -14,7 +14,7 @@ std::map<unsigned int, std::string>& MessageAttachment::MIMETypeEnumToStringMap
 
 MessageAttachment::MessageAttachment()
 {
-    LOGD("MessageAttachment constructor (%p)", this);
+    LoggerD("MessageAttachment constructor (%p)", this);
     m_id = -1;
     m_isIdSet = false;
     m_messageId = -1;
@@ -28,7 +28,7 @@ MessageAttachment::MessageAttachment()
 
 MessageAttachment::~MessageAttachment()
 {
-    LOGD("MessageAttachment destructor (%p)", this);
+    LoggerD("MessageAttachment destructor (%p)", this);
 }
 
 // id
@@ -561,8 +561,8 @@ void MessageAttachment::updateWithAttachmentData(const email_attachment_data_t&
     if (attachment_data.attachment_path) {
         setFilePath(attachment_data.attachment_path);
 
-        LOGD("save status: %d", attachment_data.save_status);
-        LOGD("attachment_size : %d", attachment_data.attachment_size);
+        LoggerD("save status: %d", attachment_data.save_status);
+        LoggerD("attachment_size : %d", attachment_data.attachment_size);
         isSaved = attachment_data.save_status;
     }
 
index 8837888a577534ad8229fb698571922cebffc83d..90ae6679df938019ed0f5752a2e60ba141355e03 100644 (file)
@@ -94,26 +94,26 @@ bool MessageBody::is_message_id_set() const
 
 void MessageBody::updateBody(email_mail_data_t& mail)
 {
-    LOGD("Enter");
+    LoggerD("Enter");
     setMessageId(mail.mail_id);
     setLoaded(mail.body_download_status);
 
     if (mail.file_path_plain) {
         try {
-            LOGD("Plain body");
+            LoggerD("Plain body");
             setPlainBody(MessagingUtil::loadFileContentToString(mail.file_path_plain));
         } catch (...) {
-            LOGE("Fail to open plain body.");
+            LoggerE("Fail to open plain body.");
             throw common::UnknownException("Fail to open plain body.");
         }
     }
 
     if (mail.file_path_html) {
         try {
-            LOGD("Html body");
+            LoggerD("Html body");
             setHtmlBody(MessagingUtil::loadFileContentToString(mail.file_path_html));
         } catch (...) {
-            LOGE("Fail to open html body.");
+            LoggerE("Fail to open html body.");
             throw common::UnknownException("Fail to open html body.");
         }
     }
index 955d74714d46dfcbd22493f15a46655e343fab63..b95765bf213646a16d70ca6ef059fb8f210b32ae 100644 (file)
@@ -103,7 +103,7 @@ void MessageEmail::updateEmailMessage(email_mail_data_t& mail)
     setIsHighPriority((EMAIL_MAIL_PRIORITY_HIGH == mail.priority) ? true : false);
 
     if (mail.subject == NULL) {
-        LOGW("Subject is null");
+        LoggerW("Subject is null");
     } else {
         LoggerD("Subject: %s", mail.subject);
         setSubject(mail.subject);
diff --git a/src/messaging/message_mms.cc b/src/messaging/message_mms.cc
new file mode 100644 (file)
index 0000000..3c26554
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        message_mm.cpp
+ */
+#include "message_mms.h"
+
+#include "common/platform_exception.h"
+#include "common/logger.h"
+
+namespace extension {
+namespace messaging {
+
+MessageMMS::MessageMMS():
+    Message()
+{
+    LoggerD("MessageMMS constructor.");
+    this->m_type = MessageType(MessageType(MMS));
+}
+
+MessageMMS::~MessageMMS()
+{
+    LoggerD("MessageMMS destructor.");
+}
+
+// *** overrided methods
+void MessageMMS::setCC(std::vector<std::string> &cc)
+{
+    // CC recipient's format validation should be done by email service
+    m_cc = cc;
+
+    if(m_cc.empty()) {
+        LoggerD("Recipient's list cleared");
+        return;
+    }
+}
+
+void MessageMMS::setBCC(std::vector<std::string> &bcc)
+{
+    // BCC recipient's format validation should be done by email service
+    m_bcc = bcc;
+
+    if(m_bcc.empty()) {
+        LoggerD("Recipient's list cleared");
+        return;
+    }
+}
+
+void MessageMMS::setSubject(std::string subject)
+{
+    m_subject = subject;
+}
+
+void MessageMMS::setMessageAttachments(AttachmentPtrVector &attachments)
+{
+    m_attachments = attachments;
+
+    m_has_attachment = true;
+    if(m_attachments.empty()) {
+        LoggerD("Recipient's list cleared");
+        m_has_attachment = false;
+    }
+}
+
+bool MessageMMS::getHasAttachment() const
+{
+    LoggerD("MessageMMS::getHasAttachment()");
+    // TODO: Analyze relation between hasAttachment flag and inlineAttachments
+    return m_has_attachment;
+}
+
+} // messaging
+} // extension
diff --git a/src/messaging/message_mms.h b/src/messaging/message_mms.h
new file mode 100644 (file)
index 0000000..cb486b7
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file        MessageMMS.h
+ */
+
+#ifndef __TIZEN_MESSAGE_MMS_H__
+#define __TIZEN_MESSAGE_MMS_H__
+
+// Header with core msg-service declarations
+#include <msg.h>
+
+#include "message.h"
+#include "message_attachment.h"
+
+namespace extension {
+namespace messaging {
+
+class MessageMMS: public Message {
+public:
+// constructor
+    MessageMMS();
+    ~MessageMMS();
+
+//overrided base class functions
+    void setCC(std::vector<std::string> &cc);
+    void setBCC(std::vector<std::string> &bcc);
+    void setSubject(std::string subject);
+    void setMessageAttachments(AttachmentPtrVector &attachments);
+
+    bool getHasAttachment() const;
+};
+
+} // messaging
+} // extension
+
+#endif // __TIZEN_MESSAGE_MMS_H__
index 93af8e0f8bea3fbf16fbd93fbc5879ef91122d4d..9566ade85ae844bd1c24b3d6ad857afa7dcc9628 100644 (file)
@@ -262,7 +262,7 @@ void MessageServiceEmail::stopSync(long op_id)
     long* data = new long(op_id);
     guint id = g_idle_add(stopSyncTask, static_cast<void*>(data));
     if (!id) {
-        LOGE("g_idle_add failed");
+        LoggerE("g_idle_add failed");
         delete data;
         data = NULL;
         throw common::UnknownException("Could not add task");
index 234b5537a3a55a350e027bfb1d74cd8466ea0c19..6e4e9fef2aaef11c926ff4dd06745015becb0a86 100644 (file)
@@ -4,9 +4,6 @@
 
 #include <iterator>
 
-#include "common/platform_exception.h"
-#include "common/logger.h"
-
 #include "message_sms.h"
 
 namespace extension {
index d9b414c06ad3707e940f03cf7d2d20903898754a..4b47560b424720ace23cb85f920ad98f692de34c 100644 (file)
         'message_storage_short_msg.cc',
         'message_storage_short_msg.h',
         'short_message_manager.cc',
-        'short_message_manager.h'
+        'short_message_manager.h',
+        'message_mms.cc',
+        'message_mms.h'
       ],
       'includes': [
         '../common/pkg-config.gypi',
index a08dc0dcdc143145c8d76b1fd8e5343410ec9677..8c70b3d2aaee472512fb9e3cc620418b6fbd06ee 100644 (file)
@@ -13,6 +13,7 @@
 #include <email-api-account.h>
 #include "message_email.h"
 #include "message_sms.h"
+#include "message_mms.h"
 #include "message_conversation.h"
 
 #include "tizen/tizen.h"
@@ -254,7 +255,7 @@ std::string MessagingUtil::loadFileContentToString(const std::string& file_path)
 }
 
 std::string MessagingUtil::messageStatusToString(MessageStatus status) {
-    LOGD("Converting MessageStatus %d to string.", (int)status);
+    LoggerD("Converting MessageStatus %d to string.", (int)status);
     switch(status) {
         case STATUS_SENT:
             return SENT;
@@ -268,7 +269,7 @@ std::string MessagingUtil::messageStatusToString(MessageStatus status) {
         // According to Web API documentation: If the status of the current
         // message does not correspond to any item from the list, an empty
         // value is returned.
-            LOGD("Unsupported or undefined MessageStatus");
+            LoggerD("Unsupported or undefined MessageStatus");
             return "";
     }
 }
@@ -297,8 +298,6 @@ picojson::value MessagingUtil::messageToJson(std::shared_ptr<Message> message)
     case MessageType::SMS:
         break;
     case MessageType::MMS:
-        LoggerD("Currently unsupported");
-        // TODO add class which will extended message_service and call message_service_short_msg
         o[MESSAGE_ATTRIBUTE_HAS_ATTACHMENT] = picojson::value(message->getHasAttachment());
         o[MESSAGE_ATTRIBUTE_SUBJECT] = picojson::value(message->getSubject());
         break;
@@ -413,11 +412,14 @@ picojson::value MessagingUtil::conversationToJson(std::shared_ptr<MessageConvers
         case MessageType::SMS:
             break;
         case MessageType::MMS:
+            o[MESSAGE_ATTRIBUTE_SUBJECT] = picojson::value(conversation->getSubject());
+            break;
         case MessageType::EMAIL:
+            o[MESSAGE_ATTRIBUTE_SUBJECT] = picojson::value(conversation->getSubject());
 
             std::vector<std::string> to = conversation->getTo();
             for_each(to.begin(), to.end(), vectorToArray);
-            o[MESSAGE_ATTRIBUTE_IN_RESPONSE_TO] = picojson::value(array);
+            o[MESSAGE_ATTRIBUTE_TO] = picojson::value(array);
             array.clear();
 
             std::vector<std::string> cc = conversation->getCC();
@@ -430,7 +432,6 @@ picojson::value MessagingUtil::conversationToJson(std::shared_ptr<MessageConvers
             o[MESSAGE_ATTRIBUTE_BCC] = picojson::value(array);
             array.clear();
 
-            o[MESSAGE_ATTRIBUTE_SUBJECT] = picojson::value(conversation->getSubject());
             break;
         }
 
@@ -472,18 +473,20 @@ std::shared_ptr<Message> MessagingUtil::jsonToMessage(const picojson::value& jso
     switch (mtype) {
     case MessageType::SMS:
         LoggerD("SMS type");
-        if (!data.at(MESSAGE_ATTRIBUTE_ID).is<picojson::null>()) {
+        if(data.at(MESSAGE_ATTRIBUTE_ID).is<picojson::null>()) {
+            message = std::shared_ptr<Message>(new MessageSMS());
+            break;
+        }
+    case MessageType::MMS:
+        LoggerD("MMS type");
+        if(data.at(MESSAGE_ATTRIBUTE_ID).is<picojson::null>()) {
+            message = std::shared_ptr<Message>(new MessageMMS());
+        } else {
             std::string mid = data.at(MESSAGE_ATTRIBUTE_ID).get<std::string>();
             int message_id = std::atoi(mid.c_str());
             message = Message::findShortMessageById(message_id);
-        } else {
-            message = std::shared_ptr<Message>(new MessageSMS());
         }
         break;
-    case MessageType::MMS:
-        LoggerD("Currently unsupported");
-        // TODO add class which will extended message_service and call message_service_short_msg
-        break;
     case MessageType::EMAIL:
         if (!data.at(MESSAGE_ATTRIBUTE_ID).is<picojson::null>()) {
             std::string mid = data.at(MESSAGE_ATTRIBUTE_ID).get<std::string>();