4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include "MsgCmdHandler.h"
22 #include "MsgSettingHandler.h"
23 #include "MsgUtilFunction.h"
24 #include "MsgCppTypes.h"
27 /*==================================================================================================
28 FUNCTION IMPLEMENTATION
29 ==================================================================================================*/
30 int MsgSetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent)
32 msg_error_t err = MSG_SUCCESS;
37 // Get Setting Structure
38 MSG_SETTING_S* pSetting = (MSG_SETTING_S*)pCmd->cmdData;
41 err = MsgSetConfigData(pSetting);
43 if (err == MSG_SUCCESS)
45 MSG_DEBUG("Command Handle Success : MsgSetConfigData()");
49 MSG_DEBUG("Command Handle Fail : MsgSetConfigData()");
53 switch (pCmd->cmdType) {
54 case MSG_CMD_SET_SMSC_OPT :
55 eventType = MSG_EVENT_SET_SMSC_OPT;
57 case MSG_CMD_SET_CB_OPT :
58 eventType = MSG_EVENT_SET_CB_OPT;
60 case MSG_CMD_SET_SMS_SEND_OPT :
61 eventType = MSG_EVENT_SET_SMS_SEND_OPT;
63 case MSG_CMD_SET_MMS_SEND_OPT :
64 eventType = MSG_EVENT_SET_MMS_SEND_OPT;
66 case MSG_CMD_SET_MMS_RECV_OPT :
67 eventType = MSG_EVENT_SET_MMS_RECV_OPT;
69 case MSG_CMD_SET_PUSH_MSG_OPT :
70 eventType = MSG_EVENT_SET_PUSH_MSG_OPT;
72 case MSG_CMD_SET_VOICE_MSG_OPT :
73 eventType = MSG_EVENT_SET_VOICE_MSG_OPT;
75 case MSG_CMD_SET_GENERAL_MSG_OPT :
76 eventType = MSG_EVENT_SET_GENERAL_MSG_OPT;
78 case MSG_CMD_SET_MSG_SIZE_OPT :
79 eventType = MSG_EVENT_SET_MSG_SIZE_OPT;
85 eventSize = MsgMakeEvent(NULL, 0, eventType, err, (void**)ppEvent);
91 int MsgGetConfigHandler(const MSG_CMD_S *pCmd, char **ppEvent)
93 msg_error_t err = MSG_SUCCESS;
95 char* encodedData = NULL;
96 AutoPtr<char> buf(&encodedData);
103 MSG_OPTION_TYPE_T* type = (MSG_OPTION_TYPE_T*)pCmd->cmdData;
106 MSG_SETTING_S setting;
107 setting.type = *type;
109 err = MsgGetConfigData(&setting);
111 if (err == MSG_SUCCESS)
113 MSG_DEBUG("Command Handle Success : MsgGetConfigData()");
115 // Encoding Config Data
116 switch (setting.type)
118 case MSG_GENERAL_OPT :
119 dataSize += sizeof(MSG_GENERAL_OPT_S);
121 case MSG_SMS_SENDOPT :
122 dataSize += sizeof(MSG_SMS_SENDOPT_S);
125 dataSize += sizeof(MSG_SMSC_LIST_S);
127 case MSG_MMS_SENDOPT :
128 dataSize += sizeof(MSG_MMS_SENDOPT_S);
130 case MSG_MMS_RECVOPT :
131 dataSize += sizeof(MSG_MMS_RECVOPT_S);
133 case MSG_MMS_STYLEOPT :
134 dataSize += sizeof(MSG_MMS_STYLEOPT_S);
136 case MSG_PUSHMSG_OPT :
137 dataSize += sizeof(MSG_PUSHMSG_OPT_S);
140 dataSize += sizeof(MSG_CBMSG_OPT_S);
142 case MSG_VOICEMAIL_OPT :
143 dataSize += sizeof(MSG_VOICEMAIL_OPT_S);
145 case MSG_MSGSIZE_OPT :
146 dataSize += sizeof(MSG_MSGSIZE_OPT_S);
152 encodedData = (char*)new char[dataSize];
153 void* p = (void*)encodedData;
155 switch (setting.type)
157 case MSG_GENERAL_OPT :
158 memcpy(p, &(setting.option.generalOpt), dataSize);
160 case MSG_SMS_SENDOPT :
161 memcpy(p, &(setting.option.smsSendOpt), dataSize);
164 memcpy(p, &(setting.option.smscList), dataSize);
166 case MSG_MMS_SENDOPT :
167 memcpy(p, &(setting.option.mmsSendOpt), dataSize);
169 case MSG_MMS_RECVOPT :
170 memcpy(p, &(setting.option.mmsRecvOpt), dataSize);
172 case MSG_MMS_STYLEOPT :
173 memcpy(p, &(setting.option.mmsStyleOpt), dataSize);
175 case MSG_PUSHMSG_OPT :
176 memcpy(p, &(setting.option.pushMsgOpt), dataSize);
179 memcpy(p, &(setting.option.cbMsgOpt), dataSize);
181 case MSG_VOICEMAIL_OPT :
182 memcpy(p, &(setting.option.voiceMailOpt), dataSize);
184 case MSG_MSGSIZE_OPT :
185 memcpy(p, &(setting.option.msgSizeOpt), dataSize);
191 MSG_DEBUG("Command Handle Fail : MsgGetConfigData()");
194 MSG_DEBUG("dataSize [%d]", dataSize);
196 switch (pCmd->cmdType) {
197 case MSG_CMD_GET_SMSC_OPT :
198 eventType = MSG_EVENT_GET_SMSC_OPT;
200 case MSG_CMD_GET_CB_OPT :
201 eventType = MSG_EVENT_GET_CB_OPT;
203 case MSG_CMD_GET_SMS_SEND_OPT :
204 eventType = MSG_EVENT_GET_SMS_SEND_OPT;
206 case MSG_CMD_GET_MMS_SEND_OPT :
207 eventType = MSG_EVENT_GET_MMS_SEND_OPT;
209 case MSG_CMD_GET_MMS_RECV_OPT :
210 eventType = MSG_EVENT_GET_MMS_RECV_OPT;
212 case MSG_CMD_GET_PUSH_MSG_OPT :
213 eventType = MSG_EVENT_GET_PUSH_MSG_OPT;
215 case MSG_CMD_GET_VOICE_MSG_OPT :
216 eventType = MSG_EVENT_GET_VOICE_MSG_OPT;
218 case MSG_CMD_GET_GENERAL_MSG_OPT :
219 eventType = MSG_EVENT_GET_GENERAL_MSG_OPT;
221 case MSG_CMD_GET_MSG_SIZE_OPT :
222 eventType = MSG_EVENT_GET_MSG_SIZE_OPT;
229 eventSize = MsgMakeEvent(encodedData, dataSize, eventType, err, (void**)ppEvent);