modify code to get contact info on proxy side for search_msg and get_message_list 66/61566/1 accepted/tizen/common/20160310.074252 accepted/tizen/ivi/20160310.053916 accepted/tizen/mobile/20160310.053816 accepted/tizen/tv/20160310.053833 accepted/tizen/wearable/20160310.053853 submit/tizen/20160309.053726
authorKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 9 Mar 2016 02:27:42 +0000 (11:27 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 9 Mar 2016 02:27:42 +0000 (11:27 +0900)
Change-Id: Iaef1bd024c57446bfb1669cd47ccc63b0d9de783
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/storage-handler/MsgStorageMessage.cpp
framework/transaction-manager/MsgCmdHandlerStorage.cpp
include/framework/MsgStorageHandler.h
proxy/MsgHandleStorage.cpp

index c65d046..f3ead06 100755 (executable)
@@ -2376,22 +2376,8 @@ msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t threadId, bool bInclud
 }
 
 
-msg_error_t MsgStoSetTempAddressTable(const char *pSearchVal, int *count)
+msg_error_t MsgStoSetTempAddressTable(MSG_ADDRESS_INFO_S *pAddrInfo, int addr_cnt)
 {
-       MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
-       unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
-       *count = 0;
-
-       /* get contact search list */
-       if (MsgGetContactSearchList(pSearchVal, &pAddrInfo, count) != MSG_SUCCESS) {
-               MSG_DEBUG("MsgGetContactSearchList fail.");
-               *count = 0;
-               return MSG_SUCCESS;
-       }
-
-       if (*count == 0) {
-               return MSG_SUCCESS;
-       }
        MsgDbHandler *dbHandle = getDbHandle();
        char sqlQuery[MAX_QUERY_LEN+1];
 
@@ -2421,7 +2407,7 @@ msg_error_t MsgStoSetTempAddressTable(const char *pSearchVal, int *count)
 
        char newPhoneNum[MAX_ADDRESS_VAL_LEN+1];
        char tmpNum[MAX_ADDRESS_VAL_LEN+1];
-       for (int i = 0; i < *count; i++) {
+       for (int i = 0; i < addr_cnt; i++) {
                memset(newPhoneNum, 0x00, sizeof(newPhoneNum));
                memset(tmpNum, 0x00, sizeof(tmpNum));
                MsgConvertNumber(pAddrInfo[i].addressVal, tmpNum, sizeof(tmpNum));
index aad61f6..cb6023a 100755 (executable)
@@ -1007,26 +1007,24 @@ int MsgSetTempAddressTableHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                return 0;
        }
 
-       int search_len = 0;
-       memcpy(&search_len, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
+       int count = 0;
+       memcpy(&count, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), sizeof(int));
 
-       char search_val[search_len + 1] = {0, };
-       memcpy(&search_val, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(char)*search_len);
+       MSG_ADDRESS_INFO_S addr_info[count] = {0, };
+       memcpy(addr_info, (void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), sizeof(MSG_ADDRESS_INFO_S)*count);
 
        int eventSize = 0;
-       int count = 0;
 
-       err = MsgStoSetTempAddressTable(search_val, &count);
+       err = MsgStoSetTempAddressTable(addr_info, count);
 
        if (err == MSG_SUCCESS) {
                MSG_DEBUG("Command Handle Success : MsgStoSetTmpAddressTable()");
        } else {
                MSG_DEBUG("Command Handle Fail : MsgStoSetTmpAddressTable()");
-               count = 0;
        }
 
        /* Make Event Data */
-       eventSize = MsgMakeEvent(&count, sizeof(int), MSG_EVENT_SET_TEMP_ADDRESS_TABLE, err, (void**)ppEvent);
+       eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_SET_TEMP_ADDRESS_TABLE, err, (void**)ppEvent);
 
        MSG_END();
 
index 75cbd82..728e7fe 100755 (executable)
@@ -72,7 +72,7 @@ msg_error_t MsgStoGetMsgType(msg_message_id_t msgId, MSG_MESSAGE_TYPE_S* pMsgTyp
 msg_error_t MsgStoGetText(msg_message_id_t MsgId, char *pSubject, char *pMsgText);
 msg_error_t MsgStoGetQuickPanelData(msg_quickpanel_type_t Type, MSG_MESSAGE_INFO_S *pMsg);
 msg_error_t MsgStoDeleteThreadMessageList(msg_thread_id_t ThreadId, bool bIncludeProtect, msg_id_list_s *pMsgIdList);
-msg_error_t MsgStoSetTempAddressTable(const char *pSearchVal, int *count);
+msg_error_t MsgStoSetTempAddressTable(MSG_ADDRESS_INFO_S *pAddrInfo, int addr_cnt);
 msg_error_t MsgStoCountMsgByContact(const MSG_THREAD_LIST_INDEX_S *pAddrInfo, MSG_THREAD_COUNT_INFO_S *pThreadCountInfo);
 msg_error_t MsgStoGetSmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus);
 msg_error_t MsgStoGetMmsReportStatus(msg_message_id_t msgId, int *count, MSG_REPORT_STATUS_INFO_S **pReportStatus);
index 8ab2d4d..3602578 100755 (executable)
@@ -22,6 +22,7 @@
 #include "MsgProxyListener.h"
 #include "MsgHandle.h"
 
+#include "MsgContact.h"
 #include "MsgVMessage.h"
 /*==================================================================================================
                                      IMPLEMENTATION OF MsgHandle - Storage Member Functions
@@ -1266,42 +1267,51 @@ msg_error_t MsgHandle::searchMessage(const char *pSearchString, msg_struct_list_
 
        int count = 0;
 
-       int search_len = strlen(pSearchString);
+       MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
+       unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
 
-       /* Allocate Memory to Command Data */
-       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(char) * search_len;
+       /* get contact search list */
+       if (MsgGetContactSearchList(pSearchString, &pAddrInfo, &count) != MSG_SUCCESS) {
+               MSG_DEBUG("MsgGetContactSearchList fail.");
+               count = 0;
+       }
 
-       char cmdBuf[cmdSize];
-       bzero(cmdBuf, cmdSize);
-       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+       if (count > 0) {
+               /* Allocate Memory to Command Data */
+               int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(MSG_ADDRESS_INFO_S) * count;
 
-       /* Set Command Parameters */
-       pCmd->cmdType = MSG_CMD_SET_TEMP_ADDRESS_TABLE;
+               char cmdBuf[cmdSize];
+               bzero(cmdBuf, cmdSize);
+               MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-       /* Copy Cookie */
-       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+               /* Set Command Parameters */
+               pCmd->cmdType = MSG_CMD_SET_TEMP_ADDRESS_TABLE;
 
-       /* Copy Command Data */
-       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &search_len, sizeof(int));
-       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), pSearchString, sizeof(char) * search_len);
+               /* Copy Cookie */
+               memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-       /* Send Command to Messaging FW */
-       char* pEventData = NULL;
-       unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
+               /* Copy Command Data */
+               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &count, sizeof(int));
+               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), pAddrInfo, sizeof(MSG_ADDRESS_INFO_S) * count);
 
