3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
32 #include "MsgUtilFunction.h"
33 #include "MsgCppTypes.h"
34 #include "MsgException.h"
35 #include "MsgHandle.h"
38 /*==================================================================================================
39 IMPLEMENTATION OF MsgHandle - Setting Member Functions
40 ==================================================================================================*/
41 MSG_ERROR_T MsgHandle::setConfig(const MSG_SETTING_S *pSetting)
43 // Allocate Memory to Command Data
44 int cmdSize = getSettingCmdSize(pSetting->type);
47 bzero(cmdBuf, cmdSize);
48 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
50 // Set Command Parameters
51 pCmd->cmdType = MSG_CMD_SET_CONFIG;
54 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
57 memcpy(pCmd->cmdData, pSetting, cmdSize-sizeof(MSG_CMD_S));
59 // Send Command to Messaging FW
60 char* pEventData = NULL;
61 AutoPtr<char> eventBuf(&pEventData);
63 write((char*)pCmd, cmdSize, &pEventData);
66 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
68 if (pEvent->eventType != MSG_EVENT_SET_CONFIG)
70 THROW(MsgException::INVALID_RESULT, "Event Data Error");
73 return pEvent->result;
77 MSG_ERROR_T MsgHandle::getConfig(MSG_SETTING_S *pSetting)
79 // Allocate Memory to Command Data
80 int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_OPTION_TYPE_T);
83 bzero(cmdBuf, cmdSize);
84 MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
86 // Set Command Parameters
87 pCmd->cmdType = MSG_CMD_GET_CONFIG;
90 memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
93 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &(pSetting->type), sizeof(MSG_OPTION_TYPE_T));
95 // Send Command to Messaging FW
96 char* pEventData = NULL;
97 AutoPtr<char> eventBuf(&pEventData);
100 write((char*)pCmd, cmdSize, &pEventData);
103 MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
105 if (pEvent->eventType != MSG_EVENT_GET_CONFIG)
107 THROW(MsgException::INVALID_RESULT, "Event Data Error");
110 if (pEvent->result == MSG_SUCCESS)
111 MsgDecodeSetting(pEvent->data, pSetting);
113 return pEvent->result;