update tizen source
[framework/messaging/msg-service.git] / proxy / MsgHandleTransport.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 <time.h>
32 #include <errno.h>
33
34 #include "MsgDebug.h"
35 #include "MsgCppTypes.h"
36 #include "MsgException.h"
37 #include "MsgProxyListener.h"
38 #include "MsgHandle.h"
39
40
41 /*==================================================================================================
42                                      IMPLEMENTATION OF MsgHandle - Transport Member Functions
43 ==================================================================================================*/
44 MSG_ERROR_T MsgHandle::submitReq(MSG_REQUEST_S* pReq)
45 {
46         MSG_BEGIN();
47
48         if (pReq == NULL)
49                 THROW(MsgException::INVALID_PARAM, "pReq is NULL");
50
51         MSG_REQUEST_INFO_S reqInfo = {0};
52         char trId[MMS_TR_ID_LEN+1] = {0};
53
54         MSG_MESSAGE_S *reqmsg = (MSG_MESSAGE_S*) pReq->msg;
55
56         if (reqmsg->msgType.subType != MSG_SENDREQ_JAVA_MMS) {
57                 // In case MMS read report, get address value later.
58                 if(reqmsg->msgType.subType != MSG_READREPLY_MMS) {
59                         if ((reqmsg->nAddressCnt == 0) || (reqmsg->nAddressCnt > MAX_TO_ADDRESS_CNT)) {
60                                 MSG_DEBUG("Recipient address count error [%d]", reqmsg->nAddressCnt );
61                                 return MSG_ERR_INVALID_MESSAGE;
62                         }
63                 }
64
65                 /* Begin: Setting default values for submit request */
66         //      pReq->msg.msgId = 0;    // Set Request ID: internal use
67         //      pReq->msg.folderId = MSG_OUTBOX_ID;     // Set Folder ID
68                 if (reqmsg->msgType.subType == MSG_RETRIEVE_MMS) {
69                         reqmsg->networkStatus = MSG_NETWORK_RETRIEVING;
70                 } else {
71                         reqmsg->networkStatus = MSG_NETWORK_SENDING;
72                 }
73
74                 reqmsg->bRead = false;
75                 reqmsg->bProtected = false;
76                 reqmsg->priority = MSG_MESSAGE_PRIORITY_NORMAL;
77                 reqmsg->direction = MSG_DIRECTION_TYPE_MO;
78                 reqmsg->storageId = MSG_STORAGE_PHONE;
79
80                 time_t curTime = time(NULL);
81
82                 if (curTime < 0)
83                         THROW(MsgException::INVALID_RESULT, "time error : %s", strerror(errno));
84
85                 reqmsg->displayTime = curTime;
86                 /* End : Setting default values for submit request */
87         } else {
88                 //in case of JAVA MMS msg, parse mms transaction id from pMmsData
89                 reqmsg->networkStatus = MSG_NETWORK_SENDING;
90                 strncpy(trId, (char*)reqmsg->pMmsData+3,MMS_TR_ID_LEN);
91                 MSG_DEBUG("JavaMMS transaction Id:%s ",trId);
92         }
93
94         // Convert MSG_MESSAGE_S to MSG_MESSAGE_INFO_S
95         convertMsgStruct(reqmsg, &(reqInfo.msgInfo));
96
97         convertSendOptStruct(&(pReq->sendOpt), &(reqInfo.sendOptInfo), reqmsg->msgType);
98
99         reqInfo.reqId = 0;
100
101         /* Register proxy info used for receiving sent status */
102         MSG_PROXY_INFO_S chInfo = {0};
103
104         chInfo.listenerFd = MsgProxyListener::instance()->getRemoteFd();
105
106         chInfo.handleAddr = (unsigned int) this;
107
108         /* Allocate Memory to Command Data */
109         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_REQUEST_INFO_S) + sizeof(MSG_PROXY_INFO_S);
110
111         // In case of JAVA MMS msg, add trId
112         if (reqmsg->msgType.subType == MSG_SENDREQ_JAVA_MMS)
113                 cmdSize += sizeof(trId);
114
115         char cmdBuf[cmdSize];
116         bzero(cmdBuf, cmdSize);
117
118         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
119
120         // Set Command Parameters
121         pCmd->cmdType = MSG_CMD_SUBMIT_REQ;
122
123         // Copy Cookie
124         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
125
126         // Copy Command Data
127         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &reqInfo, sizeof(MSG_REQUEST_INFO_S));
128         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)), &chInfo, sizeof(MSG_PROXY_INFO_S));
129
130         // In case of JAVA MMS msg, add trId
131         if (reqmsg->msgType.subType == MSG_SENDREQ_JAVA_MMS)
132                 memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN+sizeof(MSG_REQUEST_INFO_S)+sizeof(MSG_PROXY_INFO_S)), &trId, sizeof(trId));
133
134         // Send Command to Messaging FW
135         char* pEventData = NULL;
136         AutoPtr<char> eventBuf(&pEventData);
137
138         write((char*)pCmd, cmdSize, &pEventData);
139
140         // Get Return Data
141         MSG_EVENT_S* pEvent = (MSG_EVENT_S*) pEventData;
142
143         int* pReqId = (int*) pEvent->data;
144         pReq->reqId = *pReqId;
145         MSG_DEBUG("SENT_REQ_ID: %d", pReq->reqId);
146
147         if (pEvent->eventType != MSG_EVENT_SUBMIT_REQ)
148         {
149                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
150         }
151
152         MSG_END();
153
154         return pEvent->result;
155 }
156
157
158 MSG_ERROR_T MsgHandle::cancelReq(MSG_REQUEST_ID_T reqId)
159 {
160         // Allocate Memory to Command Data
161         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_REQUEST_ID_T);
162
163         char cmdBuf[cmdSize];
164         bzero(cmdBuf, cmdSize);
165
166         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
167
168         // Set Command Parameters
169         pCmd->cmdType = MSG_CMD_CANCEL_REQ;
170
171         // Copy Cookie
172         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
173
174         // Copy Command Data
175         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &reqId, sizeof(MSG_REQUEST_ID_T));
176
177         // Send Command to Messaging FW
178         char* pEventData = NULL;
179         AutoPtr<char> eventBuf(&pEventData);
180
181
182         write((char*)pCmd, cmdSize, &pEventData);
183
184         // Get Return Data
185         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
186
187         if (pEvent->eventType != MSG_EVENT_CANCEL_REQ)
188         {
189                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
190         }
191
192         return pEvent->result;
193 }
194
195
196 MSG_ERROR_T MsgHandle::regSentStatusCallback(msg_sent_status_cb onStatusChanged, void *pUserParam)
197 {
198         if (!onStatusChanged)
199                 THROW(MsgException::INVALID_PARAM, "onStatusChanged is null");
200
201         MsgProxyListener* eventListener = MsgProxyListener::instance();
202
203         eventListener->start();
204
205         if (eventListener->regSentStatusEventCB(this, onStatusChanged, pUserParam) == false) // callback was already registered, just return SUCCESS
206                 return MSG_SUCCESS;
207
208         // Allocate Memory to Command Data
209         int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); // cmd type, listenerFd
210         char cmdBuf[cmdSize];
211         bzero(cmdBuf, cmdSize);
212         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
213
214         // Set Command Parameters
215         pCmd->cmdType = MSG_CMD_REG_SENT_STATUS_CB;
216
217         // Copy Cookie
218         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
219
220         int listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
221
222         MSG_DEBUG("remote fd %d", listenerFd);
223
224         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &listenerFd, sizeof(listenerFd));
225
226         MSG_DEBUG("reg status [%d : %s], %d", pCmd->cmdType, MsgDbgCmdStr(pCmd->cmdType), listenerFd);
227
228         // Send Command to Messaging FW
229         char* pEventData = NULL;
230         AutoPtr<char> eventBuf(&pEventData);
231
232         write((char*)pCmd, cmdSize, &pEventData);
233
234         // Get Return Data
235         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
236
237         if (pEvent->eventType != MSG_EVENT_REG_SENT_STATUS_CB)
238         {
239                 THROW(MsgException::INVALID_PARAM, "Event Data Error");
240         }
241
242         return pEvent->result;
243 }
244
245
246 MSG_ERROR_T MsgHandle::regSmsMessageCallback(msg_sms_incoming_cb onMsgIncoming, unsigned short port, void *pUserParam)
247 {
248         if( (!onMsgIncoming) )
249                 THROW(MsgException::INVALID_PARAM, "Param %p", onMsgIncoming);
250
251         MsgProxyListener* eventListener = MsgProxyListener::instance();
252
253         eventListener->start();
254
255         if (eventListener->regMessageIncomingEventCB(this, onMsgIncoming, port, pUserParam) == false) // callback was already registered, just return SUCCESS
256                 return MSG_SUCCESS;
257
258         // Allocate Memory to Command Data
259         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
260
261         char cmdBuf[cmdSize];
262         bzero(cmdBuf, cmdSize);
263
264         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
265
266         // Set Command Parameters
267         pCmd->cmdType = MSG_CMD_REG_INCOMING_MSG_CB;
268
269         // Copy Cookie
270         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
271
272         MSG_CMD_REG_INCOMING_MSG_CB_S cmdParam = {0};
273
274         cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
275         cmdParam.msgType = MSG_SMS_TYPE;
276         cmdParam.port = port;
277
278         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
279
280         MSG_DEBUG("reg new msg [%s], fd %d, port %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd, cmdParam.port);
281
282         // Send Command to Messaging FW
283         char* pEventData = NULL;
284         AutoPtr<char> eventBuf(&pEventData);
285
286
287         write((char*)pCmd, cmdSize, &pEventData);
288
289         // Get Return Data
290         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
291
292         if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MSG_CB)
293         {
294                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
295         }
296
297         return pEvent->result;
298 }
299
300
301 MSG_ERROR_T MsgHandle::regMmsConfMessageCallback(msg_mms_conf_msg_incoming_cb onMMSConfMsgIncoming, const char *pAppId, void *pUserParam)
302 {
303         if( (!onMMSConfMsgIncoming) )
304                 THROW(MsgException::INVALID_PARAM, "Param %p", onMMSConfMsgIncoming);
305
306         MsgProxyListener* eventListener = MsgProxyListener::instance();
307
308         eventListener->start();
309
310         if (eventListener->regMMSConfMessageIncomingEventCB(this, onMMSConfMsgIncoming, pAppId, pUserParam) == false) // callback was already registered, just return SUCCESS
311                 return MSG_SUCCESS;
312
313         // Allocate Memory to Command Data
314         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S);
315
316         char cmdBuf[cmdSize];
317         bzero(cmdBuf, cmdSize);
318
319         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
320
321         // Set Command Parameters
322         pCmd->cmdType = MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB;
323
324         // Copy Cookie
325         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
326
327         MSG_CMD_REG_INCOMING_MMS_CONF_MSG_CB_S cmdParam = {0};
328
329         cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
330         cmdParam.msgType = MSG_MMS_TYPE;
331
332         if (pAppId)
333                 strncpy(cmdParam.appId, pAppId, MAX_MMS_JAVA_APPID_LEN);
334
335         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
336
337         MSG_DEBUG("reg new msg [%s], fd:%d, appId:%s", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd,  (pAppId)? cmdParam.appId:"NULL" );
338
339         // Send Command to Messaging FW
340         char* pEventData = NULL;
341         AutoPtr<char> eventBuf(&pEventData);
342
343
344         write((char*)pCmd, cmdSize, &pEventData);
345
346         // Get Return Data
347         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
348
349         if (pEvent->eventType != MSG_EVENT_REG_INCOMING_MMS_CONF_MSG_CB)
350         {
351                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
352         }
353
354         return pEvent->result;
355 }
356
357
358 MSG_ERROR_T MsgHandle::regSyncMLMessageCallback(msg_syncml_msg_incoming_cb onSyncMLMsgIncoming, void *pUserParam)
359 {
360         if( (!onSyncMLMsgIncoming) )
361                 THROW(MsgException::INVALID_PARAM, "Param %p", onSyncMLMsgIncoming);
362
363         MsgProxyListener* eventListener = MsgProxyListener::instance();
364
365         eventListener->start();
366
367         if (eventListener->regSyncMLMessageIncomingEventCB(this, onSyncMLMsgIncoming, pUserParam) == false) // callback was already registered, just return SUCCESS
368                 return MSG_SUCCESS;
369
370         // Allocate Memory to Command Data
371         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
372
373         char cmdBuf[cmdSize];
374         bzero(cmdBuf, cmdSize);
375
376         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
377
378         // Set Command Parameters
379         pCmd->cmdType = MSG_CMD_REG_INCOMING_SYNCML_MSG_CB;
380
381         // Copy Cookie
382         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
383
384         MSG_CMD_REG_INCOMING_SYNCML_MSG_CB_S cmdParam = {0};
385
386         cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
387         cmdParam.msgType = MSG_SMS_TYPE;
388
389         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
390
391         MSG_DEBUG("reg new msg [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
392
393         // Send Command to Messaging FW
394         char* pEventData = NULL;
395         AutoPtr<char> eventBuf(&pEventData);
396
397         write((char*)pCmd, cmdSize, &pEventData);
398
399         // Get Return Data
400         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
401
402         if (pEvent->eventType != MSG_EVENT_REG_INCOMING_SYNCML_MSG_CB)
403         {
404                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
405         }
406
407         return pEvent->result;
408 }
409
410
411 MSG_ERROR_T MsgHandle::regLBSMessageCallback(msg_lbs_msg_incoming_cb onLBSMsgIncoming, void *pUserParam)
412 {
413         if( (!onLBSMsgIncoming) )
414                 THROW(MsgException::INVALID_PARAM, "Param %p", onLBSMsgIncoming);
415
416         MsgProxyListener* eventListener = MsgProxyListener::instance();
417
418         eventListener->start();
419
420         if (eventListener->regLBSMessageIncomingEventCB(this, onLBSMsgIncoming, pUserParam) == false) // callback was already registered, just return SUCCESS
421                 return MSG_SUCCESS;
422
423         // Allocate Memory to Command Data
424         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_INCOMING_LBS_MSG_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
425         char cmdBuf[cmdSize];
426         bzero(cmdBuf, cmdSize);
427         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
428
429         // Set Command Parameters
430         pCmd->cmdType = MSG_CMD_REG_INCOMING_LBS_MSG_CB;
431
432         // Copy Cookie
433         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
434
435         MSG_CMD_REG_INCOMING_LBS_MSG_CB_S cmdParam = {0};
436
437         cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
438         cmdParam.msgType = MSG_SMS_TYPE;
439
440         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
441
442         MSG_DEBUG("reg new msg [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
443
444         // Send Command to Messaging FW
445         char* pEventData = NULL;
446         AutoPtr<char> eventBuf(&pEventData);
447
448
449         write((char*)pCmd, cmdSize, &pEventData);
450
451         // Get Return Data
452         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
453
454         if (pEvent->eventType != MSG_EVENT_REG_INCOMING_LBS_MSG_CB)
455         {
456                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
457         }
458
459         return pEvent->result;
460 }
461
462
463 MSG_ERROR_T MsgHandle::regSyncMLMessageOperationCallback(msg_syncml_msg_operation_cb onSyncMLMsgOperation, void *pUserParam)
464 {
465         if( (!onSyncMLMsgOperation) )
466                 THROW(MsgException::INVALID_PARAM, "Param %p", onSyncMLMsgOperation);
467
468         MsgProxyListener* eventListener = MsgProxyListener::instance();
469
470         eventListener->start();
471
472         if (eventListener->regSyncMLMessageOperationEventCB(this, onSyncMLMsgOperation, pUserParam) == false) // callback was already registered, just return SUCCESS
473                 return MSG_SUCCESS;
474
475         // Allocate Memory to Command Data
476         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S); //sizeof(int) + sizeof; // cmd type, listener fd
477
478         char cmdBuf[cmdSize];
479         bzero(cmdBuf, cmdSize);
480
481         MSG_CMD_S* pCmd = (MSG_CMD_S*) cmdBuf;
482
483         // Set Command Parameters
484         pCmd->cmdType = MSG_CMD_REG_SYNCML_MSG_OPERATION_CB;
485
486         // Copy Cookie
487         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
488
489         MSG_CMD_REG_SYNCML_MSG_OPERATION_CB_S cmdParam = {0};
490
491         cmdParam.listenerFd = eventListener->getRemoteFd(); // fd that is reserved to the "listener thread" by msgfw daemon
492         cmdParam.msgType = MSG_SMS_TYPE;
493
494         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &cmdParam, sizeof(cmdParam));
495
496         MSG_DEBUG("register syncML msg operation callback [%s], fd %d", MsgDbgCmdStr(pCmd->cmdType), cmdParam.listenerFd);
497
498         // Send Command to Messaging FW
499         char* pEventData = NULL;
500         AutoPtr<char> eventBuf(&pEventData);
501
502
503         write((char*)pCmd, cmdSize, &pEventData);
504
505         // Get Return Data
506         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
507
508         if (pEvent->eventType != MSG_EVENT_REG_SYNCML_MSG_OPERATION_CB)
509         {
510                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
511         }
512
513         return pEvent->result;
514 }
515
516
517 MSG_ERROR_T MsgHandle::operateSyncMLMessage(MSG_MESSAGE_ID_T msgId)
518 {
519         if( msgId < 1)
520                 THROW(MsgException::INVALID_PARAM, "Param msgId %d", msgId);
521
522         // Allocate Memory to Command Data
523         int cmdSize = sizeof(MSG_CMD_S) + sizeof(MSG_MESSAGE_ID_T);
524
525         char cmdBuf[cmdSize];
526         bzero(cmdBuf, cmdSize);
527         MSG_CMD_S* pCmd = (MSG_CMD_S*)cmdBuf;
528
529         // Set Command Parameters
530         pCmd->cmdType = MSG_CMD_SYNCML_OPERATION;
531
532         // Copy Cookie
533         memcpy(pCmd->cmdCookie, mCookie, MAX_COOKIE_LEN);
534
535         // Copy Command Data
536         memcpy((void*)((char*)pCmd+sizeof(MSG_CMD_TYPE_T)+MAX_COOKIE_LEN), &msgId, sizeof(MSG_MESSAGE_ID_T));
537
538         // Send Command to Messaging FW
539         char* pEventData = NULL;
540         AutoPtr<char> eventBuf(&pEventData);
541
542
543         write((char*)pCmd, cmdSize, &pEventData);
544
545         // Get Return Data
546         MSG_EVENT_S* pEvent = (MSG_EVENT_S*)pEventData;
547
548         if (pEvent->eventType != MSG_EVENT_SYNCML_OPERATION)
549         {
550                 THROW(MsgException::INVALID_RESULT, "Event Data Error");
551         }
552
553         return pEvent->result;
554 }
555