update tizen source
[framework/messaging/msg-service.git] / framework / setting-handler / MsgSettingHandler.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
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>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
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.
21 *
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.
28 *
29 */
30
31 #include "MsgDebug.h"
32 #include "MsgPluginManager.h"
33 #include "MsgSettingHandler.h"
34 #include "MsgGconfWrapper.h"
35
36
37 #define DEF_BUF_LEN     128
38
39
40 /*==================================================================================================
41                                      FUNCTION IMPLEMENTATION
42 ==================================================================================================*/
43 MSG_ERROR_T MsgInitSimConfig(MSG_SIM_STATUS_T SimStatus)
44 {
45         MSG_DEBUG("Start to initialize SIM Configuration");
46
47         MSG_ERROR_T err = MSG_SUCCESS;
48
49         if (SimStatus != MSG_SIM_STATUS_NOT_FOUND)
50         {
51                 MSG_MAIN_TYPE_T mainType = MSG_SMS_TYPE;
52                 MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(mainType);
53
54                 if (plg == NULL)
55                 {
56                         MSG_DEBUG("No plugin for %d type", mainType);
57                         return MSG_ERR_INVALID_PLUGIN_HANDLE;
58                 }
59
60                 // Check SIM Status
61                 MSG_DEBUG(" ** SIM is available - status : [%d] ** ", SimStatus);
62
63                 err = plg->initConfigData(SimStatus);
64         }
65
66         return err;
67 }
68
69
70 MSG_ERROR_T MsgSetConfigData(const MSG_SETTING_S *pSetting)
71 {
72         MSG_ERROR_T err = MSG_SUCCESS;
73
74         MSG_DEBUG("Setting Type : %d", pSetting->type);
75
76         switch (pSetting->type)
77         {
78                 case MSG_GENERAL_OPT :
79                         err = MsgSetGeneralOpt(pSetting);
80                 break;
81                 case MSG_SMS_SENDOPT :
82                         err = MsgSetSMSSendOpt(pSetting);
83                 break;
84                 case MSG_SMSC_LIST :
85                         err = MsgSetSMSCList(pSetting, true);
86                 break;
87                 case MSG_MMS_SENDOPT :
88                         err = MsgSetMMSSendOpt(pSetting);
89                 break;
90                 case MSG_MMS_RECVOPT :
91                         err = MsgSetMMSRecvOpt(pSetting);
92                 break;
93                 case MSG_MMS_STYLEOPT :
94                         err = MsgSetMMSStyleOpt(pSetting);
95                 break;
96                 case MSG_PUSHMSG_OPT :
97                         err = MsgSetPushMsgOpt(pSetting);
98                 break;
99                 case MSG_CBMSG_OPT :
100                         err = MsgSetCBMsgOpt(pSetting, true);
101                 break;
102                 case MSG_VOICEMAIL_OPT :
103                         err = MsgSetVoiceMailOpt(pSetting);
104                 break;
105                 case MSG_MSGSIZE_OPT:
106                         err = MsgSetMsgSizeOpt(pSetting);
107                 default :
108                 break;
109         }
110
111         return err;
112 }
113
114
115 MSG_ERROR_T MsgGetConfigData(MSG_SETTING_S *pSetting)
116 {
117         switch (pSetting->type)
118         {
119                 case MSG_GENERAL_OPT :
120                         MsgGetGeneralOpt(pSetting);
121                 break;
122                 case MSG_SMS_SENDOPT :
123                         MsgGetSMSSendOpt(pSetting);
124                 break;
125                 case MSG_SMSC_LIST :
126                         MsgGetSMSCList(pSetting);
127                 break;
128                 case MSG_MMS_SENDOPT :
129                         MsgGetMMSSendOpt(pSetting);
130                 break;
131                 case MSG_MMS_RECVOPT :
132                         MsgGetMMSRecvOpt(pSetting);
133                 break;
134                 case MSG_MMS_STYLEOPT :
135                         MsgGetMMSStyleOpt(pSetting);
136                 break;
137                 case MSG_PUSHMSG_OPT :
138                         MsgGetPushMsgOpt(pSetting);
139                 break;
140                 case MSG_CBMSG_OPT :
141                         MsgGetCBMsgOpt(pSetting);
142                 break;
143                 case MSG_VOICEMAIL_OPT :
144                         MsgGetVoiceMailOpt(pSetting);
145                 break;
146                 case MSG_MSGSIZE_OPT :
147                         MsgGetMsgSizeOpt(pSetting);
148                 break;
149
150                 default :
151                 break;
152         }
153
154         return MSG_SUCCESS;
155 }
156
157
158 MSG_ERROR_T MsgSetGeneralOpt(const MSG_SETTING_S *pSetting)
159 {
160         MSG_GENERAL_OPT_S generalOpt;
161         bool bValue = false;
162
163         memcpy(&generalOpt, &(pSetting->option.generalOpt), sizeof(MSG_GENERAL_OPT_S));
164
165         MsgSettingGetBool(MSG_KEEP_COPY, &bValue);
166         if (bValue != generalOpt.bKeepCopy) {
167                 if (MsgSettingSetBool(MSG_KEEP_COPY, generalOpt.bKeepCopy) != MSG_SUCCESS) {
168                         MSG_DEBUG("Error to set config data [%s]", MSG_KEEP_COPY);
169                         return MSG_ERR_SET_SETTING;
170                 }
171         }
172
173         MsgSettingGetBool(MSG_AUTO_ERASE, &bValue);
174         if (bValue != generalOpt.bAutoErase) {
175                 if (MsgSettingSetBool(MSG_AUTO_ERASE, generalOpt.bAutoErase) != MSG_SUCCESS) {
176                         MSG_DEBUG("Error to set config data [%s]", MSG_AUTO_ERASE);
177                         return MSG_ERR_SET_SETTING;
178                 }
179         }
180
181         return MSG_SUCCESS;
182 }
183
184
185 MSG_ERROR_T MsgSetSMSSendOpt(const MSG_SETTING_S *pSetting)
186 {
187         MSG_SMS_SENDOPT_S sendOpt;
188         int iValue = 0;
189         bool bValue = false;
190
191         memcpy(&sendOpt, &(pSetting->option.smsSendOpt), sizeof(MSG_SMS_SENDOPT_S));
192
193         iValue = MsgSettingGetInt(SMS_SEND_DCS);
194         if (iValue != (int)sendOpt.dcs) {
195                 if (MsgSettingSetInt(SMS_SEND_DCS, (int)sendOpt.dcs) != MSG_SUCCESS) {
196                         MSG_DEBUG("Error to set config data [%s]", SMS_SEND_DCS);
197                         return MSG_ERR_SET_SETTING;
198                 }
199         }
200
201         iValue = MsgSettingGetInt(SMS_SEND_NETWORK_MODE);
202         if (iValue != (int)sendOpt.netMode) {
203                 if (MsgSettingSetInt(SMS_SEND_NETWORK_MODE, (int)sendOpt.netMode) != MSG_SUCCESS) {
204                         MSG_DEBUG("Error to set config data [%s]", SMS_SEND_NETWORK_MODE);
205                         return MSG_ERR_SET_SETTING;
206                 }
207         }
208
209         MsgSettingGetBool(SMS_SEND_REPLY_PATH, &bValue);
210         if (bValue != sendOpt.bReplyPath) {
211                 if (MsgSettingSetBool(SMS_SEND_REPLY_PATH, sendOpt.bReplyPath) != MSG_SUCCESS) {
212                         MSG_DEBUG("Error to set config data [%s]", SMS_SEND_REPLY_PATH);
213                         return MSG_ERR_SET_SETTING;
214                 }
215         }
216
217         MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &bValue);
218         if (bValue != sendOpt.bDeliveryReport) {
219                 if (MsgSettingSetBool(SMS_SEND_DELIVERY_REPORT, sendOpt.bDeliveryReport) != MSG_SUCCESS) {
220                         MSG_DEBUG("Error to set config data [%s]", SMS_SEND_DELIVERY_REPORT);
221                         return MSG_ERR_SET_SETTING;
222                 }
223         }
224
225         iValue = MsgSettingGetInt(SMS_SEND_SAVE_STORAGE);
226         if (iValue != (int)sendOpt.saveStorage) {
227                 if (MsgSettingSetInt(SMS_SEND_SAVE_STORAGE, (int)sendOpt.saveStorage) != MSG_SUCCESS) {
228                         MSG_DEBUG("Error to set config data [%s]", SMS_SEND_SAVE_STORAGE);
229                         return MSG_ERR_SET_SETTING;
230                 }
231         }
232
233         return MSG_SUCCESS;
234 }
235
236
237 MSG_ERROR_T MsgSetSMSCList(const MSG_SETTING_S *pSetting, bool bSetSim)
238 {
239         MSG_ERROR_T err = MSG_SUCCESS;
240
241         for (int index = 0; index < pSetting->option.smscList.totalCnt; index++)
242         {
243                 if(strlen(pSetting->option.smscList.smscData[index].smscAddr.address) > SMSC_ADDR_MAX)
244                 {
245                         MSG_DEBUG("SMSC address is too long [%d]", strlen(pSetting->option.smscList.smscData[index].smscAddr.address));
246                         return MSG_ERR_SET_SIM_SET;
247                 }
248         }
249
250         if (bSetSim == true)
251         {
252                 err = MsgSetConfigInSim(pSetting);
253
254                 if (err != MSG_SUCCESS)
255                 {
256                         MSG_DEBUG("Error to set config data in sim [%d]", err);
257                         return MSG_ERR_SET_SIM_SET;
258                 }
259         }
260
261         MSG_SMSC_LIST_S smscList;
262
263         memcpy(&smscList, &(pSetting->option.smscList), sizeof(MSG_SMSC_LIST_S));
264
265         char keyName[DEF_BUF_LEN] = {0, };
266
267         // No selected SMSC Info. in SIM.
268         if (bSetSim == true)
269         {
270                 if (MsgSettingSetInt(SMSC_SELECTED, smscList.selected) != MSG_SUCCESS)
271                 {
272                         MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED);
273                         return MSG_ERR_SET_SETTING;
274                 }
275         }
276
277         if (MsgSettingSetInt(SMSC_TOTAL_COUNT, smscList.totalCnt) != MSG_SUCCESS)
278         {
279                 MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT);
280                 return MSG_ERR_SET_SETTING;
281         }
282
283         for (int i = 0; i < smscList.totalCnt; i++)
284         {
285                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_PID, i);
286
287                 if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].pid)) != MSG_SUCCESS)
288                         break;
289
290                 memset(keyName, 0x00, sizeof(keyName));
291                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i);
292
293                 if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].valPeriod)) != MSG_SUCCESS)
294                         break;
295
296                 memset(keyName, 0x00, sizeof(keyName));
297                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NAME, i);
298
299                 if ((err = MsgSettingSetString(keyName, smscList.smscData[i].name)) != MSG_SUCCESS)
300                         break;
301
302                 memset(keyName, 0x00, sizeof(keyName));
303                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_TON, i);
304
305                 if (smscList.smscData[i].smscAddr.address[0] == '+')
306                         smscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
307                 else
308                         smscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
309
310                 if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].smscAddr.ton)) != MSG_SUCCESS)
311                         break;
312
313                 memset(keyName, 0x00, sizeof(keyName));
314                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NPI, i);
315
316                 smscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
317
318                 if ((err = MsgSettingSetInt(keyName, (int)smscList.smscData[i].smscAddr.npi)) != MSG_SUCCESS)
319                         break;
320
321                 memset(keyName, 0x00, sizeof(keyName));
322                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_ADDRESS, i);
323
324                 if ((err = MsgSettingSetString(keyName, smscList.smscData[i].smscAddr.address)) != MSG_SUCCESS)
325                         break;
326         }
327
328         if (err != MSG_SUCCESS)
329         {
330                 MSG_DEBUG("Error to set config data [%s]", keyName);
331         }
332
333         return err;
334 }
335
336
337 MSG_ERROR_T MsgSetMMSSendOpt(const MSG_SETTING_S *pSetting)
338 {
339         MSG_MMS_SENDOPT_S sendOpt;
340         int iValue = 0;
341         bool bValue = false;
342
343         memcpy(&sendOpt, &(pSetting->option.mmsSendOpt), sizeof(MSG_MMS_SENDOPT_S));
344
345         iValue = MsgSettingGetInt(MMS_SEND_MSG_CLASS);
346         if (iValue != (int)sendOpt.msgClass) {
347                 if (MsgSettingSetInt(MMS_SEND_MSG_CLASS, (int)sendOpt.msgClass) != MSG_SUCCESS) {
348                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_MSG_CLASS);
349                         return MSG_ERR_SET_SETTING;
350                 }
351         }
352
353         iValue = MsgSettingGetInt(MMS_SEND_PRIORITY);
354         if (iValue != (int)sendOpt.priority) {
355                 if (MsgSettingSetInt(MMS_SEND_PRIORITY, (int)sendOpt.priority) != MSG_SUCCESS) {
356                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_PRIORITY);
357                         return MSG_ERR_SET_SETTING;
358                 }
359         }
360
361         iValue = MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
362         if (iValue != (int)sendOpt.expiryTime) {
363                 if (MsgSettingSetInt(MMS_SEND_EXPIRY_TIME, (int)sendOpt.expiryTime) != MSG_SUCCESS) {
364                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_EXPIRY_TIME);
365                         return MSG_ERR_SET_SETTING;
366                 }
367         }
368
369         iValue = MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
370         if (iValue != (int)sendOpt.deliveryTime) {
371                 if (MsgSettingSetInt(MMS_SEND_DELIVERY_TIME, (int)sendOpt.deliveryTime) != MSG_SUCCESS) {
372                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_DELIVERY_TIME);
373                         return MSG_ERR_SET_SETTING;
374                 }
375         }
376
377         iValue = MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
378         if (iValue != (int)sendOpt.customDeliveryTime) {
379                 if (MsgSettingSetInt(MMS_SEND_CUSTOM_DELIVERY, sendOpt.customDeliveryTime) != MSG_SUCCESS) {
380                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_CUSTOM_DELIVERY);
381                         return MSG_ERR_SET_SETTING;
382                 }
383         }
384
385         MsgSettingGetBool(MMS_SEND_SENDER_VISIBILITY, &bValue);
386         if (bValue != sendOpt.bSenderVisibility) {
387                 if (MsgSettingSetBool(MMS_SEND_SENDER_VISIBILITY, sendOpt.bSenderVisibility) != MSG_SUCCESS) {
388                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_SENDER_VISIBILITY);
389                         return MSG_ERR_SET_SETTING;
390                 }
391         }
392
393         MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &bValue);
394         if (bValue != sendOpt.bDeliveryReport) {
395                 if (MsgSettingSetBool(MMS_SEND_DELIVERY_REPORT, sendOpt.bDeliveryReport) != MSG_SUCCESS) {
396                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_DELIVERY_REPORT);
397                         return MSG_ERR_SET_SETTING;
398                 }
399         }
400
401         MsgSettingGetBool(MMS_SEND_READ_REPLY, &bValue);
402         if (bValue != sendOpt.bReadReply) {
403                 if (MsgSettingSetBool(MMS_SEND_READ_REPLY, sendOpt.bReadReply) != MSG_SUCCESS) {
404                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_READ_REPLY);
405                         return MSG_ERR_SET_SETTING;
406                 }
407         }
408
409         MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &bValue);
410         if (bValue != sendOpt.bBodyReplying) {
411                 if (MsgSettingSetBool(MMS_SEND_BODY_REPLYING, sendOpt.bBodyReplying) != MSG_SUCCESS) {
412                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_BODY_REPLYING);
413                         return MSG_ERR_SET_SETTING;
414                 }
415         }
416
417         MsgSettingGetBool(MMS_SEND_HIDE_RECIPIENTS, &bValue);
418         if (bValue != sendOpt.bHideRecipients) {
419                 if (MsgSettingSetBool(MMS_SEND_HIDE_RECIPIENTS, sendOpt.bHideRecipients) != MSG_SUCCESS)
420                 {
421                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_HIDE_RECIPIENTS);
422                         return MSG_ERR_SET_SETTING;
423                 }
424         }
425
426         iValue = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING);
427         if (iValue != sendOpt.replyCharging) {
428                 if (MsgSettingSetInt(MMS_SEND_REPLY_CHARGING, sendOpt.replyCharging) != MSG_SUCCESS) {
429                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_REPLY_CHARGING);
430                         return MSG_ERR_SET_SETTING;
431                 }
432         }
433
434         iValue = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_DEADLINE);
435         if (iValue != (int)sendOpt.replyChargingDeadline) {
436                 if (MsgSettingSetInt(MMS_SEND_REPLY_CHARGING_DEADLINE, sendOpt.replyChargingDeadline) != MSG_SUCCESS) {
437                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_REPLY_CHARGING_DEADLINE);
438                         return MSG_ERR_SET_SETTING;
439                 }
440         }
441
442         iValue = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_SIZE);
443         if (iValue != (int)sendOpt.replyChargingSize) {
444                 if (MsgSettingSetInt(MMS_SEND_REPLY_CHARGING_SIZE, sendOpt.replyChargingSize) != MSG_SUCCESS) {
445                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_REPLY_CHARGING_SIZE);
446                         return MSG_ERR_SET_SETTING;
447                 }
448         }
449
450         iValue = MsgSettingGetInt(MMS_SEND_CREATION_MODE);
451         if (iValue != sendOpt.creationMode) {
452                 if (MsgSettingSetInt(MMS_SEND_CREATION_MODE, sendOpt.creationMode) != MSG_SUCCESS) {
453                         MSG_DEBUG("Error to set config data [%s]", MMS_SEND_CREATION_MODE);
454                         return MSG_ERR_SET_SETTING;
455                 }
456         }
457
458         return MSG_SUCCESS;
459 }
460
461
462 MSG_ERROR_T MsgSetMMSRecvOpt(const MSG_SETTING_S *pSetting)
463 {
464         MSG_MMS_RECVOPT_S recvOpt;
465         int iValue = 0;
466         bool bValue = false;
467
468         memcpy(&recvOpt, &(pSetting->option.mmsRecvOpt), sizeof(MSG_MMS_RECVOPT_S));
469
470         iValue = MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
471         if (iValue != (int)recvOpt.homeNetwork) {
472                 if (MsgSettingSetInt(MMS_RECV_HOME_NETWORK, (int)recvOpt.homeNetwork) != MSG_SUCCESS) {
473                         MSG_DEBUG("Error to set config data [%s]", MMS_RECV_HOME_NETWORK);
474                         return MSG_ERR_SET_SETTING;
475                 }
476         }
477
478         iValue = MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
479         if (iValue != (int)recvOpt.abroadNetwok) {
480                 if (MsgSettingSetInt(MMS_RECV_ABROAD_NETWORK, (int)recvOpt.abroadNetwok) != MSG_SUCCESS) {
481                         MSG_DEBUG("Error to set config data [%s]", MMS_RECV_ABROAD_NETWORK);
482                         return MSG_ERR_SET_SETTING;
483                 }
484         }
485
486         MsgSettingGetBool(MMS_RECV_READ_RECEIPT, &bValue);
487         if (bValue != recvOpt.readReceipt) {
488                 if (MsgSettingSetBool(MMS_RECV_READ_RECEIPT, recvOpt.readReceipt) != MSG_SUCCESS) {
489                         MSG_DEBUG("Error to set config data [%s]", MMS_RECV_READ_RECEIPT);
490                         return MSG_ERR_SET_SETTING;
491                 }
492         }
493
494         MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &bValue);
495         if (bValue != recvOpt.bDeliveryReceipt) {
496                 if (MsgSettingSetBool(MMS_RECV_DELIVERY_RECEIPT, recvOpt.bDeliveryReceipt) != MSG_SUCCESS) {
497                         MSG_DEBUG("Error to set config data [%s]", MMS_RECV_DELIVERY_RECEIPT);
498                         return MSG_ERR_SET_SETTING;
499                 }
500         }
501
502         MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &bValue);
503         if (bValue != recvOpt.bRejectUnknown) {
504                 if (MsgSettingSetBool(MMS_RECV_REJECT_UNKNOWN, recvOpt.bRejectUnknown) != MSG_SUCCESS) {
505                         MSG_DEBUG("Error to set config data [%s]", MMS_RECV_REJECT_UNKNOWN);
506                         return MSG_ERR_SET_SETTING;
507                 }
508         }
509
510         MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &bValue);
511         if (bValue != recvOpt.bRejectAdvertisement) {
512                 if (MsgSettingSetBool(MMS_RECV_REJECT_ADVERTISE, recvOpt.bRejectAdvertisement) != MSG_SUCCESS) {
513                         MSG_DEBUG("Error to set config data [%s]", MMS_RECV_REJECT_ADVERTISE);
514                         return MSG_ERR_SET_SETTING;
515                 }
516         }
517
518         return MSG_SUCCESS;
519 }
520
521
522 MSG_ERROR_T MsgSetMMSStyleOpt(const MSG_SETTING_S *pSetting)
523 {
524         MSG_MMS_STYLEOPT_S styleOpt;
525         int iValue = 0;
526         bool bValue = false;
527
528         memcpy(&styleOpt, &(pSetting->option.mmsStyleOpt), sizeof(MSG_MMS_STYLEOPT_S));
529
530         iValue = MsgSettingGetInt(MMS_STYLE_FONT_SIZE);
531         if (iValue != (int)styleOpt.fontSize) {
532                 if (MsgSettingSetInt(MMS_STYLE_FONT_SIZE, styleOpt.fontSize) != MSG_SUCCESS) {
533                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_SIZE);
534                         return MSG_ERR_SET_SETTING;
535                 }
536         }
537
538         MsgSettingGetBool(MMS_STYLE_FONT_STYLE_BOLD, &bValue);
539         if (bValue != styleOpt.bFontStyleBold) {
540                 if (MsgSettingSetBool(MMS_STYLE_FONT_STYLE_BOLD, styleOpt.bFontStyleBold) != MSG_SUCCESS) {
541                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_STYLE_BOLD);
542                         return MSG_ERR_SET_SETTING;
543                 }
544         }
545
546         MsgSettingGetBool(MMS_STYLE_FONT_STYLE_ITALIC, &bValue);
547         if (bValue != styleOpt.bFontStyleItalic) {
548                 if (MsgSettingSetBool(MMS_STYLE_FONT_STYLE_ITALIC, styleOpt.bFontStyleItalic) != MSG_SUCCESS) {
549                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_STYLE_ITALIC);
550                         return MSG_ERR_SET_SETTING;
551                 }
552         }
553
554         MsgSettingGetBool(MMS_STYLE_FONT_STYLE_UNDERLINE, &bValue);
555         if (bValue != styleOpt.bFontStyleUnderline) {
556                 if (MsgSettingSetBool(MMS_STYLE_FONT_STYLE_UNDERLINE, styleOpt.bFontStyleUnderline) != MSG_SUCCESS) {
557                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_STYLE_UNDERLINE);
558                         return MSG_ERR_SET_SETTING;
559                 }
560         }
561
562         iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_RED);
563         if (iValue != (int)styleOpt.fontColorRed) {
564                 if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_RED, styleOpt.fontColorRed) != MSG_SUCCESS) {
565                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_RED);
566                         return MSG_ERR_SET_SETTING;
567                 }
568         }
569
570         iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_GREEN);
571         if (iValue != (int)styleOpt.fontColorGreen) {
572                 if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_GREEN, styleOpt.fontColorGreen) != MSG_SUCCESS) {
573                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_GREEN);
574                         return MSG_ERR_SET_SETTING;
575                 }
576         }
577
578         iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_BLUE);
579         if (iValue != (int)styleOpt.fontColorBlue) {
580                 if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_BLUE, styleOpt.fontColorBlue) != MSG_SUCCESS) {
581                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_BLUE);
582                         return MSG_ERR_SET_SETTING;
583                 }
584         }
585
586         iValue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_HUE);
587         if (iValue != (int)styleOpt.fontColorHue) {
588                 if (MsgSettingSetInt(MMS_STYLE_FONT_COLOR_HUE, styleOpt.fontColorHue) != MSG_SUCCESS) {
589                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_FONT_COLOR_HUE);
590                         return MSG_ERR_SET_SETTING;
591                 }
592         }
593
594         iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_RED);
595         if (iValue != (int)styleOpt.bgColorRed) {
596                 if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_RED, styleOpt.bgColorRed) != MSG_SUCCESS) {
597                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_RED);
598                         return MSG_ERR_SET_SETTING;
599                 }
600         }
601
602         iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_GREEN);
603         if (iValue != (int)styleOpt.bgColorGreen) {
604                 if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_GREEN, styleOpt.bgColorGreen) != MSG_SUCCESS) {
605                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_GREEN);
606                         return MSG_ERR_SET_SETTING;
607                 }
608         }
609
610         iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_BLUE);
611         if (iValue != (int)styleOpt.bgColorBlue) {
612                 if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_BLUE, styleOpt.bgColorBlue) != MSG_SUCCESS) {
613                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_BLUE);
614                         return MSG_ERR_SET_SETTING;
615                 }
616         }
617
618         iValue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_HUE);
619         if (iValue != (int)styleOpt.bgColorHue) {
620                 if (MsgSettingSetInt(MMS_STYLE_BG_COLOR_HUE, styleOpt.bgColorHue) != MSG_SUCCESS) {
621                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_BG_COLOR_HUE);
622                         return MSG_ERR_SET_SETTING;
623                 }
624         }
625
626         iValue = MsgSettingGetInt(MMS_STYLE_PAGE_DUR);
627         if (iValue != (int)styleOpt.pageDur) {
628                 if (MsgSettingSetInt(MMS_STYLE_PAGE_DUR, styleOpt.pageDur) != MSG_SUCCESS) {
629                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_PAGE_DUR);
630                         return MSG_ERR_SET_SETTING;
631                 }
632         }
633
634         iValue = MsgSettingGetInt(MMS_STYLE_PAGE_CUSTOM_DUR);
635         if (iValue != (int)styleOpt.pageCustomDur) {
636                 if (MsgSettingSetInt(MMS_STYLE_PAGE_CUSTOM_DUR, styleOpt.pageCustomDur) != MSG_SUCCESS) {
637                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_PAGE_CUSTOM_DUR);
638                         return MSG_ERR_SET_SETTING;
639                 }
640         }
641
642         iValue = MsgSettingGetInt(MMS_STYLE_PAGE_DUR_MANUAL);
643         if (iValue != (int)styleOpt.pageDurManual) {
644                 if (MsgSettingSetInt(MMS_STYLE_PAGE_DUR_MANUAL, styleOpt.pageDurManual) != MSG_SUCCESS) {
645                         MSG_DEBUG("Error to set config data [%s]", MMS_STYLE_PAGE_DUR_MANUAL);
646                         return MSG_ERR_SET_SETTING;
647                 }
648         }
649
650         return MSG_SUCCESS;
651 }
652
653 MSG_ERROR_T MsgSetPushMsgOpt(const MSG_SETTING_S *pSetting)
654 {
655         MSG_PUSHMSG_OPT_S pushOpt;
656         int iValue = 0;
657         bool bValue = false;
658
659         memcpy(&pushOpt, &(pSetting->option.pushMsgOpt), sizeof(MSG_PUSHMSG_OPT_S));
660
661         MsgSettingGetBool(PUSH_RECV_OPTION, &bValue);
662         if (bValue != pushOpt.bReceive) {
663                 if (MsgSettingSetBool(PUSH_RECV_OPTION, pushOpt.bReceive) != MSG_SUCCESS) {
664                         MSG_DEBUG("Error to set config data [%s]", PUSH_RECV_OPTION);
665                         return MSG_ERR_SET_SETTING;
666                 }
667         }
668
669         iValue = MsgSettingGetInt(PUSH_SERVICE_TYPE);
670         if (iValue != (int)pushOpt.serviceType) {
671                 if (MsgSettingSetInt(PUSH_SERVICE_TYPE, (int)pushOpt.serviceType) != MSG_SUCCESS) {
672                         MSG_DEBUG("Error to set config data [%s]", PUSH_SERVICE_TYPE);
673                         return MSG_ERR_SET_SETTING;
674                 }
675         }
676
677         return MSG_SUCCESS;
678 }
679
680
681 MSG_ERROR_T MsgSetCBMsgOpt(const MSG_SETTING_S *pSetting, bool bSetSim)
682 {
683         MSG_ERROR_T err = MSG_SUCCESS;
684
685         MSG_CBMSG_OPT_S cbOpt;
686         int iValue = 0;
687         bool bValue = false;
688
689         memcpy(&cbOpt, &(pSetting->option.cbMsgOpt), sizeof(MSG_CBMSG_OPT_S));
690
691         if (bSetSim == true)
692         {
693                 cbOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
694
695                 if (cbOpt.channelData.channelCnt > cbOpt.maxSimCnt)
696                 {
697                         MSG_DEBUG("Channel Count is over Max SIM Count [%d]", cbOpt.channelData.channelCnt);
698                         return MSG_ERR_SET_SIM_SET;
699                 }
700
701                 if (MsgSetConfigInSim(pSetting) != MSG_SUCCESS)
702                 {
703                         MSG_DEBUG("Error to set config data in sim [%d]", err);
704                         return MSG_ERR_SET_SIM_SET;
705                 }
706         }
707
708         MsgSettingGetBool(CB_RECEIVE, &bValue);
709         if (bValue != cbOpt.bReceive) {
710                 if (MsgSettingSetBool(CB_RECEIVE, cbOpt.bReceive) != MSG_SUCCESS) {
711                         MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
712                         return MSG_ERR_SET_SETTING;
713                 }
714         }
715
716         MsgSettingGetBool(CB_ALL_CHANNEL, &bValue);
717         if (bValue != cbOpt.bAllChannel) {
718                 if (MsgSettingSetBool(CB_ALL_CHANNEL, cbOpt.bAllChannel) != MSG_SUCCESS) {
719                         MSG_DEBUG("Error to set config data [%s]", CB_ALL_CHANNEL);
720                         return MSG_ERR_SET_SETTING;
721                 }
722         }
723
724         iValue = MsgSettingGetInt(CB_MAX_SIM_COUNT);
725         if (iValue != cbOpt.maxSimCnt) {
726                 if (MsgSettingSetInt(CB_MAX_SIM_COUNT, cbOpt.maxSimCnt) != MSG_SUCCESS) {
727                         MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
728                         return MSG_ERR_SET_SETTING;
729                 }
730         }
731
732         iValue = MsgSettingGetInt(CB_CHANNEL_COUNT);
733         if (iValue != cbOpt.channelData.channelCnt) {
734                 if (MsgSettingSetInt(CB_CHANNEL_COUNT, cbOpt.channelData.channelCnt) != MSG_SUCCESS) {
735                         MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
736                         return MSG_ERR_SET_SETTING;
737                 }
738         }
739
740         char keyName[DEF_BUF_LEN] = {0, };
741
742         for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
743         {
744                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ACTIVATE, i);
745
746                 if ((err = MsgSettingSetBool(keyName, cbOpt.channelData.channelInfo[i].bActivate)) != MSG_SUCCESS)
747                         break;
748
749                 memset(keyName, 0x00, sizeof(keyName));
750                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID, i);
751
752                 if ((err = MsgSettingSetInt(keyName, cbOpt.channelData.channelInfo[i].id)) != MSG_SUCCESS)
753                         break;
754
755                 memset(keyName, 0x00, sizeof(keyName));
756                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_NAME, i);
757
758                 if ((err = MsgSettingSetString(keyName, cbOpt.channelData.channelInfo[i].name)) != MSG_SUCCESS)
759                         break;
760         }
761
762         if (bSetSim == true)
763         {
764                 for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
765                 {
766                         memset(keyName, 0x00, sizeof(keyName));
767                         snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
768
769                         if (MsgSettingSetBool(keyName, cbOpt.bLanguage[i]) != MSG_SUCCESS)
770                         {
771                                 MSG_DEBUG("Error to set config data [%s]", keyName);
772                                 return MSG_ERR_SET_SETTING;
773                         }
774                 }
775         }
776
777         return err;
778 }
779
780
781 MSG_ERROR_T MsgSetVoiceMailOpt(const MSG_SETTING_S *pSetting)
782 {
783         MSG_VOICEMAIL_OPT_S voiceMailOpt;
784         char *pValue = NULL;
785
786         memcpy(&voiceMailOpt, &(pSetting->option.voiceMailOpt), sizeof(MSG_VOICEMAIL_OPT_S));
787
788         pValue = MsgSettingGetString(VOICEMAIL_NUMBER);
789         if (pValue != NULL && strcmp(pValue, voiceMailOpt.mailNumber) == 0) {
790                 /* Value is same with previous one. Therefore, we don't need to save it. */
791         } else {
792                 if (MsgSettingSetString(VOICEMAIL_NUMBER, voiceMailOpt.mailNumber) != MSG_SUCCESS) {
793                         MSG_DEBUG("Error to set config data [%s]", VOICEMAIL_NUMBER);
794
795                         if (pValue != NULL) {
796                                 free(pValue);
797                                 pValue = NULL;
798                         }
799
800                         return MSG_ERR_SET_SETTING;
801                 }
802         }
803
804         if (pValue != NULL) {
805                 free(pValue);
806                 pValue = NULL;
807         }
808
809         return MSG_SUCCESS;
810 }
811
812
813 MSG_ERROR_T MsgSetMsgSizeOpt(const MSG_SETTING_S *pSetting)
814 {
815         MSG_MSGSIZE_OPT_S msgSizeOpt;
816         int iValue = 0;
817
818         memcpy(&msgSizeOpt, &(pSetting->option.msgSizeOpt), sizeof(MSG_MSGSIZE_OPT_S));
819
820         iValue = MsgSettingGetInt(MSGSIZE_OPTION);
821         if (iValue != msgSizeOpt.nMsgSize) {
822                 if (MsgSettingSetInt(MSGSIZE_OPTION, msgSizeOpt.nMsgSize) != MSG_SUCCESS) {
823                         MSG_DEBUG("Error to set config data [%s]", MSGSIZE_OPTION);
824                         return MSG_ERR_SET_SETTING;
825                 }
826         }
827
828         return MSG_SUCCESS;
829 }
830
831
832 void MsgGetGeneralOpt(MSG_SETTING_S *pSetting)
833 {
834         memset(&(pSetting->option.generalOpt), 0x00, sizeof(MSG_GENERAL_OPT_S));
835
836         MsgSettingGetBool(MSG_KEEP_COPY, &pSetting->option.generalOpt.bKeepCopy);
837 }
838
839
840 void MsgGetSMSSendOpt(MSG_SETTING_S *pSetting)
841 {
842         memset(&(pSetting->option.smsSendOpt), 0x00, sizeof(MSG_SMS_SENDOPT_S));
843
844         pSetting->option.smsSendOpt.dcs = (MSG_ENCODE_TYPE_T)MsgSettingGetInt(SMS_SEND_DCS);
845
846         pSetting->option.smsSendOpt.netMode = (MSG_SMS_NETWORK_MODE_T)MsgSettingGetInt(SMS_SEND_NETWORK_MODE);
847
848         MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSetting->option.smsSendOpt.bReplyPath);
849
850         MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSetting->option.smsSendOpt.bDeliveryReport);
851
852         pSetting->option.smsSendOpt.saveStorage = (MSG_SMS_SAVE_STORAGE_T)MsgSettingGetInt(SMS_SEND_SAVE_STORAGE);
853 }
854
855
856 void MsgGetSMSCList(MSG_SETTING_S *pSetting)
857 {
858         char keyName[DEF_BUF_LEN] = {0, };
859         char *tmpValue = NULL;
860
861         memset(&(pSetting->option.smscList), 0x00, sizeof(MSG_SMSC_LIST_S));
862
863         pSetting->option.smscList.selected = MsgSettingGetInt(SMSC_SELECTED);
864
865         pSetting->option.smscList.totalCnt = MsgSettingGetInt(SMSC_TOTAL_COUNT);
866
867         for (int i = 0; i < pSetting->option.smscList.totalCnt; i++)
868         {
869                 memset(keyName, 0x00, sizeof(keyName));
870                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_PID, i);
871
872                 pSetting->option.smscList.smscData[i].pid = (MSG_SMS_PID_T)MsgSettingGetInt(keyName);
873
874                 memset(keyName, 0x00, sizeof(keyName));
875                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_VAL_PERIOD, i);
876
877                 pSetting->option.smscList.smscData[i].valPeriod = (MSG_VAL_PERIOD_T)MsgSettingGetInt(keyName);
878
879                 memset(keyName, 0x00, sizeof(keyName));
880                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NAME, i);
881
882                 memset(pSetting->option.smscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1);
883
884                 tmpValue = MsgSettingGetString(keyName);
885                 if (tmpValue != NULL) {
886                         strncpy(pSetting->option.smscList.smscData[i].name, tmpValue, SMSC_NAME_MAX);
887                         free(tmpValue);
888                         tmpValue = NULL;
889                 }
890
891                 memset(keyName, 0x00, sizeof(keyName));
892                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_TON, i);
893
894                 pSetting->option.smscList.smscData[i].smscAddr.ton = (MSG_SMS_TON_T)MsgSettingGetInt(keyName);
895
896                 memset(keyName, 0x00, sizeof(keyName));
897                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_NPI, i);
898
899                 pSetting->option.smscList.smscData[i].smscAddr.npi = (MSG_SMS_NPI_T)MsgSettingGetInt(keyName);
900
901                 memset(keyName, 0x00, sizeof(keyName));
902                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", SMSC_ADDRESS, i);
903
904                 memset(pSetting->option.smscList.smscData[i].smscAddr.address, 0x00, sizeof(pSetting->option.smscList.smscData[i].smscAddr.address));
905
906                 tmpValue = MsgSettingGetString(keyName);
907                 if (tmpValue != NULL) {
908                         strncpy(pSetting->option.smscList.smscData[i].smscAddr.address, tmpValue, SMSC_ADDR_MAX);
909                         free(tmpValue);
910                         tmpValue = NULL;
911                 }
912         }
913 }
914
915
916 void MsgGetMMSSendOpt(MSG_SETTING_S *pSetting)
917 {
918         memset(&(pSetting->option.mmsSendOpt), 0x00, sizeof(MSG_MMS_SENDOPT_S));
919
920         pSetting->option.mmsSendOpt.msgClass = (MSG_MMS_MSG_CLASS_TYPE_T)MsgSettingGetInt(MMS_SEND_MSG_CLASS);
921
922         pSetting->option.mmsSendOpt.priority = (MSG_PRIORITY_TYPE_T)MsgSettingGetInt(MMS_SEND_PRIORITY);
923
924         pSetting->option.mmsSendOpt.expiryTime = (MSG_MMS_EXPIRY_TIME_T)MsgSettingGetInt(MMS_SEND_EXPIRY_TIME);
925
926         pSetting->option.mmsSendOpt.deliveryTime = (MSG_MMS_DELIVERY_TIME_T)MsgSettingGetInt(MMS_SEND_DELIVERY_TIME);
927
928         pSetting->option.mmsSendOpt.customDeliveryTime = MsgSettingGetInt(MMS_SEND_CUSTOM_DELIVERY);
929
930         MsgSettingGetBool(MMS_SEND_SENDER_VISIBILITY, &pSetting->option.mmsSendOpt.bSenderVisibility);
931
932         MsgSettingGetBool(MMS_SEND_DELIVERY_REPORT, &pSetting->option.mmsSendOpt.bDeliveryReport);
933
934         MsgSettingGetBool(MMS_SEND_READ_REPLY, &pSetting->option.mmsSendOpt.bReadReply);
935
936         MsgSettingGetBool(MMS_SEND_BODY_REPLYING, &pSetting->option.mmsSendOpt.bBodyReplying);
937
938         MsgSettingGetBool(MMS_SEND_HIDE_RECIPIENTS, &pSetting->option.mmsSendOpt.bHideRecipients);
939
940         pSetting->option.mmsSendOpt.replyCharging = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING);
941
942         pSetting->option.mmsSendOpt.replyChargingDeadline = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_DEADLINE);
943
944         pSetting->option.mmsSendOpt.replyChargingSize = MsgSettingGetInt(MMS_SEND_REPLY_CHARGING_SIZE);
945
946         pSetting->option.mmsSendOpt.creationMode = MsgSettingGetInt(MMS_SEND_CREATION_MODE);
947 }
948
949
950 void MsgGetMMSRecvOpt(MSG_SETTING_S *pSetting)
951 {
952         memset(&(pSetting->option.mmsRecvOpt), 0x00, sizeof(MSG_MMS_RECVOPT_S));
953
954         pSetting->option.mmsRecvOpt.homeNetwork = (MSG_MMS_HOME_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_HOME_NETWORK);
955
956         pSetting->option.mmsRecvOpt.abroadNetwok = (MSG_MMS_ABROAD_RETRIEVE_TYPE_T)MsgSettingGetInt(MMS_RECV_ABROAD_NETWORK);
957
958         MsgSettingGetBool(MMS_RECV_READ_RECEIPT, &pSetting->option.mmsRecvOpt.readReceipt);
959
960         MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &pSetting->option.mmsRecvOpt.bDeliveryReceipt);
961
962         MsgSettingGetBool(MMS_RECV_REJECT_UNKNOWN, &pSetting->option.mmsRecvOpt.bRejectUnknown);
963
964         MsgSettingGetBool(MMS_RECV_REJECT_ADVERTISE, &pSetting->option.mmsRecvOpt.bRejectAdvertisement);
965 }
966
967
968 void MsgGetMMSStyleOpt(MSG_SETTING_S *pSetting)
969 {
970         memset(&(pSetting->option.mmsStyleOpt), 0x00, sizeof(MSG_MMS_STYLEOPT_S));
971
972         pSetting->option.mmsStyleOpt.fontSize = MsgSettingGetInt(MMS_STYLE_FONT_SIZE);
973
974         MsgSettingGetBool(MMS_STYLE_FONT_STYLE_BOLD, &pSetting->option.mmsStyleOpt.bFontStyleBold);
975
976         MsgSettingGetBool(MMS_STYLE_FONT_STYLE_ITALIC, &pSetting->option.mmsStyleOpt.bFontStyleItalic);
977
978         MsgSettingGetBool(MMS_STYLE_FONT_STYLE_UNDERLINE, &pSetting->option.mmsStyleOpt.bFontStyleUnderline);
979
980         pSetting->option.mmsStyleOpt.fontColorRed = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_RED);
981
982         pSetting->option.mmsStyleOpt.fontColorGreen = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_GREEN);
983
984         pSetting->option.mmsStyleOpt.fontColorBlue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_BLUE);
985
986         pSetting->option.mmsStyleOpt.fontColorHue = MsgSettingGetInt(MMS_STYLE_FONT_COLOR_HUE);
987
988         pSetting->option.mmsStyleOpt.bgColorRed = MsgSettingGetInt(MMS_STYLE_BG_COLOR_RED);
989
990         pSetting->option.mmsStyleOpt.bgColorGreen = MsgSettingGetInt(MMS_STYLE_BG_COLOR_GREEN);
991
992         pSetting->option.mmsStyleOpt.bgColorBlue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_BLUE);
993
994         pSetting->option.mmsStyleOpt.bgColorHue = MsgSettingGetInt(MMS_STYLE_BG_COLOR_HUE);
995
996         pSetting->option.mmsStyleOpt.pageDur = MsgSettingGetInt(MMS_STYLE_PAGE_DUR);
997
998         pSetting->option.mmsStyleOpt.pageCustomDur = MsgSettingGetInt(MMS_STYLE_PAGE_CUSTOM_DUR);
999
1000         pSetting->option.mmsStyleOpt.pageDurManual = MsgSettingGetInt(MMS_STYLE_PAGE_DUR_MANUAL);
1001 }
1002
1003
1004 void MsgGetPushMsgOpt(MSG_SETTING_S *pSetting)
1005 {
1006         memset(&(pSetting->option.pushMsgOpt), 0x00, sizeof(MSG_PUSHMSG_OPT_S));
1007
1008         MsgSettingGetBool(PUSH_RECV_OPTION, &pSetting->option.pushMsgOpt.bReceive);
1009
1010         pSetting->option.pushMsgOpt.serviceType = (MSG_PUSH_SERVICE_TYPE_T)MsgSettingGetInt(PUSH_SERVICE_TYPE);
1011 }
1012
1013
1014 void MsgGetCBMsgOpt(MSG_SETTING_S *pSetting)
1015 {
1016         char keyName[DEF_BUF_LEN] = {0, };
1017         char *tmpValue = NULL;
1018
1019         memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
1020
1021         MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive);
1022
1023         MsgSettingGetBool(CB_ALL_CHANNEL, &pSetting->option.cbMsgOpt.bAllChannel);
1024
1025         pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
1026
1027         pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
1028
1029         for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++)
1030         {
1031                 memset(keyName, 0x00, sizeof(keyName));
1032                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ACTIVATE, i);
1033
1034                 MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.channelData.channelInfo[i].bActivate);
1035
1036                 memset(keyName, 0x00, sizeof(keyName));
1037                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_ID, i);
1038
1039                 pSetting->option.cbMsgOpt.channelData.channelInfo[i].id = MsgSettingGetInt(keyName);
1040
1041                 memset(keyName, 0x00, sizeof(keyName));
1042                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_CHANNEL_NAME, i);
1043
1044                 tmpValue = MsgSettingGetString(keyName);
1045                 if (tmpValue != NULL) {
1046                         strncpy(pSetting->option.cbMsgOpt.channelData.channelInfo[i].name, tmpValue, CB_CHANNEL_NAME_MAX);
1047                         free(tmpValue);
1048                         tmpValue = NULL;
1049                 }
1050         }
1051
1052         for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++)
1053         {
1054                 memset(keyName, 0x00, sizeof(keyName));
1055                 snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
1056
1057                 MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]);
1058         }
1059 }
1060
1061
1062 void MsgGetVoiceMailOpt(MSG_SETTING_S *pSetting)
1063 {
1064         char *tmpValue = NULL;
1065
1066         memset(&(pSetting->option.voiceMailOpt), 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
1067
1068         tmpValue = MsgSettingGetString(VOICEMAIL_NUMBER);
1069         if (tmpValue != NULL) {
1070                 strncpy(pSetting->option.voiceMailOpt.mailNumber, tmpValue, MAX_PHONE_NUMBER_LEN);
1071                 free(tmpValue);
1072                 tmpValue = NULL;
1073         }
1074 }
1075
1076
1077 void MsgGetMsgSizeOpt(MSG_SETTING_S *pSetting)
1078 {
1079         memset(&(pSetting->option.msgSizeOpt), 0x00, sizeof(MSG_MSGSIZE_OPT_S));
1080
1081         pSetting->option.msgSizeOpt.nMsgSize = MsgSettingGetInt(MSGSIZE_OPTION);
1082 }
1083
1084
1085 MSG_ERROR_T MsgSetConfigInSim(const MSG_SETTING_S *pSetting)
1086 {
1087         MSG_ERROR_T err = MSG_SUCCESS;
1088
1089         MsgPlugin* plg = MsgPluginManager::instance()->getPlugin(MSG_SMS_TYPE);
1090
1091         // Get Setting Data from SIM
1092         if (plg != NULL)
1093                 err = plg->setConfigData(pSetting);
1094         else
1095                 err = MSG_ERR_NULL_POINTER;
1096
1097         if (err != MSG_SUCCESS)
1098         {
1099                 MSG_DEBUG("Error. Error code is %d.", err);
1100                 return err;
1101         }
1102
1103         return err;
1104 }