-       write((char*)pCmd, cmdSize, &pEventData);
+               /* Send Command to Messaging FW */
+               char* pEventData = NULL;
+               unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
-       /* Get Return Data */
-       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+               write((char*)pCmd, cmdSize, &pEventData);
 
-       if (pEvent == NULL)
-               THROW(MsgException::INVALID_RESULT, "Event is NULL");
+               /* Get Return Data */
+               MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-       if (pEvent->eventType != MSG_EVENT_SET_TEMP_ADDRESS_TABLE) {
-               THROW(MsgException::INVALID_RESULT, "Event Data Error");
-       }
+               if (pEvent == NULL)
+                       THROW(MsgException::INVALID_RESULT, "Event is NULL");
+
+               if (pEvent->eventType != MSG_EVENT_SET_TEMP_ADDRESS_TABLE)
+                       THROW(MsgException::INVALID_RESULT, "Event Data Error");
 
-       memcpy(&count, pEvent->data, sizeof(int));
+               if (pEvent->result != MSG_SUCCESS)
+                       count = 0;
+       }
 
        err = MsgStoSearchMessage(pSearchString, pThreadViewList, count);
 
@@ -1619,42 +1629,51 @@ msg_error_t MsgHandle::getMessageList(const MSG_LIST_CONDITION_S *pListCond, msg
        int count = 0;
 
        if (pListCond->pAddressVal) {
-               int address_len = strlen(pListCond->pAddressVal);
+               MSG_ADDRESS_INFO_S *pAddrInfo = NULL;
+               unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> buf(&pAddrInfo, unique_ptr_deleter);
 
-               /* Allocate Memory to Command Data */
-               int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(char) * address_len;
+               /* get contact search list */
+               if (MsgGetContactSearchList(pListCond->pAddressVal, &pAddrInfo, &count) != MSG_SUCCESS) {
+                       MSG_DEBUG("MsgGetContactSearchList fail.");
+                       count = 0;
+               }
 
-               char cmdBuf[cmdSize];
-               bzero(cmdBuf, cmdSize);
-               MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
+               if (count > 0) {
+                       /* Allocate Memory to Command Data */
+                       int cmdSize = sizeof(MSG_CMD_S) + sizeof(int) + sizeof(MSG_ADDRESS_INFO_S) * count;
 
-               /* Set Command Parameters */
-               pCmd->cmdType = MSG_CMD_SET_TEMP_ADDRESS_TABLE;
+                       char cmdBuf[cmdSize];
+                       bzero(cmdBuf, cmdSize);
+                       MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
 
-               /* Copy Cookie */
-               memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
+                       /* Set Command Parameters */
+                       pCmd->cmdType = MSG_CMD_SET_TEMP_ADDRESS_TABLE;
 
-               /* Copy Command Data */
-               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &address_len, sizeof(int));
-               memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), pListCond->pAddressVal, sizeof(char) * address_len);
+                       /* Copy Cookie */
+                       memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
 
-               /* Send Command to Messaging FW */
-               char* pEventData = NULL;
-               unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
+                       /* Copy Command Data */
+                       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &count, sizeof(int));
+                       memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(int)), pAddrInfo, sizeof(MSG_ADDRESS_INFO_S) * count);
 
-               write((char*)pCmd, cmdSize, &pEventData);
+                       /* Send Command to Messaging FW */
+                       char* pEventData = NULL;
+                       unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
-               /* Get Return Data */
-               MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
+                       write((char*)pCmd, cmdSize, &pEventData);
 
-               if (pEvent == NULL)
-                       THROW(MsgException::INVALID_RESULT, "Event is NULL");
+                       /* Get Return Data */
+                       MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
 
-               if (pEvent->eventType != MSG_EVENT_SET_TEMP_ADDRESS_TABLE) {
-                       THROW(MsgException::INVALID_RESULT, "Event Data Error");
-               }
+                       if (pEvent == NULL)
+                               THROW(MsgException::INVALID_RESULT, "Event is NULL");
+
+                       if (pEvent->eventType != MSG_EVENT_SET_TEMP_ADDRESS_TABLE)
+                               THROW(MsgException::INVALID_RESULT, "Event Data Error");
 
-               memcpy(&count, pEvent->data, sizeof(int));
+                       if (pEvent->result != MSG_SUCCESS)
+                               count = 0;
+               }
        }
 
        err = MsgStoGetMessageList(pListCond, pMsgList, count);