Modify to sync contact in transaction.
authorKeebum Kim <keebum.kim@samsung.com>
Mon, 28 Oct 2013 10:31:57 +0000 (19:31 +0900)
committerKeebum Kim <keebum.kim@samsung.com>
Mon, 28 Oct 2013 10:31:57 +0000 (19:31 +0900)
framework/transaction-manager/MsgCmdHandlerStorage.cpp
framework/transaction-manager/MsgTransManager.cpp
include/common/MsgCmdTypes.h
include/framework/MsgCmdHandler.h
packaging/msg-service.spec
utils/MsgContact.cpp

index bc80ed8..5ba9191 100755 (executable)
@@ -25,6 +25,7 @@
 #include "MsgStorageHandler.h"
 #include "MsgPluginManager.h"
 #include "MsgTransManager.h"
+#include "MsgContact.h"
 #include "MsgCmdHandler.h"
 
 
@@ -1470,3 +1471,19 @@ int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        return eventSize;
 }
+
+
+int MsgContactSyncEventHandler(const MSG_CMD_S *pCmd, char **ppEvent)
+{
+       msg_error_t err = MSG_SUCCESS;
+
+
+       int eventSize = 0;
+
+       MsgSyncContact();
+
+       // Make Event Data
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVNET_CONTACT_SYNC, err, (void**)ppEvent);
+
+       return eventSize;
+}
index f4f5bda..59e9e5d 100755 (executable)
@@ -166,6 +166,8 @@ MsgTransactionManager::MsgTransactionManager() : running(false), mx(), cv()
        handlerMap[MSG_CMD_DELETE_PUSH_EVENT] = &MsgDeletePushEventHandler;
        handlerMap[MSG_CMD_UPDATE_PUSH_EVENT] = &MsgUpdatePushEventHandler;
        handlerMap[MSG_CMD_DELETE_MESSAGE_BY_LIST] = &MsgDeleteMessageByListHandler;
+
+       handlerMap[MSG_CMD_CONTACT_SYNC] = &MsgContactSyncEventHandler;
 }
 
 
index 9c4ba1a..a05eed1 100755 (executable)
@@ -170,6 +170,7 @@ enum _MSG_CMD_TYPE_E
        MSG_CMD_UPDATE_PUSH_EVENT,
        MSG_CMD_DELETE_MESSAGE_BY_LIST,
        MSG_CMD_SET_FILTER_ACTIVATION,
+       MSG_CMD_CONTACT_SYNC,
 
 // end of MSG_CMD; new CMD should be defined before MSG_CMD_NUM
        MSG_CMD_NUM
@@ -286,6 +287,7 @@ enum _MSG_EVENT_TYPE_E
        MSG_EVENT_UPDATE_PUSH_EVENT,
        MSG_EVENT_DELETE_MESSAGE_BY_LIST,
        MSG_EVENT_SET_FILTER_ACTIVATION,
+       MSG_EVNET_CONTACT_SYNC,
 
 // end of MSG_EVENT; new EVENT should be defined before MSG_EVENT_NUM
        MSG_EVENT_NUM
index 05e6a44..3525ecc 100755 (executable)
@@ -104,5 +104,7 @@ int MsgAddPushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgDeletePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 int MsgUpdatePushEventHandler(const MSG_CMD_S *pCmd, char **ppEvent);
 
+int MsgContactSyncEventHandler(const MSG_CMD_S *pCmd, char **ppEvent);
+
 
 #endif // MSG_CMD_HANDLER_H
index e2a25b8..959abc6 100755 (executable)
@@ -1,5 +1,5 @@
 Name:           msg-service
-Version:        0.9.9
+Version:        0.9.10
 Release:        1
 License:        Flora
 Summary:        Messaging Framework Library
index ce3b54c..b4ce3fe 100755 (executable)
@@ -20,6 +20,7 @@ extern "C"
 }
 
 #include "MsgDebug.h"
+#include "MsgIpcSocket.h"
 #include "MsgUtilStorage.h"
 #include "MsgGconfWrapper.h"
 #include "MsgContact.h"
@@ -40,10 +41,34 @@ static void MsgContactSvcCallback(const char *view_uri, void *user_data)
 {
        MSG_DEBUG("Contact Data is Changed!!!");
 
-       MsgSyncContact();
+       // establish connection to msgfw daemon
+       MsgIpcClientSocket client;
+       client.connect(MSG_SOCKET_PATH);
 
-       if (ContactDbHandle.disconnect() != MSG_SUCCESS)
-               MSG_DEBUG("DB Disconnect Fail");
+       // composing command
+       int cmdSize = sizeof(MSG_CMD_S); // cmd type
+
+       char cmdBuf[cmdSize];
+       bzero(cmdBuf, cmdSize);
+
+       MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
+
+       // Set Command Parameters
+       pCmd->cmdType = MSG_CMD_CONTACT_SYNC;
+
+       memset(pCmd->cmdCookie, 0x00, MAX_COOKIE_LEN);
+
+       // Send Command to Transaction Manager
+       client.write(cmdBuf, cmdSize);
+
+       // Receive result from Transaction Manager
+       char *temp = NULL;
+       AutoPtr<char> wrap(&temp);
+       unsigned int len;
+       client.read(&temp, &len);
+
+       // close connection to msgfw daemon
+       client.close();
 }