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.
37 #include "MsgUtilFile.h"
38 #include "SmsPluginTextConvert.h"
39 #include "SmsPluginTransport.h"
40 #include "SmsPluginSimMsg.h"
41 #include "SmsPluginStorage.h"
42 #include "SmsPluginConcatHandler.h"
43 #include "SmsPluginEventHandler.h"
46 /*==================================================================================================
47 IMPLEMENTATION OF SmsPluginEventHandler - Member Functions
48 ==================================================================================================*/
49 SmsPluginEventHandler* SmsPluginEventHandler::pInstance = NULL;
52 SmsPluginEventHandler::SmsPluginEventHandler()
54 /** Initialize global parameters */
55 memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
62 SmsPluginEventHandler::~SmsPluginEventHandler()
68 SmsPluginEventHandler* SmsPluginEventHandler::instance()
71 pInstance = new SmsPluginEventHandler();
77 void SmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
79 listener = *pListener;
83 void SmsPluginEventHandler::handleSentStatus(int TapiReqId, MSG_NETWORK_STATUS_T NetStatus)
85 MSG_DEBUG("TapiReqId [%d], NetStatus[%d]", TapiReqId, NetStatus);
87 SmsPluginTransport::instance()->setNetStatus(NetStatus);
89 if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
90 /** Update Msg Status */
91 if (sentInfo.reqInfo.msgInfo.msgPort.valid == false){
92 SmsPluginStorage::instance()->updateSentMsg(&(sentInfo.reqInfo.msgInfo), NetStatus);
93 sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
94 callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
97 MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
98 MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
99 /** Check sending options */
100 if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
101 SmsPluginStorage::instance()->deleteSmsMessage(sentInfo.reqInfo.msgInfo.msgId);
102 callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
105 /** Callback to MSG FW */
106 if (sentInfo.reqInfo.bReqCb == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
107 MSG_SENT_STATUS_S msgStatus;
109 msgStatus.reqId = sentInfo.reqInfo.reqId;
110 msgStatus.status = NetStatus;
112 MSG_DEBUG("sentStatus.reqId : %d", msgStatus.reqId);
113 MSG_DEBUG("sentStatus.status : %d", msgStatus.status);
115 listener.pfSentStatusCb(&msgStatus);
121 void SmsPluginEventHandler::handleMsgIncoming(SMS_TPDU_S *pTpdu)
123 /** Make MSG_MESSAGE_INFO_S */
124 MSG_MESSAGE_INFO_S msgInfo;
126 /** initialize msgInfo */
127 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
129 /** convert to msgInfo */
130 convertTpduToMsginfo(pTpdu, &msgInfo);
132 /** Short Message Type 0 - Just Send Deliver Report */
133 if (msgInfo.msgType.subType == MSG_TYPE0_SMS) {
134 SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
138 /** Print MSG_MESSAGE_INFO_S */
139 MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
140 MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
141 MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
142 MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
143 MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
144 MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
145 MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
146 MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
147 MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
148 MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
149 MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
150 MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
151 MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
152 MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
153 MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
154 MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
156 if (msgInfo.bTextSms == true) {
157 MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
159 MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
162 MSG_DEBUG("###############################################################");
164 MSG_ERROR_T err = MSG_SUCCESS;
166 /** Update Status in Report Table */
167 if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
169 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
171 if (err == MSG_SUCCESS) {
172 MSG_DEBUG("callback to msg fw");
173 err = listener.pfMsgIncomingCb(&msgInfo);
176 /** Handling of Fail Case ?? */
177 SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
178 } else { /** SMS Deliver */
180 if (msgInfo.msgType.classType == MSG_CLASS_2) {
181 if (msgInfo.bTextSms == false) { /** Concat Msg cannot be saved in SIM */
182 msgInfo.msgType.classType = MSG_CLASS_NONE;
183 msgInfo.storageId = MSG_STORAGE_PHONE;
187 if (msgInfo.msgPort.valid == false) {
188 err = SmsPluginStorage::instance()->addMessage(&msgInfo);
191 /** Callback to MSG FW */
192 if (msgInfo.msgType.classType != MSG_CLASS_2) {
193 if (err == MSG_SUCCESS) {
194 MSG_DEBUG("callback to msg fw");
195 err = listener.pfMsgIncomingCb(&msgInfo);
198 /** Send Deliver Report */
199 SmsPluginTransport::instance()->sendDeliverReport(err);
205 void SmsPluginEventHandler::handleSyncMLMsgIncoming(MSG_SYNCML_MESSAGE_TYPE_T msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen)
207 MSG_SYNCML_MESSAGE_DATA_S syncMLData;
209 memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
211 /** set syncML data */
212 syncMLData.syncmlType = msgType;
214 syncMLData.pushBodyLen = PushBodyLen;
215 memcpy(syncMLData.pushBody, pPushBody, PushBodyLen);
217 syncMLData.wspHeaderLen= WspHeaderLen;
218 memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
220 /** Callback to MSG FW */
221 listener.pfSyncMLMsgIncomingCb(&syncMLData);
225 void SmsPluginEventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen)
227 MSG_LBS_MESSAGE_DATA_S lBSData;
229 memset(&lBSData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
232 memcpy(&lBSData.pushHeader, pPushHeader, strlen(pPushHeader));
234 lBSData.pushBodyLen = pushBodyLen;
235 memcpy(lBSData.pushBody, pPushBody, pushBodyLen);
237 /** Callback to MSG FW */
238 listener.pfLBSMsgIncomingCb(&lBSData);
242 void SmsPluginEventHandler::handleDftSms(MSG_FOLDER_ID_T FolderId, char* pNumber, char* pData)
244 MSG_ERROR_T err = MSG_SUCCESS;
246 MSG_MESSAGE_INFO_S msgInfo;
247 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
250 msgInfo.msgType.mainType = MSG_SMS_TYPE;
251 msgInfo.msgType.subType = MSG_NORMAL_SMS;
252 msgInfo.msgType.classType = MSG_CLASS_NONE;
255 msgInfo.folderId = FolderId;
257 msgInfo.networkStatus = MSG_NETWORK_RECEIVED;
258 msgInfo.bRead = false;
259 msgInfo.bProtected = false;
260 msgInfo.priority = MSG_MESSAGE_PRIORITY_NORMAL;
262 /** Set SMS Direction */
263 if (FolderId == MSG_INBOX_ID)
264 msgInfo.direction = MSG_DIRECTION_TYPE_MT;
266 msgInfo.direction = MSG_DIRECTION_TYPE_MO;
268 /** Set SMS Time Info */
272 msgInfo.displayTime = curTime;
274 /** Set Address Info */
275 msgInfo.nAddressCnt = 1;
276 msgInfo.addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
278 if (pNumber != NULL) {
279 strncpy(msgInfo.addressList[0].addressVal, pNumber, MAX_ADDRESS_VAL_LEN);
283 msgInfo.msgPort.valid = false;
284 msgInfo.msgPort.dstPort = 0;
285 msgInfo.msgPort.srcPort = 0;
288 memset(msgInfo.subject, 0x00, MAX_SUBJECT_LEN+1);
291 msgInfo.bTextSms = true;
294 strncpy(msgInfo.msgText, pData, MAX_MSG_TEXT_LEN);
295 msgInfo.dataSize = strlen(msgInfo.msgText);
297 memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
298 msgInfo.dataSize = 0;
301 /** Print MSG_MESSAGE_INFO_S */
302 MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
303 MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
304 MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
305 MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
306 MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
307 MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
308 MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
309 MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
310 MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
311 MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
312 MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
313 MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
314 MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
315 MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
316 MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
317 MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
318 if (msgInfo.bTextSms == true)
319 MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
321 MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
322 MSG_DEBUG("###############################################################");
324 /** Callback to MSG FW */
325 err = listener.pfMsgIncomingCb(&msgInfo);
329 MSG_ERROR_T SmsPluginEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo)
333 MSG_ERROR_T err = MSG_SUCCESS;
335 /** Callback to MSG FW */
336 err = listener.pfMsgIncomingCb(pMsgInfo);
344 MSG_ERROR_T SmsPluginEventHandler::callbackInitSimBySat()
346 /** Callback to MSG FW */
347 return listener.pfInitSimBySatCb();
351 MSG_ERROR_T SmsPluginEventHandler::callbackStorageChange(MSG_STORAGE_CHANGE_TYPE_T storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
353 /** Callback to MSG FW */
354 listener.pfStorageChangeCb(storageChangeType, pMsgInfo);
358 void SmsPluginEventHandler::convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
360 memset(msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
362 switch(pTpdu->tpduType)
364 case SMS_TPDU_SUBMIT :
365 convertSubmitTpduToMsginfo(&pTpdu->data.submit, msgInfo);
367 case SMS_TPDU_DELIVER :
368 convertDeliverTpduToMsginfo(&pTpdu->data.deliver, msgInfo);
370 case SMS_TPDU_STATUS_REP :
371 convertStatusRepTpduToMsginfo(&pTpdu->data.statusRep, msgInfo);
377 void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
379 int addressListCnt = 0;
381 /** Convert Type values */
382 msgInfo->msgType.mainType = MSG_SMS_TYPE;
383 msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
385 /** set folder id (temporary) */
386 msgInfo->folderId = MSG_OUTBOX_ID;
388 switch(pTpdu->dcs.msgClass)
390 case SMS_MSG_CLASS_0:
391 msgInfo->msgType.classType = MSG_CLASS_0;
393 case SMS_MSG_CLASS_1:
394 msgInfo->msgType.classType = MSG_CLASS_1;
396 case SMS_MSG_CLASS_2:
397 msgInfo->msgType.classType = MSG_CLASS_2;
399 case SMS_MSG_CLASS_3:
400 msgInfo->msgType.classType = MSG_CLASS_3;
403 msgInfo->msgType.classType = MSG_CLASS_NONE;
406 msgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
407 msgInfo->bRead = false;
408 msgInfo->bProtected = false;
409 msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
410 msgInfo->direction = MSG_DIRECTION_TYPE_MT;
411 msgInfo->bTextSms = true;
413 memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
415 /** What kind of time has to be saved?? (temporary store time) */
420 msgInfo->displayTime = curTime;
422 /** Convert Address values */
423 msgInfo->nAddressCnt = 1;
424 msgInfo->addressList[addressListCnt].addressType = MSG_ADDRESS_TYPE_PLMN;
425 strncpy(msgInfo->addressList[addressListCnt].addressVal, pTpdu->destAddress.address, MAX_ADDRESS_VAL_LEN);
427 /**exception operation for none userdata */
428 if (pTpdu->userData.length == 0) {
429 sprintf(msgInfo->msgText, "[Broken Message]");
430 msgInfo->dataSize = strlen(msgInfo->msgText);
434 /** Convert Data values */
435 if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
436 SMS_LANG_INFO_S langInfo = {0};
438 langInfo.bSingleShift = false;
439 langInfo.bLockingShift = false;
441 msgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
442 } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
443 msgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
448 void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
450 /** Convert Type values */
451 msgInfo->msgType.mainType = MSG_SMS_TYPE;
452 msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
454 /** set folder id (temporary) */
455 msgInfo->folderId = MSG_INBOX_ID;
457 msgInfo->storageId = MSG_STORAGE_PHONE;
459 switch(pTpdu->dcs.msgClass)
461 case SMS_MSG_CLASS_0:
462 msgInfo->msgType.classType = MSG_CLASS_0;
464 case SMS_MSG_CLASS_1:
465 msgInfo->msgType.classType = MSG_CLASS_1;
467 case SMS_MSG_CLASS_2:
468 msgInfo->msgType.classType = MSG_CLASS_2;
469 msgInfo->storageId = MSG_STORAGE_SIM;
471 case SMS_MSG_CLASS_3:
472 msgInfo->msgType.classType = MSG_CLASS_3;
475 msgInfo->msgType.classType = MSG_CLASS_NONE;
478 if (pTpdu->dcs.bMWI) {
479 msgInfo->msgType.subType = (pTpdu->dcs.indType + MSG_MWI_VOICE_SMS);
482 msgInfo->networkStatus = MSG_NETWORK_RECEIVED;
483 msgInfo->bRead = false;
484 msgInfo->bProtected = false;
485 msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
486 msgInfo->direction = MSG_DIRECTION_TYPE_MT;
487 msgInfo->bTextSms = true;
489 memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
491 time_t rawtime = time(NULL);
493 msgInfo->displayTime = rawtime;
495 /** Convert Address values */
496 msgInfo->nAddressCnt = 1;
497 msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
498 strncpy(msgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
500 msgInfo->msgPort.valid = false;
501 msgInfo->msgPort.dstPort = 0;
502 msgInfo->msgPort.srcPort = 0;
504 for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
505 /** Convert UDH values - Port Number */
506 if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
507 msgInfo->msgPort.valid = true;
508 msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
509 msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
510 } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
511 msgInfo->msgPort.valid = true;
512 msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
513 msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
514 } else if (pTpdu->userData.header[i].udhType == SMS_UDH_SPECIAL_SMS) {
515 msgInfo->msgType.subType = (pTpdu->userData.header[i].udh.specialInd.msgInd+MSG_MWI_VOICE_SMS);
517 if (pTpdu->userData.length == 0) {
518 sprintf(msgInfo->msgText,"[MWI Message] Total %d Message is waiting.", pTpdu->userData.header[i].udh.specialInd.waitMsgNum);
519 msgInfo->dataSize = strlen(msgInfo->msgText);
523 } else if (pTpdu->userData.header[i].udhType == SMS_UDH_ALTERNATE_REPLY_ADDRESS) {
524 strncpy(msgInfo->addressList[0].addressVal, pTpdu->userData.header[i].udh.alternateAddress.address, MAX_ADDRESS_VAL_LEN);
528 /**length 0 - no user data - msg should be received */
529 if (pTpdu->userData.length <= 0) {
530 memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
531 msgInfo->dataSize = 0;
533 switch(pTpdu->dcs.codingScheme)
535 case SMS_CHARSET_7BIT:
536 msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
538 case SMS_CHARSET_8BIT:
539 msgInfo->encodeType = MSG_ENCODE_8BIT;
541 case SMS_CHARSET_UCS2:
542 msgInfo->encodeType = MSG_ENCODE_UCS2;
545 msgInfo->encodeType = MSG_ENCODE_8BIT;
549 } else if (pTpdu->userData.length > MAX_MSG_TEXT_LEN) {
550 sprintf(msgInfo->msgText, "[Broken Message]");
551 msgInfo->dataSize = strlen(msgInfo->msgData);
555 /** Convert Data values */
556 if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
557 SMS_LANG_INFO_S langInfo = {0};
559 langInfo.bSingleShift = false;
560 langInfo.bLockingShift = false;
562 for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
563 if (pTpdu->userData.header[i].udhType == SMS_UDH_SINGLE_SHIFT) {
564 langInfo.bSingleShift = true;
565 langInfo.singleLang = pTpdu->userData.header[i].udh.singleShift.langId;
566 } else if (pTpdu->userData.header[i].udhType == SMS_UDH_LOCKING_SHIFT) {
567 langInfo.bLockingShift = true;
568 langInfo.lockingLang = pTpdu->userData.header[i].udh.lockingShift.langId;
572 msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
573 msgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
574 } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
575 msgInfo->encodeType = MSG_ENCODE_8BIT;
576 memcpy(msgInfo->msgText, pTpdu->userData.data, pTpdu->userData.length);
577 msgInfo->dataSize = pTpdu->userData.length;
578 } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
579 msgInfo->encodeType = MSG_ENCODE_UCS2;
580 msgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
585 void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
587 /** Convert Type values */
588 msgInfo->msgType.mainType = MSG_SMS_TYPE;
589 msgInfo->msgType.subType = MSG_STATUS_REPORT_SMS;
591 /** set folder id (temporary) */
592 msgInfo->folderId = MSG_INBOX_ID;
594 switch(pTpdu->dcs.msgClass)
596 case SMS_MSG_CLASS_0:
597 msgInfo->msgType.classType = MSG_CLASS_0;
599 case SMS_MSG_CLASS_1:
600 msgInfo->msgType.classType = MSG_CLASS_1;
602 case SMS_MSG_CLASS_2:
603 msgInfo->msgType.classType = MSG_CLASS_2;
605 case SMS_MSG_CLASS_3:
606 msgInfo->msgType.classType = MSG_CLASS_3;
609 msgInfo->msgType.classType = MSG_CLASS_NONE;
612 MSG_DEBUG("delivery status : [%d]", pTpdu->status);
614 if (pTpdu->status == SMS_STATUS_RECEIVE_SUCCESS) {
615 msgInfo->networkStatus = MSG_NETWORK_DELIVER_SUCCESS;
617 msgInfo->networkStatus = MSG_NETWORK_DELIVER_FAIL;
620 msgInfo->bRead = false;
621 msgInfo->bProtected = false;
622 msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
623 msgInfo->direction = MSG_DIRECTION_TYPE_MT;
624 msgInfo->bTextSms = true;
626 memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
628 time_t rawtime = time(NULL);
630 msgInfo->displayTime = rawtime;
632 /** Convert Address values */
633 msgInfo->nAddressCnt = 1;
634 msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
635 strncpy(msgInfo->addressList[0].addressVal, pTpdu->recipAddress.address, MAX_ADDRESS_VAL_LEN);
637 msgInfo->msgPort.valid = false;
638 msgInfo->msgPort.dstPort = 0;
639 msgInfo->msgPort.srcPort = 0;
641 for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
642 /** Convert UDH values - Port Number */
643 if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
644 msgInfo->msgPort.valid = true;
645 msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
646 msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
647 } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
648 msgInfo->msgPort.valid = true;
649 msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
650 msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
654 memset(msgInfo->msgText, 0x00, sizeof(MAX_MSG_TEXT_LEN+1));
655 msgInfo->dataSize = 0;
657 if (pTpdu->status <= SMS_STATUS_SMSC_SPECIFIC_LAST) {
658 strncpy(msgInfo->msgText, "Message delivered.", MAX_MSG_TEXT_LEN);
659 msgInfo->dataSize = strlen(msgInfo->msgText);
660 } else if (pTpdu->status == SMS_STATUS_TEMP_SERVICE_REJECTED) {
661 strncpy(msgInfo->msgText, "Message delivery rejected.", MAX_MSG_TEXT_LEN);
662 msgInfo->dataSize = strlen(msgInfo->msgText);
663 } else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED) {
664 strncpy(msgInfo->msgText, "Message delivery expired.", MAX_MSG_TEXT_LEN);
665 msgInfo->dataSize = strlen(msgInfo->msgText);
667 strncpy(msgInfo->msgText, "Message delivery failed.", MAX_MSG_TEXT_LEN);
668 msgInfo->dataSize = strlen(msgInfo->msgText);
673 MSG_SUB_TYPE_T SmsPluginEventHandler::convertMsgSubType(SMS_PID_T pid)
678 return MSG_TYPE0_SMS;
679 case SMS_PID_REPLACE_TYPE1 :
680 return MSG_REPLACE_TYPE1_SMS;
681 case SMS_PID_REPLACE_TYPE2 :
682 return MSG_REPLACE_TYPE2_SMS;
683 case SMS_PID_REPLACE_TYPE3 :
684 return MSG_REPLACE_TYPE3_SMS;
685 case SMS_PID_REPLACE_TYPE4 :
686 return MSG_REPLACE_TYPE4_SMS;
687 case SMS_PID_REPLACE_TYPE5 :
688 return MSG_REPLACE_TYPE5_SMS;
689 case SMS_PID_REPLACE_TYPE6 :
690 return MSG_REPLACE_TYPE6_SMS;
691 case SMS_PID_REPLACE_TYPE7 :
692 return MSG_REPLACE_TYPE7_SMS;
693 case SMS_PID_RETURN_CALL :
694 return MSG_MWI_OTHER_SMS;
696 return MSG_NORMAL_SMS;
702 void SmsPluginEventHandler::SetSentInfo(SMS_SENT_INFO_S *pSentInfo)
704 memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S));
705 memcpy(&sentInfo, pSentInfo, sizeof(SMS_SENT_INFO_S));
707 MSG_DEBUG("sentInfo.reqId : %d", sentInfo.reqInfo.reqId);
708 MSG_DEBUG("sentInfo.bLast : %d", sentInfo.bLast);
712 void SmsPluginEventHandler::setDeviceStatus()
721 bool SmsPluginEventHandler::getDeviceStatus()
727 ret = cv.timedwait(mx.pMutex(), 10);
731 if (ret == ETIMEDOUT) {
732 MSG_DEBUG("WARNING: DEVICE STATUS TIME-OUT");