From 7476a658928ff1b7baa935eeb707668675d81893 Mon Sep 17 00:00:00 2001 From: Keebum Kim Date: Mon, 28 Oct 2013 19:31:57 +0900 Subject: [PATCH] Modify to sync contact in transaction. --- .../transaction-manager/MsgCmdHandlerStorage.cpp | 17 ++++++++++++ framework/transaction-manager/MsgTransManager.cpp | 2 ++ include/common/MsgCmdTypes.h | 2 ++ include/framework/MsgCmdHandler.h | 2 ++ packaging/msg-service.spec | 2 +- utils/MsgContact.cpp | 31 +++++++++++++++++++--- 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/framework/transaction-manager/MsgCmdHandlerStorage.cpp b/framework/transaction-manager/MsgCmdHandlerStorage.cpp index bc80ed8..5ba9191 100755 --- a/framework/transaction-manager/MsgCmdHandlerStorage.cpp +++ b/framework/transaction-manager/MsgCmdHandlerStorage.cpp @@ -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; +} diff --git a/framework/transaction-manager/MsgTransManager.cpp b/framework/transaction-manager/MsgTransManager.cpp index f4f5bda..59e9e5d 100755 --- a/framework/transaction-manager/MsgTransManager.cpp +++ b/framework/transaction-manager/MsgTransManager.cpp @@ -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; } diff --git a/include/common/MsgCmdTypes.h b/include/common/MsgCmdTypes.h index 9c4ba1a..a05eed1 100755 --- a/include/common/MsgCmdTypes.h +++ b/include/common/MsgCmdTypes.h @@ -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 diff --git a/include/framework/MsgCmdHandler.h b/include/framework/MsgCmdHandler.h index 05e6a44..3525ecc 100755 --- a/include/framework/MsgCmdHandler.h +++ b/include/framework/MsgCmdHandler.h @@ -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 diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec index e2a25b8..959abc6 100755 --- a/packaging/msg-service.spec +++ b/packaging/msg-service.spec @@ -1,5 +1,5 @@ Name: msg-service -Version: 0.9.9 +Version: 0.9.10 Release: 1 License: Flora Summary: Messaging Framework Library diff --git a/utils/MsgContact.cpp b/utils/MsgContact.cpp index ce3b54c..b4ce3fe 100755 --- a/utils/MsgContact.cpp +++ b/utils/MsgContact.cpp @@ -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 wrap(&temp); + unsigned int len; + client.read(&temp, &len); + + // close connection to msgfw daemon + client.close(); } -- 2.7.4