[Messaging] getMessageServices initial C++ implementation
authorRobert Karolak <r.karolak@samsung.com>
Fri, 12 Dec 2014 08:47:56 +0000 (09:47 +0100)
committerJerzy Pabich <j.pabich@samsung.com>
Mon, 15 Dec 2014 07:01:56 +0000 (16:01 +0900)
Signed-off-by: Robert Karolak <r.karolak@samsung.com>
Change-Id: I7eb0958c507ced0fad6b607f238a4f7bd359d51b

14 files changed:
packaging/webapi-plugins.spec
src/messaging/message_service.cc [new file with mode: 0644]
src/messaging/message_service.h [new file with mode: 0755]
src/messaging/message_service_email.cc [new file with mode: 0644]
src/messaging/message_service_email.h [new file with mode: 0755]
src/messaging/messaging.gyp
src/messaging/messaging_api.js
src/messaging/messaging_extension.cc
src/messaging/messaging_instance.cc
src/messaging/messaging_instance.h
src/messaging/messaging_manager.cc [new file with mode: 0755]
src/messaging/messaging_manager.h [new file with mode: 0755]
src/messaging/messaging_util.cc [new file with mode: 0644]
src/messaging/messaging_util.h [new file with mode: 0644]

index 7c24846..60d26f9 100644 (file)
@@ -154,11 +154,13 @@ BuildRequires: pkgconfig(capi-system-power)
 BuildRequires: pkgconfig(libpcrecpp)
 BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(email-service)
 BuildRequires: pkgconfig(evas)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(libudev)
 BuildRequires: pkgconfig(message-port)
+BuildRequires: pkgconfig(msg-service)
 BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(vconf)
