2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "MsgCmdHandler.h"
19 #include "MsgSettingHandler.h"
20 #include "MsgUtilFunction.h"
21 #include "MsgCppTypes.h"
24 /*==================================================================================================
25 FUNCTION IMPLEMENTATION
26 ==================================================================================================*/
27 int MsgSetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent)
29 msg_error_t err = MSG_SUCCESS;
34 // Get Setting Structure
35 MSG_SETTING_S* pSetting = (MSG_SETTING_S*)pCmd->cmdData;
38 err = MsgSetConfigData(pSetting);
40 if (err == MSG_SUCCESS)
42 MSG_DEBUG("Command Handle Success : MsgSetConfigData()");
46 MSG_DEBUG("Command Handle Fail : MsgSetConfigData()");
50 switch (pCmd->cmdType) {
51 case MSG_CMD_SET_SMSC_OPT :
52 eventType = MSG_EVENT_SET_SMSC_OPT;
54 case MSG_CMD_SET_CB_OPT :
55 eventType = MSG_EVENT_SET_CB_OPT;
57 case MSG_CMD_SET_SMS_SEND_OPT :
58 eventType = MSG_EVENT_SET_SMS_SEND_OPT;
60 case MSG_CMD_SET_MMS_SEND_OPT :
61 eventType = MSG_EVENT_SET_MMS_SEND_OPT;
63 case MSG_CMD_SET_MMS_RECV_OPT :
64 eventType = MSG_EVENT_SET_MMS_RECV_OPT;
66 case MSG_CMD_SET_PUSH_MSG_OPT :
67 eventType = MSG_EVENT_SET_PUSH_MSG_OPT;
69 case MSG_CMD_SET_VOICE_MSG_OPT :
70 eventType = MSG_EVENT_SET_VOICE_MSG_OPT;
72 case MSG_CMD_SET_GENERAL_MSG_OPT :
73 eventType = MSG_EVENT_SET_GENERAL_MSG_OPT;
75 case MSG_CMD_SET_MSG_SIZE_OPT :
76 eventType = MSG_EVENT_SET_MSG_SIZE_OPT;
82 eventSize = MsgMakeEvent(NULL, 0, eventType, err, (void**)ppEvent);
88 int MsgGetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent)
90 msg_error_t err = MSG_SUCCESS;
92 char* encodedData = NULL;
93 AutoPtr<char> buf(&encodedData);
100 MSG_OPTION_TYPE_T* type = (MSG_OPTION_TYPE_T*)pCmd->cmdData;
103 MSG_SETTING_S setting;
104 setting.type = *type;
106 err = MsgGetConfigData(&setting);
108 if (err == MSG_SUCCESS)
110 MSG_DEBUG("Command Handle Success : MsgGetConfigData()");
112 // Encoding Config Data
113 switch (setting.type)
115 case MSG_GENERAL_OPT :
116 dataSize += sizeof(MSG_GENERAL_OPT_S);
118 case MSG_SMS_SENDOPT :
119 dataSize += sizeof(MSG_SMS_SENDOPT_S);
122 dataSize += sizeof(MSG_SMSC_LIST_S);
124 case MSG_MMS_SENDOPT :
125 dataSize += sizeof(MSG_MMS_SENDOPT_S);
127 case MSG_MMS_RECVOPT :
128 dataSize += sizeof(MSG_MMS_RECVOPT_S);
130 case MSG_MMS_STYLEOPT :
131 dataSize += sizeof(MSG_MMS_STYLEOPT_S);
133 case MSG_PUSHMSG_OPT :
134 dataSize += sizeof(MSG_PUSHMSG_OPT_S);
137 dataSize += sizeof(MSG_CBMSG_OPT_S);
139 case MSG_VOICEMAIL_OPT :
140 dataSize += sizeof(MSG_VOICEMAIL_OPT_S);
142 case MSG_MSGSIZE_OPT :
143 dataSize += sizeof(MSG_MSGSIZE_OPT_S);
149 encodedData = (char*)new char[dataSize];
150 void* p = (void*)encodedData;
152 switch (setting.type)
154 case MSG_GENERAL_OPT :
155 memcpy(p, &(setting.option.generalOpt), dataSize);
157 case MSG_SMS_SENDOPT :
158 memcpy(p, &(setting.option.smsSendOpt), dataSize);
161 memcpy(p, &(setting.option.smscList), dataSize);
163 case MSG_MMS_SENDOPT :
164 memcpy(p, &(setting.option.mmsSendOpt), dataSize);
166 case MSG_MMS_RECVOPT :
167 memcpy(p, &(setting.option.mmsRecvOpt), dataSize);
169 case MSG_MMS_STYLEOPT :
170 memcpy(p, &(setting.option.mmsStyleOpt), dataSize);
172 case MSG_PUSHMSG_OPT :
173 memcpy(p, &(setting.option.pushMsgOpt), dataSize);
176 memcpy(p, &(setting.option.cbMsgOpt), dataSize);
178 case MSG_VOICEMAIL_OPT :
179 memcpy(p, &(setting.option.voiceMailOpt), dataSize);
181 case MSG_MSGSIZE_OPT :
182 memcpy(p, &(setting.option.msgSizeOpt), dataSize);
188 MSG_DEBUG("Command Handle Fail : MsgGetConfigData()");
191 MSG_DEBUG("dataSize [%d]", dataSize);
193 switch (pCmd->cmdType) {
194 case MSG_CMD_GET_SMSC_OPT :
195 eventType = MSG_EVENT_GET_SMSC_OPT;
197 case MSG_CMD_GET_CB_OPT :
198 eventType = MSG_EVENT_GET_CB_OPT;
200 case MSG_CMD_GET_SMS_SEND_OPT :
201 eventType = MSG_EVENT_GET_SMS_SEND_OPT;
203 case MSG_CMD_GET_MMS_SEND_OPT :
204 eventType = MSG_EVENT_GET_MMS_SEND_OPT;
206 case MSG_CMD_GET_MMS_RECV_OPT :
207 eventType = MSG_EVENT_GET_MMS_RECV_OPT;
209 case MSG_CMD_GET_PUSH_MSG_OPT :
210 eventType = MSG_EVENT_GET_PUSH_MSG_OPT;
212 case MSG_CMD_GET_VOICE_MSG_OPT :
213 eventType = MSG_EVENT_GET_VOICE_MSG_OPT;
215 case MSG_CMD_GET_GENERAL_MSG_OPT :
216 eventType = MSG_EVENT_GET_GENERAL_MSG_OPT;
218 case MSG_CMD_GET_MSG_SIZE_OPT :
219 eventType = MSG_EVENT_GET_MSG_SIZE_OPT;
226 eventSize = MsgMakeEvent(encodedData, dataSize, eventType, err, (void**)ppEvent);