diff --git a/src/messaging/message_service.cc b/src/messaging/message_service.cc
new file mode 100644 (file)
index 0000000..1246ecf
--- /dev/null
@@ -0,0 +1,137 @@
+
+// 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_service.h"
+
+#include <sstream>
+
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+#include "messaging_util.h"
+
+namespace extension {
+namespace messaging {
+
+namespace{
+const char* JSON_SERVICE_ID = "id";
+const char* JSON_SERVICE_TYPE = "type";
+const char* JSON_SERVICE_NAME = "name";
+const char* JSON_SERVICE_STORAGE = "messageStorage";
+}
+
+MessageService::MessageService(int id,
+                    MessageType msgType,
+                    std::string name):
+        m_id(id),
+        m_msg_type(msgType),
+        m_name(name)
+{
+    LoggerD("Entered");
+    //FIXME MessageStorage
+    switch (msgType) {
+        case MessageType::SMS:
+        case MessageType::MMS:
+            // m_storage.reset(new MessageStorageShortMsg(id, msgType));
+            break;
+        case MessageType::EMAIL:
+            // m_storage.reset(new MessageStorageEmail(id));
+            break;
+        default:
+            LoggerE("Undefined message type");
+            throw common::InvalidValuesException("Undefined message type");
+    }
+}
+
+MessageService::~MessageService()
+{
+    LoggerD("Entered");
+}
+
+picojson::object MessageService::toPicoJS() const
+{
+    picojson::object picojs = picojson::object();
+    picojs[JSON_SERVICE_ID] = picojson::value(static_cast<double>(m_id));
+    picojs[JSON_SERVICE_TYPE] = picojson::value(MessagingUtil::messageTypeToString(m_msg_type));
+    picojs[JSON_SERVICE_NAME] = picojson::value(m_name);
+    //TODO fix when service storage object will be defined
+    picojs[JSON_SERVICE_STORAGE] = picojson::value("undefined");
+    return picojs;
+}
+
+int MessageService::getMsgServiceId() const
+{
+    return m_id;
+}
+
+std::string MessageService::getMsgServiceIdStr() const
+{
+    return std::to_string(m_id);
+}
+
+MessageType MessageService::getMsgServiceType() const
+{
+    return m_msg_type;
+}
+
+std::string MessageService::getMsgServiceName() const
+{
+    return m_name;
+}
+
+// FIXME MessageStorage
+//std::shared_ptr<MessageStorage> MessageService::getMsgStorage() const
+//{
+//    return m_storage;
+//}
+
+void MessageService::sendMessage()
+{
+    // this method should be overwritten be specific services
+    LoggerE("Cannot send message");
+    throw common::NotSupportedException("Cannot send message");
+}
+
+void MessageService::loadMessageBody()
+{
+    // this method should be overwritten by specific services
+    LoggerE("Cannot load message body");
+    throw common::NotSupportedException("Cannot load message body");
+}
+
+void MessageService::loadMessageAttachment()
+{
+    // this method should be overwritten by email service
+    // for MMS and SMS this function is not supported
+    LoggerE("Cannot load message attachment");
+    throw common::NotSupportedException("Cannot load message attachment");
+}
+
+long MessageService::sync()
+{
+    // this method should be overwritten by email service
+    // for MMS and SMS this function is not supported
+    LoggerE("Cannot sync with external server");
+    throw common::NotSupportedException("Cannot sync with external server");
+}
+
+long MessageService::syncFolder()
+{
+    // this method should be overwritten by email service
+    // for MMS and SMS this function is not supported
+    LoggerE("Cannot sync folder with external server");
+    throw common::NotSupportedException("Cannot sync folder with external server");
+}
+
+void MessageService::stopSync()
+{
+    // this method should be overwritten by email service
+    // for MMS and SMS this function is not supported
+    LoggerE("Cannot stop sync with external server");
+    throw common::NotSupportedException("Cannot stop sync with external server");
+}
+
+} // messaging
+} // extension
+
diff --git a/src/messaging/message_service.h b/src/messaging/message_service.h
new file mode 100755 (executable)
index 0000000..d430694
--- /dev/null
@@ -0,0 +1,65 @@
+
+// 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_SERVICE_H_
+#define MESSAGING_MESSAGE_SERVICE_H_
+
+#include <memory>
+#include <string>
+
+#include "common/picojson.h"
+
+#include "messaging_util.h"
+
+namespace extension {
+namespace messaging {
+
+enum MessageServiceAccountId
+{
+    UNKNOWN_ACCOUNT_ID = 0,
+    SMS_ACCOUNT_ID = 101,
+    MMS_ACCOUNT_ID = 102
+};
+
+class MessageService
+{
+public:
+    virtual ~MessageService();
+
+    virtual int getMsgServiceId() const;
+    virtual std::string getMsgServiceIdStr() const;
+    virtual MessageType getMsgServiceType() const;
+    virtual std::string getMsgServiceName() const;
+    // FIXME MessageStorage
+    // virtual std::shared_ptr<MessageStorage> getMsgStorage() const;
+
+    virtual void sendMessage();
+    virtual void loadMessageBody();
+    virtual void loadMessageAttachment();
+    virtual long sync();
+    virtual long syncFolder();
+    virtual void stopSync();
+
+    picojson::object toPicoJS() const;
+
+protected:
+    /**
+     * We have child classes MessageServiceEmail and MessageServiceShortMsg which
+     * should provide specialized implementation.
+     */
+    MessageService(int id,
+            MessageType msgType,
+            std::string name);
+
+    int m_id;
+    MessageType m_msg_type;
+    std::string m_name;
+    //FIXME
+    //std::shared_ptr<MessageStorage> m_storage;
+};
+
+} // messaging
+} // extension
+#endif // MESSAGING_MESSAGE_SERVICE_EMAIL_H_
diff --git a/src/messaging/message_service_email.cc b/src/messaging/message_service_email.cc
new file mode 100644 (file)
index 0000000..cdbe980
--- /dev/null
@@ -0,0 +1,65 @@
+
+// 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_service_email.h"
+
+#include "common/logger.h"
+
+namespace extension {
+namespace messaging {
+
+MessageServiceEmail::MessageServiceEmail(int id, std::string name)
+        : MessageService(id,
+                MessageType::EMAIL,
+                name)
+{
+    LoggerD("Entered");
+}
+
+MessageServiceEmail::~MessageServiceEmail()
+{
+    LoggerD("Entered");
+}
+
+void MessageServiceEmail::sendMessage()
+{
+    LoggerD("Entered");
+    //TODO add implementation
+}
+
+void MessageServiceEmail::loadMessageBody()
+{
+    LoggerD("Entered");
+    //TODO add implementation
+}
+
+void MessageServiceEmail::loadMessageAttachment()
+{
+    LoggerD("Entered");
+    //TODO add implementation
+}
+
+long MessageServiceEmail::sync()
+{
+    LoggerD("Entered");
+    //TODO add implementation
+    return 0;
+}
+
+long MessageServiceEmail::syncFolder()
+{
+    LoggerD("Entered");
+    //TODO add implementation
+    return 0;
+}
+
+void MessageServiceEmail::stopSync()
+{
+    LoggerD("Entered");
+    //TODO add implementation
+}
+
+} // extension
+} // messaging
+
diff --git a/src/messaging/message_service_email.h b/src/messaging/message_service_email.h
new file mode 100755 (executable)
index 0000000..b6b95be
--- /dev/null
@@ -0,0 +1,30 @@
+
+// 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_SERVICE_EMAIL_H_
+#define MESSAGING_MESSAGE_SERVICE_EMAIL_H_
+
+#include "message_service.h"
+
+namespace extension {
+namespace messaging {
+
+class MessageServiceEmail : public MessageService {
+public:
+    MessageServiceEmail(int id, std::string name);
+    virtual ~MessageServiceEmail();
+
+    virtual void sendMessage();
+    virtual void loadMessageBody();
+    virtual void loadMessageAttachment();
+    virtual long sync();
+    virtual long syncFolder();
+    virtual void stopSync();
+};
+
+} // messaging
+} // extension
+
+#endif // MESSAGING_MESSAGE_SERVICE_EMAIL_H_
index bb817aa..a74bf3e 100644 (file)
@@ -7,12 +7,28 @@
     {
       'target_name': 'tizen_messaging',
       'type': 'loadable_module',
+      'variables': {
+        'packages': [
+            'msg-service',
+            'email-service',
+            'dbus-1',
+            'dbus-glib-1'
+        ],
+      },
       'sources': [
         'messaging_api.js',
         'messaging_instance.cc',
         'messaging_instance.h',
         'messaging_extension.cc',
-        'messaging_extension.h'
+        'messaging_extension.h',
+        'messaging_manager.cc',
+        'messaging_manager.h',
+        'messaging_util.cc',
+        'messaging_util.h',
+        'message_service.cc',
+        'message_service.h',
+        'message_service_email.cc',
+        'message_service_email.h'
       ],
       'includes': [
         '../common/pkg-config.gypi',
@@ -20,8 +36,6 @@
       'conditions': [
         ['tizen == 1', {
           'variables': {
-            'packages': [
-            ]
           },
         }],
       ],
index 0d84a7e..85a7788 100644 (file)
@@ -475,7 +475,11 @@ Messaging.prototype.getMessageServices = function () {
         }
     }).then({
         success: function (data) {
-            args.successCallback.call(null, new MessageService(data));
+            var servicesArr = [];
+            data.forEach(function(e){
+                servicesArr.push(new MessageService(e));
+            });
+            args.successCallback.call(null, servicesArr);
         },
         error: function (e) {
             if (args.errorCallback) {
@@ -487,7 +491,7 @@ Messaging.prototype.getMessageServices = function () {
         }
     });
 }
-
+function MessageStorage(){};
 function MessageService(data) {
     propertyFactory_(this, 'id', data.id, Property.E);
     propertyFactory_(this, 'type', data.type, Property.E);
index 50110e8..8f83042 100644 (file)
@@ -31,5 +31,5 @@ MessagingExtension::MessagingExtension() {
 MessagingExtension::~MessagingExtension() {}
 
 common::Instance* MessagingExtension::CreateInstance() {
-  return new extension::messaging::MessagingInstance;
+  return &extension::messaging::MessagingInstance::getInstance();
 }
index 275f5e9..57875b2 100644 (file)
@@ -5,12 +5,54 @@
 
 #include "messaging_instance.h"
 
+#include <sstream>
+
+#include "common/logger.h"
+
+#include "messaging_manager.h"
+#include "messaging_util.h"
+
 namespace extension {
 namespace messaging {
 
-MessagingInstance::MessagingInstance() {}
+namespace{
+const char* FUN_MESSAGING_GET_MESSAGE_SERVICES = "Messaging_getMessageServices";
+const char* FUN_ARGS_MESSAGE_SERVICE_TYPE = "messageServiceType";
+}
+
+MessagingInstance& MessagingInstance::getInstance()
+{
+    static MessagingInstance instance;
+    return instance;
+}
+
+MessagingInstance::MessagingInstance()
+{
+    LoggerD("Entered");
+    using namespace std::placeholders;
+    #define REGISTER_ASYNC(c,x) \
+      RegisterHandler(c, std::bind(&MessagingInstance::x, this, _1, _2));
+      REGISTER_ASYNC(FUN_MESSAGING_GET_MESSAGE_SERVICES, GetMessageServices);
+    #undef REGISTER_ASYNC
+}
+
+MessagingInstance::~MessagingInstance()
+{
+    LoggerD("Entered");
+}
+
+void MessagingInstance::GetMessageServices(const picojson::value& args,
+        picojson::object& out)
+{
+    LoggerD("Entered");
+
+    picojson::object data = args.get(JSON_DATA).get<picojson::object>();
+    picojson::value serviceTag = data.at(FUN_ARGS_MESSAGE_SERVICE_TYPE);
+    const double callbackId = args.get(JSON_CALLBACK_ID).get<double>();
 
-MessagingInstance::~MessagingInstance() {}
+    // above values should be validated in js
+    MessagingManager::getInstance().getMessageServices(serviceTag.to_str(), callbackId);
+}
 
 } // namespace messaging
 } // namespace extension
index 0b41021..fc0135f 100644 (file)
@@ -12,6 +12,9 @@ namespace messaging {
 
 class MessagingInstance : public common::ParsedInstance {
     public:
+        static MessagingInstance& getInstance();
+    private:
+        void GetMessageServices(const picojson::value& args, picojson::object& out);
         MessagingInstance();
         virtual ~MessagingInstance();
 };
diff --git a/src/messaging/messaging_manager.cc b/src/messaging/messaging_manager.cc
new file mode 100755 (executable)
index 0000000..26f8b20
--- /dev/null
@@ -0,0 +1,160 @@
+// 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 "messaging_manager.h"
+
+#include <email-api.h>
+#include <email-types.h>
+#include <glib.h>
+#include <memory>
+#include <sstream>
+#include <stdexcept>
+
+#include "common/extension.h"
+#include "common/logger.h"
+#include "common/picojson.h"
+#include "common/platform_exception.h"
+#include "common/task-queue.h"
+
+#include "messaging_instance.h"
+#include "message_service_email.h"
+#include "messaging_util.h"
+
+namespace extension {
+namespace messaging {
+
+namespace{
+const char* CMD_GET_MSG_SERVICE = "getMessageServices";
+}
+
+MessagingManager::MessagingManager()
+{
+    LoggerD("Entered");
+    int ret = msg_open_msg_handle(&m_msg_handle);
+    if (ret != MSG_SUCCESS) {
+        LoggerE("Cannot get message handle: %d", ret);
+    }
+}
+
+MessagingManager::~MessagingManager()
+{
+    LoggerD("Entered");
+    int ret = msg_close_msg_handle(&m_msg_handle);
+    if (ret != MSG_SUCCESS) {
+        LoggerW("Cannot close message handle: %d", ret);
+    }
+}
+
+MessagingManager& MessagingManager::getInstance()
+{
+    LoggerD("Entered");
+    static MessagingManager instance;
+    return instance;
+}
+
+static gboolean callbackCompleted(const std::shared_ptr<picojson::value>& response)
+{
+    LoggerD("Entered");
+    std::cout<<response->serialize()<< std::endl;
+    MessagingInstance::getInstance().PostMessage(response->serialize().c_str());
+    return false;
+}
+
+static void* getMsgServicesThread(const std::shared_ptr<picojson::value>& response)
+{
+    LoggerD("Entered");
+
+    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>());
+
+        std::vector<MessageService*> msgServices;
+        MessageService* messageService = NULL;
+        email_account_t* email_accounts = NULL;
+        int count = 0;
+        bool isSupported = false;
+        switch (type) {
+        case MessageType::SMS:
+            LoggerD("Currently unsupported");
+            // TODO add class which will extended message_service and call message_service_short_msg
+            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 (email_get_account_list(&email_accounts, &count) != EMAIL_ERROR_NONE) {
+                    LoggerE("Method failed: email_get_account_list()");
+                    throw common::UnknownException("Error during getting account list");
+                }
+                else {
+                    std::stringstream stream_name;
+                    for (int i = 0; i < count; ++i) {
+                        stream_name << "[" << email_accounts[i].account_name
+                                << "] "
+                                << email_accounts[i].incoming_server_user_name;
+                        LoggerD("Account[%d/%d] id: %d, name: %s", i,
+                                count, email_accounts[i].account_id, stream_name.str().c_str());
+
+                        messageService = new (std::nothrow) MessageServiceEmail(
+                                email_accounts[i].account_id, stream_name.str());
+                        if (!messageService) {
+                            LoggerD("message service[%d] is NULL", i);
+                            unsigned int count_srvcs = msgServices.size();
+                            for (unsigned int j = 0; j < count_srvcs; ++j) {
+                                delete msgServices.at(j);
+                            }
+                            msgServices.clear();
+                            LoggerE("MessageService for email creation failed");
+                            throw common::UnknownException("MessageService for email creation failed");
+                            break;
+                        }
+                        else {
+                            msgServices.push_back(messageService);
+                        }
+                        messageService = NULL;
+                        stream_name.str("");
+                    }
+
+                    std::vector<picojson::value> response;
+                    std::for_each(msgServices.begin(), msgServices.end(),
+                        [&response](MessageService* service) {
+                              response.push_back(picojson::value(service->toPicoJS()));
+                        }
+                    );
+                    obj[JSON_DATA] = picojson::value(response);
+                    obj[JSON_ACTION] = picojson::value(JSON_CALLBACK_SUCCCESS);
+                }
+                break;
+        default:
+            LoggerE("Unsupported services type");
+            throw common::UnknownException("Unsupported services type");
+        }
+    } catch(const common::PlatformException& e) {
+          LoggerE("Unknown error");
+          obj[JSON_DATA] = e.ToJSON();
+          obj[JSON_ACTION] = picojson::value(JSON_CALLBACK_ERROR);
+    }
+
+    return nullptr;
+}
+
+void MessagingManager::getMessageServices(const std::string& type, double callbackId)
+{
+    LoggerD("Entered");
+
+    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_DATA] = picojson::value(type);
+
+    common::TaskQueue::GetInstance().Queue<picojson::value>
+        (getMsgServicesThread, callbackCompleted, json);
+}
+
+} // namespace messaging
+} // namespace extension
+
diff --git a/src/messaging/messaging_manager.h b/src/messaging/messaging_manager.h
new file mode 100755 (executable)
index 0000000..dcadf3a
--- /dev/null
@@ -0,0 +1,31 @@
+// 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_MESSAGING_MANAGER_H_
+#define MESSAGING_MESSAGING_MANAGER_H_
+
+#include <msg.h>
+#include <string>
+
+namespace extension {
+namespace messaging {
+
+class MessagingManager {
+public:
+    static MessagingManager& getInstance();
+    void getMessageServices(const std::string& type, double callbackId);
+private:
+    MessagingManager();
+    MessagingManager(const MessagingManager &);
+    void operator=(const MessagingManager &);
+    virtual ~MessagingManager();
+
+    msg_handle_t m_msg_handle;
+};
+
+} // namespace messaging
+} // namespace extension
+
+#endif // MESSAGING_MESSAGING_MANAGER_H_
+
diff --git a/src/messaging/messaging_util.cc b/src/messaging/messaging_util.cc
new file mode 100644 (file)
index 0000000..76fe7eb
--- /dev/null
@@ -0,0 +1,68 @@
+// 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 "messaging_util.h"
+
+#include <map>
+#include <stdexcept>
+
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+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";
+const char* JSON_CALLBACK_ERROR = "error";
+const char* JSON_CALLBACK_PROGRESS = "progress";
+const char* JSON_CALLBACK_KEEP = "keep";
+const char* JSON_DATA = "data";
+
+namespace {
+const std::string TYPE_SMS = "messaging.sms";
+const std::string TYPE_MMS = "messaging.mms";
+const std::string TYPE_EMAIL = "messaging.email";
+
+const std::map<std::string, MessageType> stringToTypeMap = {
+    {TYPE_SMS, MessageType::SMS},
+    {TYPE_MMS, MessageType::MMS},
+    {TYPE_EMAIL, MessageType::EMAIL}
+};
+
+const std::map<MessageType, std::string> typeToStringMap = {
+    {MessageType::SMS, TYPE_SMS},
+    {MessageType::MMS, TYPE_MMS},
+    {MessageType::EMAIL, TYPE_EMAIL}
+};
+
+}
+
+MessageType MessagingUtil::stringToMessageType(std::string str)
+{
+    try {
+        return stringToTypeMap.at(str);
+    }
+    catch (const std::out_of_range& e) {
+        std::string exceptionMsg = "Not supported type: ";
+        exceptionMsg += str;
+        LoggerE("%s", exceptionMsg.c_str());
+        throw common::TypeMismatchException(exceptionMsg.c_str());
+    }
+}
+
+std::string MessagingUtil::messageTypeToString(MessageType type)
+{
+    try {
+        return typeToStringMap.at(type);
+    }
+    catch (const std::out_of_range& e) {
+        LoggerE("Invalid MessageType");
+        throw common::TypeMismatchException("Invalid MessageType");
+    }
+}
+
+} // messaging
+} // extension
diff --git a/src/messaging/messaging_util.h b/src/messaging/messaging_util.h
new file mode 100644 (file)
index 0000000..9989716
--- /dev/null
@@ -0,0 +1,46 @@
+// 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_MESSAGING_UTIL_H_
+#define MESSAGING_MESSAGING_UTIL_H_
+
+#include <string>
+
+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;
+extern const char* JSON_CALLBACK_ERROR;
+extern const char* JSON_CALLBACK_PROGRESS;
+extern const char* JSON_CALLBACK_KEEP;
+extern const char* JSON_DATA;
+
+enum MessageType {
+    UNDEFINED = 0,
+    SMS,
+    MMS,
+    EMAIL
+};
+
+enum MessageStatus {
+    STATUS_UNDEFINED = 0,
+    STATUS_DRAFT,
+    STATUS_SENDING,
+    STATUS_SENT,
+    STATUS_LOADED,
+    STATUS_FAILED
+};
+
+class MessagingUtil {
+public:
+    static MessageType stringToMessageType(std::string);
+    static std::string messageTypeToString(MessageType);
+};
+
+} // messaging
+} // extension
+#endif // MESSAGING_MESSAGING_UTIL_H_