Both SMS plugin and SMS CDMA plugin should be loaded and work according to the current network(GSM/CDMA).
Applied the changes for MPR1320.
Change-Id: I9eb77b5f9651b3a0e0c7728286374a8dcd765039
SET(MMS-PLUGIN-LIB msg_mms_plugin)
SET(MSG-MGR msg-manager)
-IF(_FEATURE_SMS_CDMA)
- ADD_DEFINITIONS("-DFEATURE_SMS_CDMA")
-ENDIF(_FEATURE_SMS_CDMA)
-
ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
ADD_DEFINITIONS(-DTZ_SYS_RO_APP_PATH="${TZ_SYS_RO_APP}")
ADD_SUBDIRECTORY(framework)
ADD_SUBDIRECTORY(proxy)
ADD_SUBDIRECTORY(mapi)
-IF(_FEATURE_SMS_CDMA)
-ADD_SUBDIRECTORY(plugin/sms_cdma_plugin)
-ELSE(_FEATURE_SMS_CDMA)
ADD_SUBDIRECTORY(plugin/sms_plugin)
-ENDIF(_FEATURE_SMS_CDMA)
ADD_SUBDIRECTORY(plugin/mms_plugin)
ADD_SUBDIRECTORY(manager)
CONFIGURE_FILE(msg-service.pc.in msg-service.pc @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/msg-service.pc DESTINATION ${LIBDIR}/pkgconfig)
-IF(_FEATURE_SMS_CDMA)
- INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/msg-service-db.CDMA.sql DESTINATION /usr/share/msg-service RENAME msg-service-db.sql)
-ELSE(_FEATURE_SMS_CDMA)
- INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/msg-service-db.sql DESTINATION /usr/share/msg-service RENAME msg-service-db.sql)
-ENDIF(_FEATURE_SMS_CDMA)
+# DB file
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/msg-service-db.sql DESTINATION /usr/share/msg-service RENAME msg-service-db.sql)
+++ /dev/null
-PRAGMA user_version=1;
-
-CREATE TABLE MSG_CONVERSATION_TABLE
-(
- CONV_ID INTEGER PRIMARY KEY ,
- UNREAD_CNT INTEGER DEFAULT 0 ,
- SMS_CNT INTEGER DEFAULT 0 ,
- MMS_CNT INTEGER DEFAULT 0 ,
- MAIN_TYPE INTEGER DEFAULT 0 ,
- SUB_TYPE INTEGER DEFAULT 0 ,
- MSG_DIRECTION INTEGER DEFAULT 0 ,
- DISPLAY_TIME DATETIME ,
- DISPLAY_NAME TEXT NOT NULL DEFAULT '' ,
- MSG_TEXT TEXT NOT NULL DEFAULT '' ,
- TRANSLATION INTEGER DEFAULT 0,
- SENDER_LANG INTEGER DEFAULT 0,
- RECEIVER_LANG INTEGER DEFAULT 0,
- ONLY_RECEIVE INTEGER DEFAULT 0,
- INCLUDE_ORGMSG INTEGER DEFAULT 0,
- LAST_MSG_ID INTEGER DEFAULT 0
-);
-
-CREATE TABLE MSG_ADDRESS_TABLE
-(
- ADDRESS_ID INTEGER PRIMARY KEY ,
- CONV_ID INTEGER NOT NULL ,
- ADDRESS_TYPE INTEGER ,
- RECIPIENT_TYPE INTEGER ,
- ADDRESS_VAL TEXT NOT NULL DEFAULT '' ,
- CONTACT_ID INTEGER ,
- ADDR_BOOK_ID INTEGER ,
- FIRST_NAME TEXT NOT NULL DEFAULT '' ,
- LAST_NAME TEXT NOT NULL DEFAULT '' ,
- MIDDLE_NAME TEXT NOT NULL DEFAULT '' ,
- PREFIX TEXT NOT NULL DEFAULT '' ,
- SUFFIX TEXT NOT NULL DEFAULT '' ,
- IMAGE_PATH TEXT NOT NULL DEFAULT '' ,
- SYNC_TIME DATETIME ,
-
- FOREIGN KEY (CONV_ID) REFERENCES MSG_CONVERSATION_TABLE (CONV_ID)
-);
-
-CREATE TABLE MSG_FOLDER_TABLE
-(
- FOLDER_ID INTEGER PRIMARY KEY ,
- FOLDER_NAME TEXT NOT NULL ,
- FOLDER_TYPE INTEGER DEFAULT 0
-);
-
-CREATE TABLE MSG_MESSAGE_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- CONV_ID INTEGER NOT NULL ,
- FOLDER_ID INTEGER NOT NULL ,
- STORAGE_ID INTEGER NOT NULL ,
- MAIN_TYPE INTEGER NOT NULL ,
- SUB_TYPE INTEGER NOT NULL ,
- DISPLAY_TIME DATETIME ,
- DATA_SIZE INTEGER DEFAULT 0 ,
- NETWORK_STATUS INTEGER DEFAULT 0 ,
- READ_STATUS INTEGER DEFAULT 0 ,
- PROTECTED INTEGER DEFAULT 0 ,
- PRIORITY INTEGER DEFAULT 0 ,
- MSG_DIRECTION INTEGER NOT NULL ,
- SCHEDULED_TIME DATETIME ,
- BACKUP INTEGER DEFAULT 0 ,
- SUBJECT TEXT NOT NULL DEFAULT '' ,
- MSG_DATA TEXT NOT NULL DEFAULT '' ,
- THUMB_PATH TEXT NOT NULL DEFAULT '' ,
- MSG_TEXT TEXT NOT NULL DEFAULT '' ,
- ATTACHMENT_COUNT INTEGER DEFAULT 0 ,
-
- FOREIGN KEY (CONV_ID) REFERENCES MSG_CONVERSATION_TABLE (CONV_ID) ,
- FOREIGN KEY (FOLDER_ID) REFERENCES MSG_FOLDER_TABLE (FOLDER_ID)
-);
-
-CREATE TABLE MSG_SIM_TABLE
-(
- SIM_ID INTEGER PRIMARY KEY ,
- MSG_ID INTEGER NOT NULL ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_PUSH_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- ACTION INTEGER ,
- CREATED INTEGER ,
- EXPIRES INTEGER ,
- ID TEXT NOT NULL DEFAULT '' ,
- HREF TEXT NOT NULL DEFAULT '' ,
- CONTENT TEXT NOT NULL DEFAULT '' ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_CBMSG_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- CB_MSG_ID INTEGER NOT NULL ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_SYNCML_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- EXT_ID INTEGER NOT NULL ,
- PINCODE INTEGER NOT NULL ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_SCHEDULED_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- ALARM_ID INTEGER NOT NULL ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_SMS_SENDOPT_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- DELREP_REQ INTEGER NOT NULL ,
- KEEP_COPY INTEGER NOT NULL ,
- REPLY_PATH INTEGER NOT NULL ,
- ENCODE_TYPE INTEGER NOT NULL ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_FILTER_TABLE
-(
- FILTER_ID INTEGER PRIMARY KEY ,
- FILTER_TYPE INTEGER NOT NULL ,
- FILTER_VALUE TEXT NOT NULL ,
- FILTER_ACTIVE INTEGER DEFAULT 0
-);
-
-CREATE TABLE MSG_MMS_MESSAGE_TABLE
-(
- MSG_ID INTEGER PRIMARY KEY ,
- TRANSACTION_ID TEXT NOT NULL DEFAULT '' ,
- MESSAGE_ID TEXT NOT NULL DEFAULT '' ,
- FWD_MESSAGE_ID TEXT NOT NULL DEFAULT '' ,
- CONTENTS_LOCATION TEXT NOT NULL DEFAULT '' ,
- FILE_PATH TEXT NOT NULL DEFAULT '' ,
- VERSION INTEGER NOT NULL ,
- DATA_TYPE INTEGER DEFAULT -1 ,
- DATE DATETIME ,
- HIDE_ADDRESS INTEGER DEFAULT 0 ,
- ASK_DELIVERY_REPORT INTEGER DEFAULT 0 ,
- REPORT_ALLOWED INTEGER DEFAULT 0 ,
- READ_REPORT_ALLOWED_TYPE INTEGER DEFAULT 0 ,
- ASK_READ_REPLY INTEGER DEFAULT 0 ,
- READ INTEGER DEFAULT 0 ,
- READ_REPORT_SEND_STATUS INTEGER DEFAULT 0 ,
- READ_REPORT_SENT INTEGER DEFAULT 0 ,
- PRIORITY INTEGER DEFAULT 0 ,
- KEEP_COPY INTEGER DEFAULT 0 ,
- MSG_SIZE INTEGER NOT NULL ,
- MSG_CLASS INTEGER DEFAULT -1 ,
- EXPIRY_TIME DATETIME ,
- CUSTOM_DELIVERY_TIME INTEGER DEFAULT 0 ,
- DELIVERY_TIME DATETIME ,
- MSG_STATUS INTEGER DEFAULT -1 ,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_MMS_PREVIEW_INFO_TABLE
-(
- MSG_ID INTEGER NOT NULL ,
- TYPE INTEGER,
- VALUE TEXT,
- COUNT INTEGER,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_SMS_REPORT_TABLE
-(
- MSG_ID INTEGER NOT NULL ,
- ADDRESS_VAL TEXT NOT NULL DEFAULT '' ,
- MSG_REF INTEGER ,
- STATUS_TYPE INTEGER ,
- STATUS INTEGER DEFAULT 0 ,
- TIME DATETIME
-);
-
-CREATE TABLE MSG_REPORT_TABLE
-(
- MSG_ID INTEGER NOT NULL ,
- ADDRESS_VAL TEXT NOT NULL DEFAULT '' ,
- STATUS_TYPE INTEGER ,
- STATUS INTEGER DEFAULT 0 ,
- TIME DATETIME
-);
-
-CREATE TABLE MSG_PUSHCFG_TABLE
-(
- PUSH_ID INTEGER PRIMARY KEY ,
- CONTENT_TYPE TEXT NOT NULL DEFAULT '' ,
- APP_ID TEXT NOT NULL DEFAULT '' ,
- PKG_NAME TEXT NOT NULL DEFAULT '' ,
- LAUNCH INTEGER,
- APPCODE INTEGER,
- SECURE INTEGER
-);
-
-CREATE TABLE MSG_TMP_MSGID_TABLE
-(
- MSG_ID INTEGER
-);
-
-CREATE TABLE MSG_CB_CHANNEL_INFO_TABLE
-(
- CHANNEL_ID INTEGER PRIMARY KEY ,
- CHANNEL_ACTIVATION INTEGER DEFAULT 0,
- CHANNEL_FROM INTEGER DEFAULT 0,
- CHANNEL_TO INTEGER DEFAULT 0,
- CHANNEL_NAME TEXT NOT NULL DEFAULT ''
-);
-
-CREATE TABLE MSG_MULTIPART_TABLE
-(
- _ID INTEGER PRIMARY KEY AUTOINCREMENT,
- MSG_ID INTEGER NOT NULL ,
- SEQ INTEGER DEFAULT 0,
- CONTENT_TYPE TEXT,
- NAME TEXT,
- CHARSET INTEGER,
- CONTENT_ID TEXT,
- CONTENT_LOCATION TEXT,
- FILE_PATH TEXT,
- TEXT TEXT,
- TCS_LEVEL INTEGER DEFAULT -1,
- MALWARE_ALLOW INTEGER DEFAULT 0,
- THUMB_FILE_PATH TEXT,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_CDMA_CB_CHANNEL_INFO_TABLE
-(
- CHANNEL_ID INTEGER PRIMARY KEY,
- CHANNEL_ACTIVATION INTEGER DEFAULT 0,
- CHANNEL_CATEGORY INTEGER DEFAULT 0,
- CHANNEL_LANGUAGE INTEGER DEFAULT 0,
- CHANNEL_NAME TEXT NOT NULL DEFAULT ''
-);
-
-CREATE TABLE MSG_UNIQUENESS_INFO_TABLE
-(
- MSG_ID INTEGER NOT NULL,
- TELE_MSG_ID INTEGER NOT NULL,
- ADDRESS TEXT DEFAULT '',
- SUB_ADDRESS TEXT DEFAULT '',
- TIME_STAMP TEXT DEFAULT '',
- TELESVC_ID INTEGER NOT NULL,
-
- FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
-);
-
-CREATE TABLE MSG_ADDRESS_TEMP_TABLE
-(
- ADDRESS_VAL TEXT NOT NULL DEFAULT ''
-);
-
-CREATE INDEX MSG_CONVERSATION_INDEX ON MSG_CONVERSATION_TABLE(CONV_ID);
-CREATE INDEX MSG_FOLDER_INDEX ON MSG_FOLDER_TABLE(FOLDER_ID);
-CREATE INDEX MSG_MESSAGE_INDEX ON MSG_MESSAGE_TABLE(MSG_ID, CONV_ID, FOLDER_ID);
-
-INSERT INTO MSG_FOLDER_TABLE VALUES (1, 'INBOX', 1);
-INSERT INTO MSG_FOLDER_TABLE VALUES (2, 'OUTBOX', 2);
-INSERT INTO MSG_FOLDER_TABLE VALUES (3, 'SENTBOX', 2);
-INSERT INTO MSG_FOLDER_TABLE VALUES (4, 'DRAFT', 3);
-INSERT INTO MSG_FOLDER_TABLE VALUES (5, 'CBMSGBOX', 1);
-INSERT INTO MSG_FOLDER_TABLE VALUES (6, 'SPAMBOX', 4);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (1, 'text/vnd.wap.si', 'X-Wap-Application-Id: x-wap-application:wml.ua', '', 0, 1, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (2, 'application/vnd.wap.sic', 'X-Wap-Application-Id: x-wap-application:wml.ua', '', 0, 2, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (3, 'text/vnd.wap.sl', 'X-Wap-Application-Id: x-wap-application:wml.ua', '', 0, 3, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (4, 'application/vnd.wap.slc', 'X-Wap-Application-Id: x-wap-application:wml.ua', '', 0, 4, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (5, 'text/vnd.wap.co', 'X-Wap-Application-Id: x-wap-application:wml.ua', '', 0, 5, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (6, 'application/vnd.wap.coc', 'X-Wap-Application-Id: x-wap-application:wml.ua', '', 0, 6, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (7, 'application/vnd.wap.mms-message', 'X-Wap-Application-Id: x-wap-application:mms.ua', '', 0, 7, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (8, 'application/vnd.wap.sia', 'X-Wap-Application-Id: x-wap-application:push.sia', '', 0, 8, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (9, 'application/vnd.syncml.dm+wbxml', 'X-Wap-Application-Id: x-wap-application:push.syncml.dm', '', 0, 9, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (10, 'application/vnd.syncml.dm+xml', 'X-Wap-Application-Id: x-wap-application:push.syncml.dm', '', 0, 10, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (11, 'application/vnd.syncml.notification', 'X-Wap-Application-Id: x-wap-application:push.syncml.dm', '', 0, 11, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (12, 'application/vnd.syncml.ds.notification', 'X-Wap-Application-Id: x-wap-application:push.syncml.ds', '', 0, 12, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (13, 'application/vnd.syncml+wbxml', 'X-Wap-Application-Id:x-wap-application:push.syncml', '', 0, 13, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (14, 'application/vnd.wap.locc+wbxml', 'X-Wap-Application-Id: x-wap-application:loc.ua', '', 0, 14, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (15, 'application/vnd.wap.loc+xml', 'X-Wap-Application-Id: x-wap-application:loc.ua', '', 0, 15, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (16, 'application/vnd.oma.dd+xml', 'X-Wap-Application-Id: x-wap-application:loc.ua', '', 0, 16, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (17, 'application/vnd.oma.drm.message', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 17, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (18, 'application/vnd.oma.drm.content', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 18, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (19, 'application/vnd.oma.drm.rights+xml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 19, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (20, 'application/vnd.oma.drm.rights+wbxml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 20, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (21, 'application/vnd.oma.drm.ro+xml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 21, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (22, 'application/vnd.oma.drm.roap-pdu+xml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 22, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (23, 'application/vnd.oma.drm.roap-trigger+xml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 23, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (24, 'application/vnd.oma.drm.roap-trigger+wbxml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 24, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (25, 'text/vnd.wap.connectivity-xml', 'X-Wap-Application-Id: x-wap-application:drm.ua', '', 0, 26, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (26, 'application/vnd.wap.connectivity-wbxml', 'X-Wap-Application-Id: x-wap-samsung:provisioning.ua', '', 0, 27, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (27, 'application/x-wap-prov.browser-settings', 'X-Wap-Application-Id: x-wap-samsung:provisioning.ua', '', 0, 28, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (28, 'application/x-wap-prov.browser-bookmarks', 'X-Wap-Application-Id: x-wap-samsung:provisioning.ua', '', 0, 29, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (29, 'application/x-wap-prov.syncset+xml', 'X-Wap-Application-Id: x-wap-samsung:provisioning.ua', '', 0, 30, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (30, 'application/x-wap-prov.syncset+wbxml', 'X-Wap-Application-Id: x-wap-samsung:provisioning.ua', '', 0, 31, 0);
-
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (33, 'application/vnd.wv.csp.cir', 'X-Wap-Application-Id: x-wap-application:wv.ua', '', 0, 34, 0);
-INSERT INTO MSG_PUSHCFG_TABLE VALUES (34, 'application/vnd.omaloc-supl-init', 'X-Wap-Application-Id: x-oma-application:ulp.ua', '', 0, 44, 0);
-
-INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (0, 1, 4096, 1, 'Presidential');
-INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (1, 1, 4097, 1, 'Extreme');
-INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (2, 1, 4098, 1, 'Severe');
-INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (3, 1, 4099, 1, 'Amber');
-INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (4, 0, 4100, 1, 'Test');
ADDRESS_VAL TEXT NOT NULL DEFAULT ''
);
+CREATE TABLE MSG_CDMA_CB_CHANNEL_INFO_TABLE
+(
+ CHANNEL_ID INTEGER PRIMARY KEY,
+ CHANNEL_ACTIVATION INTEGER DEFAULT 0,
+ CHANNEL_CATEGORY INTEGER DEFAULT 0,
+ CHANNEL_LANGUAGE INTEGER DEFAULT 0,
+ CHANNEL_NAME TEXT NOT NULL DEFAULT ''
+);
+
+CREATE TABLE MSG_UNIQUENESS_INFO_TABLE
+(
+ MSG_ID INTEGER NOT NULL,
+ TELE_MSG_ID INTEGER NOT NULL,
+ ADDRESS TEXT DEFAULT '',
+ SUB_ADDRESS TEXT DEFAULT '',
+ TIME_STAMP TEXT DEFAULT '',
+ TELESVC_ID INTEGER NOT NULL,
+
+ FOREIGN KEY(MSG_ID) REFERENCES MSG_MESSAGE_TABLE(MSG_ID)
+);
+
CREATE TABLE MSG_SENTFAIL_INDEX_TABLE
(
MSG_ID INTEGER PRIMARY KEY ,
INSERT INTO MSG_CB_CHANNEL_INFO_TABLE VALUES (0, 1, 0, 65535, '', 1);
INSERT INTO MSG_CB_CHANNEL_INFO_TABLE VALUES (1, 1, 0, 65535, '', 2);
+
+INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (0, 1, 4096, 1, 'Presidential alert');
+INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (1, 1, 4097, 1, 'Extreme alert');
+INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (2, 1, 4098, 1, 'Severe alert');
+INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (3, 1, 4099, 1, 'Amber alert');
+INSERT INTO MSG_CDMA_CB_CHANNEL_INFO_TABLE VALUES (4, 0, 4100, 1, 'Test alert');
${CMAKE_SOURCE_DIR}/include/framework
${CMAKE_SOURCE_DIR}/include/utils
${CMAKE_SOURCE_DIR}/include/externals
- ${CMAKE_SOURCE_DIR}/vobject-engine/include
+ ${CMAKE_SOURCE_DIR}/vobject-engine/include
)
INCLUDE(FindPkgConfig)
MSG_FATAL("Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType));
/* THROW(MsgException::INCOMING_MSG_ERROR, "Wrong result(evt type %d : %s) received", pEvent->eventType, MsgDbgEvtStr(pEvent->eventType)); */
-#ifdef FEATURE_SMS_CDMA
memcpy(&(pMsg->msgId), pEvent->data, sizeof(msg_message_id_t));
-#endif
MSG_END();
return (pEvent->result);
}
-#ifdef FEATURE_SMS_CDMA
bool MsgCheckUniquenessListener(MSG_UNIQUE_INDEX_S *p_msg, msg_message_id_t msgId, bool bInsert)
{
MSG_BEGIN();
else
return false;
}
-#endif
msg_error_t MsgSimImsiListener(int sim_idx)
{
fwListener.pfCBMsgIncomingCb = &MsgIncomingCBMessageListener;
fwListener.pfSimMsgIncomingCb = &MsgSimMessageListener;
fwListener.pfResendMessageCb = &MsgResendMessageListener;
-#ifdef FEATURE_SMS_CDMA
fwListener.pfCheckUniquenessCb = &MsgCheckUniquenessListener;
-#endif
fwListener.pfSimInitImsiCb = &MsgSimImsiListener;
if (registerListener(&fwListener) != MSG_SUCCESS)
return MSG_ERR_INVALID_PLUGIN_HANDLE;
}
-#ifndef FEATURE_SMS_CDMA
msg_error_t MsgPlugin::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
{
- if (mPlgHandler.pfDeleteSimMessage != NULL)
+ if (mPlgHandler.pfDeleteSimMessage != NULL) {
return mPlgHandler.pfDeleteSimMessage(sim_idx, SimMsgId);
- else
+ } else {
return MSG_ERR_INVALID_PLUGIN_HANDLE;
+ }
}
else
return MSG_ERR_INVALID_PLUGIN_HANDLE;
}
-#else
-msg_error_t MsgPlugin::deleteSimMessage(msg_sim_id_t SimMsgId)
-{
- if (mPlgHandler.pfDeleteSimMessage != NULL)
- return mPlgHandler.pfDeleteSimMessage(SimMsgId);
- else
- return MSG_ERR_INVALID_PLUGIN_HANDLE;
-}
-msg_error_t MsgPlugin::setReadStatus(msg_sim_id_t SimMsgId)
-{
- if (mPlgHandler.pfSetReadStatus != NULL)
- return mPlgHandler.pfSetReadStatus(SimMsgId);
- else
- return MSG_ERR_INVALID_PLUGIN_HANDLE;
-}
-
-
-msg_error_t MsgPlugin::setMemoryStatus(msg_error_t Error)
-{
- if (mPlgHandler.pfSetMemoryStatus != NULL)
- return mPlgHandler.pfSetMemoryStatus(Error);
- else
- return MSG_ERR_INVALID_PLUGIN_HANDLE;
-}
-#endif
msg_error_t MsgPlugin::setConfigData(const MSG_SETTING_S *pSetting)
{
if (mPlgHandler.pfSetConfigData != NULL)
return MSG_ERR_INVALID_PLUGIN_HANDLE;
}
+
msg_error_t MsgPlugin::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
{
if (mPlgHandler.pfAddMessage != NULL) {
}
}
+
msg_error_t MsgPlugin::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
{
if (mPlgHandler.pfUpdateMessage != NULL) {
case MSG_SMS_SENDOPT :
err = MsgSetSMSSendOpt(pSetting);
break;
-#ifndef FEATURE_SMS_CDMA
case MSG_SMSC_LIST :
/* Check SIM is present or not */
snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pSetting->option.smscList.simIndex);
}
err = MsgSetSMSCList(pSetting, true);
break;
-#endif
case MSG_MMS_SENDOPT :
err = MsgSetMMSSendOpt(pSetting);
break;
msg_error_t err = MSG_SUCCESS;
MSG_CBMSG_OPT_S cbOpt;
-#ifndef FEATURE_SMS_CDMA
int iValue = 0;
-#endif
bool bValue = false;
char keyName[MAX_VCONFKEY_NAME_LEN];
msg_sim_slot_id_t simIndex;
simIndex = cbOpt.simIndex;
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+
MSG_DEBUG("SIM Index = [%d]", simIndex);
if (bSetSim == true) { /* if (bSetSim == true && simIndex != 0) { */
-#ifndef FEATURE_SMS_CDMA
- if (simIndex != 0) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
- if (MsgSettingGetInt(keyName, &(cbOpt.maxSimCnt)) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
+ if (!CDMASupported) {
+ if (simIndex != 0) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
+ if (MsgSettingGetInt(keyName, &(cbOpt.maxSimCnt)) != MSG_SUCCESS) {
+ MSG_WARN("MsgSettingGetInt() is failed");
+ }
- if (cbOpt.channelData.channelCnt > cbOpt.maxSimCnt) {
- MSG_DEBUG("Channel Count [%d] is over Max SIM Count [%d]", cbOpt.channelData.channelCnt, cbOpt.maxSimCnt);
- return MSG_ERR_SET_SIM_SET;
+ if (cbOpt.channelData.channelCnt > cbOpt.maxSimCnt) {
+ MSG_INFO("Channel Count [%d] is over Max SIM Count [%d]", cbOpt.channelData.channelCnt, cbOpt.maxSimCnt);
+ return MSG_ERR_SET_SIM_SET;
+ }
}
}
-#endif
+
err = MsgSetConfigInSim(pSetting);
if (err != MSG_SUCCESS) {
MSG_ERR("Error to set config data in sim [%d]", err);
}
}
-#ifndef FEATURE_SMS_CDMA
- if (simIndex == 0) {
- MSG_DEBUG("SIM Index for Setting CB Option = 0, Setting for CB_RECEIVE success");
- return MSG_SUCCESS;
- }
+ if (!CDMASupported) {
+ if (simIndex == 0) {
+ MSG_INFO("SIM Index for Setting CB Option = 0, Setting for CB_RECEIVE success");
+ return MSG_SUCCESS;
+ }
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
- if (MsgSettingGetInt(keyName, &iValue) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- if (iValue != cbOpt.maxSimCnt) {
- if (MsgSettingSetInt(keyName, cbOpt.maxSimCnt) != MSG_SUCCESS) {
- MSG_ERR("Error to set config data [%s]", keyName);
- return MSG_ERR_SET_SETTING;
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
+ if (MsgSettingGetInt(keyName, &iValue) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+
+ if (iValue != cbOpt.maxSimCnt) {
+ if (MsgSettingSetInt(keyName, cbOpt.maxSimCnt) != MSG_SUCCESS) {
+ MSG_ERR("Error to set config data [%s]", keyName);
+ return MSG_ERR_SET_SETTING;
+ }
}
}
-#endif
MsgDbHandler *dbHandle = getDbHandle();
- err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData, simIndex);
+
+ if (CDMASupported == false) {
+ err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData, simIndex);
+ } else {
+ err = MsgStoAddCBChannelInfo(dbHandle, &cbOpt.channelData);
+ }
MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
-#ifndef FEATURE_SMS_CDMA
- if (bSetSim == true) {
- for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
+ if (CDMASupported == false) {
+ if (bSetSim == true) {
+ for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
- if (MsgSettingSetBool(keyName, cbOpt.bLanguage[i]) != MSG_SUCCESS) {
- MSG_ERR("Error to set config data [%s]", keyName);
- return MSG_ERR_SET_SETTING;
+ if (MsgSettingSetBool(keyName, cbOpt.bLanguage[i]) != MSG_SUCCESS) {
+ MSG_ERR("Error to set config data [%s]", keyName);
+ return MSG_ERR_SET_SETTING;
+ }
}
}
}
-#endif
return err;
}
memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+
MSG_DEBUG("Sim index = [%d]", simIndex);
/* Keep simIndex */
return;
}
-#ifndef FEATURE_SMS_CDMA
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
- if (MsgSettingGetInt(keyName, &(pSetting->option.cbMsgOpt.maxSimCnt)) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetInt() is failed");
-
-#endif
-
- err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex);
+ if (!CDMASupported) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
+ if (MsgSettingGetInt(keyName, &(pSetting->option.cbMsgOpt.maxSimCnt)) != MSG_SUCCESS) {
+ MSG_ERR("MsgSettingGetInt() is failed");
+ }
- if (err != MSG_SUCCESS)
- MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
+ err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
+ }
-#ifndef FEATURE_SMS_CDMA
- for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
+ for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, DEF_BUF_LEN, "%s/%d", CB_LANGUAGE, i);
- if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
+ if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS) {
+ MSG_ERR("MsgSettingGetBool() is failed");
+ }
+ }
+ } else {
+ err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
+ }
}
-#endif
}
#include "MsgNotificationWrapper.h"
#include "MsgDevicedWrapper.h"
#include "MsgTransManager.h"
+#include "MsgUtilFunction.h"
using namespace std;
MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
- if (bRead == true) {
-#ifndef FEATURE_SMS_CDMA
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+
+ if (bRead == true && !CDMASupported) {
/* Get STORAGE_ID */
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "SELECT STORAGE_ID FROM %s WHERE MSG_ID = %d;",
}
dbHandle->finalizeQuery();
}
-#endif
}
return MSG_SUCCESS;
char sqlQuery[MAX_QUERY_LEN+1];
MsgDbHandler *dbHandle = getDbHandle();
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
/* delete report notification */
char tempAddr[MAX_ADDRESS_VAL_LEN+1];
memset(tempAddr, 0x00, sizeof(tempAddr));
dbHandle->beginTrans();
-#ifndef FEATURE_SMS_CDMA
/* Check sim message */
- if (storageId == MSG_STORAGE_SIM) {
+ if (!CDMASupported && storageId == MSG_STORAGE_SIM) {
msg_sim_id_t simMsgId;
msg_sim_slot_id_t sim_idx;
dbHandle->finalizeQuery();
}
-#endif
/* each type has to be handled in plug in ? */
if (msgType.mainType == MSG_SMS_TYPE) {
memset(sqlQuery, 0x00, sizeof(sqlQuery));
return MSG_ERR_DB_EXEC;
}
-#ifdef FEATURE_SMS_CDMA
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_UNIQUENESS_INFO_TABLE_NAME, msgId);
+ if (CDMASupported == true) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_UNIQUENESS_INFO_TABLE_NAME, msgId);
- /* Delete Message from uniqueness table */
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
+ /* Delete Message from uniqueness table */
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_EXEC;
+ }
}
-#endif
if (convId > 0) {
/* Clear Conversation table */
queue<msg_thread_id_t> threadList, threadList2;
-#ifdef FEATURE_SMS_CDMA
- const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
- MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME,
- MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME,
- MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
- MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME,
- MSGFW_SENTFAIL_INDEX_TABLE_NAME};
-#else
- const char *tableList[] = {MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
- MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME,
- MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME,
- MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
- MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_SENTFAIL_INDEX_TABLE_NAME};
-#endif
+ const char *tableList[] = { MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME, MSGFW_SYNCML_MSG_TABLE_NAME,
+ MSGFW_SMS_SENDOPT_TABLE_NAME,
+ MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME,
+ MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
+ MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME,
+ MSGFW_SENTFAIL_INDEX_TABLE_NAME};
- int listCnt = sizeof(tableList)/sizeof(char *);
+ int listCnt = sizeof(tableList) / sizeof(char *);
int rowCnt = 0;
MsgDbHandler *dbHandle = getDbHandle();
signed char folder_id;
queue<msg_thread_id_t> threadList1, threadList2, threadList3;
-#ifdef FEATURE_SMS_CDMA
const char *tableList[] = {MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME,
MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME,
MSGFW_SMS_REPORT_TABLE_NAME, MSGFW_MMS_MULTIPART_TABLE_NAME,
MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_UNIQUENESS_INFO_TABLE_NAME,
MSGFW_SENTFAIL_INDEX_TABLE_NAME};
-#else
- const char *tableList[] = {MMS_PLUGIN_MESSAGE_TABLE_NAME, MSGFW_MMS_PREVIEW_TABLE_NAME,
- MSGFW_PUSH_MSG_TABLE_NAME, MSGFW_CB_MSG_TABLE_NAME,
- MSGFW_SYNCML_MSG_TABLE_NAME, MSGFW_SMS_SENDOPT_TABLE_NAME,
- MSGFW_REPORT_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME,
- MSGFW_SMS_REPORT_TABLE_NAME, MSGFW_MMS_MULTIPART_TABLE_NAME,
- MSGFW_MMS_RECIPIENTS_TABLE_NAME, MSGFW_SENTFAIL_INDEX_TABLE_NAME};
-#endif
int listCnt = sizeof(tableList)/sizeof(char *);
int rowCnt = 0;
break;
default: { /* Moving message to memory (when destination storage id is MSG_STORAGE_PHONE) */
-#ifndef FEATURE_SMS_CDMA
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+ if (!CDMASupported) {
bool bSimMsg = false;
int rowCnt = 0;
dbHandle->endTrans(true);
}
-#endif
}
- break;
+ }
+ break;
}
return MSG_SUCCESS;
return pMsg->msgId;
}
-#ifdef FEATURE_SMS_CDMA
+
msg_error_t MsgCheckUniqueness(bool bInsert, msg_message_id_t msgId, MSG_UNIQUE_INDEX_S *p_msg)
{
MSG_BEGIN();
return MSG_SUCCESS;
}
-#endif
+
msg_error_t MsgStoUpdateIMSI(int sim_idx)
{
delete [] (char*)msgIdList.msgIdList;
}
-#ifdef FEATURE_SMS_CDMA
eventSize = MsgMakeEvent(&msgInfo.msgId, sizeof(msg_message_id_t), MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
-#else
- eventSize = MsgMakeEvent(NULL, 0, MSG_EVENT_PLG_INCOMING_MSG_IND, err, (void**)ppEvent);
-#endif
if (msgInfo.bTextSms == false) {
MsgDeleteFile(msgInfo.msgData); /*ipc */
return eventSize;
}
-#ifdef FEATURE_SMS_CDMA
int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent)
{
MSG_BEGIN();
return eventSize;
}
-#endif
handlerMap[MSG_CMD_PLG_SENT_STATUS_CNF] = &MsgSentStatusHandler;
handlerMap[MSG_CMD_PLG_STORAGE_CHANGE_IND] = &MsgStorageChangeHandler;
- handlerMap[MSG_CMD_PLG_THREAD_CHANGE_IND] = &MsgThreadChangeHandler;
+ handlerMap[MSG_CMD_PLG_THREAD_CHANGE_IND] = &MsgThreadChangeHandler;
handlerMap[MSG_CMD_PLG_INCOMING_MSG_IND] = &MsgIncomingMsgHandler;
handlerMap[MSG_CMD_PLG_INCOMING_MMS_CONF] = &MsgIncomingMMSConfMsgHandler;
handlerMap[MSG_CMD_PLG_INCOMING_PUSH_IND] = &MsgIncomingPushMsgHandler;
handlerMap[MSG_CMD_DELETE_MESSAGE_BY_LIST] = &MsgDeleteMessageByListHandler;
handlerMap[MSG_CMD_ADD_SIM_MSG] = &MsgAddSimMessageHandler;
handlerMap[MSG_CMD_PLG_RESEND_MESSAGE] = &MsgResendMessageHandler;
-#ifdef FEATURE_SMS_CDMA
handlerMap[MSG_CMD_PLG_CHECK_UNIQUENESS] = &MsgCheckUniquenessHandler;
-#endif
handlerMap[MSG_CMD_UPDATE_IMSI] = &MsgUpdateIMSIHandler;
handlerMap[MSG_CMD_ALLOW_TCS_MESSAGE] = &MsgAllowTcsMessageHandler;
}
MSG_CMD_REG_REPORT_MSG_INCOMING_CB,
MSG_CMD_UPDATE_IMSI,
MSG_CMD_SET_TEMP_ADDRESS_TABLE,
-
-#ifdef FEATURE_SMS_CDMA
+/* 85 */
MSG_CMD_PLG_CHECK_UNIQUENESS,
-#endif
MSG_CMD_ALLOW_TCS_MESSAGE,
MSG_CMD_CHECK_PERMISSION,
MSG_EVENT_REG_REPORT_MSG_INCOMING_CB,
MSG_EVENT_UPDATE_IMSI,
MSG_EVENT_SET_TEMP_ADDRESS_TABLE,
-
-#ifdef FEATURE_SMS_CDMA
+/* 85 */
MSG_EVENT_PLG_CHECK_UNIQUENESS,
-#endif
MSG_EVENT_ALLOW_TCS_MESSAGE,
MSG_EVENT_CHECK_PERMISSION,
MSG_EVENT_REG_THREAD_CHANGE_CB,
#define DEFAULT_SETTING_PATH "db/private/msg-service"
#define DEFAULT_MSG_MEMORY_PATH "memory/private/msg-service"
-#ifdef FEATURE_SMS_CDMA
#define MSG_SIM_IMSI DEFAULT_MSG_MEMORY_PATH"/sim_imsi"
-#endif
+
#define MSG_SIM_SUBS_ID DEFAULT_MSG_MEMORY_PATH"/sim_subs_id"
#define MSG_SIM_CHANGED DEFAULT_MSG_MEMORY_PATH"/sim_changed"
#define SIM_USED_COUNT DEFAULT_SIM_COUNT_PATH"/used_cnt"
#define SIM_TOTAL_COUNT DEFAULT_SIM_COUNT_PATH"/total_cnt"
-#ifdef FEATURE_SMS_CDMA
#define MSG_MESSAGE_ID_COUNTER DEFAULT_GENERAL_OPT_PATH"/msg_id_counter"
-#endif
#define MSG_MESSAGE_DURING_CALL DEFAULT_GENERAL_OPT_PATH"/during_call"
#define MSG_DEFAULT_APP_ID "org.tizen.message"
#define MSG_TELEPHONY_SMS_FEATURE "http://tizen.org/feature/network.telephony.sms"
#define MSG_TELEPHONY_MMS_FEATURE "http://tizen.org/feature/network.telephony.mms"
+#define MSG_TELEPHONY_CDMA_FEATURE "http://tizen.org/feature/network.telephony.service.cdma"
#define MSG_TCS_MESSAGE "tcs_message"
msg_message_id_t msgId; /* Message Id of MSG_MESSAGE_TABLE */
} MSG_CB_MSG_S;
-#ifdef FEATURE_SMS_CDMA
typedef struct _MSG_UNIQUE_INDEX_S {
unsigned short tele_msgId;
char address[MAX_ADDRESS_VAL_LEN+1];
unsigned short serialNum;
unsigned short messageId; /**< Message Identifier */
} MSG_CB_DUPLICATE_S;
-#endif
/*==================================================================================================
*
*/
/*================================================================================================*/
-#ifdef FEATURE_SMS_CDMA
-typedef msg_error_t (*MsgPlgDeleteSimMessage)(msg_sim_id_t SimMsgId);
-#else
typedef msg_error_t (*MsgPlgDeleteSimMessage)(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
-#endif
/**
*
*/
/*================================================================================================*/
-#ifdef FEATURE_SMS_CDMA
-typedef msg_error_t (*MsgPlgSetReadStatus)(msg_sim_id_t SimMsgId);
-#else
typedef msg_error_t (*MsgPlgSetReadStatus)(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
-#endif
/**
*
*/
/*================================================================================================*/
-#ifdef FEATURE_SMS_CDMA
-typedef msg_error_t (*MsgPlgSetMemoryStatus)(msg_error_t Error);
-#else
typedef msg_error_t (*MsgPlgSetMemoryStatus)(msg_sim_slot_id_t sim_idx, msg_error_t Error);
-#endif
/* Setting API */
/**
typedef msg_error_t (*MsgPlgOnMmsConfIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo, msg_request_id_t *pRequest);
typedef msg_error_t (*MsgPlgOnSimMessageIncoming)(MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList, msg_message_id_t *retMsgId, int listSize);
typedef msg_error_t (*MsgPlgOnResendMessage)(void);
-#ifdef FEATURE_SMS_CDMA
typedef bool (*MsgPlgCheckUniqueness)(MSG_UNIQUE_INDEX_S *p_msg, msg_message_id_t msgId, bool ischecked);
-#endif
typedef msg_error_t (*MsgPlgOnInitImsi)(int sim_idx);
/*==================================================================================================
MsgPlgOnMmsConfIncoming pfMmsConfIncomingCb; /** The function pointer of receive MMS conf */
MsgPlgOnSimMessageIncoming pfSimMsgIncomingCb; /** The function pointer of sim message callback */
MsgPlgOnResendMessage pfResendMessageCb;
-#ifdef FEATURE_SMS_CDMA
MsgPlgCheckUniqueness pfCheckUniquenessCb;
-#endif
MsgPlgOnInitImsi pfSimInitImsiCb;
};
char prefix[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the prefix of contact. */
char suffix[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the suffix of contact. */
char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */
- char alerttonePath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the message alert tone path of contact. */
- char vibrationPath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the vibration path of contact. */
+ char alerttonePath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the message alert tone path of contact. */
+ char vibrationPath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the vibration path of contact. */
} MSG_CONTACT_INFO_S;
int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
int MsgUpdateIMSIHandler(const MSG_CMD_S *pCmd, char **ppEvent);
int MsgAllowTcsMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent);
-#ifdef FEATURE_SMS_CDMA
int MsgCheckUniquenessHandler(const MSG_CMD_S *pCmd, char **ppEvent);
-#endif
#endif /* MSG_CMD_HANDLER_H */
msg_error_t registerListener(MSG_PLUGIN_LISTENER_S *pListener);
msg_error_t saveSimMessage(MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
-#ifndef FEATURE_SMS_CDMA
+
msg_error_t deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
msg_error_t setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
msg_error_t setMemoryStatus(msg_sim_slot_id_t sim_idx, msg_error_t Error);
-#else
- msg_error_t deleteSimMessage(msg_sim_id_t SimMsgId);
- msg_error_t setReadStatus(msg_sim_id_t SimMsgId);
- msg_error_t setMemoryStatus(msg_error_t Error);
-#endif
+
msg_error_t setConfigData(const MSG_SETTING_S *pSetting);
msg_error_t getConfigData(MSG_SETTING_S *pSetting);
msg_error_t MsgStoAddCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo);
msg_error_t MsgStoCheckPushMsgValidation(MSG_PUSH_MESSAGE_S *pPushMsg, bool *pbProceed);
msg_error_t MsgStoUpdateAllAddress();
-#ifdef FEATURE_SMS_CDMA
msg_error_t MsgCheckUniqueness(bool bInsert, msg_message_id_t msgId, MSG_UNIQUE_INDEX_S *p_msg);
-#endif
msg_error_t MsgStoUpdateIMSI(int sim_idx);
msg_error_t MsgStoAllowTcsMessage(msg_message_id_t msgId);
msg_error_t MsgStoUpdateDPMRestrictedStatus(MSG_MAIN_TYPE_T msgType);
MSG_ENCODE_AUTO, /**< The string encoding type is AUTO */
MSG_ENCODE_GSM7BIT_ABNORMAL, /**< The string encoding type is GSM7BIT, but abnormal character included */
-#ifdef FEATURE_SMS_CDMA
+
MSG_ENCODE_EUCKR, /**< For EUC-KR(Korean) */
MSG_ENCODE_SHIFT_JIS, /**< For Shift-JIS(Japanese) */
MSG_ENCODE_ASCII7BIT, /**< the string encoding type is ASCII 7 BIT */
-#endif
};
} \
} while (0)
+#define MSG_ERR_M(expr, fmt, ...)\
+ do { \
+ if (expr) {\
+ MSG_ERR(fmt, ##__VA_ARGS__);\
+ } \
+ } while (0)
+
/*profile log macros*/
#define MSG_PROFILE_BEGIN(pfid) \
unsigned int __prf_l1_##pfid = __LINE__;\
#endif
#define MSGFW_CB_CHANNEL_INFO_TABLE_NAME "MSG_CB_CHANNEL_INFO_TABLE"
-#ifdef FEATURE_SMS_CDMA
#define MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME "MSG_CDMA_CB_CHANNEL_INFO_TABLE"
-#endif
#define MSGFW_SMS_SENDOPT_TABLE_NAME "MSG_SMS_SENDOPT_TABLE"
#define MSGFW_SMS_REPORT_TABLE_NAME "MSG_SMS_REPORT_TABLE"
#define MSGFW_MMS_MULTIPART_TABLE_NAME "MSG_MULTIPART_TABLE"
#define MSGFW_MMS_RECIPIENTS_TABLE_NAME "MSG_MMS_RECIPIENTS_TABLE"
-#ifdef FEATURE_SMS_CDMA
#define MSGFW_UNIQUENESS_INFO_TABLE_NAME "MSG_UNIQUENESS_INFO_TABLE"
-#endif
#define MSGFW_TMP_MSGID_TABLE_NAME "MSG_TMP_MSGID_TABLE"
INCLUDE FILES
==================================================================================================*/
#include <map>
+#include "msg_types.h"
/*==================================================================================================
int convertUTF8ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT bool *bIncludeAbnormalChar);
int convertUTF8ToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen);
- int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT msg_encode_type_t *pCharType);
+ int convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN msg_encode_type_t defaultEncodingType, OUT msg_encode_type_t *pCharType);
int convertGSM7bitToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo);
int convertUCS2ToUTF8(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen);
~MsgTextConvert();
int convertUCS2ToGSM7bit(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT MSG_LANGUAGE_ID_T *pLangId, OUT bool *bIncludeAbnormalChar);
-#ifndef FEATURE_SMS_CDMA
int convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown);
-#else
int convertUCS2ToASCII(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown);
-#endif
int convertGSM7bitToUCS2(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN MSG_LANG_INFO_S *pLangInfo);
msg_thread_id_t MsgGetThreadId(MsgDbHandler *pDbHandle, msg_message_id_t msgId);
-#ifdef FEATURE_SMS_CDMA
msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel);
msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel);
-#else
msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex);
msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex);
-#endif
bool MsgExistAddress(MsgDbHandler *pDbHandle, const MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t *pConvId);
bool MsgExistAddress(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsg, msg_thread_id_t convId, int index);
msg_error_t MsgStoDbSelectWithQuery(const char *query, char ***db_res, int *row_count, int *col_count);
void MsgStoDbFree(char **db_res);
-#ifdef FEATURE_SMS_CDMA
msg_error_t MsgStoClearUniquenessTable();
-#endif
-
#endif /* MSG_UTIL_STORAGE_H */
if (msg_text == NULL || text_size == NULL || segment_size == NULL || msg_encode_type_in == NULL)
return MSG_ERR_INVALID_PARAMETER;
-#ifdef FEATURE_SMS_CDMA
if (msg_encode_type_to > MSG_ENCODE_ASCII7BIT) {
-#else
- if (msg_encode_type_to > MSG_ENCODE_GSM7BIT_ABNORMAL) {
-#endif
MSG_FATAL("unsupported msg_encode_type [%d]", msg_encode_type_to);
return MSG_ERR_INVALID_PARAMETER;
}
case MSG_ENCODE_UCS2:
decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (const unsigned char*)msg_text, textSize);
break;
- case MSG_ENCODE_AUTO:
- decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, &encodeType);
- break;
+ case MSG_ENCODE_AUTO: {
+ msg_encode_type_t defaultEncodingType = MSG_ENCODE_GSM7BIT;
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+ if (CDMASupported) {
+ defaultEncodingType = MSG_ENCODE_ASCII7BIT;
+ }
+ decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (const unsigned char*)msg_text, textSize, defaultEncodingType, &encodeType);
+ }
+ break;
default:
return MSG_ERR_INVALID_PARAMETER;
}
}
*msg_encode_type_in = MSG_ENCODE_UCS2;
-#ifdef FEATURE_SMS_CDMA
} else if (encodeType == MSG_ENCODE_ASCII7BIT) {
MSG_DEBUG("MSG_ENCODE_ASCII7BIT");
segSize = 160;
*msg_encode_type_in = MSG_ENCODE_GSM7BIT;
-#endif
-
} else {
MSG_DEBUG("Unsupported encode type.");
err = MSG_ERR_INVALID_PARAMETER;
#include <stdlib.h>
#include <time.h>
#include <curl/curl.h>
+#include "MsgUtilFunction.h"
#include "MmsPluginDebug.h"
#include "MmsPluginHttp.h"
#include "MmsPluginUserAgent.h"
static void __http_print_profile(CURL *curl);
static int __http_debug_cb(CURL *input_curl, curl_infotype input_info_type, char *input_data, size_t input_size, void *input_void);
-
static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int ulContentLen);
static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer);
static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen);
if (nResult) {
snprintf(pcheader, HTTP_REQUEST_LEN, "Accept-Encoding: %s", szBuffer);
MSG_DEBUG("%s", pcheader);
- *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
+ *responseHeaders = curl_slist_append(*responseHeaders, pcheader);
}
*/
memset(szBuffer, 0, 1025);
*responseHeaders = curl_slist_append(*responseHeaders, pcheader);
}
-#if defined(FEATURE_SMS_CDMA)
- memset(szBuffer, 0, 1025);
- memset(pcheader, 0, HTTP_REQUEST_LEN);
- nResult = __httpGetHeaderField(MMS_HH_MDN, szBuffer);
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+ if (CDMASupported) {
+ memset(szBuffer, 0, 1025);
+ memset(pcheader, 0, HTTP_REQUEST_LEN);
+ nResult = __httpGetHeaderField(MMS_HH_MDN, szBuffer);
+ }
/* TODO : if it needs to check http header mdn value, add code to below. */
-#endif
if (ulContentLen > 0) /* if post transaction then Disable 'Expect: 100-contine' option */
*responseHeaders = curl_slist_append(*responseHeaders, "Expect:");
bool result;
result = false;
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
if (szHeaderBuffer != NULL) {
switch (httpHeaderItem) {
case MMS_HH_CONTENT_TYPE:
snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_CONTENT_TYPE);
result = true;
break;
-
case MMS_HH_ACCEPT:
snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_ACCEPT);
result = true;
case MMS_HH_ACCEPT_CHARSET:
snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_CHARSET);
-#if defined(FEATURE_SMS_CDMA)
- result = false;
-#else
- result = true;
-#endif
+ if (CDMASupported) {
+ result = false;
+ } else {
+ result = true;
+ }
break;
case MMS_HH_ACCEPT_LANGUAGE:
snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_LANGUAGE);
result = true;
break;
-
case MMS_HH_ACCEPT_ENCODING:
snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_ENCODING);
result = true;
break;
-
case MMS_HH_USER_AGENT: {
-#if 0
- char szUserAgent[1024 + 1];
- char *uagent = NULL;
-
- if (MsgSettingGetString(VCONFKEY_BROWSER_USER_AGENT, &uagent) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- if (uagent && strlen(uagent) > 0) {
- MSG_SEC_INFO("Get UserAgent : %s = %s", VCONFKEY_BROWSER_USER_AGENT, uagent);
- memset(szUserAgent, 0x00, sizeof(szUserAgent));
- MmsRemoveMarkup(uagent, szUserAgent, sizeof(szUserAgent));
- } else {
- memset(szUserAgent, 0x00, sizeof(szUserAgent));
- MSG_SEC_INFO("Get Default UserAgent : %s", MSG_MMS_HH_USER_AGENT);
- snprintf(szUserAgent, 1024, "%s", MSG_MMS_HH_USER_AGENT);
- }
-
- snprintf((char *)szHeaderBuffer, 1024, "%s", szUserAgent);
- if (uagent) {
- free(uagent);
- uagent = NULL;
- }
-#else
- snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_USER_AGENT);
-#endif
- result = true;
- }
- break;
+ snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_USER_AGENT);
+ result = true;
+ }
+ break;
case MMS_HH_UA_PROFILE: {
- char *szUAProfile = NULL;
- if (MsgSettingGetString(MSG_MMS_UA_PROFILE, &szUAProfile) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
+ char *szUAProfile = NULL;
+ if (MsgSettingGetString(MSG_MMS_UA_PROFILE, &szUAProfile) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
- snprintf((char *)szHeaderBuffer, 1024, "%s", szUAProfile);
- if (szUAProfile) {
- free(szUAProfile);
- szUAProfile = NULL;
- }
- result = true;
+ snprintf((char *)szHeaderBuffer, 1024, "%s", szUAProfile);
+ if (szUAProfile) {
+ free(szUAProfile);
+ szUAProfile = NULL;
}
- break;
+ result = true;
+ }
+ break;
-#if defined(FEATURE_SMS_CDMA)
case MMS_HH_MDN: {
+ if (CDMASupported) {
/*
char *mdn = NULL;
if (MsgSettingGetString(MSG_SIM_MSISDN, &mdn) != MSG_SUCCESS) {
free(mdn);
mdn = NULL;
}
- break;
-*/
+ */
+ }
+ break;
}
-#endif
default:
MSG_WARN("invalid param [%d]", httpHeaderItem);
break;
MMS_HH_ACCEPT_ENCODING,
MMS_HH_USER_AGENT,
MMS_HH_UA_PROFILE,
-#if defined(FEATURE_SMS_CDMA)
MMS_HH_MDN
-#endif
} MMS_HTTP_HEADER_FIELD_E;
typedef enum _MMS_HTTP_TRANSACTION_TYPE_E {
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(sms-plugin CXX)
-
-SET(CMAKE_SKIP_BUILD_RPATH TRUE)
-
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall")
-
-##########################################################
-# Define SMS Plugin
-##########################################################
-
-SET(SMS-PLUGIN-SRCS
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginCallback.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginCodec.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginMain.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginParamCodec.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginTransport.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp
-)
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}/include/mapi
- ${CMAKE_SOURCE_DIR}/include/common
- ${CMAKE_SOURCE_DIR}/include/utils
- ${CMAKE_SOURCE_DIR}/include/externals
- ${CMAKE_CURRENT_SOURCE_DIR}/include
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 bundle eventsystem)
-
-FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-ADD_LIBRARY(${SMS-PLUGIN-LIB} SHARED ${SMS-PLUGIN-SRCS})
-TARGET_LINK_LIBRARIES(${SMS-PLUGIN-LIB} ${sms_plugin_pkgs_LDFLAGS} ${UTILS-LIB} ${EXTERNALS-LIB})
-
-IF(_FEATURE_TELEPHONY_ENABLE)
-INSTALL(TARGETS ${SMS-PLUGIN-LIB} LIBRARY DESTINATION ${LIBDIR})
-ENDIF(_FEATURE_TELEPHONY_ENABLE)
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <glib.h>
-#include <pthread.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "SmsCdmaPluginEventHandler.h"
-#include "SmsCdmaPluginParamCodec.h"
-#include "SmsCdmaPluginCodec.h"
-#include "SmsCdmaPluginTransport.h"
-#include "SmsCdmaPluginSetting.h"
-#include "SmsCdmaPluginCallback.h"
-
-
-extern struct tapi_handle *pTapiHandle;
-extern bool isMemAvailable;
-
-void _dnet_state_changed_cb(keynode_t *key, void* data);
-void _TapiMdnChangedCb(keynode_t *key, void *data);
-
-/*==================================================================================================
- FUNCTION IMPLEMENTATION
-==================================================================================================*/
-
-SmsPluginCallback* SmsPluginCallback::pInstance = NULL;
-
-
-SmsPluginCallback::SmsPluginCallback()
-{
-}
-
-
-SmsPluginCallback::~SmsPluginCallback()
-{
- if (pInstance != NULL) {
- delete pInstance;
- pInstance = NULL;
- }
-}
-
-
-SmsPluginCallback* SmsPluginCallback::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginCallback();
-
- return pInstance;
-}
-
-
-void SmsPluginCallback::registerEvent()
-{
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_DEVICE_READY, TapiEventDeviceReady, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_DEVICE_READY);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_INCOM_MSG, TapiEventMsgIncoming, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_INCOM_MSG);
- if (tel_register_noti_event(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, TapiEventNetworkStatusChange, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_PROP_NETWORK_SERVICE_TYPE);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_REFRESHED, TapiEventSimRefreshed, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_REFRESHED);
-
- msg_error_t err = MSG_SUCCESS;
- err = MsgSettingRegVconfCBCommon(VCONFKEY_DNET_STATE, _dnet_state_changed_cb);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("MsgSettingRegVconfCBCommon() is failed");
- }
- /* MsgSettingRegVconfCBCommon(VCONFKEY_TELEPHONY_MDN, _TapiMdnChangedCb); */
-}
-
-
-void SmsPluginCallback::deRegisterEvent()
-{
-}
-
-
-void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventDeviceReady is called. : noti_id = [%d]", noti_id);
-
- try {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->setDeviceStatus();
-
- if (SmsPluginEventHandler::instance()->getNeedInitConfig() == true) {
- SmsPluginEventHandler::instance()->setNeedInitConfig(false);
- SmsPluginSetting::instance()->SimRefreshCb();
- }
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_WARN("TapiEventMsgIncoming is called. noti_id [%s]", noti_id);
-
- if (data == NULL) {
- MSG_DEBUG("Error. evt->pData is NULL.");
- return;
- }
-
- TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
-
- MSG_DEBUG("pDataPackage->format = [%d]", pDataPackage->format);
- MSG_DEBUG("pDataPackage->Sca = [%s]", pDataPackage->Sca);
- MSG_DEBUG("pDataPackage->MsgLength = [%d]", pDataPackage->MsgLength);
- MSG_DEBUG("pDataPackage->szData = ");
- for (int i = 0; i < pDataPackage->MsgLength; i++) {
- MSG_DEBUG("[%02x]", pDataPackage->szData[i]);
- }
-
- char tpduTmp[(pDataPackage->MsgLength*2)+1];
- memset(tpduTmp, 0x00, sizeof(tpduTmp));
- for (int i = 0; i < pDataPackage->MsgLength; i++) {
- snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pDataPackage->szData[i]);
- }
- MSG_WARN("[%s]", tpduTmp);
-
- sms_trans_msg_s sms_trans_msg;
- memset(&sms_trans_msg, 0x00, sizeof(sms_trans_msg_s));
-
- if (pDataPackage->format == (TelSmsNetType_t)0x03) {
- /* voice mail notification */
- sms_trans_msg.data.p2p_msg.telesvc_msg.type = SMS_TYPE_DELIVER;
- sms_trans_msg.data.p2p_msg.telesvc_id = SMS_TRANS_TELESVC_VMN_95;
-
- int num_msg = 0;
- for (int i = 0; i < pDataPackage->MsgLength; i++) {
- num_msg*=256;
- num_msg+=pDataPackage->szData[i];
- }
-
- sms_trans_msg.data.p2p_msg.telesvc_msg.data.deliver.num_msg = num_msg;
-
- char *voiceNumber = NULL;
- if (MsgSettingGetString(VOICEMAIL_NUMBER, &voiceNumber) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
- if (voiceNumber) {
- snprintf(sms_trans_msg.data.p2p_msg.address.szData, sizeof(sms_trans_msg.data.p2p_msg.address.szData), "%s", voiceNumber);
- free(voiceNumber);
- voiceNumber = NULL;
- }
- sms_trans_msg.data.p2p_msg.address.addr_len = strlen(sms_trans_msg.data.p2p_msg.address.szData);
- } else {
- bool bInvalid = SmsPluginMsgCodec::checkInvalidPDU(pDataPackage->szData, pDataPackage->MsgLength);
- if (bInvalid == true) {
- /* Decode Incoming Message */
- SmsPluginMsgCodec::decodeMsg(pDataPackage->szData, pDataPackage->MsgLength, &sms_trans_msg);
-
- if (sms_trans_msg.data.cb_msg.telesvc_msg.data.deliver.cmas_data.is_wrong_recode_type) {
- MSG_WARN("Invalid CMAS Record Type");
- return;
- }
- } else {
- MSG_WARN("Invalid PDU");
- return;
- }
- }
-
- /* Print tpdu */
- if (sms_trans_msg.type == SMS_TRANS_P2P_MSG) {
- MSG_DEBUG("############# SMS_TRANS_P2P_MSG Incoming decoded tpdu values ####################");
- MSG_DEBUG("------------------------------ transport layer data -----------------------------");
- MSG_DEBUG("sms_trans_msg.type = [%d]", sms_trans_msg.type);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.telesvc_id = [%d]", sms_trans_msg.data.p2p_msg.telesvc_id);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.digit_mode = [%d]", sms_trans_msg.data.p2p_msg.address.digit_mode);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.number_mode = [%d]", sms_trans_msg.data.p2p_msg.address.number_mode);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.number_plan = [%d]", sms_trans_msg.data.p2p_msg.address.number_plan);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.number_type = [%d]", sms_trans_msg.data.p2p_msg.address.number_type);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.addr_len = [%d]", sms_trans_msg.data.p2p_msg.address.addr_len);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.szData = [%s]", sms_trans_msg.data.p2p_msg.address.szData);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.svc_ctg = [%d]", sms_trans_msg.data.p2p_msg.svc_ctg);
- MSG_DEBUG("----------------------- teleservice layer : deliver data -------------------------");
- sms_telesvc_deliver_s *deliver_msg = &(sms_trans_msg.data.p2p_msg.telesvc_msg.data.deliver);
- MSG_DEBUG("sms_trans_msg.data.p2p_msg.telesvc_msg.type = [%d]", sms_trans_msg.data.p2p_msg.telesvc_msg.type);
- MSG_DEBUG("priority= [%d]", deliver_msg->priority);
- MSG_DEBUG("privacy= [%d]", deliver_msg->privacy);
- MSG_DEBUG("display_mode= [%d]", deliver_msg->display_mode);
- MSG_DEBUG("language= [%d]", deliver_msg->language);
- MSG_DEBUG("msg_id= [%d]", deliver_msg->msg_id);
- MSG_DEBUG("alert_priority= [%d]", deliver_msg->alert_priority);
- MSG_DEBUG("num_msg= [%d]", deliver_msg->num_msg);
- MSG_DEBUG("user_data.msg_type= [%d]", deliver_msg->user_data.msg_type);
- MSG_DEBUG("user_data.encode_type= [%d]", deliver_msg->user_data.encode_type);
- MSG_DEBUG("user_data.data_len= [%d]", deliver_msg->user_data.data_len);
- MSG_DEBUG("user_data.user_data= [%s]", deliver_msg->user_data.user_data);
- MSG_DEBUG("time_stamp.year= [%d]", deliver_msg->time_stamp.year);
- MSG_DEBUG("time_stamp.month= [%d]", deliver_msg->time_stamp.month);
- MSG_DEBUG("time_stamp.day= [%d]", deliver_msg->time_stamp.day);
- MSG_DEBUG("time_stamp.hours= [%d]", deliver_msg->time_stamp.hours);
- MSG_DEBUG("time_stamp.minutes= [%d]", deliver_msg->time_stamp.minutes);
- MSG_DEBUG("time_stamp.seconds= [%d]", deliver_msg->time_stamp.seconds);
- MSG_DEBUG("deliver_msg->callback_number.addr_len= [%d]", deliver_msg->callback_number.addr_len);
- MSG_DEBUG("deliver_msg->callback_number.digit_mode= [%d]", deliver_msg->callback_number.digit_mode);
- MSG_DEBUG("deliver_msg->callback_number.number_plan= [%d]", deliver_msg->callback_number.number_plan);
- MSG_DEBUG("deliver_msg->callback_number.number_type= [%d]", deliver_msg->callback_number.number_type);
- MSG_DEBUG("deliver_msg->callback_number.szData= [%s]", deliver_msg->callback_number.szData);
- MSG_DEBUG("#####################################################");
- } else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
- MSG_DEBUG("############# SMS_TRANS_BROADCAST_MSG Incoming decoded tpdu values ####################");
- MSG_DEBUG("------------------------------ transport layer data -----------------------------");
- MSG_DEBUG("sms_trans_msg.data.cb_msg.svc_ctg = [%d]", sms_trans_msg.data.cb_msg.svc_ctg);
- MSG_DEBUG("----------------------- teleservice layer : deliver data -------------------------");
- sms_telesvc_deliver_s *deliver_msg = &(sms_trans_msg.data.cb_msg.telesvc_msg.data.deliver);
- MSG_DEBUG("sms_trans_msg.data.cb_msg.telesvc_msg.type = [%d]", sms_trans_msg.data.cb_msg.telesvc_msg.type);
- MSG_DEBUG("priority= [%d]", deliver_msg->priority);
- MSG_DEBUG("display_mode= [%d]", deliver_msg->display_mode);
- MSG_DEBUG("language= [%d]", deliver_msg->language);
- MSG_DEBUG("msg_id= [%d]", deliver_msg->msg_id);
- MSG_DEBUG("msg_id.msg_id)= [%d]", deliver_msg->msg_id.msg_id);
- MSG_DEBUG("header_ind= [%d]", deliver_msg->msg_id.header_ind);
- MSG_DEBUG("alert_priority= [%d]", deliver_msg->alert_priority);
- MSG_DEBUG("cmas_data.encode_type= [%d]", deliver_msg->cmas_data.encode_type);
- MSG_DEBUG("cmas_data.data_len= [%d]", deliver_msg->cmas_data.data_len);
- MSG_DEBUG("cmas_data.alert_text= [%s]", deliver_msg->cmas_data.alert_text);
- MSG_DEBUG("cmas_data.response_type= [%d]", deliver_msg->cmas_data.response_type);
- MSG_DEBUG("cmas_data.severity= [%d]", deliver_msg->cmas_data.severity);
- MSG_DEBUG("cmas_data.urgency= [%d]", deliver_msg->cmas_data.urgency);
- MSG_DEBUG("cmas_data.certainty= [%d]", deliver_msg->cmas_data.certainty);
- MSG_DEBUG("cmas_data.id= [%d]", deliver_msg->cmas_data.id);
- MSG_DEBUG("time_stamp.year= [%d]", deliver_msg->time_stamp.year);
- MSG_DEBUG("time_stamp.month= [%d]", deliver_msg->time_stamp.month);
- MSG_DEBUG("time_stamp.day= [%d]", deliver_msg->time_stamp.day);
- MSG_DEBUG("time_stamp.hours= [%d]", deliver_msg->time_stamp.hours);
- MSG_DEBUG("time_stamp.minutes= [%d]", deliver_msg->time_stamp.minutes);
- MSG_DEBUG("time_stamp.seconds= [%d]", deliver_msg->time_stamp.seconds);
- MSG_DEBUG("deliver_msg->callback_number.addr_len= [%d]", deliver_msg->callback_number.addr_len);
- MSG_DEBUG("deliver_msg->callback_number.digit_mode= [%d]", deliver_msg->callback_number.digit_mode);
- MSG_DEBUG("deliver_msg->callback_number.number_plan= [%d]", deliver_msg->callback_number.number_plan);
- MSG_DEBUG("deliver_msg->callback_number.number_type= [%d]", deliver_msg->callback_number.number_type);
- MSG_DEBUG("deliver_msg->callback_number.szData= [%s]", deliver_msg->callback_number.szData);
- MSG_DEBUG("#####################################################");
- } else if (sms_trans_msg.type == SMS_TRANS_ACK_MSG) {
- /* DLOG */
- MSG_DEBUG("#####################################################");
- }
-
- try {
- if (sms_trans_msg.type == SMS_TRANS_P2P_MSG) {
- if (sms_trans_msg.data.p2p_msg.telesvc_id == SMS_TRANS_TELESVC_WAP) {
- SmsPluginEventHandler::instance()->handleWapMsgIncoming(&(sms_trans_msg.data.p2p_msg));
- } else {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleMsgIncoming(&(sms_trans_msg.data.p2p_msg));
- }
- } else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleCbMsgIncoming(&(sms_trans_msg.data.cb_msg));
- } else if (sms_trans_msg.type == SMS_TRANS_ACK_MSG) {
- /* Call Event Handler */
- /* SmsPluginEventHandler::instance()->handleAckMsgIncoming(&(sms_trans_msg.data.ack_msg)); */
- }
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventNetworkStatusChange is called.");
-
- if (data == NULL) {
- MSG_DEBUG("Error. data is NULL.");
- return;
- }
-
- TelNetworkServiceType_t *type = (TelNetworkServiceType_t *)data;
-
- MSG_DEBUG("network status type [%d]", *type);
-
- if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleResendMessage();
- }
-}
-
-
-void TapiEventSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSimRefreshed is called.");
-
- SmsPluginSetting::instance()->SimRefreshCb();
-}
-
-
-void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("Tapi result is [%d]", result);
- if (result == TAPI_API_SUCCESS) {
- isMemAvailable = true;
- }
-}
-
-
-void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSentStatus is called. result = [%d]", result);
-
- sms_network_status_t sentStatus;
-
- /* Convert TAPI status -> SMS network status */
- switch ((TelSmsResponse_t)result) {
- case TAPI_NETTEXT_SENDSMS_SUCCESS:
- sentStatus = SMS_NETWORK_SEND_SUCCESS;
- break;
- case TAPI_NETTEXT_INVALID_MANDATORY_INFO:
- sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
- break;
- case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE:
- case TAPI_NETTEXT_TEMPORARY_FAILURE:
- case TAPI_NETTEXT_CONGESTION:
- case TAPI_NETTEXT_RESOURCES_UNAVAILABLE:
- case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL:
- sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
- break;
- case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED:
- case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED:
- sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
- break;
- default:
- sentStatus = SMS_NETWORK_SEND_FAIL;
- break;
- }
-
- MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
-
- if (sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
- sentStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING ||
- sentStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
- SmsPluginTransport::instance()->setNetStatus(sentStatus);
- return;
- }
-
- if (sentStatus == SMS_NETWORK_SEND_FAIL) {
- int svc_type;
- tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
- if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
- sentStatus = SMS_NETWORK_SEND_PENDING;
- }
- }
-
- /* Convert SMS status -> Messaging network status */
- msg_network_status_t netStatus;
-
- if (sentStatus == SMS_NETWORK_SEND_SUCCESS) {
- netStatus = MSG_NETWORK_SEND_SUCCESS;
- } else if (sentStatus == SMS_NETWORK_SENDING) {
- netStatus = MSG_NETWORK_SENDING;
- } else if (sentStatus == SMS_NETWORK_SEND_PENDING) {
- netStatus = MSG_NETWORK_SEND_PENDING;
- } else if (sentStatus == SMS_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER) {
- netStatus = MSG_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER;
- } else if (sentStatus == SMS_NETWORK_SEND_FAIL_MS_DISABLED) {
- netStatus = MSG_NETWORK_SEND_FAIL_MS_DISABLED;
- } else if (sentStatus == SMS_NETWORK_SEND_FAIL_NETWORK_NOT_READY) {
- netStatus = MSG_NETWORK_SEND_FAIL_NETWORK_NOT_READY;
- } else {
- netStatus = MSG_NETWORK_SEND_FAIL;
- }
-
- try {
- SmsPluginEventHandler::instance()->handleSentStatus(netStatus);
-
- SmsPluginTransport::instance()->setNetStatus(sentStatus);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventDeliveryReportCNF is called. : result = [%d]", result);
-
- return;
-}
-
-
-void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSetConfigData is called.");
-
- if (data == NULL) {
- MSG_DEBUG("Error. data is NULL.");
- SmsPluginSetting::instance()->setResultFromEvent(false);
- return;
- }
-
- TelSmsSetResponse* responseType = (TelSmsSetResponse*)data;
-
- MSG_DEBUG("responseType : [%d]", *responseType);
-
- switch (*responseType) {
- case TAPI_NETTEXT_SETPREFERREDBEARER_RSP:
- MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
- break;
- case TAPI_NETTEXT_SETPARAMETERS_RSP:
- MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
- break;
- case TAPI_NETTEXT_CBSETCONFIG_RSP:
- MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
- break;
- case TAPI_NETTEXT_SETMEMORYSTATUS_RSP:
- MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
- break;
- case TAPI_NETTEXT_SETMESSAGESTATUS_RSP:
- MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
- break;
- default:
- MSG_DEBUG("Unknown Response is called [%d]", *responseType);
- break;
- }
-
- bool bRet = true;
-
- MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
-
- if ((TelSmsCause_t)result != TAPI_NETTEXT_SUCCESS) bRet = false;
-
- SmsPluginSetting::instance()->setResultFromEvent(bRet);
-}
-
-
-void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventGetCBConfig is called.");
-
- MSG_CBMSG_OPT_S cbOpt = {0};
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_DEBUG("Error. data is NULL.");
-
- SmsPluginSetting::instance()->setCbConfigEvent(NULL, false);
-
- return;
- }
-
- TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)data;
-
- cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
-
- /* cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount; */
- /* MSG_DEBUG("Receive [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.maxSimCnt); */
-
- MSG_DEBUG("Receive [%d]", cbOpt.bReceive);
-
- cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
-
- if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX) {
- MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
- cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
- }
-
- MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
-
- for (int i = 0; i < cbOpt.channelData.channelCnt; i++) {
- cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp2.Selected;
- cbOpt.channelData.channelInfo[i].ctg = pCBConfig->MsgIDs[i].Net3gpp2.CBCategory;
- cbOpt.channelData.channelInfo[i].lang = pCBConfig->MsgIDs[i].Net3gpp2.CBLanguage;
- memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
-
- MSG_DEBUG("Channel Category [%d], Channel Language [%d] ", cbOpt.channelData.channelInfo[i].ctg, cbOpt.channelData.channelInfo[i].lang);
- }
-
- SmsPluginSetting::instance()->setCbConfigEvent(&cbOpt, true);
-}
-
-
-void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
-
- bool bRet = false;
-
- if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
- MSG_DEBUG("Error. data is NULL.");
- SmsPluginSetting::instance()->setResultFromSim(bRet);
- return;
- }
-
- TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int simIndex = 1;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
-
- for (int i = 0; i < list->count; i++) {
- if (list->list[i].num[0] != '\0') {
- if (MsgSettingSetString(keyName, list->list[i].num) == MSG_SUCCESS) {
- MSG_SEC_DEBUG("Get MSISDN from SIM : [%s]", list->list[i].num);
- bRet = true;
- } else {
- MSG_DEBUG("Getting MSISDN is failed!");
- }
- break;
- }
- }
-
- SmsPluginSetting::instance()->setResultFromSim(bRet);
-}
-
-
-void _dnet_state_changed_cb(keynode_t *key, void* data)
-{
- int dnet_state = 0;
- if (MsgSettingGetInt(VCONFKEY_DNET_STATE, &dnet_state) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
-
- if (dnet_state > VCONFKEY_DNET_OFF) {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleResendMessage();
- }
-}
-
-
-void _TapiMdnChangedCb(keynode_t *key, void *data)
-{
- MSG_INFO("_TapiMdnChangedCb is called.");
-
- char *mdn = vconf_get_str("db/telephony/mdn");
-
- if (mdn) {
- bool bNeedToUpdateVoicemail = SmsPluginSetting::instance()->getUpdateVoicemailByMdn();
- MSG_INFO("bNeedToUpdateVoicemail:%d, mdn:[%s]", bNeedToUpdateVoicemail, mdn);
-
- if (bNeedToUpdateVoicemail) {
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int sim_idx = 1;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
- if (MsgSettingSetString(keyName, mdn) != MSG_SUCCESS)
- MSG_DEBUG("Error to set config data [%s]", keyName);
- }
-
- free(mdn);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <stdio.h>
-#include <string.h>
-
-#include "MsgDebug.h"
-#include "MsgTextConvert.h"
-
-#include "SmsCdmaPluginParamCodec.h"
-#include "SmsCdmaPluginCodec.h"
-
-
-SmsPluginMsgCodec* SmsPluginMsgCodec::pInstance = NULL;
-
-
-SmsPluginMsgCodec::SmsPluginMsgCodec()
-{
-}
-
-
-SmsPluginMsgCodec::~SmsPluginMsgCodec()
-{
-}
-
-
-SmsPluginMsgCodec* SmsPluginMsgCodec::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginMsgCodec();
-
- return pInstance;
-}
-
-
-void _shiftNBit(unsigned char *src, unsigned int n_bytes, unsigned int n_shift_bit)
-{
- char tmp;
-
- for (unsigned int index = 1; index < n_bytes; index++) {
- tmp = src[index] >> (8 - n_shift_bit);
- src[index-1] |= tmp;
- src[index] = src[index] << n_shift_bit;
- }
-}
-
-
-void _shiftNBit_for_decode(unsigned char *src, unsigned int n_bytes, unsigned int n_shift_bit)
-{
- for (unsigned int index = 0; index < n_bytes; index++) {
- src[index]<<=n_shift_bit;
- src[index] |= (src[index+1] >> (8 - n_shift_bit));
- }
-}
-
-
-void _copy_short_to_char(unsigned char *dest, const unsigned short *src)
-{
- dest[0] = (0xff00 & *src) >> 8;
- dest[1] = 0x00ff & *src;
-}
-
-
-void _copy_char_to_short(unsigned short *dest, const unsigned char *src)
-{
- *dest = src[0]*256 + src[1];
-}
-
-
-unsigned char _convert_to_BCD(unsigned char val)
-{
- unsigned char ret = 0x00;
- ret = ((val/10) << 4) | (val%10);
- return ret;
-}
-
-
-int UnpackGSM7bitData(unsigned char *src, unsigned char *dest, unsigned int dataLen)
-{
- unsigned int srcIdx = 0, dstIdx = 0, shift = 0;
-
- MSG_DEBUG("dataLen = %d", dataLen);
-
- for (; dstIdx < dataLen; dstIdx++) {
- if (shift == 0) {
- dest[dstIdx] = src[srcIdx] & 0x7F;
-
- shift = 7;
- srcIdx++;
- dstIdx++;
-
- if (dstIdx >= dataLen)
- break;
- }
-
- if (shift > 0) {
- dest[dstIdx] = (src[srcIdx-1] >> shift) + (src[srcIdx] << (8 - shift));
-
- dest[dstIdx] &= 0x7F;
-
- shift--;
-
- if (shift > 0)
- srcIdx++;
- }
- }
-
- return dstIdx;
-}
-
-
-int PackGSM7bitData(const unsigned char *pUserData, unsigned char *pPackData, int dataLen)
-{
- int srcIdx = 0, dstIdx = 0, shift = 0;
-
- if (shift > 0)
- dstIdx = 1;
-
- while (srcIdx < dataLen) {
- if (shift == 0) {
- pPackData[dstIdx] = pUserData[srcIdx];
-
- shift = 7;
- srcIdx++;
- dstIdx++;
-
- if (srcIdx >= dataLen)
- break;
- }
-
- if (shift > 1) {
- pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
- pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
- shift--;
-
- srcIdx++;
- dstIdx++;
- } else if (shift == 1) {
- pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
-
- srcIdx++;
-
- shift--;
- }
- }
-
- return dstIdx;
-}
-
-
-bool SmsPluginMsgCodec::checkInvalidPDU(const unsigned char *p_pkg_str, const int p_pkg_len)
-{
- MSG_BEGIN();
- int offset = 0;
-
- if (!(p_pkg_str[offset] == 0x00 || p_pkg_str[offset] == 0x01 || p_pkg_str[offset] == 0x02)) {
- MSG_WARN("Invalid PDU : Message Type [%2x]", p_pkg_str[offset]);
- return false;
- }
-
- offset++;
-
- while (offset < p_pkg_len) {
- switch (p_pkg_str[offset]) {
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x08:
- offset += (p_pkg_str[offset+1]+2);
- break;
- default:
- MSG_WARN("Invalid PDU : Parameter ID [%2x], offset [%d]", p_pkg_str[offset], offset);
- return false;
- }
- }
-
- if (offset != p_pkg_len)
- return false;
-
- MSG_END();
- return true;
-}
-
-
-int SmsPluginMsgCodec::encodeMsg(const sms_trans_msg_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int encode_size = 0;
-
- switch (p_msg->type) {
- case SMS_TRANS_P2P_MSG:
- encode_size = encodeP2PMsg(&(p_msg->data.p2p_msg), p_pkg_str);
- break;
- case SMS_TRANS_BROADCAST_MSG:
- encode_size = encodeCBMsg(&(p_msg->data.cb_msg), p_pkg_str);
- break;
- case SMS_TRANS_ACK_MSG:
- encode_size = encodeAckMsg(&(p_msg->data.ack_msg), p_pkg_str);
- break;
- default:
- break;
- }
-
-
- MSG_END();
-
- return encode_size;
-}
-
-
-int SmsPluginMsgCodec::encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0, encode_size = 0;
- int addr_len = 0;
- int index = 0, len_index = 0;
-
- p_pkg_str[offset++] = SMS_TRANS_P2P_MSG;
-
- /* 1. teleservice id */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_TELESVC_IDENTIFIER;
- p_pkg_str[offset++] = 2;
- /* fixed */
- /* memcpy(p_pkg_str+offset, &(p_msg->telesvc_id), sizeof(sms_trans_telesvc_id_t)); */
- _copy_short_to_char(p_pkg_str+offset, &(p_msg->telesvc_id));
- offset += sizeof(sms_trans_telesvc_id_t);
-
- /* 2. Service category */
- if (p_msg->svc_ctg < SMS_TRANS_SVC_CTG_UNDEFINED) {
- p_pkg_str[offset++] = SMS_TRANS_PARAM_SERVICE_CATEGORY;
- p_pkg_str[offset++] = 0x02;
- /* fixed */
- _copy_short_to_char(&p_pkg_str[offset], &(p_msg->svc_ctg));
- }
-
- /* 3. Address */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_DEST_ADDRESS;
-
- /* Will be set to param length */
- len_index = offset++;
-
- p_pkg_str[offset] = p_msg->address.digit_mode ? 0x80 : 0x00;
- p_pkg_str[offset] |= (p_msg->address.number_mode ? 0x40 : 0x00);
-
- if (p_msg->address.digit_mode == false) {
- index = offset++;
- p_pkg_str[offset++] = p_msg->address.addr_len;
-
- addr_len = SmsPluginParamCodec::instance()->convertDigitToDTMF(p_msg->address.szData, p_msg->address.addr_len, 0, p_pkg_str+offset);
-
- for (int j=0; j < addr_len; j++) {
- MSG_DEBUG("ADDRESS 4BIT DTMF [%d] = [%02x]", j, p_pkg_str[offset+j]);
- }
-
- offset += addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 6);
- } else if (p_msg->address.digit_mode == true) {
- p_pkg_str[offset] |= p_msg->address.number_type << 3;
-
- if (p_msg->address.number_mode == false) {
- p_pkg_str[offset++] |= p_msg->address.number_plan >> 1;
- p_pkg_str[offset++] |= p_msg->address.number_plan << 7;
- index = offset-1;
- p_pkg_str[offset++] = p_msg->address.addr_len;
-
- memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
-
- offset += p_msg->address.addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 7);
- } else if (p_msg->address.number_mode == true) {
- index = offset++;
- p_pkg_str[offset++] = p_msg->address.addr_len;
- memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
-
- offset += p_msg->address.addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 3);
- }
- }
-
- p_pkg_str[len_index] = offset - len_index - 1 ;
- MSG_DEBUG("Address subparam length field = [%d]", p_pkg_str[len_index]);
-
- /* 4. Sub address (optional) */
- if (p_msg->sub_address.addr_len > 0) {
- p_pkg_str[offset++] = SMS_TRANS_PARAM_ORG_SUB_ADDRESS;
- p_pkg_str[offset] = p_msg->sub_address.addr_len + 2;
- index = offset++;
- p_pkg_str[offset] |= p_msg->sub_address.type << 5;
- p_pkg_str[offset++] |= (p_msg->sub_address.odd ? 0x10 : 0x00);
- p_pkg_str[offset++] = p_msg->sub_address.addr_len;
- memcpy(p_pkg_str+offset, p_msg->sub_address.szData, p_msg->sub_address.addr_len);
-
- offset += p_msg->sub_address.addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 4);
- }
-
- /* 5. Bearer reply option (optional) */
- if (p_msg->reply_seq > 0) {
- p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_REPLY_OPTION;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = (unsigned char)(p_msg->reply_seq << 2);
- MSG_DEBUG("Reply sequnce number = [%d]", p_msg->reply_seq);
- }
-
- /* 6. Bearer data */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_DATA;
- /* PARAMETER_LEN field should be filled at the last part. */
- index = offset++;
-
- unsigned char *encode_data = &p_pkg_str[offset];
-
- encode_size = encodeTelesvcMsg(&(p_msg->telesvc_msg), encode_data);
- /* PARAMETER_LEN */
- p_pkg_str[index] = encode_size;
-
- offset += encode_size;
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeCBMsg(const sms_trans_broadcast_msg_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0, encode_size = 0;
- int len_index = 0;
-
- /* 1. Service Category(Mandatory) */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_SERVICE_CATEGORY;
- p_pkg_str[offset++] = 0x02;
- _copy_short_to_char(&p_pkg_str[offset], &p_msg->svc_ctg);
-
-
- /* 2. Bearer Data(Optional) */
- /* TODO: give condition */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_DATA;
- /* PARAMETER_LEN field should be filled at the last part. */
- len_index = offset++;
-
- unsigned char *encode_data = &p_pkg_str[offset];
-
- encode_size = encodeTelesvcMsg(&(p_msg->telesvc_msg), encode_data);
- /* PARAMETER_LEN */
- p_pkg_str[len_index] = encode_size;
-
- offset += encode_size;
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0;
- int addr_len = 0, len_index = 0;
- int index = 0;
-
- /* 1. Address */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_DEST_ADDRESS;
-
- /* Will be set to param length */
- len_index = offset++;
-
- p_pkg_str[offset] = p_msg->address.digit_mode ? 0x80 : 0x00;
- p_pkg_str[offset] |= (p_msg->address.number_mode ? 0x40 : 0x00);
-
- index = offset++;
-
- if (p_msg->address.digit_mode == false) {
- p_pkg_str[offset++] = p_msg->address.addr_len;
-
- addr_len = SmsPluginParamCodec::instance()->convertDigitToDTMF(p_msg->address.szData, p_msg->address.addr_len, 0, p_pkg_str+offset);
-
- for (int j=0; j < addr_len; j++) {
- MSG_DEBUG("ADDRESS 4BIT DTMF [%d] = [%02x]", j, p_pkg_str[offset+j]);
- }
-
- offset += addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 6);
- } else if (p_msg->address.digit_mode == true) {
- p_pkg_str[offset] |= p_msg->address.number_type << 3;
-
- if (p_msg->address.number_mode == false) {
- p_pkg_str[offset++] |= p_msg->address.number_plan >> 1;
- p_pkg_str[offset++] |= p_msg->address.number_plan << 7;
- index++;
- p_pkg_str[offset++] = p_msg->address.addr_len;
-
- memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
-
- offset += p_msg->address.addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 7);
- } else if (p_msg->address.number_mode == true) {
- p_pkg_str[++offset] = p_msg->address.addr_len;
- offset++;
- memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
-
- offset += p_msg->address.addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 3);
- }
- }
-
- p_pkg_str[len_index] = offset - len_index - 1 ;
- MSG_DEBUG("Address subparam length field = [%d]", p_pkg_str[len_index]);
-
- /* 2. Sub address */
- if (p_msg->sub_address.addr_len > 0) {
- p_pkg_str[offset++] = SMS_TRANS_PARAM_ORG_SUB_ADDRESS;
- p_pkg_str[offset] = p_msg->sub_address.addr_len + 2;
- index = offset++;
- p_pkg_str[offset] |= p_msg->sub_address.type << 5;
- p_pkg_str[offset++] |= (p_msg->sub_address.odd ? 0x10 : 0x00);
- p_pkg_str[offset++] = p_msg->sub_address.addr_len;
- memcpy(p_pkg_str+offset, p_msg->sub_address.szData, p_msg->sub_address.addr_len);
-
- offset += p_msg->sub_address.addr_len;
-
- _shiftNBit(&p_pkg_str[index], offset-index+1, 4);
- }
-
- /* 3. Cause code */
- p_pkg_str[offset++] = SMS_TRANS_PARAM_CAUSE_CODES;
- index = offset++;
- p_pkg_str[offset] |= p_msg->cause_code.reply_seq << 2;
- p_pkg_str[offset] |= p_msg->cause_code.error_class;
- if (p_msg->cause_code.error_class != 0x0) {
- p_pkg_str[++offset] = p_msg->cause_code.cause_code;
- }
- p_pkg_str[index] = offset - index;
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeTelesvcMsg(const sms_telesvc_msg_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
- int encode_size = 0;
-
- MSG_DEBUG("Teleservice msg type = [%d]", p_msg->type);
-
- switch (p_msg->type) {
- /* case SMS_TYPE_DELIVER:
- encode_size = encodeTelesvcDeliverMsg(&(p_msg->data.delever), p_pkg_str);
- break; */
- case SMS_TYPE_SUBMIT:
- encode_size = encodeTelesvcSubmitMsg(&(p_msg->data.submit), p_pkg_str);
- break;
- case SMS_TYPE_CANCEL:
- encode_size = encodeTelesvcCancelMsg(&(p_msg->data.cancel), p_pkg_str);
- break;
- case SMS_TYPE_USER_ACK:
- encode_size = encodeTelesvcUserAckMsg(&(p_msg->data.user_ack), p_pkg_str);
- break;
- case SMS_TYPE_READ_ACK:
- encode_size = encodeTelesvcReadAckMsg(&(p_msg->data.read_ack), p_pkg_str);
- break;
- case SMS_TYPE_DELIVER_REPORT:
- encode_size = encodeTelesvcDeliverReportMsg(&(p_msg->data.report), p_pkg_str);
- break;
- default:
- MSG_DEBUG("No matching type for [%d]", p_msg->type);
- break;
- }
-
- MSG_END();
- return encode_size;
-}
-
-
-/*
-int SmsPluginMsgCodec::encodeTelesvcDeliverMsg(const sms_telesvc_deliver_s *p_msg, char *p_pkg_str)
-{
-
-}
-*/
-
-
-int SmsPluginMsgCodec::encodeTelesvcReadAckMsg(const sms_telesvc_read_ack_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0;
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeTelesvcUserAckMsg(const sms_telesvc_user_ack_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0;
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeTelesvcDeliverReportMsg(const sms_telesvc_report_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0, len_index = 0, encode_size = 0;
- bool delReservedBit = false;
-
- /* 1. Message Identifier (Mandatory) */
- p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
- p_pkg_str[offset++] = 3;
- _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
- _shiftNBit(&p_pkg_str[offset], 3, 4);
- p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
- offset += 2;
- p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
-
-
- /* 2. TP-Failure Cause (Conditional) */
- if (p_msg->tp_fail_cause >= 0x8000) {
- p_pkg_str[offset++] = SMS_BEARER_TP_FAILURE_CAUSE;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->tp_fail_cause;
- }
-
- /* 3. User Data (Optional) */
- if (p_msg->user_data.data_len > 0) {
- p_pkg_str[offset++] = SMS_BEARER_USER_DATA;
- len_index = offset;
- offset++;
- if (p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
- p_pkg_str[offset++] = p_msg->user_data.msg_type;
-
- p_pkg_str[offset++] = p_msg->user_data.encode_type << 3;
- p_pkg_str[offset++] = p_msg->user_data.data_len;
-
- if (p_msg->user_data.encode_type == SMS_ENCODE_7BIT_ASCII || p_msg->user_data.encode_type == SMS_ENCODE_GSM7BIT) {
- encode_size = encodeUserData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
- offset += encode_size;
- if (p_msg->user_data.data_len % 8 > 4)
- delReservedBit = true;
- } else {
- memcpy(p_pkg_str+offset, p_msg->user_data.user_data, p_msg->user_data.data_len);
- offset += p_msg->user_data.data_len;
- }
- _shiftNBit(&p_pkg_str[len_index+1], offset-len_index-1, 3);
-
- if (delReservedBit == true)
- offset--;
-
- p_pkg_str[len_index] = offset - len_index - 1;
- }
-
- /* 4. Language Indicator (Optional) */
- /* TODO : give condition */
- /*
- p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->language;
- */
-
- /* 5. Multiple Encoding User Data (Optional) */
- /* Omitted */
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeTelesvcCancelMsg(const sms_telesvc_cancel_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0;
-
- /* 1. Message Identifier */
- p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
- p_pkg_str[offset++] = 3;
- _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
- _shiftNBit(&p_pkg_str[offset], 3, 4);
- p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
- offset += 2;
- p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg, unsigned char *p_pkg_str)
-{
- MSG_BEGIN();
-
- int offset = 0, len_index = 0;
- int encode_size = 0;
- bool delReservedBit = false;
-
- /* 1. Message Identifier */
- p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
- p_pkg_str[offset++] = 3;
- _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
- _shiftNBit(&p_pkg_str[offset], 3, 4);
- p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
- offset += 2;
- p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
-
- /* 2. User Data */
- if (p_msg->user_data.data_len > 0) {
- p_pkg_str[offset++] = SMS_BEARER_USER_DATA;
- len_index = offset;
- offset++;
- if (p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
- p_pkg_str[offset++] = p_msg->user_data.msg_type;
-
- p_pkg_str[offset++] = p_msg->user_data.encode_type << 3;
- p_pkg_str[offset++] = p_msg->user_data.data_len;
-
- if (p_msg->user_data.encode_type == SMS_ENCODE_7BIT_ASCII) {
- encode_size = encodeUserData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
- offset += encode_size;
- if (p_msg->user_data.data_len % 8 > 4)
- delReservedBit = true;
- } else if (p_msg->user_data.encode_type == SMS_ENCODE_GSM7BIT) {
- encode_size = PackGSM7bitData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
- offset += encode_size;
- if (p_msg->user_data.data_len % 8 > 4)
- delReservedBit = true;
- } else if (p_msg->user_data.encode_type == SMS_ENCODE_UNICODE) {
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- encode_size = textCvt->convertUTF8ToUCS2(&p_pkg_str[offset], SMS_MAX_USER_DATA_LEN, p_msg->user_data.user_data, p_msg->user_data.data_len);
- p_pkg_str[offset-1] = encode_size / 2;
- offset += encode_size;
- } else {
- memcpy(p_pkg_str+offset, p_msg->user_data.user_data, p_msg->user_data.data_len);
- offset += p_msg->user_data.data_len;
- }
- _shiftNBit(&p_pkg_str[len_index+1], offset-len_index-1, 3);
-
- if (delReservedBit == true)
- offset--;
-
- p_pkg_str[len_index] = offset - len_index - 1;
- }
- /* Sprint and Verizon issue */
- /* 3. Validity Period */
- /*
- if (p_msg->val_period.format == SMS_TIME_RELATIVE) {
- p_pkg_str[offset++] = SMS_BEARER_VALIDITY_PERIOD_RELATIVE;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->val_period.time.rel_time.rel_time;
-
- } else if (p_msg->val_period.format == SMS_TIME_ABSOLUTE){
- p_pkg_str[offset++] = SMS_BEARER_VALIDITY_PERIOD_ABSOLUTE;
- p_pkg_str[offset++] = 6;
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.year);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.month);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.day);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.hours);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.minutes);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.seconds);
- }
- */
-
- /* 4. Deferred Delivery Time */
- if (p_msg->defer_val_period.format == SMS_TIME_RELATIVE) {
- p_pkg_str[offset++] = SMS_BEARER_DEFERRED_DELIVERY_TIME_RELATIVE;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->defer_val_period.time.rel_time.rel_time;
-
- } else if (p_msg->defer_val_period.format == SMS_TIME_ABSOLUTE) {
- p_pkg_str[offset++] = SMS_BEARER_DEFERRED_DELIVERY_TIME_ABSOLUTE;
- p_pkg_str[offset++] = 6;
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.year);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.month);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.day);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.hours);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.minutes);
- p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.seconds);
- }
-
- /* 5. Priority Indicator */
- if (p_msg->priority >= SMS_PRIORITY_NORMAL && p_msg->priority <= SMS_PRIORITY_EMERGENCY) {
- p_pkg_str[offset++] = SMS_BEARER_PRIORITY_INDICATOR;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->priority << 6;
- }
-
- /* Sprint and Verizon issue */
- /* 6. Privacy Indicator */
- /*
- if (p_msg->privacy >= SMS_PRIVACY_NOT_RESTRICTED && p_msg->privacy <= SMS_PRIVACY_SECRET) {
- p_pkg_str[offset++] = SMS_BEARER_PRIVACY_INDICATOR;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->privacy << 6;
- }
- */
-
- /* 7. Reply Option */
- if (p_msg->reply_opt.user_ack_req | p_msg->reply_opt.deliver_ack_req | p_msg->reply_opt.read_ack_req | p_msg->reply_opt.report_req) {
- p_pkg_str[offset++] = SMS_BEARER_REPLY_OPTION;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset] |= p_msg->reply_opt.user_ack_req << 7;
- p_pkg_str[offset] |= p_msg->reply_opt.deliver_ack_req << 6;
- p_pkg_str[offset] |= p_msg->reply_opt.read_ack_req << 5;
- p_pkg_str[offset++] |= p_msg->reply_opt.report_req << 4;
- }
-
- /* 8. Alert on Message Delivery */
- /* TODO : give condition */
- /*
- p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->alert_priority << 6;
- */
-
- /* 9. Language Indicator */
- /* TODO : give condition */
- /*
- p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
- p_pkg_str[offset++] = 1;
- p_pkg_str[offset++] = p_msg->language;
- */
-
- /* 10. Call-back Number */
- if (p_msg->callback_number.addr_len > 0) {
- p_pkg_str[offset++] = SMS_BEARER_CALLBACK_NUMBER;
-
- int len_index = offset++;
-
- p_pkg_str[offset] |= p_msg->callback_number.digit_mode << 7;
-
- if (p_msg->callback_number.digit_mode == false) {
- p_pkg_str[offset++] |= (p_msg->callback_number.addr_len & 0xfe) >> 1;
- p_pkg_str[offset] |= (p_msg->callback_number.addr_len & 0x01) << 7;
- int addr_len = SmsPluginParamCodec::instance()->convertDigitToDTMF(p_msg->callback_number.szData, p_msg->callback_number.addr_len, 1, p_pkg_str+offset);
- offset += addr_len;
- } else if (p_msg->callback_number.digit_mode == true) {
- p_pkg_str[offset] |= p_msg->callback_number.number_type << 6;
- p_pkg_str[offset++] |= p_msg->callback_number.number_plan;
- p_pkg_str[offset++] = p_msg->callback_number.addr_len;
- memcpy(p_pkg_str+offset, p_msg->callback_number.szData, p_msg->callback_number.addr_len);
- offset += p_msg->callback_number.addr_len;
- }
-
- p_pkg_str[len_index] = offset- len_index - 1;
- }
-
- /* 11. Multiple Encoding User Data */
- /* Omitted */
-
- /* 12. Message Deposit Index */
- /* Omitted */
-
- /* 13. Service Category Program Results */
- /* Omitted */
-
- MSG_END();
- return offset;
-}
-
-
-int SmsPluginMsgCodec::decodeMsg(const unsigned char *p_pkg_str, int pkg_len, sms_trans_msg_s *p_msg)
-{
- MSG_BEGIN();
-
- int decodelen = 0;
-
- char mti = p_pkg_str[0] & 0xff;
-
- switch (mti) {
- case SMS_TRANS_P2P_MSG:
- p_msg->type = SMS_TRANS_P2P_MSG;
- decodelen = decodeP2PMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.p2p_msg));
- break;
- case SMS_TRANS_BROADCAST_MSG:
- p_msg->type = SMS_TRANS_BROADCAST_MSG;
- decodelen = decodeCBMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.cb_msg));
- break;
- case SMS_TRANS_ACK_MSG:
- p_msg->type = SMS_TRANS_ACK_MSG;
- decodelen = decodeAckMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.ack_msg));
- break;
- default:
- p_msg->type = SMS_TRANS_TYPE_RESERVED;
- break;
- }
-
- MSG_END();
-
- return decodelen+1;
-}
-
-
-int SmsPluginMsgCodec::decodeP2PMsg(const unsigned char *p_pkg_str, int pkg_len, sms_trans_p2p_msg_s *p_p2p)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len = 0;
-
- while (offset < pkg_len) {
- switch (p_pkg_str[offset]) {
- case 0x00:
- /* Teleservice Identifier */
- offset += decodeTeleId(p_pkg_str+offset, pkg_len, &(p_p2p->telesvc_id));
- break;
- case 0x01:
- /* Service Category */
- offset += decodeSvcCtg(p_pkg_str+offset, pkg_len, &(p_p2p->svc_ctg));
- break;
- case 0x02:
- case 0x04:
- /* Address */
- offset += decodeAddress(p_pkg_str+offset, pkg_len, &(p_p2p->address));
- break;
- case 0x03:
- case 0x05:
- /* Subaddress */
- offset += decodeSubAddress(p_pkg_str+offset, pkg_len, &(p_p2p->sub_address));
- break;
- case 0x06:
- /* Bearer Reply Option*/
- offset += 2;
- p_p2p->reply_seq = (sms_trans_reply_seq_t)(p_pkg_str[offset] >> 2);
- offset++;
- break;
- case 0x08:
- /* Bearer Data */
- tmp_len = p_pkg_str[++offset];
- decodeP2PTelesvcMsg(p_pkg_str+offset+1, tmp_len, &p_p2p->telesvc_msg);
- offset += (tmp_len+1);
- break;
- default:
- break;
- }
- }
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::decodeCBMsg(const unsigned char *p_pkg_str, int pkg_len, sms_trans_broadcast_msg_s *p_cb)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len = 0;
-
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x01) {
- /* Service Category */
- offset += decodeTeleId(p_pkg_str+offset, pkg_len, &(p_cb->svc_ctg));
- } else if (p_pkg_str[offset] == 0x08) {
- /* Bearer Data */
- tmp_len = p_pkg_str[++offset];
- if (p_cb->svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && p_cb->svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST) {
- decodeCBBearerData(p_pkg_str+offset+1, tmp_len, &(p_cb->telesvc_msg), true);
- } else {
- decodeCBBearerData(p_pkg_str+offset+1, tmp_len, &(p_cb->telesvc_msg), false);
- }
-
- offset += (tmp_len+1);
- }
- }
-
- MSG_END();
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::decodeAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_trans_ack_msg_s *p_ack)
-{
- MSG_BEGIN();
-
- int offset = 0;
-
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x04) {
- /* Destination Address */
- offset += decodeAddress(p_pkg_str+offset, pkg_len, &(p_ack->address));
- } else if (p_pkg_str[offset] == 0x05) {
- /* Destination Subaddress */
- offset += decodeSubAddress(p_pkg_str+offset, pkg_len, &(p_ack->sub_address));
- } else if (p_pkg_str[offset] == 0x07) {
- /* Cause Codes */
- offset += 2;
- p_ack->cause_code.reply_seq = (sms_trans_reply_seq_t)p_pkg_str[offset] >> 2;
- switch (p_pkg_str[offset++] & 0x03) {
- case 0x00:
- p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_NONE;
- break;
- case 0x01:
- break;
- case 0x10:
- p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
- break;
- case 0x11:
- p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_PERMANENT;
- break;
- }
-
- if (p_ack->cause_code.error_class != SMS_TRANS_ERR_CLASS_NONE) {
- p_ack->cause_code.cause_code = (sms_trans_cause_code_t)p_pkg_str[offset++];
- }
- }
- }
-
- MSG_END();
-
- return offset;
-}
-
-
-void SmsPluginMsgCodec::decodeP2PTelesvcMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_msg_s *p_telesvc)
-{
- MSG_BEGIN();
-
- p_telesvc->type = findMsgType(p_pkg_str, pkg_len);
-
- MSG_DEBUG("Msg Type = [%d]", p_telesvc->type);
-
- switch (p_telesvc->type) {
- case SMS_TYPE_DELIVER:
- decodeP2PDeliverMsg(p_pkg_str, pkg_len, &p_telesvc->data.deliver);
- break;
- case SMS_TYPE_SUBMIT:
- decodeP2PSubmitMsg(p_pkg_str, pkg_len, &p_telesvc->data.submit);
- break;
- case SMS_TYPE_DELIVERY_ACK:
- decodeP2PDeliveryAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.delivery_ack);
- break;
- case SMS_TYPE_USER_ACK:
- decodeP2PUserAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.user_ack);
- break;
- case SMS_TYPE_READ_ACK:
- decodeP2PReadAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.read_ack);
- break;
- case SMS_TYPE_SUBMIT_REPORT:
- /* decodeP2PSubmitReportMsg(p_pkg_str, pkg_len, &p_telesvc->data.report); */
- break;
- default:
- break;
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeP2PDeliverMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_deliver_s *p_del)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len, tmp_off;
- unsigned short tmp_param_s;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- MSG_DEBUG("current offset = [%d] [%x]", offset, p_pkg_str[offset]);
-
- switch (p_pkg_str[offset]) {
- case 0x00:
- /* Message Identifier */
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del->msg_id));
- break;
- case 0x01:
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
- decodeUserData(tmp_str, tmp_len, &(p_del->user_data));
- offset += tmp_len;
- break;
- case 0x03:
- /* Message Center Time Stamp */
- offset += 2;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_del->time_stamp));
- break;
- case 0x04:
- /* Validity Period - Absolute */
- offset += 2;
- p_del->val_period.format = SMS_TIME_ABSOLUTE;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_del->val_period.time.abs_time));
- break;
- case 0x05:
- /* Validity Period - Relative */
- offset += 2;
- p_del->val_period.format = SMS_TIME_RELATIVE;
- p_del->val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
- break;
- case 0x08:
- /* Priority Indicator */
- offset += 2;
- p_del->priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- break;
- case 0x09:
- /* Privacy Indicator */
- offset += 2;
- p_del->privacy = (sms_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- break;
- case 0x0a:
- /* Reply Option */
- offset += 2;
-
- if (p_pkg_str[offset] & 0x80)
- p_del->reply_opt.user_ack_req = true;
- else
- p_del->reply_opt.user_ack_req = false;
-
- if (p_pkg_str[offset] & 0x40)
- p_del->reply_opt.deliver_ack_req = true;
- else
- p_del->reply_opt.deliver_ack_req = false;
-
- if (p_pkg_str[offset] & 0x20)
- p_del->reply_opt.read_ack_req = true;
- else
- p_del->reply_opt.read_ack_req = false;
-
- if (p_pkg_str[offset] & 0x10)
- p_del->reply_opt.report_req = true;
- else
- p_del->reply_opt.report_req = false;
-
- offset++;
- break;
- case 0x0b:
- /* Number of Message */
- offset += 2;
- p_del->num_msg = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
- break;
- case 0x0c:
- /* Alert on Message Delivery */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- if (tmp_len > 0)
- p_del->alert_priority = (sms_alert_priority_t)((p_pkg_str[offset] & 0xc0) >> 6);
- offset += tmp_len;
- break;
- case 0x0d:
- /* Language Indicator */
- offset += 2;
- p_del->language = (sms_language_type_t)p_pkg_str[offset++];
- break;
- case 0x0e:
- /* Call-Back Number */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_del->callback_number));
-
- offset += tmp_len;
- break;
- case 0x0f:
- /* Message Display Mode */
- offset += 2;
-
- p_del->display_mode = (sms_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- break;
- case 0x10:
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- break;
- case 0x11:
- /* Message Deposit Index */
- offset += 2;
-
- memset(&tmp_param_s, 0x00, sizeof(unsigned short));
- _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
- p_del->deposit_id = tmp_param_s;
-
- offset += 2;
- break;
- case 0x16:
- /* Enhanced VMN */
- offset++;
- tmp_len = p_pkg_str[offset++];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
- tmp_off = 0;
-
- p_del->enhanced_vmn.priority = (sms_priority_indicator_t)(p_pkg_str[offset] >> 6);
- p_del->enhanced_vmn.password_req = p_pkg_str[offset] & 0x20 ? true : false;
- p_del->enhanced_vmn.setup_req = p_pkg_str[offset] & 0x10 ? true : false;
- p_del->enhanced_vmn.pw_change_req = p_pkg_str[offset] & 0x08 ? true : false;
- _shiftNBit_for_decode(tmp_str, tmp_len, 5);
-
- if (p_del->enhanced_vmn.setup_req || p_del->enhanced_vmn.pw_change_req) {
- p_del->enhanced_vmn.min_pw_len = tmp_str[tmp_off] >> 4;
- p_del->enhanced_vmn.max_pw_len = tmp_str[tmp_off++] & 0x0f;
- }
-
- p_del->enhanced_vmn.vm_num_unheard_msg = tmp_str[tmp_off++];
- p_del->enhanced_vmn.vm_mailbox_alm_full = tmp_str[tmp_off] & 0x80 ? true : false;
- p_del->enhanced_vmn.vm_mailbox_full = tmp_str[tmp_off] & 0x40 ? true : false;
- p_del->enhanced_vmn.reply_allowed = tmp_str[tmp_off] & 0x20 ? true : false;
- p_del->enhanced_vmn.fax_included = tmp_str[tmp_off] & 0x10 ? true : false;
- p_del->enhanced_vmn.vm_len = ((tmp_str[tmp_off] >> 0x0f) << 8) | tmp_str[tmp_off+1];
- tmp_off += 2;
- p_del->enhanced_vmn.vm_ret_day = tmp_str[tmp_off] >> 1;
- _shiftNBit_for_decode(tmp_str, tmp_len, 7);
- p_del->enhanced_vmn.vm_msg_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
- tmp_off += 2;
- p_del->enhanced_vmn.vm_mailbox_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
- tmp_off += 2;
-
- p_del->enhanced_vmn.an_digit_mode = (sms_digit_mode_t)(tmp_str[tmp_off] & 0x80 ? true : false);
- p_del->enhanced_vmn.an_number_type = (sms_number_type_t)((tmp_str[tmp_off] & 0x70) >> 4);
- if (p_del->enhanced_vmn.an_digit_mode) {
- p_del->enhanced_vmn.an_number_plan = (sms_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
- p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
- for (int i = 0; i < p_del->enhanced_vmn.an_num_field; i++) {
- switch (tmp_str[tmp_off] & 0xf0) {
- case 0x10:
- case 0x20:
- case 0x30:
- case 0x40:
- case 0x50:
- case 0x60:
- case 0x70:
- case 0x80:
- case 0x90:
- p_del->enhanced_vmn.an_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
- break;
- case 0xa0:
- p_del->enhanced_vmn.an_char[i] = '0';
- break;
- case 0xb0:
- p_del->enhanced_vmn.an_char[i] = '*';
- break;
- case 0xc0:
- p_del->enhanced_vmn.an_char[i] = '#';
- break;
- default:
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- }
- } else {
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
- memset(p_del->enhanced_vmn.an_char, 0x00, sizeof(p_del->enhanced_vmn.an_char));
- memcpy(p_del->enhanced_vmn.an_char, tmp_str+tmp_off, p_del->enhanced_vmn.an_num_field);
- tmp_off += p_del->enhanced_vmn.an_num_field;
- }
-
- p_del->enhanced_vmn.cli_digit_mode = (sms_digit_mode_t)(tmp_str[offset] & 0x80 ? true : false);
- p_del->enhanced_vmn.cli_number_type = (sms_number_type_t)(tmp_str[offset] & 0x70 >> 4);
- if (p_del->enhanced_vmn.cli_digit_mode) {
- p_del->enhanced_vmn.cli_number_plan = (sms_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
- p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
- for (int i = 0; i < p_del->enhanced_vmn.cli_num_field; i++) {
- switch (tmp_str[tmp_off] & 0xf0) {
- case 0x10:
- case 0x20:
- case 0x30:
- case 0x40:
- case 0x50:
- case 0x60:
- case 0x70:
- case 0x80:
- case 0x90:
- p_del->enhanced_vmn.cli_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
- break;
- case 0xa0:
- p_del->enhanced_vmn.cli_char[i] = '0';
- break;
- case 0xb0:
- p_del->enhanced_vmn.cli_char[i] = '*';
- break;
- case 0xc0:
- p_del->enhanced_vmn.cli_char[i] = '#';
- break;
- default:
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- }
- } else {
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
- memset(p_del->enhanced_vmn.cli_char, 0x00, sizeof(p_del->enhanced_vmn.cli_char));
- memcpy(p_del->enhanced_vmn.cli_char, tmp_str+tmp_off, p_del->enhanced_vmn.cli_num_field);
- tmp_off += p_del->enhanced_vmn.cli_num_field;
- }
-
- offset += tmp_len;
- break;
- case 0x17:
- /* Enhanced VMN Ack */
- offset++;
- tmp_len = p_pkg_str[offset++];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
- p_del->enhanced_vmn_ack.vm_mailbox_id = tmp_str[offset] << 8 | tmp_str[offset+1];
- offset += 2;
- p_del->enhanced_vmn_ack.vm_num_unheard_msg = tmp_str[offset++];
- p_del->enhanced_vmn_ack.num_delete_ack = tmp_str[offset] >> 5;
- p_del->enhanced_vmn_ack.num_play_ack = (tmp_str[offset] & 0x1c) >> 2;
- _shiftNBit_for_decode(tmp_str, tmp_len, 6);
- for (int i = 0; i < p_del->enhanced_vmn_ack.num_delete_ack; i++) {
- p_del->enhanced_vmn_ack.da_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
- offset += 2;
- }
- for (int i = 0; i < p_del->enhanced_vmn_ack.num_play_ack; i++) {
- p_del->enhanced_vmn_ack.pa_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
- offset += 2;
- }
- break;
- default:
- /* skip unrecognized sub parameters */
- offset++;
- tmp_len = p_pkg_str[offset++];
- offset += tmp_len;
- break;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_submit_s *p_sub)
-{
- int offset = 0, tmp_len;
- unsigned short tmp_param_s;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x00) {
- /* Message Identifier */
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_sub->msg_id));
- } else if (p_pkg_str[offset] == 0x01) {
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-
- decodeUserData(tmp_str, tmp_len, &(p_sub->user_data));
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x04) {
- /* Validity Period - Absolute */
- offset += 2;
- p_sub->val_period.format = SMS_TIME_ABSOLUTE;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_sub->val_period.time.abs_time));
- } else if (p_pkg_str[offset] == 0x05) {
- /* Validity Period - Relative */
- offset += 2;
- p_sub->val_period.format = SMS_TIME_RELATIVE;
- p_sub->val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
- } else if (p_pkg_str[offset] == 0x06) {
- /* Deferred Delivery Time - Absolute */
- offset += 2;
- p_sub->defer_val_period.format = SMS_TIME_ABSOLUTE;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_sub->defer_val_period.time.abs_time));
- } else if (p_pkg_str[offset] == 0x07) {
- /* Deferred Delivery Time - Relative */
- offset += 2;
- p_sub->defer_val_period.format = SMS_TIME_RELATIVE;
- p_sub->defer_val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
- } else if (p_pkg_str[offset] == 0x08) {
- /* Priority indicator */
- offset += 2;
- p_sub->priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- } else if (p_pkg_str[offset] == 0x09) {
- /* Privacy indicator */
- offset += 2;
- p_sub->privacy = (sms_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- } else if (p_pkg_str[offset] == 0x0a) {
- /* Reply Option */
- offset += 2;
-
- if (p_pkg_str[offset] & 0x80)
- p_sub->reply_opt.user_ack_req = true;
- else
- p_sub->reply_opt.user_ack_req = false;
-
- if (p_pkg_str[offset] & 0x40)
- p_sub->reply_opt.deliver_ack_req = true;
- else
- p_sub->reply_opt.deliver_ack_req = false;
-
- if (p_pkg_str[offset] & 0x20)
- p_sub->reply_opt.read_ack_req = true;
- else
- p_sub->reply_opt.read_ack_req = false;
-
- if (p_pkg_str[offset] & 0x10)
- p_sub->reply_opt.report_req = true;
- else
- p_sub->reply_opt.report_req = false;
-
- offset++;
- } else if (p_pkg_str[offset] == 0x0c) {
- /* Alert on Message Delivery */
- offset += 2;
-
- p_sub->alert_priority = (sms_alert_priority_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- } else if (p_pkg_str[offset] == 0x0d) {
- /* Language Indicator */
- offset += 2;
-
- p_sub->language = (sms_language_type_t)p_pkg_str[offset++];
- } else if (p_pkg_str[offset] == 0x0e) {
- /* Call-Back Number */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_sub->callback_number));
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x10) {
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x11) {
- /* Message Deposit Index */
- offset += 2;
-
- memset(&tmp_param_s, 0x00, sizeof(unsigned short));
- _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
- p_sub->deposit_id = tmp_param_s;
-
- offset += 2;
- }
- }
-}
-
-
-void SmsPluginMsgCodec::decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_user_ack_s *p_user_ack)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len;
- unsigned short tmp_param_s;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x00) {
- /* Message Identifier */
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_user_ack->msg_id));
- } else if (p_pkg_str[offset] == 0x01) {
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-
- decodeUserData(tmp_str, tmp_len, &(p_user_ack->user_data));
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x02) {
- /* User Response Code */
- offset += 2;
- p_user_ack->resp_code = p_pkg_str[offset++];
- } else if (p_pkg_str[offset] == 0x03) {
- /* Message Center Time Stamp */
- offset += 2;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_user_ack->time_stamp));
- } else if (p_pkg_str[offset] == 0x10) {
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x11) {
- /* Message Deposit Index */
- offset += 2;
-
- memset(&tmp_param_s, 0x00, sizeof(unsigned short));
- _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
- p_user_ack->deposit_id = tmp_param_s;
-
- offset += 2;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_read_ack_s *p_read_ack)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len;
- unsigned short tmp_param_s;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x00) {
- /* Message Identifier */
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_read_ack->msg_id));
- } else if (p_pkg_str[offset] == 0x01) {
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-
- decodeUserData(tmp_str, tmp_len, &(p_read_ack->user_data));
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x03) {
- /* Message Center Time Stamp */
- offset += 2;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_read_ack->time_stamp));
- } else if (p_pkg_str[offset] == 0x10) {
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x11) {
- /* Message Deposit Index */
- offset += 2;
-
- memset(&tmp_param_s, 0x00, sizeof(unsigned short));
- _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
- p_read_ack->deposit_id = tmp_param_s;
-
- offset += 2;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_report_s *p_sub_report)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- switch (p_pkg_str[offset]) {
- case 0x00:
- /* Message Identifier */
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_sub_report->msg_id));
- break;
- case 0x01:
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
- decodeUserData(tmp_str, tmp_len, &(p_sub_report->user_data));
- offset += tmp_len;
- break;
- case 0x0d:
- /* Language Indicator */
- offset += 2;
- p_sub_report->language = (sms_language_type_t)p_pkg_str[offset++];
- break;
- case 0x10:
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- break;
- case 0x15:
- /* TP-Failure Cause */
- offset += 2;
- p_sub_report->tp_fail_cause = p_pkg_str[offset++];
- break;
- default:
- break;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_deliver_ack_s *p_del_ack)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- switch (p_pkg_str[offset]) {
- case 0x00:
- /* Message Identifier */
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del_ack->msg_id));
- break;
- case 0x01:
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-
- decodeUserData(tmp_str, tmp_len, &(p_del_ack->user_data));
-
- offset += tmp_len;
- break;
- case 0x03:
- /* Message Center Time Stamp */
- offset += 2;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_del_ack->time_stamp));
- break;
- case 0x10:
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- break;
- case 0x14:
- /* Message Status */
- offset += 2;
- p_del_ack->msg_status = (sms_status_code_t)p_pkg_str[offset++];
- break;
- default:
- break;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeCBBearerData(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_msg_s *p_telesvc, bool isCMAS)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len;
- unsigned char tmp_str[pkg_len+1];
-
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x00) {
- /* Message Identifier */
- p_telesvc->type = SMS_TYPE_DELIVER;
- offset += decodeMsgId(p_pkg_str+offset, 5, &(p_telesvc->data.deliver.msg_id));
- } else if (p_pkg_str[offset] == 0x01) {
- /* User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-
- if (isCMAS)
- decodeCMASData(tmp_str, tmp_len, &(p_telesvc->data.deliver.cmas_data));
- else
- decodeUserData(tmp_str, tmp_len, &(p_telesvc->data.deliver.user_data));
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x03) {
- /* Message Center Time Stamp */
- offset += 2;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_telesvc->data.deliver.time_stamp));
- } else if (p_pkg_str[offset] == 0x04) {
- /* Validity Period - Absolute */
- offset += 2;
- p_telesvc->data.deliver.val_period.format = SMS_TIME_ABSOLUTE;
- offset += decodeAbsTime(p_pkg_str+offset, &(p_telesvc->data.deliver.val_period.time.abs_time));
- } else if (p_pkg_str[offset] == 0x05) {
- /* Validity Period - Relative */
- offset += 2;
- p_telesvc->data.deliver.val_period.format = SMS_TIME_RELATIVE;
- p_telesvc->data.deliver.val_period.time.rel_time.rel_time = (sms_relative_time_t)p_pkg_str[offset++];
- } else if (p_pkg_str[offset] == 0x08) {
- /* Priority indicator */
- offset += 2;
- p_telesvc->data.deliver.priority = (sms_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- } else if (p_pkg_str[offset] == 0x0c) {
- /* Alert on Message Delivery */
- offset += 2;
-
- p_telesvc->data.deliver.alert_priority = (sms_alert_priority_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- } else if (p_pkg_str[offset] == 0x0d) {
- /* Language Indicator */
- offset += 2;
-
- p_telesvc->data.deliver.language = (sms_language_type_t)p_pkg_str[offset++];
- } else if (p_pkg_str[offset] == 0x0e) {
- /* Call-Back Number */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_telesvc->data.deliver.callback_number));
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x0f) {
- /* Message Display Mode */
- offset += 2;
-
- p_telesvc->data.deliver.display_mode = (sms_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
- } else if (p_pkg_str[offset] == 0x10) {
- /* Multiple Encoding User Data */
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
-
- /* TODO */
-
- offset += tmp_len;
- }
- }
-
- MSG_END();
-}
-
-
-int SmsPluginMsgCodec::decodeTeleId(const unsigned char *p_pkg_str, int pkg_len, sms_trans_telesvc_id_t *tele_id)
-{
- int offset = 0;
- unsigned short tmp_param_s;
-
- offset += 2;
-
- _copy_char_to_short(&tmp_param_s, &p_pkg_str[offset]);
-
- switch (tmp_param_s) {
- case SMS_TRANS_TELESVC_CMT_91:
- *tele_id = SMS_TRANS_TELESVC_CMT_91;
- break;
- case SMS_TRANS_TELESVC_CPT_95:
- *tele_id = SMS_TRANS_TELESVC_CPT_95;
- break;
- case SMS_TRANS_TELESVC_CMT_95:
- *tele_id = SMS_TRANS_TELESVC_CMT_95;
- break;
- case SMS_TRANS_TELESVC_VMN_95:
- *tele_id = SMS_TRANS_TELESVC_VMN_95;
- break;
- case SMS_TRANS_TELESVC_WAP:
- *tele_id = SMS_TRANS_TELESVC_WAP;
- break;
- case SMS_TRANS_TELESVC_WEMT:
- *tele_id = SMS_TRANS_TELESVC_WEMT;
- break;
- case SMS_TRANS_TELESVC_SCPT:
- *tele_id = SMS_TRANS_TELESVC_SCPT;
- break;
- case SMS_TRANS_TELESVC_CATPT:
- *tele_id = SMS_TRANS_TELESVC_CATPT;
- break;
- default:
- *tele_id = SMS_TRANS_TELESVC_RESERVED;
- break;
- }
-
- return offset+2;
-}
-
-
-int SmsPluginMsgCodec::decodeSvcCtg(const unsigned char *p_pkg_str, int pkg_len, sms_trans_svc_ctg_t *svc_ctg)
-{
- int offset = 0;
- unsigned short tmp_param_s;
-
- offset += 2;
-
- _copy_char_to_short(&tmp_param_s, &p_pkg_str[offset]);
- if ((tmp_param_s >= SMS_TRANS_SVC_CTG_UNKNOWN && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1)
- || (tmp_param_s >= SMS_TRANS_SVC_CTG_KDDI_CORP_MIN2 && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX2)
- || (tmp_param_s >= SMS_TRANS_SVC_CTG_KDDI_CORP_MIN3 && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX3)) {
- *svc_ctg = (sms_trans_svc_ctg_t)tmp_param_s;
- } else {
- *svc_ctg = SMS_TRANS_SVC_CTG_RESERVED;
- }
-
- return offset+2;
-}
-
-
-int SmsPluginMsgCodec::decodeAddress(const unsigned char *p_pkg_str, int pkg_len, sms_trans_addr_s *addr)
-{
- int offset = 0, tmp_len = 0;
- unsigned char tmp_str[pkg_len+1];
-
- tmp_len = p_pkg_str[++offset];
-
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset+1, tmp_len);
-
- offset += (tmp_len+1);
-
- if (tmp_str[0] & 0x80)
- addr->digit_mode = true;
- else
- addr->digit_mode = false;
-
- if (tmp_str[0] & 0x40)
- addr->number_mode = true;
- else
- addr->number_mode = false;
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 2);
-
- if (addr->digit_mode == false) {
- addr->addr_len = tmp_str[0];
-
- memset(addr->szData, 0x00, sizeof(addr->szData));
-
- for (unsigned int i = 0; i < addr->addr_len; i++) {
- switch (tmp_str[1] & 0xf0) {
- case 0x10:
- case 0x20:
- case 0x30:
- case 0x40:
- case 0x50:
- case 0x60:
- case 0x70:
- case 0x80:
- case 0x90:
- addr->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
- break;
- case 0x00:
- /* sprint issue */
- case 0xa0:
- addr->szData[i] = '0';
- break;
- case 0xb0:
- addr->szData[i] = '*';
- break;
- case 0xc0:
- addr->szData[i] = '#';
- break;
- default:
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- }
- } else if (addr->digit_mode == true) {
- if (addr->number_mode == false) {
- /* digit mode = 1, number mode = 0 */
- switch (tmp_str[0] & 0xe0) {
- case 0x00:
- addr->number_type = SMS_NUMBER_TYPE_UNKNOWN;
- break;
- case 0x20:
- addr->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
- break;
- case 0x40:
- addr->number_type = SMS_NUMBER_TYPE_NATIONAL;
- break;
- case 0x60:
- addr->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
- break;
- case 0x80:
- addr->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
- break;
- case 0xa0:
- addr->number_type = SMS_NUMBER_TYPE_RESERVED_5;
- break;
- case 0xc0:
- addr->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
- break;
- case 0xe0:
- addr->number_type = SMS_NUMBER_TYPE_RESERVED_7;
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 3);
-
- switch (tmp_str[0] & 0xf0) {
- case 0x00:
- addr->number_plan = SMS_NPI_UNKNOWN;
- break;
- case 0x10:
- addr->number_plan = SMS_NPI_ISDN;
- break;
- case 0x30:
- addr->number_plan = SMS_NPI_DATA;
- break;
- case 0x40:
- addr->number_plan = SMS_NPI_TELEX;
- break;
- case 0x90:
- addr->number_plan = SMS_NPI_PRIVATE;
- break;
- default:
- addr->number_plan = SMS_NPI_RESERVED;
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- } else if (addr->number_mode == true) {
- /* digit mode = 1, number mode = 1 */
- switch (tmp_str[0] & 0xe0) {
- case 0x00:
- addr->number_type = SMS_TRANS_DNET_UNKNOWN;
- break;
- case 0x20:
- addr->number_type = SMS_TRANS_DNET_INTERNET_PROTOCOL;
- break;
- case 0x40:
- addr->number_type = SMS_TRANS_DNET_INTERNET_MAIL_ADDR;
- break;
- default:
- addr->number_type = SMS_TRANS_DNET_RESERVED;
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 3);
- }
-
- addr->addr_len = tmp_str[0];
-
- memset(addr->szData, 0x00, sizeof(addr->szData));
- memcpy(addr->szData, &tmp_str[1], addr->addr_len);
- }
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::decodeSubAddress(const unsigned char *p_pkg_str, int pkg_len, sms_trans_sub_addr_s *sub_addr)
-{
- int offset = 0, tmp_len = 0;
- unsigned char tmp_str[pkg_len+1];
-
- tmp_len = p_pkg_str[++offset];
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset+1, tmp_len);
-
- offset += (tmp_len+1);
-
- switch (tmp_str[0] & 0xe0) {
- case 0x00:
- sub_addr->type = SMS_TRANS_SUB_ADDR_NSAP;
- break;
- case 0x20:
- sub_addr->type = SMS_TRANS_SUB_ADDR_USER;
- break;
- default:
- sub_addr->type = SMS_TRANS_SUB_ADDR_RESERVED;
- break;
- }
-
- if (tmp_str[0] & 0x10)
- sub_addr->odd = true;
- else
- sub_addr->odd = false;
-
- _shiftNBit_for_decode(tmp_str, tmp_len, 4);
- memset(sub_addr->szData, 0x00, sizeof(sub_addr->szData));
- memcpy(sub_addr->szData, tmp_str+1, tmp_str[0]);
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::decodeMsgId(const unsigned char *p_pkg_str, int pkg_len, sms_trans_msg_id_s *p_msg_id)
-{
- int offset = 0;
- unsigned short tmp_param_s;
- unsigned char tmp_str[pkg_len+1];
-
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, &p_pkg_str[offset+2], 3);
-
- _shiftNBit_for_decode(tmp_str, 3, 4);
-
- memset(&tmp_param_s, 0x00, sizeof(unsigned short));
- _copy_char_to_short(&tmp_param_s, tmp_str);
-
- p_msg_id->msg_id = tmp_param_s;
- if (tmp_str[2] & 0x80)
- p_msg_id->header_ind = true;
- else
- p_msg_id->header_ind = false;
-
- offset += 5;
-
- return offset;
-}
-
-
-void SmsPluginMsgCodec::decodeCallBackNum(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_addr_s *p_callback)
-{
- int offset = 0;
- unsigned char tmp_str[pkg_len+1];
-
- if (p_pkg_str[offset] & 0x80) {
- p_callback->digit_mode = true;
-
- switch (p_pkg_str[offset] & 0x70) {
- case 0x00:
- p_callback->number_type = SMS_NUMBER_TYPE_UNKNOWN;
- break;
- case 0x10:
- p_callback->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
- break;
- case 0x20:
- p_callback->number_type = SMS_NUMBER_TYPE_NATIONAL;
- break;
- case 0x30:
- p_callback->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
- break;
- case 0x40:
- p_callback->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
- break;
- case 0x50:
- p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_5;
- break;
- case 0x60:
- p_callback->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
- break;
- case 0x70:
- p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_7;
- break;
- default:
- break;
- }
-
- switch (p_pkg_str[offset++] & 0x0f) {
- case 0x00:
- p_callback->number_plan = SMS_NPI_UNKNOWN;
- break;
- case 0x01:
- p_callback->number_plan = SMS_NPI_ISDN;
- break;
- case 0x03:
- p_callback->number_plan = SMS_NPI_DATA;
- break;
- case 0x04:
- p_callback->number_plan = SMS_NPI_TELEX;
- break;
- case 0x09:
- p_callback->number_plan = SMS_NPI_PRIVATE;
- break;
- case 0x0f:
- default:
- p_callback->number_plan = SMS_NPI_RESERVED;
- break;
- }
-
- p_callback->addr_len = p_pkg_str[offset++];
- memset(p_callback->szData, 0x00, sizeof(p_callback->szData));
-
- if (p_callback->number_type == SMS_NUMBER_TYPE_INTERNATIONAL) {
- memcpy(&(p_callback->szData[1]), p_pkg_str+offset, p_callback->addr_len);
- if (p_callback->szData[1] != '\0') {
- p_callback->szData[0] = '+';
- }
- } else {
- memcpy(p_callback->szData, p_pkg_str+offset, p_callback->addr_len);
- }
- } else {
- p_callback->digit_mode = false;
-
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, pkg_len);
-
- _shiftNBit_for_decode(tmp_str, pkg_len, 1);
-
- p_callback->addr_len = tmp_str[0];
-
- memset(p_callback->szData, 0x00, sizeof(p_callback->szData));
-
- for (unsigned int i = 0; i < p_callback->addr_len; i++) {
- switch (tmp_str[1] & 0xf0) {
- case 0x10:
- case 0x20:
- case 0x30:
- case 0x40:
- case 0x50:
- case 0x60:
- case 0x70:
- case 0x80:
- case 0x90:
- p_callback->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
- break;
- case 0xa0:
- p_callback->szData[i] = '0';
- break;
- case 0xb0:
- p_callback->szData[i] = '*';
- break;
- case 0xc0:
- p_callback->szData[i] = '#';
- break;
- default :
- break;
- }
-
- _shiftNBit_for_decode(tmp_str, pkg_len, 4);
- }
- }
-}
-
-
-int SmsPluginMsgCodec::decodeAbsTime(const unsigned char *p_pkg_str, sms_time_abs_s *p_time_abs)
-{
- int offset = 0;
-
- p_time_abs->year = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
- p_time_abs->month = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
- p_time_abs->day = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
- p_time_abs->hours = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
- p_time_abs->minutes = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
- p_time_abs->seconds = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
- offset++;
-
- return offset;
-}
-
-
-int SmsPluginMsgCodec::encodeUserData(const unsigned char* src, unsigned char *dest, int src_size)
-{
- int i, j;
- int shift = 0;
-
- unsigned char *tmp = (unsigned char *)calloc(1, src_size+1);
- for (i = 0; i < src_size; i++) {
- tmp[i] = src[i] << 1;
- }
-
- j = 0;
- for (i = 0; i < src_size; i++) {
- shift = j % 7;
- dest[j++] = (tmp[i] << shift) + (tmp[i+1] >> (7-shift));
- if (shift == 6) {
- i++;
- }
- }
-
- if (tmp) {
- free(tmp);
- tmp = NULL;
- }
-
- return j;
-}
-
-
-void SmsPluginMsgCodec::decodeCMASData(unsigned char *p_pkg_str, int pkg_len, sms_telesvc_cmasdata_s *p_cmas)
-{
- MSG_BEGIN();
-
- int offset = 0, tmp_len = 0;
- unsigned char tmp_str[pkg_len+1];
-
- if ((p_pkg_str[offset] & 0xf8) != 0x00) {
- MSG_ERR("Wrong Encode Type = [%d]!! The type must be 0", (p_pkg_str[offset]&0xf8)>>3);
- return;
- } else {
- _shiftNBit_for_decode(p_pkg_str, pkg_len, 5);
-
- offset++;
-
- if (p_pkg_str[offset++] != 0x00) {
- MSG_ERR("Wrong protocol version = [%d]!! This field must be 0", p_pkg_str[offset-1]);
- p_cmas->is_wrong_recode_type = TRUE;
- return;
- }
-
- while (offset < pkg_len - 1) {
- if (p_pkg_str[offset] == 0x00) {
- MSG_DEBUG("Type 0 Decode!");
- offset++;
- tmp_len = p_pkg_str[offset++];
- MSG_DEBUG("Type 0 length = [%d]", tmp_len);
- memset(tmp_str, 0x00, sizeof(tmp_str));
- memcpy(tmp_str, p_pkg_str+offset, tmp_len);
-
- switch (tmp_str[0] & 0xf8) {
- case 0x00:
- p_cmas->encode_type = SMS_ENCODE_OCTET;
- break;
- case 0x08:
- p_cmas->encode_type = SMS_ENCODE_EPM;
- break;
- case 0x10:
- p_cmas->encode_type = SMS_ENCODE_7BIT_ASCII;
- break;
- case 0x18:
- p_cmas->encode_type = SMS_ENCODE_IA5;
- break;
- case 0x20:
- p_cmas->encode_type = SMS_ENCODE_UNICODE;
- break;
- case 0x28:
- p_cmas->encode_type = SMS_ENCODE_SHIFT_JIS;
- break;
- case 0x30:
- p_cmas->encode_type = SMS_ENCODE_KOREAN;
- break;
- case 0x38:
- p_cmas->encode_type = SMS_ENCODE_LATIN_HEBREW;
- break;
- case 0x40:
- p_cmas->encode_type = SMS_ENCODE_LATIN;
- break;
- case 0x48:
- p_cmas->encode_type = SMS_ENCODE_GSM7BIT;
- break;
- case 0x50:
- p_cmas->encode_type = SMS_ENCODE_GSMDCS;
- break;
- case 0x80:
- /* reserved value, but SKT use this value for KSC5601 */
- p_cmas->encode_type = SMS_ENCODE_EUCKR;
- break;
- default :
- p_cmas->encode_type = SMS_ENCODE_RESERVED;
- break;
- }
- _shiftNBit_for_decode(tmp_str, tmp_len, 5);
-
- switch (p_cmas->encode_type) {
- case SMS_ENCODE_7BIT_ASCII:
- case SMS_ENCODE_IA5:
- case SMS_ENCODE_GSM7BIT:
- memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
- p_cmas->data_len = (tmp_len*8-5) / 7;
- for (unsigned int i = 0; i < p_cmas->data_len; i++) {
- p_cmas->alert_text[i] = tmp_str[0] >> 1;
- _shiftNBit_for_decode(tmp_str, tmp_len, 7);
- }
- break;
- case SMS_ENCODE_EPM:
- break;
- case SMS_ENCODE_GSMDCS:
- break;
- default:
- p_cmas->data_len = tmp_len - 1;
- memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
- memcpy(p_cmas->alert_text, tmp_str+offset, tmp_len-1);
- break;
- }
-
- offset += tmp_len;
- } else if (p_pkg_str[offset] == 0x01) {
- MSG_DEBUG("Type 1 Decode!");
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- MSG_DEBUG("Type 1 length = [%d]", tmp_len);
- p_cmas->category = (sms_cmae_category_t)p_pkg_str[offset++];
- p_cmas->response_type = (sms_cmae_response_type_t)p_pkg_str[offset++];
- p_cmas->severity = (sms_cmae_severity_t)(p_pkg_str[offset] >> 4);
- p_cmas->urgency = (sms_cmae_urgency_t)(p_pkg_str[offset++] & 0x0f);
- p_cmas->certainty = (sms_cmae_certainty_t)(p_pkg_str[offset++] >> 4);
- } else if (p_pkg_str[offset] == 0x02) {
- MSG_DEBUG("Type 2 Decode!");
- offset += 2;
- tmp_len = p_pkg_str[offset-1];
- MSG_DEBUG("Type 2 length = [%d]", tmp_len);
- _copy_char_to_short(&(p_cmas->id), p_pkg_str+offset);
- offset += 2;
- p_cmas->alert_handle = (sms_cmae_alert_handle_t)p_pkg_str[offset++];
- offset += decodeAbsTime(p_pkg_str+offset, &(p_cmas->expires));
- p_cmas->language = (sms_language_type_t)p_pkg_str[offset++];
- }
-
- MSG_DEBUG("offset = [%d], pkg_len = [%d]", offset, pkg_len);
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginMsgCodec::decodeUserData(unsigned char *p_pkg_str, int pkg_len, sms_telesvc_userdata_s *p_user)
-{
- switch (p_pkg_str[0] & 0xf8) {
- case 0x00:
- p_user->encode_type = SMS_ENCODE_OCTET;
- break;
- case 0x08:
- p_user->encode_type = SMS_ENCODE_EPM;
- break;
- case 0x10:
- p_user->encode_type = SMS_ENCODE_7BIT_ASCII;
- break;
- case 0x18:
- p_user->encode_type = SMS_ENCODE_IA5;
- break;
- case 0x20:
- p_user->encode_type = SMS_ENCODE_UNICODE;
- break;
- case 0x28:
- p_user->encode_type = SMS_ENCODE_SHIFT_JIS;
- break;
- case 0x30:
- p_user->encode_type = SMS_ENCODE_KOREAN;
- break;
- case 0x38:
- p_user->encode_type = SMS_ENCODE_LATIN_HEBREW;
- break;
- case 0x40:
- p_user->encode_type = SMS_ENCODE_LATIN;
- break;
- case 0x48:
- p_user->encode_type = SMS_ENCODE_GSM7BIT;
- break;
- case 0x50:
- p_user->encode_type = SMS_ENCODE_GSMDCS;
- break;
- case 0x80:
- /* reserved value, but SKT use this value for KSC5601 */
- p_user->encode_type = SMS_ENCODE_EUCKR;
- break;
- default :
- p_user->encode_type = SMS_ENCODE_RESERVED;
- break;
- }
-
- _shiftNBit_for_decode(p_pkg_str, pkg_len, 5);
-
- if (p_user->encode_type == SMS_ENCODE_EPM || p_user->encode_type == SMS_ENCODE_GSMDCS) {
- p_user->msg_type = p_pkg_str[0];
- _shiftNBit_for_decode(p_pkg_str, pkg_len, 8);
- }
-
- p_user->data_len = p_pkg_str[0];
- switch (p_user->encode_type) {
- case SMS_ENCODE_7BIT_ASCII:
- case SMS_ENCODE_IA5:
- memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
- for (unsigned int i = 0; i < p_user->data_len; i++) {
- p_user->user_data[i] = p_pkg_str[1] >> 1;
- _shiftNBit_for_decode(p_pkg_str, pkg_len, 7);
- }
- break;
- case SMS_ENCODE_GSM7BIT:
- memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
- UnpackGSM7bitData(&(p_pkg_str[1]), p_user->user_data, p_user->data_len);
- break;
- case SMS_ENCODE_EPM:
- break;
- case SMS_ENCODE_GSMDCS:
- break;
- case SMS_ENCODE_UNICODE:
- p_user->data_len*=2;
- memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
- memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
- break;
- default:
- memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
- memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
- break;
- }
-}
-
-
-sms_message_type_t SmsPluginMsgCodec::findMsgType(const unsigned char *p_pkg_str, int pkg_len)
-{
- int offset = 0;
- while (offset < pkg_len) {
- if (p_pkg_str[offset] == 0x00) {
- return (sms_message_type_t)((p_pkg_str[offset+2]&0xf0)>>4);
- }
- offset += (p_pkg_str[offset+1]+2);
- }
-
- return SMS_TYPE_MAX_VALUE;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <time.h>
-
-#include <bundle.h>
-#include <eventsystem.h>
-
-#include "MsgDebug.h"
-#include "MsgUtilFile.h"
-#include "MsgUtilFunction.h"
-#include "MsgUtilStorage.h"
-#include "MsgCppTypes.h"
-#include "MsgContact.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-
-#include "SmsCdmaPluginTransport.h"
-#include "SmsCdmaPluginStorage.h"
-#include "SmsCdmaPluginSetting.h"
-#include "SmsCdmaPluginEventHandler.h"
-#include "SmsCdmaPluginWapPushHandler.h"
-
-
-
-SmsPluginEventHandler* SmsPluginEventHandler::pInstance = NULL;
-
-
-SmsPluginEventHandler::SmsPluginEventHandler()
-{
- /* Initialize global parameters */
- memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
- memset(&sentInfo, 0x00, sizeof(sms_sent_info_s));
- devStatus = false;
-}
-
-
-SmsPluginEventHandler::~SmsPluginEventHandler()
-{
-}
-
-
-SmsPluginEventHandler* SmsPluginEventHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginEventHandler();
-
- return pInstance;
-}
-
-
-void SmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
-{
- listener = *pListener;
-}
-
-
-void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_p2p_msg_s *p_p2p_msg, MSG_MESSAGE_INFO_S *p_msg_info)
-{
- MSG_BEGIN();
-
- /* Address */
- if (p_p2p_msg->telesvc_msg.data.deliver.callback_number.szData[0] != '\0')
- p_msg_info->nAddressCnt = 2;
- else
- p_msg_info->nAddressCnt = 1;
-
- p_msg_info->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * p_msg_info->nAddressCnt];
-
- if (p_msg_info->addressList) {
- switch (p_msg_info->nAddressCnt) {
- case 2:
- memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
- case 1:
- memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
- break;
- default:
- MSG_ERR("Invalid case");
- memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
- }
- }
-
- if (p_p2p_msg->address.szData[0] != '\0') {
- p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
- memcpy(p_msg_info->addressList[0].addressVal, p_p2p_msg->address.szData, MAX_ADDRESS_VAL_LEN);
- p_msg_info->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
- }
-
-
- /* Teleservice message */
- switch (p_p2p_msg->telesvc_msg.type) {
- case SMS_TYPE_DELIVER:
- p_msg_info->msgType.subType = MSG_NORMAL_SMS;
- p_msg_info->folderId = MSG_INBOX_ID;
-
- convertDeliverMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.deliver), p_msg_info);
- break;
- case SMS_TYPE_DELIVERY_ACK:
- convertAckMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.delivery_ack), p_msg_info);
- break;
- case SMS_TYPE_SUBMIT_REPORT:
- convertReportMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.report), p_msg_info);
- break;
- default:
- MSG_DEBUG("No matching type = [%d]", p_p2p_msg->telesvc_msg.type);
- break;
- }
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::convertTpduToMsginfo(sms_trans_broadcast_msg_s *p_cb_msg, MSG_MESSAGE_INFO_S *p_msg_info)
-{
- MSG_BEGIN();
-
- /* Address */
- p_msg_info->nAddressCnt = 0;
- p_msg_info->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
-
- if (p_msg_info->addressList) {
- memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
- }
-
- /* Bearer Data */
- if (p_cb_msg->telesvc_msg.type == SMS_TYPE_DELIVER) {
- p_msg_info->msgType.subType = MSG_CB_SMS;
- p_msg_info->folderId = MSG_CBMSGBOX_ID;
-
- if (p_cb_msg->svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && p_cb_msg->svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST)
- convertCMASMsgToMsgInfo(&(p_cb_msg->telesvc_msg.data.deliver), p_msg_info);
- else
- convertDeliverMsgToMsgInfo(&(p_cb_msg->telesvc_msg.data.deliver), p_msg_info);
- } else {
- MSG_DEBUG("No matching type = [%d]", p_cb_msg->telesvc_msg.type);
- }
-
- if (p_msg_info->nAddressCnt == 0) {
- p_msg_info->nAddressCnt = 1;
- p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
- p_msg_info->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
-
- if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL)
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Presidential Alert");
- else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_EXTREME)
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Extreme Alert");
- else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_SEVERE)
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Severe Alert");
- else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_AMBER)
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "AMBER Alert");
- else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_TEST)
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Emergency Alert");
- else
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "CB Message");
- }
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::convertCMASMsgToMsgInfo(sms_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
-{
- MSG_BEGIN();
-
- p_msg_info->msgType.mainType = MSG_SMS_TYPE;
-
- p_msg_info->msgType.classType = MSG_CLASS_NONE;
- p_msg_info->networkStatus = MSG_NETWORK_RECEIVED;
- p_msg_info->bRead = false;
- p_msg_info->bProtected = false;
- p_msg_info->direction = MSG_DIRECTION_TYPE_MT;
- p_msg_info->bTextSms = true;
-
- if (p_deliver->callback_number.szData[0] != '\0') {
- /* If callback number is in received pdu, replace the address value. */
- memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
- p_msg_info->nAddressCnt = 1;
- p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
- snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "%s", p_deliver->callback_number.szData);
- p_msg_info->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
- }
-
- time_t rawtime = 0;
- p_msg_info->storageId = MSG_STORAGE_PHONE;
-
-#if 0 /* Save Timestamp of message center. */
- char displayTime[32];
- struct tm * timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- if (p_deliver->time_stamp.year > 95)
- timeinfo.tm_year = (p_deliver->time_stamp.year + 1900);
- else
- timeinfo.tm_year = (p_deliver->time_stamp.year + 2000);
-
- timeinfo.tm_mon = (p_deliver->time_stamp.month - 1);
- timeinfo.tm_mday = p_deliver->time_stamp.day;
- timeinfo.tm_hour = p_deliver->time_stamp.hour;
- timeinfo.tm_min = p_deliver->time_stamp.minute;
- timeinfo.tm_sec = p_deliver->time_stamp.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%d]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
-#else
- rawtime = time(NULL);
-#endif
-
- p_msg_info->displayTime = rawtime;
-
-
- if (p_deliver->priority == SMS_PRIORITY_URGENT || p_deliver->priority == SMS_PRIORITY_EMERGENCY)
- p_msg_info->priority = MSG_MESSAGE_PRIORITY_HIGH;
- else
- p_msg_info->priority = MSG_MESSAGE_PRIORITY_NORMAL;
-
-
- memset(p_msg_info->subject, 0x00, MAX_SUBJECT_LEN+1);
-
- p_msg_info->msgPort.valid = false;
- p_msg_info->msgPort.dstPort = 0;
- p_msg_info->msgPort.srcPort = 0;
-
- p_msg_info->encodeType = getEncodeType(p_deliver->cmas_data.encode_type);
-
- if (p_deliver->cmas_data.data_len <= 0) {
- memset(p_msg_info->msgText, 0x00, sizeof(p_msg_info->msgText));
- p_msg_info->dataSize = 0;
- } else if (p_deliver->cmas_data.data_len > MAX_MSG_TEXT_LEN) {
- snprintf(p_msg_info->msgText, MAX_MSG_TEXT_LEN, "[Broken Message]");
- p_msg_info->dataSize = strlen(p_msg_info->msgData);
- return;
- } else {
- if (p_msg_info->encodeType == MSG_ENCODE_UCS2) {
- MSG_DEBUG("Encode Type = UCS2");
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
- } else if (p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
- MSG_DEBUG("Encode Type = EUCKR");
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
- } else if (p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
- MSG_DEBUG("Encode Type = Shift-JIS");
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertSHIFTJISToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
- } else if (p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
- MSG_DEBUG("Encode Type = GSM7BIT");
- MSG_LANG_INFO_S langinfo = {0, };
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len, &langinfo);
- } else {
- snprintf(p_msg_info->msgText, sizeof(p_msg_info->msgText), "%s", p_deliver->cmas_data.alert_text);
- p_msg_info->dataSize = p_deliver->cmas_data.data_len;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
-{
- MSG_BEGIN();
-
- p_msg_info->msgType.mainType = MSG_SMS_TYPE;
- /*
- p_msg_info->msgType.subType = MSG_NORMAL_SMS;
- p_msg_info->folderId = MSG_INBOX_ID;
- */
- p_msg_info->msgType.classType = MSG_CLASS_NONE;
- p_msg_info->networkStatus = MSG_NETWORK_RECEIVED;
- p_msg_info->bRead = false;
- p_msg_info->bProtected = false;
- p_msg_info->direction = MSG_DIRECTION_TYPE_MT;
- p_msg_info->bTextSms = true;
-
- if (p_deliver->callback_number.szData[0] != '\0') {
- /* If callback number is in received pdu, replace the address value. */
- memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
- p_msg_info->addressList[1].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
- memcpy(p_msg_info->addressList[1].addressVal, p_deliver->callback_number.szData, MAX_ADDRESS_VAL_LEN);
- p_msg_info->addressList[1].recipientType = MSG_RECIPIENTS_TYPE_TO;
- }
-
- time_t rawtime = 0;
- p_msg_info->storageId = MSG_STORAGE_PHONE;
-
-#if 0 /* Save Timestamp of message center. */
- char displayTime[32];
- struct tm * timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- if (p_deliver->time_stamp.year > 95)
- timeinfo.tm_year = (p_deliver->time_stamp.year + 1900);
- else
- timeinfo.tm_year = (p_deliver->time_stamp.year + 2000);
-
- timeinfo.tm_mon = (p_deliver->time_stamp.month - 1);
- timeinfo.tm_mday = p_deliver->time_stamp.day;
- timeinfo.tm_hour = p_deliver->time_stamp.hour;
- timeinfo.tm_min = p_deliver->time_stamp.minute;
- timeinfo.tm_sec = p_deliver->time_stamp.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%d]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
-#else
- rawtime = time(NULL);
-#endif
-
- p_msg_info->displayTime = rawtime;
-
-
- if (p_deliver->priority == SMS_PRIORITY_URGENT || p_deliver->priority == SMS_PRIORITY_EMERGENCY)
- p_msg_info->priority = MSG_MESSAGE_PRIORITY_HIGH;
- else
- p_msg_info->priority = MSG_MESSAGE_PRIORITY_NORMAL;
-
-
- memset(p_msg_info->subject, 0x00, MAX_SUBJECT_LEN+1);
-
- p_msg_info->msgPort.valid = false;
- p_msg_info->msgPort.dstPort = 0;
- p_msg_info->msgPort.srcPort = 0;
-
- p_msg_info->encodeType = getEncodeType(p_deliver->user_data.encode_type);
-
- if (p_deliver->user_data.data_len <= 0) {
- memset(p_msg_info->msgText, 0x00, sizeof(p_msg_info->msgText));
- p_msg_info->dataSize = 0;
- } else if (p_deliver->user_data.data_len > MAX_MSG_TEXT_LEN) {
- snprintf(p_msg_info->msgText, MAX_MSG_TEXT_LEN, "[Broken Message]");
- p_msg_info->dataSize = strlen(p_msg_info->msgData);
- return;
- } else {
- if (p_msg_info->encodeType == MSG_ENCODE_UCS2) {
- MSG_DEBUG("Encode Type = UCS2");
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
- } else if (p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
- MSG_DEBUG("Encode Type = EUCKR");
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
- } else if (p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
- MSG_DEBUG("Encode Type = Shift-JIS");
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertSHIFTJISToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
- } else if (p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
- MSG_DEBUG("Encode Type = GSM7BIT");
- MSG_LANG_INFO_S langinfo = {0, };
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- p_msg_info->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len, &langinfo);
- } else {
- snprintf(p_msg_info->msgText, sizeof(p_msg_info->msgText), "%s", p_deliver->user_data.user_data);
- p_msg_info->dataSize = p_deliver->user_data.data_len;
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::convertAckMsgToMsgInfo(sms_telesvc_deliver_ack_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
-{
-}
-
-
-void SmsPluginEventHandler::convertReportMsgToMsgInfo(sms_telesvc_report_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
-{
-}
-
-
-void SmsPluginEventHandler::SetSentInfo(sms_sent_info_s *pSentInfo)
-{
- memset(&sentInfo, 0x00, sizeof(sms_sent_info_s));
- memcpy(&sentInfo, pSentInfo, sizeof(sms_sent_info_s));
-
- MSG_DEBUG("sentInfo.reqId : %d", sentInfo.reqInfo.reqId);
- MSG_DEBUG("sentInfo.bLast : %d", sentInfo.bLast);
-}
-
-
-
-void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
-{
- MSG_DEBUG("NetStatus[%d]", NetStatus);
-
- if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
- /* Update Msg Status */
- if (sentInfo.reqInfo.msgInfo.msgPort.valid == false) {
- sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
-
- if (NetStatus == MSG_NETWORK_SEND_SUCCESS) {
- MSG_DEBUG("Add phone log");
- MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
- sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID;
- /* Send system event */
- bundle *b = NULL;
- b = bundle_create();
- if (b) {
- if (sentInfo.reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE)
- bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_SMS);
- else
- bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_MMS);
-
- char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
- snprintf(msgId, sizeof(msgId), "%u", sentInfo.reqInfo.msgInfo.msgId);
- bundle_add_str(b, EVT_KEY_OUT_MSG_ID, msgId);
- eventsystem_send_system_event(SYS_EVENT_OUTGOING_MSG, b);
- bundle_free(b);
- }
- } else {
- sentInfo.reqInfo.msgInfo.bRead = false;
- }
-
- callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
- }
-
- MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
- MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
- /* Check sending options */
- if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
- callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
- }
-
- /* Callback to MSG FW */
- MSG_SENT_STATUS_S msgStatus;
-
- msgStatus.reqId = sentInfo.reqInfo.reqId;
- msgStatus.status = NetStatus;
-
- MSG_DEBUG("sentStatus.reqId : %d", msgStatus.reqId);
- MSG_DEBUG("sentStatus.status : %d", msgStatus.status);
-
- listener.pfSentStatusCb(&msgStatus);
- }
-}
-
-
-void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
-{
- /* Make MSG_MESSAGE_INFO_S */
- MSG_MESSAGE_INFO_S msgInfo;
-
- /* initialize msgInfo */
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- /* convert to msgInfo */
- convertTpduToMsginfo(p_p2p_msg, &msgInfo);
-
- if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_RESERVED) {
- MSG_DEBUG("This Incoming Message has Unknown Teleservice ID");
- SmsPluginTransport::instance()->sendDeliverReport(MSG_ERR_INVALID_MSG_TYPE, p_p2p_msg);
- return;
- }
-
- /* Check for Voice Mail Notification */
- if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_VMN_95) {
- if (p_p2p_msg->telesvc_msg.data.deliver.enhanced_vmn.fax_included)
- msgInfo.msgType.subType = MSG_MWI_FAX_SMS;
- else
- msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
-
- if (p_p2p_msg->telesvc_msg.data.deliver.num_msg < 0)
- p_p2p_msg->telesvc_msg.data.deliver.num_msg = 0;
-
- int voice_cnt = 0;
- if (MsgSettingGetInt(VOICEMAIL_COUNT, &voice_cnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
-
- /* repeated msg check for voicemail */
- if (voice_cnt == p_p2p_msg->telesvc_msg.data.deliver.num_msg) {
- SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS, p_p2p_msg);
- return;
- }
-
- SmsPluginSetting::instance()->setMwiInfo(msgInfo.msgType.subType, p_p2p_msg->telesvc_msg.data.deliver.num_msg);
-
- memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
-
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", p_p2p_msg->telesvc_msg.data.deliver.num_msg);
- msgInfo.dataSize = strlen(msgInfo.msgText);
- } else if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
- /* Check for EMS(Unsupported) */
- char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_POP_ERROR_UNSUPPORTED_MSG");
- memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%s", msg_text);
- msgInfo.dataSize = strlen(msgInfo.msgText);
-
- if (msg_text) {
- free(msg_text);
- msg_text = NULL;
- }
- }
-
- /* Print MSG_MESSAGE_INFO_S */
- MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
- MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
- MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
- MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
- MSG_DEBUG("msgInfo.addressList[0].displayName : %s", msgInfo.addressList[0].displayName);
- MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
- MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
- MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
- MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
- MSG_DEBUG("msgInfo.bStore : %d", msgInfo.bStore);
- MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
- MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
- MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
- MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
- MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
- MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
- MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
- MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
-
- if (msgInfo.bTextSms == true) {
- MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
- } else {
- MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
- }
-
- MSG_DEBUG("###############################################################");
-
- msg_error_t err = MSG_SUCCESS;
- bool isUnique = true;
- MSG_UNIQUE_INDEX_S unq_ind;
- memset(&unq_ind, 0x00, sizeof(MSG_UNIQUE_INDEX_S));
-
- if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
- /* Status Report Message */
- /*
- err = SmsPluginStorage::instance()->updateMsgDeliverStatus(&msgInfo, pTpdu->data.statusRep.msgRef);
-
- if (err == MSG_SUCCESS)
- err = listener.pfMsgIncomingCb(&msgInfo);
- else
- MSG_DEBUG("updateMsgDeliverStatus is failed [%d]", err);
- */
-
- /* Handling of Fail Case ?? */
- /* SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS); */
- } else { /* SMS Deliver */
- /* Add message to DB */
- if (msgInfo.msgPort.valid == false) {
- if (p_p2p_msg->telesvc_id != SMS_TRANS_TELESVC_VMN_95) {
- memcpy(unq_ind.address, p_p2p_msg->address.szData, sizeof(p_p2p_msg->address.szData));
- memcpy(unq_ind.sub_address, p_p2p_msg->sub_address.szData, sizeof(p_p2p_msg->sub_address.szData));
- unq_ind.tele_msgId = p_p2p_msg->telesvc_msg.data.deliver.msg_id.msg_id;
- snprintf(unq_ind.time_stamp, sizeof(unq_ind.time_stamp), "%02d%02d%02d%02d%02d%02d",
- p_p2p_msg->telesvc_msg.data.deliver.time_stamp.year, p_p2p_msg->telesvc_msg.data.deliver.time_stamp.month,
- p_p2p_msg->telesvc_msg.data.deliver.time_stamp.day, p_p2p_msg->telesvc_msg.data.deliver.time_stamp.hours,
- p_p2p_msg->telesvc_msg.data.deliver.time_stamp.minutes, p_p2p_msg->telesvc_msg.data.deliver.time_stamp.seconds);
- unq_ind.telesvc_id = p_p2p_msg->telesvc_id;
- isUnique = listener.pfCheckUniquenessCb(&unq_ind, 0, false);
- }
- }
-
- if (isUnique) {
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
- } else {
- SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS, p_p2p_msg);
- return;
- }
-
- /* Callback to MSG FW */
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("callback to msg fw");
- err = listener.pfMsgIncomingCb(&msgInfo);
- } else {
- if (msgInfo.msgType.classType == MSG_CLASS_0) {
- MSG_DEBUG("callback for class0 message to msg fw");
- if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
- MSG_DEBUG("listener.pfMsgIncomingCb is failed!");
- }
- }
-
- if (err == MSG_SUCCESS && p_p2p_msg->telesvc_id != SMS_TRANS_TELESVC_VMN_95)
- listener.pfCheckUniquenessCb(&unq_ind, msgInfo.msgId, true);
-
- /* Send Deliver Report */
- if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
- SmsPluginTransport::instance()->sendDeliverReport(MSG_ERR_INVALID_MSG_TYPE, p_p2p_msg);
- } else {
- SmsPluginTransport::instance()->sendDeliverReport(err, p_p2p_msg);
- }
-
- /* Tizen Validation System */
- char *msisdn = NULL;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int simIndex = 1;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
-
- if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s", msgInfo.msgId, \
- msgInfo.addressList[0].addressVal, \
- (msisdn == NULL)?"ME":msisdn, \
- (err == MSG_SUCCESS)?"Success":"Fail");
-
- MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
-
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
- }
-}
-
-
-void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_msg)
-{
- MSG_BEGIN();
-
- if (p_cb_msg->telesvc_msg.data.deliver.cmas_data.encode_type == SMS_ENCODE_KOREAN
- || p_cb_msg->telesvc_msg.data.deliver.cmas_data.encode_type == SMS_ENCODE_GSMDCS) {
- MSG_DEBUG("This encode type is not supported [%d]", p_cb_msg->telesvc_msg.data.deliver.cmas_data.encode_type);
- return;
- }
-
- /* Make MSG_MESSAGE_INFO_S */
- MSG_MESSAGE_INFO_S msgInfo;
-
- /* initialize msgInfo */
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- /* convert to msgInfo */
- convertTpduToMsginfo(p_cb_msg, &msgInfo);
- msgInfo.msgId = p_cb_msg->telesvc_msg.data.deliver.msg_id.msg_id;
-
- /* Print MSG_MESSAGE_INFO_S */
- MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
- MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
- MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
- MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
- MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
- MSG_DEBUG("msgInfo.bStore : %d", msgInfo.bStore);
- MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
- MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
- MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
- MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
- MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
- MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
- MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
- MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
- MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
-
- if (msgInfo.bTextSms == true) {
- MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
- } else {
- MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
- }
-
- MSG_DEBUG("###############################################################");
-
- msg_error_t err = MSG_SUCCESS;
-
- /* Add message to DB */
- if (msgInfo.msgPort.valid == false) {
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
- }
-
- if (!checkCbOpt(p_cb_msg->svc_ctg)) {
- MSG_DEBUG("The CB Msg is not supported by option.");
- return;
- }
-
- /* Callback to MSG FW */
- if (err == MSG_SUCCESS) {
-#if 1
- MSG_CB_MSG_S cbOutMsg = {0, };
- bool is_duplicate = false;
-
- switch (p_cb_msg->svc_ctg) {
- case SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL :
- msgInfo.msgType.subType = MSG_CMAS_PRESIDENTIAL;
- break;
- case SMS_TRANS_SVC_CTG_CMAS_EXTREME :
- msgInfo.msgType.subType = MSG_CMAS_EXTREME;
- break;
- case SMS_TRANS_SVC_CTG_CMAS_SEVERE :
- msgInfo.msgType.subType = MSG_CMAS_SEVERE;
- break;
- case SMS_TRANS_SVC_CTG_CMAS_AMBER :
- msgInfo.msgType.subType = MSG_CMAS_AMBER;
- break;
- case SMS_TRANS_SVC_CTG_CMAS_TEST :
- msgInfo.msgType.subType = MSG_CMAS_TEST;
- break;
- default :
- msgInfo.msgType.subType = MSG_CB_SMS;
- break;
- }
-
- cbOutMsg.type = msgInfo.msgType.subType;
- cbOutMsg.receivedTime = msgInfo.displayTime;
- /* encodeCbSerialNum (CbMsgPage.pageHeader.serialNum); */
- cbOutMsg.serialNum = 0;
- cbOutMsg.messageId = msgInfo.msgId;
- /* cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData; */
- memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText));
-
- cbOutMsg.cbTextLen = msgInfo.dataSize;
- memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type));
- /* memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3); */
-
- if (!is_duplicate) {
- MSG_DEBUG("callback to msg fw");
- err = listener.pfCBMsgIncomingCb(&cbOutMsg, &msgInfo);
-
- if (err != MSG_SUCCESS) {
- MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
- }
- } else {
- MSG_WARN("duplicate cb serialNum[%d] messageId[%d]", cbOutMsg.serialNum, cbOutMsg.messageId);
- }
-
-#else
- err = listener.pfMsgIncomingCb(&msgInfo);
-#endif
- }
-
- /* Send Deliver Report */
- /* SmsPluginTransport::instance()->sendDeliverReport(err, p_cb_msg); */
-
- /* Tizen Validation System */
- char *msisdn = NULL;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int simIndex = 1;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
-
- if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s", msgInfo.msgId, \
- msgInfo.addressList[0].addressVal, \
- (msisdn == NULL)?"ME":msisdn, \
- (err == MSG_SUCCESS)?"Success":"Fail");
-
- MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
-
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg)
-{
- MSG_BEGIN();
-
- sms_wap_msg_s msg;
- memset(&msg, 0x00, sizeof(sms_wap_msg_s));
-
- msg.msgId = p_p2p_msg->telesvc_msg.data.deliver.msg_id.msg_id;
- msg.totalSeg = p_p2p_msg->telesvc_msg.data.deliver.user_data.user_data[1];
- msg.segNum = p_p2p_msg->telesvc_msg.data.deliver.user_data.user_data[2];
-
- char tmpUserText[SMS_MAX_USER_DATA_LEN+1] = {0, };
- sms_telesvc_userdata_s tmpUserData;
- memset(&tmpUserData, 0x00, sizeof(sms_telesvc_userdata_s));
-
- tmpUserData.data_len = p_p2p_msg->telesvc_msg.data.deliver.user_data.data_len - 3;
- memcpy(tmpUserText, &(p_p2p_msg->telesvc_msg.data.deliver.user_data.user_data[3]), tmpUserData.data_len);
- memcpy(tmpUserData.user_data, tmpUserText, sizeof(tmpUserData.user_data));
-
- unsigned char segCnt = checkWapMsg(&msg, &tmpUserData);
-
- MSG_DEBUG("segNum [%d]", msg.segNum);
- MSG_DEBUG("segCnt [%d]", segCnt);
- MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
-
- if (segCnt == msg.totalSeg) {
- MSG_DEBUG("RECEIVED LAST WAP : %d", segCnt);
-
- unsigned short srcPort = 0, dstPort = 0;
- int dataSize = 0;
- char* pUserData = NULL;
- char* pTmpUserData = NULL;
- unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
- unique_ptr<char*, void(*)(char**)> dataBuf1(&pTmpUserData, unique_ptr_deleter);
-
- MSG_MESSAGE_INFO_S msgInfo = {0, };
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- dataSize = MakeWapUserData(msg.msgId, &pUserData);
-
- pTmpUserData = new char[dataSize];
-
- memcpy(pTmpUserData, pUserData, dataSize);
- memset(pUserData, 0x00, dataSize);
-
- srcPort = pTmpUserData[0] << 8 | pTmpUserData[1];
- dstPort = pTmpUserData[2] << 8 | pTmpUserData[3];
-
-#ifndef FEATURE_OMADM_DUPLICATE_PORT_WAPPUSH
- dataSize -= 4;
- memcpy(pUserData, &pTmpUserData[4], dataSize);
-#else
- if ((srcPort == 0x23f0 && dstPort == 0x0b84) &&
- ((pTmpUserData[4] << 8 | pTmpUserData[5]) == 0x23f0) &&
- ((pTmpUserData[6] << 8 | pTmpUserData[7]) == 0x0b84)) {
- dataSize -= 8;
- memcpy(pUserData, &pTmpUserData[8], dataSize);
- } else {
- dataSize -= 4;
- memcpy(pUserData, &pTmpUserData[4], dataSize);
- }
-#endif
-
- if (dataSize > 0) {
- MSG_DEBUG("dataSize = %d", dataSize);
- for (int i = 0; i < dataSize; i++)
- MSG_DEBUG("UserData[%d] = [%c] [%02x]", i, pUserData[i], pUserData[i]);
-
- if (SmsPluginWapPushHandler::instance()->IsWapPushMsg(dstPort) == true) {
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- SmsPluginWapPushHandler::instance()->copyDeliverData(&(p_p2p_msg->address));
- SmsPluginWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize);
- } else {
- MSG_DEBUG("not supported wap push port [%x]", dstPort);
- }
- }
-
- /* remove from waplist */
- for (int index = wapList.size()-1; index >= 0 ; index--) {
- if (wapList[index].msgId == msg.msgId) {
- MSG_DEBUG("remove waplist of the index [%d]", index);
- wapList.erase(wapList.begin()+index);
- break;
- }
- }
- }
-
- /* Send Deliver Report */
- SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS, p_p2p_msg);
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::handleResendMessage(void)
-{
- listener.pfResendMessageCb();
-}
-
-
-msg_error_t SmsPluginEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /* Callback to MSG FW */
- err = listener.pfMsgIncomingCb(pMsgInfo);
-
- MSG_END();
-
- return err;
-}
-
-
-msg_error_t SmsPluginEventHandler::callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- /* Callback to MSG FW */
- listener.pfStorageChangeCb(storageChangeType, pMsgInfo);
-
- return MSG_SUCCESS;
-}
-
-
-void SmsPluginEventHandler::setDeviceStatus()
-{
- mx.lock();
- devStatus = true;
- cv.signal();
- mx.unlock();
-}
-
-
-bool SmsPluginEventHandler::getDeviceStatus()
-{
- int ret = 0;
-
- mx.lock();
-
- ret = cv.timedwait(mx.pMsgMutex(), 25);
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: DEVICE STATUS TIME-OUT");
- devStatus = false;
- bNeedInitConfig = true;
- }
- mx.unlock();
- return devStatus;
-}
-
-
-void SmsPluginEventHandler::setNeedInitConfig(bool bNeeded)
-{
- bNeedInitConfig = bNeeded;
-}
-
-
-bool SmsPluginEventHandler::getNeedInitConfig()
-{
- return bNeedInitConfig;
-}
-
-
-msg_encode_type_t SmsPluginEventHandler::getEncodeType(sms_encoding_type_t encode_type)
-{
- switch (encode_type) {
- case SMS_ENCODE_GSM7BIT:
- return MSG_ENCODE_GSM7BIT;
- case SMS_ENCODE_KOREAN:
- case SMS_ENCODE_EUCKR:
- return MSG_ENCODE_EUCKR;
- case SMS_ENCODE_IA5:
- case SMS_ENCODE_7BIT_ASCII:
- case SMS_ENCODE_LATIN_HEBREW:
- case SMS_ENCODE_LATIN:
- case SMS_ENCODE_OCTET:
- return MSG_ENCODE_8BIT;
- case SMS_ENCODE_SHIFT_JIS:
- return MSG_ENCODE_SHIFT_JIS;
- /*
- case SMS_ENCODE_EPM :
- case SMS_ENCODE_UNICODE :
- case SMS_ENCODE_GSMDCS :
- */
- default:
- return MSG_ENCODE_UCS2;
- }
-
- return MSG_ENCODE_UCS2;
-}
-
-
-unsigned short SmsPluginEventHandler::checkWapMsg(sms_wap_msg_s *pMsg, sms_telesvc_userdata_s *pUserdata)
-{
- unsigned char currSegNum = 0;
-
- bool bFind = false;
-
- for (unsigned int i = 0; i < wapList.size(); i++) {
- if (wapList[i].msgId == pMsg->msgId) {
- if (wapList[i].data.count(pMsg->segNum) != 0) {
- MSG_DEBUG("The Segment Number already exists [%d]", pMsg->segNum);
- return 0;
- }
- wap_data_s wapData = {0};
-
- memcpy(wapData.data, pUserdata->user_data, pUserdata->data_len);
- wapData.length = pUserdata->data_len;
-
- pair<unsigned char, wap_data_s> newData(pMsg->segNum, wapData);
- wapList[i].data.insert(newData);
-
- MSG_DEBUG("MSG DATA : %s", pUserdata->user_data);
- MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
- MSG_DEBUG("DATA SIZE [%d]", pUserdata->data_len);
-
- wapList[i].segNum++;
- wapList[i].totalSize += pUserdata->data_len;
- currSegNum = wapList[i].segNum;
-
- bFind = true;
-
- break;
- }
- }
-
- /* New Wap Push Msg */
- if (bFind == false) {
- sms_wap_info_s tmpInfo;
- tmpInfo.msgId = pMsg->msgId;
- tmpInfo.totalSeg = pMsg->totalSeg;
- tmpInfo.segNum = 1;
-
- tmpInfo.totalSize = pUserdata->data_len;
-
- wap_data_s wapData = {0};
-
- memcpy(wapData.data, pUserdata->user_data, pUserdata->data_len);
- wapData.length = pUserdata->data_len;
-
- pair<unsigned char, wap_data_s> newData(pMsg->segNum, wapData);
- tmpInfo.data.insert(newData);
-
- MSG_DEBUG("MSG DATA : %s", pUserdata->user_data);
- MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
- MSG_DEBUG("DATA SIZE [%d]", pUserdata->data_len);
-
- wapList.push_back(tmpInfo);
-
- currSegNum = tmpInfo.segNum;
- }
-
- return currSegNum;
-}
-
-
-int SmsPluginEventHandler::MakeWapUserData(unsigned short msgId, char **ppTotalData)
-{
- wapDataMap::iterator it;
-
- int totalSize = 0, offset = 0;
-
- for (unsigned int i = 0; i < wapList.size(); i++) {
- if (wapList[i].msgId == msgId) {
- totalSize = wapList[i].totalSize;
-
- if (totalSize <= 0) {
- MSG_DEBUG("Size Error : totalSize <= 0");
- return 0;
- }
-
- MSG_DEBUG("totalSize [%d]", totalSize);
-
- if (*ppTotalData == NULL)
- *ppTotalData = new char[totalSize];
-
- for (it = wapList[i].data.begin(); it != wapList[i].data.end(); it++) {
- memcpy(*ppTotalData+offset, it->second.data, it->second.length);
- offset += it->second.length;
- }
- }
- }
-
- return totalSize;
-}
-
-
-void SmsPluginEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen)
-{
- MSG_SYNCML_MESSAGE_DATA_S syncMLData;
-
- memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
-
- /* set syncML data */
- syncMLData.syncmlType = msgType;
-
- syncMLData.pushBodyLen = PushBodyLen;
- memcpy(syncMLData.pushBody, pPushBody, PushBodyLen);
-
- syncMLData.wspHeaderLen = WspHeaderLen;
- memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
-
- /* Callback to MSG FW */
- listener.pfSyncMLMsgIncomingCb(&syncMLData);
-}
-
-
-void SmsPluginEventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen)
-{
- MSG_LBS_MESSAGE_DATA_S lBSData;
-
- memset(&lBSData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
-
- /* set LBA data */
- memcpy(lBSData.pushHeader, pPushHeader, strlen(pPushHeader));
-
- lBSData.pushBodyLen = pushBodyLen;
- memcpy(lBSData.pushBody, pPushBody, pushBodyLen);
-
- /* Callback to MSG FW */
- listener.pfLBSMsgIncomingCb(&lBSData);
-}
-
-
-void SmsPluginEventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *application_id, char *content_type)
-{
- MSG_PUSH_MESSAGE_DATA_S pushData;
-
- memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
-
- /* set PUSH data */
- memcpy(pushData.pushHeader, pPushHeader, strlen(pPushHeader));
-
- pushData.pushBodyLen = pushBodyLen;
- memcpy(pushData.pushBody, pPushBody, pushBodyLen);
-
- memcpy(pushData.pushAppId, application_id, MAX_WAPPUSH_ID_LEN);
- memcpy(pushData.pushContentType, content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
-
- /* Callback to MSG FW */
- listener.pfPushMsgIncomingCb(&pushData);
-}
-
-
-bool SmsPluginEventHandler::checkCbOpt(sms_trans_svc_ctg_t svc_ctg)
-{
- bool bReceive = false;
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
- int sim_idx = 1;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, sim_idx);
- if (MsgSettingGetBool(keyName, &bReceive) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- /* Receive CB Msg = FALSE */
- if (!bReceive) {
- MSG_DEBUG("RECEIVE CB = FALSE");
- return false;
- }
-
- if (svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST) {
- bool bActivate = false;
- short Category = 0;
- MSG_CB_CHANNEL_S cbChannelInfo = {0, };
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler *dbHandle = getDbHandle();
-
- err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("Error value of MsgStoGetCBChannelInfo [%d]", err);
- return false;
- }
-
- for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
- bActivate = cbChannelInfo.channelInfo[i].bActivate;
- Category = cbChannelInfo.channelInfo[i].ctg;
-
- if (bActivate == true && svc_ctg == Category) {
- MSG_DEBUG("FIND CHANNEL = [%d]", svc_ctg);
- return true;
- }
- }
-
- return false;
- }
-
- return true;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-
-#include "MsgDebug.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-
-#include "MsgMutex.h"
-#include "SmsCdmaPluginTransport.h"
-#include "SmsCdmaPluginStorage.h"
-#include "SmsCdmaPluginCallback.h"
-#include "SmsCdmaPluginEventHandler.h"
-#include "SmsCdmaPluginUAManager.h"
-#include "SmsCdmaPluginSetting.h"
-#include "SmsCdmaPluginMain.h"
-#include <gio/gio.h>
-#include <tzplatform_config.h>
-
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiSim.h>
- #include <ITapiNetText.h>
-}
-
-#define BUS_NAME "org.tizen.system.storage"
-#define PATH_NAME "/Org/Tizen/System/Storage/Lowmem"
-#define INTERFACE_NAME BUS_NAME".lowmem"
-#define MEMBER_NAME "NeedCleanup"
-#define SIGNAL_VAL "Full"
-
-
-
-struct tapi_handle *pTapiHandle = NULL;
-bool isMemAvailable = true;
-
-GDBusConnection *gdbus_conn = NULL;
-GDBusProxy *gdbus_proxy = NULL;
-gint subs_id = 0;
-
-MsgMutex mx;
-MsgCndVar cv;
-
-
-void MsgResourceMonitorInit(void);
-void MsgResourceMonitorDeinit(void);
-
-/*==================================================================================================
- FUNCTION IMPLEMENTATION
-==================================================================================================*/
-
-static void MsgTapiInitCB(keynode_t *key, void* data)
-{
- MSG_DEBUG("MsgTapiInitCB is called.");
- mx.lock();
- cv.signal();
- mx.unlock();
-}
-
-
-msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
-{
- if (pPluginHandle == NULL) {
- MSG_DEBUG("SMS plugin: create handler error ");
- return MSG_ERR_NULL_POINTER;
- } else {
- pPluginHandle->pfInitialize = SmsPlgInitialize;
- pPluginHandle->pfFinalize = SmsPlgFinalize;
- pPluginHandle->pfRegisterListener = SmsPlgRegisterListener;
- pPluginHandle->pfSubmitRequest = SmsPlgSubmitRequest;
- pPluginHandle->pfSaveSimMessage = SmsPlgSaveSimMessage;
- pPluginHandle->pfDeleteSimMessage = SmsPlgDeleteSimMessage;
- pPluginHandle->pfSetReadStatus = SmsPlgSetReadStatus;
- pPluginHandle->pfSetMemoryStatus = SmsPlgSetMemoryStatus;
- pPluginHandle->pfSetConfigData = SmsPlgSetConfigData;
- pPluginHandle->pfGetConfigData = SmsPlgGetConfigData;
- pPluginHandle->pfAddMessage = SmsPlgAddMessage;
-
- MSG_DEBUG("SMS plugin: create handler OK");
- MSG_DEBUG("SMS plugin %p", pPluginHandle);
- }
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
-{
- if (pPluginHandle != NULL) {
- free(pPluginHandle);
- pPluginHandle = NULL;
- }
-
- MSG_DEBUG("SMS plugin: destory handler OK");
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgInitialize()
-{
- MSG_BEGIN();
-
- bool bReady = false;
-
- for (int i = 0; i < 100; i++) {
- if (MsgSettingGetBool(VCONFKEY_TELEPHONY_READY, &bReady) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- MSG_DEBUG("Get VCONFKEY_TELEPHONY_READY [%d].", bReady ? 1 : 0);
-
- if (bReady)
- break;
-
- sleep(1);
- }
-
- if (!bReady) {
- MSG_DEBUG("Fail to wait telephony init complete.");
- return MSG_ERR_PLUGIN_TAPIINIT;
- }
-
- pTapiHandle = tel_init(NULL);
-
- if (pTapiHandle) {
- /* register event. */
- SmsPluginCallback::instance()->registerEvent();
-
- /* set sim change status. */
- MSG_DEBUG("Try to initialize SIM on init");
- SmsPluginSetting::instance()->setSimChangeStatus();
-
- /* set resource monitor */
- MsgResourceMonitorInit();
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgFinalize()
-{
- MSG_BEGIN();
-
- MsgResourceMonitorDeinit();
-
- if (!pTapiHandle)
- return MSG_ERR_PLUGIN_TAPIINIT;
-
- SmsPluginCallback::instance()->deRegisterEvent();
-
- tel_deinit(pTapiHandle);
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgRegisterListener(MSG_PLUGIN_LISTENER_S *pListener)
-{
- MSG_BEGIN();
-
- SmsPluginEventHandler::instance()->registerListener(pListener);
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
-{
- msg_error_t err = MSG_SUCCESS;
-
- /* Add Submit SMS into DB */
- if (pReqInfo->msgInfo.msgId == 0) {
- if (pReqInfo->msgInfo.msgPort.valid == false) {
- err = SmsPluginStorage::instance()->checkMessage(&(pReqInfo->msgInfo));
-
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("######## checkMessage Fail !! [err=%d]", err);
- return MSG_ERR_PLUGIN_STORAGE;
- }
-
- err = SmsPluginStorage::instance()->addSmsMessage(&(pReqInfo->msgInfo));
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("######## addSmsMessage Fail !! [err=%d]", err);
- return MSG_ERR_PLUGIN_STORAGE;
- }
-
- if (SmsPluginStorage::instance()->addSmsSendOption(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)) != MSG_SUCCESS) {
- MSG_DEBUG("######## addSmsSendOption Fail !!");
- return MSG_ERR_PLUGIN_STORAGE;
- }
- }
- }
-
- sms_request_info_s *request = NULL;
-
- request = (sms_request_info_s *)calloc(1, sizeof(sms_request_info_s));
-
- if (request != NULL) {
- request->reqId = pReqInfo->reqId;
-
- memcpy(&(request->msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
- memcpy(&(request->sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
-
- /* Add Request into Queue and Start UA Manger */
- SmsPluginUAManager::instance()->addReqEntity(request);
-
- free(request);
- }
-
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
-{
- MSG_DEBUG("CDMA does not support sim card operations.");
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgDeleteSimMessage(msg_sim_id_t SimMsgId)
-{
- MSG_DEBUG("CDMA does not support sim card operations.");
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgSetReadStatus(msg_sim_id_t SimMsgId)
-{
- MSG_DEBUG("CDMA does not support sim card operations.");
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error)
-{
- int tapiRet = TAPI_API_SUCCESS;
- int status = TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE;
-
- if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL) {
- status = TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL;
- }
-
- MSG_DEBUG("Set Status : [%d]", status);
-
- tapiRet = tel_set_sms_memory_status(pTapiHandle, status, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
- }
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
-{
- try {
- SmsPluginSetting::instance()->setConfigData(pSetting);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return MSG_ERR_PLUGIN_SETTING;
- } catch (exception& e) {
- MSG_FATAL("%s", e.what());
- return MSG_ERR_PLUGIN_SETTING;
- }
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgGetConfigData(MSG_SETTING_S *pSetting)
-{
- try {
- SmsPluginSetting::instance()->getConfigData(pSetting);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return MSG_ERR_PLUGIN_SETTING;
- } catch (exception& e) {
- MSG_FATAL("%s", e.what());
- return MSG_ERR_PLUGIN_SETTING;
- }
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char* pFileData)
-{
- MSG_DEBUG("CDMA does not support sim card operations.");
- return MSG_SUCCESS;
-}
-
-
-static void on_change_received(GDBusConnection *connection, const gchar *sender_name,
- const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
- GVariant *parameters, gpointer user_data)
-{
- MSG_DEBUG("signal_name = [%s]", signal_name);
-
- if (g_strcmp0(signal_name, MEMBER_NAME) == 0) {
- gchar *str_val = NULL;
- gint path;
- g_variant_get(parameters, "(is)", &path, &str_val);
- MSG_DEBUG("path = [%i] and str_val = [%s]", path , str_val);
- if (path == TZ_SYS_USER && g_strcmp0(str_val, SIGNAL_VAL) == 0)
- {
- SmsPlgSetMemoryStatus(MSG_ERR_SIM_STORAGE_FULL);
- }
- }
-}
-
-
-void MsgResourceMonitorInit(void)
-{
- MSG_BEGIN();
-
- GError *error = NULL;
-
- if (gdbus_conn) {
- g_object_unref(gdbus_conn);
- gdbus_conn = NULL;
- }
-
- gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_FATAL("g_bus_get_sync() failed : %s", error->message);
- g_error_free(error);
- error = NULL;
- goto _DBUS_ERROR;
- }
-
- if (gdbus_proxy) {
- g_object_unref(gdbus_proxy);
- gdbus_proxy = NULL;
- }
-
- gdbus_proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
- NULL, BUS_NAME, PATH_NAME, INTERFACE_NAME, NULL, &error);
- if (error) {
- MSG_FATAL("G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES() failed : %s", error->message);
- g_error_free(error);
- error = NULL;
- goto _DBUS_ERROR;
- }
-
- subs_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL,
- INTERFACE_NAME, MEMBER_NAME, PATH_NAME,
- NULL, G_DBUS_SIGNAL_FLAGS_NONE,
- on_change_received,
- NULL, NULL);
- MSG_END();
- return;
-
-_DBUS_ERROR:
- if (gdbus_conn) {
- g_object_unref(gdbus_conn);
- gdbus_conn = NULL;
- }
-
- if (gdbus_proxy) {
- g_object_unref(gdbus_proxy);
- gdbus_proxy = NULL;
- }
-
- MSG_END();
- return;
-}
-
-
-void MsgResourceMonitorDeinit(void)
-{
- MSG_BEGIN();
-
- if (subs_id) {
- g_dbus_connection_signal_unsubscribe(gdbus_conn, subs_id);
- subs_id = 0;
- }
-
- if (gdbus_conn) {
- g_object_unref(gdbus_conn);
- gdbus_conn = NULL;
- }
-
- if (gdbus_proxy) {
- g_object_unref(gdbus_proxy);
- gdbus_proxy = NULL;
- }
-
- MSG_END();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <stdio.h>
-#include <string.h>
-
-#include "SmsCdmaPluginParamCodec.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsCdmaPluginParamCodec - Member Functions
-==================================================================================================*/
-SmsPluginParamCodec* SmsPluginParamCodec::pInstance = NULL;
-
-
-SmsPluginParamCodec::SmsPluginParamCodec()
-{
-}
-
-
-SmsPluginParamCodec::~SmsPluginParamCodec()
-{
-}
-
-
-SmsPluginParamCodec* SmsPluginParamCodec::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginParamCodec();
-
- return pInstance;
-}
-
-
-
-/*==================================================================================================
- Util Functions
-==================================================================================================*/
-int SmsPluginParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd)
-{
- int offset = 0;
- unsigned char temp;
-
- for (int i = 0; i < DigitLen; i++) {
- if (pDigit[i] == '*')
- temp = 0x0A;
- else if (pDigit[i] == '#')
- temp = 0x0B;
- else if (pDigit[i] == 'P' || pDigit[i] == 'p')
- temp = 0x0C;
- else
- temp = pDigit[i] - '0';
-
- if ((i % 2) == 0)
- pBcd[offset] = temp & 0x0F;
- else
- pBcd[offset++] |= ((temp & 0x0F) << 4);
- }
-
- if ((DigitLen % 2) == 1) {
- pBcd[offset++] |= 0xF0;
- }
-
- return offset;
-}
-
-
-int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
-{
- int offset = 0;
- unsigned char temp;
-
- for (int i = 0; i < BcdLen; i++) {
- temp = pBcd[i] & 0x0F;
-
- if (temp == 0x0A)
- pDigit[offset++] = '*';
- else if (temp == 0x0B)
- pDigit[offset++] = '#';
- else if (temp == 0x0C)
- pDigit[offset++] = 'P';
- else
- pDigit[offset++] = temp + '0';
-
- temp = (pBcd[i] & 0xF0) >> 4;
-
- if (temp == 0x0F) {
- pDigit[offset] = '\0';
- return offset;
- }
-
- if (temp == 0x0A)
- pDigit[offset++] = '*';
- else if (temp == 0x0B)
- pDigit[offset++] = '#';
- else if (temp == 0x0C)
- pDigit[offset++] = 'P';
- else
- pDigit[offset++] = temp + '0';
- }
-
- pDigit[offset] = '\0';
-
- return offset;
-}
-
-
-int SmsPluginParamCodec::convertDigitToDTMF(const char *pDigit, int DigitLen, int startBit, unsigned char *pDtmf)
-{
- int shift = startBit;
- int offset = 0;
- int srcIdx = 0;
- unsigned char temp;
-
- if (shift > 7) {
- MSG_DEBUG("Invalid Param value shift : %d", shift);
- return 0;
- }
- /* shift 1 and shift 2 are supported in this spec. */
- if (shift >= 4) {
- MSG_DEBUG("Invalid Param value shift : %d", shift);
- return 0;
- }
-
- for (int i = 0; i < DigitLen; i++) {
- if (pDigit[srcIdx] == '*')
- temp = 0x0B;
- else if (pDigit[srcIdx] == '#')
- temp = 0x0C;
- else if (pDigit[srcIdx] == '0')
- temp = 0x0A;
- else
- temp = pDigit[srcIdx] - '0';
-
- temp &= 0x0F;
-
- if (shift == 0) {
- if (i % 2 == 1) {
- pDtmf[offset] |= temp;
- offset++;
- } else {
- pDtmf[offset] |= temp << 4;
- }
- } else if (shift >= 1 && shift < 4) {
- if (i % 2 == 1) {
- pDtmf[offset] |= (temp >> shift);
- pDtmf[offset + 1] = temp << (8 - shift);
- offset++;
- } else {
- pDtmf[offset] |= (temp << (8 - shift - 4));
- }
- }
-
- srcIdx++;
- }
-
- return offset;
-}
-
-
-int SmsPluginParamCodec::convertDTMFToDigit(const unsigned char *pDtmf, int DtmfLen, int startBit, char *pDigit)
-{
- int shift = startBit;
- int offset = 0;
- int srcIdx = 0;
- unsigned char temp = 0;
-
- if (shift > 7) {
- MSG_DEBUG("Invalid Param value shift : %d", shift);
- return 0;
- }
- /* shift 1 and shift 2 are supported in this spec. */
- if (shift >= 4) {
- MSG_DEBUG("Invalid Param value shift : %d", shift);
- return 0;
- }
-
- for (int i = 0; i < DtmfLen; i++) {
- if (shift == 0) {
- if (i % 2 == 1) {
- temp = pDtmf[srcIdx] & 0x0F;
- srcIdx++;
- } else {
- temp = (pDtmf[srcIdx] >> 4) & 0x0F;
- }
- } else if (shift >= 1 && shift < 4) {
- if (i % 2 == 1) {
- temp = ((pDtmf[srcIdx] << shift) & 0x0F) + (pDtmf[srcIdx + 1] >> (8 - shift));
- srcIdx++;
- } else {
- temp = (pDtmf[srcIdx] >> (8 - shift - 4)) & 0x0F;
- }
- }
-
- if (temp == 0x0A)
- pDigit[offset++] = '0';
- else if (temp == 0x0B)
- pDigit[offset++] = '*';
- else if (temp == 0x0C)
- pDigit[offset++] = '#';
- else
- pDigit[offset++] = temp + '0';
- }
-
- pDigit[offset] = '\0';
-
- return offset;
-}
-
-
-bool SmsPluginParamCodec::isDtmfNumber(const char *pDigit, int DigitLen)
-{
- bool isDtmf = true;
-
- for (int i = 0; i < DigitLen; i++) {
- if (!((pDigit[i] >= '0' && pDigit[i] <= '9') ||
- pDigit[i] == '*' ||
- pDigit[i] == '#')) {
- isDtmf = false;
- break;
- }
- }
-
- return isDtmf;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-#include <pthread.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-
-#include "MsgContact.h"
-#include "MsgUtilStorage.h"
-#include "MsgTextConvert.h"
-
-#include "SmsCdmaPluginParamCodec.h"
-#include "SmsCdmaPluginCallback.h"
-#include "SmsCdmaPluginEventHandler.h"
-#include "SmsCdmaPluginMain.h"
-#include "SmsCdmaPluginSetting.h"
-
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
- #include <ITapiSim.h>
- #include <ITapiModem.h>
-}
-
-extern struct tapi_handle *pTapiHandle;
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginSetting - Member Functions
-==================================================================================================*/
-SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
-
-
-SmsPluginSetting::SmsPluginSetting()
-{
- /* Initialize member variables */
- memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
- memset(&meImei, 0x00, sizeof(meImei));
-
- bTapiResult = false;
- bUpdateVoicemailByMdn = false;
-}
-
-
-SmsPluginSetting::~SmsPluginSetting()
-{
-}
-
-
-SmsPluginSetting* SmsPluginSetting::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginSetting();
-
- return pInstance;
-}
-
-
-void* SmsPluginSetting::initSimInfo(void *data)
-{
- MSG_BEGIN();
-
- int tapiRet = TAPI_API_SUCCESS;
-
- /* Get IMSI */
- char imsi[17];
- memset(imsi, 0x00, sizeof(imsi));
-
- /* Get IMSI */
- TelSimImsiInfo_t imsiInfo;
- memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
-
- tapiRet = tel_get_sim_imsi(pTapiHandle, &imsiInfo);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_SEC_DEBUG("tel_get_sim_imsi() Success - MCC [%s], MNC [%s], MSIN [%s]", imsiInfo.szMcc, imsiInfo.szMnc, imsiInfo.szMsin);
- snprintf(imsi, sizeof(imsi), "%03d%03d%s", atoi(imsiInfo.szMcc), atoi(imsiInfo.szMnc), imsiInfo.szMsin);
- MSG_SEC_DEBUG("IMSI [%s]", imsi);
- } else {
- MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
- }
-
- MsgSettingSetString(MSG_SIM_IMSI, imsi);
-
- instance()->updateSimStatus();
-
- MSG_END();
- return NULL;
-}
-
-
-void SmsPluginSetting::updateSimStatus()
-{
- MSG_BEGIN();
-
- if (!pTapiHandle) {
- MSG_DEBUG("pTapiHandle is NULL.");
- return;
- }
-
- int status = 0;
- int tapiRet = TAPI_API_SUCCESS;
-
- tapiRet = tel_check_sms_device_status(pTapiHandle, &status);
-
- if (tapiRet != TAPI_API_SUCCESS) {
- MSG_DEBUG("tel_check_sms_device_status() Error! [%d], Status [%d]", tapiRet, status);
- return;
- }
-
- if (status == 1 || status == 2) {
- MSG_DEBUG("Device Is Ready, status = %d", status);
- SmsPluginEventHandler::instance()->setNeedInitConfig(false);
- } else if (status == 0) {
- MSG_DEBUG("Device Is Not Ready.. Waiting For Ready Callback");
-
- if (SmsPluginEventHandler::instance()->getDeviceStatus() == true) {
- MSG_DEBUG("Device Is Ready");
- } else {
- MSG_DEBUG("Device Is Not Ready.");
- return;
- }
- }
-
- /* init config data. */
- initConfigData();
-
- MSG_END();
-
- return;
-}
-
-
-void SmsPluginSetting::setSimChangeStatus()
-{
- MSG_BEGIN();
-
- pthread_t thd;
-
- if (pthread_create(&thd, NULL, &initSimInfo, NULL) < 0) {
- MSG_DEBUG("pthread_create() error");
- }
-
- pthread_detach(thd);
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::initConfigData()
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int sim_idx = 1;
-
- /*==================== CB configuration ====================*/
- /*
- if (simStatus != MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("simStatus == [%d]", simStatus);
- */
- MSG_CBMSG_OPT_S cbMsgOpt = {0, };
-
- if (getCbConfig(&cbMsgOpt) == true) {
- err = addCbOpt(&cbMsgOpt);
-
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("######## Add CB Option Success !!! #######");
- MSG_SETTING_S cbSetting;
- cbSetting.type = MSG_CBMSG_OPT;
- getCbOpt(&cbSetting);
- setCbConfig(&(cbSetting.option.cbMsgOpt));
- } else {
- MSG_DEBUG("######## Add CB Option Fail !!! return : %d #######", err);
- }
- } else {
- MSG_DEBUG("######## getCbConfig Fail !!! #######");
- }
-
- /*==================== MSISDN update ====================*/
- if (getMsisdnInfo() == true) {
- MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
- } else {
- MSG_DEBUG("######## getMsisdnInfo Fail !!! #######");
- }
-
- /*==================== Default Voice mail Setting ====================*/
- MSG_DEBUG("Voicemail Default Number is NULL");
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
- if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_NUMBER) != MSG_SUCCESS)
- MSG_DEBUG("Error to set config data [%s]", keyName);
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, sim_idx);
- if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
- MSG_DEBUG("Error to set config data [%s]", keyName);
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::SimRefreshCb()
-{
- pthread_t thd;
-
- if (pthread_create(&thd, NULL, &init_config_data, NULL) < 0) {
- MSG_DEBUG("pthread_create() error");
- }
-
- pthread_detach(thd);
-}
-
-
-void* SmsPluginSetting::init_config_data(void *data)
-{
- instance()->initConfigData();
- return NULL;
-}
-
-
-void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
-{
- MSG_DEBUG("Setting Type : [%d]", pSetting->type);
-
- switch (pSetting->type) {
-#if 0
- case MSG_SMS_SENDOPT :
- setNetworkMode(&pSetting->option.smsSendOpt);
- break;
- case MSG_SMSC_LIST :
- setParamList(&pSetting->option.smscList);
- break;
-#endif
- case MSG_VOICEMAIL_OPT:
- setVoiceMailInfo(&pSetting->option.voiceMailOpt);
- break;
-
- case MSG_CBMSG_OPT :
- setCbConfig(&pSetting->option.cbMsgOpt);
- break;
- default :
- THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
- break;
- }
-}
-
-
-void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
-{
- MSG_DEBUG("Setting Type : [%d]", pSetting->type);
-
- switch (pSetting->type) {
-#if 0
- case MSG_SMSC_LIST :
- getParamList(&pSetting->option.smscList);
- break;
-#endif
- case MSG_CBMSG_OPT :
- getCbConfig(&pSetting->option.cbMsgOpt);
- break;
-
- default :
- THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
- break;
- }
-}
-
-
-msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
-{
- msg_error_t err = MSG_SUCCESS;
-
- /* MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt); */
-
- MSG_DEBUG("Receive [%d], Channel Count [%d]", pCbOpt->bReceive, pCbOpt->channelData.channelCnt);
-
- for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
- MSG_DEBUG("Channel Category [%d], Channel Language [%d]", pCbOpt->channelData.channelInfo[i].ctg, pCbOpt->channelData.channelInfo[i].lang);
- }
-
-#if 0
- /* Set Setting Data into Vconf */
- if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
- return MSG_ERR_SET_SETTING;
- }
-#endif
-
-#if 0
- if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
- return MSG_ERR_SET_SETTING;
- }
-#endif
-
-#if 0
- MsgDbHandler dbHandle;
- err = MsgStoAddCBChannelInfo(&dbHandle, &pCbOpt->channelData);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("MsgStoGetCBChannelInfo is failed [%d]", err);
- return MSG_ERR_SET_SETTING;
- }
-#endif
-
- return err;
-}
-
-
-void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
-{
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler dbHandle;
-
- memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
-
- if (MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- err = MsgStoGetCBChannelInfo(&dbHandle, &pSetting->option.cbMsgOpt.channelData);
- MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
-
-#if 0
- char keyName[128];
-
- for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_LANGUAGE, i);
-
- if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
- }
-#endif
-}
-
-
-void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
-{
- bUpdateVoicemailByMdn = false;
-
- return;
-}
-
-
-bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
-{
- int ret = TAPI_API_SUCCESS;
-
-#if 1
- TelSmsCbConfig_t cbConfig = {};
-
- cbConfig.CBEnabled = (int)pCbOpt->bReceive;
- cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP2;
- /* cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt; */
- cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
-
- for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
- cbConfig.MsgIDs[i].Net3gpp2.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
- cbConfig.MsgIDs[i].Net3gpp2.CBCategory = (unsigned short)pCbOpt->channelData.channelInfo[i].ctg;
- cbConfig.MsgIDs[i].Net3gpp2.CBLanguage = (unsigned short)pCbOpt->channelData.channelInfo[i].lang;
-
- MSG_DEBUG("Category: %d, Language: %d", cbConfig.MsgIDs[i].Net3gpp2.CBCategory, cbConfig.MsgIDs[i].Net3gpp2.CBLanguage);
- }
- MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);
-
- ret = tel_set_sms_cb_config(pTapiHandle, &cbConfig, TapiEventSetConfigData, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
- return false;
- }
-
-#if 0
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Set Cb Config was Failed !!! #######");
- return false;
- }
-#endif
-#endif
- return true;
-}
-
-
-bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
-{
- int ret = TAPI_API_SUCCESS;
-#if 1
- ret = tel_get_sms_cb_config(pTapiHandle, TapiEventGetCBConfig, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getCbConfigEvent(pCbOpt) == true) {
- MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Get Cb Config was Failed !!! #######");
- return false;
- }
-#endif
- return true;
-}
-
-
-void SmsPluginSetting::getMeImei(char *pImei)
-{
-#if 0
- int ret = TAPI_API_SUCCESS;
- ret = tel_get_misc_me_imei(pTapiHandle, TapiEventGetMeImei, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Success !!! #######");
-
- if (getResultImei(pImei) == true) {
- MSG_SEC_DEBUG("######## Get ME IMEI was Successful !!! #######");
- } else {
- MSG_SEC_DEBUG("######## Get ME IMEI was Failed !!! #######");
- }
- } else {
- MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Fail !!! return : %d #######", ret);
- }
-#endif
-}
-
-bool SmsPluginSetting::getUpdateVoicemailByMdn()
-{
- return bUpdateVoicemailByMdn;
-}
-
-void SmsPluginSetting::setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
-{
- mx.lock();
-
- bTapiResult = bSuccess;
-
- memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
-
- if (bTapiResult == true) {
- MSG_DEBUG("Success to get cb config data");
-
- memcpy(&cbOpt, pCbOpt, sizeof(MSG_CBMSG_OPT_S));
- }
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
-{
- int ret = 0;
-
- mx.lock();
-
- bTapiResult = false;
- ret = cv.timedwait(mx.pMsgMutex(), 25);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
-
- if (bTapiResult == true) {
- memcpy(pCbOpt, &cbOpt, sizeof(MSG_CBMSG_OPT_S));
- }
-
- return bTapiResult;
-}
-
-
-void SmsPluginSetting::setResultImei(bool bResult, char *pImei)
-{
- mx.lock();
-
- bTapiResult = bResult;
-
- memset(&meImei, 0x00, sizeof(meImei));
-
- if (bTapiResult == true && pImei) {
- snprintf(meImei, sizeof(meImei), "%s", pImei);
- }
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSetting::getResultImei(char *pImei)
-{
- int ret = 0;
-
- mx.lock();
-
- ret = cv.timedwait(mx.pMsgMutex(), 25);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- if (bTapiResult == true && pImei) {
- snprintf(pImei, sizeof(meImei), "%s", meImei);
- }
-
- return bTapiResult;
-}
-
-
-void SmsPluginSetting::setResultFromEvent(bool bResult)
-{
- mx.lock();
-
- bTapiResult = bResult;
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
-{
- MSG_DEBUG("SET MWI INFO, type=[%d]", type);
- MSG_DEBUG("SET MWI INFO, count=[%d]", count);
-
- if (MsgSettingSetInt(VOICEMAIL_COUNT, count) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetInt is failed!!");
- /*
- if (count == 0) {
- MsgStoClearUniquenessTable();
- }
-
- if (count <= 0) {
- if (type == MSG_MWI_VOICE_SMS)
- MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_1);
- else if (type == MSG_MWI_VOICE2_SMS)
- MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_2);
- }
-
- if (bMbdnEnable == false) {
- MSG_DEBUG("MBDN service is disable.");
- return;
- }
- */
- return;
-}
-
-
-bool SmsPluginSetting::getMsisdnInfo(void)
-{
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sim_msisdn(pTapiHandle, TapiEventGetMsisdnInfo, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Get Sim msisdn was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Get Sim msisdn was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-void SmsPluginSetting::setResultFromSim(bool bResult)
-{
- mx.lock();
-
- bTapiResult = bResult;
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSetting::getResultFromSim()
-{
- int ret = 0;
-
- mx.lock();
-
- ret = cv.timedwait(mx.pMsgMutex(), 25);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- return bTapiResult;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgContact.h"
-#include "MsgUtilFile.h"
-#include "MsgUtilStorage.h"
-#include "MsgUtilFunction.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-
-#include "SmsCdmaPluginMain.h"
-#include "SmsCdmaPluginStorage.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginStorage - Member Functions
-==================================================================================================*/
-SmsPluginStorage* SmsPluginStorage::pInstance = NULL;
-
-
-SmsPluginStorage::SmsPluginStorage()
-{
-}
-
-
-SmsPluginStorage::~SmsPluginStorage()
-{
-}
-
-
-SmsPluginStorage* SmsPluginStorage::instance()
-{
- if (!pInstance) {
- MSG_DEBUG("pInstance is NULL. Now creating instance.");
- pInstance = new SmsPluginStorage();
- }
-
- return pInstance;
-}
-
-
-msg_error_t SmsPluginStorage::insertMsgRef(MSG_MESSAGE_INFO_S *pMsg, unsigned char msgRef, int index)
-{
- MSG_BEGIN();
-
- time_t curTime = time(NULL);
-
- MsgDbHandler *dbHandle = getDbHandle();
- char sqlQuery[MAX_QUERY_LEN+1];
- char *normalNum = NULL;
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
- normalNum = msg_normalize_number(pMsg->addressList[index].addressVal);
-
- MSG_SEC_DEBUG("Insert MsgID=[%d], Address=[%s], MsgRef=[%d], Time=[%d]", \
- pMsg->msgId, normalNum, (int)msgRef, (int)curTime);
-
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %s, %d, 0, -1, %d);",
- MSGFW_SMS_REPORT_TABLE_NAME, pMsg->msgId, normalNum, (int)msgRef, (int)curTime);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("MsgExecQuery() : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInfo, unsigned char msgRef)
-{
- MSG_BEGIN();
-
- MsgDbHandler *dbHandle = getDbHandle();
- char sqlQuery[MAX_QUERY_LEN+1];
-
- msg_message_id_t msgId = 0;
- int rowCnt = 0;
- char *normalNum = NULL;
-
- normalNum = msg_normalize_number(pMsgInfo->addressList[0].addressVal);
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE ADDRESS_VAL = %s AND MSG_REF > 0 ORDER BY TIME ASC;",
- MSGFW_SMS_REPORT_TABLE_NAME, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
- return MSG_ERR_DB_PREPARE;
-
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
- msgId = dbHandle->columnInt(0);
-
- dbHandle->finalizeQuery();
-
- pMsgInfo->msgId = msgId;
-
- /* Update Status - MSG_MESSAGE_TABLE */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;",
- MSGFW_SMS_REPORT_TABLE_NAME, msgId);
-
- if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS)
- return MSG_ERR_DB_GETTABLE;
-
- MSG_DEBUG("Selected row count = [%d]", rowCnt);
-
- if (rowCnt == 1 && pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE MSG_ID = %d;",
- MSGFW_MESSAGE_TABLE_NAME, (int)pMsgInfo->networkStatus, msgId);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- }
-
- /* Update Status - MSG_REPORT_TABLE */
- if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 1, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 0, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 3, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 8, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t status)
-{
- MSG_BEGIN();
-
- if (!pMsgInfo || (pMsgInfo && pMsgInfo->msgId <= 0)) {
- MSG_DEBUG("Invalid message id");
- return MSG_ERR_INVALID_MESSAGE_ID;
- }
-
- MsgDbHandler *dbHandle = getDbHandle();
- char sqlQuery[MAX_QUERY_LEN+1];
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
- MSG_DEBUG("Update Msg ID : [%d], Network Status : [%d] ", pMsgInfo->msgId, status);
-
- /* Move Msg to SENTBOX */
- if (status == MSG_NETWORK_SEND_SUCCESS) {
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d, FOLDER_ID = %d WHERE MSG_ID = %d;",
- MSGFW_MESSAGE_TABLE_NAME, status, MSG_SENTBOX_ID, pMsgInfo->msgId);
- } else {
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d, READ_STATUS = 0 WHERE MSG_ID = %d;",
- MSGFW_MESSAGE_TABLE_NAME, status, pMsgInfo->msgId);
- }
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("MsgExecQuery() : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
-
- if (status == MSG_NETWORK_SEND_SUCCESS) {
- MSG_DEBUG("MsgAddPhoneLog() : folderId [%d]", pMsgInfo->folderId);
- MsgAddPhoneLog(pMsgInfo);
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /* Check whether storage is full or not */
- err = checkStorageStatus(pMsgInfo);
-
- if (err != MSG_SUCCESS) {
- if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
- pMsgInfo->folderId = 0;
- err = MSG_SUCCESS;
-/* }
- else if (pMsgInfo->msgType.classType == MSG_CLASS_2 &&
- (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS)) {
- err = addClass2Message(pMsgInfo);
-*/
- } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
- err = MSG_SUCCESS;
- }
- return err;
- }
-
- /* Amend message information for type */
- if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS) {
- MSG_DEBUG("Normal SMS");
-
- if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
- /* err = addClass2Message(pMsgInfo); */
- } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
- /* Class 0 Msg should be saved in hidden folder */
- pMsgInfo->folderId = 0;
- }
-
- } else if ((pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS) && (pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS)) {
- MSG_DEBUG("Replace SM Type [%d]", pMsgInfo->msgType.subType-3);
-
- if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
- /* err = addClass2Message(pMsgInfo); */
- } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
- /* Class 0 Msg should be saved in hidden folder */
- pMsgInfo->folderId = 0;
- pMsgInfo->msgType.subType = MSG_NORMAL_SMS;
- }
-
- } else if ((pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS) && (pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
- if (pMsgInfo->bStore == true) {
- MSG_DEBUG("MWI Message");
- /*
- if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
- err = addClass2Message(pMsgInfo);
- }
- */
- }
- } else {
- MSG_DEBUG("No matching type [%d]", pMsgInfo->msgType.subType);
- }
-
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("Success to check message !!");
- } else {
- MSG_DEBUG("fail to check message !! : [%d]", err);
- }
-
- return err;
-}
-
-
-msg_error_t SmsPluginStorage::addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- msg_error_t err = MSG_SUCCESS;
-
- unsigned int rowId = 0;
- msg_thread_id_t convId = 0;
-
- MsgDbHandler *dbHandle = getDbHandle();
- dbHandle->beginTrans();
-
- if (pMsgInfo->nAddressCnt > 0) {
- err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId);
-
- if (err != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return err;
- }
-
- pMsgInfo->threadId = convId;
- }
-
- /* Add Message Table */
- rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo);
-
- if (rowId <= 0) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_ROW;
- }
-
- /* Update conversation table */
- err = MsgStoUpdateConversation(dbHandle, convId);
-
- if (err != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return err;
- }
-
- err = dbHandle->endTrans(true);
- if (err != MSG_SUCCESS) {
- return err;
- }
-
- pMsgInfo->msgId = (msg_message_id_t)rowId;
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
-{
- MSG_BEGIN();
-
- MsgDbHandler *dbHandle = getDbHandle();
- char sqlQuery[MAX_QUERY_LEN+1];
-
- /* Get SUB_TYPE, STORAGE_ID */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE, FOLDER_ID, CONV_ID, SIM_INDEX \
- FROM %s WHERE MSG_ID = %d;",
- MSGFW_MESSAGE_TABLE_NAME, msgId);
-
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
- return MSG_ERR_DB_PREPARE;
-
- MSG_MESSAGE_TYPE_S msgType;
- msg_folder_id_t folderId;
-
- msg_thread_id_t convId;
- int simIndex;
-
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
- msgType.mainType = dbHandle->columnInt(0);
- msgType.subType = dbHandle->columnInt(1);
- folderId = dbHandle->columnInt(2);
- convId = dbHandle->columnInt(3);
- simIndex = dbHandle->columnInt(4);
-
- MSG_DEBUG("Main Type:[%d] SubType:[%d] FolderId:[%d] ConversationId:[%d] simIndex:[%d]", msgType.mainType, msgType.subType, folderId, convId, simIndex);
- } else {
- MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
- dbHandle->finalizeQuery();
- return MSG_ERR_DB_STEP;
- }
-
- dbHandle->finalizeQuery();
-
- dbHandle->beginTrans();
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_SENDOPT_TABLE_NAME, msgId);
-
- /* Delete SMS Send Option */
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- if (msgType.subType == MSG_CB_SMS || msgType.subType == MSG_JAVACB_SMS) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_CB_MSG_TABLE_NAME, msgId);
-
- /* Delete Push Message from push table */
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
- } else if (msgType.subType >= MSG_WAP_SI_SMS && msgType.subType <= MSG_WAP_CO_SMS) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_PUSH_MSG_TABLE_NAME, msgId);
-
- /* Delete Push Message from push table */
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
- } else if (msgType.subType == MSG_SYNCML_CP) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SYNCML_MSG_TABLE_NAME, msgId);
-
- /* Delete SyncML Message from syncML table */
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
- }
-
- /* Delete Message from msg table */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId);
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- /* Delete Message from msg_report table */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_REPORT_TABLE_NAME, msgId);
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- /* Delete Message from msg_sim table */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, msgId);
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- /* Clear Conversation table */
- if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- /* Update conversation table.*/
- if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_STORAGE_ERROR;
- }
-
- dbHandle->endTrans(true);
-
- if (folderId == MSG_INBOX_ID) {
- msgType.classType = MSG_CLASS_NONE;
-
- /* Set memory status in SIM */
- if (MsgStoCheckMsgCntFull(dbHandle, &msgType, folderId) == MSG_SUCCESS) {
- MSG_DEBUG("Set Memory Status");
- SmsPlgSetMemoryStatus(MSG_SUCCESS);
- } else if (MsgStoCheckMsgCntFull(dbHandle, &msgType, folderId) == MSG_ERR_MESSAGE_COUNT_FULL) {
- MSG_DEBUG("Set Memory Status");
- SmsPlgSetMemoryStatus(MSG_ERR_MESSAGE_COUNT_FULL);
- } else {
- MSG_DEBUG("Storage event error :Failed to get space info ");
- }
- }
-
- /* MsgRefreshAllNotification(true, false, false); */
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo)
-{
- MSG_BEGIN();
-
- MsgDbHandler *dbHandle = getDbHandle();
- msg_error_t err = MSG_SUCCESS;
-
- if (pSendOptInfo->bSetting == false) {
- if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if (MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSendOptInfo->option.smsSendOptInfo.bReplyPath) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
- /*
- if (pSendOptInfo->bDeliverReq || pSendOptInfo->option.smsSendOptInfo.bReplyPath) {
- pSendOptInfo->bSetting = true;
- */
- if (MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
- /* } */
- }
-
- /* if (pSendOptInfo->bSetting == true) { */
- char sqlQuery[MAX_QUERY_LEN+1];
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
- MSGFW_SMS_SENDOPT_TABLE_NAME, pMsg->msgId, pSendOptInfo->bDeliverReq,
- pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->encodeType);
-
- MSG_DEBUG("Query = [%s]", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- err = MSG_ERR_DB_EXEC;
- }
- /* } */
-
- MSG_END();
-
- return err;
-}
-
-
-msg_error_t SmsPluginStorage::checkStorageStatus(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- msg_error_t err = MSG_SUCCESS;
-
- MsgDbHandler *dbHandle = getDbHandle();
- err = MsgStoCheckMsgCntFull(dbHandle, &(pMsgInfo->msgType), pMsgInfo->folderId);
-
- if (err != MSG_SUCCESS) {
- if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
- bool bAutoErase = false;
-
- if (MsgSettingGetBool(MSG_AUTO_ERASE, &bAutoErase) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- MSG_DEBUG("bAutoErase: %d", bAutoErase);
-
- if (bAutoErase == true) {
- msg_message_id_t msgId;
-
- /* Find the oldest message's msgId */
- err = MsgStoGetOldestMessage(dbHandle, pMsgInfo, &msgId);
-
- if (err != MSG_SUCCESS)
- return err;
-
- /* Delete the corresponding message. */
- err = deleteSmsMessage(msgId);
- }
- }
-
- return err;
- }
-
- return err;
-}
-
-
-msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *count, char *application_id, int app_id_len, char *content_type, int content_type_len)
-{
- msg_error_t err = MSG_SUCCESS;
-
- int rowCnt = 0, index = 0;
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1] = {0, };
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENT_TYPE, APP_ID, APPCODE FROM %s", MSGFW_PUSH_CONFIG_TABLE_NAME);
-
- err = dbHandle->getTable(sqlQuery, &rowCnt, &index);
- MSG_DEBUG("rowCnt: %d", rowCnt);
-
- if (err == MSG_ERR_DB_NORECORD) {
- dbHandle->freeTable();
- return MSG_SUCCESS;
- } else if (err != MSG_SUCCESS) {
- dbHandle->freeTable();
- return err;
- }
-
- char contentType[MAX_WAPPUSH_CONTENT_TYPE_LEN + 1] = {0, };
- char appId[MAX_WAPPUSH_ID_LEN + 1] = {0, };
- int appcode = 0, default_appcode = 0;
- bool found = false;
- char *_content_type = NULL, *_app_id = NULL;
- *count = 0;
-
-
- for (int i = 0; i < rowCnt; i++) {
- memset(contentType, 0, MAX_WAPPUSH_CONTENT_TYPE_LEN);
- memset(appId, 0, MAX_WAPPUSH_ID_LEN);
-
- dbHandle->getColumnToString(index++, MAX_WAPPUSH_CONTENT_TYPE_LEN + 1, contentType);
- dbHandle->getColumnToString(index++, MAX_WAPPUSH_ID_LEN + 1, appId);
- appcode = dbHandle->getColumnToInt(index++);
-
- /* MSG_DEBUG("content_type: %s, app_id: %s", content_type, app_id); */
- _content_type = strcasestr(pPushHeader, contentType);
- if (_content_type) {
- _app_id = strcasestr(pPushHeader, appId);
- if (appcode)
- default_appcode = appcode;
-
- if (_app_id) {
- PUSH_APPLICATION_INFO_S pInfo = {0, };
- pInfo.appcode = appcode;
- MSG_SEC_DEBUG("appcode: %d, app_id: %s", pInfo.appcode, appId);
- snprintf(application_id, app_id_len, "%s", appId);
- snprintf(content_type, content_type_len, "%s", contentType);
- pushAppInfoList.push_back(pInfo);
- (*count)++;
- found = true;
- }
- }
- }
-
- if (!found && default_appcode != SMS_WAP_APPLICATION_LBS) {
- /* perform default action. */
- PUSH_APPLICATION_INFO_S pInfo = {0, };
- pInfo.appcode = default_appcode;
- memset(appId, 0, MAX_WAPPUSH_ID_LEN + 1);
- snprintf(application_id, app_id_len, "%s", appId);
- snprintf(content_type, content_type_len, "%s", contentType);
- pushAppInfoList.push_back(pInfo);
- *count = 1;
- }
- dbHandle->freeTable();
-
- return err;
-}
-
-
-msg_error_t SmsPluginStorage::getnthPushEvent(int index, int *appcode)
-{
- msg_error_t err = MSG_SUCCESS;
- if ((unsigned int)index > pushAppInfoList.size() - 1)
- return MSG_ERR_INVALID_PARAMETER;
-
- std::list<PUSH_APPLICATION_INFO_S>::iterator it = pushAppInfoList.begin();
- int count = 0;
- for (; it != pushAppInfoList.end(); it++) {
- if (index == count) {
- *appcode = it->appcode;
- break;
- }
- count++;
- }
-
- return err;
-}
-
-
-msg_error_t SmsPluginStorage::releasePushEvent()
-{
- msg_error_t err = MSG_SUCCESS;
- std::list<PUSH_APPLICATION_INFO_S>::iterator it = pushAppInfoList.begin();
-
- for (; it != pushAppInfoList.end(); it++)
- it = pushAppInfoList.erase(it);
-
- return err;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-
-#include "MsgGconfWrapper.h"
-#include "MsgException.h"
-
-#include "MsgUtilStorage.h"
-#include "MsgNotificationWrapper.h"
-
-#include "SmsCdmaPluginTransport.h"
-#include "SmsCdmaPluginCodec.h"
-#include "SmsCdmaPluginEventHandler.h"
-#include "SmsCdmaPluginCallback.h"
-
-extern "C" {
-#include "TapiUtility.h"
-#include "TelSms.h"
-#include "TelNetwork.h"
-#include "ITapiNetText.h"
-}
-
-extern struct tapi_handle *pTapiHandle;
-extern bool isMemAvailable;
-
-
-/*==================================================================================================
- FUNCTION IMPLEMENTATION
-==================================================================================================*/
-
-SmsPluginTransport* SmsPluginTransport::pInstance = NULL;
-
-
-SmsPluginTransport::SmsPluginTransport()
-{
- msgRef = 0x00;
- msgRef8bit = 0x00;
- msgRef16bit = 0x0000;
-
- msgSeqNum = 0x00;
- if (MsgSettingGetInt(MSG_MESSAGE_ID_COUNTER, (int *)&msgSubmitId) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
-}
-
-
-SmsPluginTransport::~SmsPluginTransport()
-{
-}
-
-
-SmsPluginTransport* SmsPluginTransport::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginTransport();
-
- return pInstance;
-}
-
-
-unsigned char SmsPluginTransport::getMsgRef()
-{
- return msgRef++;
-}
-
-
-unsigned char SmsPluginTransport::getSeqNum()
-{
- msgSeqNum = ((msgSeqNum + 1) % SMS_SEQ_NUM_MAX);
-
- return msgSeqNum;
-}
-
-
-unsigned char SmsPluginTransport::getSubmitMsgId()
-{
- msgSubmitId = ((msgSubmitId + 1) % SMS_MAX_MESSAGE_ID);
-
- MsgSettingSetInt(MSG_MESSAGE_ID_COUNTER, msgSubmitId);
-
- return msgSubmitId;
-}
-
-
-void SmsPluginTransport::convertMsgInfoToTelesvcMsg(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_trans_msg_s *pTransMsg)
-{
- switch (pTransMsg->type) {
- case SMS_TRANS_P2P_MSG: {
- MSG_DEBUG("Convert MSG_MESSAGE_INFO_S data to SMS_TRANS_MSG_S data.");
- sms_trans_p2p_msg_s *pPtpMsg = (sms_trans_p2p_msg_s *)&(pTransMsg->data.p2p_msg);
-
- convertMsgInfoToPtp(pMsgInfo, pPtpMsg);
- }
- break;
- default:
- MSG_DEBUG("Error Unsupported Transport Type");
- break;
- }
-}
-
-
-void SmsPluginTransport::convertMsgInfoToPtp(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_trans_p2p_msg_s *pPtpMsg)
-{
- /* 1. Set Teleservice ID */
- pPtpMsg->telesvc_id = SMS_TRANS_TELESVC_CMT_95;
-
- /* 2. Set Service category */
- pPtpMsg->svc_ctg = SMS_TRANS_SVC_CTG_UNDEFINED;
-
- /* 3. Convert Address values */
- pPtpMsg->address.digit_mode = SMS_DIGIT_4BIT_DTMF;
- pPtpMsg->address.number_mode = SMS_NUMBER_MODE_NONE_DATANETWORK;
- pPtpMsg->address.number_type = SMS_NUMBER_TYPE_UNKNOWN;
- pPtpMsg->address.number_plan = SMS_NPI_UNKNOWN;
- pPtpMsg->address.addr_len = strlen(pMsgInfo->addressList[0].addressVal);
- strncpy(pPtpMsg->address.szData, pMsgInfo->addressList[0].addressVal, pPtpMsg->address.addr_len);
-
- if (pMsgInfo->addressList[0].addressVal[0] == '+') {
- pPtpMsg->address.digit_mode = SMS_DIGIT_8BIT;
- pPtpMsg->address.number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
- } else {
- pPtpMsg->address.number_type = SMS_NUMBER_TYPE_NATIONAL;
- }
-
- /* 4. Convert Sub-address values */
- /* TODO */
-
- /* 5. Set Reply sequence number. */
- pPtpMsg->reply_seq = getSeqNum();
-
- /* convert msgInfo to Teleservice Message */
- switch (pPtpMsg->telesvc_msg.type) {
- case SMS_TYPE_SUBMIT:
- convertMsgInfoToSubmit(pMsgInfo, &(pPtpMsg->telesvc_msg.data.submit));
- break;
- default:
- break;
- }
-}
-
-
-void SmsPluginTransport::convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_telesvc_submit_s *pSubmit)
-{
- if (pSubmit == NULL)
- return;
-
- /* 1. Set msg ID. */
- pSubmit->msg_id.msg_id = getSubmitMsgId();
- pSubmit->msg_id.header_ind = false;
-
- /* 2. Set User Data */
- unsigned char decodeData[SMS_MAX_USER_DATA_LEN + 1];
- memset(decodeData, 0x00, sizeof(decodeData));
-
- MsgTextConvert *textCvt = MsgTextConvert::instance();
-
- msg_encode_type_t encodeType = MSG_ENCODE_GSM7BIT;
-
-
- if (pMsgInfo->bTextSms == true) {
- if (pMsgInfo->encodeType == MSG_ENCODE_GSM7BIT) {
- pSubmit->user_data.encode_type = SMS_ENCODE_GSM7BIT;
- } else if (pMsgInfo->encodeType == MSG_ENCODE_8BIT) {
- pSubmit->user_data.encode_type = SMS_ENCODE_OCTET;
- } else if (pMsgInfo->encodeType == MSG_ENCODE_UCS2) {
- pSubmit->user_data.encode_type = SMS_ENCODE_UNICODE;
- } else if (pMsgInfo->encodeType == MSG_ENCODE_AUTO) {
- textCvt->convertUTF8ToAuto(decodeData, SMS_MAX_USER_DATA_LEN + 1, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &encodeType);
- if (encodeType == MSG_ENCODE_ASCII7BIT) {
- pSubmit->user_data.encode_type = SMS_ENCODE_7BIT_ASCII;
- } else if (encodeType == MSG_ENCODE_8BIT) {
- pSubmit->user_data.encode_type = SMS_ENCODE_OCTET;
- } else if (encodeType == MSG_ENCODE_UCS2) {
- pSubmit->user_data.encode_type = SMS_ENCODE_UNICODE;
- }
- }
- }
-
- memset(pSubmit->user_data.user_data, 0x00, sizeof(pSubmit->user_data.user_data));
- snprintf((char *)pSubmit->user_data.user_data, sizeof(pSubmit->user_data.user_data), "%s", pMsgInfo->msgText);
- pSubmit->user_data.data_len = pMsgInfo->dataSize;
-
- MSG_DEBUG("encode type : [%d]", pSubmit->user_data.encode_type);
-
- /* 3. Set Valid period */
-#if 0
- pSubmit->val_period.format = SMS_TIME_ABSOLUTE;
- pSubmit->val_period.time.abs_time.year = 0;
- pSubmit->val_period.time.abs_time.month = 0;
- pSubmit->val_period.time.abs_time.day = 0;
- pSubmit->val_period.time.abs_time.hours = 0;
- pSubmit->val_period.time.abs_time.minutes = 0;
- pSubmit->val_period.time.abs_time.seconds = 0;
-#else
- pSubmit->val_period.format = SMS_TIME_RELATIVE;
- pSubmit->val_period.time.rel_time.rel_time = SMS_REL_TIME_INDEFINITE;
-#endif
-
- /* 4. Set Defer valid period */
- /* TODO */
-
- /* 5. Set Priority */
- switch (pMsgInfo->priority) {
- case MSG_MESSAGE_PRIORITY_HIGH:
- pSubmit->priority = SMS_PRIORITY_URGENT;
- break;
- default:
- pSubmit->priority = SMS_PRIORITY_NORMAL;
- break;
- }
-
- /* 6. Set Privacy */
- pSubmit->privacy = SMS_PRIVACY_NOT_RESTRICTED;
-
- /* 7. Set Reply option */
- if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, (bool *)&(pSubmit->reply_opt.deliver_ack_req)) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- /* 8. Set Alert priority */
- pSubmit->alert_priority = SMS_ALERT_MOBILE_DEFAULT;
-
- /* 9. Set Language */
- pSubmit->language = SMS_LAN_UNKNOWN;
-
- /* 10. Set Callback number */
- /* TODO :: Set callback number to MSISDN */
-
- /* 11. Set Multi encode data */
- /* TODO */
-
- /* 12. Set Deposit id */
- /* TODO */
-
- /* 13. Set Service category program data */
- /* TODO */
-}
-
-
-void SmsPluginTransport::submitRequest(sms_request_info_s *pReqInfo)
-{
- int tapiRet = TAPI_API_SUCCESS;
-
- if (pReqInfo == NULL) {
- THROW(MsgException::SMS_PLG_ERROR, "pReqInfo is NULL");
- }
-
- /* Get address informations. */
- MsgDbHandler *dbHandle = getDbHandle();
- MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
-
- MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt);
-
- /* Get MSISDN */
- char *msisdn = NULL;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int simIndex = 1;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
-
- if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- /* Tapi Data Structure */
- TelSmsDatapackageInfo_t tapi_data_pkg;
- memset(&tapi_data_pkg, 0x00, sizeof(TelSmsDatapackageInfo_t));
-
- bool bMoreMsgToSend = false;
-
- tapi_data_pkg.format = (TelSmsNetType_t)TAPI_NETTEXT_NETTYPE_3GPP2;
-
- /* convert msg_info to trans_msg */
- sms_trans_msg_s trans_msg;
- memset(&trans_msg, 0x00, sizeof(sms_trans_msg_s));
-
- trans_msg.type = (sms_trans_msg_type_t)SMS_TRANS_P2P_MSG;
- trans_msg.data.p2p_msg.telesvc_msg.type = (sms_message_type_t)SMS_TYPE_SUBMIT;
-
- convertMsgInfoToTelesvcMsg(&pReqInfo->msgInfo, &trans_msg);
-
- /* encode msg data */
- unsigned char tel_sms_data[TAPI_NETTEXT_SMDATA_SIZE_MAX+1] = {0, };
-
- tapi_data_pkg.MsgLength = SmsPluginMsgCodec::instance()->encodeMsg(&trans_msg, tel_sms_data);
-
- memcpy((void *)tapi_data_pkg.szData, (void *)tel_sms_data, sizeof(tapi_data_pkg.szData));
-
- MSG_DEBUG("Submit Request TPDU.");
- char pduDbg[TAPI_NETTEXT_SMDATA_SIZE_MAX*2];
- memset(pduDbg, 0x00, sizeof(pduDbg));
-
- for (int i = 0; i < tapi_data_pkg.MsgLength; i++) {
- snprintf(pduDbg+(i*2), sizeof(pduDbg)- (i*2), "%02x", tapi_data_pkg.szData[i]);
- }
- MSG_DEBUG("Encode PDU= [%s]", pduDbg);
-
- sms_network_status_t retStatus;
-
- for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY; ++cnt) {
- /* send request */
- sms_sent_info_s sent_info;
- memset(&sent_info, 0x00, sizeof(sms_sent_info_s));
- memcpy(&sent_info.reqInfo, pReqInfo, sizeof(sent_info.reqInfo));
-
- sent_info.bLast = true;
-
- SmsPluginEventHandler::instance()->SetSentInfo(&sent_info);
-
- int svc_type;
- tel_get_property_int(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
-
- if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
- MSG_DEBUG("Network service is not available : [%d]", svc_type);
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
- goto _RETURN_FUNC;
- }
-
- curStatus = SMS_NETWORK_SENDING;
-
- /* Send SMS */
- tapiRet = tel_send_sms(pTapiHandle, &tapi_data_pkg, bMoreMsgToSend, TapiEventSentStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_send_sms Success !!! return : [%d] #######", tapiRet);
- } else {
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_send_sms Fail !!! return : [%d] #######", tapiRet);
- }
-
- /* Tizen Validation System */
- MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s", pReqInfo->msgInfo.msgId, \
- (msisdn == NULL)?"ME":msisdn, \
- pReqInfo->msgInfo.addressList[0].addressVal, \
- (tapiRet == TAPI_API_SUCCESS)?"Success":"Fail");
-
- MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
-
- retStatus = getNetStatus();
-
- if (retStatus != SMS_NETWORK_SEND_FAIL_TEMPORARY)
- break;
- }
-
- MSG_SMS_VLD_INFO("%d, SMS Send End, %s->%s, %s", pReqInfo->msgInfo.msgId, \
- (msisdn == NULL)?"ME":msisdn, \
- pReqInfo->msgInfo.addressList[0].addressVal, \
- (retStatus == SMS_NETWORK_SEND_SUCCESS)?"Success":"Fail");
-
- if (retStatus == SMS_NETWORK_SEND_SUCCESS) {
- MSG_DEBUG("######## Msg Sent was Successful !!! #######");
- } else {
- if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT || retStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY
- || retStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING || retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
-
- if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
- MsgInsertTicker("Unable to send the message while Fixed dialling mode is enabled", SMS_FDN_RESTRICTED, true, 0);
- else if (retStatus == SMS_NETWORK_SEND_PENDING)
- MsgInsertTicker("Network not available. Message will be sent when connected to network.", SMS_MESSAGE_SENDING_PENDING, true, 0);
- else
- MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, pReqInfo->msgInfo.msgId);
- }
-
-_RETURN_FUNC :
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
-
- MSG_END();
-
- return;
-}
-
-
-void SmsPluginTransport::sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s *p_p2p_msg)
-{
- MSG_BEGIN();
-
- int tapiRet = TAPI_API_SUCCESS;
- TelSmsResponse_t response;
-
- sms_trans_msg_s trans_msg;
- memset(&trans_msg, 0x00, sizeof(sms_trans_msg_s));
-
- trans_msg.type = (sms_trans_msg_type_t)SMS_TRANS_ACK_MSG;
-
- if (p_p2p_msg)
- memcpy(&(trans_msg.data.ack_msg.address), &(p_p2p_msg->address), sizeof(sms_trans_addr_s));
-
- sms_trans_cause_code_s cause_code;
- memset(&cause_code, 0x00, sizeof(sms_trans_cause_code_s));
-
- if (p_p2p_msg->reply_seq > 0)
- cause_code.reply_seq = p_p2p_msg->reply_seq;
-
-
- if (err == MSG_SUCCESS) {
- cause_code.error_class = SMS_TRANS_ERR_CLASS_NONE;
-
- response = TAPI_NETTEXT_SENDSMS_SUCCESS;
-
- if (isMemAvailable == false) {
- tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- }
-
- } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
- cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
-
- response = TAPI_NETTEXT_ME_FULL;
- /* MsgInsertTicker("Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL, true, 0); */
-
- tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
-
- } else if (err == MSG_ERR_UNKNOWN) {
- cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
- cause_code.cause_code = SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED;
-
- response = TAPI_NETTEXT_SENDSMS_SUCCESS;
-
- } else if (err == MSG_ERR_INVALID_MSG_TYPE) {
- cause_code.error_class = SMS_TRANS_ERR_CLASS_PERMANENT;
- cause_code.cause_code = SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID;
-
- response = TAPI_NETTEXT_INVALID_MSG;
- } else {
- cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
- response = TAPI_NETTEXT_SIM_FULL;
- }
-
- memcpy(&(trans_msg.data.ack_msg.cause_code), &(cause_code), sizeof(sms_trans_cause_code_s));
-
- MSG_DEBUG("err : [%d], response : [%02x]", err, response);
-
- int bufLen = 0;
-
- unsigned char buf[512];
- memset(buf, 0x00, sizeof(buf));
- bufLen = SmsPluginMsgCodec::encodeMsg(&trans_msg, buf);
-
-
- MSG_DEBUG("######## DeliverReport tpdu #########");
- for (int i=0; i < bufLen; i++) {
- printf("[%02x] ", buf[i]);
- }
- MSG_DEBUG("#################################");
-
- /* Make Telephony Structure */
- TelSmsDatapackageInfo_t pkgInfo;
-
- pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP2;
-
- /* Set TPDU data */
- memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
- memcpy((void*)pkgInfo.szData, buf, bufLen);
-
- pkgInfo.szData[bufLen] = 0;
- pkgInfo.MsgLength = bufLen;
-
-
- /* Send Deliver Report */
- tapiRet = tel_send_sms_deliver_report(pTapiHandle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! #######");
- else
- MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
-
- MSG_END();
-}
-
-
-void SmsPluginTransport::setNetStatus(sms_network_status_t sentStatus)
-{
- mx.lock();
- curStatus = sentStatus;
- cv.signal();
- mx.unlock();
-}
-
-
-sms_network_status_t SmsPluginTransport::getNetStatus()
-{
- mx.lock();
-
- int ret = 0;
-
- if (curStatus == SMS_NETWORK_SENDING)
- ret = cv.timedwait(mx.pMsgMutex(), 125);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
- curStatus = SMS_NETWORK_SEND_FAIL_TIMEOUT;
- }
-
- return curStatus;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgException.h"
-#include "MsgCppTypes.h"
-#include "SmsCdmaPluginUAManager.h"
-#include "SmsCdmaPluginTransport.h"
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginUAManager - Member Functions
-==================================================================================================*/
-SmsPluginUAManager* SmsPluginUAManager::pInstance = NULL;
-
-
-SmsPluginUAManager::SmsPluginUAManager() : mx(), cv()
-{
- start();
-}
-
-
-SmsPluginUAManager::~SmsPluginUAManager()
-{
-}
-
-
-SmsPluginUAManager* SmsPluginUAManager::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginUAManager();
-
- return pInstance;
-}
-
-
-void SmsPluginUAManager::run()
-{
- while (1) {
- lock();
- while (smsTranQ.empty()) {
- wait();
- }
- sms_request_info_s request;
- smsTranQ.front(&request);
- unlock();
-
- request.msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter);
-
- try {
- SmsPluginTransport::instance()->submitRequest(&request);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
-
- lock();
- smsTranQ.pop_front();
- unlock();
- continue;
- } catch (exception& e) {
- MSG_FATAL("%s", e.what());
- lock();
- smsTranQ.pop_front();
- unlock();
- continue;
- }
-
- lock();
- smsTranQ.pop_front();
- unlock();
- }
-}
-
-
-void SmsPluginUAManager::addReqEntity(sms_request_info_s *request)
-{
- sms_request_info_s reqTmp = {0, };
-
- memcpy(&reqTmp, request, sizeof(sms_request_info_s));
-
- lock();
- smsTranQ.push_back(reqTmp);
- cv.signal();
- unlock();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgGconfWrapper.h"
-#include "MsgException.h"
-#include "MsgUtilFile.h"
-#include "SmsCdmaPluginStorage.h"
-#include "SmsCdmaPluginTransport.h"
-#include "SmsCdmaPluginEventHandler.h"
-#include "SmsCdmaPluginWapPushHandler.h"
-
-#include <glib.h>
-#include <gio/gio.h>
-#if MSG_DRM_SUPPORT
-#include <drm_client.h>
-#endif
-
-static unsigned short wapPushPortList[] = {0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F};
-
-char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
-char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
-
-const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
-
-const unsigned char wspHeaderFieldCount = 0x43;
-const unsigned char wspContentsTypeCount = 0x34;
-const unsigned long wspLanguageCount = 0x11a;
-const unsigned char wspSecurityTypeCount = 0x04;
-
-
-static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] = {
- { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
- { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
- { (char*)"application/pkcs7-mime", 0x37 },
- { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
- { (char*)"application/vnd.wap.signed-certificate", 0x39 },
- { (char*)"application/vnd.wap.cert-response", 0x3A },
- { (char*)"application/xhtml+xml", 0x3B },
- { (char*)"application/wml+xml", 0x3C },
- { (char*)"text/css", 0x3D },
-
- { (char*)"application/vnd.wap.mms-message", 0x3E },
-
- { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
- { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
- { (char*)"application/vnd.wap.loc+xml", 0x41 },
- { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
- { (char*)"application/vnd.syncml.dm+xml", 0x43 },
- { (char*)"application/vnd.syncml.notification", 0x44 },
- { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
- { (char*)"application/vnd.wv.csp.cir", 0x46 },
-
- { (char*)"application/vnd.oma.dd+xml", 0x47},
- { (char*)"application/vnd.oma.drm.message", 0x48 },
- { (char*)"application/vnd.oma.drm.content", 0x49 },
- { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
- { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
- { (char*)"application/vnd.syncml.ds.notification", 0x4E},
- { (char*)"application/mikey", 0x52},
- { (char*)"", 0xff }
-};
-
-
-const char* wspHeaderFieldName[] = {
- (char*)"Accept", /* 0x00 */
- (char*)"Accept-Charset",
- (char*)"Accept-Encoding",
- (char*)"Accept-Language",
- (char*)"Accept-Ranges",
- (char*)"Age", /* 0x05 */
- (char*)"Allow",
- (char*)"Authorization",
- (char*)"Cache-Control",
- (char*)"Connection",
- (char*)"Content-Base", /* 0x0a */
- (char*)"Content-Encoding",
- (char*)"Content-Language",
- (char*)"Content-Length",
- (char*)"Content-Location",
- (char*)"Content-MD5",
- (char*)"Content-Range", /* 0x10 */
- (char*)"Content-Type",
- (char*)"Date",
- (char*)"ETag",
- (char*)"Expires",
- (char*)"From", /* 0x15 */
- (char*)"Host",
- (char*)"If-Modified-Since",
- (char*)"If-Match",
- (char*)"If-None-Match",
- (char*)"If-Range", /* 0x1a */
- (char*)"If-Unmodified-Since",
- (char*)"Location",
- (char*)"Last-Modified",
- (char*)"Max-Forwards",
- (char*)"Pragma",
- (char*)"Proxy-Authenticate", /* 0x20 */
- (char*)"Proxy-Authorization",
- (char*)"Public",
- (char*)"Range",
- (char*)"Referer",
- (char*)"Retry-After", /* 0x25 */
- (char*)"Server",
- (char*)"Transfer-Encodig",
- (char*)"Upgrade",
- (char*)"User-Agent",
- (char*)"Vary", /* 0x2a */
- (char*)"Via",
- (char*)"Warning",
- (char*)"Www-Authenticate",
- (char*)"Content-Disposition",
- (char*)"X-Wap-Application-Id",
- (char*)"X-Wap-Content-URI", /* 0x30 */
- (char*)"X-Wap-Iinitiator-URI",
- (char*)"Accept-Application", /* Back */
- (char*)"Bearer-Indication",
- (char*)"Push-Flag",
- (char*)"Profile", /* 0x35 */
- (char*)"Profile-Diff",
- (char*)"Profile-Warning", /* end of WAP 1.2 */
- (char*)"Expect",
- (char*)"Te",
- (char*)"Trailer", /* 0x3a */
- (char*)"Accept-Charset", /* Back */
- (char*)"Accept-Encoding", /* Back */
- (char*)"Cache-Control", /* back */
- (char*)"Content-Range",
- (char*)"X-Wap-Tod",
- (char*)"Content-ID", /*x40 */
- (char*)"Set-Cookie",
- (char*)"Cookie",
- (char*)"Encoding-Version"
-};
-
-
-const SMS_WSP_CHARSET_S wspCharset[] = {
- { (char*)"big5", 0x07ea },
- { (char*)"iso-10646-ucs-2", 0x03e8 },
- { (char*)"iso-8859-1", 0x04 },
- { (char*)"iso-8859-2", 0x05 },
- { (char*)"iso-8859-3", 0x06 },
- { (char*)"iso-8859-4", 0x07 },
- { (char*)"iso-8859-5", 0x08 },
- { (char*)"iso-8859-6", 0x09 },
- { (char*)"iso-8859-7", 0x0a },
- { (char*)"iso-8859-8", 0x0b },
- { (char*)"iso-8859-9", 0x0c },
- { (char*)"shift-JIS", 0x11 },
- { (char*)"us-ascii", 0x03 },
- { (char*)"utf-8", 0x6a },
- { (char*)"none", 0x26 },
- { (char*)"", 0xffff }
-};
-
-
-const char* wspEncodeMethod[] = {
- (char*)"Gzip",
- (char*)"Compress",
- (char*)"Deflate"
-};
-
-
-const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] = {
- { (char*)"*/*", 0x00 },
- { (char*)"text/*", 0x01 },
- { (char*)"text/html", 0x02 },
- { (char*)"text/plain", 0x03 },
- { (char*)"text/x-hdml", 0x04 },
- { (char*)"text/x-ttml", 0x05 },
- { (char*)"text/x-vCalendar", 0x06 },
- { (char*)"text/x-vCard", 0x07 },
- { (char*)"text/vnd.wap.wml", 0x08 },
- { (char*)"text/vnd.wap.wmlscript", 0x09 },
- { (char*)"text/vnd.wap.wta-event", 0x0a },
- { (char*)"multipart/*", 0x0b },
- { (char*)"multipart/mixed", 0x0c },
- { (char*)"multipart/form-data", 0x0d },
- { (char*)"multipart/byteranges", 0x0e },
- { (char*)"multipart/alternative", 0x0f },
- { (char*)"application/*", 0x10 },
- { (char*)"application/java-vm", 0x11 },
- { (char*)"application/x-www-form-urlencoded", 0x12 },
- { (char*)"application/x-hdmlc", 0x13 },
- { (char*)"application/vnd.wap.wmlc", 0x14 },
- { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
- { (char*)"application/vnd.wap.wta-eventc", 0x16 },
- { (char*)"application/vnd.wap.uaprof", 0x17 },
- { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
- { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
- { (char*)"application/x-x509-ca-cert", 0x1a },
- { (char*)"application/x-x509-user-cert", 0x1b },
- { (char*)"image/*", 0x1c },
- { (char*)"image/gif", 0x1d },
- { (char*)"image/jpeg", 0x1e },
- { (char*)"image/tiff", 0x1f },
- { (char*)"image/png", 0x20 },
- { (char*)"image/vnd.wap.wbmp", 0x21 },
- { (char*)"application/vnd.wap.multipart.*", 0x22 },
- { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
- { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
- { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
- { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
- { (char*)"application/xml", 0x27 },
- { (char*)"text/xml", 0x28 },
- { (char*)"application/vnd.wap.wbxml", 0x29 },
- { (char*)"application/x-x968-cross-cert", 0x2a },
- { (char*)"application/x-x968-ca-cert", 0x2b },
- { (char*)"application/x-x968-user-cert", 0x2c },
- { (char*)"text/vnd.wap.si", 0x2d },
- { (char*)"application/vnd.wap.sic", 0x2e },
- { (char*)"text/vnd.wap.sl", 0x2f },
- { (char*)"application/vnd.wap.slc", 0x30 },
- { (char*)"text/vnd.wap.co", 0x31 },
- { (char*)"application/vnd.wap.coc", 0x32 },
- { (char*)"application/vnd.wap.multipart.related", 0x33 },
- { (char*)"application/vnd.wap.sia", 0x34 },
-
- { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
- { (char*)"application/vnd.connectivity-wbxml", 0x36 },
- { (char*)"application/pkcs7-mime", 0x37 },
- { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
- { (char*)"application/vnd.wap.signed-certificate", 0x39 },
- { (char*)"application/vnd.wap.cert-response", 0x3A },
- { (char*)"application/xhtml+xml", 0x3B },
- { (char*)"application/wml+xml", 0x3C },
- { (char*)"text/css", 0x3D },
-
- { (char*)"application/vnd.wap.mms-message", 0x3E },
-
- { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
- { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
- { (char*)"application/vnd.wap.loc+xml", 0x41 },
- { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
- { (char*)"application/vnd.syncml.dm+xml", 0x43 },
- { (char*)"application/vnd.syncml.notification", 0x44 },
- { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
- { (char*)"application/vnd.wv.csp.cir", 0x46 }
-};
-
-
-static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]= {
- { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
- { (char*)"application/vnd.omaloc-supl-init", 0x312},
- { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
-};
-
-
-const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
-
-
-const SMS_WSP_LANGUAGE_S wspLanguage[] = {
- { (char*)"English", 0x19 },
- { (char*)"en", 0x19 },
- { (char*)"Korean", 0x3d },
- { (char*)"*", 0x00 },
- { (char*)"Afar", 0x01 },
- { (char*)"aa", 0x01 },
- { (char*)"Abkhazian", 0x02 },
- { (char*)"ab", 0x02 },
- { (char*)"Afrikaans", 0x03 },
- { (char*)"af", 0x03 },
- { (char*)"Amharic", 0x04 },
- { (char*)"am", 0x04 },
- { (char*)"Arabic", 0x05 },
- { (char*)"ar", 0x05 },
- { (char*)"Assamese", 0x06 },
- { (char*)"as", 0x06 },
- { (char*)"Aymara", 0x07 },
- { (char*)"ay", 0x07 },
- { (char*)"Azerbaijani", 0x08 },
- { (char*)"az", 0x08 },
- { (char*)"Bashkir", 0x09 },
- { (char*)"ba", 0x09 },
- { (char*)"Byelorussian", 0x0a },
- { (char*)"be", 0x0a },
- { (char*)"Bulgarian", 0x0b },
- { (char*)"bg", 0x0b },
- { (char*)"Bihari", 0x0c },
- { (char*)"bh", 0x0c },
- { (char*)"Bislama", 0x0d },
- { (char*)"bi", 0x0f },
- { (char*)"Bengali", 0x0e },
- { (char*)"Bangla", 0x0e },
- { (char*)"bn", 0x0e },
- { (char*)"Tibetan", 0x0f },
- { (char*)"bo", 0x0f },
- { (char*)"Breton", 0x10 },
- { (char*)"br", 0x10 },
- { (char*)"Catalan", 0x11 },
- { (char*)"ca", 0x11 },
- { (char*)"Corsican", 0x12 },
- { (char*)"co", 0x12 },
- { (char*)"Czech", 0x13 },
- { (char*)"cs", 0x13 },
- { (char*)"Welsh", 0x14 },
- { (char*)"cy", 0x14 },
- { (char*)"Denish", 0x15 },
- { (char*)"da", 0x15 },
- { (char*)"German", 0x16 },
- { (char*)"de", 0x16 },
- { (char*)"Bhutani", 0x17 },
- { (char*)"dz", 0x17 },
- { (char*)"Greek", 0x18 },
- { (char*)"el", 0x18 },
- { (char*)"Esperanto", 0x81 },
- { (char*)"eo", 0x1a },
- { (char*)"Spanish", 0x1b },
- { (char*)"es", 0x1b },
- { (char*)"Estonian", 0x1c },
- { (char*)"et", 0x1c },
- { (char*)"Basque", 0x1d },
- { (char*)"eu", 0x1d },
- { (char*)"Persian", 0x1e },
- { (char*)"fa", 0x1e },
- { (char*)"Finnish", 0x1f },
- { (char*)"fi", 0x1f },
- { (char*)"Fiji", 0x20 },
- { (char*)"fj", 0x20 },
- { (char*)"Faeroese", 0x82 },
- { (char*)"fo", 0x82 },
- { (char*)"French", 0x22 },
- { (char*)"fr", 0x22 },
- { (char*)"Frisian", 0x83 },
- { (char*)"fy", 0x83 },
- { (char*)"Irish", 0x24 },
- { (char*)"ga", 0x24 },
- { (char*)"Scots Gaelic", 0x25 },
- { (char*)"gd", 0x25 },
- { (char*)"Galician", 0x26 },
- { (char*)"gl", 0x26 },
- { (char*)"Guarani", 0x27 },
- { (char*)"gn", 0x27 },
- { (char*)"Gujarati", 0x28 },
- { (char*)"gu", 0x28 },
- { (char*)"Hausa", 0x29 },
- { (char*)"ha", 0x29 },
- { (char*)"Hebrew", 0x2a },
- { (char*)"he", 0x2a },
- { (char*)"Hindi", 0x2b },
- { (char*)"hi", 0x2b },
- { (char*)"Croatian", 0x2c },
- { (char*)"hr", 0x2c },
- { (char*)"Hungarian", 0x2d },
- { (char*)"hu", 0x2d },
- { (char*)"Armenian", 0x2e },
- { (char*)"hy", 0x2e },
- { (char*)"Interlingua", 0x84 },
- { (char*)"ia", 0x84 },
- { (char*)"Indonesian", 0x30 },
- { (char*)"id", 0x30 },
- { (char*)"Interlingue", 0x86 },
- { (char*)"ie", 0x86 },
- { (char*)"Maori", 0x47 },
- { (char*)"mi", 0x47 },
- { (char*)"Macedonian", 0x48 },
- { (char*)"mk", 0x48 },
- { (char*)"Malayalam", 0x49 },
- { (char*)"ml", 0x49 },
- { (char*)"Mongolian", 0x4a },
- { (char*)"mn", 0x4a },
- { (char*)"Moldavian", 0x4b },
- { (char*)"mo", 0x4d },
- { (char*)"Marathi", 0x4c },
- { (char*)"mr", 0x4c },
- { (char*)"Malay", 0x4d },
- { (char*)"ms", 0x4d },
- { (char*)"Maltese", 0x4e },
- { (char*)"mt", 0x4e },
- { (char*)"Burmese", 0x4f },
- { (char*)"my", 0x4f },
- { (char*)"Nauru", 0x50 },
- { (char*)"na", 0x50 },
- { (char*)"Nepali", 0x51 },
- { (char*)"ne", 0x51 },
- { (char*)"Dutch", 0x52 },
- { (char*)"nl", 0x52 },
- { (char*)"Norwegian", 0x53 },
- { (char*)"no", 0x53 },
- { (char*)"Occitan", 0x54 },
- { (char*)"oc", 0x54 },
- { (char*)"(Afan) Oromo", 0x55 },
- { (char*)"(Afan)Oromo", 0x55 },
- { (char*)"om", 0x55 },
- { (char*)"Oriya", 0x56 },
- { (char*)"or", 0x56 },
- { (char*)"Punjabi", 0x57 },
- { (char*)"pa", 0x57 },
- { (char*)"Polish", 0x58 },
- { (char*)"po", 0x58 },
- { (char*)"Pashto", 0x59 },
- { (char*)"Pushto", 0x59 },
- { (char*)"ps", 0x59 },
- { (char*)"Portugurse", 0x5a },
- { (char*)"pt", 0x5a },
- { (char*)"Quechua", 0x5b },
- { (char*)"qu", 0x5b },
- { (char*)"Rhaeto-Romance", 0x8c },
- { (char*)"rm", 0x8c },
- { (char*)"Kirundi", 0x5d },
- { (char*)"rn", 0x5d },
- { (char*)"Romanian", 0x5e },
- { (char*)"ro", 0x5e },
- { (char*)"Russian", 0x5f },
- { (char*)"ru", 0x5f },
- { (char*)"Kinyarwanda", 0x60 },
- { (char*)"rw", 0x60 },
- { (char*)"Sanskrit", 0x61 },
- { (char*)"sa", 0x61 },
- { (char*)"Sindhi", 0x62 },
- { (char*)"sd", 0x62 },
- { (char*)"Sangho", 0x63 },
- { (char*)"sg", 0x63 },
- { (char*)"Serbo-Croatian", 0x64 },
- { (char*)"sh", 0x64 },
- { (char*)"Sinhalese", 0x65 },
- { (char*)"si", 0x65 },
- { (char*)"Slovak", 0x66 },
- { (char*)"sk", 0x66 },
- { (char*)"Slovenian", 0x67 },
- { (char*)"sl", 0x67 },
- { (char*)"Samoan", 0x68 },
- { (char*)"sm", 0x68 },
- { (char*)"Shona", 0x69 },
- { (char*)"sn", 0x69 },
- { (char*)"Somali", 0x6a },
- { (char*)"so", 0x6a },
- { (char*)"Albanian", 0x6b },
- { (char*)"sq", 0x6b },
- { (char*)"Serbian", 0x6c },
- { (char*)"sr", 0x6c },
- { (char*)"Siswati", 0x6d },
- { (char*)"ss", 0x6d },
- { (char*)"Sesotho", 0x6e },
- { (char*)"st", 0x6e },
- { (char*)"Sundanese", 0x6f },
- { (char*)"su", 0x6f },
- { (char*)"Swedish", 0x70 },
- { (char*)"sv", 0x70 },
- { (char*)"Swahili", 0x71 },
- { (char*)"sw", 0x71 },
- { (char*)"Tamil", 0x72 },
- { (char*)"ta", 0x72 },
- { (char*)"Telugu", 0x73 },
- { (char*)"te", 0x73 },
- { (char*)"Tajik", 0x74 },
- { (char*)"tg", 0x74 },
- { (char*)"Thai", 0x75 },
- { (char*)"th", 0x75 },
- { (char*)"Tigrinya", 0x76 },
- { (char*)"ti", 0x76 },
- { (char*)"Turkmen", 0x77 },
- { (char*)"tk", 0x77 },
- { (char*)"Inupiak", 0x87 },
- { (char*)"ik", 0x87 },
- { (char*)"Icelandic", 0x33 },
- { (char*)"is", 0x33 },
- { (char*)"Italian", 0x34 },
- { (char*)"it", 0x34 },
- { (char*)"Inuktitut", 0x89 },
- { (char*)"iu", 0x89 },
- { (char*)"Japanese", 0x36 },
- { (char*)"ja", 0x36 },
- { (char*)"Javanese", 0x37 },
- { (char*)"jw", 0x37 },
- { (char*)"Georgian", 0x38 },
- { (char*)"ka", 0x38 },
- { (char*)"Kazakh", 0x39 },
- { (char*)"kk", 0x39 },
- { (char*)"Gerrnlandic", 0x8a },
- { (char*)"kl", 0x8a },
- { (char*)"Cambodian", 0x3b },
- { (char*)"km", 0x3b },
- { (char*)"Kannada", 0x3c },
- { (char*)"kn", 0x3c },
- { (char*)"Kashmiri", 0x3e },
- { (char*)"ks", 0x3e },
- { (char*)"Kurdish", 0x3f },
- { (char*)"ku", 0x3f },
- { (char*)"Kirghiz", 0x40 },
- { (char*)"ky", 0x40 },
- { (char*)"Latin", 0x8b },
- { (char*)"la", 0x8b },
- { (char*)"Lingala", 0x42 },
- { (char*)"ln", 0x42 },
- { (char*)"Laothian", 0x43 },
- { (char*)"lo", 0x43 },
- { (char*)"Lithuanian", 0x44 },
- { (char*)"lt", 0x44 },
- { (char*)"Lavian", 0x45 },
- { (char*)"Lettish", 0x45 },
- { (char*)"lv", 0x45 },
- { (char*)"Malagasy", 0x46 },
- { (char*)"mg", 0x46 },
- { (char*)"Tagalog", 0x78 },
- { (char*)"tl", 0x78 },
- { (char*)"Setswana", 0x79 },
- { (char*)"tn", 0x79 },
- { (char*)"Tonga", 0x7a },
- { (char*)"to", 0x7a },
- { (char*)"Turkish", 0x7b },
- { (char*)"tr", 0x7b },
- { (char*)"Tsonga", 0x7c },
- { (char*)"ts", 0x7c },
- { (char*)"Tatar", 0x7d },
- { (char*)"tt", 0x7d },
- { (char*)"Twi", 0x7e },
- { (char*)"tw", 0x7e },
- { (char*)"Uighur", 0x7f },
- { (char*)"ug", 0x7f },
- { (char*)"Ukrainian", 0x1a },
- { (char*)"uk", 0x1a },
- { (char*)"Urdu", 0x21 },
- { (char*)"ur", 0x21 },
- { (char*)"Uzbek", 0x23 },
- { (char*)"uz", 0x23 },
- { (char*)"Vietnamese", 0x2f },
- { (char*)"vi", 0x2f },
- { (char*)"Volapuk", 0x85 },
- { (char*)"vo", 0x85 },
- { (char*)"Wolof", 0x31 },
- { (char*)"wo" , 0x31 },
- { (char*)"Xhosa", 0x32 },
- { (char*)"xh", 0x32 },
- { (char*)"Yiddish", 0x88 },
- { (char*)"yi", 0x88 },
- { (char*)"Yoruba", 0x35 },
- { (char*)"yo", 0x35 },
- { (char*)"Zhuang", 0x3a },
- { (char*)"z", 0x3a },
- { (char*)"Chinese", 0x41 },
- { (char*)"ch", 0x41 },
- { (char*)"Zulu", 0x5c },
- { (char*)"zu", 0x5c },
- { (char*)"Ko", 0x3d }
-};
-
-
-const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] = {
- { (char*)"x-wap-application:*", 0x00 },
- { (char*)"x-wap-application:push.sia", 0x01},
- { (char*)"x-wap-application:wml.ua", 0x02 },
- { (char*)"x-wap-application:wta.ua", 0x03 },
- { (char*)"x-wap-application:mms.ua", 0x04 },
- { (char*)"x-wap-application:push.syncml", 0x05 },
- { (char*)"x-wap-application:loc.ua", 0x06 },
- { (char*)"x-wap-application:syncml.dm", 0x07 },
- { (char*)"x-wap-application:drm.ua", 0x08 },
- { (char*)"x-wap-application:emn.ua", 0x09 },
- { (char*)"x-oma-application:ulp.ua ", 0x90 },
- { (char*)"x-oma-docomo:open.ctl", 0x9055 },
- { (char*)"x-oma-docomo:xmd.mail.ua", 0x905C },
- { (char*)"x-oma-docomo:xmd.storage.ua", 0x905F },
- { (char*)"x-oma-docomo:xmd.lcsapp.ua", 0x9060 },
- { (char*)"x-oma-docomo:xmd.info.ua", 0x9061 },
- { (char*)"x-oma-docomo:xmd.agent.ua", 0x9062 },
- { (char*)"x-oma-docomo:xmd.sab.ua", 0x9063 },
- { (char*)"x-oma-docomo:xmd.am.ua", 0x9064 },
- { (char*)"x-oma-docomo:xmd.emdm.ua", 0x906B },
- { (char*)"x-oma-docomo:xmd.lac.ua", 0x906C },
- { (char*)"x-oma-docomo:xmd.osv.ua", 0x906D },
- { (char*)"x-oma-docomo:xmd.dcs.ua", 0x906E },
- { (char*)"x-oma-docomo:xmd.wipe.ua", 0x906F },
- { (char*)"x-oma-docomo:xmd.vdapp.ua ", 0x9070 },
-};
-
-
-const char* wspCacheControl[] = {
- (char*)"No-cache",
- (char*)"No-store",
- (char*)"Max-age",
- (char*)"Max-stale",
- (char*)"Min-fresh",
- (char*)"Only-if-cached",
- (char*)"Public",
- (char*)"Private",
- (char*)"No-transform",
- (char*)"Must-revalidate",
- (char*)"Proxy-revalidate"
-};
-
-const SMS_WSP_METHOD_TYPE_S wspMethodType[] = {
- { (char*)"GET", 0x40 },
- { (char*)"OPTIONS", 0x41 },
- { (char*)"HEAD", 0x42 },
- { (char*)"DELETE", 0x43 },
- { (char*)"TRACE", 0x44 },
- { (char*)"POST", 0x60 },
- { (char*)"PUT", 0x61 }
-};
-
-
-const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] = {
- {(char*)"NETWPIN", 0x00},
- {(char*)"USERPIN", 0x01},
- {(char*)"USERNETWPIN", 0x02},
- {(char*)"USERPINMAC", 0x03}
-};
-
-
-
-const char* wspWeek[] = {
- (char*)"Sun",
- (char*)"Mon",
- (char*)"Tue",
- (char*)"Wed",
- (char*)"Thu",
- (char*)"Fri",
- (char*)"Sat"
-};
-
-
-const char* wspWeekDay[] = {
- (char*)"Sunday",
- (char*)"Monday",
- (char*)"Tuesday",
- (char*)"Wednesday",
- (char*)"Thursday",
- (char*)"Friday",
- (char*)"Saturday"
-};
-
-const char* wspMonth[] = {
- (char*)"Jan",
- (char*)"Feb",
- (char*)"Mar",
- (char*)"Apr",
- (char*)"May",
- (char*)"Jun",
- (char*)"Jul",
- (char*)"Aug",
- (char*)"Sep",
- (char*)"Oct",
- (char*)"Nov",
- (char*)"Dec"
-};
-
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginWapPushHandler - Member Functions
-==================================================================================================*/
-SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL;
-
-
-SmsPluginWapPushHandler::SmsPluginWapPushHandler()
-{
- memset(&tmpAddress, 0x00, sizeof(tmpAddress));
-}
-
-
-SmsPluginWapPushHandler::~SmsPluginWapPushHandler()
-{
-}
-
-
-SmsPluginWapPushHandler* SmsPluginWapPushHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginWapPushHandler();
-
- return pInstance;
-}
-
-
-bool SmsPluginWapPushHandler::IsWapPushMsg(unsigned short dstport)
-{
- MSG_BEGIN();
-
- int PortCount = sizeof(wapPushPortList)/sizeof(wapPushPortList[0]);
-
- MSG_DEBUG("Port Count [%d]", PortCount);
-
- for (int i = 0; i < PortCount; i++) {
- if (dstport == wapPushPortList[i]) {
- MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[i]);
- return true;
- }
- }
-
- MSG_END();
-
- return false;
-}
-
-#if 0
-sms_wap_app_code_t SmsPluginWapPushHandler::getAppCode(const char *pPushHeader)
-{
- int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
-
- unsigned char *header = NULL;
- SMS_WAP_APP_CODE_T appCode = SMS_WAP_APPLICATION_DEFAULT;
-
- MSG_DEBUG("Application Count [%d]", appCount);
-
- for (int i = 0; i < appCount; i++) {
- header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
-
- if (header != NULL) {
- appCode = pushDefaultApplication[i].appCode;
- break;
- }
- }
-
- if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
- MSG_DEBUG("Application Type is not supported");
- } else {
- MSG_DEBUG("Find Application [%d]", appCode);
- }
-
- return appCode;
-}
-#endif
-
-
-void SmsPluginWapPushHandler::copyDeliverData(sms_trans_addr_s *pAddr)
-{
- memcpy(&tmpAddress, pAddr, sizeof(tmpAddress));
-
- MSG_SEC_DEBUG("Address [%s]", tmpAddress.szData);
-
-/*
- tmpTimeStamp.format = pDeliver->timeStamp.format;
-
- if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
- tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
- tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
- tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
- tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
- tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
- tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
- tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
- }
-*/
-}
-
-
-void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize)
-{
- MSG_BEGIN();
-
-#ifdef MSG_FW_FOR_DEBUG
- MSG_DEBUG("DataSize [%d]", DataSize);
-
- MSG_DEBUG("[pUserData]");
- for (int i = 0; i < DataSize; i++) {
- printf("[%02x]", pUserData[i]);
- }
- printf("\n\n");
-#endif
-
- unsigned char* pPDUTypeData = (unsigned char*)pUserData;
- unsigned long PDUTypeDataLen = DataSize;
-
- char* pPushHeader = NULL;
- unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter);
- unsigned long pushHeaderLen = 0;
-
- char* pPushBody = NULL;
- unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter);
- unsigned long pushBodyLen = 0;
-
- unsigned long iPDU = 1;
-
- char* pWspHeader = NULL;
- unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter);
- unsigned long wspHeaderLen = 0;
-
- char* pWspBody = NULL;
- unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter);
- unsigned long wspBodyLen = 0;
-
- /* pass PDU type */
- iPDU++;
-
- pushHeaderLen = wspRetriveUintvarDecode(pPDUTypeData, &iPDU);
-
- MSG_DEBUG("PDUTypeDataLen [%d]", PDUTypeDataLen);
- MSG_DEBUG("pushHeaderLen [%d]", pushHeaderLen);
- MSG_DEBUG("iPDU [%d]", iPDU);
-
- wspHeaderLen = pushHeaderLen + iPDU;
-
- MSG_DEBUG("wspBodyLen [%d]", wspBodyLen);
-
- if (wspHeaderLen > 0) {
- pWspHeader = new char[wspHeaderLen];
-
- if (pWspHeader == NULL) {
- MSG_DEBUG("pWspHeader Memory Allocation Failed");
- return;
- } else {
- memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
- }
- }
-
-#ifdef MSG_FW_FOR_DEBUG
- MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
-
- MSG_DEBUG("[pWspHeader]");
- for (int i = 0; i < wspHeaderLen; i++) {
- printf("[%02x]", pWspHeader[i]);
- }
- printf("\n\n");
-#endif
-
- /* return if it is below case error */
- if (PDUTypeDataLen < wspHeaderLen) {
- MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
- return;
- }
-
- /* Finding wspBody Information */
- wspBodyLen = PDUTypeDataLen - wspHeaderLen;
-
- if (wspBodyLen > 0) {
- pWspBody = new char[wspBodyLen];
-
- if (pWspBody == NULL) {
- MSG_DEBUG("pWspBody Memory Allocation Failed");
- return;
- } else {
- memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
- }
- } else {
- pWspBody = NULL;
- }
-
- wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
-
- iPDU = iPDU + pushHeaderLen;
-
- pushBodyLen = PDUTypeDataLen - iPDU ;
-
- if (pushBodyLen > 0) {
- pPushBody = new char[pushBodyLen];
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody Memory Allocation Failed");
- return;
- } else {
- memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
- }
- } else {
- pPushBody = NULL;
- return;
- }
-
- handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen);
-
- MSG_END();
-}
-
-#if 0
-void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
-{
- MSG_BEGIN();
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- SMS_WAP_APP_CODE_T appCode = getAppCode(pPushHeader);
-
- /* check Push message receive setting */
- bool bPushRecv = false;
-
- if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
- MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
- return;
- }
-
- switch (appCode) {
- case SMS_WAP_APPLICATION_MMS_UA:
- MSG_DEBUG("Received MMS Notification");
- handleMMSNotification(pPushBody, PushBodyLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_SI:
- MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
- handleSIMessage(pPushBody, PushBodyLen, true);
- break;
- case SMS_WAP_APPLICATION_PUSH_SIC:
- MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
- handleSIMessage(pPushBody, PushBodyLen, false);
- break;
- case SMS_WAP_APPLICATION_PUSH_SL:
- MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
- handleSLMessage(pPushBody, PushBodyLen, true);
- break;
- case SMS_WAP_APPLICATION_PUSH_SLC:
- MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
- handleSLMessage(pPushBody, PushBodyLen, false);
- break;
- case SMS_WAP_APPLICATION_PUSH_CO:
- MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
- handleCOMessage(pPushBody, PushBodyLen, true);
- break;
- case SMS_WAP_APPLICATION_PUSH_COC:
- MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
- handleCOMessage(pPushBody, PushBodyLen, false);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
- MSG_DEBUG("Received DM Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
- MSG_DEBUG("Received DRM UA");
- if (pPushBody != NULL)
- handleDrmVer1(pPushBody, PushBodyLen);
- break;
- case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
- MSG_DEBUG("Received DRM V2");
- /* TODO: DRM V2 */
- break;
- case SMS_WAP_APPLICATION_PUSH_EMAIL:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
- MSG_DEBUG("Received Email");
- /* TODO: Email */
- break;
- case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
- MSG_DEBUG("Received IMPS CIR");
- /* TODO: IMPS CIR */
- break;
- case SMS_WAP_APPLICATION_LBS:
- MSG_DEBUG("Received LBS related message");
- SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
- /* TODO: LBS */
- break;
- case SMS_WAP_APPLICATION_PUSH_SIA:
- MSG_DEBUG("Received SIA");
- /* TODO: SIA */
- break;
- default:
- MSG_DEBUG("Unknown Application [%d]", appCode);
- break;
- }
-
- MSG_END();
-}
-#else
-
-static void launchProcessByAppcode(int appcode)
-{
- MSG_BEGIN();
- GError *error = NULL;
- GDBusConnection *connection_agent = NULL;
- GDBusProxy *dbus_proxy_agent = NULL;
- GDBusConnection *connection_service = NULL;
- GDBusProxy *dbus_proxy_service = NULL;
- GVariant *result_agent = NULL;
- GVariant *result_service = NULL;
-
- switch (appcode) {
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION: {
- connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
- NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
- "org.tizen.omadmagent", NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) {
- MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- dbus_proxy_service = g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
- "org.tizen.omadmservice", "/org/tizen/omadmservice",
- "org.tizen.omadmservice", NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) {
- MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- MsgMutex mx;
- MsgCndVar cv;
- mx.lock();
- cv.timedwait(mx.pMsgMutex(), 2);
- mx.unlock();
- MSG_END();
- }
- break;
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML: {
- connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
- "org.tizen.omadsagent", "/org/tizen/omadsagent",
- "org.tizen.omadsagent", NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) {
- MSG_DEBUG("invoking service error: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- }
- break;
- default:
- break;
- }
-
-_DBUS_ERROR:
- if (error) {
- g_error_free(error);
- error = NULL;
- }
-
- if (connection_agent) {
- g_object_unref(connection_agent);
- connection_agent = NULL;
- }
-
- if (dbus_proxy_agent) {
- g_object_unref(dbus_proxy_agent);
- dbus_proxy_agent = NULL;
- }
-
- if (result_agent) {
- g_object_unref(result_service);
- result_service = NULL;
- }
-
- if (connection_service) {
- g_object_unref(connection_service);
- connection_service = NULL;
- }
-
- if (dbus_proxy_service) {
- g_object_unref(dbus_proxy_service);
- dbus_proxy_service = NULL;
- }
-
- if (result_service) {
- g_object_unref(result_service);
- result_service = NULL;
- }
-
- MSG_END();
-}
-
-
-void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
-{
- MSG_BEGIN();
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- msg_error_t err = MSG_SUCCESS;
- int pushEvt_cnt = 0;
- char app_id[MAX_WAPPUSH_ID_LEN] = {0, };
- char content_type[MAX_WAPPUSH_CONTENT_TYPE_LEN] = {0, };
- SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
-
- err = storageHandler->getRegisteredPushEvent(pPushHeader, &pushEvt_cnt, app_id, sizeof(app_id), content_type, sizeof(content_type));
- MSG_DEBUG("pushEvt_cnt: %d", pushEvt_cnt);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("Fail to get registered push event");
- return;
- }
-
- for (int i = 0; i < pushEvt_cnt; ++i) {
- /* check Push message receive setting */
- bool bPushRecv = false;
- int appcode = 0;
- if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- storageHandler->getnthPushEvent(i, &appcode);
- MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
- if ((bPushRecv == false) && (appcode != SMS_WAP_APPLICATION_MMS_UA)) {
- MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
- return;
- }
-
-#ifdef FEATURE_MMS_DISABLE
- if (appcode == SMS_WAP_APPLICATION_MMS_UA) {
- MSG_DEBUG("Drop MMS Notification for DOCOMO");
- return;
- }
-
-#endif
- launchProcessByAppcode(appcode);
-
- switch (appcode) {
- case SMS_WAP_APPLICATION_MMS_UA:
- MSG_DEBUG("Received MMS Notification");
- handleMMSNotification(pPushBody, PushBodyLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_SI:
- MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
- /* handleSIMessage(pPushBody, PushBodyLen, true); */
- break;
- case SMS_WAP_APPLICATION_PUSH_SIC:
- MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
- /* handleSIMessage(pPushBody, PushBodyLen, false); */
- break;
- case SMS_WAP_APPLICATION_PUSH_SL:
- MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
- /* handleSLMessage(pPushBody, PushBodyLen, true); */
- break;
- case SMS_WAP_APPLICATION_PUSH_SLC:
- MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
- /* handleSLMessage(pPushBody, PushBodyLen, false); */
- break;
- case SMS_WAP_APPLICATION_PUSH_CO:
- MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
- /* handleCOMessage(pPushBody, PushBodyLen, true); */
- break;
- case SMS_WAP_APPLICATION_PUSH_COC:
- MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
- /* handleCOMessage(pPushBody, PushBodyLen, false); */
- break;
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
- MSG_DEBUG("Received DM Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
- MSG_DEBUG("Received DRM UA");
- if (pPushBody != NULL)
- handleDrmVer1(pPushBody, PushBodyLen);
- break;
- case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
- MSG_DEBUG("Received DRM V2");
- /* TODO: DRM V2 */
- break;
- case SMS_WAP_APPLICATION_PUSH_EMAIL:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
- MSG_DEBUG("Received Email");
- /* TODO: Email */
- break;
- case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
- MSG_DEBUG("Received IMPS CIR");
- /* TODO: IMPS CIR */
- break;
- case SMS_WAP_APPLICATION_LBS:
- MSG_DEBUG("Received LBS related message");
- SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
- /* TODO: LBS */
- break;
- case SMS_WAP_APPLICATION_PUSH_SIA:
- MSG_DEBUG("Received SIA");
- /* TODO: SIA */
- break;
- default:
- SmsPluginEventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id, content_type);
- break;
- }
- }
- storageHandler->releasePushEvent();
-
- MSG_END();
-}
-#endif
-
-void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen)
-{
- MSG_BEGIN();
-
-#ifdef MSG_FW_FOR_DEBUG
- printf("\n\n[handleMMSNotification] Push Body.\n");
-
- for (int i = 0; i < PushBodyLen; i++) {
- printf(" [%02x]", pPushBody[i]);
- }
- printf("\n\n");
-#endif
-
- /* Make MSG_MESSAGE_INFO_S */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- /* Convert Type values */
- msgInfo.msgType.mainType = MSG_MMS_TYPE;
- msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
- msgInfo.msgType.classType = MSG_CLASS_NONE;
- msgInfo.storageId = MSG_STORAGE_PHONE;
- msgInfo.dataSize = PushBodyLen;
-
- if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
- msgInfo.bTextSms = false;
-
- /* Save Message Data into File */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false) {
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
- }
-
- if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false) {
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
- }
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
- } else {
- msgInfo.bTextSms = true;
-
- memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
- msgInfo.msgText[msgInfo.dataSize] = '\0';
- }
-
- msg_error_t err = MSG_SUCCESS;
-
- /* Add MMS Noti Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /* Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- MSG_END();
-}
-
-
-void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText)
-{
- MSG_BEGIN();
-
- MSG_PUSH_MESSAGE_S pushMsg = {};
-
- xmlDocPtr xmlDoc = NULL;
- xmlNodePtr topNode = NULL;
- xmlNodePtr indNode = NULL;
-
- xmlChar* tmpXmlChar = NULL;
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
-
- if (xmlDoc == NULL) {
- MSG_DEBUG("xmlDoc is NULL");
- return;
- }
-
- topNode = xmlDocGetRootElement(xmlDoc);
-
- if (topNode == NULL) {
- MSG_DEBUG("topNode is NULL");
- xmlFreeDoc(xmlDoc);
- return;
- }
-
- indNode = topNode->xmlChildrenNode;
-
- while (indNode != NULL) {
- if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
- break;
- }
-
- indNode = indNode->next;
- }
-
- if (indNode == NULL) {
- MSG_DEBUG("indNode is NULL.");
- return;
- }
-
- /* temporary set to max. */
- pushMsg.expires = 0xFFFFFFFF;
-
- /* setting received time */
- time_t t = time(NULL);
- time_t utfTime = time(&t);
-
- pushMsg.received = (unsigned long)utfTime;
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
-
- if (tmpXmlChar == NULL) {
- MSG_DEBUG("href is NULL.");
- return;
- }
-
- if (tmpXmlChar != NULL)
- strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
-
- if (tmpXmlChar != NULL)
- strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
-
- if (tmpXmlChar != NULL)
- pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
-
- if (pushMsg.created == 0)
- pushMsg.created = pushMsg.received;
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
-
- if (tmpXmlChar != NULL)
- pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
-
- pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
-
- tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
-
- if (tmpXmlChar == NULL) {
- MSG_DEBUG("contents is NULL.");
- return;
- }
-
- strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
-
- /* Write push Msg to file */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false) {
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
- }
-
- if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
- }
-
- /* Pack Message Info Structure */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-
- /* Convert Type values */
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_WAP_SI_SMS;
-
- msgInfo.dataSize = sizeof(pushMsg);
-
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
-
- msg_error_t err = MSG_SUCCESS;
-
- /* Add WAP Push Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /* Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
- }
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- MSG_END();
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText)
-{
- MSG_BEGIN();
-
- MSG_PUSH_MESSAGE_S pushMsg = {};
-
- xmlDocPtr xmlDoc = NULL;
- xmlNodePtr topNode = NULL;
- xmlNodePtr indNode = NULL;
-
- xmlChar* tmpXmlChar = NULL;
-
- msg_error_t err = MSG_SUCCESS;
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL \n");
- return;
- }
-
- getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
-
- if (xmlDoc == NULL) {
- MSG_DEBUG("xmlDoc is NULL \n");
- return;
- }
-
- topNode = xmlDocGetRootElement(xmlDoc);
-
- if (topNode == NULL) {
- MSG_DEBUG("Empty Document.");
- xmlFreeDoc(xmlDoc);
- return;
- } else {
- MSG_SEC_DEBUG("Not an empty Document and topNode->name = %s \n", topNode->name);
- }
-
- indNode = topNode;
-
- while (indNode != NULL) {
- if (!xmlStrcmp(indNode->name, (const xmlChar*) "sl")) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
- break;
- }
-
- indNode = indNode->next;
- }
-
- /* setting received time setting */
- time_t t = time(NULL);
- time_t utfTime = time(&t);
-
- pushMsg.received = (unsigned long)utfTime;
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
-
- if (tmpXmlChar == NULL) {
- MSG_DEBUG("href is NULL.");
- return;
- }
-
- strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
- pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
-
- /* Setting other parameters in default values */
- pushMsg.created = pushMsg.received;
- /* temporary set to MAX value. */
- pushMsg.expires = 0xFFFFFFFF;
-
- MSG_DEBUG("check pushMsg data");
- MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
- MSG_DEBUG("pushMsg.received : [%d]", pushMsg.received);
- MSG_DEBUG("pushMsg.created : [%d]", pushMsg.created);
- MSG_DEBUG("pushMsg.expires : [%d]", pushMsg.expires);
- MSG_SEC_DEBUG("pushMsg.id : [%s]", pushMsg.id);
- MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
- MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
-
- /* Write push Msg to file */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
-
- if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
-
- /* Pack Message Info Structure */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-
- /* Convert Type values */
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_WAP_SL_SMS;
-
- /* Update Msg Text */
- strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
-
- msgInfo.dataSize = sizeof(pushMsg);
-
- MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
-
- /* Add WAP Push Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /* Callback to MSG FW */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
-
- MSG_END();
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText)
-{
- MSG_PUSH_CACHEOP_S cacheOp;
-
- xmlDocPtr xmlDoc = NULL;
- xmlNodePtr topNode = NULL;
- xmlNodePtr indNode = NULL;
-
- memset(&cacheOp, 0x00, sizeof(cacheOp));
-
- MSG_DEBUG("Enter handleCOMessage");
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL \n");
- return;
- }
-
- getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
-
- if (xmlDoc == NULL) {
- MSG_DEBUG("xmlDoc is NULL \n");
- return;
- }
-
- topNode = xmlDocGetRootElement(xmlDoc);
- if (topNode == NULL) {
- MSG_DEBUG("Warning:Empty Document\n");
- xmlFreeDoc(xmlDoc);
- return;
- }
-
- indNode = topNode->xmlChildrenNode;
-
- while (indNode != NULL) {
- xmlChar* tmpUrl = NULL;
- if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
-
- tmpUrl = xmlGetProp(indNode, (xmlChar*) SMS_PUSH_XML_CO_URI);
-
- if (tmpUrl != NULL) {
- strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
-
- MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
- } else {
- MSG_DEBUG("NO href value from the xmlDoc\n");
- }
- } else if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_SVC)) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
- tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
-
- if (tmpUrl != NULL) {
- strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
- MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
- } else {
- MSG_DEBUG("NO href value from the xmlDoc\n");
- }
- }
-
- if (tmpUrl != NULL)
- xmlFree(tmpUrl);
-
- indNode = indNode->next;
- }
-
- /* Write push Msg to file */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false) {
- xmlFree(xmlDoc);
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
- }
-
- if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
- xmlFree(xmlDoc);
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
- }
-
- /* Pack Message Info Structure */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-
- /* Convert Type values */
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_WAP_CO_SMS;
-
- msgInfo.dataSize = sizeof(cacheOp);
-
- msg_error_t err = MSG_SUCCESS;
-
- /* Add WAP Push Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /* Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
- }
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- xmlFree(xmlDoc);
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
-{
-#if MSG_DRM_SUPPORT
- int drmRt = DRM_RETURN_SUCCESS;
- char* cid = NULL;
- unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter);
-
- MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
- drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
- drm_register_lic_info_s lic_req_info;
- drm_register_lic_resp_s lic_resp_info;
-
- bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
- bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
- bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
-
- memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
-
- lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
- lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
- lic_req_info.operation_callback.callback = NULL;
-
- drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
- if (drmRt == DRM_RETURN_SUCCESS) {
- MSG_DEBUG("DRM successfully registed to drm-service.");
- } else {
- MSG_DEBUG("Fail to regist DRM to drm-service.");
- }
-#endif
- return;
-}
-
-
-void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
-{
- /* Convert class Type values */
- pMsgInfo->msgType.classType = MSG_CLASS_NONE;
-
- /* set folder id (temporary) */
- pMsgInfo->folderId = MSG_INBOX_ID;
-
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
- time_t rawtime = time(NULL);
- /* Comment below lines to save local UTC time..... (it could be used later.) */
- /*
- if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
-
- MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
- MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
- MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
- MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
- MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
- MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
- MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
-
- char displayTime[32];
- struct tm * timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
- timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
- timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
- timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
- timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
- timeinfo.tm_sec = tmpTimeStamp.time.absolute.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%d]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (tmpTimeStamp.time.absolute.timeZone * (3600/4));
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
- */
-
- pMsgInfo->displayTime = rawtime;
-
- /* Convert Address values */
- pMsgInfo->nAddressCnt = 1;
-
- pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.szData, MAX_ADDRESS_VAL_LEN);
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-}
-
-
-void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
-{
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- if (isText) {
- *pXmlDoc = xmlParseMemory(pPushBody, AcStrlen(pPushBody));
- } else {
- WB_UTINY* xmldata = NULL;
- WBXMLConvWBXML2XML *conv = NULL;
- WBXMLError ret = WBXML_OK;
-
- ret = wbxml_conv_wbxml2xml_create(&conv);
- if (ret != WBXML_OK)
- return;
-
- ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
-
- wbxml_conv_wbxml2xml_destroy(conv);
-
- if (ret != WBXML_OK ||xmldata == NULL) {
- MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
- return;
- }
-
- MSG_DEBUG("xmldata : \n%s\n", xmldata);
-
- *pXmlDoc = xmlParseMemory((char*)xmldata, AcStrlen((char*)xmldata));
- }
-}
-
-
-unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
-{
- struct tm timeStruct;
- time_t nTimeInSec = 0;
- char tmpBuf[10];
- int i = 0, index = 0;
-
- memset(tmpBuf, 0x00, sizeof(tmpBuf));
- memset(&timeStruct, 0x00, sizeof(struct tm));
-
- /* check pDate */
- if (AcStrlen(pDate) < 20)
- return 0;
-
- MSG_DEBUG("pDate [%s]", pDate);
-
- /* Year */
- for (i = 0; i < 4; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_year = (atoi(tmpBuf)-1900);
-
- /* Month */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_mon = (atoi(tmpBuf) - 1);
-
- /* Date */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_mday = atoi(tmpBuf);
-
- /* Hours */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_hour = atoi(tmpBuf);
-
- /* Minites */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_min = atoi(tmpBuf);
-
- /* Seconds */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_sec = atoi(tmpBuf);
-
- nTimeInSec = mktime(&timeStruct);
-
- return nTimeInSec;
-}
-
-
-msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pAction)
-{
- int comp = 0;
-
- if (pAction == NULL) {
- MSG_DEBUG("pAction is NULL. Setting to default action type.");
- return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
- }
-
- /* compare with signal-none. */
- comp = g_strcmp0("signal-none", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
-
- /* compare with signal-low. */
- comp = g_strcmp0("signal-low", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
-
- /* compare with signal-medium. */
- comp = g_strcmp0("signal-medium", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
-
- /* compare with signal-high. */
- comp = g_strcmp0("signal-high", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
-
- /* compare with delete. */
- comp = g_strcmp0("delete", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_DELETE;
-
- /* signal-medium is default action value. */
- return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
-}
-
-
-msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pAction)
-{
- int comp = 0;
-
- if (pAction == NULL) {
- MSG_DEBUG("MSG_DEBUG is NULL. Setting to default action type.\n");
- return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
- }
-
- /* compare pSrcStr with execute-low. */
- comp = g_strcmp0("execute-low", pAction);
- if (comp == 0)
- return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
-
- /* compare pSrcStr with execute-high. */
- comp = g_strcmp0("execute-high", pAction);
- if (comp == 0)
- return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
-
- /* compare pSrcStr with cache. */
- comp = g_strcmp0("cache", pAction);
- if (comp == 0)
- return MSG_PUSH_SL_ACTION_CACHE;
-
- /* default SL action value is execute-low. */
- return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer)
-{
- unsigned long i = 0;
- unsigned long decodedValue;
-
- while (sourceData[*currentPointer +i] >= 0x80) i++;
-
- decodedValue = wspDecodeUintvar(i+1, sourceData + *currentPointer);
- *currentPointer = *currentPointer + i + 1;
- MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%d .\n", decodedValue);
- return decodedValue;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar)
-{
- unsigned long i;
- unsigned long decodedUintvar = 0;
-
-
- for (i = 0 ; i < length; i++) {
- decodedUintvar = decodedUintvar + (wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f));
- }
-
- return decodedUintvar;
-}
-
-
-void SmsPluginWapPushHandler::wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
-{
- unsigned long iField;
- bool continueField = FALSE;
- unsigned long currentLength;
-
- char* encodedHeader = NULL;
- unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter);
-
- char* outTemper = NULL;
-
- char* temper = NULL;
- unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter);
-
- unsigned char track;
- unsigned long iEncodedHeader = 0;
- unsigned char fieldCode = 0xff;
-
- /* outTemper is Decoded Headers.
- temper is Single Decoded Header.
- */
- if (NULL == (outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
- MSG_DEBUG("outTemper Memory allocation is failed.\n");
- return;
- }
- memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
- currentLength = WSP_STANDARD_STR_LEN_MAX;
-
- MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n");
-
- int loop;
- char szBuf[64];
-
- szBuf[0] = 0x00;
- MSG_DEBUG("wspDecodeHeader: RAW data \n");
- for (loop = 0 ; loop < (int)encodedHeaderLen; loop++) {
- char szTempBuf[5];
- szTempBuf[0] = 0x00;
- snprintf(szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop]);
-
- if (AcStrlen(szBuf) + 7 < 64) {
- strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
- } else {
- strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
- MSG_DEBUG("[%s]", szBuf);
- szBuf[0] = 0x00;
- strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
- }
- }
- strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
- MSG_DEBUG("[%s]", szBuf);
- MSG_DEBUG("fContentType=%d \n", fContentType);
- /* operation for content-type */
- /* makes psuedo- content-type fieldcode */
- /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
-
- if (fContentType) {
- encodedHeader = new char[ encodedHeaderLen + 1 ];
- if (encodedHeader == NULL) {
- MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
- return;
- }
- encodedHeader[0] = 0x91;
- memcpy(encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen);
- } else {
- encodedHeader = new char[ encodedHeaderLen ];
- if (encodedHeader == NULL) {
- MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
- return;
- }
-
- memcpy(encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen);
- }
-
- /* Is it reacehd end of header? */
- while (iEncodedHeader < encodedHeaderLen) {
- /* Get memory for single header */
- if (temper == NULL) {
- temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
-
- if (temper == NULL) {
- MSG_DEBUG("temper Memory allocation is failed.\n");
- return;
- }
- memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
- } else {
- memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
- }
-
-
- /* this section presents header code page shifting procedure
- This part can be implemented by future request.
- if (track == 0x 7f)
- */
- track = encodedHeader[iEncodedHeader];
-
- if (track == 0x00) {
- MSG_DEBUG("WspLDecodeHeader: fieldcode is 0 \n");
- strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
- fieldCode = 0xff;
- iEncodedHeader++;
- } else if ((track > 0) && (track < 0x20)) {
- iEncodedHeader++;
- } else if ((track < 0x7f) && (track > 0x1f)) { /* In this case, first byte is normal string. So it's considered to unknown header. */
- unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
- unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
-
- strncpy((char*)fieldName, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
- fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
- iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldName) + 1;
- strncpy((char*)fieldValue, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
- fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
- iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldValue) + 1;
-
- strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- /* this means 'don't process anymore.' */
- fieldCode = 0xff;
-
- } else if (track > 0x7f) {
- /* In case of first byte is field code, else case is error. */
- /*if ((track & 0x7f) <= wspHeaderFieldCount) { */
- unsigned long fieldValueLen = encodedHeader[iEncodedHeader + 1];
- unsigned char fieldValue[1275];
- fieldCode = track & 0x7f;
- /*
- if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
- dprint(DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5]);
- }
- */
- memset(fieldValue, 0, 1275);
-
- /* add field name */
- /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
- if (!continueField) {
- strncat((char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- continueField = FALSE;
- }
-
- /* field value is string */
- /* In this case, it just copy field value. */
- if ((fieldValueLen > LENGTH_QUOTE) && (fieldValueLen < 0x80)) {
- /* string field value should be NULL terminated */
- strncat((char*)temper, (char*)(encodedHeader + iEncodedHeader + 1), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- iEncodedHeader = iEncodedHeader + AcStrlen((char*)encodedHeader + iEncodedHeader + 1) + 2;
- fieldCode = 0xff;
- }
- /* first field value is length */
- /* If first byte of field value is length value, allocate field value by the length.
- In field value, data is
- 1D 03 8F 24 24 - Then 8F 24 24 is field value.
- 1D 1F 33.... - Then allocate 33H for FieldValue.
- 1D 8F - Then 8F
- 1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
- 1D 8F 24 24 - In this case, original data is wrong.
- If accept-charset: ISO-10646-ucs-2;Q=0.7 is
- 01 03 03 E8 47
- 01 - field code
- 03 - field value length
- 03 E8 47 - field value
- it's decoded by above value.
- */
- if (fieldValueLen < 0x20) {
- if (fieldValueLen == LENGTH_QUOTE) {
- /* field length is encoded in UINTVAR */
- unsigned long uintvarLen = 0;
- fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen);
- memcpy(fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen);
- iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
-
- } else {
- if (fieldValueLen == 1) {
- /* field value is one byte integer over 0x80 */
- /* make it two byte integer */
- fieldValue[0] = 0x00;
- memcpy(fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
- fieldValueLen = 2;
- iEncodedHeader = iEncodedHeader + 1 + 2;
- } else {
- memcpy(fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
- fieldValue[fieldValueLen] = 0;
- iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
- if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
- MSG_DEBUG("%X \n", encodedHeader[iEncodedHeader]);
- }
- }
- }
- }
-
- /* field value is single encoded */
- if (fieldValueLen > 0x7f) {
- fieldValue[0] = encodedHeader[iEncodedHeader + 1];
- fieldValueLen = 1;
- iEncodedHeader = iEncodedHeader + 2;
- }
- /* processing normal pre-defined field decoding */
-
- MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode);
- MSG_DEBUG("WspLDecodeHeader: fieldSize %d\n", fieldValueLen);
-
- if ((fieldCode > wspHeaderFieldCount) && (fieldCode != 0xff)) {
- MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track);
- strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
- fieldCode = 0xff;
- }
-
-
- switch (fieldCode) {
- /* accept charset */
- /* It's normal way of field process. */
- case 0x01: {
- unsigned long i = 0;
- unsigned long code;
-
- /* Case of length of charset greater than 1 are two thigins.
- 1. code length of charset is greater than 1.
- 2. It include parameter.
- 3. Or both of two
- */
- if (1 != fieldValueLen) {
- code = wspHeaderDecodeInteger(fieldValue);
- /* Calculate iField. */
- if (fieldValue[0] < 0x80)
- iField = fieldValue[0];
- else
- iField = 1;
-
- while (wspCharset[i].charsetCode != code)
- i++;
- strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- /* If parameter exist */
- if (iField < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeQValue(fieldValueLen - iField, fieldValue + iField, ¶m);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- } else {
- code = fieldValue[0] & 0x7f;
-
- while ((wspCharset[i].charsetCode != code) && (wspCharset[i].charsetCode != 0xffff)) i++;
- strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- break;
-
- /* type encoding */
- /* Like below routine, Same decoding routine process together. */
- /* Accept-encoding */
- case 0x02:
- /* content-encoding */
- case 0x0b: {
- int integerValue;
-
- integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
- if (integerValue > 2) {
- MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
- break;
- }
- strncat((char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* contents type decoder */
- /* accept */
- case 0x00:
- /* content-type */
- case 0x11: {
- unsigned long contentsTypeCode;
- unsigned long i = 0;
- /* encoded content type length body */
- unsigned long tempLen;
- MSG_DEBUG("fieldValueLen: %d", fieldValueLen);
-
- /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
- if (0 == fieldValueLen) {
- strncat((char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- break;
- }
- /* 01 AE --> 00 AE --> AE*/
- if (fieldValueLen == 2 && fieldValue[0] == 0) {
- memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
- MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
- }
-
- if ((fieldValue[0] < 0x20) || (fieldValue[0] >= 0x80)) {
- if (fieldValue[0] >= 0x80) {
- tempLen = 1;
- } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /* 06 05 02 03 0A AF 89 */
- fieldValue[3] = fieldValue[2];
- fieldValue[2] = fieldValue[1];
- fieldValue[1] = fieldValue[0];
- fieldValue[0] = 0x02;
- tempLen = 2;
- fieldValueLen = 3;
- MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n");
- } else {
- tempLen = fieldValue[0]; /* 06 06 03 02 03 16 AF 88 */
- }
-
- if (tempLen == 1) {
- char* szExtendedContent;
-
- contentsTypeCode = fieldValue[0] & 0x7f;
- while ((wspContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspContentsTypeCount)) i++;
-
- /* If specified content type doesn't exist */
- if (i < wspContentsTypeCount)
- strncat((char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- szExtendedContent = wspExtendedDecodeType((char)contentsTypeCode);
-
- if (szExtendedContent != NULL) {
- MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n ");
- strncat((char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- } else {
- contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
-
- while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode))
- i++;
-
- /* If there is a Content-Type assigned, */
- if (i < wspUnregisteredContentsTypeCount)
- strncat((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- tempLen +=1;
- }
- } else {
- tempLen = AcStrlen((char*)fieldValue) + 1;
-
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type\n ", tempLen);
- }
-
- /* If there is a parameter */
- if (tempLen < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + tempLen, fieldValueLen - tempLen, ¶m);
- if (param != NULL) {
- strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- }
- break;
-
- /* language */
- /* content-language */
- case 0x0c:
- /* accept-language */
- case 0x03: {
- unsigned long i = 0;
- unsigned long code;
- unsigned long tempLen;
- if ((fieldValue[0] < 0x20) || (fieldValue[0] > 0x80)) {
- if (fieldValue[0] > 0x80)
- tempLen = 1;
- else
- tempLen = fieldValue[0];
- } else {
- tempLen = AcStrlen((char*)fieldValue) + 1;
- }
-
- if (tempLen == 1) {
- code = wspHeaderDecodeInteger(fieldValue);
- while (wspLanguage[i].languageCode != code) {
- i++;
- if (i == wspLanguageCount)
- break;
- }
-
- if (i < wspLanguageCount) {
- strncat((char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- } else {
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
-
- if (tempLen < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeQValue(fieldValueLen - tempLen, fieldValue + tempLen, ¶m);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- break;
-
- /* integer */
- /* Max-forwards */
- case 0x1e:
- /* content-length */
- case 0x0d:
- /* age */
- case 0x05:
- /* Bearer-indication */
- case 0x33:
- /* Push-Flag */
- case 0x34: {
- unsigned char temp[16];
- /*
- if ((fieldValueLen == 2) && (fieldValue[0] > 0x7f))
- AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[1]);
- else
- */
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* X-Wap-Application-Id */
- case 0x2f: {
- unsigned char temp[64];
- int integerValue;
-
- if (fieldValueLen == 2 && fieldValue[0] == 0) {
- memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
- MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
- fieldValueLen = 1;
- }
-
- integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
-
- int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
- for (int i = 0; i < count ; ++i) {
- if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode) {
- snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- break;
- }
- }
- }
- break;
- /* Accept-Application */
- case 0x32:
- if (0x80 == fieldValue[0]) {
- strncat((char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- } else {
- unsigned char temp[16];
- /*
- if ((fieldValueLen == 2) && (fieldValue[0] == 1))
- AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[0]);
- else
- */
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- }
- break;
-
-
- /* date */
- /* last-modified */
- case 0x1d:
- /* if-unmodified-since */
- case 0x1b:
- /* if-range */
- case 0x1a:
- /* if-modified-since */
- case 0x17:
- /* expires */
- case 0x14:
- /* date */
- case 0x12: {
- char* decodedString = NULL;
- unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
- wspHeaderDecodeDateValue(fieldValueLen, fieldValue, &decodedString);
- strncat((char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- }
- break;
-
- /* connection */
- case 0x09:
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- break;
- /* accept-ranges */
- case 0x04:
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- if (fieldValue[0] == 0x81)
- strncat((char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- break;
- /* content-md5 */
- case 0x0f: {
- unsigned char temp[1275];
- memcpy(temp, fieldValue, (size_t)fieldValueLen);
- temp[fieldValueLen] = 0;
- wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
- }
- break;
- /* Credential */
- /* authorization */
- case 0x07:
- /* proxy - authorization */
- case 0x21:
- if (fieldValue[0] == 0x80) {
- char* addString = NULL;
- unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
- wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString);
- strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- } else {
- iField = AcStrlen((char*)fieldValue) + 1;
-
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- if (iField < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
- if (param != NULL) {
- strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- }
- break;
-
- /* Challenge */
- /* www - auth */
- case 0x2d:
- /* Proxy-authenticate */
- case 0x20:
- if (0 == fieldValueLen)
- break;
- if (fieldValue[0] == 0x80) {
- char* addString = NULL;
- unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
- wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString);
- strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- } else {
- unsigned char authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
- unsigned char realmValue[WSP_STANDARD_STR_LEN_MAX];
- unsigned char addedString[WSP_STANDARD_STR_LEN_MAX];
-
- strncpy((char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
- iField = AcStrlen((char*)authScheme) + 1;
- strncpy((char*)realmValue, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
- iField = iField + AcStrlen((char*)realmValue) + 1;
- snprintf((char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue);
- wspHeaderCopyDecodedString(addedString, ¤tLength, &temper);
-
- if (iField < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + iField, fieldValueLen - iField, ¶m);
- if (param != NULL) {
- strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- wspHeaderCopyDecodedString((unsigned char*)param, ¤tLength, &temper);
- }
- }
- }
- break;
-
- /* content -range */
- case 0x10: {
- unsigned long first, len, last;
-
- unsigned char temp[16];
- iField = 0;
-
- strncat((char*)temper, " bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- first = wspRetriveUintvarDecode(fieldValue, &iField);
- len = wspRetriveUintvarDecode(fieldValue, &iField);
- /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length. */
- last = first + contentsLength - 1;
-
- snprintf((char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
-
- /* cache-control */
- case 0x08: {
- char* cacheString = NULL;
- unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
-
- wspHeaderDecodeCacheControl(fieldValue, fieldValueLen, &cacheString);
- strncat((char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
-
- /* pragma */
- case 0x1f:
- if (fieldValue[0] == 0x80) {
- strncat((char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- } else {
- if (1 < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue, fieldValueLen, ¶m);
-
- if (param != NULL) {
- strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- }
- break;
-
- /* public */
- case 0x22:
- /* allow */
- case 0x06: {
- unsigned long i = 0;
- while (wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen) != wspMethodType[i].methodCode) i++;
- strncat((char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* range */
- case 0x23:
- strncat((char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- if (fieldValue[0] == 0x80) {
- unsigned char temp[16];
- unsigned long first, last;
- iField = 0;
-
- first = wspRetriveUintvarDecode(fieldValue, &iField);
- last = wspRetriveUintvarDecode(fieldValue, &iField);
-
- snprintf((char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- if (fieldValue[0] == 0x81) {
- unsigned char temp[16];
- unsigned long suffix;
-
- suffix = wspRetriveUintvarDecode(fieldValue, &iField);
-
- snprintf((char*)temp, sizeof(temp), "-%u", (unsigned int)suffix);
- }
- break;
- /* retry-after */
- case 0x25:
- if (fieldValue[0] == 0x80) {
- char* temp = NULL;
- unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
-
- wspHeaderDecodeDateValue(fieldValueLen - 1, fieldValue + 1, &temp);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
-
- if (fieldValue[0] == 0x81) {
- unsigned char temp[16];
-
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* transfer-encoding */
- case 0x27:
- /* No other cases allowed */
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- break;
- /* vary */
- case 0x2a: {
- int integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
- if (integerValue > wspHeaderFieldCount) {
- MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n", wspHeaderFieldCount);
- break;
- }
- strncat((char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* warning */
- case 0x2c: {
- unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
- if (fieldValue[0] < 0x20)
- iField = fieldValue[0];
- else
- iField = 1;
-
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, iField));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- if (iField < fieldValueLen) {
- unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
- unsigned char text[WSP_STANDARD_STR_LEN_MAX];
- strncpy((char*)agent, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
- iField = iField + AcStrlen((char*)agent) + 1;
- strncpy((char*)text, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
- snprintf((char*)temp, sizeof(temp), " %s %s", agent, text);
- wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
- }
- }
- break;
- /* content-disposition */
- case 0x2e:
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- if (fieldValue[0] == 0x81)
- strncat((char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- if (1 < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
-
- if (param != NULL) {
- strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- break;
- /* Profile-diff */
- case 0x36:
- temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
- memcpy(temper, fieldValue, (size_t)fieldValueLen);
- break;
- /* Profile-Warning */
- case 0x37: {
- unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
- snprintf((char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue));
- temp[2] = temp[1];
- temp[1] = (unsigned char)0x30;
- temp[3] = '\0';
- if (fieldValueLen > 1) {
- /* copy warn-target - URI */
- strncat((char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
- if (fieldValueLen > (AcStrlen((char*)(fieldValue + 1)) + 1)) {
- /* copy warn-date */
- char* decodedString = NULL;
- unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
- wspHeaderDecodeDateValue(fieldValueLen - (AcStrlen((char*)(fieldValue + 1)) + 2), fieldValue + AcStrlen((char*)(fieldValue + 1)) + 1, &decodedString);
- strncat((char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
- }
- }
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
-
- default:
- break;
- }
- /*}*/
- }
- /* It deosn't finished decoding yet. */
- if ((iEncodedHeader < encodedHeaderLen) && (fieldCode != 0xff)) {
- /* In here, iEncodedHeader already point next field code to be decoded. */
- /* If this code is same, then set continueField else add CRLF. */
- if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f)) {
- strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- continueField = TRUE;
- } else {
- strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- continueField = FALSE;
- }
- } else {
- strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
-
- /* add single header to total headers */
- strncat((char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1);
- MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper);
- }
-
-
- MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n");
-
- *pHeader = outTemper;
-
- return;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger(unsigned char* data)
-{
- /* we only can handle max 32bit integer */
- unsigned long i;
-
- union {
- unsigned long integer;
- unsigned char seg[4];
- } returner;
-
- returner.integer = 0;
-
- if (data[0] < 0x80) {
- unsigned long IntLen = 0;
-
- IntLen = (data[0] > 0x04) ? 0x04:data[0];
-
- MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %d\n", data[0], IntLen);
-
- for (i = 0; i < IntLen; i++)
- returner.seg[IntLen-(i+1)] = data[i+1];
-
- return returner.integer;
- }
-
- return data[0] & 0x7f;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString)
-{
- unsigned short qBase = 0;
- float qValue;
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
- return;
- }
-
- memcpy(&qBase, data, (size_t)length);
- qValue = (float)qBase;
- if (qValue > 100) {
- qValue = qValue - 100;
- qValue = qValue / 1000;
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue);
- } else {
- /* qValue variable is divided by 100. And it's multiplied by 100.
- It's to resolve problem of changed 0.01 of qValue. */
- unsigned long qValueTemp;
- qValue = qValue - 1;
- qValue = qValue / 100;
- qValueTemp = (unsigned long)(qValue * 100);
- if (0 == (qValueTemp % 10))
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue);
- else
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue);
- }
- return;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length)
-{
- unsigned long i;
-
- union {
- unsigned long integer;
- unsigned short seg[4];
- } returner;
-
- returner.integer = 0;
-
- if (length == 1)
- return data[0] & 0x7f;
-
- returner.integer = 0;
-
- for (i = 0 ; i < length; i++) {
- returner.integer = returner.integer + (data[i] * (0x1 << ((length - (i + 1)) * 8)));
- MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %d \n", returner.integer);
- }
-
- return returner.integer;
-}
-
-
-char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType)
-{
- int i = 0;
-
- while (wspExtendedContentsType[i].contentsTypeCode != contentType) {
- if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
- return NULL;
- i++;
- }
-
- return (char*)wspExtendedContentsType[i].contentsTypeName;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam)
-{
- char* param = *pParam;
-
- unsigned long SecurityTypeCode;
- unsigned long i = 0;
-
- if (data[0] < 0x80) {
- /* unknown parameter type */
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n");
- return;
- }
-
- strncpy((char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
-
- if (NO_VALUE == data[AcStrlen((char*)param) + 1]) {
- *pParam = param;
- return;
- }
-
- strncat((char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- strncat((char*)param, (char*)(data + AcStrlen((char*)param)), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
-
- *pParam = param;
-
- return;
- }
-
- switch (data[0] & 0x7f) {
- case 0x00:
- wspHeaderDecodeQValue(length - 1, data + 1, ¶m);
- break;
- case 0x01:
- wspHeaderDecodeCharset(length - 1 , data + 1, ¶m);
- break;
- case 0x02:
- wspHeaderDecodeVersion(length - 1, data + 1, ¶m);
- break;
- /* integer */
- case 0x03:
- /* param = (unsigned char *)malloc((size_t)WSP_STANDARD_STR_LEN_MAX); */
- param = new char[WSP_STANDARD_STR_LEN_MAX];
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
- return;
- } else {
- snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger(data + 1));
- }
- break;
- case 0x08:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
- return;
- } else {
- snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger(data + 1));
- }
- break;
- case 0x05:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
- return;
- } else {
- strncpy((char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
- memcpy(param + 5, data + 1, length - 1);
- param[5 + length - 1] = '\0';
- }
- break;
- case 0x06:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
- return;
- } else {
- strncpy((char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
- memcpy(param + 9, (char*)(data + 1), (size_t)(length - 1));
- param[9 + length - 1] = '\0';
- }
- break;
- case 0x07:
- param = NULL;
- /* TBI */
- break;
- /*OMA Provisioning*/
- case 0x11:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
- return;
- } else {
- strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
- SecurityTypeCode = data[1] & 0x7f;
- while ((i < wspSecurityTypeCount) && (wspSecurityType[i].SecurityTypeCode != SecurityTypeCode))
- i++;
-
- if (i < wspSecurityTypeCount) {
- strncat((char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- }
-
- if (0x12 == (data[2] & 0x7f)) {
- strncat((char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- memcpy(param+AcStrlen((char*)param), (char*)(data+3), (size_t)length-3);
- }
- }
- break;
-
- default:
- param = NULL;
- break;
- }
-
- *pParam = param;
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString)
-{
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
- return;
- }
-
- strncpy((char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
-
- if (data[0] > 0x80) {
- unsigned long code = wspHeaderDecodeInteger(data);
- unsigned long i = 0;
- while (wspCharset[i].charsetCode != code) {
- if (wspCharset[i].charsetCode == 0xffff) {
- return;
- }
- i++;
- }
- strncat((char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1);
- } else {
- unsigned long lastLen = AcStrlen((char*)*pDecodedString);
- memcpy((char*)(*pDecodedString + lastLen), data, (size_t)length);
- *pDecodedString[length + lastLen] = '\0';
- }
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString)
-{
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
- return;
- }
-
- if (length > 1) {
- /* untyped version */
- memcpy(*pDecodedString, data, (size_t)length);
- } else {
- /* typed version */
- unsigned char majorVer = ((data[0] & 0x7f) >> 4);
- unsigned char minorVer = data[0] & 0x0f;
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer);
- }
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString)
-{
- time_t lTime;
- struct tm* pTMData;
-
- MSG_DEBUG("WspLHeaderDecodeDateValue: \n");
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeDateValue:MemAlloc failed\n");
- return;
- }
-
- lTime = wspHeaderDecodeIntegerByLength(data, length);
-
- pTMData = (struct tm*)gmtime((const time_t*)&lTime);
-
- if (pTMData == NULL) {
- MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail \n");
- strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
- return;
- }
-
- /* check date value validity */
- if ((pTMData->tm_wday > 6) || (pTMData->tm_mon > 11) || (pTMData->tm_mday > 31)) {
- MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday);
- strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
- return;
- }
-
-#ifdef MSG_FW_FOR_DEBUG
- /* Date type selection */
- switch (wspMachineStatus.dateType) {
- /* UNIX asciitime function */
- case UNIX_DATE_TYPE:
- snprintf((char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
- pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900);
- break;
- case RFC1123_DATE_TYPE:
- snprintf((char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday,
- wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec);
- break;
- case RFC850_DATE_TYPE:
- /* Have some Y2K Problems */
- /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */
- snprintf((char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday,
- wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec);
- break;
- }
-#endif
- /*UNIX_DATE_TYPE : */
- snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
- pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900);
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper)
-{
- unsigned long elementLen = AcStrlen((char*)szDecodedString);
- char* temper2 = NULL;
-
- /* CR+LF */
- *currentLen = *currentLen + elementLen + 2;
-
- if (*currentLen > AcStrlen((char*)* pTemper) + 2) {
- temper2 = new char[(*currentLen + 1)];
-
- if (temper2 == NULL) {
- MSG_DEBUG("WspLHeaderCopyDecodedString:MemAlloc failed\n");
- return;
- }
- strncpy((char*)temper2, (char*)* pTemper, *currentLen);
- delete[] *pTemper;
- strncpy((char*)temper2, (char*)szDecodedString, *currentLen);
- }
-
- *pTemper = temper2;
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
-{
- unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
- unsigned char passWd[WSP_STANDARD_STR_LEN_MAX];
- unsigned long iField = 0;
- char authStr[256];
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n");
- return;
- }
-
- /* skip 'basic' code */
- iField++;
- memset(authStr, 0x00, sizeof(authStr));
- snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId));
- sscanf((char*)(fieldValue + iField), authStr, userId);
- iField = iField + AcStrlen((char*)userId) + 1;
- memset(authStr, 0x00, sizeof(authStr));
- snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(passWd));
- sscanf((char*)(fieldValue + iField), authStr, passWd);
- iField = iField + AcStrlen((char*)userId) + 1;
- snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd);
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
-{
- unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
- unsigned long iField = 0;
- char authStr[256];
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeChallenge:MemAlloc failed\n");
- return;
- }
-
- /* skip 'basic' code */
- iField++;
- memset(authStr, 0x00, sizeof(authStr));
- snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId));
- sscanf((char*)(fieldValue + iField), authStr, userId);
- iField = iField + AcStrlen((char*)userId) + 1;
-
- snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "basic realm=\"%s\"", userId);
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
-{
- unsigned char paramString[WSP_STANDARD_STR_LEN_MAX];
- unsigned char cacheCode;
-
- *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
- if (*pCacheString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeCacheControl:MemAlloc failed\n");
- return;
- }
-
- if (1 == fieldValueLen) {
- /* only one directive */
- if (fieldValue[0] > 0x8b) {
- return; /* It's error detection. can be omitted. */
- }
- strncpy((char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
- return;
- }
-
- if (fieldValue[0] > 0x7f) {
- /* directive that has parameter */
- cacheCode = fieldValue[0] & 0x7f;
- switch (cacheCode) {
- /* field name */
- /* no-cache */
- case 0x00:
- /* private */
- case 0x07:
- if (fieldValue[1] > 0x7f) {
- /* well known field name */
- strncpy((char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
- paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
- } else {
- /* unknown field name */
- strncpy((char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
- }
- break;
- /* secound */
- /* max-age */
- case 0x02:
- /* max- stale */
- case 0x03:
- /* min-fresh */
- case 0x04:
- snprintf((char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger(fieldValue + 1));
- break;
- default:
- break;
- }
- snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString);
- } else {
- /* cache extentions */
- /* In case of come directive of doesn't specified string style */
-
- unsigned long stringLen;
- char szString[32];
- strncpy((char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
- stringLen = AcStrlen((char*)*pCacheString);
-
- if (stringLen + 1 < fieldValueLen) {
- if (fieldValue[stringLen+ 1] > 0x7f) {
- int untyped = (int)wspHeaderDecodeIntegerByLength(fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1));
-
- snprintf(szString, sizeof(szString), "%d", untyped);
- strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- strncat((char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- } else {
- if (fieldValue[fieldValueLen] == 0) {
- strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- strncat((char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- }
- }
- }
- }
-
- return;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_CALLBACK_H
-#define SMS_CDMA_PLUGIN_CALLBACK_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include <map>
-#include <vector>
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TelSim.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
- #include <ITapiNetwork.h>
-}
-
-/*==================================================================================================
- FUNCTION PROTOTYPES
-==================================================================================================*/
-void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data);
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginCallback
-{
-public:
- static SmsPluginCallback* instance();
-
- void registerEvent();
- void deRegisterEvent();
-
-private:
- SmsPluginCallback();
- ~SmsPluginCallback();
-
- static SmsPluginCallback* pInstance;
-};
-
-#endif /* SMS_CDMA_PLUGIN_CALLBACK_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_CODEC_H
-#define SMS_CDMA_PLUGIN_CODEC_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsCdmaPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginMsgCodec
-{
-public:
- static SmsPluginMsgCodec* instance();
-
- static bool checkInvalidPDU(const unsigned char *p_pkg_str, const int p_pkg_len);
-
- static int encodeMsg(const sms_trans_msg_s *pMsg, unsigned char *p_pkg_str);
- static int decodeMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_msg_s *p_msg);
-
-private:
- SmsPluginMsgCodec();
- ~SmsPluginMsgCodec();
-
- static SmsPluginMsgCodec* pInstance;
-
- static int encodeP2PMsg(const sms_trans_p2p_msg_s *p_msg, unsigned char *p_pkg_str);
- static int encodeAckMsg(const sms_trans_ack_msg_s *p_msg, unsigned char *p_pkg_str);
- static int encodeCBMsg(const sms_trans_broadcast_msg_s *p_msg, unsigned char *p_pkg_str);
-
- static int encodeTelesvcMsg(const sms_telesvc_msg_s *p_msg, unsigned char *p_pkg_str);
-
- static int encodeTelesvcCancelMsg(const sms_telesvc_cancel_s *p_msg, unsigned char *p_pkg_str);
- static int encodeTelesvcSubmitMsg(const sms_telesvc_submit_s *p_msg, unsigned char *p_pkg_str);
- static int encodeTelesvcUserAckMsg(const sms_telesvc_user_ack_s *p_msg, unsigned char *p_pkg_str);
- static int encodeTelesvcReadAckMsg(const sms_telesvc_read_ack_s *p_msg, unsigned char *p_pkg_str);
- static int encodeTelesvcDeliverReportMsg(const sms_telesvc_report_s *p_msg, unsigned char *p_pkg_str);
-
- static int decodeP2PMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_p2p_msg_s *p_p2p);
- static int decodeCBMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_broadcast_msg_s *p_cb);
- static int decodeAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_ack_msg_s *p_ack);
-
- static void decodeP2PTelesvcMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_msg_s *p_telesvc);
- static void decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_deliver_ack_s *p_del_ack);
- static void decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_report_s *p_sub_report);
- static void decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_user_ack_s *p_user_ack);
- static void decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_read_ack_s *p_read_ack);
- static void decodeP2PDeliverMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_deliver_s *p_del);
- static void decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_submit_s *p_sub);
- static void decodeCBBearerData(const unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_msg_s *p_telesvc, bool isCMAS);
-
- static int encodeUserData(const unsigned char* src, unsigned char *dest, int src_size);
- static void decodeUserData(unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_userdata_s *p_user);
- static void decodeCMASData(unsigned char *p_pkg_str, int p_pkg_len, sms_telesvc_cmasdata_s *p_cmas);
-
- static int decodeTeleId(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_telesvc_id_t *tele_id);
- static int decodeSvcCtg(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_svc_ctg_t *svc_ctg);
- static int decodeAddress(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_addr_s *addr);
- static int decodeSubAddress(const unsigned char *p_pkg_str, int p_pkg_len, sms_trans_sub_addr_s *sub_addr);
-
- static int decodeMsgId(const unsigned char *p_pkg_str, int pkg_len, sms_trans_msg_id_s *p_msg_id);
- static void decodeCallBackNum(const unsigned char *p_pkg_str, int pkg_len, sms_telesvc_addr_s *p_callback);
- static int decodeAbsTime(const unsigned char *p_pkg_str, sms_time_abs_s *p_time_abs);
- static sms_message_type_t findMsgType(const unsigned char *p_pkg_str, int pkg_len);
-};
-
-#endif /* SMS_CDMA_PLUGIN_CODEC_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_EVENT_HANDLER_H
-#define SMS_CDMA_PLUGIN_EVENT_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include <string>
-#include <map>
-#include <vector>
-#include <list>
-
-using namespace std;
-
-#include "MsgMutex.h"
-#include "MsgTextConvert.h"
-#include "MsgPluginInterface.h"
-#include "SmsCdmaPluginTypes.h"
-
-
-/*==================================================================================================
- VARIABLES AND DEFINES
-==================================================================================================*/
-struct wap_data_s {
- int length;
- char data[SMS_MAX_USER_DATA_LEN+1];
-};
-
-typedef map<unsigned char, wap_data_s> wapDataMap;
-
-typedef struct _sms_wap_msg_s {
- unsigned short msgId;
- unsigned char totalSeg;
- unsigned char segNum;
-} sms_wap_msg_s;
-
-typedef struct _sms_wap_info_s {
- unsigned short msgId;
- unsigned char totalSeg;
- unsigned char segNum;
-
- unsigned int totalSize;
- wapDataMap data;
-} sms_wap_info_s;
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginEventHandler
-{
-public:
- static SmsPluginEventHandler* instance();
-
- void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
- void handleSentStatus(msg_network_status_t NetStatus);
- void handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg);
- void handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_msg);
- void handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg);
-
- void handleResendMessage(void);
-
- msg_error_t callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
-
- void convertTpduToMsginfo(sms_trans_p2p_msg_s *p_p2p_msg, MSG_MESSAGE_INFO_S *p_msg_info);
- void convertTpduToMsginfo(sms_trans_broadcast_msg_s *p_cb_msg, MSG_MESSAGE_INFO_S *p_msg_info);
-
- void SetSentInfo(sms_sent_info_s *pSentInfo);
-
- void setDeviceStatus();
- bool getDeviceStatus();
- void setNeedInitConfig(bool bNeeded);
- bool getNeedInitConfig();
-
- void handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen);
- void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
- void handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *app_id, char *content_type);
-
-private:
- SmsPluginEventHandler();
- virtual ~SmsPluginEventHandler();
-
- static SmsPluginEventHandler* pInstance;
-
- MSG_PLUGIN_LISTENER_S listener;
-
- sms_sent_info_s sentInfo;
-
- bool devStatus;
- bool bNeedInitConfig;
-
- MsgMutex mx;
- MsgCndVar cv;
- vector<sms_wap_info_s> wapList;
-
- void convertDeliverMsgToMsgInfo(sms_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
- void convertCMASMsgToMsgInfo(sms_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
- void convertAckMsgToMsgInfo(sms_telesvc_deliver_ack_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
- void convertReportMsgToMsgInfo(sms_telesvc_report_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
-
- msg_encode_type_t getEncodeType(sms_encoding_type_t encode_type);
-
- unsigned short checkWapMsg(sms_wap_msg_s *pMsg, sms_telesvc_userdata_s *pUserdata);
- int MakeWapUserData(unsigned short msgId, char **ppTotalData);
-
- bool checkCbOpt(sms_trans_svc_ctg_t svc_ctg);
-};
-
-#endif /* SMS_CDMA_PLUGIN_EVENT_HANDLER_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_MAIN_H
-#define SMS_CDMA_PLUGIN_MAIN_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsCdmaPluginTypes.h"
-#include "MsgPluginInterface.h"
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-/*==================================================================================================
- FUNCTION PROTOTYPES
-==================================================================================================*/
-msg_error_t SmsPlgInitialize();
-
-msg_error_t SmsPlgFinalize();
-
-msg_error_t SmsPlgRegisterListener(MSG_PLUGIN_LISTENER_S *pListener);
-
-msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo);
-
-msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
-
-msg_error_t SmsPlgDeleteSimMessage(msg_sim_id_t SimMsgId);
-
-msg_error_t SmsPlgGetSimMessage(msg_sim_id_t SimMsgId);
-
-msg_error_t SmsPlgSetReadStatus(msg_sim_id_t SimMsgId);
-
-msg_error_t SmsPlgSetMemoryStatus(msg_error_t Error);
-
-msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting);
-
-msg_error_t SmsPlgGetConfigData(MSG_SETTING_S *pSetting);
-
-msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char* pFileData);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SMS_CDMA_PLUGIN_MAIN_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_PARAMCODEC_H
-#define SMS_CDMA_PLUGIN_PARAMCODEC_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsCdmaPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginParamCodec
-{
-public:
- static SmsPluginParamCodec* instance();
-
- static int convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd);
- static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit);
- static int convertDigitToDTMF(const char *pDigit, int DigitLen, int startBit, unsigned char *pDtmf);
- static int convertDTMFToDigit(const unsigned char *pDtmf, int DtmfLen, int startBit, char *pDigit);
-
-private:
- SmsPluginParamCodec();
- virtual ~SmsPluginParamCodec();
-
- static SmsPluginParamCodec* pInstance;
-
- static bool isDtmfNumber(const char *pDigit, int DigitLen);
-};
-
-#endif /*SMS_CDMA_PLUGIN_PARAMCODEC_H*/
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_SETTING_H
-#define SMS_CDMA_PLUGIN_SETTING_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-#include "MsgSettingTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginSetting
-{
-public:
- static SmsPluginSetting* instance();
-
- void setSimChangeStatus();
-
- void setConfigData(const MSG_SETTING_S *pSetting);
- void getConfigData(MSG_SETTING_S *pSetting);
- void getMeImei(char *pImei);
-
- void setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
-
- void setResultImei(bool bResult, char *pImei);
- void setResultFromEvent(bool bResult);
- void setResultFromSim(bool bResult);
-
- void setMwiInfo(MSG_SUB_TYPE_T type, int count);
- void SimRefreshCb();
-
- bool getUpdateVoicemailByMdn();
-
-private:
- SmsPluginSetting();
- ~SmsPluginSetting();
-
- void updateSimStatus();
-
- void initConfigData();
- static void* init_config_data(void *data);
- static void* initSimInfo(void *data);
-
- msg_error_t addCbOpt(MSG_CBMSG_OPT_S *pCbOpt);
- void getCbOpt(MSG_SETTING_S *pSetting);
-
- void setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt);
- bool setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt);
- bool getCbConfig(MSG_CBMSG_OPT_S *pCbOpt);
-
- bool getMsisdnInfo(void);
-
- bool getResultImei(char *pImei);
-
- bool getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt);
-
- bool getResultFromSim();
-
- static SmsPluginSetting* pInstance;
-
- MSG_SMSC_DATA_S smscData;
- MSG_CBMSG_OPT_S cbOpt;
-
- bool bTapiResult;
- bool bUpdateVoicemailByMdn;
-
- char meImei[MAX_ME_IMEI_LEN + 1];
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_CDMA_PLUGIN_SETTING_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_STORAGE_H
-#define SMS_CDMA_PLUGIN_STORAGE_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-
-#include "MsgStorageTypes.h"
-#include "SmsCdmaPluginTypes.h"
-#include "MsgInternalTypes.h"
-#include "MsgSqliteWrapper.h"
-#include <list>
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
-}
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginStorage
-{
-public:
- static SmsPluginStorage* instance();
-
- msg_error_t insertMsgRef(MSG_MESSAGE_INFO_S *pMsg, unsigned char msgRef, int index);
- msg_error_t updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInfo, unsigned char msgRef);
-
- msg_error_t updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t Status);
-
- msg_error_t checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t deleteSmsMessage(msg_message_id_t msgId);
- msg_error_t addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo);
-
- msg_error_t checkStorageStatus(MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t getRegisteredPushEvent(char* pPushHeader, int *count, char *app_id, int app_id_len, char *content_type, int content_type_len);
- msg_error_t getnthPushEvent(int index, int *appcode);
- msg_error_t releasePushEvent();
-
-private:
- SmsPluginStorage();
- ~SmsPluginStorage();
-
- static SmsPluginStorage* pInstance;
-
- MSG_MESSAGE_INFO_S msgInfo;
- MSG_ADDRESS_INFO_S addrInfo;
-
- std::list<PUSH_APPLICATION_INFO_S> pushAppInfoList;
-};
-
-#endif /* SMS_CDMA_PLUGIN_STORAGE_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_TRANSPORT_H
-#define SMS_CDMA_PLUGIN_TRANSPORT_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgInternalTypes.h"
-#include "MsgMutex.h"
-#include "SmsCdmaPluginTypes.h"
-
-extern "C"
-{
- #include <TelSat.h>
-}
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginTransport
-{
-public:
- static SmsPluginTransport* instance();
-
- void submitRequest(sms_request_info_s *pReqInfo);
- void sendDeliverReport(msg_error_t err, sms_trans_p2p_msg_s *p_p2p_msg);
-
- void setNetStatus(sms_network_status_t sentStatus);
-
-private:
- SmsPluginTransport();
- ~SmsPluginTransport();
-
- static SmsPluginTransport* pInstance;
-
- unsigned char getMsgRef();
- unsigned char getSeqNum();
- unsigned char getSubmitMsgId();
-
- sms_network_status_t getNetStatus();
-
- void convertMsgInfoToTelesvcMsg(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_trans_msg_s *pMsg);
- void convertMsgInfoToPtp(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_trans_p2p_msg_s *pPtpMsg);
- void convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_telesvc_submit_s *pSubmit);
-
- unsigned char msgRef;
- unsigned char msgSeqNum;
- unsigned char msgSubmitId;
-
- unsigned char msgRef8bit;
- unsigned short msgRef16bit;
-
- sms_network_status_t curStatus;
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_PLUGIN_TRANSPORT_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgDebug.h"
-#include "MsgTypes.h"
-#include "MsgInternalTypes.h"
-
-#ifndef SMS_CDMA_PLUGIN_TYPES_H
-#define SMS_CDMA_PLUGIN_TYPES_H
-
-#define MAX_SMS_SEND_RETRY 4
-#define SMS_MAX_MESSAGE_ID 65536
-#define SMS_SEQ_NUM_MAX 64
-#define SMS_MAX_USER_DATA_LEN 160
-#define SMS_MAX_SUBMIT_MESSAGE_ID 256
-
-#define SMS_TRANS_ADDRESS_MAX_LEN 256
-
-#define SMS_MAX_NUMBER_OF_ACK 8
-
-#define SMS_PUSH_XML_HREF_TAG "href"
-#define SMS_PUSH_XML_SI_ID_TAG "si-id"
-#define SMS_PUSH_XML_CREATED_TAG "created"
-#define SMS_PUSH_XML_EXPIRES_TAG "si-expires"
-#define SMS_PUSH_XML_ACTION_TAG "action"
-
-#define SMS_PUSH_XML_INVAL_OBJ "invalidate-object"
-#define SMS_PUSH_XML_INVAL_SVC "invalidate-service"
-#define SMS_PUSH_XML_CO_URI "uri"
-
-
-typedef unsigned char sms_wap_app_code_t; /* _sms_wap_app_code_e */
-
-typedef struct _SMS_WSP_CONTENTS_TYPE_S {
- char* contentsTypeName;
- unsigned char contentsTypeCode;
-} SMS_WSP_CONTENTS_TYPE_S;
-
-
-typedef struct _SMS_WSP_CHARSET_S {
- char* charsetName;
- unsigned short charsetCode;
-} SMS_WSP_CHARSET_S;
-
-
-typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S {
- char* contentsTypeName;
- unsigned short contentsTypeCode;
-} SMS_WAP_UNREGISTER_CONTENTS_TYPE_S;
-
-
-typedef struct _SMS_WSP_LANGUAGE_S {
- char* languageName;
- unsigned char languageCode;
-} SMS_WSP_LANGUAGE_S;
-
-
-typedef struct _SMS_WSP_HEADER_PARAMETER_S {
- char* parameterToken;
- unsigned int parameterCode;
-} SMS_WSP_HEADER_PARAMETER_S;
-
-
-typedef struct _SMS_WSP_METHOD_TYPE_S {
- char* methodName;
- unsigned char methodCode;
-} SMS_WSP_METHOD_TYPE_S;
-
-
-typedef struct _SMS_WSP_SECURITY_TYPE_S {
- char* SecurityTypeName;
- unsigned char SecurityTypeCode;
-} SMS_WSP_SECURITY_TYPE_S;
-
-
-typedef struct {
- msg_request_id_t reqId; /* < Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
- MSG_MESSAGE_INFO_S msgInfo; /* < Indicates the message structure to be sent by applications. */
- MSG_SENDINGOPT_INFO_S sendOptInfo;
-} sms_request_info_s;
-
-
-typedef struct _sms_sent_info_s {
- sms_request_info_s reqInfo; /* < Indicates the corresponding request structure. */
- bool bLast;
-} sms_sent_info_s;
-
-
-enum _sms_network_status_e {
- SMS_NETWORK_SEND_SUCCESS = 0x00,
- SMS_NETWORK_SENDING,
- SMS_NETWORK_SEND_FAIL,
- SMS_NETWORK_SEND_FAIL_TIMEOUT,
- SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING,
- SMS_NETWORK_SEND_FAIL_TEMPORARY,
- SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD,
- SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED,
- SMS_NETWORK_SEND_FAIL_FDN_RESTRICED,
- SMS_NETWORK_SEND_PENDING,
- SMS_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER,
- SMS_NETWORK_SEND_FAIL_MS_DISABLED,
- SMS_NETWORK_SEND_FAIL_NETWORK_NOT_READY,
-};
-
-
-enum _sms_wap_app_code_e {
- SMS_WAP_APPLICATION_DEFAULT = 0x00,
-
- SMS_WAP_APPLICATION_PUSH_SI,
- SMS_WAP_APPLICATION_PUSH_SIC,
-
- SMS_WAP_APPLICATION_PUSH_SL,
- SMS_WAP_APPLICATION_PUSH_SLC,
-
- SMS_WAP_APPLICATION_PUSH_CO,
- SMS_WAP_APPLICATION_PUSH_COC,
-
- SMS_WAP_APPLICATION_MMS_UA,
-
- SMS_WAP_APPLICATION_PUSH_SIA,
-
- SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP,
- SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML,
- SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION,
- SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION,
- SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML,
-
- SMS_WAP_APPLICATION_LOC_UA_WBXML,
- SMS_WAP_APPLICATION_LOC_UA_XML,
-
- SMS_WAP_APPLICATION_DRM_UA_XML,
- SMS_WAP_APPLICATION_DRM_UA_MESSAGE,
- SMS_WAP_APPLICATION_DRM_UA_CONETENT,
- SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML,
- SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML,
- SMS_WAP_APPLICATION_DRM_V2_RO_XML,
- SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML,
- SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML,
- SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML,
-
- SMS_WAP_APPLICATION_PUSH_PROVISIONING,
- SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML,
- SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML,
-
- SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS,
- SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS,
- SMS_WAP_APPLICATION_PUSH_SYNCSET_WBXML,
- SMS_WAP_APPLICATION_PUSH_SYNCSET_XML,
-
- SMS_WAP_APPLICATION_PUSH_EMAIL_XML,
- SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML,
-
- SMS_WAP_APPLICATION_PUSH_IMPS_CIR,
-
- SMS_WAP_APPLICATION_PUSH_WAP_WMLC,
-
- SMS_WAP_APPLICATION_WML_UA,
- SMS_WAP_APPLICATION_WTA_UA,
-
- SMS_WAP_APPLICATION_PUSH_SYNCML,
- SMS_WAP_APPLICATION_LOC_UA,
- SMS_WAP_APPLICATION_SYNCML_DM,
- SMS_WAP_APPLICATION_PUSH_EMAIL,
-
- SMS_OMA_APPLICATION_ULP_UA,
- SMS_OMA_APPLICATION_DLOTA_UA,
-
- SMS_WAP_APPLICATION_LBS,
-};
-
-
-typedef unsigned char sms_network_status_t; /* _sms_network_status_e */
-
-/********************************************************************************/
-/* TELESERVICE LAYER */
-/********************************************************************************/
-
-
-typedef bool sms_digit_mode_t; /* _sms_digit_mode_e */
-
-typedef bool sms_number_mode_t; /* _sms_number_mode_e */
-
-typedef unsigned char sms_number_type_t; /* _sms_number_type_e */
-
-typedef unsigned char sms_number_plan_t; /* _sms_number_plan_e */
-
-
-typedef enum _sms_message_type_e {
- SMS_TYPE_RESERVED = 0x00, /* reserved */
- SMS_TYPE_DELIVER, /* mobile-terminated only */
- SMS_TYPE_SUBMIT, /* mobile-originated only */
- SMS_TYPE_CANCEL, /* mobile-originated only */
- SMS_TYPE_DELIVERY_ACK, /* mobile-terminated only*/
- SMS_TYPE_USER_ACK, /* either direction */
- SMS_TYPE_READ_ACK, /* either direction */
- SMS_TYPE_DELIVER_REPORT, /* mobile-originated only */
- SMS_TYPE_SUBMIT_REPORT = 0x08, /* mobile-terminated only */
- SMS_TYPE_MAX_VALUE
-} sms_message_type_t;
-
-
-typedef enum _sms_alert_option_e {
- SMS_ALERT_NO_ALERT = 0,
- SMS_ALERT_DEFAULT_ALERT,
- SMS_ALERT_VIBRATE_ONCE,
- SMS_ALERT_VIBRATE_REPEAT,
- SMS_ALERT_VISUAL_ONCE,
- SMS_ALERT_VISUAL_REPEAT,
- SMS_ALERT_LOW_PRIORITY_ONCE,
- SMS_ALERT_LOW_PRIORITY_REPEAT,
- SMS_ALERT_MEDIUM_PRIORITY_ONCE,
- SMS_ALERT_MEDIUM_PRIORITY_REPEAT,
- SMS_ALERT_HIGH_PRIORITY_ONCE,
- SMS_ALERT_HIGH_PRIORITY_REPEAT,
- SMS_ALERT_RESERVED
-} sms_alert_option_t;
-
-
-typedef enum _sms_language_type_e {
- SMS_LAN_UNKNOWN,
- SMS_LAN_ENGLISH,
- SMS_LAN_FRENCH,
- SMS_LAN_SPANISH,
- SMS_LAN_JAPANESE,
- SMS_LAN_KOREAN,
- SMS_LAN_CHINESE,
- SMS_LAN_HEBREW,
-} sms_language_type_t;
-
-
-typedef enum _sms_priority_indicator_e {
- SMS_PRIORITY_NORMAL = 0x00,
- SMS_PRIORITY_INTERACTIVE,
- SMS_PRIORITY_URGENT,
- SMS_PRIORITY_EMERGENCY
-} sms_priority_indicator_t;
-
-
-typedef enum _sms_privacy_indicator_e {
- SMS_PRIVACY_NOT_RESTRICTED = 0x00,
- SMS_PRIVACY_RESTRICTED,
- SMS_PRIVACY_CONFIDENTIAL,
- SMS_PRIVACY_SECRET
-} sms_privacy_indicator_t;
-
-
-typedef enum _sms_alert_priority_e {
- SMS_ALERT_MOBILE_DEFAULT = 0x00,
- SMS_ALERT_LOW_PRIORITY,
- SMS_ALERT_MEDIUM_PRIORITY,
- SMS_ALERT_HIGH_PRIORITY
-} sms_alert_priority_t;
-
-
-typedef enum _sms_display_mode_e {
- SMS_DISPLAY_IMMEDIATE = 0x00,
- SMS_DISPLAY_DEFAULT_SETTING,
- SMS_DISPLAY_USER_INVOKE,
- SMS_DISPLAY_RESERVED
-} sms_display_mode_t;
-
-
-typedef enum _sms_encoding_type_e {
- SMS_ENCODE_OCTET = 0x0,
- SMS_ENCODE_EPM = 0x1, /*IS-91 Extended Protocol Message*/
- SMS_ENCODE_7BIT_ASCII = 0x2,
- SMS_ENCODE_IA5 = 0x3,
- SMS_ENCODE_UNICODE = 0x4,
- SMS_ENCODE_SHIFT_JIS = 0x5,
- SMS_ENCODE_KOREAN = 0x6,
- SMS_ENCODE_LATIN_HEBREW = 0x7,
- SMS_ENCODE_LATIN = 0x8,
- SMS_ENCODE_GSM7BIT = 0x9,
- SMS_ENCODE_GSMDCS = 0xa,
- SMS_ENCODE_EUCKR = 0x10,
- SMS_ENCODE_RESERVED
-} sms_encoding_type_t;
-
-
-typedef enum _sms_relative_time_e {
- SMS_REL_TIME_5_MINS = 0,
- SMS_REL_TIME_12_HOURS = 143,
- SMS_REL_TIME_1_DAY = 167,
- SMS_REL_TIME_2_DAYS = 168,
- SMS_REL_TIME_3_DAYS = 169,
- SMS_REL_TIME_1_WEEK = 173,
- SMS_REL_TIME_INDEFINITE = 245,
- SMS_REL_TIME_IMMEDIATE = 246,
- SMS_REL_TIME_ACTIVE = 247,
- SMS_REL_TIME_REGISTRATION = 248,
- SMS_REL_TIME_RESERVED
-} sms_relative_time_t;
-
-
-typedef enum _sms_status_code_e {
- /* ERROR_CLASS = '00' (no error) */
- SMS_STATUS_ACCEPTED = 0x00,
- SMS_STATUS_DEPOSITED = 0x01,
- SMS_STATUS_DELIVERED = 0x02,
- SMS_STATUS_CANCELLED = 0x03,
-
- /* ERROR_CLASS = '10' (temporary condition) */
- SMS_STATUS_TEMP_NETWORK_CONGESTION = 0x84,
- SMS_STATUS_TEMP_NETWORK_ERROR = 0x85,
- SMS_STATUS_TEMP_UNKNOWN_ERROR = 0x9F,
-
- /* ERROR_CLASS = '11' (permanent condition) */
- SMS_STATUS_PERMANENT_NETWORK_CONGESTION = 0xC4,
- SMS_STATUS_PERMANENT_NETWORK_ERROR = 0xC5,
- SMS_STATUS_PERMANENT_CANCEL_FAILED = 0xC6,
- SMS_STATUS_PERMANENT_BLOCKED_DESTINATION = 0xC7,
- SMS_STATUS_PERMANENT_TEXT_TOO_LONG = 0xC8,
- SMS_STATUS_PERMANENT_DUPLICATE_MESSAGE = 0xC9,
- SMS_STATUS_PERMANENT_INVALID_DESTINATION = 0xCA,
- SMS_STATUS_PERMANENT_MESSAGE_EXPIRED = 0xCD,
- SMS_STATUS_PERMANENT_UNKNOWN_ERROR = 0xDF,
-} sms_status_code_t;
-
-
-typedef enum _sms_cmae_category_e {
- SMS_CMAE_CTG_GEO = 0x00,
- SMS_CMAE_CTG_MET = 0x01,
- SMS_CMAE_CTG_SAFETY = 0x02,
- SMS_CMAE_CTG_SECURITY = 0x03,
- SMS_CMAE_CTG_RESCUE = 0x04,
- SMS_CMAE_CTG_FIRE = 0x05,
- SMS_CMAE_CTG_HEALTH = 0x06,
- SMS_CMAE_CTG_ENV = 0x07,
- SMS_CMAE_CTG_TRANSPORT = 0x08,
- SMS_CMAE_CTG_INFRA = 0x09,
- SMS_CMAE_CTG_CBRNE = 0x0a,
- SMS_CMAE_CTG_OTHER = 0x0b,
- SMS_CMAE_CTG_RESERVED,
-} sms_cmae_category_t;
-
-
-typedef enum _sms_cmae_response_type_e {
- SMS_CMAE_RESP_TYPE_SHELTER = 0x00,
- SMS_CMAE_RESP_TYPE_EVACUATE = 0x01,
- SMS_CMAE_RESP_TYPE_PREPARE = 0x02,
- SMS_CMAE_RESP_TYPE_EXECUTE = 0x03,
- SMS_CMAE_RESP_TYPE_MONITOR = 0x04,
- SMS_CMAE_RESP_TYPE_AVOID = 0x05,
- SMS_CMAE_RESP_TYPE_ASSESS = 0x06,
- SMS_CMAE_RESP_TYPE_NONE = 0x07,
- SMS_CMAE_RESP_TYPE_RESERVED,
-} sms_cmae_response_type_t;
-
-
-typedef enum _sms_cmae_severity_e {
- SMS_CMAE_SEVERITY_EXTREME = 0x0,
- SMS_CMAE_SEVERITY_SEVERE = 0x1,
- SMS_CMAE_SEVERITY_RESERVED,
-} sms_cmae_severity_t;
-
-
-typedef enum _sms_cmae_urgency_e {
- SMS_CMAE_URGENCY_IMMEDIATE = 0x0,
- SMS_CMAE_URGENCY_EXPECTED = 0x1,
- SMS_CMAE_URGENCY_RESERVED,
-} sms_cmae_urgency_t;
-
-
-typedef enum _sms_cmae_certainty_e {
- SMS_CMAE_CERTAINTY_OBSERVED = 0x0,
- SMS_CMAE_CERTAINTY_LIKELY = 0x1,
- SMS_CMAE_CERTAINTY_RESERVED,
-} sms_cmae_certainty_t;
-
-
-typedef enum _sms_cmae_alert_handle_e {
- SMS_CMAE_ALERT_PRESIDENTIAL = 0x00,
- SMS_CMAE_ALERT_EXTREME = 0x01,
- SMS_CMAE_ALERT_SEVERE = 0x02,
- SMS_CMAE_ALERT_AMBER = 0x03,
- SMS_CMAE_ALERT_RESERVED,
-} sms_cmae_alert_handle_t;
-
-
-enum _sms_bearer_sub_param_e {
- SMS_BEARER_MESSAGE_IDENTIFIER = 0x00,
- SMS_BEARER_USER_DATA = 0x01,
- SMS_BEARER_USER_RESPONSE_CODE = 0x02,
- SMS_BEARER_MSG_CENTER_TIME_STAMP = 0x03,
- SMS_BEARER_VALIDITY_PERIOD_ABSOLUTE = 0x04,
- SMS_BEARER_VALIDITY_PERIOD_RELATIVE = 0x05,
- SMS_BEARER_DEFERRED_DELIVERY_TIME_ABSOLUTE = 0x06,
- SMS_BEARER_DEFERRED_DELIVERY_TIME_RELATIVE = 0x07,
- SMS_BEARER_PRIORITY_INDICATOR = 0x08,
- SMS_BEARER_PRIVACY_INDICATOR = 0x09,
- SMS_BEARER_REPLY_OPTION = 0x0A,
- SMS_BEARER_NUMBER_OF_MESSAGES = 0x0B,
- SMS_BEARER_ALERT_ON_MSG_DELIVERY = 0x0C,
- SMS_BEARER_LANGUAGE_INDICATOR = 0x0D,
- SMS_BEARER_CALLBACK_NUMBER = 0x0E,
- SMS_BEARER_MSG_DISPLAY_MODE = 0x0F,
- SMS_BEARER_MULTI_ENCODING_USER_DATA = 0x10,
- SMS_BEARER_MSG_DEPOSIT_INDEX = 0x11,
- SMS_BEARER_SVC_CATEGORY_PROGRAM_DATA = 0x12,
- SMS_BEARER_SVC_CATEGORY_PROGRAM_RESULT = 0x13,
- SMS_BEARER_MESSAGE_STATUS = 0x14,
- SMS_BEARER_TP_FAILURE_CAUSE = 0x15,
- SMS_BEARER_ENHANCED_VMN = 0x16,
- SMS_BEARER_ENHANCED_VMN_ACK = 0x17,
- SMS_BEARER_MAX_VALUE
-};
-
-
-enum _sms_svc_ctg_result_e {
- SMS_SVC_RESULT_SUCCESS = 0x00,
- SMS_SVC_RESULT_MEMORY_LIMIT_EXCEEDED,
- SMS_SVC_RESULT_LIMIT_EXCEEDED,
- SMS_SVC_RESULT_ALREADY_PROGRAMMED,
- SMS_SVC_RESULT_NOT_PREVIOUSLY_PROGRAMMED,
- SMS_SVC_RESULT_INVALID_MAX_MESSAGES,
- SMS_SVC_RESULT_INVALID_ALERT_OPTION,
- SMS_SVC_RESULT_INVALID_SVC_CTG_NAME,
- SMS_SVC_RESULT_INSPECIFIED_PROGRAMMING_FAILURE,
- SMS_SVC_RESULT_RESERVED
-};
-
-
-enum _SMS_TIME_FORMAT_E {
- SMS_TIME_EMPTY = 0,
- SMS_TIME_RELATIVE ,
- SMS_TIME_ABSOLUTE
-};
-
-
-enum _sms_tp_failure_cause_e {
- /* 0x00 ~ 0x7f reserved */
- SMS_TP_CAUSE_RESERVED,
-
- /* 0x80 ~ 0x8f TP-PID errors */
- SMS_TP_CAUSE_TELEMATIC_INTERWORKING_NOT_SUPPORTED = 0x80,
- SMS_TP_CAUSE_SHORT_MSG_TYPE_0_NOT_SUPPORTED = 0x81,
- SMS_TP_CAUSE_CANNOT_REPLACE_SHORT_MSG = 0x82,
- SMS_TP_CAUSE_UNSPECIFIED_TP_PID_ERROR = 0x8f,
-
- /* 0x90 ~ 0x9f TP-DCS errors */
- SMS_TP_CAUSE_DCS_NOT_SPPORTED = 0x90,
- SMS_TP_CAUSE_MSG_CLASS_NOT_SUPPORTED = 0x91,
- SMS_TP_CAUSE_UNSPECIFIED_TP_DCS_ERROR = 0x9f,
-
- /* 0xa0 ~ 0xaf TP-Command Errors */
- SMS_TP_CAUSE_CMD_CANNOT_BE_ACTIONED = 0xa0,
- SMS_TP_CAUSE_CMD_UNSUPPORTED = 0xa1,
- SMS_TP_CAUSE_UNSPECIFIED_TP_CMD_ERROR = 0xaf,
-
- SMS_TP_CAUSE_TPDU_NOT_SUPPORTED = 0xb0,
-
- SMS_TP_CAUSE_SC_BUSY = 0xc0,
- SMS_TP_CAUSE_NO_SC_SUBCRIPTION = 0xc1,
- SMS_TP_CAUSE_SC_SYSTEM_FAILURE = 0xc2,
- SMS_TP_CAUSE_INVALID_SME_ADDRESS = 0xc3,
- SMS_TP_CAUSE_DESTINATION_SME_BARRED = 0xc4,
- SMS_TP_CAUSE_SM_REJECTED_DUPLICATE_SM = 0xc5,
- SMS_TP_CAUSE_TP_VPF_NOT_SUPPORTED = 0xc6,
- SMS_TP_CAUSE_TP_VP_NOT_SUPPORTED = 0xc7,
-
- SMS_TP_CAUSE_SIM_SMS_STORAGE_FULL = 0xd0,
- SMS_TP_CAUSE_NO_SMS_STORAGE_CAPABILITY_IN_SIM = 0xd1,
- SMS_TP_CAUSE_ERROR_IN_MS = 0xd2,
- SMS_TP_CAUSE_MEMORY_CAPACITY_EXCEEDED = 0xd3,
- SMS_TP_CAUSE_SIM_APPLICATION_TOOLKIT_BUSY = 0xd4,
- SMS_TP_CAUSE_SIM_DATA_DOWNLOAD_ERROR = 0xd5,
-
- /* 0xe0 ~ 0xfe Values specific to an application */
- SMS_TP_CAUSE_SPECIFIC_TO_APPLICATION_MIN = 0xe0,
- SMS_TP_CAUSE_SPECIFIC_TO_APPLICATION_MAX = 0xfe,
-
- SMS_TP_CAUSE_UNSPECIFIED_ERROR_CAUSE = 0xff
-};
-
-
-typedef struct _sms_trans_msg_id_s {
- unsigned short msg_id;
- bool header_ind;
-} sms_trans_msg_id_s;
-
-
-typedef struct _sms_telesvc_addr_s {
- sms_digit_mode_t digit_mode;
- sms_number_type_t number_type;
- sms_number_plan_t number_plan;
- unsigned int addr_len;
- char szData[SMS_TRANS_ADDRESS_MAX_LEN + 1];
-} sms_telesvc_addr_s;
-
-
-typedef struct _sms_reply_option_s {
- bool user_ack_req;
- bool deliver_ack_req;
- bool read_ack_req;
- bool report_req;
-} sms_reply_option_s;
-
-
-typedef struct _sms_time_relative_s {
- sms_relative_time_t rel_time;
-} sms_time_rel_s;
-
-typedef struct _sms_time_stamp_s {
- unsigned char year; /* range 00-99 (96~99 : 19xx, 00~95 : 20xx) */
- unsigned char month; /* range 1-12 */
- unsigned char day;
- unsigned char hours; /* range 0-23 */
- unsigned char minutes; /* range 0-59 */
- unsigned char seconds; /* range 0-59 */
-} sms_time_abs_s;
-
-
-typedef struct _sms_val_period_s {
- unsigned char format;
- union {
- sms_time_rel_s rel_time;
- sms_time_abs_s abs_time;
- } time;
-} sms_val_period_s;
-
-
-typedef struct _sms_encoding_specific_s {
- sms_encoding_type_t encode_type;
- unsigned int data_len;
- char user_data[SMS_MAX_USER_DATA_LEN +1];
-} sms_encoding_specific_s;
-
-
-typedef struct _sms_ctg_specific_s {
- unsigned char operation_code;
- unsigned short category;
- sms_language_type_t language;
- unsigned char max_msg;
- sms_alert_option_t alert_option;
- unsigned int data_len;
- char user_data[SMS_MAX_USER_DATA_LEN +1];
-} sms_ctg_specific_s;
-
-
-typedef struct _sms_svc_ctg_program_data_s {
- sms_encoding_type_t encode_type;
- unsigned int num_data;
- sms_ctg_specific_s *specific_data;
-} sms_svc_ctg_program_data_s;
-
-
-typedef struct _sms_telesvc_userdata_s {
- sms_encoding_type_t encode_type;
- unsigned char msg_type;
- unsigned int data_len;
- unsigned char user_data[SMS_MAX_USER_DATA_LEN +1];
-} sms_telesvc_userdata_s;
-
-
-typedef struct _sms_telesvc_cmasdata_s {
- unsigned int data_len;
- sms_encoding_type_t encode_type;
- unsigned char alert_text[SMS_MAX_USER_DATA_LEN +1];
- sms_cmae_category_t category;
- sms_cmae_response_type_t response_type;
- sms_cmae_severity_t severity;
- sms_cmae_urgency_t urgency;
- sms_cmae_certainty_t certainty;
- unsigned short id;
- sms_cmae_alert_handle_t alert_handle; /* 00:Presidential 01:Extreme 02:Severe 03:AMBER 04:Test */
- sms_time_abs_s expires;
- sms_language_type_t language;
- bool is_wrong_recode_type;
-} sms_telesvc_cmasdata_s;
-
-
-typedef struct _sms_enhanced_vmn_s {
- sms_priority_indicator_t priority;
- bool password_req;
- bool setup_req;
- bool pw_change_req;
- unsigned char min_pw_len;
- unsigned char max_pw_len;
- unsigned char vm_num_unheard_msg;
- bool vm_mailbox_alm_full;
- bool vm_mailbox_full;
- bool reply_allowed;
- bool fax_included;
- unsigned short vm_len;
- unsigned char vm_ret_day;
- unsigned short vm_msg_id;
- unsigned short vm_mailbox_id;
-
- sms_digit_mode_t an_digit_mode;
- sms_number_type_t an_number_type;
- sms_number_plan_t an_number_plan;
- unsigned char an_num_field;
- unsigned char an_char[SMS_MAX_USER_DATA_LEN+1];
-
- sms_digit_mode_t cli_digit_mode;
- sms_number_type_t cli_number_type;
- sms_number_plan_t cli_number_plan;
- unsigned char cli_num_field;
- unsigned char cli_char[SMS_MAX_USER_DATA_LEN+1];
-} sms_enhanced_vmn_s;
-
-
-typedef struct _sms_enhanced_vmn_ack_s {
- unsigned short vm_mailbox_id;
- unsigned char vm_num_unheard_msg;
- unsigned char num_delete_ack;
- unsigned char num_play_ack;
-
- unsigned short da_vm_msg_id[SMS_MAX_NUMBER_OF_ACK+1];
- unsigned short pa_vm_msg_id[SMS_MAX_NUMBER_OF_ACK+1];
-} sms_enhanced_vmn_ack_s;
-
-
-typedef struct _sms_telesvc_deliver_s {
- sms_trans_msg_id_s msg_id;
- sms_telesvc_userdata_s user_data;
- sms_telesvc_cmasdata_s cmas_data;
- sms_time_abs_s time_stamp;
- sms_val_period_s val_period;
- sms_val_period_s defer_val_period;
- sms_priority_indicator_t priority;
- sms_privacy_indicator_t privacy;
- sms_reply_option_s reply_opt;
- unsigned int num_msg;
- sms_alert_priority_t alert_priority;
- sms_language_type_t language;
- sms_telesvc_addr_s callback_number;
- sms_display_mode_t display_mode;
- sms_encoding_specific_s multi_encode_data;
- unsigned short deposit_id;
- /* sms_svc_ctg_program_data_s svc_ctg; */
- sms_enhanced_vmn_s enhanced_vmn;
- sms_enhanced_vmn_ack_s enhanced_vmn_ack;
-} sms_telesvc_deliver_s;
-
-
-typedef struct _sms_telesvc_submit_s {
- sms_trans_msg_id_s msg_id;
- sms_telesvc_userdata_s user_data;
- sms_val_period_s val_period;
- sms_val_period_s defer_val_period;
- sms_priority_indicator_t priority;
- sms_privacy_indicator_t privacy;
- sms_reply_option_s reply_opt;
- sms_alert_priority_t alert_priority;
- sms_language_type_t language;
- sms_telesvc_addr_s callback_number;
- sms_encoding_specific_s multi_encode_data;
- unsigned char deposit_id;
- /* sms_svc_ctg_program_data_s svc_ctg; */
-} sms_telesvc_submit_s;
-
-
-typedef struct _sms_telesvc_cancel_s {
- sms_trans_msg_id_s msg_id;
-} sms_telesvc_cancel_s;
-
-
-typedef struct _sms_telesvc_user_ack_s {
- sms_trans_msg_id_s msg_id;
- sms_telesvc_userdata_s user_data;
- unsigned char resp_code;
- sms_time_abs_s time_stamp;
- sms_encoding_specific_s multi_encode_data;
- unsigned char deposit_id;
-} sms_telesvc_user_ack_s;
-
-
-typedef struct _sms_telesvc_deliver_ack_s {
- sms_trans_msg_id_s msg_id;
- sms_telesvc_userdata_s user_data;
- sms_time_abs_s time_stamp;
- sms_encoding_specific_s multi_encode_data;
- sms_status_code_t msg_status;
-} sms_telesvc_deliver_ack_s;
-
-
-typedef struct _sms_telesvc_read_ack_s {
- sms_trans_msg_id_s msg_id;
- sms_telesvc_userdata_s user_data;
- sms_time_abs_s time_stamp;
- sms_encoding_specific_s multi_encode_data;
- unsigned char deposit_id;
-} sms_telesvc_read_ack_s;
-
-typedef struct _sms_telesvc_deliver_report_s {
- sms_trans_msg_id_s msg_id;
- unsigned char tp_fail_cause;
- sms_telesvc_userdata_s user_data;
- sms_language_type_t language;
- unsigned char multi_encode_data;
-} sms_telesvc_report_s;
-
-
-typedef struct _sms_telesvc_msg_s {
- sms_message_type_t type;
-
- union {
- sms_telesvc_deliver_s deliver;
- sms_telesvc_submit_s submit;
- sms_telesvc_cancel_s cancel;
- sms_telesvc_user_ack_s user_ack;
- sms_telesvc_deliver_ack_s delivery_ack;
- sms_telesvc_read_ack_s read_ack;
- sms_telesvc_report_s report;
- } data;
-} sms_telesvc_msg_s;
-
-
-
-/********************************************************************************/
-/* TRANSPORT LAYER */
-/********************************************************************************/
-
-typedef unsigned short sms_trans_param_id_t; /* _sms_trans_param_id_e */
-
-typedef unsigned short sms_trans_telesvc_id_t; /* _sms_trans_telesvc_id_e */
-
-typedef unsigned short sms_trans_svc_ctg_t; /* _sms_trans_svc_ctg_e */
-
-typedef unsigned char sms_trans_reply_seq_t;
-
-
-typedef enum _sms_trans_msg_type_e {
- SMS_TRANS_P2P_MSG = 0x00,
- SMS_TRANS_BROADCAST_MSG = 0x01,
- SMS_TRANS_ACK_MSG = 0x02,
- SMS_TRANS_TYPE_RESERVED
-} sms_trans_msg_type_t;
-
-
-enum _sms_trans_param_id_e {
- SMS_TRANS_PARAM_TELESVC_IDENTIFIER = 0x00,
- SMS_TRANS_PARAM_SERVICE_CATEGORY = 0x01,
- SMS_TRANS_PARAM_ORG_ADDRESS = 0x02,
- SMS_TRANS_PARAM_ORG_SUB_ADDRESS = 0x02,
- SMS_TRANS_PARAM_DEST_ADDRESS = 0x04,
- SMS_TRANS_PARAM_DEST_SUB_ADDRESS = 0x05,
- SMS_TRANS_PARAM_BEARER_REPLY_OPTION = 0x06,
- SMS_TRANS_PARAM_CAUSE_CODES = 0x07,
- SMS_TRANS_PARAM_BEARER_DATA = 0x08,
- SMS_TRANS_PARAM_RESERVED
-};
-
-
-enum _sms_trans_telesvc_id_e {
- SMS_TRANS_TELESVC_CMT_91 = 0x1000, /* IS-91 Extended Protocol Enhanced Services */
- SMS_TRANS_TELESVC_CPT_95 = 0x1001, /* Wireless Paging Teleservice */
- SMS_TRANS_TELESVC_CMT_95 = 0x1002, /* Wireless Messaging Teleservice */
- SMS_TRANS_TELESVC_VMN_95 = 0x1003, /* Voice Mail Notification */
- SMS_TRANS_TELESVC_WAP = 0x1004, /* Wireless Application Protocol */
- SMS_TRANS_TELESVC_WEMT = 0x1005, /* Wireless Enhanced Messaging Teleservice */
- SMS_TRANS_TELESVC_SCPT = 0x1006, /* Service Category Programming Teleservice */
- SMS_TRANS_TELESVC_CATPT = 0x1007, /* Card Application Toolkit Protocol Teleservice */
- SMS_TRANS_TELESVC_RESERVED = 0xffff
-};
-
-
-enum _sms_trans_svc_ctg_e {
- SMS_TRANS_SVC_CTG_UNKNOWN = 0x0000,
- SMS_TRANS_SVC_CTG_EMERGENCY = 0x0001,
- SMS_TRANS_SVC_CTG_ADMINISTRATIVE = 0x0002,
- SMS_TRANS_SVC_CTG_MAINTENANCE = 0x0003,
- SMS_TRANS_SVC_CTG_GNEWS_LOCAL = 0x0004,
- SMS_TRANS_SVC_CTG_GNEWS_REGIONAL = 0x0005,
- SMS_TRANS_SVC_CTG_GNEWS_NATIONAL = 0x0006,
- SMS_TRANS_SVC_CTG_GNEWS_INTERNATIONAL = 0x0007,
- SMS_TRANS_SVC_CTG_BFNEWS_LOCAL = 0x0008,
- SMS_TRANS_SVC_CTG_BFNEWS_REGIONAL = 0x0009,
- SMS_TRANS_SVC_CTG_BFNEWS_NATIONAL = 0x000a,
- SMS_TRANS_SVC_CTG_BFNEWS_INTERNATIONAL = 0x000b,
- SMS_TRANS_SVC_CTG_SNEWS_LOCAL = 0x000c,
- SMS_TRANS_SVC_CTG_SNEWS_REGIONAL = 0x000d,
- SMS_TRANS_SVC_CTG_SNEWS_NATIONAL = 0x000e,
- SMS_TRANS_SVC_CTG_SNEWS_INTERNATIONAL = 0x000f,
- SMS_TRANS_SVC_CTG_ENEWS_LOCAL = 0x0010,
- SMS_TRANS_SVC_CTG_ENEWS_REGIONAL = 0x0011,
- SMS_TRANS_SVC_CTG_ENEWS_NATIONAL = 0x0012,
- SMS_TRANS_SVC_CTG_ENEWS_INTERNATIONAL = 0x0013,
- SMS_TRANS_SVC_CTG_LOCAL_WEATHER = 0x0014,
- SMS_TRANS_SVC_CTG_TRAFFIC_REPORTS = 0x0015,
- SMS_TRANS_SVC_CTG_FLIGHT_SCHEDULES = 0x0016,
- SMS_TRANS_SVC_CTG_RESTAURANTS = 0x0017,
- SMS_TRANS_SVC_CTG_LODGINGS = 0x0018,
- SMS_TRANS_SVC_CTG_RETAIL_DIRECTORY = 0x0019,
- SMS_TRANS_SVC_CTG_ADVERTISEMENTS = 0x001a,
- SMS_TRANS_SVC_CTG_STOCK_QUOTES = 0x001b,
- SMS_TRANS_SVC_CTG_EMPLOYMENT = 0x001c,
- SMS_TRANS_SVC_CTG_MEDICAL = 0x001d,
- SMS_TRANS_SVC_CTG_TECHNOLOGY_NEWS = 0x001e,
- SMS_TRANS_SVC_CTG_MULTI_CTG = 0x001f,
- SMS_TRANS_SVC_CTG_CATPT = 0x0020,
- SMS_TRANS_SVC_CTG_KDDI_CORP_MIN1 = 0x0021,
- SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1 = 0x003f,
- SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL = 0x1000,
- SMS_TRANS_SVC_CTG_CMAS_EXTREME = 0x1001,
- SMS_TRANS_SVC_CTG_CMAS_SEVERE = 0x1002,
- SMS_TRANS_SVC_CTG_CMAS_AMBER = 0x1003,
- SMS_TRANS_SVC_CTG_CMAS_TEST = 0x1004,
- SMS_TRANS_SVC_CTG_KDDI_CORP_MIN2 = 0x8001,
- SMS_TRANS_SVC_CTG_KDDI_CORP_MAX2 = 0x803f,
- SMS_TRANS_SVC_CTG_KDDI_CORP_MIN3 = 0xc001,
- SMS_TRANS_SVC_CTG_KDDI_CORP_MAX3 = 0xc03f,
- SMS_TRANS_SVC_CTG_RESERVED,
- SMS_TRANS_SVC_CTG_UNDEFINED = 0x8001,
-};
-
-
-typedef enum _sms_trans_err_class_e {
- SMS_TRANS_ERR_CLASS_NONE = 0x00,
- SMS_TRANS_ERR_CLASS_TEMPORARY = 0x02,
- SMS_TRANS_ERR_CLASS_PERMANENT = 0x03
-} sms_trans_err_class_t;
-
-
-typedef enum _sms_trans_cause_code_e {
- SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID = 0x04,
- SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED = 0x62,
- SMS_TODO_FILL_THIS_ENUMS
-} sms_trans_cause_code_t;
-
-
-typedef enum _sms_trans_sub_addr_type_e {
- SMS_TRANS_SUB_ADDR_NSAP = 0x00,
- SMS_TRANS_SUB_ADDR_USER = 0x01,
- SMS_TRANS_SUB_ADDR_RESERVED
-} sms_trans_sub_addr_type_t;
-
-
-
-enum _sms_trans_dnet_addr_type_e {
- SMS_TRANS_DNET_UNKNOWN = 0x00,
- SMS_TRANS_DNET_INTERNET_PROTOCOL = 0x01,
- SMS_TRANS_DNET_INTERNET_MAIL_ADDR = 0x02,
- SMS_TRANS_DNET_RESERVED
-};
-
-
-enum _sms_digit_mode_e {
- SMS_DIGIT_4BIT_DTMF = 0,
- SMS_DIGIT_8BIT = 1
-};
-
-
-enum _sms_number_mode_e {
- SMS_NUMBER_MODE_NONE_DATANETWORK = 0,
- SMS_NUMBER_MODE_DATANETWORK = 1, /*using data network address format*/
-};
-
-
-enum _sms_dnet_number_type_e {
- SMS_ADDRESS_TYPE_UNKNOWN = 0x00,
- SMS_ADDRESS_TYPE_INTERNET_PROTOCOL = 0x01,
- SMS_ADDRESS_TYPE_EMAIL_ADDRESS = 0x02,
-};
-
-
-enum _sms_number_type_e {
- SMS_NUMBER_TYPE_UNKNOWN = 0x00,
- SMS_NUMBER_TYPE_INTERNATIONAL = 0x01,
- SMS_NUMBER_TYPE_NATIONAL = 0x02,
- SMS_NUMBER_TYPE_NETWORK_SPECIFIC = 0x03,
- SMS_NUMBER_TYPE_SUBSCRIBER = 0x04,
- SMS_NUMBER_TYPE_RESERVED_5 = 0x05,
- SMS_NUMBER_TYPE_ABBREVIATED = 0x06,
- SMS_NUMBER_TYPE_RESERVED_7 = 0x07,
-/*
- * TODO : check this type is valid or not
- * SMS_NUMBER_TYPE_IP = 0x11,
- * SMS_NUMBER_TYPE_EMAILADDR = 0x12,
- */
-};
-
-
-enum _sms_number_plan_e {
- SMS_NPI_UNKNOWN = 0,
- SMS_NPI_ISDN = 1,
- SMS_NPI_DATA = 3,
- SMS_NPI_TELEX = 4,
- SMS_NPI_PRIVATE = 9,
- SMS_NPI_RESERVED = 15,
-};
-
-
-typedef struct _sms_trans_addr_s {
- sms_digit_mode_t digit_mode;
- sms_number_mode_t number_mode;
- sms_number_type_t number_type;
- sms_number_plan_t number_plan;
- unsigned int addr_len;
- char szData[SMS_TRANS_ADDRESS_MAX_LEN + 1];
-} sms_trans_addr_s;
-
-
-typedef struct _sms_trans_sub_addr_s {
- sms_trans_sub_addr_type_t type;
- bool odd;
- unsigned int addr_len;
- char szData[SMS_TRANS_ADDRESS_MAX_LEN + 1];
-} sms_trans_sub_addr_s;
-
-
-typedef struct _sms_trans_cause_code_s {
- sms_trans_reply_seq_t reply_seq;
- sms_trans_err_class_t error_class;
- sms_trans_cause_code_t cause_code;
-} sms_trans_cause_code_s;
-
-
-typedef struct _sms_trans_p2p_msg_s {
- sms_trans_telesvc_id_t telesvc_id;
- sms_trans_svc_ctg_t svc_ctg;
- sms_trans_addr_s address;
- sms_trans_sub_addr_s sub_address;
- sms_trans_reply_seq_t reply_seq;
- sms_telesvc_msg_s telesvc_msg;
-} sms_trans_p2p_msg_s;
-
-
-typedef struct _sms_trans_broadcast_msg_s {
- sms_trans_svc_ctg_t svc_ctg;
- sms_telesvc_msg_s telesvc_msg;
-} sms_trans_broadcast_msg_s;
-
-
-typedef struct _sms_trans_ack_msg_s {
- sms_trans_addr_s address;
- sms_trans_sub_addr_s sub_address;
- sms_trans_cause_code_s cause_code;
-} sms_trans_ack_msg_s;
-
-
-typedef struct _sms_trans_msg_s {
- sms_trans_msg_type_t type;
- union {
- sms_trans_p2p_msg_s p2p_msg;
- sms_trans_broadcast_msg_s cb_msg;
- sms_trans_ack_msg_s ack_msg;
- } data;
-} sms_trans_msg_s;
-
-
-#endif /* SMS_CDMA_PLUGIN_TYPES_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_UA_MANAGER_H
-#define SMS_CDMA_PLUGIN_UA_MANAGER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-#include "MsgQueue.h"
-#include "MsgThread.h"
-#include "SmsCdmaPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginUAManager : public MsgThread
-{
-public:
- static SmsPluginUAManager* instance();
-
- /* virtual void start(); */
-
- void addReqEntity(sms_request_info_s *request);
-
-private:
- SmsPluginUAManager();
- ~SmsPluginUAManager();
- void lock() { mx.lock(); };
- void unlock() { mx.unlock(); };
- void wait() { cv.wait(mx.pMsgMutex()); };
- void signal() { cv.signal(); };
-
- virtual void run();
-
- static SmsPluginUAManager* pInstance;
-
- bool bRunning;
-
- MsgSimpleQ <sms_request_info_s> smsTranQ;
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_CDMA_PLUGIN_UA_MANAGER_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_CDMA_PLUGIN_WAPPUSH_HANDLER_H
-#define SMS_CDMA_PLUGIN_WAPPUSH_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include <wbxml/wbxml.h>
-#include <libxml/parser.h>
-
-
-#include "SmsCdmaPluginTypes.h"
-
-
-/*==================================================================================================
- DEFINES
-==================================================================================================*/
-#define WSP_STANDARD_STR_LEN_MAX 255
-#define LENGTH_QUOTE 0x1F
-#define NO_VALUE 0x00
-
-#define WSP_CODE_BUFFER_LEFT_LEN_MAX 1024
-#define WSP_CODE_BUFFER_RIGHT_LEN_MAX 2048
-
-#define AcStrlen(x) ((x == NULL) ? 0 : strlen(x))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginWapPushHandler
-{
-public:
- static SmsPluginWapPushHandler* instance();
-
- /* void registerPushCallback(); */
- bool IsWapPushMsg(unsigned short dstport);
-
- void copyDeliverData(sms_trans_addr_s *pAddr);
- void handleWapPushMsg(const char *pUserData, int DataSize);
- void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen);
-
-private:
- SmsPluginWapPushHandler();
- virtual ~SmsPluginWapPushHandler();
-
- static SmsPluginWapPushHandler* pInstance;
-
- sms_wap_app_code_t getAppCode(const char *pPushHeader);
-
- void handleMMSNotification(const char *pPushBody, int PushBodyLen);
- void handleSIMessage(char* pPushBody, int PushBodyLen, bool isText);
- void handleSLMessage(char* pPushBody, int PushBodyLen, bool isText);
- void handleCOMessage(char* pPushBody, int PushBodyLen, bool isText);
- void handleDrmVer1(char* pPushBody, int PushBodyLen);
- void getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText);
- void createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo);
- unsigned long convertXmlCharToSec(char* pDate);
- msg_push_action_t convertSIActionStrToEnum(char* pAction);
- msg_push_action_t convertSLActionStrToEnum(char* pAction);
-
- unsigned long wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer);
- unsigned long wspDecodeUintvar(unsigned long length, unsigned char* userVar);
- void wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader);
- unsigned long wspHeaderDecodeInteger(unsigned char* data);
- void wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString);
- unsigned long wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length);
- char* wspExtendedDecodeType(char contentType);
- void wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam);
- void wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString);
- void wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString);
- void wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString);
- void wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper);
- void wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
- void wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
- void wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString);
-
-
- sms_trans_addr_s tmpAddress;
- /* SMS_TIMESTAMP_S tmpTimeStamp; */
-};
-
-#endif /* SmsPluginWapPushHandler */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <time.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilStorage.h"
+#include "Sms3gppUDCodec.h"
+#include "SmsPluginStorage.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppCbMsgHandler.h"
+#include "SmsPluginDSHandler.h"
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppCbMsgHandler - Member Functions
+==================================================================================================*/
+Sms3gppCbMsgHandler* Sms3gppCbMsgHandler::pInstance = NULL;
+
+
+
+Sms3gppCbMsgHandler::Sms3gppCbMsgHandler()
+{
+ pageList.clear();
+}
+
+
+Sms3gppCbMsgHandler::~Sms3gppCbMsgHandler()
+{
+}
+
+
+Sms3gppCbMsgHandler* Sms3gppCbMsgHandler::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppCbMsgHandler();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gppCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMsg)
+{
+ MSG_BEGIN();
+
+#if 0
+ char temp[1000]= {0x01, 0xa4, 0x1f, 0x51, 0x10, 0x11, 0x02, 0xea, 0x30, 0x30, 0xa8, 0x30, 0xea, 0x30, 0xa2, 0x30, 0xe1, 0x30, 0xfc, 0x30, 0xeb, 0x91, 0x4d, 0x4f, 0xe1, 0x30, 0xc6, 0x30, 0xb9, 0x30, 0xc8, 0x00, 0x0d, 0x00, 0x0a, 0x30, 0x53, 0x30, 0x8c, 0x30, 0x6f, 0x8a, 0x66, 0x9a, 0x13, 0x75, 0x28, 0x30, 0x6e, 0x30, 0xe1, 0x30, 0xc3, 0x30, 0xbb, 0x30, 0xfc, 0x30, 0xb8, 0x30, 0x67, 0x30, 0x59, 0x30, 0x02, 0x00, 0x0d, 0x00, 0x0a, 0xff, 0x08, 0x00, 0x32, 0x00, 0x30, 0x00, 0x31, 0x00, 0x33, 0x00, 0x2f, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2f, 0x00, 0x32, 0x52, 0xea, 0x30, 0x00, 0x37, 0x00, 0x20, 0x00, 0x31, 0x00, 0x35, 0x00, 0x3a, 0x00, 0x34, 0x00, 0x34, 0xff, 0x09, 0x00, 0x0d, 0x00, 0x0a, 0xff, 0x08, 0x30, 0xa8, 0x30, 0xea, 0x30, 0xa2, 0x5e, 0x02, 0xff, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22};
+ TelSmsEtwsMsg_t *pCbMsg = (TelSmsEtwsMsg_t *)calloc(1, sizeof(TelSmsEtwsMsg_t));
+ pCbMsg->Length = 173;
+ pCbMsg->EtwsMsgType = (TelSmsEtwsMsgType_t)2;
+ memcpy(pCbMsg->szMsgData, temp, pCbMsg->Length);
+
+ SMS_CB_NETWORK_TYPE_T type = pCbMsg->EtwsMsgType;
+ SMS_CBMSG_PAGE_S CbMsgPage = {0};
+
+ switch (type) {
+ case SMS_CB_NETWORK_TYPE_2G_GSM :
+ Decode2gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
+ break;
+
+ case SMS_CB_NETWORK_TYPE_3G_UMTS :
+ Decode3gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
+ break;
+ }
+#else
+ SMS_3GPP_CB_NETWORK_TYPE_T type = pCbMsg->CbMsgType;
+ SMS_3GPP_CBMSG_PAGE_S CbMsgPage = {0};
+
+ switch (type) {
+ case SMS_CB_NETWORK_TYPE_2G_GSM :
+ Decode2gCbMsg(pCbMsg, &CbMsgPage);
+ break;
+
+ case SMS_CB_NETWORK_TYPE_3G_UMTS :
+ Decode3gCbMsg(pCbMsg, &CbMsgPage);
+ break;
+ }
+#endif
+ /* Check CB Msg Options */
+ bool bJavaMsg = false;
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (!checkCbOpt(&CbMsgPage, &bJavaMsg, simIndex)) {
+ MSG_ERR("Received CB Msg is not supported by option.");
+ return;
+ }
+
+ if (bJavaMsg == true) {
+ MSG_DEBUG("JAVA CB Msg.");
+ CbMsgPage.cbMsgType = SMS_CBMSG_TYPE_JAVACBS;
+ }
+
+ /* Check CB Pages */
+ unsigned char pageCnt = checkCbPage(&CbMsgPage);
+ if (pageCnt == CbMsgPage.pageHeader.totalPages) {
+ MSG_DEBUG("RECEIVED LAST MSG : %d", pageCnt);
+
+ SMS_3GPP_CBMSG_S *cbMsg = NULL;
+ unique_ptr<SMS_3GPP_CBMSG_S*, void(*)(SMS_3GPP_CBMSG_S**)> buf(&cbMsg, unique_ptr_deleter);
+ cbMsg = (SMS_3GPP_CBMSG_S *)new char[sizeof(SMS_3GPP_CBMSG_S)];
+ memset(cbMsg, 0x00, sizeof(SMS_3GPP_CBMSG_S));
+
+ MSG_MESSAGE_INFO_S msgInfo;
+
+ /** initialize msgInfo */
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ /* Make CB Msg Structure */
+ MakeCbMsg(&CbMsgPage, cbMsg);
+
+ /* Convert to MSG_MESSAGE_INFO_S */
+ convertCbMsgToMsginfo(cbMsg, &msgInfo, simIndex);
+
+ /* Add CB Msg into DB */
+ msg_error_t err = MSG_SUCCESS;
+
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ if (err == MSG_SUCCESS) {
+ bool is_duplicated = SmsPluginStorage::instance()->isDuplicatedCBMsg(&msgInfo);
+ if (is_duplicated == false) {
+ MSG_CB_MSG_S cbOutMsg = {0, };
+
+ /*cbOutMsg.type = MSG_CB_SMS; */
+ cbOutMsg.type = msgInfo.msgType.subType;
+ cbOutMsg.receivedTime = cbMsg->recvTime;
+ cbOutMsg.serialNum = cbMsg->serialNum;
+ cbOutMsg.messageId = cbMsg->msgId;
+ cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData;
+ memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText));
+
+ cbOutMsg.cbTextLen = convertTextToUtf8((unsigned char*)cbOutMsg.cbText, sizeof(cbOutMsg.cbText), cbMsg);
+ memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type));
+ memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3);
+ err = Sms3gppEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, &msgInfo);
+ if (err != MSG_SUCCESS)
+ MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
+ } else {
+ MSG_DEBUG("This cb message is duplicated");
+ }
+ } else {
+ MSG_WARN("checkMessage() Error !! [%d]", err);
+ }
+
+#if 0
+ /* insert message-id to internal CB message table */
+ Sms3gppStorage *storageHandler = Sms3gppStorage::instance();
+ err = storageHandler->insertReceivedCBMessage(CbMsgPage);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("insertReceivedCBMessage() Error !! [%d]", err);
+ }
+#endif
+ /* Remove From List */
+ removeFromPageList(&CbMsgPage);
+ }
+ MSG_END();
+}
+
+
+void Sms3gppCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *pEtwsMsg)
+{
+ MSG_BEGIN();
+ msg_error_t err = MSG_SUCCESS;
+ TelSmsEtwsMsgType_t type = pEtwsMsg->EtwsMsgType;
+ SMS_3GPP_ETWS_PRIMARY_S etwsPn = {0, };
+ MSG_CB_MSG_S cbOutMsg = {0, };
+
+ if (type != TAPI_NETTEXT_ETWS_PRIMARY) {
+ MSG_DEBUG("The Etws secondary Message");
+ handleCbMsg(handle, (TelSmsCbMsg_t *)pEtwsMsg);
+ return;
+ }
+
+ DecodeEtwsMsg(pEtwsMsg, &etwsPn);
+
+ cbOutMsg.type = MSG_ETWS_SMS;
+ cbOutMsg.receivedTime = etwsPn.recvTime;
+ cbOutMsg.serialNum = encodeCbSerialNum(etwsPn.serialNum);
+ cbOutMsg.messageId = etwsPn.msgId;
+ cbOutMsg.etwsWarningType = etwsPn.warningType;
+ memcpy (cbOutMsg.etwsWarningSecurityInfo, etwsPn.warningSecurityInfo, sizeof(cbOutMsg.etwsWarningSecurityInfo));
+
+ err = Sms3gppEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, NULL);
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+
+ MSG_END();
+}
+
+
+void Sms3gppCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_3GPP_CBMSG_PAGE_S *pCbPage)
+{
+ unsigned char cbData[pCbMsg->Length+1] = {0};
+ memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
+ cbData[pCbMsg->Length] = '\0';
+
+ /* print cb data */
+ MSG_INFO("Received CB length:%d", pCbMsg->Length);
+ char cbDataTmp[(pCbMsg->Length*2)+1];
+ memset(cbDataTmp, 0x00, sizeof(cbDataTmp));
+
+ for (int i = 0; i < pCbMsg->Length; i++) {
+ snprintf(cbDataTmp+(i*2), sizeof(cbDataTmp)-(i*2), "%02X", cbData[i]);
+ }
+ MSG_INFO("[%s]", cbDataTmp);
+
+ pCbPage->cbMsgType = SMS_CBMSG_TYPE_CBS;
+
+ /* Serial Number */
+ pCbPage->pageHeader.serialNum.geoScope = (cbData[0] & 0xC0) >> 6;
+
+ pCbPage->pageHeader.serialNum.msgCode = (cbData[0] & 0x3F) << 4;
+ pCbPage->pageHeader.serialNum.msgCode |= (cbData[1] & 0xF0) >> 4;
+
+ pCbPage->pageHeader.serialNum.updateNum = cbData[1] & 0x0F;
+
+ MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
+
+ pCbPage->pageHeader.msgId = (cbData[2] << 8) | cbData[3];
+
+ MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
+
+ /* DCS */
+ decodeCbMsgDCS(cbData[4], (unsigned char*)cbData + 6, &(pCbPage->pageHeader.dcs));
+
+ /* Page Parameter */
+ pCbPage->pageHeader.totalPages = cbData[5] & 0x0F;
+ pCbPage->pageHeader.page = (cbData[5] & 0xF0) >> 4;
+
+ if (pCbPage->pageHeader.totalPages > MAX_CBMSG_PAGE_NUM)
+ THROW(MsgException::SMS_PLG_ERROR, "CB Page Count is over MAX[%d]", pCbPage->pageHeader.totalPages);
+
+ MSG_DEBUG("Total Page : [%d], Page : [%d]", pCbPage->pageHeader.totalPages, pCbPage->pageHeader.page);
+
+ /* Convert Language Type */
+ convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
+
+ MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
+ MSG_DEBUG("iso639Lang : [%s]", pCbPage->pageHeader.dcs.iso639Lang);
+ /* Get Receive Time */
+ pCbPage->pageHeader.recvTime = getRecvTime();
+
+ /* Decode CB Data */
+ int dataLen = pCbMsg->Length - 6;
+
+ MSG_DEBUG("codingScheme:[%d]", pCbPage->pageHeader.dcs.codingScheme);
+
+ switch (pCbPage->pageHeader.dcs.codingScheme) {
+ case SMS_CHARSET_7BIT: {
+ MSG_DEBUG("GSM 7 BIT");
+
+ dataLen = (dataLen*8) / 7;
+
+ Sms3gppUDCodec udCodec;
+ char pageData[MAX_CBMSG_PAGE_SIZE*8/7] = {0};
+ int unpackLen = udCodec.unpack7bitChar(&cbData[6], dataLen, 0, pageData);
+
+ if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+ unpackLen = unpackLen - 3;
+ if (unpackLen > 0)
+ memcpy(pCbPage->pageData, &pageData[3], unpackLen);
+ else
+ unpackLen = 0;
+ } else {
+ memcpy(pCbPage->pageData, &pageData, unpackLen);
+ }
+
+ MSG_DEBUG("unpackLen : [%d]", unpackLen);
+
+ pCbPage->pageLength = unpackLen;
+ pCbPage->pageData[unpackLen] = '\0';
+ }
+ break;
+
+ case SMS_CHARSET_8BIT:
+ case SMS_CHARSET_UCS2: {
+ MSG_DEBUG("UCS2 or 8BIT");
+
+ if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+ memcpy(pCbPage->pageData, &cbData[8], dataLen - 2);
+ pCbPage->pageLength = dataLen - 2;
+ } else {
+ memcpy(pCbPage->pageData, &cbData[6], dataLen);
+ pCbPage->pageLength = dataLen;
+ }
+ }
+ break;
+ }
+
+ MSG_DEBUG("Page Length : [%d], Page Data : [%s]", pCbPage->pageLength, pCbPage->pageData);
+}
+
+
+void Sms3gppCbMsgHandler::DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_3GPP_ETWS_PRIMARY_S *pEtwsPn)
+{
+ if ( !pEtwsMsg || !pEtwsPn )
+ return;
+
+ if (pEtwsMsg->Length > MAX_ETWS_SIZE)
+ THROW(MsgException::SMS_PLG_ERROR, "ETWS Msg Size is over MAX [%d]", pEtwsMsg->Length);
+
+ unsigned char EtwsData[pEtwsMsg->Length+1];
+
+ memset(EtwsData, 0x00, sizeof(EtwsData));
+ memcpy(EtwsData, pEtwsMsg->szMsgData, pEtwsMsg->Length);
+ EtwsData[pEtwsMsg->Length] = '\0';
+
+ /* print received msg data */
+ MSG_INFO("Received Etws length:%d", pEtwsMsg->Length);
+ char EtwsDataTmp[(pEtwsMsg->Length*2)+1];
+ memset(EtwsDataTmp, 0x00, sizeof(EtwsDataTmp));
+
+ for (int i = 0; i < pEtwsMsg->Length; i++) {
+ snprintf(EtwsDataTmp+(i*2), sizeof(EtwsDataTmp)-(i*2), "%02X", EtwsData[i]);
+ }
+ MSG_INFO("[%s]", EtwsDataTmp);
+
+ /* received time */
+ pEtwsPn->recvTime = getRecvTime();
+
+ /* Serial Number */
+ pEtwsPn->serialNum.geoScope = (EtwsData[0] & 0xC0) >> 6;
+ pEtwsPn->serialNum.msgCode = (EtwsData[0] & 0x3F) << 4;
+ pEtwsPn->serialNum.msgCode |= (EtwsData[1] & 0xF0) >> 4;
+ pEtwsPn->serialNum.updateNum = EtwsData[1] & 0x0F;
+
+ MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pEtwsPn->serialNum.geoScope, pEtwsPn->serialNum.msgCode, pEtwsPn->serialNum.updateNum);
+
+ /* Message Identifier */
+ pEtwsPn->msgId = (EtwsData[2] << 8) | EtwsData[3];
+ MSG_DEBUG("MSG ID : [%d]", pEtwsPn->msgId);
+
+ /* warning type */
+ pEtwsPn->warningType = (EtwsData[4] << 8) | EtwsData[5];
+ MSG_DEBUG("warningType : [0x%04x]", pEtwsPn->msgId);
+
+ /* warning security information */
+ memcpy(pEtwsPn->warningSecurityInfo, &EtwsData[6], sizeof(pEtwsPn->warningSecurityInfo)); /* 50bytes */
+ for (unsigned int i = 0; i < sizeof(pEtwsPn->warningSecurityInfo); i++) {
+ MSG_DEBUG("warning secu info [%02x]", pEtwsPn->warningSecurityInfo[i]);
+ }
+}
+
+void Sms3gppCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_3GPP_CBMSG_PAGE_S *pCbPage)
+{
+ unsigned char cbData[MAX_CBMSG_TOTAL_PAGE_SIZE + 1] = {0};
+ memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
+ cbData[pCbMsg->Length] = '\0';
+
+ /* print cb data */
+ MSG_INFO("Received CB length:%d", pCbMsg->Length);
+ char cbDataTmp[(pCbMsg->Length*2)+1];
+ memset(cbDataTmp, 0x00, sizeof(cbDataTmp));
+
+ for (int i = 0; i < pCbMsg->Length; i++) {
+ snprintf(cbDataTmp+(i*2), sizeof(cbDataTmp)-(i*2), "%02X", cbData[i]);
+ }
+ MSG_INFO("[%s]", cbDataTmp);
+
+ pCbPage->cbMsgType = (SMS_3GPP_CBMSG_TYPE_T)cbData[0];
+
+ pCbPage->pageHeader.msgId = (cbData[1] << 8) | cbData[2];
+
+ MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
+
+ /* Serial Number */
+ pCbPage->pageHeader.serialNum.geoScope = (cbData[3] & 0xC0) >> 6;
+
+ pCbPage->pageHeader.serialNum.msgCode = (cbData[3] & 0x3F) << 4;
+ pCbPage->pageHeader.serialNum.msgCode |= (cbData[4] & 0xF0) >> 4;
+
+ pCbPage->pageHeader.serialNum.updateNum = cbData[4] & 0x0F;
+
+ MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
+
+ /* DCS */
+ decodeCbMsgDCS(cbData[5], (unsigned char*)cbData + 6, &(pCbPage->pageHeader.dcs));
+
+ /* Convert Language Type */
+ convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
+
+ MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
+
+ /* Get Receive Time */
+ pCbPage->pageHeader.recvTime = getRecvTime();
+ pCbPage->pageHeader.totalPages = cbData[6];
+
+ /* Decode CB Data */
+ int dataLen = 0;
+ int offset = 0;
+
+ switch (pCbPage->pageHeader.dcs.codingScheme) {
+ case SMS_CHARSET_7BIT: {
+ for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
+ unsigned char cbMessage[MAX_CBMSG_PAGE_SIZE] = {0};
+ dataLen = cbData[7 + (i + 1) * MAX_CBMSG_PAGE_SIZE + i];
+
+ if (dataLen > MAX_CBMSG_PAGE_SIZE)
+ THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", dataLen);
+
+ memcpy(cbMessage, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
+ dataLen = (dataLen*8) / 7;
+
+ Sms3gppUDCodec udCodec;
+ int unpackLen = udCodec.unpack7bitChar((const unsigned char *)cbMessage, dataLen, 0, pCbPage->pageData + offset);
+ offset += unpackLen;
+ }
+ pCbPage->pageLength = offset;
+ }
+ break;
+
+ case SMS_CHARSET_8BIT:
+ case SMS_CHARSET_UCS2: {
+#if 0
+ char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0, };
+
+ for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
+ dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i];
+ memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
+ offset += dataLen;
+ }
+ dataLen = offset;
+
+ if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+ int tmpDataLen = (dataLen > 2)?(dataLen - 2):0;
+ memcpy(pCbPage->pageData, cbMessage + 2, tmpDataLen);
+ pCbPage->pageLength = tmpDataLen;
+ } else {
+ memcpy(pCbPage->pageData, cbMessage, dataLen);
+ pCbPage->pageLength = dataLen;
+ }
+#else
+ char cbMessage[MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM+1] = {0, };
+
+ for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
+ if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
+ dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i] - 2;
+ if (dataLen > 0) {
+ memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i + 2], dataLen);
+ offset += dataLen;
+ }
+ } else {
+ dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i];
+ if (dataLen > 0) {
+ memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
+ offset += dataLen;
+ }
+ }
+ }
+ dataLen = offset;
+ memcpy(pCbPage->pageData, cbMessage, dataLen);
+ pCbPage->pageLength = dataLen;
+#endif
+ }
+ break;
+ }
+ pCbPage->pageHeader.totalPages = 1;
+
+ MSG_DEBUG("Page Length : [%d], Page Data : [%s]", pCbPage->pageLength, pCbPage->pageData);
+}
+
+unsigned short Sms3gppCbMsgHandler::encodeCbSerialNum(SMS_3GPP_CBMSG_SERIAL_NUM_S snFields)
+{
+ unsigned short serialNum = 0;
+
+ serialNum = ((snFields.geoScope & 0x03) << 14) | ((snFields.msgCode&0x03FF) << 4) | (snFields.updateNum&0x0F);
+ MSG_DEBUG("serialNum (%x), geo(%x), mc(%x), un(%x)\n", serialNum, snFields.geoScope, snFields.msgCode, snFields.updateNum);
+
+ return serialNum;
+}
+
+int Sms3gppCbMsgHandler::getCMASType(unsigned short message_id)
+{
+ int ret = 0;
+
+ switch (message_id) {
+ case 4370:
+ ret = MSG_CMAS_PRESIDENTIAL;
+ break;
+ case 4383:
+ ret = MSG_CMAS_PRESIDENTIAL_OTHER_LANG;
+ break;
+ case 4371:
+ case 4372:
+ ret = MSG_CMAS_EXTREME;
+ break;
+ case 4384:
+ case 4385:
+ ret = MSG_CMAS_EXTREME_OTHER_LANG;
+ break;
+ case 4373:
+ case 4374:
+ case 4375:
+ case 4376:
+ case 4377:
+ case 4378:
+ ret = MSG_CMAS_SEVERE;
+ break;
+ case 4386:
+ case 4387:
+ case 4388:
+ case 4389:
+ case 4390:
+ case 4391:
+ ret = MSG_CMAS_SEVERE_OTHER_LANG;
+ break;
+ case 4379:
+ ret = MSG_CMAS_AMBER;
+ break;
+ case 4392:
+ ret = MSG_CMAS_AMBER_OTHER_LANG;
+ break;
+ case 4380:
+ ret = MSG_CMAS_TEST;
+ break;
+ case 4393:
+ ret = MSG_CMAS_TEST_OTHER_LANG;
+ break;
+ case 4381:
+ ret = MSG_CMAS_EXERCISE;
+ break;
+ case 4394:
+ ret = MSG_CMAS_EXERCISE_OTHER_LANG;
+ break;
+ case 4382:
+ ret = MSG_CMAS_OPERATOR_DEFINED;
+ break;
+ case 4395:
+ ret = MSG_CMAS_OPERATOR_DEFINED_OTHER_LANG;
+ break;
+ case 4396:
+ ret = MSG_CMAS_PUBLIC_SAFETY;
+ break;
+ case 4397:
+ ret = MSG_CMAS_PUBLIC_SAFETY_OTHER_LANG;
+ break;
+ case 4398:
+ ret = MSG_CMAS_STATE_LOCAL_TEST;
+ break;
+ case 4399:
+ ret = MSG_CMAS_STATE_LOCAL_TEST_OTHER_LANG;
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+bool Sms3gppCbMsgHandler::checkCbOpt(SMS_3GPP_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex)
+{
+ bool bReceive = false;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex);
+ if (MsgSettingGetBool(keyName, &bReceive) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ /* Receive CB Msg = FALSE */
+ if (!bReceive) {
+ MSG_DEBUG("RECEIVE CB = FALSE");
+ return false;
+ }
+
+#if 0
+ char keyname[128];
+ /* check Language */
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyname), "%s/%d", CB_LANGUAGE, MSG_CBLANG_TYPE_ALL);
+
+ bool bAllLang = false;
+ if (MsgSettingGetBool(keyName, &bAllLang) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ if (!bAllLang) {
+ MSG_DEBUG("ALL LANGUAGE = FALSE");
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyname), "%s/%d", CB_LANGUAGE, CbPage.pageHeader.langType);
+
+ bool bLang = false;
+
+ if (MsgSettingGetBool(keyName, &bLang) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ if (!bLang || CbPage.pageHeader.langType == MSG_CBLANG_TYPE_MAX) {
+ MSG_DEBUG("LANGUAGE [%d] = FALSE", CbPage.pageHeader.langType);
+ return false;
+ }
+ }
+#endif
+
+ bool bActivate = false;
+ int MsgId_from = 0, MsgId_to = 0;
+ MSG_CB_CHANNEL_S cbChannelInfo = {0, };
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo, simIndex);
+ if (err != MSG_SUCCESS)
+ MSG_ERR("Error value of MsgStoGetCBChannelInfo [%d]", err);
+
+ for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
+ bActivate = cbChannelInfo.channelInfo[i].bActivate;
+ MsgId_from = cbChannelInfo.channelInfo[i].from;
+ MsgId_to = cbChannelInfo.channelInfo[i].to;
+
+ if (bActivate == true && CbPage->pageHeader.msgId >= MsgId_from && CbPage->pageHeader.msgId <= MsgId_to) {
+ MSG_DEBUG("FIND CHANNEL = [%d]", CbPage->pageHeader.msgId);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+unsigned char Sms3gppCbMsgHandler::checkCbPage(SMS_3GPP_CBMSG_PAGE_S *CbPage)
+{
+ unsigned char currPageCnt = 0;
+
+ bool bFind = false;
+
+#if 0
+ msg_error_t err = MSG_SUCCESS;
+
+ Sms3gppStorage *storageHandler = Sms3gppStorage::instance();
+ err = storageHandler->isReceivedCBMessage(CbPage);
+
+ /* check existing message with cb internal table; */
+ if (err != MSG_ERR_DB_NORECORD) {
+ MSG_DEBUG("already received message: [%d]", CbPage.pageHeader.msgId);
+ return 0;
+ }
+#endif
+
+ if (CbPage->pageHeader.totalPages > 0) {
+ for (unsigned int i = 0; i < pageList.size(); i++) {
+ if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) {
+ MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
+
+ if (pageList[i].msgId == CbPage->pageHeader.msgId) {
+ int updateNum = CbPage->pageHeader.serialNum.updateNum - pageList[i].updateNum;
+
+ if (updateNum > 0) { /* New Message Content */
+ break;
+ } else if (updateNum == 0) { /* Same Message Content */
+ if (pageList[i].data.count(CbPage->pageHeader.page) != 0) {
+ MSG_DEBUG("The Page Number already exists [%d]", CbPage->pageHeader.page);
+ return 0;
+ }
+
+ pair<unsigned char, SMS_3GPP_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage);
+ pageList[i].data.insert(newData);
+
+ MSG_DEBUG("PAGE DATA : %s", CbPage->pageData);
+ MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData);
+
+ pageList[i].pageCnt++;
+ pageList[i].totalSize += CbPage->pageLength;
+
+ currPageCnt = pageList[i].pageCnt;
+
+ bFind = true;
+
+ break;
+ } else { /* Old Message Content */
+ return 0;
+ }
+ }
+ }
+ }
+ }
+
+ if (bFind == false || CbPage->pageHeader.totalPages == 1) {
+ addToPageList(CbPage);
+ return 1;
+ }
+
+ return currPageCnt;
+}
+
+
+void Sms3gppCbMsgHandler::MakeCbMsg(SMS_3GPP_CBMSG_PAGE_S *CbPage, SMS_3GPP_CBMSG_S *pCbMsg)
+{
+ pCbMsg->cbMsgType = CbPage->cbMsgType;
+ pCbMsg->msgId = CbPage->pageHeader.msgId;
+ pCbMsg->classType = CbPage->pageHeader.dcs.classType;
+ pCbMsg->codingScheme = CbPage->pageHeader.dcs.codingScheme;
+ pCbMsg->recvTime = CbPage->pageHeader.recvTime;
+ pCbMsg->serialNum = encodeCbSerialNum(CbPage->pageHeader.serialNum);
+
+ Sms3gppCbPageMap::iterator it;
+ int offset = 0;
+
+ for (unsigned int i = 0; i < pageList.size(); i++) {
+ if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) {
+ MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
+
+ if (pageList[i].msgId == CbPage->pageHeader.msgId) {
+ for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++) {
+ memcpy(pCbMsg->msgData + offset, it->second.pageData, it->second.pageLength);
+ pCbMsg->msgLength += it->second.pageLength;
+ offset = pCbMsg->msgLength;
+ }
+ }
+ }
+ }
+
+#if 0
+ pCbMsg->msgLength = tmpStr.size();
+
+ memcpy(pCbMsg->msgData, tmpStr.c_str(), tmpStr.size());
+ pCbMsg->msgData[tmpStr.size()] = '\0';
+
+ MSG_DEBUG("SIZE : [%d] TOTAL MSG : %s", tmpStr.size(), tmpStr.c_str());
+#endif
+}
+
+
+void Sms3gppCbMsgHandler::convertCbMsgToMsginfo(SMS_3GPP_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex)
+{
+ pMsgInfo->msgId = (msg_message_id_t)pCbMsg->msgId;
+ pMsgInfo->serialNum = pCbMsg->serialNum;
+
+ pMsgInfo->folderId = MSG_CBMSGBOX_ID;
+
+ /* Convert Type values */
+ pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+
+ if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_CBS) {
+ int cmas_Type = getCMASType(pCbMsg->msgId);
+
+ if (cmas_Type == 0)
+ pMsgInfo->msgType.subType = MSG_CB_SMS;
+ else
+ pMsgInfo->msgType.subType = (MSG_SUB_TYPE_T)cmas_Type;
+ } else if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_JAVACBS) {
+ pMsgInfo->msgType.subType = MSG_JAVACB_SMS;
+ }
+
+ switch (pCbMsg->classType) {
+ case SMS_MSG_CLASS_0:
+ pMsgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ pMsgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ pMsgInfo->msgType.classType = MSG_CLASS_2;
+ break;
+ case SMS_MSG_CLASS_3:
+ pMsgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+ break;
+ }
+
+ pMsgInfo->storageId = MSG_STORAGE_PHONE;
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+ /* Temporary */
+ pMsgInfo->nAddressCnt = 1;
+
+ pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+ pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
+ pMsgInfo->sim_idx = simIndex;
+
+ /* TODO :: MSG ID should be used to get CB message type */
+ getDisplayName(pCbMsg->msgId, pMsgInfo->addressList[0].addressVal, simIndex);
+ MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
+
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+
+ pMsgInfo->displayTime = pCbMsg->recvTime;
+ MSG_DEBUG("recvTime is %ld", pMsgInfo->displayTime);
+
+ int bufSize = pCbMsg->msgLength*2;
+
+ char tmpBuf[bufSize];
+ memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+ while (pCbMsg->msgLength > 0) {
+ if (pCbMsg->msgData[pCbMsg->msgLength-1] == ' ' ||
+ pCbMsg->msgData[pCbMsg->msgLength-1] == '\r' ||
+ pCbMsg->msgData[pCbMsg->msgLength-1] == '\n') {
+ pCbMsg->msgLength--;
+ } else {
+ break;
+ }
+ }
+ pCbMsg->msgData[pCbMsg->msgLength] = '\0';
+
+ MSG_DEBUG("LENGTH %d CB MSG %s", pCbMsg->msgLength, pCbMsg->msgData);
+
+ /* Convert Data values */
+ pMsgInfo->dataSize = convertTextToUtf8((unsigned char*)tmpBuf, bufSize, pCbMsg);
+
+ if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
+ pMsgInfo->bTextSms = false;
+
+ /* Save Message Data into File */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+ MSG_SEC_DEBUG("Save Message Data into file : size[%zu] name[%s]\n", pMsgInfo->dataSize, fileName);
+ if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+ strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+ } else {
+ pMsgInfo->bTextSms = true;
+
+ memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
+ memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
+ pMsgInfo->dataSize = strlen(pMsgInfo->msgText);
+ MSG_SEC_DEBUG("CB MSG %s", pMsgInfo->msgText);
+ }
+}
+
+
+void Sms3gppCbMsgHandler::convertEtwsMsgToMsginfo(SMS_3GPP_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex)
+{
+ pMsgInfo->msgId = (msg_message_id_t)EtwsMsg->pageHeader.msgId;
+
+ pMsgInfo->folderId = MSG_CBMSGBOX_ID;
+
+ /* Convert Type values */
+ pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+
+ if (EtwsMsg->cbMsgType == SMS_CBMSG_TYPE_ETWS)
+ pMsgInfo->msgType.subType = MSG_ETWS_SMS;
+
+ pMsgInfo->storageId = MSG_STORAGE_PHONE;
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+ /* Temporary */
+ pMsgInfo->nAddressCnt = 1;
+
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+ pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
+
+ getDisplayName(EtwsMsg->pageHeader.msgId, pMsgInfo->addressList[0].addressVal, simIndex);
+ MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+
+ pMsgInfo->displayTime = EtwsMsg->pageHeader.recvTime;
+ MSG_DEBUG("recvTime is %ld", pMsgInfo->displayTime);
+ MSG_DEBUG("LENGTH %d", EtwsMsg->pageLength);
+ pMsgInfo->bTextSms = true;
+ pMsgInfo->dataSize = EtwsMsg->pageLength;
+ memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
+ memcpy(pMsgInfo->msgData, EtwsMsg->pageData, pMsgInfo->dataSize);
+}
+
+
+int Sms3gppCbMsgHandler::convertTextToUtf8(unsigned char* outBuf, int outBufSize, SMS_3GPP_CBMSG_S* pCbMsg)
+{
+ int convertedTextSize = 0;
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+
+ if (!outBuf || !pCbMsg) {
+ MSG_DEBUG("invalid param.\n");
+ return 0;
+ }
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+
+ /* Convert Data values */
+ if (pCbMsg->codingScheme == SMS_CHARSET_7BIT)
+ convertedTextSize = textCvt->convertGSM7bitToUTF8(outBuf, outBufSize, (unsigned char*)pCbMsg->msgData, pCbMsg->msgLength, &langInfo);
+ else if (pCbMsg->codingScheme == SMS_CHARSET_UCS2)
+ convertedTextSize = textCvt->convertUCS2ToUTF8(outBuf, outBufSize, (unsigned char*)pCbMsg->msgData, pCbMsg->msgLength);
+
+ return convertedTextSize;
+}
+
+
+void Sms3gppCbMsgHandler::addToPageList(SMS_3GPP_CBMSG_PAGE_S *CbPage)
+{
+ SMS_3GPP_CB_PAGE_INFO_S tmpInfo;
+
+ tmpInfo.geoScope = CbPage->pageHeader.serialNum.geoScope;
+ tmpInfo.msgCode = CbPage->pageHeader.serialNum.msgCode;
+ tmpInfo.updateNum = CbPage->pageHeader.serialNum.updateNum;
+ tmpInfo.msgId = CbPage->pageHeader.msgId;
+ tmpInfo.totalPages = CbPage->pageHeader.totalPages;
+
+ tmpInfo.pageCnt = 1;
+ tmpInfo.totalSize = CbPage->pageLength;
+
+ pair<unsigned char, SMS_3GPP_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage);
+ tmpInfo.data.insert(newData);
+
+ MSG_DEBUG("MSG DATA : %s", CbPage->pageData);
+ MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData);
+
+ pageList.push_back(tmpInfo);
+}
+
+
+void Sms3gppCbMsgHandler::removeFromPageList(SMS_3GPP_CBMSG_PAGE_S *CbPage)
+{
+ unsigned int index;
+
+ for (index = 0; index < pageList.size(); index++) {
+ if (pageList[index].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage->pageHeader.serialNum.msgCode) {
+ MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[index].geoScope, pageList[index].msgCode);
+
+ if (pageList[index].msgId == CbPage->pageHeader.msgId)
+ break;
+ }
+ }
+
+ MSG_DEBUG("remove index [%d]", index);
+
+ pageList.erase(pageList.begin()+index);
+}
+
+
+void Sms3gppCbMsgHandler::decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_3GPP_CBMSG_DCS_S* pDcs)
+{
+ pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+ pDcs->classType = SMS_MSG_CLASS_NONE;
+ pDcs->bCompressed = false;
+ pDcs->codingScheme = SMS_CHARSET_7BIT;
+ pDcs->langType = SMS_CBMSG_LANG_UNSPECIFIED;
+ memset(pDcs->iso639Lang, 0x00, sizeof(pDcs->iso639Lang));
+ pDcs->bUDH = false;
+ pDcs->rawData = dcsData;
+
+ unsigned char codingGrp = (dcsData & 0xF0) >> 4;
+
+ switch (codingGrp) {
+ case 0x00:
+ case 0x02:
+ case 0x03: {
+ pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+ pDcs->langType = (SMS_3GPP_CBMSG_LANG_TYPE_T)dcsData;
+ }
+ break;
+
+ case 0x01: {
+ if (dcsData == 0x10 || dcsData == 0x11) {
+ pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+ pDcs->codingScheme = (dcsData & 0x01) ? SMS_CHARSET_UCS2 : SMS_CHARSET_7BIT;
+ pDcs->langType = SMS_CBMSG_LANG_ISO639;
+ MSG_DEBUG("codingScheme: [%d]", pDcs->codingScheme);
+ if (pMsgData[0] && pMsgData[1]) {
+ pDcs->iso639Lang[0] = pMsgData[0] & 0x7F;
+ pDcs->iso639Lang[1] = (pMsgData[0] & 0X80) >> 7;
+ pDcs->iso639Lang[1] |= (pMsgData[1] & 0X3F) << 1;
+ pDcs->iso639Lang[2] = 0x13; /* CR */
+ } else {
+ /* Default it to English if pMsgData is NULL */
+ pDcs->iso639Lang[0] = 0x45; /* E */
+ pDcs->iso639Lang[1] = 0x4E; /* N */
+ pDcs->iso639Lang[2] = 0x13; /* CR */
+ }
+ }
+ }
+ break;
+
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07: {
+ pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
+
+ pDcs->bCompressed = (dcsData & 0x20) ? true : false;
+
+ if (dcsData & 0x10)
+ pDcs->classType = (SMS_3GPP_MSG_CLASS_T)(dcsData & 0x03);
+
+ unsigned char tmpScheme = (dcsData & 0x0C) >> 2;
+
+ switch (tmpScheme) {
+ case 0x00:
+ pDcs->codingScheme = SMS_CHARSET_7BIT;
+ break;
+ case 0x01:
+ pDcs->codingScheme = SMS_CHARSET_8BIT;
+ break;
+ case 0x02:
+ pDcs->codingScheme = SMS_CHARSET_UCS2;
+ break;
+ default:
+ MSG_DEBUG("tmpScheme: [%d]", tmpScheme);
+ break;
+ }
+ }
+ break;
+
+ case 0x09: {
+ pDcs->bUDH = true;
+ pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
+ pDcs->codingScheme = (SMS_3GPP_CODING_SCHEME_T)((dcsData & 0x0C) >> 2);
+ }
+ break;
+
+ case 0x0E: {
+ pDcs->codingGroup = SMS_CBMSG_CODGRP_WAP;
+ }
+ break;
+
+ case 0x0F: {
+ pDcs->codingGroup = SMS_CBMSG_CODGRP_CLASS_CODING;
+ pDcs->codingScheme = (dcsData & 0x04) ? SMS_CHARSET_8BIT : SMS_CHARSET_7BIT;
+ pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
+ }
+ break;
+ default:
+ MSG_DEBUG("codingGrp: [0x%x]", codingGrp);
+ break;
+ }
+}
+
+
+void Sms3gppCbMsgHandler::convertLangType(SMS_3GPP_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType)
+{
+ switch (InType) {
+ case SMS_CBMSG_LANG_GERMAN :
+ *pOutType = MSG_CBLANG_TYPE_GER;
+ break;
+
+ case SMS_CBMSG_LANG_ENGLISH :
+ *pOutType = MSG_CBLANG_TYPE_ENG;
+ break;
+
+ case SMS_CBMSG_LANG_ITALIAN :
+ *pOutType = MSG_CBLANG_TYPE_ITA;
+ break;
+
+ case SMS_CBMSG_LANG_FRENCH :
+ *pOutType = MSG_CBLANG_TYPE_FRE;
+ break;
+
+ case SMS_CBMSG_LANG_SPANISH :
+ *pOutType = MSG_CBLANG_TYPE_SPA;
+ break;
+
+ case SMS_CBMSG_LANG_DUTCH :
+ *pOutType = MSG_CBLANG_TYPE_NED;
+ break;
+
+ case SMS_CBMSG_LANG_SWEDISH :
+ *pOutType = MSG_CBLANG_TYPE_SWE;
+ break;
+
+ case SMS_CBMSG_LANG_PORTUGUESE :
+ *pOutType = MSG_CBLANG_TYPE_POR;
+ break;
+
+ case SMS_CBMSG_LANG_TURKISH :
+ *pOutType = MSG_CBLANG_TYPE_TUR;
+ break;
+
+ default :
+ *pOutType = MSG_CBLANG_TYPE_MAX;
+ break;
+ }
+}
+
+
+unsigned long Sms3gppCbMsgHandler::getRecvTime()
+{
+ time_t recvTime;
+
+ recvTime = time(NULL);
+
+ return (unsigned long)recvTime;
+}
+
+
+void Sms3gppCbMsgHandler::getDisplayName(unsigned short MsgId, char *pDisplayName, msg_sim_slot_id_t simIndex)
+{
+ MSG_CB_CHANNEL_S cbChannelInfo = {0, };
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo, simIndex);
+ MSG_DEBUG("MsgStoGetCBChannelInfo [err = %d]", err);
+
+ for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
+ if (MsgId >= cbChannelInfo.channelInfo[i].from && MsgId <= cbChannelInfo.channelInfo[i].to) {
+ MSG_DEBUG("FIND MSG ID = [%d]", MsgId);
+#if 0
+ char strTmp[CB_CHANNEL_NAME_MAX + 1];
+ memset(strTmp, 0x00, sizeof(strTmp));
+
+ strncpy(strTmp, cbChannelInfo.channelInfo[i].name, CB_CHANNEL_NAME_MAX);
+
+ if (strlen(strTmp) > 0)
+ snprintf(pDisplayName, sizeof(strTmp), "[%s]", strTmp);
+ else
+ snprintf(pDisplayName, sizeof(unsigned short), "[%d]", MsgId);
+#else
+
+#ifdef MSG_NOTI_INTEGRATION
+ snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "CB message");
+#else
+ snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId);
+#endif
+
+#endif
+ return;
+ }
+ }
+
+ snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId);
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include "MsgDebug.h"
+#include "MsgException.h"
+#include "MsgCppTypes.h"
+#include "MsgUtilFile.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "SmsPluginDSHandler.h"
+#include "SmsPluginStorage.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppWapPushHandler.h"
+#include "Sms3gppConcatHandler.h"
+#include "Sms3gppSimMsg.h"
+#include "Sms3gppParamCodec.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppConcatHandler - Member Functions
+==================================================================================================*/
+Sms3gppConcatHandler* Sms3gppConcatHandler::pInstance = NULL;
+
+
+Sms3gppConcatHandler::Sms3gppConcatHandler()
+{
+ concatList.clear();
+}
+
+
+Sms3gppConcatHandler::~Sms3gppConcatHandler()
+{
+ concatList.clear();
+}
+
+
+Sms3gppConcatHandler* Sms3gppConcatHandler::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppConcatHandler();
+ }
+
+ return pInstance;
+}
+
+
+bool Sms3gppConcatHandler::IsConcatMsg(SMS_3GPP_USERDATA_S *pUserData)
+{
+ MSG_BEGIN();
+
+ MSG_DEBUG("headerCnt [%d]", pUserData->headerCnt);
+
+ for (int i = 0; i < pUserData->headerCnt; i++) {
+ /** Handler Concatenated Message */
+ if (pUserData->header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+ return true;
+ } else if (pUserData->header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ return true;
+ }
+ }
+
+ MSG_END();
+
+ return false;
+}
+
+
+void Sms3gppConcatHandler::handleConcatMsg(TapiHandle *handle, SMS_3GPP_TPDU_S *pTpdu)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+ bool noneConcatTypeHeader = true;
+
+ if (pTpdu->tpduType != SMS_TPDU_DELIVER) {
+ MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
+ return;
+ }
+
+ SMS_3GPP_CONCAT_MSG_S msg = {0};
+
+ msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
+ if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
+ msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
+ msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
+
+ memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_3GPP_DCS_S));
+
+#if 0
+ if (msg.totalSeg > MAX_SEGMENT_NUM) {
+ MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+ return;
+ }
+#endif
+ /** check noneConcatTypeHeader */
+ noneConcatTypeHeader = false;
+
+ break;
+ } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
+ msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
+ msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
+
+ memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_3GPP_DCS_S));
+#if 0
+ if (msg.totalSeg > MAX_SEGMENT_NUM) {
+ MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+ return;
+ }
+#endif
+
+ /** check noneConcatTypeHeader */
+ noneConcatTypeHeader = false;
+
+ break;
+ }
+ }
+
+ unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
+
+ MSG_DEBUG("segCnt [%d]", segCnt);
+ MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
+
+ if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
+ MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
+
+ int dataSize = 0;
+ char* pUserData = NULL;
+ bool simSlotSizeOver = false;
+ unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
+
+ MSG_MESSAGE_INFO_S msgInfo = {0};
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+ msgInfo.sim_idx = msg.simIndex;
+
+ dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
+
+ if (dataSize > 0) {
+ if (Sms3gppWapPushHandler::instance()->IsWapPushMsg(&(pTpdu->data.deliver.userData)) == true) {
+ Sms3gppWapPushHandler::instance()->copyDeliverData(&(pTpdu->data.deliver));
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ if (err == MSG_SUCCESS) {
+ time_t sent_time = 0;
+ if (pTpdu->data.deliver.timeStamp.format == SMS_3GPP_TIME_ABSOLUTE) {
+ sent_time = time(NULL);
+ }
+ Sms3gppWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize, msg.simIndex, sent_time);
+ }
+ } else {
+ convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
+
+ if (msgInfo.msgType.classType == MSG_CLASS_2) {
+ msgInfo.storageId = MSG_STORAGE_SIM;
+ Sms3gppSimMsg::instance()->setSmsTpduTotalSegCount(msg.totalSeg);
+ }
+
+ if (msgInfo.msgPort.valid == true) {
+ if ((msgInfo.msgPort.dstPort >= 0x23F4 && msgInfo.msgPort.dstPort <= 0x23F7) || /** Check unsupported message (Vcalendar WAP push) **/
+ (msgInfo.msgPort.dstPort == 0x1581)) { /** Check unsupported message (ringtone smart message) **/
+ memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "<<Content not supported>>");
+ msgInfo.dataSize = strlen(msgInfo.msgText);
+ msgInfo.msgPort.valid = false;
+ }
+ }
+
+ if (msgInfo.msgPort.valid == false) {
+ /** Add Concat Msg into DB */
+
+ /* check Class2 Normal SMS is longer than SIM slot full size and send DeliveryReport SUCCESS because that Class2 msg cannot be saved on SIM
+ * It MUST be done before calling addClass2Message(thread) beause 10+ page message body ipc file is deleted after SmsPluginTransport::instance()->msgInfoToSubmitData() */
+ if (msgInfo.msgType.subType == MSG_NORMAL_SMS && msgInfo.msgType.classType == MSG_CLASS_2 &&
+ (Sms3gppSimMsg::instance()->checkSimMsgFull(msg.simIndex, segCnt) == true)) {
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, msg.simIndex);
+ int totalCnt = 0;
+ if (MsgSettingGetInt(keyName, &totalCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+
+ if (segCnt > totalCnt) {
+ /* send DeliveryResport as MSG_SUCCESS and return when total sim storage cnt is less than segment cnt. */
+ MSG_INFO("SIM slot total count [%d] is less than total sement count of Class2 message [%d], send delivery report as SUCCESS and save it only PHONE", totalCnt, segCnt);
+
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
+
+ MsgInsertTicker("Message is too large to store as a single message to SIM card.", SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE, false, 0);
+
+ simSlotSizeOver = true;
+ }
+ } else {
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ }
+ }
+
+ if (err == MSG_SUCCESS) {
+ if (simSlotSizeOver || (msgInfo.msgType.classType != MSG_CLASS_2)) {
+ if (simSlotSizeOver)
+ msgInfo.storageId = MSG_STORAGE_PHONE;
+
+ /** Callback */
+ err = Sms3gppEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+ if (err != MSG_SUCCESS) {
+ MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
+ }
+ }
+ } else {
+ MSG_DEBUG("addMessage() Error !! [%d]", err);
+ }
+ }
+ }
+
+ removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
+ }
+
+ /** Send Deliver Report */
+ Sms3gppTransport::instance()->sendDeliverReport(handle, err);
+
+ MSG_END();
+}
+
+void Sms3gppConcatHandler::handleSimConcatMsg(TapiHandle *handle, SMS_3GPP_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList)
+{
+ MSG_BEGIN();
+
+ bool noneConcatTypeHeader = true;
+
+ if (pTpdu->tpduType == SMS_TPDU_DELIVER) {
+ SMS_3GPP_CONCAT_MSG_S msg = {0};
+
+ msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
+ if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
+ msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
+ msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
+ msg.simId = msgId;
+ memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_3GPP_DCS_S));
+
+
+ /** check noneConcatTypeHeader */
+ noneConcatTypeHeader = false;
+
+ break;
+ } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
+ msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
+ msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
+ msg.simId = msgId;
+ memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_3GPP_DCS_S));
+
+ /** check noneConcatTypeHeader */
+ noneConcatTypeHeader = false;
+
+ break;
+ }
+ }
+
+ unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
+ MSG_DEBUG("segCnt [%d]", segCnt);
+ MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
+
+ if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
+ MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
+
+ int dataSize = 0;
+ char* pUserData = NULL;
+ unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
+
+ MSG_MESSAGE_INFO_S msgInfo = {0};
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+ msgInfo.sim_idx = msg.simIndex;
+
+ dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
+
+ if (dataSize > 0) {
+ convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
+ /* set Sim Message ID */
+ msgInfo.msgId = msgId;
+
+ /* set read status */
+ msgInfo.bRead = bRead;
+ /* set storage id */
+ msgInfo.storageId = MSG_STORAGE_SIM;
+ }
+ for (int index = concatList.size(); index >= 0 ; index--) {
+ if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex
+ && g_strcmp0(concatList[index].originAddress.address, msg.originAddress.address) == 0) {
+ memcpy(simIdList, concatList[index].simIdList, sizeof(int) * MAX_SIM_SMS_NUM);
+ for (int i = 0; i < 255; ++i) {
+ MSG_DEBUG("sim id [%d]", simIdList[i]);
+ }
+ break;
+ }
+ }
+ removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
+ /* Call Event Handler */
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
+ return;
+ }
+ /* Call Event Handler */
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ } else {
+ SMS_3GPP_CONCAT_MSG_S msg = {0};
+
+ msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ for (int i = 0; i < pTpdu->data.submit.userData.headerCnt; i++) {
+ if (pTpdu->data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.submit.userData.header[i].udh.concat8bit.msgRef;
+ msg.totalSeg = pTpdu->data.submit.userData.header[i].udh.concat8bit.totalSeg;
+ msg.seqNum = pTpdu->data.submit.userData.header[i].udh.concat8bit.seqNum;
+ msg.simId = msgId;
+ memcpy(&(msg.originAddress), &(pTpdu->data.submit.destAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.submit.dcs), sizeof(SMS_3GPP_DCS_S));
+
+ /** check noneConcatTypeHeader */
+ noneConcatTypeHeader = false;
+
+ break;
+ } else if (pTpdu->data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.submit.userData.header[i].udh.concat16bit.msgRef;
+ msg.totalSeg = pTpdu->data.submit.userData.header[i].udh.concat16bit.totalSeg;
+ msg.seqNum = pTpdu->data.submit.userData.header[i].udh.concat16bit.seqNum;
+ msg.simId = msgId;
+ memcpy(&(msg.originAddress), &(pTpdu->data.submit.destAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.submit.dcs), sizeof(SMS_3GPP_DCS_S));
+
+ /** check noneConcatTypeHeader */
+ noneConcatTypeHeader = false;
+
+ break;
+ }
+ }
+
+ unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.submit.userData));
+
+ MSG_DEBUG("segCnt [%d]", segCnt);
+ MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
+
+ if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
+ MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
+
+ int dataSize = 0;
+ char* pUserData = NULL;
+ unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
+
+ MSG_MESSAGE_INFO_S msgInfo = {0};
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+ msgInfo.sim_idx = msg.simIndex;
+
+ dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
+
+ if (dataSize > 0) {
+ convertConcatToMsginfo(&(pTpdu->data.submit), pUserData, dataSize, &msgInfo);
+
+ /* set Sim Message ID */
+ msgInfo.msgId = msgId;
+ /* set read status */
+ msgInfo.bRead = bRead;
+
+ msgInfo.msgType.subType = MSG_CONCAT_SIM_SMS;
+
+ /* set storage id */
+ msgInfo.storageId = MSG_STORAGE_SIM;
+ }
+ for (int index = concatList.size(); index >= 0 ; index--) {
+ if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex
+ && g_strcmp0(concatList[index].originAddress.address, msg.originAddress.address) == 0) {
+ memcpy(simIdList, concatList[index].simIdList, sizeof(int) * MAX_SIM_SMS_NUM);
+ break;
+ }
+ }
+ /* Call Event Handler */
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
+ removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
+ return;
+ }
+ /* Call Event Handler */
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ }
+
+ MSG_END();
+}
+
+#ifdef CONCAT_SIM_MSG_OPERATION
+void Sms3gppConcatHandler::handleConcatMsg(SMS_3GPP_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead)
+{
+ MSG_BEGIN();
+
+ if (pTpdu->tpduType != SMS_TPDU_DELIVER) {
+ MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
+ return;
+ }
+
+ SMS_3GPP_CONCAT_MSG_S msg;
+ memset(&msg, 0x00, sizeof(SMS_3GPP_CONCAT_MSG_S));
+
+ for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
+ if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
+ msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
+ msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
+
+ memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_3GPP_DCS_S));
+
+ msg.bRead = bRead;
+
+ if (msg.totalSeg > MAX_SEGMENT_NUM) {
+ MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+ return;
+ }
+
+ break;
+ } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
+ msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
+ msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
+
+ memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_3GPP_DCS_S));
+
+ msg.bRead = bRead;
+
+ if (msg.totalSeg > MAX_SEGMENT_NUM) {
+ MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
+ return;
+ }
+
+ break;
+ }
+ }
+
+ unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
+
+ addToSimIdList(msg.msgRef, SimMsgId);
+
+ if (segCnt == msg.totalSeg) {
+ MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
+
+ int dataSize = 0;
+ char* pUserData = NULL;
+ unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
+
+ MSG_MESSAGE_INFO_S msgInfo = {0};
+
+ dataSize = makeConcatUserData(msg.msgRef, &pUserData);
+
+ if (dataSize >= 0) {
+ MSG_DEBUG("TOTAL DATA : %s", pUserData);
+
+ convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
+
+ /* set Sim Message ID */
+ msgInfo.msgId = SimMsgId;
+
+ /* set read status */
+ msgInfo.bRead = bRead;
+
+ /* Print MSG_MESSAGE_INFO_S */
+ MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
+
+ MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
+ MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+ MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+ MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+ MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+ MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+ MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+ MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+ MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+ MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+ MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+ MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+ MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+ MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+
+ if (msgInfo.bTextSms == true)
+ MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+ else
+ MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+
+ MSG_DEBUG("###############################################################");
+
+ /* Remove from List */
+ removeFromConcatList(msg.msgRef);
+ removeFromSimIdList(msg.msgRef);
+
+ /* add msgInfo to msg list */
+ Sms3gppStorage::instance()->addSimMsgToList(&msgInfo, true);
+
+ /* Callback to MSG FW */
+ Sms3gppEventHandler::instance()->callbackGetSimMsg();
+ }
+ } else {
+ /* add index count to msg list */
+ Sms3gppStorage::instance()->addSimMsgToList(NULL, false);
+
+ /* Callback to MSG FW */
+ Sms3gppEventHandler::instance()->callbackGetSimMsg();
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gppConcatHandler::handleBrokenMsg()
+{
+ if (concatList.size() <= 0 || simIdList.size() <= 0) {
+ MSG_DEBUG("No Broken Concatenated Message");
+ return;
+ }
+
+ do {
+ int index = 0, dataSize = 0;
+ char* pUserData = NULL;
+ unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
+
+ MSG_MESSAGE_INFO_S msgInfo = {0};
+
+ dataSize = makeConcatUserData(concatList[index].msgRef, &pUserData);
+
+ if (dataSize > 0) {
+ MSG_DEBUG("TOTAL DATA : %s", pUserData);
+
+ SMS_3GPP_CONCAT_MSG_S msg;
+ memset(&msg, 0x00, sizeof(SMS_3GPP_CONCAT_MSG_S));
+
+ msg.msgRef = concatList[index].msgRef;
+ msg.totalSeg = concatList[index].totalSeg;
+
+ memcpy(&(msg.timeStamp.time.absolute), &(concatList[index].timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(msg.originAddress), &(concatList[index].originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(msg.dcs), &(concatList[index].dcs), sizeof(SMS_3GPP_DCS_S));
+
+ convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
+
+ /* set Sim Message ID */
+ msgInfo.msgId = 0;
+
+ /* set read status */
+ msgInfo.bRead = concatList[index].bRead;
+
+ /* Print MSG_MESSAGE_INFO_S */
+ MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
+ MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
+ MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+ MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+ MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+ MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+ MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+ MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+ MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+ MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+ MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+ MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+ MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+ MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+ MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+ if (msgInfo.bTextSms == true)
+ MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+ else
+ MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+ MSG_DEBUG("###############################################################");
+
+ /* add msgInfo to msg list */
+ Sms3gppStorage::instance()->addSimMsgToList(&msgInfo, true);
+ }
+
+ removeFromConcatList(concatList[index].msgRef);
+ removeFromSimIdList(concatList[index].msgRef);
+ } while (concatList.size() > 0);
+}
+#endif
+
+
+unsigned char Sms3gppConcatHandler::checkConcatMsg(SMS_3GPP_CONCAT_MSG_S *pConcatMsg, SMS_3GPP_USERDATA_S *pUserData)
+{
+ if (pConcatMsg == NULL || pUserData == NULL) {
+ MSG_DEBUG("In Parameter is NULL");
+ return 0;
+ }
+
+ unsigned char currSegCnt = 0;
+
+ bool bFind = false;
+
+ for (unsigned int i = 0; i < concatList.size(); i++) {
+ if (concatList[i].msgRef == pConcatMsg->msgRef && concatList[i].simIndex == pConcatMsg->simIndex
+ && g_strcmp0(concatList[i].originAddress.address, pConcatMsg->originAddress.address) == 0) {
+ if (concatList[i].data.count(pConcatMsg->seqNum) != 0) {
+ MSG_DEBUG("The Sequence Number already exists [%d]", pConcatMsg->seqNum);
+ return 0;
+ }
+ SMS_3GPP_CONCAT_DATA_S concatData = {0};
+
+ memcpy(concatData.data, pUserData->data, pUserData->length);
+ concatData.length = pUserData->length;
+
+ pair<unsigned char, SMS_3GPP_CONCAT_DATA_S> newData(pConcatMsg->seqNum, concatData);
+ concatList[i].data.insert(newData);
+ concatList[i].simIdList[concatList[i].segCnt] = pConcatMsg->simId + 1;
+
+ MSG_DEBUG("MSG DATA : %s", pUserData->data);
+ MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
+
+ concatList[i].segCnt++;
+ concatList[i].totalSize += pUserData->length;
+ currSegCnt = concatList[i].segCnt;
+
+ bFind = true;
+
+ break;
+ }
+ }
+
+ /** New Concat Msg */
+ if (bFind == false) {
+ SMS_3GPP_CONCAT_INFO_S tmpInfo;
+ memset(tmpInfo.simIdList, 0x00, sizeof(int) * MAX_SIM_SMS_NUM);
+ tmpInfo.msgRef = pConcatMsg->msgRef;
+ tmpInfo.totalSeg = pConcatMsg->totalSeg;
+ tmpInfo.segCnt = 1;
+ tmpInfo.simIdList[0] = pConcatMsg->simId + 1;
+ tmpInfo.simIndex = pConcatMsg->simIndex;
+ tmpInfo.bRead = false;
+
+ memcpy(&(tmpInfo.timeStamp.time.absolute), &(pConcatMsg->timeStamp.time.absolute), sizeof(SMS_3GPP_TIME_ABS_S));
+ memcpy(&(tmpInfo.originAddress), &(pConcatMsg->originAddress), sizeof(SMS_3GPP_ADDRESS_S));
+ memcpy(&(tmpInfo.dcs), &(pConcatMsg->dcs), sizeof(SMS_3GPP_DCS_S));
+
+ tmpInfo.totalSize = pUserData->length;
+ tmpInfo.display_time = time(NULL);
+
+ SMS_3GPP_CONCAT_DATA_S concatData = {0};
+
+ memcpy(concatData.data, pUserData->data, pUserData->length);
+ concatData.length = pUserData->length;
+
+ pair<unsigned char, SMS_3GPP_CONCAT_DATA_S> newData(pConcatMsg->seqNum, concatData);
+ tmpInfo.data.insert(newData);
+
+ MSG_DEBUG("MSG DATA : %s", pUserData->data);
+ MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
+
+ concatList.push_back(tmpInfo);
+
+ currSegCnt = tmpInfo.segCnt;
+ }
+
+ return currSegCnt;
+}
+
+
+int Sms3gppConcatHandler::makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData, char *originAddress)
+{
+ Sms3gppConcatDataMap::iterator it;
+
+ int totalSize = 0, offset = 0;
+
+ for (unsigned int i = 0; i < concatList.size(); i++) {
+ if (concatList[i].msgRef == MsgRef && concatList[i].simIndex == simIndex
+ && g_strcmp0(concatList[i].originAddress.address, originAddress) == 0) {
+ totalSize = concatList[i].totalSize;
+
+ if (totalSize <= 0) {
+ MSG_DEBUG("Size Error : totalSize <= 0");
+ return 0;
+ }
+
+ MSG_DEBUG("totalSize [%d]", totalSize);
+
+ if (*ppTotalData == NULL)
+ *ppTotalData = new char[totalSize];
+
+ for (it = concatList[i].data.begin(); it != concatList[i].data.end(); it++) {
+ memcpy(*ppTotalData+offset, it->second.data, it->second.length);
+ offset += it->second.length;
+ }
+ }
+ }
+
+ return totalSize;
+}
+
+
+void Sms3gppConcatHandler::convertConcatToMsginfo(const SMS_3GPP_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ /** Convert Type values */
+ pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+ pMsgInfo->msgType.subType = Sms3gppEventHandler::instance()->convertMsgSubType(pTpdu->pid);
+
+ /** set folder id */
+ pMsgInfo->folderId = MSG_INBOX_ID;
+
+ /** set storage id */
+ pMsgInfo->storageId = MSG_STORAGE_PHONE;
+
+ switch (pTpdu->dcs.msgClass) {
+ case SMS_MSG_CLASS_0:
+ pMsgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ pMsgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ pMsgInfo->msgType.classType = MSG_CLASS_2;
+ break;
+ case SMS_MSG_CLASS_3:
+ pMsgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+ break;
+ }
+
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+
+ time_t rawtime = time(NULL);
+
+/*** Comment below lines to save local UTC time..... (it could be used later.)
+
+ if (pTpdu->timeStamp.format == SMS_3GPP_TIME_ABSOLUTE) {
+
+ MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
+ MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
+ MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
+ MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
+ MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
+ MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
+ MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
+
+ char displayTime[32];
+ struct tm * timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
+ timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
+ timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
+ timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
+ timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
+ timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%d]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+
+***/
+
+ pMsgInfo->displayTime = rawtime;
+
+ /** Convert Address values */
+ pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ pMsgInfo->nAddressCnt = 1;
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(pMsgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+
+ for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+ /** Convert UDH values - Port Number */
+ if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+ pMsgInfo->msgPort.valid = true;
+ pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+ pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+ pMsgInfo->msgPort.valid = true;
+ pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+ pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+ }
+ }
+
+ /* For UTF8 */
+ int bufSize = (DataSize*4) + 1;
+
+ char tmpBuf[bufSize];
+ memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+ /** Convert Data values */
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+ pMsgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
+ pMsgInfo->encodeType = MSG_ENCODE_8BIT;
+ memcpy(tmpBuf, pUserData, DataSize);
+ pMsgInfo->dataSize = DataSize;
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+ pMsgInfo->encodeType = MSG_ENCODE_UCS2;
+ pMsgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
+ }
+
+ MSG_DEBUG("Data Size [%zu]", pMsgInfo->dataSize);
+ MSG_DEBUG("Data [%s]", tmpBuf);
+
+#ifdef MSG_FW_FOR_DEBUG
+printf("\n");
+
+for (int i = 0; i < pMsgInfo->dataSize; i++)
+{
+ printf("[%02x]", tmpBuf[i]);
+}
+
+printf("\n");
+#endif
+
+ if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
+ pMsgInfo->bTextSms = false;
+
+ /** Save Message Data into File */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "######## MsgCreateFileName Fail !!! #######");
+
+ MSG_SEC_DEBUG("Save Message Data into file : size[%zu] name[%s]\n", pMsgInfo->dataSize, fileName);
+ if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
+ THROW(MsgException::FILE_ERROR, "######## MsgWriteIpcFile Fail !!! #######");
+
+ strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+ } else {
+ pMsgInfo->bTextSms = true;
+
+ memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
+ memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
+ }
+}
+
+
+void Sms3gppConcatHandler::convertConcatToMsginfo(const SMS_3GPP_SUBMIT_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ /** Convert Type values */
+ pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+ pMsgInfo->msgType.subType = Sms3gppEventHandler::instance()->convertMsgSubType(pTpdu->pid);
+
+ /** set folder id */
+ pMsgInfo->folderId = MSG_INBOX_ID;
+
+ /** set storage id */
+ pMsgInfo->storageId = MSG_STORAGE_PHONE;
+
+ switch (pTpdu->dcs.msgClass) {
+ case SMS_MSG_CLASS_0:
+ pMsgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ pMsgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ pMsgInfo->msgType.classType = MSG_CLASS_2;
+ break;
+ case SMS_MSG_CLASS_3:
+ pMsgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+ break;
+ }
+
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+ time_t rawtime = time(NULL);
+ pMsgInfo->displayTime = rawtime;
+
+ /** Convert Address values */
+ pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ pMsgInfo->nAddressCnt = 1;
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(pMsgInfo->addressList[0].addressVal, pTpdu->destAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+
+ for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+ /** Convert UDH values - Port Number */
+ if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+ pMsgInfo->msgPort.valid = true;
+ pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+ pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+ pMsgInfo->msgPort.valid = true;
+ pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+ pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+ }
+ }
+
+ /* For UTF8 */
+ int bufSize = (DataSize*4) + 1;
+
+ char tmpBuf[bufSize];
+ memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+ /** Convert Data values */
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+ pMsgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
+ pMsgInfo->encodeType = MSG_ENCODE_8BIT;
+ memcpy(tmpBuf, pUserData, DataSize);
+ pMsgInfo->dataSize = DataSize;
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+ pMsgInfo->encodeType = MSG_ENCODE_UCS2;
+ pMsgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
+ }
+
+ MSG_DEBUG("Data Size [%zu]", pMsgInfo->dataSize);
+ MSG_DEBUG("Data [%s]", tmpBuf);
+
+ if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
+ pMsgInfo->bTextSms = false;
+
+ /** Save Message Data into File */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "######## MsgCreateFileName Fail !!! #######");
+
+ MSG_SEC_DEBUG("Save Message Data into file : size[%zu] name[%s]\n", pMsgInfo->dataSize, fileName);
+ if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
+ THROW(MsgException::FILE_ERROR, "######## MsgWriteIpcFile Fail !!! #######");
+
+ strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+ } else {
+ pMsgInfo->bTextSms = true;
+
+ memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
+ memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
+ }
+}
+
+#ifdef CONCAT_SIM_MSG_OPERATION
+void Sms3gppConcatHandler::convertSimMsgToMsginfo(const SMS_3GPP_CONCAT_MSG_S *pConcatMsg, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ /* Convert Type values */
+ pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
+ pMsgInfo->msgType.subType = MSG_CONCAT_SIM_SMS;
+
+ /* set folder id (temporary) */
+ pMsgInfo->folderId = MSG_INBOX_ID;
+
+ pMsgInfo->storageId = MSG_STORAGE_SIM;
+
+ switch (pConcatMsg->dcs.msgClass) {
+ case SMS_MSG_CLASS_0:
+ pMsgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ pMsgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ pMsgInfo->msgType.classType = MSG_CLASS_2;
+ break;
+ case SMS_MSG_CLASS_3:
+ pMsgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+ }
+
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+ time_t rawtime = time(NULL);
+
+/*** Comment below lines to save local UTC time..... (it could be used later.)
+
+ if (pTpdu->timeStamp.format == SMS_3GPP_TIME_ABSOLUTE) {
+
+ MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
+ MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
+ MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
+ MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
+ MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
+ MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
+ MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
+
+ char displayTime[32];
+ struct tm * timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
+ timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
+ timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
+ timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
+ timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
+ timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%d]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+
+***/
+
+ pMsgInfo->displayTime = rawtime;
+
+ /* Convert Address values */
+ pMsgInfo->nAddressCnt = 1;
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(pMsgInfo->addressList[0].addressVal, pConcatMsg->originAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+
+ /* Insert SMS_CONCAT_SIM_MSG_S into File */
+ SMS_CONCAT_SIM_MSG_S concatSimMsg = {0};
+
+ for (unsigned int i = 0; i < simIdList.size(); i++) {
+ if (simIdList[i].msgRef == pConcatMsg->msgRef) {
+ MSG_DEBUG("Get SIM ID [%d] - List Index [%d]", simIdList[i].simId, concatSimMsg.simIdCnt);
+
+ concatSimMsg.simIdList[concatSimMsg.simIdCnt] = simIdList[i].simId;
+ concatSimMsg.simIdCnt++;
+ }
+ }
+
+ int bufSize = (MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM) + 1;
+
+ char tmpBuf[bufSize];
+ memset(tmpBuf, 0x00, sizeof(tmpBuf));
+
+ /* Convert Data values */
+ if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_7BIT) {
+ SMS_LANG_INFO_S langInfo = {0};
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+ pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
+ } else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_8BIT) {
+ pMsgInfo->encodeType = MSG_ENCODE_8BIT;
+ memcpy(tmpBuf, pUserData, DataSize);
+ pMsgInfo->dataSize = DataSize;
+ } else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_UCS2) {
+ pMsgInfo->encodeType = MSG_ENCODE_UCS2;
+ pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
+ }
+
+ MSG_DEBUG("Data Size [%d]", pMsgInfo->dataSize);
+
+ pMsgInfo->bTextSms = false;
+
+ if (pMsgInfo->dataSize > 0)
+ memcpy(concatSimMsg.msgData, tmpBuf, pMsgInfo->dataSize);
+
+ /* Save Message Data into File */
+ char fileName[MAX_COMMON_INFO_SIZE+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+ if (MsgWriteIpcFile(fileName, (char*)(&concatSimMsg), sizeof(SMS_CONCAT_SIM_MSG_S)) == false)
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+ memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
+ strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
+
+ MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]", pMsgInfo->dataSize, fileName);
+}
+#endif
+
+
+void Sms3gppConcatHandler::removeFromConcatList(unsigned short MsgRef, int simIndex, char *originAddress)
+{
+ for (int index = concatList.size()-1; index >= 0 ; index--) {
+ if (concatList[index].msgRef == MsgRef && concatList[index].simIndex == simIndex
+ && g_strcmp0(concatList[index].originAddress.address, originAddress) == 0) {
+ MSG_DEBUG("remove concatlist of the index [%d]", index);
+ concatList.erase(concatList.begin()+index);
+ break;
+ }
+ }
+}
+
+#ifdef CONCAT_SIM_MSG_OPERATION
+void Sms3gppConcatHandler::addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId)
+{
+ SMS_SIM_ID_S simIdStruct;
+
+ simIdStruct.msgRef = MsgRef;
+ simIdStruct.simId = SimMsgId;
+
+ simIdList.push_back(simIdStruct);
+}
+
+
+void Sms3gppConcatHandler::removeFromSimIdList(unsigned short MsgRef)
+{
+ for (int index = simIdList.size()-1; index >= 0 ; index--) {
+ if (simIdList[index].msgRef == MsgRef) {
+ MSG_DEBUG("remove simIdList of the index [%d]", index);
+
+ simIdList.erase(simIdList.begin()+index);
+ }
+ }
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <bundle.h>
+#include <eventsystem.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilFunction.h"
+#include "MsgCppTypes.h"
+#include "MsgContact.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgDevicedWrapper.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppSimMsg.h"
+#include "Sms3gppStorage.h"
+#include "Sms3gppSetting.h"
+#include "Sms3gppConcatHandler.h"
+#include "Sms3gppEventHandler.h"
+#include "SmsPluginDSHandler.h"
+#include "SmsPluginStorage.h"
+#include "Sms3gppParamCodec.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppEventHandler - Member Functions
+==================================================================================================*/
+Sms3gppEventHandler* Sms3gppEventHandler::pInstance = NULL;
+
+
+Sms3gppEventHandler::Sms3gppEventHandler()
+{
+ /* Initialize global parameters */
+ memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
+ memset(&sentInfo, 0x00, sizeof(SMS_3GPP_SENT_INFO_S));
+
+ pSimCnt = NULL;
+ devStatus = false;
+ bUdhMwiMethod = false;
+ udhMwiCnt = 0;
+ devHandle = NULL;
+}
+
+
+Sms3gppEventHandler::~Sms3gppEventHandler()
+{
+}
+
+
+Sms3gppEventHandler* Sms3gppEventHandler::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppEventHandler();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gppEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+ listener = *pListener;
+}
+
+
+void Sms3gppEventHandler::handleSentStatus(msg_network_status_t NetStatus)
+{
+ MSG_DEBUG("NetStatus[%d]", NetStatus);
+
+ if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
+ /** Update Msg Status */
+ if (sentInfo.reqInfo.msgInfo.msgPort.valid == false) {
+ /*SmsPluginStorage::instance()->updateSentMsg(&(sentInfo.reqInfo.msgInfo), NetStatus); */
+
+ sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
+
+ if (NetStatus == MSG_NETWORK_SEND_SUCCESS) {
+ /* contacts-service is not used for gear */
+#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
+ MSG_DEBUG("Add phone log");
+ MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
+#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
+ sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID; /* It should be set after adding phone log. */
+ /* Send system event */
+ bundle *b = NULL;
+ b = bundle_create();
+ if (b) {
+ if (sentInfo.reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE)
+ bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_SMS);
+ else
+ bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_MMS);
+
+ char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+ snprintf(msgId, sizeof(msgId), "%u", sentInfo.reqInfo.msgInfo.msgId);
+ bundle_add_str(b, EVT_KEY_OUT_MSG_ID, msgId);
+ eventsystem_send_system_event(SYS_EVENT_OUTGOING_MSG, b);
+ bundle_free(b);
+ }
+ } else {
+ sentInfo.reqInfo.msgInfo.bRead = false;
+ }
+
+ SmsPluginStorage::instance()->updateSmsMessage(&(sentInfo.reqInfo.msgInfo));
+
+ callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
+ }
+
+ MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
+ MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
+ /* Check sending options */
+ if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
+ SmsPluginStorage::instance()->deleteSmsMessage(sentInfo.reqInfo.msgInfo.msgId);
+ callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
+ }
+
+ /* Callback to MSG FW */
+ MSG_SENT_STATUS_S msgStatus;
+
+ msgStatus.reqId = sentInfo.reqInfo.reqId;
+ msgStatus.status = NetStatus;
+
+ MSG_DEBUG("sentStatus.reqId : %d", msgStatus.reqId);
+ MSG_DEBUG("sentStatus.status : %d", msgStatus.status);
+
+ listener.pfSentStatusCb(&msgStatus);
+ }
+}
+
+
+void Sms3gppEventHandler::handleMsgIncoming(TapiHandle *handle, SMS_3GPP_TPDU_S *pTpdu)
+{
+ /* Make MSG_MESSAGE_INFO_S */
+ MSG_MESSAGE_INFO_S msgInfo;
+ MSG_MESSAGE_INFO_S stored_msgInfo;
+
+ /* initialize msgInfo */
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+
+ if (pTpdu->tpduType == SMS_TPDU_DELIVER) {
+ /* check unsupported message */
+ if (pTpdu->data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && pTpdu->data.deliver.pid == 0x11) {
+ MSG_DEBUG("Unsupported message!!");
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
+ return;
+ }
+ }
+
+ bUdhMwiMethod = false;
+ udhMwiCnt = 0;
+
+ if (pTpdu->data.deliver.dcs.msgClass == SMS_MSG_CLASS_2)
+ msgInfo.storageId = MSG_STORAGE_UNKNOWN;
+ else
+ msgInfo.storageId = MSG_STORAGE_PHONE;
+
+ msgInfo.sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ /** convert to msgInfo */
+ convertTpduToMsginfo(pTpdu, &msgInfo);
+
+ if (msgInfo.msgPort.valid == true) {
+ if ((msgInfo.msgPort.dstPort >= 0x23F4 && msgInfo.msgPort.dstPort <= 0x23F7) || /** Check unsupported message (Vcard WAP push) **/
+ (msgInfo.msgPort.dstPort == 0x1581)) { /** Check unsupported message (ringtone smart message) **/
+ memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "<Unsupported message>");
+ msgInfo.dataSize = strlen(msgInfo.msgText);
+ msgInfo.msgPort.valid = false;
+ }
+ }
+
+ bool bStoreVoiceMsg = false;
+
+ if (bUdhMwiMethod == false) {
+ /* check MWI and set info to SIM for DCS & Address method */
+ if (pTpdu->tpduType == SMS_TPDU_DELIVER && pTpdu->data.deliver.dcs.bMWI == true) {
+ int MwiCnt = 0;
+ MSG_DEBUG("MWI message - DCS method");
+
+ if (pTpdu->data.deliver.dcs.bIndActive == false) {
+ Sms3gppSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 0);
+ MwiCnt = 0;
+ } else {
+ Sms3gppSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 1);
+ MwiCnt = 1;
+
+ /* For address method */
+ if (pTpdu->data.deliver.pid == 0x20 && pTpdu->data.deliver.originAddress.ton == SMS_TON_ALPHANUMERIC) {
+ MSG_DEBUG("MWI message - Address method");
+ char *voiceNumber = NULL;
+ char *voiceAlphaId = NULL;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msgInfo.sim_idx);
+ if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msgInfo.sim_idx);
+ if (MsgSettingGetString(keyName, &voiceAlphaId) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ memset(msgInfo.addressList[0].addressVal, 0x00, sizeof(msgInfo.addressList[0].addressVal));
+ memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
+
+ if (voiceNumber) {
+ snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNumber);
+ free(voiceNumber);
+ voiceNumber = NULL;
+ }
+
+ if (voiceAlphaId) {
+ snprintf(msgInfo.addressList[0].displayName, sizeof(msgInfo.addressList[0].displayName), "%s", voiceAlphaId);
+ free(voiceAlphaId);
+ voiceAlphaId = NULL;
+ }
+ }
+ }
+
+ if (pTpdu->data.deliver.dcs.codingGroup == SMS_GROUP_STORE) {
+ bStoreVoiceMsg = true;
+ memset(&stored_msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+ memcpy(&stored_msgInfo, &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
+ stored_msgInfo.msgType.subType = MSG_NORMAL_SMS;
+ }
+
+ memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+ switch (msgInfo.msgType.subType) {
+ case MSG_MWI_VOICE_SMS :
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", MwiCnt);
+ break;
+ case MSG_MWI_FAX_SMS :
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new fax message", MwiCnt);
+ break;
+ case MSG_MWI_EMAIL_SMS :
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new email message", MwiCnt);
+ break;
+ default :
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new special message", MwiCnt);
+ break;
+ }
+ msgInfo.dataSize = strlen(msgInfo.msgText);
+
+ if (pTpdu->data.deliver.dcs.codingGroup == SMS_GROUP_DISCARD)
+ msgInfo.bStore = false;
+ }
+ }
+
+ /* Short Message Type 0 - Just Send Deliver Report */
+ if (msgInfo.msgType.subType == MSG_TYPE0_SMS) {
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
+ return;
+ }
+
+ /** Print MSG_MESSAGE_INFO_S */
+ MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
+ MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+ if (msgInfo.nAddressCnt > 0) {
+ MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+ MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+ MSG_SEC_DEBUG("msgInfo.addressList[0].displayName : %s", msgInfo.addressList[0].displayName);
+ }
+ MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+ MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+ MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+ MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+ MSG_DEBUG("msgInfo.bStore : %d", msgInfo.bStore);
+ MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+ MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+ MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+ MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+ MSG_DEBUG("msgInfo.displayTime : %ld", msgInfo.displayTime);
+ MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
+ MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
+ MSG_DEBUG("msgInfo.dataSize : %zu", msgInfo.dataSize);
+ MSG_DEBUG("msgInfo.sim_idx : %d", msgInfo.sim_idx);
+
+ if (msgInfo.bTextSms == true) {
+ MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+ } else {
+ MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+ }
+
+ MSG_DEBUG("###############################################################");
+
+ msg_error_t err = MSG_SUCCESS;
+
+ if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
+ /* Status Report Message */
+ err = Sms3gppStorage::instance()->updateMsgDeliverStatus(&msgInfo, pTpdu->data.statusRep.msgRef);
+
+ if (err == MSG_SUCCESS)
+ err = listener.pfMsgIncomingCb(&msgInfo);
+ else
+ MSG_DEBUG("updateMsgDeliverStatus is failed [%d]", err);
+
+ /* Handling of Fail Case ?? */
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
+ } else { /* SMS Deliver */
+ /* Class 2 Msg */
+ if (msgInfo.msgType.classType == MSG_CLASS_2) {
+ if (msgInfo.bTextSms == false) { /* Concat Msg cannot be saved in SIM */
+ msgInfo.msgType.classType = MSG_CLASS_NONE;
+ msgInfo.storageId = MSG_STORAGE_PHONE;
+ } else {
+ /** set total segment of Class2 message as 1 */
+ Sms3gppSimMsg::instance()->setSmsTpduTotalSegCount(1);
+ }
+ }
+
+ /** Add message to DB */
+ if (msgInfo.msgPort.valid == false) {
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ }
+
+ /* Callback to MSG FW */
+ if (msgInfo.msgType.classType == MSG_CLASS_2) {
+ if (((msgInfo.msgType.subType >= MSG_MWI_VOICE_SMS) && (msgInfo.msgType.subType <= MSG_MWI_OTHER_SMS)) &&
+ (msgInfo.bStore == false)) {
+ if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
+ MSG_DEBUG("listener.pfMsgIncomingCb is failed!");
+
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
+ }
+ } else {
+ if (err == MSG_SUCCESS) {
+ MSG_DEBUG("callback to msg fw");
+ err = listener.pfMsgIncomingCb(&msgInfo);
+ if (bStoreVoiceMsg) {
+ err = listener.pfMsgIncomingCb(&stored_msgInfo);
+ }
+ } else {
+ if (msgInfo.msgType.classType == MSG_CLASS_0) {
+ MSG_DEBUG("callback for class0 message to msg fw");
+ if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
+ MSG_DEBUG("listener.pfMsgIncomingCb is failed!");
+ }
+ }
+
+ /* Send Deliver Report */
+ if (msgInfo.msgType.classType == MSG_CLASS_0)
+ Sms3gppTransport::instance()->sendClass0DeliverReport(handle, err);
+ else
+ Sms3gppTransport::instance()->sendDeliverReport(handle, err);
+ }
+
+ /* Tizen Validation System */
+ char *msisdn = NULL;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, msgInfo.sim_idx);
+ if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s", msgInfo.msgId, \
+ msgInfo.addressList[0].addressVal, \
+ (msisdn == NULL)?"ME":msisdn, \
+ (err == MSG_SUCCESS)?"Success":"Fail");
+
+ MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
+
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+ }
+}
+
+void Sms3gppEventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *application_id, char *content_type)
+{
+ MSG_PUSH_MESSAGE_DATA_S pushData;
+
+ memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
+
+ /* set PUSH data */
+ memcpy(pushData.pushHeader, pPushHeader, strlen(pPushHeader));
+ pushData.pushHeader[strlen(pPushHeader)] = '\0';
+
+ pushData.pushBodyLen = pushBodyLen;
+ memcpy(pushData.pushBody, pPushBody, pushBodyLen);
+ pushData.pushBody[pushBodyLen] = '\0';
+
+ memcpy(pushData.pushAppId, application_id, MAX_WAPPUSH_ID_LEN);
+ memcpy(pushData.pushContentType, content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+
+ /* Callback to MSG FW */
+ listener.pfPushMsgIncomingCb(&pushData);
+}
+
+
+void Sms3gppEventHandler::handleResendMessage(void)
+{
+ listener.pfResendMessageCb();
+}
+
+
+void Sms3gppEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, int simIndex)
+{
+ MSG_SYNCML_MESSAGE_DATA_S syncMLData;
+
+ memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
+
+ /* set syncML data */
+ syncMLData.syncmlType = msgType;
+
+ syncMLData.simIndex = simIndex;
+
+ syncMLData.pushBodyLen = PushBodyLen;
+ memcpy(syncMLData.pushBody, pPushBody, PushBodyLen);
+
+ syncMLData.wspHeaderLen = WspHeaderLen;
+ memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
+
+ /* Callback to MSG FW */
+ listener.pfSyncMLMsgIncomingCb(&syncMLData);
+}
+
+
+void Sms3gppEventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen)
+{
+ MSG_LBS_MESSAGE_DATA_S lbsData;
+
+ memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
+
+ /* set LBA data */
+ memcpy(lbsData.pushHeader, pPushHeader, strlen(pPushHeader));
+ lbsData.pushHeader[strlen(pPushHeader)] = '\0';
+
+ lbsData.pushBodyLen = pushBodyLen;
+ memcpy(lbsData.pushBody, pPushBody, pushBodyLen);
+ lbsData.pushBody[pushBodyLen] = '\0';
+
+ /* Callback to MSG FW */
+ listener.pfLBSMsgIncomingCb(&lbsData);
+}
+
+msg_error_t Sms3gppEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Callback to MSG FW */
+ err = listener.pfMsgIncomingCb(pMsgInfo);
+
+ MSG_END();
+
+ return err;
+}
+
+msg_error_t Sms3gppEventHandler::callbackCBMsgIncoming(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Callback to MSG FW */
+ err = listener.pfCBMsgIncomingCb(pCbMsg, pMsgInfo);
+
+ MSG_END();
+
+ return err;
+}
+
+
+msg_error_t Sms3gppEventHandler::callbackInitSimBySat()
+{
+ /* Callback to MSG FW */
+ return listener.pfInitSimBySatCb();
+}
+
+
+msg_error_t Sms3gppEventHandler::callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ msg_id_list_s msgIdList;
+ msg_message_id_t msgIds[1];
+ memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
+
+ msgIdList.nCount = 1;
+ msgIds[0] = pMsgInfo->msgId;
+ msgIdList.msgIdList = msgIds;
+
+ /* Callback to MSG FW */
+ listener.pfStorageChangeCb(storageChangeType, &msgIdList);
+
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t Sms3gppEventHandler::callbackThreadChange(msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId)
+{
+ /* Callback to MSG FW */
+ listener.pfThreadChangeCb(storageChangeType, threadId);
+
+ return MSG_SUCCESS;
+}
+
+
+void Sms3gppEventHandler::convertTpduToMsginfo(SMS_3GPP_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+ switch (pTpdu->tpduType) {
+ case SMS_TPDU_SUBMIT :
+ convertSubmitTpduToMsginfo(&pTpdu->data.submit, msgInfo);
+ break;
+ case SMS_TPDU_DELIVER :
+ convertDeliverTpduToMsginfo(&pTpdu->data.deliver, msgInfo);
+ break;
+ case SMS_TPDU_STATUS_REP :
+ convertStatusRepTpduToMsginfo(&pTpdu->data.statusRep, msgInfo);
+ break;
+ }
+}
+
+
+void Sms3gppEventHandler::convertSubmitTpduToMsginfo(const SMS_3GPP_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+ int addressListCnt = 0;
+
+ /* Convert Type values */
+ msgInfo->msgType.mainType = MSG_SMS_TYPE;
+ msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
+
+ /* set folder id (temporary) */
+ msgInfo->folderId = MSG_SENTBOX_ID;
+
+ switch (pTpdu->dcs.msgClass) {
+ case SMS_MSG_CLASS_0:
+ msgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ msgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ msgInfo->msgType.classType = MSG_CLASS_2;
+ break;
+ case SMS_MSG_CLASS_3:
+ msgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ msgInfo->msgType.classType = MSG_CLASS_NONE;
+ break;
+ }
+
+ msgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
+ msgInfo->bRead = false;
+ msgInfo->bProtected = false;
+ msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ msgInfo->direction = MSG_DIRECTION_TYPE_MO;
+ msgInfo->bTextSms = true;
+
+ memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+ /* What kind of time has to be saved?? (temporary store time) */
+ msgInfo->displayTime = time(NULL);
+
+ /* Convert Address values */
+ msgInfo->nAddressCnt = 1;
+
+ msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ msgInfo->addressList[addressListCnt].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(msgInfo->addressList[addressListCnt].addressVal, pTpdu->destAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ /*exception operation for none userdata */
+ if (pTpdu->userData.length == 0) {
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]");
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+ return;
+ }
+
+ /* Convert Data values */
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ msgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+ msgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
+ }
+}
+
+
+void Sms3gppEventHandler::convertDeliverTpduToMsginfo(const SMS_3GPP_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+ MSG_BEGIN();
+
+ /* Convert Type values */
+ msgInfo->msgType.mainType = MSG_SMS_TYPE;
+ msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
+
+ /* set folder id (temporary) */
+ msgInfo->folderId = MSG_INBOX_ID;
+
+ time_t rawtime = 0;
+ if (msgInfo->storageId == MSG_STORAGE_SIM) {
+ /*** Comment below lines to save local UTC time..... (it could be used later.)
+ ***/
+ if (pTpdu->timeStamp.format == SMS_3GPP_TIME_ABSOLUTE) {
+ MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
+ MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
+ MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
+ MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
+ MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
+ MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
+ MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
+
+ char displayTime[32];
+ struct tm timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
+ timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
+ timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
+ timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
+ timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
+ timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%lu]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
+
+ localtime_r(&rawtime, &timeTM);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ localtime_r(&rawtime, &timeTM);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+ } else {
+ rawtime = time(NULL);
+ }
+
+ msgInfo->displayTime = rawtime;
+
+ switch (pTpdu->dcs.msgClass) {
+ case SMS_MSG_CLASS_0:
+ msgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ msgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ msgInfo->msgType.classType = MSG_CLASS_2;
+ msgInfo->storageId = MSG_STORAGE_SIM;
+ break;
+ case SMS_MSG_CLASS_3:
+ msgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ msgInfo->msgType.classType = MSG_CLASS_NONE;
+ break;
+ }
+
+ if (pTpdu->dcs.bMWI) {
+ if (pTpdu->dcs.indType == SMS_VOICE_INDICATOR)
+ msgInfo->msgType.subType = MSG_MWI_VOICE_SMS;
+ else if (pTpdu->dcs.indType == SMS_VOICE2_INDICATOR)
+ msgInfo->msgType.subType = MSG_MWI_VOICE2_SMS;
+ else if (pTpdu->dcs.indType == SMS_FAX_INDICATOR)
+ msgInfo->msgType.subType = MSG_MWI_FAX_SMS;
+ else if (pTpdu->dcs.indType == SMS_EMAIL_INDICATOR)
+ msgInfo->msgType.subType = MSG_MWI_EMAIL_SMS;
+ else if (pTpdu->dcs.indType == SMS_OTHER_INDICATOR)
+ msgInfo->msgType.subType = MSG_MWI_OTHER_SMS;
+ }
+
+ msgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ msgInfo->bRead = false;
+ msgInfo->bProtected = false;
+ msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ msgInfo->direction = MSG_DIRECTION_TYPE_MT;
+ msgInfo->bTextSms = true;
+
+ memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+ /* Convert Address values */
+ msgInfo->nAddressCnt = 1;
+
+ msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(msgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ msgInfo->msgPort.valid = false;
+ msgInfo->msgPort.dstPort = 0;
+ msgInfo->msgPort.srcPort = 0;
+
+ for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+ /* Convert UDH values - Port Number */
+ if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+ msgInfo->msgPort.valid = true;
+ msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+ msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+ msgInfo->msgPort.valid = true;
+ msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+ msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_SPECIAL_SMS) {
+ msgInfo->msgType.subType = (pTpdu->userData.header[i].udh.specialInd.msgInd+MSG_MWI_VOICE_SMS);
+ msgInfo->bStore = pTpdu->userData.header[i].udh.specialInd.bStore;
+
+ bUdhMwiMethod = true;
+
+ if (pTpdu->dcs.codingGroup == SMS_GROUP_DISCARD)
+ msgInfo->bStore = false;
+
+ udhMwiCnt = pTpdu->userData.header[i].udh.specialInd.waitMsgNum;
+
+ if (udhMwiCnt < 0) {
+ MSG_DEBUG("Message waiting number is smaller than 0. It will be treated as 0. [%d]", udhMwiCnt);
+ udhMwiCnt = 0;
+ }
+
+ MSG_DEBUG("Message waiting number : [%d]", udhMwiCnt);
+ Sms3gppSetting::instance()->setMwiInfo(msgInfo->sim_idx, msgInfo->msgType.subType, udhMwiCnt);
+
+ if (udhMwiCnt > 0 && (msgInfo->msgType.subType >= MSG_MWI_VOICE_SMS && msgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
+ switch (msgInfo->msgType.subType) {
+ case MSG_MWI_VOICE_SMS :
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d", udhMwiCnt);
+ break;
+ case MSG_MWI_FAX_SMS :
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d new fax message", udhMwiCnt);
+ break;
+ case MSG_MWI_EMAIL_SMS :
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d new email message", udhMwiCnt);
+ break;
+ default :
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d new special message", udhMwiCnt);
+ break;
+ }
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+ return;
+ }
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_ALTERNATE_REPLY_ADDRESS) {
+ strncpy(msgInfo->addressList[0].addressVal, pTpdu->userData.header[i].udh.alternateAddress.address, MAX_ADDRESS_VAL_LEN);
+ } else if (pTpdu->userData.header[i].udhType >= SMS_UDH_EMS_FIRST && pTpdu->userData.header[i].udhType <= SMS_UDH_EMS_LAST) {
+ /* TODO: Raw text should be changed to string design id. Currently there's no design id in message-app-lite */
+/* char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_POP_ERROR_UNSUPPORTED_MSG");
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
+*/
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "Unsupported Message");
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+/* if (msg_text) {
+ free(msg_text);
+ msg_text = NULL;
+ }
+*/
+ return;
+ }
+ }
+
+ /*length 0 - no user data - msg should be received */
+ if (pTpdu->userData.length <= 0) {
+ memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
+ msgInfo->dataSize = 0;
+
+ switch (pTpdu->dcs.codingScheme) {
+ case SMS_CHARSET_7BIT:
+ msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+ break;
+ case SMS_CHARSET_8BIT:
+ msgInfo->encodeType = MSG_ENCODE_8BIT;
+ break;
+ case SMS_CHARSET_UCS2:
+ msgInfo->encodeType = MSG_ENCODE_UCS2;
+ break;
+ default:
+ msgInfo->encodeType = MSG_ENCODE_8BIT;
+ break;
+ }
+
+ return;
+ } else if (pTpdu->userData.length > MAX_MSG_TEXT_LEN) {
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]");
+ msgInfo->dataSize = strlen(msgInfo->msgData);
+ return;
+ }
+
+ /* Convert Data values */
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+ if (pTpdu->userData.header[i].udhType == SMS_UDH_SINGLE_SHIFT) {
+ langInfo.bSingleShift = true;
+ langInfo.singleLang = pTpdu->userData.header[i].udh.singleShift.langId;
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_LOCKING_SHIFT) {
+ langInfo.bLockingShift = true;
+ langInfo.lockingLang = pTpdu->userData.header[i].udh.lockingShift.langId;
+ }
+ }
+
+ msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
+ msgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
+ msgInfo->encodeType = MSG_ENCODE_8BIT;
+ memcpy(msgInfo->msgText, pTpdu->userData.data, sizeof(pTpdu->userData.data));
+ msgInfo->dataSize = pTpdu->userData.length;
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
+ msgInfo->encodeType = MSG_ENCODE_UCS2;
+ msgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
+ } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_EUCKR) {
+ msgInfo->encodeType = MSG_ENCODE_8BIT;
+ msgInfo->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
+ return;
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gppEventHandler::convertStatusRepTpduToMsginfo(const SMS_3GPP_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
+{
+ /* Convert Type values */
+ msgInfo->msgType.mainType = MSG_SMS_TYPE;
+ msgInfo->msgType.subType = MSG_STATUS_REPORT_SMS;
+
+ /* set folder id */
+ msgInfo->folderId = MSG_INBOX_ID;
+
+ /* set storage id */
+ if (msgInfo->storageId == MSG_STORAGE_UNKNOWN) {
+ msgInfo->storageId = MSG_STORAGE_PHONE;
+ }
+
+ switch (pTpdu->dcs.msgClass) {
+ case SMS_MSG_CLASS_0:
+ msgInfo->msgType.classType = MSG_CLASS_0;
+ break;
+ case SMS_MSG_CLASS_1:
+ msgInfo->msgType.classType = MSG_CLASS_1;
+ break;
+ case SMS_MSG_CLASS_2:
+ msgInfo->msgType.classType = MSG_CLASS_2;
+ break;
+ case SMS_MSG_CLASS_3:
+ msgInfo->msgType.classType = MSG_CLASS_3;
+ break;
+ default:
+ msgInfo->msgType.classType = MSG_CLASS_NONE;
+ break;
+ }
+
+ MSG_DEBUG("delivery status : [%d]", pTpdu->status);
+
+ if (pTpdu->status == SMS_STATUS_RECEIVE_SUCCESS)
+ msgInfo->networkStatus = MSG_NETWORK_DELIVER_SUCCESS;
+ else if (pTpdu->status == SMS_STATUS_TRY_REQUEST_PENDING)
+ msgInfo->networkStatus = MSG_NETWORK_DELIVER_PENDING;
+ else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED)
+ msgInfo->networkStatus = MSG_NETWORK_DELIVER_EXPIRED;
+ else
+ msgInfo->networkStatus = MSG_NETWORK_DELIVER_FAIL;
+
+ msgInfo->bRead = false;
+ msgInfo->bProtected = false;
+ msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ msgInfo->direction = MSG_DIRECTION_TYPE_MT;
+ msgInfo->bTextSms = true;
+
+ memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+ msgInfo->displayTime = time(NULL);
+
+ /* Convert Address values */
+ msgInfo->nAddressCnt = 1;
+
+ msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(msgInfo->addressList[0].addressVal, pTpdu->recipAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ msgInfo->msgPort.valid = false;
+ msgInfo->msgPort.dstPort = 0;
+ msgInfo->msgPort.srcPort = 0;
+
+ for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
+ /* Convert UDH values - Port Number */
+ if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+ msgInfo->msgPort.valid = true;
+ msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
+ msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
+ } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+ msgInfo->msgPort.valid = true;
+ msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
+ msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
+ }
+ }
+
+ memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
+ msgInfo->dataSize = 0;
+
+ if (pTpdu->status <= SMS_STATUS_SMSC_SPECIFIC_LAST) {
+ char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSG_SBODY_MESSAGE_DELIVERED_M_STATUS_ABB");
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+ if (msg_text) {
+ free(msg_text);
+ msg_text = NULL;
+ }
+ } else if (pTpdu->status == SMS_STATUS_TEMP_SERVICE_REJECTED) {
+ char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSG_SBODY_MESSAGE_REJECTED_M_STATUS_ABB");
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+ if (msg_text) {
+ free(msg_text);
+ msg_text = NULL;
+ }
+ } else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED) {
+ char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSG_SBODY_MESSAGE_EXPIRED_M_STATUS_ABB");
+ snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+ if (msg_text) {
+ free(msg_text);
+ msg_text = NULL;
+ }
+ } else {
+ strncpy(msgInfo->msgText, "Message delivery failed.", MAX_MSG_TEXT_LEN);
+ msgInfo->dataSize = strlen(msgInfo->msgText);
+ }
+}
+
+
+MSG_SUB_TYPE_T Sms3gppEventHandler::convertMsgSubType(SMS_3GPP_PID_T pid)
+{
+ switch (pid) {
+ case SMS_PID_TYPE0 :
+ return MSG_TYPE0_SMS;
+ case SMS_PID_REPLACE_TYPE1 :
+ return MSG_REPLACE_TYPE1_SMS;
+ case SMS_PID_REPLACE_TYPE2 :
+ return MSG_REPLACE_TYPE2_SMS;
+ case SMS_PID_REPLACE_TYPE3 :
+ return MSG_REPLACE_TYPE3_SMS;
+ case SMS_PID_REPLACE_TYPE4 :
+ return MSG_REPLACE_TYPE4_SMS;
+ case SMS_PID_REPLACE_TYPE5 :
+ return MSG_REPLACE_TYPE5_SMS;
+ case SMS_PID_REPLACE_TYPE6 :
+ return MSG_REPLACE_TYPE6_SMS;
+ case SMS_PID_REPLACE_TYPE7 :
+ return MSG_REPLACE_TYPE7_SMS;
+ case SMS_PID_RETURN_CALL :
+ return MSG_MWI_OTHER_SMS;
+ default :
+ return MSG_NORMAL_SMS;
+ }
+}
+
+
+void Sms3gppEventHandler::SetSentInfo(SMS_3GPP_SENT_INFO_S *pSentInfo)
+{
+ memset(&sentInfo, 0x00, sizeof(SMS_3GPP_SENT_INFO_S));
+ memcpy(&sentInfo, pSentInfo, sizeof(SMS_3GPP_SENT_INFO_S));
+
+ MSG_DEBUG("sentInfo.reqId : %d", sentInfo.reqInfo.reqId);
+ MSG_DEBUG("sentInfo.bLast : %d", sentInfo.bLast);
+}
+
+
+void Sms3gppEventHandler::setDeviceStatus(TapiHandle *handle, bool status)
+{
+ if (handle == devHandle) {
+ mx.lock();
+ devStatus = true;
+ cv.signal();
+ mx.unlock();
+ }
+}
+
+
+bool Sms3gppEventHandler::getDeviceStatus(TapiHandle *handle)
+{
+ int ret = 0;
+
+ mx.lock();
+ devHandle = handle;
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ if (ret == ETIMEDOUT) {
+ MSG_WARN("WARNING: DEVICE STATUS TIME-OUT");
+ devStatus = false;
+ }
+ devHandle = NULL;
+ mx.unlock();
+ return devStatus;
+}
+
+
+msg_error_t Sms3gppEventHandler::handleSimMsg(MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList, msg_message_id_t *retMsgId, int listSize)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Callback to MSG FW */
+ err = listener.pfSimMsgIncomingCb(pMsgInfo, simIdList, retMsgId, listSize);
+
+ MSG_END();
+
+ return err;
+}
+
+msg_error_t Sms3gppEventHandler::updateIMSI(int sim_idx)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Callback to MSG FW */
+ err = listener.pfSimInitImsiCb(sim_idx);
+
+ MSG_END();
+
+ return err;
+}
+
+void Sms3gppEventHandler::handleSimMemoryFull(int simIndex)
+{
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ bool bSimSst = true;
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, simIndex);
+ if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS)
+ MSG_ERR("MsgSettingGetBool [%s] failed", keyName);
+
+ if (bSimSst == true)
+ MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "MsgDebug.h"
+#include "MsgTextConvert.h"
+#include "Sms3gppUDCodec.h"
+#include "Sms3gppParamCodec.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppParamCodec - Member Functions
+==================================================================================================*/
+Sms3gppParamCodec::Sms3gppParamCodec()
+{
+}
+
+
+Sms3gppParamCodec::~Sms3gppParamCodec()
+{
+}
+
+
+/*==================================================================================================
+ Encode Functions
+==================================================================================================*/
+int Sms3gppParamCodec::encodeAddress(const SMS_3GPP_ADDRESS_S *pAddress, char **ppParam)
+{
+ int offset = 0, length = 0;
+ char *temp = (char *)pAddress->address;
+
+ SMS_3GPP_TON_T ton;
+
+ char *tempParam = new char[MAX_ADD_PARAM_LEN];
+ if (tempParam == NULL)
+ return 0;
+
+ memset(tempParam, 0x00, sizeof(char)*MAX_ADD_PARAM_LEN);
+
+ /* Set Address Length */
+ if (temp[0] == '+') {
+ tempParam[offset++] = strlen(temp) - 1;
+ temp++;
+
+ ton = SMS_TON_INTERNATIONAL;
+ } else {
+ tempParam[offset++] = strlen(temp);
+
+ ton = pAddress->ton;
+ }
+
+ /* Set TON, NPI */
+ tempParam[offset++] = 0x80 + (ton << 4) + pAddress->npi;
+
+ MSG_DEBUG("Address length is %d.", tempParam[0]);
+ MSG_DEBUG("pAddress->ton : %d.", ton);
+ MSG_DEBUG("pAddress->npi : %d.", pAddress->npi);
+
+ length = convertDigitToBcd(temp, strlen(temp), (unsigned char *) &(tempParam[offset]));
+
+ offset += length;
+
+ *ppParam = tempParam;
+
+ return offset ;
+}
+
+
+int Sms3gppParamCodec::encodeTime(const SMS_3GPP_TIMESTAMP_S *pTimeStamp, char **ppParam)
+{
+ int offset = 0;
+
+ if (pTimeStamp->format == SMS_3GPP_TIME_ABSOLUTE) {
+ int timeZone = pTimeStamp->time.absolute.timeZone;
+ *ppParam = new char[MAX_ABS_TIME_PARAM_LEN];
+
+ (*ppParam)[offset++] = ((pTimeStamp->time.absolute.year % 10) << 4) + (pTimeStamp->time.absolute.year / 10);
+ (*ppParam)[offset++] = ((pTimeStamp->time.absolute.month % 10) << 4) + (pTimeStamp->time.absolute.month / 10);
+ (*ppParam)[offset++] = ((pTimeStamp->time.absolute.day % 10) << 4) + (pTimeStamp->time.absolute.day / 10);
+ (*ppParam)[offset++] = ((pTimeStamp->time.absolute.hour % 10) << 4) + (pTimeStamp->time.absolute.hour / 10);
+ (*ppParam)[offset++] = ((pTimeStamp->time.absolute.minute % 10) << 4) + (pTimeStamp->time.absolute.minute / 10);
+ (*ppParam)[offset++] = ((pTimeStamp->time.absolute.second % 10) << 4) + (pTimeStamp->time.absolute.second / 10);
+
+ if (timeZone < 0) {
+ timeZone *= -1;
+ (*ppParam)[offset] = 0x08;
+ }
+ (*ppParam)[offset++] += ((pTimeStamp->time.absolute.timeZone % 10) << 4) + (pTimeStamp->time.absolute.timeZone / 10);
+
+
+ return offset;
+ } else if (pTimeStamp->format == SMS_3GPP_TIME_RELATIVE) {
+ *ppParam = new char[MAX_REL_TIME_PARAM_LEN+1];
+
+ memcpy(*ppParam, &(pTimeStamp->time.relative.time), MAX_REL_TIME_PARAM_LEN);
+
+ return MAX_REL_TIME_PARAM_LEN;
+ }
+
+ return offset;
+}
+
+
+int Sms3gppParamCodec::encodeDCS(const SMS_3GPP_DCS_S *pDCS, char **ppParam)
+{
+ *ppParam = new char[MAX_DCS_PARAM_LEN];
+
+ **ppParam = 0x00;
+
+ switch (pDCS->codingGroup) {
+ case SMS_GROUP_GENERAL: {
+ if (pDCS->msgClass != SMS_MSG_CLASS_NONE)
+ **ppParam = 0x10 + pDCS->msgClass;
+
+ if (pDCS->bCompressed)
+ **ppParam |= 0x20;
+ }
+ break;
+
+ case SMS_GROUP_CODING_CLASS: {
+ **ppParam = 0xF0 + pDCS->msgClass;
+ }
+ break;
+
+ case SMS_GROUP_DELETION:
+ /* not supported */
+ break;
+ case SMS_GROUP_DISCARD:
+ /* not supported */
+ break;
+ case SMS_GROUP_STORE:
+ /* not supported */
+ break;
+ default:
+ return 0;
+ }
+
+ switch (pDCS->codingScheme) {
+ case SMS_CHARSET_7BIT:
+ break;
+ case SMS_CHARSET_8BIT:
+ **ppParam |= 0x04;
+ break;
+ case SMS_CHARSET_UCS2:
+ **ppParam |= 0x08;
+ break;
+ default:
+ return 0;
+ }
+
+ return MAX_DCS_PARAM_LEN;
+}
+
+
+int Sms3gppParamCodec::encodeSMSC(const char *pAddress, unsigned char *pEncodeAddr)
+{
+ char newAddr[MAX_SMSC_LEN+1];
+ memset(newAddr, 0x00, sizeof(newAddr));
+
+/* MSG_DEBUG("SMSC [%s]", pAddress);
+*/
+ if (pAddress[0] == '+')
+ strncpy(newAddr, pAddress+1, MAX_SMSC_LEN);
+ else
+ strncpy(newAddr, pAddress, MAX_SMSC_LEN);
+
+ /* Set Address */
+ int encodeLen = convertDigitToBcd(newAddr, strlen(newAddr), pEncodeAddr);
+
+ pEncodeAddr[encodeLen] = '\0';
+
+ return encodeLen;
+}
+
+
+int Sms3gppParamCodec::encodeSMSC(const SMS_3GPP_ADDRESS_S *pAddress, unsigned char *pSMSC)
+{
+ char newAddr[MAX_SMSC_LEN+2]; // the size of pAddress->address is greater than newAddr. So +2.
+ memset(newAddr, 0x00, sizeof(newAddr));
+
+ int dataSize = 0, addrLen = 0;
+
+ if (pAddress->address[0] == '+') {
+ newAddr[strlen(pAddress->address)-1] = '\0';
+ memcpy(newAddr, pAddress->address+1, strlen(pAddress->address)-1);
+ } else {
+ memcpy(newAddr, pAddress->address, strlen(pAddress->address));
+ newAddr[strlen(pAddress->address)] = '\0';
+ }
+
+ addrLen = strlen(newAddr);
+
+ if (addrLen % 2 == 0) {
+ dataSize = 2 + (addrLen/2);
+ } else {
+ dataSize = 2 + (addrLen/2) + 1;
+ }
+
+ if (dataSize > MAX_SMSC_LEN) {
+ MSG_DEBUG("addrLen is too long [%d]", addrLen);
+ MSG_DEBUG("dataSize is too long [%d]", dataSize);
+
+ return 0;
+ }
+
+ /* Set Address Length
+ Check IPC 4.0 -> addrLen/2 */
+ pSMSC[0] = addrLen;
+
+ /* Set TON, NPI */
+ pSMSC[1] = 0x80 + (pAddress->ton << 4) + pAddress->npi;
+
+ /* Set Address */
+ convertDigitToBcd(newAddr, addrLen, &(pSMSC[2]));
+
+ pSMSC[dataSize] = '\0';
+
+ return dataSize;
+}
+
+
+/*==================================================================================================
+ Decode Functions
+==================================================================================================*/
+int Sms3gppParamCodec::decodeAddress(const unsigned char *pTpdu, SMS_3GPP_ADDRESS_S *pAddress)
+{
+ int offset = 0, addrLen = 0, bcdLen = 0;
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ memset(pAddress->address, 0x00, sizeof(pAddress->address));
+
+ addrLen = (int)pTpdu[offset++];
+
+ if (addrLen % 2 == 0)
+ bcdLen = addrLen/2;
+ else
+ bcdLen = addrLen/2 + 1;
+
+ pAddress->ton = (pTpdu[offset] & 0x70) >> 4;
+ pAddress->npi = pTpdu[offset++] & 0x0F;
+
+ MSG_DEBUG("ton [%d]", pAddress->ton);
+ MSG_DEBUG("npi [%d]", pAddress->npi);
+
+ if (pAddress->ton == SMS_TON_ALPHANUMERIC) {
+ MSG_DEBUG("Alphanumeric address");
+
+ char* tmpAddress = new char[MAX_ADDRESS_LEN];
+ int tmplength = 0;
+
+ tmplength = Sms3gppUDCodec::unpack7bitChar(&(pTpdu[offset]), (addrLen*4)/7, 0, tmpAddress);
+
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ textCvt->convertGSM7bitToUTF8((unsigned char*)pAddress->address, MAX_ADDRESS_LEN, (unsigned char*)tmpAddress, tmplength, &langInfo);
+
+ if (tmpAddress)
+ delete[] tmpAddress;
+ } else if (pAddress->ton == SMS_TON_INTERNATIONAL) {
+ convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[1]));
+ if (pAddress->address[1] != '\0')
+ pAddress->address[0] = '+';
+ } else {
+ convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[0]));
+ }
+
+ offset += bcdLen;
+
+/* MSG_DEBUG("address [%s]", pAddress->address);
+*/
+ return offset;
+}
+
+
+int Sms3gppParamCodec::decodeTime(const unsigned char *pTpdu, SMS_3GPP_TIMESTAMP_S *pTimeStamp)
+{
+ int offset = 0;
+
+ /* decode in ABSOLUTE time type. */
+ pTimeStamp->format = SMS_3GPP_TIME_ABSOLUTE;
+
+ pTimeStamp->time.absolute.year = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+ offset++;
+
+ pTimeStamp->time.absolute.month = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+ offset++;
+
+ pTimeStamp->time.absolute.day = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+ offset++;
+
+ pTimeStamp->time.absolute.hour = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+ offset++;
+
+ pTimeStamp->time.absolute.minute = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+ offset++;
+
+ pTimeStamp->time.absolute.second = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+ offset++;
+
+ pTimeStamp->time.absolute.timeZone = (pTpdu[offset] & 0x07)*10 + ((pTpdu[offset] & 0xF0) >> 4);
+
+ if (pTpdu[offset] & 0x08)
+ pTimeStamp->time.absolute.timeZone *= (-1);
+
+ offset++;
+
+ return offset;
+}
+
+
+int Sms3gppParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_3GPP_DCS_S *pDCS)
+{
+ int offset = 0;
+ char dcs = pTpdu[offset++];
+
+ pDCS->bMWI = false;
+ pDCS->bIndActive = false;
+ pDCS->indType = SMS_OTHER_INDICATOR;
+
+ if (((dcs & 0xC0) >> 6) == 0) {
+ pDCS->codingGroup = SMS_GROUP_GENERAL;
+ pDCS->bCompressed = (dcs & 0x20) >> 5;
+ pDCS->codingScheme = (dcs & 0x0C) >> 2;
+
+ if (((dcs & 0x10) >> 4) == 0)
+ pDCS->msgClass = SMS_MSG_CLASS_NONE;
+ else
+ pDCS->msgClass = dcs & 0x03;
+ } else if (((dcs & 0xF0) >> 4) == 0x0F) {
+ pDCS->codingGroup = SMS_GROUP_CODING_CLASS;
+ pDCS->bCompressed = false;
+ pDCS->codingScheme = (dcs & 0x0C) >> 2;
+
+ pDCS->msgClass = dcs & 0x03;
+ } else if (((dcs & 0xC0) >> 6) == 1) {
+ pDCS->codingGroup = SMS_GROUP_DELETION;
+ pDCS->bCompressed = false;
+ pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+ /* TODO: finish here. ?? */
+ } else if (((dcs & 0xF0) >> 4) == 0x0C) {
+ pDCS->codingGroup = SMS_GROUP_DISCARD;
+ pDCS->bCompressed = false;
+ pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+ pDCS->bMWI = true;
+ pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1) ? true : false;
+ pDCS->indType = (SMS_3GPP_INDICATOR_TYPE_T)(dcs & 0x03);
+ } else if (((dcs & 0xF0) >> 4) == 0x0D) {
+ pDCS->codingGroup = SMS_GROUP_STORE;
+ pDCS->codingScheme = SMS_CHARSET_7BIT;
+ pDCS->bCompressed = false;
+ pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+ pDCS->bMWI = true;
+ pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1) ? true : false;
+ pDCS->indType = (SMS_3GPP_INDICATOR_TYPE_T)(dcs & 0x03);
+ } else if (((dcs & 0xF0) >> 4) == 0x0E) {
+ pDCS->codingGroup = SMS_GROUP_STORE;
+ pDCS->codingScheme = SMS_CHARSET_UCS2;
+ pDCS->bCompressed = false;
+ pDCS->msgClass = SMS_MSG_CLASS_NONE;
+
+ pDCS->bMWI = true;
+ pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1) ? true : false;
+ pDCS->indType = (SMS_3GPP_INDICATOR_TYPE_T)(dcs & 0x03);
+ } else {
+ pDCS->codingGroup = SMS_GROUP_UNKNOWN;
+
+ pDCS->bCompressed = (dcs & 0x20) >> 5;
+ pDCS->codingScheme = (dcs & 0x0C) >> 2;
+
+ pDCS->msgClass = SMS_MSG_CLASS_NONE;
+ }
+
+ return offset;
+}
+
+
+void Sms3gppParamCodec::decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_SMS_TON_T ton, char *pDecodeAddr)
+{
+ if (pAddress == NULL || AddrLen == 0)
+ return;
+
+ if (ton == SMS_TON_INTERNATIONAL) {
+ pDecodeAddr[0] = '+';
+ convertBcdToDigit(pAddress, AddrLen, &(pDecodeAddr[1]));
+ } else {
+ convertBcdToDigit(pAddress, AddrLen, pDecodeAddr);
+ }
+}
+
+
+/*==================================================================================================
+ Util Functions
+==================================================================================================*/
+int Sms3gppParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd)
+{
+ int offset = 0;
+ unsigned char temp;
+
+/* MSG_DEBUG("DigitLen [%d]", DigitLen);
+ MSG_DEBUG("pDigit [%s]", pDigit); */
+
+ for (int i = 0; i < DigitLen; i++) {
+ if (pDigit[i] == '*')
+ temp = 0x0A;
+ else if (pDigit[i] == '#')
+ temp = 0x0B;
+ else if (pDigit[i] == 'P' || pDigit[i] == 'p')
+ temp = 0x0C;
+ else
+ temp = pDigit[i] - '0';
+
+ if ((i%2) == 0)
+ pBcd[offset] = temp & 0x0F;
+ else
+ pBcd[offset++] |= ((temp & 0x0F) << 4);
+ }
+
+ if ((DigitLen%2) == 1)
+ pBcd[offset++] |= 0xF0;
+
+ return offset;
+}
+
+
+int Sms3gppParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
+{
+ int offset = 0;
+ unsigned char temp;
+
+ for (int i = 0; i < BcdLen; i++) {
+ temp = pBcd[i] & 0x0F;
+
+ if (temp == 0x0A)
+ pDigit[offset++] = '*';
+ else if (temp == 0x0B)
+ pDigit[offset++] = '#';
+ else if (temp == 0x0C)
+ pDigit[offset++] = 'P';
+ else
+ pDigit[offset++] = temp + '0';
+
+ temp = (pBcd[i] & 0xF0) >> 4;
+
+ if (temp == 0x0F) {
+ pDigit[offset] = '\0';
+ return offset;
+ }
+
+ if (temp == 0x0A)
+ pDigit[offset++] = '*';
+ else if (temp == 0x0B)
+ pDigit[offset++] = '#';
+ else if (temp == 0x0C)
+ pDigit[offset++] = 'P';
+ else
+ pDigit[offset++] = temp + '0';
+ }
+
+ pDigit[offset] = '\0';
+
+ return offset;
+}
+
+bool Sms3gppParamCodec::checkCphsVmiMsg(const unsigned char *pTpdu, int *setType, int *indType)
+{
+ bool ret = false;
+
+ int offset = 0;
+ int addrLen = 0;
+
+ addrLen = (int)pTpdu[offset++];
+
+ if (addrLen == 0x04 && pTpdu[offset++] == 0xD0) {
+ if (pTpdu[offset] == 0x11 || pTpdu[offset] == 0x10) {
+ MSG_DEBUG("####### VMI msg ######");
+ *setType = (int)(pTpdu[offset] & 0x01); /* 0 : clear, 1 : set */
+ *indType = (int)(pTpdu[offset+1] & 0x01); /* 0 : indicator 1, 1 : indicator 2 */
+
+ ret = true;
+ }
+ }
+
+ return ret;
+}
+
+time_t Sms3gppParamCodec::convertTime(const SMS_3GPP_TIMESTAMP_S *time_stamp)
+{
+ time_t rawtime;
+
+ if (time_stamp->format == SMS_3GPP_TIME_ABSOLUTE) {
+ MSG_DEBUG("year : %d", time_stamp->time.absolute.year);
+ MSG_DEBUG("month : %d", time_stamp->time.absolute.month);
+ MSG_DEBUG("day : %d", time_stamp->time.absolute.day);
+ MSG_DEBUG("hour : %d", time_stamp->time.absolute.hour);
+ MSG_DEBUG("minute : %d", time_stamp->time.absolute.minute);
+ MSG_DEBUG("second : %d", time_stamp->time.absolute.second);
+ MSG_DEBUG("timezone : %d", time_stamp->time.absolute.timeZone);
+
+ char displayTime[32];
+ struct tm timeTM;
+ memset(&timeTM, 0x00, sizeof(tm));
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ timeinfo.tm_year = (time_stamp->time.absolute.year + 100);
+ timeinfo.tm_mon = (time_stamp->time.absolute.month - 1);
+ timeinfo.tm_mday = time_stamp->time.absolute.day;
+ timeinfo.tm_hour = time_stamp->time.absolute.hour;
+ timeinfo.tm_min = time_stamp->time.absolute.minute;
+ timeinfo.tm_sec = time_stamp->time.absolute.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%ld]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (time_stamp->time.absolute.timeZone * (3600/4));
+
+ localtime_r(&rawtime, &timeTM);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+/* timezone value is tiemzone + daylight. So should not add daylight */
+#ifdef __MSG_DAYLIGHT_APPLIED__
+ rawtime -= (timezone - daylight*3600);
+#else
+ rawtime -= timezone;
+#endif
+
+ memset(&timeTM, 0x00, sizeof(tm));
+ localtime_r(&rawtime, &timeTM);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ } else {
+ rawtime = time(NULL);
+ }
+
+ return rawtime;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgUtilStorage.h"
+#include "Sms3gppParamCodec.h"
+#include "Sms3gppUDCodec.h"
+#include "Sms3gppTpduCodec.h"
+#include "Sms3gppSetting.h"
+#include "Sms3gppTransport.h"
+#include "include/Sms3gppTapiEventHandler.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppSatHandler.h"
+#include "SmsPluginDSHandler.h"
+
+#include <tapi_common.h>
+#include <TelSms.h>
+#include <TapiUtility.h>
+#include <ITapiNetText.h>
+#include <ITapiSat.h>
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppCbMsgHandler - Member Functions
+==================================================================================================*/
+Sms3gppSatHandler* Sms3gppSatHandler::pInstance = NULL;
+
+
+Sms3gppSatHandler::Sms3gppSatHandler()
+{
+ commandId = 0;
+
+ bInitSim = false;
+ bSMSPChanged = false;
+ bCBMIChanged = false;
+}
+
+
+Sms3gppSatHandler::~Sms3gppSatHandler()
+{
+}
+
+
+Sms3gppSatHandler* Sms3gppSatHandler::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppSatHandler();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gppSatHandler::refreshSms(TapiHandle *handle, void *pData)
+{
+/*
+ TelSatRefreshInd_t* pRefreshData = (TelSatRefreshInd_t*)pData;
+
+ if (pRefreshData->appType != TAPI_SAT_REFRESH_MSG)
+ {
+ MSG_DEBUG("App Type is wrong. [%d]", pRefreshData->appType);
+ return;
+ }
+
+ commandId = pRefreshData->commandId;
+
+ switch (pRefreshData->refreshMode)
+ {
+ case TAPI_SAT_REFRESH_SIM_INIT_AND_FULL_FCN :
+ case TAPI_SAT_REFRESH_SIM_INIT_AND_FCN :
+ {
+ for (int i = 0; i < pRefreshData->fileCount; i++)
+ {
+ if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
+ (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
+ {
+ bSMSPChanged = true;
+ }
+ else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
+ (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
+ {
+ bCBMIChanged = true;
+ }
+ }
+
+ initSim();
+ }
+ break;
+
+ case TAPI_SAT_REFRESH_FCN :
+ {
+ for (int i = 0; i < pRefreshData->fileCount; i++)
+ {
+ if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
+ (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
+ {
+ bSMSPChanged = true;
+ }
+ else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
+ (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
+ {
+ bCBMIChanged = true;
+ }
+ }
+ }
+ break;
+
+ case TAPI_SAT_REFRESH_SIM_INIT :
+ {
+ initSim();
+ }
+ break;
+
+ default:
+ break;
+ }
+ */
+}
+
+
+void Sms3gppSatHandler::sendSms(TapiHandle *handle, void *pData)
+{
+ TelSatSendSmsIndSmsData_t* pSmsData = (TelSatSendSmsIndSmsData_t*)pData;
+
+ commandId = pSmsData->commandId;
+
+ MSG_DEBUG("commandId [%d]", commandId);
+
+ /* The TPDU Maximum Length at SAT side is 175
+ This is because Sat can send 160 bytes unpacked and header */
+ unsigned char tpdu[MAX_SAT_TPDU_LEN+1];
+ int tpduLen = 0;
+
+ memset(tpdu, 0x00, sizeof(tpdu));
+ memcpy(tpdu, pSmsData->smsTpdu.data, pSmsData->smsTpdu.dataLen);
+
+ /* Modify Parameters, Pack User Data */
+ tpduLen = handleSatTpdu(tpdu, pSmsData->smsTpdu.dataLen, pSmsData->bIsPackingRequired);
+
+ if (tpduLen <= 0) {
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
+ return;
+ } else if (tpduLen > MAX_SAT_TPDU_LEN) {
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
+ return;
+ }
+
+ /* Make Telephony Structure */
+ TelSmsDatapackageInfo_t pkgInfo;
+
+ /* Set TPDU data */
+ memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+ memcpy((void*)pkgInfo.szData, tpdu, tpduLen);
+
+ pkgInfo.szData[tpduLen] = '\0';
+ pkgInfo.MsgLength = tpduLen;
+ pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
+
+ /* Set SMSC Address */
+ SMS_3GPP_ADDRESS_S smsc = {0,};
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (pSmsData->address.diallingNumberLen > 0) {
+ smsc.ton = pSmsData->address.ton;
+ smsc.npi = pSmsData->address.npi;
+ int wrn = snprintf(smsc.address, sizeof(smsc.address), "%s", pSmsData->address.diallingNumber);
+ if(wrn<0)
+ MSG_DEBUG("snprintf was failed");
+
+ MSG_SEC_DEBUG("SCA TON[%d], NPI[%d], LEN[%zu], ADDR[%s]", smsc.ton, smsc.npi, strlen(smsc.address), smsc.address);
+ } else {
+ /* Set SMSC Options */
+ Sms3gppTransport::instance()->setSmscOptions(simIndex, &smsc);
+ }
+
+ unsigned char smscAddr[MAX_SMSC_LEN];
+ int smscLen = 0;
+
+ memset(smscAddr, 0x00, sizeof(smscAddr));
+ smscLen = Sms3gppParamCodec::encodeSMSC(&smsc, smscAddr);
+
+ if (smscLen <= 0)
+ return;
+
+ /* Set SMSC Address */
+ memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+ memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+ pkgInfo.Sca[smscLen] = '\0';
+
+ int tapiRet = TAPI_API_SUCCESS;
+
+ /* Send SMS */
+ tapiRet = tel_send_sms(handle, &pkgInfo, 0, Sms3gppTapiEventHandler::respSatSmsSentStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## TelTapiSmsSend Success !!! return : %d #######", tapiRet);
+ } else {
+ MSG_DEBUG("######## TelTapiSmsSend Fail !!! return : %d #######", tapiRet);
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
+ }
+}
+
+
+void Sms3gppSatHandler::ctrlSms(TapiHandle *handle, void *pData)
+{
+ if (!pData) {
+ MSG_ERR("pData is NULL");
+ return;
+ }
+
+ TelSatMoSmCtrlIndData_t* pCtrlData = (TelSatMoSmCtrlIndData_t*)pData;
+
+#if 0
+ if (bSendSmsbySat == true) {
+ /* Send SMS By SAT */
+ MSG_DEBUG("Event Noti for sending message by SAT : result = [%d]", pCtrlData->moSmsCtrlResult);
+ } else {
+ /* Send SMS By APP */
+ Sms3gppTransport::instance()->setMoCtrlStatus(pCtrlData);
+ }
+#else
+ if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
+ MsgInsertTicker("Sending message failed : blocked by call control", NULL, true, 0);
+ }
+#endif
+
+ return;
+
+#if 0
+ if (bSendSms == true) { /* Send SMS By SAT */
+ if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
+ MSG_DEBUG("SIM does not allow to send SMS");
+
+ sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM);
+ } else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
+ MSG_DEBUG("SIM allows to send SMS with modification");
+
+ sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
+ }
+ } else { /* Send SMS By APP */
+ msg_network_status_t netStatus = MSG_NETWORK_NOT_SEND;
+
+ if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
+ MSG_DEBUG("SIM does not allow to send SMS");
+
+ netStatus = MSG_NETWORK_SEND_FAIL;
+ } else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
+ MSG_DEBUG("SIM allows to send SMS with modification");
+
+ netStatus = MSG_NETWORK_SEND_SUCCESS;
+ }
+
+ /* Call Event Handler */
+ Sms3gppEventHandler::instance()->handleSentStatus(netStatus);
+ }
+#endif
+}
+
+
+void Sms3gppSatHandler::ctrlSms(TapiHandle *handle, SMS_NETWORK_STATUS_T smsStatus)
+{
+ MSG_DEBUG("SMS network status = [%d]", smsStatus);
+
+ if (smsStatus == SMS_NETWORK_SEND_SUCCESS) {
+ MSG_DEBUG("Sending SMS by SAT is OK");
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
+ } else if (smsStatus == SMS_NETWORK_SEND_FAIL) {
+ MSG_ERR("Sending SMS by SAT is failed");
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SMS_RP_ERROR);
+ } else if (smsStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING) {
+ MSG_ERR("Sending SMS by SAT is failed, but result is 'success'");
+ /* sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_ERROR_REQUIRED_VALUES_ARE_MISSING); */
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
+ } else if (smsStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED) {
+ MSG_ERR("Sending SMS is failed by MO control");
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM);
+ } else if (smsStatus == SMS_NETWORK_SEND_FAIL_NO_ROUTING) {
+ MSG_ERR("Sending SMS is failed by no routing");
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_NETWORK_UNABLE_TO_PROCESS_COMMAND);
+ } else {
+ /*Default case*/
+ MSG_ERR("Sending SMS by SAT is failed");
+ sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SMS_RP_ERROR);
+ }
+
+#if 0 /* no ticker and sound for sending SAT sms failure case. */
+ if (smsStatus != SMS_NETWORK_SEND_SUCCESS) {
+ MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, 0);
+ }
+#endif
+}
+
+#if 0
+void Sms3gppSatHandler::finishSimMsgInit(msg_error_t Err)
+{
+ /* SAT Handler is initializing SIM now */
+ if (bInitSim == true) {
+ /* Init SMSC List and CB ID Info */
+ try {
+ if (bSMSPChanged == true) initSMSCList();
+ } catch (MsgException& e) {
+ /* Send Result to TAPI */
+ sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
+
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+
+ try {
+ if (bCBMIChanged == true) initCBConfig();
+ } catch (MsgException& e) {
+ /* Send Result to TAPI */
+ sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
+
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+
+ /* Send Result to TAPI */
+ sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_SUCCESS);
+ }
+}
+
+
+void Sms3gppSatHandler::initSim()
+{
+ bInitSim = true;
+
+ /* Init SIM Message */
+ if (Sms3gppEventHandler::instance()->callbackInitSimBySat() != MSG_SUCCESS) {
+ MSG_DEBUG("Init Sim Error");
+
+ /* Send Result to TAPI */
+ sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
+ }
+}
+
+
+void Sms3gppSatHandler::initSMSCList()
+{
+ MSG_SETTING_S settingData;
+
+ settingData.type = MSG_SMSC_LIST;
+
+ /* Get Data From SIM */
+ Sms3gppSetting::instance()->getConfigData(&settingData);
+
+ MSG_DEBUG("total_count[%d]", settingData.option.smscList.totalCnt);
+ MSG_DEBUG("selected[%d]", settingData.option.smscList.selected);
+
+ for (int i = 0; i < settingData.option.smscList.totalCnt; i++) {
+ MSG_DEBUG("pid[%d]", settingData.option.smscList.smscData[i].pid);
+ MSG_DEBUG("val_period[%d]", settingData.option.smscList.smscData[i].valPeriod);
+ MSG_SEC_DEBUG("name[%s]", settingData.option.smscList.smscData[i].name);
+
+ MSG_DEBUG("ton[%d]", settingData.option.smscList.smscData[i].smscAddr.ton);
+ MSG_DEBUG("npi[%d]", settingData.option.smscList.smscData[i].smscAddr.npi);
+ MSG_SEC_DEBUG("address[%s]", settingData.option.smscList.smscData[i].smscAddr.address);
+ }
+
+ if (MsgSettingSetInt(SMSC_SELECTED, settingData.option.smscList.selected) != MSG_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", SMSC_SELECTED);
+ return;
+ }
+
+ if (MsgSettingSetInt(SMSC_TOTAL_COUNT, settingData.option.smscList.totalCnt) != MSG_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", SMSC_TOTAL_COUNT);
+ return;
+ }
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ msg_error_t err = MSG_SUCCESS;
+
+ for (int i = 0; i < settingData.option.smscList.totalCnt; i++) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_PID, i);
+
+ if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].pid)) != MSG_SUCCESS)
+ break;
+
+#if 0
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_DCS, i);
+
+ if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].dcs)) != MSG_SUCCESS)
+ break;
+#endif
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_VAL_PERIOD, i);
+
+ if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].valPeriod)) != MSG_SUCCESS)
+ break;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_NAME, i);
+
+ if ((err = MsgSettingSetString(keyName, settingData.option.smscList.smscData[i].name)) != MSG_SUCCESS)
+ break;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_TON, i);
+
+ if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].smscAddr.ton)) != MSG_SUCCESS)
+ break;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_NPI, i);
+
+ if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].smscAddr.npi)) != MSG_SUCCESS)
+ break;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_ADDRESS, i);
+
+ if ((err = MsgSettingSetString(keyName, settingData.option.smscList.smscData[i].smscAddr.address)) != MSG_SUCCESS)
+ break;
+ }
+
+ if (err != MSG_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", keyName);
+ }
+}
+
+
+void Sms3gppSatHandler::initCBConfig()
+{
+ MSG_SETTING_S settingData;
+
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ settingData.type = MSG_CBMSG_OPT;
+
+ /* Get Data From SIM */
+ Sms3gppSetting::instance()->getConfigData(&settingData);
+
+ if (MsgSettingSetBool(CB_RECEIVE, settingData.option.cbMsgOpt.bReceive) != MSG_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_RECEIVE);
+ return;
+ }
+
+ if (MsgSettingSetInt(CB_MAX_SIM_COUNT, settingData.option.cbMsgOpt.maxSimCnt) != MSG_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_MAX_SIM_COUNT);
+ return;
+ }
+
+ err = MsgStoAddCBChannelInfo(dbHandle, &(settingData.option.cbMsgOpt.channelData), settingData.option.cbMsgOpt.simIndex);
+ MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
+
+ if (err != MSG_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "Error to set config data");
+ }
+}
+#endif
+
+int Sms3gppSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired)
+{
+ if (pTpdu == NULL)
+ THROW(MsgException::SMS_PLG_ERROR, "SAT TPDU is NULL");
+
+ int pos = 0;
+
+ /* TP-MTI, TP-RD, TP-VPF, TP-RP, TP-UDHI, TP-SRR */
+ /* TP-VPF */
+ SMS_3GPP_VPF_T vpf = (SMS_3GPP_VPF_T)(pTpdu[pos++] & 0x18) >> 3;
+
+ /* TP-MR */
+ unsigned char tmpRef = pTpdu[pos];
+
+ MSG_DEBUG("current Msg Ref : %d", tmpRef);
+
+ pTpdu[pos] = tmpRef + 1;
+
+ MSG_DEBUG("new Msg Ref : %d", pTpdu[pos]);
+
+ pos++;
+
+ /*pTpdu[pos++] = SmsPluginTransport::instance()->getMsgRef(); */
+
+
+ /* TP-DA */
+ SMS_3GPP_ADDRESS_S destAddr = {0};
+ int addrLen = Sms3gppParamCodec::decodeAddress(&pTpdu[pos], &destAddr);
+
+ pos += addrLen;
+
+ /* TP-PID */
+ pos++;
+
+ /* TP-DCS */
+ SMS_3GPP_DCS_S dcs = {0};
+
+ int dcsLen = Sms3gppParamCodec::decodeDCS(&pTpdu[pos], &dcs);
+
+ if (bIsPackingRequired == true) {
+ dcs.codingScheme = SMS_CHARSET_7BIT;
+
+ char* pDcs = NULL;
+ unique_ptr<char*, void(*)(char**)> dcsBuf(&pDcs, unique_ptr_deleter);
+
+ Sms3gppParamCodec::encodeDCS(&dcs, &pDcs);
+
+ memcpy(&(pTpdu[pos]), pDcs, dcsLen);
+ }
+
+ pos++;
+
+ /* TP-VP */
+ if (vpf == SMS_VPF_RELATIVE)
+ pos += MAX_REL_TIME_PARAM_LEN;
+ else if (vpf == SMS_VPF_ABSOLUTE)
+ pos += MAX_ABS_TIME_PARAM_LEN;
+
+ /* TP-UDL */
+ int udl = pTpdu[pos];
+ int retLen = 0;
+
+ if (bIsPackingRequired == true) {
+ SMS_3GPP_USERDATA_S userData = {0};
+
+ userData.headerCnt = 0;
+ userData.length = udl;
+ memcpy(userData.data, &pTpdu[pos+1], udl);
+ userData.data[udl] = '\0';
+
+ MSG_DEBUG("user data : [%s]", userData.data);
+
+ /* check for user data whether it is 7-bit packed or not. */
+ bool is7bitPacked = false;
+ int bitValue = 0;
+ for (int i = 0; i < userData.length; i++) {
+ bitValue = userData.data[i] & (1 << 7);
+ if (bitValue != 0) {
+ is7bitPacked = true;
+ MSG_DEBUG("user data is already 7-bit packed !!");
+ break;
+ }
+ }
+
+ if (!is7bitPacked) {
+ MSG_DEBUG("packing 8-bit user data to 7-bit charset !!");
+ int encodeSize = Sms3gppUDCodec::encodeUserData(&userData, dcs.codingScheme, (char*)&pTpdu[pos]);
+ retLen = pos + encodeSize;
+ } else {
+ retLen = TpduLen;
+ }
+ } else {
+ retLen = TpduLen;
+ }
+
+ return retLen;
+}
+
+
+void Sms3gppSatHandler::sendResult(TapiHandle *handle, SMS_3GPP_SAT_CMD_TYPE_T CmdType, int ResultType)
+{
+ TelSatAppsRetInfo_t satRetInfo;
+ memset(&satRetInfo, 0, sizeof(TelSatAppsRetInfo_t));
+
+ satRetInfo.commandId = commandId;
+
+ MSG_INFO("satRetInfo.commandId [%d]", satRetInfo.commandId);
+
+ if (CmdType == SMS_SAT_CMD_REFRESH) {
+ satRetInfo.commandType = TAPI_SAT_CMD_TYPE_REFRESH;
+
+ satRetInfo.appsRet.refresh.appType = TAPI_SAT_REFRESH_MSG;
+ satRetInfo.appsRet.refresh.resp = (TelSatResultType_t)ResultType;
+ } else if (CmdType == SMS_SAT_CMD_SEND_SMS) {
+ satRetInfo.commandType = TAPI_SAT_CMD_TYPE_SEND_SMS;
+
+ satRetInfo.appsRet.sendSms.resp = (TelSatResultType_t)ResultType;
+ }
+
+ int tapiRet = TAPI_API_SUCCESS;
+
+ tapiRet = tel_send_sat_app_exec_result(handle, &satRetInfo);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("TelTapiSatSendAppExecutionResult() SUCCESS");
+ else
+ MSG_ERR("TelTapiSatSendAppExecutionResult() FAIL [%d]", tapiRet);
+
+ bInitSim = false;
+ bSMSPChanged = false;
+ bCBMIChanged = false;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+#include <pthread.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgContact.h"
+#include "MsgUtilStorage.h"
+#include "MsgTextConvert.h"
+#include "MsgDevicedWrapper.h"
+
+#include "SmsPluginDSHandler.h"
+#include "SmsPluginMain.h"
+#include "Sms3gppParamCodec.h"
+#include "Sms3gppTapiEventHandler.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppSimMsg.h"
+#include "Sms3gppSetting.h"
+
+#include <tapi_common.h>
+#include <TelSms.h>
+#include <TapiUtility.h>
+#include <ITapiNetText.h>
+#include <ITapiSim.h>
+#include <ITapiModem.h>
+
+/*==================================================================================================
+ INTERNAL FUNCTION
+==================================================================================================*/
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppSetting - Member Functions
+==================================================================================================*/
+Sms3gppSetting* Sms3gppSetting::pInstance = NULL;
+
+
+Sms3gppSetting::Sms3gppSetting()
+{
+ /* Initialize member variables */
+ for (int i = 0; i <= MAX_TELEPHONY_HANDLE_CNT; i++) {
+ simStatus[i] = MSG_SIM_STATUS_NOT_FOUND;
+ }
+ smscList.clear();
+ simMailboxList.clear();
+ simMwiInfo.clear();
+ cbOpt.clear();
+ memset(&meImei, 0x00, sizeof(meImei));
+ memset(&smscData, 0x00, sizeof(smscData));
+
+ bTapiResult = false;
+ paramCnt = 0;
+ selectedParam = 0;
+ selectedSimIndex = 0;
+
+ for (int i = 0; i < MAX_TELEPHONY_HANDLE_CNT; i++)
+ bMbdnEnable[i] = false;
+}
+
+
+Sms3gppSetting::~Sms3gppSetting()
+{
+ smscList.erase(smscList.begin(), smscList.end());
+ simMailboxList.erase(simMailboxList.begin(), simMailboxList.end());
+ simMwiInfo.erase(simMwiInfo.begin(), simMwiInfo.end());
+ cbOpt.erase(cbOpt.begin(), cbOpt.end());
+}
+
+
+Sms3gppSetting* Sms3gppSetting::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppSetting();
+ }
+
+ return pInstance;
+}
+
+
+void* Sms3gppSetting::initSimInfo(void *data)
+{
+ static MsgMutex mm;
+ MsgMutexLocker lock(mm);
+
+ instance()->processInitSimInfo(data);
+
+ return NULL;
+}
+
+void* Sms3gppSetting::processInitSimInfo(void *data)
+{
+ MSG_BEGIN();
+
+ /* Handle sim info initialization separately */
+ TapiHandle *handle = (TapiHandle *)data;
+ instance()->updateSimStatus(handle);
+
+ MSG_END();
+ return NULL;
+}
+
+
+void Sms3gppSetting::updateSimStatus(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ MSG_ERR_RET_M(!handle, "handle is NULL!");
+
+ int status = 0;
+ int tapiRet = TAPI_API_SUCCESS;
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+
+ /* Get IMSI */
+ TelSimImsiInfo_t imsiInfo;
+ memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
+
+ tapiRet = tel_get_sim_imsi(handle, &imsiInfo);
+ if (tapiRet != TAPI_API_SUCCESS) {
+ MSG_SEC_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
+ }
+
+ /* Save Subcriber ID */
+ char *subscriberId = NULL;
+ memset(keyName, 0x00, sizeof(keyName));
+
+ if (SmsPluginDSHandler::instance()->getSubscriberId(simIndex, &subscriberId) != MSG_SUCCESS) {
+ MSG_DEBUG("getSubscriberId() is failed");
+ } else {
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, simIndex);
+ if (MsgSettingSetString(keyName, subscriberId) != MSG_SUCCESS)
+ MSG_DEBUG("Fail MsgSettingSetString");
+ }
+
+ g_free(subscriberId); subscriberId = NULL;
+
+ /* Check device status */
+ tapiRet = tel_check_sms_device_status(handle, &status);
+
+ if (tapiRet != TAPI_API_SUCCESS) {
+ MSG_DEBUG("tel_check_sms_device_status() Error! [%d], Status [%d]", tapiRet, status);
+ return;
+ }
+
+ if (status == TAPI_NETTEXT_READY_STATUS_3GPP) {
+ MSG_DEBUG("Device Is Ready");
+ } else {
+ MSG_DEBUG("Device Is Not Ready.. Waiting For Ready Callback");
+
+ if (Sms3gppEventHandler::instance()->getDeviceStatus(handle) == true) {
+ MSG_DEBUG("Device Is Ready");
+ } else {
+ MSG_DEBUG("Device Is Not Ready.");
+ return;
+ }
+ }
+
+ /* init config data. */
+ initConfigData(handle);
+
+ try {
+ /* init sim messages. */
+ Sms3gppSimMsg::instance()->initSimMessage(handle);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+
+
+ MSG_END();
+
+ return;
+}
+
+
+void Sms3gppSetting::initConfigData(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ /*==================== SMSC setting ====================*/
+ /* Init SMS Parameter */
+ int paramCnt = 0;
+ int failCnt = 0;
+ bool bSelectedFound = false;
+ bool bAPReceive = false;
+
+ paramCnt = getParamCount(handle);
+
+ MSG_INFO("Parameter Count [%d]", paramCnt);
+
+ MSG_SMSC_DATA_S tmpSmscData = {};
+ MSG_SMSC_LIST_S tmpSmscList = {0, };
+
+ for (int index = 0; index < paramCnt; index++) {
+ memset(&tmpSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
+ if (getParam(handle, index, &tmpSmscData) == false) {
+ failCnt++;
+ continue;
+ }
+
+ memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
+
+ MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid);
+ MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod);
+ MSG_SEC_DEBUG("name[%s]", tmpSmscList.smscData[index].name);
+
+ MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton);
+ MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
+ MSG_SEC_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
+
+ /* First smsc is selected index */
+ if (!bSelectedFound) {
+ tmpSmscList.selected = selectedParam;
+ bSelectedFound = !bSelectedFound;
+ }
+ }
+
+ tmpSmscList.totalCnt = (paramCnt - failCnt);
+ tmpSmscList.simIndex = sim_idx;
+
+ if (paramCnt > 0) {
+ MSG_DEBUG("######## Add SMSC ist #######");
+ addSMSCList(&tmpSmscList);
+ }
+
+ /*==================== CB configuration ====================*/
+ if (simStatus[sim_idx] != MSG_SIM_STATUS_NOT_FOUND) {
+ MSG_DEBUG("simStatus == [%d]", simStatus[sim_idx]);
+
+ MSG_CBMSG_OPT_S cbMsgOpt = {0, };
+ cbMsgOpt.simIndex = sim_idx;
+
+ if (getCbConfig(&cbMsgOpt) == true) {
+ cbMsgOpt.simIndex = sim_idx;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, sim_idx);
+ if (MsgSettingGetBool(keyName, &bAPReceive) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ if (cbMsgOpt.bReceive == false && bAPReceive == false) {
+ MSG_DEBUG("CB is off in CP and in AP. No need to send CB request to CP. ");
+ } else {
+ MSG_DEBUG("######## Add CB Option Success !!! #######");
+ MSG_SETTING_S cbSetting;
+ getCbOpt(&cbSetting, sim_idx);
+ setCbConfig(&(cbSetting.option.cbMsgOpt));
+ }
+ } else {
+ MSG_WARN("######## getCbConfig Fail !!! #######");
+ }
+
+ /*==================== Default Voice mail Setting ====================*/
+ if (simStatus[sim_idx] == MSG_SIM_STATUS_CHANGED) {
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ MSG_INFO("=================SIM CHANGED===================");
+ /* reset voicemail number */
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+ if (MsgSettingSetString(keyName, "") != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetString is failed!!");
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx);
+ if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetInt is failed!!");
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, sim_idx);
+ if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetString is failed!!");
+
+ MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_1, sim_idx);
+ MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, sim_idx);
+ }
+
+ /*==================== Voice mail information update ====================*/
+ if (getVoiceMailInfo(handle) == true) {
+ MSG_DEBUG("######## getVoiceMailInfo Success !!! #######");
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+
+ char *voiceNumber = NULL;
+ if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ if (!voiceNumber || (voiceNumber && voiceNumber[0] == '\0')) {
+ MSG_WARN("Voice Number is Empty!!");
+ }
+
+ if (voiceNumber) {
+ free(voiceNumber);
+ voiceNumber = NULL;
+ }
+ } else {
+ MSG_WARN("######## getVoiceMailInfo Fail !!! #######");
+ }
+
+ /*==================== Voice mail count update ====================*/
+ if (getMwiInfo(handle) == true) {
+ MSG_DEBUG("######## getMwiInfo Success !!! #######");
+ } else {
+ MSG_WARN("######## getMwiInfo Fail !!! #######");
+
+ /* Get MWI from vconf and insert notification */
+ int mwiCnt = 0;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx);
+ if (MsgSettingGetInt(keyName, &mwiCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ if (mwiCnt > 0)
+ deliverVoiceMsgNoti(sim_idx, mwiCnt);
+ }
+
+ /*==================== MSISDN update ====================*/
+ if (getMsisdnInfo(handle) == true) {
+ MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
+ } else {
+ MSG_WARN("######## getMsisdnInfo Fail !!! #######");
+ }
+
+ /*==================== SST(SIM Service Table) update ====================*/
+ if (getSimServiceTable(handle) == true) {
+ MSG_DEBUG("######## getSimServiceTable Success !!! #######");
+ } else {
+ MSG_WARN("######## getSimServiceTable Fail !!! #######");
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gppSetting::SimRefreshCb(TapiHandle *handle)
+{
+ pthread_t thd;
+
+ if (pthread_create(&thd, NULL, &init_config_data, handle) < 0) {
+ MSG_ERR("pthread_create() error");
+ return;
+ }
+
+ pthread_detach(thd);
+}
+
+
+void* Sms3gppSetting::init_config_data(void *data)
+{
+ TapiHandle *handle = (TapiHandle *)data;
+ instance()->initConfigData(handle);
+ return NULL;
+}
+
+
+void Sms3gppSetting::setConfigData(const MSG_SETTING_S *pSetting)
+{
+ MSG_DEBUG("Setting Type : [%d]", pSetting->type);
+
+ switch (pSetting->type) {
+#if 0
+ case MSG_SMS_SENDOPT :
+ setNetworkMode(&pSetting->option.smsSendOpt);
+ break;
+#endif
+ case MSG_SMSC_LIST :
+ setParamList(&pSetting->option.smscList);
+ addSMSCList((MSG_SMSC_LIST_S *)(&pSetting->option.smscList));
+ break;
+ case MSG_CBMSG_OPT :
+ if (setCbConfig(&pSetting->option.cbMsgOpt) == false) {
+ THROW(MsgException::SMS_PLG_ERROR, "Failed to set config.");
+ }
+ break;
+ case MSG_VOICEMAIL_OPT:
+ setVoiceMailInfo(&pSetting->option.voiceMailOpt);
+ break;
+ default :
+ THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+ break;
+ }
+}
+
+
+void Sms3gppSetting::getConfigData(MSG_SETTING_S *pSetting)
+{
+ MSG_DEBUG("Setting Type : [%d]", pSetting->type);
+
+ switch (pSetting->type) {
+ case MSG_SMSC_LIST :
+ getSmscListInfo(pSetting->option.smscList.simIndex, &(pSetting->option.smscList));
+ break;
+
+ case MSG_CBMSG_OPT :
+ if (getCbConfig(&pSetting->option.cbMsgOpt) == false) {
+ THROW(MsgException::SMS_PLG_ERROR, "Get CB config option failed.");
+ }
+ break;
+
+ default :
+ THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+ break;
+ }
+}
+
+
+void Sms3gppSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
+{
+ MSG_BEGIN();
+
+ int sim_index = -1;
+
+ MSG_DEBUG("SIM index[%d]", pSmscList->simIndex);
+ MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
+ MSG_DEBUG("selected index[%d]", pSmscList->selected);
+
+ for (int i = 0; i < pSmscList->totalCnt; i++) {
+ MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
+ MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
+ MSG_SEC_DEBUG("name[%s]", pSmscList->smscData[i].name);
+
+ MSG_DEBUG("ton[%d]", pSmscList->smscData[i].smscAddr.ton);
+ MSG_DEBUG("npi[%d]", pSmscList->smscData[i].smscAddr.npi);
+ MSG_SEC_DEBUG("address[%s]", pSmscList->smscData[i].smscAddr.address);
+ }
+
+ sim_index = pSmscList->simIndex;
+
+ smscListMap::iterator it = smscList.find(pSmscList->simIndex);
+ if (it == smscList.end()) {
+ pair<int, MSG_SMSC_LIST_S> newList(sim_index, *pSmscList);
+ smscList.insert(newList);
+ } else {
+ /* update the list. */
+ MSG_SMSC_LIST_S &pTmpSmscList = it->second;
+ pTmpSmscList.simIndex = pSmscList->simIndex;
+ pTmpSmscList.totalCnt = pSmscList->totalCnt;
+ pTmpSmscList.selected = pSmscList->selected;
+
+ for (int i = 0; i < pSmscList->totalCnt; i++) {
+ pTmpSmscList.smscData[i].pid = pSmscList->smscData[i].pid;
+ pTmpSmscList.smscData[i].valPeriod = pSmscList->smscData[i].valPeriod;
+ memset(pTmpSmscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1);
+ memcpy(pTmpSmscList.smscData[i].name, pSmscList->smscData[i].name, SMSC_NAME_MAX);
+
+ memset(pTmpSmscList.smscData[i].smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
+ memcpy(pTmpSmscList.smscData[i].smscAddr.address, pSmscList->smscData[i].smscAddr.address, SMSC_ADDR_MAX);
+
+ if (pTmpSmscList.smscData[i].smscAddr.address[0] == '+')
+ pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
+ else
+ pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
+
+ pTmpSmscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; /* app cannot set this value */
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gppSetting::getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList)
+{
+ if (pSmscList == NULL) {
+ MSG_DEBUG("pSmscList is NULL!");
+ return;
+ }
+
+ if (simIndex <= 0) {
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+ simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ }
+
+ memset(pSmscList, 0x00, sizeof(MSG_SMSC_LIST_S));
+
+ if (simIndex != -1) {
+ smscListMap::iterator it = smscList.find(simIndex);
+ if (it != smscList.end()) {
+ MSG_SMSC_LIST_S &pTmpSmscList = it->second;
+ memcpy(pSmscList, &pTmpSmscList, sizeof(MSG_SMSC_LIST_S));
+ MSG_SEC_DEBUG("SMSC number for sim index [%d] is [%s]", pSmscList->simIndex, pSmscList->smscData[pSmscList->selected].smscAddr.address);
+ }
+ }
+
+ return;
+}
+
+
+msg_error_t Sms3gppSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
+{
+ msg_error_t err = MSG_SUCCESS;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt);
+
+ MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
+
+ for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
+ MSG_DEBUG("Channel FROM [%d], Channel TO [%d]", pCbOpt->channelData.channelInfo[i].from, pCbOpt->channelData.channelInfo[i].to);
+ }
+
+#if 0
+ /* Set Setting Data into Vconf */
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, pCbOpt->simIndex);
+ if (MsgSettingSetBool(keyName, pCbOpt->bReceive) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+ return MSG_ERR_SET_SETTING;
+ }
+#endif
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, pCbOpt->simIndex);
+ if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+ return MSG_ERR_SET_SETTING;
+ }
+
+#if 0
+ MsgDbHandler *dbHandle = getDbHandle();
+ err = MsgStoAddCBChannelInfo(dbHandle, &pCbOpt->channelData);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("MsgStoGetCBChannelInfo is failed [%d]", err);
+ return MSG_ERR_SET_SETTING;
+ }
+#endif
+
+ return err;
+}
+
+
+void Sms3gppSetting::getCbOpt(MSG_SETTING_S *pSetting, int simIndex)
+{
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+ pSetting->type = MSG_CBMSG_OPT;
+ pSetting->option.cbMsgOpt.simIndex = simIndex;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex);
+ if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bReceive) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
+ int maxSimCnt = 0;
+ if (MsgSettingGetInt(keyName, &maxSimCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ pSetting->option.cbMsgOpt.maxSimCnt = maxSimCnt;
+
+ err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex);
+ if (err != MSG_SUCCESS)
+ MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
+
+ for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_LANGUAGE, i);
+
+ if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+ }
+}
+
+
+void Sms3gppSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
+{
+ MSG_BEGIN();
+
+ MsgMutexLocker lock(mx);
+
+ TelSmsParams_t smsParam = {0};
+
+ int ret = TAPI_API_SUCCESS;
+
+ int index = pSMSCList->index;
+ MSG_DEBUG("SMSC Index to be set in SIM = %d", index);
+
+ /*Setting the SMSP Record index value*/
+ smsParam.RecordIndex = (unsigned char)index;
+
+ /*Setting the SMSP Record Length value = 28 + alphaId_len*/
+ smsParam.RecordLen = 28 + strlen(pSMSCList->smscData[index].name);
+
+ /*Setting the SMSP Alpha ID value*/
+ smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
+ MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
+
+ if (smsParam.AlphaIdLen > 0 && smsParam.AlphaIdLen <= SMSC_NAME_MAX) {
+ memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
+ smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
+ MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
+ }
+
+ smsParam.ParamIndicator = 0x00;
+
+ if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
+ smsParam.ParamIndicator |= 0x02 ; /* enable 2nd Bit */
+ MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+ if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
+ smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_INTERNATIONAL;
+ else
+ smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
+
+ smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
+
+ MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
+
+ MSG_SEC_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
+
+ smsParam.TpSvcCntrAddr.DialNumLen = Sms3gppParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
+ } else {
+ MSG_DEBUG("SMSC Addr is not present");
+ }
+
+ /*Setting the PID value*/
+ smsParam.ParamIndicator |= 0x04 ; /* enable 3rd Bit */
+ MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+ smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
+
+ /*Setting the ValidityPeriod value*/
+ smsParam.ParamIndicator |= 0x10 ; /* enable 5th Bit */
+ MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+ smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
+
+ smsParam.ParamIndicator = ~(smsParam.ParamIndicator);
+ MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
+
+ /* Get TAPI handle */
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
+
+ ret = tel_set_sms_parameters(handle, (const TelSmsParams_t*)&smsParam, Sms3gppTapiEventHandler::respSetConfigData, NULL);
+
+ if (ret != TAPI_API_SUCCESS)
+ THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Error. [%d]", ret);
+
+ if (!getResultFromSim())
+ THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Result Error.");
+
+ MSG_END();
+}
+
+
+void Sms3gppSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
+{
+ MSG_BEGIN();
+
+ int paramCnt = 0;
+
+ MSG_SEC_DEBUG("SIM index [%d]", pSMSCList->simIndex);
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
+ paramCnt = getParamCount(handle);
+
+ MSG_DEBUG("Parameter Count [%d]", paramCnt);
+
+ int ret = TAPI_API_SUCCESS;
+
+ MSG_SMSC_DATA_S tmpSmscData = {};
+
+ for (int index = 0; index < paramCnt; index++) {
+ ret = tel_get_sms_parameters(handle, index, Sms3gppTapiEventHandler::respGetParam, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
+ } else {
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
+ }
+
+ if (getParamEvent(handle, &tmpSmscData) == true) {
+ MSG_DEBUG("######## Get Parameter was Successful !!! #######");
+ memcpy(&(pSMSCList->smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
+
+ MSG_DEBUG("pid[%d]", pSMSCList->smscData[index].pid);
+ MSG_DEBUG("val_period[%d]", pSMSCList->smscData[index].valPeriod);
+ MSG_SEC_DEBUG("name[%s]", pSMSCList->smscData[index].name);
+
+ MSG_DEBUG("ton[%d]", pSMSCList->smscData[index].smscAddr.ton);
+ MSG_DEBUG("npi[%d]", pSMSCList->smscData[index].smscAddr.npi);
+ MSG_SEC_DEBUG("address[%s]", pSMSCList->smscData[index].smscAddr.address);
+ } else {
+ MSG_DEBUG("######## Get Parameter was Failed !!! #######");
+ }
+ }
+
+ pSMSCList->totalCnt = paramCnt;
+ pSMSCList->selected = selectedParam;
+
+ MSG_DEBUG("total_count[%d]", pSMSCList->totalCnt);
+
+ MSG_END();
+}
+
+
+int Sms3gppSetting::getParamCount(TapiHandle *handle)
+{
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sms_parameter_count(handle, Sms3gppTapiEventHandler::respGetParamCnt, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
+ } else {
+ THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
+ }
+
+ return getParamCntEvent();
+}
+
+
+bool Sms3gppSetting::getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData)
+{
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sms_parameters(handle, Index, Sms3gppTapiEventHandler::respGetParam, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getParamEvent(handle, pSmscData) == true) {
+ MSG_DEBUG("######## Get Parameter was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Get Parameter was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gppSetting::setSmscInfo(const MSG_SMSC_LIST_S *pSmscList)
+{
+ MSG_BEGIN();
+
+ MsgMutexLocker lock(mx);
+
+ int ret = TAPI_API_SUCCESS;
+
+ TapiHandle *handle = NULL;
+
+ handle = SmsPluginDSHandler::instance()->getTelHandle(pSmscList->simIndex);
+
+ int select_id = pSmscList->selected;
+ const MSG_SMSC_DATA_S *pSmscData = (const MSG_SMSC_DATA_S *)&(pSmscList->smscData[select_id]);
+
+ MSG_DEBUG("Select SMSC id = [%d]", select_id);
+
+ TelSmsAddressInfo_t sca;
+ memset(&sca, 0x00, sizeof(TelSmsAddressInfo_t));
+
+ if (strlen(pSmscData->smscAddr.address) > 0) {
+ if (pSmscData->smscAddr.address[0] == '+')
+ sca.Ton = TAPI_SIM_TON_INTERNATIONAL;
+ else
+ sca.Ton = TAPI_SIM_TON_NATIONAL;
+
+ sca.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
+
+ MSG_SEC_DEBUG("SMSC TON = [%d], NPI = [%d], Address = [%s]", sca.Ton, sca.Npi, pSmscData->smscAddr.address);
+
+ sca.DialNumLen = Sms3gppParamCodec::encodeSMSC(pSmscData->smscAddr.address, sca.szDiallingNum);
+ } else {
+ MSG_DEBUG("SMSC Addr is not present");
+ }
+
+ ret = tel_set_sms_sca(handle, (const TelSmsAddressInfo_t *)&sca, 0, Sms3gppTapiEventHandler::respSetSmscInfo, NULL);
+
+ if (ret != TAPI_API_SUCCESS)
+ THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_sca() Error. [%d]", ret);
+
+ if (!getResultFromSim())
+ THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_sca() Result Error.");
+
+ MSG_END();
+}
+
+
+bool Sms3gppSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
+{
+ TapiHandle *handle = NULL;
+ int simCnt = SmsPluginDSHandler::instance()->getTelHandleCount();
+
+ TelSmsCbConfig_t cbConfig = {};
+
+ int cbEnabled = 0;
+ int ret = TAPI_API_SUCCESS;
+
+ if (pCbOpt->bReceive == true)
+ cbEnabled = 2;/* Need to get a Enumeration from TAPI, currently it is not available */
+
+ MSG_DEBUG("simIndex:%d, cbEnabled:%d", pCbOpt->simIndex, cbEnabled);
+
+ if (pCbOpt->simIndex == 0) {
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NOT_FOUND;
+
+ for (int i = 1; i <= simCnt; i++) {
+ MsgMutexLocker lock(mx);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, i);
+ int tmpVal = 0;
+ if (MsgSettingGetInt(keyName, &tmpVal) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ simStatus = (MSG_SIM_STATUS_T)tmpVal;
+
+ if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
+ MSG_DEBUG("SIM %d is not present..", i);
+ continue;
+ }
+
+ handle = SmsPluginDSHandler::instance()->getTelHandle(i);
+ memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
+ cbConfig.CBEnabled = cbEnabled;
+ cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
+
+ /*MSG_SETTING_S cbSetting;
+ getCbOpt(&cbSetting, i);
+
+ cbConfig.CBEnabled = (int)pCbOpt->bReceive;
+ cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
+ cbConfig.MsgIdMaxCount = cbSetting.option.cbMsgOpt.maxSimCnt;
+ cbConfig.MsgIdRangeCount = cbSetting.option.cbMsgOpt.channelData.channelCnt;
+
+ for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
+ cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].bActivate;
+ cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].from;
+ cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].to;
+ }*/
+
+ ret = tel_set_sms_cb_config(handle, &cbConfig, Sms3gppTapiEventHandler::respSetConfigData, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Set Cb Config was Failed !!! #######");
+ return false;
+ }
+
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler *dbHandle = getDbHandle();
+ err = MsgStoAddCBChannelInfo(dbHandle, const_cast<MSG_CB_CHANNEL_S*>(&pCbOpt->channelData), i);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("MsgStoAddCBChannelInfo is failed [%d]", err);
+ return false;
+ }
+ }
+
+ MSG_DEBUG("SIM Index = [0], Set CB Receive is done");
+ return true;
+ } else {
+ MsgMutexLocker lock(mx);
+
+ handle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
+
+ memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
+ cbConfig.CBEnabled = cbEnabled;
+ cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
+ /* cbConfig.CBEnabled = (int)pCbOpt->bReceive;
+ cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
+ cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
+ cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
+
+ for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
+ cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
+ cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].from;
+ cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].to;
+
+ MSG_DEBUG("FROM: %d, TO: %d", cbConfig.MsgIDs[i].Net3gpp.FromMsgId, cbConfig.MsgIDs[i].Net3gpp.ToMsgId);
+ }
+ MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);*/
+
+ ret = tel_set_sms_cb_config(handle, &cbConfig, Sms3gppTapiEventHandler::respSetConfigData, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Set Cb Config was Failed !!! #######");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+bool Sms3gppSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
+{
+ int ret = TAPI_API_SUCCESS;
+
+ TapiHandle *handle = NULL;
+
+ if (pCbOpt->simIndex == 0) {
+ MSG_DEBUG("SIM Index for getCBConfig = 0, CANNOT get cbconfig from SIM 0");
+ return false;
+ }
+
+ handle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
+
+ ret = tel_get_sms_cb_config(handle, Sms3gppTapiEventHandler::respGetCBConfig, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getCbConfigEvent(pCbOpt) == true) {
+ MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Get Cb Config was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gppSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
+{
+ MSG_BEGIN();
+ MsgMutexLocker lock(mx);
+
+ int ret = TAPI_API_SUCCESS;
+ bool *bShowError = NULL; /* When invalid voicemail data exists on SIM, update error should not be handled. */
+
+ int simIndex = pVoiceOpt->simIndex;
+
+ if (bMbdnEnable[simIndex] == false) {
+ MSG_DEBUG("MBDN service is disable.");
+ return;
+ }
+
+ TelSimMailBoxNumber_t mailboxInfo = {0, };
+ bool bExistVoicetype = false;
+ int i = 0;
+
+ smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
+ if (it == simMailboxList.end()) {
+ return;
+ }
+
+ SMS_3GPP_SIM_MAILBOX_LIST_S &pTmpSimMailboxList = it->second;
+ if (pTmpSimMailboxList.count < 0) { /* Not available */
+ return;
+ }
+
+ bShowError = (bool*)calloc(1, sizeof(bool));
+ if (!bShowError)
+ return;
+
+ if (pTmpSimMailboxList.count == 0) {
+ char num[MAX_PHONE_NUMBER_LEN + 1] = {0, };
+
+ mailboxInfo.mb_type = TAPI_SIM_MAILBOX_VOICE;
+ mailboxInfo.rec_index = 1;
+ mailboxInfo.ton = TAPI_SIM_TON_UNKNOWN;
+
+ snprintf(num, sizeof(num), "%s", pVoiceOpt->mailNumber);
+ MSG_DEBUG("Mailbox number config [%s]", num);
+
+ if (num[0] == '+') {
+ snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(num[1]));
+ mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
+ } else {
+ snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", num);
+ }
+
+ MSG_SEC_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
+
+ *bShowError = false;
+
+ } else {
+ for (i = 0; i < pTmpSimMailboxList.count; i++) {
+ if (pTmpSimMailboxList.list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
+ bExistVoicetype = true;
+ break;
+ }
+ }
+
+ if (bExistVoicetype == false) {
+ *bShowError = false;
+ /* There is no mailbox information for voicemail type on SIM. */
+ for (i = 0; i < pTmpSimMailboxList.count; i++) {
+ if (pTmpSimMailboxList.list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pTmpSimMailboxList.list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
+ pTmpSimMailboxList.list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
+ break;
+ }
+ }
+ }
+
+ /* if strlen of voicemail number retrieved from SIM is zero, error is not shown */
+ if (pTmpSimMailboxList.list[i].num_len == 0) {
+ MSG_DEBUG("In SIM voicemail does not exist");
+ *bShowError = false;
+ } else if (pTmpSimMailboxList.list[i].num_len > 0) {
+ MSG_DEBUG("In SIM voicemail exist");
+ *bShowError = true;
+ }
+
+ MSG_INFO("bShowError = %d", *bShowError);
+
+ memset(&pTmpSimMailboxList.list[i].num, 0x00, sizeof(pTmpSimMailboxList.list[i].num));
+ snprintf(pTmpSimMailboxList.list[i].num, sizeof(pTmpSimMailboxList.list[i].num), "%s", pVoiceOpt->mailNumber);
+ MSG_DEBUG("Mailbox number config [%s]", pTmpSimMailboxList.list[i].num);
+
+ mailboxInfo.b_cphs = pTmpSimMailboxList.list[i].b_cphs;
+ mailboxInfo.alpha_id_max_len = pTmpSimMailboxList.list[i].alpha_id_max_len;
+ mailboxInfo.mb_type = (TelSimMailboxType_t)pTmpSimMailboxList.list[i].mb_type;
+ mailboxInfo.profile_num = pTmpSimMailboxList.list[i].profile_num;
+ mailboxInfo.rec_index = (pTmpSimMailboxList.list[i].rec_index == 0) ? 1 : pTmpSimMailboxList.list[i].rec_index;
+ mailboxInfo.ton = (TelSimTypeOfNum_t)pTmpSimMailboxList.list[i].ton;
+ mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)pTmpSimMailboxList.list[i].npi;
+ snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", pTmpSimMailboxList.list[i].alpha_id);
+
+ if (pTmpSimMailboxList.list[i].num[0] == '+') {
+ snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(pTmpSimMailboxList.list[i].num[1]));
+ mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
+ } else {
+ snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", pTmpSimMailboxList.list[i].num);
+ }
+ MSG_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
+
+ mailboxInfo.cc_id = pTmpSimMailboxList.list[i].cc_id;
+ mailboxInfo.ext1_id = pTmpSimMailboxList.list[i].ext1_id;
+ }
+
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+
+ ret = tel_set_sim_mailbox_info(handle, &mailboxInfo, Sms3gppTapiEventHandler::respSetMailboxInfo, (void*)bShowError);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sim_mailbox_info() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_set_sim_mailbox_info() Fail !!! return : %d #######", ret);
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Set mailbox info Success !!! #######");
+ } else {
+ if (bShowError)
+ free(bShowError);
+ THROW(MsgException::SMS_PLG_ERROR, "######## Set mailbox info Failed !!!#######");
+ MSG_ERR("######## Set mailbox info Failed !!! #######");
+ }
+
+ if (bShowError)
+ free(bShowError);
+
+ MSG_END();
+ return;
+}
+
+
+bool Sms3gppSetting::getVoiceMailInfo(TapiHandle *handle)
+{
+ MsgMutexLocker lock(mx);
+
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sim_mailbox_info(handle, Sms3gppTapiEventHandler::respGetMailboxInfo, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sim_mailbox_info() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_get_sim_mailbox_info() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getMailboxInfoEvent() == true) {
+ MSG_DEBUG("######## Get mailbox info was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Get mailbox info was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gppSetting::getMeImei(char *pImei)
+{
+ int ret = TAPI_API_SUCCESS;
+
+ TapiHandle *handle = NULL;
+ handle = SmsPluginDSHandler::instance()->getTelHandle(1);
+
+ if (handle == NULL) {
+ MSG_DEBUG("Tapi Handle is NULL!");
+ return;
+ }
+
+ ret = tel_get_misc_me_imei(handle, Sms3gppTapiEventHandler::respGetMeImei, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Success !!! #######");
+
+ if (getResultImei(pImei) == true) {
+ MSG_SEC_DEBUG("######## Get ME IMEI was Successful !!! #######");
+ } else {
+ MSG_SEC_DEBUG("######## Get ME IMEI was Failed !!! #######");
+ }
+ } else {
+ MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Fail !!! return : %d #######", ret);
+ }
+}
+
+
+void Sms3gppSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
+{
+ MSG_DEBUG("SET MWI INFO, type=[%d]", type);
+ MSG_DEBUG("SET MWI INFO, count=[%d]", count);
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, simIndex);
+
+ if (MsgSettingSetInt(keyName, count) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetInt is failed!!");
+
+ if (count <= 0) {
+ if (type == MSG_MWI_VOICE_SMS)
+ MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_1, simIndex);
+ else if (type == MSG_MWI_VOICE2_SMS)
+ MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, simIndex);
+ }
+
+ if (bMbdnEnable[simIndex] == false) {
+ MSG_DEBUG("MBDN service is disable.");
+ return;
+ }
+
+ int ret = TAPI_API_SUCCESS;
+ TelSimMessageWaitingReq_t mwReq = {0, };
+
+ simMwiInfoMap::iterator iter = simMwiInfo.find(simIndex);
+ if(iter == simMwiInfo.end()) {
+ MSG_DEBUG("IT is not present");
+ return;
+ }
+
+ MSG_DEBUG("IT is present");
+
+ SMS_3GPP_SIM_MWI_INFO_S &pTmpsimMwiInfo = iter->second;
+
+ MSG_DEBUG("SET MWI INFO, CPHS? [%s]", pTmpsimMwiInfo.b_cphs?"Yes":"No");
+
+ if (pTmpsimMwiInfo.b_cphs) {
+ MSG_DEBUG("b_cphs is set");
+ if (type == MSG_MWI_VOICE_SMS) {
+ pTmpsimMwiInfo.cphs_mwi.b_voice1 = (count > 0 ? 1:0);
+ } else if (type == MSG_MWI_VOICE2_SMS) {
+ pTmpsimMwiInfo.cphs_mwi.b_voice2 = (count > 0 ? 1:0);
+ } else if (type == MSG_MWI_FAX_SMS) {
+ pTmpsimMwiInfo.cphs_mwi.b_fax = (count > 0 ? 1:0);
+ } else {
+ MSG_DEBUG("There is no type [%d] in CPHS.", type);
+ return;
+ }
+
+ mwReq.mw_data_u.cphs_mw.b_voice1 = pTmpsimMwiInfo.cphs_mwi.b_voice1;
+ mwReq.mw_data_u.cphs_mw.b_voice2 = pTmpsimMwiInfo.cphs_mwi.b_voice2;
+ mwReq.mw_data_u.cphs_mw.b_fax = pTmpsimMwiInfo.cphs_mwi.b_fax;
+ mwReq.mw_data_u.cphs_mw.b_data = pTmpsimMwiInfo.cphs_mwi.b_data;
+
+ MSG_DEBUG("MWI voice 1 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice1);
+ MSG_DEBUG("MWI voice 2 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice2);
+ MSG_DEBUG("MWI fax = [%d]", mwReq.mw_data_u.cphs_mw.b_fax);
+ MSG_DEBUG("MWI data = [%d]", mwReq.mw_data_u.cphs_mw.b_data);
+
+ } else {
+ MSG_DEBUG("b_cphs is not set");
+
+ if (type == MSG_MWI_VOICE_SMS)
+ pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count = count;
+ else if (type == MSG_MWI_FAX_SMS)
+ pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count = count;
+ else if (type == MSG_MWI_EMAIL_SMS)
+ pTmpsimMwiInfo.mwi_list.mw_info[0].email_count = count;
+ else /* MSG_MWI_OTHER_SMS */
+ pTmpsimMwiInfo.mwi_list.mw_info[0].other_count = count;
+
+ mwReq.mw_data_u.mw.rec_index = pTmpsimMwiInfo.mwi_list.mw_info[0].rec_index;
+
+ if (count <= 0)
+ mwReq.mw_data_u.mw.indicator_status = 0x00;
+ else
+ mwReq.mw_data_u.mw.indicator_status = 0x01;
+
+ mwReq.mw_data_u.mw.voice_count = pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count;
+ mwReq.mw_data_u.mw.fax_count = pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count;
+ mwReq.mw_data_u.mw.email_count = pTmpsimMwiInfo.mwi_list.mw_info[0].email_count;
+ mwReq.mw_data_u.mw.other_count = pTmpsimMwiInfo.mwi_list.mw_info[0].other_count;
+ mwReq.mw_data_u.mw.video_count = pTmpsimMwiInfo.mwi_list.mw_info[0].video_count;
+
+ MSG_DEBUG("MWI record index = [%d]", mwReq.mw_data_u.mw.rec_index);
+ MSG_DEBUG("MWI ind status = [%d]", mwReq.mw_data_u.mw.indicator_status);
+ MSG_DEBUG("MWI voice = [%d]", mwReq.mw_data_u.mw.voice_count);
+ MSG_DEBUG("MWI fax = [%d]", mwReq.mw_data_u.mw.fax_count);
+ MSG_DEBUG("MWI email = [%d]", mwReq.mw_data_u.mw.email_count);
+ MSG_DEBUG("MWI other = [%d]", mwReq.mw_data_u.mw.other_count);
+ MSG_DEBUG("MWI video = [%d]", mwReq.mw_data_u.mw.video_count);
+ }
+
+ mwReq.b_cphs = pTmpsimMwiInfo.b_cphs;
+
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+
+ ret = tel_set_sim_messagewaiting_info(handle, &mwReq, Sms3gppTapiEventHandler::respSetMwiInfo, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Success !!! #######");
+ } else {
+ MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
+ }
+
+ return;
+}
+
+
+bool Sms3gppSetting::getMwiInfo(TapiHandle *handle)
+{
+ MsgMutexLocker lock(mx);
+
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sim_messagewaiting_info(handle, Sms3gppTapiEventHandler::respGetMwiInfo, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Success !!! #######");
+ } else {
+ MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Get Mainbox info was Successful !!! #######");
+ } else {
+ MSG_DEBUG("######## Get Mainbox info was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+bool Sms3gppSetting::getMsisdnInfo(TapiHandle *handle)
+{
+ MsgMutexLocker lock(mx);
+
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sim_msisdn(handle, Sms3gppTapiEventHandler::respGetMsisdnInfo, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
+ } else {
+ MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Get Sim msisdn was Successful !!! #######");
+ } else {
+ MSG_DEBUG("######## Get Sim msisdn was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+bool Sms3gppSetting::getSimServiceTable(TapiHandle *handle)
+{
+ MsgMutexLocker lock(mx);
+
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sim_service_table(handle, Sms3gppTapiEventHandler::respGetSimServiceTable, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sim_service_table() Success !!! #######");
+ } else {
+ MSG_DEBUG("######## tel_get_sim_service_table() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Get SST info was Successful !!! #######");
+ } else {
+ MSG_DEBUG("######## Get SST info was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gppSetting::setParamCntEvent(int ParamCnt)
+{
+ mx.lock();
+
+ paramCnt = ParamCnt;
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+int Sms3gppSetting::getParamCntEvent()
+{
+ int ret = 0;
+
+ mx.lock();
+
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_ERR("WARNING: TAPI callback TIME-OUT");
+ return 0;
+ }
+
+ return paramCnt;
+}
+
+
+void Sms3gppSetting::setParamEvent(TapiHandle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess)
+{
+ mx.lock();
+
+ bTapiResult = bSuccess;
+
+ int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ memset(&smscData[sim_idx], 0x00, sizeof(MSG_SMSC_DATA_S));
+
+ if (bTapiResult == true) {
+ MSG_DEBUG("Success to get parameter data");
+
+ selectedParam = RecordIdx;
+
+ memcpy(&smscData[sim_idx], pSmscData, sizeof(MSG_SMSC_DATA_S));
+ }
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSetting::getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ bTapiResult = false;
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
+
+ if (bTapiResult == true) {
+ int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ memcpy(pSmscData, &smscData[index], sizeof(MSG_SMSC_DATA_S));
+ }
+
+ return bTapiResult;
+}
+
+
+void Sms3gppSetting::setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
+{
+ MSG_BEGIN();
+
+ mx.lock();
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ bTapiResult = bSuccess;
+
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (bTapiResult == true) {
+ MSG_DEBUG("Success to get cb config data");
+
+ pair <int, MSG_CBMSG_OPT_S> newCbOpt(simIndex, *pCbOpt);
+ cbOptMap::iterator it = cbOpt.find(simIndex);
+
+ if (it == cbOpt.end()) {
+ MSG_DEBUG("IT is not present");
+ } else {
+ MSG_DEBUG("IT present");
+ cbOpt.erase(it);
+ }
+ cbOpt.insert(newCbOpt);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
+ if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+ }
+ } else {
+ MSG_DEBUG("Failed to get cb config data");
+
+ cbOptMap::iterator it = cbOpt.find(simIndex);
+
+ if (it == cbOpt.end()) {
+ MSG_DEBUG("IT not present");
+ MSG_CBMSG_OPT_S pTmpCbOpt;
+
+ memset(&pTmpCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+ pair <int, MSG_CBMSG_OPT_S> newCbOpt(simIndex, pTmpCbOpt);
+
+ cbOpt.insert(newCbOpt);
+ }
+ }
+
+ cv.signal();
+
+ mx.unlock();
+ MSG_END();
+}
+
+
+bool Sms3gppSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
+{
+ MSG_BEGIN();
+
+ int ret = 0;
+
+ mx.lock();
+
+ bTapiResult = false;
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ int simIndex = pCbOpt->simIndex;
+
+ memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+ if (bTapiResult == true) {
+ cbOptMap::iterator it = cbOpt.find(simIndex);
+
+ if (it == cbOpt.end()) {
+ MSG_DEBUG("IT is not present");
+ return false;
+ }
+
+ MSG_DEBUG("IT is present");
+
+ MSG_CBMSG_OPT_S &pTmpCbOpt = it->second;
+ memcpy(pCbOpt, &pTmpCbOpt, sizeof(MSG_CBMSG_OPT_S));
+ }
+
+ MSG_END();
+ return bTapiResult;
+}
+
+
+void Sms3gppSetting::setMailboxInfoEvent(TapiHandle *handle, SMS_3GPP_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess, bool bMbdn)
+{
+ MSG_BEGIN();
+
+ MSG_DEBUG("bSuccess = %d, bMbdn = %d", bSuccess, bMbdn);
+ mx.lock();
+
+ bTapiResult = bSuccess;
+
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ bMbdnEnable[simIndex] = bMbdn;
+
+ /* print incoming mailbox list */
+ if (pMailboxList) {
+ MSG_DEBUG("Input list is count = %d ", pMailboxList->count);
+
+ for (int i = 0; i < pMailboxList->count; i++) {
+ MSG_DEBUG("List index = %d", i);
+ MSG_DEBUG("ton = %d, num = %s, alpha_id = %s", pMailboxList->list[i].ton, pMailboxList->list[i].num, pMailboxList->list[i].alpha_id);
+ }
+ } else {
+ MSG_INFO("pMailboxList is NULL");
+ }
+
+ if (bTapiResult == true) {
+ int i = 0;
+ bool bExistMailboxType = false;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ if (pMailboxList && pMailboxList->count > 0) {
+ pair <int, SMS_3GPP_SIM_MAILBOX_LIST_S> newList(simIndex, *pMailboxList);
+
+ smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
+ if (it == simMailboxList.end()) {
+ MSG_DEBUG("IT not present !!!");
+ simMailboxList.insert(newList);
+ } else {
+ MSG_DEBUG("IT present !!!");
+ simMailboxList.erase(it);
+ simMailboxList.insert(newList);
+ }
+
+ /* Temp :: Save voicemail number with VOICE1 line number */
+ for (i = 0; i < pMailboxList->count ; i++) {
+ MSG_SEC_DEBUG("Mailbox list[%d] type=[%d]", i, pMailboxList->list[i].mb_type);
+
+ if (pMailboxList->list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
+ bExistMailboxType = true;
+ break;
+ }
+ }
+
+ if (bExistMailboxType == false) {
+ MSG_DEBUG("There is no voice mailbox type.");
+ for (i = 0; i < simMailboxList[simIndex].count; i++) {
+ if (pMailboxList->list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pMailboxList->list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
+ pMailboxList->list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
+ break;
+ }
+ }
+ }
+
+ smsSimMailboxListMap::iterator iter = simMailboxList.find(simIndex);
+ SMS_3GPP_SIM_MAILBOX_LIST_S &pTmpMailboxList = iter->second;
+ char mailNumber[MAX_PHONE_NUMBER_LEN+1];
+ memset(mailNumber, 0x00 , sizeof(mailNumber));
+
+ MSG_SEC_DEBUG("Mailbox list[%d] ton=[%d], address=[%s], alpha_id=[%s]", \
+ i, pTmpMailboxList.list[i].ton, pTmpMailboxList.list[i].num, \
+ pTmpMailboxList.list[i].alpha_id);
+
+ if (pTmpMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && pTmpMailboxList.list[i].num[0] != '+') {
+ snprintf(mailNumber, sizeof(mailNumber), "+%s", pTmpMailboxList.list[i].num);
+ MSG_WARN("MSG_TON_INTERNATIONAL [%s]", mailNumber);
+ } else {
+ snprintf(mailNumber, sizeof(mailNumber), "%s", pTmpMailboxList.list[i].num);
+ MSG_DEBUG("[%s]", mailNumber);
+ }
+
+ if (mailNumber[0] != '\0') {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
+ if (MsgSettingSetString(keyName, mailNumber) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetString is failed!!");
+ }
+
+ if (pTmpMailboxList.list[i].alpha_id[0] != '\0') {
+ char unpackAlphaId[MAX_SIM_XDN_ALPHA_ID_LEN+8];
+ int tmpLen = 0;
+ MSG_LANG_INFO_S langInfo = {0, };
+
+ memset(unpackAlphaId, 0x00, sizeof(unpackAlphaId));
+
+ langInfo.bSingleShift = false;
+ langInfo.bLockingShift = false;
+
+ tmpLen = strlen(pTmpMailboxList.list[i].alpha_id);
+
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ textCvt->convertGSM7bitToUTF8((unsigned char*)unpackAlphaId, sizeof(unpackAlphaId), (unsigned char*)pTmpMailboxList.list[i].alpha_id, tmpLen, &langInfo);
+
+ MSG_DEBUG("UTF8 ALPHA_ID = [%s]", unpackAlphaId);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, simIndex);
+ if (MsgSettingSetString(keyName, unpackAlphaId) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetString is failed!!");
+ }
+ }
+ } else {
+ /* insert empty list with sim index */
+ SMS_3GPP_SIM_MAILBOX_LIST_S pDummySimMailboxList;
+
+ memset(&pDummySimMailboxList, 0x00, sizeof(SMS_3GPP_SIM_MAILBOX_LIST_S));
+ pair <int, SMS_3GPP_SIM_MAILBOX_LIST_S> newTmpList(simIndex, pDummySimMailboxList);
+ simMailboxList.insert(newTmpList);
+ }
+
+ cv.signal();
+
+ mx.unlock();
+ MSG_END();
+}
+
+bool Sms3gppSetting::getMailboxInfoEvent()
+{
+ int ret = 0;
+
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ return bTapiResult;
+}
+
+void Sms3gppSetting::setMwiInfoEvent(TapiHandle *handle, SMS_3GPP_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess)
+{
+ MSG_BEGIN();
+
+ mx.lock();
+
+ bTapiResult = bSuccess;
+
+ int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (bTapiResult == true) {
+ int mwiCnt = 0;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ pair <int, SMS_3GPP_SIM_MWI_INFO_S> newList(index, *pMwiInfo);
+ simMwiInfoMap::iterator it = simMwiInfo.find(index);
+
+ if (it == simMwiInfo.end()) {
+ MSG_DEBUG("IT not present");
+ } else {
+ MSG_DEBUG("IT present");
+ simMwiInfo.erase(it);
+ }
+ simMwiInfo.insert(newList);
+
+ simMwiInfoMap::iterator iter = simMwiInfo.find(index);
+
+ SMS_3GPP_SIM_MWI_INFO_S &pTmpsimMwiInfoList = iter->second;
+
+ /* Save MW count with VOICE line1 number */
+ if (pTmpsimMwiInfoList.b_cphs == true) {
+ mwiCnt = pTmpsimMwiInfoList.cphs_mwi.b_voice1;
+ } else {
+ mwiCnt = pTmpsimMwiInfoList.mwi_list.mw_info[0].voice_count;
+ }
+ /* TODO :: Add operation for voice mail of line 2 */
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, index);
+ if (MsgSettingSetInt(keyName, mwiCnt) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetInt is failed!!");
+
+ MSG_DEBUG("MWI count = [%d]", mwiCnt);
+
+ if (mwiCnt > 0) {
+ deliverVoiceMsgNoti(index, mwiCnt);
+ }
+ } else {
+ SMS_3GPP_SIM_MWI_INFO_S pTmpsimMwiInfo;
+
+ memset(&pTmpsimMwiInfo, 0x00, sizeof(SMS_3GPP_SIM_MWI_INFO_S));
+
+ pair <int, SMS_3GPP_SIM_MWI_INFO_S> newList(index, pTmpsimMwiInfo);
+ simMwiInfoMap::iterator it = simMwiInfo.find(index);
+
+ if (it == simMwiInfo.end()) {
+ MSG_DEBUG("IT not present");
+ } else {
+ MSG_DEBUG("IT present");
+ simMwiInfo.erase(it);
+ }
+ simMwiInfo.insert(newList);
+ }
+
+ cv.signal();
+
+ mx.unlock();
+
+ MSG_END();
+}
+
+
+void Sms3gppSetting::setResultImei(bool bResult, char *pImei)
+{
+ mx.lock();
+
+ bTapiResult = bResult;
+
+ memset(&meImei, 0x00, sizeof(meImei));
+
+ if (bTapiResult == true && pImei) {
+ snprintf(meImei, sizeof(meImei), "%s", pImei);
+ }
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSetting::getResultImei(char *pImei)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ if (bTapiResult == true && pImei) {
+ snprintf(pImei, sizeof(meImei), "%s", meImei);
+ }
+
+ return bTapiResult;
+}
+
+
+void Sms3gppSetting::setResultFromSim(bool bResult)
+{
+ mx.lock();
+
+ bTapiResult = bResult;
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSetting::getResultFromSim()
+{
+ int ret = 0;
+
+ MSG_DEBUG("getResultFromSim() is called .");
+
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ return bTapiResult;
+}
+
+
+SMS_3GPP_PID_T Sms3gppSetting::convertPid(MSG_SMS_PID_T pid)
+{
+ SMS_3GPP_PID_T retPid;
+
+ switch (pid) {
+ case MSG_PID_TEXT :
+ retPid = SMS_PID_NORMAL;
+ break;
+ case MSG_PID_VOICE :
+ retPid = SMS_PID_VOICE;
+ break;
+ case MSG_PID_FAX :
+ retPid = SMS_PID_TELEX;
+ break;
+ case MSG_PID_X400 :
+ retPid = SMS_PID_x400;
+ break;
+ case MSG_PID_ERMES :
+ retPid = SMS_PID_ERMES;
+ break;
+ case MSG_PID_EMAIL :
+ retPid = SMS_PID_EMAIL;
+ break;
+ default :
+ retPid = SMS_PID_NORMAL;
+ break;
+ }
+
+ return retPid;
+}
+
+
+void Sms3gppSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt)
+{
+ MSG_BEGIN();
+
+ MSG_MESSAGE_INFO_S msgInfo = {0, };
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(msgInfo.addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ msgInfo.nAddressCnt = 1;
+
+ msgInfo.displayTime = time(NULL);
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ char *voiceNum = NULL;
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
+ if (MsgSettingGetString(keyName, &voiceNum) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ if (voiceNum) {
+ snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNum);
+ free(voiceNum);
+ voiceNum = NULL;
+ }
+ memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
+ msgInfo.sim_idx = simIndex;
+
+#if 0
+ if (simMwiInfo.b_cphs == false) {
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new voice message", mwiCnt);
+ } else {
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "New voice message");
+ }
+#else
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", mwiCnt);
+#endif
+
+#if 0
+ if (Sms3gppEventHandler::instance()->callbackMsgIncoming(&msgInfo) != MSG_SUCCESS)
+ MSG_DEBUG("callbackIncoming is failed.");
+#else
+ MsgInsertNotification(&msgInfo);
+ MsgChangePmState();
+#endif
+
+ MSG_END();
+}
+
+
+void Sms3gppSetting::setSimChangeStatus(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ int tapiRet = TAPI_API_SUCCESS;
+ TelSimCardStatus_t status = TAPI_SIM_STATUS_CARD_ERROR;
+
+ int cardChanged = 0;
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ pthread_t thd;
+ char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
+
+ tapiRet = tel_get_sim_init_info(handle, &status, &cardChanged);
+ MSG_INFO("Tapi Ret=[%d], SIM index [%d], SIM status [%d], CardChanged [%d]", tapiRet, simIndex, status, cardChanged);
+
+ if (status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ if (simStatus[simIndex] == MSG_SIM_STATUS_NOT_FOUND) {
+ if (cardChanged == 1) {
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
+ MsgSettingSetInt(keyName, MSG_SIM_STATUS_CHANGED);
+ simStatus[simIndex] = MSG_SIM_STATUS_CHANGED;
+ } else {
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
+ MsgSettingSetInt(keyName, MSG_SIM_STATUS_NORMAL);
+ simStatus[simIndex] = MSG_SIM_STATUS_NORMAL;
+ }
+
+ /* Modified to call initSimInfo for SIM separately */
+ MSG_DEBUG("calling initSimInfo");
+ if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
+ MSG_DEBUG("pthread_create() error");
+ } else {
+ pthread_detach(thd);
+ }
+ } else {
+ MSG_DEBUG("SIM init was already done!");
+ }
+ } else {
+ MSG_DEBUG("It doesn't initialize yet!!");
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
+ MSG_DEBUG("Set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND");
+ if (MsgSettingSetInt(keyName, MSG_SIM_STATUS_NOT_FOUND) != MSG_SUCCESS)
+ MSG_DEBUG("Fail to set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND");
+
+ simStatus[simIndex] = MSG_SIM_STATUS_NOT_FOUND;
+ }
+
+ MSG_END();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+
+#include "SmsPluginDSHandler.h"
+#include "Sms3gppTapiEventHandler.h"
+#include "Sms3gppTpduCodec.h"
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "Sms3gppParamCodec.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppStorage.h"
+#include "Sms3gppEventHandler.h"
+#include "MsgUtilStorage.h"
+#include "MsgNotificationWrapper.h"
+
+#include "Sms3gppSimMsg.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppSimMsg - Member Functions
+==================================================================================================*/
+Sms3gppSimMsg* Sms3gppSimMsg::pInstance = NULL;
+
+
+Sms3gppSimMsg::Sms3gppSimMsg()
+{
+ /* Initialize member variables */
+ simMsgId = 0;
+ delSimMsgId = -1;
+ usedCnt = 0;
+ totalCnt = 0;
+ bTapiResult = false;
+ memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo));
+ memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
+ memset(&simMsgCnt, 0x00, sizeof(simMsgCnt));
+ memset(&simMsgInfo, 0x00, sizeof(simMsgInfo));
+ memset(&simAddrInfo, 0x00, sizeof(simAddrInfo));
+}
+
+
+Sms3gppSimMsg::~Sms3gppSimMsg()
+{
+}
+
+
+Sms3gppSimMsg* Sms3gppSimMsg::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppSimMsg();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gppSimMsg::initSimMessage(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
+ int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
+ /* Set SIM count of vconf to 0 */
+ if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+ }
+ memset(keyName, 0, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
+
+ if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+ }
+
+ MSG_3GPP_SIM_COUNT_S tmpMsgCnt;
+ memset(&tmpMsgCnt, 0x00, sizeof(MSG_3GPP_SIM_COUNT_S));
+ getSimMsgCount(handle, &tmpMsgCnt);
+
+ MSG_MESSAGE_INFO_S tmpMsgInfo;
+ int simIdList[MAX_SIM_SMS_NUM];
+ int unreadSimMsg = 0;
+
+ for (int i = 0; i < tmpMsgCnt.usedCount; i++) {
+ memset(&tmpMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+ memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
+
+ /* Get SIM Msg */
+ if (getSimMsg(handle, tmpMsgCnt.indexList[i], &tmpMsgInfo, simIdList) == false)
+ continue;
+
+ if (tmpMsgInfo.bRead == false)
+ unreadSimMsg++;
+
+ if (Sms3gppEventHandler::instance()->handleSimMsg(&tmpMsgInfo, simIdList, NULL, MAX_SIM_SMS_NUM) < 0) {
+ MSG_DEBUG("Fail to handleSimMsg()");
+ }
+
+ if (tmpMsgInfo.addressList) {
+ free(tmpMsgInfo.addressList);
+ tmpMsgInfo.addressList = NULL;
+ }
+ }
+
+ MSG_DEBUG("Unread SIM message count = [%d]", unreadSimMsg);
+#ifndef MSG_NOTI_INTEGRATION
+ if (unreadSimMsg > 0) {
+ MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, MSG_ACTIVE_NOTI_TYPE_NONE);
+ }
+#endif
+
+ if (Sms3gppEventHandler::instance()->updateIMSI(sim_idx) != MSG_SUCCESS) {
+ MSG_ERR("Fail to handleSimMsg()");
+ }
+
+ MSG_END();
+}
+
+
+msg_error_t Sms3gppSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
+{
+ bool bSimSst = true;
+
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
+ if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
+ /* No return, default value is true. */
+
+ if (bSimSst == false)
+ return MSG_ERR_STORE_RESTRICT;
+
+ /* Reset Out Parameter */
+ pSimIdList->count = 0;
+
+ SMS_3GPP_TPDU_S tpdu;
+ memset(&tpdu, 0x00, sizeof(SMS_3GPP_TPDU_S));
+ if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) {
+ tpdu.tpduType = SMS_TPDU_SUBMIT;
+ tpdu.data.submit.dcs.msgClass = SMS_MSG_CLASS_NONE;
+ /*SmsPluginTransport::instance()->setSmsSendOptions(&(tpdu.data.submit));*/
+ tpdu.data.submit.vpf = SMS_VPF_NOT_PRESENT;
+ tpdu.data.submit.dcs.codingScheme = SMS_CHARSET_AUTO;
+ } else {
+ tpdu.tpduType = SMS_TPDU_DELIVER;
+ setSmsOptions(pMsgInfo, &(tpdu.data.deliver));
+ /* Set TimeStamp */
+ convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
+ tpdu.data.deliver.dcs.codingScheme = SMS_CHARSET_AUTO;
+ }
+
+ for (int i = 0; i <pMsgInfo->nAddressCnt; ++i) {
+ SMS_3GPP_SUBMIT_DATA_S submitData;
+ memset(&submitData, 0x00, sizeof(SMS_3GPP_SUBMIT_DATA_S));
+ int bufLen = 0;
+ char buf[MAX_TPDU_DATA_LEN];
+
+ if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) { /* SUBMIT MSG */
+ Sms3gppTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.submit.dcs.codingScheme), i);
+
+ int addLen = strlen(submitData.destAddress.address);
+
+ tpdu.data.submit.destAddress.ton = submitData.destAddress.ton;
+ tpdu.data.submit.destAddress.npi = submitData.destAddress.npi;
+
+ if (addLen < MAX_ADDRESS_LEN) {
+ memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen);
+ tpdu.data.submit.destAddress.address[addLen] = '\0';
+ } else {
+ memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
+ tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
+ }
+ } else { /* DELIVER MSG */
+ Sms3gppTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme), i);
+
+ int addLen = strlen(submitData.destAddress.address);
+
+ tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
+ tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
+
+ if (addLen < MAX_ADDRESS_LEN) {
+ memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addLen);
+ tpdu.data.deliver.originAddress.address[addLen] = '\0';
+ } else {
+ memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
+ tpdu.data.deliver.originAddress.address[MAX_ADDRESS_LEN] = '\0';
+ }
+ }
+
+ /* Check sim message full. */
+ if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true) {
+ MSG_DEBUG("SIM storage is full.");
+ MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
+
+ return MSG_ERR_SIM_STORAGE_FULL;
+ }
+
+ if (submitData.segCount > 1) {
+ if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) { /* SUBMIT MSG */
+ tpdu.data.submit.bHeaderInd = true;
+ } else {
+ tpdu.data.deliver.bHeaderInd = true;
+ }
+ }
+
+ for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
+ if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) {
+ memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_3GPP_USERDATA_S));
+ } else {
+ memcpy(&(tpdu.data.deliver.userData), &(submitData.userData[segCnt]), sizeof(SMS_3GPP_USERDATA_S));
+ }
+
+ memset(buf, 0x00, sizeof(buf));
+
+ /* Encode SMS-DELIVER TPDU */
+ bufLen = Sms3gppTpduCodec::encodeTpdu(&tpdu, buf);
+
+ /* Make Telephony Structure */
+ TelSmsData_t simSmsData;
+ memset((void*)&simSmsData, 0x00, sizeof(simSmsData));
+
+ /* Set TPDU data */
+ memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
+
+ simSmsData.SmsData.szData[bufLen] = 0;
+ simSmsData.SmsData.MsgLength = bufLen;
+ simSmsData.SmsData.format = TAPI_NETTEXT_NETTYPE_3GPP;
+
+ if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MT) { /* MT messages */
+ if (pMsgInfo->bRead == true)
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_READ;
+ else
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
+ } else { /* MO messages */
+ if (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_SENT;
+ else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS)
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_DELIVERED;
+ else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL)
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_DELIVERY_UNCONFIRMED;
+ else
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNSENT;
+ }
+
+ /* Save SMS in SIM */
+ int ret = 0;
+
+ ret = tel_write_sms_in_sim(handle, &simSmsData, Sms3gppTapiEventHandler::respSaveSimMsg, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_write_sms_in_sim Success !!!#######");
+ } else {
+ MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", ret);
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+
+ msg_sim_id_t SimId = 0;
+
+ bool bResult = false;
+
+ bResult = getSimEvent(&SimId);
+
+ int usedCnt = 0;
+
+ if (bResult == true) {
+ MSG_DEBUG("######## Saving Msg was Successful !!! SIM ID : [%d] #######", SimId);
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx);
+ if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ usedCnt++;
+
+ if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
+ MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+
+ pSimIdList->simId[pSimIdList->count] = SimId;
+ pSimIdList->count++;
+ } else {
+ MSG_DEBUG("######## Saving Msg was Failed !!! SIM ID : [%d] #######", SimId);
+
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+ }
+ }
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t Sms3gppSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ msg_error_t err = MSG_SUCCESS;
+ bool bSimSst = true;
+ int tapiRet = TAPI_API_SUCCESS;
+ int simId = -1;
+ int replaceSimId = -1;
+ int replaceMsgId = 0;
+
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
+ if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
+ /* No return, default value is true. */
+
+ if (bSimSst == false) {
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
+ return MSG_SUCCESS;
+ }
+
+ /* Reset Flag */
+ SMS_3GPP_TPDU_S tpdu;
+
+ tpdu.tpduType = SMS_TPDU_DELIVER;
+
+ convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
+
+ /* Set SMS TPDU Options */
+ setSmsOptions(pMsgInfo, &(tpdu.data.deliver));
+
+ SMS_3GPP_SUBMIT_DATA_S submitData;
+ int bufLen = 0;
+ char buf[MAX_TPDU_DATA_LEN];
+
+ Sms3gppTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme), 0);
+
+ if (pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS && pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS) {
+ err = Sms3gppStorage::instance()->getReplaceSimMsg(pMsgInfo, &replaceMsgId, &replaceSimId);
+ MSG_DEBUG("getReplaceSimMsg(): err=[%d], Replace Sim Id = [%d], Replace message id = [%d]", err, replaceSimId, replaceMsgId);
+ if (replaceMsgId < 0)
+ replaceMsgId = 0;
+ }
+
+ /* Check SIM ID */
+ if (replaceSimId < 0) { /* Normal message type */
+ /* Check sim message full. */
+ if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true) {
+ MSG_ERR("SIM storage is full.");
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_ERR_SIM_STORAGE_FULL);
+ return MSG_ERR_SIM_STORAGE_FULL;
+ }
+
+ int addLen = strlen(submitData.destAddress.address);
+
+ tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
+ tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
+
+ if (addLen < MAX_ADDRESS_LEN) {
+ memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addLen);
+ tpdu.data.deliver.originAddress.address[addLen] = '\0';
+ } else {
+ memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
+ tpdu.data.deliver.originAddress.address[MAX_ADDRESS_LEN] = '\0';
+ }
+
+ if (submitData.segCount > 1)
+ tpdu.data.deliver.bHeaderInd = true;
+ } else { /* Replace message type */
+ tapiRet = tel_delete_sms_in_sim(handle, replaceSimId, Sms3gppTapiEventHandler::respDeleteSimMsg, NULL);
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_delete_sms_in_sim Success !!! #######");
+
+ simId = -1;
+ if (getDelSimEvent(&simId) == true) {
+ err = Sms3gppStorage::instance()->deleteSimMessage(pMsgInfo->sim_idx, replaceSimId);
+ }
+ MSG_DEBUG("tel_delete_sms_in_sim() : Err=[%d], Replace Sim Id=[%d], Result Sim id=[%d]", err, replaceSimId, simId);
+
+ } else {
+ MSG_DEBUG("######## tel_delete_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
+ }
+ }
+
+ for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
+ /* Create TelSmsData_t data */
+ TelSmsData_t simSmsData = {0, };
+
+ if (submitData.segCount == 1) {
+ memcpy(&simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca)-1);
+ memcpy(&simSmsData.SmsData.szData, &simMsgDataInfo.szData, sizeof(simSmsData.SmsData.szData)-1);
+ simSmsData.SmsData.MsgLength = simMsgDataInfo.msgLength;
+
+ } else {
+ memcpy(&(tpdu.data.deliver.userData), &(submitData.userData[segCnt]), sizeof(SMS_3GPP_USERDATA_S));
+
+ memset(buf, 0x00, sizeof(buf));
+
+ /* Encode SMS-DELIVER TPDU */
+ bufLen = Sms3gppTpduCodec::encodeTpdu(&tpdu, buf);
+
+ /* Set TPDU data */
+ int copyLen = (bufLen > TAPI_NETTEXT_SMDATA_SIZE_MAX) ? TAPI_NETTEXT_SMDATA_SIZE_MAX : bufLen;
+ memcpy((void*)simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca)-1);
+ memcpy((void*)simSmsData.SmsData.szData, buf, (size_t)copyLen);
+ simSmsData.SmsData.szData[copyLen] = 0;
+ simSmsData.SmsData.MsgLength = copyLen;
+ }
+
+ simSmsData.SmsData.format = TAPI_NETTEXT_NETTYPE_3GPP;
+ simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
+
+ MSG_MESSAGE_INFO_S *tmpSimMsgInfo = (MSG_MESSAGE_INFO_S *)calloc(1, sizeof(MSG_MESSAGE_INFO_S));
+ if (tmpSimMsgInfo) {
+ memcpy(tmpSimMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+
+ tmpSimMsgInfo->msgId = replaceMsgId;
+
+ tmpSimMsgInfo->addressList = NULL;
+ tmpSimMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memcpy(&tmpSimMsgInfo->addressList[0], &pMsgInfo->addressList[0], sizeof(MSG_ADDRESS_INFO_S));
+
+ tapiRet = tel_write_sms_in_sim(handle, &simSmsData, Sms3gppTapiEventHandler::respSaveClass2Msg, tmpSimMsgInfo);
+
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_write_sms_in_sim Success !!!, segNum = [%d] #######", segCnt);
+ } else {
+ MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
+ Sms3gppTransport::instance()->sendDeliverReport(handle, MSG_ERR_STORAGE_ERROR);
+
+ if (tmpSimMsgInfo) {
+ if (tmpSimMsgInfo->addressList) {
+ delete[] tmpSimMsgInfo->addressList;
+ tmpSimMsgInfo->addressList = NULL;
+ }
+ free(tmpSimMsgInfo);
+ tmpSimMsgInfo = NULL;
+ }
+
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+ }
+
+ msg_sim_id_t retSimId;
+ if (!getSimEvent(&retSimId))
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+
+ return MSG_SUCCESS;
+}
+
+
+void Sms3gppSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
+{
+ int tapiRet = TAPI_API_SUCCESS;
+
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
+ tapiRet = tel_delete_sms_in_sim(handle, (int)SimMsgId, Sms3gppTapiEventHandler::respDeleteSimMsg, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_delete_sms_in_sim Success !!! #######");
+ else
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_delete_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
+
+ int SimId = 0;
+ bool bResult = false;
+
+ bResult = getDelSimEvent(&SimId);
+
+ int usedCnt = 0, totalCnt = 0;
+
+ if (bResult == true) {
+ MSG_DEBUG("######## Deleting Msg was Successful !!! SIM ID : [%d] #######", SimId);
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
+ if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
+ if (MsgSettingGetInt(keyName, &totalCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+
+ if (usedCnt == totalCnt) {
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, NULL, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
+ }
+
+ usedCnt--;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
+
+ if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+ } else {
+ THROW(MsgException::SMS_PLG_ERROR, "######## Deleting Msg was Failed !!! SIM ID : [%d] #######", SimId);
+ }
+}
+
+
+bool Sms3gppSimMsg::checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int SegCnt)
+{
+ int usedCnt = 0, totalCnt = 0;
+
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
+ if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
+ if (MsgSettingGetInt(keyName, &totalCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+
+ MSG_DEBUG("Segment Count [%d]", SegCnt);
+ MSG_DEBUG("usedCnt [%d], totalCnt [%d]", usedCnt, totalCnt);
+
+ if ((usedCnt + (int)SegCnt) <= totalCnt)
+ return false;
+ else
+ return true;
+}
+
+
+void Sms3gppSimMsg::setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
+{
+ MSG_DEBUG("Sim Message ID [%d]", SimMsgId);
+
+ int ret = TAPI_API_SUCCESS;
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
+
+ ret = tel_set_sms_message_status(handle, (int)SimMsgId, TAPI_NETTEXT_STATUS_READ, Sms3gppTapiEventHandler::respSetMsgStatus, (void *)&SimMsgId);
+
+ if (ret == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_message_status Success !!! return : %d #######", ret);
+ else
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_set_sms_message_status Fail !!! return : %d #######", ret);
+
+ msg_sim_id_t SimId = 0;
+ bool bResult = false;
+
+ bResult = getSimEvent(&SimId);
+
+ if (bResult == true)
+ MSG_DEBUG("######## Setting Read Status was Successful !!!, sim id=[%d] #######", SimId);
+ else
+ THROW(MsgException::SMS_PLG_ERROR, "######## Setting Read Status was Failed !!! #######");
+}
+
+
+void Sms3gppSimMsg::getSimMsgCount(TapiHandle *handle, MSG_3GPP_SIM_COUNT_S *pSimMsgCnt)
+{
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_get_sms_count(handle, Sms3gppTapiEventHandler::respGetSimMsgCnt, NULL);
+
+ if (ret == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_get_sms_count() Success !!! #######");
+ else
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_count() Fail !!! return : %d #######", ret);
+
+ if (getSimMsgCntEvent(handle, pSimMsgCnt) == true)
+ MSG_DEBUG("######## Get Sim Msg Count was Successful !!! #######");
+ else
+ THROW(MsgException::SMS_PLG_ERROR, "######## Get Sim Msg Count was Failed !!! #######");
+}
+
+
+bool Sms3gppSimMsg::getSimMsg(TapiHandle *handle, msg_sim_id_t SimMsgId, MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList)
+{
+ int ret = TAPI_API_SUCCESS;
+
+ ret = tel_read_sms_in_sim(handle, SimMsgId, Sms3gppTapiEventHandler::respGetSimMsg, simIdList);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_read_sms_in_sim() Success !!! Sim ID : [%d] #######", SimMsgId);
+ } else {
+ MSG_DEBUG("######## tel_read_sms_in_sim() Fail !!! return : %d #######", ret);
+ return false;
+ }
+
+ if (getSimMsgEvent(handle, pMsgInfo) == true) {
+ MSG_DEBUG("######## Get Sim Msg was Successful !!! #######");
+ } else {
+ MSG_DEBUG("######## Get Sim Msg was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gppSimMsg::setSmsOptions(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_3GPP_DELIVER_S *pDeliver)
+{
+ pDeliver->bMoreMsg = false;
+ pDeliver->bStatusReport = false;
+ pDeliver->bHeaderInd = false;
+ pDeliver->bReplyPath = false;
+
+ pDeliver->dcs.bCompressed = false;
+ pDeliver->dcs.msgClass = SMS_MSG_CLASS_NONE;
+ pDeliver->dcs.codingGroup = SMS_GROUP_GENERAL;
+
+ pDeliver->dcs.codingScheme = pMsgInfo->encodeType;
+
+ MSG_DEBUG("DCS : %d", pDeliver->dcs.codingScheme);
+
+ pDeliver->pid = SMS_PID_NORMAL;
+
+ MSG_DEBUG("PID : %d", pDeliver->pid);
+}
+
+
+void Sms3gppSimMsg::convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_3GPP_DELIVER_S *pDeliver)
+{
+ MSG_BEGIN();
+
+ /* encode time stamp */
+ pDeliver->timeStamp.format = SMS_3GPP_TIME_ABSOLUTE;
+
+ /* encode absolute time */
+ struct tm timeinfo = {0,};
+ tzset();
+ localtime_r(&pMsgInfo->displayTime, &timeinfo);
+
+ pDeliver->timeStamp.time.absolute.year = timeinfo.tm_year - 100;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.year is %d", pDeliver->timeStamp.time.absolute.year);
+
+ pDeliver->timeStamp.time.absolute.month = timeinfo.tm_mon + 1;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.month is %d", pDeliver->timeStamp.time.absolute.month);
+
+ pDeliver->timeStamp.time.absolute.day = timeinfo.tm_mday;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.day is %d", pDeliver->timeStamp.time.absolute.day);
+
+ pDeliver->timeStamp.time.absolute.hour = timeinfo.tm_hour;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.hour is %d", pDeliver->timeStamp.time.absolute.hour);
+
+ pDeliver->timeStamp.time.absolute.minute = timeinfo.tm_min;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.minute is %d", pDeliver->timeStamp.time.absolute.minute);
+
+ pDeliver->timeStamp.time.absolute.second = timeinfo.tm_sec;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.second is %d", pDeliver->timeStamp.time.absolute.second);
+
+ pDeliver->timeStamp.time.absolute.timeZone = 0;
+ MSG_DEBUG("pDeliver->timeStamp.time.absolute.timeZone is %d", pDeliver->timeStamp.time.absolute.timeZone);
+
+ MSG_END();
+}
+
+
+void Sms3gppSimMsg::setSimMsgCntEvent(TapiHandle *handle, const MSG_3GPP_SIM_COUNT_S *pSimMsgCnt)
+{
+ mx.lock();
+
+ MSG_INFO("Sim Message Count is %d.", pSimMsgCnt->usedCount);
+
+ int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
+
+ for (int i = 0; i < pSimMsgCnt->usedCount; i++) {
+ MSG_DEBUG("Sim Message Index is %d.", pSimMsgCnt->indexList[i]);
+ }
+
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
+ if (MsgSettingSetInt(keyName, pSimMsgCnt->usedCount) != MSG_SUCCESS)
+ MSG_ERR("Error to set config data [%s]", SIM_USED_COUNT);
+
+ memset(keyName, 0, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
+ if (MsgSettingSetInt(keyName, (int)pSimMsgCnt->totalCount) != MSG_SUCCESS)
+ MSG_ERR("Error to set config data [%s]", SIM_TOTAL_COUNT);
+
+ memset(&simMsgCnt, 0x00, sizeof(MSG_3GPP_SIM_COUNT_S));
+ memcpy(&simMsgCnt, pSimMsgCnt, sizeof(MSG_3GPP_SIM_COUNT_S));
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSimMsg::getSimMsgCntEvent(TapiHandle *handle, MSG_3GPP_SIM_COUNT_S *pSimMsgCnt)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_ERR("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ memcpy(pSimMsgCnt, &simMsgCnt, sizeof(MSG_3GPP_SIM_COUNT_S));
+
+ return true;
+}
+
+void Sms3gppSimMsg::setSimMsgEvent(TapiHandle *handle, const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess)
+{
+ mx.lock();
+
+ bTapiResult = bSuccess;
+
+ memset(&simMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+ memset(&simAddrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ if (bTapiResult == true) {
+ MSG_DEBUG("Success to get sim msg - Id : [%d]", pMsgInfo->msgId);
+
+ memcpy(&simMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+ simMsgInfo.addressList = &simAddrInfo;
+ memcpy(&simAddrInfo, pMsgInfo->addressList, sizeof(MSG_ADDRESS_INFO_S));
+ }
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSimMsg::getSimMsgEvent(TapiHandle *handle, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ bTapiResult = false;
+ ret = cv.timedwait(mx.pMsgMutex(), 10);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ memset(pMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ if (bTapiResult == true) {
+ memcpy(pMsgInfo, &simMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+ pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)calloc(1, sizeof(MSG_ADDRESS_INFO_S));
+ memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+ memcpy(pMsgInfo->addressList, simMsgInfo.addressList, sizeof(MSG_ADDRESS_INFO_S));
+ pMsgInfo->sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ }
+
+ return bTapiResult;
+}
+
+
+void Sms3gppSimMsg::setSaveSimMsgEvent(TapiHandle *handle, int simId, int result)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ mx.lock();
+
+ if (result != TAPI_NETTEXT_SENDSMS_SUCCESS) {
+ if (result == TAPI_NETTEXT_ROUTING_NOT_AVAILABLE || result == TAPI_NETTEXT_SIM_FULL)
+ err = MSG_ERR_SIM_STORAGE_FULL;
+ else
+ err = MSG_ERR_UNKNOWN;
+ }
+
+ if (err == MSG_SUCCESS)
+ bTapiResult = true;
+ else
+ bTapiResult = false;
+
+ simMsgId = simId;
+
+ cv.signal();
+
+ mx.unlock();
+
+ int tapiRet = TAPI_API_SUCCESS;
+
+ if (err == MSG_SUCCESS) {
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+ } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+ } else {
+ return;
+ }
+
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ } else {
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ }
+}
+
+
+void Sms3gppSimMsg::setSaveClass2MsgEvent(TapiHandle *handle, int simId, int result, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ MSG_ERR_RET_M(!pMsgInfo, "pMsgInfo is NULL");
+
+ msg_error_t err = MSG_SUCCESS;
+ /*int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle); */
+
+ if (result == TAPI_NETTEXT_SENDSMS_SUCCESS && simId >= 0 && pMsgInfo) {
+ bool isNewSimMsg = true;
+
+ for (int i = 0; i < MAX_SIM_SMS_NUM; i++) {
+ if (simIdList[i] != 0) {
+ MSG_DEBUG("simIdList[%d] is exist [%d]", i, simIdList[i]);
+ continue;
+ } else {
+ simIdList[i] = simId + 1;
+ MSG_DEBUG("simIdList[%d] is assigned [%d]", i, simId + 1);
+ break;
+ }
+ }
+
+ if (pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS && pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS) {
+ if (pMsgInfo->msgId > 0) {
+ isNewSimMsg = false;
+ }
+ }
+
+ if (simMsgDataInfo.totalSegment >= 1 && simIdList[simMsgDataInfo.totalSegment-1] != 0) {
+ msg_message_id_t saved_msg_id = 0;
+ Sms3gppEventHandler::instance()->handleSimMsg(pMsgInfo, simIdList, &saved_msg_id, MAX_SIM_SMS_NUM);
+
+ MSG_DEBUG("Saved message ID = [%d]", saved_msg_id);
+
+ if (saved_msg_id > 0)
+ pMsgInfo->msgId = saved_msg_id;
+
+ err = Sms3gppEventHandler::instance()->callbackMsgIncoming(pMsgInfo);
+
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+ }
+
+ if (isNewSimMsg == true) {
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx);
+ if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ usedCnt++;
+
+ if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
+ MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
+ }
+
+ if (simMsgDataInfo.totalSegment >= 1 && simIdList[simMsgDataInfo.totalSegment-1] != 0) {
+ memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
+ }
+ } else {
+ if (result == TAPI_NETTEXT_SIM_FULL)
+ err = MSG_ERR_SIM_STORAGE_FULL;
+ else
+ err = MSG_ERR_UNKNOWN;
+ }
+
+ /* Send Deliver Report */
+ Sms3gppTransport::instance()->sendDeliverReport(handle, err);
+}
+
+
+void Sms3gppSimMsg::setSimEvent(msg_sim_id_t SimId, bool bResult)
+{
+ mx.lock();
+
+ simMsgId = SimId;
+ bTapiResult = bResult;
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSimMsg::getSimEvent(msg_sim_id_t *pSimId)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ bTapiResult = false;
+ ret = cv.timedwait(mx.pMsgMutex(), 10);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ *pSimId = simMsgId;
+
+ MSG_DEBUG("Returned SimMsgId is %d.", simMsgId);
+
+ return bTapiResult;
+}
+
+
+void Sms3gppSimMsg::setDelSimEvent(int SimId, bool bResult)
+{
+ mx.lock();
+
+ delSimMsgId = SimId;
+ bTapiResult = bResult;
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gppSimMsg::getDelSimEvent(int *pSimId)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ delSimMsgId = -1;
+ bTapiResult = false;
+ ret = cv.timedwait(mx.pMsgMutex(), 10);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ *pSimId = delSimMsgId;
+
+ MSG_DEBUG("Returned delSimMsgId is %d.", delSimMsgId);
+
+ return bTapiResult;
+}
+
+
+void Sms3gppSimMsg::setSmsData(const char *sca, const char *szData, int msgLength)
+{
+ MSG_DEBUG("Set SMS data(class2 message)");
+
+ memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo));
+
+ memcpy(&simMsgDataInfo.sca, sca, sizeof(simMsgDataInfo.sca)-1);
+ memcpy(&simMsgDataInfo.szData, szData, sizeof(simMsgDataInfo.szData)-1);
+ simMsgDataInfo.msgLength = msgLength;
+}
+
+void Sms3gppSimMsg::setSmsTpduTotalSegCount(int totalSeg)
+{
+ MSG_DEBUG("Set SMS Segements Info");
+
+ simMsgDataInfo.totalSegment = totalSeg;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgContact.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilStorage.h"
+#include "MsgUtilFunction.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+
+#include "SmsPluginMain.h"
+#include "Sms3gppSimMsg.h"
+#include "Sms3gppStorage.h"
+#include "Sms3gppSetting.h"
+
+/*==================================================================================================
+ Variables
+==================================================================================================*/
+Sms3gppStorage* Sms3gppStorage::pInstance = NULL;
+
+/*==================================================================================================
+ Methods of Sms3gppStorage
+==================================================================================================*/
+
+Sms3gppStorage::Sms3gppStorage()
+{
+ memset(&msgInfo, 0x00, sizeof(msgInfo));
+ memset(&addrInfo, 0x00, sizeof(addrInfo));
+}
+
+
+Sms3gppStorage* Sms3gppStorage::instance()
+{
+ if (!pInstance) {
+ MSG_DEBUG("pInstance is NULL. Now creating instance.");
+ pInstance = new Sms3gppStorage();
+ }
+
+ return pInstance;
+}
+
+
+msg_error_t Sms3gppStorage::insertMsgRef(MSG_MESSAGE_INFO_S *pMsg, unsigned char msgRef, int index)
+{
+ MSG_BEGIN();
+
+ time_t curTime = time(NULL);
+
+ MsgDbHandler *dbHandle = getDbHandle();
+ char sqlQuery[MAX_QUERY_LEN+1];
+ char *normalNum = NULL;
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+ normalNum = msg_normalize_number(pMsg->addressList[index].addressVal);
+
+ MSG_SEC_DEBUG("Insert MsgID=[%d], Address=[%s], MsgRef=[%d], Time=[%d]", pMsg->msgId, normalNum, (int)msgRef, (int)curTime);
+
+ snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %s, %d, 0, -1, %d);",
+ MSGFW_SMS_REPORT_TABLE_NAME, pMsg->msgId, normalNum, (int)msgRef, (int)curTime);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("MsgExecQuery() : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+
+ MSG_END();
+ return MSG_SUCCESS;
+}
+
+msg_error_t Sms3gppStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInfo, unsigned char msgRef)
+{
+ MSG_BEGIN();
+
+ MsgDbHandler *dbHandle = getDbHandle();
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ msg_message_id_t msgId = 0;
+ int rowCnt = 0;
+ char *normalNum = NULL;
+
+ normalNum = msg_normalize_number(pMsgInfo->addressList[0].addressVal);
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE ADDRESS_VAL = %s AND MSG_REF > 0 ORDER BY TIME ASC;",
+ MSGFW_SMS_REPORT_TABLE_NAME, normalNum);
+ MSG_DEBUG("[SQL Query] %s", sqlQuery);
+
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+ return MSG_ERR_DB_PREPARE;
+
+ if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
+ msgId = dbHandle->columnInt(0);
+
+ dbHandle->finalizeQuery();
+
+ pMsgInfo->msgId = msgId;
+
+ /** Update Status - MSG_MESSAGE_TABLE */
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;",
+ MSGFW_SMS_REPORT_TABLE_NAME, msgId);
+
+ if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) {
+ dbHandle->freeTable();
+ return MSG_ERR_DB_GETTABLE;
+ }
+
+ dbHandle->freeTable();
+
+ MSG_DEBUG("Selected row count = [%d]", rowCnt);
+
+ if (rowCnt == 1 && pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE MSG_ID = %d;",
+ MSGFW_MESSAGE_TABLE_NAME, (int)pMsgInfo->networkStatus, msgId);
+ MSG_DEBUG("[SQL Query] %s", sqlQuery);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+ }
+
+ /** Update Status - MSG_REPORT_TABLE */
+ if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
+ MSGFW_SMS_REPORT_TABLE_NAME, 1, (int)pMsgInfo->displayTime, msgId, normalNum);
+ MSG_DEBUG("[SQL Query] %s", sqlQuery);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+ } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
+ MSGFW_SMS_REPORT_TABLE_NAME, 0, (int)pMsgInfo->displayTime, msgId, normalNum);
+ MSG_DEBUG("[SQL Query] %s", sqlQuery);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+ } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
+ MSGFW_SMS_REPORT_TABLE_NAME, 3, (int)pMsgInfo->displayTime, msgId, normalNum);
+ MSG_DEBUG("[SQL Query] %s", sqlQuery);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+ } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
+ MSGFW_SMS_REPORT_TABLE_NAME, 8, (int)pMsgInfo->displayTime, msgId, normalNum);
+ MSG_DEBUG("[SQL Query] %s", sqlQuery);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+ }
+
+ MSG_END();
+ return MSG_SUCCESS;
+}
+
+#ifdef SMS_REPORT_OPERATION
+msg_error_t Sms3gppStorage::updateMsgRef(msg_message_id_t MsgId, unsigned char MsgRef)
+{
+ MSG_BEGIN();
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = %d WHERE MSG_ID = %d;",
+ MSGFW_REPORT_TABLE_NAME, (int)MsgRef, MsgId);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+
+ /** Set Message Reference for updating report table */
+ tmpMsgRef = MsgRef;
+
+ MSG_DEBUG("MsgRef : %d", MsgRef);
+
+ MSG_END();
+
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t Sms3gppStorage::updateStatusReport(unsigned char MsgRef, msg_delivery_report_status_t Status, time_t DeliveryTime)
+{
+ MSG_BEGIN();
+
+ MSG_DEBUG("tmpMsgRef : %d", tmpMsgRef);
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ /** Get Msg Id for Quickpanel Noti */
+ msg_message_id_t msgId = 0;
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE MSG_REF = %d;",
+ MSGFW_REPORT_TABLE_NAME, (int)tmpMsgRef);
+
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+ return MSG_ERR_DB_PREPARE;
+
+ if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
+ msgId = dbHandle->columnInt(0);
+
+ dbHandle->finalizeQuery();
+
+ /** Update Status */
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, DELIVERY_REPORT_STATUS = %d, DELIVERY_REPORT_TIME = %lu WHERE MSG_REF = %d;",
+ MSGFW_REPORT_TABLE_NAME, Status, DeliveryTime, (int)tmpMsgRef);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_DEBUG("Query Failed : [%s]", sqlQuery);
+ return MSG_ERR_DB_EXEC;
+ }
+
+ /** Insert Quickpanel Noti */
+ msg_error_t ret = MSG_SUCCESS;
+
+ ret = MsgInsertSmsNotiToQuickpanel(dbHandle, msgId, Status);
+ if (ret != MSG_SUCCESS) {
+ MSG_DEBUG("MsgInsertSmsNotiToQuickpanel() Failed : [%d]", ret);
+ return ret;
+ }
+
+ MSG_END();
+
+ return MSG_SUCCESS;
+}
+#endif
+
+msg_error_t Sms3gppStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo, int *simIdList)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ unsigned int simId = 0;
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ if (simIdList) {
+ MSG_DEBUG("simIdList exist.");
+ for (int i = 0; i < MAX_SIM_SMS_NUM; ++i) {
+ if (simIdList[i]) {
+ simId = simIdList[i] - 1;
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);",
+ MSGFW_SIM_MSG_TABLE_NAME, simId, pSimMsgInfo->msgId);
+
+ MSG_DEBUG("QUERY : %s", sqlQuery);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ return MSG_ERR_DB_EXEC;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ return err;
+}
+
+msg_error_t Sms3gppStorage::insertSimMessage(int simId, int msgId)
+{
+ MSG_BEGIN();
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ dbHandle->beginTrans();
+
+ /* Insert Message into msg_sim table */
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);", MSGFW_SIM_MSG_TABLE_NAME, simId, msgId);
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_EXEC;
+ }
+
+ dbHandle->endTrans(true);
+
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t Sms3gppStorage::deleteSimMessage(int sim_idx, int simId)
+{
+ MSG_BEGIN();
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ dbHandle->beginTrans();
+
+ /** Delete Message from msg_sim table */
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE SIM_ID = %d AND SIM_SLOT_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, simId, sim_idx);
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_EXEC;
+ }
+
+ dbHandle->endTrans(true);
+
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t Sms3gppStorage::getReplaceSimMsg(const MSG_MESSAGE_INFO_S *pMsg, int *pMsgId, int *pSimId)
+{
+ MSG_BEGIN();
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+ msg_thread_id_t convId = 0;
+ msg_message_id_t msgId = 0;
+
+ dbHandle->beginTrans();
+
+ if (MsgExistAddress(dbHandle, pMsg, &convId) == true) {
+ MSG_DEBUG("Address Info. exists [%d]", convId);
+
+ /** Find Replace Type Msg : Same Replace Type, Same Origin Address, Same Storage ID */
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s \
+ WHERE CONV_ID = %d AND SUB_TYPE = %d AND STORAGE_ID = %d \
+ ORDER BY DISPLAY_TIME ASC;",
+ MSGFW_MESSAGE_TABLE_NAME, (int)convId, pMsg->msgType.subType, MSG_STORAGE_SIM);
+
+ MSG_DEBUG("Query=[%s]", sqlQuery);
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_PREPARE;
+ }
+
+ if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+ *pMsgId = dbHandle->columnInt(0);
+ } else {
+ dbHandle->finalizeQuery();
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_STEP;
+ }
+
+ dbHandle->finalizeQuery();
+
+ } else {
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_NORECORD;
+ }
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s \
+ WHERE MSG_ID = %d;",
+ MSGFW_SIM_MSG_TABLE_NAME, *pMsgId);
+
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_PREPARE;
+ }
+
+ if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+ *pSimId = dbHandle->columnInt(0);
+ } else {
+ dbHandle->finalizeQuery();
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_STEP;
+ }
+
+ MSG_DEBUG("Replace Msg Id=[%d], Sim Id=[%d]", *pMsgId, *pSimId);
+
+ dbHandle->finalizeQuery();
+
+ dbHandle->endTrans(true);
+
+ MSG_END();
+ return msgId;
+}
+
+
+msg_error_t Sms3gppStorage::addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+ bool bSimSst = true;
+
+ char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
+
+ if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS) {
+ MSG_ERR("MsgSettingGetBool [%s] failed", keyName);
+ }
+
+ if (bSimSst == false) {
+ return MSG_ERR_SIM_STORAGE_FULL;
+ }
+
+ pthread_t thd;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+ memset(&addrInfo, 0, sizeof(MSG_ADDRESS_INFO_S));
+ memcpy(&msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
+ memcpy(&addrInfo, pMsgInfo->addressList, sizeof(MSG_ADDRESS_INFO_S));
+ msgInfo.addressList = &addrInfo;
+
+ if (pthread_create(&thd, NULL, &class2_thread, (void *)&msgInfo) < 0) {
+ MSG_ERR("pthread_create() error");
+ } else {
+ pthread_detach(thd);
+ }
+
+ MSG_END();
+ return err;
+}
+
+void* Sms3gppStorage::class2_thread(void *data)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+ MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)data;
+
+ err = Sms3gppSimMsg::instance()->saveClass2Message(pMsgInfo);
+ if (err == MSG_SUCCESS) {
+ MSG_DEBUG("Success to saveClass2Message.");
+ } else {
+ MSG_ERR("Fail to saveClass2Message : [%d]", err);
+ }
+
+ MSG_END();
+ return NULL;
+}
+
+#if 0
+msg_error_t Sms3gppStorage::isReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ int rowCnt = 0;
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1] = {0, };
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE GEO_SCOPE = %d AND MSG_CODE = %d AND MESSAGE_ID = %d AND UPDATE_NUM = %d",
+ MSGFW_RECEIVED_CB_MSG_TABLE_NAME, CbPage.pageHeader.serialNum.geoScope,
+ CbPage.pageHeader.serialNum.msgCode, CbPage.pageHeader.msgId, CbPage.pageHeader.serialNum.updateNum);
+
+ err = dbHandle->getTable(sqlQuery, &rowCnt, NULL);
+ MSG_DEBUG("rowCnt: %d", rowCnt);
+
+ dbHandle->freeTable();
+ return err;
+}
+
+msg_error_t Sms3gppStorage::insertReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ unsigned int rowId = 0;
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+
+ err = dbHandle->getRowId(MSGFW_RECEIVED_CB_MSG_TABLE_NAME, &rowId);
+
+ if (err != MSG_SUCCESS)
+ return err;
+
+ /* Add Folder */
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
+ MSGFW_RECEIVED_CB_MSG_TABLE_NAME, rowId, CbPage.pageHeader.serialNum.geoScope,
+ CbPage.pageHeader.serialNum.msgCode, CbPage.pageHeader.msgId, CbPage.pageHeader.serialNum.updateNum);
+
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
+ return MSG_ERR_DB_EXEC;
+
+ return MSG_SUCCESS;
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <glib.h>
+#include <pthread.h>
+#ifdef MSG_FEATURE_FDN
+#include <csc-feature.h>
+#endif
+
+#include "Sms3gppTapiEventHandler.h"
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppWapPushHandler.h"
+#include "Sms3gppParamCodec.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppSetting.h"
+#include "MsgGconfWrapper.h"
+#include "SmsPluginDSHandler.h"
+#include "Sms3gppCbMsgHandler.h"
+#include "Sms3gppConcatHandler.h"
+#include "Sms3gppSatHandler.h"
+#include "Sms3gppSimMsg.h"
+#include "Sms3gppTpduCodec.h"
+#include "MsgUtilFunction.h"
+#include "MsgUtilStorage.h"
+#include "MsgDevicedWrapper.h"
+
+static SMS_NETWORK_STATUS_T convertTapiRespToSmsPlugin(int result);
+
+/*==================================================================================================
+ FUNCTION IMPLEMENTATION
+==================================================================================================*/
+SMS_NETWORK_STATUS_T convertTapiRespToSmsPlugin(int result)
+{
+ SMS_NETWORK_STATUS_T sentStatus;
+
+ /* Convert TAPI status -> SMS network status */
+ switch ((TelSmsResponse_t)result) {
+ case TAPI_NETTEXT_SENDSMS_SUCCESS :
+ sentStatus = SMS_NETWORK_SEND_SUCCESS;
+ break;
+ case TAPI_NETTEXT_INVALID_MANDATORY_INFO :
+ sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
+ break;
+ case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE :
+ case TAPI_NETTEXT_TEMPORARY_FAILURE :
+ case TAPI_NETTEXT_CONGESTION :
+ case TAPI_NETTEXT_RESOURCES_UNAVAILABLE :
+ case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL :
+ case TAPI_NETTEXT_NETWORK_OUTOFORDER:
+ sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
+ break;
+ case TAPI_NETTEXT_MESSAGE_TRANSFER_REJECTED :
+ sentStatus = SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED;
+ break;
+ case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED :
+ case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED :
+ sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
+ break;
+ case TAPI_NETTEXT_ROUTING_NOT_AVAILABLE :
+ sentStatus = SMS_NETWORK_SEND_FAIL_NO_ROUTING;
+ break;
+ default :
+ sentStatus = SMS_NETWORK_SEND_FAIL;
+ break;
+ }
+
+ return sentStatus;
+}
+
+
+void Sms3gppTapiEventHandler::NotiSmsDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ try {
+ int deviceStatus = *(int*)data;
+ MSG_INFO("Device ready status: (%d)", deviceStatus);
+ Sms3gppEventHandler::instance()->setDeviceStatus(handle, deviceStatus != TAPI_NETTEXT_READY_STATUS_NONE);
+
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ }
+}
+
+void Sms3gppTapiEventHandler::NotiSmsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ /* make a margin timeout(500ms) till suspending status */
+ MsgDisplayLock();
+
+ TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
+
+ SMS_3GPP_TPDU_S tpdu;
+ memset(&tpdu, 0x00, sizeof(SMS_3GPP_TPDU_S));
+
+ /* Decode Incoming Message */
+ Sms3gppTpduCodec::decodeTpdu(handle, pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
+
+ /* Print tpdu */
+ if (tpdu.tpduType == SMS_TPDU_DELIVER) {
+ MSG_DEBUG("############# SMS_TPDU_DELIVER Incoming decoded tpdu values ####################");
+ MSG_DEBUG("tpdu.data.deliver.bMoreMsg : %d", tpdu.data.deliver.bMoreMsg);
+ MSG_DEBUG("tpdu.data.deliver.bStatusReport : %d", tpdu.data.deliver.bStatusReport);
+ MSG_DEBUG("tpdu.data.deliver.bHeaderInd : %d", tpdu.data.deliver.bHeaderInd);
+ MSG_DEBUG("tpdu.data.deliver.bReplyPath : %d", tpdu.data.deliver.bReplyPath);
+ MSG_DEBUG("tpdu.data.deliver.pid : %d", tpdu.data.deliver.pid);
+ MSG_DEBUG("tpdu.data.deliver.dcs.bCompressed : %d", tpdu.data.deliver.dcs.bCompressed);
+ MSG_DEBUG("tpdu.data.deliver.dcs.msgClass : %d", tpdu.data.deliver.dcs.msgClass);
+ MSG_DEBUG("tpdu.data.deliver.dcs.codingScheme : %d", tpdu.data.deliver.dcs.codingScheme);
+ MSG_DEBUG("tpdu.data.deliver.dcs.codingGroup : %d", tpdu.data.deliver.dcs.codingGroup);
+ MSG_DEBUG("tpdu.data.deliver.dcs.bIndActive : %d", tpdu.data.deliver.dcs.bIndActive);
+ MSG_SEC_DEBUG("tpdu.data.deliver.originAddress.address : %s", tpdu.data.deliver.originAddress.address);
+ MSG_DEBUG("tpdu.data.deliver.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.deliver.timeStamp.time.absolute.year, tpdu.data.deliver.timeStamp.time.absolute.month, tpdu.data.deliver.timeStamp.time.absolute.day,
+ tpdu.data.deliver.timeStamp.time.absolute.hour, tpdu.data.deliver.timeStamp.time.absolute.minute, tpdu.data.deliver.timeStamp.time.absolute.second);
+ MSG_DEBUG("tpdu.data.deliver.userData.headerCnt : %d", tpdu.data.deliver.userData.headerCnt);
+ MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
+ MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
+ MSG_DEBUG("#####################################################");
+ } else if (tpdu.tpduType == SMS_TPDU_STATUS_REP) {
+ MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
+ MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
+ MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
+ MSG_DEBUG("tpdu.data.statusRep.bStatusReport : %d", tpdu.data.statusRep.bStatusReport);
+ MSG_DEBUG("tpdu.data.statusRep.statusRep : %d", tpdu.data.statusRep.bHeaderInd);
+ MSG_DEBUG("tpdu.data.statusRep.status : %02x", tpdu.data.statusRep.status);
+ MSG_DEBUG("tpdu.data.statusRep.pid : %d", tpdu.data.statusRep.pid);
+ MSG_DEBUG("tpdu.data.statusRep.dcs.bCompressed : %d", tpdu.data.statusRep.dcs.bCompressed);
+ MSG_DEBUG("tpdu.data.statusRep.dcs.msgClass : %d", tpdu.data.statusRep.dcs.msgClass);
+ MSG_DEBUG("tpdu.data.statusRep.dcs.codingScheme : %d", tpdu.data.statusRep.dcs.codingScheme);
+ MSG_DEBUG("tpdu.data.statusRep.dcs.codingGroup : %d", tpdu.data.statusRep.dcs.codingGroup);
+ MSG_SEC_DEBUG("tpdu.data.statusRep.recipAddress.address : %s", tpdu.data.statusRep.recipAddress.address);
+ MSG_DEBUG("tpdu.data.statusRep.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.timeStamp.time.absolute.year, tpdu.data.statusRep.timeStamp.time.absolute.month, tpdu.data.statusRep.timeStamp.time.absolute.day,
+ tpdu.data.statusRep.timeStamp.time.absolute.hour, tpdu.data.statusRep.timeStamp.time.absolute.minute, tpdu.data.statusRep.timeStamp.time.absolute.second);
+ MSG_DEBUG("tpdu.data.statusRep.dischargeTime.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.dischargeTime.time.absolute.year, tpdu.data.statusRep.dischargeTime.time.absolute.month, tpdu.data.statusRep.dischargeTime.time.absolute.day,
+ tpdu.data.statusRep.dischargeTime.time.absolute.hour, tpdu.data.statusRep.dischargeTime.time.absolute.minute, tpdu.data.statusRep.dischargeTime.time.absolute.second);
+ MSG_DEBUG("tpdu.data.statusRep.userData.headerCnt : %d", tpdu.data.statusRep.userData.headerCnt);
+ MSG_DEBUG("tpdu.data.statusRep.userData.length : %d", tpdu.data.statusRep.userData.length);
+ MSG_DEBUG("tpdu.data.statusRep.userData.data : %s", tpdu.data.statusRep.userData.data);
+ MSG_DEBUG("#####################################################");
+ }
+
+ MsgDisplayUnlock();
+
+ try {
+ if (tpdu.tpduType == SMS_TPDU_DELIVER) {
+ if (tpdu.data.deliver.dcs.msgClass == SMS_MSG_CLASS_2) {
+ /* For GCF test, 34.2.5.3 */
+ Sms3gppSimMsg::instance()->setSmsData((const char*)pDataPackage->Sca, (const char *)pDataPackage->szData, pDataPackage->MsgLength);
+ }
+
+ if (Sms3gppConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
+ Sms3gppWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true) {
+ Sms3gppConcatHandler::instance()->handleConcatMsg(handle, &tpdu);
+ } else {
+ Sms3gppEventHandler::instance()->handleMsgIncoming(handle, &tpdu);
+ }
+ } else if (tpdu.tpduType == SMS_TPDU_STATUS_REP) {
+ Sms3gppEventHandler::instance()->handleMsgIncoming(handle, &tpdu);
+ }
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiSmsCbIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ try {
+ Sms3gppCbMsgHandler::instance()->handleCbMsg(handle, (TelSmsCbMsg_t*)data);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiSmsEtwsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ try {
+ Sms3gppCbMsgHandler::instance()->handleEtwsMsg(handle, (TelSmsEtwsMsg_t*)data);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiSimStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ int status = *(int *)data;
+
+ MSG_INFO("SIM Status [%d]", status);
+
+ if (status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ MSG_INFO("SIM Initialize by sim status change callback");
+ Sms3gppSetting::instance()->setSimChangeStatus(handle);
+ } else if (status == TAPI_SIM_STATUS_UNKNOWN) {
+ MSG_INFO("SIM TAPI_SIM_STATUS_UNKNOWN");
+ Sms3gppSetting::instance()->setSimChangeStatus(handle);
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiNetworkRegistrationType(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ TelNetworkServiceType_t *type = (TelNetworkServiceType_t *)data;
+
+ MSG_INFO("network status type [%d]", *type);
+
+ if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) {
+ /* Call Event Handler */
+ Sms3gppEventHandler::instance()->handleResendMessage();
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ Sms3gppSetting::instance()->SimRefreshCb(handle);
+}
+
+
+void Sms3gppTapiEventHandler::NotiSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ try {
+ Sms3gppSatHandler::instance()->sendSms(handle, data);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiSatMoSmControlResult(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ try {
+ Sms3gppSatHandler::instance()->ctrlSms(handle, data);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::NotiSmsMemoryStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ TelSmsMemStatusType *type = (TelSmsMemStatusType *)data;
+ if (*type == TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL) {
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ Sms3gppEventHandler::instance()->handleSimMemoryFull(simIndex);
+ }
+}
+
+
+void Sms3gppTapiEventHandler::respSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result = [0x%x]", result);
+
+ SMS_NETWORK_STATUS_T sentStatus;
+
+ TelSatMoSmCtrlIndData_t *moCtrlStatus = (TelSatMoSmCtrlIndData_t *)user_data;
+
+ sentStatus = convertTapiRespToSmsPlugin(result);
+
+ if (moCtrlStatus && sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED) {
+ if (moCtrlStatus->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
+ sentStatus = SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD;
+ }
+ }
+
+ if (result != TAPI_NETTEXT_SENDSMS_SUCCESS) {
+ MSG_INFO("sentStatus:[%d], tapi_result:[0x%x]", sentStatus, result);
+ }
+
+ MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
+
+ /* only temporary errors should be returned without calling handleSentStatus() in order to resend sms */
+ if (sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
+ sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD ||
+ sentStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
+ Sms3gppTransport::instance()->setNetStatus(sentStatus);
+ return;
+ }
+
+ if (sentStatus == SMS_NETWORK_SEND_FAIL) {
+ int svc_type;
+ tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+ if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G)
+ sentStatus = SMS_NETWORK_SEND_PENDING;
+ }
+
+ /* Convert SMS status -> Messaging network status */
+ msg_network_status_t netStatus;
+
+ if (sentStatus == SMS_NETWORK_SEND_SUCCESS) {
+ netStatus = MSG_NETWORK_SEND_SUCCESS;
+ } else if (sentStatus == SMS_NETWORK_SENDING) {
+ netStatus = MSG_NETWORK_SENDING;
+ } else if (sentStatus == SMS_NETWORK_SEND_PENDING) {
+ netStatus = MSG_NETWORK_SEND_PENDING;
+ } else {
+ netStatus = MSG_NETWORK_SEND_FAIL;
+ }
+
+ try {
+ Sms3gppEventHandler::instance()->handleSentStatus(netStatus);
+
+ Sms3gppTransport::instance()->setNetStatus(sentStatus);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::respSatSmsSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result = [%d]", result);
+
+ SMS_NETWORK_STATUS_T sentStatus = convertTapiRespToSmsPlugin(result);
+
+ MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
+
+ if (sentStatus == SMS_NETWORK_SEND_FAIL && result != TAPI_NETTEXT_DEVICE_FAILURE) {
+ int svc_type;
+ tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+ if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G)
+ sentStatus = SMS_NETWORK_SEND_PENDING;
+ }
+
+ try {
+ Sms3gppSatHandler::instance()->ctrlSms(handle, sentStatus);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::respDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result = [%d]", result);
+}
+
+
+void Sms3gppTapiEventHandler::respGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result = [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:[0x%x]", result);
+ MSG_3GPP_SIM_COUNT_S simCnt;
+ memset(&simCnt, 0x00, sizeof(MSG_3GPP_SIM_COUNT_S));
+ Sms3gppSimMsg::instance()->setSimMsgCntEvent(handle, &simCnt);
+ return;
+ }
+
+ Sms3gppSimMsg::instance()->setSimMsgCntEvent(handle, (MSG_3GPP_SIM_COUNT_S *)data);
+}
+
+
+void Sms3gppTapiEventHandler::respGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result = [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_WARN("Error! Result:(%d)", result);
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ return;
+ }
+
+ TelSmsData_t* pSmsTpdu = (TelSmsData_t*)data;
+
+ int *simIdList = (int *)user_data;
+
+ /* Reading TelSmsData_t */
+ MSG_DEBUG("sim index %d", pSmsTpdu->SimIndex);
+ MSG_DEBUG("status %d", pSmsTpdu->MsgStatus);
+ MSG_DEBUG("sim msg [%s]", pSmsTpdu->SmsData.szData);
+
+ /* Reading TelSmsDatapackageInfo_t */
+ if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN) {
+ MSG_DEBUG("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ return;
+ }
+
+ SMS_3GPP_TPDU_S tpdu;
+
+ /* decode Tpdu */
+ Sms3gppTpduCodec::decodeTpdu(handle, pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
+
+ MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
+
+ bool bRead = false;
+
+ /* set read status */
+ if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ) {
+ bRead = true;
+ } else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD) {
+ bRead = false;
+ }
+
+ if (tpdu.tpduType == SMS_TPDU_DELIVER) {
+ if (tpdu.data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.deliver.pid == 0x11) {
+ MSG_DEBUG("Unsupported message!!");
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ return;
+ }
+
+ MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
+ for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++) {
+ /* Handler Concatenated Message */
+ if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
+ tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ Sms3gppConcatHandler::instance()->handleSimConcatMsg(handle, &tpdu, pSmsTpdu->SimIndex, bRead, simIdList);
+ return;
+ }
+
+ if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_SPECIAL_SMS) {
+ MSG_DEBUG("Unsupported Special SMS!!");
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ return;
+ }
+ }
+ } else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
+ if (tpdu.data.submit.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.submit.pid == 0x11) {
+ MSG_DEBUG("Unsupported message!!");
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
+ return;
+ }
+ MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
+
+ for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++) {
+ /* Handler Concatenated Message */
+ if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
+ tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
+ Sms3gppConcatHandler::instance()->handleSimConcatMsg(handle, &tpdu, pSmsTpdu->SimIndex, bRead, simIdList);
+ return;
+ }
+ }
+ }
+
+ /* Make MSG_MESSAGE_INFO_S */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ /* set storage id */
+ msgInfo.storageId = MSG_STORAGE_SIM;
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ Sms3gppEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo);
+
+ msgInfo.sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (tpdu.tpduType == SMS_TPDU_DELIVER && tpdu.data.deliver.dcs.bMWI == true) {
+ if (tpdu.data.deliver.pid == 0x20 && tpdu.data.deliver.originAddress.ton == SMS_TON_ALPHANUMERIC) {
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ char *voiceNumber = NULL;
+ char *voiceAlphaId = NULL;
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msgInfo.sim_idx);
+ if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msgInfo.sim_idx);
+ if (MsgSettingGetString(keyName, &voiceAlphaId) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ memset(msgInfo.addressList[0].addressVal, 0x00, sizeof(msgInfo.addressList[0].addressVal));
+ memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
+
+ if (voiceNumber) {
+ snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNumber);
+ free(voiceNumber);
+ voiceNumber = NULL;
+ }
+
+ if (voiceAlphaId) {
+ snprintf(msgInfo.addressList[0].displayName, sizeof(msgInfo.addressList[0].displayName), "%s", voiceAlphaId);
+ free(voiceAlphaId);
+ voiceAlphaId = NULL;
+ }
+
+ memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "Voice message");
+ }
+ } else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
+ msgInfo.displayTime = time(NULL);
+ }
+
+ /* set read status */
+ msgInfo.bRead = bRead;
+
+ simIdList[0] = pSmsTpdu->SimIndex + 1;
+ /* Print MSG_MESSAGE_INFO_S */
+ MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
+ MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
+ MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+ MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+ MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+ MSG_SEC_DEBUG("msgInfo.addressList[0].displayName : %s", msgInfo.addressList[0].displayName);
+ MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+ MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+ MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+ MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+ MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+ MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+ MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+ MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+ MSG_DEBUG("msgInfo.displayTime : %ld", msgInfo.displayTime);
+ MSG_DEBUG("msgInfo.dataSize : %zu", msgInfo.dataSize);
+ if (msgInfo.bTextSms == true)
+ MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+ else
+ MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+ MSG_DEBUG("msgInfo.sim_idx : %d", msgInfo.sim_idx);
+ MSG_DEBUG("###############################################################");
+
+ Sms3gppSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
+}
+
+
+void Sms3gppTapiEventHandler::respSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result [%d]", result);
+
+ int simId = -1;
+
+ if (data != NULL) {
+ simId = *((int*)data);
+ } else {
+ MSG_ERR("Data(SIM Msg ID) is NULL");
+ }
+
+ Sms3gppSimMsg::instance()->setSaveSimMsgEvent(handle, simId, result);
+}
+
+
+void Sms3gppTapiEventHandler::respSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result [%d]", result);
+
+ int simId = -1;
+
+ if (data != NULL) {
+ simId = *((int*)data);
+ MSG_DEBUG("SIM Msg ID : %d", simId);
+ } else {
+ MSG_ERR("Data(SIM Msg ID) is NULL");
+ }
+
+ MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)user_data;
+
+ Sms3gppSimMsg::instance()->setSaveClass2MsgEvent(handle, simId, result, pMsgInfo);
+
+ if (result == TAPI_NETTEXT_SENDSMS_SUCCESS) {
+ Sms3gppSimMsg::instance()->setSimEvent((msg_sim_id_t)simId, true);
+ } else {
+ Sms3gppSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
+ }
+
+ if (pMsgInfo) {
+ if (pMsgInfo->addressList) {
+ delete[] pMsgInfo->addressList;
+ pMsgInfo->addressList = NULL;
+ }
+ free(pMsgInfo);
+ pMsgInfo = NULL;
+ }
+}
+
+
+void Sms3gppTapiEventHandler::respDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error! result:(0x%x)", result);
+ Sms3gppSimMsg::instance()->setDelSimEvent(-1, false);
+ return;
+ }
+
+ int sim_id = *((int*)data);
+ Sms3gppSimMsg::instance()->setDelSimEvent(sim_id, true);
+}
+
+
+void Sms3gppTapiEventHandler::respSetConfigData(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("respSetConfigData is called.");
+
+ if (data == NULL) {
+ MSG_ERR("Error. data is NULL. result:%d", result);
+ Sms3gppSetting::instance()->setResultFromSim(false);
+ return;
+ }
+
+ TelSmsSetResponse* responseType = (TelSmsSetResponse*)data;
+
+ MSG_DEBUG("responseType : [%d]", *responseType);
+
+ switch (*responseType) {
+ case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
+ MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
+ break;
+ case TAPI_NETTEXT_SETPARAMETERS_RSP :
+ MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
+ break;
+ case TAPI_NETTEXT_CBSETCONFIG_RSP :
+ MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
+ break;
+ case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
+ MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
+ break;
+ case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
+ MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
+ break;
+ default :
+ MSG_DEBUG("Unknown Response is called [%d]", *responseType);
+ break;
+ }
+
+ bool bRet = true;
+
+ MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
+
+ if ((TelSmsCause_t)result != TAPI_NETTEXT_SUCCESS) bRet = false;
+
+ if (*responseType == TAPI_NETTEXT_SETMESSAGESTATUS_RSP) {
+ Sms3gppSimMsg::instance()->setSimEvent(0, bRet);
+ } else {
+ Sms3gppSetting::instance()->setResultFromSim(bRet);
+ }
+}
+
+
+void Sms3gppTapiEventHandler::respGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ MSG_CBMSG_OPT_S cbOpt = {0};
+
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (result != TAPI_API_SUCCESS || data == NULL || simIndex == 0) {
+ MSG_ERR("Error. data is NULL. result:(0x%x), simIndex:(%d)", result, simIndex);
+ Sms3gppSetting::instance()->setCbConfigEvent(handle, NULL, false);
+ return;
+ }
+
+ TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)data;
+
+ cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
+ cbOpt.maxSimCnt = TAPI_NETTEXT_SMS_CBMI_LIST_SIZE_MAX;
+ cbOpt.simIndex = simIndex;
+
+ MSG_DEBUG("Sim Index [%d], Receive [%d], Max SIM Count [%d]", simIndex, cbOpt.bReceive, cbOpt.maxSimCnt);
+
+ cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
+ if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX) {
+ MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
+ cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
+ }
+
+ MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
+
+ for (int i = 0; i < cbOpt.channelData.channelCnt; i++) {
+ cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp.Selected;
+ cbOpt.channelData.channelInfo[i].from = pCBConfig->MsgIDs[i].Net3gpp.FromMsgId;
+ cbOpt.channelData.channelInfo[i].to = pCBConfig->MsgIDs[i].Net3gpp.ToMsgId;
+ memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
+
+ MSG_DEBUG("Channel FROM [%d], Channel TO [%d] ", cbOpt.channelData.channelInfo[i].from, cbOpt.channelData.channelInfo[i].to);
+ }
+
+ Sms3gppSetting::instance()->setCbConfigEvent(handle, &cbOpt, true);
+}
+
+
+void Sms3gppTapiEventHandler::respSetSmscInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ if (result != TAPI_API_SUCCESS) {
+ Sms3gppSetting::instance()->setResultFromSim(false);
+ } else {
+ Sms3gppSetting::instance()->setResultFromSim(true);
+ }
+}
+
+
+void Sms3gppTapiEventHandler::respSetMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ if (result == TAPI_API_SUCCESS) {
+ Sms3gppTransport::instance()->setIsMemAvailable(true);
+ }
+}
+
+void Sms3gppTapiEventHandler::respSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result = [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:0x%x", result);
+ Sms3gppSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
+ return;
+ }
+
+ msg_sim_id_t sim_id = *((msg_sim_id_t *)user_data);
+ Sms3gppSimMsg::instance()->setSimEvent(sim_id, true);
+}
+
+void Sms3gppTapiEventHandler::respGetParamCnt(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:0x%x", result);
+ Sms3gppSetting::instance()->setParamCntEvent(0);
+ return;
+ }
+
+ int paramCnt = *((int*)data);
+ Sms3gppSetting::instance()->setParamCntEvent(paramCnt);
+}
+
+void Sms3gppTapiEventHandler::respGetParam(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:0x%x", result);
+ Sms3gppSetting::instance()->setParamEvent(handle, NULL, -1, false);
+ return;
+ }
+
+ TelSmsParams_t* smsParam = (TelSmsParams_t*)data;
+
+ int alphaIdLen = 0;
+ int addrLen = 0;
+ MSG_SMSC_DATA_S smscData = {0, };
+
+ /*Check Alpha ID value*/
+ alphaIdLen = smsParam->AlphaIdLen;
+ MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
+
+ if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX) {
+ MSG_ERR("Wrong Alpha ID Length: [%d]", alphaIdLen);
+ Sms3gppSetting::instance()->setParamEvent(handle, NULL, -1, false);
+ return;
+ }
+
+ /*Check Address value*/
+ addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
+ if (addrLen > SMSC_ADDR_MAX) {
+ MSG_ERR("addrLen is too long: %d", addrLen);
+ Sms3gppSetting::instance()->setParamEvent(handle, NULL, -1, false);
+ return;
+ } else if (addrLen < 2) {
+ MSG_ERR("addrLen is too short: %d", addrLen);
+ Sms3gppSetting::instance()->setParamEvent(handle, NULL, -1, false);
+ return;
+ }
+
+ MSG_DEBUG("addrLen : %d", addrLen);
+
+ /*SMSP Parameter Indicator value*/
+ MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
+
+ /*Get SMSC Address*/
+ if (0x00 == (0x02 & smsParam->ParamIndicator)) {
+ MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
+
+ MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
+ MSG_DEBUG("NPI : %d", smsParam->TpSvcCntrAddr.Npi);
+
+ smscData.smscAddr.ton = smsParam->TpSvcCntrAddr.Ton;
+ smscData.smscAddr.npi = smsParam->TpSvcCntrAddr.Npi;
+
+ Sms3gppParamCodec paramCodec;
+
+ memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
+ paramCodec.decodeSMSC(smsParam->TpSvcCntrAddr.szDiallingNum, addrLen, smscData.smscAddr.ton, smscData.smscAddr.address);
+
+ MSG_SEC_DEBUG("SMSC Address : [%s]", smscData.smscAddr.address);
+
+ memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
+ memcpy(smscData.name, smsParam->szAlphaId, alphaIdLen);
+ smscData.name[alphaIdLen] = '\0';
+
+ MSG_SEC_DEBUG("SMSC Name : [%s]", smscData.name);
+ } else {
+ MSG_ERR("SMSC Address is not present");
+ Sms3gppSetting::instance()->setParamEvent(handle, NULL, -1, false);
+
+ return;
+ }
+
+ /*Get the PID value*/
+ if (0x00 == (0x04 & smsParam->ParamIndicator)) {
+ SMS_3GPP_PID_T pid = (SMS_3GPP_PID_T)smsParam->TpProtocolId;
+
+ MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
+
+ switch (pid) {
+ case SMS_PID_NORMAL:
+ smscData.pid = MSG_PID_TEXT;
+ break;
+ case SMS_PID_VOICE:
+ smscData.pid = MSG_PID_VOICE;
+ break;
+ case SMS_PID_TELEX:
+ smscData.pid = MSG_PID_FAX;
+ break;
+ case SMS_PID_x400:
+ smscData.pid = MSG_PID_X400;
+ break;
+ case SMS_PID_ERMES:
+ smscData.pid = MSG_PID_ERMES;
+ break;
+ case SMS_PID_EMAIL:
+ smscData.pid = MSG_PID_EMAIL;
+ break;
+ default:
+ smscData.pid = MSG_PID_TEXT;
+ break;
+ }
+
+ MSG_DEBUG("smscData.pid : %d", smscData.pid);
+ } else {
+ MSG_INFO("PID is not present");
+ smscData.pid = MSG_PID_TEXT;
+ MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
+ }
+
+#if 0
+ /*Get the DCS value*/
+ if (0x00 == (0x08 & smsParam->ParamIndicator)) {
+ smscList.smscData[index].dcs = smsParam->TpDataCodingScheme;
+ MSG_DEBUG("dcs : %d", smscList.smscData[index].dcs);
+ } else {
+ smscList.smscData[index].dcs = MSG_ENCODE_GSM7BIT;
+ MSG_DEBUG("DCS is not present");
+ }
+#endif
+
+ /*Get the ValidityPeriod value*/
+ if (0x00 == (0x10 & smsParam->ParamIndicator)) {
+ smscData.valPeriod = smsParam->TpValidityPeriod;
+ MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
+ } else {
+ smscData.valPeriod = 0;
+
+ MSG_DEBUG("Validity Period is not present");
+ }
+
+ Sms3gppSetting::instance()->setParamEvent(handle, &smscData, (int)smsParam->RecordIndex, true);
+}
+
+void Sms3gppTapiEventHandler::respSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ bool bRet = true;
+ bool *bShowError = (bool*)user_data;
+
+ if (result != TAPI_SIM_ACCESS_SUCCESS && *bShowError == true) {
+ bRet = false;
+ }
+
+ Sms3gppSetting::instance()->setResultFromSim(bRet);
+}
+
+void Sms3gppTapiEventHandler::respGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result = [%d]", result);
+
+ if (result == TAPI_API_SIM_SERVICE_IS_DISABLED) {
+ MSG_INFO("result is TAPI_API_SIM_SERVICE_IS_DISABLED");
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ char *voiceNum = NULL;
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
+ if (MsgSettingGetString(keyName, &voiceNum) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ if (voiceNum && strlen(voiceNum)) {
+ MSG_DEBUG("Voice mailbox number exist in vconf");
+ Sms3gppSetting::instance()->setMailboxInfoEvent(handle, NULL, true, false);
+ free(voiceNum);
+ voiceNum = NULL;
+ return;
+ } else {
+ Sms3gppSetting::instance()->setMailboxInfoEvent(handle, NULL, false, false);
+ if (voiceNum) {
+ free(voiceNum);
+ voiceNum = NULL;
+ }
+ return;
+ }
+ } else if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL.");
+ /*If result is not TAPI_SIM_ACCESS_SUCCESS, set bMbdnEnable to false*/
+ Sms3gppSetting::instance()->setMailboxInfoEvent(handle, NULL, false, false);
+ return;
+ }
+
+ TelSimMailboxList_t *list = (TelSimMailboxList_t *)data;
+ SMS_3GPP_SIM_MAILBOX_LIST_S mbList = {0,};
+
+ if (list->count <= 0) {
+ MSG_INFO("Mailbox list is empty");
+ Sms3gppSetting::instance()->setMailboxInfoEvent(handle, NULL, false, true);
+ return;
+ }
+
+ mbList.count = list->count;
+
+ for (int i = 0; i < mbList.count; i++) {
+ mbList.list[i].b_cphs = list->list[i].b_cphs;
+ mbList.list[i].alpha_id_max_len = list->list[i].alpha_id_max_len;
+ mbList.list[i].mb_type = list->list[i].mb_type;
+ mbList.list[i].profile_num = list->list[i].profile_num;
+ mbList.list[i].rec_index = list->list[i].rec_index;
+ mbList.list[i].ton = list->list[i].ton;
+ mbList.list[i].npi = list->list[i].npi;
+ snprintf(mbList.list[i].alpha_id, sizeof(mbList.list[i].alpha_id), "%s", list->list[i].alpha_id);
+ snprintf(mbList.list[i].num, sizeof(mbList.list[i].num), "%s", list->list[i].num);
+ mbList.list[i].cc_id = list->list[i].cc_id;
+ mbList.list[i].ext1_id = list->list[i].ext1_id;
+ mbList.list[i].num_len = strlen(mbList.list[i].num);
+ }
+
+ Sms3gppSetting::instance()->setMailboxInfoEvent(handle, &mbList, true, true);
+}
+
+void Sms3gppTapiEventHandler::respSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("TapiEventSetMwiInfo is called. result = [%d]", result);
+}
+
+void Sms3gppTapiEventHandler::respGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("TapiEventGetMwiInfo is called.");
+
+ if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:0x%x", result);
+ Sms3gppSetting::instance()->setMwiInfoEvent(handle, NULL, false);
+ return;
+ }
+
+ TelSimMessageWaitingResp_t *MwiInfo = (TelSimMessageWaitingResp_t *)data;
+ SMS_3GPP_SIM_MWI_INFO_S simMwiInfo = {0,};
+ memcpy(&simMwiInfo, MwiInfo, sizeof(SMS_3GPP_SIM_MWI_INFO_S));
+
+ Sms3gppSetting::instance()->setMwiInfoEvent(handle, &simMwiInfo, true);
+}
+
+void Sms3gppTapiEventHandler::respGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("respGetMsisdnInfo is called");
+
+ bool bRet = false;
+ bool bDisableGroupMessage = false;
+
+ if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:0x%x", result);
+ Sms3gppSetting::instance()->setResultFromSim(bRet);
+ return;
+ }
+
+ TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
+
+ for (int i = 0; i < list->count; i++) {
+ if (list->list[i].num[0] != '\0') {
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
+
+ if (MsgSettingSetString(keyName, list->list[i].num) == MSG_SUCCESS) {
+ MSG_SEC_INFO("Get MSISDN from SIM : [%s]", list->list[i].num);
+ bRet = true;
+ } else {
+ MSG_DEBUG("Getting MSISDN is failed!");
+ }
+ break;
+ } else {
+ MSG_WARN("Msisdn is empty");
+ bDisableGroupMessage = true;
+ }
+ }
+
+ int tmpVal = 0;
+ if (MsgSettingGetInt(MMS_RECV_GROUP_MESSAGE, &tmpVal) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetInt() is failed");
+
+ /* If the value from MMS_RECV_GROUP_MESSAGE is less than 0, it means group message mode is disabled. */
+ if ((tmpVal < 0 && bDisableGroupMessage == false) || (tmpVal > 0 && bDisableGroupMessage == true)) {
+ if (MsgSettingSetInt(MMS_RECV_GROUP_MESSAGE, -tmpVal))
+ MSG_ERR("Error to set config data [%s]", MMS_RECV_GROUP_MESSAGE);
+ }
+
+ Sms3gppSetting::instance()->setResultFromSim(bRet);
+}
+
+void Sms3gppTapiEventHandler::respGetSimServiceTable(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("TapiEventGetSimServiceTable is called.");
+
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimServiceTable_t *svct = (TelSimServiceTable_t *)data;
+
+ bool bRet = true;
+
+ if (access_rt != TAPI_SIM_ACCESS_SUCCESS || svct == NULL) {
+ MSG_ERR("Error. data is NULL and access_rt [%d] failed", access_rt);
+ Sms3gppSetting::instance()->setResultFromSim(false);
+ return;
+ }
+
+ msg_error_t err = MSG_SUCCESS;
+
+ char sstKey[128];
+ char moCtrlKey[128];
+
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ memset(sstKey, 0x00, sizeof(sstKey));
+ snprintf(sstKey, sizeof(sstKey), "%s/%d", MSG_SIM_SERVICE_TABLE, simIndex);
+
+ memset(moCtrlKey, 0x00, sizeof(moCtrlKey));
+ snprintf(moCtrlKey, sizeof(moCtrlKey), "%s/%d", MSG_SIM_MO_CONTROL, simIndex);
+
+ if (svct->sim_type == TAPI_SIM_CARD_TYPE_GSM) {
+ if (svct->table.sst.service[TAPI_SIM_SST_SMS] == 1) {
+ err = MsgSettingSetBool(sstKey, true);
+ } else {
+ err = MsgSettingSetBool(sstKey, false);
+ }
+ MSG_DEBUG("Setting result = [%d]", err);
+
+ if (svct->table.sst.service[TAPI_SIM_SST_MO_SMS_CTRL_BY_SIM] == 1) {
+ err = MsgSettingSetBool(moCtrlKey, true);
+ } else {
+ err = MsgSettingSetBool(moCtrlKey, false);
+ }
+ MSG_DEBUG("Setting result = [%d]", err);
+
+ } else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) {
+ if (svct->table.ust.service[TAPI_SIM_UST_SMS] == 1) {
+ err = MsgSettingSetBool(sstKey, true);
+ } else {
+ err = MsgSettingSetBool(sstKey, false);
+ }
+ MSG_DEBUG("Setting result = [%d]", err);
+
+ if (svct->table.ust.service[TAPI_SIM_UST_MO_SMS_CTRL] == 1) {
+ err = MsgSettingSetBool(moCtrlKey, true);
+ } else {
+ err = MsgSettingSetBool(moCtrlKey, false);
+ }
+ MSG_DEBUG("Setting result = [%d]", err);
+
+ } else {
+ MSG_DEBUG("Unknown SIM type value");
+
+ }
+
+ Sms3gppSetting::instance()->setResultFromSim(bRet);
+}
+
+
+void Sms3gppTapiEventHandler::respGetMeImei(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_SEC_DEBUG("TapiEventGetMeImei is called. result [%d]", result);
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:0x%x", result);
+ Sms3gppSetting::instance()->setResultImei(false, NULL);
+ return;
+ }
+
+ char *tmpImei = (char *)data;
+
+ Sms3gppSetting::instance()->setResultImei(true, tmpImei);
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include "Sms3gppTpduCodec.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "Sms3gppUDCodec.h"
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+
+#include "Sms3gppParamCodec.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppTpduCodec - Member Functions
+==================================================================================================*/
+Sms3gppTpduCodec::Sms3gppTpduCodec()
+{
+}
+
+
+Sms3gppTpduCodec::~Sms3gppTpduCodec()
+{
+}
+
+
+int Sms3gppTpduCodec::encodeTpdu(const SMS_3GPP_TPDU_S *pSmsTpdu, char *pTpdu)
+{
+ int tpduLen = 0;
+
+ switch (pSmsTpdu->tpduType) {
+ case SMS_TPDU_SUBMIT:
+ tpduLen = encodeSubmit(&(pSmsTpdu->data.submit), pTpdu);
+ break;
+ case SMS_TPDU_DELIVER:
+ tpduLen = encodeDeliver(&(pSmsTpdu->data.deliver), pTpdu);
+ break;
+ case SMS_TPDU_DELIVER_REP:
+ tpduLen = encodeDeliverReport(&(pSmsTpdu->data.deliverRep), pTpdu);
+ break;
+ case SMS_TPDU_STATUS_REP:
+ tpduLen = encodeStatusReport(&(pSmsTpdu->data.statusRep), pTpdu);
+ break;
+ }
+
+ return tpduLen;
+}
+
+
+int Sms3gppTpduCodec::decodeTpdu(TapiHandle *handle, const unsigned char *pTpdu, int TpduLen, SMS_3GPP_TPDU_S *pSmsTpdu)
+{
+ int decodeLen = 0;
+
+ char mti = pTpdu[0] & 0x03;
+
+ switch (mti) {
+ case 0x00:
+ pSmsTpdu->tpduType = SMS_TPDU_DELIVER;
+ decodeLen = decodeDeliver(handle, pTpdu, TpduLen, &(pSmsTpdu->data.deliver));
+ break;
+ case 0x01:
+ pSmsTpdu->tpduType = SMS_TPDU_SUBMIT;
+ decodeLen = decodeSubmit(pTpdu, TpduLen, &(pSmsTpdu->data.submit));
+ break;
+ case 0x02:
+ pSmsTpdu->tpduType = SMS_TPDU_STATUS_REP;
+ decodeLen = decodeStatusReport(pTpdu, TpduLen, &(pSmsTpdu->data.statusRep));
+ break;
+ }
+
+ return decodeLen;
+}
+
+
+int Sms3gppTpduCodec::encodeSubmit(const SMS_3GPP_SUBMIT_S *pSubmit, char *pTpdu)
+{
+ int offset = 0, length = 0, encodeSize = 0;
+
+ char* address = NULL;
+ unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
+
+ char* dcs = NULL;
+ unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
+
+ char* vpTime = NULL;
+ unique_ptr<char*, void(*)(char**)> vpBuf(&vpTime, unique_ptr_deleter);
+
+ /* TP-MTI */
+ pTpdu[offset] = 0x01;
+
+ /* TP-RD */
+ if (pSubmit->bRejectDup == true)
+ pTpdu[offset] |= 0x04;
+
+ /* TP-VPF */
+ switch (pSubmit->vpf) {
+ case SMS_VPF_NOT_PRESENT:
+ break;
+ case SMS_VPF_ENHANCED:
+ pTpdu[offset] |= 0x08;
+ break;
+ case SMS_VPF_RELATIVE:
+ pTpdu[offset] |= 0x10;
+ break;
+ case SMS_VPF_ABSOLUTE:
+ pTpdu[offset] |= 0x18;
+ break;
+ default:
+ break;
+ }
+
+ /* TP-SRR */
+ if (pSubmit->bStatusReport == true)
+ pTpdu[offset] |= 0x20;
+
+ MSG_DEBUG("TP-SRR pSubmit->bStatusReport : %d.", pSubmit->bStatusReport);
+
+ /* TP-UDHI */
+ if (pSubmit->bHeaderInd == true)
+ pTpdu[offset] |= 0x40;
+
+ /* TP-RP */
+ if (pSubmit->bReplyPath == true)
+ pTpdu[offset] |= 0x80;
+
+ offset++;
+
+ /* TP-MR */
+ pTpdu[offset++] = pSubmit->msgRef;
+
+ MSG_DEBUG("TP-MR pSubmit->msgRef : %d.", pSubmit->msgRef);
+
+ /* TP-DA */
+ length = Sms3gppParamCodec::encodeAddress(&pSubmit->destAddress, &address);
+ memcpy(&(pTpdu[offset]), address, length);
+ offset += length;
+
+ MSG_DEBUG("TP-DA length : %d.", length);
+
+ /* TP-PID */
+ pTpdu[offset++] = pSubmit->pid;
+
+ MSG_DEBUG("TP-PID pSubmit->pid : %d.", pSubmit->pid);
+
+ /* TP-DCS */
+ length = Sms3gppParamCodec::encodeDCS(&pSubmit->dcs, &dcs);
+ memcpy(&(pTpdu[offset]), dcs, length);
+ offset += length;
+
+ MSG_DEBUG("TP-DCS length : %d.", length);
+
+ /* TP-VP */
+ if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
+ length = Sms3gppParamCodec::encodeTime(&pSubmit->validityPeriod, &vpTime);
+
+ if (length > 0) {
+ memcpy(&(pTpdu[offset]), vpTime, length);
+ offset += length;
+ }
+ }
+
+ encodeSize = Sms3gppUDCodec::encodeUserData(&(pSubmit->userData), pSubmit->dcs.codingScheme, &(pTpdu[offset]));
+
+ MSG_DEBUG("encodeSize : %d", encodeSize);
+
+ offset += encodeSize;
+
+#if 0
+ printf("\n\n[encodeSubmit] pTpdu data.\n");
+ for (int i = 0; i < offset; i++) {
+ printf(" [%02x]", pTpdu[i]);
+ }
+ printf("\n\n");
+#endif
+
+ return offset;
+}
+
+
+int Sms3gppTpduCodec::encodeDeliver(const SMS_3GPP_DELIVER_S *pDeliver, char *pTpdu)
+{
+ int offset = 0, length = 0, encodeSize = 0;
+
+ char* address = NULL;
+ unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
+
+ char* dcs = NULL;
+ unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
+
+ char* scts = NULL;
+ unique_ptr<char*, void(*)(char**)> timeBuf(&scts, unique_ptr_deleter);
+
+ /* TP-MTI : 00 */
+ pTpdu[offset] = 0x00;
+
+ /* TP-MMS */
+ if (pDeliver->bMoreMsg == false)
+ pTpdu[offset] |= 0x04;
+
+ /* TP-SRI */
+ if (pDeliver->bStatusReport == true)
+ pTpdu[offset] |= 0x20;
+
+ /* TP-UDHI */
+ if (pDeliver->bHeaderInd == true)
+ pTpdu[offset] |= 0x40;
+
+ /* TP-RP */
+ if (pDeliver->bReplyPath == true)
+ pTpdu[offset] |= 0x80;
+
+ offset++;
+
+ /* TP-OA */
+ length = Sms3gppParamCodec::encodeAddress(&pDeliver->originAddress, &address);
+ memcpy(&(pTpdu[offset]), address, length);
+ offset += length;
+
+ /* TP-PID */
+ pTpdu[offset++] = pDeliver->pid;
+
+ /* TP-DCS */
+ length = Sms3gppParamCodec::encodeDCS(&pDeliver->dcs, &dcs);
+ memcpy(&(pTpdu[offset]), dcs, length);
+ offset += length;
+
+ /* TP-SCTS */
+ length = Sms3gppParamCodec::encodeTime(&pDeliver->timeStamp, &scts);
+ memcpy(&(pTpdu[offset]), scts, length);
+ offset += length;
+
+ /* TP-UDL & TP-UD */
+ encodeSize = Sms3gppUDCodec::encodeUserData(&(pDeliver->userData), pDeliver->dcs.codingScheme, &(pTpdu[offset]));
+
+ MSG_DEBUG("encodeSize : %d", encodeSize);
+
+ offset += encodeSize;
+
+ return offset;
+}
+
+
+int Sms3gppTpduCodec::encodeDeliverReport(const SMS_3GPP_DELIVER_REPORT_S *pDeliverRep, char *pTpdu)
+{
+ int offset = 0;
+
+ /* TP-MTI : 00 */
+ pTpdu[offset] = 0x00;
+
+ /* TP-UDHI */
+ if (pDeliverRep->bHeaderInd == true)
+ pTpdu[offset] |= 0x40;
+
+ offset++;
+
+ /* TP-FCS */
+ if (pDeliverRep->reportType == SMS_REPORT_NEGATIVE) {
+ pTpdu[offset++] = pDeliverRep->failCause;
+ MSG_DEBUG("Delivery report : fail cause = [%02x]", pDeliverRep->failCause);
+ }
+
+ /* TP-PI */
+ pTpdu[offset++] = pDeliverRep->paramInd;
+
+ /* TP-PID */
+ if (pDeliverRep->paramInd & 0x01)
+ pTpdu[offset++] = pDeliverRep->pid;
+
+ /* TP-DCS */
+ if (pDeliverRep->paramInd & 0x02) {
+ int length = 0;
+
+ char* dcs = NULL;
+ unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
+
+ length = Sms3gppParamCodec::encodeDCS(&pDeliverRep->dcs, &dcs);
+ memcpy(&(pTpdu[offset]), dcs, length);
+
+ offset += length;
+ }
+
+ /* TP-UDL & TP-UD */
+ if (pDeliverRep->paramInd & 0x04) {
+ int encodeSize = 0;
+
+ encodeSize = Sms3gppUDCodec::encodeUserData(&(pDeliverRep->userData), pDeliverRep->dcs.codingScheme, &(pTpdu[offset]));
+
+ MSG_DEBUG("encodeSize : %d", encodeSize);
+
+ offset += encodeSize;
+ }
+
+ pTpdu[offset] = '\0';
+
+ return offset;
+}
+
+
+int Sms3gppTpduCodec::encodeStatusReport(const SMS_3GPP_STATUS_REPORT_S *pStatusRep, char *pTpdu)
+{
+ int offset = 0, length = 0;
+
+ char* address = NULL;
+ unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
+
+ char* scts = NULL;
+ unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter);
+
+ char* dt = NULL;
+ unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
+
+ /* TP-MTI : 10 */
+ pTpdu[offset] = 0x02;
+
+ /* TP-MMS */
+ if (pStatusRep->bMoreMsg == true)
+ pTpdu[offset] |= 0x04;
+
+ /* TP-SRQ */
+ if (pStatusRep->bStatusReport == true)
+ pTpdu[offset] |= 0x20;
+
+ /* TP-UDHI */
+ if (pStatusRep->bHeaderInd == true)
+ pTpdu[offset] |= 0x40;
+
+ offset++;
+
+ /* TP-MR */
+ pTpdu[offset++] = pStatusRep->msgRef;
+
+ /* TP-RA */
+ length = Sms3gppParamCodec::encodeAddress(&pStatusRep->recipAddress, &address);
+ memcpy(&(pTpdu[offset]), address, length);
+ offset += length;
+
+ /* TP-SCTS */
+ length = Sms3gppParamCodec::encodeTime(&pStatusRep->timeStamp, &scts);
+ memcpy(&(pTpdu[offset]), scts, length);
+ offset += length;
+
+ /* TP-DT */
+ length = Sms3gppParamCodec::encodeTime(&pStatusRep->dischargeTime, &dt);
+ memcpy(&(pTpdu[offset]), dt, length);
+ offset += length;
+
+ /* TP-Status */
+ pTpdu[offset++] = pStatusRep->status;
+
+ /* TP-PI */
+ pTpdu[offset++] = pStatusRep->paramInd;
+
+ /* TP-PID */
+ if (pStatusRep->paramInd & 0x01)
+ pTpdu[offset++] = pStatusRep->pid;
+
+ /* TP-DCS */
+ if (pStatusRep->paramInd & 0x02) {
+ int length = 0;
+
+ char* dcs = NULL;
+ unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
+
+ length = Sms3gppParamCodec::encodeDCS(&pStatusRep->dcs, &dcs);
+ memcpy(&(pTpdu[offset]), dcs, length);
+
+ offset += length;
+ }
+
+ /* TP-UDL & TP-UD */
+ if (pStatusRep->paramInd & 0x04) {
+ int encodeSize = 0;
+
+ encodeSize = Sms3gppUDCodec::encodeUserData(&(pStatusRep->userData), pStatusRep->dcs.codingScheme, &(pTpdu[offset]));
+
+ MSG_DEBUG("encodeSize : %d", encodeSize);
+
+ offset += encodeSize;
+ }
+
+ pTpdu[offset] = '\0';
+
+ return offset;
+}
+
+
+int Sms3gppTpduCodec::decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_3GPP_SUBMIT_S *pSubmit)
+{
+ int offset = 0, udLen = 0;
+
+ char tpduTmp[(TpduLen*2)+1];
+ memset(tpduTmp, 0x00, sizeof(tpduTmp));
+ for (int i = 0; i < TpduLen; i++) {
+ snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
+ }
+ MSG_DEBUG("Sumbit TPDU.");
+ MSG_INFO("[%s]", tpduTmp);
+
+ /* TP-RD */
+ if (pTpdu[offset] & 0x04)
+ pSubmit->bRejectDup = false;
+ else
+ pSubmit->bRejectDup = true;
+
+ /* TP-VPF */
+ pSubmit->vpf = (SMS_3GPP_VPF_T)(pTpdu[offset] & 0x18);
+
+ /* TP-SRR */
+ if (pTpdu[offset] & 0x20)
+ pSubmit->bStatusReport = true;
+ else
+ pSubmit->bStatusReport = false;
+
+ /* TP-UDHI */
+ if (pTpdu[offset] & 0x40)
+ pSubmit->bHeaderInd = true;
+ else
+ pSubmit->bHeaderInd = false;
+
+ /* TP-RP */
+ if (pTpdu[offset] & 0x80)
+ pSubmit->bReplyPath = true;
+ else
+ pSubmit->bReplyPath = false;
+
+ offset++;
+
+ /* TP-MR */
+ pSubmit->msgRef = pTpdu[offset++];
+
+ /* TP-DA */
+ offset += Sms3gppParamCodec::decodeAddress(pTpdu+offset, &(pSubmit->destAddress));
+
+ /* TP-PID */
+ pSubmit->pid = pTpdu[offset++];
+
+ /* TP-DCS */
+ offset += Sms3gppParamCodec::decodeDCS(pTpdu+offset, &(pSubmit->dcs));
+
+ /* TP-VP */
+ if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
+ /* Decode VP */
+ }
+
+ /* TP-UDL & TP-UD */
+ udLen = Sms3gppUDCodec::decodeUserData(pTpdu+offset, TpduLen, pSubmit->bHeaderInd, pSubmit->dcs.codingScheme, &(pSubmit->userData));
+
+ return udLen;
+}
+
+
+int Sms3gppTpduCodec::decodeDeliver(TapiHandle *handle, const unsigned char *pTpdu, int TpduLen, SMS_3GPP_DELIVER_S *pDeliver)
+{
+ int offset = 0, udLen = 0, tmpOffset = 0;
+
+ char tpduTmp[(TpduLen*2)+1];
+ memset(tpduTmp, 0x00, sizeof(tpduTmp));
+ for (int i = 0; i < TpduLen; i++) {
+ snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
+ }
+ MSG_DEBUG("Deliver TPDU.");
+ MSG_INFO("[%s]", tpduTmp);
+
+ /* TP-MMS */
+ if (pTpdu[offset] & 0x04)
+ pDeliver->bMoreMsg = false;
+ else
+ pDeliver->bMoreMsg = true;
+
+ /* TP-SRI */
+ if (pTpdu[offset] & 0x20)
+ pDeliver->bStatusReport = true;
+ else
+ pDeliver->bStatusReport = false;
+
+ /* TP-UDHI */
+ if (pTpdu[offset] & 0x40)
+ pDeliver->bHeaderInd = true;
+ else
+ pDeliver->bHeaderInd = false;
+
+ /* TP-RP */
+ if (pTpdu[offset] & 0x80)
+ pDeliver->bReplyPath = true;
+ else
+ pDeliver->bReplyPath = false;
+
+ offset++;
+
+ tmpOffset = offset;
+#if 1
+ /* TP-OA */
+ offset += Sms3gppParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
+
+ /* TP-PID */
+ pDeliver->pid = pTpdu[offset++];
+
+ /* TP-DCS */
+ offset += Sms3gppParamCodec::decodeDCS(&pTpdu[offset], &(pDeliver->dcs));
+
+ /* Support KSC5601 :: Coding group bits == 0x84 */
+ if (pTpdu[offset-1] == 0x84) {
+ pDeliver->dcs.codingScheme = SMS_CHARSET_EUCKR;
+ }
+#else
+ /* For alphanumeric address test */
+
+ offset += Sms3gppParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
+
+ char* address = new char[15];
+ address[0] = 0x04;
+ address[1] = 0xd0;
+ address[2] = 0x11;
+ address[3] = 0x00;
+ address[4] = 0x20;
+ address[5] = 0xF2;
+ address[6] = 0x01;
+ address[7] = 0x01;
+ address[8] = 0x11;
+ address[9] = 0x61;
+ address[10] = 0x40;
+ address[11] = 0x82;
+ address[12] = 0x2b;
+ address[13] = 0x01;
+ address[14] = 0x20;
+
+ Sms3gppParamCodec::decodeAddress((unsigned char*)address, &(pDeliver->originAddress));
+
+ pDeliver->pid = 0x20;
+ offset++;
+ offset += Sms3gppParamCodec::decodeDCS((unsigned char*)address, &(pDeliver->dcs));
+#endif /* end test */
+
+ if (pDeliver->pid == 0x20 && pDeliver->originAddress.ton == SMS_TON_ALPHANUMERIC) {
+ int setType = -1;
+ int indType = -1;
+
+ bool bVmi = Sms3gppParamCodec::checkCphsVmiMsg(&pTpdu[tmpOffset], &setType, &indType);
+
+ MSG_DEBUG("bVmi = [%d], setType=[%d], indType=[%d]", bVmi, setType, indType);
+
+ if (bVmi) {
+ pDeliver->dcs.bMWI = true;
+
+ if (setType == 0) {
+ pDeliver->dcs.bIndActive = false;
+ } else {
+ pDeliver->dcs.bIndActive = true;
+ }
+
+ if (indType == 0)
+ pDeliver->dcs.indType = SMS_VOICE_INDICATOR;
+ else if (indType == 1)
+ pDeliver->dcs.indType = SMS_VOICE2_INDICATOR;
+ }
+ }
+
+ /* TP-SCTS */
+ offset += Sms3gppParamCodec::decodeTime(&pTpdu[offset], &(pDeliver->timeStamp));
+
+ /* TP-UD */
+ udLen = Sms3gppUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pDeliver->bHeaderInd, pDeliver->dcs.codingScheme, &(pDeliver->userData), &(pDeliver->udData));
+
+ return udLen;
+}
+
+
+int Sms3gppTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_3GPP_STATUS_REPORT_S *pStatusRep)
+{
+#ifdef LOG_ENABLE
+ printf("\n\n[decodeStatusReport] pTpdu data - Length [%d]\n", TpduLen);
+
+ for (int i = 0; i < TpduLen; i++) {
+ printf(" [%02x]", pTpdu[i]);
+ }
+ printf("\n\n");
+#endif
+
+ int offset = 0, udLen = 0;
+
+ char* address = NULL;
+ unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
+
+ char* scts = NULL;
+ unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter);
+
+ char* dt = NULL;
+ unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
+
+ /* TP-MMS */
+ if (pTpdu[offset] & 0x04)
+ pStatusRep->bMoreMsg = false;
+ else
+ pStatusRep->bMoreMsg = true;
+
+ /* TP-SRQ */
+ if (pTpdu[offset] & 0x20)
+ pStatusRep->bStatusReport = true;
+ else
+ pStatusRep->bStatusReport = false;
+
+ /* TP-UDHI */
+ if (pTpdu[offset] & 0x40)
+ pStatusRep->bHeaderInd = true;
+ else
+ pStatusRep->bHeaderInd = false;
+
+ offset++;
+
+ /* TP-MR */
+ pStatusRep->msgRef = pTpdu[offset++];
+
+ /* TP-RA */
+ offset += Sms3gppParamCodec::decodeAddress(&pTpdu[offset], &(pStatusRep->recipAddress));
+
+ /* TP-SCTS */
+ /* Decode timestamp */
+ offset += Sms3gppParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->timeStamp));
+
+ /* TP-DT */
+ /* Decode timestamp */
+ offset += Sms3gppParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->dischargeTime));
+
+ /* TP-Status */
+ pStatusRep->status = pTpdu[offset++];
+
+ /* TP-PI */
+ pStatusRep->paramInd = pTpdu[offset++];
+
+ /* No Parameters */
+ if (pStatusRep->paramInd == 0) {
+ pStatusRep->pid = SMS_PID_NORMAL;
+
+ pStatusRep->dcs.bCompressed = false;
+ pStatusRep->dcs.bMWI = false;
+ pStatusRep->dcs.bIndActive = false;
+
+ pStatusRep->dcs.msgClass = MSG_CLASS_NONE;
+ pStatusRep->dcs.codingScheme = SMS_CHARSET_7BIT;
+ pStatusRep->dcs.codingGroup = SMS_GROUP_GENERAL;
+ pStatusRep->dcs.indType = SMS_OTHER_INDICATOR;
+
+ pStatusRep->userData.headerCnt = 0;
+ pStatusRep->userData.length = 0;
+ memset(pStatusRep->userData.data, 0x00, MAX_USER_DATA_LEN+1);
+ }
+
+ /* TP-PID */
+ if (pStatusRep->paramInd & 0x01)
+ pStatusRep->pid = pTpdu[offset++];
+
+ /* TP-DCS */
+ if (pStatusRep->paramInd & 0x02)
+ offset += Sms3gppParamCodec::decodeDCS(&pTpdu[offset], &(pStatusRep->dcs));
+
+ /* TP-UDL & TP-UD */
+ if (pStatusRep->paramInd & 0x04)
+ /* Decode User Data */
+ udLen = Sms3gppUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pStatusRep->bHeaderInd, pStatusRep->dcs.codingScheme, &(pStatusRep->userData));
+
+ return udLen;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+#include <math.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilFunction.h"
+#include "MsgNotificationWrapper.h"
+#include "MsgUtilStorage.h"
+
+#include "SmsPluginDSHandler.h"
+#include "SmsPluginStorage.h"
+#include "Sms3gppParamCodec.h"
+#include "Sms3gppTpduCodec.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppStorage.h"
+#include "Sms3gppTapiEventHandler.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppSetting.h"
+#include "Sms3gppUAManager.h"
+
+#include <ITapiNetText.h>
+#include <TelNetwork.h>
+
+
+
+Sms3gppTransport* Sms3gppTransport::pInstance = NULL;
+
+msg_error_t Sms3gppSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+#ifdef MSG_FEATURE_MDM
+#ifdef MSG_FEATURE_MDM_PHASE_2
+ /* Check MDM policy for Normal SMS */
+ if (pReqInfo->msgInfo.msgType.subType == MSG_NORMAL_SMS) {
+ if (MsgMdmGetStatus(MSG_MDM_OUTGOING_COUNT_LIMIT, pReqInfo->msgInfo.sim_idx, NULL) == MDM_RESTRICTED) {
+ MSG_INFO("SmsPlgSubmitRequest is restricted by MDM count limit.");
+ if (pReqInfo->msgInfo.msgId > 0) {
+ err = SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+ if (err == MSG_SUCCESS) {
+ return MSG_ERR_MDM_RESTRICT;
+ } else {
+ return err;
+ }
+ } else {
+ return MSG_ERR_MDM_RESTRICT;
+ }
+ }
+
+ for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) {
+ if (MsgMdmGetStatus(MSG_MDM_OUTGOING_RESTRICTION, pReqInfo->msgInfo.sim_idx, pReqInfo->msgInfo.addressList[i].addressVal) == MDM_RESTRICTED) {
+ MSG_INFO("SmsPlgSubmitRequest is restricted by MDM pattern matching.");
+ if (pReqInfo->msgInfo.msgId > 0) {
+ err = SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+ if (err == MSG_SUCCESS) {
+ return MSG_ERR_MDM_RESTRICT;
+ } else {
+ return err;
+ }
+ } else {
+ return MSG_ERR_MDM_RESTRICT;
+ }
+ }
+ }
+ }
+#endif
+#endif
+
+ /* Add Submit SMS into DB */
+ if (pReqInfo->msgInfo.msgId == 0) {
+ if (pReqInfo->msgInfo.msgPort.valid == false) {
+ err = SmsPluginStorage::instance()->checkMessage(&(pReqInfo->msgInfo));
+
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("######## checkMessage Fail !! [err=%d]", err);
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+
+ err = SmsPluginStorage::instance()->addSmsMessage(&(pReqInfo->msgInfo));
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("######## addSmsMessage Fail !! [err=%d]", err);
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+
+ if (SmsPluginStorage::instance()->addSmsSendOption(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)) != MSG_SUCCESS) {
+ MSG_ERR("######## addSmsSendOption Fail !!");
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+ }
+ }
+
+#ifdef MSG_FEATURE_MDM
+#ifdef MSG_FEATURE_MDM_PHASE_2
+ /* MDM :: SMS capture for outgoing SMS */
+ if (pReqInfo->msgInfo.msgType.subType == MSG_NORMAL_SMS) {
+ if (MsgMdmGetStatus(MSG_MDM_MESSAGE_COPY, pReqInfo->msgInfo.sim_idx, NULL) == MDM_ENABLED) {
+ mdm_result_t mdmResult = MsgMdmMessageCopy(&pReqInfo->msgInfo);
+ if (mdmResult != MDM_RESULT_SUCCESS) {
+ MSG_ERR("MsgMdmMessageCopy() failed: (%d)", mdmResult);
+ }
+ }
+ }
+#endif
+#endif
+
+ /* Check SIM is present or not */
+ char keyName[MAX_VCONFKEY_NAME_LEN] = {0,};
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx);
+
+ MSG_SIM_STATUS_T simStatus = 0;
+ if (MsgSettingGetInt(keyName, (int*)&simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
+ }
+
+ if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
+ MSG_DEBUG("SIM is not present..");
+
+ /* Update Msg Status */
+ if (pReqInfo->msgInfo.msgPort.valid == false) {
+ SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+ }
+
+ return MSG_ERR_NO_SIM;
+ }
+
+ SMS_3GPP_REQUEST_INFO_S *request = NULL;
+
+ request = (SMS_3GPP_REQUEST_INFO_S *)calloc(1, sizeof(SMS_3GPP_REQUEST_INFO_S));
+
+ if (request != NULL) {
+ request->reqId = pReqInfo->reqId;
+
+ memcpy(&(request->msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
+ memcpy(&(request->sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
+
+ /* Add Request into Queue and Start UA Manger */
+ Sms3gppUAManager::instance()->addReqEntity(request);
+
+ free(request);
+ }
+
+ return MSG_SUCCESS;
+}
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppTransport - Member Functions
+==================================================================================================*/
+
+Sms3gppTransport::Sms3gppTransport()
+{
+ isMemAvailable = true;
+ msgRef = 0x00;
+ msgRef8bit = 0x00;
+ msgRef16bit = 0x0000;
+ curStatus = SMS_NETWORK_SEND_SUCCESS;
+ memset(&curMoCtrlData, 0x00, sizeof(curMoCtrlData));
+}
+
+
+Sms3gppTransport::~Sms3gppTransport()
+{
+}
+
+
+Sms3gppTransport* Sms3gppTransport::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppTransport();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gppTransport::submitRequest(SMS_3GPP_REQUEST_INFO_S *pReqInfo)
+{
+ MSG_BEGIN();
+
+ SMS_3GPP_TPDU_S tpdu = {0, };
+ tpdu.tpduType = SMS_TPDU_SUBMIT;
+ /* Get TAPI handle */
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pReqInfo->msgInfo.sim_idx);
+
+ /* Get SMS Send Options - Setting */
+ getSmsSendOption(pReqInfo->msgInfo.sim_idx, &(tpdu.data.submit));
+
+ /* Set SMS Send Options - Each Message */
+ setSmsSendOption(pReqInfo, &tpdu);
+
+ /* Set coding scheme */
+ setSmsDcsOption(pReqInfo, &tpdu);
+
+ /* Set SMS report request */
+ setSmsReportOption(pReqInfo, &tpdu);
+
+ /* Set SMSC Options */
+ SMS_3GPP_ADDRESS_S smsc = {0, };
+ setSmscOptions(pReqInfo->msgInfo.sim_idx, &smsc);
+
+ /* Get address informations. */
+ MsgDbHandler *dbHandle = getDbHandle();
+ MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
+ MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt);
+
+ /* Get MSISDN */
+ char *msisdn = NULL;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pReqInfo->msgInfo.sim_idx);
+ if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ int failedIndex = SmsPluginStorage::instance()->getFailedIndex(dbHandle, pReqInfo->msgInfo.msgId);
+
+ for (int i = failedIndex; i < pReqInfo->msgInfo.nAddressCnt; i++) {
+ /* Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S */
+ SMS_3GPP_SUBMIT_DATA_S submitData = {{0}, };
+ msgInfoToSubmitData(&(pReqInfo->msgInfo), &submitData, &(tpdu.data.submit.dcs.codingScheme), i);
+
+ /* Insert message reference into db */
+ if (tpdu.data.submit.bStatusReport == true) {
+ Sms3gppStorage::instance()->insertMsgRef(&(pReqInfo->msgInfo), tpdu.data.submit.msgRef, i);
+ }
+
+ /* Encode SMSC Address */
+ unsigned char smscAddr[MAX_SMSC_LEN];
+ memset(smscAddr, 0x00, sizeof(smscAddr));
+
+ int smscLen = Sms3gppParamCodec::encodeSMSC(&smsc, smscAddr);
+ if (smscLen <= 0) {
+ MSG_DEBUG("smscLen <= 0");
+ goto _RETURN_FUNC;
+ }
+
+ char smscAddrTmp[(smscLen*2)+1];
+ memset(smscAddrTmp, 0x00, sizeof(smscAddrTmp));
+ for (int j = 0; j < smscLen; j++) {
+ snprintf(smscAddrTmp+(j*2), sizeof(smscAddrTmp)-(j*2), "%02X", smscAddr[j]);
+ }
+ MSG_DEBUG("pSCAInfo [%s]", smscAddrTmp);
+
+ int bufLen = 0;
+ char buf[MAX_TPDU_DATA_LEN];
+ int addLen = strlen(submitData.destAddress.address);
+
+ tpdu.data.submit.destAddress.ton = submitData.destAddress.ton;
+ tpdu.data.submit.destAddress.npi = submitData.destAddress.npi;
+
+ if (addLen < MAX_ADDRESS_LEN) {
+ memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen);
+ tpdu.data.submit.destAddress.address[addLen] = '\0';
+ } else {
+ if (submitData.destAddress.address[0] == '+')
+ memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
+ else
+ memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN-1);
+
+ tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
+ }
+
+ MSG_DEBUG("ton [%d]", tpdu.data.submit.destAddress.ton);
+ MSG_DEBUG("npi [%d]", tpdu.data.submit.destAddress.npi);
+ MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
+
+ bool bStatusReport = false;
+
+ for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
+ if (submitData.userData[segCnt].headerCnt > 0) {
+ tpdu.data.submit.bHeaderInd = true;
+ } else {
+ tpdu.data.submit.bHeaderInd = false;
+ }
+
+ if (segCnt == 0 && submitData.segCount > 1) {
+ bStatusReport = tpdu.data.submit.bStatusReport;
+ tpdu.data.submit.bStatusReport = false;
+ } else if ((segCnt+1 == submitData.segCount) && submitData.segCount > 1) {
+ tpdu.data.submit.bStatusReport = bStatusReport;
+ }
+
+ memset(&(tpdu.data.submit.userData), 0x00, sizeof(SMS_3GPP_USERDATA_S));
+ memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_3GPP_USERDATA_S));
+
+ SMS_NETWORK_STATUS_T retStatus = SMS_NETWORK_SENDING;
+ bool bMoreMsg = false;
+ int retMoCtrlStatus = TAPI_SAT_CALL_CTRL_R_ALLOWED_NO_MOD;
+ bool bRetryByMoCtrl = false;
+ bool bSatMoCtrl = false;
+
+ for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY; ++cnt) {
+ /* Encode SMS-SUBMIT TPDU */
+ memset(buf, 0x00, sizeof(buf));
+
+ if (cnt > 0)
+ tpdu.data.submit.bRejectDup = true;
+
+ bufLen = Sms3gppTpduCodec::encodeTpdu(&tpdu, buf);
+
+ /* Make Telephony Structure */
+ TelSmsDatapackageInfo_t pkgInfo;
+
+ /* Set TPDU data */
+ memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+ memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+ pkgInfo.szData[bufLen] = 0;
+ pkgInfo.MsgLength = bufLen;
+ pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
+
+ /* Set SMSC data */
+ memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+ memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+ pkgInfo.Sca[smscLen] = '\0';
+
+ char pkgInfoTmp[(pkgInfo.MsgLength*2)+1];
+ memset(pkgInfoTmp, 0x00, sizeof(pkgInfoTmp));
+ for (int j = 0; j < pkgInfo.MsgLength; j++) {
+ snprintf(pkgInfoTmp+(j*2), sizeof(pkgInfoTmp)-(j*2), "%02X", pkgInfo.szData[j]);
+ }
+ MSG_INFO("Submit Request TPDU. try cnt : %d", cnt+1);
+ MSG_INFO("[%s]", pkgInfoTmp);
+
+ SMS_3GPP_SENT_INFO_S sentInfo;
+ memset(&sentInfo, 0x00, sizeof(SMS_3GPP_SENT_INFO_S));
+
+ bMoreMsg = FALSE;
+
+ memcpy(&(sentInfo.reqInfo), pReqInfo, sizeof(SMS_3GPP_REQUEST_INFO_S));
+
+ if ((segCnt + 1) == submitData.segCount && (i + 1) == pReqInfo->msgInfo.nAddressCnt) {
+ sentInfo.bLast = true;
+ bMoreMsg = FALSE;
+ } else {
+ sentInfo.bLast = false;
+ bMoreMsg = TRUE;
+ }
+
+ Sms3gppEventHandler::instance()->SetSentInfo(&sentInfo);
+
+ int svc_type;
+ tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+
+ if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
+ MSG_DEBUG("Network service is not available : [%d]", svc_type);
+ Sms3gppEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
+ MsgInsertTicker("Network not available. Message will be sent when connected to network.", SMS_MESSAGE_SENDING_PENDING, false, 0);
+ goto _RETURN_FUNC;
+ }
+
+ curStatus = SMS_NETWORK_SENDING;
+
+ /* Send SMS */
+ int tapiRet = TAPI_API_SUCCESS;
+ tapiRet = tel_send_sms(handle, &pkgInfo, bMoreMsg, Sms3gppTapiEventHandler::respSentStatus, (void *)&curMoCtrlData);
+
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_send_sms Success !!! return : [%d] #######", tapiRet);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MO_CONTROL, pReqInfo->msgInfo.sim_idx);
+ if (MsgSettingGetBool(keyName, &bSatMoCtrl) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
+
+ if (bSatMoCtrl) {
+ /* Get SAT MO SM control */
+ retMoCtrlStatus = getMoCtrlStatus();
+ MSG_DEBUG("retMoCtrlStatus = [%d]", retMoCtrlStatus);
+
+ if (retMoCtrlStatus == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
+ if (bRetryByMoCtrl == false) {
+ bRetryByMoCtrl = true;
+
+ /* Modify Address with control data */
+ memset(smsc.address, 0x00, sizeof(smsc.address));
+ memcpy(smsc.address, curMoCtrlData.rpDestAddr.string, sizeof(smsc.address)-1);
+
+ memset(smscAddr, 0x00, sizeof(smscAddr));
+ smscLen = Sms3gppParamCodec::encodeSMSC(&smsc, smscAddr);
+
+ MSG_SEC_DEBUG("SMSC address=[%s], Encoded length=[%d]", smsc.address, smscLen);
+
+ if (curMoCtrlData.tpDestAddr.stringLen < MAX_ADDRESS_LEN) {
+ memcpy(tpdu.data.submit.destAddress.address, curMoCtrlData.tpDestAddr.string, curMoCtrlData.tpDestAddr.stringLen);
+ tpdu.data.submit.destAddress.address[curMoCtrlData.tpDestAddr.stringLen] = '\0';
+ } else {
+ memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
+ tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
+ }
+ } else {
+ curMoCtrlData.moSmsCtrlResult = TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED;
+ }
+ }
+ }
+ } else {
+ Sms3gppEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+ SmsPluginStorage::instance()->setFailedIndex(dbHandle, pReqInfo->msgInfo.msgId, i);
+
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_send_sms Fail !!! return : [%d] #######", tapiRet);
+ }
+
+ /* Tizen Validation System */
+ MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s", pReqInfo->msgInfo.msgId, \
+ (msisdn == NULL)?"ME":msisdn, \
+ pReqInfo->msgInfo.addressList[i].addressVal, \
+ "Success");
+
+ MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
+
+ retStatus = getNetStatus();
+
+ if (retStatus != SMS_NETWORK_SEND_FAIL_TEMPORARY && retStatus != SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD)
+ break;
+ }
+
+#ifdef MSG_SMS_REPORT
+ if (err == MSG_SUCCESS && tmpInfo.msgInfo.msgPort.valid == false) {
+ if (pReqInfo->sendOptInfo.bDeliverReq == true) {
+ MSG_DEBUG("Update Delivery Report Status : [%d] Msg ID : [%d]", err, tmpInfo.msgInfo.msgId);
+
+ /* Adding delivery report status info. */
+ MsgStoAddDeliveryReportStatus(tmpInfo.msgInfo.msgId, (unsigned char)tmpInfo.msgInfo.referenceId);
+ }
+ }
+#endif
+
+ MSG_SMS_VLD_INFO("%d, SMS Send End, %s->%s, %s", pReqInfo->msgInfo.msgId, \
+ (msisdn == NULL)?"ME":msisdn, \
+ pReqInfo->msgInfo.addressList[0].addressVal, \
+ (retStatus == SMS_NETWORK_SEND_SUCCESS)?"Success":"Fail");
+
+ if (retStatus == SMS_NETWORK_SEND_SUCCESS) {
+ bool bTTS = false;
+
+ if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
+ MSG_DEBUG("MsgSettingGetBool is failed.");
+ }
+
+ if (bTTS) {
+ if (bMoreMsg == false) {
+ MsgInsertTicker("SMS is sent", SMS_MESSAGE_SENT, false, 0);
+ }
+ MSG_DEBUG("######## Msg Sent was Successful !!! #######");
+ }
+ } else {
+ if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT || retStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY || retStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD)
+ Sms3gppEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+ else if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
+ /* Sms3gppEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL_FDN_ENABLED); */
+ Sms3gppEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+
+ if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
+ MsgInsertTicker("Unable to send the message while Fixed dialling mode is enabled", SMS_FDN_RESTRICTED, true, 0);
+ } else {
+ MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, pReqInfo->msgInfo.msgId);
+ }
+
+ SmsPluginStorage::instance()->setFailedIndex(dbHandle, pReqInfo->msgInfo.msgId, i);
+
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+ THROW(MsgException::SMS_PLG_ERROR, "######## Msg Sent was Failed !!! return : [%d] #######", retStatus);
+ }
+
+ if (tpdu.data.submit.userData.headerCnt > 0)
+ tpdu.data.submit.userData.headerCnt--;
+ }
+ }
+
+ SmsPluginStorage::instance()->deleteFailedIndex(dbHandle, pReqInfo->msgInfo.msgId);
+
+_RETURN_FUNC :
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+ MSG_END();
+ return;
+}
+
+
+void Sms3gppTransport::sendDeliverReport(TapiHandle *handle, msg_error_t err)
+{
+ MSG_BEGIN();
+
+ SMS_3GPP_TPDU_S tpdu;
+
+ tpdu.tpduType = SMS_TPDU_DELIVER_REP;
+
+ TelSmsResponse_t response;
+
+ int tapiRet = TAPI_API_SUCCESS;
+
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (err == MSG_SUCCESS) {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+ response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+ if (isMemAvailable == false) {
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ }
+ } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+ tpdu.data.deliverRep.failCause = SMS_FC_SIM_STORAGE_FULL;
+
+ response = TAPI_NETTEXT_SIM_FULL;
+ MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
+
+#if 0
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ } else {
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ }
+#endif
+ } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+ tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED;
+ response = TAPI_NETTEXT_ME_FULL;
+ MsgInsertTicker("Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL, true, 0);
+
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ } else {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+ tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
+ /*response = TAPI_NETTEXT_PROTOCOL_ERROR;
+ For gcf test [34.2.5.3 class2 message] */
+ response = TAPI_NETTEXT_SIM_FULL;
+ }
+
+ MSG_DEBUG("err : [%d], response : [%02x]", err, response);
+
+ tpdu.data.deliverRep.bHeaderInd = false;
+ tpdu.data.deliverRep.paramInd = 0x00;
+
+ /* Encode SMS-DELIVER-REPORT TPDU */
+ int bufLen = 0;
+
+ char buf[MAX_TPDU_DATA_LEN];
+ memset(buf, 0x00, sizeof(buf));
+
+ bufLen = Sms3gppTpduCodec::encodeTpdu(&tpdu, buf);
+
+#ifdef MSG_FOR_DEBUG
+ /* print DeliverReport tpdu */
+ printf("\n\n######## DeliverReport tpdu #########\n");
+ for (int i=0; i < bufLen; i++) {
+ printf("[%02x] ", buf[i]);
+ }
+ printf("\n#################################\n\n");
+#endif
+
+ /* Make Telephony Structure */
+ TelSmsDatapackageInfo_t pkgInfo;
+
+ /* Set TPDU data */
+ memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+ memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+ pkgInfo.szData[bufLen] = 0;
+ pkgInfo.MsgLength = bufLen;
+ pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
+
+ /* Set SMSC Address */
+ SMS_3GPP_ADDRESS_S smsc;
+
+ /* Set SMSC Options */
+ setSmscOptions(simIndex, &smsc);
+
+ /* Encode SMSC Address */
+ unsigned char smscAddr[MAX_SMSC_LEN];
+ memset(smscAddr, 0x00, sizeof(smscAddr));
+
+ int smscLen = Sms3gppParamCodec::encodeSMSC(&smsc, smscAddr);
+
+ if (smscLen <= 0) return;
+
+ /* Set SMSC data */
+ memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+ memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+ pkgInfo.Sca[smscLen] = '\0';
+
+ /* Send Deliver Report */
+ tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, Sms3gppTapiEventHandler::respDeliveryReportCNF, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
+
+ MSG_END();
+}
+
+void Sms3gppTransport::sendClass0DeliverReport(TapiHandle *handle, msg_error_t err)
+{
+ MSG_BEGIN();
+
+ SMS_3GPP_TPDU_S tpdu;
+
+ tpdu.tpduType = SMS_TPDU_DELIVER_REP;
+
+ TelSmsResponse_t response;
+
+ int tapiRet = TAPI_API_SUCCESS;
+
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ if (err == MSG_SUCCESS) {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+ response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+ response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
+ response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, Sms3gppTapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ } else {
+ tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
+ tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
+ /*response = TAPI_NETTEXT_PROTOCOL_ERROR;
+ For gcf test [34.2.5.3 class2 message] */
+ response = TAPI_NETTEXT_SIM_FULL;
+ }
+
+ MSG_DEBUG("err : [%d], response : [%02x]", err, response);
+
+ tpdu.data.deliverRep.bHeaderInd = false;
+ tpdu.data.deliverRep.paramInd = 0x00;
+
+ /* Encode SMS-DELIVER-REPORT TPDU */
+ int bufLen = 0;
+
+ char buf[MAX_TPDU_DATA_LEN];
+ memset(buf, 0x00, sizeof(buf));
+
+ bufLen = Sms3gppTpduCodec::encodeTpdu(&tpdu, buf);
+
+ /* Make Telephony Structure */
+ TelSmsDatapackageInfo_t pkgInfo;
+
+ /* Set TPDU data */
+ memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+ memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+ pkgInfo.szData[bufLen] = 0;
+ pkgInfo.MsgLength = bufLen;
+ pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
+
+ /* Set SMSC Address */
+ SMS_3GPP_ADDRESS_S smsc;
+
+ /* Set SMSC Options */
+ setSmscOptions(simIndex, &smsc);
+
+ /* Encode SMSC Address */
+ unsigned char smscAddr[MAX_SMSC_LEN];
+ memset(smscAddr, 0x00, sizeof(smscAddr));
+
+ int smscLen = Sms3gppParamCodec::encodeSMSC(&smsc, smscAddr);
+
+ if (smscLen <= 0) return;
+
+ /* Set SMSC data */
+ memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
+ memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
+ pkgInfo.Sca[smscLen] = '\0';
+
+ /* Send Deliver Report */
+ tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, Sms3gppTapiEventHandler::respDeliveryReportCNF, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
+
+ MSG_END();
+}
+
+
+void Sms3gppTransport::getSmsSendOption(int simIndex, SMS_3GPP_SUBMIT_S *pSubmit)
+{
+ /* Set SMS Send Options */
+ pSubmit->bRejectDup = false;
+ pSubmit->bHeaderInd = false;
+
+ if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSubmit->bStatusReport) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ if (MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSubmit->bReplyPath) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ pSubmit->msgRef = msgRef++;
+
+ pSubmit->dcs.bCompressed = false;
+ pSubmit->dcs.msgClass = SMS_MSG_CLASS_NONE;
+ pSubmit->dcs.codingGroup = SMS_GROUP_GENERAL;
+
+ int codingScheme = 0;
+ if (MsgSettingGetInt(SMS_SEND_DCS, &codingScheme) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+ pSubmit->dcs.codingScheme = (SMS_3GPP_CODING_SCHEME_T)codingScheme;
+ MSG_DEBUG("DCS : %d", pSubmit->dcs.codingScheme);
+
+ MSG_SMSC_LIST_S smscList = {0, };
+ Sms3gppSetting::instance()->getSmscListInfo(simIndex, &smscList);
+
+ int selectIdx = smscList.selected;
+ int valPeriod = 0;
+
+ if (selectIdx < SMSC_LIST_MAX) {
+ MSG_SMS_PID_T pid = smscList.smscData[selectIdx].pid;
+ pSubmit->pid = convertPid(pid);
+
+ valPeriod = smscList.smscData[selectIdx].valPeriod;
+ } else {
+ MSG_WARN("Invalid case");
+ pSubmit->pid = SMS_PID_NORMAL;
+ valPeriod = 255;
+ }
+
+ MSG_DEBUG("PID : %d", pSubmit->pid);
+
+ pSubmit->vpf = SMS_VPF_NOT_PRESENT; /* default value */
+
+ MSG_DEBUG("valPeriod : %d", valPeriod);
+ MSG_DEBUG("vpf : %d", pSubmit->vpf);
+}
+
+
+void Sms3gppTransport::setSmsSendOption(SMS_3GPP_REQUEST_INFO_S *pReqInfo, SMS_3GPP_TPDU_S* pSmsTpdu)
+{
+ if (!pReqInfo || !pSmsTpdu) {
+ MSG_DEBUG("Input param is NULL");
+ return;
+ }
+
+ if (pReqInfo->sendOptInfo.bSetting == true) {
+ pSmsTpdu->data.submit.bStatusReport = pReqInfo->sendOptInfo.bDeliverReq;
+ pSmsTpdu->data.submit.bReplyPath = pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath;
+ }
+}
+
+
+void Sms3gppTransport::setSmsDcsOption(SMS_3GPP_REQUEST_INFO_S *pReqInfo, SMS_3GPP_TPDU_S* pSmsTpdu)
+{
+ if (!pReqInfo || !pSmsTpdu) {
+ MSG_DEBUG("Input param is NULL");
+ return;
+ }
+
+ if (pReqInfo->msgInfo.msgPort.valid == true) {
+ /* Set Coding Scheme for apps that use port number */
+ pSmsTpdu->data.submit.dcs.codingScheme = (SMS_3GPP_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
+ MSG_DEBUG("DCS is changed by application : [%d]", pSmsTpdu->data.submit.dcs.codingScheme);
+ } else {
+ /* Change coding scheme if it is set coding scheme by apps */
+ if (pSmsTpdu->data.submit.dcs.codingScheme == SMS_CHARSET_7BIT && pReqInfo->msgInfo.encodeType != MSG_ENCODE_GSM7BIT) {
+ pSmsTpdu->data.submit.dcs.codingScheme = (SMS_3GPP_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
+ MSG_DEBUG("DCS is changed by application : [%d]", pSmsTpdu->data.submit.dcs.codingScheme);
+ }
+ }
+}
+
+
+void Sms3gppTransport::setSmsReportOption(SMS_3GPP_REQUEST_INFO_S *pReqInfo, SMS_3GPP_TPDU_S* pSmsTpdu)
+{
+ if (!pReqInfo || !pSmsTpdu) {
+ MSG_DEBUG("Input param is NULL");
+ return;
+ }
+
+#ifdef MSG_SMS_REPORT
+ /* Update Msg Ref into Report Table */
+ if (pSmsTpdu->data.submit.bStatusReport == true) {
+ MSG_DEBUG("Update Msg Ref [%d] in Report Table", pSmsTpdu->data.submit.msgRef);
+
+ Sms3gppStorage::instance()->updateMsgRef(pReqInfo->msgInfo.msgId, pSmsTpdu->data.submit.msgRef);
+ }
+#endif
+
+ /* Set Message Reference */
+ if (pSmsTpdu->data.submit.bStatusReport == true) {
+ pSmsTpdu->data.submit.msgRef = (pReqInfo->msgInfo.msgId % 256);
+ }
+}
+
+
+void Sms3gppTransport::setSmscOptions(int simIndex, SMS_3GPP_ADDRESS_S *pSmsc)
+{
+ /* Set SMSC Options */
+ MSG_SMSC_LIST_S smscList = {0, };
+ Sms3gppSetting::instance()->getSmscListInfo(simIndex, &smscList);
+
+ int selectIdx = smscList.selected;
+
+ if (selectIdx < SMSC_LIST_MAX) {
+ if (smscList.smscData[selectIdx].smscAddr.address[0] != '\0') {
+ memset(pSmsc->address, 0x00, sizeof(pSmsc->address));
+ strncpy(pSmsc->address, smscList.smscData[selectIdx].smscAddr.address, MAX_ADDRESS_LEN);
+
+ MSG_SEC_DEBUG("address : %s", pSmsc->address);
+ } else {
+ memset(pSmsc->address, 0x00, MAX_ADDRESS_LEN);
+ }
+
+ pSmsc->ton = (SMS_3GPP_TON_T)smscList.smscData[selectIdx].smscAddr.ton;
+ MSG_DEBUG("ton : %d", pSmsc->ton);
+
+ pSmsc->npi = (SMS_3GPP_NPI_T)smscList.smscData[selectIdx].smscAddr.npi;
+ MSG_DEBUG("npi : %d", pSmsc->npi);
+ }
+}
+
+
+void Sms3gppTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_3GPP_SUBMIT_DATA_S *pData, SMS_3GPP_CODING_SCHEME_T *pCharType, int addrIndex)
+{
+ /* Destination Address */
+ pData->destAddress.ton = SMS_TON_UNKNOWN;
+ pData->destAddress.npi = SMS_3GPP_NPI_ISDN;
+
+ memset(pData->destAddress.address, 0x00, MAX_ADDRESS_LEN+1);
+ memcpy(pData->destAddress.address, pMsgInfo->addressList[addrIndex].addressVal, MAX_ADDRESS_LEN);
+
+ MSG_DEBUG("ton [%d]", pData->destAddress.ton);
+ MSG_DEBUG("npi [%d]", pData->destAddress.npi);
+ MSG_SEC_DEBUG("address [%s]", pData->destAddress.address);
+
+ int decodeLen = 0, bufSize = (MAX_GSM_7BIT_DATA_LEN*MAX_SEGMENT_NUM) + 1; /* SMS_CHARSET_7BIT */
+
+ unsigned char decodeData[bufSize];
+ memset(decodeData, 0x00, sizeof(decodeData));
+
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+
+ msg_encode_type_t encodeType = MSG_ENCODE_GSM7BIT;
+
+ MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
+
+ bool bAbnormal = false;
+
+ /* User Data */
+ if (pMsgInfo->bTextSms == true) {
+ if (*pCharType == SMS_CHARSET_7BIT) {
+ decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &langId, &bAbnormal);
+ } else if (*pCharType == SMS_CHARSET_8BIT) {
+ memcpy(decodeData, pMsgInfo->msgText, pMsgInfo->dataSize);
+ decodeLen = pMsgInfo->dataSize;
+ } else if (*pCharType == SMS_CHARSET_UCS2) {
+ decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize);
+ } else if (*pCharType == SMS_CHARSET_AUTO) {
+ decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, MSG_ENCODE_GSM7BIT, &encodeType);
+ *pCharType = encodeType;
+ }
+ } else {
+ int fileSize = 0;
+
+ char* pFileData = NULL;
+ unique_ptr<char*, void(*)(char**)> FileBuf(&pFileData, unique_ptr_deleter);
+
+ /* Read Message Data from File */
+ if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
+ THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
+
+ MSG_DEBUG("file size : [%d] file data : [%s]", fileSize, pFileData);
+
+ if (*pCharType == SMS_CHARSET_7BIT) {
+ decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId, &bAbnormal);
+ } else if (*pCharType == SMS_CHARSET_8BIT) {
+ memcpy(decodeData, pFileData, fileSize);
+ decodeLen = fileSize;
+ } else if (*pCharType == SMS_CHARSET_UCS2) {
+ decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pFileData, fileSize);
+ } else if (*pCharType == SMS_CHARSET_AUTO) {
+ decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pFileData, fileSize, MSG_ENCODE_GSM7BIT, &encodeType);
+ *pCharType = encodeType;
+ }
+
+ /* Delete File */
+ if (pMsgInfo->nAddressCnt == (addrIndex + 1))
+ MsgDeleteFile(pMsgInfo->msgData);
+ }
+
+ MSG_DEBUG("decode length : [%d]", decodeLen);
+ MSG_DEBUG("character type : [%d]", *pCharType);
+ MSG_DEBUG("Language Identifier : [%d]", langId);
+ MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
+
+ int addrLen = 0;
+
+ char* encodedAddr = NULL;
+ unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter);
+
+ if (strlen(pMsgInfo->replyAddress) > 0) {
+ SMS_3GPP_ADDRESS_S replyAddr = {};
+
+ replyAddr.ton = SMS_TON_NATIONAL;
+ replyAddr.npi = SMS_3GPP_NPI_ISDN;
+
+ memset(replyAddr.address, 0x00, MAX_ADDRESS_LEN+1);
+ memcpy(replyAddr.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
+
+ addrLen = Sms3gppParamCodec::encodeAddress(&replyAddr, &encodedAddr);
+
+ MSG_DEBUG("reply addr length : [%d]", addrLen);
+ }
+
+ int segSize = 0, index = 0;
+
+ segSize = getSegmentSize(*pCharType, decodeLen, pMsgInfo->msgPort.valid, langId, addrLen);
+
+ if (segSize == 0) {
+ if (decodeLen == 0) /* to handle empty message -> (pMsgInfo->msgText = NULL) */
+ pData->segCount = 1;
+ else
+ THROW(MsgException::SMS_PLG_ERROR, "DIVIDE_BY_ZERO : %d", segSize);
+ } else {
+ pData->segCount = ceil((double)decodeLen/(double)segSize);
+ }
+
+ MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount);
+
+ if (pData->segCount > MAX_SEGMENT_NUM)
+ THROW(MsgException::SMS_PLG_ERROR, "Segment Count is over maximum : %d", pData->segCount);
+
+ int headerCnt = 0;
+
+ for (unsigned int i = 0; i < pData->segCount; i++) {
+ headerCnt = 0;
+
+ if ((i + 1) == pData->segCount)
+ pData->userData[i].length = decodeLen - (i*segSize);
+ else
+ pData->userData[i].length = segSize;
+
+ memset(pData->userData[i].data, 0x00, MAX_USER_DATA_LEN+1);
+ memcpy(pData->userData[i].data, &(decodeData[index]), pData->userData[i].length);
+ pData->userData[i].data[pData->userData[i].length] = 0;
+
+ MSG_DEBUG("user data len [%d]", pData->userData[i].length);
+ MSG_DEBUG("user data [%s]", pData->userData[i].data);
+
+ index += segSize;
+
+ /* Set User Data Header for Concatenated Message */
+ if (pData->segCount > 1) {
+ pData->userData[i].header[headerCnt].udhType = SMS_UDH_CONCAT_8BIT;
+ pData->userData[i].header[headerCnt].udh.concat8bit.msgRef = msgRef8bit;
+ pData->userData[i].header[headerCnt].udh.concat8bit.totalSeg = pData->segCount;
+ pData->userData[i].header[headerCnt].udh.concat8bit.seqNum = i + 1;
+
+ headerCnt++;
+ }
+
+ /* Set User Data Header Port Information */
+ if (pMsgInfo->msgPort.valid == true) {
+ pData->userData[i].header[headerCnt].udhType = SMS_UDH_APP_PORT_16BIT;
+ pData->userData[i].header[headerCnt].udh.appPort16bit.destPort = pMsgInfo->msgPort.dstPort;
+ pData->userData[i].header[headerCnt].udh.appPort16bit.originPort = pMsgInfo->msgPort.srcPort;
+
+ headerCnt++;
+ }
+
+ /* Set User Data Header for Alternate Reply Address */
+ if (strlen(pMsgInfo->replyAddress) > 0) {
+ pData->userData[i].header[headerCnt].udhType = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
+
+ pData->userData[i].header[headerCnt].udh.alternateAddress.ton = SMS_TON_NATIONAL;
+ pData->userData[i].header[headerCnt].udh.alternateAddress.npi = SMS_3GPP_NPI_ISDN;
+
+ memset(pData->userData[i].header[headerCnt].udh.alternateAddress.address, 0x00, MAX_ADDRESS_LEN+1);
+ memcpy(pData->userData[i].header[headerCnt].udh.alternateAddress.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
+
+ headerCnt++;
+ }
+
+ /* Set User Data Header for National Language Single Shift */
+ if (*pCharType == SMS_CHARSET_7BIT && langId != MSG_LANG_ID_RESERVED) {
+ pData->userData[i].header[headerCnt].udhType = SMS_UDH_SINGLE_SHIFT;
+ pData->userData[i].header[headerCnt].udh.singleShift.langId = langId;
+
+ headerCnt++;
+ }
+
+ pData->userData[i].headerCnt = headerCnt;
+ }
+
+ msgRef8bit++;
+}
+
+
+int Sms3gppTransport::getSegmentSize(SMS_3GPP_CODING_SCHEME_T CodingScheme, int DataLen, bool bPortNum, MSG_LANGUAGE_ID_T LangId, int ReplyAddrLen)
+{
+ int headerLen = 1, concat = 5, port = 6, lang = 3, reply = 2;
+ int headerSize = 0, segSize = 0, maxSize = 0;
+
+ if (CodingScheme == SMS_CHARSET_7BIT) {
+ MSG_DEBUG("SMS_CHARSET_7BIT");
+ maxSize = MAX_GSM_7BIT_DATA_LEN;
+ } else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2) {
+ MSG_DEBUG("SMS_CHARSET_8BIT or SMS_CHARSET_UCS2 [%d]", CodingScheme);
+ maxSize = MAX_UCS2_DATA_LEN;
+ }
+
+ if (bPortNum == true) {
+ MSG_DEBUG("Port Number Exists");
+ headerSize += port;
+ }
+
+ if (LangId != MSG_LANG_ID_RESERVED) {
+ MSG_DEBUG("National Language Exists");
+ headerSize += lang;
+ }
+
+ if (ReplyAddrLen > 0) {
+ MSG_DEBUG("Reply Address Exists");
+ headerSize += reply;
+ headerSize += ReplyAddrLen;
+ }
+
+ if (CodingScheme == SMS_CHARSET_7BIT) {
+ if ((DataLen+headerSize) > maxSize)
+ segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
+ else
+ segSize = DataLen;
+ } else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2) {
+ if ((DataLen+headerSize) > maxSize)
+ segSize = 140 - (headerLen + concat + headerSize);
+ else
+ segSize = DataLen;
+ }
+
+ return segSize;
+}
+
+
+void Sms3gppTransport::setConcatHeader(SMS_3GPP_UDH_S *pSrcHeader, SMS_3GPP_UDH_S *pDstHeader)
+{
+ pDstHeader->udhType = pSrcHeader->udhType;
+
+ switch (pDstHeader->udhType) {
+ case SMS_UDH_CONCAT_8BIT: {
+ pDstHeader->udh.concat8bit.msgRef = pSrcHeader->udh.concat8bit.msgRef;
+ pDstHeader->udh.concat8bit.totalSeg = pSrcHeader->udh.concat8bit.totalSeg;
+ pDstHeader->udh.concat8bit.seqNum = pSrcHeader->udh.concat8bit.seqNum;
+ }
+ break;
+
+ case SMS_UDH_CONCAT_16BIT: {
+ pDstHeader->udh.concat16bit.msgRef = pSrcHeader->udh.concat16bit.msgRef;
+ pDstHeader->udh.concat16bit.totalSeg = pSrcHeader->udh.concat16bit.totalSeg;
+ pDstHeader->udh.concat16bit.seqNum = pSrcHeader->udh.concat16bit.seqNum;
+ }
+ break;
+ }
+}
+
+
+void Sms3gppTransport::setNetStatus(SMS_NETWORK_STATUS_T sentStatus)
+{
+ mx.lock();
+ curStatus = sentStatus;
+ cv.signal();
+ mx.unlock();
+}
+
+
+SMS_NETWORK_STATUS_T Sms3gppTransport::getNetStatus()
+{
+ mx.lock();
+
+ int ret = 0;
+
+ if (curStatus == SMS_NETWORK_SENDING)
+ ret = cv.timedwait(mx.pMsgMutex(), 125);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
+ curStatus = SMS_NETWORK_SEND_FAIL_TIMEOUT;
+ }
+
+ return curStatus;
+}
+
+
+void Sms3gppTransport::setMoCtrlStatus(TelSatMoSmCtrlIndData_t *moCtrlData)
+{
+ mx.lock();
+
+ if (moCtrlData) {
+ memset(&curMoCtrlData, 0x00, sizeof(TelSatMoSmCtrlIndData_t));
+ memcpy(&curMoCtrlData, moCtrlData, sizeof(TelSatMoSmCtrlIndData_t));
+ MSG_DEBUG("MO Control Data is set by Tapi Event Noti");
+ }
+
+ cv.signal();
+ mx.unlock();
+}
+
+
+int Sms3gppTransport::getMoCtrlStatus()
+{
+ mx.lock();
+
+ int ret = 0;
+
+ ret = cv.timedwait(mx.pMsgMutex(), 10);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
+ return -1;
+ }
+
+ return (curMoCtrlData.moSmsCtrlResult);
+}
+
+
+unsigned char Sms3gppTransport::getMsgRef()
+{
+ return msgRef++;
+}
+
+
+void Sms3gppTransport::setIsMemAvailable(bool isAvailable)
+{
+ isMemAvailable = isAvailable;
+}
+
+
+SMS_3GPP_PID_T Sms3gppTransport::convertPid(MSG_SMS_PID_T pid)
+{
+ SMS_3GPP_PID_T retPid;
+
+ switch (pid) {
+ case MSG_PID_TEXT :
+ retPid = SMS_PID_NORMAL;
+ break;
+ case MSG_PID_VOICE :
+ retPid = SMS_PID_VOICE;
+ break;
+ case MSG_PID_FAX :
+ retPid = SMS_PID_TELEX;
+ break;
+ case MSG_PID_X400 :
+ retPid = SMS_PID_x400;
+ break;
+ case MSG_PID_ERMES :
+ retPid = SMS_PID_ERMES;
+ break;
+ case MSG_PID_EMAIL :
+ retPid = SMS_PID_EMAIL;
+ break;
+ default :
+ retPid = SMS_PID_NORMAL;
+ break;
+ }
+
+ return retPid;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppWapPushHandler.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppUAManager.h"
+#include "Sms3gppConcatHandler.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppUAManager - Member Functions
+==================================================================================================*/
+Sms3gppUAManager* Sms3gppUAManager::pInstance = NULL;
+
+
+Sms3gppUAManager::Sms3gppUAManager() : mx(), cv()
+{
+ start();
+}
+
+
+Sms3gppUAManager::~Sms3gppUAManager()
+{
+}
+
+
+Sms3gppUAManager* Sms3gppUAManager::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gppUAManager();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gppUAManager::run()
+{
+ while (1) {
+ lock();
+ while (smsTranQ.empty()) {
+ wait();
+ }
+ SMS_3GPP_REQUEST_INFO_S request;
+ smsTranQ.front(&request);
+ unlock();
+
+ request.msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter);
+
+ try {
+ Sms3gppTransport::instance()->submitRequest(&request);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+
+ lock();
+ smsTranQ.pop_front();
+ unlock();
+ continue;
+ } catch (exception& e) {
+ MSG_FATAL("%s", e.what());
+ lock();
+ smsTranQ.pop_front();
+ unlock();
+ continue;
+ }
+
+ lock();
+ smsTranQ.pop_front();
+ unlock();
+ }
+}
+
+
+void Sms3gppUAManager::addReqEntity(SMS_3GPP_REQUEST_INFO_S *request)
+{
+ SMS_3GPP_REQUEST_INFO_S reqTmp = {0, };
+
+ memcpy(&reqTmp, request, sizeof(SMS_3GPP_REQUEST_INFO_S));
+
+ lock();
+
+ smsTranQ.push_back(reqTmp);
+ cv.signal();
+
+ unlock();
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "Sms3gppParamCodec.h"
+#include "Sms3gppUDCodec.h"
+
+using namespace std;
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppUDCodec - Member Functions
+==================================================================================================*/
+Sms3gppUDCodec::Sms3gppUDCodec()
+{
+}
+
+
+Sms3gppUDCodec::~Sms3gppUDCodec()
+{
+}
+
+
+int Sms3gppUDCodec::encodeUserData(const SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_CODING_SCHEME_T CodingScheme, char *pEncodeData)
+{
+ int encodeSize = 0;
+
+ switch (CodingScheme) {
+ case SMS_CHARSET_7BIT:
+ encodeSize = encodeGSMData(pUserData, pEncodeData);
+ break;
+ case SMS_CHARSET_8BIT:
+ encodeSize = encode8bitData(pUserData, pEncodeData);
+ break;
+ case SMS_CHARSET_UCS2:
+ encodeSize = encodeUCS2Data(pUserData, pEncodeData);
+ break;
+ }
+
+ return encodeSize;
+}
+
+
+int Sms3gppUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_CODING_SCHEME_T CodingScheme, SMS_3GPP_USERDATA_S *pUserData)
+{
+ int decodeSize = 0;
+
+ memset(pUserData, 0x00, sizeof(SMS_3GPP_USERDATA_S));
+
+ switch (CodingScheme) {
+ case SMS_CHARSET_7BIT:
+ decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
+ break;
+ case SMS_CHARSET_8BIT:
+ decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, NULL);
+ break;
+ case SMS_CHARSET_UCS2:
+ decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
+ break;
+ }
+
+ return decodeSize;
+}
+
+
+int Sms3gppUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_CODING_SCHEME_T CodingScheme, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD)
+{
+ int decodeSize = 0;
+
+ memset(pUserData, 0x00, sizeof(SMS_3GPP_USERDATA_S));
+
+ switch (CodingScheme) {
+ case SMS_CHARSET_7BIT:
+ decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+ break;
+ case SMS_CHARSET_8BIT:
+ decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, pTPUD);
+ break;
+ case SMS_CHARSET_UCS2:
+ decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+ break;
+ case SMS_CHARSET_EUCKR:
+ decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
+ break;
+ }
+
+ return decodeSize;
+}
+
+
+int Sms3gppUDCodec::encodeGSMData(const SMS_3GPP_USERDATA_S *pUserData, char *pEncodeData)
+{
+ int headerLen = 0, offset = 0, fillBits = 0, packSize = 0, encodeLen = 0;
+ unsigned char udhl = 0x00;
+
+ if (pUserData->headerCnt > 0)
+ offset = 2;
+ else
+ offset = 1;
+
+ MSG_DEBUG("pUserData->headerCnt [%d]", pUserData->headerCnt);
+
+ /* Encode User Data Header */
+ for (int i = 0; i < pUserData->headerCnt; i++) {
+ headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
+
+ MSG_DEBUG("headerLen [%d]", headerLen);
+
+ udhl += headerLen;
+ offset += headerLen;
+ }
+
+ MSG_DEBUG("udhl [%d]", udhl);
+
+ if (udhl > 0)
+ fillBits = ((udhl+1)*8)%7; /* + UDHL */
+
+ if (fillBits > 0)
+ fillBits = 7 - fillBits;
+
+ MSG_DEBUG("fillBits [%d]", fillBits);
+ MSG_DEBUG("dataLen [%d]", pUserData->length);
+
+ /* Set UDL, UDHL */
+ if (udhl > 0) {
+ pEncodeData[0] = (((udhl+1)*8) + fillBits + (pUserData->length*7)) / 7;
+ pEncodeData[1] = udhl;
+ } else {
+ pEncodeData[0] = (char)pUserData->length;
+ }
+
+ packSize = pack7bitChar((unsigned char*)pUserData->data, pUserData->length, fillBits, &(pEncodeData[offset]));
+
+ encodeLen = offset + packSize;
+
+ MSG_DEBUG("packSize [%d]", packSize);
+ MSG_DEBUG("encodeLen [%d]", encodeLen);
+
+#if 0
+printf("\n\n[encodeGSMData] userData data.\n");
+for (int j = 0; j < encodeLen; j++)
+{
+ printf(" [%02x]", pEncodeData[j]);
+}
+printf("\n\n");
+#endif
+
+ return encodeLen;
+}
+
+
+int Sms3gppUDCodec::encode8bitData(const SMS_3GPP_USERDATA_S *pUserData, char *pEncodeData)
+{
+ int headerLen = 0, offset = 2, fillBits = 0, encodeLen = 0;
+ unsigned char udhl = 0x00;
+
+ if (pUserData->headerCnt > 0)
+ offset = 2;
+ else
+ offset = 1;
+
+ /* Encode User Data Header */
+ for (int i = 0; i < pUserData->headerCnt; i++) {
+ headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
+
+ udhl += headerLen;
+ offset += headerLen;
+ }
+
+ MSG_DEBUG("fillBits [%d]", fillBits);
+ MSG_DEBUG("dataLen [%d]", pUserData->length);
+
+ /* Set UDL, UDHL */
+ if (udhl > 0) {
+ pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
+ pEncodeData[1] = udhl;
+ } else {
+ pEncodeData[0] = (char)pUserData->length;
+ }
+
+ memcpy(&(pEncodeData[offset]), pUserData->data, pUserData->length);
+
+ encodeLen = offset + pUserData->length;
+
+ return encodeLen;
+}
+
+
+int Sms3gppUDCodec::encodeUCS2Data(const SMS_3GPP_USERDATA_S *pUserData, char *pEncodeData)
+{
+ int headerLen = 0, offset = 2, fillBits = 0, encodeLen = 0;
+ unsigned char udhl = 0x00;
+
+ if (pUserData->headerCnt > 0)
+ offset = 2;
+ else
+ offset = 1;
+
+ /* Encode User Data Header */
+ for (int i = 0; i < pUserData->headerCnt; i++) {
+ headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
+
+ udhl += headerLen;
+ offset += headerLen;
+ }
+
+ MSG_DEBUG("fillBits [%d]", fillBits);
+ MSG_DEBUG("dataLen [%d]", pUserData->length);
+
+ /* Set UDL, UDHL */
+ if (udhl > 0) {
+ pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
+ pEncodeData[1] = udhl;
+ } else {
+ pEncodeData[0] = (char)pUserData->length;
+ }
+
+ memcpy(&(pEncodeData[offset]), pUserData->data, pUserData->length);
+
+ encodeLen = offset + pUserData->length;
+
+#if 0
+printf("\n\n[encodeUCS2Data] userData data.\n");
+for (int j = 0; j < encodeLen; j++)
+{
+ printf(" [%02x]", pEncodeData[j]);
+}
+printf("\n\n");
+#endif
+
+ return encodeLen;
+}
+
+
+int Sms3gppUDCodec::decodeGSMData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD)
+{
+ int offset = 0, udl = 0, udhl = 0, headerLen = 0, fillBits = 0, octetUdl = 0;
+
+ /* UDL */
+ udl = pTpdu[offset++];
+ octetUdl = (udl*7)/8;
+
+ MSG_DEBUG("udl = %d, tpdulen = %d, octetUdl = %d.", udl, tpduLen, octetUdl);
+ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+
+ if (udl > MAX_GSM_7BIT_DATA_LEN || octetUdl > tpduLen) {
+ pUserData->length = 0;
+ pUserData->headerCnt = 0;
+ return 0;
+ }
+
+ /* Setting for Wap Push */
+ if (pTPUD != NULL) {
+ pTPUD->udl = udl;
+
+ memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
+ pTPUD->ud[udl] = '\0';
+ }
+
+ /* Decode User Data Header */
+ if (bHeaderInd == true) {
+ /* UDHL */
+ udhl = pTpdu[offset++];
+
+ MSG_DEBUG("udhl = %d", udhl);
+
+ pUserData->headerCnt = 0;
+
+ for (int i = 0; offset < udhl; i++) {
+ headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
+
+ if (headerLen <= 0) {
+ MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
+
+ pUserData->length = 0;
+ memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+ return 0;
+ }
+
+ offset += headerLen;
+
+ if (offset > (udhl+2)) {
+ MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
+
+ pUserData->length = 0;
+ memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+ return 0;
+ }
+
+ pUserData->headerCnt++;
+ }
+ } else {
+ pUserData->headerCnt = 0;
+ }
+
+ MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
+
+ if (udhl > 0) {
+ fillBits = ((udl*7) - ((udhl+1)*8)) % 7;
+ udl = ((udl*7) - ((udhl+1)*8)) / 7;
+ }
+
+ MSG_DEBUG("fillBits = %d", fillBits);
+ MSG_DEBUG("udhl = %d", udhl);
+ MSG_DEBUG("udl = %d", udl);
+
+ MSG_DEBUG("offset = %d", offset);
+
+ pUserData->length = unpack7bitChar(&(pTpdu[offset]), udl, fillBits, pUserData->data);
+
+ return pUserData->length;
+}
+
+
+int Sms3gppUDCodec::decode8bitData(const unsigned char *pTpdu, bool bHeaderInd, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD)
+{
+ int offset = 0, udl = 0, udhl = 0, headerLen = 0;
+
+ /* UDL */
+ udl = pTpdu[offset++];
+
+ if (udl > MAX_UCS2_DATA_LEN) {
+ pUserData->length = 0;
+ return 0;
+ }
+
+ /* Setting for Wap Push */
+ if (pTPUD != NULL) {
+ pTPUD->udl = udl;
+
+ memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
+ pTPUD->ud[udl] = '\0';
+ }
+
+ MSG_DEBUG("udl = %d", udl);
+ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+
+ /* Decode User Data Header */
+ if (bHeaderInd == true) {
+ /* UDHL */
+ udhl = pTpdu[offset++];
+
+ MSG_DEBUG("udhl = %d", udhl);
+
+ pUserData->headerCnt = 0;
+
+ for (int i = 0; offset < udhl; i++) {
+ headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
+
+ if (headerLen <= 0) {
+ MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
+
+ pUserData->length = 0;
+ memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+ return 0;
+ }
+
+ offset += headerLen;
+
+ if (offset > (udhl+2)) {
+ MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
+
+ pUserData->length = 0;
+ memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+ return 0;
+ }
+
+ pUserData->headerCnt++;
+ }
+ } else {
+ pUserData->headerCnt = 0;
+ }
+
+ MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
+
+ if (udhl > 0)
+ pUserData->length = (udl) - (udhl+1);
+ else
+ pUserData->length = udl;
+
+ MSG_DEBUG("pUserData->length = %d", pUserData->length);
+ MSG_DEBUG("offset = %d", offset);
+
+ memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
+
+ return pUserData->length;
+}
+
+
+int Sms3gppUDCodec::decodeUCS2Data(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD)
+{
+ int offset = 0, udl = 0, udhl = 0, headerLen = 0;
+
+ /* UDL */
+ udl = pTpdu[offset++];
+
+ MSG_DEBUG("udl = %d, tpdulen = %d.", udl, tpduLen);
+ MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
+
+ if (udl > MAX_UCS2_DATA_LEN || udl > tpduLen) {
+ pUserData->length = 0;
+ pUserData->headerCnt = 0;
+ return 0;
+ }
+
+ /* Setting for Wap Push */
+ if (pTPUD != NULL) {
+ pTPUD->udl = udl;
+
+ memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
+ pTPUD->ud[udl] = '\0';
+ }
+
+ /* Decode User Data Header */
+ if (bHeaderInd == true) {
+ /* UDHL */
+ udhl = pTpdu[offset++];
+
+ MSG_DEBUG("udhl = %d", udhl);
+
+ pUserData->headerCnt = 0;
+
+ for (int i = 0; offset < udhl; i++) {
+ headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
+
+ if (headerLen <= 0) {
+ MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
+
+ pUserData->length = 0;
+ memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+ return 0;
+ }
+
+ offset += headerLen;
+
+ if (offset > (udhl+2)) {
+ MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
+
+ pUserData->length = 0;
+ memset(pUserData->data, 0x00, sizeof(pUserData->data));
+
+ return 0;
+ }
+
+ pUserData->headerCnt++;
+ }
+ } else {
+ pUserData->headerCnt = 0;
+ }
+
+ if (udhl > 0)
+ pUserData->length = (udl) - (udhl+1);
+ else
+ pUserData->length = udl;
+
+ MSG_DEBUG("pUserData->length = %d", pUserData->length);
+ MSG_DEBUG("offset = %d", offset);
+
+ memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
+ pUserData->data[pUserData->length] = 0;
+
+ return pUserData->length;
+}
+
+
+int Sms3gppUDCodec::encodeHeader(const SMS_3GPP_UDH_S header, char *pEncodeHeader)
+{
+ int offset = 0, addrLen = 0;
+
+ char* encodedAddr = NULL;
+ unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter);
+
+ switch (header.udhType) {
+ case SMS_UDH_CONCAT_8BIT :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_CONCAT_8BIT;
+
+ /* IEDL */
+ pEncodeHeader[offset++] = 0x03;
+
+ /* Reference Number */
+ pEncodeHeader[offset++] = header.udh.concat8bit.msgRef;
+
+ /* Number of Segments */
+ pEncodeHeader[offset++] = header.udh.concat8bit.totalSeg;
+
+ /* Sequence Number */
+ pEncodeHeader[offset++] = header.udh.concat8bit.seqNum;
+
+ break;
+
+ case SMS_UDH_CONCAT_16BIT :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_CONCAT_16BIT;
+
+ /* IEDL */
+ pEncodeHeader[offset++] = 0x04;
+
+ /* Reference Number */
+ pEncodeHeader[offset++] = (char)(header.udh.concat16bit.msgRef >> 8);
+ pEncodeHeader[offset++] = header.udh.concat16bit.msgRef & 0x00FF;
+
+ /* Number of Segments */
+ pEncodeHeader[offset++] = header.udh.concat16bit.totalSeg;
+
+ /* Sequence Number */
+ pEncodeHeader[offset++] = header.udh.concat16bit.seqNum;
+
+ break;
+
+ case SMS_UDH_APP_PORT_8BIT :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_APP_PORT_8BIT;
+
+ /* IEDL */
+ pEncodeHeader[offset++] = 0x02;
+
+ /* Dest Port */
+ pEncodeHeader[offset++] = header.udh.appPort8bit.destPort;
+
+ /* Origin Port */
+ pEncodeHeader[offset++] = header.udh.appPort8bit.originPort;
+
+ break;
+
+ case SMS_UDH_APP_PORT_16BIT :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_APP_PORT_16BIT;
+
+ /* IEDL */
+ pEncodeHeader[offset++] = 0x04;
+
+ /* Dest Port */
+ pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.destPort >> 8);
+ pEncodeHeader[offset++] = header.udh.appPort16bit.destPort & 0x00FF;
+
+ /* Origin Port */
+ pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.originPort >> 8);
+ pEncodeHeader[offset++] = header.udh.appPort16bit.originPort & 0x00FF;
+
+ break;
+
+ case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
+
+ addrLen = Sms3gppParamCodec::encodeAddress(&(header.udh.alternateAddress), &encodedAddr);
+
+ /* IEDL */
+ pEncodeHeader[offset++] = addrLen;
+
+ /* Alternate Reply Address */
+ memcpy(&pEncodeHeader[offset], encodedAddr, addrLen);
+
+ offset += addrLen;
+
+ break;
+
+ case SMS_UDH_SINGLE_SHIFT :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_SINGLE_SHIFT;
+
+ /* IEDL */
+ pEncodeHeader[offset++] = 0x01;
+
+ /* National Language Identifier */
+ pEncodeHeader[offset++] = header.udh.singleShift.langId;
+
+ break;
+
+ case SMS_UDH_LOCKING_SHIFT :
+ /* IEI */
+ pEncodeHeader[offset++] = SMS_UDH_LOCKING_SHIFT;
+
+ /* IEDL */
+ pEncodeHeader[offset++] = 0x01;
+
+ /* National Language Identifier */
+ pEncodeHeader[offset++] = header.udh.lockingShift.langId;
+
+ break;
+
+ case SMS_UDH_NONE :
+ default :
+ break;
+ }
+
+ return offset;
+}
+
+
+int Sms3gppUDCodec::decodeHeader(const unsigned char *pTpdu, SMS_3GPP_UDH_S *pHeader)
+{
+ int offset = 0;
+ unsigned char IEDL = 0;
+
+ pHeader->udhType = pTpdu[offset++];
+
+ switch (pHeader->udhType) {
+ case SMS_UDH_CONCAT_8BIT: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ pHeader->udh.concat8bit.msgRef = pTpdu[offset++];
+ pHeader->udh.concat8bit.totalSeg = pTpdu[offset++];
+ pHeader->udh.concat8bit.seqNum = pTpdu[offset++];
+
+ MSG_DEBUG("concat8bit.msgRef [%02x]", pHeader->udh.concat8bit.msgRef);
+ MSG_DEBUG("concat8bit.totalSeg [%02x]", pHeader->udh.concat8bit.totalSeg);
+ MSG_DEBUG("concat8bit.seqNum [%02x]", pHeader->udh.concat8bit.seqNum);
+ }
+ break;
+
+ case SMS_UDH_CONCAT_16BIT: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ pHeader->udh.concat16bit.msgRef = pTpdu[offset++];
+ pHeader->udh.concat16bit.msgRef = (unsigned short)((pHeader->udh.concat16bit.msgRef << 8) | pTpdu[offset++]);
+ pHeader->udh.concat16bit.totalSeg = pTpdu[offset++];
+ pHeader->udh.concat16bit.seqNum = pTpdu[offset++];
+
+ MSG_DEBUG("concat16bit.msgRef [%04x]", pHeader->udh.concat16bit.msgRef);
+ MSG_DEBUG("concat16bit.totalSeg [%02x]", pHeader->udh.concat16bit.totalSeg);
+ MSG_DEBUG("concat16bit.seqNum [%02x]", pHeader->udh.concat16bit.seqNum);
+ }
+ break;
+
+ case SMS_UDH_APP_PORT_8BIT: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ pHeader->udh.appPort8bit.destPort = pTpdu[offset++];
+ pHeader->udh.appPort8bit.originPort = pTpdu[offset++];
+
+ MSG_DEBUG("appPort8bit.destPort [%02x]", pHeader->udh.appPort8bit.destPort);
+ MSG_DEBUG("appPort8bit.originPort [%02x]", pHeader->udh.appPort8bit.originPort);
+ }
+ break;
+
+ case SMS_UDH_APP_PORT_16BIT: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ pHeader->udh.appPort16bit.destPort = pTpdu[offset++];
+ pHeader->udh.appPort16bit.destPort = (unsigned short)((pHeader->udh.appPort16bit.destPort << 8) | pTpdu[offset++]);
+ pHeader->udh.appPort16bit.originPort = pTpdu[offset++];
+ pHeader->udh.appPort16bit.originPort = (unsigned short)((pHeader->udh.appPort16bit.originPort << 8) | pTpdu[offset++]);
+
+ MSG_DEBUG("appPort16bit.destPort [%04x]", pHeader->udh.appPort16bit.destPort);
+ MSG_DEBUG("appPort16bit.originPort [%04x]", pHeader->udh.appPort16bit.originPort);
+ }
+ break;
+
+ case SMS_UDH_SPECIAL_SMS: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL != 2)
+ return 0;
+
+ MSG_DEBUG("Decoding special sms udh.");
+
+ pHeader->udh.specialInd.bStore = (bool) (pTpdu[offset] & 0x80);
+ pHeader->udh.specialInd.msgInd = (unsigned short) (pTpdu[offset++] & 0x7F);
+ pHeader->udh.specialInd.waitMsgNum = (unsigned short) pTpdu[offset];
+ }
+ break;
+
+ case SMS_UDH_ALTERNATE_REPLY_ADDRESS: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ offset += Sms3gppParamCodec::decodeAddress(&pTpdu[offset], &(pHeader->udh.alternateAddress));
+
+ MSG_SEC_DEBUG("alternate reply address [%s]", pHeader->udh.alternateAddress.address);
+ }
+ break;
+
+ case SMS_UDH_SINGLE_SHIFT: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ pHeader->udh.singleShift.langId = pTpdu[offset++];
+
+ MSG_DEBUG("singleShift.langId [%02x]", pHeader->udh.singleShift.langId);
+ }
+ break;
+
+ case SMS_UDH_LOCKING_SHIFT: {
+ IEDL = pTpdu[offset++];
+
+ if (IEDL == 0)
+ return 0;
+
+ pHeader->udh.lockingShift.langId = pTpdu[offset++];
+
+ MSG_DEBUG("lockingShift.langId [%02x]", pHeader->udh.lockingShift.langId);
+ }
+ break;
+
+ default: {
+ MSG_DEBUG("Not Supported Header Type [%02x]", pHeader->udhType);
+
+ IEDL = pTpdu[offset++];
+
+ MSG_DEBUG("IEDL [%d]", IEDL);
+ return (offset + IEDL);
+ }
+ break;
+ }
+
+ return offset;
+}
+
+
+int Sms3gppUDCodec::pack7bitChar(const unsigned char *pUserData, int dataLen, int fillBits, char *pPackData)
+{
+ int srcIdx = 0, dstIdx = 0, shift = fillBits;
+
+ if (shift > 0)
+ dstIdx = 1;
+
+ while (srcIdx < dataLen) {
+ if (shift == 0) {
+ pPackData[dstIdx] = pUserData[srcIdx];
+
+ shift = 7;
+ srcIdx++;
+ dstIdx++;
+
+ if (srcIdx >= dataLen)
+ break;
+ }
+
+ if (shift > 1) {
+ pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
+ pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
+ shift--;
+
+ srcIdx++;
+ dstIdx++;
+ } else if (shift == 1) {
+ pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
+
+ srcIdx++;
+
+ shift--;
+ }
+ }
+
+ return dstIdx;
+}
+
+
+int Sms3gppUDCodec::unpack7bitChar(const unsigned char *pTpdu, unsigned char dataLen, int fillBits, char *pUnpackData)
+{
+ int srcIdx = 0, dstIdx = 0, shift = fillBits;
+
+MSG_DEBUG("dataLen = %d", dataLen);
+
+ if (shift > 0)
+ srcIdx = 1;
+
+ for (; dstIdx < dataLen; dstIdx++) {
+ if (shift == 0) {
+ pUnpackData[dstIdx] = pTpdu[srcIdx] & 0x7F;
+
+ shift = 7;
+ srcIdx++;
+ dstIdx++;
+
+ if (dstIdx >= dataLen)
+ break;
+ }
+
+ if (shift > 0) {
+ pUnpackData[dstIdx] = (pTpdu[srcIdx-1] >> shift) + (pTpdu[srcIdx] << (8 - shift));
+
+ pUnpackData[dstIdx] &= 0x7F;
+
+ shift--;
+
+ if (shift > 0)
+ srcIdx++;
+ }
+ }
+
+ return dstIdx;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <glib.h>
+#include <gio/gio.h>
+#if MSG_DRM_SUPPORT
+#include <drm_client.h>
+#endif
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppWapPushHandler.h"
+#include "SmsPluginStorage.h"
+
+
+static unsigned short wapPushPortList[] = { 0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F };
+
+static char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
+static char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
+
+static const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
+
+static const unsigned char wspHeaderFieldCount = 0x43;
+static const unsigned char wspContentsTypeCount = 0x34;
+static const unsigned long wspLanguageCount = 0x11a;
+static const unsigned char wspSecurityTypeCount = 0x04;
+
+
+static const SMS_3GPP_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] = {
+ { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
+ { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
+ { (char*)"application/pkcs7-mime", 0x37 },
+ { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
+ { (char*)"application/vnd.wap.signed-certificate", 0x39 },
+ { (char*)"application/vnd.wap.cert-response", 0x3A },
+ { (char*)"application/xhtml+xml", 0x3B },
+ { (char*)"application/wml+xml", 0x3C },
+ { (char*)"text/css", 0x3D },
+
+ { (char*)"application/vnd.wap.mms-message", 0x3E },
+
+ { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
+ { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
+ { (char*)"application/vnd.wap.loc+xml", 0x41 },
+ { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
+ { (char*)"application/vnd.syncml.dm+xml", 0x43 },
+ { (char*)"application/vnd.syncml.notification", 0x44 },
+ { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
+ { (char*)"application/vnd.wv.csp.cir", 0x46 },
+
+ { (char*)"application/vnd.oma.dd+xml", 0x47},
+ { (char*)"application/vnd.oma.drm.message", 0x48 },
+ { (char*)"application/vnd.oma.drm.content", 0x49 },
+ { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
+ { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
+ { (char*)"application/vnd.syncml.ds.notification", 0x4E},
+ { (char*)"application/mikey", 0x52},
+ { (char*)"", 0xff }
+};
+
+
+static const char* wspHeaderFieldName[] = {
+ (char*)"Accept", /* 0x00 */
+ (char*)"Accept-Charset",
+ (char*)"Accept-Encoding",
+ (char*)"Accept-Language",
+ (char*)"Accept-Ranges",
+ (char*)"Age", /* 0x05 */
+ (char*)"Allow",
+ (char*)"Authorization",
+ (char*)"Cache-Control",
+ (char*)"Connection",
+ (char*)"Content-Base", /* 0x0a */
+ (char*)"Content-Encoding",
+ (char*)"Content-Language",
+ (char*)"Content-Length",
+ (char*)"Content-Location",
+ (char*)"Content-MD5",
+ (char*)"Content-Range", /* 0x10 */
+ (char*)"Content-Type",
+ (char*)"Date",
+ (char*)"ETag",
+ (char*)"Expires",
+ (char*)"From", /* 0x15 */
+ (char*)"Host",
+ (char*)"If-Modified-Since",
+ (char*)"If-Match",
+ (char*)"If-None-Match",
+ (char*)"If-Range", /* 0x1a */
+ (char*)"If-Unmodified-Since",
+ (char*)"Location",
+ (char*)"Last-Modified",
+ (char*)"Max-Forwards",
+ (char*)"Pragma",
+ (char*)"Proxy-Authenticate", /* 0x20 */
+ (char*)"Proxy-Authorization",
+ (char*)"Public",
+ (char*)"Range",
+ (char*)"Referer",
+ (char*)"Retry-After", /* 0x25 */
+ (char*)"Server",
+ (char*)"Transfer-Encodig",
+ (char*)"Upgrade",
+ (char*)"User-Agent",
+ (char*)"Vary", /* 0x2a */
+ (char*)"Via",
+ (char*)"Warning",
+ (char*)"Www-Authenticate",
+ (char*)"Content-Disposition",
+ (char*)"X-Wap-Application-Id",
+ (char*)"X-Wap-Content-URI", /* 0x30 */
+ (char*)"X-Wap-Iinitiator-URI",
+ (char*)"Accept-Application", /* Back */
+ (char*)"Bearer-Indication",
+ (char*)"Push-Flag",
+ (char*)"Profile", /* 0x35 */
+ (char*)"Profile-Diff",
+ (char*)"Profile-Warning", /* end of WAP 1.2 */
+ (char*)"Expect",
+ (char*)"Te",
+ (char*)"Trailer", /* 0x3a */
+ (char*)"Accept-Charset", /* Back */
+ (char*)"Accept-Encoding", /* Back */
+ (char*)"Cache-Control", /* back */
+ (char*)"Content-Range",
+ (char*)"X-Wap-Tod",
+ (char*)"Content-ID", /* 0x40 */
+ (char*)"Set-Cookie",
+ (char*)"Cookie",
+ (char*)"Encoding-Version"
+};
+
+
+static const SMS_3GPP_WSP_CHARSET_S wspCharset[] = {
+ { (char*)"big5", 0x07ea },
+ { (char*)"iso-10646-ucs-2", 0x03e8 },
+ { (char*)"iso-8859-1", 0x04 },
+ { (char*)"iso-8859-2", 0x05 },
+ { (char*)"iso-8859-3", 0x06 },
+ { (char*)"iso-8859-4", 0x07 },
+ { (char*)"iso-8859-5", 0x08 },
+ { (char*)"iso-8859-6", 0x09 },
+ { (char*)"iso-8859-7", 0x0a },
+ { (char*)"iso-8859-8", 0x0b },
+ { (char*)"iso-8859-9", 0x0c },
+ { (char*)"shift-JIS", 0x11 },
+ { (char*)"us-ascii", 0x03 },
+ { (char*)"utf-8", 0x6a },
+ { (char*)"none", 0x26 },
+ { (char*)"", 0xffff }
+};
+
+
+static const char* wspEncodeMethod[] = {
+ (char*)"Gzip",
+ (char*)"Compress",
+ (char*)"Deflate"
+};
+
+
+static const SMS_3GPP_WSP_CONTENTS_TYPE_S wspContentsType[] = {
+ { (char*)"*/*", 0x00 },
+ { (char*)"text/*", 0x01 },
+ { (char*)"text/html", 0x02 },
+ { (char*)"text/plain", 0x03 },
+ { (char*)"text/x-hdml", 0x04 },
+ { (char*)"text/x-ttml", 0x05 },
+ { (char*)"text/x-vCalendar", 0x06 },
+ { (char*)"text/x-vCard", 0x07 },
+ { (char*)"text/vnd.wap.wml", 0x08 },
+ { (char*)"text/vnd.wap.wmlscript", 0x09 },
+ { (char*)"text/vnd.wap.wta-event", 0x0a },
+ { (char*)"multipart/*", 0x0b },
+ { (char*)"multipart/mixed", 0x0c },
+ { (char*)"multipart/form-data", 0x0d },
+ { (char*)"multipart/byteranges", 0x0e },
+ { (char*)"multipart/alternative", 0x0f },
+ { (char*)"application/*", 0x10 },
+ { (char*)"application/java-vm", 0x11 },
+ { (char*)"application/x-www-form-urlencoded", 0x12 },
+ { (char*)"application/x-hdmlc", 0x13 },
+ { (char*)"application/vnd.wap.wmlc", 0x14 },
+ { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
+ { (char*)"application/vnd.wap.wta-eventc", 0x16 },
+ { (char*)"application/vnd.wap.uaprof", 0x17 },
+ { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
+ { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
+ { (char*)"application/x-x509-ca-cert", 0x1a },
+ { (char*)"application/x-x509-user-cert", 0x1b },
+ { (char*)"image/*", 0x1c },
+ { (char*)"image/gif", 0x1d },
+ { (char*)"image/jpeg", 0x1e },
+ { (char*)"image/tiff", 0x1f },
+ { (char*)"image/png", 0x20 },
+ { (char*)"image/vnd.wap.wbmp", 0x21 },
+ { (char*)"application/vnd.wap.multipart.*", 0x22 },
+ { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
+ { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
+ { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
+ { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
+ { (char*)"application/xml", 0x27 },
+ { (char*)"text/xml", 0x28 },
+ { (char*)"application/vnd.wap.wbxml", 0x29 },
+ { (char*)"application/x-x968-cross-cert", 0x2a },
+ { (char*)"application/x-x968-ca-cert", 0x2b },
+ { (char*)"application/x-x968-user-cert", 0x2c },
+ { (char*)"text/vnd.wap.si", 0x2d },
+ { (char*)"application/vnd.wap.sic", 0x2e },
+ { (char*)"text/vnd.wap.sl", 0x2f },
+ { (char*)"application/vnd.wap.slc", 0x30 },
+ { (char*)"text/vnd.wap.co", 0x31 },
+ { (char*)"application/vnd.wap.coc", 0x32 },
+ { (char*)"application/vnd.wap.multipart.related", 0x33 },
+ { (char*)"application/vnd.wap.sia", 0x34 },
+
+ { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
+ { (char*)"application/vnd.connectivity-wbxml", 0x36 },
+ { (char*)"application/pkcs7-mime", 0x37 },
+ { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
+ { (char*)"application/vnd.wap.signed-certificate", 0x39 },
+ { (char*)"application/vnd.wap.cert-response", 0x3A },
+ { (char*)"application/xhtml+xml", 0x3B },
+ { (char*)"application/wml+xml", 0x3C },
+ { (char*)"text/css", 0x3D },
+
+ { (char*)"application/vnd.wap.mms-message", 0x3E },
+
+ { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
+ { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
+ { (char*)"application/vnd.wap.loc+xml", 0x41 },
+ { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
+ { (char*)"application/vnd.syncml.dm+xml", 0x43 },
+ { (char*)"application/vnd.syncml.notification", 0x44 },
+ { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
+ { (char*)"application/vnd.wv.csp.cir", 0x46 }
+};
+
+
+static const SMS_3GPP_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]= {
+ { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
+ { (char*)"application/vnd.omaloc-supl-init", 0x312},
+ { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
+};
+
+
+static const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_3GPP_WAP_UNREGISTER_CONTENTS_TYPE_S);
+
+
+static const SMS_3GPP_WSP_LANGUAGE_S wspLanguage[] = {
+ { (char*)"English", 0x19 },
+ { (char*)"en", 0x19 },
+ { (char*)"Korean", 0x3d },
+ { (char*)"*", 0x00 },
+ { (char*)"Afar", 0x01 },
+ { (char*)"aa", 0x01 },
+ { (char*)"Abkhazian", 0x02 },
+ { (char*)"ab", 0x02 },
+ { (char*)"Afrikaans", 0x03 },
+ { (char*)"af", 0x03 },
+ { (char*)"Amharic", 0x04 },
+ { (char*)"am", 0x04 },
+ { (char*)"Arabic", 0x05 },
+ { (char*)"ar", 0x05 },
+ { (char*)"Assamese", 0x06 },
+ { (char*)"as", 0x06 },
+ { (char*)"Aymara", 0x07 },
+ { (char*)"ay", 0x07 },
+ { (char*)"Azerbaijani", 0x08 },
+ { (char*)"az", 0x08 },
+ { (char*)"Bashkir", 0x09 },
+ { (char*)"ba", 0x09 },
+ { (char*)"Byelorussian", 0x0a },
+ { (char*)"be", 0x0a },
+ { (char*)"Bulgarian", 0x0b },
+ { (char*)"bg", 0x0b },
+ { (char*)"Bihari", 0x0c },
+ { (char*)"bh", 0x0c },
+ { (char*)"Bislama", 0x0d },
+ { (char*)"bi", 0x0f },
+ { (char*)"Bengali", 0x0e },
+ { (char*)"Bangla", 0x0e },
+ { (char*)"bn", 0x0e },
+ { (char*)"Tibetan", 0x0f },
+ { (char*)"bo", 0x0f },
+ { (char*)"Breton", 0x10 },
+ { (char*)"br", 0x10 },
+ { (char*)"Catalan", 0x11 },
+ { (char*)"ca", 0x11 },
+ { (char*)"Corsican", 0x12 },
+ { (char*)"co", 0x12 },
+ { (char*)"Czech", 0x13 },
+ { (char*)"cs", 0x13 },
+ { (char*)"Welsh", 0x14 },
+ { (char*)"cy", 0x14 },
+ { (char*)"Denish", 0x15 },
+ { (char*)"da", 0x15 },
+ { (char*)"German", 0x16 },
+ { (char*)"de", 0x16 },
+ { (char*)"Bhutani", 0x17 },
+ { (char*)"dz", 0x17 },
+ { (char*)"Greek", 0x18 },
+ { (char*)"el", 0x18 },
+ { (char*)"Esperanto", 0x81 },
+ { (char*)"eo", 0x1a },
+ { (char*)"Spanish", 0x1b },
+ { (char*)"es", 0x1b },
+ { (char*)"Estonian", 0x1c },
+ { (char*)"et", 0x1c },
+ { (char*)"Basque", 0x1d },
+ { (char*)"eu", 0x1d },
+ { (char*)"Persian", 0x1e },
+ { (char*)"fa", 0x1e },
+ { (char*)"Finnish", 0x1f },
+ { (char*)"fi", 0x1f },
+ { (char*)"Fiji", 0x20 },
+ { (char*)"fj", 0x20 },
+ { (char*)"Faeroese", 0x82 },
+ { (char*)"fo", 0x82 },
+ { (char*)"French", 0x22 },
+ { (char*)"fr", 0x22 },
+ { (char*)"Frisian", 0x83 },
+ { (char*)"fy", 0x83 },
+ { (char*)"Irish", 0x24 },
+ { (char*)"ga", 0x24 },
+ { (char*)"Scots Gaelic", 0x25 },
+ { (char*)"gd", 0x25 },
+ { (char*)"Galician", 0x26 },
+ { (char*)"gl", 0x26 },
+ { (char*)"Guarani", 0x27 },
+ { (char*)"gn", 0x27 },
+ { (char*)"Gujarati", 0x28 },
+ { (char*)"gu", 0x28 },
+ { (char*)"Hausa", 0x29 },
+ { (char*)"ha", 0x29 },
+ { (char*)"Hebrew", 0x2a },
+ { (char*)"he", 0x2a },
+ { (char*)"Hindi", 0x2b },
+ { (char*)"hi", 0x2b },
+ { (char*)"Croatian", 0x2c },
+ { (char*)"hr", 0x2c },
+ { (char*)"Hungarian", 0x2d },
+ { (char*)"hu", 0x2d },
+ { (char*)"Armenian", 0x2e },
+ { (char*)"hy", 0x2e },
+ { (char*)"Interlingua", 0x84 },
+ { (char*)"ia", 0x84 },
+ { (char*)"Indonesian", 0x30 },
+ { (char*)"id", 0x30 },
+ { (char*)"Interlingue", 0x86 },
+ { (char*)"ie", 0x86 },
+ { (char*)"Maori", 0x47 },
+ { (char*)"mi", 0x47 },
+ { (char*)"Macedonian", 0x48 },
+ { (char*)"mk", 0x48 },
+ { (char*)"Malayalam", 0x49 },
+ { (char*)"ml", 0x49 },
+ { (char*)"Mongolian", 0x4a },
+ { (char*)"mn", 0x4a },
+ { (char*)"Moldavian", 0x4b },
+ { (char*)"mo", 0x4d },
+ { (char*)"Marathi", 0x4c },
+ { (char*)"mr", 0x4c },
+ { (char*)"Malay", 0x4d },
+ { (char*)"ms", 0x4d },
+ { (char*)"Maltese", 0x4e },
+ { (char*)"mt", 0x4e },
+ { (char*)"Burmese", 0x4f },
+ { (char*)"my", 0x4f },
+ { (char*)"Nauru", 0x50 },
+ { (char*)"na", 0x50 },
+ { (char*)"Nepali", 0x51 },
+ { (char*)"ne", 0x51 },
+ { (char*)"Dutch", 0x52 },
+ { (char*)"nl", 0x52 },
+ { (char*)"Norwegian", 0x53 },
+ { (char*)"no", 0x53 },
+ { (char*)"Occitan", 0x54 },
+ { (char*)"oc", 0x54 },
+ { (char*)"(Afan) Oromo", 0x55 },
+ { (char*)"(Afan)Oromo", 0x55 },
+ { (char*)"om", 0x55 },
+ { (char*)"Oriya", 0x56 },
+ { (char*)"or", 0x56 },
+ { (char*)"Punjabi", 0x57 },
+ { (char*)"pa", 0x57 },
+ { (char*)"Polish", 0x58 },
+ { (char*)"po", 0x58 },
+ { (char*)"Pashto", 0x59 },
+ { (char*)"Pushto", 0x59 },
+ { (char*)"ps", 0x59 },
+ { (char*)"Portugurse", 0x5a },
+ { (char*)"pt", 0x5a },
+ { (char*)"Quechua", 0x5b },
+ { (char*)"qu", 0x5b },
+ { (char*)"Rhaeto-Romance", 0x8c },
+ { (char*)"rm", 0x8c },
+ { (char*)"Kirundi", 0x5d },
+ { (char*)"rn", 0x5d },
+ { (char*)"Romanian", 0x5e },
+ { (char*)"ro", 0x5e },
+ { (char*)"Russian", 0x5f },
+ { (char*)"ru", 0x5f },
+ { (char*)"Kinyarwanda", 0x60 },
+ { (char*)"rw", 0x60 },
+ { (char*)"Sanskrit", 0x61 },
+ { (char*)"sa", 0x61 },
+ { (char*)"Sindhi", 0x62 },
+ { (char*)"sd", 0x62 },
+ { (char*)"Sangho", 0x63 },
+ { (char*)"sg", 0x63 },
+ { (char*)"Serbo-Croatian", 0x64 },
+ { (char*)"sh", 0x64 },
+ { (char*)"Sinhalese", 0x65 },
+ { (char*)"si", 0x65 },
+ { (char*)"Slovak", 0x66 },
+ { (char*)"sk", 0x66 },
+ { (char*)"Slovenian", 0x67 },
+ { (char*)"sl", 0x67 },
+ { (char*)"Samoan", 0x68 },
+ { (char*)"sm", 0x68 },
+ { (char*)"Shona", 0x69 },
+ { (char*)"sn", 0x69 },
+ { (char*)"Somali", 0x6a },
+ { (char*)"so", 0x6a },
+ { (char*)"Albanian", 0x6b },
+ { (char*)"sq", 0x6b },
+ { (char*)"Serbian", 0x6c },
+ { (char*)"sr", 0x6c },
+ { (char*)"Siswati", 0x6d },
+ { (char*)"ss", 0x6d },
+ { (char*)"Sesotho", 0x6e },
+ { (char*)"st", 0x6e },
+ { (char*)"Sundanese", 0x6f },
+ { (char*)"su", 0x6f },
+ { (char*)"Swedish", 0x70 },
+ { (char*)"sv", 0x70 },
+ { (char*)"Swahili", 0x71 },
+ { (char*)"sw", 0x71 },
+ { (char*)"Tamil", 0x72 },
+ { (char*)"ta", 0x72 },
+ { (char*)"Telugu", 0x73 },
+ { (char*)"te", 0x73 },
+ { (char*)"Tajik", 0x74 },
+ { (char*)"tg", 0x74 },
+ { (char*)"Thai", 0x75 },
+ { (char*)"th", 0x75 },
+ { (char*)"Tigrinya", 0x76 },
+ { (char*)"ti", 0x76 },
+ { (char*)"Turkmen", 0x77 },
+ { (char*)"tk", 0x77 },
+ { (char*)"Inupiak", 0x87 },
+ { (char*)"ik", 0x87 },
+ { (char*)"Icelandic", 0x33 },
+ { (char*)"is", 0x33 },
+ { (char*)"Italian", 0x34 },
+ { (char*)"it", 0x34 },
+ { (char*)"Inuktitut", 0x89 },
+ { (char*)"iu", 0x89 },
+ { (char*)"Japanese", 0x36 },
+ { (char*)"ja", 0x36 },
+ { (char*)"Javanese", 0x37 },
+ { (char*)"jw", 0x37 },
+ { (char*)"Georgian", 0x38 },
+ { (char*)"ka", 0x38 },
+ { (char*)"Kazakh", 0x39 },
+ { (char*)"kk", 0x39 },
+ { (char*)"Gerrnlandic", 0x8a },
+ { (char*)"kl", 0x8a },
+ { (char*)"Cambodian", 0x3b },
+ { (char*)"km", 0x3b },
+ { (char*)"Kannada", 0x3c },
+ { (char*)"kn", 0x3c },
+ { (char*)"Kashmiri", 0x3e },
+ { (char*)"ks", 0x3e },
+ { (char*)"Kurdish", 0x3f },
+ { (char*)"ku", 0x3f },
+ { (char*)"Kirghiz", 0x40 },
+ { (char*)"ky", 0x40 },
+ { (char*)"Latin", 0x8b },
+ { (char*)"la", 0x8b },
+ { (char*)"Lingala", 0x42 },
+ { (char*)"ln", 0x42 },
+ { (char*)"Laothian", 0x43 },
+ { (char*)"lo", 0x43 },
+ { (char*)"Lithuanian", 0x44 },
+ { (char*)"lt", 0x44 },
+ { (char*)"Lavian", 0x45 },
+ { (char*)"Lettish", 0x45 },
+ { (char*)"lv", 0x45 },
+ { (char*)"Malagasy", 0x46 },
+ { (char*)"mg", 0x46 },
+ { (char*)"Tagalog", 0x78 },
+ { (char*)"tl", 0x78 },
+ { (char*)"Setswana", 0x79 },
+ { (char*)"tn", 0x79 },
+ { (char*)"Tonga", 0x7a },
+ { (char*)"to", 0x7a },
+ { (char*)"Turkish", 0x7b },
+ { (char*)"tr", 0x7b },
+ { (char*)"Tsonga", 0x7c },
+ { (char*)"ts", 0x7c },
+ { (char*)"Tatar", 0x7d },
+ { (char*)"tt", 0x7d },
+ { (char*)"Twi", 0x7e },
+ { (char*)"tw", 0x7e },
+ { (char*)"Uighur", 0x7f },
+ { (char*)"ug", 0x7f },
+ { (char*)"Ukrainian", 0x1a },
+ { (char*)"uk", 0x1a },
+ { (char*)"Urdu", 0x21 },
+ { (char*)"ur", 0x21 },
+ { (char*)"Uzbek", 0x23 },
+ { (char*)"uz", 0x23 },
+ { (char*)"Vietnamese", 0x2f },
+ { (char*)"vi", 0x2f },
+ { (char*)"Volapuk", 0x85 },
+ { (char*)"vo", 0x85 },
+ { (char*)"Wolof", 0x31 },
+ { (char*)"wo" , 0x31 },
+ { (char*)"Xhosa", 0x32 },
+ { (char*)"xh", 0x32 },
+ { (char*)"Yiddish", 0x88 },
+ { (char*)"yi", 0x88 },
+ { (char*)"Yoruba", 0x35 },
+ { (char*)"yo", 0x35 },
+ { (char*)"Zhuang", 0x3a },
+ { (char*)"z", 0x3a },
+ { (char*)"Chinese", 0x41 },
+ { (char*)"ch", 0x41 },
+ { (char*)"Zulu", 0x5c },
+ { (char*)"zu", 0x5c },
+ { (char*)"Ko", 0x3d }
+};
+
+
+static const SMS_3GPP_WSP_HEADER_PARAMETER_S wspHeaderApplId[] = {
+ { (char*)"x-wap-application:*", 0x00 },
+ { (char*)"x-wap-application:push.sia", 0x01},
+ { (char*)"x-wap-application:wml.ua", 0x02 },
+ { (char*)"x-wap-application:wta.ua", 0x03 },
+ { (char*)"x-wap-application:mms.ua", 0x04 },
+ { (char*)"x-wap-application:push.syncml", 0x05 },
+ { (char*)"x-wap-application:loc.ua", 0x06 },
+ { (char*)"x-wap-application:syncml.dm", 0x07 },
+ { (char*)"x-wap-application:drm.ua", 0x08 },
+ { (char*)"x-wap-application:emn.ua", 0x09 },
+ { (char*)"x-oma-application:ulp.ua ", 0x10 },
+ { (char*)"x-oma-docomo:open.ctl", 0x9055 },
+ { (char*)"x-oma-docomo:xmd.mail.ua", 0x905C },
+ { (char*)"x-oma-docomo:xmd.storage.ua", 0x905F },
+ { (char*)"x-oma-docomo:xmd.lcsapp.ua", 0x9060 },
+ { (char*)"x-oma-docomo:xmd.info.ua", 0x9061 },
+ { (char*)"x-oma-docomo:xmd.agent.ua", 0x9062 },
+ { (char*)"x-oma-docomo:xmd.sab.ua", 0x9063 },
+ { (char*)"x-oma-docomo:xmd.am.ua", 0x9064 },
+ { (char*)"x-oma-docomo:xmd.emdm.ua", 0x906B },
+ { (char*)"x-oma-docomo:xmd.lac.ua", 0x906C },
+ { (char*)"x-oma-docomo:xmd.osv.ua", 0x906D },
+ { (char*)"x-oma-docomo:xmd.dcs.ua", 0x906E },
+ { (char*)"x-oma-docomo:xmd.wipe.ua", 0x906F },
+ { (char*)"x-oma-docomo:xmd.vdapp.ua ", 0x9070 },
+};
+
+
+static const char* wspCacheControl[] = {
+ (char*)"No-cache",
+ (char*)"No-store",
+ (char*)"Max-age",
+ (char*)"Max-stale",
+ (char*)"Min-fresh",
+ (char*)"Only-if-cached",
+ (char*)"Public",
+ (char*)"Private",
+ (char*)"No-transform",
+ (char*)"Must-revalidate",
+ (char*)"Proxy-revalidate"
+};
+
+
+static const SMS_3GPP_WSP_METHOD_TYPE_S wspMethodType[] = {
+ { (char*)"GET", 0x40 },
+ { (char*)"OPTIONS", 0x41 },
+ { (char*)"HEAD", 0x42 },
+ { (char*)"DELETE", 0x43 },
+ { (char*)"TRACE", 0x44 },
+ { (char*)"POST", 0x60 },
+ { (char*)"PUT", 0x61 }
+};
+
+
+static const SMS_3GPP_WSP_SECURITY_TYPE_S wspSecurityType[] = {
+ {(char*)"NETWPIN", 0x00},
+ {(char*)"USERPIN", 0x01},
+ {(char*)"USERNETWPIN", 0x02},
+ {(char*)"USERPINMAC", 0x03}
+};
+
+
+static const char* wspWeek[] = {
+ (char*)"Sun",
+ (char*)"Mon",
+ (char*)"Tue",
+ (char*)"Wed",
+ (char*)"Thu",
+ (char*)"Fri",
+ (char*)"Sat"
+};
+
+
+#ifdef MSG_FW_FOR_DEBUG
+static const char* wspWeekDay[] = {
+ (char*)"Sunday",
+ (char*)"Monday",
+ (char*)"Tuesday",
+ (char*)"Wednesday",
+ (char*)"Thursday",
+ (char*)"Friday",
+ (char*)"Saturday"
+};
+#endif
+
+
+static const char* wspMonth[] = {
+ (char*)"Jan",
+ (char*)"Feb",
+ (char*)"Mar",
+ (char*)"Apr",
+ (char*)"May",
+ (char*)"Jun",
+ (char*)"Jul",
+ (char*)"Aug",
+ (char*)"Sep",
+ (char*)"Oct",
+ (char*)"Nov",
+ (char*)"Dec"
+};
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gppWapPushHandler - Member Functions
+==================================================================================================*/
+Sms3gppWapPushHandler* Sms3gppWapPushHandler::pInstance = NULL;
+
+
+Sms3gppWapPushHandler::Sms3gppWapPushHandler()
+{
+ memset(&tmpAddress, 0x00, sizeof(tmpAddress));
+ memset(&tmpTimeStamp, 0x00, sizeof(tmpTimeStamp));
+}
+
+
+Sms3gppWapPushHandler::~Sms3gppWapPushHandler()
+{
+}
+
+
+Sms3gppWapPushHandler* Sms3gppWapPushHandler::instance()
+{
+ if (!pInstance)
+ pInstance = new Sms3gppWapPushHandler();
+
+ return pInstance;
+}
+
+
+bool Sms3gppWapPushHandler::IsWapPushMsg(SMS_3GPP_USERDATA_S *pUserData)
+{
+ MSG_BEGIN();
+
+ if (pUserData == NULL) {
+ MSG_DEBUG("pUserData is NULL");
+ return false;
+ }
+
+ int PortCount = sizeof(wapPushPortList) / sizeof(wapPushPortList[0]);
+
+ MSG_DEBUG("Port Count [%d]", PortCount);
+
+ for (int i = 0; i < pUserData->headerCnt; i++) {
+ if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
+ /** Have to check something??? */
+ } else if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
+ for (int j = 0; j < PortCount; j++) {
+ if (pUserData->header[i].udh.appPort16bit.destPort == wapPushPortList[j]) {
+ MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[j]);
+ return true;
+ }
+ }
+ }
+ }
+
+ MSG_END();
+
+ return false;
+}
+
+#if 0
+SMS_WAP_APP_CODE_T Sms3gppWapPushHandler::getAppCode(const char *pPushHeader)
+{
+ int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
+
+ unsigned char *header = NULL;
+ SMS_WAP_APP_CODE_T appCode = SMS_WAP_APPLICATION_DEFAULT;
+
+ MSG_DEBUG("Application Count [%d]", appCount);
+
+ for (int i = 0; i < appCount; i++) {
+ header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
+
+ if (header != NULL) {
+ appCode = pushDefaultApplication[i].appCode;
+ break;
+ }
+ }
+
+ if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
+ MSG_DEBUG("Application Type is not supported");
+ } else {
+ MSG_DEBUG("Find Application [%d]", appCode);
+ }
+
+ return appCode;
+}
+#endif
+
+
+void Sms3gppWapPushHandler::copyDeliverData(SMS_3GPP_DELIVER_S *pDeliver)
+{
+ tmpAddress.ton = pDeliver->originAddress.ton;
+ tmpAddress.npi = pDeliver->originAddress.npi;
+
+ strncpy(tmpAddress.address, pDeliver->originAddress.address, MAX_ADDRESS_LEN);
+
+ MSG_SEC_DEBUG("Address [%s]", tmpAddress.address);
+
+ tmpTimeStamp.format = pDeliver->timeStamp.format;
+
+ if (tmpTimeStamp.format == SMS_3GPP_TIME_ABSOLUTE) {
+ tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
+ tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
+ tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
+ tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
+ tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
+ tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
+ tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
+ }
+}
+
+
+void Sms3gppWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize, int simIndex, time_t sent_time)
+{
+ MSG_BEGIN();
+
+#ifdef MSG_FW_FOR_DEBUG
+ MSG_DEBUG("DataSize [%d]", DataSize);
+
+ MSG_DEBUG("[pUserData]");
+ for (int i = 0; i < DataSize; i++) {
+ printf("[%02x]", pUserData[i]);
+ }
+ printf("\n\n");
+#endif
+
+ unsigned char* pPDUTypeData = (unsigned char*)pUserData;
+ unsigned long PDUTypeDataLen = DataSize;
+
+ char* pPushHeader = NULL;
+ unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter);
+ unsigned long pushHeaderLen = 0;
+
+ char* pPushBody = NULL;
+ unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter);
+ unsigned long pushBodyLen = 0;
+
+ unsigned long iPDU = 1;
+
+ char* pWspHeader = NULL;
+ unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter);
+ unsigned long wspHeaderLen = 0;
+
+ char* pWspBody = NULL;
+ unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter);
+ unsigned long wspBodyLen = 0;
+
+ /* pass PDU type */
+ iPDU++;
+
+ pushHeaderLen = wspRetriveUintvarDecode(pPDUTypeData, &iPDU);
+
+ MSG_DEBUG("PDUTypeDataLen [%lu]", PDUTypeDataLen);
+ MSG_DEBUG("pushHeaderLen [%lu]", pushHeaderLen);
+ MSG_DEBUG("iPDU [%lu]", iPDU);
+
+ wspHeaderLen = pushHeaderLen + iPDU;
+
+ MSG_DEBUG("wspBodyLen [%lu]", wspBodyLen);
+
+ if (wspHeaderLen > 0) {
+ pWspHeader = new char[wspHeaderLen];
+
+ if (pWspHeader == NULL) {
+ MSG_DEBUG("pWspHeader Memory Allocation Failed");
+ return;
+ } else {
+ memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
+ }
+ }
+
+#ifdef MSG_FW_FOR_DEBUG
+ MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
+
+ MSG_DEBUG("[pWspHeader]");
+ for (int i = 0; i < wspHeaderLen; i++) {
+ printf("[%02x]", pWspHeader[i]);
+ }
+ printf("\n\n");
+#endif
+
+ /* return if it is below case error */
+ if (PDUTypeDataLen < wspHeaderLen) {
+ MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
+ return;
+ }
+
+ /* Finding wspBody Information */
+ wspBodyLen = PDUTypeDataLen - wspHeaderLen;
+
+ if (wspBodyLen > 0) {
+ pWspBody = new char[wspBodyLen];
+
+ if (pWspBody == NULL) {
+ MSG_DEBUG("pWspBody Memory Allocation Failed");
+ return;
+ } else {
+ memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
+ }
+ } else {
+ pWspBody = NULL;
+ }
+
+ wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
+
+ iPDU = iPDU + pushHeaderLen;
+
+ pushBodyLen = PDUTypeDataLen - iPDU ;
+
+ if (pushBodyLen > 0) {
+ pPushBody = new char[pushBodyLen];
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody Memory Allocation Failed");
+ return;
+ } else {
+ memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
+ }
+ } else {
+ pPushBody = NULL;
+ return;
+ }
+
+ handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen, simIndex, sent_time);
+
+ MSG_END();
+}
+
+#if 0
+void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
+{
+ MSG_BEGIN();
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ SMS_WAP_APP_CODE_T appCode = getAppCode(pPushHeader);
+
+ /** check Push message receive setting */
+ bool bPushRecv = false;
+
+ if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
+ MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
+ return;
+ }
+
+ switch (appCode) {
+ case SMS_WAP_APPLICATION_MMS_UA:
+ MSG_DEBUG("Received MMS Notification");
+ handleMMSNotification(pPushBody, PushBodyLen);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_SI:
+ MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
+ handleSIMessage(pPushBody, PushBodyLen, true);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_SIC:
+ MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
+ handleSIMessage(pPushBody, PushBodyLen, false);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_SL:
+ MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
+ handleSLMessage(pPushBody, PushBodyLen, true);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_SLC:
+ MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
+ handleSLMessage(pPushBody, PushBodyLen, false);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_CO:
+ MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
+ handleCOMessage(pPushBody, PushBodyLen, true);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_COC:
+ MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
+ handleCOMessage(pPushBody, PushBodyLen, false);
+ break;
+
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ MSG_DEBUG("Received Provisioning");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ MSG_DEBUG("Received Provisioning");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ MSG_DEBUG("Received Provisioning");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+ MSG_DEBUG("Received DM Notification");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ MSG_DEBUG("Received DS Notification");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+ MSG_DEBUG("Received DS Notification");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
+ MSG_DEBUG("Received DRM UA");
+
+ if (pPushBody != NULL)
+ handleDrmVer1(pPushBody, PushBodyLen);
+
+ break;
+
+ case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
+ MSG_DEBUG("Received DRM V2");
+ /* TODO: DRM V2 */
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_EMAIL:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
+ MSG_DEBUG("Received Email");
+ /* TODO: Email */
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
+ MSG_DEBUG("Received IMPS CIR");
+ /* TODO: IMPS CIR */
+ break;
+
+ case SMS_WAP_APPLICATION_LBS :
+ MSG_DEBUG("Received LBS related message");
+ SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
+ /* TODO: LBS */
+ break;
+
+ case SMS_WAP_APPLICATION_PUSH_SIA :
+ MSG_DEBUG("Received SIA");
+ /* TODO: SIA */
+ break;
+
+ default:
+ MSG_DEBUG("Unknown Application [%d]", appCode);
+ break;
+ }
+
+ MSG_END();
+}
+#else
+
+static void launchProcessByAppcode(int appcode)
+{
+ MSG_BEGIN();
+ GError *error = NULL;
+ GDBusConnection *connection_agent = NULL;
+ GDBusProxy *dbus_proxy_agent = NULL;
+ GDBusConnection *connection_service = NULL;
+ GDBusProxy *dbus_proxy_service = NULL;
+ GVariant *result_agent = NULL;
+ GVariant *result_service = NULL;
+
+ switch (appcode) {
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION: {
+ connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
+ "org.tizen.omadmagent", NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ dbus_proxy_service = g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
+ "org.tizen.omadmservice", "/org/tizen/omadmservice",
+ "org.tizen.omadmservice", NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ MsgMutex mx;
+ MsgCndVar cv;
+ mx.lock();
+ cv.timedwait(mx.pMsgMutex(), 2);
+ mx.unlock();
+ MSG_END();
+ }
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML: {
+ connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
+ "org.tizen.omadsagent", "/org/tizen/omadsagent",
+ "org.tizen.omadsagent", NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_DEBUG("invoking service error: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+_DBUS_ERROR:
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+
+ if (connection_agent) {
+ g_object_unref(connection_agent);
+ connection_agent = NULL;
+ }
+
+ if (dbus_proxy_agent) {
+ g_object_unref(dbus_proxy_agent);
+ dbus_proxy_agent = NULL;
+ }
+
+ if (result_agent) {
+ g_object_unref(result_service);
+ result_service = NULL;
+ }
+
+ if (connection_service) {
+ g_object_unref(connection_service);
+ connection_service = NULL;
+ }
+
+ if (dbus_proxy_service) {
+ g_object_unref(dbus_proxy_service);
+ dbus_proxy_service = NULL;
+ }
+
+ if (result_service) {
+ g_object_unref(result_service);
+ result_service = NULL;
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gppWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex, time_t sent_time)
+{
+ MSG_BEGIN();
+
+ MSG_ERR_RET_M(pPushHeader == NULL, "pPushHeader is NULL!");
+ MSG_ERR_RET_M(pPushBody == NULL, "pPushBody is NULL!");
+
+ msg_error_t err = MSG_SUCCESS;
+ int pushEvt_cnt = 0;
+ char app_id[MAX_WAPPUSH_ID_LEN] = {0, };
+ char content_type[MAX_WAPPUSH_CONTENT_TYPE_LEN] = {0, };
+ SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
+
+ err = storageHandler->getRegisteredPushEvent(pPushHeader, &pushEvt_cnt, app_id, sizeof(app_id), content_type, sizeof(content_type));
+ MSG_DEBUG("pushEvt_cnt: %d", pushEvt_cnt);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("Fail to get registered push event");
+ return;
+ }
+
+ for (int i = 0; i < pushEvt_cnt; ++i) {
+ /* check Push message receive setting */
+ bool bPushRecv = false;
+ int appcode = 0;
+ if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ storageHandler->getnthPushEvent(i, &appcode);
+ MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
+ if ((bPushRecv == false) && (IsWapPushMsgInWhiteList(appcode) == false)) {
+ MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
+ return;
+ }
+
+#ifdef FEATURE_MMS_DISABLE
+ if (appcode == SMS_WAP_APPLICATION_MMS_UA) {
+ MSG_DEBUG("Drop MMS Notification for DOCOMO");
+ return;
+ }
+
+#endif
+ launchProcessByAppcode(appcode);
+
+ switch (appcode) {
+ case SMS_WAP_APPLICATION_MMS_UA:
+ MSG_DEBUG("Received MMS Notification");
+ handleMMSNotification(pPushBody, PushBodyLen, simIndex, sent_time);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SI:
+ MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
+ handleSIMessage(pPushBody, PushBodyLen, true, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SIC:
+ MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
+ handleSIMessage(pPushBody, PushBodyLen, false, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SL:
+ MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
+ handleSLMessage(pPushBody, PushBodyLen, true, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SLC:
+ MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
+ handleSLMessage(pPushBody, PushBodyLen, false, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_CO:
+ MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
+ handleCOMessage(pPushBody, PushBodyLen, true, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_COC:
+ MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
+ handleCOMessage(pPushBody, PushBodyLen, false, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ MSG_DEBUG("Received Provisioning");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ MSG_DEBUG("Received Provisioning");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ MSG_DEBUG("Received Provisioning");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+ MSG_DEBUG("Received DM Notification");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ MSG_DEBUG("Received DS Notification");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+ MSG_DEBUG("Received DS Notification");
+ Sms3gppEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
+ MSG_DEBUG("Received DRM UA");
+ if (pPushBody != NULL)
+ handleDrmVer1(pPushBody, PushBodyLen);
+
+ break;
+ case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
+ MSG_DEBUG("Received DRM V2");
+ /* TODO: DRM V2 */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_EMAIL:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
+ MSG_DEBUG("Received Email");
+ /* TODO: Email */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
+ MSG_DEBUG("Received IMPS CIR");
+ /* TODO: IMPS CIR */
+ break;
+ case SMS_WAP_APPLICATION_LBS:
+ MSG_DEBUG("Received LBS related message");
+ Sms3gppEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
+ /* TODO: LBS */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SIA:
+ MSG_DEBUG("Received SIA");
+ /* TODO: SIA */
+ break;
+ default:
+ Sms3gppEventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id, content_type);
+ break;
+ }
+ }
+ storageHandler->releasePushEvent();
+
+ MSG_END();
+}
+#endif
+
+bool Sms3gppWapPushHandler::IsWapPushMsgInWhiteList(int appCode)
+{
+ MSG_BEGIN();
+
+ bool isAllowed = false;
+
+ switch (appCode) {
+ case SMS_WAP_APPLICATION_MMS_UA:
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+ MSG_INFO("appcode[%d] is allowed even if push receive option is disabled.", appCode);
+ isAllowed = true;
+ break;
+ default:
+ MSG_DEBUG("appcode[%d] is not allowed when push receive option is disabled.", appCode);
+ break;
+ }
+
+ return isAllowed;
+}
+
+
+void Sms3gppWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex, time_t sent_time)
+{
+ MSG_BEGIN();
+
+#ifdef MSG_FW_FOR_DEBUG
+ printf("\n\n[handleMMSNotification] Push Body.\n");
+
+ for (int i = 0; i < PushBodyLen; i++) {
+ printf(" [%02x]", pPushBody[i]);
+ }
+ printf("\n\n");
+#endif
+
+ /* Make MSG_MESSAGE_INFO_S */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_MMS_TYPE;
+ msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
+ msgInfo.msgType.classType = MSG_CLASS_NONE;
+ msgInfo.storageId = MSG_STORAGE_PHONE;
+ msgInfo.dataSize = PushBodyLen;
+ msgInfo.sim_idx = simIndex;
+
+ if (sent_time > 0)
+ msgInfo.displayTime = sent_time;
+
+ if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
+ msgInfo.bTextSms = false;
+
+ /* Save Message Data into File */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+ if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false)
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+ } else {
+ msgInfo.bTextSms = true;
+
+ memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
+ msgInfo.msgText[msgInfo.dataSize] = '\0';
+ }
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add MMS Noti Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+
+ if (err == MSG_SUCCESS) {
+ /* Callback */
+ err = Sms3gppEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+ }
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gppWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex)
+{
+ MSG_BEGIN();
+
+ MSG_PUSH_MESSAGE_S pushMsg = {};
+
+ xmlDocPtr xmlDoc = NULL;
+ xmlNodePtr topNode = NULL;
+ xmlNodePtr indNode = NULL;
+
+ xmlChar* tmpXmlChar = NULL;
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+ if (xmlDoc == NULL) {
+ MSG_DEBUG("xmlDoc is NULL");
+ return;
+ }
+
+ topNode = xmlDocGetRootElement(xmlDoc);
+
+ if (topNode == NULL) {
+ MSG_DEBUG("topNode is NULL");
+ xmlFreeDoc(xmlDoc);
+ return;
+ }
+
+ indNode = topNode->xmlChildrenNode;
+
+ while (indNode != NULL) {
+ if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+ break;
+ }
+
+ indNode = indNode->next;
+ }
+
+ if (indNode == NULL) {
+ MSG_DEBUG("indNode is NULL.");
+ return;
+ }
+
+ /** temporary set to max. */
+ pushMsg.expires = 0xFFFFFFFF;
+
+ /** setting received time */
+ time_t t = time(NULL);
+ time_t utfTime = time(&t);
+
+ pushMsg.received = (unsigned long)utfTime;
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
+
+ if (tmpXmlChar == NULL) {
+ MSG_DEBUG("href is NULL.");
+ return;
+ }
+
+ if (tmpXmlChar != NULL)
+ strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
+
+ if (tmpXmlChar != NULL)
+ strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
+
+ if (tmpXmlChar != NULL)
+ pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
+
+ if (pushMsg.created == 0)
+ pushMsg.created = pushMsg.received;
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
+
+ if (tmpXmlChar != NULL)
+ pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
+
+ pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
+
+ tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
+
+ if (tmpXmlChar == NULL) {
+ MSG_DEBUG("contents is NULL.");
+ return;
+ }
+
+ strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
+
+ /** Write push Msg to file */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false) {
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+ }
+
+ if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+ }
+
+ /* Pack Message Info Structure */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_WAP_SI_SMS;
+ msgInfo.sim_idx = simIndex;
+
+ msgInfo.dataSize = sizeof(pushMsg);
+ getDisplayName(msgInfo.msgType.subType, msgInfo.addressList[0].addressVal);
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add WAP Push Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ if (err == MSG_SUCCESS) {
+ /* Callback */
+ err = Sms3gppEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ MSG_END();
+
+ return;
+}
+
+
+void Sms3gppWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex)
+{
+ MSG_BEGIN();
+
+ MSG_PUSH_MESSAGE_S pushMsg = {};
+
+ xmlDocPtr xmlDoc = NULL;
+ xmlNodePtr topNode = NULL;
+ xmlNodePtr indNode = NULL;
+
+ xmlChar* tmpXmlChar = NULL;
+
+ msg_error_t err = MSG_SUCCESS;
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL \n");
+ return;
+ }
+
+ getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+ if (xmlDoc == NULL) {
+ MSG_DEBUG("xmlDoc is NULL \n");
+ return;
+ }
+
+ topNode = xmlDocGetRootElement(xmlDoc);
+
+ if (topNode == NULL) {
+ MSG_DEBUG("Empty Document.");
+ xmlFreeDoc(xmlDoc);
+ return;
+ } else {
+ MSG_SEC_DEBUG("Not an empty Document and topNode->name = %s \n", topNode->name);
+ }
+
+ indNode = topNode;
+
+ while (indNode != NULL) {
+ if (!xmlStrcmp(indNode->name, (const xmlChar*)"sl")) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+ break;
+ }
+
+ indNode = indNode->next;
+ }
+
+ /* setting received time setting */
+ time_t t = time(NULL);
+ time_t utfTime = time(&t);
+
+ pushMsg.received = (unsigned long)utfTime;
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
+
+ if (tmpXmlChar == NULL) {
+ MSG_DEBUG("href is NULL.");
+ return;
+ }
+
+ strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
+ pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
+
+ /* Setting other parameters in default values */
+ pushMsg.created = pushMsg.received;
+ /* temporary set to MAX value. */
+ pushMsg.expires = 0xFFFFFFFF;
+
+ MSG_DEBUG("check pushMsg data");
+ MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
+ MSG_DEBUG("pushMsg.received : [%lu]", pushMsg.received);
+ MSG_DEBUG("pushMsg.created : [%lu]", pushMsg.created);
+ MSG_DEBUG("pushMsg.expires : [%lu]", pushMsg.expires);
+ MSG_SEC_DEBUG("pushMsg.id : [%s]", pushMsg.id);
+ MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
+ MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
+
+ /* Write push Msg to file */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+ if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+ /* Pack Message Info Structure */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_WAP_SL_SMS;
+ msgInfo.sim_idx = simIndex;
+
+ /* Update Msg Text */
+ strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
+
+ msgInfo.dataSize = sizeof(pushMsg);
+ getDisplayName(msgInfo.msgType.subType, msgInfo.addressList[0].addressVal);
+ MSG_DEBUG("dataSize : %zu", msgInfo.dataSize);
+
+ /** Add WAP Push Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ if (err == MSG_SUCCESS) {
+ /* Callback to MSG FW */
+ err = Sms3gppEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+
+ MSG_END();
+
+ return;
+}
+
+void Sms3gppWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex)
+{
+ MSG_PUSH_CACHEOP_S cacheOp;
+
+ xmlDocPtr xmlDoc = NULL;
+ xmlNodePtr topNode = NULL;
+ xmlNodePtr indNode = NULL;
+
+ memset(&cacheOp, 0x00, sizeof(cacheOp));
+
+ MSG_DEBUG("Enter handleCOMessage");
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL \n");
+ return;
+ }
+
+ getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+ if (xmlDoc == NULL) {
+ MSG_DEBUG("xmlDoc is NULL \n");
+ return;
+ }
+
+ topNode = xmlDocGetRootElement(xmlDoc);
+ if (topNode == NULL) {
+ MSG_DEBUG("Warning:Empty Document\n");
+ xmlFreeDoc(xmlDoc);
+ return;
+ }
+
+ indNode = topNode->xmlChildrenNode;
+
+ while (indNode != NULL) {
+ xmlChar* tmpUrl = NULL;
+ if (!xmlStrcmp(indNode->name, (const xmlChar*)SMS_PUSH_XML_INVAL_OBJ)) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+
+ tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
+
+ if (tmpUrl != NULL) {
+ strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
+
+ MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
+ } else {
+ MSG_DEBUG("NO href value from the xmlDoc\n");
+ }
+ } else if (!xmlStrcmp(indNode->name, (const xmlChar*)SMS_PUSH_XML_INVAL_SVC)) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+ tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
+
+ if (tmpUrl != NULL) {
+ strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
+ MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
+ } else {
+ MSG_DEBUG("NO href value from the xmlDoc\n");
+ }
+ }
+
+ if (tmpUrl != NULL)
+ xmlFree(tmpUrl);
+
+ indNode = indNode->next;
+ }
+
+ /* Write push Msg to file */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false) {
+ xmlFree(xmlDoc);
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+ }
+
+ if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
+ xmlFree(xmlDoc);
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+ }
+
+ /* Pack Message Info Structure */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_WAP_CO_SMS;
+ msgInfo.sim_idx = simIndex;
+
+ msgInfo.dataSize = sizeof(cacheOp);
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add WAP Push Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ if (err == MSG_SUCCESS) {
+ /* Callback */
+ err = Sms3gppEventHandler::instance()->callbackMsgIncoming(&msgInfo);
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ xmlFree(xmlDoc);
+
+ return;
+}
+
+
+void Sms3gppWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
+{
+#if MSG_DRM_SUPPORT
+ int drmRt = DRM_RETURN_SUCCESS;
+ char* cid = NULL;
+ unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter);
+
+ MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
+ drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
+ drm_register_lic_info_s lic_req_info;
+ drm_register_lic_resp_s lic_resp_info;
+
+ bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
+ bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
+ bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
+
+ memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
+
+ lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
+ lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
+ lic_req_info.operation_callback.callback = NULL;
+
+ drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
+ if (drmRt == DRM_RETURN_SUCCESS) {
+ MSG_DEBUG("DRM successfully registed to drm-service.");
+ } else {
+ MSG_DEBUG("Fail to regist DRM to drm-service.");
+ }
+#endif
+ return;
+}
+
+
+void Sms3gppWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
+{
+ /* Convert class Type values */
+ pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+
+ /* set folder id (temporary) */
+ pMsgInfo->folderId = MSG_INBOX_ID;
+
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+ time_t rawtime = time(NULL);
+ /* Comment below lines to save local UTC time..... (it could be used later.) */
+ /*
+ if (tmpTimeStamp.format == SMS_3GPP_TIME_ABSOLUTE) {
+
+ MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
+ MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
+ MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
+ MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
+ MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
+ MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
+ MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
+
+ char displayTime[32];
+ struct tm * timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
+ timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
+ timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
+ timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
+ timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
+ timeinfo.tm_sec = tmpTimeStamp.time.absolute.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%d]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (tmpTimeStamp.time.absolute.timeZone * (3600/4));
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+ */
+
+ pMsgInfo->displayTime = rawtime;
+
+ /* Convert Address values */
+ pMsgInfo->nAddressCnt = 1;
+
+ pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.address, MAX_ADDRESS_VAL_LEN);
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+}
+
+void Sms3gppWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
+{
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ if (isText) {
+ *pXmlDoc = xmlParseMemory(pPushBody, AcStrlen(pPushBody));
+ } else {
+ WB_UTINY* xmldata = NULL;
+ WBXMLConvWBXML2XML *conv = NULL;
+ WBXMLError ret = WBXML_OK;
+
+ ret = wbxml_conv_wbxml2xml_create(&conv);
+ if (ret != WBXML_OK)
+ return;
+
+ ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
+
+ wbxml_conv_wbxml2xml_destroy(conv);
+
+ if (ret != WBXML_OK ||xmldata == NULL) {
+ MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
+ return;
+ }
+
+ MSG_DEBUG("xmldata : \n%s\n", xmldata);
+
+ *pXmlDoc = xmlParseMemory((char*)xmldata, AcStrlen((char*)xmldata));
+ }
+}
+
+unsigned long Sms3gppWapPushHandler::convertXmlCharToSec(char* pDate)
+{
+ struct tm timeStruct;
+ time_t nTimeInSec = 0;
+ char tmpBuf[10];
+ int i = 0;
+ int index = 0;
+
+ memset(tmpBuf, 0x00, sizeof(tmpBuf));
+ memset(&timeStruct, 0x00, sizeof(struct tm));
+
+ /* check pDate */
+ if (AcStrlen(pDate) < 20)
+ return 0;
+
+ MSG_DEBUG("pDate [%s]", pDate);
+
+ /* Year */
+ for (i = 0; i < 4; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_year = (atoi(tmpBuf)-1900);
+
+ /* Month */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_mon = (atoi(tmpBuf) - 1);
+
+ /* Date */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_mday = atoi(tmpBuf);
+
+ /* Hours */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_hour = atoi(tmpBuf);
+
+ /* Minites */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_min = atoi(tmpBuf);
+
+ /* Seconds */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_sec = atoi(tmpBuf);
+
+ nTimeInSec = mktime(&timeStruct);
+
+ return nTimeInSec;
+}
+
+
+msg_push_action_t Sms3gppWapPushHandler::convertSIActionStrToEnum(char* pAction)
+{
+ int comp = 0;
+
+ if (pAction == NULL) {
+ MSG_DEBUG("pAction is NULL. Setting to default action type.");
+ return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+ }
+
+ /* compare with signal-none. */
+ comp = g_strcmp0("signal-none", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
+
+ /* compare with signal-low. */
+ comp = g_strcmp0("signal-low", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
+
+ /* compare with signal-medium. */
+ comp = g_strcmp0("signal-medium", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+
+ /* compare with signal-high. */
+ comp = g_strcmp0("signal-high", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
+
+ /* compare with delete. */
+ comp = g_strcmp0("delete", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_DELETE;
+
+ /* signal-medium is default action value. */
+ return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+}
+
+
+msg_push_action_t Sms3gppWapPushHandler::convertSLActionStrToEnum(char* pAction)
+{
+ int comp = 0;
+
+ if (pAction == NULL) {
+ MSG_DEBUG("MSG_DEBUG is NULL. Setting to default action type.\n");
+ return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+ }
+
+ /* compare pSrcStr with execute-low. */
+ comp = g_strcmp0("execute-low", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+
+ /* compare pSrcStr with execute-high. */
+ comp = g_strcmp0("execute-high", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
+
+ /* compare pSrcStr with cache. */
+ comp = g_strcmp0("cache", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SL_ACTION_CACHE;
+
+ /* default SL action value is execute-low. */
+ return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+}
+
+
+unsigned long Sms3gppWapPushHandler::wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer)
+{
+ unsigned long i = 0;
+ unsigned long decodedValue;
+
+ while (sourceData[*currentPointer + i] >= 0x80)
+ i++;
+
+ decodedValue = wspDecodeUintvar(i + 1, sourceData + *currentPointer);
+ *currentPointer = *currentPointer + i + 1;
+ MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%lu .\n", decodedValue);
+ return decodedValue;
+}
+
+
+unsigned long Sms3gppWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar)
+{
+ unsigned long i;
+ unsigned long decodedUintvar = 0;
+
+ for (i = 0 ; i < length; i++) {
+ decodedUintvar = decodedUintvar + (wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f));
+ }
+
+ return decodedUintvar;
+}
+
+
+void Sms3gppWapPushHandler::wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
+{
+ unsigned long iField = 0;
+ bool continueField = FALSE;
+ unsigned long currentLength;
+
+ char* encodedHeader = NULL;
+ unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter);
+
+ char* outTemper = NULL;
+
+ char* temper = NULL;
+ unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter);
+
+ unsigned char track;
+ unsigned long iEncodedHeader = 0;
+ unsigned char fieldCode = 0xff;
+
+ /* outTemper is Decoded Headers.
+ temper is Single Decoded Header.
+ */
+ if (NULL == (outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
+ MSG_DEBUG("outTemper Memory allocation is failed.\n");
+ return;
+ }
+ memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
+ currentLength = WSP_STANDARD_STR_LEN_MAX;
+
+ MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n");
+
+ int loop;
+ char szBuf[64];
+
+ szBuf[0] = 0x00;
+ MSG_DEBUG("wspDecodeHeader: RAW data \n");
+ for (loop = 0 ; loop < (int)encodedHeaderLen; loop++) {
+ char szTempBuf[5];
+ szTempBuf[0] = 0x00;
+ snprintf(szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop]);
+
+ if (AcStrlen(szBuf) + 7 < 64) {
+ strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
+ } else {
+ strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
+ MSG_DEBUG("[%s]", szBuf);
+ szBuf[0] = 0x00;
+ strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
+ }
+ }
+ strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
+ MSG_DEBUG("[%s]", szBuf);
+ MSG_DEBUG("fContentType=%d \n", fContentType);
+ /* operation for content-type */
+ /* makes psuedo- content-type fieldcode */
+ /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
+
+ if (fContentType) {
+ encodedHeader = new char[ encodedHeaderLen + 1 ];
+ if (encodedHeader == NULL) {
+ MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
+ return;
+ }
+ encodedHeader[0] = 0x91;
+ memcpy(encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen);
+ } else {
+ encodedHeader = new char[ encodedHeaderLen ];
+ if (encodedHeader == NULL) {
+ MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
+ return;
+ }
+
+ memcpy(encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen);
+ }
+
+ /* Is it reacehd end of header? */
+ while (iEncodedHeader < encodedHeaderLen) {
+ /* Get memory for single header */
+ if (temper == NULL) {
+ temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
+
+ if (temper == NULL) {
+ MSG_DEBUG("temper Memory allocation is failed.\n");
+ return;
+ }
+ memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
+ } else {
+ memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
+ }
+
+ /* this section presents header code page shifting procedure
+ This part can be implemented by future request.
+ if (track == 0x 7f)
+ */
+ track = encodedHeader[iEncodedHeader];
+
+ if (track == 0x00) {
+ MSG_DEBUG("WspLDecodeHeader: fieldcode is 0 \n");
+ strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+ fieldCode = 0xff;
+ iEncodedHeader++;
+ } else if ((track > 0) && (track < 0x20)) {
+ iEncodedHeader++;
+ } else if ((track < 0x7f) && (track > 0x1f)) { /* In this case, first byte is normal string. So it's considered to unknown header. */
+ unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
+ unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
+
+ strncpy((char*)fieldName, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
+ fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
+ iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldName) + 1;
+ strncpy((char*)fieldValue, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
+ fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
+ iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldValue) + 1;
+
+ strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ /* this means 'don't process anymore.' */
+ fieldCode = 0xff;
+
+ } else if (track > 0x7f) {
+ /* In case of first byte is field code, else case is error. */
+ /*if ((track & 0x7f) <= wspHeaderFieldCount) { */
+ unsigned long fieldValueLen = encodedHeader[iEncodedHeader + 1];
+ unsigned char fieldValue[1275];
+ fieldCode = track & 0x7f;
+ /*
+ if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
+ dprint(DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5]);
+ }
+ */
+ memset(fieldValue, 0, 1275);
+
+ /* add field name */
+ /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
+ if (!continueField) {
+ strncat((char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ continueField = FALSE;
+ }
+
+ /* field value is string */
+ /* In this case, it just copy field value. */
+ if ((fieldValueLen > LENGTH_QUOTE) && (fieldValueLen < 0x80)) {
+ /* string field value should be NULL terminated */
+ strncat((char*)temper, (char*)(encodedHeader + iEncodedHeader + 1), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ iEncodedHeader = iEncodedHeader + AcStrlen((char*)encodedHeader + iEncodedHeader + 1) + 2;
+ fieldCode = 0xff;
+ }
+
+ /* first field value is length */
+ /* If first byte of field value is length value, allocate field value by the length.
+ In field value, data is
+ 1D 03 8F 24 24 - Then 8F 24 24 is field value.
+ 1D 1F 33.... - Then allocate 33H for FieldValue.
+ 1D 8F - Then 8F
+ 1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
+ 1D 8F 24 24 - In this case, original data is wrong.
+ If accept-charset: ISO-10646-ucs-2;Q=0.7 is
+ 01 03 03 E8 47
+ 01 - field code
+ 03 - field value length
+ 03 E8 47 - field value
+ it's decoded by above value.
+ */
+ if (fieldValueLen < 0x20) {
+ if (fieldValueLen == LENGTH_QUOTE) {
+ /* field length is encoded in UINTVAR */
+ unsigned long uintvarLen = 0;
+ fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen);
+ memcpy(fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen);
+ iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
+ } else {
+ if (fieldValueLen == 1) {
+ /* field value is one byte integer over 0x80 */
+ /** make it two byte integer */
+ fieldValue[0] = 0x00;
+ memcpy(fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+ fieldValueLen = 2;
+ iEncodedHeader = iEncodedHeader + 1 + 2;
+ } else {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+ fieldValue[fieldValueLen] = 0;
+ iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
+ if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
+ MSG_DEBUG("%X \n", encodedHeader[iEncodedHeader]);
+ }
+ }
+ }
+ }
+
+ /* field value is single encoded */
+ if (fieldValueLen > 0x7f) {
+ fieldValue[0] = encodedHeader[iEncodedHeader + 1];
+ fieldValueLen = 1;
+ iEncodedHeader = iEncodedHeader + 2;
+ }
+ /* processing normal pre-defined field decoding */
+
+ MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode);
+ MSG_DEBUG("WspLDecodeHeader: fieldSize %lu\n", fieldValueLen);
+
+ if ((fieldCode > wspHeaderFieldCount) && (fieldCode != 0xff)) {
+ MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track);
+ strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+ fieldCode = 0xff;
+ }
+
+ switch (fieldCode) {
+ /* accept charset */
+ /* It's normal way of field process. */
+ case 0x01: {
+ unsigned long i = 0;
+ unsigned long code;
+
+ /* Case of length of charset greater than 1 are two thigins.
+ 1. code length of charset is greater than 1.
+ 2. It include parameter.
+ 3. Or both of two
+ */
+ if (1 != fieldValueLen) {
+ code = wspHeaderDecodeInteger(fieldValue);
+ /* Calculate iField. */
+ if (fieldValue[0] < 0x80)
+ iField = fieldValue[0];
+ else
+ iField = 1;
+
+ while (wspCharset[i].charsetCode != code)
+ i++;
+ strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ /* If parameter exist */
+ if (iField < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeQValue(fieldValueLen - iField, fieldValue + iField, ¶m);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ } else {
+ code = fieldValue[0] & 0x7f;
+
+ while ((wspCharset[i].charsetCode != code) && (wspCharset[i].charsetCode != 0xffff )) i++;
+ strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ break;
+
+ /* type encoding */
+ /* Like below routine, Same decoding routine process together. */
+ /* Accept-encoding */
+ case 0x02:
+ /* content-encoding */
+ case 0x0b: {
+ int integerValue;
+
+ integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+ if (integerValue > 2) {
+ MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
+ break;
+ }
+ strncat((char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* contents type decoder */
+ /* accept */
+ case 0x00:
+ /* content-type */
+ case 0x11: {
+ unsigned long contentsTypeCode;
+ unsigned long i = 0;
+ /* encoded content type length body */
+ unsigned long tempLen;
+ MSG_DEBUG("fieldValueLen: %lu", fieldValueLen);
+
+ /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
+ if (0 == fieldValueLen) {
+ strncat((char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ break;
+ }
+ /* 01 AE --> 00 AE --> AE*/
+ if (fieldValueLen == 2 && fieldValue[0] == 0) {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
+ MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
+ }
+
+ if ((fieldValue[0] < 0x20) || (fieldValue[0] >= 0x80)) {
+ if (fieldValue[0] >= 0x80) {
+ tempLen = 1;
+ } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
+ fieldValue[3] = fieldValue[2];
+ fieldValue[2] = fieldValue[1];
+ fieldValue[1] = fieldValue[0];
+ fieldValue[0] = 0x02;
+ tempLen = 2;
+ fieldValueLen = 3;
+ MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n");
+ } else {
+ tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
+ }
+
+ if (tempLen == 1) {
+ char* szExtendedContent;
+
+ contentsTypeCode = fieldValue[0] & 0x7f;
+ while ((wspContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspContentsTypeCount)) i++;
+
+ /* If specified content type doesn't exist */
+ if (i < wspContentsTypeCount)
+ strncat((char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ szExtendedContent = wspExtendedDecodeType((char)contentsTypeCode);
+
+ if (szExtendedContent != NULL) {
+ MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n ");
+ strncat((char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ } else {
+ contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
+
+ while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode)) i++;
+
+ /** If there is a Content-Type assigned, */
+ if (i < wspUnregisteredContentsTypeCount)
+ strncat((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ tempLen +=1;
+ }
+ } else {
+ tempLen = AcStrlen((char*)fieldValue) + 1;
+
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type %lu\n ", tempLen);
+ }
+
+ /* If there is a parameter */
+ if (tempLen < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + tempLen, fieldValueLen - tempLen, ¶m);
+ if (param != NULL) {
+ strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ }
+ break;
+
+ /* language */
+ /* content-language */
+ case 0x0c:
+ /* accept-language */
+ case 0x03: {
+ unsigned long i = 0;
+ unsigned long code;
+ unsigned long tempLen;
+ if ((fieldValue[0] < 0x20) || (fieldValue[0] > 0x80)) {
+ if (fieldValue[0] > 0x80)
+ tempLen = 1;
+ else
+ tempLen = fieldValue[0];
+ } else {
+ tempLen = AcStrlen((char*)fieldValue) + 1;
+ }
+
+ if (tempLen == 1) {
+ code = wspHeaderDecodeInteger(fieldValue);
+ while (wspLanguage[i].languageCode != code) {
+ i++;
+ if (i == wspLanguageCount)
+ break;
+ }
+
+ if (i < wspLanguageCount) {
+ strncat((char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ } else {
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+
+ if (tempLen < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeQValue(fieldValueLen - tempLen, fieldValue + tempLen, ¶m);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ break;
+
+ /* integer */
+ /* Max-forwards */
+ case 0x1e:
+ /* content-length */
+ case 0x0d:
+ /* age */
+ case 0x05:
+ /* Bearer-indication */
+ case 0x33:
+ /* Push-Flag */
+ case 0x34: {
+ unsigned char temp[16];
+ /*
+ if ((fieldValueLen == 2) && (fieldValue[0] > 0x7f))
+ AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[1]);
+ else
+ */
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* X-Wap-Application-Id */
+ case 0x2f: {
+ unsigned char temp[64];
+ int integerValue;
+
+ if (track == 0xaf) { /* WAP short-integer-encoded */
+ if (fieldValueLen == 2 && fieldValue[0] == 0) {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen);
+ }
+ integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+ } else {
+ if (fieldValueLen == 2 && fieldValue[0] == 0) {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
+ MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
+ fieldValueLen = 1;
+ }
+ integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+ }
+
+ MSG_DEBUG("integerValue = [%02x]", integerValue);
+
+ int count = sizeof(wspHeaderApplId)/sizeof(SMS_3GPP_WSP_HEADER_PARAMETER_S);
+ for (int i = 0; i < count ; ++i) {
+ if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode) {
+ snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ break;
+ }
+ }
+ }
+ break;
+ /* Accept-Application */
+ case 0x32:
+ if (0x80 == fieldValue[0]) {
+ strncat((char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ } else {
+ unsigned char temp[16];
+ /*
+ if ((fieldValueLen == 2) && (fieldValue[0] == 1))
+ AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[0]);
+ else
+ */
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ }
+ break;
+
+
+ /* date */
+ /* last-modified */
+ case 0x1d:
+ /* if-unmodified-since */
+ case 0x1b:
+ /* if-range */
+ case 0x1a:
+ /* if-modified-since */
+ case 0x17:
+ /* expires */
+ case 0x14:
+ /* date */
+ case 0x12: {
+ char* decodedString = NULL;
+ unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+ wspHeaderDecodeDateValue(fieldValueLen, fieldValue, &decodedString);
+ strncat((char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ }
+ break;
+
+ /* connection */
+ case 0x09:
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ break;
+ /* accept-ranges */
+ case 0x04:
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ if (fieldValue[0] == 0x81)
+ strncat((char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ break;
+ /* content-md5 */
+ case 0x0f: {
+ unsigned char temp[1275];
+ memcpy(temp, fieldValue, (size_t)fieldValueLen);
+ temp[fieldValueLen] = 0;
+ wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
+ }
+ break;
+ /* Credential */
+ /* authorization */
+ case 0x07:
+ /* proxy - authorization */
+ case 0x21:
+ if (fieldValue[0] == 0x80) {
+ char* addString = NULL;
+ unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+ wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString);
+ strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ } else {
+ iField = AcStrlen((char*)fieldValue) + 1;
+
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ if (iField < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
+ if (param != NULL) {
+ strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ }
+ break;
+
+
+ /* Challenge */
+ /* www - auth */
+ case 0x2d:
+ /* Proxy-authenticate */
+ case 0x20:
+ if (0 == fieldValueLen)
+ break;
+ if (fieldValue[0] == 0x80) {
+ char* addString = NULL;
+ unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+ wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString);
+ strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ } else {
+ unsigned char authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
+ unsigned char realmValue[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char addedString[WSP_STANDARD_STR_LEN_MAX];
+
+ strncpy((char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
+ iField = AcStrlen((char*)authScheme) + 1;
+ strncpy((char*)realmValue, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+ iField = iField + AcStrlen((char*)realmValue) + 1;
+ int wrn = snprintf((char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue);
+ if(wrn<0)
+ MSG_DEBUG("snprintf was failed");
+ wspHeaderCopyDecodedString(addedString, ¤tLength, &temper);
+
+ if (iField < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + iField, fieldValueLen - iField, ¶m);
+ if (param != NULL) {
+ strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ wspHeaderCopyDecodedString((unsigned char*)param, ¤tLength, &temper);
+ }
+ }
+ }
+ break;
+
+ /* content -range */
+ case 0x10: {
+ unsigned long first, len, last;
+
+ unsigned char temp[16];
+ iField = 0;
+
+ strncat((char*)temper, " bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ first = wspRetriveUintvarDecode(fieldValue, &iField);
+ len = wspRetriveUintvarDecode(fieldValue, &iField);
+ /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
+ */
+ last = first + contentsLength - 1;
+
+ snprintf((char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+
+ /* cache-control */
+ case 0x08: {
+ char* cacheString = NULL;
+ unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
+
+ wspHeaderDecodeCacheControl(fieldValue, fieldValueLen, &cacheString);
+ strncat((char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+
+ /* pragma */
+ case 0x1f:
+ if (fieldValue[0] == 0x80) {
+ strncat((char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ } else {
+ if (1 < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue, fieldValueLen, ¶m);
+
+ if (param != NULL) {
+ strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ }
+
+ break;
+ /* public */
+ case 0x22:
+ /* allow */
+ case 0x06: {
+ unsigned long i = 0;
+ while (wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen) != wspMethodType[i].methodCode) i++;
+ strncat((char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* range */
+ case 0x23:
+ strncat((char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ if (fieldValue[0] == 0x80) {
+ unsigned char temp[16];
+ unsigned long first, last;
+ iField = 0;
+
+ first = wspRetriveUintvarDecode(fieldValue, &iField);
+ last = wspRetriveUintvarDecode(fieldValue, &iField);
+
+ snprintf((char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ if (fieldValue[0] == 0x81) {
+ unsigned char temp[16];
+ unsigned long suffix;
+
+ suffix = wspRetriveUintvarDecode(fieldValue, &iField);
+
+ snprintf((char*)temp, sizeof(temp), "-%u", (unsigned int)suffix);
+ }
+ break;
+ /* retry-after */
+ case 0x25:
+ if (fieldValue[0] == 0x80) {
+ char* temp = NULL;
+ unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
+
+ wspHeaderDecodeDateValue(fieldValueLen - 1, fieldValue + 1, &temp);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+
+ if (fieldValue[0] == 0x81) {
+ unsigned char temp[16];
+
+ snprintf((char*)temp, 16, "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* transfer-encoding */
+ case 0x27:
+ /* No other cases allowed */
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ break;
+ /* vary */
+ case 0x2a: {
+ int integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+ if (integerValue > wspHeaderFieldCount) {
+ MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n", wspHeaderFieldCount);
+ break;
+ }
+ strncat((char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* warning */
+ case 0x2c: {
+ unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+ if (fieldValue[0] < 0x20)
+ iField = fieldValue[0];
+ else
+ iField = 1;
+
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, iField));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ if (iField < fieldValueLen) {
+ unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char text[WSP_STANDARD_STR_LEN_MAX];
+ strncpy((char*)agent, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+ iField = iField + AcStrlen((char*)agent) + 1;
+ strncpy((char*)text, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+ int wrn = snprintf((char*)temp, sizeof(temp), " %s %s", agent, text);
+ if(wrn<0)
+ MSG_DEBUG("snprintf was failed");
+ wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
+ }
+ }
+ break;
+ /* content-disposition */
+ case 0x2e:
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ if (fieldValue[0] == 0x81)
+ strncat((char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ if (1 < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
+
+ if (param != NULL) {
+ strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ break;
+ /* Profile-diff */
+ case 0x36:
+ temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
+ memcpy(temper, fieldValue, (size_t)fieldValueLen);
+ break;
+ /* Profile-Warning */
+ case 0x37: {
+ unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+ snprintf((char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue));
+ temp[2] = temp[1];
+ temp[1] = (unsigned char)0x30;
+ temp[3] = '\0';
+ if (fieldValueLen > 1) {
+ /* copy warn-target - URI */
+ strncat((char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
+ if (fieldValueLen > (AcStrlen((char*)(fieldValue + 1)) + 1)) {
+ /* copy warn-date */
+ char* decodedString = NULL;
+ unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+ wspHeaderDecodeDateValue(fieldValueLen - (AcStrlen((char*)(fieldValue + 1)) + 2), fieldValue + AcStrlen((char*)(fieldValue + 1)) + 1, &decodedString);
+ strncat((char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
+ }
+ }
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+
+ default:
+ break;
+ }
+ /*}*/
+ }
+ /* It deosn't finished decoding yet. */
+ if ((iEncodedHeader < encodedHeaderLen) && (fieldCode != 0xff)) {
+ /* In here, iEncodedHeader already point next field code to be decoded. */
+ /* If this code is same, then set continueField else add CRLF. */
+ if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f)) {
+ strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ continueField = TRUE;
+ } else {
+ strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ continueField = FALSE;
+ }
+ } else {
+ strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+
+ /* add single header to total headers */
+ strncat((char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1);
+ MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper);
+ }
+
+ MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n");
+
+ *pHeader = outTemper;
+
+ return;
+}
+
+
+unsigned long Sms3gppWapPushHandler::wspHeaderDecodeInteger(unsigned char* data)
+{
+ /* we only can handle max 32bit integer */
+ unsigned long i;
+
+ union {
+ unsigned long integer;
+ unsigned char seg[4];
+ } returner;
+
+ returner.integer = 0;
+
+ if (data[0] < 0x80) {
+ unsigned long IntLen = 0;
+
+ IntLen = (data[0] > 0x04) ? 0x04:data[0];
+
+ MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %lu\n", data[0], IntLen);
+
+ for (i = 0; i < IntLen; i++)
+ returner.seg[IntLen-(i+1)] = data[i+1];
+
+ return returner.integer;
+ }
+
+ return data[0] & 0x7f;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString)
+{
+ unsigned short qBase = 0;
+ float qValue;
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
+ return;
+ }
+
+ memcpy(&qBase, data, (size_t)length);
+ qValue = (float)qBase;
+ if (qValue > 100) {
+ qValue = qValue - 100;
+ qValue = qValue / 1000;
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue);
+ } else {
+ /* qValue variable is divided by 100. And it's multiplied by 100.
+ It's to resolve problem of changed 0.01 of qValue. */
+ unsigned long qValueTemp;
+ qValue = qValue - 1;
+ qValue = qValue / 100;
+ qValueTemp = (unsigned long)(qValue * 100);
+ if (0 == (qValueTemp % 10))
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue);
+ else
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue);
+ }
+ return;
+}
+
+
+unsigned long Sms3gppWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length)
+{
+ unsigned long i;
+
+ union {
+ unsigned long integer;
+ unsigned short seg[4];
+ } returner;
+
+ returner.integer = 0;
+
+ if (length == 1)
+ return data[0] & 0x7f;
+
+ returner.integer = 0;
+
+ for (i = 0 ; i < length; i++) {
+ returner.integer = returner.integer + (data[i] * (0x1 << ((length - (i + 1)) * 8)));
+ MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %lu \n", returner.integer);
+ }
+
+ return returner.integer;
+}
+
+
+char* Sms3gppWapPushHandler::wspExtendedDecodeType(char contentType)
+{
+ int i = 0;
+
+ while (wspExtendedContentsType[i].contentsTypeCode != contentType) {
+ if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
+ return NULL;
+ i++;
+ }
+
+ return (char*)wspExtendedContentsType[i].contentsTypeName;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam)
+{
+ char* param = *pParam;
+
+ unsigned long SecurityTypeCode;
+ unsigned long i = 0;
+
+ if (data[0] < 0x80) {
+ /* unknown parameter type */
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n");
+ return;
+ }
+
+ strncpy((char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
+
+ if (NO_VALUE == data[AcStrlen((char*)param) + 1]) {
+ *pParam = param;
+ return;
+ }
+
+ strncat((char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ strncat((char*)param, (char*)(data + strlen((char*)param)), WSP_STANDARD_STR_LEN_MAX-strlen((char*)param)-1);
+
+ *pParam = param;
+
+ return;
+ }
+
+ switch (data[0] & 0x7f) {
+ case 0x00:
+ wspHeaderDecodeQValue(length - 1, data + 1, ¶m);
+ break;
+ case 0x01:
+ wspHeaderDecodeCharset(length - 1 , data + 1, ¶m);
+ break;
+ case 0x02:
+ wspHeaderDecodeVersion(length - 1, data + 1, ¶m);
+ break;
+ /* integer */
+ case 0x03:
+ /* param = (unsigned char *)malloc((size_t)WSP_STANDARD_STR_LEN_MAX); */
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
+ return;
+ } else {
+ snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger(data + 1));
+ }
+ break;
+ case 0x08:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
+ return;
+ } else {
+ snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger(data + 1));
+ }
+ break;
+ case 0x05:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
+ return;
+ } else {
+ strncpy((char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
+ memcpy(param + 5, data + 1, length - 1);
+ param[5 + length - 1] = '\0';
+ }
+ break;
+ case 0x06:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
+ return;
+ } else {
+ strncpy((char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
+ memcpy(param + 9, (char*)(data + 1), (size_t)(length - 1));
+ param[9 + length - 1] = '\0';
+ }
+ break;
+ case 0x07:
+ param = NULL;
+ /* TBI */
+ break;
+ /*OMA Provisioning*/
+ case 0x11:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
+ return;
+ } else {
+ strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
+ SecurityTypeCode = data[1] & 0x7f;
+ while ((i < wspSecurityTypeCount) && (wspSecurityType[i].SecurityTypeCode != SecurityTypeCode)) i++;
+
+ if (i < wspSecurityTypeCount) {
+ strncat((char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ }
+
+ if (0x12 == (data[2] & 0x7f)) {
+ strncat((char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ memcpy(param+AcStrlen((char*)param), (char*)(data+3), (size_t)length-3);
+ }
+ }
+ break;
+ default:
+ param = NULL;
+ break;
+ }
+
+ *pParam = param;
+ return;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString)
+{
+ char* param = NULL;
+
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
+ *pDecodedString = NULL;
+ return;
+ }
+
+ strncpy((char*)param, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
+
+ if (data[0] > 0x80) {
+ unsigned long code = wspHeaderDecodeInteger(data);
+ unsigned long i = 0;
+ while (wspCharset[i].charsetCode != code) {
+ if (wspCharset[i].charsetCode == 0xffff) {
+ *pDecodedString = param;
+ return;
+ }
+ i++;
+ }
+ strncat((char*)param, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ } else {
+ unsigned long lastLen = AcStrlen((char*)param);
+ if (length + lastLen < WSP_STANDARD_STR_LEN_MAX - 1) {
+ memcpy((char*)(param + lastLen), data, (size_t)length);
+ param[length + lastLen] = '\0';
+ } else {
+ memcpy((char*)(param + lastLen), data, WSP_STANDARD_STR_LEN_MAX - lastLen - 1);
+ param[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
+ }
+ }
+
+ *pDecodedString = param;
+ return;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString)
+{
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
+ return;
+ }
+
+ if (length > 1) {
+ /* untyped version */
+ memcpy(*pDecodedString, data, (size_t)length);
+ } else {
+ /* typed version */
+ unsigned char majorVer = ((data[0] & 0x7f) >> 4);
+ unsigned char minorVer = data[0] & 0x0f;
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer);
+ }
+
+ return;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString)
+{
+ time_t lTime;
+ struct tm pTMData;
+
+ MSG_DEBUG("WspLHeaderDecodeDateValue: \n");
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeDateValue:MemAlloc failed\n");
+ return;
+ }
+
+ lTime = wspHeaderDecodeIntegerByLength(data, length);
+
+ (struct tm*)gmtime_r((const time_t*)&lTime, &pTMData);
+
+ /* check date value validity */
+ if ((pTMData.tm_wday > 6) || (pTMData.tm_mon > 11) || (pTMData.tm_mday > 31)) {
+ MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData.tm_wday, pTMData.tm_mon, pTMData.tm_mday);
+ strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
+ return;
+ }
+
+#ifdef MSG_FW_FOR_DEBUG
+ /** Date type selection */
+ switch (wspMachineStatus.dateType) {
+ /* UNIX asciitime function */
+ case UNIX_DATE_TYPE:
+ snprintf((char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
+ pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900);
+ break;
+ case RFC1123_DATE_TYPE:
+ snprintf((char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData.tm_wday], pTMData.tm_mday,
+ wspMonth[pTMData.tm_mon], pTMData.tm_year + 1900, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec);
+ break;
+ case RFC850_DATE_TYPE:
+ /* Have some Y2K Problems */
+ /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */
+ snprintf((char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData.tm_wday], pTMData.tm_mday,
+ wspMonth[pTMData.tm_mon], pTMData.tm_year % CENTURY, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec);
+
+ break;
+ }
+#endif
+ /**UNIX_DATE_TYPE : */
+ snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
+ pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900);
+
+ return;
+}
+
+void Sms3gppWapPushHandler::wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper)
+{
+ unsigned long elementLen = AcStrlen((char*)szDecodedString);
+ char* temper2 = NULL;
+
+ /** CR+LF */
+ *currentLen = *currentLen + elementLen + 2;
+
+ if (*currentLen > AcStrlen((char*)* pTemper) + 2) {
+ temper2 = new char[(*currentLen + 1)];
+
+ if (temper2 == NULL) {
+ MSG_DEBUG("WspLHeaderCopyDecodedString:MemAlloc failed\n");
+ return;
+ }
+ strncpy((char*)temper2, (char*)* pTemper, *currentLen);
+ delete[] *pTemper;
+ strncpy((char*)temper2, (char*)szDecodedString, *currentLen);
+ }
+
+ *pTemper = temper2;
+
+ return;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
+{
+ unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char passWd[WSP_STANDARD_STR_LEN_MAX];
+ unsigned long iField = 0;
+ char authStr[256];
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n");
+ return;
+ }
+
+ /* skip 'basic' code */
+ iField++;
+ memset(authStr, 0x00, sizeof(authStr));
+ snprintf(authStr, sizeof(authStr), "%%%zus", sizeof(userId));
+ sscanf((char*)(fieldValue + iField), authStr, userId);
+ iField = iField + AcStrlen((char*)userId) + 1;
+ memset(authStr, 0x00, sizeof(authStr));
+ snprintf(authStr, sizeof(authStr), "%%%zus", sizeof(passWd));
+ sscanf((char*)(fieldValue + iField), authStr, passWd);
+ iField = iField + AcStrlen((char*)userId) + 1;
+ int wrn = snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd);
+ if(wrn<0)
+ MSG_DEBUG("snprintf was failed\n");
+
+ return;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
+{
+ unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
+ unsigned long iField = 0;
+ char authStr[256];
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeChallenge:MemAlloc failed\n");
+ return;
+ }
+
+ /* skip 'basic' code */
+ iField++;
+ memset(authStr, 0x00, sizeof(authStr));
+ snprintf(authStr, sizeof(authStr), "%%%zus", sizeof(userId));
+ sscanf((char*)(fieldValue + iField), authStr, userId);
+ iField = iField + AcStrlen((char*)userId) + 1;
+
+ int wrn = snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "basic realm=\"%s\"", userId);
+ if(wrn<0)
+ MSG_DEBUG("snprintf was failed\n");
+
+ return;
+}
+
+
+void Sms3gppWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
+{
+ unsigned char paramString[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char cacheCode;
+ int wrn =0;
+
+ *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (*pCacheString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeCacheControl:MemAlloc failed\n");
+ return;
+ }
+
+ if (1 == fieldValueLen) {
+ /* only one directive */
+ if (fieldValue[0] > 0x8b) {
+ return; /* It's error detection. can be omitted. */
+ }
+ strncpy((char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
+ return;
+ }
+
+ if (fieldValue[0] > 0x7f) {
+ /* directive that has parameter */
+ cacheCode = fieldValue[0] & 0x7f;
+ switch (cacheCode) {
+ /* field name */
+ /* no-cache */
+ case 0x00 :
+ /* private */
+ case 0x07 :
+ if (fieldValue[1] > 0x7f) {
+ /* well known field name */
+ strncpy((char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
+ paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
+ } else {
+ /* unknown field name */
+ strncpy((char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
+ }
+ break;
+ /* secound */
+ /* max-age */
+ case 0x02 :
+ /* max- stale */
+ case 0x03 :
+ /* min-fresh */
+ case 0x04 :
+ snprintf((char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger(fieldValue + 1));
+ break;
+
+ default :
+ break;
+ }
+ wrn = snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString);
+ if(wrn<0)
+ MSG_DEBUG("snprintf was failed");
+ } else {
+ /* cache extentions */
+ /* In case of come directive of doesn't specified string style */
+
+ unsigned long stringLen;
+ char szString[32];
+ strncpy((char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
+ stringLen = AcStrlen((char*)*pCacheString);
+
+ if (stringLen + 1 < fieldValueLen) {
+ if (fieldValue[stringLen+ 1] > 0x7f) {
+ int untyped = (int)wspHeaderDecodeIntegerByLength(fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1));
+
+ snprintf(szString, sizeof(szString), "%d", untyped);
+ strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ strncat((char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ } else {
+ if (fieldValue[fieldValueLen] == 0) {
+ strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ strncat((char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ }
+ }
+ }
+ }
+
+ return;
+}
+
+void Sms3gppWapPushHandler::getDisplayName(MSG_SUB_TYPE_T subType, char* displayName)
+{
+ if (subType == MSG_WAP_SL_SMS || subType == MSG_WAP_SI_SMS)
+ snprintf(displayName, MAX_ADDRESS_VAL_LEN + 1, "Push message");
+ return;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_CBMSG_HANDLER_H
+#define SMS_3GPP_CBMSG_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <map>
+#include <vector>
+
+#include <tapi_common.h>
+#include <TelSms.h>
+#include <ITapiNetText.h>
+
+#include "MsgTextConvert.h"
+#include "Sms3gppTypes.h"
+
+using namespace std;
+
+
+/*==================================================================================================
+ VARIABLES
+==================================================================================================*/
+typedef map<unsigned char, SMS_3GPP_CBMSG_PAGE_S> Sms3gppCbPageMap;
+
+typedef struct _CB_PAGE_INFO_S {
+ unsigned char geoScope;
+ unsigned char updateNum;
+ unsigned short msgCode;
+ unsigned short msgId;
+ unsigned char totalPages;
+
+ unsigned char pageCnt;
+ unsigned int totalSize;
+ Sms3gppCbPageMap data;
+} SMS_3GPP_CB_PAGE_INFO_S;
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppCbMsgHandler
+{
+public:
+ static Sms3gppCbMsgHandler* instance();
+
+ void handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMsg);
+ void handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *pEtwsMsg);
+
+private:
+ Sms3gppCbMsgHandler();
+ virtual ~Sms3gppCbMsgHandler();
+
+ static Sms3gppCbMsgHandler* pInstance;
+
+ void Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_3GPP_CBMSG_PAGE_S *pCbPage);
+ void Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_3GPP_CBMSG_PAGE_S *pCbPage);
+ void DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_3GPP_ETWS_PRIMARY_S *pEtwsPn);
+ unsigned short encodeCbSerialNum(SMS_3GPP_CBMSG_SERIAL_NUM_S snFields);
+ int getCMASType(unsigned short message_id);
+
+ bool checkCbOpt(SMS_3GPP_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex);
+ unsigned char checkCbPage(SMS_3GPP_CBMSG_PAGE_S *CbPage);
+ void MakeCbMsg(SMS_3GPP_CBMSG_PAGE_S *CbPage, SMS_3GPP_CBMSG_S *pCbMsg);
+ void convertCbMsgToMsginfo(SMS_3GPP_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex);
+ void convertEtwsMsgToMsginfo(SMS_3GPP_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex);
+ int convertTextToUtf8(unsigned char* outBuf, int outBufSize, SMS_3GPP_CBMSG_S* pCbMsg);
+ void addToPageList(SMS_3GPP_CBMSG_PAGE_S *CbPage);
+ void removeFromPageList(SMS_3GPP_CBMSG_PAGE_S *CbPage);
+
+ void decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_3GPP_CBMSG_DCS_S* pDcs);
+ void convertLangType(SMS_3GPP_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType);
+ unsigned long getRecvTime();
+ void getDisplayName(unsigned short MsgId, char *pDisplayName, msg_sim_slot_id_t simIndex);
+
+ vector<SMS_3GPP_CB_PAGE_INFO_S> pageList;
+};
+
+#endif /* SMS_3GPP_CBMSG_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_CONCAT_HANDLER_H
+#define SMS_3GPP_CONCAT_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <string>
+#include <map>
+#include <vector>
+
+using namespace std;
+
+#include "MsgTextConvert.h"
+#include "Sms3gppTypes.h"
+
+
+/*==================================================================================================
+ VARIABLES AND DEFINES
+==================================================================================================*/
+#define MAX_CONCAT_LIST 10
+
+struct SMS_3GPP_CONCAT_DATA_S {
+ int length;
+ char data[MAX_USER_DATA_LEN+1];
+};
+
+typedef map<unsigned char, SMS_3GPP_CONCAT_DATA_S> Sms3gppConcatDataMap;
+
+typedef struct _SMS_3GPP_CONCAT_MSG_S {
+ unsigned short msgRef;
+ unsigned char totalSeg;
+ unsigned char seqNum;
+
+ SMS_3GPP_TIMESTAMP_S timeStamp;
+ SMS_3GPP_ADDRESS_S originAddress;
+ SMS_3GPP_DCS_S dcs;
+ bool bRead;
+ int simId;
+ int simIndex;
+} SMS_3GPP_CONCAT_MSG_S;
+
+typedef struct _SMS_3GPP_CONCAT_INFO_S {
+ unsigned short msgRef;
+ unsigned char totalSeg;
+ unsigned char segCnt;
+
+ SMS_3GPP_TIMESTAMP_S timeStamp;
+ SMS_3GPP_ADDRESS_S originAddress;
+ SMS_3GPP_DCS_S dcs;
+ bool bRead;
+
+ unsigned int totalSize;
+ Sms3gppConcatDataMap data;
+ int simIdList[MAX_SIM_SMS_NUM];
+ unsigned int display_time;
+ int simIndex;
+} SMS_3GPP_CONCAT_INFO_S;
+
+typedef struct _SMS_SIM_ID_S {
+ unsigned short msgRef;
+ msg_sim_id_t simId;
+} SMS_3GPP_SIM_ID_S;
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppConcatHandler
+{
+public:
+ static Sms3gppConcatHandler* instance();
+
+ bool IsConcatMsg(SMS_3GPP_USERDATA_S *pUserData);
+ void handleConcatMsg(TapiHandle *handle, SMS_3GPP_TPDU_S *pTpdu);
+ void handleSimConcatMsg(TapiHandle *handle, SMS_3GPP_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList);
+/* void handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead); */
+/* void handleBrokenMsg(); */
+
+private:
+ Sms3gppConcatHandler();
+ virtual ~Sms3gppConcatHandler();
+
+ static Sms3gppConcatHandler* pInstance;
+
+ unsigned char checkConcatMsg(SMS_3GPP_CONCAT_MSG_S *pConcatMsg, SMS_3GPP_USERDATA_S *pUserData);
+ int makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData, char *originAddress);
+
+ void convertConcatToMsginfo(const SMS_3GPP_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
+ void convertConcatToMsginfo(const SMS_3GPP_SUBMIT_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
+/* void convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pConcatMsg, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo); */
+
+ void removeFromConcatList(unsigned short MsgRef, int simIndex, char *originAddress);
+
+/* void addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId); */
+/* void removeFromSimIdList(unsigned short MsgRef); */
+
+ vector<SMS_3GPP_CONCAT_INFO_S> concatList;
+/* vector<SMS_3GPP_SIM_ID_S> simIdList; */
+};
+
+#endif /* SMS_3GPP_CONCAT_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_EVENT_HANDLER_H
+#define SMS_3GPP_EVENT_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <tapi_common.h>
+#include <TelSms.h>
+#include "MsgMutex.h"
+#include "MsgTextConvert.h"
+#include "MsgPluginInterface.h"
+#include "Sms3gppTypes.h"
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppEventHandler
+{
+public:
+ static Sms3gppEventHandler* instance();
+
+ void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
+ void handleSentStatus(msg_network_status_t NetStatus);
+ void handleMsgIncoming(TapiHandle *handle, SMS_3GPP_TPDU_S *pTpdu);
+ void handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, int simIndex);
+ void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
+ void handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *app_id, char *content_type);
+ void handleResendMessage(void);
+
+ msg_error_t callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo);
+ msg_error_t callbackCBMsgIncoming(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo);
+ msg_error_t callbackInitSimBySat();
+ msg_error_t callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
+ msg_error_t callbackThreadChange(msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId);
+ msg_error_t handleSimMsg(MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList, msg_message_id_t *retMsgId, int listSize);
+ msg_error_t updateIMSI(int sim_idx);
+ void handleSimMemoryFull(int simIndex);
+
+ void SetSentInfo(SMS_3GPP_SENT_INFO_S *pSentInfo);
+
+ void setDeviceStatus(TapiHandle *handle, bool status);
+ bool getDeviceStatus(TapiHandle *handle);
+
+ /* temp */
+ void convertTpduToMsginfo(SMS_3GPP_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+
+ MSG_SUB_TYPE_T convertMsgSubType(SMS_3GPP_PID_T pid);
+
+private:
+ Sms3gppEventHandler();
+ virtual ~Sms3gppEventHandler();
+
+ void convertSubmitTpduToMsginfo(const SMS_3GPP_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+ void convertDeliverTpduToMsginfo(const SMS_3GPP_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+ void convertStatusRepTpduToMsginfo(const SMS_3GPP_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
+
+ static Sms3gppEventHandler* pInstance;
+
+ MSG_PLUGIN_LISTENER_S listener;
+ MSG_3GPP_SIM_COUNT_S* pSimCnt;
+ SMS_3GPP_SENT_INFO_S sentInfo;
+
+ bool devStatus;
+ bool bUdhMwiMethod;
+ int udhMwiCnt;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+ TapiHandle *devHandle;
+};
+
+#endif /* SMS_3GPP_EVENT_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_PARAM_CODEC_H
+#define SMS_3GPP_PARAM_CODEC_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "Sms3gppTypes.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppParamCodec
+{
+public:
+ Sms3gppParamCodec();
+ virtual ~Sms3gppParamCodec();
+
+ static int encodeAddress(const SMS_3GPP_ADDRESS_S *pAddress, char **ppParam);
+ static int encodeTime(const SMS_3GPP_TIMESTAMP_S *pTimeStamp, char **ppParam);
+ static int encodeDCS(const SMS_3GPP_DCS_S *pDCS, char **ppParam);
+ static int encodeSMSC(const char *pAddress, unsigned char *pEncodeAddr);
+ static int encodeSMSC(const SMS_3GPP_ADDRESS_S *pAddress, unsigned char *pSMSC);
+
+ static int decodeAddress(const unsigned char *pTpdu, SMS_3GPP_ADDRESS_S *pAddress);
+ static int decodeTime(const unsigned char *pTpdu, SMS_3GPP_TIMESTAMP_S *pTimeStamp);
+ static int decodeDCS(const unsigned char *pTpdu, SMS_3GPP_DCS_S *pDCS);
+ static void decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_SMS_TON_T ton, char *pDecodeAddr);
+
+ static bool checkCphsVmiMsg(const unsigned char *pTpdu, int *setType, int *indType);
+
+ static time_t convertTime(const SMS_3GPP_TIMESTAMP_S *time_stamp);
+
+private:
+ static int convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd);
+ static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit);
+};
+
+#endif /* SMS_3GPP_PARAM_CODEC_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_SAT_HANDLER_H
+#define SMS_3GPP_SAT_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "Sms3gppTypes.h"
+#include "MsgMutex.h"
+
+extern "C"
+{
+ #include <TelSat.h>
+}
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppSatHandler
+{
+public:
+ static Sms3gppSatHandler* instance();
+
+ void refreshSms(TapiHandle *handle, void *pData);
+ void sendSms(TapiHandle *handle, void *pData);
+ void ctrlSms(TapiHandle *handle, void *pData);
+ void ctrlSms(TapiHandle *handle, SMS_NETWORK_STATUS_T netStatus);
+
+ void finishSimMsgInit(msg_error_t Err);
+
+private:
+ Sms3gppSatHandler();
+ virtual ~Sms3gppSatHandler();
+
+ void initSim();
+
+ void initSMSCList();
+ void initCBConfig();
+
+ int handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired);
+
+ void sendResult(TapiHandle *handle, SMS_3GPP_SAT_CMD_TYPE_T CmdType, int ResultType);
+
+ static Sms3gppSatHandler* pInstance;
+
+ int commandId;
+
+ bool bInitSim;
+ bool bSMSPChanged;
+ bool bCBMIChanged;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP_SAT_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_SETTING_H
+#define SMS_3GPP_SETTING_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgSettingTypes.h"
+#include <list>
+#include <map>
+
+extern "C"
+{
+ #include <tapi_common.h>
+}
+
+typedef map <int, MSG_SMSC_LIST_S> smscListMap;
+typedef map <int, SMS_3GPP_SIM_MAILBOX_LIST_S> smsSimMailboxListMap;
+typedef map <int, SMS_3GPP_SIM_MWI_INFO_S> simMwiInfoMap;
+typedef map <int, MSG_CBMSG_OPT_S> cbOptMap;
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppSetting
+{
+public:
+ static Sms3gppSetting* instance();
+
+ void setConfigData(const MSG_SETTING_S *pSetting);
+ void getConfigData(MSG_SETTING_S *pSetting);
+ void getMeImei(char *pImei);
+
+ void setParamCntEvent(int ParamCnt);
+ void setParamEvent(TapiHandle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess);
+ void setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
+ void setMailboxInfoEvent(TapiHandle *handle, SMS_3GPP_SIM_MAILBOX_LIST_S *pVoiceOpt, bool bSuccess, bool bMbdn);
+ void setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count);
+ void setMwiInfoEvent(TapiHandle *handle, SMS_3GPP_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess);
+ void setResultFromSim(bool bResult);
+ void setResultImei(bool bResult, char *pImei);
+
+ void setSmscInfo(const MSG_SMSC_LIST_S *pSmscList);
+
+ void setSimChangeStatus(TapiHandle *handle);
+ void getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList);
+
+ void initializeSimInfo(TapiHandle *handle);
+ void SimRefreshCb(TapiHandle *handle);
+
+private:
+ Sms3gppSetting();
+ ~Sms3gppSetting();
+
+ void updateSimStatus(TapiHandle *handle);
+ void initConfigData(TapiHandle *handle);
+ static void* init_config_data(void *data);
+ static void* initSimInfo(void *data);
+ void* processInitSimInfo(void *data);
+
+ void addSMSCList(MSG_SMSC_LIST_S *pSmscList);
+
+ msg_error_t addCbOpt(MSG_CBMSG_OPT_S *pCbOpt);
+ void getCbOpt(MSG_SETTING_S *pSetting, int simIndex);
+
+ void setParamList(const MSG_SMSC_LIST_S *pSMSCList);
+ void getParamList(MSG_SMSC_LIST_S *pSMSCList);
+
+ int getParamCount(TapiHandle *handle);
+ bool getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData);
+
+ bool setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt);
+ bool getCbConfig(MSG_CBMSG_OPT_S *pCbOpt);
+
+ void setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt);
+ bool getVoiceMailInfo(TapiHandle *handle);
+
+ bool getMwiInfo(TapiHandle *handle);
+ bool getMsisdnInfo(TapiHandle *handle);
+ bool getSimServiceTable(TapiHandle *handle);
+ bool getResultImei(char *pImei);
+
+ int getParamCntEvent();
+ bool getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData);
+ bool getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt);
+
+ bool getMailboxInfoEvent();
+
+ bool getResultFromSim();
+
+ SMS_3GPP_PID_T convertPid(MSG_SMS_PID_T pid);
+ void deliverVoiceMsgNoti(int simIndex, int mwiCnt);
+
+ static Sms3gppSetting* pInstance;
+ std::list<TapiHandle *> tel_handle_list;
+
+ /* Setting values for keeping in setting instance */
+ smscListMap smscList;
+ MSG_SIM_STATUS_T simStatus[MAX_TELEPHONY_HANDLE_CNT+1];
+ MSG_SMSC_DATA_S smscData[MAX_TELEPHONY_HANDLE_CNT+1];
+ smsSimMailboxListMap simMailboxList;
+ simMwiInfoMap simMwiInfo;
+ cbOptMap cbOpt;
+
+ /* Local values for getting from SIM(TAPI) */
+ bool bTapiResult;
+ int paramCnt;
+ int selectedParam;
+ int selectedSimIndex;
+ char meImei[MAX_ME_IMEI_LEN + 1];
+
+ bool bMbdnEnable[MAX_TELEPHONY_HANDLE_CNT+1];
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP_SETTING_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_SIM_MSG_H
+#define SMS_3GPP_SIM_MSG_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+
+#include "MsgStorageTypes.h"
+#include "Sms3gppTypes.h"
+#include "MsgInternalTypes.h"
+
+extern "C"
+{
+ #include <tapi_common.h>
+ #include <TelSms.h>
+ #include <TapiUtility.h>
+ #include <ITapiNetText.h>
+}
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppSimMsg
+{
+public:
+ static Sms3gppSimMsg* instance();
+
+ void initSimMessage(struct tapi_handle *handle);
+ msg_error_t saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
+ msg_error_t saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo);
+ void deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
+ void setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
+ bool checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int SegCnt);
+
+ void setSimMsgCntEvent(struct tapi_handle *handle, const MSG_3GPP_SIM_COUNT_S *pSimMsgCnt);
+ void setSimMsgEvent(struct tapi_handle *handle, const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess);
+ void setSaveSimMsgEvent(struct tapi_handle *handle, int simId, int result);
+ void setSaveClass2MsgEvent(struct tapi_handle *handle, int simId, int result, MSG_MESSAGE_INFO_S *data);
+ void setSimEvent(msg_sim_id_t SimId, bool bResult);
+ void setUpdateSimEvent(int SimId, bool bResult);
+ void setDelSimEvent(int SimId, bool bResult);
+
+ void setSmsData(const char *sca, const char *szData, int msgLength);
+ void setSmsTpduTotalSegCount(int totalSeg);
+
+private:
+ Sms3gppSimMsg();
+ ~Sms3gppSimMsg();
+
+ void getSimMsgCount(struct tapi_handle *handle, MSG_3GPP_SIM_COUNT_S *pSimMsgCnt);
+ bool getSimMsg(struct tapi_handle *handle, msg_sim_id_t SimMsgId, MSG_MESSAGE_INFO_S* pMsgInfo, int *simIdList);
+
+ void setSmsOptions(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_3GPP_DELIVER_S *pDeliver);
+ void convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_3GPP_DELIVER_S *pDeliver);
+
+ bool getSimMsgCntEvent(struct tapi_handle *handle, MSG_3GPP_SIM_COUNT_S *pSimMsgCnt);
+ bool getSimMsgEvent(struct tapi_handle *handle, MSG_MESSAGE_INFO_S *pMsgInfo);
+ bool getSimEvent(msg_sim_id_t *pSimId);
+ bool getUpdateSimEvent();
+ bool getDelSimEvent(int *pSimId);
+
+
+ static Sms3gppSimMsg* pInstance;
+
+ msg_sim_id_t simMsgId;
+ int delSimMsgId;
+ int simIdList[MAX_SIM_SMS_NUM]; /** send total simIds to handleSimMsg **/
+
+ MSG_3GPP_SIM_COUNT_S simMsgCnt;
+
+ MSG_MESSAGE_INFO_S simMsgInfo;
+ MSG_ADDRESS_INFO_S simAddrInfo;
+
+ int usedCnt;
+ int totalCnt;
+
+ bool bTapiResult;
+
+ SMS_3GPP_DATA_INFO_S simMsgDataInfo;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP_SIM_MSG_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_STORAGE_H
+#define SMS_3GPP_STORAGE_H
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgStorageTypes.h"
+#include "MsgInternalTypes.h"
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppStorage
+{
+public:
+ static Sms3gppStorage* instance();
+
+ msg_error_t insertMsgRef(MSG_MESSAGE_INFO_S *pMsg, unsigned char msgRef, int index);
+ msg_error_t updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInfo, unsigned char msgRef);
+ msg_error_t addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo, int *simIdList);
+ msg_error_t insertSimMessage(int simId, int msgId);
+ msg_error_t deleteSimMessage(int sim_idx, int simId);
+ msg_error_t getReplaceSimMsg(const MSG_MESSAGE_INFO_S *pMsg, int *pMsgId, int *pSimId);
+
+ msg_error_t addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo);
+ msg_error_t updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+private:
+ Sms3gppStorage();
+ ~Sms3gppStorage() = default;
+
+ static void* class2_thread(void *data);
+
+ static Sms3gppStorage* pInstance;
+
+ MSG_MESSAGE_INFO_S msgInfo;
+ MSG_ADDRESS_INFO_S addrInfo;
+};
+
+#endif /* SMS_3GPP_STORAGE_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_TAPI_EVENT_HANDLER_H
+#define SMS_3GPP_TAPI_EVENT_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <map>
+#include <vector>
+#include <tapi_common.h>
+#include <TelSms.h>
+#include <TelSim.h>
+#include <TapiUtility.h>
+#include <ITapiNetText.h>
+#include <ITapiNetwork.h>
+
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+class Sms3gppTapiEventHandler
+{
+public:
+ static void NotiSmsDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSmsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSmsCbIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSmsEtwsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSimStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiNetworkRegistrationType(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSatMoSmControlResult(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSmsMemoryStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+
+ static void respSentStatus(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSatSmsSentStatus(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respSetConfigData(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respSetSmscInfo(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSetMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respGetParamCnt(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetParam(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data);
+
+ static void respGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetSimServiceTable(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetMeImei(TapiHandle *handle, int result, void *data, void *user_data);
+
+};
+
+#endif /* SMS_3GPP_TAPI_EVENT_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_TPDU_CODEC_H
+#define SMS_3GPP_TPDU_CODEC_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <tapi_common.h>
+#include "Sms3gppTypes.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppTpduCodec
+{
+public:
+ Sms3gppTpduCodec();
+ virtual ~Sms3gppTpduCodec();
+
+ static int encodeTpdu(const SMS_3GPP_TPDU_S *pSmsTpdu, char *pTpdu);
+ /* TODO: Need to remove TapiHandle on this function */
+ static int decodeTpdu(TapiHandle *handle, const unsigned char *pTpdu, int TpduLen, SMS_3GPP_TPDU_S *pSmsTpdu);
+
+private:
+ static int encodeSubmit(const SMS_3GPP_SUBMIT_S *pSubmit, char *pTpdu);
+ static int encodeDeliver(const SMS_3GPP_DELIVER_S *pDeliver, char *pTpdu);
+ static int encodeDeliverReport(const SMS_3GPP_DELIVER_REPORT_S *pDeliverRep, char *pTpdu);
+ static int encodeStatusReport(const SMS_3GPP_STATUS_REPORT_S *pStatusRep, char *pTpdu);
+
+ static int decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_3GPP_SUBMIT_S *pSubmit);
+ static int decodeDeliver(TapiHandle *handle, const unsigned char *pTpdu, int TpduLen, SMS_3GPP_DELIVER_S *pDeliver);
+ static int decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_3GPP_STATUS_REPORT_S *pStatusRep);
+};
+
+#endif /* SMS_3GPP_TPDU_CODEC_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_TRANSPORT_H
+#define SMS_3GPP_TRANSPORT_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgTextConvert.h"
+#include "MsgTransportTypes.h"
+#include "MsgSettingTypes.h"
+#include "Sms3gppTypes.h"
+#include "MsgInternalTypes.h"
+
+extern "C"
+{
+ #include <TelSat.h>
+}
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+msg_error_t Sms3gppSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo);
+
+class Sms3gppTransport
+{
+public:
+ static Sms3gppTransport* instance();
+
+ void submitRequest(SMS_3GPP_REQUEST_INFO_S *pReqInfo);
+ void sendDeliverReport(struct tapi_handle *handle, msg_error_t err);
+ void sendClass0DeliverReport(struct tapi_handle *handle, msg_error_t err);
+
+ void setSmscOptions(int simIndex, SMS_3GPP_ADDRESS_S *pSmsc);
+
+ void msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_3GPP_SUBMIT_DATA_S *pData, SMS_3GPP_CODING_SCHEME_T *pCharType, int addrIndex);
+ void setConcatHeader(SMS_3GPP_UDH_S *pSrcHeader, SMS_3GPP_UDH_S *pDstHeader);
+
+ void setNetStatus(SMS_NETWORK_STATUS_T sentStatus);
+ SMS_NETWORK_STATUS_T getNetStatus();
+
+ void setMoCtrlStatus(TelSatMoSmCtrlIndData_t *moCtrlData);
+ int getMoCtrlStatus();
+
+ unsigned char getMsgRef();
+ void setIsMemAvailable(bool isAvailable);
+
+private:
+ Sms3gppTransport();
+ ~Sms3gppTransport();
+
+ void getSmsSendOption(int simIndex, SMS_3GPP_SUBMIT_S *pSubmit);
+ void setSmsSendOption(SMS_3GPP_REQUEST_INFO_S *pReqInfo, SMS_3GPP_TPDU_S* pSmsTpdu);
+ void setSmsDcsOption(SMS_3GPP_REQUEST_INFO_S *pReqInfo, SMS_3GPP_TPDU_S* pSmsTpdu);
+ void setSmsReportOption(SMS_3GPP_REQUEST_INFO_S *pReqInfo, SMS_3GPP_TPDU_S* pSmsTpdu);
+
+ int getSegmentSize(SMS_3GPP_CODING_SCHEME_T CodingScheme, int DataLen, bool bPortNum, MSG_LANGUAGE_ID_T LangId, int ReplyAddrLen);
+ SMS_3GPP_PID_T convertPid(MSG_SMS_PID_T pid);
+
+ static Sms3gppTransport* pInstance;
+
+ bool isMemAvailable;
+ unsigned char msgRef;
+ unsigned char msgRef8bit;
+ unsigned short msgRef16bit;
+
+ SMS_NETWORK_STATUS_T curStatus;
+ TelSatMoSmCtrlIndData_t curMoCtrlData;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP_TRANSPORT_H */
+
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_TYPES_H
+#define SMS_3GPP_TYPES_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgTextConvert.h"
+#include "MsgInternalTypes.h"
+#include "MsgStorageTypes.h"
+#include "MsgSettingTypes.h"
+#include "SmsPluginTypes.h"
+
+
+/*==================================================================================================
+ DEFINES
+==================================================================================================*/
+#define MAX_ADDRESS_LEN 21 /* including '+' */
+#define MAX_USER_DATA_LEN 160
+#define MAX_GSM_7BIT_DATA_LEN 160
+#define MAX_UCS2_DATA_LEN 140
+/* #define MAX_TPDU_DATA_LEN 165 */
+#define MAX_TPDU_DATA_LEN 255
+#define MAX_SMS_SEND_RETRY 4
+#define MAX_SMSC_LEN 20
+#define MAX_ADD_PARAM_LEN 12
+#define MAX_DCS_PARAM_LEN 1
+#define MAX_ABS_TIME_PARAM_LEN 7
+#define MAX_REL_TIME_PARAM_LEN 1
+#define MAX_UD_HEADER_NUM 7
+#define MAX_SAT_TPDU_LEN 175
+#define MAX_CBMSG_PAGE_SIZE 82
+#define MAX_CBMSG_TOTAL_PAGE_SIZE 1252 /* 6 + 1 + (MAX_CBMSG_PAGE_SIZE + 1) * MAX_CBMSG_PAGE_NUM = 1252 */
+#define MAX_ETWS_SIZE 56
+#define MAX_CBMSG_PAGE_NUM 15
+#define MAX_SIM_SMS_NUM 255
+#define MAX_SIM_IMSI_NUM 20
+#define MAX_SIM_MSP_CNT 2
+
+#define SMS_PUSH_XML_HREF_TAG "href"
+#define SMS_PUSH_XML_SI_ID_TAG "si-id"
+#define SMS_PUSH_XML_CREATED_TAG "created"
+#define SMS_PUSH_XML_EXPIRES_TAG "si-expires"
+#define SMS_PUSH_XML_ACTION_TAG "action"
+
+#define SMS_PUSH_XML_INVAL_OBJ "invalidate-object"
+#define SMS_PUSH_XML_INVAL_SVC "invalidate-service"
+#define SMS_PUSH_XML_CO_URI "uri"
+
+
+/*==================================================================================================
+ TYPES
+==================================================================================================*/
+
+typedef unsigned char SMS_3GPP_TPDU_TYPE_T; /* _SMS_3GPP_TPDU_TYPE_E */
+
+typedef unsigned char SMS_3GPP_VPF_T; /* _SMS_3GPP_VPF_E */
+
+typedef unsigned char SMS_3GPP_TON_T; /* _SMS_3GPP_TON_E */
+
+typedef unsigned char SMS_3GPP_NPI_T; /* _SMS_3GPP_NPI_E */
+
+typedef unsigned char SMS_3GPP_PID_T; /* _SMS_3GPP_PID_E */
+
+typedef unsigned char SMS_3GPP_MSG_CLASS_T; /* _SMS_3GPP_MSG_CLASS_E */
+
+typedef unsigned char SMS_3GPP_CODING_SCHEME_T; /* _SMS_3GPP_CODING_SCHEME_E */
+
+typedef unsigned char SMS_3GPP_CODING_GROUP_T; /* _SMS_3GPP_CODING_GROUP_E */
+
+typedef unsigned char SMS_3GPP_INDICATOR_TYPE_T; /* _SMS_3GPP_INDICATOR_TYPE_E */
+
+typedef unsigned char SMS_3GPP_TIME_FORMAT_T; /* _SMS_3GPP_TIME_FORMAT_E */
+
+typedef unsigned char SMS_3GPP_FAIL_CAUSE_T; /* _SMS_3GPP_FAIL_CAUSE_E */
+
+typedef unsigned char SMS_3GPP_STATUS_T; /* _SMS_3GPP_STATUS_E */
+
+typedef unsigned char SMS_3GPP_REF_NUMBER_T; /* _SMS_3GPP_REF_NUMBER_E */
+
+typedef unsigned char SMS_3GPP_REPORT_TYPE_T; /* _SMS_3GPP_REPORT_TYPE_E */
+
+typedef unsigned char SMS_3GPP_UDH_TYPE_T; /* _SMS_3GPP_UDH_TYPE_E */
+
+typedef unsigned char SMS_3GPP_CB_NETWORK_TYPE_T; /* _SMS_3GPP_CB_NETWORK_TYPE_E */
+
+typedef unsigned char SMS_3GPP_CBMSG_TYPE_T; /* _SMS_3GPP_CBMSG_TYPE_E */
+
+typedef unsigned char SMS_3GPP_CBMSG_LANG_TYPE_T; /* _SMS_3GPP_CBMSG_LANG_TYPE_E */
+
+typedef unsigned char SMS_3GPP_CBMSG_CODING_GROUP_T; /* _SMS_3GPP_CBMSG_CODING_GROUP_E */
+
+typedef unsigned char SMS_3GPP_SAT_CMD_TYPE_T; /* _SMS_3GPP_SAT_CMD_TYPE_E */
+
+typedef unsigned short SMS_3GPP_SIM_EFILE_NAME_T; /* _SMS_3GPP_SIM_EFILE_NAME_E */
+
+typedef unsigned char SMS_3GPP_SIM_MAILBOX_TYPE_T; /* _SMS_3GPP_SIM_MAILBOX_TYPE_E */
+
+/*==================================================================================================
+ ENUMS
+==================================================================================================*/
+enum _SMS_3GPP_TPDU_TYPE_E {
+ SMS_TPDU_SUBMIT,
+ SMS_TPDU_DELIVER,
+ SMS_TPDU_DELIVER_REP,
+ SMS_TPDU_STATUS_REP,
+};
+
+
+enum _SMS_3GPP_VPF_E {
+ SMS_VPF_NOT_PRESENT = 0,
+ SMS_VPF_ENHANCED,
+ SMS_VPF_RELATIVE,
+ SMS_VPF_ABSOLUTE,
+};
+
+
+enum _SMS_3GPP_TON_E
+{
+ SMS_TON_UNKNOWN = 0, /* unknown */
+ SMS_TON_INTERNATIONAL, /* international */
+ SMS_TON_NATIONAL, /* national */
+ SMS_TON_NETWORK, /* network */
+ SMS_TON_SUBSCRIBER, /* subscriber */
+ SMS_TON_ALPHANUMERIC, /* alpha numberic */
+ SMS_TON_ABBREVIATED, /* abbreviated */
+ SMS_TON_RESERVE, /* reserve */
+};
+
+
+enum _SMS_3GPP_NPI_E {
+ SMS_3GPP_NPI_UNKNOWN = 0, /* unknown */
+ SMS_3GPP_NPI_ISDN = 1, /* idsn */
+ SMS_3GPP_NPI_DATA = 3, /* data */
+ SMS_3GPP_NPI_TELEX = 4, /* telex */
+ SMS_3GPP_NPI_SMSC = 5, /* smsc */
+ SMS_3GPP_NPI_NATIONAL = 8, /* national */
+ SMS_3GPP_NPI_PRIVATE = 9, /* private */
+ SMS_3GPP_NPI_ERMES = 10, /* ermes */
+};
+
+
+enum _SMS_3GPP_PID_E {
+ SMS_PID_NORMAL = 0x00,
+
+ SMS_PID_TELEX = 0x21,
+ SMS_PID_GROUP3_TELEX = 0x22,
+ SMS_PID_GROUP4_TELEX = 0x23,
+ SMS_PID_VOICE = 0x24,
+ SMS_PID_ERMES = 0x25,
+ SMS_PID_NPS = 0x26,
+ SMS_PID_VIDEO = 0x27,
+ SMS_PID_TELETEX_UNSPEC = 0x28,
+ SMS_PID_TELETEX_PSPDN = 0x29,
+ SMS_PID_TELETEX_CSPDN = 0x2A,
+ SMS_PID_TELETEX_PSTN = 0x2B,
+ SMS_PID_TELETEX_ISDN = 0x2C,
+ SMS_PID_UCI = 0x2D,
+ SMS_PID_x400 = 0x31,
+ SMS_PID_EMAIL = 0x32,
+
+ SMS_PID_TYPE0 = 0x40,
+ SMS_PID_REPLACE_TYPE1 = 0x41,
+ SMS_PID_REPLACE_TYPE2 = 0x42,
+ SMS_PID_REPLACE_TYPE3 = 0x43,
+ SMS_PID_REPLACE_TYPE4 = 0x44,
+ SMS_PID_REPLACE_TYPE5 = 0x45,
+ SMS_PID_REPLACE_TYPE6 = 0x46,
+ SMS_PID_REPLACE_TYPE7 = 0x47,
+
+ SMS_PID_RETURN_CALL = 0x5F,
+};
+
+
+enum _SMS_3GPP_MSG_CLASS_E {
+ SMS_MSG_CLASS_0 = 0,
+ SMS_MSG_CLASS_1,
+ SMS_MSG_CLASS_2,
+ SMS_MSG_CLASS_3,
+ SMS_MSG_CLASS_NONE,
+};
+
+
+enum _SMS_3GPP_CODING_SCHEME_E {
+ SMS_CHARSET_7BIT = 0,
+ SMS_CHARSET_8BIT,
+ SMS_CHARSET_UCS2,
+ SMS_CHARSET_AUTO,
+ SMS_CHARSET_EUCKR,
+};
+
+
+enum _SMS_3GPP_CODING_GROUP_E {
+ SMS_GROUP_GENERAL = 0,
+ SMS_GROUP_CODING_CLASS,
+ SMS_GROUP_DELETION,
+ SMS_GROUP_DISCARD,
+ SMS_GROUP_STORE,
+ SMS_GROUP_UNKNOWN,
+};
+
+
+enum _SMS_3GPP_INDICATOR_TYPE_E {
+ SMS_VOICE_INDICATOR = 0,
+ SMS_VOICE2_INDICATOR, /* Only for CPSH */
+ SMS_FAX_INDICATOR,
+ SMS_EMAIL_INDICATOR,
+ SMS_OTHER_INDICATOR,
+};
+
+
+enum _SMS_3GPP_TIME_FORMAT_E {
+ SMS_3GPP_TIME_RELATIVE = 0,
+ SMS_3GPP_TIME_ABSOLUTE
+};
+
+
+enum _SMS_3GPP_FAIL_CAUSE_E {
+ SMS_FC_MSG_TYPE0_NOT_SUPPORTED = 0x81,
+ SMS_FC_SM_CANNOT_BE_REPLACED = 0x82,
+ SMS_FC_UNSPEC_PID_ERROR = 0x8F,
+ SMS_FC_MSG_CLASS_NOT_SUPPORTED = 0x91,
+ SMS_FC_UNSPEC_DCS_ERROR = 0x9F,
+ SMS_FC_TPDU_NOT_SUPPORTED = 0xB0,
+ SMS_FC_SIM_STORAGE_FULL = 0xD0,
+ SMS_FC_NO_STORAGE_IN_SIM = 0xD1,
+ SMS_FC_ERROR_IN_MS = 0xD2,
+ SMS_FC_MSG_CAPA_EXCEEDED = 0xD3,
+ SMS_FC_SAT_BUSY = 0xD4,
+ SMS_FC_SIM_DOWNLOAD_ERROR = 0xD5,
+ SMS_FC_UNSPEC_ERROR = 0xFF,
+};
+
+
+enum _SMS_3GPP_STATUS_E {
+ SMS_STATUS_RECEIVE_SUCCESS = 0x00,
+ SMS_STATUS_UNABLE_TO_CONFIRM_DELIVER = 0x01,
+ SMS_STATUS_REPLACED = 0x02,
+ SMS_STATUS_SMSC_SPECIFIC_LAST = 0x1F,
+
+ SMS_STATUS_TRY_CONGESTION = 0x20,
+ SMS_STATUS_TRY_SME_BUSY = 0x21,
+ SMS_STATUS_TRY_NO_RESPONSE = 0x22,
+ SMS_STATUS_TRY_SERVICE_REJECTED = 0x23,
+ SMS_STATUS_TRY_QOS_NOT_AVAILABLE = 0x24,
+ SMS_STATUS_TRY_REQUEST_PENDING = 0x30,
+
+ SMS_STATUS_PERM_REMOTE_ERROR = 0x40,
+ SMS_STATUS_PERM_IMCOMPATIBLE_DEST = 0x41,
+ SMS_STATUS_PERM_CONNECTION_REJECTED = 0x42,
+ SMS_STATUS_PERM_NOT_OBTAINABLE = 0x43,
+ SMS_STATUS_PERM_QOS_NOT_AVAILABLE = 0x44,
+ SMS_STATUS_PERM_NO_INTERWORK_AVAILABLE = 0x45,
+ SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED = 0x46,
+ SMS_STATUS_PERM_MSG_DEL_BY_ORIGIN_SME = 0x47,
+ SMS_STATUS_PERM_MSG_DEL_BY_SMSC_ADMIN = 0x48,
+ SMS_STATUS_PERM_MSG_NOT_EXIST = 0x49,
+
+ SMS_STATUS_TEMP_CONGESTION = 0x60,
+ SMS_STATUS_TEMP_SME_BUSY = 0x61,
+ SMS_STATUS_TEMP_NO_RESPONSE = 0x62,
+ SMS_STATUS_TEMP_SERVICE_REJECTED = 0x63,
+ SMS_STATUS_TEMP_QOS_NOT_AVAILABLE = 0x64,
+ SMS_STATUS_TEMP_ERROR_IN_SME = 0x65,
+};
+
+
+enum _SMS_3GPP_REF_NUMBER_E {
+ SMS_REF_NUM_8BIT = 0,
+ SMS_REF_NUM_16BIT
+};
+
+
+enum _SMS_3GPP_REPORT_TYPE_E {
+ SMS_REPORT_POSITIVE = 0,
+ SMS_REPORT_NEGATIVE
+};
+
+
+enum _SMS_3GPP_UDH_TYPE_E {
+ SMS_UDH_CONCAT_8BIT = 0x00,
+ SMS_UDH_SPECIAL_SMS = 0x01,
+ /* 0x02, 0x03 - Reserved */
+ SMS_UDH_APP_PORT_8BIT = 0x04,
+ SMS_UDH_APP_PORT_16BIT = 0x05,
+ SMS_UDH_SC_CONTROL = 0x06,
+ SMS_UDH_SRC_IND = 0x07,
+ SMS_UDH_CONCAT_16BIT = 0x08,
+ SMS_UDH_WCMP = 0x09,
+ SMS_UDH_EMS_FIRST = 0x0a,
+ SMS_UDH_EMS_LAST = 0x1f,
+ SMS_UDH_ALTERNATE_REPLY_ADDRESS = 0x22,
+ SMS_UDH_SINGLE_SHIFT = 0x24,
+ SMS_UDH_LOCKING_SHIFT = 0x25,
+ SMS_UDH_NONE = 0xFF,
+};
+
+
+enum _SMS_3GPP_CB_NETWORK_TYPE_E {
+ SMS_CB_NETWORK_TYPE_2G_GSM = 1,
+ SMS_CB_NETWORK_TYPE_3G_UMTS,
+};
+
+
+enum _SMS_3GPP_CBMSG_TYPE_E {
+ SMS_CBMSG_TYPE_CBS = 1, /**< CBS */
+ SMS_CBMSG_TYPE_SCHEDULE, /**< Schedule */
+ SMS_CBMSG_TYPE_CBS41, /**< CBS41 */
+ SMS_CBMSG_TYPE_JAVACBS, /**< JAVA-CB Message*/
+ SMS_CBMSG_TYPE_ETWS,
+};
+
+
+enum _SMS_3GPP_CBMSG_LANG_TYPE_E {
+ SMS_CBMSG_LANG_GERMAN = 0x00,
+ SMS_CBMSG_LANG_ENGLISH = 0x01,
+ SMS_CBMSG_LANG_ITALIAN = 0x02,
+ SMS_CBMSG_LANG_FRENCH = 0x03,
+ SMS_CBMSG_LANG_SPANISH = 0x04,
+ SMS_CBMSG_LANG_DUTCH = 0x05,
+ SMS_CBMSG_LANG_SWEDISH = 0x06,
+ SMS_CBMSG_LANG_DANISH = 0x07,
+ SMS_CBMSG_LANG_PORTUGUESE = 0x08,
+ SMS_CBMSG_LANG_FINNISH = 0x09,
+ SMS_CBMSG_LANG_NORWEGIAN = 0x0a,
+ SMS_CBMSG_LANG_GREEK = 0x0b,
+ SMS_CBMSG_LANG_TURKISH = 0x0c,
+ SMS_CBMSG_LANG_HUNGARIAN = 0x0d,
+ SMS_CBMSG_LANG_POLISH = 0x0e,
+ SMS_CBMSG_LANG_UNSPECIFIED = 0x0f,
+
+ SMS_CBMSG_LANG_ISO639 = 0x10,
+
+ SMS_CBMSG_LANG_CZECH = 0x20,
+ SMS_CBMSG_LANG_HEBREW = 0x21,
+ SMS_CBMSG_LANG_ARABIC = 0x22,
+ SMS_CBMSG_LANG_RUSSIAN = 0x23,
+ SMS_CBMSG_LANG_ICELANDIC = 0x24,
+ SMS_CBMSG_LANG_RESERVED_25 = 0x25,
+ SMS_CBMSG_LANG_RESERVED_26 = 0x26,
+ SMS_CBMSG_LANG_RESERVED_27 = 0x27,
+ SMS_CBMSG_LANG_RESERVED_28 = 0x28,
+ SMS_CBMSG_LANG_RESERVED_29 = 0x29,
+ SMS_CBMSG_LANG_RESERVED_2A = 0x2a,
+ SMS_CBMSG_LANG_RESERVED_2B = 0x2b,
+ SMS_CBMSG_LANG_RESERVED_2C = 0x2c,
+ SMS_CBMSG_LANG_RESERVED_2D = 0x2d,
+ SMS_CBMSG_LANG_RESERVED_2E = 0x2e,
+ SMS_CBMSG_LANG_RESERVED_2F = 0x2f,
+
+ SMS_CBMSG_LANG_DUMMY = 0xFF
+};
+
+
+enum _SMS_3GPP_CBMSG_CODING_GROUP_E {
+ SMS_CBMSG_CODGRP_GENERAL_DCS, /**< Bits 7..4 00xx */
+ SMS_CBMSG_CODGRP_WAP, /**< 1110 Cell Broadcast */
+ SMS_CBMSG_CODGRP_CLASS_CODING, /**< 1111 Cell Broadcast */
+};
+
+
+enum _SMS_3GPP_SAT_CMD_TYPE_E {
+ SMS_SAT_CMD_REFRESH,
+ SMS_SAT_CMD_SEND_SMS,
+ SMS_SAT_CMD_SMS_CTRL,
+};
+
+
+enum _SMS_3GPP_SIM_EFILE_NAME_E {
+ SMS_SIM_EFILE_USIM_SMS = 0x6A3C, /** < USIM Short Messages file */
+ SMS_SIM_EFILE_USIM_SMSP = 0x6A42, /** < USIM SMS parameter */
+ SMS_SIM_EFILE_USIM_SMSS = 0x6A43, /** < USIM SMS status */
+ SMS_SIM_EFILE_USIM_CBMI = 0x6A45, /** < USIM Cell Broadcast Message Identifier */
+ SMS_SIM_EFILE_USIM_MBDN = 0x6FC7, /** < USIM Mail Box Dialing Number */
+ SMS_SIM_EFILE_SMS = 0x6F3C, /** < Short Messages file */
+ SMS_SIM_EFILE_SMSP = 0x6F42, /** < SMS Parameter */
+ SMS_SIM_EFILE_SMSS = 0x6F43, /** < SMS Status */
+ SMS_SIM_EFILE_CBMI = 0x6F45, /** < Cell Broadcast Message Identifier */
+ SMS_SIM_EFILE_MBDN = 0x6FC7, /** < Mail Box Dialing Number */
+};
+
+
+enum _SMS_3GPP_SIM_MAILBOX_TYPE_E {
+ SMS_SIM_MAILBOX_VOICE = 0x01,
+ SMS_SIM_MAILBOX_VOICE2 = 0x02,
+ SMS_SIM_MAILBOX_FAX = 0x03,
+ SMS_SIM_MAILBOX_DATA = 0x04,
+ SMS_SIM_MAILBOX_EMAIL = 0x05,
+ SMS_SIM_MAILBOX_OTHER = 0x06,
+};
+
+
+/*==================================================================================================
+ STRUCTURES
+==================================================================================================*/
+typedef struct _SMS_3GPP_ADDRESS_S {
+ SMS_3GPP_TON_T ton;
+ SMS_3GPP_NPI_T npi;
+ char address[MAX_ADDRESS_LEN+1]; /* < null terminated string */
+} SMS_3GPP_ADDRESS_S;
+
+
+typedef struct _SMS_3GPP_DCS_S {
+ bool bCompressed;
+ bool bMWI;
+ bool bIndActive;
+ SMS_3GPP_MSG_CLASS_T msgClass;
+ SMS_3GPP_CODING_SCHEME_T codingScheme;
+ SMS_3GPP_CODING_GROUP_T codingGroup;
+ SMS_3GPP_INDICATOR_TYPE_T indType;
+} SMS_3GPP_DCS_S;
+
+
+typedef struct _SMS_TIME_REL_S {
+ unsigned char time;
+} SMS_3GPP_TIME_REL_S;
+
+
+typedef struct _SMS_TIME_ABS_S {
+ unsigned char year;
+ unsigned char month;
+ unsigned char day;
+ unsigned char hour;
+ unsigned char minute;
+ unsigned char second;
+ int timeZone;
+} SMS_3GPP_TIME_ABS_S;
+
+
+typedef struct _SMS_TIMESTAMP_S {
+ SMS_3GPP_TIME_FORMAT_T format;
+
+ union {
+ SMS_3GPP_TIME_REL_S relative;
+ SMS_3GPP_TIME_ABS_S absolute;
+ } time;
+} SMS_3GPP_TIMESTAMP_S;
+
+
+typedef struct _SMS_CONCAT_8BIT_S {
+ unsigned char msgRef;
+ unsigned char totalSeg;
+ unsigned char seqNum;
+} SMS_3GPP_CONCAT_8BIT_S;
+
+
+typedef struct _SMS_CONCAT_16BIT_S {
+ unsigned short msgRef;
+ unsigned char totalSeg;
+ unsigned char seqNum;
+} SMS_3GPP_CONCAT_16BIT_S;
+
+
+typedef struct _SMS_APP_PORT_8BIT_S {
+ unsigned char destPort;
+ unsigned char originPort;
+} SMS_3GPP_APP_PORT_8BIT_S;
+
+
+typedef struct _SMS_APP_PORT_16BIT_S {
+ unsigned short destPort;
+ unsigned short originPort;
+} SMS_3GPP_APP_PORT_16BIT_S;
+
+
+typedef struct _SMS_SPECIAL_INDICATION_S {
+ bool bStore;
+ unsigned short msgInd;
+ unsigned short waitMsgNum;
+} SMS_3GPP_SPECIAL_INDICATION_S;
+
+
+typedef struct _SMS_UDH_S {
+ SMS_3GPP_UDH_TYPE_T udhType;
+
+ union {
+ SMS_3GPP_CONCAT_8BIT_S concat8bit;
+ SMS_3GPP_CONCAT_16BIT_S concat16bit;
+ SMS_3GPP_APP_PORT_8BIT_S appPort8bit;
+ SMS_3GPP_APP_PORT_16BIT_S appPort16bit;
+ SMS_3GPP_SPECIAL_INDICATION_S specialInd;
+ MSG_SINGLE_SHIFT_S singleShift;
+ MSG_LOCKING_SHIFT_S lockingShift;
+ SMS_3GPP_ADDRESS_S alternateAddress;
+ } udh;
+} SMS_3GPP_UDH_S;
+
+
+typedef struct _SMS_USERDATA_S {
+ int headerCnt;
+ SMS_3GPP_UDH_S header[MAX_UD_HEADER_NUM];
+ int length;
+ char data[MAX_USER_DATA_LEN+1];
+} SMS_3GPP_USERDATA_S;
+
+
+typedef struct _SMS_TPUD_S {
+ int udl;
+ char ud[MAX_USER_DATA_LEN+1];
+} SMS_3GPP_TPUD_S;
+
+
+typedef struct _SMS_SUBMIT_S {
+ bool bRejectDup;
+ bool bStatusReport;
+ bool bHeaderInd;
+ bool bReplyPath;
+ unsigned char msgRef;
+ SMS_3GPP_VPF_T vpf;
+ SMS_3GPP_ADDRESS_S destAddress;
+ SMS_3GPP_PID_T pid;
+ SMS_3GPP_DCS_S dcs;
+ SMS_3GPP_TIMESTAMP_S validityPeriod;
+ SMS_3GPP_USERDATA_S userData;
+} SMS_3GPP_SUBMIT_S;
+
+
+typedef struct _SMS_SUBMIT_DATA_S {
+ SMS_3GPP_ADDRESS_S destAddress;
+ unsigned int segCount;
+ SMS_3GPP_USERDATA_S userData[MAX_SEGMENT_NUM];
+} SMS_3GPP_SUBMIT_DATA_S;
+
+
+typedef struct _SMS_DELIVER_S {
+ bool bMoreMsg;
+ bool bStatusReport;
+ bool bHeaderInd;
+ bool bReplyPath;
+ SMS_3GPP_ADDRESS_S originAddress;
+ SMS_3GPP_PID_T pid;
+ SMS_3GPP_DCS_S dcs;
+ SMS_3GPP_TIMESTAMP_S timeStamp;
+ SMS_3GPP_USERDATA_S userData;
+ SMS_3GPP_TPUD_S udData;
+} SMS_3GPP_DELIVER_S;
+
+
+typedef struct _SMS_DELIVER_REPORT_S {
+ SMS_3GPP_REPORT_TYPE_T reportType;
+ bool bHeaderInd;
+ SMS_3GPP_FAIL_CAUSE_T failCause;
+ unsigned char paramInd;
+ SMS_3GPP_PID_T pid;
+ SMS_3GPP_DCS_S dcs;
+ SMS_3GPP_USERDATA_S userData;
+} SMS_3GPP_DELIVER_REPORT_S;
+
+
+typedef struct _SMS_STATUS_REPORT_S {
+ bool bMoreMsg;
+ bool bStatusReport;
+ bool bHeaderInd;
+ unsigned char msgRef;
+ SMS_3GPP_ADDRESS_S recipAddress;
+ SMS_3GPP_TIMESTAMP_S timeStamp;
+ SMS_3GPP_TIMESTAMP_S dischargeTime;
+ SMS_3GPP_STATUS_T status;
+ unsigned char paramInd;
+ SMS_3GPP_PID_T pid;
+ SMS_3GPP_DCS_S dcs;
+ SMS_3GPP_USERDATA_S userData;
+} SMS_3GPP_STATUS_REPORT_S;
+
+
+typedef struct _SMS_TPDU_S {
+ SMS_3GPP_TPDU_TYPE_T tpduType;
+
+ union {
+ SMS_3GPP_SUBMIT_S submit;
+ SMS_3GPP_DELIVER_S deliver;
+ SMS_3GPP_DELIVER_REPORT_S deliverRep;
+ SMS_3GPP_STATUS_REPORT_S statusRep;
+ } data;
+} SMS_3GPP_TPDU_S;
+
+
+typedef struct {
+ msg_request_id_t reqId; /**< Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
+ MSG_MESSAGE_INFO_S msgInfo; /**< Indicates the message structure to be sent by applications. */
+ MSG_SENDINGOPT_INFO_S sendOptInfo;
+} SMS_3GPP_REQUEST_INFO_S;
+
+
+typedef struct _SMS_SENT_INFO_S {
+ SMS_3GPP_REQUEST_INFO_S reqInfo; /**< Indicates the corresponding request structure. */
+ bool bLast;
+} SMS_3GPP_SENT_INFO_S;
+
+
+typedef struct _SMS_PUSH_APP_INFO_S {
+ char* pContentType;
+ char* pAppId;
+ SMS_WAP_APP_CODE_T appCode;
+} SMS_3GPP_PUSH_APP_INFO_S;
+
+
+typedef struct _SMS_CBMSG_SERIAL_NUM_S {
+ unsigned char geoScope;
+ unsigned char updateNum;
+ unsigned short msgCode;
+} SMS_3GPP_CBMSG_SERIAL_NUM_S;
+
+
+typedef struct _SMS_CBMSG_DCS_S {
+ SMS_3GPP_CBMSG_CODING_GROUP_T codingGroup; /**< Coding group, GSM 03.38 */
+ SMS_3GPP_MSG_CLASS_T classType; /**< The message class */
+ bool bCompressed; /**< if text is compressed this is TRUE */
+ SMS_3GPP_CODING_SCHEME_T codingScheme; /**< How to encode a message. */
+ SMS_3GPP_CBMSG_LANG_TYPE_T langType;
+ unsigned char iso639Lang[3]; /* 2 GSM chars and a CR char */
+ bool bUDH;
+ unsigned char rawData;
+} SMS_3GPP_CBMSG_DCS_S;
+
+
+typedef struct _SMS_CBMSG_HEADER_S {
+ SMS_3GPP_CBMSG_SERIAL_NUM_S serialNum; /**< Cell Broadcast Serial number */
+ unsigned short msgId; /**< Message identifier code */
+ MSG_CB_LANGUAGE_TYPE_T langType; /**< Languages in CB Messages */
+ SMS_3GPP_CBMSG_DCS_S dcs; /**< Data coding scheme */
+ unsigned char page; /**< current page number */
+ unsigned char totalPages; /**< Total number of pages in this messages */
+ time_t recvTime; /**< Msg Recv Time */
+} SMS_3GPP_CBMSG_HEADER_S;
+
+
+typedef struct _SMS_CBMSG_PAGE_S {
+ SMS_3GPP_CBMSG_TYPE_T cbMsgType; /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
+ SMS_3GPP_CBMSG_HEADER_S pageHeader; /**< CB Message Header */
+ int pageLength; /**< message string length */
+ char pageData[MAX_CBMSG_TOTAL_PAGE_SIZE * 8 / 7 + 1]; /**< user data */
+} SMS_3GPP_CBMSG_PAGE_S;
+
+
+typedef struct _SMS_CBMSG_S {
+ SMS_3GPP_CBMSG_TYPE_T cbMsgType; /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
+ unsigned short msgId; /**< Message identifier code */
+ unsigned short serialNum; /* Serial number */
+ SMS_3GPP_MSG_CLASS_T classType; /**< The message class */
+ SMS_3GPP_CODING_SCHEME_T codingScheme; /**< How to encode a message. */
+ time_t recvTime; /**< Msg Recv Time */
+ int msgLength; /**< message string length */
+ char msgData[MAX_CBMSG_TOTAL_PAGE_SIZE * 8 / 7 + 1]; /**< user data */
+} SMS_3GPP_CBMSG_S;
+
+typedef struct _SMS_ETWS_PRIMARY_S {
+ time_t recvTime;
+ SMS_3GPP_CBMSG_SERIAL_NUM_S serialNum;
+ unsigned short msgId;
+ unsigned short warningType;
+ unsigned char warningSecurityInfo[MAX_ETWS_SIZE-6];
+} SMS_3GPP_ETWS_PRIMARY_S;
+
+
+typedef struct _SMS_WSP_CONTENTS_TYPE_S {
+ char* contentsTypeName;
+ unsigned char contentsTypeCode;
+} SMS_3GPP_WSP_CONTENTS_TYPE_S;
+
+
+typedef struct _SMS_WSP_CHARSET_S {
+ char* charsetName;
+ unsigned short charsetCode;
+} SMS_3GPP_WSP_CHARSET_S;
+
+
+typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S {
+ char* contentsTypeName;
+ unsigned short contentsTypeCode;
+} SMS_3GPP_WAP_UNREGISTER_CONTENTS_TYPE_S;
+
+
+typedef struct _SMS_WSP_LANGUAGE_S {
+ char* languageName;
+ unsigned char languageCode;
+} SMS_3GPP_WSP_LANGUAGE_S;
+
+
+typedef struct _SMS_WSP_HEADER_PARAMETER_S {
+ char* parameterToken;
+ unsigned int parameterCode;
+} SMS_3GPP_WSP_HEADER_PARAMETER_S;
+
+
+typedef struct _SMS_WSP_METHOD_TYPE_S {
+ char* methodName;
+ unsigned char methodCode;
+} SMS_3GPP_WSP_METHOD_TYPE_S;
+
+
+typedef struct _SMS_WSP_SECURITY_TYPE_S {
+ char* SecurityTypeName;
+ unsigned char SecurityTypeCode;
+} SMS_3GPP_WSP_SECURITY_TYPE_S;
+
+
+/**
+ * @brief Represents SIM count information.
+ */
+typedef struct {
+ unsigned int totalCount; /**< The total number of SIM */
+ int usedCount; /**< The used number of SIM */
+ int indexList[MAX_SIM_SMS_NUM]; /**< The SIM index list */
+} MSG_3GPP_SIM_COUNT_S;
+
+
+/**
+ * @brief Represents Concat SIM Msg information.
+ */
+typedef struct {
+ unsigned int simIdCnt; /**< The total number of SIM Msg ID*/
+ msg_sim_id_t simIdList[MAX_SEGMENT_NUM]; /**< The SIM Msg ID List */
+ char msgData[(MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM)+1]; /**< user data */
+} SMS_3GPP_CONCAT_SIM_MSG_S;
+
+
+/**
+ * @brief Represents Sim Mailbox information
+ */
+typedef struct {
+ int b_cphs;
+ int rec_index; /**< index which stands for the location where record is saved in SIM*/
+ int profile_num; /**< SIM profile index*/
+ SMS_3GPP_SIM_MAILBOX_TYPE_T mb_type;
+ int alpha_id_max_len; /**< alpha max length in SIM - READ ONLY*/
+ char alpha_id[MAX_SIM_XDN_ALPHA_ID_LEN + 1]; /**< Alpha Identifier */
+ MSG_SMS_TON_T ton; /**< Type Of Number */
+ MSG_SMS_NPI_T npi; /**< Number Plan Identity */
+ char num[MAX_PHONE_NUMBER_LEN + 1]; /**< Dialing Number/SSC String */
+ unsigned char cc_id; /**< Capability/Configuration Identifier */
+ unsigned char ext1_id; /**< Extensiion1 Record Identifier */
+ int num_len; /**< Length of the original number read from SIM*/
+} SMS_3GPP_SIM_MAILBOX_INFO_S;
+
+
+/**
+ * @brief Represents Sim Mailbox list
+ */
+typedef struct {
+ int count;
+ SMS_3GPP_SIM_MAILBOX_INFO_S list[MAX_SIM_MSP_CNT*5]; /* max is 10 */
+} SMS_3GPP_SIM_MAILBOX_LIST_S;
+
+
+/**
+ * @brief Represents Message Waiting Indication
+ */
+typedef struct {
+ int rec_index;
+ unsigned char indicator_status; /**< Indicator Type*/
+ int voice_count; /**< VoiceMail Count*/
+ int fax_count; /**< FAX Count*/
+ int email_count; /**< Email Count*/
+ int other_count; /**< Other Count*/
+ int video_count; /**< VideoMail Count*/
+} SMS_3GPP_SIM_MWI_NORMAL_INFO_S;
+
+
+/**
+ * @brief Represents Message Waiting Indication list
+ */
+typedef struct {
+ int profile_count;
+ SMS_3GPP_SIM_MWI_NORMAL_INFO_S mw_info[MAX_SIM_MSP_CNT];
+} SMS_3GPP_SIM_MWI_LIST_S;
+
+
+/**
+ * @brief Represents Message Waiting Indication for CPHS
+ */
+typedef struct {
+ int b_voice1; /**< VoiceMsgLine1 message waiting flag */
+ int b_voice2; /**< VoiceMsgLine2 message waiting flag */
+ int b_fax; /**< FAX message waiting flag */
+ int b_data; /**< Data message waiting flag */
+} SMS_3GPP_SIM_MWI_CPHS_INFO_S;
+
+
+/**
+ * @brief Represents Message Waiting Indication Information
+ */
+typedef struct {
+ int b_cphs;
+ SMS_3GPP_SIM_MWI_LIST_S mwi_list;
+ SMS_3GPP_SIM_MWI_CPHS_INFO_S cphs_mwi;
+} SMS_3GPP_SIM_MWI_INFO_S;
+
+/**
+ * @brief Represents SIM MSISDN Information
+ */
+typedef struct {
+ char simMsisdn[MAX_SIM_MSISDN_LEN + 1];
+ int sim_index;
+} SMS_3GPP_SIM_MSISDN_INFO_S;
+
+
+/**
+ * @brief Represents Message Data Information from Telephony.
+ */
+typedef struct {
+ unsigned char sca[MAX_ADDRESS_LEN]; /**< Service Center address */
+ int msgLength; /**< Size of array szData (which is actual TPDU message) */
+ unsigned char szData[MAX_TPDU_DATA_LEN + 1]; /**< SMS TPDU message */
+ int totalSegment; /** total segment count of TPDU message */
+} SMS_3GPP_DATA_INFO_S;
+
+
+#endif /* SMS_3GPP_TYPES_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_UA_MANAGER_H
+#define SMS_3GPP_UA_MANAGER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgQueue.h"
+#include "MsgThread.h"
+#include "Sms3gppTypes.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppUAManager : public MsgThread
+{
+public:
+ static Sms3gppUAManager* instance();
+
+ /* virtual void start(); */
+
+ void addReqEntity(SMS_3GPP_REQUEST_INFO_S *request);
+
+private:
+ Sms3gppUAManager();
+ ~Sms3gppUAManager();
+ void lock() { mx.lock(); };
+ void unlock() { mx.unlock(); };
+ void wait() { cv.wait(mx.pMsgMutex()); };
+ void signal() { cv.signal(); };
+
+ virtual void run();
+
+ static Sms3gppUAManager* pInstance;
+
+ MsgSimpleQ <SMS_3GPP_REQUEST_INFO_S> smsTranQ;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP_UA_MANAGER_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_UD_CODEC_H
+#define SMS_3GPP_UD_CODEC_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "Sms3gppTypes.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppUDCodec
+{
+public:
+ Sms3gppUDCodec();
+ virtual ~Sms3gppUDCodec();
+
+ static int encodeUserData(const SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_CODING_SCHEME_T CodingScheme, char *pEncodeData);
+ static int decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_CODING_SCHEME_T CodingScheme, SMS_3GPP_USERDATA_S *pUserData);
+ static int decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_CODING_SCHEME_T CodingScheme, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD);
+
+ static int pack7bitChar(const unsigned char *pUserData, int dataLen, int fillBits, char *pPackData);
+ static int unpack7bitChar(const unsigned char *pTpdu, unsigned char dataLen, int fillBits, char *pUnpackData);
+
+private:
+ static int encodeGSMData(const SMS_3GPP_USERDATA_S *pUserData, char *pEncodeData);
+ static int encode8bitData(const SMS_3GPP_USERDATA_S *pUserData, char *pEncodeData);
+ static int encodeUCS2Data(const SMS_3GPP_USERDATA_S *pUserData, char *pEncodeData);
+
+ static int decodeGSMData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD);
+ static int decode8bitData(const unsigned char *pTpdu, bool bHeaderInd, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD);
+ static int decodeUCS2Data(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_3GPP_USERDATA_S *pUserData, SMS_3GPP_TPUD_S *pTPUD);
+
+ static int encodeHeader(const SMS_3GPP_UDH_S header, char *pEncodeHeader);
+ static int decodeHeader(const unsigned char *pTpdu, SMS_3GPP_UDH_S *pHeader);
+};
+
+#endif /* SMS_3GPP_UD_CODEC_H */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP_WAP_PUSH_HANDLER_H
+#define SMS_3GPP_WAP_PUSH_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <wbxml/wbxml.h>
+#include <libxml/parser.h>
+
+
+#include "Sms3gppTypes.h"
+
+
+/*==================================================================================================
+ DEFINES
+==================================================================================================*/
+#define WSP_STANDARD_STR_LEN_MAX 255
+#define LENGTH_QUOTE 0x1F
+#define NO_VALUE 0x00
+
+#define WSP_CODE_BUFFER_LEFT_LEN_MAX 1024
+#define WSP_CODE_BUFFER_RIGHT_LEN_MAX 2048
+
+#define AcStrlen(x) ((x == NULL) ? 0 : strlen(x))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gppWapPushHandler
+{
+public:
+ static Sms3gppWapPushHandler* instance();
+
+ bool IsWapPushMsg(SMS_3GPP_USERDATA_S *pUserData);
+
+ void copyDeliverData(SMS_3GPP_DELIVER_S *pDeliver);
+ void handleWapPushMsg(const char *pUserData, int DataSize, int simIndex, time_t sent_time);
+ void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex, time_t sent_time);
+
+private:
+ Sms3gppWapPushHandler();
+ virtual ~Sms3gppWapPushHandler();
+
+ static Sms3gppWapPushHandler* pInstance;
+
+ SMS_WAP_APP_CODE_T getAppCode(const char *pPushHeader);
+ bool IsWapPushMsgInWhiteList(int appCode);
+
+ void handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex, time_t sent_time);
+ void handleSIMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
+ void handleSLMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
+ void handleCOMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
+ void handleDrmVer1(char* pPushBody, int PushBodyLen);
+ void getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText);
+ void createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo);
+ void getDisplayName(MSG_SUB_TYPE_T subType, char* displayName);
+ unsigned long convertXmlCharToSec(char* pDate);
+ msg_push_action_t convertSIActionStrToEnum(char* pAction);
+ msg_push_action_t convertSLActionStrToEnum(char* pAction);
+
+ unsigned long wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer);
+ unsigned long wspDecodeUintvar(unsigned long length, unsigned char* userVar);
+ void wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader);
+ unsigned long wspHeaderDecodeInteger(unsigned char* data);
+ void wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString);
+ unsigned long wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length);
+ char* wspExtendedDecodeType(char contentType);
+ void wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam);
+ void wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString);
+ void wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString);
+ void wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString);
+ void wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper);
+ void wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
+ void wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
+ void wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString);
+
+ SMS_3GPP_ADDRESS_S tmpAddress;
+ SMS_3GPP_TIMESTAMP_S tmpTimeStamp;
+};
+
+#endif /* SMS_3GPP_WAP_PUSH_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "MsgDebug.h"
+#include "MsgTextConvert.h"
+
+#include "Sms3gpp2Types.h"
+#include "Sms3gpp2ParamCodec.h"
+#include "Sms3gpp2Codec.h"
+
+
+Sms3gpp2MsgCodec* Sms3gpp2MsgCodec::pInstance = NULL;
+
+Sms3gpp2MsgCodec::Sms3gpp2MsgCodec()
+{
+}
+
+
+Sms3gpp2MsgCodec::~Sms3gpp2MsgCodec()
+{
+}
+
+
+Sms3gpp2MsgCodec* Sms3gpp2MsgCodec::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2MsgCodec();
+ }
+
+ return pInstance;
+}
+
+
+void _shiftNBit(unsigned char *src, unsigned int n_bytes, unsigned int n_shift_bit)
+{
+ char tmp;
+
+ for (unsigned int index = 1; index < n_bytes; index++) {
+ tmp = src[index] >> (8 - n_shift_bit);
+ src[index-1] |= tmp;
+ src[index] = src[index] << n_shift_bit;
+ }
+}
+
+
+void _shiftNBit_for_decode(unsigned char *src, unsigned int n_bytes, unsigned int n_shift_bit)
+{
+ for (unsigned int index = 0; index < n_bytes; index++) {
+ src[index]<<=n_shift_bit;
+ src[index] |= (src[index+1] >> (8 - n_shift_bit));
+ }
+}
+
+
+void _copy_short_to_char(unsigned char *dest, const unsigned short *src)
+{
+ dest[0] = (0xff00 & *src) >> 8;
+ dest[1] = 0x00ff & *src;
+}
+
+
+void _copy_char_to_short(unsigned short *dest, const unsigned char *src)
+{
+ *dest = src[0]*256 + src[1];
+}
+
+
+unsigned char _convert_to_BCD(unsigned char val)
+{
+ unsigned char ret = 0x00;
+ ret = ((val/10) << 4) | (val%10);
+ return ret;
+}
+
+
+int UnpackGSM7bitData(unsigned char *src, unsigned char *dest, unsigned int dataLen)
+{
+ unsigned int srcIdx = 0, dstIdx = 0, shift = 0;
+
+ MSG_DEBUG("dataLen = %d", dataLen);
+
+ for (; dstIdx < dataLen; dstIdx++) {
+ if (shift == 0) {
+ dest[dstIdx] = src[srcIdx] & 0x7F;
+
+ shift = 7;
+ srcIdx++;
+ dstIdx++;
+
+ if (dstIdx >= dataLen)
+ break;
+ }
+
+ if (shift > 0) {
+ dest[dstIdx] = (src[srcIdx-1] >> shift) + (src[srcIdx] << (8 - shift));
+
+ dest[dstIdx] &= 0x7F;
+
+ shift--;
+
+ if (shift > 0)
+ srcIdx++;
+ }
+ }
+
+ return dstIdx;
+}
+
+
+int PackGSM7bitData(const unsigned char *pUserData, unsigned char *pPackData, int dataLen)
+{
+ int srcIdx = 0, dstIdx = 0, shift = 0;
+
+ while (srcIdx < dataLen) {
+ if (shift == 0) {
+ pPackData[dstIdx] = pUserData[srcIdx];
+
+ shift = 7;
+ srcIdx++;
+ dstIdx++;
+
+ if (srcIdx >= dataLen)
+ break;
+ }
+
+ if (shift > 1) {
+ pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
+ pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
+ shift--;
+
+ srcIdx++;
+ dstIdx++;
+ } else if (shift == 1) {
+ pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
+
+ srcIdx++;
+
+ shift--;
+ }
+ }
+
+ return dstIdx;
+}
+
+
+bool Sms3gpp2MsgCodec::checkInvalidPDU(const unsigned char *p_pkg_str, const int p_pkg_len)
+{
+ MSG_BEGIN();
+ int offset = 0;
+
+ if (!(p_pkg_str[offset] == 0x00 || p_pkg_str[offset] == 0x01 || p_pkg_str[offset] == 0x02)) {
+ MSG_WARN("Invalid PDU : Message Type [%2x]", p_pkg_str[offset]);
+ return false;
+ }
+
+ offset++;
+
+ while (offset < p_pkg_len) {
+ switch (p_pkg_str[offset]) {
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ case 0x08:
+ offset += (p_pkg_str[offset+1]+2);
+ break;
+ default:
+ MSG_WARN("Invalid PDU : Parameter ID [%2x], offset [%d]", p_pkg_str[offset], offset);
+ return false;
+ }
+ }
+
+ if (offset != p_pkg_len)
+ return false;
+
+ MSG_END();
+ return true;
+}
+
+
+int Sms3gpp2MsgCodec::encodeMsg(const sms_3gpp2_trans_msg_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int encode_size = 0;
+
+ switch (p_msg->type) {
+ case SMS_TRANS_P2P_MSG:
+ encode_size = encodeP2PMsg(&(p_msg->data.p2p_msg), p_pkg_str);
+ break;
+ case SMS_TRANS_BROADCAST_MSG:
+ encode_size = encodeCBMsg(&(p_msg->data.cb_msg), p_pkg_str);
+ break;
+ case SMS_TRANS_ACK_MSG:
+ encode_size = encodeAckMsg(&(p_msg->data.ack_msg), p_pkg_str);
+ break;
+ default:
+ break;
+ }
+
+ MSG_END();
+
+ return encode_size;
+}
+
+
+int Sms3gpp2MsgCodec::encodeP2PMsg(const sms_3gpp2_trans_p2p_msg_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0, encode_size = 0;
+ int addr_len = 0;
+ int index = 0, len_index = 0;
+
+ p_pkg_str[offset++] = SMS_TRANS_P2P_MSG;
+
+ /* 1. teleservice id */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_TELESVC_IDENTIFIER;
+ p_pkg_str[offset++] = 2;
+ /* fixed */
+ /* memcpy(p_pkg_str+offset, &(p_msg->telesvc_id), sizeof(sms_trans_telesvc_id_t)); */
+ _copy_short_to_char(p_pkg_str+offset, &(p_msg->telesvc_id));
+ offset += sizeof(sms_3gpp2_trans_telesvc_id_t);
+
+ /* 2. Service category */
+ if (p_msg->svc_ctg < SMS_TRANS_SVC_CTG_UNDEFINED) {
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_SERVICE_CATEGORY;
+ p_pkg_str[offset++] = 0x02;
+ /* fixed */
+ _copy_short_to_char(&p_pkg_str[offset], &(p_msg->svc_ctg));
+ }
+
+ /* 3. Address */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_DEST_ADDRESS;
+
+ /* Will be set to param length */
+ len_index = offset++;
+
+ p_pkg_str[offset] = p_msg->address.digit_mode ? 0x80 : 0x00;
+ p_pkg_str[offset] |= (p_msg->address.number_mode ? 0x40 : 0x00);
+
+ if (p_msg->address.digit_mode == false) {
+ index = offset++;
+ p_pkg_str[offset++] = p_msg->address.addr_len;
+
+ addr_len = Sms3gpp2ParamCodec::instance()->convertDigitToDTMF(p_msg->address.szData, p_msg->address.addr_len, 0, p_pkg_str+offset);
+
+ for (int j=0; j < addr_len; j++) {
+ MSG_DEBUG("ADDRESS 4BIT DTMF [%d] = [%02x]", j, p_pkg_str[offset+j]);
+ }
+
+ offset += addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 6);
+ } else if (p_msg->address.digit_mode == true) {
+ p_pkg_str[offset] |= p_msg->address.number_type << 3;
+
+ if (p_msg->address.number_mode == false) {
+ p_pkg_str[offset++] |= p_msg->address.number_plan >> 1;
+ p_pkg_str[offset++] |= p_msg->address.number_plan << 7;
+ index = offset-1;
+ p_pkg_str[offset++] = p_msg->address.addr_len;
+
+ memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
+
+ offset += p_msg->address.addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 7);
+ } else if (p_msg->address.number_mode == true) {
+ index = offset++;
+ p_pkg_str[offset++] = p_msg->address.addr_len;
+ memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
+
+ offset += p_msg->address.addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 3);
+ }
+ }
+
+ p_pkg_str[len_index] = offset - len_index - 1 ;
+ MSG_DEBUG("Address subparam length field = [%d]", p_pkg_str[len_index]);
+
+ /* 4. Sub address (optional) */
+ if (p_msg->sub_address.addr_len > 0) {
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_ORG_SUB_ADDRESS;
+ p_pkg_str[offset] = p_msg->sub_address.addr_len + 2;
+ index = offset++;
+ p_pkg_str[offset] |= p_msg->sub_address.type << 5;
+ p_pkg_str[offset++] |= (p_msg->sub_address.odd ? 0x10 : 0x00);
+ p_pkg_str[offset++] = p_msg->sub_address.addr_len;
+ memcpy(p_pkg_str+offset, p_msg->sub_address.szData, p_msg->sub_address.addr_len);
+
+ offset += p_msg->sub_address.addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 4);
+ }
+
+ /* 5. Bearer reply option (optional) */
+ if (p_msg->reply_seq > 0) {
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_REPLY_OPTION;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = (unsigned char)(p_msg->reply_seq << 2);
+ MSG_DEBUG("Reply sequnce number = [%d]", p_msg->reply_seq);
+ }
+
+ /* 6. Bearer data */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_DATA;
+ /* PARAMETER_LEN field should be filled at the last part. */
+ index = offset++;
+
+ unsigned char *encode_data = &p_pkg_str[offset];
+
+ encode_size = encodeTelesvcMsg(&(p_msg->telesvc_msg), encode_data);
+ /* PARAMETER_LEN */
+ p_pkg_str[index] = encode_size;
+
+ offset += encode_size;
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeCBMsg(const sms_3gpp2_trans_broadcast_msg_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0, encode_size = 0;
+ int len_index = 0;
+
+ /* 1. Service Category(Mandatory) */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_SERVICE_CATEGORY;
+ p_pkg_str[offset++] = 0x02;
+ _copy_short_to_char(&p_pkg_str[offset], &p_msg->svc_ctg);
+
+
+ /* 2. Bearer Data(Optional) */
+ /* TODO: give condition */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_BEARER_DATA;
+ /* PARAMETER_LEN field should be filled at the last part. */
+ len_index = offset++;
+
+ unsigned char *encode_data = &p_pkg_str[offset];
+
+ encode_size = encodeTelesvcMsg(&(p_msg->telesvc_msg), encode_data);
+ /* PARAMETER_LEN */
+ p_pkg_str[len_index] = encode_size;
+
+ offset += encode_size;
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeAckMsg(const sms_3gpp2_trans_ack_msg_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0;
+ int addr_len = 0, len_index = 0;
+ int index = 0;
+
+ /* 1. Address */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_DEST_ADDRESS;
+
+ /* Will be set to param length */
+ len_index = offset++;
+
+ p_pkg_str[offset] = p_msg->address.digit_mode ? 0x80 : 0x00;
+ p_pkg_str[offset] |= (p_msg->address.number_mode ? 0x40 : 0x00);
+
+ index = offset++;
+
+ if (p_msg->address.digit_mode == false) {
+ p_pkg_str[offset++] = p_msg->address.addr_len;
+
+ addr_len = Sms3gpp2ParamCodec::instance()->convertDigitToDTMF(p_msg->address.szData, p_msg->address.addr_len, 0, p_pkg_str+offset);
+
+ for (int j=0; j < addr_len; j++) {
+ MSG_DEBUG("ADDRESS 4BIT DTMF [%d] = [%02x]", j, p_pkg_str[offset+j]);
+ }
+
+ offset += addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 6);
+ } else if (p_msg->address.digit_mode == true) {
+ p_pkg_str[offset] |= p_msg->address.number_type << 3;
+
+ if (p_msg->address.number_mode == false) {
+ p_pkg_str[offset++] |= p_msg->address.number_plan >> 1;
+ p_pkg_str[offset++] |= p_msg->address.number_plan << 7;
+ index++;
+ p_pkg_str[offset++] = p_msg->address.addr_len;
+
+ memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
+
+ offset += p_msg->address.addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 7);
+ } else if (p_msg->address.number_mode == true) {
+ p_pkg_str[++offset] = p_msg->address.addr_len;
+ offset++;
+ memcpy(p_pkg_str+offset, p_msg->address.szData, p_msg->address.addr_len);
+
+ offset += p_msg->address.addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 3);
+ }
+ }
+
+ p_pkg_str[len_index] = offset - len_index - 1 ;
+ MSG_DEBUG("Address subparam length field = [%d]", p_pkg_str[len_index]);
+
+ /* 2. Sub address */
+ if (p_msg->sub_address.addr_len > 0) {
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_ORG_SUB_ADDRESS;
+ p_pkg_str[offset] = p_msg->sub_address.addr_len + 2;
+ index = offset++;
+ p_pkg_str[offset] |= p_msg->sub_address.type << 5;
+ p_pkg_str[offset++] |= (p_msg->sub_address.odd ? 0x10 : 0x00);
+ p_pkg_str[offset++] = p_msg->sub_address.addr_len;
+ memcpy(p_pkg_str+offset, p_msg->sub_address.szData, p_msg->sub_address.addr_len);
+
+ offset += p_msg->sub_address.addr_len;
+
+ _shiftNBit(&p_pkg_str[index], offset-index+1, 4);
+ }
+
+ /* 3. Cause code */
+ p_pkg_str[offset++] = SMS_TRANS_PARAM_CAUSE_CODES;
+ index = offset++;
+ p_pkg_str[offset] |= p_msg->cause_code.reply_seq << 2;
+ p_pkg_str[offset] |= p_msg->cause_code.error_class;
+ if (p_msg->cause_code.error_class != 0x0) {
+ p_pkg_str[++offset] = p_msg->cause_code.cause_code;
+ }
+ p_pkg_str[index] = offset - index;
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeTelesvcMsg(const sms_3gpp2_telesvc_msg_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+ int encode_size = 0;
+
+ MSG_DEBUG("Teleservice msg type = [%d]", p_msg->type);
+
+ switch (p_msg->type) {
+ /* case SMS_TYPE_DELIVER:
+ encode_size = encodeTelesvcDeliverMsg(&(p_msg->data.delever), p_pkg_str);
+ break; */
+ case SMS_TYPE_SUBMIT:
+ encode_size = encodeTelesvcSubmitMsg(&(p_msg->data.submit), p_pkg_str);
+ break;
+ case SMS_TYPE_CANCEL:
+ encode_size = encodeTelesvcCancelMsg(&(p_msg->data.cancel), p_pkg_str);
+ break;
+ case SMS_TYPE_USER_ACK:
+ encode_size = encodeTelesvcUserAckMsg(&(p_msg->data.user_ack), p_pkg_str);
+ break;
+ case SMS_TYPE_READ_ACK:
+ encode_size = encodeTelesvcReadAckMsg(&(p_msg->data.read_ack), p_pkg_str);
+ break;
+ case SMS_TYPE_DELIVER_REPORT:
+ encode_size = encodeTelesvcDeliverReportMsg(&(p_msg->data.report), p_pkg_str);
+ break;
+ default:
+ MSG_DEBUG("No matching type for [%d]", p_msg->type);
+ break;
+ }
+
+ MSG_END();
+ return encode_size;
+}
+
+
+/*
+int Sms3gpp2MsgCodec::encodeTelesvcDeliverMsg(const sms_3gpp2_telesvc_read_ack_s *p_msg, char *p_pkg_str)
+{
+
+}
+*/
+
+
+int Sms3gpp2MsgCodec::encodeTelesvcReadAckMsg(const sms_3gpp2_telesvc_read_ack_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0;
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeTelesvcUserAckMsg(const sms_3gpp2_telesvc_user_ack_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0;
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeTelesvcDeliverReportMsg(const sms_3gpp2_telesvc_report_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0, len_index = 0, encode_size = 0;
+ bool delReservedBit = false;
+
+ /* 1. Message Identifier (Mandatory) */
+ p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
+ p_pkg_str[offset++] = 3;
+ _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
+ _shiftNBit(&p_pkg_str[offset], 3, 4);
+ p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
+ offset += 2;
+ p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
+
+ /* 2. TP-Failure Cause (Conditional) */
+ if (p_msg->tp_fail_cause >= 0x80) {
+ p_pkg_str[offset++] = SMS_BEARER_TP_FAILURE_CAUSE;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->tp_fail_cause;
+ }
+
+ /* 3. User Data (Optional) */
+ if (p_msg->user_data.data_len > 0) {
+ p_pkg_str[offset++] = SMS_BEARER_USER_DATA;
+ len_index = offset;
+ offset++;
+ if (p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
+ p_pkg_str[offset++] = p_msg->user_data.msg_type;
+
+ p_pkg_str[offset++] = p_msg->user_data.encode_type << 3;
+ p_pkg_str[offset++] = p_msg->user_data.data_len;
+
+ if (p_msg->user_data.encode_type == SMS_ENCODE_7BIT_ASCII || p_msg->user_data.encode_type == SMS_ENCODE_GSM7BIT) {
+ encode_size = encodeUserData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
+ offset += encode_size;
+ if (p_msg->user_data.data_len % 8 > 4)
+ delReservedBit = true;
+ } else {
+ memcpy(p_pkg_str+offset, p_msg->user_data.user_data, p_msg->user_data.data_len);
+ offset += p_msg->user_data.data_len;
+ }
+ _shiftNBit(&p_pkg_str[len_index+1], offset-len_index-1, 3);
+
+ if (delReservedBit == true)
+ offset--;
+
+ p_pkg_str[len_index] = offset - len_index - 1;
+ }
+
+ /* 4. Language Indicator (Optional) */
+ /* TODO : give condition */
+ /*
+ p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->language;
+ */
+
+ /* 5. Multiple Encoding User Data (Optional) */
+ /* Omitted */
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeTelesvcCancelMsg(const sms_3gpp2_telesvc_cancel_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0;
+
+ /* 1. Message Identifier */
+ p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
+ p_pkg_str[offset++] = 3;
+ _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
+ _shiftNBit(&p_pkg_str[offset], 3, 4);
+ p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
+ offset += 2;
+ p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeTelesvcSubmitMsg(const sms_3gpp2_telesvc_submit_s *p_msg, unsigned char *p_pkg_str)
+{
+ MSG_BEGIN();
+
+ int offset = 0, len_index = 0;
+ int encode_size = 0;
+ bool delReservedBit = false;
+
+ /* 1. Message Identifier */
+ p_pkg_str[offset++] = SMS_BEARER_MESSAGE_IDENTIFIER;
+ p_pkg_str[offset++] = 3;
+ _copy_short_to_char(p_pkg_str+offset+1, &(p_msg->msg_id.msg_id));
+ _shiftNBit(&p_pkg_str[offset], 3, 4);
+ p_pkg_str[offset] |= SMS_TYPE_SUBMIT << 4;
+ offset += 2;
+ p_pkg_str[offset++] |= (p_msg->msg_id.header_ind ? 0x08 : 0x00);
+
+ /* 2. User Data */
+ if (p_msg->user_data.data_len > 0) {
+ p_pkg_str[offset++] = SMS_BEARER_USER_DATA;
+ len_index = offset;
+ offset++;
+ if (p_msg->user_data.encode_type == 0x01 || p_msg->user_data.encode_type == 0x0a)
+ p_pkg_str[offset++] = p_msg->user_data.msg_type;
+
+ p_pkg_str[offset++] = p_msg->user_data.encode_type << 3;
+ p_pkg_str[offset++] = p_msg->user_data.data_len;
+
+ if (p_msg->user_data.encode_type == SMS_ENCODE_7BIT_ASCII) {
+ encode_size = encodeUserData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
+ offset += encode_size;
+ if (p_msg->user_data.data_len % 8 > 4)
+ delReservedBit = true;
+ } else if (p_msg->user_data.encode_type == SMS_ENCODE_GSM7BIT) {
+ encode_size = PackGSM7bitData(p_msg->user_data.user_data, &p_pkg_str[offset], p_msg->user_data.data_len);
+ offset += encode_size;
+ if (p_msg->user_data.data_len % 8 > 4)
+ delReservedBit = true;
+ } else if (p_msg->user_data.encode_type == SMS_ENCODE_UNICODE) {
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ encode_size = textCvt->convertUTF8ToUCS2(&p_pkg_str[offset], SMS_MAX_USER_DATA_LEN, p_msg->user_data.user_data, p_msg->user_data.data_len);
+ p_pkg_str[offset-1] = encode_size / 2;
+ offset += encode_size;
+ } else {
+ memcpy(p_pkg_str+offset, p_msg->user_data.user_data, p_msg->user_data.data_len);
+ offset += p_msg->user_data.data_len;
+ }
+ _shiftNBit(&p_pkg_str[len_index+1], offset-len_index-1, 3);
+
+ if (delReservedBit == true)
+ offset--;
+
+ p_pkg_str[len_index] = offset - len_index - 1;
+ }
+ /* Sprint and Verizon issue */
+ /* 3. Validity Period */
+ /*
+ if (p_msg->val_period.format == SMS_3GPP2_TIME_RELATIVE) {
+ p_pkg_str[offset++] = SMS_BEARER_VALIDITY_PERIOD_RELATIVE;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->val_period.time.rel_time.rel_time;
+
+ } else if (p_msg->val_period.format == SMS_3GPP2_TIME_ABSOLUTE){
+ p_pkg_str[offset++] = SMS_BEARER_VALIDITY_PERIOD_ABSOLUTE;
+ p_pkg_str[offset++] = 6;
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.year);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.month);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.day);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.hours);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.minutes);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->val_period.time.abs_time.seconds);
+ }
+ */
+
+ /* 4. Deferred Delivery Time */
+ if (p_msg->defer_val_period.format == SMS_3GPP2_TIME_RELATIVE) {
+ p_pkg_str[offset++] = SMS_BEARER_DEFERRED_DELIVERY_TIME_RELATIVE;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->defer_val_period.time.rel_time.rel_time;
+
+ } else if (p_msg->defer_val_period.format == SMS_3GPP2_TIME_ABSOLUTE) {
+ p_pkg_str[offset++] = SMS_BEARER_DEFERRED_DELIVERY_TIME_ABSOLUTE;
+ p_pkg_str[offset++] = 6;
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.year);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.month);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.day);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.hours);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.minutes);
+ p_pkg_str[offset++] = _convert_to_BCD(p_msg->defer_val_period.time.abs_time.seconds);
+ }
+
+ /* 5. Priority Indicator */
+ if (p_msg->priority >= SMS_PRIORITY_NORMAL && p_msg->priority <= SMS_PRIORITY_EMERGENCY) {
+ p_pkg_str[offset++] = SMS_BEARER_PRIORITY_INDICATOR;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->priority << 6;
+ }
+
+ /* Sprint and Verizon issue */
+ /* 6. Privacy Indicator */
+ /*
+ if (p_msg->privacy >= SMS_PRIVACY_NOT_RESTRICTED && p_msg->privacy <= SMS_PRIVACY_SECRET) {
+ p_pkg_str[offset++] = SMS_BEARER_PRIVACY_INDICATOR;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->privacy << 6;
+ }
+ */
+
+ /* 7. Reply Option */
+ if (p_msg->reply_opt.user_ack_req | p_msg->reply_opt.deliver_ack_req | p_msg->reply_opt.read_ack_req | p_msg->reply_opt.report_req) {
+ p_pkg_str[offset++] = SMS_BEARER_REPLY_OPTION;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset] |= p_msg->reply_opt.user_ack_req << 7;
+ p_pkg_str[offset] |= p_msg->reply_opt.deliver_ack_req << 6;
+ p_pkg_str[offset] |= p_msg->reply_opt.read_ack_req << 5;
+ p_pkg_str[offset++] |= p_msg->reply_opt.report_req << 4;
+ }
+
+ /* 8. Alert on Message Delivery */
+ /* TODO : give condition */
+ /*
+ p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->alert_priority << 6;
+ */
+
+ /* 9. Language Indicator */
+ /* TODO : give condition */
+ /*
+ p_pkg_str[offset++] = SMS_BEARER_ALERT_ON_MSG_DELIVERY;
+ p_pkg_str[offset++] = 1;
+ p_pkg_str[offset++] = p_msg->language;
+ */
+
+ /* 10. Call-back Number */
+ if (p_msg->callback_number.addr_len > 0) {
+ p_pkg_str[offset++] = SMS_BEARER_CALLBACK_NUMBER;
+
+ int len_index = offset++;
+
+ p_pkg_str[offset] |= p_msg->callback_number.digit_mode << 7;
+
+ if (p_msg->callback_number.digit_mode == false) {
+ p_pkg_str[offset++] |= (p_msg->callback_number.addr_len & 0xfe) >> 1;
+ p_pkg_str[offset] |= (p_msg->callback_number.addr_len & 0x01) << 7;
+ int addr_len = Sms3gpp2ParamCodec::instance()->convertDigitToDTMF(p_msg->callback_number.szData, p_msg->callback_number.addr_len, 1, p_pkg_str+offset);
+ offset += addr_len;
+ } else if (p_msg->callback_number.digit_mode == true) {
+ p_pkg_str[offset] |= p_msg->callback_number.number_type << 6;
+ p_pkg_str[offset++] |= p_msg->callback_number.number_plan;
+ p_pkg_str[offset++] = p_msg->callback_number.addr_len;
+ memcpy(p_pkg_str+offset, p_msg->callback_number.szData, p_msg->callback_number.addr_len);
+ offset += p_msg->callback_number.addr_len;
+ }
+
+ p_pkg_str[len_index] = offset- len_index - 1;
+ }
+
+ /* 11. Multiple Encoding User Data */
+ /* Omitted */
+
+ /* 12. Message Deposit Index */
+ /* Omitted */
+
+ /* 13. Service Category Program Results */
+ /* Omitted */
+
+ MSG_END();
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::decodeMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_msg_s *p_msg)
+{
+ MSG_BEGIN();
+
+ int decodelen = 0;
+
+ char mti = p_pkg_str[0] & 0xff;
+
+ switch (mti) {
+ case SMS_TRANS_P2P_MSG:
+ p_msg->type = SMS_TRANS_P2P_MSG;
+ decodelen = decodeP2PMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.p2p_msg));
+ break;
+ case SMS_TRANS_BROADCAST_MSG:
+ p_msg->type = SMS_TRANS_BROADCAST_MSG;
+ decodelen = decodeCBMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.cb_msg));
+ break;
+ case SMS_TRANS_ACK_MSG:
+ p_msg->type = SMS_TRANS_ACK_MSG;
+ decodelen = decodeAckMsg(p_pkg_str+1, pkg_len-1, &(p_msg->data.ack_msg));
+ break;
+ default:
+ p_msg->type = SMS_TRANS_TYPE_RESERVED;
+ break;
+ }
+
+ MSG_END();
+
+ return decodelen+1;
+}
+
+
+int Sms3gpp2MsgCodec::decodeP2PMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_p2p_msg_s *p_p2p)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len = 0;
+
+ while (offset < pkg_len) {
+ switch (p_pkg_str[offset]) {
+ case 0x00:
+ /* Teleservice Identifier */
+ offset += decodeTeleId(p_pkg_str+offset, pkg_len, &(p_p2p->telesvc_id));
+ break;
+ case 0x01:
+ /* Service Category */
+ offset += decodeSvcCtg(p_pkg_str+offset, pkg_len, &(p_p2p->svc_ctg));
+ break;
+ case 0x02:
+ case 0x04:
+ /* Address */
+ offset += decodeAddress(p_pkg_str+offset, pkg_len, &(p_p2p->address));
+ break;
+ case 0x03:
+ case 0x05:
+ /* Subaddress */
+ offset += decodeSubAddress(p_pkg_str+offset, pkg_len, &(p_p2p->sub_address));
+ break;
+ case 0x06:
+ /* Bearer Reply Option*/
+ offset += 2;
+ p_p2p->reply_seq = (sms_3gpp2_trans_reply_seq_t)(p_pkg_str[offset] >> 2);
+ offset++;
+ break;
+ case 0x08:
+ /* Bearer Data */
+ tmp_len = p_pkg_str[++offset];
+ decodeP2PTelesvcMsg(p_pkg_str+offset+1, tmp_len, &p_p2p->telesvc_msg);
+ offset += (tmp_len+1);
+ break;
+ default:
+ break;
+ }
+ }
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::decodeCBMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_broadcast_msg_s *p_cb)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len = 0;
+
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x01) {
+ /* Service Category */
+ offset += decodeTeleId(p_pkg_str+offset, pkg_len, &(p_cb->svc_ctg));
+ } else if (p_pkg_str[offset] == 0x08) {
+ /* Bearer Data */
+ tmp_len = p_pkg_str[++offset];
+ if (p_cb->svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && p_cb->svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST) {
+ decodeCBBearerData(p_pkg_str+offset+1, tmp_len, &(p_cb->telesvc_msg), true);
+ } else {
+ decodeCBBearerData(p_pkg_str+offset+1, tmp_len, &(p_cb->telesvc_msg), false);
+ }
+
+ offset += (tmp_len+1);
+ }
+ }
+
+ MSG_END();
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::decodeAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_ack_msg_s *p_ack)
+{
+ MSG_BEGIN();
+
+ int offset = 0;
+
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x04) {
+ /* Destination Address */
+ offset += decodeAddress(p_pkg_str+offset, pkg_len, &(p_ack->address));
+ } else if (p_pkg_str[offset] == 0x05) {
+ /* Destination Subaddress */
+ offset += decodeSubAddress(p_pkg_str+offset, pkg_len, &(p_ack->sub_address));
+ } else if (p_pkg_str[offset] == 0x07) {
+ /* Cause Codes */
+ offset += 2;
+ p_ack->cause_code.reply_seq = (sms_3gpp2_trans_reply_seq_t)p_pkg_str[offset] >> 2;
+ switch (p_pkg_str[offset++] & 0x03) {
+ case 0:
+ p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_NONE;
+ break;
+ case 1:
+ /* Reserved */
+ break;
+ case 2:
+ p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
+ break;
+ case 3:
+ p_ack->cause_code.error_class = SMS_TRANS_ERR_CLASS_PERMANENT;
+ break;
+ }
+
+ if (p_ack->cause_code.error_class != SMS_TRANS_ERR_CLASS_NONE) {
+ p_ack->cause_code.cause_code = (sms_3gpp2_trans_cause_code_t)p_pkg_str[offset++];
+ }
+ }
+ }
+
+ MSG_END();
+
+ return offset;
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PTelesvcMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_msg_s *p_telesvc)
+{
+ MSG_BEGIN();
+
+ p_telesvc->type = findMsgType(p_pkg_str, pkg_len);
+
+ MSG_DEBUG("Msg Type = [%d]", p_telesvc->type);
+
+ switch (p_telesvc->type) {
+ case SMS_TYPE_DELIVER:
+ decodeP2PDeliverMsg(p_pkg_str, pkg_len, &p_telesvc->data.deliver);
+ break;
+ case SMS_TYPE_SUBMIT:
+ decodeP2PSubmitMsg(p_pkg_str, pkg_len, &p_telesvc->data.submit);
+ break;
+ case SMS_TYPE_DELIVERY_ACK:
+ decodeP2PDeliveryAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.delivery_ack);
+ break;
+ case SMS_TYPE_USER_ACK:
+ decodeP2PUserAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.user_ack);
+ break;
+ case SMS_TYPE_READ_ACK:
+ decodeP2PReadAckMsg(p_pkg_str, pkg_len, &p_telesvc->data.read_ack);
+ break;
+ case SMS_TYPE_SUBMIT_REPORT:
+ /* decodeP2PSubmitReportMsg(p_pkg_str, pkg_len, &p_telesvc->data.report); */
+ break;
+ default:
+ break;
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PDeliverMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_deliver_s *p_del)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len, tmp_off;
+ unsigned short tmp_param_s;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ MSG_DEBUG("current offset = [%d] [%x]", offset, p_pkg_str[offset]);
+
+ switch (p_pkg_str[offset]) {
+ case 0x00:
+ /* Message Identifier */
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del->msg_id));
+ break;
+ case 0x01:
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+ decodeUserData(tmp_str, tmp_len, &(p_del->user_data));
+ offset += tmp_len;
+ break;
+ case 0x03:
+ /* Message Center Time Stamp */
+ offset += 2;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_del->time_stamp));
+ break;
+ case 0x04:
+ /* Validity Period - Absolute */
+ offset += 2;
+ p_del->val_period.format = SMS_3GPP2_TIME_ABSOLUTE;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_del->val_period.time.abs_time));
+ break;
+ case 0x05:
+ /* Validity Period - Relative */
+ offset += 2;
+ p_del->val_period.format = SMS_3GPP2_TIME_RELATIVE;
+ p_del->val_period.time.rel_time.rel_time = (sms_3gpp2_relative_time_t)p_pkg_str[offset++];
+ break;
+ case 0x08:
+ /* Priority Indicator */
+ offset += 2;
+ p_del->priority = (sms_3gpp2_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ break;
+ case 0x09:
+ /* Privacy Indicator */
+ offset += 2;
+ p_del->privacy = (sms_3gpp2_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ break;
+ case 0x0a:
+ /* Reply Option */
+ offset += 2;
+
+ if (p_pkg_str[offset] & 0x80)
+ p_del->reply_opt.user_ack_req = true;
+ else
+ p_del->reply_opt.user_ack_req = false;
+
+ if (p_pkg_str[offset] & 0x40)
+ p_del->reply_opt.deliver_ack_req = true;
+ else
+ p_del->reply_opt.deliver_ack_req = false;
+
+ if (p_pkg_str[offset] & 0x20)
+ p_del->reply_opt.read_ack_req = true;
+ else
+ p_del->reply_opt.read_ack_req = false;
+
+ if (p_pkg_str[offset] & 0x10)
+ p_del->reply_opt.report_req = true;
+ else
+ p_del->reply_opt.report_req = false;
+
+ offset++;
+ break;
+ case 0x0b:
+ /* Number of Message */
+ offset += 2;
+ p_del->num_msg = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+ break;
+ case 0x0c:
+ /* Alert on Message Delivery */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ if (tmp_len > 0)
+ p_del->alert_priority = (sms_3gpp2_alert_priority_t)((p_pkg_str[offset] & 0xc0) >> 6);
+ offset += tmp_len;
+ break;
+ case 0x0d:
+ /* Language Indicator */
+ offset += 2;
+ p_del->language = (sms_3gpp2_language_type_t)p_pkg_str[offset++];
+ break;
+ case 0x0e:
+ /* Call-Back Number */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_del->callback_number));
+
+ offset += tmp_len;
+ break;
+ case 0x0f:
+ /* Message Display Mode */
+ offset += 2;
+
+ p_del->display_mode = (sms_3gpp2_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ break;
+ case 0x10:
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ break;
+ case 0x11:
+ /* Message Deposit Index */
+ offset += 2;
+
+ memset(&tmp_param_s, 0x00, sizeof(unsigned short));
+ _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
+ p_del->deposit_id = tmp_param_s;
+
+ offset += 2;
+ break;
+ case 0x16:
+ /* Enhanced VMN */
+ offset++;
+ tmp_len = p_pkg_str[offset++];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+ tmp_off = 0;
+
+ p_del->enhanced_vmn.priority = (sms_3gpp2_priority_indicator_t)(p_pkg_str[offset] >> 6);
+ p_del->enhanced_vmn.password_req = p_pkg_str[offset] & 0x20 ? true : false;
+ p_del->enhanced_vmn.setup_req = p_pkg_str[offset] & 0x10 ? true : false;
+ p_del->enhanced_vmn.pw_change_req = p_pkg_str[offset] & 0x08 ? true : false;
+ _shiftNBit_for_decode(tmp_str, tmp_len, 5);
+
+ if (p_del->enhanced_vmn.setup_req || p_del->enhanced_vmn.pw_change_req) {
+ p_del->enhanced_vmn.min_pw_len = tmp_str[tmp_off] >> 4;
+ p_del->enhanced_vmn.max_pw_len = tmp_str[tmp_off++] & 0x0f;
+ }
+
+ p_del->enhanced_vmn.vm_num_unheard_msg = tmp_str[tmp_off++];
+ p_del->enhanced_vmn.vm_mailbox_alm_full = tmp_str[tmp_off] & 0x80 ? true : false;
+ p_del->enhanced_vmn.vm_mailbox_full = tmp_str[tmp_off] & 0x40 ? true : false;
+ p_del->enhanced_vmn.reply_allowed = tmp_str[tmp_off] & 0x20 ? true : false;
+ p_del->enhanced_vmn.fax_included = tmp_str[tmp_off] & 0x10 ? true : false;
+ p_del->enhanced_vmn.vm_len = ((tmp_str[tmp_off] & 0x0f) << 8) | tmp_str[tmp_off+1];
+ tmp_off += 2;
+ p_del->enhanced_vmn.vm_ret_day = tmp_str[tmp_off] >> 1;
+ _shiftNBit_for_decode(tmp_str, tmp_len, 7);
+ p_del->enhanced_vmn.vm_msg_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
+ tmp_off += 2;
+ p_del->enhanced_vmn.vm_mailbox_id = (tmp_str[tmp_off] << 8) | tmp_str[tmp_off+1];
+ tmp_off += 2;
+
+ p_del->enhanced_vmn.an_digit_mode = (sms_3gpp2_digit_mode_t)(tmp_str[tmp_off] & 0x80 ? true : false);
+ p_del->enhanced_vmn.an_number_type = (sms_3gpp2_number_type_t)((tmp_str[tmp_off] & 0x70) >> 4);
+ if (p_del->enhanced_vmn.an_digit_mode) {
+ p_del->enhanced_vmn.an_number_plan = (sms_3gpp2_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
+ p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
+ for (int i = 0; i < p_del->enhanced_vmn.an_num_field; i++) {
+ switch (tmp_str[tmp_off] & 0xf0) {
+ case 0x10:
+ case 0x20:
+ case 0x30:
+ case 0x40:
+ case 0x50:
+ case 0x60:
+ case 0x70:
+ case 0x80:
+ case 0x90:
+ p_del->enhanced_vmn.an_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
+ break;
+ case 0xa0:
+ p_del->enhanced_vmn.an_char[i] = '0';
+ break;
+ case 0xb0:
+ p_del->enhanced_vmn.an_char[i] = '*';
+ break;
+ case 0xc0:
+ p_del->enhanced_vmn.an_char[i] = '#';
+ break;
+ default:
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ }
+ } else {
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ p_del->enhanced_vmn.an_num_field = tmp_str[tmp_off++];
+ memset(p_del->enhanced_vmn.an_char, 0x00, sizeof(p_del->enhanced_vmn.an_char));
+ memcpy(p_del->enhanced_vmn.an_char, tmp_str+tmp_off, p_del->enhanced_vmn.an_num_field);
+ tmp_off += p_del->enhanced_vmn.an_num_field;
+ }
+
+ p_del->enhanced_vmn.cli_digit_mode = (sms_3gpp2_digit_mode_t)(tmp_str[offset] & 0x80 ? true : false);
+ p_del->enhanced_vmn.cli_number_type = (sms_3gpp2_number_type_t)(tmp_str[offset] & 0x70 >> 4);
+ if (p_del->enhanced_vmn.cli_digit_mode) {
+ p_del->enhanced_vmn.cli_number_plan = (sms_3gpp2_number_plan_t)(tmp_str[tmp_off++] & 0x0f);
+ p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
+ for (int i = 0; i < p_del->enhanced_vmn.cli_num_field; i++) {
+ switch (tmp_str[tmp_off] & 0xf0) {
+ case 0x10:
+ case 0x20:
+ case 0x30:
+ case 0x40:
+ case 0x50:
+ case 0x60:
+ case 0x70:
+ case 0x80:
+ case 0x90:
+ p_del->enhanced_vmn.cli_char[i] = ((tmp_str[tmp_off] & 0xf0) >> 4) + '0';
+ break;
+ case 0xa0:
+ p_del->enhanced_vmn.cli_char[i] = '0';
+ break;
+ case 0xb0:
+ p_del->enhanced_vmn.cli_char[i] = '*';
+ break;
+ case 0xc0:
+ p_del->enhanced_vmn.cli_char[i] = '#';
+ break;
+ default:
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ }
+ } else {
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ p_del->enhanced_vmn.cli_num_field = tmp_str[tmp_off++];
+ memset(p_del->enhanced_vmn.cli_char, 0x00, sizeof(p_del->enhanced_vmn.cli_char));
+ memcpy(p_del->enhanced_vmn.cli_char, tmp_str+tmp_off, p_del->enhanced_vmn.cli_num_field);
+ tmp_off += p_del->enhanced_vmn.cli_num_field;
+ }
+
+ offset += tmp_len;
+ break;
+ case 0x17:
+ /* Enhanced VMN Ack */
+ offset++;
+ tmp_len = p_pkg_str[offset++];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+ p_del->enhanced_vmn_ack.vm_mailbox_id = tmp_str[offset] << 8 | tmp_str[offset+1];
+ offset += 2;
+ p_del->enhanced_vmn_ack.vm_num_unheard_msg = tmp_str[offset++];
+ p_del->enhanced_vmn_ack.num_delete_ack = tmp_str[offset] >> 5;
+ p_del->enhanced_vmn_ack.num_play_ack = (tmp_str[offset] & 0x1c) >> 2;
+ _shiftNBit_for_decode(tmp_str, tmp_len, 6);
+ for (int i = 0; i < p_del->enhanced_vmn_ack.num_delete_ack; i++) {
+ p_del->enhanced_vmn_ack.da_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
+ offset += 2;
+ }
+ for (int i = 0; i < p_del->enhanced_vmn_ack.num_play_ack; i++) {
+ p_del->enhanced_vmn_ack.pa_vm_msg_id[i] = tmp_str[offset] << 8 | tmp_str[offset+1];
+ offset += 2;
+ }
+ break;
+ default:
+ /* skip unrecognized sub parameters */
+ offset++;
+ tmp_len = p_pkg_str[offset++];
+ offset += tmp_len;
+ break;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_submit_s *p_sub)
+{
+ int offset = 0, tmp_len;
+ unsigned short tmp_param_s;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x00) {
+ /* Message Identifier */
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_sub->msg_id));
+ } else if (p_pkg_str[offset] == 0x01) {
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+
+ decodeUserData(tmp_str, tmp_len, &(p_sub->user_data));
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x04) {
+ /* Validity Period - Absolute */
+ offset += 2;
+ p_sub->val_period.format = SMS_3GPP2_TIME_ABSOLUTE;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_sub->val_period.time.abs_time));
+ } else if (p_pkg_str[offset] == 0x05) {
+ /* Validity Period - Relative */
+ offset += 2;
+ p_sub->val_period.format = SMS_3GPP2_TIME_RELATIVE;
+ p_sub->val_period.time.rel_time.rel_time = (sms_3gpp2_relative_time_t)p_pkg_str[offset++];
+ } else if (p_pkg_str[offset] == 0x06) {
+ /* Deferred Delivery Time - Absolute */
+ offset += 2;
+ p_sub->defer_val_period.format = SMS_3GPP2_TIME_ABSOLUTE;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_sub->defer_val_period.time.abs_time));
+ } else if (p_pkg_str[offset] == 0x07) {
+ /* Deferred Delivery Time - Relative */
+ offset += 2;
+ p_sub->defer_val_period.format = SMS_3GPP2_TIME_RELATIVE;
+ p_sub->defer_val_period.time.rel_time.rel_time = (sms_3gpp2_relative_time_t)p_pkg_str[offset++];
+ } else if (p_pkg_str[offset] == 0x08) {
+ /* Priority indicator */
+ offset += 2;
+ p_sub->priority = (sms_3gpp2_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ } else if (p_pkg_str[offset] == 0x09) {
+ /* Privacy indicator */
+ offset += 2;
+ p_sub->privacy = (sms_3gpp2_privacy_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ } else if (p_pkg_str[offset] == 0x0a) {
+ /* Reply Option */
+ offset += 2;
+
+ if (p_pkg_str[offset] & 0x80)
+ p_sub->reply_opt.user_ack_req = true;
+ else
+ p_sub->reply_opt.user_ack_req = false;
+
+ if (p_pkg_str[offset] & 0x40)
+ p_sub->reply_opt.deliver_ack_req = true;
+ else
+ p_sub->reply_opt.deliver_ack_req = false;
+
+ if (p_pkg_str[offset] & 0x20)
+ p_sub->reply_opt.read_ack_req = true;
+ else
+ p_sub->reply_opt.read_ack_req = false;
+
+ if (p_pkg_str[offset] & 0x10)
+ p_sub->reply_opt.report_req = true;
+ else
+ p_sub->reply_opt.report_req = false;
+
+ offset++;
+ } else if (p_pkg_str[offset] == 0x0c) {
+ /* Alert on Message Delivery */
+ offset += 2;
+
+ p_sub->alert_priority = (sms_3gpp2_alert_priority_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ } else if (p_pkg_str[offset] == 0x0d) {
+ /* Language Indicator */
+ offset += 2;
+
+ p_sub->language = (sms_3gpp2_language_type_t)p_pkg_str[offset++];
+ } else if (p_pkg_str[offset] == 0x0e) {
+ /* Call-Back Number */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_sub->callback_number));
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x10) {
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x11) {
+ /* Message Deposit Index */
+ offset += 2;
+
+ memset(&tmp_param_s, 0x00, sizeof(unsigned short));
+ _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
+ p_sub->deposit_id = tmp_param_s;
+
+ offset += 2;
+ }
+ }
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_user_ack_s *p_user_ack)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len;
+ unsigned short tmp_param_s;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x00) {
+ /* Message Identifier */
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_user_ack->msg_id));
+ } else if (p_pkg_str[offset] == 0x01) {
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+
+ decodeUserData(tmp_str, tmp_len, &(p_user_ack->user_data));
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x02) {
+ /* User Response Code */
+ offset += 2;
+ p_user_ack->resp_code = p_pkg_str[offset++];
+ } else if (p_pkg_str[offset] == 0x03) {
+ /* Message Center Time Stamp */
+ offset += 2;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_user_ack->time_stamp));
+ } else if (p_pkg_str[offset] == 0x10) {
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x11) {
+ /* Message Deposit Index */
+ offset += 2;
+
+ memset(&tmp_param_s, 0x00, sizeof(unsigned short));
+ _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
+ p_user_ack->deposit_id = tmp_param_s;
+
+ offset += 2;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_read_ack_s *p_read_ack)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len;
+ unsigned short tmp_param_s;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x00) {
+ /* Message Identifier */
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_read_ack->msg_id));
+ } else if (p_pkg_str[offset] == 0x01) {
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+
+ decodeUserData(tmp_str, tmp_len, &(p_read_ack->user_data));
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x03) {
+ /* Message Center Time Stamp */
+ offset += 2;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_read_ack->time_stamp));
+ } else if (p_pkg_str[offset] == 0x10) {
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x11) {
+ /* Message Deposit Index */
+ offset += 2;
+
+ memset(&tmp_param_s, 0x00, sizeof(unsigned short));
+ _copy_char_to_short(&tmp_param_s, p_pkg_str+offset);
+ p_read_ack->deposit_id = tmp_param_s;
+
+ offset += 2;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_report_s *p_sub_report)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ switch (p_pkg_str[offset]) {
+ case 0x00:
+ /* Message Identifier */
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_sub_report->msg_id));
+ break;
+ case 0x01:
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+ decodeUserData(tmp_str, tmp_len, &(p_sub_report->user_data));
+ offset += tmp_len;
+ break;
+ case 0x0d:
+ /* Language Indicator */
+ offset += 2;
+ p_sub_report->language = (sms_3gpp2_language_type_t)p_pkg_str[offset++];
+ break;
+ case 0x10:
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ break;
+ case 0x15:
+ /* TP-Failure Cause */
+ offset += 2;
+ p_sub_report->tp_fail_cause = p_pkg_str[offset++];
+ break;
+ default:
+ break;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_deliver_ack_s *p_del_ack)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ switch (p_pkg_str[offset]) {
+ case 0x00:
+ /* Message Identifier */
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_del_ack->msg_id));
+ break;
+ case 0x01:
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+
+ decodeUserData(tmp_str, tmp_len, &(p_del_ack->user_data));
+
+ offset += tmp_len;
+ break;
+ case 0x03:
+ /* Message Center Time Stamp */
+ offset += 2;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_del_ack->time_stamp));
+ break;
+ case 0x10:
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ break;
+ case 0x14:
+ /* Message Status */
+ offset += 2;
+ p_del_ack->msg_status = (sms_3gpp2_status_code_t)p_pkg_str[offset++];
+ break;
+ default:
+ break;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeCBBearerData(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_msg_s *p_telesvc, bool isCMAS)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len;
+ unsigned char tmp_str[pkg_len+1];
+
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x00) {
+ /* Message Identifier */
+ p_telesvc->type = SMS_TYPE_DELIVER;
+ offset += decodeMsgId(p_pkg_str+offset, 5, &(p_telesvc->data.deliver.msg_id));
+ } else if (p_pkg_str[offset] == 0x01) {
+ /* User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+
+ if (isCMAS)
+ decodeCMASData(tmp_str, tmp_len, &(p_telesvc->data.deliver.cmas_data));
+ else
+ decodeUserData(tmp_str, tmp_len, &(p_telesvc->data.deliver.user_data));
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x03) {
+ /* Message Center Time Stamp */
+ offset += 2;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_telesvc->data.deliver.time_stamp));
+ } else if (p_pkg_str[offset] == 0x04) {
+ /* Validity Period - Absolute */
+ offset += 2;
+ p_telesvc->data.deliver.val_period.format = SMS_3GPP2_TIME_ABSOLUTE;
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_telesvc->data.deliver.val_period.time.abs_time));
+ } else if (p_pkg_str[offset] == 0x05) {
+ /* Validity Period - Relative */
+ offset += 2;
+ p_telesvc->data.deliver.val_period.format = SMS_3GPP2_TIME_RELATIVE;
+ p_telesvc->data.deliver.val_period.time.rel_time.rel_time = (sms_3gpp2_relative_time_t)p_pkg_str[offset++];
+ } else if (p_pkg_str[offset] == 0x08) {
+ /* Priority indicator */
+ offset += 2;
+ p_telesvc->data.deliver.priority = (sms_3gpp2_priority_indicator_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ } else if (p_pkg_str[offset] == 0x0c) {
+ /* Alert on Message Delivery */
+ offset += 2;
+
+ p_telesvc->data.deliver.alert_priority = (sms_3gpp2_alert_priority_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ } else if (p_pkg_str[offset] == 0x0d) {
+ /* Language Indicator */
+ offset += 2;
+
+ p_telesvc->data.deliver.language = (sms_3gpp2_language_type_t)p_pkg_str[offset++];
+ } else if (p_pkg_str[offset] == 0x0e) {
+ /* Call-Back Number */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ decodeCallBackNum(&p_pkg_str[offset], tmp_len, &(p_telesvc->data.deliver.callback_number));
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x0f) {
+ /* Message Display Mode */
+ offset += 2;
+
+ p_telesvc->data.deliver.display_mode = (sms_3gpp2_display_mode_t)((p_pkg_str[offset++] & 0xc0) >> 6);
+ } else if (p_pkg_str[offset] == 0x10) {
+ /* Multiple Encoding User Data */
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+
+ /* TODO */
+
+ offset += tmp_len;
+ }
+ }
+
+ MSG_END();
+}
+
+
+int Sms3gpp2MsgCodec::decodeTeleId(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_telesvc_id_t *tele_id)
+{
+ int offset = 0;
+ unsigned short tmp_param_s;
+
+ offset += 2;
+
+ _copy_char_to_short(&tmp_param_s, &p_pkg_str[offset]);
+
+ switch (tmp_param_s) {
+ case SMS_TRANS_TELESVC_CMT_91:
+ *tele_id = SMS_TRANS_TELESVC_CMT_91;
+ break;
+ case SMS_TRANS_TELESVC_CPT_95:
+ *tele_id = SMS_TRANS_TELESVC_CPT_95;
+ break;
+ case SMS_TRANS_TELESVC_CMT_95:
+ *tele_id = SMS_TRANS_TELESVC_CMT_95;
+ break;
+ case SMS_TRANS_TELESVC_VMN_95:
+ *tele_id = SMS_TRANS_TELESVC_VMN_95;
+ break;
+ case SMS_TRANS_TELESVC_WAP:
+ *tele_id = SMS_TRANS_TELESVC_WAP;
+ break;
+ case SMS_TRANS_TELESVC_WEMT:
+ *tele_id = SMS_TRANS_TELESVC_WEMT;
+ break;
+ case SMS_TRANS_TELESVC_SCPT:
+ *tele_id = SMS_TRANS_TELESVC_SCPT;
+ break;
+ case SMS_TRANS_TELESVC_CATPT:
+ *tele_id = SMS_TRANS_TELESVC_CATPT;
+ break;
+ default:
+ *tele_id = SMS_TRANS_TELESVC_RESERVED;
+ break;
+ }
+
+ return offset+2;
+}
+
+
+int Sms3gpp2MsgCodec::decodeSvcCtg(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_svc_ctg_t *svc_ctg)
+{
+ int offset = 0;
+ unsigned short tmp_param_s;
+
+ offset += 2;
+
+ _copy_char_to_short(&tmp_param_s, &p_pkg_str[offset]);
+ if ((tmp_param_s >= SMS_TRANS_SVC_CTG_UNKNOWN && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1)
+ || (tmp_param_s >= SMS_TRANS_SVC_CTG_KDDI_CORP_MIN2 && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX2)
+ || (tmp_param_s >= SMS_TRANS_SVC_CTG_KDDI_CORP_MIN3 && tmp_param_s <= SMS_TRANS_SVC_CTG_KDDI_CORP_MAX3)) {
+ *svc_ctg = (sms_3gpp2_trans_svc_ctg_t)tmp_param_s;
+ } else {
+ *svc_ctg = SMS_TRANS_SVC_CTG_RESERVED;
+ }
+
+ return offset+2;
+}
+
+
+int Sms3gpp2MsgCodec::decodeAddress(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_addr_s *addr)
+{
+ int offset = 0, tmp_len = 0;
+ unsigned char tmp_str[pkg_len+1];
+
+ tmp_len = p_pkg_str[++offset];
+
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset+1, tmp_len);
+
+ offset += (tmp_len+1);
+
+ if (tmp_str[0] & 0x80)
+ addr->digit_mode = true;
+ else
+ addr->digit_mode = false;
+
+ if (tmp_str[0] & 0x40)
+ addr->number_mode = true;
+ else
+ addr->number_mode = false;
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 2);
+
+ if (addr->digit_mode == false) {
+ addr->addr_len = tmp_str[0];
+
+ memset(addr->szData, 0x00, sizeof(addr->szData));
+
+ for (unsigned int i = 0; i < addr->addr_len; i++) {
+ switch (tmp_str[1] & 0xf0) {
+ case 0x10:
+ case 0x20:
+ case 0x30:
+ case 0x40:
+ case 0x50:
+ case 0x60:
+ case 0x70:
+ case 0x80:
+ case 0x90:
+ addr->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
+ break;
+ case 0x00:
+ /* sprint issue */
+ case 0xa0:
+ addr->szData[i] = '0';
+ break;
+ case 0xb0:
+ addr->szData[i] = '*';
+ break;
+ case 0xc0:
+ addr->szData[i] = '#';
+ break;
+ default:
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ }
+ } else if (addr->digit_mode == true) {
+ if (addr->number_mode == false) {
+ /* digit mode = 1, number mode = 0 */
+ switch (tmp_str[0] & 0xe0) {
+ case 0x00:
+ addr->number_type = SMS_NUMBER_TYPE_UNKNOWN;
+ break;
+ case 0x20:
+ addr->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
+ break;
+ case 0x40:
+ addr->number_type = SMS_NUMBER_TYPE_NATIONAL;
+ break;
+ case 0x60:
+ addr->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
+ break;
+ case 0x80:
+ addr->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
+ break;
+ case 0xa0:
+ addr->number_type = SMS_NUMBER_TYPE_RESERVED_5;
+ break;
+ case 0xc0:
+ addr->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
+ break;
+ case 0xe0:
+ addr->number_type = SMS_NUMBER_TYPE_RESERVED_7;
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 3);
+
+ switch (tmp_str[0] & 0xf0) {
+ case 0x00:
+ addr->number_plan = SMS_3GPP2_NPI_UNKNOWN;
+ break;
+ case 0x10:
+ addr->number_plan = SMS_3GPP2_NPI_ISDN;
+ break;
+ case 0x30:
+ addr->number_plan = SMS_3GPP2_NPI_DATA;
+ break;
+ case 0x40:
+ addr->number_plan = SMS_3GPP2_NPI_TELEX;
+ break;
+ case 0x90:
+ addr->number_plan = SMS_3GPP2_NPI_PRIVATE;
+ break;
+ default:
+ addr->number_plan = SMS_3GPP2_NPI_RESERVED;
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ } else if (addr->number_mode == true) {
+ /* digit mode = 1, number mode = 1 */
+ switch (tmp_str[0] & 0xe0) {
+ case 0x00:
+ addr->number_type = SMS_TRANS_DNET_UNKNOWN;
+ break;
+ case 0x20:
+ addr->number_type = SMS_TRANS_DNET_INTERNET_PROTOCOL;
+ break;
+ case 0x40:
+ addr->number_type = SMS_TRANS_DNET_INTERNET_MAIL_ADDR;
+ break;
+ default:
+ addr->number_type = SMS_TRANS_DNET_RESERVED;
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 3);
+ }
+
+ addr->addr_len = tmp_str[0];
+
+ memset(addr->szData, 0x00, sizeof(addr->szData));
+ memcpy(addr->szData, &tmp_str[1], addr->addr_len);
+ }
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::decodeSubAddress(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_sub_addr_s *sub_addr)
+{
+ int offset = 0, tmp_len = 0;
+ unsigned char tmp_str[pkg_len+1];
+
+ tmp_len = p_pkg_str[++offset];
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset+1, tmp_len);
+
+ offset += (tmp_len+1);
+
+ switch (tmp_str[0] & 0xe0) {
+ case 0x00:
+ sub_addr->type = SMS_TRANS_SUB_ADDR_NSAP;
+ break;
+ case 0x20:
+ sub_addr->type = SMS_TRANS_SUB_ADDR_USER;
+ break;
+ default:
+ sub_addr->type = SMS_TRANS_SUB_ADDR_RESERVED;
+ break;
+ }
+
+ if (tmp_str[0] & 0x10)
+ sub_addr->odd = true;
+ else
+ sub_addr->odd = false;
+
+ _shiftNBit_for_decode(tmp_str, tmp_len, 4);
+ memset(sub_addr->szData, 0x00, sizeof(sub_addr->szData));
+ memcpy(sub_addr->szData, tmp_str+1, tmp_str[0]);
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::decodeMsgId(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_msg_id_s *p_msg_id)
+{
+ int offset = 0;
+ unsigned short tmp_param_s;
+ unsigned char tmp_str[pkg_len+1];
+
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, &p_pkg_str[offset+2], 3);
+
+ _shiftNBit_for_decode(tmp_str, 3, 4);
+
+ memset(&tmp_param_s, 0x00, sizeof(unsigned short));
+ _copy_char_to_short(&tmp_param_s, tmp_str);
+
+ p_msg_id->msg_id = tmp_param_s;
+ if (tmp_str[2] & 0x80)
+ p_msg_id->header_ind = true;
+ else
+ p_msg_id->header_ind = false;
+
+ offset += 5;
+
+ return offset;
+}
+
+
+void Sms3gpp2MsgCodec::decodeCallBackNum(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_addr_s *p_callback)
+{
+ int offset = 0;
+ unsigned char tmp_str[pkg_len+1];
+
+ if (p_pkg_str[offset] & 0x80) {
+ p_callback->digit_mode = true;
+
+ switch (p_pkg_str[offset] & 0x70) {
+ case 0x00:
+ p_callback->number_type = SMS_NUMBER_TYPE_UNKNOWN;
+ break;
+ case 0x10:
+ p_callback->number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
+ break;
+ case 0x20:
+ p_callback->number_type = SMS_NUMBER_TYPE_NATIONAL;
+ break;
+ case 0x30:
+ p_callback->number_type = SMS_NUMBER_TYPE_NETWORK_SPECIFIC;
+ break;
+ case 0x40:
+ p_callback->number_type = SMS_NUMBER_TYPE_SUBSCRIBER;
+ break;
+ case 0x50:
+ p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_5;
+ break;
+ case 0x60:
+ p_callback->number_type = SMS_NUMBER_TYPE_ABBREVIATED;
+ break;
+ case 0x70:
+ p_callback->number_type = SMS_NUMBER_TYPE_RESERVED_7;
+ break;
+ default:
+ break;
+ }
+
+ switch (p_pkg_str[offset++] & 0x0f) {
+ case 0x00:
+ p_callback->number_plan = SMS_3GPP2_NPI_UNKNOWN;
+ break;
+ case 0x01:
+ p_callback->number_plan = SMS_3GPP2_NPI_ISDN;
+ break;
+ case 0x03:
+ p_callback->number_plan = SMS_3GPP2_NPI_DATA;
+ break;
+ case 0x04:
+ p_callback->number_plan = SMS_3GPP2_NPI_TELEX;
+ break;
+ case 0x09:
+ p_callback->number_plan = SMS_3GPP2_NPI_PRIVATE;
+ break;
+ case 0x0f:
+ default:
+ p_callback->number_plan = SMS_3GPP2_NPI_RESERVED;
+ break;
+ }
+
+ p_callback->addr_len = p_pkg_str[offset++];
+ memset(p_callback->szData, 0x00, sizeof(p_callback->szData));
+
+ if (p_callback->number_type == SMS_NUMBER_TYPE_INTERNATIONAL) {
+ memcpy(&(p_callback->szData[1]), p_pkg_str+offset, p_callback->addr_len);
+ if (p_callback->szData[1] != '\0') {
+ p_callback->szData[0] = '+';
+ }
+ } else {
+ memcpy(p_callback->szData, p_pkg_str+offset, p_callback->addr_len);
+ }
+ } else {
+ p_callback->digit_mode = false;
+
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, pkg_len);
+
+ _shiftNBit_for_decode(tmp_str, pkg_len, 1);
+
+ p_callback->addr_len = tmp_str[0];
+
+ memset(p_callback->szData, 0x00, sizeof(p_callback->szData));
+
+ for (unsigned int i = 0; i < p_callback->addr_len; i++) {
+ switch (tmp_str[1] & 0xf0) {
+ case 0x10:
+ case 0x20:
+ case 0x30:
+ case 0x40:
+ case 0x50:
+ case 0x60:
+ case 0x70:
+ case 0x80:
+ case 0x90:
+ p_callback->szData[i] = ((tmp_str[1] & 0xf0) >> 4) + '0';
+ break;
+ case 0xa0:
+ p_callback->szData[i] = '0';
+ break;
+ case 0xb0:
+ p_callback->szData[i] = '*';
+ break;
+ case 0xc0:
+ p_callback->szData[i] = '#';
+ break;
+ default :
+ break;
+ }
+
+ _shiftNBit_for_decode(tmp_str, pkg_len, 4);
+ }
+ }
+}
+
+
+int Sms3gpp2MsgCodec::decodeAbsTime(const unsigned char *p_pkg_str, sms_3gpp2_time_abs_s *p_time_abs)
+{
+ int offset = 0;
+
+ p_time_abs->year = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+ p_time_abs->month = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+ p_time_abs->day = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+ p_time_abs->hours = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+ p_time_abs->minutes = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+ p_time_abs->seconds = (((p_pkg_str[offset] & 0xf0) >> 4) * 10) + (p_pkg_str[offset] & 0x0f);
+ offset++;
+
+ return offset;
+}
+
+
+int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *dest, int src_size)
+{
+ int i, j;
+ int shift = 0;
+
+ unsigned char *tmp = (unsigned char *)calloc(1, src_size+1);
+ for (i = 0; i < src_size; i++) {
+ tmp[i] = src[i] << 1;
+ }
+
+ j = 0;
+ for (i = 0; i < src_size; i++) {
+ shift = j % 7;
+ dest[j++] = (tmp[i] << shift) + (tmp[i+1] >> (7-shift));
+ if (shift == 6) {
+ i++;
+ }
+ }
+
+ if (tmp) {
+ free(tmp);
+ tmp = NULL;
+ }
+
+ return j;
+}
+
+
+void Sms3gpp2MsgCodec::decodeCMASData(unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_cmasdata_s *p_cmas)
+{
+ MSG_BEGIN();
+
+ int offset = 0, tmp_len = 0;
+ unsigned char tmp_str[pkg_len+1];
+
+ if ((p_pkg_str[offset] & 0xf8) != 0x00) {
+ MSG_ERR("Wrong Encode Type = [%d]!! The type must be 0", (p_pkg_str[offset]&0xf8)>>3);
+ return;
+ } else {
+ _shiftNBit_for_decode(p_pkg_str, pkg_len, 5);
+
+ offset++;
+
+ if (p_pkg_str[offset++] != 0x00) {
+ MSG_ERR("Wrong protocol version = [%d]!! This field must be 0", p_pkg_str[offset-1]);
+ p_cmas->is_wrong_recode_type = TRUE;
+ return;
+ }
+
+ while (offset < pkg_len - 1) {
+ if (p_pkg_str[offset] == 0x00) {
+ MSG_DEBUG("Type 0 Decode!");
+ offset++;
+ tmp_len = p_pkg_str[offset++];
+ MSG_DEBUG("Type 0 length = [%d]", tmp_len);
+ memset(tmp_str, 0x00, sizeof(tmp_str));
+ memcpy(tmp_str, p_pkg_str+offset, tmp_len);
+
+ switch (tmp_str[0] & 0xf8) {
+ case 0x00:
+ p_cmas->encode_type = SMS_ENCODE_OCTET;
+ break;
+ case 0x08:
+ p_cmas->encode_type = SMS_ENCODE_EPM;
+ break;
+ case 0x10:
+ p_cmas->encode_type = SMS_ENCODE_7BIT_ASCII;
+ break;
+ case 0x18:
+ p_cmas->encode_type = SMS_ENCODE_IA5;
+ break;
+ case 0x20:
+ p_cmas->encode_type = SMS_ENCODE_UNICODE;
+ break;
+ case 0x28:
+ p_cmas->encode_type = SMS_ENCODE_SHIFT_JIS;
+ break;
+ case 0x30:
+ p_cmas->encode_type = SMS_ENCODE_KOREAN;
+ break;
+ case 0x38:
+ p_cmas->encode_type = SMS_ENCODE_LATIN_HEBREW;
+ break;
+ case 0x40:
+ p_cmas->encode_type = SMS_ENCODE_LATIN;
+ break;
+ case 0x48:
+ p_cmas->encode_type = SMS_ENCODE_GSM7BIT;
+ break;
+ case 0x50:
+ p_cmas->encode_type = SMS_ENCODE_GSMDCS;
+ break;
+ case 0x80:
+ /* reserved value, but SKT use this value for KSC5601 */
+ p_cmas->encode_type = SMS_ENCODE_EUCKR;
+ break;
+ default :
+ p_cmas->encode_type = SMS_ENCODE_RESERVED;
+ break;
+ }
+ _shiftNBit_for_decode(tmp_str, tmp_len, 5);
+
+ switch (p_cmas->encode_type) {
+ case SMS_ENCODE_7BIT_ASCII:
+ case SMS_ENCODE_IA5:
+ case SMS_ENCODE_GSM7BIT:
+ memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
+ p_cmas->data_len = (tmp_len*8-5) / 7;
+ for (unsigned int i = 0; i < p_cmas->data_len; i++) {
+ p_cmas->alert_text[i] = tmp_str[0] >> 1;
+ _shiftNBit_for_decode(tmp_str, tmp_len, 7);
+ }
+ break;
+ case SMS_ENCODE_EPM:
+ break;
+ case SMS_ENCODE_GSMDCS:
+ break;
+ default:
+ p_cmas->data_len = tmp_len - 1;
+ memset(p_cmas->alert_text, 0x00, sizeof(p_cmas->alert_text));
+ memcpy(p_cmas->alert_text, tmp_str+offset, tmp_len-1);
+ break;
+ }
+
+ offset += tmp_len;
+ } else if (p_pkg_str[offset] == 0x01) {
+ MSG_DEBUG("Type 1 Decode!");
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ MSG_DEBUG("Type 1 length = [%d]", tmp_len);
+ p_cmas->category = (sms_3gpp2_cmae_category_t)p_pkg_str[offset++];
+ p_cmas->response_type = (sms_3gpp2_cmae_response_type_t)p_pkg_str[offset++];
+ p_cmas->severity = (sms_3gpp2_cmae_severity_t)(p_pkg_str[offset] >> 4);
+ p_cmas->urgency = (sms_3gpp2_cmae_urgency_t)(p_pkg_str[offset++] & 0x0f);
+ p_cmas->certainty = (sms_3gpp2_cmae_certainty_t)(p_pkg_str[offset++] >> 4);
+ } else if (p_pkg_str[offset] == 0x02) {
+ MSG_DEBUG("Type 2 Decode!");
+ offset += 2;
+ tmp_len = p_pkg_str[offset-1];
+ MSG_DEBUG("Type 2 length = [%d]", tmp_len);
+ _copy_char_to_short(&(p_cmas->id), p_pkg_str+offset);
+ offset += 2;
+ p_cmas->alert_handle = (sms_3gpp2_cmae_alert_handle_t)p_pkg_str[offset++];
+ offset += decodeAbsTime(p_pkg_str+offset, &(p_cmas->expires));
+ p_cmas->language = (sms_3gpp2_language_type_t)p_pkg_str[offset++];
+ }
+
+ MSG_DEBUG("offset = [%d], pkg_len = [%d]", offset, pkg_len);
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2MsgCodec::decodeUserData(unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_userdata_s *p_user)
+{
+ switch (p_pkg_str[0] & 0xf8) {
+ case 0x00:
+ p_user->encode_type = SMS_ENCODE_OCTET;
+ break;
+ case 0x08:
+ p_user->encode_type = SMS_ENCODE_EPM;
+ break;
+ case 0x10:
+ p_user->encode_type = SMS_ENCODE_7BIT_ASCII;
+ break;
+ case 0x18:
+ p_user->encode_type = SMS_ENCODE_IA5;
+ break;
+ case 0x20:
+ p_user->encode_type = SMS_ENCODE_UNICODE;
+ break;
+ case 0x28:
+ p_user->encode_type = SMS_ENCODE_SHIFT_JIS;
+ break;
+ case 0x30:
+ p_user->encode_type = SMS_ENCODE_KOREAN;
+ break;
+ case 0x38:
+ p_user->encode_type = SMS_ENCODE_LATIN_HEBREW;
+ break;
+ case 0x40:
+ p_user->encode_type = SMS_ENCODE_LATIN;
+ break;
+ case 0x48:
+ p_user->encode_type = SMS_ENCODE_GSM7BIT;
+ break;
+ case 0x50:
+ p_user->encode_type = SMS_ENCODE_GSMDCS;
+ break;
+ case 0x80:
+ /* reserved value, but SKT use this value for KSC5601 */
+ p_user->encode_type = SMS_ENCODE_EUCKR;
+ break;
+ default :
+ p_user->encode_type = SMS_ENCODE_RESERVED;
+ break;
+ }
+
+ _shiftNBit_for_decode(p_pkg_str, pkg_len, 5);
+
+ if (p_user->encode_type == SMS_ENCODE_EPM || p_user->encode_type == SMS_ENCODE_GSMDCS) {
+ p_user->msg_type = p_pkg_str[0];
+ _shiftNBit_for_decode(p_pkg_str, pkg_len, 8);
+ }
+
+ p_user->data_len = p_pkg_str[0];
+ switch (p_user->encode_type) {
+ case SMS_ENCODE_7BIT_ASCII:
+ case SMS_ENCODE_IA5:
+ memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+ for (unsigned int i = 0; i < p_user->data_len; i++) {
+ p_user->user_data[i] = p_pkg_str[1] >> 1;
+ _shiftNBit_for_decode(p_pkg_str, pkg_len, 7);
+ }
+ break;
+ case SMS_ENCODE_GSM7BIT:
+ memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+ UnpackGSM7bitData(&(p_pkg_str[1]), p_user->user_data, p_user->data_len);
+ break;
+ case SMS_ENCODE_EPM:
+ break;
+ case SMS_ENCODE_GSMDCS:
+ break;
+ case SMS_ENCODE_UNICODE:
+ p_user->data_len*=2;
+ memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+ memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
+ break;
+ default:
+ memset(p_user->user_data, 0x00, sizeof(p_user->user_data));
+ memcpy(p_user->user_data, p_pkg_str+1, p_user->data_len);
+ break;
+ }
+}
+
+
+sms_3gpp2_message_type_t Sms3gpp2MsgCodec::findMsgType(const unsigned char *p_pkg_str, int pkg_len)
+{
+ int offset = 0;
+ while (offset < pkg_len) {
+ if (p_pkg_str[offset] == 0x00) {
+ return (sms_3gpp2_message_type_t)((p_pkg_str[offset + 2] & 0xf0) >> 4);
+ }
+ offset += (p_pkg_str[offset+1]+2);
+ }
+
+ return SMS_TYPE_MAX_VALUE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <time.h>
+
+#include <bundle.h>
+#include <eventsystem.h>
+
+#include "MsgDebug.h"
+#include "MsgUtilFile.h"
+#include "MsgUtilFunction.h"
+#include "MsgUtilStorage.h"
+#include "MsgCppTypes.h"
+#include "MsgContact.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+
+#include "Sms3gpp2Transport.h"
+#include "Sms3gpp2Setting.h"
+#include "Sms3gpp2EventHandler.h"
+#include "Sms3gpp2WapPushHandler.h"
+#include "SmsPluginDSHandler.h"
+#include "SmsPluginStorage.h"
+
+
+
+Sms3gpp2EventHandler* Sms3gpp2EventHandler::pInstance = NULL;
+
+
+Sms3gpp2EventHandler::Sms3gpp2EventHandler()
+{
+ /* Initialize global parameters */
+ memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
+ memset(&sentInfo, 0x00, sizeof(sms_3gpp2_sent_info_s));
+ devStatus = false;
+ devHandle = NULL;
+}
+
+
+Sms3gpp2EventHandler::~Sms3gpp2EventHandler()
+{
+}
+
+
+Sms3gpp2EventHandler* Sms3gpp2EventHandler::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2EventHandler();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gpp2EventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
+{
+ listener = *pListener;
+}
+
+
+void Sms3gpp2EventHandler::convertTpduToMsginfo(sms_3gpp2_trans_p2p_msg_s *p_p2p_msg, MSG_MESSAGE_INFO_S *p_msg_info)
+{
+ MSG_BEGIN();
+
+ /* Address */
+ if (p_p2p_msg->telesvc_msg.data.deliver.callback_number.szData[0] != '\0')
+ p_msg_info->nAddressCnt = 2;
+ else
+ p_msg_info->nAddressCnt = 1;
+
+ p_msg_info->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S) * p_msg_info->nAddressCnt];
+
+ if (p_msg_info->addressList) {
+ switch (p_msg_info->nAddressCnt) {
+ case 2:
+ memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+ case 1:
+ memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+ break;
+ default:
+ MSG_ERR("Invalid case");
+ memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+ }
+ }
+
+ if (p_p2p_msg->address.szData[0] != '\0') {
+ p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+ memcpy(p_msg_info->addressList[0].addressVal, p_p2p_msg->address.szData, MAX_ADDRESS_VAL_LEN);
+ p_msg_info->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
+ }
+
+
+ /* Teleservice message */
+ switch (p_p2p_msg->telesvc_msg.type) {
+ case SMS_TYPE_DELIVER:
+ p_msg_info->msgType.subType = MSG_NORMAL_SMS;
+ p_msg_info->folderId = MSG_INBOX_ID;
+
+ convertDeliverMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.deliver), p_msg_info);
+ break;
+ case SMS_TYPE_DELIVERY_ACK:
+ convertAckMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.delivery_ack), p_msg_info);
+ break;
+ case SMS_TYPE_SUBMIT_REPORT:
+ convertReportMsgToMsgInfo(&(p_p2p_msg->telesvc_msg.data.report), p_msg_info);
+ break;
+ default:
+ MSG_DEBUG("No matching type = [%d]", p_p2p_msg->telesvc_msg.type);
+ break;
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2EventHandler::convertTpduToMsginfo(sms_3gpp2_trans_broadcast_msg_s *p_cb_msg, MSG_MESSAGE_INFO_S *p_msg_info)
+{
+ MSG_BEGIN();
+
+ /* Address */
+ p_msg_info->nAddressCnt = 0;
+ p_msg_info->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+
+ if (p_msg_info->addressList) {
+ memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+ }
+
+ /* Bearer Data */
+ if (p_cb_msg->telesvc_msg.type == SMS_TYPE_DELIVER) {
+ p_msg_info->msgType.subType = MSG_CB_SMS;
+ p_msg_info->folderId = MSG_CBMSGBOX_ID;
+
+ if (p_cb_msg->svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && p_cb_msg->svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST)
+ convertCMASMsgToMsgInfo(&(p_cb_msg->telesvc_msg.data.deliver), p_msg_info);
+ else
+ convertDeliverMsgToMsgInfo(&(p_cb_msg->telesvc_msg.data.deliver), p_msg_info);
+ } else {
+ MSG_DEBUG("No matching type = [%d]", p_cb_msg->telesvc_msg.type);
+ }
+
+ if (p_msg_info->nAddressCnt == 0) {
+ p_msg_info->nAddressCnt = 1;
+ p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+ p_msg_info->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
+
+ if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL)
+ snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Presidential Alert");
+ else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_EXTREME)
+ snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Extreme Alert");
+ else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_SEVERE)
+ snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Severe Alert");
+ else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_AMBER)
+ snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "AMBER Alert");
+ else if (p_cb_msg->svc_ctg == SMS_TRANS_SVC_CTG_CMAS_TEST)
+ snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "Emergency Alert");
+ else
+ snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "CB Message");
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2EventHandler::convertCMASMsgToMsgInfo(sms_3gpp2_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
+{
+ MSG_BEGIN();
+
+ p_msg_info->msgType.mainType = MSG_SMS_TYPE;
+
+ p_msg_info->msgType.classType = MSG_CLASS_NONE;
+ p_msg_info->networkStatus = MSG_NETWORK_RECEIVED;
+ p_msg_info->bRead = false;
+ p_msg_info->bProtected = false;
+ p_msg_info->direction = MSG_DIRECTION_TYPE_MT;
+ p_msg_info->bTextSms = true;
+
+ if (p_deliver->callback_number.szData[0] != '\0') {
+ /* If callback number is in received pdu, replace the address value. */
+ memset(p_msg_info->addressList[0].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+ p_msg_info->nAddressCnt = 1;
+ p_msg_info->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+ int wrn = snprintf(p_msg_info->addressList[0].addressVal, MAX_ADDRESS_VAL_LEN, "%s", p_deliver->callback_number.szData);
+ if (wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+ p_msg_info->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_TO;
+ }
+
+ time_t rawtime = 0;
+ p_msg_info->storageId = MSG_STORAGE_PHONE;
+
+#if 0 /* Save Timestamp of message center. */
+ char displayTime[32];
+ struct tm * timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ if (p_deliver->time_stamp.year > 95)
+ timeinfo.tm_year = (p_deliver->time_stamp.year + 1900);
+ else
+ timeinfo.tm_year = (p_deliver->time_stamp.year + 2000);
+
+ timeinfo.tm_mon = (p_deliver->time_stamp.month - 1);
+ timeinfo.tm_mday = p_deliver->time_stamp.day;
+ timeinfo.tm_hour = p_deliver->time_stamp.hour;
+ timeinfo.tm_min = p_deliver->time_stamp.minute;
+ timeinfo.tm_sec = p_deliver->time_stamp.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%d]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+#else
+ rawtime = time(NULL);
+#endif
+
+ p_msg_info->displayTime = rawtime;
+
+
+ if (p_deliver->priority == SMS_PRIORITY_URGENT || p_deliver->priority == SMS_PRIORITY_EMERGENCY)
+ p_msg_info->priority = MSG_MESSAGE_PRIORITY_HIGH;
+ else
+ p_msg_info->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+
+
+ memset(p_msg_info->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+ p_msg_info->msgPort.valid = false;
+ p_msg_info->msgPort.dstPort = 0;
+ p_msg_info->msgPort.srcPort = 0;
+
+ p_msg_info->encodeType = getEncodeType(p_deliver->cmas_data.encode_type);
+
+ if (p_deliver->cmas_data.data_len <= 0) {
+ memset(p_msg_info->msgText, 0x00, sizeof(p_msg_info->msgText));
+ p_msg_info->dataSize = 0;
+ } else if (p_deliver->cmas_data.data_len > MAX_MSG_TEXT_LEN) {
+ snprintf(p_msg_info->msgText, MAX_MSG_TEXT_LEN, "[Broken Message]");
+ p_msg_info->dataSize = strlen(p_msg_info->msgData);
+ return;
+ } else {
+ if (p_msg_info->encodeType == MSG_ENCODE_UCS2) {
+ MSG_DEBUG("Encode Type = UCS2");
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
+ } else if (p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
+ MSG_DEBUG("Encode Type = EUCKR");
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
+ } else if (p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
+ MSG_DEBUG("Encode Type = Shift-JIS");
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertSHIFTJISToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len);
+ } else if (p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
+ MSG_DEBUG("Encode Type = GSM7BIT");
+ MSG_LANG_INFO_S langinfo = {0, };
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->cmas_data.alert_text, p_deliver->cmas_data.data_len, &langinfo);
+ } else {
+ snprintf(p_msg_info->msgText, sizeof(p_msg_info->msgText), "%s", p_deliver->cmas_data.alert_text);
+ p_msg_info->dataSize = p_deliver->cmas_data.data_len;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2EventHandler::convertDeliverMsgToMsgInfo(sms_3gpp2_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
+{
+ MSG_BEGIN();
+
+ p_msg_info->msgType.mainType = MSG_SMS_TYPE;
+ /*
+ p_msg_info->msgType.subType = MSG_NORMAL_SMS;
+ p_msg_info->folderId = MSG_INBOX_ID;
+ */
+ p_msg_info->msgType.classType = MSG_CLASS_NONE;
+ p_msg_info->networkStatus = MSG_NETWORK_RECEIVED;
+ p_msg_info->bRead = false;
+ p_msg_info->bProtected = false;
+ p_msg_info->direction = MSG_DIRECTION_TYPE_MT;
+ p_msg_info->bTextSms = true;
+
+ if (p_deliver->callback_number.szData[0] != '\0') {
+ /* If callback number is in received pdu, replace the address value. */
+ memset(p_msg_info->addressList[1].addressVal, 0x00, MAX_ADDRESS_VAL_LEN+1);
+ p_msg_info->addressList[1].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
+ memcpy(p_msg_info->addressList[1].addressVal, p_deliver->callback_number.szData, MAX_ADDRESS_VAL_LEN);
+ p_msg_info->addressList[1].recipientType = MSG_RECIPIENTS_TYPE_TO;
+ }
+
+ time_t rawtime = 0;
+ p_msg_info->storageId = MSG_STORAGE_PHONE;
+
+#if 0 /* Save Timestamp of message center. */
+ char displayTime[32];
+ struct tm * timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ if (p_deliver->time_stamp.year > 95)
+ timeinfo.tm_year = (p_deliver->time_stamp.year + 1900);
+ else
+ timeinfo.tm_year = (p_deliver->time_stamp.year + 2000);
+
+ timeinfo.tm_mon = (p_deliver->time_stamp.month - 1);
+ timeinfo.tm_mday = p_deliver->time_stamp.day;
+ timeinfo.tm_hour = p_deliver->time_stamp.hour;
+ timeinfo.tm_min = p_deliver->time_stamp.minute;
+ timeinfo.tm_sec = p_deliver->time_stamp.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%d]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+#else
+ rawtime = time(NULL);
+#endif
+
+ p_msg_info->displayTime = rawtime;
+
+
+ if (p_deliver->priority == SMS_PRIORITY_URGENT || p_deliver->priority == SMS_PRIORITY_EMERGENCY)
+ p_msg_info->priority = MSG_MESSAGE_PRIORITY_HIGH;
+ else
+ p_msg_info->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+
+
+ memset(p_msg_info->subject, 0x00, MAX_SUBJECT_LEN+1);
+
+ p_msg_info->msgPort.valid = false;
+ p_msg_info->msgPort.dstPort = 0;
+ p_msg_info->msgPort.srcPort = 0;
+
+ p_msg_info->encodeType = getEncodeType(p_deliver->user_data.encode_type);
+
+ if (p_deliver->user_data.data_len <= 0) {
+ memset(p_msg_info->msgText, 0x00, sizeof(p_msg_info->msgText));
+ p_msg_info->dataSize = 0;
+ } else if (p_deliver->user_data.data_len > MAX_MSG_TEXT_LEN) {
+ snprintf(p_msg_info->msgText, MAX_MSG_TEXT_LEN, "[Broken Message]");
+ p_msg_info->dataSize = strlen(p_msg_info->msgData);
+ return;
+ } else {
+ if (p_msg_info->encodeType == MSG_ENCODE_UCS2) {
+ MSG_DEBUG("Encode Type = UCS2");
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
+ } else if (p_msg_info->encodeType == MSG_ENCODE_EUCKR) {
+ MSG_DEBUG("Encode Type = EUCKR");
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
+ } else if (p_msg_info->encodeType == MSG_ENCODE_SHIFT_JIS) {
+ MSG_DEBUG("Encode Type = Shift-JIS");
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertSHIFTJISToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len);
+ } else if (p_msg_info->encodeType == MSG_ENCODE_GSM7BIT) {
+ MSG_DEBUG("Encode Type = GSM7BIT");
+ MSG_LANG_INFO_S langinfo = {0, };
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+ p_msg_info->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)&p_msg_info->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)&p_deliver->user_data.user_data, p_deliver->user_data.data_len, &langinfo);
+ } else {
+ snprintf(p_msg_info->msgText, sizeof(p_msg_info->msgText), "%s", p_deliver->user_data.user_data);
+ p_msg_info->dataSize = p_deliver->user_data.data_len;
+ }
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2EventHandler::convertAckMsgToMsgInfo(sms_3gpp2_telesvc_deliver_ack_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
+{
+}
+
+
+void Sms3gpp2EventHandler::convertReportMsgToMsgInfo(sms_3gpp2_telesvc_report_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info)
+{
+}
+
+
+void Sms3gpp2EventHandler::SetSentInfo(sms_3gpp2_sent_info_s *pSentInfo)
+{
+ memset(&sentInfo, 0x00, sizeof(sms_3gpp2_sent_info_s));
+ memcpy(&sentInfo, pSentInfo, sizeof(sms_3gpp2_sent_info_s));
+
+ MSG_DEBUG("sentInfo.reqId : %d", sentInfo.reqInfo.reqId);
+ MSG_DEBUG("sentInfo.bLast : %d", sentInfo.bLast);
+}
+
+
+void Sms3gpp2EventHandler::handleSentStatus(msg_network_status_t NetStatus)
+{
+ MSG_DEBUG("NetStatus[%d]", NetStatus);
+
+ if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
+ /* Update Msg Status */
+ if (sentInfo.reqInfo.msgInfo.msgPort.valid == false) {
+ sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
+
+ if (NetStatus == MSG_NETWORK_SEND_SUCCESS) {
+ MSG_DEBUG("Add phone log");
+ MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
+ sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID;
+ /* Send system event */
+ bundle *b = NULL;
+ b = bundle_create();
+ if (b) {
+ if (sentInfo.reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE)
+ bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_SMS);
+ else
+ bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_MMS);
+
+ char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+ snprintf(msgId, sizeof(msgId), "%u", sentInfo.reqInfo.msgInfo.msgId);
+ bundle_add_str(b, EVT_KEY_OUT_MSG_ID, msgId);
+ eventsystem_send_system_event(SYS_EVENT_OUTGOING_MSG, b);
+ bundle_free(b);
+ }
+ } else {
+ sentInfo.reqInfo.msgInfo.bRead = false;
+ }
+
+ callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
+ }
+
+ MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
+ MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
+ /* Check sending options */
+ if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
+ callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
+ }
+
+ /* Callback to MSG FW */
+ MSG_SENT_STATUS_S msgStatus;
+
+ msgStatus.reqId = sentInfo.reqInfo.reqId;
+ msgStatus.status = NetStatus;
+
+ MSG_DEBUG("sentStatus.reqId : %d", msgStatus.reqId);
+ MSG_DEBUG("sentStatus.status : %d", msgStatus.status);
+
+ listener.pfSentStatusCb(&msgStatus);
+ }
+}
+
+
+void Sms3gpp2EventHandler::handleMsgIncoming(TapiHandle *handle, sms_3gpp2_trans_p2p_msg_s *p_p2p_msg)
+{
+ /* Make MSG_MESSAGE_INFO_S */
+ MSG_MESSAGE_INFO_S msgInfo;
+
+ /* initialize msgInfo */
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ msgInfo.sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ /* convert to msgInfo */
+ convertTpduToMsginfo(p_p2p_msg, &msgInfo);
+
+ if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_RESERVED) {
+ MSG_DEBUG("This Incoming Message has Unknown Teleservice ID");
+ Sms3gpp2Transport::instance()->sendDeliverReport(handle, MSG_ERR_INVALID_MSG_TYPE, p_p2p_msg);
+ return;
+ }
+
+ /* Check for Voice Mail Notification */
+ if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_VMN_95) {
+ if (p_p2p_msg->telesvc_msg.data.deliver.enhanced_vmn.fax_included)
+ msgInfo.msgType.subType = MSG_MWI_FAX_SMS;
+ else
+ msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
+
+ //if (p_p2p_msg->telesvc_msg.data.deliver.num_msg < 0)
+ // p_p2p_msg->telesvc_msg.data.deliver.num_msg = 0;
+
+ int voice_cnt = 0;
+ if (MsgSettingGetInt(VOICEMAIL_COUNT, &voice_cnt) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+
+ /* repeated msg check for voicemail */
+ if (voice_cnt == static_cast<int>(p_p2p_msg->telesvc_msg.data.deliver.num_msg)) {
+ Sms3gpp2Transport::instance()->sendDeliverReport(handle, MSG_SUCCESS, p_p2p_msg);
+ return;
+ }
+
+ Sms3gpp2Setting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, p_p2p_msg->telesvc_msg.data.deliver.num_msg);
+
+ memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", p_p2p_msg->telesvc_msg.data.deliver.num_msg);
+ msgInfo.dataSize = strlen(msgInfo.msgText);
+ } else if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
+ /* Check for EMS(Unsupported) */
+ char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_POP_ERROR_UNSUPPORTED_MSG");
+ memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
+ snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%s", msg_text);
+ msgInfo.dataSize = strlen(msgInfo.msgText);
+
+ if (msg_text) {
+ free(msg_text);
+ msg_text = NULL;
+ }
+ }
+
+ /* Print MSG_MESSAGE_INFO_S */
+ MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
+ MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
+ MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
+ MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
+ MSG_DEBUG("msgInfo.addressList[0].displayName : %s", msgInfo.addressList[0].displayName);
+ MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+ MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+ MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+ MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+ MSG_DEBUG("msgInfo.bStore : %d", msgInfo.bStore);
+ MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+ MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+ MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+ MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+ MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+ MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
+ MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
+ MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+
+ if (msgInfo.bTextSms == true) {
+ MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+ } else {
+ MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+ }
+
+ MSG_DEBUG("###############################################################");
+
+ msg_error_t err = MSG_SUCCESS;
+ bool isUnique = true;
+ MSG_UNIQUE_INDEX_S unq_ind;
+ memset(&unq_ind, 0x00, sizeof(MSG_UNIQUE_INDEX_S));
+
+ if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
+ /* Status Report Message */
+ /*
+ err = SmsPluginStorage::instance()->updateMsgDeliverStatus(&msgInfo, pTpdu->data.statusRep.msgRef);
+
+ if (err == MSG_SUCCESS)
+ err = listener.pfMsgIncomingCb(&msgInfo);
+ else
+ MSG_DEBUG("updateMsgDeliverStatus is failed [%d]", err);
+ */
+
+ /* Handling of Fail Case ?? */
+ /* SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS); */
+ } else { /* SMS Deliver */
+ /* Add message to DB */
+ if (msgInfo.msgPort.valid == false) {
+ if (p_p2p_msg->telesvc_id != SMS_TRANS_TELESVC_VMN_95) {
+ memcpy(unq_ind.address, p_p2p_msg->address.szData, sizeof(p_p2p_msg->address.szData));
+ memcpy(unq_ind.sub_address, p_p2p_msg->sub_address.szData, sizeof(p_p2p_msg->sub_address.szData));
+ unq_ind.tele_msgId = p_p2p_msg->telesvc_msg.data.deliver.msg_id.msg_id;
+ snprintf(unq_ind.time_stamp, sizeof(unq_ind.time_stamp), "%02d%02d%02d%02d%02d%02d",
+ p_p2p_msg->telesvc_msg.data.deliver.time_stamp.year, p_p2p_msg->telesvc_msg.data.deliver.time_stamp.month,
+ p_p2p_msg->telesvc_msg.data.deliver.time_stamp.day, p_p2p_msg->telesvc_msg.data.deliver.time_stamp.hours,
+ p_p2p_msg->telesvc_msg.data.deliver.time_stamp.minutes, p_p2p_msg->telesvc_msg.data.deliver.time_stamp.seconds);
+ unq_ind.telesvc_id = p_p2p_msg->telesvc_id;
+ isUnique = listener.pfCheckUniquenessCb(&unq_ind, 0, false);
+ }
+ }
+
+ if (isUnique) {
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ } else {
+ Sms3gpp2Transport::instance()->sendDeliverReport(handle, MSG_SUCCESS, p_p2p_msg);
+ return;
+ }
+
+ /* Callback to MSG FW */
+ if (err == MSG_SUCCESS) {
+ MSG_DEBUG("callback to msg fw");
+ err = listener.pfMsgIncomingCb(&msgInfo);
+ } else {
+ if (msgInfo.msgType.classType == MSG_CLASS_0) {
+ MSG_DEBUG("callback for class0 message to msg fw");
+ if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
+ MSG_ERR("listener.pfMsgIncomingCb is failed!");
+ }
+ }
+
+ if (err == MSG_SUCCESS && p_p2p_msg->telesvc_id != SMS_TRANS_TELESVC_VMN_95)
+ listener.pfCheckUniquenessCb(&unq_ind, msgInfo.msgId, true);
+
+ /* Send Deliver Report */
+ if (p_p2p_msg->telesvc_id == SMS_TRANS_TELESVC_WEMT) {
+ Sms3gpp2Transport::instance()->sendDeliverReport(handle, MSG_ERR_INVALID_MSG_TYPE, p_p2p_msg);
+ } else {
+ Sms3gpp2Transport::instance()->sendDeliverReport(handle, err, p_p2p_msg);
+ }
+
+ /* Tizen Validation System */
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, msgInfo.sim_idx);
+
+ char *msisdn = NULL;
+ if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s", msgInfo.msgId, \
+ msgInfo.addressList[0].addressVal, \
+ (msisdn == NULL)?"ME":msisdn, \
+ (err == MSG_SUCCESS)?"Success":"Fail");
+
+ MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
+
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+ }
+}
+
+
+void Sms3gpp2EventHandler::handleCbMsgIncoming(TapiHandle *handle, sms_3gpp2_trans_broadcast_msg_s *p_cb_msg)
+{
+ MSG_BEGIN();
+
+ if (p_cb_msg->telesvc_msg.data.deliver.cmas_data.encode_type == SMS_ENCODE_KOREAN
+ || p_cb_msg->telesvc_msg.data.deliver.cmas_data.encode_type == SMS_ENCODE_GSMDCS) {
+ MSG_DEBUG("This encode type is not supported [%d]", p_cb_msg->telesvc_msg.data.deliver.cmas_data.encode_type);
+ return;
+ }
+
+ /* Make MSG_MESSAGE_INFO_S */
+ MSG_MESSAGE_INFO_S msgInfo;
+
+ /* initialize msgInfo */
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ msgInfo.sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ /* convert to msgInfo */
+ convertTpduToMsginfo(p_cb_msg, &msgInfo);
+ msgInfo.msgId = p_cb_msg->telesvc_msg.data.deliver.msg_id.msg_id;
+
+ /* Print MSG_MESSAGE_INFO_S */
+ MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
+ MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
+ MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
+ MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
+ MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
+ MSG_DEBUG("msgInfo.bStore : %d", msgInfo.bStore);
+ MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
+ MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
+ MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
+ MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
+ MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
+ MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
+ MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
+ MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
+ MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
+
+ if (msgInfo.bTextSms == true) {
+ MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
+ } else {
+ MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
+ }
+
+ MSG_DEBUG("###############################################################");
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add message to DB */
+ if (msgInfo.msgPort.valid == false) {
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+ }
+
+ if (!checkCbOpt(handle, p_cb_msg->svc_ctg)) {
+ MSG_ERR("The CB Msg is not supported by option.");
+ return;
+ }
+
+ /* Callback to MSG FW */
+ if (err == MSG_SUCCESS) {
+#if 1
+ MSG_CB_MSG_S cbOutMsg = {0, };
+ bool is_duplicate = false;
+
+ switch (p_cb_msg->svc_ctg) {
+ case SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL :
+ msgInfo.msgType.subType = MSG_CMAS_PRESIDENTIAL;
+ break;
+ case SMS_TRANS_SVC_CTG_CMAS_EXTREME :
+ msgInfo.msgType.subType = MSG_CMAS_EXTREME;
+ break;
+ case SMS_TRANS_SVC_CTG_CMAS_SEVERE :
+ msgInfo.msgType.subType = MSG_CMAS_SEVERE;
+ break;
+ case SMS_TRANS_SVC_CTG_CMAS_AMBER :
+ msgInfo.msgType.subType = MSG_CMAS_AMBER;
+ break;
+ case SMS_TRANS_SVC_CTG_CMAS_TEST :
+ msgInfo.msgType.subType = MSG_CMAS_TEST;
+ break;
+ default :
+ msgInfo.msgType.subType = MSG_CB_SMS;
+ break;
+ }
+
+ cbOutMsg.type = msgInfo.msgType.subType;
+ cbOutMsg.receivedTime = msgInfo.displayTime;
+ /* encodeCbSerialNum (CbMsgPage.pageHeader.serialNum); */
+ cbOutMsg.serialNum = 0;
+ cbOutMsg.messageId = msgInfo.msgId;
+ /* cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData; */
+ memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText));
+
+ cbOutMsg.cbTextLen = msgInfo.dataSize;
+ memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type));
+ /* memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3); */
+
+ if (!is_duplicate) {
+ MSG_DEBUG("callback to msg fw");
+ err = listener.pfCBMsgIncomingCb(&cbOutMsg, &msgInfo);
+
+ if (err != MSG_SUCCESS) {
+ MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
+ }
+ } //else {
+ // MSG_WARN("duplicate cb serialNum[%d] messageId[%d]", cbOutMsg.serialNum, cbOutMsg.messageId);
+ //}
+
+#else
+ err = listener.pfMsgIncomingCb(&msgInfo);
+#endif
+ }
+
+ /* Send Deliver Report */
+ /* Sms3gpp2Transport::instance()->sendDeliverReport(handle, err, p_p2p_msg); */
+
+ /* Tizen Validation System */
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, msgInfo.sim_idx);
+
+ char *msisdn = NULL;
+ if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s", msgInfo.msgId, \
+ msgInfo.addressList[0].addressVal, \
+ (msisdn == NULL)?"ME":msisdn, \
+ (err == MSG_SUCCESS)?"Success":"Fail");
+
+ MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
+
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2EventHandler::handleWapMsgIncoming(TapiHandle *handle, sms_3gpp2_trans_p2p_msg_s *p_p2p_msg)
+{
+ MSG_BEGIN();
+
+ sms_3gpp2_wap_msg_s msg;
+ memset(&msg, 0x00, sizeof(sms_3gpp2_wap_msg_s));
+
+ msg.msgId = p_p2p_msg->telesvc_msg.data.deliver.msg_id.msg_id;
+ msg.totalSeg = p_p2p_msg->telesvc_msg.data.deliver.user_data.user_data[1];
+ msg.segNum = p_p2p_msg->telesvc_msg.data.deliver.user_data.user_data[2];
+ msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ char tmpUserText[SMS_MAX_USER_DATA_LEN+1] = {0, };
+ sms_3gpp2_telesvc_userdata_s tmpUserData;
+ memset(&tmpUserData, 0x00, sizeof(sms_3gpp2_telesvc_userdata_s));
+
+ tmpUserData.data_len = p_p2p_msg->telesvc_msg.data.deliver.user_data.data_len - 3;
+ memcpy(tmpUserText, &(p_p2p_msg->telesvc_msg.data.deliver.user_data.user_data[3]), tmpUserData.data_len);
+ memcpy(tmpUserData.user_data, tmpUserText, sizeof(tmpUserData.user_data));
+
+ unsigned char segCnt = checkWapMsg(&msg, &tmpUserData);
+
+ MSG_DEBUG("segNum [%d]", msg.segNum);
+ MSG_DEBUG("segCnt [%d]", segCnt);
+ MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
+
+ if (segCnt == msg.totalSeg) {
+ MSG_DEBUG("RECEIVED LAST WAP : %d", segCnt);
+
+ unsigned short dstPort = 0;
+ int dataSize = 0;
+ char* pUserData = NULL;
+ char* pTmpUserData = NULL;
+ unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
+ unique_ptr<char*, void(*)(char**)> dataBuf1(&pTmpUserData, unique_ptr_deleter);
+
+ MSG_MESSAGE_INFO_S msgInfo = {0, };
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ dataSize = MakeWapUserData(msg.msgId, msg.simIndex, &pUserData);
+
+ pTmpUserData = new char[dataSize];
+
+ memcpy(pTmpUserData, pUserData, dataSize);
+ memset(pUserData, 0x00, dataSize);
+
+ dstPort = pTmpUserData[2] << 8 | pTmpUserData[3];
+
+#ifndef FEATURE_OMADM_DUPLICATE_PORT_WAPPUSH
+ dataSize -= 4;
+ memcpy(pUserData, &pTmpUserData[4], dataSize);
+#else
+ unsigned short srcPort = 0;
+ srcPort = pTmpUserData[0] << 8 | pTmpUserData[1];
+
+ if ((srcPort == 0x23f0 && dstPort == 0x0b84) &&
+ ((pTmpUserData[4] << 8 | pTmpUserData[5]) == 0x23f0) &&
+ ((pTmpUserData[6] << 8 | pTmpUserData[7]) == 0x0b84)) {
+ dataSize -= 8;
+ memcpy(pUserData, &pTmpUserData[8], dataSize);
+ } else {
+ dataSize -= 4;
+ memcpy(pUserData, &pTmpUserData[4], dataSize);
+ }
+#endif
+
+ if (dataSize > 0) {
+ MSG_DEBUG("dataSize = %d", dataSize);
+ for (int i = 0; i < dataSize; i++)
+ MSG_DEBUG("UserData[%d] = [%c] [%02x]", i, pUserData[i], pUserData[i]);
+
+ if (Sms3gpp2WapPushHandler::instance()->IsWapPushMsg(dstPort) == true) {
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ Sms3gpp2WapPushHandler::instance()->copyDeliverData(&(p_p2p_msg->address));
+ Sms3gpp2WapPushHandler::instance()->handleWapPushMsg(pUserData, msg.simIndex, dataSize);
+ } else {
+ MSG_DEBUG("not supported wap push port [%x]", dstPort);
+ }
+ }
+
+ /* remove from waplist */
+ for (int index = wapList.size()-1; index >= 0 ; index--) {
+ if (wapList[index].msgId == msg.msgId) {
+ MSG_DEBUG("remove waplist of the index [%d]", index);
+ wapList.erase(wapList.begin()+index);
+ break;
+ }
+ }
+ }
+
+ /* Send Deliver Report */
+ Sms3gpp2Transport::instance()->sendDeliverReport(handle, MSG_SUCCESS, p_p2p_msg);
+
+ MSG_END();
+}
+
+
+void Sms3gpp2EventHandler::handleResendMessage(void)
+{
+ listener.pfResendMessageCb();
+}
+
+
+msg_error_t Sms3gpp2EventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Callback to MSG FW */
+ err = listener.pfMsgIncomingCb(pMsgInfo);
+
+ MSG_END();
+
+ return err;
+}
+
+
+msg_error_t Sms3gpp2EventHandler::callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
+{
+ msg_id_list_s msgIdList;
+ msg_message_id_t msgIds[1];
+ memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
+
+ msgIdList.nCount = 1;
+ msgIds[0] = pMsgInfo->msgId;
+ msgIdList.msgIdList = msgIds;
+
+ /** Callback to MSG FW */
+ listener.pfStorageChangeCb(storageChangeType, &msgIdList);
+
+ return MSG_SUCCESS;
+}
+
+
+void Sms3gpp2EventHandler::setDeviceStatus(TapiHandle *handle, bool status)
+{
+ if (handle == devHandle) {
+ mx.lock();
+ devStatus = true;
+ cv.signal();
+ mx.unlock();
+ }
+}
+
+
+bool Sms3gpp2EventHandler::getDeviceStatus(TapiHandle *handle)
+{
+ mx.lock();
+ devHandle = handle;
+ int ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: DEVICE STATUS TIME-OUT");
+ devStatus = false;
+ }
+ devHandle = NULL;
+ mx.unlock();
+ return devStatus;
+}
+
+
+msg_encode_type_t Sms3gpp2EventHandler::getEncodeType(sms_3gpp2_encoding_type_t encode_type)
+{
+ switch(encode_type) {
+ case SMS_ENCODE_GSM7BIT:
+ return MSG_ENCODE_GSM7BIT;
+ case SMS_ENCODE_KOREAN:
+ case SMS_ENCODE_EUCKR:
+ return MSG_ENCODE_EUCKR;
+ case SMS_ENCODE_IA5:
+ case SMS_ENCODE_7BIT_ASCII:
+ case SMS_ENCODE_LATIN_HEBREW:
+ case SMS_ENCODE_LATIN:
+ case SMS_ENCODE_OCTET:
+ return MSG_ENCODE_8BIT;
+ case SMS_ENCODE_SHIFT_JIS:
+ return MSG_ENCODE_SHIFT_JIS;
+ /*
+ case SMS_ENCODE_EPM :
+ case SMS_ENCODE_UNICODE :
+ case SMS_ENCODE_GSMDCS :
+ */
+ default:
+ return MSG_ENCODE_UCS2;
+ }
+
+ return MSG_ENCODE_UCS2;
+}
+
+
+unsigned short Sms3gpp2EventHandler::checkWapMsg(sms_3gpp2_wap_msg_s *pMsg, sms_3gpp2_telesvc_userdata_s *pUserdata)
+{
+ unsigned char currSegNum = 0;
+
+ bool bFind = false;
+
+ for (unsigned int i = 0; i < wapList.size(); i++) {
+ if (wapList[i].msgId == pMsg->msgId) {
+ if (wapList[i].data.count(pMsg->segNum) != 0) {
+ MSG_DEBUG("The Segment Number already exists [%d]", pMsg->segNum);
+ return 0;
+ }
+ wap_3gpp2_data_s wapData = {0};
+
+ memcpy(wapData.data, pUserdata->user_data, pUserdata->data_len);
+ wapData.length = pUserdata->data_len;
+
+ pair<unsigned char, wap_3gpp2_data_s> newData(pMsg->segNum, wapData);
+ wapList[i].data.insert(newData);
+
+ MSG_DEBUG("MSG DATA : %s", pUserdata->user_data);
+ MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
+ MSG_DEBUG("DATA SIZE [%d]", pUserdata->data_len);
+
+ wapList[i].segNum++;
+ wapList[i].totalSize += pUserdata->data_len;
+ currSegNum = wapList[i].segNum;
+
+ bFind = true;
+
+ break;
+ }
+ }
+
+ /* New Wap Push Msg */
+ if (bFind == false) {
+ sms_3gpp2_wap_info_s tmpInfo;
+ tmpInfo.msgId = pMsg->msgId;
+ tmpInfo.totalSeg = pMsg->totalSeg;
+ tmpInfo.segNum = 1;
+ tmpInfo.simIndex = pMsg->simIndex;
+
+ tmpInfo.totalSize = pUserdata->data_len;
+
+ wap_3gpp2_data_s wapData = {0};
+
+ memcpy(wapData.data, pUserdata->user_data, pUserdata->data_len);
+ wapData.length = pUserdata->data_len;
+
+ pair<unsigned char, wap_3gpp2_data_s> newData(pMsg->segNum, wapData);
+ tmpInfo.data.insert(newData);
+
+ MSG_DEBUG("MSG DATA : %s", pUserdata->user_data);
+ MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
+ MSG_DEBUG("DATA SIZE [%d]", pUserdata->data_len);
+
+ wapList.push_back(tmpInfo);
+
+ currSegNum = tmpInfo.segNum;
+ }
+
+ return currSegNum;
+}
+
+
+int Sms3gpp2EventHandler::MakeWapUserData(unsigned short msgId, msg_sim_slot_id_t simIndex, char **ppTotalData)
+{
+ wap3gpp2DataMap::iterator it;
+
+ int totalSize = 0, offset = 0;
+
+ for (unsigned int i = 0; i < wapList.size(); i++) {
+ if (wapList[i].msgId == msgId && wapList[i].simIndex == simIndex) {
+ totalSize = wapList[i].totalSize;
+
+ if (totalSize <= 0) {
+ MSG_DEBUG("Size Error : totalSize <= 0");
+ return 0;
+ }
+
+ MSG_DEBUG("totalSize [%d]", totalSize);
+
+ if (*ppTotalData == NULL)
+ *ppTotalData = new char[totalSize];
+
+ for (it = wapList[i].data.begin(); it != wapList[i].data.end(); it++) {
+ memcpy(*ppTotalData+offset, it->second.data, it->second.length);
+ offset += it->second.length;
+ }
+ }
+ }
+
+ return totalSize;
+}
+
+
+void Sms3gpp2EventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen)
+{
+ MSG_SYNCML_MESSAGE_DATA_S syncMLData;
+
+ memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
+
+ /* set syncML data */
+ syncMLData.syncmlType = msgType;
+
+ syncMLData.pushBodyLen = PushBodyLen;
+ memcpy(syncMLData.pushBody, pPushBody, PushBodyLen);
+
+ syncMLData.wspHeaderLen = WspHeaderLen;
+ memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
+
+ /* Callback to MSG FW */
+ listener.pfSyncMLMsgIncomingCb(&syncMLData);
+}
+
+
+void Sms3gpp2EventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen)
+{
+ MSG_LBS_MESSAGE_DATA_S lbsData;
+
+ memset(&lbsData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
+
+ /* set LBA data */
+ memcpy(lbsData.pushHeader, pPushHeader, strlen(pPushHeader));
+ lbsData.pushHeader[strlen(pPushHeader)] = '\0';
+
+ lbsData.pushBodyLen = pushBodyLen;
+ memcpy(lbsData.pushBody, pPushBody, pushBodyLen);
+ lbsData.pushBody[pushBodyLen] = '\0';
+
+ /* Callback to MSG FW */
+ listener.pfLBSMsgIncomingCb(&lbsData);
+}
+
+
+void Sms3gpp2EventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *application_id, char *content_type)
+{
+ MSG_PUSH_MESSAGE_DATA_S pushData;
+
+ memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
+
+ /* set PUSH data */
+ memcpy(pushData.pushHeader, pPushHeader, strlen(pPushHeader));
+ pushData.pushHeader[strlen(pPushHeader)] = '\0';
+
+ pushData.pushBodyLen = pushBodyLen;
+ memcpy(pushData.pushBody, pPushBody, pushBodyLen);
+ pushData.pushBody[pushBodyLen] = '\0';
+
+ memcpy(pushData.pushAppId, application_id, MAX_WAPPUSH_ID_LEN);
+ memcpy(pushData.pushContentType, content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+
+ /* Callback to MSG FW */
+ listener.pfPushMsgIncomingCb(&pushData);
+}
+
+
+bool Sms3gpp2EventHandler::checkCbOpt(TapiHandle *handle, sms_3gpp2_trans_svc_ctg_t svc_ctg)
+{
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, SmsPluginDSHandler::instance()->getSimIndex(handle));
+
+ bool bReceive = false;
+ if (MsgSettingGetBool(keyName, &bReceive) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetBool() is failed");
+ }
+
+ /* Receive CB Msg = FALSE */
+ if (!bReceive) {
+ MSG_DEBUG("RECEIVE CB = FALSE");
+ return false;
+ }
+
+ if (svc_ctg >= SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL && svc_ctg <= SMS_TRANS_SVC_CTG_CMAS_TEST) {
+ bool bActivate = false;
+ short Category = 0;
+ MSG_CB_CHANNEL_S cbChannelInfo = {0, };
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("Error value of MsgStoGetCBChannelInfo [%d]", err);
+ return false;
+ }
+
+ for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
+ bActivate = cbChannelInfo.channelInfo[i].bActivate;
+ Category = cbChannelInfo.channelInfo[i].ctg;
+
+ if (bActivate == true && svc_ctg == Category) {
+ MSG_DEBUG("FIND CHANNEL = [%d]", svc_ctg);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "Sms3gpp2ParamCodec.h"
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF Sms3gpp2ParamCodec - Member Functions
+==================================================================================================*/
+Sms3gpp2ParamCodec* Sms3gpp2ParamCodec::pInstance = NULL;
+
+
+Sms3gpp2ParamCodec::Sms3gpp2ParamCodec()
+{
+}
+
+
+Sms3gpp2ParamCodec::~Sms3gpp2ParamCodec()
+{
+}
+
+Sms3gpp2ParamCodec* Sms3gpp2ParamCodec::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2ParamCodec();
+ }
+
+ return pInstance;
+}
+
+
+
+/*==================================================================================================
+ Util Functions
+==================================================================================================*/
+int Sms3gpp2ParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd)
+{
+ int offset = 0;
+ unsigned char temp;
+
+ for (int i = 0; i < DigitLen; i++) {
+ if (pDigit[i] == '*')
+ temp = 0x0A;
+ else if (pDigit[i] == '#')
+ temp = 0x0B;
+ else if (pDigit[i] == 'P' || pDigit[i] == 'p')
+ temp = 0x0C;
+ else
+ temp = pDigit[i] - '0';
+
+ if ((i % 2) == 0)
+ pBcd[offset] = temp & 0x0F;
+ else
+ pBcd[offset++] |= ((temp & 0x0F) << 4);
+ }
+
+ if ((DigitLen % 2) == 1) {
+ pBcd[offset++] |= 0xF0;
+ }
+
+ return offset;
+}
+
+
+int Sms3gpp2ParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
+{
+ int offset = 0;
+ unsigned char temp;
+
+ for (int i = 0; i < BcdLen; i++) {
+ temp = pBcd[i] & 0x0F;
+
+ if (temp == 0x0A)
+ pDigit[offset++] = '*';
+ else if (temp == 0x0B)
+ pDigit[offset++] = '#';
+ else if (temp == 0x0C)
+ pDigit[offset++] = 'P';
+ else
+ pDigit[offset++] = temp + '0';
+
+ temp = (pBcd[i] & 0xF0) >> 4;
+
+ if (temp == 0x0F) {
+ pDigit[offset] = '\0';
+ return offset;
+ }
+
+ if (temp == 0x0A)
+ pDigit[offset++] = '*';
+ else if (temp == 0x0B)
+ pDigit[offset++] = '#';
+ else if (temp == 0x0C)
+ pDigit[offset++] = 'P';
+ else
+ pDigit[offset++] = temp + '0';
+ }
+
+ pDigit[offset] = '\0';
+
+ return offset;
+}
+
+
+int Sms3gpp2ParamCodec::convertDigitToDTMF(const char *pDigit, int DigitLen, int startBit, unsigned char *pDtmf)
+{
+ int shift = startBit;
+ int offset = 0;
+ int srcIdx = 0;
+ unsigned char temp;
+
+ if (shift > 7) {
+ MSG_DEBUG("Invalid Param value shift : %d", shift);
+ return 0;
+ }
+ /* shift 1 and shift 2 are supported in this spec. */
+ if (shift >= 4) {
+ MSG_DEBUG("Invalid Param value shift : %d", shift);
+ return 0;
+ }
+
+ for (int i = 0; i < DigitLen; i++) {
+ if (pDigit[srcIdx] == '*')
+ temp = 0x0B;
+ else if (pDigit[srcIdx] == '#')
+ temp = 0x0C;
+ else if (pDigit[srcIdx] == '0')
+ temp = 0x0A;
+ else
+ temp = pDigit[srcIdx] - '0';
+
+ temp &= 0x0F;
+
+ if (shift == 0) {
+ if (i % 2 == 1) {
+ pDtmf[offset] |= temp;
+ offset++;
+ } else {
+ pDtmf[offset] |= temp << 4;
+ }
+ } else if (shift >= 1 && shift < 4) {
+ if (i % 2 == 1) {
+ pDtmf[offset] |= (temp >> shift);
+ pDtmf[offset + 1] = temp << (8 - shift);
+ offset++;
+ } else {
+ pDtmf[offset] |= (temp << (8 - shift - 4));
+ }
+ }
+
+ srcIdx++;
+ }
+
+ return offset;
+}
+
+
+int Sms3gpp2ParamCodec::convertDTMFToDigit(const unsigned char *pDtmf, int DtmfLen, int startBit, char *pDigit)
+{
+ int shift = startBit;
+ int offset = 0;
+ int srcIdx = 0;
+ unsigned char temp = 0;
+
+ if (shift > 7) {
+ MSG_DEBUG("Invalid Param value shift : %d", shift);
+ return 0;
+ }
+ /* shift 1 and shift 2 are supported in this spec. */
+ if (shift >= 4) {
+ MSG_DEBUG("Invalid Param value shift : %d", shift);
+ return 0;
+ }
+
+ for (int i = 0; i < DtmfLen; i++) {
+ if (shift == 0) {
+ if (i % 2 == 1) {
+ temp = pDtmf[srcIdx] & 0x0F;
+ srcIdx++;
+ } else {
+ temp = (pDtmf[srcIdx] >> 4) & 0x0F;
+ }
+ } else if (shift >= 1 && shift < 4) {
+ if (i % 2 == 1) {
+ temp = ((pDtmf[srcIdx] << shift) & 0x0F) + (pDtmf[srcIdx + 1] >> (8 - shift));
+ srcIdx++;
+ } else {
+ temp = (pDtmf[srcIdx] >> (8 - shift - 4)) & 0x0F;
+ }
+ }
+
+ if (temp == 0x0A)
+ pDigit[offset++] = '0';
+ else if (temp == 0x0B)
+ pDigit[offset++] = '*';
+ else if (temp == 0x0C)
+ pDigit[offset++] = '#';
+ else
+ pDigit[offset++] = temp + '0';
+ }
+
+ pDigit[offset] = '\0';
+
+ return offset;
+}
+
+
+bool Sms3gpp2ParamCodec::isDtmfNumber(const char *pDigit, int DigitLen)
+{
+ bool isDtmf = true;
+
+ for (int i = 0; i < DigitLen; i++) {
+ if (!((pDigit[i] >= '0' && pDigit[i] <= '9') ||
+ pDigit[i] == '*' ||
+ pDigit[i] == '#')) {
+ isDtmf = false;
+ break;
+ }
+ }
+
+ return isDtmf;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+#include <pthread.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+#include "MsgNotificationWrapper.h"
+
+#include "MsgContact.h"
+#include "MsgUtilStorage.h"
+#include "MsgTextConvert.h"
+
+#include "SmsPluginMain.h"
+#include "SmsPluginDSHandler.h"
+#include "Sms3gpp2ParamCodec.h"
+#include "Sms3gpp2TapiEventHandler.h"
+#include "Sms3gpp2EventHandler.h"
+#include "Sms3gpp2Setting.h"
+
+
+#include <tapi_common.h>
+#include <TelSms.h>
+#include <TapiUtility.h>
+#include <ITapiNetText.h>
+#include <ITapiSim.h>
+#include <ITapiModem.h>
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF SmsPluginSetting - Member Functions
+==================================================================================================*/
+Sms3gpp2Setting* Sms3gpp2Setting::pInstance = NULL;
+
+
+Sms3gpp2Setting::Sms3gpp2Setting()
+{
+ /* Initialize member variables */
+ memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
+ memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+ memset(&meImei, 0x00, sizeof(meImei));
+
+ bTapiResult = false;
+ bUpdateVoicemailByMdn = false;
+}
+
+
+Sms3gpp2Setting::~Sms3gpp2Setting()
+{
+}
+
+
+Sms3gpp2Setting* Sms3gpp2Setting::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2Setting();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gpp2Setting::initializeSimInfo(TapiHandle *handle)
+{
+ pthread_t thd;
+ int tapiRet = TAPI_API_SUCCESS;
+ /* Get IMSI */
+ char imsi[17];
+ memset(imsi, 0x00, sizeof(imsi));
+
+ /* Get IMSI */
+ TelSimImsiInfo_t imsiInfo;
+ memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
+
+ tapiRet = tel_get_sim_imsi(handle, &imsiInfo);
+
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_SEC_DEBUG("tel_get_sim_imsi() Success - MCC [%s], MNC [%s], MSIN [%s]", imsiInfo.szMcc, imsiInfo.szMnc, imsiInfo.szMsin);
+ snprintf(imsi, sizeof(imsi), "%03d%03d%s", atoi(imsiInfo.szMcc), atoi(imsiInfo.szMnc), imsiInfo.szMsin);
+ MSG_SEC_DEBUG("IMSI [%s]", imsi);
+ } else {
+ MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
+ }
+
+ MsgSettingSetString(MSG_SIM_IMSI, imsi);
+
+ if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
+ MSG_ERR("pthread_create() error");
+ } else {
+ pthread_detach(thd);
+ }
+}
+
+
+void* Sms3gpp2Setting::initSimInfo(void *data)
+{
+ static MsgMutex mm;
+ MsgMutexLocker lock(mm);
+
+ Sms3gpp2Setting::instance()->updateSimStatus(static_cast<TapiHandle*>(data));
+
+ return NULL;
+}
+
+void Sms3gpp2Setting::updateSimStatus(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ MSG_ERR_RET_M(!handle, "handle is NULL!");
+
+ int tapiRet = TAPI_API_SUCCESS;
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ /* Check device ready & modem status */
+ int deviceStatus = 0;
+ tapiRet = tel_check_sms_device_status(handle, &deviceStatus);
+ MSG_ERR_RET_M(tapiRet != TAPI_API_SUCCESS, "tel_check_sms_device_status() failed: (%d)", tapiRet);
+
+ if (deviceStatus != TAPI_NETTEXT_READY_STATUS_NONE) {
+ MSG_INFO("Device is READY!");
+ } else {
+ MSG_INFO("Device is NOT READY.. Waiting for ready Callback!");
+
+ if (Sms3gpp2EventHandler::instance()->getDeviceStatus(handle) == true) {
+ MSG_INFO("Device is finally READY!");
+ } else {
+ SmsPluginDSHandler::instance()->setNeedToInitializeSim(handle, true);
+ MSG_ERR("Device is finally NOT READY!");
+ return;
+ }
+ }
+
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+
+ /* Save Subcriber ID */
+ char *subscriberId = NULL;
+ if (SmsPluginDSHandler::instance()->getSubscriberId(simIndex, &subscriberId) != MSG_SUCCESS) {
+ MSG_ERR("getSubscriberId() is failed");
+ } else {
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, simIndex);
+ MsgSettingSetString(keyName, subscriberId);
+ }
+
+ g_free(subscriberId); subscriberId = NULL;
+
+ initConfigData(handle);
+
+ MSG_END();
+
+ return;
+}
+
+
+void Sms3gpp2Setting::setSimChangeStatus(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ pthread_t thd;
+ if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
+ MSG_ERR("pthread_create() error");
+ } else {
+ pthread_detach(thd);
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2Setting::initConfigData(TapiHandle *handle)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+ int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+
+ /*==================== CB configuration ====================*/
+ /*
+ if (simStatus != MSG_SIM_STATUS_NOT_FOUND) {
+ MSG_DEBUG("simStatus == [%d]", simStatus);
+ */
+ MSG_CBMSG_OPT_S cbMsgOpt = {0, };
+ cbMsgOpt.simIndex = simIndex;
+ if (getCbConfig(&cbMsgOpt) == true) {
+ err = addCbOpt(&cbMsgOpt);
+
+ if (err == MSG_SUCCESS) {
+ MSG_DEBUG("######## Add CB Option Success !!! #######");
+ MSG_SETTING_S cbSetting;
+ cbSetting.type = MSG_CBMSG_OPT;
+ getCbOpt(&cbSetting, simIndex);
+ setCbConfig(&(cbSetting.option.cbMsgOpt));
+ } else {
+ MSG_DEBUG("######## Add CB Option Fail !!! return : %d #######", err);
+ }
+ } else {
+ MSG_DEBUG("######## getCbConfig Fail !!! #######");
+ }
+
+ /*==================== MSISDN update ====================*/
+ if (getMsisdnInfo(handle) == true) {
+ MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
+ } else {
+ MSG_DEBUG("######## getMsisdnInfo Fail !!! #######");
+ }
+
+ /*==================== Default Voice mail Setting ====================*/
+ MSG_DEBUG("Voicemail Default Number is NULL");
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
+ if (MsgSettingSetString(keyName, "") != MSG_SUCCESS)
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, simIndex);
+ if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
+ MSG_DEBUG("Error to set config data [%s]", keyName);
+
+ MSG_END();
+}
+
+
+void Sms3gpp2Setting::SimRefreshCb(TapiHandle *handle)
+{
+ pthread_t thd;
+
+ if (pthread_create(&thd, NULL, &init_config_data, handle) < 0) {
+ MSG_ERR("pthread_create() error");
+ } else {
+ pthread_detach(thd);
+ }
+}
+
+
+void* Sms3gpp2Setting::init_config_data(void *data)
+{
+ instance()->initConfigData(static_cast<TapiHandle*>(data));
+ return NULL;
+}
+
+
+void Sms3gpp2Setting::setConfigData(const MSG_SETTING_S *pSetting)
+{
+ MSG_DEBUG("Setting Type : [%d]", pSetting->type);
+
+ switch (pSetting->type) {
+#if 0
+ case MSG_SMS_SENDOPT :
+ setNetworkMode(&pSetting->option.smsSendOpt);
+ break;
+ case MSG_SMSC_LIST :
+ setParamList(&pSetting->option.smscList);
+ break;
+#endif
+ case MSG_VOICEMAIL_OPT:
+ setVoiceMailInfo(&pSetting->option.voiceMailOpt);
+ break;
+ case MSG_CBMSG_OPT :
+ setCbConfig(&pSetting->option.cbMsgOpt);
+ break;
+ default :
+ THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+ break;
+ }
+}
+
+
+void Sms3gpp2Setting::getConfigData(MSG_SETTING_S *pSetting)
+{
+ MSG_DEBUG("Setting Type : [%d]", pSetting->type);
+
+ switch (pSetting->type) {
+#if 0
+ case MSG_SMSC_LIST :
+ getParamList(&pSetting->option.smscList);
+ break;
+#endif
+ case MSG_CBMSG_OPT :
+ getCbConfig(&pSetting->option.cbMsgOpt);
+ break;
+ default :
+ THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+ break;
+ }
+}
+
+
+msg_error_t Sms3gpp2Setting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+ /* MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt); */
+
+ MSG_DEBUG("Receive [%d], Channel Count [%d]", pCbOpt->bReceive, pCbOpt->channelData.channelCnt);
+
+ for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
+ MSG_DEBUG("Channel Category [%d], Channel Language [%d]", pCbOpt->channelData.channelInfo[i].ctg, pCbOpt->channelData.channelInfo[i].lang);
+ }
+
+#if 0
+ /* Set Setting Data into Vconf */
+ if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
+ return MSG_ERR_SET_SETTING;
+ }
+#endif
+
+#if 0
+ if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
+ MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
+ return MSG_ERR_SET_SETTING;
+ }
+#endif
+
+#if 0
+ MsgDbHandler dbHandle;
+ err = MsgStoAddCBChannelInfo(&dbHandle, &pCbOpt->channelData);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("MsgStoGetCBChannelInfo is failed [%d]", err);
+ return MSG_ERR_SET_SETTING;
+ }
+#endif
+
+ return err;
+}
+
+
+void Sms3gpp2Setting::getCbOpt(MSG_SETTING_S *pSetting, int simIndex)
+{
+ msg_error_t err = MSG_SUCCESS;
+ MsgDbHandler dbHandle;
+
+ memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+ if (MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ err = MsgStoGetCBChannelInfo(&dbHandle, &pSetting->option.cbMsgOpt.channelData);
+ MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
+ pSetting->option.cbMsgOpt.simIndex = simIndex;
+
+#if 0
+ char keyName[128];
+
+ for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", CB_LANGUAGE, i);
+
+ if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+ }
+#endif
+}
+
+void Sms3gpp2Setting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
+{
+ bUpdateVoicemailByMdn = false;
+}
+
+bool Sms3gpp2Setting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
+{
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
+ MSG_DEBUG("simIndex: (%d)", pCbOpt->simIndex);
+
+ TelSmsCbConfig_t cbConfig = {};
+ cbConfig.CBEnabled = (int)pCbOpt->bReceive;
+ cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP2;
+ /* cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt; */
+ cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
+
+ for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
+ cbConfig.MsgIDs[i].Net3gpp2.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
+ cbConfig.MsgIDs[i].Net3gpp2.CBCategory = (unsigned short)pCbOpt->channelData.channelInfo[i].ctg;
+ cbConfig.MsgIDs[i].Net3gpp2.CBLanguage = (unsigned short)pCbOpt->channelData.channelInfo[i].lang;
+
+ MSG_DEBUG("Category: %d, Language: %d", cbConfig.MsgIDs[i].Net3gpp2.CBCategory, cbConfig.MsgIDs[i].Net3gpp2.CBLanguage);
+ }
+ MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);
+
+ int tRet = tel_set_sms_cb_config(tHandle, &cbConfig, Sms3gpp2TapiEventHandler::respSetConfigData, NULL);
+ if (tRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", tRet);
+ return false;
+ }
+
+ return true;
+}
+
+
+bool Sms3gpp2Setting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
+{
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
+ MSG_DEBUG("simIndex: (%d)", pCbOpt->simIndex);
+
+ int tRet = tel_get_sms_cb_config(tHandle, Sms3gpp2TapiEventHandler::respGetCBConfig, NULL);
+ if (tRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_get_sms_cb_config() Fail !!! return : %d #######", tRet);
+ return false;
+ }
+
+ if (getCbConfigEvent(pCbOpt) == true) {
+ MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Get Cb Config was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gpp2Setting::getMeImei(char *pImei)
+{
+#if 0
+ int ret = TAPI_API_SUCCESS;
+ ret = tel_get_misc_me_imei(pTapiHandle, TapiEventGetMeImei, NULL);
+
+ if (ret == TAPI_API_SUCCESS) {
+ MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Success !!! #######");
+
+ if (getResultImei(pImei) == true) {
+ MSG_SEC_DEBUG("######## Get ME IMEI was Successful !!! #######");
+ } else {
+ MSG_SEC_DEBUG("######## Get ME IMEI was Failed !!! #######");
+ }
+ } else {
+ MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Fail !!! return : %d #######", ret);
+ }
+#endif
+}
+
+bool Sms3gpp2Setting::getUpdateVoicemailByMdn()
+{
+ return bUpdateVoicemailByMdn;
+}
+
+void Sms3gpp2Setting::setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
+{
+ mx.lock();
+
+ bTapiResult = bSuccess;
+
+ memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+ if (bTapiResult == true) {
+ MSG_DEBUG("Success to get cb config data");
+
+ memcpy(&cbOpt, pCbOpt, sizeof(MSG_CBMSG_OPT_S));
+ }
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gpp2Setting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ bTapiResult = false;
+ ret = cv.timedwait(mx.pMsgMutex(), 25);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
+
+ if (bTapiResult == true) {
+ memcpy(pCbOpt, &cbOpt, sizeof(MSG_CBMSG_OPT_S));
+ }
+
+ return bTapiResult;
+}
+
+
+void Sms3gpp2Setting::setResultImei(bool bResult, char *pImei)
+{
+ mx.lock();
+
+ bTapiResult = bResult;
+
+ memset(&meImei, 0x00, sizeof(meImei));
+
+ if (bTapiResult == true && pImei) {
+ snprintf(meImei, sizeof(meImei), "%s", pImei);
+ }
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gpp2Setting::getResultImei(char *pImei)
+{
+ int ret = 0;
+
+ mx.lock();
+
+ ret = cv.timedwait(mx.pMsgMutex(), 25);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ if (bTapiResult == true && pImei) {
+ snprintf(pImei, sizeof(meImei), "%s", meImei);
+ }
+
+ return bTapiResult;
+}
+
+
+void Sms3gpp2Setting::setResultFromEvent(bool bResult)
+{
+ mx.lock();
+
+ bTapiResult = bResult;
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+void Sms3gpp2Setting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
+{
+ MSG_DEBUG("SET MWI INFO, type=[%d]", type);
+ MSG_DEBUG("SET MWI INFO, count=[%d]", count);
+
+ if (MsgSettingSetInt(VOICEMAIL_COUNT, count) != MSG_SUCCESS)
+ MSG_DEBUG("MsgSettingSetInt is failed!!");
+ /*
+ if (count == 0) {
+ MsgStoClearUniquenessTable();
+ }
+
+ if (count <= 0) {
+ if (type == MSG_MWI_VOICE_SMS)
+ MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_1);
+ else if (type == MSG_MWI_VOICE2_SMS)
+ MsgCleanAndResetNotification(MSG_NOTI_TYPE_VOICE_2);
+ }
+
+ if (bMbdnEnable == false) {
+ MSG_DEBUG("MBDN service is disable.");
+ return;
+ }
+ */
+ return;
+}
+
+
+bool Sms3gpp2Setting::getMsisdnInfo(TapiHandle *handle)
+{
+ int tRet = tel_get_sim_msisdn(handle, Sms3gpp2TapiEventHandler::respGetMsisdnInfo, NULL);
+
+ if (tRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
+ } else {
+ MSG_ERR("######## tel_get_sim_msisdn() Fail !!! return : %d #######", tRet);
+ return false;
+ }
+
+ if (getResultFromSim() == true) {
+ MSG_DEBUG("######## Get Sim msisdn was Successful !!! #######");
+ } else {
+ MSG_ERR("######## Get Sim msisdn was Failed !!! #######");
+ return false;
+ }
+
+ return true;
+}
+
+
+void Sms3gpp2Setting::setResultFromSim(bool bResult)
+{
+ mx.lock();
+
+ bTapiResult = bResult;
+
+ cv.signal();
+
+ mx.unlock();
+}
+
+
+bool Sms3gpp2Setting::getResultFromSim()
+{
+ int ret = 0;
+
+ mx.lock();
+
+ ret = cv.timedwait(mx.pMsgMutex(), 25);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
+ return false;
+ }
+
+ return bTapiResult;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <glib.h>
+#include <TelSms.h>
+#include <TelNetwork.h>
+#include <TelPower.h>
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgException.h"
+#include "MsgGconfWrapper.h"
+
+#include "SmsPluginDSHandler.h"
+#include "Sms3gpp2TapiEventHandler.h"
+#include "Sms3gpp2EventHandler.h"
+#include "Sms3gpp2Transport.h"
+#include "Sms3gpp2Setting.h"
+#include "Sms3gpp2Types.h"
+#include "Sms3gpp2Codec.h"
+
+/*==================================================================================================
+ FUNCTION IMPLEMENTATION
+==================================================================================================*/
+void Sms3gpp2TapiEventHandler::NotiSmsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
+
+ MSG_DEBUG("pDataPackage->format = [%d]", pDataPackage->format);
+ MSG_DEBUG("pDataPackage->Sca = [%s]", pDataPackage->Sca);
+ MSG_DEBUG("pDataPackage->MsgLength = [%d]", pDataPackage->MsgLength);
+ MSG_DEBUG("pDataPackage->szData = ");
+ for (int i = 0; i < pDataPackage->MsgLength; i++) {
+ MSG_DEBUG("[%02x]", pDataPackage->szData[i]);
+ }
+
+ char tpduTmp[(pDataPackage->MsgLength*2)+1];
+ memset(tpduTmp, 0x00, sizeof(tpduTmp));
+ for (int i = 0; i < pDataPackage->MsgLength; i++) {
+ snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pDataPackage->szData[i]);
+ }
+ MSG_WARN("[%s]", tpduTmp);
+
+ sms_3gpp2_trans_msg_s sms_trans_msg;
+ memset(&sms_trans_msg, 0x00, sizeof(sms_3gpp2_trans_msg_s));
+
+ if (pDataPackage->format == (TelSmsNetType_t)0x03) {
+ /* voice mail notification */
+ sms_trans_msg.data.p2p_msg.telesvc_msg.type = SMS_TYPE_DELIVER;
+ sms_trans_msg.data.p2p_msg.telesvc_id = SMS_TRANS_TELESVC_VMN_95;
+
+ int num_msg = 0;
+ for (int i = 0; i < pDataPackage->MsgLength; i++) {
+ num_msg*=256;
+ num_msg+=pDataPackage->szData[i];
+ }
+
+ sms_trans_msg.data.p2p_msg.telesvc_msg.data.deliver.num_msg = num_msg;
+
+ char *voiceNumber = NULL;
+ if (MsgSettingGetString(VOICEMAIL_NUMBER, &voiceNumber) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+ if (voiceNumber) {
+ snprintf(sms_trans_msg.data.p2p_msg.address.szData, sizeof(sms_trans_msg.data.p2p_msg.address.szData), "%s", voiceNumber);
+ free(voiceNumber);
+ voiceNumber = NULL;
+ }
+ sms_trans_msg.data.p2p_msg.address.addr_len = strlen(sms_trans_msg.data.p2p_msg.address.szData);
+ } else {
+ bool bInvalid = Sms3gpp2MsgCodec::checkInvalidPDU(pDataPackage->szData, pDataPackage->MsgLength);
+ if (bInvalid == true) {
+ /* Decode Incoming Message */
+ Sms3gpp2MsgCodec::decodeMsg(pDataPackage->szData, pDataPackage->MsgLength, &sms_trans_msg);
+
+ if (sms_trans_msg.data.cb_msg.telesvc_msg.data.deliver.cmas_data.is_wrong_recode_type) {
+ MSG_WARN("Invalid CMAS Record Type");
+ return;
+ }
+ } else {
+ MSG_WARN("Invalid PDU");
+ return;
+ }
+ }
+
+ /* Print tpdu */
+ if (sms_trans_msg.type == SMS_TRANS_P2P_MSG) {
+ MSG_DEBUG("############# SMS_TRANS_P2P_MSG Incoming decoded tpdu values ####################");
+ MSG_DEBUG("------------------------------ transport layer data -----------------------------");
+ MSG_DEBUG("sms_trans_msg.type = [%d]", sms_trans_msg.type);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.telesvc_id = [%d]", sms_trans_msg.data.p2p_msg.telesvc_id);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.digit_mode = [%d]", sms_trans_msg.data.p2p_msg.address.digit_mode);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.number_mode = [%d]", sms_trans_msg.data.p2p_msg.address.number_mode);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.number_plan = [%d]", sms_trans_msg.data.p2p_msg.address.number_plan);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.number_type = [%d]", sms_trans_msg.data.p2p_msg.address.number_type);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.addr_len = [%d]", sms_trans_msg.data.p2p_msg.address.addr_len);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.address.szData = [%s]", sms_trans_msg.data.p2p_msg.address.szData);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.svc_ctg = [%d]", sms_trans_msg.data.p2p_msg.svc_ctg);
+ MSG_DEBUG("----------------------- teleservice layer : deliver data -------------------------");
+ sms_3gpp2_telesvc_deliver_s *deliver_msg = &(sms_trans_msg.data.p2p_msg.telesvc_msg.data.deliver);
+ MSG_DEBUG("sms_trans_msg.data.p2p_msg.telesvc_msg.type = [%d]", sms_trans_msg.data.p2p_msg.telesvc_msg.type);
+ MSG_DEBUG("priority= [%d]", deliver_msg->priority);
+ MSG_DEBUG("privacy= [%d]", deliver_msg->privacy);
+ MSG_DEBUG("display_mode= [%d]", deliver_msg->display_mode);
+ MSG_DEBUG("language= [%d]", deliver_msg->language);
+ MSG_DEBUG("msg_id= [%u]", deliver_msg->msg_id.msg_id);
+ MSG_DEBUG("alert_priority= [%d]", deliver_msg->alert_priority);
+ MSG_DEBUG("num_msg= [%d]", deliver_msg->num_msg);
+ MSG_DEBUG("user_data.msg_type= [%d]", deliver_msg->user_data.msg_type);
+ MSG_DEBUG("user_data.encode_type= [%d]", deliver_msg->user_data.encode_type);
+ MSG_DEBUG("user_data.data_len= [%d]", deliver_msg->user_data.data_len);
+ MSG_DEBUG("user_data.user_data= [%s]", deliver_msg->user_data.user_data);
+ MSG_DEBUG("time_stamp.year= [%d]", deliver_msg->time_stamp.year);
+ MSG_DEBUG("time_stamp.month= [%d]", deliver_msg->time_stamp.month);
+ MSG_DEBUG("time_stamp.day= [%d]", deliver_msg->time_stamp.day);
+ MSG_DEBUG("time_stamp.hours= [%d]", deliver_msg->time_stamp.hours);
+ MSG_DEBUG("time_stamp.minutes= [%d]", deliver_msg->time_stamp.minutes);
+ MSG_DEBUG("time_stamp.seconds= [%d]", deliver_msg->time_stamp.seconds);
+ MSG_DEBUG("deliver_msg->callback_number.addr_len= [%d]", deliver_msg->callback_number.addr_len);
+ MSG_DEBUG("deliver_msg->callback_number.digit_mode= [%d]", deliver_msg->callback_number.digit_mode);
+ MSG_DEBUG("deliver_msg->callback_number.number_plan= [%d]", deliver_msg->callback_number.number_plan);
+ MSG_DEBUG("deliver_msg->callback_number.number_type= [%d]", deliver_msg->callback_number.number_type);
+ MSG_DEBUG("deliver_msg->callback_number.szData= [%s]", deliver_msg->callback_number.szData);
+ MSG_DEBUG("#####################################################");
+ } else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
+ MSG_DEBUG("############# SMS_TRANS_BROADCAST_MSG Incoming decoded tpdu values ####################");
+ MSG_DEBUG("------------------------------ transport layer data -----------------------------");
+ MSG_DEBUG("sms_trans_msg.data.cb_msg.svc_ctg = [%d]", sms_trans_msg.data.cb_msg.svc_ctg);
+ MSG_DEBUG("----------------------- teleservice layer : deliver data -------------------------");
+ sms_3gpp2_telesvc_deliver_s *deliver_msg = &(sms_trans_msg.data.cb_msg.telesvc_msg.data.deliver);
+ MSG_DEBUG("sms_trans_msg.data.cb_msg.telesvc_msg.type = [%d]", sms_trans_msg.data.cb_msg.telesvc_msg.type);
+ MSG_DEBUG("priority= [%d]", deliver_msg->priority);
+ MSG_DEBUG("display_mode= [%d]", deliver_msg->display_mode);
+ MSG_DEBUG("language= [%d]", deliver_msg->language);
+ MSG_DEBUG("msg_id= [%u]", deliver_msg->msg_id.msg_id);
+ MSG_DEBUG("msg_id.msg_id)= [%d]", deliver_msg->msg_id.msg_id);
+ MSG_DEBUG("header_ind= [%d]", deliver_msg->msg_id.header_ind);
+ MSG_DEBUG("alert_priority= [%d]", deliver_msg->alert_priority);
+ MSG_DEBUG("cmas_data.encode_type= [%d]", deliver_msg->cmas_data.encode_type);
+ MSG_DEBUG("cmas_data.data_len= [%d]", deliver_msg->cmas_data.data_len);
+ MSG_DEBUG("cmas_data.alert_text= [%s]", deliver_msg->cmas_data.alert_text);
+ MSG_DEBUG("cmas_data.response_type= [%d]", deliver_msg->cmas_data.response_type);
+ MSG_DEBUG("cmas_data.severity= [%d]", deliver_msg->cmas_data.severity);
+ MSG_DEBUG("cmas_data.urgency= [%d]", deliver_msg->cmas_data.urgency);
+ MSG_DEBUG("cmas_data.certainty= [%d]", deliver_msg->cmas_data.certainty);
+ MSG_DEBUG("cmas_data.id= [%d]", deliver_msg->cmas_data.id);
+ MSG_DEBUG("time_stamp.year= [%d]", deliver_msg->time_stamp.year);
+ MSG_DEBUG("time_stamp.month= [%d]", deliver_msg->time_stamp.month);
+ MSG_DEBUG("time_stamp.day= [%d]", deliver_msg->time_stamp.day);
+ MSG_DEBUG("time_stamp.hours= [%d]", deliver_msg->time_stamp.hours);
+ MSG_DEBUG("time_stamp.minutes= [%d]", deliver_msg->time_stamp.minutes);
+ MSG_DEBUG("time_stamp.seconds= [%d]", deliver_msg->time_stamp.seconds);
+ MSG_DEBUG("deliver_msg->callback_number.addr_len= [%d]", deliver_msg->callback_number.addr_len);
+ MSG_DEBUG("deliver_msg->callback_number.digit_mode= [%d]", deliver_msg->callback_number.digit_mode);
+ MSG_DEBUG("deliver_msg->callback_number.number_plan= [%d]", deliver_msg->callback_number.number_plan);
+ MSG_DEBUG("deliver_msg->callback_number.number_type= [%d]", deliver_msg->callback_number.number_type);
+ MSG_DEBUG("deliver_msg->callback_number.szData= [%s]", deliver_msg->callback_number.szData);
+ MSG_DEBUG("#####################################################");
+ } else if (sms_trans_msg.type == SMS_TRANS_ACK_MSG) {
+ /* DLOG */
+ MSG_DEBUG("#####################################################");
+ }
+
+ try {
+ if (sms_trans_msg.type == SMS_TRANS_P2P_MSG) {
+ if (sms_trans_msg.data.p2p_msg.telesvc_id == SMS_TRANS_TELESVC_WAP) {
+ Sms3gpp2EventHandler::instance()->handleWapMsgIncoming(handle, &(sms_trans_msg.data.p2p_msg));
+ } else {
+ /* Call Event Handler */
+ Sms3gpp2EventHandler::instance()->handleMsgIncoming(handle, &(sms_trans_msg.data.p2p_msg));
+ }
+ } else if (sms_trans_msg.type == SMS_TRANS_BROADCAST_MSG) {
+ /* Call Event Handler */
+ Sms3gpp2EventHandler::instance()->handleCbMsgIncoming(handle, &(sms_trans_msg.data.cb_msg));
+ } else if (sms_trans_msg.type == SMS_TRANS_ACK_MSG) {
+ /* Call Event Handler */
+ /* Sms3gpp2EventHandler::instance()->handleAckMsgIncoming(&(sms_trans_msg.data.ack_msg)); */
+ }
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+void Sms3gpp2TapiEventHandler::NotiSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_INFO("noti_id: (%s)", noti_id);
+
+ Sms3gpp2Setting::instance()->SimRefreshCb(handle);
+}
+
+void Sms3gpp2TapiEventHandler::NotiSmsDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ try {
+ int deviceStatus = *(int*)data;
+ MSG_INFO("Device ready status: (%d)", deviceStatus);
+
+ Sms3gpp2EventHandler::instance()->setDeviceStatus(handle, deviceStatus != TAPI_NETTEXT_READY_STATUS_NONE);
+
+ if (SmsPluginDSHandler::instance()->getNeedToInitializeSim(handle) == true) {
+ SmsPluginDSHandler::instance()->setNeedToInitializeSim(handle, false);
+ Sms3gpp2Setting::instance()->initializeSimInfo(handle);
+ }
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+
+void Sms3gpp2TapiEventHandler::NotiNetworkRegistrationType(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+{
+ MSG_ERR_RET_M(data == NULL, "Invalid parameter: data is NULL!");
+
+ TelNetworkServiceType_t *type = (TelNetworkServiceType_t *)data;
+ MSG_DEBUG("network status type [%d]", *type);
+
+ if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) {
+ Sms3gpp2EventHandler::instance()->handleResendMessage();
+ }
+}
+
+void Sms3gpp2TapiEventHandler::respSetMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result: (%d)", result);
+
+ if (result == TAPI_API_SUCCESS) {
+ Sms3gpp2Transport::instance()->setIsMemAvailable(true);
+ }
+}
+
+void Sms3gpp2TapiEventHandler::respSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result: (0x%x)", result);
+
+ SMS_NETWORK_STATUS_T sentStatus;
+
+ /* Convert TAPI status -> SMS network status */
+ switch ((TelSmsResponse_t)result) {
+ case TAPI_NETTEXT_SENDSMS_SUCCESS:
+ sentStatus = SMS_NETWORK_SEND_SUCCESS;
+ break;
+ case TAPI_NETTEXT_INVALID_MANDATORY_INFO:
+ sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
+ break;
+ case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE:
+ case TAPI_NETTEXT_TEMPORARY_FAILURE:
+ case TAPI_NETTEXT_CONGESTION:
+ case TAPI_NETTEXT_RESOURCES_UNAVAILABLE:
+ case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL:
+ sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
+ break;
+ case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED:
+ case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED:
+ sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
+ break;
+ default:
+ sentStatus = SMS_NETWORK_SEND_FAIL;
+ break;
+ }
+
+ MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
+
+ if (sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
+ sentStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING ||
+ sentStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
+ Sms3gpp2Transport::instance()->setNetStatus(sentStatus);
+ return;
+ }
+
+ if (sentStatus == SMS_NETWORK_SEND_FAIL) {
+ int svc_type;
+ tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+ if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
+ sentStatus = SMS_NETWORK_SEND_PENDING;
+ }
+ }
+
+ /* Convert SMS status -> Messaging network status */
+ msg_network_status_t netStatus;
+
+ if (sentStatus == SMS_NETWORK_SEND_SUCCESS) {
+ netStatus = MSG_NETWORK_SEND_SUCCESS;
+ } else if (sentStatus == SMS_NETWORK_SENDING) {
+ netStatus = MSG_NETWORK_SENDING;
+ } else if (sentStatus == SMS_NETWORK_SEND_PENDING) {
+ netStatus = MSG_NETWORK_SEND_PENDING;
+#if 0 /* sentStatus below is not used */
+ } else if (sentStatus == SMS_NETWORK_SENDING) {
+ netStatus = MSG_NETWORK_SENDING;
+ } else if (sentStatus == SMS_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER) {
+ netStatus = MSG_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER;
+ } else if (sentStatus == SMS_NETWORK_SEND_FAIL_MS_DISABLED) {
+ netStatus = MSG_NETWORK_SEND_FAIL_MS_DISABLED;
+ } else if (sentStatus == SMS_NETWORK_SEND_FAIL_NETWORK_NOT_READY) {
+ netStatus = MSG_NETWORK_SEND_FAIL_NETWORK_NOT_READY;
+#endif
+ } else {
+ netStatus = MSG_NETWORK_SEND_FAIL;
+ }
+
+ try {
+ Sms3gpp2EventHandler::instance()->handleSentStatus(netStatus);
+ Sms3gpp2Transport::instance()->setNetStatus(sentStatus);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+ return;
+ }
+}
+
+void Sms3gpp2TapiEventHandler::respDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_DEBUG("result: (%d)", result);
+}
+
+void Sms3gpp2TapiEventHandler::respSetConfigData(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result: (%d)", result);
+
+ if (data == NULL) {
+ MSG_ERR("Error. data is NULL. result:%d", result);
+ Sms3gpp2Setting::instance()->setResultFromEvent(false);
+ return;
+ }
+
+ TelSmsSetResponse* responseType = (TelSmsSetResponse*)data;
+
+ MSG_DEBUG("responseType : [%d]", *responseType);
+
+ switch (*responseType) {
+ case TAPI_NETTEXT_SETPREFERREDBEARER_RSP:
+ MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
+ break;
+ case TAPI_NETTEXT_SETPARAMETERS_RSP:
+ MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
+ break;
+ case TAPI_NETTEXT_CBSETCONFIG_RSP:
+ MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
+ break;
+ case TAPI_NETTEXT_SETMEMORYSTATUS_RSP:
+ MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
+ break;
+ case TAPI_NETTEXT_SETMESSAGESTATUS_RSP:
+ MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
+ break;
+ default:
+ MSG_WARN("Unknown Response is called [%d]", *responseType);
+ break;
+ }
+
+ bool bRet = true;
+
+ MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
+
+ if ((TelSmsCause_t)result != TAPI_NETTEXT_SUCCESS) {
+ bRet = false;
+ }
+
+ Sms3gpp2Setting::instance()->setResultFromEvent(bRet);
+}
+
+void Sms3gpp2TapiEventHandler::respGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result: (%d)", result);
+
+ MSG_CBMSG_OPT_S cbOpt = {0};
+
+ if (result != TAPI_API_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:%d", result);
+ Sms3gpp2Setting::instance()->setCbConfigEvent(NULL, false);
+ return;
+ }
+
+ TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)data;
+
+ cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
+
+ /* cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount; */
+ /* MSG_DEBUG("Receive [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.maxSimCnt); */
+ MSG_DEBUG("Receive [%d]", cbOpt.bReceive);
+
+ cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
+
+ if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX) {
+ MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
+ cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
+ }
+
+ MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
+
+ for (int i = 0; i < cbOpt.channelData.channelCnt; i++) {
+ cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp2.Selected;
+ cbOpt.channelData.channelInfo[i].ctg = pCBConfig->MsgIDs[i].Net3gpp2.CBCategory;
+ cbOpt.channelData.channelInfo[i].lang = pCBConfig->MsgIDs[i].Net3gpp2.CBLanguage;
+ memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
+
+ MSG_DEBUG("Channel Category [%d], Channel Language [%d] ", cbOpt.channelData.channelInfo[i].ctg, cbOpt.channelData.channelInfo[i].lang);
+ }
+
+ Sms3gpp2Setting::instance()->setCbConfigEvent(&cbOpt, true);
+}
+
+void Sms3gpp2TapiEventHandler::respGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ MSG_INFO("result: (%d)", result);
+
+ bool bRet = false;
+
+ if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
+ MSG_ERR("Error. data is NULL. result:%d", result);
+ Sms3gpp2Setting::instance()->setResultFromSim(bRet);
+ return;
+ }
+
+ TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
+
+ for (int i = 0; i < list->count; i++) {
+ if (list->list[i].num[0] != '\0') {
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, SmsPluginDSHandler::instance()->getSimIndex(handle));
+
+ if (MsgSettingSetString(keyName, list->list[i].num) == MSG_SUCCESS) {
+ MSG_SEC_INFO("Get MSISDN from SIM : [%s]", list->list[i].num);
+ bRet = true;
+ } else {
+ MSG_ERR("Getting MSISDN is failed!");
+ }
+ break;
+ }
+ }
+
+ Sms3gpp2Setting::instance()->setResultFromSim(bRet);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <errno.h>
+#include <TapiUtility.h>
+#include <TelSms.h>
+#include <TelNetwork.h>
+#include <ITapiNetText.h>
+
+#include "MsgGconfWrapper.h"
+#include "MsgException.h"
+#include "MsgUtilFunction.h"
+
+#include "MsgUtilStorage.h"
+#include "MsgNotificationWrapper.h"
+
+#include "Sms3gpp2Transport.h"
+#include "Sms3gpp2Codec.h"
+#include "Sms3gpp2EventHandler.h"
+#include "Sms3gpp2TapiEventHandler.h"
+#include "Sms3gpp2UAManager.h"
+#include "SmsPluginDSHandler.h"
+#include "SmsPluginStorage.h"
+
+
+Sms3gpp2Transport* Sms3gpp2Transport::pInstance = NULL;
+
+
+msg_error_t Sms3gpp2SubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
+{
+ msg_error_t err = MSG_SUCCESS;
+
+#ifdef MSG_FEATURE_MDM
+#ifdef MSG_FEATURE_MDM_PHASE_2
+ /* Check MDM policy for Normal SMS */
+ if (pReqInfo->msgInfo.msgType.subType == MSG_NORMAL_SMS) {
+ if (MsgMdmGetStatus(MSG_MDM_OUTGOING_COUNT_LIMIT, pReqInfo->msgInfo.sim_idx, NULL) == MDM_RESTRICTED) {
+ MSG_INFO("SmsPlgSubmitRequest is restricted by MDM count limit.");
+ err = SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+ if (err == MSG_SUCCESS) {
+ return MSG_ERR_MDM_RESTRICT;
+ } else {
+ return err;
+ }
+ }
+
+ for (int i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) {
+ if (MsgMdmGetStatus(MSG_MDM_OUTGOING_RESTRICTION, pReqInfo->msgInfo.sim_idx, pReqInfo->msgInfo.addressList[i].addressVal) == MDM_RESTRICTED) {
+ MSG_INFO("SmsPlgSubmitRequest is restricted by MDM pattern matching.");
+ err = SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+ if (err == MSG_SUCCESS) {
+ return MSG_ERR_MDM_RESTRICT;
+ } else {
+ return err;
+ }
+ }
+ }
+ }
+#endif
+#endif
+
+ /* Add Submit SMS into DB */
+ if (pReqInfo->msgInfo.msgId == 0) {
+ if (pReqInfo->msgInfo.msgPort.valid == false) {
+ err = SmsPluginStorage::instance()->checkMessage(&(pReqInfo->msgInfo));
+
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("######## checkMessage Fail !! [err=%d]", err);
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+
+ err = SmsPluginStorage::instance()->addSmsMessage(&(pReqInfo->msgInfo));
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("######## addSmsMessage Fail !! [err=%d]", err);
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+
+ if (SmsPluginStorage::instance()->addSmsSendOption(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)) != MSG_SUCCESS) {
+ MSG_ERR("######## addSmsSendOption Fail !!");
+ return MSG_ERR_PLUGIN_STORAGE;
+ }
+ }
+ }
+
+#ifdef MSG_FEATURE_MDM
+#ifdef MSG_FEATURE_MDM_PHASE_2
+ /* MDM :: SMS capture for outgoing SMS */
+ if (pReqInfo->msgInfo.msgType.subType == MSG_NORMAL_SMS) {
+ if (MsgMdmGetStatus(MSG_MDM_MESSAGE_COPY, pReqInfo->msgInfo.sim_idx, NULL) == MDM_ENABLED) {
+ mdm_result_t mdmResult = MsgMdmMessageCopy(&pReqInfo->msgInfo);
+ if (mdmResult != MDM_RESULT_SUCCESS) {
+ MSG_ERR("MsgMdmMessageCopy() failed: (%d)", mdmResult);
+ }
+ }
+ }
+#endif
+#endif
+
+ /* Check SIM is present or not */
+ /*
+ MSG_SIM_STATUS_T simStatus = 0;
+ if (MsgSettingGetInt(keyName, (int*)&simStatus) != MSG_SUCCESS) {
+ MSG_ERR("MsgSettingGetInt() failed!");
+ }
+
+ if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
+ MSG_DEBUG("SIM is not present..");
+
+ if (pReqInfo->msgInfo.msgPort.valid == false)
+ SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
+
+ return MSG_ERR_NO_SIM;
+ }
+ */
+
+ sms_3gpp2_request_info_s *request = NULL;
+
+ request = (sms_3gpp2_request_info_s *)calloc(1, sizeof(sms_3gpp2_request_info_s));
+
+ if (request != NULL) {
+ request->reqId = pReqInfo->reqId;
+
+ memcpy(&(request->msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
+ memcpy(&(request->sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
+
+ /* Add Request into Queue and Start UA Manger */
+ Sms3gpp2UAManager::instance()->addReqEntity(request);
+
+ free(request);
+ }
+
+
+ return MSG_SUCCESS;
+}
+
+/*==================================================================================================
+ FUNCTION IMPLEMENTATION
+==================================================================================================*/
+Sms3gpp2Transport::Sms3gpp2Transport()
+{
+ isMemAvailable = true;
+ msgRef = 0x00;
+ msgRef8bit = 0x00;
+ msgRef16bit = 0x0000;
+ curStatus = SMS_NETWORK_SEND_SUCCESS;
+
+ msgSeqNum = 0x00;
+ if (MsgSettingGetInt(MSG_MESSAGE_ID_COUNTER, (int *)&msgSubmitId) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() is failed");
+ }
+}
+
+
+Sms3gpp2Transport::~Sms3gpp2Transport()
+{
+}
+
+
+Sms3gpp2Transport* Sms3gpp2Transport::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2Transport();
+ }
+
+ return pInstance;
+}
+
+
+unsigned char Sms3gpp2Transport::getMsgRef()
+{
+ return msgRef++;
+}
+
+
+unsigned char Sms3gpp2Transport::getSeqNum()
+{
+ msgSeqNum = ((msgSeqNum + 1) % SMS_SEQ_NUM_MAX);
+
+ return msgSeqNum;
+}
+
+
+unsigned char Sms3gpp2Transport::getSubmitMsgId()
+{
+ msgSubmitId = ((msgSubmitId + 1) % SMS_MAX_MESSAGE_ID);
+
+ MsgSettingSetInt(MSG_MESSAGE_ID_COUNTER, msgSubmitId);
+
+ return msgSubmitId;
+}
+
+
+void Sms3gpp2Transport::convertMsgInfoToTelesvcMsg(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_3gpp2_trans_msg_s *pTransMsg)
+{
+ switch (pTransMsg->type) {
+ case SMS_TRANS_P2P_MSG: {
+ MSG_DEBUG("Convert MSG_MESSAGE_INFO_S data to SMS_TRANS_MSG_S data.");
+ sms_3gpp2_trans_p2p_msg_s *pPtpMsg = (sms_3gpp2_trans_p2p_msg_s *)&(pTransMsg->data.p2p_msg);
+
+ convertMsgInfoToPtp(pMsgInfo, pPtpMsg);
+ }
+ break;
+ default:
+ MSG_DEBUG("Error Unsupported Transport Type");
+ break;
+ }
+}
+
+
+void Sms3gpp2Transport::convertMsgInfoToPtp(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_3gpp2_trans_p2p_msg_s *pPtpMsg)
+{
+ /* 1. Set Teleservice ID */
+ pPtpMsg->telesvc_id = SMS_TRANS_TELESVC_CMT_95;
+
+ /* 2. Set Service category */
+ pPtpMsg->svc_ctg = SMS_TRANS_SVC_CTG_UNDEFINED;
+
+ /* 3. Convert Address values */
+ pPtpMsg->address.digit_mode = SMS_DIGIT_4BIT_DTMF;
+ pPtpMsg->address.number_mode = SMS_NUMBER_MODE_NONE_DATANETWORK;
+ pPtpMsg->address.number_type = SMS_NUMBER_TYPE_UNKNOWN;
+ pPtpMsg->address.number_plan = SMS_3GPP2_NPI_UNKNOWN;
+ pPtpMsg->address.addr_len = strlen(pMsgInfo->addressList[0].addressVal);
+ strncpy(pPtpMsg->address.szData, pMsgInfo->addressList[0].addressVal, pPtpMsg->address.addr_len);
+ pPtpMsg->address.szData[pPtpMsg->address.addr_len] = '\0';
+
+ if (pMsgInfo->addressList[0].addressVal[0] == '+') {
+ pPtpMsg->address.digit_mode = SMS_DIGIT_8BIT;
+ pPtpMsg->address.number_type = SMS_NUMBER_TYPE_INTERNATIONAL;
+ } else {
+ pPtpMsg->address.number_type = SMS_NUMBER_TYPE_NATIONAL;
+ }
+
+ /* 4. Convert Sub-address values */
+ /* TODO */
+
+ /* 5. Set Reply sequence number. */
+ bool CDMASupported = MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE);
+
+ if (CDMASupported) {
+ pPtpMsg->reply_seq = getSeqNum();
+ }
+
+ /* convert msgInfo to Teleservice Message */
+ switch (pPtpMsg->telesvc_msg.type) {
+ case SMS_TYPE_SUBMIT:
+ convertMsgInfoToSubmit(pMsgInfo, &(pPtpMsg->telesvc_msg.data.submit));
+ break;
+ default:
+ break;
+ }
+}
+
+
+void Sms3gpp2Transport::convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_3gpp2_telesvc_submit_s *pSubmit)
+{
+ if (pSubmit == NULL)
+ return;
+
+ /* 1. Set msg ID. */
+ pSubmit->msg_id.msg_id = getSubmitMsgId();
+ pSubmit->msg_id.header_ind = false;
+
+ /* 2. Set User Data */
+ unsigned char decodeData[SMS_MAX_USER_DATA_LEN + 1];
+ memset(decodeData, 0x00, sizeof(decodeData));
+
+ MsgTextConvert *textCvt = MsgTextConvert::instance();
+
+ msg_encode_type_t encodeType = MSG_ENCODE_GSM7BIT;
+
+ if (pMsgInfo->bTextSms == true) {
+ if (pMsgInfo->encodeType == MSG_ENCODE_GSM7BIT) {
+ pSubmit->user_data.encode_type = SMS_ENCODE_GSM7BIT;
+ } else if (pMsgInfo->encodeType == MSG_ENCODE_8BIT) {
+ pSubmit->user_data.encode_type = SMS_ENCODE_OCTET;
+ } else if (pMsgInfo->encodeType == MSG_ENCODE_UCS2) {
+ pSubmit->user_data.encode_type = SMS_ENCODE_UNICODE;
+ } else if (pMsgInfo->encodeType == MSG_ENCODE_AUTO) {
+ textCvt->convertUTF8ToAuto(decodeData, SMS_MAX_USER_DATA_LEN + 1, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, MSG_ENCODE_ASCII7BIT, &encodeType);
+ if (encodeType == MSG_ENCODE_ASCII7BIT) {
+ pSubmit->user_data.encode_type = SMS_ENCODE_7BIT_ASCII;
+ } else if (encodeType == MSG_ENCODE_8BIT) {
+ pSubmit->user_data.encode_type = SMS_ENCODE_OCTET;
+ } else if (encodeType == MSG_ENCODE_UCS2) {
+ pSubmit->user_data.encode_type = SMS_ENCODE_UNICODE;
+ }
+ }
+ }
+
+ memset(pSubmit->user_data.user_data, 0x00, sizeof(pSubmit->user_data.user_data));
+ int wrn = snprintf((char *)pSubmit->user_data.user_data, sizeof(pSubmit->user_data.user_data), "%s", pMsgInfo->msgText);
+ if (wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+ pSubmit->user_data.data_len = pMsgInfo->dataSize;
+
+ MSG_DEBUG("encode type : [%d]", pSubmit->user_data.encode_type);
+
+ /* 3. Set Valid period */
+#if 0
+ pSubmit->val_period.format = SMS_3GPP2_TIME_ABSOLUTE;
+ pSubmit->val_period.time.abs_time.year = 0;
+ pSubmit->val_period.time.abs_time.month = 0;
+ pSubmit->val_period.time.abs_time.day = 0;
+ pSubmit->val_period.time.abs_time.hours = 0;
+ pSubmit->val_period.time.abs_time.minutes = 0;
+ pSubmit->val_period.time.abs_time.seconds = 0;
+#else
+ pSubmit->val_period.format = SMS_3GPP2_TIME_RELATIVE;
+ pSubmit->val_period.time.rel_time.rel_time = SMS_REL_TIME_INDEFINITE;
+#endif
+
+ /* 4. Set Defer valid period */
+ /* TODO */
+
+ /* 5. Set Priority */
+ switch (pMsgInfo->priority) {
+ case MSG_MESSAGE_PRIORITY_HIGH:
+ pSubmit->priority = SMS_PRIORITY_URGENT;
+ break;
+ default:
+ pSubmit->priority = SMS_PRIORITY_NORMAL;
+ break;
+ }
+
+ /* 6. Set Privacy */
+ pSubmit->privacy = SMS_PRIVACY_NOT_RESTRICTED;
+
+ /* 7. Set Reply option */
+ if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, (bool *)&(pSubmit->reply_opt.deliver_ack_req)) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ /* 8. Set Alert priority */
+ pSubmit->alert_priority = SMS_ALERT_MOBILE_DEFAULT;
+
+ /* 9. Set Language */
+ pSubmit->language = SMS_LAN_UNKNOWN;
+
+ /* 10. Set Callback number */
+ /* TODO :: Set callback number to MSISDN */
+
+ /* 11. Set Multi encode data */
+ /* TODO */
+
+ /* 12. Set Deposit id */
+ /* TODO */
+
+ /* 13. Set Service category program data */
+ /* TODO */
+}
+
+
+void Sms3gpp2Transport::submitRequest(sms_3gpp2_request_info_s *pReqInfo)
+{
+ int tapiRet = TAPI_API_SUCCESS;
+
+ if (pReqInfo == NULL) {
+ THROW(MsgException::SMS_PLG_ERROR, "pReqInfo is NULL");
+ }
+
+ TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pReqInfo->msgInfo.sim_idx);
+
+ /* Get address informations. */
+ MsgDbHandler *dbHandle = getDbHandle();
+ MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
+
+ MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt);
+
+ /* Get MSISDN */
+ char *msisdn = NULL;
+ char keyName[MAX_VCONFKEY_NAME_LEN];
+
+ memset(keyName, 0x00, sizeof(keyName));
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pReqInfo->msgInfo.sim_idx);
+
+ if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetString() is failed");
+ }
+
+ /* Tapi Data Structure */
+ TelSmsDatapackageInfo_t tapi_data_pkg;
+ memset(&tapi_data_pkg, 0x00, sizeof(TelSmsDatapackageInfo_t));
+
+ bool bMoreMsgToSend = false;
+
+ tapi_data_pkg.format = (TelSmsNetType_t)TAPI_NETTEXT_NETTYPE_3GPP2;
+
+ /* convert msg_info to trans_msg */
+ sms_3gpp2_trans_msg_s trans_msg;
+ memset(&trans_msg, 0x00, sizeof(sms_3gpp2_trans_msg_s));
+
+ trans_msg.type = (sms_3gpp2_trans_msg_type_t)SMS_TRANS_P2P_MSG;
+ trans_msg.data.p2p_msg.telesvc_msg.type = (sms_3gpp2_message_type_t)SMS_TYPE_SUBMIT;
+
+ convertMsgInfoToTelesvcMsg(&pReqInfo->msgInfo, &trans_msg);
+
+ /* encode msg data */
+ unsigned char tel_sms_data[TAPI_NETTEXT_SMDATA_SIZE_MAX+1] = {0,};
+ tapi_data_pkg.MsgLength = Sms3gpp2MsgCodec::instance()->encodeMsg(&trans_msg, tel_sms_data);
+ memcpy((void *)tapi_data_pkg.szData, (void *)tel_sms_data, sizeof(tapi_data_pkg.szData));
+
+ MSG_DEBUG("Submit Request TPDU.");
+ char pduDbg[TAPI_NETTEXT_SMDATA_SIZE_MAX*2];
+ memset(pduDbg, 0x00, sizeof(pduDbg));
+
+ for (int i = 0; i < tapi_data_pkg.MsgLength; i++) {
+ snprintf(pduDbg+(i*2), sizeof(pduDbg)- (i*2), "%02x", tapi_data_pkg.szData[i]);
+ }
+ MSG_DEBUG("Encode PDU= [%s]", pduDbg);
+
+ SMS_NETWORK_STATUS_T retStatus;
+
+ for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY_FOR_3GPP2; cnt++) {
+ /* send request */
+ sms_3gpp2_sent_info_s sent_info;
+ memset(&sent_info, 0x00, sizeof(sms_3gpp2_sent_info_s));
+ memcpy(&sent_info.reqInfo, pReqInfo, sizeof(sent_info.reqInfo));
+
+ sent_info.bLast = true;
+ Sms3gpp2EventHandler::instance()->SetSentInfo(&sent_info);
+
+ int svc_type;
+ tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
+
+ if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
+ MSG_DEBUG("Network service is not available : [%d]", svc_type);
+ Sms3gpp2EventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
+ goto _RETURN_FUNC;
+ }
+
+ curStatus = SMS_NETWORK_SENDING;
+
+ /* Send SMS */
+ tapiRet = tel_send_sms(handle, &tapi_data_pkg, bMoreMsgToSend, Sms3gpp2TapiEventHandler::respSentStatus, NULL);
+ if (tapiRet == TAPI_API_SUCCESS) {
+ MSG_DEBUG("######## tel_send_sms Success !!! return : [%d] #######", tapiRet);
+ } else {
+ Sms3gpp2EventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_send_sms Fail !!! return : [%d] #######", tapiRet);
+ }
+
+ /* Tizen Validation System */
+ MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s", pReqInfo->msgInfo.msgId, \
+ (msisdn == NULL)?"ME":msisdn, \
+ pReqInfo->msgInfo.addressList[0].addressVal, \
+ (tapiRet == TAPI_API_SUCCESS)?"Success":"Fail");
+
+ MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
+
+ retStatus = getNetStatus();
+ if (retStatus != SMS_NETWORK_SEND_FAIL_TEMPORARY)
+ break;
+ }
+
+ MSG_SMS_VLD_INFO("%d, SMS Send End, %s->%s, %s", pReqInfo->msgInfo.msgId, \
+ (msisdn == NULL)?"ME":msisdn, \
+ pReqInfo->msgInfo.addressList[0].addressVal, \
+ (retStatus == SMS_NETWORK_SEND_SUCCESS)?"Success":"Fail");
+
+ if (retStatus == SMS_NETWORK_SEND_SUCCESS) {
+ MSG_DEBUG("######## Msg Sent was Successful !!! #######");
+ } else {
+ if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT || retStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY
+ || retStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING || retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
+ Sms3gpp2EventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
+
+ if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
+ MsgInsertTicker("Unable to send the message while Fixed dialling mode is enabled", SMS_FDN_RESTRICTED, true, 0);
+ else if (retStatus == SMS_NETWORK_SEND_PENDING)
+ MsgInsertTicker("Network not available. Message will be sent when connected to network.", SMS_MESSAGE_SENDING_PENDING, true, 0);
+ else
+ MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, pReqInfo->msgInfo.msgId);
+ }
+
+_RETURN_FUNC :
+ if (msisdn) {
+ free(msisdn);
+ msisdn = NULL;
+ }
+
+ MSG_END();
+ return;
+}
+
+void Sms3gpp2Transport::sendDeliverReport(TapiHandle *handle, msg_error_t err, sms_3gpp2_trans_p2p_msg_s *p_p2p_msg)
+{
+ MSG_BEGIN();
+
+ int tapiRet = TAPI_API_SUCCESS;
+ TelSmsResponse_t response;
+
+ sms_3gpp2_trans_msg_s trans_msg;
+ memset(&trans_msg, 0x00, sizeof(sms_3gpp2_trans_msg_s));
+
+ trans_msg.type = (sms_3gpp2_trans_msg_type_t)SMS_TRANS_ACK_MSG;
+
+ if (p_p2p_msg) {
+ memcpy(&(trans_msg.data.ack_msg.address), &(p_p2p_msg->address), sizeof(sms_3gpp2_trans_addr_s));
+ }
+
+ sms_3gpp2_trans_cause_code_s cause_code;
+ memset(&cause_code, 0x00, sizeof(sms_3gpp2_trans_cause_code_s));
+
+ if ((p_p2p_msg) && (p_p2p_msg->reply_seq > 0))
+ cause_code.reply_seq = p_p2p_msg->reply_seq;
+
+
+ if (err == MSG_SUCCESS) {
+ cause_code.error_class = SMS_TRANS_ERR_CLASS_NONE;
+
+ response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+
+ if (isMemAvailable == false) {
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, Sms3gpp2TapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+ }
+ } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
+ cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
+ response = TAPI_NETTEXT_ME_FULL;
+ /* MsgInsertTicker("Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL, true, 0); */
+
+ tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, Sms3gpp2TapiEventHandler::respSetMemoryStatus, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
+
+ } else if (err == MSG_ERR_UNKNOWN) {
+ cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
+ cause_code.cause_code = SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED;
+
+ response = TAPI_NETTEXT_SENDSMS_SUCCESS;
+ } else if (err == MSG_ERR_INVALID_MSG_TYPE) {
+ cause_code.error_class = SMS_TRANS_ERR_CLASS_PERMANENT;
+ cause_code.cause_code = SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID;
+
+ response = TAPI_NETTEXT_INVALID_MSG;
+ } else {
+ cause_code.error_class = SMS_TRANS_ERR_CLASS_TEMPORARY;
+
+ response = TAPI_NETTEXT_SIM_FULL;
+ }
+
+ memcpy(&(trans_msg.data.ack_msg.cause_code), &(cause_code), sizeof(sms_3gpp2_trans_cause_code_s));
+
+ MSG_DEBUG("err : [%d], response : [%02x]", err, response);
+
+ int bufLen = 0;
+ unsigned char buf[512];
+ memset(buf, 0x00, sizeof(buf));
+ bufLen = Sms3gpp2MsgCodec::encodeMsg(&trans_msg, buf);
+
+ MSG_DEBUG("######## DeliverReport tpdu #########");
+ for (int i=0; i < bufLen; i++) {
+ printf("[%02x] ", buf[i]);
+ }
+ MSG_DEBUG("#################################");
+
+ /* Make Telephony Structure */
+ TelSmsDatapackageInfo_t pkgInfo;
+
+ pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP2;
+
+ /* Set TPDU data */
+ memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
+ memcpy((void*)pkgInfo.szData, buf, bufLen);
+
+ pkgInfo.szData[bufLen] = 0;
+ pkgInfo.MsgLength = bufLen;
+
+ /* Send Deliver Report */
+ tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, Sms3gpp2TapiEventHandler::respDeliveryReportCNF, NULL);
+
+ if (tapiRet == TAPI_API_SUCCESS)
+ MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! #######");
+ else
+ MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
+
+ MSG_END();
+}
+
+
+void Sms3gpp2Transport::setNetStatus(SMS_NETWORK_STATUS_T sentStatus)
+{
+ mx.lock();
+ curStatus = sentStatus;
+ cv.signal();
+ mx.unlock();
+}
+
+
+void Sms3gpp2Transport::setIsMemAvailable(bool isAvailable)
+{
+ isMemAvailable = isAvailable;
+}
+
+
+SMS_NETWORK_STATUS_T Sms3gpp2Transport::getNetStatus()
+{
+ mx.lock();
+
+ int ret = 0;
+
+ if (curStatus == SMS_NETWORK_SENDING)
+ ret = cv.timedwait(mx.pMsgMutex(), 125);
+
+ mx.unlock();
+
+ if (ret == ETIMEDOUT) {
+ MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
+ curStatus = SMS_NETWORK_SEND_FAIL_TIMEOUT;
+ }
+
+ return curStatus;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+
+#include "MsgException.h"
+#include "MsgCppTypes.h"
+#include "Sms3gpp2UAManager.h"
+#include "Sms3gpp2Transport.h"
+
+/*==================================================================================================
+ IMPLEMENTATION OF SmsPluginUAManager - Member Functions
+==================================================================================================*/
+Sms3gpp2UAManager* Sms3gpp2UAManager::pInstance = NULL;
+
+
+Sms3gpp2UAManager::Sms3gpp2UAManager() : mx(), cv()
+{
+ start();
+}
+
+
+Sms3gpp2UAManager::~Sms3gpp2UAManager()
+{
+}
+
+
+Sms3gpp2UAManager* Sms3gpp2UAManager::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2UAManager();
+ }
+
+ return pInstance;
+}
+
+
+void Sms3gpp2UAManager::run()
+{
+ while (1) {
+ lock();
+ while (smsTranQ.empty()) {
+ wait();
+ }
+ sms_3gpp2_request_info_s request;
+ smsTranQ.front(&request);
+ unlock();
+
+ request.msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter);
+
+ try {
+ Sms3gpp2Transport::instance()->submitRequest(&request);
+ } catch (MsgException& e) {
+ MSG_FATAL("%s", e.what());
+
+ lock();
+ smsTranQ.pop_front();
+ unlock();
+ continue;
+ } catch (exception& e) {
+ MSG_FATAL("%s", e.what());
+ lock();
+ smsTranQ.pop_front();
+ unlock();
+ continue;
+ }
+
+ lock();
+ smsTranQ.pop_front();
+ unlock();
+ }
+}
+
+
+void Sms3gpp2UAManager::addReqEntity(sms_3gpp2_request_info_s *request)
+{
+ sms_3gpp2_request_info_s reqTmp = {0, };
+
+ memcpy(&reqTmp, request, sizeof(sms_3gpp2_request_info_s));
+
+ lock();
+ smsTranQ.push_back(reqTmp);
+ cv.signal();
+ unlock();
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <glib.h>
+#include <gio/gio.h>
+#if MSG_DRM_SUPPORT
+#include <drm_client.h>
+#endif
+
+#include "MsgDebug.h"
+#include "MsgCppTypes.h"
+#include "MsgGconfWrapper.h"
+#include "MsgException.h"
+#include "MsgUtilFile.h"
+#include "Sms3gpp2Transport.h"
+#include "Sms3gpp2EventHandler.h"
+#include "Sms3gpp2WapPushHandler.h"
+#include "SmsPluginStorage.h"
+
+
+static unsigned short wapPushPortList[] = { 0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F };
+
+static char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
+static char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
+
+static const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000};
+
+static const unsigned char wspHeaderFieldCount = 0x43;
+static const unsigned char wspContentsTypeCount = 0x34;
+static const unsigned long wspLanguageCount = 0x11a;
+static const unsigned char wspSecurityTypeCount = 0x04;
+
+
+static const SMS_3GPP2_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] = {
+ { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
+ { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
+ { (char*)"application/pkcs7-mime", 0x37 },
+ { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
+ { (char*)"application/vnd.wap.signed-certificate", 0x39 },
+ { (char*)"application/vnd.wap.cert-response", 0x3A },
+ { (char*)"application/xhtml+xml", 0x3B },
+ { (char*)"application/wml+xml", 0x3C },
+ { (char*)"text/css", 0x3D },
+
+ { (char*)"application/vnd.wap.mms-message", 0x3E },
+
+ { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
+ { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
+ { (char*)"application/vnd.wap.loc+xml", 0x41 },
+ { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
+ { (char*)"application/vnd.syncml.dm+xml", 0x43 },
+ { (char*)"application/vnd.syncml.notification", 0x44 },
+ { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
+ { (char*)"application/vnd.wv.csp.cir", 0x46 },
+
+ { (char*)"application/vnd.oma.dd+xml", 0x47},
+ { (char*)"application/vnd.oma.drm.message", 0x48 },
+ { (char*)"application/vnd.oma.drm.content", 0x49 },
+ { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
+ { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
+ { (char*)"application/vnd.syncml.ds.notification", 0x4E},
+ { (char*)"application/mikey", 0x52},
+ { (char*)"", 0xff }
+};
+
+
+static const char* wspHeaderFieldName[] = {
+ (char*)"Accept", /* 0x00 */
+ (char*)"Accept-Charset",
+ (char*)"Accept-Encoding",
+ (char*)"Accept-Language",
+ (char*)"Accept-Ranges",
+ (char*)"Age", /* 0x05 */
+ (char*)"Allow",
+ (char*)"Authorization",
+ (char*)"Cache-Control",
+ (char*)"Connection",
+ (char*)"Content-Base", /* 0x0a */
+ (char*)"Content-Encoding",
+ (char*)"Content-Language",
+ (char*)"Content-Length",
+ (char*)"Content-Location",
+ (char*)"Content-MD5",
+ (char*)"Content-Range", /* 0x10 */
+ (char*)"Content-Type",
+ (char*)"Date",
+ (char*)"ETag",
+ (char*)"Expires",
+ (char*)"From", /* 0x15 */
+ (char*)"Host",
+ (char*)"If-Modified-Since",
+ (char*)"If-Match",
+ (char*)"If-None-Match",
+ (char*)"If-Range", /* 0x1a */
+ (char*)"If-Unmodified-Since",
+ (char*)"Location",
+ (char*)"Last-Modified",
+ (char*)"Max-Forwards",
+ (char*)"Pragma",
+ (char*)"Proxy-Authenticate", /* 0x20 */
+ (char*)"Proxy-Authorization",
+ (char*)"Public",
+ (char*)"Range",
+ (char*)"Referer",
+ (char*)"Retry-After", /* 0x25 */
+ (char*)"Server",
+ (char*)"Transfer-Encodig",
+ (char*)"Upgrade",
+ (char*)"User-Agent",
+ (char*)"Vary", /* 0x2a */
+ (char*)"Via",
+ (char*)"Warning",
+ (char*)"Www-Authenticate",
+ (char*)"Content-Disposition",
+ (char*)"X-Wap-Application-Id",
+ (char*)"X-Wap-Content-URI", /* 0x30 */
+ (char*)"X-Wap-Iinitiator-URI",
+ (char*)"Accept-Application", /* Back */
+ (char*)"Bearer-Indication",
+ (char*)"Push-Flag",
+ (char*)"Profile", /* 0x35 */
+ (char*)"Profile-Diff",
+ (char*)"Profile-Warning", /* end of WAP 1.2 */
+ (char*)"Expect",
+ (char*)"Te",
+ (char*)"Trailer", /* 0x3a */
+ (char*)"Accept-Charset", /* Back */
+ (char*)"Accept-Encoding", /* Back */
+ (char*)"Cache-Control", /* back */
+ (char*)"Content-Range",
+ (char*)"X-Wap-Tod",
+ (char*)"Content-ID", /* 0x40 */
+ (char*)"Set-Cookie",
+ (char*)"Cookie",
+ (char*)"Encoding-Version"
+};
+
+
+static const SMS_3GPP2_WSP_CHARSET_S wspCharset[] = {
+ { (char*)"big5", 0x07ea },
+ { (char*)"iso-10646-ucs-2", 0x03e8 },
+ { (char*)"iso-8859-1", 0x04 },
+ { (char*)"iso-8859-2", 0x05 },
+ { (char*)"iso-8859-3", 0x06 },
+ { (char*)"iso-8859-4", 0x07 },
+ { (char*)"iso-8859-5", 0x08 },
+ { (char*)"iso-8859-6", 0x09 },
+ { (char*)"iso-8859-7", 0x0a },
+ { (char*)"iso-8859-8", 0x0b },
+ { (char*)"iso-8859-9", 0x0c },
+ { (char*)"shift-JIS", 0x11 },
+ { (char*)"us-ascii", 0x03 },
+ { (char*)"utf-8", 0x6a },
+ { (char*)"none", 0x26 },
+ { (char*)"", 0xffff }
+};
+
+
+static const char* wspEncodeMethod[] = {
+ (char*)"Gzip",
+ (char*)"Compress",
+ (char*)"Deflate"
+};
+
+
+static const SMS_3GPP2_WSP_CONTENTS_TYPE_S wspContentsType[] = {
+ { (char*)"*/*", 0x00 },
+ { (char*)"text/*", 0x01 },
+ { (char*)"text/html", 0x02 },
+ { (char*)"text/plain", 0x03 },
+ { (char*)"text/x-hdml", 0x04 },
+ { (char*)"text/x-ttml", 0x05 },
+ { (char*)"text/x-vCalendar", 0x06 },
+ { (char*)"text/x-vCard", 0x07 },
+ { (char*)"text/vnd.wap.wml", 0x08 },
+ { (char*)"text/vnd.wap.wmlscript", 0x09 },
+ { (char*)"text/vnd.wap.wta-event", 0x0a },
+ { (char*)"multipart/*", 0x0b },
+ { (char*)"multipart/mixed", 0x0c },
+ { (char*)"multipart/form-data", 0x0d },
+ { (char*)"multipart/byteranges", 0x0e },
+ { (char*)"multipart/alternative", 0x0f },
+ { (char*)"application/*", 0x10 },
+ { (char*)"application/java-vm", 0x11 },
+ { (char*)"application/x-www-form-urlencoded", 0x12 },
+ { (char*)"application/x-hdmlc", 0x13 },
+ { (char*)"application/vnd.wap.wmlc", 0x14 },
+ { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
+ { (char*)"application/vnd.wap.wta-eventc", 0x16 },
+ { (char*)"application/vnd.wap.uaprof", 0x17 },
+ { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
+ { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
+ { (char*)"application/x-x509-ca-cert", 0x1a },
+ { (char*)"application/x-x509-user-cert", 0x1b },
+ { (char*)"image/*", 0x1c },
+ { (char*)"image/gif", 0x1d },
+ { (char*)"image/jpeg", 0x1e },
+ { (char*)"image/tiff", 0x1f },
+ { (char*)"image/png", 0x20 },
+ { (char*)"image/vnd.wap.wbmp", 0x21 },
+ { (char*)"application/vnd.wap.multipart.*", 0x22 },
+ { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
+ { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
+ { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
+ { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
+ { (char*)"application/xml", 0x27 },
+ { (char*)"text/xml", 0x28 },
+ { (char*)"application/vnd.wap.wbxml", 0x29 },
+ { (char*)"application/x-x968-cross-cert", 0x2a },
+ { (char*)"application/x-x968-ca-cert", 0x2b },
+ { (char*)"application/x-x968-user-cert", 0x2c },
+ { (char*)"text/vnd.wap.si", 0x2d },
+ { (char*)"application/vnd.wap.sic", 0x2e },
+ { (char*)"text/vnd.wap.sl", 0x2f },
+ { (char*)"application/vnd.wap.slc", 0x30 },
+ { (char*)"text/vnd.wap.co", 0x31 },
+ { (char*)"application/vnd.wap.coc", 0x32 },
+ { (char*)"application/vnd.wap.multipart.related", 0x33 },
+ { (char*)"application/vnd.wap.sia", 0x34 },
+
+ { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
+ { (char*)"application/vnd.connectivity-wbxml", 0x36 },
+ { (char*)"application/pkcs7-mime", 0x37 },
+ { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
+ { (char*)"application/vnd.wap.signed-certificate", 0x39 },
+ { (char*)"application/vnd.wap.cert-response", 0x3A },
+ { (char*)"application/xhtml+xml", 0x3B },
+ { (char*)"application/wml+xml", 0x3C },
+ { (char*)"text/css", 0x3D },
+
+ { (char*)"application/vnd.wap.mms-message", 0x3E },
+
+ { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
+ { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
+ { (char*)"application/vnd.wap.loc+xml", 0x41 },
+ { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
+ { (char*)"application/vnd.syncml.dm+xml", 0x43 },
+ { (char*)"application/vnd.syncml.notification", 0x44 },
+ { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
+ { (char*)"application/vnd.wv.csp.cir", 0x46 }
+};
+
+
+static const SMS_3GPP2_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]= {
+ { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
+ { (char*)"application/vnd.omaloc-supl-init", 0x312},
+ { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
+};
+
+
+static const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_3GPP2_WAP_UNREGISTER_CONTENTS_TYPE_S);
+
+
+static const SMS_3GPP2_WSP_LANGUAGE_S wspLanguage[] = {
+ { (char*)"English", 0x19 },
+ { (char*)"en", 0x19 },
+ { (char*)"Korean", 0x3d },
+ { (char*)"*", 0x00 },
+ { (char*)"Afar", 0x01 },
+ { (char*)"aa", 0x01 },
+ { (char*)"Abkhazian", 0x02 },
+ { (char*)"ab", 0x02 },
+ { (char*)"Afrikaans", 0x03 },
+ { (char*)"af", 0x03 },
+ { (char*)"Amharic", 0x04 },
+ { (char*)"am", 0x04 },
+ { (char*)"Arabic", 0x05 },
+ { (char*)"ar", 0x05 },
+ { (char*)"Assamese", 0x06 },
+ { (char*)"as", 0x06 },
+ { (char*)"Aymara", 0x07 },
+ { (char*)"ay", 0x07 },
+ { (char*)"Azerbaijani", 0x08 },
+ { (char*)"az", 0x08 },
+ { (char*)"Bashkir", 0x09 },
+ { (char*)"ba", 0x09 },
+ { (char*)"Byelorussian", 0x0a },
+ { (char*)"be", 0x0a },
+ { (char*)"Bulgarian", 0x0b },
+ { (char*)"bg", 0x0b },
+ { (char*)"Bihari", 0x0c },
+ { (char*)"bh", 0x0c },
+ { (char*)"Bislama", 0x0d },
+ { (char*)"bi", 0x0f },
+ { (char*)"Bengali", 0x0e },
+ { (char*)"Bangla", 0x0e },
+ { (char*)"bn", 0x0e },
+ { (char*)"Tibetan", 0x0f },
+ { (char*)"bo", 0x0f },
+ { (char*)"Breton", 0x10 },
+ { (char*)"br", 0x10 },
+ { (char*)"Catalan", 0x11 },
+ { (char*)"ca", 0x11 },
+ { (char*)"Corsican", 0x12 },
+ { (char*)"co", 0x12 },
+ { (char*)"Czech", 0x13 },
+ { (char*)"cs", 0x13 },
+ { (char*)"Welsh", 0x14 },
+ { (char*)"cy", 0x14 },
+ { (char*)"Denish", 0x15 },
+ { (char*)"da", 0x15 },
+ { (char*)"German", 0x16 },
+ { (char*)"de", 0x16 },
+ { (char*)"Bhutani", 0x17 },
+ { (char*)"dz", 0x17 },
+ { (char*)"Greek", 0x18 },
+ { (char*)"el", 0x18 },
+ { (char*)"Esperanto", 0x81 },
+ { (char*)"eo", 0x1a },
+ { (char*)"Spanish", 0x1b },
+ { (char*)"es", 0x1b },
+ { (char*)"Estonian", 0x1c },
+ { (char*)"et", 0x1c },
+ { (char*)"Basque", 0x1d },
+ { (char*)"eu", 0x1d },
+ { (char*)"Persian", 0x1e },
+ { (char*)"fa", 0x1e },
+ { (char*)"Finnish", 0x1f },
+ { (char*)"fi", 0x1f },
+ { (char*)"Fiji", 0x20 },
+ { (char*)"fj", 0x20 },
+ { (char*)"Faeroese", 0x82 },
+ { (char*)"fo", 0x82 },
+ { (char*)"French", 0x22 },
+ { (char*)"fr", 0x22 },
+ { (char*)"Frisian", 0x83 },
+ { (char*)"fy", 0x83 },
+ { (char*)"Irish", 0x24 },
+ { (char*)"ga", 0x24 },
+ { (char*)"Scots Gaelic", 0x25 },
+ { (char*)"gd", 0x25 },
+ { (char*)"Galician", 0x26 },
+ { (char*)"gl", 0x26 },
+ { (char*)"Guarani", 0x27 },
+ { (char*)"gn", 0x27 },
+ { (char*)"Gujarati", 0x28 },
+ { (char*)"gu", 0x28 },
+ { (char*)"Hausa", 0x29 },
+ { (char*)"ha", 0x29 },
+ { (char*)"Hebrew", 0x2a },
+ { (char*)"he", 0x2a },
+ { (char*)"Hindi", 0x2b },
+ { (char*)"hi", 0x2b },
+ { (char*)"Croatian", 0x2c },
+ { (char*)"hr", 0x2c },
+ { (char*)"Hungarian", 0x2d },
+ { (char*)"hu", 0x2d },
+ { (char*)"Armenian", 0x2e },
+ { (char*)"hy", 0x2e },
+ { (char*)"Interlingua", 0x84 },
+ { (char*)"ia", 0x84 },
+ { (char*)"Indonesian", 0x30 },
+ { (char*)"id", 0x30 },
+ { (char*)"Interlingue", 0x86 },
+ { (char*)"ie", 0x86 },
+ { (char*)"Maori", 0x47 },
+ { (char*)"mi", 0x47 },
+ { (char*)"Macedonian", 0x48 },
+ { (char*)"mk", 0x48 },
+ { (char*)"Malayalam", 0x49 },
+ { (char*)"ml", 0x49 },
+ { (char*)"Mongolian", 0x4a },
+ { (char*)"mn", 0x4a },
+ { (char*)"Moldavian", 0x4b },
+ { (char*)"mo", 0x4d },
+ { (char*)"Marathi", 0x4c },
+ { (char*)"mr", 0x4c },
+ { (char*)"Malay", 0x4d },
+ { (char*)"ms", 0x4d },
+ { (char*)"Maltese", 0x4e },
+ { (char*)"mt", 0x4e },
+ { (char*)"Burmese", 0x4f },
+ { (char*)"my", 0x4f },
+ { (char*)"Nauru", 0x50 },
+ { (char*)"na", 0x50 },
+ { (char*)"Nepali", 0x51 },
+ { (char*)"ne", 0x51 },
+ { (char*)"Dutch", 0x52 },
+ { (char*)"nl", 0x52 },
+ { (char*)"Norwegian", 0x53 },
+ { (char*)"no", 0x53 },
+ { (char*)"Occitan", 0x54 },
+ { (char*)"oc", 0x54 },
+ { (char*)"(Afan) Oromo", 0x55 },
+ { (char*)"(Afan)Oromo", 0x55 },
+ { (char*)"om", 0x55 },
+ { (char*)"Oriya", 0x56 },
+ { (char*)"or", 0x56 },
+ { (char*)"Punjabi", 0x57 },
+ { (char*)"pa", 0x57 },
+ { (char*)"Polish", 0x58 },
+ { (char*)"po", 0x58 },
+ { (char*)"Pashto", 0x59 },
+ { (char*)"Pushto", 0x59 },
+ { (char*)"ps", 0x59 },
+ { (char*)"Portugurse", 0x5a },
+ { (char*)"pt", 0x5a },
+ { (char*)"Quechua", 0x5b },
+ { (char*)"qu", 0x5b },
+ { (char*)"Rhaeto-Romance", 0x8c },
+ { (char*)"rm", 0x8c },
+ { (char*)"Kirundi", 0x5d },
+ { (char*)"rn", 0x5d },
+ { (char*)"Romanian", 0x5e },
+ { (char*)"ro", 0x5e },
+ { (char*)"Russian", 0x5f },
+ { (char*)"ru", 0x5f },
+ { (char*)"Kinyarwanda", 0x60 },
+ { (char*)"rw", 0x60 },
+ { (char*)"Sanskrit", 0x61 },
+ { (char*)"sa", 0x61 },
+ { (char*)"Sindhi", 0x62 },
+ { (char*)"sd", 0x62 },
+ { (char*)"Sangho", 0x63 },
+ { (char*)"sg", 0x63 },
+ { (char*)"Serbo-Croatian", 0x64 },
+ { (char*)"sh", 0x64 },
+ { (char*)"Sinhalese", 0x65 },
+ { (char*)"si", 0x65 },
+ { (char*)"Slovak", 0x66 },
+ { (char*)"sk", 0x66 },
+ { (char*)"Slovenian", 0x67 },
+ { (char*)"sl", 0x67 },
+ { (char*)"Samoan", 0x68 },
+ { (char*)"sm", 0x68 },
+ { (char*)"Shona", 0x69 },
+ { (char*)"sn", 0x69 },
+ { (char*)"Somali", 0x6a },
+ { (char*)"so", 0x6a },
+ { (char*)"Albanian", 0x6b },
+ { (char*)"sq", 0x6b },
+ { (char*)"Serbian", 0x6c },
+ { (char*)"sr", 0x6c },
+ { (char*)"Siswati", 0x6d },
+ { (char*)"ss", 0x6d },
+ { (char*)"Sesotho", 0x6e },
+ { (char*)"st", 0x6e },
+ { (char*)"Sundanese", 0x6f },
+ { (char*)"su", 0x6f },
+ { (char*)"Swedish", 0x70 },
+ { (char*)"sv", 0x70 },
+ { (char*)"Swahili", 0x71 },
+ { (char*)"sw", 0x71 },
+ { (char*)"Tamil", 0x72 },
+ { (char*)"ta", 0x72 },
+ { (char*)"Telugu", 0x73 },
+ { (char*)"te", 0x73 },
+ { (char*)"Tajik", 0x74 },
+ { (char*)"tg", 0x74 },
+ { (char*)"Thai", 0x75 },
+ { (char*)"th", 0x75 },
+ { (char*)"Tigrinya", 0x76 },
+ { (char*)"ti", 0x76 },
+ { (char*)"Turkmen", 0x77 },
+ { (char*)"tk", 0x77 },
+ { (char*)"Inupiak", 0x87 },
+ { (char*)"ik", 0x87 },
+ { (char*)"Icelandic", 0x33 },
+ { (char*)"is", 0x33 },
+ { (char*)"Italian", 0x34 },
+ { (char*)"it", 0x34 },
+ { (char*)"Inuktitut", 0x89 },
+ { (char*)"iu", 0x89 },
+ { (char*)"Japanese", 0x36 },
+ { (char*)"ja", 0x36 },
+ { (char*)"Javanese", 0x37 },
+ { (char*)"jw", 0x37 },
+ { (char*)"Georgian", 0x38 },
+ { (char*)"ka", 0x38 },
+ { (char*)"Kazakh", 0x39 },
+ { (char*)"kk", 0x39 },
+ { (char*)"Gerrnlandic", 0x8a },
+ { (char*)"kl", 0x8a },
+ { (char*)"Cambodian", 0x3b },
+ { (char*)"km", 0x3b },
+ { (char*)"Kannada", 0x3c },
+ { (char*)"kn", 0x3c },
+ { (char*)"Kashmiri", 0x3e },
+ { (char*)"ks", 0x3e },
+ { (char*)"Kurdish", 0x3f },
+ { (char*)"ku", 0x3f },
+ { (char*)"Kirghiz", 0x40 },
+ { (char*)"ky", 0x40 },
+ { (char*)"Latin", 0x8b },
+ { (char*)"la", 0x8b },
+ { (char*)"Lingala", 0x42 },
+ { (char*)"ln", 0x42 },
+ { (char*)"Laothian", 0x43 },
+ { (char*)"lo", 0x43 },
+ { (char*)"Lithuanian", 0x44 },
+ { (char*)"lt", 0x44 },
+ { (char*)"Lavian", 0x45 },
+ { (char*)"Lettish", 0x45 },
+ { (char*)"lv", 0x45 },
+ { (char*)"Malagasy", 0x46 },
+ { (char*)"mg", 0x46 },
+ { (char*)"Tagalog", 0x78 },
+ { (char*)"tl", 0x78 },
+ { (char*)"Setswana", 0x79 },
+ { (char*)"tn", 0x79 },
+ { (char*)"Tonga", 0x7a },
+ { (char*)"to", 0x7a },
+ { (char*)"Turkish", 0x7b },
+ { (char*)"tr", 0x7b },
+ { (char*)"Tsonga", 0x7c },
+ { (char*)"ts", 0x7c },
+ { (char*)"Tatar", 0x7d },
+ { (char*)"tt", 0x7d },
+ { (char*)"Twi", 0x7e },
+ { (char*)"tw", 0x7e },
+ { (char*)"Uighur", 0x7f },
+ { (char*)"ug", 0x7f },
+ { (char*)"Ukrainian", 0x1a },
+ { (char*)"uk", 0x1a },
+ { (char*)"Urdu", 0x21 },
+ { (char*)"ur", 0x21 },
+ { (char*)"Uzbek", 0x23 },
+ { (char*)"uz", 0x23 },
+ { (char*)"Vietnamese", 0x2f },
+ { (char*)"vi", 0x2f },
+ { (char*)"Volapuk", 0x85 },
+ { (char*)"vo", 0x85 },
+ { (char*)"Wolof", 0x31 },
+ { (char*)"wo" , 0x31 },
+ { (char*)"Xhosa", 0x32 },
+ { (char*)"xh", 0x32 },
+ { (char*)"Yiddish", 0x88 },
+ { (char*)"yi", 0x88 },
+ { (char*)"Yoruba", 0x35 },
+ { (char*)"yo", 0x35 },
+ { (char*)"Zhuang", 0x3a },
+ { (char*)"z", 0x3a },
+ { (char*)"Chinese", 0x41 },
+ { (char*)"ch", 0x41 },
+ { (char*)"Zulu", 0x5c },
+ { (char*)"zu", 0x5c },
+ { (char*)"Ko", 0x3d }
+};
+
+
+static const SMS_3GPP2_WSP_HEADER_PARAMETER_S wspHeaderApplId[] = {
+ { (char*)"x-wap-application:*", 0x00 },
+ { (char*)"x-wap-application:push.sia", 0x01},
+ { (char*)"x-wap-application:wml.ua", 0x02 },
+ { (char*)"x-wap-application:wta.ua", 0x03 },
+ { (char*)"x-wap-application:mms.ua", 0x04 },
+ { (char*)"x-wap-application:push.syncml", 0x05 },
+ { (char*)"x-wap-application:loc.ua", 0x06 },
+ { (char*)"x-wap-application:syncml.dm", 0x07 },
+ { (char*)"x-wap-application:drm.ua", 0x08 },
+ { (char*)"x-wap-application:emn.ua", 0x09 },
+ { (char*)"x-oma-application:ulp.ua ", 0x90 },
+ { (char*)"x-oma-docomo:open.ctl", 0x9055 },
+ { (char*)"x-oma-docomo:xmd.mail.ua", 0x905C },
+ { (char*)"x-oma-docomo:xmd.storage.ua", 0x905F },
+ { (char*)"x-oma-docomo:xmd.lcsapp.ua", 0x9060 },
+ { (char*)"x-oma-docomo:xmd.info.ua", 0x9061 },
+ { (char*)"x-oma-docomo:xmd.agent.ua", 0x9062 },
+ { (char*)"x-oma-docomo:xmd.sab.ua", 0x9063 },
+ { (char*)"x-oma-docomo:xmd.am.ua", 0x9064 },
+ { (char*)"x-oma-docomo:xmd.emdm.ua", 0x906B },
+ { (char*)"x-oma-docomo:xmd.lac.ua", 0x906C },
+ { (char*)"x-oma-docomo:xmd.osv.ua", 0x906D },
+ { (char*)"x-oma-docomo:xmd.dcs.ua", 0x906E },
+ { (char*)"x-oma-docomo:xmd.wipe.ua", 0x906F },
+ { (char*)"x-oma-docomo:xmd.vdapp.ua ", 0x9070 },
+};
+
+
+static const char* wspCacheControl[] = {
+ (char*)"No-cache",
+ (char*)"No-store",
+ (char*)"Max-age",
+ (char*)"Max-stale",
+ (char*)"Min-fresh",
+ (char*)"Only-if-cached",
+ (char*)"Public",
+ (char*)"Private",
+ (char*)"No-transform",
+ (char*)"Must-revalidate",
+ (char*)"Proxy-revalidate"
+};
+
+
+static const SMS_3GPP2_WSP_METHOD_TYPE_S wspMethodType[] = {
+ { (char*)"GET", 0x40 },
+ { (char*)"OPTIONS", 0x41 },
+ { (char*)"HEAD", 0x42 },
+ { (char*)"DELETE", 0x43 },
+ { (char*)"TRACE", 0x44 },
+ { (char*)"POST", 0x60 },
+ { (char*)"PUT", 0x61 }
+};
+
+
+static const SMS_3GPP2_WSP_SECURITY_TYPE_S wspSecurityType[] = {
+ {(char*)"NETWPIN", 0x00},
+ {(char*)"USERPIN", 0x01},
+ {(char*)"USERNETWPIN", 0x02},
+ {(char*)"USERPINMAC", 0x03}
+};
+
+
+static const char* wspWeek[] = {
+ (char*)"Sun",
+ (char*)"Mon",
+ (char*)"Tue",
+ (char*)"Wed",
+ (char*)"Thu",
+ (char*)"Fri",
+ (char*)"Sat"
+};
+
+
+#ifdef MSG_FW_FOR_DEBUG
+static const char* wspWeekDay[] = {
+ (char*)"Sunday",
+ (char*)"Monday",
+ (char*)"Tuesday",
+ (char*)"Wednesday",
+ (char*)"Thursday",
+ (char*)"Friday",
+ (char*)"Saturday"
+};
+#endif
+
+
+static const char* wspMonth[] = {
+ (char*)"Jan",
+ (char*)"Feb",
+ (char*)"Mar",
+ (char*)"Apr",
+ (char*)"May",
+ (char*)"Jun",
+ (char*)"Jul",
+ (char*)"Aug",
+ (char*)"Sep",
+ (char*)"Oct",
+ (char*)"Nov",
+ (char*)"Dec"
+};
+
+
+
+/*==================================================================================================
+ IMPLEMENTATION OF SmsPluginWapPushHandler - Member Functions
+==================================================================================================*/
+Sms3gpp2WapPushHandler* Sms3gpp2WapPushHandler::pInstance = NULL;
+
+
+Sms3gpp2WapPushHandler::Sms3gpp2WapPushHandler()
+{
+ memset(&tmpAddress, 0x00, sizeof(tmpAddress));
+}
+
+
+Sms3gpp2WapPushHandler::~Sms3gpp2WapPushHandler()
+{
+}
+
+
+Sms3gpp2WapPushHandler* Sms3gpp2WapPushHandler::instance()
+{
+ if (!pInstance) {
+ pInstance = new Sms3gpp2WapPushHandler();
+ }
+
+ return pInstance;
+}
+
+
+bool Sms3gpp2WapPushHandler::IsWapPushMsg(unsigned short dstport)
+{
+ MSG_BEGIN();
+
+ int PortCount = sizeof(wapPushPortList)/sizeof(wapPushPortList[0]);
+
+ MSG_DEBUG("Port Count [%d]", PortCount);
+
+ for (int i = 0; i < PortCount; i++) {
+ if (dstport == wapPushPortList[i]) {
+ MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[i]);
+ return true;
+ }
+ }
+
+ MSG_END();
+
+ return false;
+}
+
+#if 0
+sms_wap_app_code_t Sms3gpp2WapPushHandler::getAppCode(const char *pPushHeader)
+{
+ int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
+
+ unsigned char *header = NULL;
+ SMS_WAP_APP_CODE_T appCode = SMS_WAP_APPLICATION_DEFAULT;
+
+ MSG_DEBUG("Application Count [%d]", appCount);
+
+ for (int i = 0; i < appCount; i++) {
+ header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
+
+ if (header != NULL) {
+ appCode = pushDefaultApplication[i].appCode;
+ break;
+ }
+ }
+
+ if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
+ MSG_DEBUG("Application Type is not supported");
+ } else {
+ MSG_DEBUG("Find Application [%d]", appCode);
+ }
+
+ return appCode;
+}
+#endif
+
+
+void Sms3gpp2WapPushHandler::copyDeliverData(sms_3gpp2_trans_addr_s *pAddr)
+{
+ memcpy(&tmpAddress, pAddr, sizeof(tmpAddress));
+
+ MSG_SEC_DEBUG("Address [%s]", tmpAddress.szData);
+
+/*
+ tmpTimeStamp.format = pDeliver->timeStamp.format;
+
+ if (tmpTimeStamp.format == SMS_3GPP2_TIME_ABSOLUTE) {
+ tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
+ tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
+ tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
+ tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
+ tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
+ tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
+ tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
+ }
+*/
+}
+
+
+void Sms3gpp2WapPushHandler::handleWapPushMsg(const char *pUserData, int simIndex, int DataSize)
+{
+ MSG_BEGIN();
+
+#ifdef MSG_FW_FOR_DEBUG
+ MSG_DEBUG("DataSize [%d]", DataSize);
+
+ MSG_DEBUG("[pUserData]");
+ for (int i = 0; i < DataSize; i++) {
+ printf("[%02x]", pUserData[i]);
+ }
+ printf("\n\n");
+#endif
+
+ unsigned char* pPDUTypeData = (unsigned char*)pUserData;
+ unsigned long PDUTypeDataLen = DataSize;
+
+ char* pPushHeader = NULL;
+ unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter);
+ unsigned long pushHeaderLen = 0;
+
+ char* pPushBody = NULL;
+ unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter);
+ unsigned long pushBodyLen = 0;
+
+ unsigned long iPDU = 1;
+
+ char* pWspHeader = NULL;
+ unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter);
+ unsigned long wspHeaderLen = 0;
+
+ char* pWspBody = NULL;
+ unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter);
+ unsigned long wspBodyLen = 0;
+
+ /* pass PDU type */
+ iPDU++;
+
+ pushHeaderLen = wspRetriveUintvarDecode(pPDUTypeData, &iPDU);
+
+ MSG_DEBUG("PDUTypeDataLen [%lu]", PDUTypeDataLen);
+ MSG_DEBUG("pushHeaderLen [%lu]", pushHeaderLen);
+ MSG_DEBUG("iPDU [%lu]", iPDU);
+
+ wspHeaderLen = pushHeaderLen + iPDU;
+
+ MSG_DEBUG("wspBodyLen [%lu]", wspBodyLen);
+
+ if (wspHeaderLen > 0) {
+ pWspHeader = new char[wspHeaderLen];
+
+ if (pWspHeader == NULL) {
+ MSG_DEBUG("pWspHeader Memory Allocation Failed");
+ return;
+ } else {
+ memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
+ }
+ }
+
+#ifdef MSG_FW_FOR_DEBUG
+ MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
+
+ MSG_DEBUG("[pWspHeader]");
+ for (int i = 0; i < wspHeaderLen; i++) {
+ printf("[%02x]", pWspHeader[i]);
+ }
+ printf("\n\n");
+#endif
+
+ /* return if it is below case error */
+ if (PDUTypeDataLen < wspHeaderLen) {
+ MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
+ return;
+ }
+
+ /* Finding wspBody Information */
+ wspBodyLen = PDUTypeDataLen - wspHeaderLen;
+
+ if (wspBodyLen > 0) {
+ pWspBody = new char[wspBodyLen];
+
+ if (pWspBody == NULL) {
+ MSG_DEBUG("pWspBody Memory Allocation Failed");
+ return;
+ } else {
+ memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
+ }
+ } else {
+ pWspBody = NULL;
+ }
+
+ wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
+
+ iPDU = iPDU + pushHeaderLen;
+
+ pushBodyLen = PDUTypeDataLen - iPDU ;
+
+ if (pushBodyLen > 0) {
+ pPushBody = new char[pushBodyLen];
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody Memory Allocation Failed");
+ return;
+ } else {
+ memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
+ }
+ } else {
+ pPushBody = NULL;
+ return;
+ }
+
+ handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen, simIndex);
+
+ MSG_END();
+}
+
+#if 0
+void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
+{
+ MSG_BEGIN();
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ SMS_WAP_APP_CODE_T appCode = getAppCode(pPushHeader);
+
+ /* check Push message receive setting */
+ bool bPushRecv = false;
+
+ if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
+ MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
+ return;
+ }
+
+ switch (appCode) {
+ case SMS_WAP_APPLICATION_MMS_UA:
+ MSG_DEBUG("Received MMS Notification");
+ handleMMSNotification(pPushBody, PushBodyLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SI:
+ MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
+ handleSIMessage(pPushBody, PushBodyLen, true);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SIC:
+ MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
+ handleSIMessage(pPushBody, PushBodyLen, false);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SL:
+ MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
+ handleSLMessage(pPushBody, PushBodyLen, true);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SLC:
+ MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
+ handleSLMessage(pPushBody, PushBodyLen, false);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_CO:
+ MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
+ handleCOMessage(pPushBody, PushBodyLen, true);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_COC:
+ MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
+ handleCOMessage(pPushBody, PushBodyLen, false);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ MSG_DEBUG("Received Provisioning");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ MSG_DEBUG("Received Provisioning");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ MSG_DEBUG("Received Provisioning");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+ MSG_DEBUG("Received DM Notification");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ MSG_DEBUG("Received DS Notification");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+ MSG_DEBUG("Received DS Notification");
+ SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
+ MSG_DEBUG("Received DRM UA");
+ if (pPushBody != NULL)
+ handleDrmVer1(pPushBody, PushBodyLen);
+ break;
+ case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
+ MSG_DEBUG("Received DRM V2");
+ /* TODO: DRM V2 */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_EMAIL:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
+ MSG_DEBUG("Received Email");
+ /* TODO: Email */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
+ MSG_DEBUG("Received IMPS CIR");
+ /* TODO: IMPS CIR */
+ break;
+ case SMS_WAP_APPLICATION_LBS:
+ MSG_DEBUG("Received LBS related message");
+ SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
+ /* TODO: LBS */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SIA:
+ MSG_DEBUG("Received SIA");
+ /* TODO: SIA */
+ break;
+ default:
+ MSG_DEBUG("Unknown Application [%d]", appCode);
+ break;
+ }
+
+ MSG_END();
+}
+#else
+
+static void launchProcessByAppcode(int appcode)
+{
+ MSG_BEGIN();
+ GError *error = NULL;
+ GDBusConnection *connection_agent = NULL;
+ GDBusProxy *dbus_proxy_agent = NULL;
+ GDBusConnection *connection_service = NULL;
+ GDBusProxy *dbus_proxy_service = NULL;
+ GVariant *result_agent = NULL;
+ GVariant *result_service = NULL;
+
+ switch (appcode) {
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION: {
+ connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
+ "org.tizen.omadmagent", NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ dbus_proxy_service = g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
+ "org.tizen.omadmservice", "/org/tizen/omadmservice",
+ "org.tizen.omadmservice", NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ MsgMutex mx;
+ MsgCndVar cv;
+ mx.lock();
+ cv.timedwait(mx.pMsgMutex(), 2);
+ mx.unlock();
+ MSG_END();
+ }
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML: {
+ connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+
+ dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
+ "org.tizen.omadsagent", "/org/tizen/omadsagent",
+ "org.tizen.omadsagent", NULL, &error);
+ if (error) {
+ MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error) {
+ MSG_DEBUG("invoking service error: %s\n", error->message);
+ goto _DBUS_ERROR;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+_DBUS_ERROR:
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+
+ if (connection_agent) {
+ g_object_unref(connection_agent);
+ connection_agent = NULL;
+ }
+
+ if (dbus_proxy_agent) {
+ g_object_unref(dbus_proxy_agent);
+ dbus_proxy_agent = NULL;
+ }
+
+ if (result_agent) {
+ g_object_unref(result_service);
+ result_service = NULL;
+ }
+
+ if (connection_service) {
+ g_object_unref(connection_service);
+ connection_service = NULL;
+ }
+
+ if (dbus_proxy_service) {
+ g_object_unref(dbus_proxy_service);
+ dbus_proxy_service = NULL;
+ }
+
+ if (result_service) {
+ g_object_unref(result_service);
+ result_service = NULL;
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2WapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex)
+{
+ MSG_BEGIN();
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ msg_error_t err = MSG_SUCCESS;
+ int pushEvt_cnt = 0;
+ char app_id[MAX_WAPPUSH_ID_LEN] = {0, };
+ char content_type[MAX_WAPPUSH_CONTENT_TYPE_LEN] = {0, };
+ SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
+
+ err = storageHandler->getRegisteredPushEvent(pPushHeader, &pushEvt_cnt, app_id, sizeof(app_id), content_type, sizeof(content_type));
+ MSG_DEBUG("pushEvt_cnt: %d", pushEvt_cnt);
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("Fail to get registered push event");
+ return;
+ }
+
+ for (int i = 0; i < pushEvt_cnt; ++i) {
+ /* check Push message receive setting */
+ bool bPushRecv = false;
+ int appcode = 0;
+ if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
+ MSG_INFO("MsgSettingGetBool() is failed");
+
+ storageHandler->getnthPushEvent(i, &appcode);
+ MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
+ if ((bPushRecv == false) && (appcode != SMS_WAP_APPLICATION_MMS_UA)) {
+ MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
+ return;
+ }
+
+#ifdef FEATURE_MMS_DISABLE
+ if (appcode == SMS_WAP_APPLICATION_MMS_UA) {
+ MSG_DEBUG("Drop MMS Notification for DOCOMO");
+ return;
+ }
+
+#endif
+ launchProcessByAppcode(appcode);
+
+ switch (appcode) {
+ case SMS_WAP_APPLICATION_MMS_UA:
+ MSG_DEBUG("Received MMS Notification");
+ handleMMSNotification(pPushBody, PushBodyLen, simIndex);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SI:
+ MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
+ /* handleSIMessage(pPushBody, PushBodyLen, true); */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SIC:
+ MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
+ /* handleSIMessage(pPushBody, PushBodyLen, false); */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SL:
+ MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
+ /* handleSLMessage(pPushBody, PushBodyLen, true); */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SLC:
+ MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
+ /* handleSLMessage(pPushBody, PushBodyLen, false); */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_CO:
+ MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
+ /* handleCOMessage(pPushBody, PushBodyLen, true); */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_COC:
+ MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
+ /* handleCOMessage(pPushBody, PushBodyLen, false); */
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
+ MSG_DEBUG("Received DM BOOTSTRAP");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
+ MSG_DEBUG("Received Provisioning");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
+ MSG_DEBUG("Received Provisioning");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
+ case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
+ MSG_DEBUG("Received Provisioning");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
+ MSG_DEBUG("Received DM Notification");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
+ MSG_DEBUG("Received DS Notification");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
+ MSG_DEBUG("Received DS Notification");
+ Sms3gpp2EventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
+ break;
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
+ case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
+ MSG_DEBUG("Received DRM UA");
+ if (pPushBody != NULL)
+ handleDrmVer1(pPushBody, PushBodyLen);
+ break;
+ case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
+ case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
+ MSG_DEBUG("Received DRM V2");
+ /* TODO: DRM V2 */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_EMAIL:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
+ case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
+ MSG_DEBUG("Received Email");
+ /* TODO: Email */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
+ MSG_DEBUG("Received IMPS CIR");
+ /* TODO: IMPS CIR */
+ break;
+ case SMS_WAP_APPLICATION_LBS:
+ MSG_DEBUG("Received LBS related message");
+ Sms3gpp2EventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
+ /* TODO: LBS */
+ break;
+ case SMS_WAP_APPLICATION_PUSH_SIA:
+ MSG_DEBUG("Received SIA");
+ /* TODO: SIA */
+ break;
+ default:
+ Sms3gpp2EventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id, content_type);
+ break;
+ }
+ }
+ storageHandler->releasePushEvent();
+
+ MSG_END();
+}
+#endif
+
+void Sms3gpp2WapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex)
+{
+ MSG_BEGIN();
+
+#ifdef MSG_FW_FOR_DEBUG
+ printf("\n\n[handleMMSNotification] Push Body.\n");
+
+ for (int i = 0; i < PushBodyLen; i++) {
+ printf(" [%02x]", pPushBody[i]);
+ }
+ printf("\n\n");
+#endif
+
+ /* Make MSG_MESSAGE_INFO_S */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_MMS_TYPE;
+ msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
+ msgInfo.msgType.classType = MSG_CLASS_NONE;
+ msgInfo.storageId = MSG_STORAGE_PHONE;
+ msgInfo.dataSize = PushBodyLen;
+
+ if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
+ msgInfo.bTextSms = false;
+
+ /* Save Message Data into File */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false) {
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+ }
+
+ if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false) {
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+ }
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+ } else {
+ msgInfo.bTextSms = true;
+
+ memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
+ msgInfo.msgText[msgInfo.dataSize] = '\0';
+ }
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add MMS Noti Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+
+ if (err == MSG_SUCCESS) {
+ /* Callback */
+ err = Sms3gpp2EventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ MSG_END();
+}
+
+
+void Sms3gpp2WapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText)
+{
+ MSG_BEGIN();
+
+ MSG_PUSH_MESSAGE_S pushMsg = {};
+
+ xmlDocPtr xmlDoc = NULL;
+ xmlNodePtr topNode = NULL;
+ xmlNodePtr indNode = NULL;
+
+ xmlChar* tmpXmlChar = NULL;
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+ if (xmlDoc == NULL) {
+ MSG_DEBUG("xmlDoc is NULL");
+ return;
+ }
+
+ topNode = xmlDocGetRootElement(xmlDoc);
+
+ if (topNode == NULL) {
+ MSG_DEBUG("topNode is NULL");
+ xmlFreeDoc(xmlDoc);
+ return;
+ }
+
+ indNode = topNode->xmlChildrenNode;
+
+ while (indNode != NULL) {
+ if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+ break;
+ }
+
+ indNode = indNode->next;
+ }
+
+ if (indNode == NULL) {
+ MSG_DEBUG("indNode is NULL.");
+ return;
+ }
+
+ /* temporary set to max. */
+ pushMsg.expires = 0xFFFFFFFF;
+
+ /* setting received time */
+ time_t t = time(NULL);
+ time_t utfTime = time(&t);
+
+ pushMsg.received = (unsigned long)utfTime;
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
+
+ if (tmpXmlChar == NULL) {
+ MSG_DEBUG("href is NULL.");
+ return;
+ }
+
+ if (tmpXmlChar != NULL)
+ strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
+
+ if (tmpXmlChar != NULL)
+ strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
+
+ if (tmpXmlChar != NULL)
+ pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
+
+ if (pushMsg.created == 0)
+ pushMsg.created = pushMsg.received;
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
+
+ if (tmpXmlChar != NULL)
+ pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
+
+ pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
+
+ tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
+
+ if (tmpXmlChar == NULL) {
+ MSG_DEBUG("contents is NULL.");
+ return;
+ }
+
+ strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
+
+ /* Write push Msg to file */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false) {
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+ }
+
+ if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+ }
+
+ /* Pack Message Info Structure */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_WAP_SI_SMS;
+
+ msgInfo.dataSize = sizeof(pushMsg);
+
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add WAP Push Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+
+ if (err == MSG_SUCCESS) {
+ /* Callback */
+ err = Sms3gpp2EventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+ }
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ MSG_END();
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText)
+{
+ MSG_BEGIN();
+
+ MSG_PUSH_MESSAGE_S pushMsg = {};
+
+ xmlDocPtr xmlDoc = NULL;
+ xmlNodePtr topNode = NULL;
+ xmlNodePtr indNode = NULL;
+
+ xmlChar* tmpXmlChar = NULL;
+
+ msg_error_t err = MSG_SUCCESS;
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL \n");
+ return;
+ }
+
+ getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+ if (xmlDoc == NULL) {
+ MSG_DEBUG("xmlDoc is NULL \n");
+ return;
+ }
+
+ topNode = xmlDocGetRootElement(xmlDoc);
+
+ if (topNode == NULL) {
+ MSG_DEBUG("Empty Document.");
+ xmlFreeDoc(xmlDoc);
+ return;
+ } else {
+ MSG_SEC_DEBUG("Not an empty Document and topNode->name = %s \n", topNode->name);
+ }
+
+ indNode = topNode;
+
+ while (indNode != NULL) {
+ if (!xmlStrcmp(indNode->name, (const xmlChar*) "sl")) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+ break;
+ }
+
+ indNode = indNode->next;
+ }
+
+ /* setting received time setting */
+ time_t t = time(NULL);
+ time_t utfTime = time(&t);
+
+ pushMsg.received = (unsigned long)utfTime;
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
+
+ if (tmpXmlChar == NULL) {
+ MSG_DEBUG("href is NULL.");
+ return;
+ }
+
+ strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
+
+ tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
+ pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
+
+ /* Setting other parameters in default values */
+ pushMsg.created = pushMsg.received;
+ /* temporary set to MAX value. */
+ pushMsg.expires = 0xFFFFFFFF;
+
+ MSG_DEBUG("check pushMsg data");
+ MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
+ MSG_DEBUG("pushMsg.received : [%lu]", pushMsg.received);
+ MSG_DEBUG("pushMsg.created : [%lu]", pushMsg.created);
+ MSG_DEBUG("pushMsg.expires : [%lu]", pushMsg.expires);
+ MSG_SEC_DEBUG("pushMsg.id : [%s]", pushMsg.id);
+ MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
+ MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
+
+ /* Write push Msg to file */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false)
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+
+ if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+
+ /* Pack Message Info Structure */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_WAP_SL_SMS;
+
+ /* Update Msg Text */
+ strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
+
+ msgInfo.dataSize = sizeof(pushMsg);
+
+ MSG_DEBUG("dataSize : %d", msgInfo.dataSize);
+
+ /* Add WAP Push Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+
+ if (err == MSG_SUCCESS) {
+ /* Callback to MSG FW */
+ err = Sms3gpp2EventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+ if (err != MSG_SUCCESS)
+ MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ xmlFree(xmlDoc);
+ xmlFree(tmpXmlChar);
+
+ MSG_END();
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText)
+{
+ MSG_PUSH_CACHEOP_S cacheOp;
+
+ xmlDocPtr xmlDoc = NULL;
+ xmlNodePtr topNode = NULL;
+ xmlNodePtr indNode = NULL;
+
+ memset(&cacheOp, 0x00, sizeof(cacheOp));
+
+ MSG_DEBUG("Enter handleCOMessage");
+
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL \n");
+ return;
+ }
+
+ getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
+
+ if (xmlDoc == NULL) {
+ MSG_DEBUG("xmlDoc is NULL \n");
+ return;
+ }
+
+ topNode = xmlDocGetRootElement(xmlDoc);
+ if (topNode == NULL) {
+ MSG_DEBUG("Warning:Empty Document\n");
+ xmlFreeDoc(xmlDoc);
+ return;
+ }
+
+ indNode = topNode->xmlChildrenNode;
+
+ while (indNode != NULL) {
+ xmlChar* tmpUrl = NULL;
+ if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_OBJ)) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+
+ tmpUrl = xmlGetProp(indNode, (xmlChar*) SMS_PUSH_XML_CO_URI);
+
+ if (tmpUrl != NULL) {
+ strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
+
+ MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
+ } else {
+ MSG_DEBUG("NO href value from the xmlDoc\n");
+ }
+ } else if (!xmlStrcmp(indNode->name, (const xmlChar*) SMS_PUSH_XML_INVAL_SVC)) {
+ MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
+ tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
+
+ if (tmpUrl != NULL) {
+ strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
+ MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
+ } else {
+ MSG_DEBUG("NO href value from the xmlDoc\n");
+ }
+ }
+
+ if (tmpUrl != NULL)
+ xmlFree(tmpUrl);
+
+ indNode = indNode->next;
+ }
+
+ /* Write push Msg to file */
+ char fileName[MSG_FILENAME_LEN_MAX+1];
+ memset(fileName, 0x00, sizeof(fileName));
+
+ if (MsgCreateFileName(fileName) == false) {
+ xmlFree(xmlDoc);
+ THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
+ }
+
+ if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
+ xmlFree(xmlDoc);
+ THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
+ }
+
+ /* Pack Message Info Structure */
+ MSG_MESSAGE_INFO_S msgInfo;
+ memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
+
+ msgInfo.addressList = NULL;
+ unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
+
+ createMsgInfo(&msgInfo);
+
+ strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
+
+ /* Convert Type values */
+ msgInfo.msgType.mainType = MSG_SMS_TYPE;
+ msgInfo.msgType.subType = MSG_WAP_CO_SMS;
+
+ msgInfo.dataSize = sizeof(cacheOp);
+
+ msg_error_t err = MSG_SUCCESS;
+
+ /* Add WAP Push Msg into DB */
+ err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
+
+ if (err == MSG_SUCCESS) {
+ /* Callback */
+ err = Sms3gpp2EventHandler::instance()->callbackMsgIncoming(&msgInfo);
+
+ if (err != MSG_SUCCESS) {
+ MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
+ }
+ } else {
+ MSG_DEBUG("checkMessage() Error !! [%d]", err);
+ }
+
+ xmlFree(xmlDoc);
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
+{
+#if MSG_DRM_SUPPORT
+ int drmRt = DRM_RETURN_SUCCESS;
+ char* cid = NULL;
+ unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter);
+
+ MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
+ drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
+ drm_register_lic_info_s lic_req_info;
+ drm_register_lic_resp_s lic_resp_info;
+
+ bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
+ bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
+ bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
+
+ memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
+
+ lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
+ lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
+ lic_req_info.operation_callback.callback = NULL;
+
+ drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
+ if (drmRt == DRM_RETURN_SUCCESS) {
+ MSG_DEBUG("DRM successfully registed to drm-service.");
+ } else {
+ MSG_DEBUG("Fail to regist DRM to drm-service.");
+ }
+#endif
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
+{
+ /* Convert class Type values */
+ pMsgInfo->msgType.classType = MSG_CLASS_NONE;
+
+ /* set folder id (temporary) */
+ pMsgInfo->folderId = MSG_INBOX_ID;
+
+ pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
+ pMsgInfo->bRead = false;
+ pMsgInfo->bProtected = false;
+ pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
+ pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
+
+ time_t rawtime = time(NULL);
+ /* Comment below lines to save local UTC time..... (it could be used later.) */
+ /*
+ if (tmpTimeStamp.format == SMS_3GPP2_TIME_ABSOLUTE) {
+
+ MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
+ MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
+ MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
+ MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
+ MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
+ MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
+ MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
+
+ char displayTime[32];
+ struct tm * timeTM;
+
+ struct tm timeinfo;
+ memset(&timeinfo, 0x00, sizeof(tm));
+
+ timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
+ timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
+ timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
+ timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
+ timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
+ timeinfo.tm_sec = tmpTimeStamp.time.absolute.second;
+ timeinfo.tm_isdst = 0;
+
+ rawtime = mktime(&timeinfo);
+
+ MSG_DEBUG("tzname[0] [%s]", tzname[0]);
+ MSG_DEBUG("tzname[1] [%s]", tzname[1]);
+ MSG_DEBUG("timezone [%d]", timezone);
+ MSG_DEBUG("daylight [%d]", daylight);
+
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= (tmpTimeStamp.time.absolute.timeZone * (3600/4));
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+
+ rawtime -= timezone;
+
+ timeTM = localtime(&rawtime);
+ memset(displayTime, 0x00, sizeof(displayTime));
+ strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
+ MSG_DEBUG("displayTime [%s]", displayTime);
+ }
+ */
+
+ pMsgInfo->displayTime = rawtime;
+
+ /* Convert Address values */
+ pMsgInfo->nAddressCnt = 1;
+
+ pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
+ memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
+
+ pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+ strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.szData, MAX_ADDRESS_VAL_LEN);
+
+ pMsgInfo->msgPort.valid = false;
+ pMsgInfo->msgPort.dstPort = 0;
+ pMsgInfo->msgPort.srcPort = 0;
+}
+
+void Sms3gpp2WapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
+{
+ if (pPushBody == NULL) {
+ MSG_DEBUG("pPushBody is NULL");
+ return;
+ }
+
+ if (isText) {
+ *pXmlDoc = xmlParseMemory(pPushBody, AcStrlen(pPushBody));
+ } else {
+ WB_UTINY* xmldata = NULL;
+ WBXMLConvWBXML2XML *conv = NULL;
+ WBXMLError ret = WBXML_OK;
+
+ ret = wbxml_conv_wbxml2xml_create(&conv);
+ if (ret != WBXML_OK)
+ return;
+
+ ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
+
+ wbxml_conv_wbxml2xml_destroy(conv);
+
+ if (ret != WBXML_OK ||xmldata == NULL) {
+ MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
+ return;
+ }
+
+ MSG_DEBUG("xmldata : \n%s\n", xmldata);
+
+ *pXmlDoc = xmlParseMemory((char*)xmldata, AcStrlen((char*)xmldata));
+ }
+}
+
+unsigned long Sms3gpp2WapPushHandler::convertXmlCharToSec(char* pDate)
+{
+ struct tm timeStruct;
+ time_t nTimeInSec = 0;
+ char tmpBuf[10];
+ int i = 0, index = 0;
+
+ memset(tmpBuf, 0x00, sizeof(tmpBuf));
+ memset(&timeStruct, 0x00, sizeof(struct tm));
+
+ /* check pDate */
+ if (AcStrlen(pDate) < 20)
+ return 0;
+
+ MSG_DEBUG("pDate [%s]", pDate);
+
+ /* Year */
+ for (i = 0; i < 4; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_year = (atoi(tmpBuf)-1900);
+
+ /* Month */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_mon = (atoi(tmpBuf) - 1);
+
+ /* Date */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_mday = atoi(tmpBuf);
+
+ /* Hours */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_hour = atoi(tmpBuf);
+
+ /* Minites */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_min = atoi(tmpBuf);
+
+ /* Seconds */
+ for (i = 0; i < 2; i++) {
+ tmpBuf[i] = pDate[index++];
+ }
+ tmpBuf[i] = '\0';
+ index++;
+ timeStruct.tm_sec = atoi(tmpBuf);
+
+ nTimeInSec = mktime(&timeStruct);
+
+ return nTimeInSec;
+}
+
+
+msg_push_action_t Sms3gpp2WapPushHandler::convertSIActionStrToEnum(char* pAction)
+{
+ int comp = 0;
+
+ if (pAction == NULL) {
+ MSG_DEBUG("pAction is NULL. Setting to default action type.");
+ return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+ }
+
+ /* compare with signal-none. */
+ comp = g_strcmp0("signal-none", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
+
+ /* compare with signal-low. */
+ comp = g_strcmp0("signal-low", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
+
+ /* compare with signal-medium. */
+ comp = g_strcmp0("signal-medium", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+
+ /* compare with signal-high. */
+ comp = g_strcmp0("signal-high", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
+
+ /* compare with delete. */
+ comp = g_strcmp0("delete", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SI_ACTION_DELETE;
+
+ /* signal-medium is default action value. */
+ return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
+}
+
+
+msg_push_action_t Sms3gpp2WapPushHandler::convertSLActionStrToEnum(char* pAction)
+{
+ int comp = 0;
+
+ if (pAction == NULL) {
+ MSG_DEBUG("MSG_DEBUG is NULL. Setting to default action type.\n");
+ return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+ }
+
+ /* compare pSrcStr with execute-low. */
+ comp = g_strcmp0("execute-low", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+
+ /* compare pSrcStr with execute-high. */
+ comp = g_strcmp0("execute-high", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
+
+ /* compare pSrcStr with cache. */
+ comp = g_strcmp0("cache", pAction);
+ if (comp == 0)
+ return MSG_PUSH_SL_ACTION_CACHE;
+
+ /* default SL action value is execute-low. */
+ return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
+}
+
+
+unsigned long Sms3gpp2WapPushHandler::wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer)
+{
+ unsigned long i = 0;
+ unsigned long decodedValue;
+
+ while (sourceData[*currentPointer +i] >= 0x80) i++;
+
+ decodedValue = wspDecodeUintvar(i+1, sourceData + *currentPointer);
+ *currentPointer = *currentPointer + i + 1;
+ MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%lu .\n", decodedValue);
+ return decodedValue;
+}
+
+
+unsigned long Sms3gpp2WapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar)
+{
+ unsigned long i;
+ unsigned long decodedUintvar = 0;
+
+
+ for (i = 0 ; i < length; i++) {
+ decodedUintvar = decodedUintvar + (wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f));
+ }
+
+ return decodedUintvar;
+}
+
+
+void Sms3gpp2WapPushHandler::wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
+{
+ unsigned long iField;
+ bool continueField = FALSE;
+ unsigned long currentLength;
+
+ char* encodedHeader = NULL;
+ unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter);
+
+ char* outTemper = NULL;
+
+ char* temper = NULL;
+ unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter);
+
+ unsigned char track;
+ unsigned long iEncodedHeader = 0;
+ unsigned char fieldCode = 0xff;
+
+ /* outTemper is Decoded Headers.
+ temper is Single Decoded Header.
+ */
+ if (NULL == (outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
+ MSG_DEBUG("outTemper Memory allocation is failed.\n");
+ return;
+ }
+ memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
+ currentLength = WSP_STANDARD_STR_LEN_MAX;
+
+ MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n");
+
+ int loop;
+ char szBuf[64];
+
+ szBuf[0] = 0x00;
+ MSG_DEBUG("wspDecodeHeader: RAW data \n");
+ for (loop = 0 ; loop < (int)encodedHeaderLen; loop++) {
+ char szTempBuf[5];
+ szTempBuf[0] = 0x00;
+ snprintf(szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop]);
+
+ if (AcStrlen(szBuf) + 7 < 64) {
+ strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
+ } else {
+ strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
+ MSG_DEBUG("[%s]", szBuf);
+ szBuf[0] = 0x00;
+ strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
+ }
+ }
+ strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
+ MSG_DEBUG("[%s]", szBuf);
+ MSG_DEBUG("fContentType=%d \n", fContentType);
+ /* operation for content-type */
+ /* makes psuedo- content-type fieldcode */
+ /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
+
+ if (fContentType) {
+ encodedHeader = new char[ encodedHeaderLen + 1 ];
+ if (encodedHeader == NULL) {
+ MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
+ return;
+ }
+ encodedHeader[0] = 0x91;
+ memcpy(encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen);
+ } else {
+ encodedHeader = new char[ encodedHeaderLen ];
+ if (encodedHeader == NULL) {
+ MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
+ return;
+ }
+
+ memcpy(encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen);
+ }
+
+ /* Is it reacehd end of header? */
+ while (iEncodedHeader < encodedHeaderLen) {
+ /* Get memory for single header */
+ if (temper == NULL) {
+ temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
+
+ if (temper == NULL) {
+ MSG_DEBUG("temper Memory allocation is failed.\n");
+ return;
+ }
+ memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
+ } else {
+ memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
+ }
+
+
+ /* this section presents header code page shifting procedure
+ This part can be implemented by future request.
+ if (track == 0x 7f)
+ */
+ track = encodedHeader[iEncodedHeader];
+
+ if (track == 0x00) {
+ MSG_DEBUG("WspLDecodeHeader: fieldcode is 0 \n");
+ strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+ fieldCode = 0xff;
+ iEncodedHeader++;
+ } else if ((track > 0) && (track < 0x20)) {
+ iEncodedHeader++;
+ } else if ((track < 0x7f) && (track > 0x1f)) { /* In this case, first byte is normal string. So it's considered to unknown header. */
+ unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
+ unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
+
+ strncpy((char*)fieldName, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
+ fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
+ iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldName) + 1;
+ strncpy((char*)fieldValue, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
+ fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
+ iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldValue) + 1;
+
+ strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ /* this means 'don't process anymore.' */
+ fieldCode = 0xff;
+
+ } else if (track > 0x7f) {
+ /* In case of first byte is field code, else case is error. */
+ /*if ((track & 0x7f) <= wspHeaderFieldCount) { */
+ unsigned long fieldValueLen = encodedHeader[iEncodedHeader + 1];
+ unsigned char fieldValue[1275];
+ fieldCode = track & 0x7f;
+ /*
+ if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
+ dprint(DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5]);
+ }
+ */
+ memset(fieldValue, 0, 1275);
+
+ /* add field name */
+ /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
+ if (!continueField) {
+ strncat((char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ continueField = FALSE;
+ }
+
+ /* field value is string */
+ /* In this case, it just copy field value. */
+ if ((fieldValueLen > LENGTH_QUOTE) && (fieldValueLen < 0x80)) {
+ /* string field value should be NULL terminated */
+ strncat((char*)temper, (char*)(encodedHeader + iEncodedHeader + 1), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ iEncodedHeader = iEncodedHeader + AcStrlen((char*)encodedHeader + iEncodedHeader + 1) + 2;
+ fieldCode = 0xff;
+ }
+ /* first field value is length */
+ /* If first byte of field value is length value, allocate field value by the length.
+ In field value, data is
+ 1D 03 8F 24 24 - Then 8F 24 24 is field value.
+ 1D 1F 33.... - Then allocate 33H for FieldValue.
+ 1D 8F - Then 8F
+ 1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
+ 1D 8F 24 24 - In this case, original data is wrong.
+ If accept-charset: ISO-10646-ucs-2;Q=0.7 is
+ 01 03 03 E8 47
+ 01 - field code
+ 03 - field value length
+ 03 E8 47 - field value
+ it's decoded by above value.
+ */
+ if (fieldValueLen < 0x20) {
+ if (fieldValueLen == LENGTH_QUOTE) {
+ /* field length is encoded in UINTVAR */
+ unsigned long uintvarLen = 0;
+ fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen);
+ memcpy(fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen);
+ iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
+
+ } else {
+ if (fieldValueLen == 1) {
+ /* field value is one byte integer over 0x80 */
+ /* make it two byte integer */
+ fieldValue[0] = 0x00;
+ memcpy(fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+ fieldValueLen = 2;
+ iEncodedHeader = iEncodedHeader + 1 + 2;
+ } else {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
+ fieldValue[fieldValueLen] = 0;
+ iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
+ if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
+ MSG_DEBUG("%X \n", encodedHeader[iEncodedHeader]);
+ }
+ }
+ }
+ }
+
+ /* field value is single encoded */
+ if (fieldValueLen > 0x7f) {
+ fieldValue[0] = encodedHeader[iEncodedHeader + 1];
+ fieldValueLen = 1;
+ iEncodedHeader = iEncodedHeader + 2;
+ }
+ /* processing normal pre-defined field decoding */
+
+ MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode);
+ MSG_DEBUG("WspLDecodeHeader: fieldSize %lu\n", fieldValueLen);
+
+ if ((fieldCode > wspHeaderFieldCount) && (fieldCode != 0xff)) {
+ MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track);
+ strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
+ fieldCode = 0xff;
+ }
+
+
+ switch (fieldCode) {
+ /* accept charset */
+ /* It's normal way of field process. */
+ case 0x01: {
+ unsigned long i = 0;
+ unsigned long code;
+
+ /* Case of length of charset greater than 1 are two thigins.
+ 1. code length of charset is greater than 1.
+ 2. It include parameter.
+ 3. Or both of two
+ */
+ if (1 != fieldValueLen) {
+ code = wspHeaderDecodeInteger(fieldValue);
+ /* Calculate iField. */
+ if (fieldValue[0] < 0x80)
+ iField = fieldValue[0];
+ else
+ iField = 1;
+
+ while (wspCharset[i].charsetCode != code)
+ i++;
+ strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ /* If parameter exist */
+ if (iField < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeQValue(fieldValueLen - iField, fieldValue + iField, ¶m);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ } else {
+ code = fieldValue[0] & 0x7f;
+
+ while ((wspCharset[i].charsetCode != code) && (wspCharset[i].charsetCode != 0xffff)) i++;
+ strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ break;
+
+ /* type encoding */
+ /* Like below routine, Same decoding routine process together. */
+ /* Accept-encoding */
+ case 0x02:
+ /* content-encoding */
+ case 0x0b: {
+ int integerValue;
+
+ integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+ if (integerValue > 2) {
+ MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
+ break;
+ }
+ strncat((char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* contents type decoder */
+ /* accept */
+ case 0x00:
+ /* content-type */
+ case 0x11: {
+ unsigned long contentsTypeCode;
+ unsigned long i = 0;
+ /* encoded content type length body */
+ unsigned long tempLen;
+ MSG_DEBUG("fieldValueLen: %lu", fieldValueLen);
+
+ /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
+ if (0 == fieldValueLen) {
+ strncat((char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ break;
+ }
+ /* 01 AE --> 00 AE --> AE*/
+ if (fieldValueLen == 2 && fieldValue[0] == 0) {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
+ MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
+ }
+
+ if ((fieldValue[0] < 0x20) || (fieldValue[0] >= 0x80)) {
+ if (fieldValue[0] >= 0x80) {
+ tempLen = 1;
+ } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /* 06 05 02 03 0A AF 89 */
+ fieldValue[3] = fieldValue[2];
+ fieldValue[2] = fieldValue[1];
+ fieldValue[1] = fieldValue[0];
+ fieldValue[0] = 0x02;
+ tempLen = 2;
+ fieldValueLen = 3;
+ MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n");
+ } else {
+ tempLen = fieldValue[0]; /* 06 06 03 02 03 16 AF 88 */
+ }
+
+ if (tempLen == 1) {
+ char* szExtendedContent;
+
+ contentsTypeCode = fieldValue[0] & 0x7f;
+ while ((wspContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspContentsTypeCount)) i++;
+
+ /* If specified content type doesn't exist */
+ if (i < wspContentsTypeCount)
+ strncat((char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ szExtendedContent = wspExtendedDecodeType((char)contentsTypeCode);
+
+ if (szExtendedContent != NULL) {
+ MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n ");
+ strncat((char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ } else {
+ contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
+
+ while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode))
+ i++;
+
+ /* If there is a Content-Type assigned, */
+ if (i < wspUnregisteredContentsTypeCount) {
+ strncat((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ }
+ tempLen +=1;
+ }
+ } else {
+ tempLen = AcStrlen((char*)fieldValue) + 1;
+
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type: %lu \n ", tempLen);
+ }
+
+ /* If there is a parameter */
+ if (tempLen < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + tempLen, fieldValueLen - tempLen, ¶m);
+ if (param != NULL) {
+ strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ }
+ break;
+
+ /* language */
+ /* content-language */
+ case 0x0c:
+ /* accept-language */
+ case 0x03: {
+ unsigned long i = 0;
+ unsigned long code;
+ unsigned long tempLen;
+ if ((fieldValue[0] < 0x20) || (fieldValue[0] > 0x80)) {
+ if (fieldValue[0] > 0x80)
+ tempLen = 1;
+ else
+ tempLen = fieldValue[0];
+ } else {
+ tempLen = AcStrlen((char*)fieldValue) + 1;
+ }
+
+ if (tempLen == 1) {
+ code = wspHeaderDecodeInteger(fieldValue);
+ while (wspLanguage[i].languageCode != code) {
+ i++;
+ if (i == wspLanguageCount)
+ break;
+ }
+
+ if (i < wspLanguageCount) {
+ strncat((char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ } else {
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+
+ if (tempLen < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeQValue(fieldValueLen - tempLen, fieldValue + tempLen, ¶m);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ break;
+
+ /* integer */
+ /* Max-forwards */
+ case 0x1e:
+ /* content-length */
+ case 0x0d:
+ /* age */
+ case 0x05:
+ /* Bearer-indication */
+ case 0x33:
+ /* Push-Flag */
+ case 0x34: {
+ unsigned char temp[16];
+ /*
+ if ((fieldValueLen == 2) && (fieldValue[0] > 0x7f))
+ AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[1]);
+ else
+ */
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* X-Wap-Application-Id */
+ case 0x2f: {
+ unsigned char temp[64];
+ int integerValue;
+
+ if (fieldValueLen == 2 && fieldValue[0] == 0) {
+ memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
+ MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
+ fieldValueLen = 1;
+ }
+
+ integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+
+ int count = sizeof(wspHeaderApplId)/sizeof(SMS_3GPP2_WSP_HEADER_PARAMETER_S);
+ for (int i = 0; i < count ; ++i) {
+ if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode) {
+ snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ break;
+ }
+ }
+ }
+ break;
+ /* Accept-Application */
+ case 0x32:
+ if (0x80 == fieldValue[0]) {
+ strncat((char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ } else {
+ unsigned char temp[16];
+ /*
+ if ((fieldValueLen == 2) && (fieldValue[0] == 1))
+ AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[0]);
+ else
+ */
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ }
+ break;
+
+
+ /* date */
+ /* last-modified */
+ case 0x1d:
+ /* if-unmodified-since */
+ case 0x1b:
+ /* if-range */
+ case 0x1a:
+ /* if-modified-since */
+ case 0x17:
+ /* expires */
+ case 0x14:
+ /* date */
+ case 0x12: {
+ char* decodedString = NULL;
+ unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+ wspHeaderDecodeDateValue(fieldValueLen, fieldValue, &decodedString);
+ strncat((char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ }
+ break;
+
+ /* connection */
+ case 0x09:
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ break;
+ /* accept-ranges */
+ case 0x04:
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ if (fieldValue[0] == 0x81)
+ strncat((char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
+ break;
+ /* content-md5 */
+ case 0x0f: {
+ unsigned char temp[1275];
+ memcpy(temp, fieldValue, (size_t)fieldValueLen);
+ temp[fieldValueLen] = 0;
+ wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
+ }
+ break;
+ /* Credential */
+ /* authorization */
+ case 0x07:
+ /* proxy - authorization */
+ case 0x21:
+ if (fieldValue[0] == 0x80) {
+ char* addString = NULL;
+ unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+ wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString);
+ strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ } else {
+ iField = AcStrlen((char*)fieldValue) + 1;
+
+ strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ if (iField < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
+ if (param != NULL) {
+ strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ }
+ break;
+
+ /* Challenge */
+ /* www - auth */
+ case 0x2d:
+ /* Proxy-authenticate */
+ case 0x20:
+ if (0 == fieldValueLen)
+ break;
+ if (fieldValue[0] == 0x80) {
+ char* addString = NULL;
+ unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
+ wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString);
+ strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ } else {
+ unsigned char authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
+ unsigned char realmValue[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char addedString[WSP_STANDARD_STR_LEN_MAX];
+
+ strncpy((char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
+ iField = AcStrlen((char*)authScheme) + 1;
+ strncpy((char*)realmValue, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+ iField = iField + AcStrlen((char*)realmValue) + 1;
+ int wrn = snprintf((char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue);
+ if(wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+ wspHeaderCopyDecodedString(addedString, ¤tLength, &temper);
+
+ if (iField < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + iField, fieldValueLen - iField, ¶m);
+ if (param != NULL) {
+ strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ wspHeaderCopyDecodedString((unsigned char*)param, ¤tLength, &temper);
+ }
+ }
+ }
+ break;
+
+ /* content -range */
+ case 0x10: {
+ unsigned long first, len, last;
+
+ unsigned char temp[16];
+ iField = 0;
+
+ strncat((char*)temper, " bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ first = wspRetriveUintvarDecode(fieldValue, &iField);
+ len = wspRetriveUintvarDecode(fieldValue, &iField);
+ /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length. */
+ last = first + contentsLength - 1;
+
+ snprintf((char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+
+ /* cache-control */
+ case 0x08: {
+ char* cacheString = NULL;
+ unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
+
+ wspHeaderDecodeCacheControl(fieldValue, fieldValueLen, &cacheString);
+ strncat((char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+
+ /* pragma */
+ case 0x1f:
+ if (fieldValue[0] == 0x80) {
+ strncat((char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ } else {
+ if (1 < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue, fieldValueLen, ¶m);
+
+ if (param != NULL) {
+ strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ }
+ break;
+
+ /* public */
+ case 0x22:
+ /* allow */
+ case 0x06: {
+ unsigned long i = 0;
+ while (wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen) != wspMethodType[i].methodCode) i++;
+ strncat((char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* range */
+ case 0x23:
+ strncat((char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ if (fieldValue[0] == 0x80) {
+ unsigned char temp[16];
+ unsigned long first, last;
+ iField = 0;
+
+ first = wspRetriveUintvarDecode(fieldValue, &iField);
+ last = wspRetriveUintvarDecode(fieldValue, &iField);
+
+ snprintf((char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ if (fieldValue[0] == 0x81) {
+ unsigned char temp[16];
+ unsigned long suffix;
+
+ suffix = wspRetriveUintvarDecode(fieldValue, &iField);
+
+ snprintf((char*)temp, sizeof(temp), "-%u", (unsigned int)suffix);
+ }
+ break;
+ /* retry-after */
+ case 0x25:
+ if (fieldValue[0] == 0x80) {
+ char* temp = NULL;
+ unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
+
+ wspHeaderDecodeDateValue(fieldValueLen - 1, fieldValue + 1, &temp);
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+
+ if (fieldValue[0] == 0x81) {
+ unsigned char temp[16];
+
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* transfer-encoding */
+ case 0x27:
+ /* No other cases allowed */
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ break;
+ /* vary */
+ case 0x2a: {
+ int integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
+ if (integerValue > wspHeaderFieldCount) {
+ MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n", wspHeaderFieldCount);
+ break;
+ }
+ strncat((char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+ /* warning */
+ case 0x2c: {
+ unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+ if (fieldValue[0] < 0x20)
+ iField = fieldValue[0];
+ else
+ iField = 1;
+
+ snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, iField));
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ if (iField < fieldValueLen) {
+ unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char text[WSP_STANDARD_STR_LEN_MAX];
+ strncpy((char*)agent, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+ iField = iField + AcStrlen((char*)agent) + 1;
+ strncpy((char*)text, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
+ int wrn = snprintf((char*)temp, sizeof(temp), " %s %s", agent, text);
+ if (wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+ wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
+ }
+ }
+ break;
+ /* content-disposition */
+ case 0x2e:
+ if (fieldValue[0] == 0x80)
+ strncat((char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ if (fieldValue[0] == 0x81)
+ strncat((char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+
+ if (1 < fieldValueLen) {
+ char* param = NULL;
+ unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
+ wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
+
+ if (param != NULL) {
+ strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ }
+ break;
+ /* Profile-diff */
+ case 0x36:
+ temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
+ memcpy(temper, fieldValue, (size_t)fieldValueLen);
+ break;
+ /* Profile-Warning */
+ case 0x37: {
+ unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
+
+ snprintf((char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue));
+ temp[2] = temp[1];
+ temp[1] = (unsigned char)0x30;
+ temp[3] = '\0';
+ if (fieldValueLen > 1) {
+ /* copy warn-target - URI */
+ strncat((char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
+ if (fieldValueLen > (AcStrlen((char*)(fieldValue + 1)) + 1)) {
+ /* copy warn-date */
+ char* decodedString = NULL;
+ unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
+ wspHeaderDecodeDateValue(fieldValueLen - (AcStrlen((char*)(fieldValue + 1)) + 2), fieldValue + AcStrlen((char*)(fieldValue + 1)) + 1, &decodedString);
+ strncat((char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
+ }
+ }
+ strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+ break;
+
+ default:
+ break;
+ }
+ /*}*/
+ }
+ /* It deosn't finished decoding yet. */
+ if ((iEncodedHeader < encodedHeaderLen) && (fieldCode != 0xff)) {
+ /* In here, iEncodedHeader already point next field code to be decoded. */
+ /* If this code is same, then set continueField else add CRLF. */
+ if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f)) {
+ strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ continueField = TRUE;
+ } else {
+ strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ continueField = FALSE;
+ }
+ } else {
+ strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
+ }
+
+ /* add single header to total headers */
+ strncat((char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1);
+ MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper);
+ }
+
+
+ MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n");
+
+ *pHeader = outTemper;
+
+ return;
+}
+
+
+unsigned long Sms3gpp2WapPushHandler::wspHeaderDecodeInteger(unsigned char* data)
+{
+ /* we only can handle max 32bit integer */
+ unsigned long i;
+
+ union {
+ unsigned long integer;
+ unsigned char seg[4];
+ } returner;
+
+ returner.integer = 0;
+
+ if (data[0] < 0x80) {
+ unsigned long IntLen = 0;
+
+ IntLen = (data[0] > 0x04) ? 0x04:data[0];
+
+ MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %lu\n", data[0], IntLen);
+
+ for (i = 0; i < IntLen; i++)
+ returner.seg[IntLen-(i+1)] = data[i+1];
+
+ return returner.integer;
+ }
+
+ return data[0] & 0x7f;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString)
+{
+ unsigned short qBase = 0;
+ float qValue;
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
+ return;
+ }
+
+ memcpy(&qBase, data, (size_t)length);
+ qValue = (float)qBase;
+ if (qValue > 100) {
+ qValue = qValue - 100;
+ qValue = qValue / 1000;
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue);
+ } else {
+ /* qValue variable is divided by 100. And it's multiplied by 100.
+ It's to resolve problem of changed 0.01 of qValue. */
+ unsigned long qValueTemp;
+ qValue = qValue - 1;
+ qValue = qValue / 100;
+ qValueTemp = (unsigned long)(qValue * 100);
+ if (0 == (qValueTemp % 10))
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue);
+ else
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue);
+ }
+ return;
+}
+
+
+unsigned long Sms3gpp2WapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length)
+{
+ unsigned long i;
+
+ union {
+ unsigned long integer;
+ unsigned short seg[4];
+ } returner;
+
+ returner.integer = 0;
+
+ if (length == 1)
+ return data[0] & 0x7f;
+
+ returner.integer = 0;
+
+ for (i = 0 ; i < length; i++) {
+ returner.integer = returner.integer + (data[i] * (0x1 << ((length - (i + 1)) * 8)));
+ MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %lu \n", returner.integer);
+ }
+
+ return returner.integer;
+}
+
+
+char* Sms3gpp2WapPushHandler::wspExtendedDecodeType(char contentType)
+{
+ int i = 0;
+
+ while (wspExtendedContentsType[i].contentsTypeCode != contentType) {
+ if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
+ return NULL;
+ i++;
+ }
+
+ return (char*)wspExtendedContentsType[i].contentsTypeName;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam)
+{
+ char* param = *pParam;
+
+ unsigned long SecurityTypeCode;
+ unsigned long i = 0;
+
+ if (data[0] < 0x80) {
+ /* unknown parameter type */
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n");
+ return;
+ }
+
+ strncpy((char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
+
+ if (NO_VALUE == data[AcStrlen((char*)param) + 1]) {
+ *pParam = param;
+ return;
+ }
+
+ strncat((char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ strncat((char*)param, (char*)(data + AcStrlen((char*)param)), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+
+ *pParam = param;
+
+ return;
+ }
+
+ switch (data[0] & 0x7f) {
+ case 0x00:
+ wspHeaderDecodeQValue(length - 1, data + 1, ¶m);
+ break;
+ case 0x01:
+ wspHeaderDecodeCharset(length - 1 , data + 1, ¶m);
+ break;
+ case 0x02:
+ wspHeaderDecodeVersion(length - 1, data + 1, ¶m);
+ break;
+ /* integer */
+ case 0x03:
+ /* param = (unsigned char *)malloc((size_t)WSP_STANDARD_STR_LEN_MAX); */
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
+ return;
+ } else {
+ snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger(data + 1));
+ }
+ break;
+ case 0x08:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
+ return;
+ } else {
+ snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger(data + 1));
+ }
+ break;
+ case 0x05:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
+ return;
+ } else {
+ strncpy((char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
+ memcpy(param + 5, data + 1, length - 1);
+ param[5 + length - 1] = '\0';
+ }
+ break;
+ case 0x06:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
+ return;
+ } else {
+ strncpy((char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
+ memcpy(param + 9, (char*)(data + 1), (size_t)(length - 1));
+ param[9 + length - 1] = '\0';
+ }
+ break;
+ case 0x07:
+ param = NULL;
+ /* TBI */
+ break;
+ /*OMA Provisioning*/
+ case 0x11:
+ param = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (param == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
+ return;
+ } else {
+ strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
+ SecurityTypeCode = data[1] & 0x7f;
+ while ((i < wspSecurityTypeCount) && (wspSecurityType[i].SecurityTypeCode != SecurityTypeCode))
+ i++;
+
+ if (i < wspSecurityTypeCount) {
+ strncat((char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ }
+
+ if (0x12 == (data[2] & 0x7f)) {
+ strncat((char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
+ memcpy(param+AcStrlen((char*)param), (char*)(data+3), (size_t)length-3);
+ }
+ }
+ break;
+
+ default:
+ param = NULL;
+ break;
+ }
+
+ *pParam = param;
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString)
+{
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
+ return;
+ }
+
+ strncpy((char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
+
+ if (data[0] > 0x80) {
+ unsigned long code = wspHeaderDecodeInteger(data);
+ unsigned long i = 0;
+ while (wspCharset[i].charsetCode != code) {
+ if (wspCharset[i].charsetCode == 0xffff) {
+ return;
+ }
+ i++;
+ }
+ strncat((char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1);
+ } else {
+ unsigned long lastLen = AcStrlen((char*)*pDecodedString);
+ memcpy((char*)(*pDecodedString + lastLen), data, (size_t)length);
+ *pDecodedString[length + lastLen] = '\0';
+ }
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString)
+{
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
+ return;
+ }
+
+ if (length > 1) {
+ /* untyped version */
+ memcpy(*pDecodedString, data, (size_t)length);
+ } else {
+ /* typed version */
+ unsigned char majorVer = ((data[0] & 0x7f) >> 4);
+ unsigned char minorVer = data[0] & 0x0f;
+ snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer);
+ }
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString)
+{
+ time_t lTime;
+ struct tm* pTMData;
+
+ MSG_DEBUG("WspLHeaderDecodeDateValue: \n");
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeDateValue:MemAlloc failed\n");
+ return;
+ }
+
+ lTime = wspHeaderDecodeIntegerByLength(data, length);
+
+ pTMData = (struct tm*)gmtime((const time_t*)&lTime);
+
+ if (pTMData == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail \n");
+ strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
+ return;
+ }
+
+ /* check date value validity */
+ if ((pTMData->tm_wday > 6) || (pTMData->tm_mon > 11) || (pTMData->tm_mday > 31)) {
+ MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday);
+ strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
+ return;
+ }
+
+#ifdef MSG_FW_FOR_DEBUG
+ /* Date type selection */
+ switch (wspMachineStatus.dateType) {
+ /* UNIX asciitime function */
+ case UNIX_DATE_TYPE:
+ snprintf((char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
+ pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900);
+ break;
+ case RFC1123_DATE_TYPE:
+ snprintf((char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday,
+ wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec);
+ break;
+ case RFC850_DATE_TYPE:
+ /* Have some Y2K Problems */
+ /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */
+ snprintf((char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday,
+ wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec);
+ break;
+ }
+#endif
+ /*UNIX_DATE_TYPE : */
+ snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon],
+ pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900);
+
+ return;
+}
+
+void Sms3gpp2WapPushHandler::wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper)
+{
+ unsigned long elementLen = AcStrlen((char*)szDecodedString);
+ char* temper2 = NULL;
+
+ /* CR+LF */
+ *currentLen = *currentLen + elementLen + 2;
+
+ if (*currentLen > AcStrlen((char*)* pTemper) + 2) {
+ temper2 = new char[(*currentLen + 1)];
+
+ if (temper2 == NULL) {
+ MSG_DEBUG("WspLHeaderCopyDecodedString:MemAlloc failed\n");
+ return;
+ }
+ strncpy((char*)temper2, (char*)* pTemper, *currentLen);
+ delete[] *pTemper;
+ strncpy((char*)temper2, (char*)szDecodedString, *currentLen);
+ }
+
+ *pTemper = temper2;
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
+{
+ unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char passWd[WSP_STANDARD_STR_LEN_MAX];
+ unsigned long iField = 0;
+ char authStr[256];
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n");
+ return;
+ }
+
+ /* skip 'basic' code */
+ iField++;
+ memset(authStr, 0x00, sizeof(authStr));
+ snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId));
+ sscanf((char*)(fieldValue + iField), authStr, userId);
+ iField = iField + AcStrlen((char*)userId) + 1;
+ memset(authStr, 0x00, sizeof(authStr));
+ snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(passWd));
+ sscanf((char*)(fieldValue + iField), authStr, passWd);
+ iField = iField + AcStrlen((char*)userId) + 1;
+ int wrn = snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd);
+ if (wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
+{
+ unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
+ unsigned long iField = 0;
+ char authStr[256];
+
+ *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
+
+ if (*pDecodedString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeChallenge:MemAlloc failed\n");
+ return;
+ }
+
+ /* skip 'basic' code */
+ iField++;
+ memset(authStr, 0x00, sizeof(authStr));
+ snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId));
+ sscanf((char*)(fieldValue + iField), authStr, userId);
+ iField = iField + AcStrlen((char*)userId) + 1;
+
+ int wrn = snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "basic realm=\"%s\"", userId);
+ if (wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+
+ return;
+}
+
+
+void Sms3gpp2WapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
+{
+ unsigned char paramString[WSP_STANDARD_STR_LEN_MAX];
+ unsigned char cacheCode;
+
+ *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
+ if (*pCacheString == NULL) {
+ MSG_DEBUG("WspLHeaderDecodeCacheControl:MemAlloc failed\n");
+ return;
+ }
+
+ if (1 == fieldValueLen) {
+ /* only one directive */
+ if (fieldValue[0] > 0x8b) {
+ return; /* It's error detection. can be omitted. */
+ }
+ strncpy((char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
+ return;
+ }
+
+ if (fieldValue[0] > 0x7f) {
+ /* directive that has parameter */
+ cacheCode = fieldValue[0] & 0x7f;
+ switch (cacheCode) {
+ /* field name */
+ /* no-cache */
+ case 0x00:
+ /* private */
+ case 0x07:
+ if (fieldValue[1] > 0x7f) {
+ /* well known field name */
+ strncpy((char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
+ paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
+ } else {
+ /* unknown field name */
+ strncpy((char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
+ }
+ break;
+ /* secound */
+ /* max-age */
+ case 0x02:
+ /* max- stale */
+ case 0x03:
+ /* min-fresh */
+ case 0x04:
+ snprintf((char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger(fieldValue + 1));
+ break;
+ default:
+ break;
+ }
+ int wrn = snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString);
+ if (wrn < 0)
+ MSG_DEBUG("snprintf was failed");
+ } else {
+ /* cache extentions */
+ /* In case of come directive of doesn't specified string style */
+
+ unsigned long stringLen;
+ char szString[32];
+ strncpy((char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
+ stringLen = AcStrlen((char*)*pCacheString);
+
+ if (stringLen + 1 < fieldValueLen) {
+ if (fieldValue[stringLen+ 1] > 0x7f) {
+ int untyped = (int)wspHeaderDecodeIntegerByLength(fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1));
+
+ snprintf(szString, sizeof(szString), "%d", untyped);
+ strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ strncat((char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ } else {
+ if (fieldValue[fieldValueLen] == 0) {
+ strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ strncat((char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
+ }
+ }
+ }
+ }
+
+ return;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_CODEC_H
+#define SMS_3GPP2_CODEC_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "Sms3gpp2Types.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gpp2MsgCodec
+{
+public:
+
+ static Sms3gpp2MsgCodec* instance();
+
+ static bool checkInvalidPDU(const unsigned char *p_pkg_str, const int p_pkg_len);
+
+ static int encodeMsg(const sms_3gpp2_trans_msg_s *pMsg, unsigned char *p_pkg_str);
+ static int decodeMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_msg_s *p_msg);
+
+private:
+ Sms3gpp2MsgCodec();
+ ~Sms3gpp2MsgCodec();
+
+ static Sms3gpp2MsgCodec* pInstance;
+
+ static int encodeP2PMsg(const sms_3gpp2_trans_p2p_msg_s *p_msg, unsigned char *p_pkg_str);
+ static int encodeAckMsg(const sms_3gpp2_trans_ack_msg_s *p_msg, unsigned char *p_pkg_str);
+ static int encodeCBMsg(const sms_3gpp2_trans_broadcast_msg_s *p_msg, unsigned char *p_pkg_str);
+
+ static int encodeTelesvcMsg(const sms_3gpp2_telesvc_msg_s *p_msg, unsigned char *p_pkg_str);
+
+ static int encodeTelesvcCancelMsg(const sms_3gpp2_telesvc_cancel_s *p_msg, unsigned char *p_pkg_str);
+ static int encodeTelesvcSubmitMsg(const sms_3gpp2_telesvc_submit_s *p_msg, unsigned char *p_pkg_str);
+ static int encodeTelesvcUserAckMsg(const sms_3gpp2_telesvc_user_ack_s *p_msg, unsigned char *p_pkg_str);
+ static int encodeTelesvcReadAckMsg(const sms_3gpp2_telesvc_read_ack_s *p_msg, unsigned char *p_pkg_str);
+ static int encodeTelesvcDeliverReportMsg(const sms_3gpp2_telesvc_report_s *p_msg, unsigned char *p_pkg_str);
+
+ static int decodeP2PMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_p2p_msg_s *p_p2p);
+ static int decodeCBMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_broadcast_msg_s *p_cb);
+ static int decodeAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_ack_msg_s *p_ack);
+
+ static void decodeP2PTelesvcMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_msg_s *p_telesvc);
+ static void decodeP2PDeliveryAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_deliver_ack_s *p_del_ack);
+ static void decodeP2PSubmitReportMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_report_s *p_sub_report);
+ static void decodeP2PUserAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_user_ack_s *p_user_ack);
+ static void decodeP2PReadAckMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_read_ack_s *p_read_ack);
+ static void decodeP2PDeliverMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_deliver_s *p_del);
+ static void decodeP2PSubmitMsg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_submit_s *p_sub);
+ static void decodeCBBearerData(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_msg_s *p_telesvc, bool isCMAS);
+
+ static int encodeUserData(const unsigned char* src, unsigned char *dest, int src_size);
+ static void decodeUserData(unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_userdata_s *p_user);
+ static void decodeCMASData(unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_telesvc_cmasdata_s *p_cmas);
+
+ static int decodeTeleId(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_telesvc_id_t *tele_id);
+ static int decodeSvcCtg(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_svc_ctg_t *svc_ctg);
+ static int decodeAddress(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_addr_s *addr);
+ static int decodeSubAddress(const unsigned char *p_pkg_str, int p_pkg_len, sms_3gpp2_trans_sub_addr_s *sub_addr);
+
+ static int decodeMsgId(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_trans_msg_id_s *p_msg_id);
+ static void decodeCallBackNum(const unsigned char *p_pkg_str, int pkg_len, sms_3gpp2_telesvc_addr_s *p_callback);
+ static int decodeAbsTime(const unsigned char *p_pkg_str, sms_3gpp2_time_abs_s *p_time_abs);
+ static sms_3gpp2_message_type_t findMsgType(const unsigned char *p_pkg_str, int pkg_len);
+};
+
+#endif /* SMS_3GPP2_CODEC_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_EVENT_HANDLER_H
+#define SMS_3GPP2_EVENT_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <string>
+#include <map>
+#include <vector>
+#include <list>
+
+using namespace std;
+
+#include <tapi_common.h>
+#include <TelSms.h>
+#include "MsgMutex.h"
+#include "MsgTextConvert.h"
+#include "MsgPluginInterface.h"
+#include "Sms3gpp2Types.h"
+
+/*==================================================================================================
+ VARIABLES AND DEFINES
+==================================================================================================*/
+struct wap_3gpp2_data_s {
+ int length;
+ char data[SMS_MAX_USER_DATA_LEN+1];
+};
+
+typedef map<unsigned char, wap_3gpp2_data_s> wap3gpp2DataMap;
+
+typedef struct _sms_wap_msg_s {
+ unsigned short msgId;
+ unsigned char totalSeg;
+ unsigned char segNum;
+ int simIndex;
+} sms_3gpp2_wap_msg_s;
+
+typedef struct _sms_wap_info_s {
+ unsigned short msgId;
+ unsigned char totalSeg;
+ unsigned char segNum;
+ int simIndex;
+
+ unsigned int totalSize;
+ wap3gpp2DataMap data;
+} sms_3gpp2_wap_info_s;
+
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gpp2EventHandler
+{
+public:
+ static Sms3gpp2EventHandler* instance();
+
+ void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
+ void handleSentStatus(msg_network_status_t NetStatus);
+ void handleMsgIncoming(TapiHandle *handle, sms_3gpp2_trans_p2p_msg_s *p_p2p_msg);
+ void handleCbMsgIncoming(TapiHandle *handle, sms_3gpp2_trans_broadcast_msg_s *p_cb_msg);
+ void handleWapMsgIncoming(TapiHandle *handle, sms_3gpp2_trans_p2p_msg_s *p_p2p_msg);
+
+ void handleResendMessage(void);
+
+ msg_error_t callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo);
+ msg_error_t callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
+
+ void convertTpduToMsginfo(sms_3gpp2_trans_p2p_msg_s *p_p2p_msg, MSG_MESSAGE_INFO_S *p_msg_info);
+ void convertTpduToMsginfo(sms_3gpp2_trans_broadcast_msg_s *p_cb_msg, MSG_MESSAGE_INFO_S *p_msg_info);
+
+ void SetSentInfo(sms_3gpp2_sent_info_s *pSentInfo);
+
+ void setDeviceStatus(TapiHandle *handle, bool status);
+ bool getDeviceStatus(TapiHandle *handle);
+
+ void handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen);
+ void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
+ void handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *app_id, char *content_type);
+
+private:
+ Sms3gpp2EventHandler();
+ virtual ~Sms3gpp2EventHandler();
+
+ static Sms3gpp2EventHandler* pInstance;
+
+ MSG_PLUGIN_LISTENER_S listener;
+
+ sms_3gpp2_sent_info_s sentInfo;
+
+ bool devStatus;
+ TapiHandle *devHandle;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+ vector<sms_3gpp2_wap_info_s> wapList;
+
+ void convertDeliverMsgToMsgInfo(sms_3gpp2_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
+ void convertCMASMsgToMsgInfo(sms_3gpp2_telesvc_deliver_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
+ void convertAckMsgToMsgInfo(sms_3gpp2_telesvc_deliver_ack_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
+ void convertReportMsgToMsgInfo(sms_3gpp2_telesvc_report_s *p_deliver, MSG_MESSAGE_INFO_S *p_msg_info);
+
+ msg_encode_type_t getEncodeType(sms_3gpp2_encoding_type_t encode_type);
+
+ unsigned short checkWapMsg(sms_3gpp2_wap_msg_s *pMsg, sms_3gpp2_telesvc_userdata_s *pUserdata);
+ int MakeWapUserData(unsigned short msgId, msg_sim_slot_id_t simIndex, char **ppTotalData);
+
+ bool checkCbOpt(TapiHandle *handle, sms_3gpp2_trans_svc_ctg_t svc_ctg);
+};
+
+#endif /* SMS_3GPP2_EVENT_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_PARAM_CODEC_H
+#define SMS_3GPP2_PARAM_CODEC_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "Sms3gpp2Types.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gpp2ParamCodec
+{
+public:
+
+ static Sms3gpp2ParamCodec* instance();
+
+ static int convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd);
+ static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit);
+ static int convertDigitToDTMF(const char *pDigit, int DigitLen, int startBit, unsigned char *pDtmf);
+ static int convertDTMFToDigit(const unsigned char *pDtmf, int DtmfLen, int startBit, char *pDigit);
+
+private:
+ Sms3gpp2ParamCodec();
+ virtual ~Sms3gpp2ParamCodec();
+
+ static Sms3gpp2ParamCodec* pInstance;
+
+ static bool isDtmfNumber(const char *pDigit, int DigitLen);
+};
+
+#endif /* SMS_3GPP2_PARAM_CODEC_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_SETTING_H
+#define SMS_3GPP2_SETTING_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgSettingTypes.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gpp2Setting
+{
+public:
+ static Sms3gpp2Setting* instance();
+
+ void setSimChangeStatus(TapiHandle *handle);
+
+ void setConfigData(const MSG_SETTING_S *pSetting);
+ void getConfigData(MSG_SETTING_S *pSetting);
+ void getMeImei(char *pImei);
+
+ void setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
+
+ void setResultImei(bool bResult, char *pImei);
+ void setResultFromEvent(bool bResult);
+ void setResultFromSim(bool bResult);
+
+ void setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count);
+ void SimRefreshCb(TapiHandle *handle);
+ void initializeSimInfo(TapiHandle *handle);
+
+ bool getUpdateVoicemailByMdn();
+
+private:
+ Sms3gpp2Setting();
+ ~Sms3gpp2Setting();
+
+ void updateSimStatus(TapiHandle *handle);
+
+ void initConfigData(TapiHandle *handle);
+ static void* init_config_data(void *data);
+ static void* initSimInfo(void *data);
+
+ msg_error_t addCbOpt(MSG_CBMSG_OPT_S *pCbOpt);
+ void getCbOpt(MSG_SETTING_S *pSetting, int simIndex);
+
+ void setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt);
+ bool setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt);
+ bool getCbConfig(MSG_CBMSG_OPT_S *pCbOpt);
+
+ bool getMsisdnInfo(TapiHandle *handle);
+
+ bool getResultImei(char *pImei);
+
+ bool getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt);
+
+ bool getResultFromSim();
+
+ static Sms3gpp2Setting* pInstance;
+
+ MSG_SMSC_DATA_S smscData;
+ MSG_CBMSG_OPT_S cbOpt;
+
+ bool bTapiResult;
+ bool bUpdateVoicemailByMdn;
+
+ char meImei[MAX_ME_IMEI_LEN + 1];
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP2_SETTING_H */
+
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_TAPI_EVENT_HANDLER_H
+#define SMS_3GPP2_TAPI_EVENT_HANDLER_H
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <tapi_common.h>
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+class Sms3gpp2TapiEventHandler
+{
+public:
+ static void NotiSmsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiSmsDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void NotiNetworkRegistrationType(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+
+ static void respSetMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSentStatus(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respSetConfigData(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data);
+ static void respGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data);
+};
+
+#endif /* SMS_3GPP2_TAPI_EVENT_HANDLER_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_TRANSPORT_H
+#define SMS_3GPP2_TRANSPORT_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <tapi_common.h>
+#include <TelSms.h>
+#include "MsgInternalTypes.h"
+#include "MsgMutex.h"
+#include "Sms3gpp2Types.h"
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+msg_error_t Sms3gpp2SubmitRequest(MSG_REQUEST_INFO_S *pReqInfo);
+
+class Sms3gpp2Transport
+{
+public:
+ static Sms3gpp2Transport* instance();
+
+ void submitRequest(sms_3gpp2_request_info_s *pReqInfo);
+ void sendDeliverReport(TapiHandle *handle, msg_error_t err, sms_3gpp2_trans_p2p_msg_s *p_p2p_msg);
+
+ void setNetStatus(SMS_NETWORK_STATUS_T sentStatus);
+ void setIsMemAvailable(bool isAvailable);
+
+private:
+ Sms3gpp2Transport();
+ ~Sms3gpp2Transport();
+
+ static Sms3gpp2Transport* pInstance;
+
+ unsigned char getMsgRef();
+ unsigned char getSeqNum();
+ unsigned char getSubmitMsgId();
+
+ SMS_NETWORK_STATUS_T getNetStatus();
+
+ void convertMsgInfoToTelesvcMsg(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_3gpp2_trans_msg_s *pMsg);
+ void convertMsgInfoToPtp(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_3gpp2_trans_p2p_msg_s *pPtpMsg);
+ void convertMsgInfoToSubmit(const MSG_MESSAGE_INFO_S *pMsgInfo, sms_3gpp2_telesvc_submit_s *pSubmit);
+
+ bool isMemAvailable;
+ unsigned char msgRef;
+ unsigned char msgSeqNum;
+ unsigned char msgSubmitId;
+
+ unsigned char msgRef8bit;
+ unsigned short msgRef16bit;
+
+ SMS_NETWORK_STATUS_T curStatus;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP2_TRANSPORT_H */
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_TYPES_H
+#define SMS_3GPP2_TYPES_H
+
+#include "MsgDebug.h"
+#include "MsgTypes.h"
+#include "MsgInternalTypes.h"
+#include "SmsPluginTypes.h"
+
+#define SMS_MAX_MESSAGE_ID 65536
+#define SMS_SEQ_NUM_MAX 64
+#define SMS_MAX_USER_DATA_LEN 160
+#define SMS_MAX_SUBMIT_MESSAGE_ID 256
+
+#define SMS_TRANS_ADDRESS_MAX_LEN 256
+
+#define SMS_MAX_NUMBER_OF_ACK 8
+
+#define SMS_PUSH_XML_HREF_TAG "href"
+#define SMS_PUSH_XML_SI_ID_TAG "si-id"
+#define SMS_PUSH_XML_CREATED_TAG "created"
+#define SMS_PUSH_XML_EXPIRES_TAG "si-expires"
+#define SMS_PUSH_XML_ACTION_TAG "action"
+
+#define SMS_PUSH_XML_INVAL_OBJ "invalidate-object"
+#define SMS_PUSH_XML_INVAL_SVC "invalidate-service"
+#define SMS_PUSH_XML_CO_URI "uri"
+
+
+typedef struct {
+ char* contentsTypeName;
+ unsigned char contentsTypeCode;
+} SMS_3GPP2_WSP_CONTENTS_TYPE_S;
+
+
+typedef struct {
+ char* charsetName;
+ unsigned short charsetCode;
+} SMS_3GPP2_WSP_CHARSET_S;
+
+
+typedef struct {
+ char* contentsTypeName;
+ unsigned short contentsTypeCode;
+} SMS_3GPP2_WAP_UNREGISTER_CONTENTS_TYPE_S;
+
+
+typedef struct {
+ char* languageName;
+ unsigned char languageCode;
+} SMS_3GPP2_WSP_LANGUAGE_S;
+
+
+typedef struct {
+ char* parameterToken;
+ unsigned int parameterCode;
+} SMS_3GPP2_WSP_HEADER_PARAMETER_S;
+
+
+typedef struct {
+ char* methodName;
+ unsigned char methodCode;
+} SMS_3GPP2_WSP_METHOD_TYPE_S;
+
+
+typedef struct {
+ char* SecurityTypeName;
+ unsigned char SecurityTypeCode;
+} SMS_3GPP2_WSP_SECURITY_TYPE_S;
+
+
+typedef struct {
+ msg_request_id_t reqId; /* < Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
+ MSG_MESSAGE_INFO_S msgInfo; /* < Indicates the message structure to be sent by applications. */
+ MSG_SENDINGOPT_INFO_S sendOptInfo;
+} sms_3gpp2_request_info_s;
+
+
+typedef struct {
+ sms_3gpp2_request_info_s reqInfo; /* < Indicates the corresponding request structure. */
+ bool bLast;
+} sms_3gpp2_sent_info_s;
+
+/********************************************************************************/
+/* TELESERVICE LAYER */
+/********************************************************************************/
+typedef bool sms_3gpp2_digit_mode_t; /* _sms_digit_mode_e */
+typedef bool sms_3gpp2_number_mode_t; /* _sms_number_mode_e */
+typedef unsigned char sms_3gpp2_number_type_t; /* _sms_number_type_e */
+typedef unsigned char sms_3gpp2_number_plan_t; /* _sms_number_plan_e */
+
+
+typedef enum {
+ SMS_TYPE_RESERVED = 0x00, /* reserved */
+ SMS_TYPE_DELIVER, /* mobile-terminated only */
+ SMS_TYPE_SUBMIT, /* mobile-originated only */
+ SMS_TYPE_CANCEL, /* mobile-originated only */
+ SMS_TYPE_DELIVERY_ACK, /* mobile-terminated only*/
+ SMS_TYPE_USER_ACK, /* either direction */
+ SMS_TYPE_READ_ACK, /* either direction */
+ SMS_TYPE_DELIVER_REPORT, /* mobile-originated only */
+ SMS_TYPE_SUBMIT_REPORT = 0x08, /* mobile-terminated only */
+ SMS_TYPE_MAX_VALUE
+} sms_3gpp2_message_type_t;
+
+
+typedef enum {
+ SMS_ALERT_NO_ALERT = 0,
+ SMS_ALERT_DEFAULT_ALERT,
+ SMS_ALERT_VIBRATE_ONCE,
+ SMS_ALERT_VIBRATE_REPEAT,
+ SMS_ALERT_VISUAL_ONCE,
+ SMS_ALERT_VISUAL_REPEAT,
+ SMS_ALERT_LOW_PRIORITY_ONCE,
+ SMS_ALERT_LOW_PRIORITY_REPEAT,
+ SMS_ALERT_MEDIUM_PRIORITY_ONCE,
+ SMS_ALERT_MEDIUM_PRIORITY_REPEAT,
+ SMS_ALERT_HIGH_PRIORITY_ONCE,
+ SMS_ALERT_HIGH_PRIORITY_REPEAT,
+ SMS_ALERT_RESERVED
+} sms_3gpp2_alert_option_t;
+
+
+typedef enum {
+ SMS_LAN_UNKNOWN,
+ SMS_LAN_ENGLISH,
+ SMS_LAN_FRENCH,
+ SMS_LAN_SPANISH,
+ SMS_LAN_JAPANESE,
+ SMS_LAN_KOREAN,
+ SMS_LAN_CHINESE,
+ SMS_LAN_HEBREW,
+} sms_3gpp2_language_type_t;
+
+
+typedef enum {
+ SMS_PRIORITY_NORMAL = 0x00,
+ SMS_PRIORITY_INTERACTIVE,
+ SMS_PRIORITY_URGENT,
+ SMS_PRIORITY_EMERGENCY
+} sms_3gpp2_priority_indicator_t;
+
+
+typedef enum {
+ SMS_PRIVACY_NOT_RESTRICTED = 0x00,
+ SMS_PRIVACY_RESTRICTED,
+ SMS_PRIVACY_CONFIDENTIAL,
+ SMS_PRIVACY_SECRET
+} sms_3gpp2_privacy_indicator_t;
+
+
+typedef enum {
+ SMS_ALERT_MOBILE_DEFAULT = 0x00,
+ SMS_ALERT_LOW_PRIORITY,
+ SMS_ALERT_MEDIUM_PRIORITY,
+ SMS_ALERT_HIGH_PRIORITY
+} sms_3gpp2_alert_priority_t;
+
+
+typedef enum {
+ SMS_DISPLAY_IMMEDIATE = 0x00,
+ SMS_DISPLAY_DEFAULT_SETTING,
+ SMS_DISPLAY_USER_INVOKE,
+ SMS_DISPLAY_RESERVED
+} sms_3gpp2_display_mode_t;
+
+
+typedef enum {
+ SMS_ENCODE_OCTET = 0x0,
+ SMS_ENCODE_EPM = 0x1, /*IS-91 Extended Protocol Message*/
+ SMS_ENCODE_7BIT_ASCII = 0x2,
+ SMS_ENCODE_IA5 = 0x3,
+ SMS_ENCODE_UNICODE = 0x4,
+ SMS_ENCODE_SHIFT_JIS = 0x5,
+ SMS_ENCODE_KOREAN = 0x6,
+ SMS_ENCODE_LATIN_HEBREW = 0x7,
+ SMS_ENCODE_LATIN = 0x8,
+ SMS_ENCODE_GSM7BIT = 0x9,
+ SMS_ENCODE_GSMDCS = 0xa,
+ SMS_ENCODE_EUCKR = 0x10,
+ SMS_ENCODE_RESERVED
+} sms_3gpp2_encoding_type_t;
+
+
+typedef enum {
+ SMS_REL_TIME_5_MINS = 0,
+ SMS_REL_TIME_12_HOURS = 143,
+ SMS_REL_TIME_1_DAY = 167,
+ SMS_REL_TIME_2_DAYS = 168,
+ SMS_REL_TIME_3_DAYS = 169,
+ SMS_REL_TIME_1_WEEK = 173,
+ SMS_REL_TIME_INDEFINITE = 245,
+ SMS_REL_TIME_IMMEDIATE = 246,
+ SMS_REL_TIME_ACTIVE = 247,
+ SMS_REL_TIME_REGISTRATION = 248,
+ SMS_REL_TIME_RESERVED
+} sms_3gpp2_relative_time_t;
+
+
+typedef enum {
+ /* ERROR_CLASS = '00' (no error) */
+ SMS_STATUS_ACCEPTED = 0x00,
+ SMS_STATUS_DEPOSITED = 0x01,
+ SMS_STATUS_DELIVERED = 0x02,
+ SMS_STATUS_CANCELLED = 0x03,
+
+ /* ERROR_CLASS = '10' (temporary condition) */
+ SMS_STATUS_TEMP_NETWORK_CONGESTION = 0x84,
+ SMS_STATUS_TEMP_NETWORK_ERROR = 0x85,
+ SMS_STATUS_TEMP_UNKNOWN_ERROR = 0x9F,
+
+ /* ERROR_CLASS = '11' (permanent condition) */
+ SMS_STATUS_PERMANENT_NETWORK_CONGESTION = 0xC4,
+ SMS_STATUS_PERMANENT_NETWORK_ERROR = 0xC5,
+ SMS_STATUS_PERMANENT_CANCEL_FAILED = 0xC6,
+ SMS_STATUS_PERMANENT_BLOCKED_DESTINATION = 0xC7,
+ SMS_STATUS_PERMANENT_TEXT_TOO_LONG = 0xC8,
+ SMS_STATUS_PERMANENT_DUPLICATE_MESSAGE = 0xC9,
+ SMS_STATUS_PERMANENT_INVALID_DESTINATION = 0xCA,
+ SMS_STATUS_PERMANENT_MESSAGE_EXPIRED = 0xCD,
+ SMS_STATUS_PERMANENT_UNKNOWN_ERROR = 0xDF,
+} sms_3gpp2_status_code_t;
+
+
+typedef enum {
+ SMS_CMAE_CTG_GEO = 0x00,
+ SMS_CMAE_CTG_MET = 0x01,
+ SMS_CMAE_CTG_SAFETY = 0x02,
+ SMS_CMAE_CTG_SECURITY = 0x03,
+ SMS_CMAE_CTG_RESCUE = 0x04,
+ SMS_CMAE_CTG_FIRE = 0x05,
+ SMS_CMAE_CTG_HEALTH = 0x06,
+ SMS_CMAE_CTG_ENV = 0x07,
+ SMS_CMAE_CTG_TRANSPORT = 0x08,
+ SMS_CMAE_CTG_INFRA = 0x09,
+ SMS_CMAE_CTG_CBRNE = 0x0a,
+ SMS_CMAE_CTG_OTHER = 0x0b,
+ SMS_CMAE_CTG_RESERVED,
+} sms_3gpp2_cmae_category_t;
+
+
+typedef enum {
+ SMS_CMAE_RESP_TYPE_SHELTER = 0x00,
+ SMS_CMAE_RESP_TYPE_EVACUATE = 0x01,
+ SMS_CMAE_RESP_TYPE_PREPARE = 0x02,
+ SMS_CMAE_RESP_TYPE_EXECUTE = 0x03,
+ SMS_CMAE_RESP_TYPE_MONITOR = 0x04,
+ SMS_CMAE_RESP_TYPE_AVOID = 0x05,
+ SMS_CMAE_RESP_TYPE_ASSESS = 0x06,
+ SMS_CMAE_RESP_TYPE_NONE = 0x07,
+ SMS_CMAE_RESP_TYPE_RESERVED,
+} sms_3gpp2_cmae_response_type_t;
+
+
+typedef enum {
+ SMS_CMAE_SEVERITY_EXTREME = 0x0,
+ SMS_CMAE_SEVERITY_SEVERE = 0x1,
+ SMS_CMAE_SEVERITY_RESERVED,
+} sms_3gpp2_cmae_severity_t;
+
+
+typedef enum {
+ SMS_CMAE_URGENCY_IMMEDIATE = 0x0,
+ SMS_CMAE_URGENCY_EXPECTED = 0x1,
+ SMS_CMAE_URGENCY_RESERVED,
+} sms_3gpp2_cmae_urgency_t;
+
+
+typedef enum {
+ SMS_CMAE_CERTAINTY_OBSERVED = 0x0,
+ SMS_CMAE_CERTAINTY_LIKELY = 0x1,
+ SMS_CMAE_CERTAINTY_RESERVED,
+} sms_3gpp2_cmae_certainty_t;
+
+
+typedef enum {
+ SMS_CMAE_ALERT_PRESIDENTIAL = 0x00,
+ SMS_CMAE_ALERT_EXTREME = 0x01,
+ SMS_CMAE_ALERT_SEVERE = 0x02,
+ SMS_CMAE_ALERT_AMBER = 0x03,
+ SMS_CMAE_ALERT_RESERVED,
+} sms_3gpp2_cmae_alert_handle_t;
+
+
+enum _sms_bearer_sub_param_e {
+ SMS_BEARER_MESSAGE_IDENTIFIER = 0x00,
+ SMS_BEARER_USER_DATA = 0x01,
+ SMS_BEARER_USER_RESPONSE_CODE = 0x02,
+ SMS_BEARER_MSG_CENTER_TIME_STAMP = 0x03,
+ SMS_BEARER_VALIDITY_PERIOD_ABSOLUTE = 0x04,
+ SMS_BEARER_VALIDITY_PERIOD_RELATIVE = 0x05,
+ SMS_BEARER_DEFERRED_DELIVERY_TIME_ABSOLUTE = 0x06,
+ SMS_BEARER_DEFERRED_DELIVERY_TIME_RELATIVE = 0x07,
+ SMS_BEARER_PRIORITY_INDICATOR = 0x08,
+ SMS_BEARER_PRIVACY_INDICATOR = 0x09,
+ SMS_BEARER_REPLY_OPTION = 0x0A,
+ SMS_BEARER_NUMBER_OF_MESSAGES = 0x0B,
+ SMS_BEARER_ALERT_ON_MSG_DELIVERY = 0x0C,
+ SMS_BEARER_LANGUAGE_INDICATOR = 0x0D,
+ SMS_BEARER_CALLBACK_NUMBER = 0x0E,
+ SMS_BEARER_MSG_DISPLAY_MODE = 0x0F,
+ SMS_BEARER_MULTI_ENCODING_USER_DATA = 0x10,
+ SMS_BEARER_MSG_DEPOSIT_INDEX = 0x11,
+ SMS_BEARER_SVC_CATEGORY_PROGRAM_DATA = 0x12,
+ SMS_BEARER_SVC_CATEGORY_PROGRAM_RESULT = 0x13,
+ SMS_BEARER_MESSAGE_STATUS = 0x14,
+ SMS_BEARER_TP_FAILURE_CAUSE = 0x15,
+ SMS_BEARER_ENHANCED_VMN = 0x16,
+ SMS_BEARER_ENHANCED_VMN_ACK = 0x17,
+ SMS_BEARER_MAX_VALUE
+};
+
+
+enum _sms_svc_ctg_result_e {
+ SMS_SVC_RESULT_SUCCESS = 0x00,
+ SMS_SVC_RESULT_MEMORY_LIMIT_EXCEEDED,
+ SMS_SVC_RESULT_LIMIT_EXCEEDED,
+ SMS_SVC_RESULT_ALREADY_PROGRAMMED,
+ SMS_SVC_RESULT_NOT_PREVIOUSLY_PROGRAMMED,
+ SMS_SVC_RESULT_INVALID_MAX_MESSAGES,
+ SMS_SVC_RESULT_INVALID_ALERT_OPTION,
+ SMS_SVC_RESULT_INVALID_SVC_CTG_NAME,
+ SMS_SVC_RESULT_INSPECIFIED_PROGRAMMING_FAILURE,
+ SMS_SVC_RESULT_RESERVED
+};
+
+
+enum _SMS_3GPP2_TIME_FORMAT_E {
+ SMS_3GPP2_TIME_EMPTY = 0,
+ SMS_3GPP2_TIME_RELATIVE,
+ SMS_3GPP2_TIME_ABSOLUTE
+};
+
+
+enum _sms_tp_failure_cause_e {
+ /* 0x00 ~ 0x7f reserved */
+ SMS_TP_CAUSE_RESERVED,
+
+ /* 0x80 ~ 0x8f TP-PID errors */
+ SMS_TP_CAUSE_TELEMATIC_INTERWORKING_NOT_SUPPORTED = 0x80,
+ SMS_TP_CAUSE_SHORT_MSG_TYPE_0_NOT_SUPPORTED = 0x81,
+ SMS_TP_CAUSE_CANNOT_REPLACE_SHORT_MSG = 0x82,
+ SMS_TP_CAUSE_UNSPECIFIED_TP_PID_ERROR = 0x8f,
+
+ /* 0x90 ~ 0x9f TP-DCS errors */
+ SMS_TP_CAUSE_DCS_NOT_SPPORTED = 0x90,
+ SMS_TP_CAUSE_MSG_CLASS_NOT_SUPPORTED = 0x91,
+ SMS_TP_CAUSE_UNSPECIFIED_TP_DCS_ERROR = 0x9f,
+
+ /* 0xa0 ~ 0xaf TP-Command Errors */
+ SMS_TP_CAUSE_CMD_CANNOT_BE_ACTIONED = 0xa0,
+ SMS_TP_CAUSE_CMD_UNSUPPORTED = 0xa1,
+ SMS_TP_CAUSE_UNSPECIFIED_TP_CMD_ERROR = 0xaf,
+
+ SMS_TP_CAUSE_TPDU_NOT_SUPPORTED = 0xb0,
+
+ SMS_TP_CAUSE_SC_BUSY = 0xc0,
+ SMS_TP_CAUSE_NO_SC_SUBCRIPTION = 0xc1,
+ SMS_TP_CAUSE_SC_SYSTEM_FAILURE = 0xc2,
+ SMS_TP_CAUSE_INVALID_SME_ADDRESS = 0xc3,
+ SMS_TP_CAUSE_DESTINATION_SME_BARRED = 0xc4,
+ SMS_TP_CAUSE_SM_REJECTED_DUPLICATE_SM = 0xc5,
+ SMS_TP_CAUSE_TP_VPF_NOT_SUPPORTED = 0xc6,
+ SMS_TP_CAUSE_TP_VP_NOT_SUPPORTED = 0xc7,
+
+ SMS_TP_CAUSE_SIM_SMS_STORAGE_FULL = 0xd0,
+ SMS_TP_CAUSE_NO_SMS_STORAGE_CAPABILITY_IN_SIM = 0xd1,
+ SMS_TP_CAUSE_ERROR_IN_MS = 0xd2,
+ SMS_TP_CAUSE_MEMORY_CAPACITY_EXCEEDED = 0xd3,
+ SMS_TP_CAUSE_SIM_APPLICATION_TOOLKIT_BUSY = 0xd4,
+ SMS_TP_CAUSE_SIM_DATA_DOWNLOAD_ERROR = 0xd5,
+
+ /* 0xe0 ~ 0xfe Values specific to an application */
+ SMS_TP_CAUSE_SPECIFIC_TO_APPLICATION_MIN = 0xe0,
+ SMS_TP_CAUSE_SPECIFIC_TO_APPLICATION_MAX = 0xfe,
+
+ SMS_TP_CAUSE_UNSPECIFIED_ERROR_CAUSE = 0xff
+};
+
+
+typedef struct {
+ unsigned short msg_id;
+ bool header_ind;
+} sms_3gpp2_trans_msg_id_s;
+
+
+typedef struct {
+ sms_3gpp2_digit_mode_t digit_mode;
+ sms_3gpp2_number_type_t number_type;
+ sms_3gpp2_number_plan_t number_plan;
+ unsigned int addr_len;
+ char szData[SMS_TRANS_ADDRESS_MAX_LEN + 1];
+} sms_3gpp2_telesvc_addr_s;
+
+
+typedef struct {
+ bool user_ack_req;
+ bool deliver_ack_req;
+ bool read_ack_req;
+ bool report_req;
+} sms_3gpp2_reply_option_s;
+
+
+typedef struct {
+ sms_3gpp2_relative_time_t rel_time;
+} sms_3gpp2_time_rel_s;
+
+typedef struct {
+ unsigned char year; /* range 00-99 (96~99 : 19xx, 00~95 : 20xx) */
+ unsigned char month; /* range 1-12 */
+ unsigned char day;
+ unsigned char hours; /* range 0-23 */
+ unsigned char minutes; /* range 0-59 */
+ unsigned char seconds; /* range 0-59 */
+} sms_3gpp2_time_abs_s;
+
+
+typedef struct {
+ unsigned char format;
+ union {
+ sms_3gpp2_time_rel_s rel_time;
+ sms_3gpp2_time_abs_s abs_time;
+ } time;
+} sms_3gpp2_val_period_s;
+
+
+typedef struct {
+ sms_3gpp2_encoding_type_t encode_type;
+ unsigned int data_len;
+ char user_data[SMS_MAX_USER_DATA_LEN +1];
+} sms_3gpp2_encoding_specific_s;
+
+
+typedef struct {
+ unsigned char operation_code;
+ unsigned short category;
+ sms_3gpp2_language_type_t language;
+ unsigned char max_msg;
+ sms_3gpp2_alert_option_t alert_option;
+ unsigned int data_len;
+ char user_data[SMS_MAX_USER_DATA_LEN +1];
+} sms_3gpp2_ctg_specific_s;
+
+
+typedef struct {
+ sms_3gpp2_encoding_type_t encode_type;
+ unsigned int num_data;
+ sms_3gpp2_ctg_specific_s *specific_data;
+} sms_3gpp2_svc_ctg_program_data_s;
+
+
+typedef struct {
+ sms_3gpp2_encoding_type_t encode_type;
+ unsigned char msg_type;
+ unsigned int data_len;
+ unsigned char user_data[SMS_MAX_USER_DATA_LEN +1];
+} sms_3gpp2_telesvc_userdata_s;
+
+
+typedef struct {
+ unsigned int data_len;
+ sms_3gpp2_encoding_type_t encode_type;
+ unsigned char alert_text[SMS_MAX_USER_DATA_LEN +1];
+ sms_3gpp2_cmae_category_t category;
+ sms_3gpp2_cmae_response_type_t response_type;
+ sms_3gpp2_cmae_severity_t severity;
+ sms_3gpp2_cmae_urgency_t urgency;
+ sms_3gpp2_cmae_certainty_t certainty;
+ unsigned short id;
+ sms_3gpp2_cmae_alert_handle_t alert_handle; /* 00:Presidential 01:Extreme 02:Severe 03:AMBER 04:Test */
+ sms_3gpp2_time_abs_s expires;
+ sms_3gpp2_language_type_t language;
+ bool is_wrong_recode_type;
+} sms_3gpp2_telesvc_cmasdata_s;
+
+
+typedef struct {
+ sms_3gpp2_priority_indicator_t priority;
+ bool password_req;
+ bool setup_req;
+ bool pw_change_req;
+ unsigned char min_pw_len;
+ unsigned char max_pw_len;
+ unsigned char vm_num_unheard_msg;
+ bool vm_mailbox_alm_full;
+ bool vm_mailbox_full;
+ bool reply_allowed;
+ bool fax_included;
+ unsigned short vm_len;
+ unsigned char vm_ret_day;
+ unsigned short vm_msg_id;
+ unsigned short vm_mailbox_id;
+
+ sms_3gpp2_digit_mode_t an_digit_mode;
+ sms_3gpp2_number_type_t an_number_type;
+ sms_3gpp2_number_plan_t an_number_plan;
+ unsigned char an_num_field;
+ unsigned char an_char[SMS_MAX_USER_DATA_LEN+1];
+
+ sms_3gpp2_digit_mode_t cli_digit_mode;
+ sms_3gpp2_number_type_t cli_number_type;
+ sms_3gpp2_number_plan_t cli_number_plan;
+ unsigned char cli_num_field;
+ unsigned char cli_char[SMS_MAX_USER_DATA_LEN+1];
+} sms_3gpp2_enhanced_vmn_s;
+
+
+typedef struct {
+ unsigned short vm_mailbox_id;
+ unsigned char vm_num_unheard_msg;
+ unsigned char num_delete_ack;
+ unsigned char num_play_ack;
+
+ unsigned short da_vm_msg_id[SMS_MAX_NUMBER_OF_ACK+1];
+ unsigned short pa_vm_msg_id[SMS_MAX_NUMBER_OF_ACK+1];
+} sms_3gpp2_enhanced_vmn_ack_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+ sms_3gpp2_telesvc_userdata_s user_data;
+ sms_3gpp2_telesvc_cmasdata_s cmas_data;
+ sms_3gpp2_time_abs_s time_stamp;
+ sms_3gpp2_val_period_s val_period;
+ sms_3gpp2_val_period_s defer_val_period;
+ sms_3gpp2_priority_indicator_t priority;
+ sms_3gpp2_privacy_indicator_t privacy;
+ sms_3gpp2_reply_option_s reply_opt;
+ unsigned int num_msg;
+ sms_3gpp2_alert_priority_t alert_priority;
+ sms_3gpp2_language_type_t language;
+ sms_3gpp2_telesvc_addr_s callback_number;
+ sms_3gpp2_display_mode_t display_mode;
+ sms_3gpp2_encoding_specific_s multi_encode_data;
+ unsigned short deposit_id;
+ /* sms_3gpp2_svc_ctg_program_data_s svc_ctg; */
+ sms_3gpp2_enhanced_vmn_s enhanced_vmn;
+ sms_3gpp2_enhanced_vmn_ack_s enhanced_vmn_ack;
+} sms_3gpp2_telesvc_deliver_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+ sms_3gpp2_telesvc_userdata_s user_data;
+ sms_3gpp2_val_period_s val_period;
+ sms_3gpp2_val_period_s defer_val_period;
+ sms_3gpp2_priority_indicator_t priority;
+ sms_3gpp2_privacy_indicator_t privacy;
+ sms_3gpp2_reply_option_s reply_opt;
+ sms_3gpp2_alert_priority_t alert_priority;
+ sms_3gpp2_language_type_t language;
+ sms_3gpp2_telesvc_addr_s callback_number;
+ sms_3gpp2_encoding_specific_s multi_encode_data;
+ unsigned char deposit_id;
+ /* sms_3gpp2_svc_ctg_program_data_s svc_ctg; */
+} sms_3gpp2_telesvc_submit_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+} sms_3gpp2_telesvc_cancel_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+ sms_3gpp2_telesvc_userdata_s user_data;
+ unsigned char resp_code;
+ sms_3gpp2_time_abs_s time_stamp;
+ sms_3gpp2_encoding_specific_s multi_encode_data;
+ unsigned char deposit_id;
+} sms_3gpp2_telesvc_user_ack_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+ sms_3gpp2_telesvc_userdata_s user_data;
+ sms_3gpp2_time_abs_s time_stamp;
+ sms_3gpp2_encoding_specific_s multi_encode_data;
+ sms_3gpp2_status_code_t msg_status;
+} sms_3gpp2_telesvc_deliver_ack_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+ sms_3gpp2_telesvc_userdata_s user_data;
+ sms_3gpp2_time_abs_s time_stamp;
+ sms_3gpp2_encoding_specific_s multi_encode_data;
+ unsigned char deposit_id;
+} sms_3gpp2_telesvc_read_ack_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_id_s msg_id;
+ unsigned char tp_fail_cause;
+ sms_3gpp2_telesvc_userdata_s user_data;
+ sms_3gpp2_language_type_t language;
+ unsigned char multi_encode_data;
+} sms_3gpp2_telesvc_report_s;
+
+
+typedef struct {
+ sms_3gpp2_message_type_t type;
+
+ union {
+ sms_3gpp2_telesvc_deliver_s deliver;
+ sms_3gpp2_telesvc_submit_s submit;
+ sms_3gpp2_telesvc_cancel_s cancel;
+ sms_3gpp2_telesvc_user_ack_s user_ack;
+ sms_3gpp2_telesvc_deliver_ack_s delivery_ack;
+ sms_3gpp2_telesvc_read_ack_s read_ack;
+ sms_3gpp2_telesvc_report_s report;
+ } data;
+} sms_3gpp2_telesvc_msg_s;
+
+
+
+/********************************************************************************/
+/* TRANSPORT LAYER */
+/********************************************************************************/
+
+typedef unsigned short sms_3gpp2_trans_param_id_t; /* _sms_trans_param_id_e */
+typedef unsigned short sms_3gpp2_trans_telesvc_id_t; /* _sms_trans_telesvc_id_e */
+typedef unsigned short sms_3gpp2_trans_svc_ctg_t; /* _sms_trans_svc_ctg_e */
+typedef unsigned char sms_3gpp2_trans_reply_seq_t;
+
+
+typedef enum {
+ SMS_TRANS_P2P_MSG = 0x00,
+ SMS_TRANS_BROADCAST_MSG = 0x01,
+ SMS_TRANS_ACK_MSG = 0x02,
+ SMS_TRANS_TYPE_RESERVED
+} sms_3gpp2_trans_msg_type_t;
+
+
+enum _sms_trans_param_id_e {
+ SMS_TRANS_PARAM_TELESVC_IDENTIFIER = 0x00,
+ SMS_TRANS_PARAM_SERVICE_CATEGORY = 0x01,
+ SMS_TRANS_PARAM_ORG_ADDRESS = 0x02,
+ SMS_TRANS_PARAM_ORG_SUB_ADDRESS = 0x02,
+ SMS_TRANS_PARAM_DEST_ADDRESS = 0x04,
+ SMS_TRANS_PARAM_DEST_SUB_ADDRESS = 0x05,
+ SMS_TRANS_PARAM_BEARER_REPLY_OPTION = 0x06,
+ SMS_TRANS_PARAM_CAUSE_CODES = 0x07,
+ SMS_TRANS_PARAM_BEARER_DATA = 0x08,
+ SMS_TRANS_PARAM_RESERVED
+};
+
+
+enum _sms_trans_telesvc_id_e {
+ SMS_TRANS_TELESVC_CMT_91 = 0x1000, /* IS-91 Extended Protocol Enhanced Services */
+ SMS_TRANS_TELESVC_CPT_95 = 0x1001, /* Wireless Paging Teleservice */
+ SMS_TRANS_TELESVC_CMT_95 = 0x1002, /* Wireless Messaging Teleservice */
+ SMS_TRANS_TELESVC_VMN_95 = 0x1003, /* Voice Mail Notification */
+ SMS_TRANS_TELESVC_WAP = 0x1004, /* Wireless Application Protocol */
+ SMS_TRANS_TELESVC_WEMT = 0x1005, /* Wireless Enhanced Messaging Teleservice */
+ SMS_TRANS_TELESVC_SCPT = 0x1006, /* Service Category Programming Teleservice */
+ SMS_TRANS_TELESVC_CATPT = 0x1007, /* Card Application Toolkit Protocol Teleservice */
+ SMS_TRANS_TELESVC_RESERVED = 0xffff
+};
+
+
+enum _sms_trans_svc_ctg_e {
+ SMS_TRANS_SVC_CTG_UNKNOWN = 0x0000,
+ SMS_TRANS_SVC_CTG_EMERGENCY = 0x0001,
+ SMS_TRANS_SVC_CTG_ADMINISTRATIVE = 0x0002,
+ SMS_TRANS_SVC_CTG_MAINTENANCE = 0x0003,
+ SMS_TRANS_SVC_CTG_GNEWS_LOCAL = 0x0004,
+ SMS_TRANS_SVC_CTG_GNEWS_REGIONAL = 0x0005,
+ SMS_TRANS_SVC_CTG_GNEWS_NATIONAL = 0x0006,
+ SMS_TRANS_SVC_CTG_GNEWS_INTERNATIONAL = 0x0007,
+ SMS_TRANS_SVC_CTG_BFNEWS_LOCAL = 0x0008,
+ SMS_TRANS_SVC_CTG_BFNEWS_REGIONAL = 0x0009,
+ SMS_TRANS_SVC_CTG_BFNEWS_NATIONAL = 0x000a,
+ SMS_TRANS_SVC_CTG_BFNEWS_INTERNATIONAL = 0x000b,
+ SMS_TRANS_SVC_CTG_SNEWS_LOCAL = 0x000c,
+ SMS_TRANS_SVC_CTG_SNEWS_REGIONAL = 0x000d,
+ SMS_TRANS_SVC_CTG_SNEWS_NATIONAL = 0x000e,
+ SMS_TRANS_SVC_CTG_SNEWS_INTERNATIONAL = 0x000f,
+ SMS_TRANS_SVC_CTG_ENEWS_LOCAL = 0x0010,
+ SMS_TRANS_SVC_CTG_ENEWS_REGIONAL = 0x0011,
+ SMS_TRANS_SVC_CTG_ENEWS_NATIONAL = 0x0012,
+ SMS_TRANS_SVC_CTG_ENEWS_INTERNATIONAL = 0x0013,
+ SMS_TRANS_SVC_CTG_LOCAL_WEATHER = 0x0014,
+ SMS_TRANS_SVC_CTG_TRAFFIC_REPORTS = 0x0015,
+ SMS_TRANS_SVC_CTG_FLIGHT_SCHEDULES = 0x0016,
+ SMS_TRANS_SVC_CTG_RESTAURANTS = 0x0017,
+ SMS_TRANS_SVC_CTG_LODGINGS = 0x0018,
+ SMS_TRANS_SVC_CTG_RETAIL_DIRECTORY = 0x0019,
+ SMS_TRANS_SVC_CTG_ADVERTISEMENTS = 0x001a,
+ SMS_TRANS_SVC_CTG_STOCK_QUOTES = 0x001b,
+ SMS_TRANS_SVC_CTG_EMPLOYMENT = 0x001c,
+ SMS_TRANS_SVC_CTG_MEDICAL = 0x001d,
+ SMS_TRANS_SVC_CTG_TECHNOLOGY_NEWS = 0x001e,
+ SMS_TRANS_SVC_CTG_MULTI_CTG = 0x001f,
+ SMS_TRANS_SVC_CTG_CATPT = 0x0020,
+ SMS_TRANS_SVC_CTG_KDDI_CORP_MIN1 = 0x0021,
+ SMS_TRANS_SVC_CTG_KDDI_CORP_MAX1 = 0x003f,
+ SMS_TRANS_SVC_CTG_CMAS_PRESIDENTIAL = 0x1000,
+ SMS_TRANS_SVC_CTG_CMAS_EXTREME = 0x1001,
+ SMS_TRANS_SVC_CTG_CMAS_SEVERE = 0x1002,
+ SMS_TRANS_SVC_CTG_CMAS_AMBER = 0x1003,
+ SMS_TRANS_SVC_CTG_CMAS_TEST = 0x1004,
+ SMS_TRANS_SVC_CTG_KDDI_CORP_MIN2 = 0x8001,
+ SMS_TRANS_SVC_CTG_KDDI_CORP_MAX2 = 0x803f,
+ SMS_TRANS_SVC_CTG_KDDI_CORP_MIN3 = 0xc001,
+ SMS_TRANS_SVC_CTG_KDDI_CORP_MAX3 = 0xc03f,
+ SMS_TRANS_SVC_CTG_RESERVED,
+ SMS_TRANS_SVC_CTG_UNDEFINED = 0x8001,
+};
+
+
+typedef enum {
+ SMS_TRANS_ERR_CLASS_NONE = 0x00,
+ SMS_TRANS_ERR_CLASS_TEMPORARY = 0x02,
+ SMS_TRANS_ERR_CLASS_PERMANENT = 0x03
+} sms_3gpp2_trans_err_class_t;
+
+
+typedef enum {
+ SMS_CAUSE_CODE_INVAILD_TELESERVICE_ID = 0x04,
+ SMS_CAUSE_CODE_SERVICE_TERMINATION_DENIED = 0x62,
+ SMS_TODO_FILL_THIS_ENUMS
+} sms_3gpp2_trans_cause_code_t;
+
+
+typedef enum {
+ SMS_TRANS_SUB_ADDR_NSAP = 0x00,
+ SMS_TRANS_SUB_ADDR_USER = 0x01,
+ SMS_TRANS_SUB_ADDR_RESERVED
+} sms_3gpp2_trans_sub_addr_type_t;
+
+
+enum _sms_trans_dnet_addr_type_e {
+ SMS_TRANS_DNET_UNKNOWN = 0x00,
+ SMS_TRANS_DNET_INTERNET_PROTOCOL = 0x01,
+ SMS_TRANS_DNET_INTERNET_MAIL_ADDR = 0x02,
+ SMS_TRANS_DNET_RESERVED
+};
+
+
+enum _sms_digit_mode_e {
+ SMS_DIGIT_4BIT_DTMF = 0,
+ SMS_DIGIT_8BIT = 1
+};
+
+
+enum _sms_number_mode_e {
+ SMS_NUMBER_MODE_NONE_DATANETWORK = 0,
+ SMS_NUMBER_MODE_DATANETWORK = 1, /*using data network address format*/
+};
+
+
+enum _sms_dnet_number_type_e {
+ SMS_ADDRESS_TYPE_UNKNOWN = 0x00,
+ SMS_ADDRESS_TYPE_INTERNET_PROTOCOL = 0x01,
+ SMS_ADDRESS_TYPE_EMAIL_ADDRESS = 0x02,
+};
+
+
+enum _sms_number_type_e {
+ SMS_NUMBER_TYPE_UNKNOWN = 0x00,
+ SMS_NUMBER_TYPE_INTERNATIONAL = 0x01,
+ SMS_NUMBER_TYPE_NATIONAL = 0x02,
+ SMS_NUMBER_TYPE_NETWORK_SPECIFIC = 0x03,
+ SMS_NUMBER_TYPE_SUBSCRIBER = 0x04,
+ SMS_NUMBER_TYPE_RESERVED_5 = 0x05,
+ SMS_NUMBER_TYPE_ABBREVIATED = 0x06,
+ SMS_NUMBER_TYPE_RESERVED_7 = 0x07,
+/*
+ * TODO : check this type is valid or not
+ * SMS_NUMBER_TYPE_IP = 0x11,
+ * SMS_NUMBER_TYPE_EMAILADDR = 0x12,
+ */
+};
+
+
+enum _sms_number_plan_e {
+ SMS_3GPP2_NPI_UNKNOWN = 0,
+ SMS_3GPP2_NPI_ISDN = 1,
+ SMS_3GPP2_NPI_DATA = 3,
+ SMS_3GPP2_NPI_TELEX = 4,
+ SMS_3GPP2_NPI_PRIVATE = 9,
+ SMS_3GPP2_NPI_RESERVED = 15,
+};
+
+
+typedef struct {
+ sms_3gpp2_digit_mode_t digit_mode;
+ sms_3gpp2_number_mode_t number_mode;
+ sms_3gpp2_number_type_t number_type;
+ sms_3gpp2_number_plan_t number_plan;
+ unsigned int addr_len;
+ char szData[SMS_TRANS_ADDRESS_MAX_LEN + 1];
+} sms_3gpp2_trans_addr_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_sub_addr_type_t type;
+ bool odd;
+ unsigned int addr_len;
+ char szData[SMS_TRANS_ADDRESS_MAX_LEN + 1];
+} sms_3gpp2_trans_sub_addr_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_reply_seq_t reply_seq;
+ sms_3gpp2_trans_err_class_t error_class;
+ sms_3gpp2_trans_cause_code_t cause_code;
+} sms_3gpp2_trans_cause_code_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_telesvc_id_t telesvc_id;
+ sms_3gpp2_trans_svc_ctg_t svc_ctg;
+ sms_3gpp2_trans_addr_s address;
+ sms_3gpp2_trans_sub_addr_s sub_address;
+ sms_3gpp2_trans_reply_seq_t reply_seq;
+ sms_3gpp2_telesvc_msg_s telesvc_msg;
+} sms_3gpp2_trans_p2p_msg_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_svc_ctg_t svc_ctg;
+ sms_3gpp2_telesvc_msg_s telesvc_msg;
+} sms_3gpp2_trans_broadcast_msg_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_addr_s address;
+ sms_3gpp2_trans_sub_addr_s sub_address;
+ sms_3gpp2_trans_cause_code_s cause_code;
+} sms_3gpp2_trans_ack_msg_s;
+
+
+typedef struct {
+ sms_3gpp2_trans_msg_type_t type;
+ union {
+ sms_3gpp2_trans_p2p_msg_s p2p_msg;
+ sms_3gpp2_trans_broadcast_msg_s cb_msg;
+ sms_3gpp2_trans_ack_msg_s ack_msg;
+ } data;
+} sms_3gpp2_trans_msg_s;
+
+#endif /* SMS_3GPP2_TYPES_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_UA_MANAGER_H
+#define SMS_3GPP2_UA_MANAGER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include "MsgMutex.h"
+#include "MsgQueue.h"
+#include "MsgThread.h"
+#include "Sms3gpp2Types.h"
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gpp2UAManager : public MsgThread
+{
+public:
+ static Sms3gpp2UAManager* instance();
+
+ /* virtual void start(); */
+
+ void addReqEntity(sms_3gpp2_request_info_s *request);
+
+private:
+ Sms3gpp2UAManager();
+ ~Sms3gpp2UAManager();
+ void lock() { mx.lock(); };
+ void unlock() { mx.unlock(); };
+ void wait() { cv.wait(mx.pMsgMutex()); };
+ void signal() { cv.signal(); };
+
+ virtual void run();
+
+ static Sms3gpp2UAManager* pInstance;
+
+ bool bRunning;
+
+ MsgSimpleQ <sms_3gpp2_request_info_s> smsTranQ;
+
+ MsgMutex mx;
+ MsgCndVar cv;
+};
+
+#endif /* SMS_3GPP2_UA_MANAGER_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#ifndef SMS_3GPP2_WAP_PUSH_HANDLER_H
+#define SMS_3GPP2_WAP_PUSH_HANDLER_H
+
+
+/*==================================================================================================
+ INCLUDE FILES
+==================================================================================================*/
+#include <wbxml/wbxml.h>
+#include <libxml/parser.h>
+
+
+#include "Sms3gpp2Types.h"
+
+
+/*==================================================================================================
+ DEFINES
+==================================================================================================*/
+#define WSP_STANDARD_STR_LEN_MAX 255
+#define LENGTH_QUOTE 0x1F
+#define NO_VALUE 0x00
+
+#define WSP_CODE_BUFFER_LEFT_LEN_MAX 1024
+#define WSP_CODE_BUFFER_RIGHT_LEN_MAX 2048
+
+#define AcStrlen(x) ((x == NULL) ? 0 : strlen(x))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+
+/*==================================================================================================
+ CLASS DEFINITIONS
+==================================================================================================*/
+class Sms3gpp2WapPushHandler
+{
+public:
+ static Sms3gpp2WapPushHandler* instance();
+
+ /* void registerPushCallback(); */
+ bool IsWapPushMsg(unsigned short dstport);
+
+ void copyDeliverData(sms_3gpp2_trans_addr_s *pAddr);
+ void handleWapPushMsg(const char *pUserData, int simIndex, int DataSize);
+ void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex);
+
+private:
+ Sms3gpp2WapPushHandler();
+ virtual ~Sms3gpp2WapPushHandler();
+
+ static Sms3gpp2WapPushHandler* pInstance;
+
+ SMS_WAP_APP_CODE_T getAppCode(const char *pPushHeader);
+
+ void handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex);
+ void handleSIMessage(char* pPushBody, int PushBodyLen, bool isText);
+ void handleSLMessage(char* pPushBody, int PushBodyLen, bool isText);
+ void handleCOMessage(char* pPushBody, int PushBodyLen, bool isText);
+ void handleDrmVer1(char* pPushBody, int PushBodyLen);
+ void getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText);
+ void createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo);
+ unsigned long convertXmlCharToSec(char* pDate);
+ msg_push_action_t convertSIActionStrToEnum(char* pAction);
+ msg_push_action_t convertSLActionStrToEnum(char* pAction);
+
+ unsigned long wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer);
+ unsigned long wspDecodeUintvar(unsigned long length, unsigned char* userVar);
+ void wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader);
+ unsigned long wspHeaderDecodeInteger(unsigned char* data);
+ void wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString);
+ unsigned long wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length);
+ char* wspExtendedDecodeType(char contentType);
+ void wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam);
+ void wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString);
+ void wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString);
+ void wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString);
+ void wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper);
+ void wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
+ void wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
+ void wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString);
+
+
+ sms_3gpp2_trans_addr_s tmpAddress;
+ /* SMS_TIMESTAMP_S tmpTimeStamp; */
+};
+
+#endif /* SMS_3GPP2_WAP_PUSH_HANDLER_H */
##########################################################
SET(SMS-PLUGIN-SRCS
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginUDCodec.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginParamCodec.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginTpduCodec.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginSatHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginWapPushHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginConcatHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginSetting.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginSimMsg.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginStorage.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginTransport.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginEventHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginUAManager.cpp
${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginCallback.cpp
- ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginMain.cpp
${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginDSHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginMain.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/SmsPluginStorage.cpp
+ # 3gpp module
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppUDCodec.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppParamCodec.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppTpduCodec.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppSatHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppCbMsgHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppWapPushHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppConcatHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppSetting.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppSimMsg.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppStorage.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppTransport.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppEventHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppUAManager.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp/Sms3gppTapiEventHandler.cpp
+ # 3gpp2 module
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2TapiEventHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2Codec.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2EventHandler.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2ParamCodec.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2Transport.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2UAManager.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2Setting.cpp
+ ${CMAKE_SOURCE_DIR}/plugin/sms_plugin/3gpp2/Sms3gpp2WapPushHandler.cpp
)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include/common
${CMAKE_SOURCE_DIR}/include/utils
${CMAKE_SOURCE_DIR}/include/externals
+ ${CMAKE_SOURCE_DIR}/include/framework
${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/3gpp/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/3gpp2/include
)
INCLUDE(FindPkgConfig)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_LIBRARY(${SMS-PLUGIN-LIB} SHARED ${SMS-PLUGIN-SRCS})
-TARGET_LINK_LIBRARIES(${SMS-PLUGIN-LIB} ${sms_plugin_pkgs_LDFLAGS} ${UTILS-LIB} ${EXTERNALS-LIB})
+TARGET_LINK_LIBRARIES(${SMS-PLUGIN-LIB} ${sms_plugin_pkgs_LDFLAGS} ${FW-HANDLER-LIB} ${UTILS-LIB} ${EXTERNALS-LIB})
INSTALL(TARGETS ${SMS-PLUGIN-LIB} LIBRARY DESTINATION ${LIBDIR})
* limitations under the License.
*/
-#include <glib.h>
-#include <pthread.h>
+#include <ITapiNetText.h>
+#include <tapi_common.h>
+#include <vconf.h>
#include "MsgDebug.h"
-#include "MsgCppTypes.h"
#include "MsgException.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginCbMsgHandler.h"
-#include "SmsPluginConcatHandler.h"
-#include "SmsPluginWapPushHandler.h"
-#include "SmsPluginSatHandler.h"
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginTpduCodec.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginSetting.h"
#include "MsgGconfWrapper.h"
-#include "MsgDevicedWrapper.h"
+
#include "SmsPluginCallback.h"
#include "SmsPluginDSHandler.h"
-
-extern bool isMemAvailable;
-
+#include "SmsPluginStorage.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppSetting.h"
+#include "Sms3gppTapiEventHandler.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gpp2Setting.h"
+#include "Sms3gpp2TapiEventHandler.h"
/*==================================================================================================
- FUNCTION IMPLEMENTATION
+ Methods of SmsPluginCallback
==================================================================================================*/
-void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventDeviceReady is called. : noti_id = [%s]", noti_id);
-
- try {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->setDeviceStatus(handle);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-SMS_NETWORK_STATUS_T convertTapiRespToSmsPlugin(int result)
-{
- SMS_NETWORK_STATUS_T sentStatus;
-
- /* Convert TAPI status -> SMS network status */
- switch ((TelSmsResponse_t)result) {
- case TAPI_NETTEXT_SENDSMS_SUCCESS :
- sentStatus = SMS_NETWORK_SEND_SUCCESS;
- break;
-
- case TAPI_NETTEXT_INVALID_MANDATORY_INFO :
- sentStatus = SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING;
- break;
-
- case TAPI_NETTEXT_DESTINAITION_OUTOFSERVICE :
- case TAPI_NETTEXT_TEMPORARY_FAILURE :
- case TAPI_NETTEXT_CONGESTION :
- case TAPI_NETTEXT_RESOURCES_UNAVAILABLE :
- case TAPI_NETTEXT_MESSAGE_NOT_COMPAT_PROTOCOL :
- case TAPI_NETTEXT_NETWORK_OUTOFORDER:
- sentStatus = SMS_NETWORK_SEND_FAIL_TEMPORARY;
- break;
-
- case TAPI_NETTEXT_MESSAGE_TRANSFER_REJECTED :
- sentStatus = SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED;
- break;
-
- case TAPI_NETTEXT_DEST_ADDRESS_FDN_RESTRICTED :
- case TAPI_NETTEXT_SCADDRESS_FDN_RESTRICTED :
- sentStatus = SMS_NETWORK_SEND_FAIL_FDN_RESTRICED;
- break;
- case TAPI_NETTEXT_ROUTING_NOT_AVAILABLE :
- sentStatus = SMS_NETWORK_SEND_FAIL_NO_ROUTING;
- break;
- default :
- sentStatus = SMS_NETWORK_SEND_FAIL;
- break;
- }
-
- return sentStatus;
-}
-
-void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSentStatus is called. : result = [0x%x]", result);
-
- SMS_NETWORK_STATUS_T sentStatus;
-
- TelSatMoSmCtrlIndData_t *moCtrlStatus = (TelSatMoSmCtrlIndData_t *)user_data;
-
- sentStatus = convertTapiRespToSmsPlugin(result);
-
- if (moCtrlStatus && sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED) {
- if (moCtrlStatus->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD)
- sentStatus = SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD;
- }
-
- if (result != TAPI_NETTEXT_SENDSMS_SUCCESS)
- MSG_INFO("sentStatus:[%d], tapi_result:[0x%x]", sentStatus, result);
-
- MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
-
- /* only temporary errors should be returned without calling handleSentStatus() in order to resend sms */
- if (sentStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY ||
- sentStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD ||
- sentStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
- SmsPluginTransport::instance()->setNetStatus(sentStatus);
- return;
- }
-
- if (sentStatus == SMS_NETWORK_SEND_FAIL) {
- int svc_type;
- tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
- if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G)
- sentStatus = SMS_NETWORK_SEND_PENDING;
- }
-
- /* Convert SMS status -> Messaging network status */
- msg_network_status_t netStatus;
-
- if (sentStatus == SMS_NETWORK_SEND_SUCCESS) {
- netStatus = MSG_NETWORK_SEND_SUCCESS;
- } else if (sentStatus == SMS_NETWORK_SENDING) {
- netStatus = MSG_NETWORK_SENDING;
- } else if (sentStatus == SMS_NETWORK_SEND_PENDING) {
- netStatus = MSG_NETWORK_SEND_PENDING;
- } else {
- netStatus = MSG_NETWORK_SEND_FAIL;
- }
-
- try {
- SmsPluginEventHandler::instance()->handleSentStatus(netStatus);
-
- SmsPluginTransport::instance()->setNetStatus(sentStatus);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-void TapiEventSatSmsSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_INFO("TapiEventSatSmsSentStatus is called. : result = [%d]", result);
-
- SMS_NETWORK_STATUS_T sentStatus;
-
- sentStatus = convertTapiRespToSmsPlugin(result);
-
- MSG_DEBUG("SMS Network Status = [%d]", sentStatus);
-
- if (sentStatus == SMS_NETWORK_SEND_FAIL && result != TAPI_NETTEXT_DEVICE_FAILURE) {
- int svc_type;
- tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
- if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G)
- sentStatus = SMS_NETWORK_SEND_PENDING;
- }
-
- try {
- SmsPluginSatHandler::instance()->ctrlSms(handle, sentStatus);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_SEC_DEBUG("TapiEventMsgIncoming is called. noti_id [%s]", noti_id);
-
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
- }
-#if 0
- SmsPluginCbMsgHandler::instance()->handleCbMsg(handle, NULL);
- return;
-#endif
- /* make a margin timeout(500ms) till suspending status */
- MsgDisplayLock();
-
- TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
-
- SMS_TPDU_S tpdu;
- memset(&tpdu, 0x00, sizeof(SMS_TPDU_S));
-
- /* Decode Incoming Message */
- SmsPluginTpduCodec::decodeTpdu(pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
-
- /* Print tpdu */
- if (tpdu.tpduType == SMS_TPDU_DELIVER) {
- MSG_DEBUG("############# SMS_TPDU_DELIVER Incoming decoded tpdu values ####################");
- MSG_DEBUG("tpdu.data.deliver.bMoreMsg : %d", tpdu.data.deliver.bMoreMsg);
- MSG_DEBUG("tpdu.data.deliver.bStatusReport : %d", tpdu.data.deliver.bStatusReport);
- MSG_DEBUG("tpdu.data.deliver.bHeaderInd : %d", tpdu.data.deliver.bHeaderInd);
- MSG_DEBUG("tpdu.data.deliver.bReplyPath : %d", tpdu.data.deliver.bReplyPath);
- MSG_DEBUG("tpdu.data.deliver.pid : %d", tpdu.data.deliver.pid);
- MSG_DEBUG("tpdu.data.deliver.dcs.bCompressed : %d", tpdu.data.deliver.dcs.bCompressed);
- MSG_DEBUG("tpdu.data.deliver.dcs.msgClass : %d", tpdu.data.deliver.dcs.msgClass);
- MSG_DEBUG("tpdu.data.deliver.dcs.codingScheme : %d", tpdu.data.deliver.dcs.codingScheme);
- MSG_DEBUG("tpdu.data.deliver.dcs.codingGroup : %d", tpdu.data.deliver.dcs.codingGroup);
- MSG_DEBUG("tpdu.data.deliver.dcs.bIndActive : %d", tpdu.data.deliver.dcs.bIndActive);
- MSG_SEC_DEBUG("tpdu.data.deliver.originAddress.address : %s", tpdu.data.deliver.originAddress.address);
- MSG_DEBUG("tpdu.data.deliver.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.deliver.timeStamp.time.absolute.year, tpdu.data.deliver.timeStamp.time.absolute.month, tpdu.data.deliver.timeStamp.time.absolute.day,
- tpdu.data.deliver.timeStamp.time.absolute.hour, tpdu.data.deliver.timeStamp.time.absolute.minute, tpdu.data.deliver.timeStamp.time.absolute.second);
- MSG_DEBUG("tpdu.data.deliver.userData.headerCnt : %d", tpdu.data.deliver.userData.headerCnt);
- MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
- MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
- MSG_DEBUG("#####################################################");
- } else if (tpdu.tpduType == SMS_TPDU_STATUS_REP) {
- MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
- MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
- MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
- MSG_DEBUG("tpdu.data.statusRep.bStatusReport : %d", tpdu.data.statusRep.bStatusReport);
- MSG_DEBUG("tpdu.data.statusRep.statusRep : %d", tpdu.data.statusRep.bHeaderInd);
- MSG_DEBUG("tpdu.data.statusRep.status : %02x", tpdu.data.statusRep.status);
- MSG_DEBUG("tpdu.data.statusRep.pid : %d", tpdu.data.statusRep.pid);
- MSG_DEBUG("tpdu.data.statusRep.dcs.bCompressed : %d", tpdu.data.statusRep.dcs.bCompressed);
- MSG_DEBUG("tpdu.data.statusRep.dcs.msgClass : %d", tpdu.data.statusRep.dcs.msgClass);
- MSG_DEBUG("tpdu.data.statusRep.dcs.codingScheme : %d", tpdu.data.statusRep.dcs.codingScheme);
- MSG_DEBUG("tpdu.data.statusRep.dcs.codingGroup : %d", tpdu.data.statusRep.dcs.codingGroup);
- MSG_SEC_DEBUG("tpdu.data.statusRep.recipAddress.address : %s", tpdu.data.statusRep.recipAddress.address);
- MSG_DEBUG("tpdu.data.statusRep.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.timeStamp.time.absolute.year, tpdu.data.statusRep.timeStamp.time.absolute.month, tpdu.data.statusRep.timeStamp.time.absolute.day,
- tpdu.data.statusRep.timeStamp.time.absolute.hour, tpdu.data.statusRep.timeStamp.time.absolute.minute, tpdu.data.statusRep.timeStamp.time.absolute.second);
- MSG_DEBUG("tpdu.data.statusRep.dischargeTime.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.dischargeTime.time.absolute.year, tpdu.data.statusRep.dischargeTime.time.absolute.month, tpdu.data.statusRep.dischargeTime.time.absolute.day,
- tpdu.data.statusRep.dischargeTime.time.absolute.hour, tpdu.data.statusRep.dischargeTime.time.absolute.minute, tpdu.data.statusRep.dischargeTime.time.absolute.second);
- MSG_DEBUG("tpdu.data.statusRep.userData.headerCnt : %d", tpdu.data.statusRep.userData.headerCnt);
- MSG_DEBUG("tpdu.data.statusRep.userData.length : %d", tpdu.data.statusRep.userData.length);
- MSG_DEBUG("tpdu.data.statusRep.userData.data : %s", tpdu.data.statusRep.userData.data);
- MSG_DEBUG("#####################################################");
- }
-
- MsgDisplayUnlock();
-
- try {
- if (tpdu.tpduType == SMS_TPDU_DELIVER) {
- if (tpdu.data.deliver.dcs.msgClass == SMS_MSG_CLASS_2) {
- /* For GCF test, 34.2.5.3 */
- SmsPluginSimMsg::instance()->setSmsData((const char*)pDataPackage->Sca, (const char *)pDataPackage->szData, pDataPackage->MsgLength);
- }
-
- if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
- SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true) {
- /* Call Concat Msg Handler */
- SmsPluginConcatHandler::instance()->handleConcatMsg(handle, &tpdu);
- } else {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleMsgIncoming(handle, &tpdu);
- }
- } else if (tpdu.tpduType == SMS_TPDU_STATUS_REP) {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleMsgIncoming(handle, &tpdu);
- }
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventCbMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_SEC_DEBUG("TapiEventCbMsgIncoming is called. noti_id [%s]", noti_id);
-
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
- }
-
- TelSmsCbMsg_t *pCbMsg = (TelSmsCbMsg_t*)data;
-
- try {
- SmsPluginCbMsgHandler::instance()->handleCbMsg(handle, pCbMsg);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventEtwsMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_SEC_DEBUG("TapiEventEtwsMsgIncoming is called. noti_id [%s]", noti_id);
-
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
- }
-
- TelSmsEtwsMsg_t *pEtwsMsg = (TelSmsEtwsMsg_t*)data;
-
- try {
- SmsPluginCbMsgHandler::instance()->handleEtwsMsg(handle, pEtwsMsg);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventDeliveryReportCNF is called. : result = [%d]", result);
-
- return;
-}
-
-
-void TapiEventGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventGetSimMsgCnt is called.");
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:[0x%x]", result);
- MSG_SIM_COUNT_S simCnt;
- memset(&simCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
- SmsPluginSimMsg::instance()->setSimMsgCntEvent(handle, &simCnt);
- return;
- }
-
- SmsPluginSimMsg::instance()->setSimMsgCntEvent(handle, (MSG_SIM_COUNT_S *)data);
-}
-
-
-void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::registerEvents()
{
- MSG_DEBUG("TapiEventGetSimMsg is called.");
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error!! result [0x%x]", result);
-
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
-
- return;
- }
-
-
- TelSmsData_t* pSmsTpdu = (TelSmsData_t*)data;
-
- int *simIdList = (int *)user_data;
-
- /* Reading TelSmsData_t */
- MSG_DEBUG("sim index %d", pSmsTpdu->SimIndex);
- MSG_DEBUG("status %d", pSmsTpdu->MsgStatus);
- MSG_DEBUG("sim msg [%s]", pSmsTpdu->SmsData.szData);
-
- /* Reading TelSmsDatapackageInfo_t */
- if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN) {
- MSG_DEBUG("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
-
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
-
- return;
- }
-
- SMS_TPDU_S tpdu;
-
- /* decode Tpdu */
- SmsPluginTpduCodec::decodeTpdu(pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
-
- MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
-
- bool bRead = false;
-
- /* set read status */
- if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ)
- bRead = true;
- else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD)
- bRead = false;
-
- if (tpdu.tpduType == SMS_TPDU_DELIVER) {
- if (tpdu.data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.deliver.pid == 0x11) {
- MSG_DEBUG("Unsupported message!!");
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
- return;
- }
-
- MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
- for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++) {
- /* Handler Concatenated Message */
- if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
- tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- SmsPluginConcatHandler::instance()->handleSimConcatMsg(handle, &tpdu, pSmsTpdu->SimIndex, bRead, simIdList);
- return;
- }
-
- if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_SPECIAL_SMS) {
- MSG_DEBUG("Unsupported Special SMS!!");
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
- return;
- }
- }
- } else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
- if (tpdu.data.submit.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.submit.pid == 0x11) {
- MSG_DEBUG("Unsupported message!!");
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
- return;
- }
- MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
-
- for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++) {
- /* Handler Concatenated Message */
- if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
- tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- SmsPluginConcatHandler::instance()->handleSimConcatMsg(handle, &tpdu, pSmsTpdu->SimIndex, bRead, simIdList);
- return;
- }
- }
- }
-
- /* Make MSG_MESSAGE_INFO_S */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- /* set storage id */
- msgInfo.storageId = MSG_STORAGE_SIM;
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo);
-
- msgInfo.sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (tpdu.tpduType == SMS_TPDU_DELIVER && tpdu.data.deliver.dcs.bMWI == true) {
- if (tpdu.data.deliver.pid == 0x20 && tpdu.data.deliver.originAddress.ton == SMS_TON_ALPHANUMERIC) {
- char keyName[MAX_VCONFKEY_NAME_LEN];
- char *voiceNumber = NULL;
- char *voiceAlphaId = NULL;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msgInfo.sim_idx);
- if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msgInfo.sim_idx);
- if (MsgSettingGetString(keyName, &voiceAlphaId) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- memset(msgInfo.addressList[0].addressVal, 0x00, sizeof(msgInfo.addressList[0].addressVal));
- memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
-
- if (voiceNumber) {
- snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNumber);
- free(voiceNumber);
- voiceNumber = NULL;
- }
-
- if (voiceAlphaId) {
- snprintf(msgInfo.addressList[0].displayName, sizeof(msgInfo.addressList[0].displayName), "%s", voiceAlphaId);
- free(voiceAlphaId);
- voiceAlphaId = NULL;
- }
-
- memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "Voice message");
- }
- } else if (tpdu.tpduType == SMS_TPDU_SUBMIT) {
- msgInfo.displayTime = time(NULL);
- }
-
- /* set read status */
- msgInfo.bRead = bRead;
-
- simIdList[0] = pSmsTpdu->SimIndex + 1;
- /* Print MSG_MESSAGE_INFO_S */
- MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
- MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
- MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
- MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
- MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
- MSG_SEC_DEBUG("msgInfo.addressList[0].displayName : %s", msgInfo.addressList[0].displayName);
- MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
- MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
- MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
- MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
- MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
- MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
- MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
- MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
- MSG_DEBUG("msgInfo.displayTime : %ld", msgInfo.displayTime);
- MSG_DEBUG("msgInfo.dataSize : %zu", msgInfo.dataSize);
- if (msgInfo.bTextSms == true)
- MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
- else
- MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
- MSG_DEBUG("msgInfo.sim_idx : %d", msgInfo.sim_idx);
- MSG_DEBUG("###############################################################");
-
- /* Call Event Handler */
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
-}
-
+ int count = SmsPluginDSHandler::instance()->getTelHandleCount();
-void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
+ for (int i = 1; i <= count; i++) {
+ int tRet = TAPI_API_SUCCESS;
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(i);
- int simId = -1;
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SMS_INCOM_MSG, tapiNotiSmsIncomMsg, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SMS_INCOM_MSG, tRet);
- if (data != NULL)
- simId = *((int*)data);
- else
- MSG_ERR("Data(SIM Msg ID) is NULL");
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SIM_REFRESHED, tapiNotiSimRefreshed, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SIM_REFRESHED, tRet);
- SmsPluginSimMsg::instance()->setSaveSimMsgEvent(handle, simId, result);
-}
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SMS_DEVICE_READY, tapiNotiSmsDeviceReady, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SMS_DEVICE_READY, tRet);
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_NETWORK_REGISTRATION_STATUS, tapiNotiNetworkRegistrationStatus, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_NETWORK_REGISTRATION_STATUS, tRet);
-void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSaveClass2Msg is called. result [%d]", result);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SMS_CB_INCOM_MSG, tapiNotiSmsCbIncomMsg, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SMS_CB_INCOM_MSG, tRet);
- int simId = -1;
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SMS_ETWS_INCOM_MSG, tapiNotiSmsEtwsIncomMsg, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SMS_ETWS_INCOM_MSG, tRet);
- if (data != NULL) {
- simId = *((int*)data);
- MSG_DEBUG("SIM Msg ID : %d", simId);
- } else {
- MSG_ERR("Data(SIM Msg ID) is NULL");
- }
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SAT_SEND_SMS, tapiNotiSatSendSms, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SAT_SEND_SMS, tRet);
- MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)user_data;
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SAT_MO_SM_CONTROL_RESULT, tapiNotiSatMoSmControlResult, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SAT_MO_SM_CONTROL_RESULT, tRet);
- SmsPluginSimMsg::instance()->setSaveClass2MsgEvent(handle, simId, result, pMsgInfo);
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SIM_STATUS, tapiNotiSimStatus, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SIM_STATUS, tRet);
- if (result == TAPI_NETTEXT_SENDSMS_SUCCESS)
- SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)simId, true);
- else
- SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
+ tRet = tel_register_noti_event(tHandle, TAPI_NOTI_SMS_MEMORY_STATUS, tapiNotiSmsMemoryStatus, NULL);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_register_noti_event() for (%s) failed: (%d)", TAPI_NOTI_SMS_MEMORY_STATUS, tRet);
- if (pMsgInfo) {
- if (pMsgInfo->addressList) {
- delete[] pMsgInfo->addressList;
- pMsgInfo->addressList = NULL;
}
- free(pMsgInfo);
- pMsgInfo = NULL;
- }
-}
-
-
-void TapiEventDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventDeleteSimMsg is called. result [%d]", result);
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSimMsg::instance()->setDelSimEvent(-1, false);
- return;
- }
-
- int sim_id = *((int*)data);
-
- SmsPluginSimMsg::instance()->setDelSimEvent(sim_id, true);
-}
-
-
-void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSetConfigData is called.");
-
- if (data == NULL) {
- MSG_ERR("Error. data is NULL. result:%d", result);
- SmsPluginSetting::instance()->setResultFromSim(false);
- return;
- }
-
- TelSmsSetResponse* responseType = (TelSmsSetResponse*)data;
-
- MSG_DEBUG("responseType : [%d]", *responseType);
-
- switch (*responseType) {
- case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
- MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
- break;
-
- case TAPI_NETTEXT_SETPARAMETERS_RSP :
- MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
- break;
-
- case TAPI_NETTEXT_CBSETCONFIG_RSP :
- MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
- break;
-
- case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
- MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
- break;
-
- case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
- MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
- break;
-
- default :
- MSG_DEBUG("Unknown Response is called [%d]", *responseType);
- break;
}
+ MsgSettingRegVconfCBCommon(VCONFKEY_DNET_STATE, vconfDnetStateChanged);
- bool bRet = true;
-
- MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
-
- if ((TelSmsCause_t)result != TAPI_NETTEXT_SUCCESS) bRet = false;
-
- if (*responseType == TAPI_NETTEXT_SETMESSAGESTATUS_RSP)
- SmsPluginSimMsg::instance()->setSimEvent(0, bRet);
- else
- SmsPluginSetting::instance()->setResultFromSim(bRet);
}
-void TapiEventGetParamCnt(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::deRegisterEvents()
{
- MSG_DEBUG("TapiEventGetParamCnt is called.");
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSetting::instance()->setParamCntEvent(0);
- return;
- }
-
- int paramCnt = 0;
- paramCnt = *((int*)data);
-
- SmsPluginSetting::instance()->setParamCntEvent(paramCnt);
+ MsgSettingRemoveVconfCBCommon(VCONFKEY_DNET_STATE, vconfDnetStateChanged);
}
-
-void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSmsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventGetConfigData is called.");
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
- return;
- }
-
- TelSmsParams_t* smsParam = (TelSmsParams_t*)data;
-
- int alphaIdLen = 0;
- int addrLen = 0;
- MSG_SMSC_DATA_S smscData = {0, };
-
- /*Check Alpha ID value*/
- alphaIdLen = smsParam->AlphaIdLen;
- MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
-
- if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX) {
- MSG_DEBUG("Wrong Alpha ID Length[%d]", alphaIdLen);
-
- SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
+ MSG_WARN("noti_id: (%s)", noti_id);
- return;
- }
-
-
- /*Check Address value*/
- addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
-
- if (addrLen > SMSC_ADDR_MAX) {
- MSG_DEBUG("addrLen is too long: %d", addrLen);
- SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
- return;
- } else if (addrLen < 2) {
- MSG_DEBUG("addrLen is too short: %d", addrLen);
- SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
- return;
- }
-
- MSG_DEBUG("addrLen : %d", addrLen);
-
- /*SMSP Parameter Indicator value*/
- MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
-
- /*Get SMSC Address*/
- if (0x00 == (0x02 & smsParam->ParamIndicator)) {
- MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
-
- MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
- MSG_DEBUG("NPI : %d", smsParam->TpSvcCntrAddr.Npi);
-
- smscData.smscAddr.ton = smsParam->TpSvcCntrAddr.Ton;
- smscData.smscAddr.npi = smsParam->TpSvcCntrAddr.Npi;
-
- SmsPluginParamCodec paramCodec;
-
- memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
- paramCodec.decodeSMSC(smsParam->TpSvcCntrAddr.szDiallingNum, addrLen, smscData.smscAddr.ton, smscData.smscAddr.address);
-
- MSG_SEC_DEBUG("SMSC Address : [%s]", smscData.smscAddr.address);
-
- memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
- memcpy(smscData.name, smsParam->szAlphaId, alphaIdLen);
- smscData.name[alphaIdLen] = '\0';
-
- MSG_SEC_DEBUG("SMSC Name : [%s]", smscData.name);
- } else {
- MSG_DEBUG("SMSC Address is not present");
-
- SmsPluginSetting::instance()->setParamEvent(handle, NULL, -1, false);
-
- return;
- }
-
- /*Get the PID value*/
- if (0x00 == (0x04 & smsParam->ParamIndicator)) {
- SMS_PID_T pid = (SMS_PID_T)smsParam->TpProtocolId;
-
- MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
-
- switch (pid) {
- case SMS_PID_NORMAL:
- smscData.pid = MSG_PID_TEXT;
- break;
- case SMS_PID_VOICE:
- smscData.pid = MSG_PID_VOICE;
- break;
- case SMS_PID_TELEX:
- smscData.pid = MSG_PID_FAX;
- break;
- case SMS_PID_x400:
- smscData.pid = MSG_PID_X400;
- break;
- case SMS_PID_ERMES:
- smscData.pid = MSG_PID_ERMES;
- break;
- case SMS_PID_EMAIL:
- smscData.pid = MSG_PID_EMAIL;
- break;
- default:
- smscData.pid = MSG_PID_TEXT;
- break;
+ if (SmsPluginDSHandler::instance()->getHandleType(handle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ TelSmsDatapackageInfo_t* smsDataPackage = static_cast<TelSmsDatapackageInfo_t *>(data);
+ if (smsDataPackage->format == TAPI_NETTEXT_NETTYPE_3GPP || smsDataPackage->format == 0) {
+ Sms3gppTapiEventHandler::NotiSmsIncomMsg(handle, noti_id, data, user_data);
+ } else if (smsDataPackage->format == TAPI_NETTEXT_NETTYPE_3GPP2) {
+ Sms3gpp2TapiEventHandler::NotiSmsIncomMsg(handle, noti_id, data, user_data);
+ } else {
+ MSG_ERR("Invalid sms format: (%d)", smsDataPackage->format);
}
-
- MSG_DEBUG("smscData.pid : %d", smscData.pid);
- } else {
- MSG_DEBUG("PID is not present");
- smscData.pid = MSG_PID_TEXT;
- MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
- }
-
-#if 0
- /*Get the DCS value*/
- if (0x00 == (0x08 & smsParam->ParamIndicator)) {
- smscList.smscData[index].dcs = smsParam->TpDataCodingScheme;
- MSG_DEBUG("dcs : %d", smscList.smscData[index].dcs);
- } else {
- smscList.smscData[index].dcs = MSG_ENCODE_GSM7BIT;
- MSG_DEBUG("DCS is not present");
- }
-#endif
-
- /*Get the ValidityPeriod value*/
- if (0x00 == (0x10 & smsParam->ParamIndicator)) {
- smscData.valPeriod = smsParam->TpValidityPeriod;
- MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
} else {
- smscData.valPeriod = 0;
-
- MSG_DEBUG("Validity Period is not present");
+ Sms3gpp2TapiEventHandler::NotiSmsIncomMsg(handle, noti_id, data, user_data);
}
-
- SmsPluginSetting::instance()->setParamEvent(handle, &smscData, (int)smsParam->RecordIndex, true);
}
-
-void TapiEventSetSmscInfo(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSmsCbIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventSetSmscInfo is called. result=[%d]", result);
-
- if (result != TAPI_API_SUCCESS)
- SmsPluginSetting::instance()->setResultFromSim(false);
- else
- SmsPluginSetting::instance()->setResultFromSim(true);
-}
-
-
-void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventGetCBConfig is called.");
-
- MSG_CBMSG_OPT_S cbOpt = {0};
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (result != TAPI_API_SUCCESS || data == NULL || simIndex == 0) {
- MSG_ERR("Error. data is NULL. result:0x%x, simIndex:%d", result, simIndex);
-
- SmsPluginSetting::instance()->setCbConfigEvent(handle, NULL, false);
-
- return;
- }
-
- TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)data;
-
- cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
+ MSG_WARN("noti_id: (%s)", noti_id);
- cbOpt.maxSimCnt = TAPI_NETTEXT_SMS_CBMI_LIST_SIZE_MAX;
+ MSG_ERR_RET_M(SmsPluginDSHandler::instance()->getHandleType(handle) != SmsPluginDSHandler::HandleType::H_3GPP, "Invalid tapi handle type!");
- cbOpt.simIndex = simIndex;
-
- MSG_DEBUG("Sim Index [%d], Receive [%d], Max SIM Count [%d]", simIndex, cbOpt.bReceive, cbOpt.maxSimCnt);
-
- cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
-
- if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX) {
- MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
- cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
- }
-
- MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
-
- for (int i = 0; i < cbOpt.channelData.channelCnt; i++) {
- cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp.Selected;
- cbOpt.channelData.channelInfo[i].from = pCBConfig->MsgIDs[i].Net3gpp.FromMsgId;
- cbOpt.channelData.channelInfo[i].to = pCBConfig->MsgIDs[i].Net3gpp.ToMsgId;
- memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
-
- MSG_DEBUG("Channel FROM [%d], Channel TO [%d] ", cbOpt.channelData.channelInfo[i].from, cbOpt.channelData.channelInfo[i].to);
- }
-
- SmsPluginSetting::instance()->setCbConfigEvent(handle, &cbOpt, true);
+ Sms3gppTapiEventHandler::NotiSmsCbIncomMsg(handle, noti_id, data, user_data);
}
-void TapiEventSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSmsEtwsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventSetMailboxInfo is called. result = [%d]", result);
+ MSG_WARN("noti_id: (%s)", noti_id);
- bool bRet = true;
- bool *bShowError = (bool*)user_data;
+ MSG_ERR_RET_M(SmsPluginDSHandler::instance()->getHandleType(handle) != SmsPluginDSHandler::HandleType::H_3GPP, "Invalid tapi handle type!");
- if (result != TAPI_SIM_ACCESS_SUCCESS && *bShowError == true)
- bRet = false;
-
- SmsPluginSetting::instance()->setResultFromSim(bRet);
+ Sms3gppTapiEventHandler::NotiSmsEtwsIncomMsg(handle, noti_id, data, user_data);
}
-void TapiEventGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventGetMailboxInfo is called. result=[%d]", result);
-
- if (result == TAPI_API_SIM_SERVICE_IS_DISABLED) {
- MSG_INFO("result is TAPI_API_SIM_SERVICE_IS_DISABLED");
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
- char *voiceNum = NULL;
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
- if (MsgSettingGetString(keyName, &voiceNum) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
+ MSG_WARN("noti_id: (%s)", noti_id);
- if (voiceNum && strlen(voiceNum)) {
- MSG_DEBUG("Voice mailbox number exist in vconf");
- SmsPluginSetting::instance()->setMailboxInfoEvent(handle, NULL, true, false);
- free(voiceNum);
- voiceNum = NULL;
- return;
- } else {
- SmsPluginSetting::instance()->setMailboxInfoEvent(handle, NULL, false, false);
- if (voiceNum) {
- free(voiceNum);
- voiceNum = NULL;
- }
- return;
- }
- } else if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL.");
- /*If result is not TAPI_SIM_ACCESS_SUCCESS, set bMbdnEnable to false*/
- SmsPluginSetting::instance()->setMailboxInfoEvent(handle, NULL, false, false);
- return;
- }
-
- TelSimMailboxList_t *list = (TelSimMailboxList_t *)data;
- SMS_SIM_MAILBOX_LIST_S mbList = {0, };
-
- if (list->count <= 0) {
- MSG_INFO("Mailbox list is empty");
- SmsPluginSetting::instance()->setMailboxInfoEvent(handle, NULL, false, true);
- return;
- }
-
- mbList.count = list->count;
-
- for (int i = 0; i < mbList.count; i++) {
- mbList.list[i].b_cphs = list->list[i].b_cphs;
- mbList.list[i].alpha_id_max_len = list->list[i].alpha_id_max_len;
- mbList.list[i].mb_type = list->list[i].mb_type;
- mbList.list[i].profile_num = list->list[i].profile_num;
- mbList.list[i].rec_index = list->list[i].rec_index;
- mbList.list[i].ton = list->list[i].ton;
- mbList.list[i].npi = list->list[i].npi;
- snprintf(mbList.list[i].alpha_id, sizeof(mbList.list[i].alpha_id), "%s", list->list[i].alpha_id);
- snprintf(mbList.list[i].num, sizeof(mbList.list[i].num), "%s", list->list[i].num);
- mbList.list[i].cc_id = list->list[i].cc_id;
- mbList.list[i].ext1_id = list->list[i].ext1_id;
- mbList.list[i].num_len = strlen(mbList.list[i].num);
- }
-
- SmsPluginSetting::instance()->setMailboxInfoEvent(handle, &mbList, true, true);
-}
+ MSG_ERR_RET_M(SmsPluginDSHandler::instance()->getHandleType(handle) != SmsPluginDSHandler::HandleType::H_3GPP, "Invalid tapi handle type!");
-void TapiEventSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSetMwiInfo is called. result = [%d]", result);
+ Sms3gppTapiEventHandler::NotiSatSendSms(handle, noti_id, data, user_data);
}
-void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSatMoSmControlResult(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventGetMwiInfo is called.");
-
- if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSetting::instance()->setMwiInfoEvent(handle, NULL, false);
-
- return;
- }
-
- TelSimMessageWaitingResp_t *MwiInfo = (TelSimMessageWaitingResp_t *)data;
- SMS_SIM_MWI_INFO_S simMwiInfo = {0, };
+ MSG_WARN("noti_id: (%s)", noti_id);
- memcpy(&simMwiInfo, MwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
+ MSG_ERR_RET_M(SmsPluginDSHandler::instance()->getHandleType(handle) != SmsPluginDSHandler::HandleType::H_3GPP, "Invalid tapi handle type!");
- SmsPluginSetting::instance()->setMwiInfoEvent(handle, &simMwiInfo, true);
+ Sms3gppTapiEventHandler::NotiSatMoSmControlResult(handle, noti_id, data, user_data);
}
-void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSimStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
-
- bool bRet = false;
- bool bDisableGroupMessage = false;
+ MSG_WARN("noti_id: (%s)", noti_id);
- if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSetting::instance()->setResultFromSim(bRet);
- return;
- }
-
- TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
-
- for (int i = 0; i < list->count; i++) {
- if (list->list[i].num[0] != '\0') {
- char keyName[MAX_VCONFKEY_NAME_LEN];
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
+ MSG_ERR_RET_M(SmsPluginDSHandler::instance()->getHandleType(handle) != SmsPluginDSHandler::HandleType::H_3GPP, "Invalid tapi handle type!");
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, simIndex);
-
- if (MsgSettingSetString(keyName, list->list[i].num) == MSG_SUCCESS) {
- MSG_SEC_INFO("Get MSISDN from SIM : [%s]", list->list[i].num);
- bRet = true;
- } else {
- MSG_DEBUG("Getting MSISDN is failed!");
- }
- break;
- } else {
- bDisableGroupMessage = true;
- }
- }
-
- int tmpVal = 0;
- if (MsgSettingGetInt(MMS_RECV_GROUP_MESSAGE, &tmpVal) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetInt() is failed");
-
- /* If the value from MMS_RECV_GROUP_MESSAGE is less than 0, it means group message mode is disabled. */
- if ((tmpVal < 0 && bDisableGroupMessage == false) || (tmpVal > 0 && bDisableGroupMessage == true)) {
- if (MsgSettingSetInt(MMS_RECV_GROUP_MESSAGE, -tmpVal))
- MSG_ERR("Error to set config data [%s]", MMS_RECV_GROUP_MESSAGE);
- }
-
- SmsPluginSetting::instance()->setResultFromSim(bRet);
+ Sms3gppTapiEventHandler::NotiSimStatus(handle, noti_id, data, user_data);
}
-void TapiEventGetSimServiceTable(TapiHandle *handle, int result, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventGetSimServiceTable is called.");
-
- TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
- TelSimServiceTable_t *svct = (TelSimServiceTable_t *)data;
-
- bool bRet = true;
-
- if (access_rt != TAPI_SIM_ACCESS_SUCCESS || svct == NULL) {
- MSG_ERR("Error. data is NULL and access_rt [%d] failed", access_rt);
- SmsPluginSetting::instance()->setResultFromSim(false);
- return;
- }
-
- msg_error_t err = MSG_SUCCESS;
-
- char sstKey[128];
- char moCtrlKey[128];
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- memset(sstKey, 0x00, sizeof(sstKey));
- snprintf(sstKey, sizeof(sstKey), "%s/%d", MSG_SIM_SERVICE_TABLE, simIndex);
-
- memset(moCtrlKey, 0x00, sizeof(moCtrlKey));
- snprintf(moCtrlKey, sizeof(moCtrlKey), "%s/%d", MSG_SIM_MO_CONTROL, simIndex);
-
- if (svct->sim_type == TAPI_SIM_CARD_TYPE_GSM) {
- if (svct->table.sst.service[TAPI_SIM_SST_SMS] == 1) {
- err = MsgSettingSetBool(sstKey, true);
- } else {
- err = MsgSettingSetBool(sstKey, false);
- }
- MSG_DEBUG("Setting result = [%d]", err);
-
- if (svct->table.sst.service[TAPI_SIM_SST_MO_SMS_CTRL_BY_SIM] == 1) {
- err = MsgSettingSetBool(moCtrlKey, true);
- } else {
- err = MsgSettingSetBool(moCtrlKey, false);
- }
- MSG_DEBUG("Setting result = [%d]", err);
-
- } else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) {
- if (svct->table.ust.service[TAPI_SIM_UST_SMS] == 1) {
- err = MsgSettingSetBool(sstKey, true);
- } else {
- err = MsgSettingSetBool(sstKey, false);
- }
- MSG_DEBUG("Setting result = [%d]", err);
-
- if (svct->table.ust.service[TAPI_SIM_UST_MO_SMS_CTRL] == 1) {
- err = MsgSettingSetBool(moCtrlKey, true);
- } else {
- err = MsgSettingSetBool(moCtrlKey, false);
- }
- MSG_DEBUG("Setting result = [%d]", err);
+ MSG_WARN("noti_id: (%s)", noti_id);
+ if (SmsPluginDSHandler::instance()->getHandleType(handle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ Sms3gppTapiEventHandler::NotiSimRefreshed(handle, noti_id, data, user_data);
} else {
- MSG_DEBUG("Unknown SIM type value");
- }
-
- SmsPluginSetting::instance()->setResultFromSim(bRet);
-}
-
-void TapiEventSatSmsRefresh(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSatSmsRefresh is called.");
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- return;
- }
-
- try {
- SmsPluginSatHandler::instance()->refreshSms(handle, data);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
+ Sms3gpp2TapiEventHandler::NotiSimRefreshed(handle, noti_id, data, user_data);
}
}
-
-void TapiEventSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSatSendSms is called.");
-
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
- }
-
- try {
- SmsPluginSatHandler::instance()->sendSms(handle, data);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-
-void TapiEventSatMoSmsCtrl(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSmsDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
+ MSG_WARN("noti_id: (%s)", noti_id);
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
- }
-
- try {
- SmsPluginSatHandler::instance()->ctrlSms(handle, data);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-}
-
-void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("Tapi result is [%d]", result);
- if (result == TAPI_API_SUCCESS)
- isMemAvailable = true;
-}
-
-void TapiEventSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_DEBUG("TapiEventSetMsgStatus is called. result [%d]", result);
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
- return;
- }
-
- msg_sim_id_t sim_id = *((msg_sim_id_t *)user_data);
-
- SmsPluginSimMsg::instance()->setSimEvent(sim_id, true);
-}
-
-
-void TapiEventGetMeImei(TapiHandle *handle, int result, void *data, void *user_data)
-{
- MSG_SEC_DEBUG("TapiEventGetMeImei is called. result [%d]", result);
-
- if (result != TAPI_API_SUCCESS || data == NULL) {
- MSG_ERR("Error. data is NULL. result:0x%x", result);
- SmsPluginSetting::instance()->setResultImei(false, NULL);
- return;
+ if (SmsPluginDSHandler::instance()->getHandleType(handle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ Sms3gppTapiEventHandler::NotiSmsDeviceReady(handle, noti_id, data, user_data);
+ } else {
+ Sms3gpp2TapiEventHandler::NotiSmsDeviceReady(handle, noti_id, data, user_data);
}
-
- char *tmpImei = (char *)data;
-
- SmsPluginSetting::instance()->setResultImei(true, tmpImei);
}
-
-void TapiEventSimStatusChange(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiNetworkRegistrationStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventSimStatusChange is called.");
+ MSG_WARN("noti_id: (%s)", noti_id);
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
+ if (SmsPluginDSHandler::instance()->getHandleType(handle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ Sms3gppTapiEventHandler::NotiNetworkRegistrationType(handle, noti_id, data, user_data);
+ } else {
+ Sms3gpp2TapiEventHandler::NotiNetworkRegistrationType(handle, noti_id, data, user_data);
}
-
- int status = *(int *)data;
-
- MSG_DEBUG("SIM Status [%d]", status);
-
- if (status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
- MSG_INFO("SIM Initialize by sim status change callback");
- SmsPluginSetting::instance()->setSimChangeStatus(handle, false);
- }
}
-void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+void SmsPluginCallbacks::tapiNotiSmsMemoryStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
{
- MSG_DEBUG("TapiEventNetworkStatusChange is called.");
+ MSG_WARN("noti_id: (%s)", noti_id);
- if (data == NULL) {
- MSG_ERR("Error. data is NULL.");
- return;
- }
-
- TelNetworkServiceType_t *type = (TelNetworkServiceType_t *)data;
-
- MSG_INFO("network status type [%d]", *type);
+ MSG_ERR_RET_M(SmsPluginDSHandler::instance()->getHandleType(handle) != SmsPluginDSHandler::HandleType::H_3GPP, "Invalid tapi handle type!");
- if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) {
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleResendMessage();
- }
+ Sms3gppTapiEventHandler::NotiSmsMemoryStatus(handle, noti_id, data, user_data);
}
-void TapiEventSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
+void SmsPluginCallbacks::vconfDnetStateChanged(keynode_t *key, void* data)
{
- MSG_DEBUG("TapiEventSimRefreshed is called.");
-
- SmsPluginSetting::instance()->SimRefreshCb(handle);
-}
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginCallback - Member Functions
-==================================================================================================*/
-SmsPluginCallback* SmsPluginCallback::pInstance = NULL;
-
-
-SmsPluginCallback::SmsPluginCallback()
-{
-}
-
-
-SmsPluginCallback::~SmsPluginCallback()
-{
- if (pInstance != NULL) {
- delete pInstance;
- pInstance = NULL;
+ int dnet_state = 0;
+ if (MsgSettingGetInt(VCONFKEY_DNET_STATE, &dnet_state) != MSG_SUCCESS) {
+ MSG_ERR("MsgSettingGetInt() failed!");
}
-}
-
-
-SmsPluginCallback* SmsPluginCallback::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginCallback();
-
- return pInstance;
-}
-
-void SmsPluginCallback::registerEvent()
-{
- TapiHandle *pTapiHandle;
-
- int count = SmsPluginDSHandler::instance()->getTelHandleCount();
-
- for (int i = 1; i <= count; ++i) {
- pTapiHandle = SmsPluginDSHandler::instance()->getTelHandle(i);
-/* int simIndex = SmsPluginDSHandler::instance()->getSimIndex(pTapiHandle); */
-
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_DEVICE_READY, TapiEventDeviceReady, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_DEVICE_READY);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_INCOM_MSG, TapiEventMsgIncoming, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_INCOM_MSG);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_CB_INCOM_MSG, TapiEventCbMsgIncoming, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_CB_INCOM_MSG);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_ETWS_INCOM_MSG, TapiEventEtwsMsgIncoming, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SMS_ETWS_INCOM_MSG);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_SEND_SMS, TapiEventSatSendSms, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SAT_SEND_SMS);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_MO_SM_CONTROL_RESULT, TapiEventSatMoSmsCtrl, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SAT_MO_SM_CONTROL_RESULT);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_STATUS, TapiEventSimStatusChange, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_STATUS);
- if (tel_register_noti_event(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, TapiEventNetworkStatusChange, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_PROP_NETWORK_SERVICE_TYPE);
- if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_REFRESHED, TapiEventSimRefreshed, NULL) != TAPI_API_SUCCESS)
- MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_REFRESHED);
-/* if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_REFRESH, TapiEventSatSmsRefresh, NULL) != TAPI_API_SUCCESS) */
-/* MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SAT_REFRESH); */
-/* if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_MO_SMS_CTRL, TapiEventSatMoSmsCtrl, NULL) != TAPI_API_SUCCESS) */
-/* MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SAT_MO_SMS_CTRL); */
+ if (dnet_state > VCONFKEY_DNET_OFF) {
+ Sms3gppEventHandler::instance()->handleResendMessage();
}
}
-
-
-void SmsPluginCallback::deRegisterEvent()
-{
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <time.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "MsgUtilFile.h"
-#include "MsgUtilStorage.h"
-#include "SmsPluginUDCodec.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginCbMsgHandler.h"
-#include "SmsPluginDSHandler.h"
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
-==================================================================================================*/
-SmsPluginCbMsgHandler* SmsPluginCbMsgHandler::pInstance = NULL;
-
-
-SmsPluginCbMsgHandler::SmsPluginCbMsgHandler()
-{
- pageList.clear();
-}
-
-
-SmsPluginCbMsgHandler::~SmsPluginCbMsgHandler()
-{
-}
-
-
-SmsPluginCbMsgHandler* SmsPluginCbMsgHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginCbMsgHandler();
-
- return pInstance;
-}
-
-
-void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMsg)
-{
- MSG_BEGIN();
-
-#if 0
- char temp[1000]= {0x01, 0xa4, 0x1f, 0x51, 0x10, 0x11, 0x02, 0xea, 0x30, 0x30, 0xa8, 0x30, 0xea, 0x30, 0xa2, 0x30, 0xe1, 0x30, 0xfc, 0x30, 0xeb, 0x91, 0x4d, 0x4f, 0xe1, 0x30, 0xc6, 0x30, 0xb9, 0x30, 0xc8, 0x00, 0x0d, 0x00, 0x0a, 0x30, 0x53, 0x30, 0x8c, 0x30, 0x6f, 0x8a, 0x66, 0x9a, 0x13, 0x75, 0x28, 0x30, 0x6e, 0x30, 0xe1, 0x30, 0xc3, 0x30, 0xbb, 0x30, 0xfc, 0x30, 0xb8, 0x30, 0x67, 0x30, 0x59, 0x30, 0x02, 0x00, 0x0d, 0x00, 0x0a, 0xff, 0x08, 0x00, 0x32, 0x00, 0x30, 0x00, 0x31, 0x00, 0x33, 0x00, 0x2f, 0x00, 0x31, 0x00, 0x31, 0x00, 0x2f, 0x00, 0x32, 0x52, 0xea, 0x30, 0x00, 0x37, 0x00, 0x20, 0x00, 0x31, 0x00, 0x35, 0x00, 0x3a, 0x00, 0x34, 0x00, 0x34, 0xff, 0x09, 0x00, 0x0d, 0x00, 0x0a, 0xff, 0x08, 0x30, 0xa8, 0x30, 0xea, 0x30, 0xa2, 0x5e, 0x02, 0xff, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22};
- TelSmsEtwsMsg_t *pCbMsg = (TelSmsEtwsMsg_t *)calloc(1, sizeof(TelSmsEtwsMsg_t));
- pCbMsg->Length = 173;
- pCbMsg->EtwsMsgType = (TelSmsEtwsMsgType_t)2;
- memcpy(pCbMsg->szMsgData, temp, pCbMsg->Length);
-
- SMS_CB_NETWORK_TYPE_T type = pCbMsg->EtwsMsgType;
- SMS_CBMSG_PAGE_S CbMsgPage = {0};
-
- switch (type) {
- case SMS_CB_NETWORK_TYPE_2G_GSM :
- Decode2gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
- break;
-
- case SMS_CB_NETWORK_TYPE_3G_UMTS :
- Decode3gCbMsg((TelSmsCbMsg_t *)pCbMsg, &CbMsgPage);
- break;
- }
-#else
- SMS_CB_NETWORK_TYPE_T type = pCbMsg->CbMsgType;
- SMS_CBMSG_PAGE_S CbMsgPage = {0};
-
- switch (type) {
- case SMS_CB_NETWORK_TYPE_2G_GSM :
- Decode2gCbMsg(pCbMsg, &CbMsgPage);
- break;
-
- case SMS_CB_NETWORK_TYPE_3G_UMTS :
- Decode3gCbMsg(pCbMsg, &CbMsgPage);
- break;
- }
-#endif
- /* Check CB Msg Options */
- bool bJavaMsg = false;
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (!checkCbOpt(&CbMsgPage, &bJavaMsg, simIndex)) {
- MSG_DEBUG("The CB Msg is not supported by option.");
- return;
- }
-
- if (bJavaMsg == true) {
- MSG_DEBUG("JAVA CB Msg.");
- CbMsgPage.cbMsgType = SMS_CBMSG_TYPE_JAVACBS;
- }
-
-
- /* Check CB Pages */
- unsigned char pageCnt = checkCbPage(&CbMsgPage);
-
- if (pageCnt == CbMsgPage.pageHeader.totalPages) {
- MSG_DEBUG("RECEIVED LAST MSG : %d", pageCnt);
-
- SMS_CBMSG_S *cbMsg = NULL;
- unique_ptr<SMS_CBMSG_S*, void(*)(SMS_CBMSG_S**)> buf(&cbMsg, unique_ptr_deleter);
- cbMsg = (SMS_CBMSG_S *)new char[sizeof(SMS_CBMSG_S)];
- memset(cbMsg, 0x00, sizeof(SMS_CBMSG_S));
-
- MSG_MESSAGE_INFO_S msgInfo;
-
- /** initialize msgInfo */
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- /* Make CB Msg Structure */
- MakeCbMsg(&CbMsgPage, cbMsg);
-
- /* Convert to MSG_MESSAGE_INFO_S */
- convertCbMsgToMsginfo(cbMsg, &msgInfo, simIndex);
-
- /* Add CB Msg into DB */
- msg_error_t err = MSG_SUCCESS;
-
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- bool is_duplicated = SmsPluginStorage::instance()->isDuplicatedCBMsg(&msgInfo);
- if (is_duplicated == false) {
- MSG_CB_MSG_S cbOutMsg = {0, };
-
- /*cbOutMsg.type = MSG_CB_SMS; */
- cbOutMsg.type = msgInfo.msgType.subType;
- cbOutMsg.receivedTime = cbMsg->recvTime;
- cbOutMsg.serialNum = cbMsg->serialNum;
- cbOutMsg.messageId = cbMsg->msgId;
- cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData;
- memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText));
-
- cbOutMsg.cbTextLen = convertTextToUtf8((unsigned char*)cbOutMsg.cbText, sizeof(cbOutMsg.cbText), cbMsg);
- memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type));
- memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3);
- err = SmsPluginEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, &msgInfo);
- if (err != MSG_SUCCESS)
- MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
- } else {
- MSG_DEBUG("This cb message is duplicated");
- }
- } else {
- MSG_WARN("checkMessage() Error !! [%d]", err);
- }
-
-#if 0
- /* insert message-id to internal CB message table */
- SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
- err = storageHandler->insertReceivedCBMessage(CbMsgPage);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("insertReceivedCBMessage() Error !! [%d]", err);
- }
-#endif
- /* Remove From List */
- removeFromPageList(&CbMsgPage);
- }
- MSG_END();
-}
-
-
-void SmsPluginCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *pEtwsMsg)
-{
- MSG_BEGIN();
- msg_error_t err = MSG_SUCCESS;
- TelSmsEtwsMsgType_t type = pEtwsMsg->EtwsMsgType;
- SMS_ETWS_PRIMARY_S etwsPn = {0, };
- MSG_CB_MSG_S cbOutMsg = {0, };
-
- if (type != TAPI_NETTEXT_ETWS_PRIMARY) {
- MSG_DEBUG("The Etws secondary Message");
- handleCbMsg(handle, (TelSmsCbMsg_t *)pEtwsMsg);
- return;
- }
- DecodeEtwsMsg(pEtwsMsg, &etwsPn);
-
- cbOutMsg.type = MSG_ETWS_SMS;
- cbOutMsg.receivedTime = etwsPn.recvTime;
- cbOutMsg.serialNum = encodeCbSerialNum(etwsPn.serialNum);
- cbOutMsg.messageId = etwsPn.msgId;
- cbOutMsg.etwsWarningType = etwsPn.warningType;
- memcpy (cbOutMsg.etwsWarningSecurityInfo, etwsPn.warningSecurityInfo, sizeof(cbOutMsg.etwsWarningSecurityInfo));
-
- err = SmsPluginEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, NULL);
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
-
- MSG_END();
-}
-
-
-void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage)
-{
- unsigned char cbData[pCbMsg->Length+1] = {0};
- memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
- cbData[pCbMsg->Length] = '\0';
-
- /* print cb data */
- MSG_INFO("Received CB length:%d", pCbMsg->Length);
- char cbDataTmp[(pCbMsg->Length*2)+1];
- memset(cbDataTmp, 0x00, sizeof(cbDataTmp));
-
- for (int i = 0; i < pCbMsg->Length; i++) {
- snprintf(cbDataTmp+(i*2), sizeof(cbDataTmp)-(i*2), "%02X", cbData[i]);
- }
- MSG_INFO("[%s]", cbDataTmp);
-
- pCbPage->cbMsgType = SMS_CBMSG_TYPE_CBS;
-
- /* Serial Number */
- pCbPage->pageHeader.serialNum.geoScope = (cbData[0] & 0xC0) >> 6;
-
- pCbPage->pageHeader.serialNum.msgCode = (cbData[0] & 0x3F) << 4;
- pCbPage->pageHeader.serialNum.msgCode |= (cbData[1] & 0xF0) >> 4;
-
- pCbPage->pageHeader.serialNum.updateNum = cbData[1] & 0x0F;
-
- MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
-
- pCbPage->pageHeader.msgId = (cbData[2] << 8) | cbData[3];
-
- MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
-
- /* DCS */
- decodeCbMsgDCS(cbData[4], (unsigned char*)cbData + 6, &(pCbPage->pageHeader.dcs));
-
- /* Page Parameter */
- pCbPage->pageHeader.totalPages = cbData[5] & 0x0F;
- pCbPage->pageHeader.page = (cbData[5] & 0xF0) >> 4;
-
- if (pCbPage->pageHeader.totalPages > MAX_CBMSG_PAGE_NUM)
- THROW(MsgException::SMS_PLG_ERROR, "CB Page Count is over MAX[%d]", pCbPage->pageHeader.totalPages);
-
- MSG_DEBUG("Total Page : [%d], Page : [%d]", pCbPage->pageHeader.totalPages, pCbPage->pageHeader.page);
-
- /* Convert Language Type */
- convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
-
- MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
- MSG_DEBUG("iso639Lang : [%s]", pCbPage->pageHeader.dcs.iso639Lang);
- /* Get Receive Time */
- pCbPage->pageHeader.recvTime = getRecvTime();
-
- /* Decode CB Data */
- int dataLen = pCbMsg->Length - 6;
-
- MSG_DEBUG("codingScheme:[%d]", pCbPage->pageHeader.dcs.codingScheme);
-
- switch (pCbPage->pageHeader.dcs.codingScheme) {
- case SMS_CHARSET_7BIT: {
- MSG_DEBUG("GSM 7 BIT");
-
- dataLen = (dataLen*8) / 7;
-
- SmsPluginUDCodec udCodec;
- char pageData[MAX_CBMSG_PAGE_SIZE*8/7] = {0};
- int unpackLen = udCodec.unpack7bitChar(&cbData[6], dataLen, 0, pageData);
-
- if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
- unpackLen = unpackLen - 3;
- if (unpackLen > 0)
- memcpy(pCbPage->pageData, &pageData[3], unpackLen);
- else
- unpackLen = 0;
- } else {
- memcpy(pCbPage->pageData, &pageData, unpackLen);
- }
-
- MSG_DEBUG("unpackLen : [%d]", unpackLen);
-
- pCbPage->pageLength = unpackLen;
- pCbPage->pageData[unpackLen] = '\0';
- }
- break;
-
- case SMS_CHARSET_8BIT:
- case SMS_CHARSET_UCS2: {
- MSG_DEBUG("UCS2 or 8BIT");
-
- if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
- memcpy(pCbPage->pageData, &cbData[8], dataLen - 2);
- pCbPage->pageLength = dataLen - 2;
- } else {
- memcpy(pCbPage->pageData, &cbData[6], dataLen);
- pCbPage->pageLength = dataLen;
- }
- }
- break;
- }
-
- MSG_DEBUG("Page Length : [%d], Page Data : [%s]", pCbPage->pageLength, pCbPage->pageData);
-}
-
-
-void SmsPluginCbMsgHandler::DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PRIMARY_S *pEtwsPn)
-{
- if ( !pEtwsMsg || !pEtwsPn )
- return;
-
- if (pEtwsMsg->Length > MAX_ETWS_SIZE)
- THROW(MsgException::SMS_PLG_ERROR, "ETWS Msg Size is over MAX [%d]", pEtwsMsg->Length);
-
- unsigned char EtwsData[pEtwsMsg->Length+1];
-
- memset(EtwsData, 0x00, sizeof(EtwsData));
- memcpy(EtwsData, pEtwsMsg->szMsgData, pEtwsMsg->Length);
- EtwsData[pEtwsMsg->Length] = '\0';
-
- /* print received msg data */
- MSG_INFO("Received Etws length:%d", pEtwsMsg->Length);
- char EtwsDataTmp[(pEtwsMsg->Length*2)+1];
- memset(EtwsDataTmp, 0x00, sizeof(EtwsDataTmp));
-
- for (int i = 0; i < pEtwsMsg->Length; i++) {
- snprintf(EtwsDataTmp+(i*2), sizeof(EtwsDataTmp)-(i*2), "%02X", EtwsData[i]);
- }
- MSG_INFO("[%s]", EtwsDataTmp);
-
- /* received time */
- pEtwsPn->recvTime = getRecvTime();
-
- /* Serial Number */
- pEtwsPn->serialNum.geoScope = (EtwsData[0] & 0xC0) >> 6;
- pEtwsPn->serialNum.msgCode = (EtwsData[0] & 0x3F) << 4;
- pEtwsPn->serialNum.msgCode |= (EtwsData[1] & 0xF0) >> 4;
- pEtwsPn->serialNum.updateNum = EtwsData[1] & 0x0F;
-
- MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pEtwsPn->serialNum.geoScope, pEtwsPn->serialNum.msgCode, pEtwsPn->serialNum.updateNum);
-
- /* Message Identifier */
- pEtwsPn->msgId = (EtwsData[2] << 8) | EtwsData[3];
- MSG_DEBUG("MSG ID : [%d]", pEtwsPn->msgId);
-
- /* warning type */
- pEtwsPn->warningType = (EtwsData[4] << 8) | EtwsData[5];
- MSG_DEBUG("warningType : [0x%04x]", pEtwsPn->msgId);
-
- /* warning security information */
- memcpy(pEtwsPn->warningSecurityInfo, &EtwsData[6], sizeof(pEtwsPn->warningSecurityInfo)); /* 50bytes */
- for (unsigned int i = 0; i < sizeof(pEtwsPn->warningSecurityInfo); i++) {
- MSG_DEBUG("warning secu info [%02x]", pEtwsPn->warningSecurityInfo[i]);
- }
-}
-
-void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage)
-{
- unsigned char cbData[MAX_CBMSG_TOTAL_PAGE_SIZE + 1] = {0};
- memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
- cbData[pCbMsg->Length] = '\0';
-
- /* print cb data */
- MSG_INFO("Received CB length:%d", pCbMsg->Length);
- char cbDataTmp[(pCbMsg->Length*2)+1];
- memset(cbDataTmp, 0x00, sizeof(cbDataTmp));
-
- for (int i = 0; i < pCbMsg->Length; i++) {
- snprintf(cbDataTmp+(i*2), sizeof(cbDataTmp)-(i*2), "%02X", cbData[i]);
- }
- MSG_INFO("[%s]", cbDataTmp);
-
- pCbPage->cbMsgType = (SMS_CBMSG_TYPE_T)cbData[0];
-
- pCbPage->pageHeader.msgId = (cbData[1] << 8) | cbData[2];
-
- MSG_DEBUG("MSG ID : [%d]", pCbPage->pageHeader.msgId);
-
- /* Serial Number */
- pCbPage->pageHeader.serialNum.geoScope = (cbData[3] & 0xC0) >> 6;
-
- pCbPage->pageHeader.serialNum.msgCode = (cbData[3] & 0x3F) << 4;
- pCbPage->pageHeader.serialNum.msgCode |= (cbData[4] & 0xF0) >> 4;
-
- pCbPage->pageHeader.serialNum.updateNum = cbData[4] & 0x0F;
-
- MSG_DEBUG("geoScope : [%d], msgCode : [%d], updateNum : [%d]", pCbPage->pageHeader.serialNum.geoScope, pCbPage->pageHeader.serialNum.msgCode, pCbPage->pageHeader.serialNum.updateNum);
-
- /* DCS */
- decodeCbMsgDCS(cbData[5], (unsigned char*)cbData + 6, &(pCbPage->pageHeader.dcs));
-
- /* Convert Language Type */
- convertLangType(pCbPage->pageHeader.dcs.langType, &(pCbPage->pageHeader.langType));
-
- MSG_DEBUG("In Language Type : [%d], Out Language Type : [%d]", pCbPage->pageHeader.dcs.langType, pCbPage->pageHeader.langType);
-
- /* Get Receive Time */
- pCbPage->pageHeader.recvTime = getRecvTime();
- pCbPage->pageHeader.totalPages = cbData[6];
-
- /* Decode CB Data */
- int dataLen = 0;
- int offset = 0;
-
- switch (pCbPage->pageHeader.dcs.codingScheme) {
- case SMS_CHARSET_7BIT: {
- for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
- unsigned char cbMessage[MAX_CBMSG_PAGE_SIZE] = {0};
- dataLen = cbData[7 + (i + 1) * MAX_CBMSG_PAGE_SIZE + i];
-
- if (dataLen > MAX_CBMSG_PAGE_SIZE)
- THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", dataLen);
-
- memcpy(cbMessage, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
- dataLen = (dataLen*8) / 7;
-
- SmsPluginUDCodec udCodec;
- int unpackLen = udCodec.unpack7bitChar((const unsigned char *)cbMessage, dataLen, 0, pCbPage->pageData + offset);
- offset += unpackLen;
- }
- pCbPage->pageLength = offset;
- }
- break;
-
- case SMS_CHARSET_8BIT:
- case SMS_CHARSET_UCS2: {
-#if 0
- char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0, };
-
- for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
- dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i];
- memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
- offset += dataLen;
- }
- dataLen = offset;
-
- if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
- int tmpDataLen = (dataLen > 2)?(dataLen - 2):0;
- memcpy(pCbPage->pageData, cbMessage + 2, tmpDataLen);
- pCbPage->pageLength = tmpDataLen;
- } else {
- memcpy(pCbPage->pageData, cbMessage, dataLen);
- pCbPage->pageLength = dataLen;
- }
-#else
- char cbMessage[MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM+1] = {0, };
-
- for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
- if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
- dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i] - 2;
- if (dataLen > 0) {
- memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i + 2], dataLen);
- offset += dataLen;
- }
- } else {
- dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i];
- if (dataLen > 0) {
- memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
- offset += dataLen;
- }
- }
- }
- dataLen = offset;
- memcpy(pCbPage->pageData, cbMessage, dataLen);
- pCbPage->pageLength = dataLen;
-#endif
- }
- break;
- }
- pCbPage->pageHeader.totalPages = 1;
-
- MSG_DEBUG("Page Length : [%d], Page Data : [%s]", pCbPage->pageLength, pCbPage->pageData);
-}
-
-unsigned short SmsPluginCbMsgHandler::encodeCbSerialNum(SMS_CBMSG_SERIAL_NUM_S snFields)
-{
- unsigned short serialNum = 0;
-
- serialNum = ((snFields.geoScope & 0x03) << 14) | ((snFields.msgCode&0x03FF) << 4) | (snFields.updateNum&0x0F);
- MSG_DEBUG("serialNum (%x), geo(%x), mc(%x), un(%x)\n", serialNum, snFields.geoScope, snFields.msgCode, snFields.updateNum);
-
- return serialNum;
-}
-
-int SmsPluginCbMsgHandler::getCMASType(unsigned short message_id)
-{
- int ret = 0;
-
- switch (message_id) {
- case 4370:
- ret = MSG_CMAS_PRESIDENTIAL;
- break;
- case 4383:
- ret = MSG_CMAS_PRESIDENTIAL_OTHER_LANG;
- break;
- case 4371:
- case 4372:
- ret = MSG_CMAS_EXTREME;
- break;
- case 4384:
- case 4385:
- ret = MSG_CMAS_EXTREME_OTHER_LANG;
- break;
- case 4373:
- case 4374:
- case 4375:
- case 4376:
- case 4377:
- case 4378:
- ret = MSG_CMAS_SEVERE;
- break;
- case 4386:
- case 4387:
- case 4388:
- case 4389:
- case 4390:
- case 4391:
- ret = MSG_CMAS_SEVERE_OTHER_LANG;
- break;
- case 4379:
- ret = MSG_CMAS_AMBER;
- break;
- case 4392:
- ret = MSG_CMAS_AMBER_OTHER_LANG;
- break;
- case 4380:
- ret = MSG_CMAS_TEST;
- break;
- case 4393:
- ret = MSG_CMAS_TEST_OTHER_LANG;
- break;
- case 4381:
- ret = MSG_CMAS_EXERCISE;
- break;
- case 4394:
- ret = MSG_CMAS_EXERCISE_OTHER_LANG;
- break;
- case 4382:
- ret = MSG_CMAS_OPERATOR_DEFINED;
- break;
- case 4395:
- ret = MSG_CMAS_OPERATOR_DEFINED_OTHER_LANG;
- break;
- case 4396:
- ret = MSG_CMAS_PUBLIC_SAFETY;
- break;
- case 4397:
- ret = MSG_CMAS_PUBLIC_SAFETY_OTHER_LANG;
- break;
- case 4398:
- ret = MSG_CMAS_STATE_LOCAL_TEST;
- break;
- case 4399:
- ret = MSG_CMAS_STATE_LOCAL_TEST_OTHER_LANG;
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex)
-{
- bool bReceive = false;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex);
- if (MsgSettingGetBool(keyName, &bReceive) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- /* Receive CB Msg = FALSE */
- if (!bReceive) {
- MSG_DEBUG("RECEIVE CB = FALSE");
- return false;
- }
-
-#if 0
- char keyname[128];
- /* check Language */
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyname), "%s/%d", CB_LANGUAGE, MSG_CBLANG_TYPE_ALL);
-
- bool bAllLang = false;
- if (MsgSettingGetBool(keyName, &bAllLang) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if (!bAllLang) {
- MSG_DEBUG("ALL LANGUAGE = FALSE");
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyname), "%s/%d", CB_LANGUAGE, CbPage.pageHeader.langType);
-
- bool bLang = false;
-
- if (MsgSettingGetBool(keyName, &bLang) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if (!bLang || CbPage.pageHeader.langType == MSG_CBLANG_TYPE_MAX) {
- MSG_DEBUG("LANGUAGE [%d] = FALSE", CbPage.pageHeader.langType);
- return false;
- }
- }
-#endif
-
- bool bActivate = false;
- int MsgId_from = 0, MsgId_to = 0;
- MSG_CB_CHANNEL_S cbChannelInfo = {0, };
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler *dbHandle = getDbHandle();
-
- err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo, simIndex);
- if (err != MSG_SUCCESS)
- MSG_ERR("Error value of MsgStoGetCBChannelInfo [%d]", err);
-
- for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
- bActivate = cbChannelInfo.channelInfo[i].bActivate;
- MsgId_from = cbChannelInfo.channelInfo[i].from;
- MsgId_to = cbChannelInfo.channelInfo[i].to;
-
- if (bActivate == true && CbPage->pageHeader.msgId >= MsgId_from && CbPage->pageHeader.msgId <= MsgId_to) {
- MSG_DEBUG("FIND CHANNEL = [%d]", CbPage->pageHeader.msgId);
- return true;
- }
- }
-
- return false;
-}
-
-unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S *CbPage)
-{
- unsigned char currPageCnt = 0;
-
- bool bFind = false;
-
-#if 0
- msg_error_t err = MSG_SUCCESS;
-
- SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
- err = storageHandler->isReceivedCBMessage(CbPage);
-
- /* check existing message with cb internal table; */
- if (err != MSG_ERR_DB_NORECORD) {
- MSG_DEBUG("already received message: [%d]", CbPage.pageHeader.msgId);
- return 0;
- }
-#endif
-
- if (CbPage->pageHeader.totalPages > 0) {
- for (unsigned int i = 0; i < pageList.size(); i++) {
- if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) {
- MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
-
- if (pageList[i].msgId == CbPage->pageHeader.msgId) {
- int updateNum = CbPage->pageHeader.serialNum.updateNum - pageList[i].updateNum;
-
- if (updateNum > 0) { /* New Message Content */
- break;
- } else if (updateNum == 0) { /* Same Message Content */
- if (pageList[i].data.count(CbPage->pageHeader.page) != 0) {
- MSG_DEBUG("The Page Number already exists [%d]", CbPage->pageHeader.page);
- return 0;
- }
-
- pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage);
- pageList[i].data.insert(newData);
-
- MSG_DEBUG("PAGE DATA : %s", CbPage->pageData);
- MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData);
-
- pageList[i].pageCnt++;
- pageList[i].totalSize += CbPage->pageLength;
-
- currPageCnt = pageList[i].pageCnt;
-
- bFind = true;
-
- break;
- } else { /* Old Message Content */
- return 0;
- }
- }
- }
- }
- }
-
- if (bFind == false || CbPage->pageHeader.totalPages == 1) {
- addToPageList(CbPage);
- return 1;
- }
-
- return currPageCnt;
-}
-
-
-void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg)
-{
- pCbMsg->cbMsgType = CbPage->cbMsgType;
- pCbMsg->msgId = CbPage->pageHeader.msgId;
- pCbMsg->classType = CbPage->pageHeader.dcs.classType;
- pCbMsg->codingScheme = CbPage->pageHeader.dcs.codingScheme;
- pCbMsg->recvTime = CbPage->pageHeader.recvTime;
- pCbMsg->serialNum = encodeCbSerialNum(CbPage->pageHeader.serialNum);
-
- cbPageMap::iterator it;
- int offset = 0;
-
- for (unsigned int i = 0; i < pageList.size(); i++) {
- if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) {
- MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode);
-
- if (pageList[i].msgId == CbPage->pageHeader.msgId) {
- for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++) {
- memcpy(pCbMsg->msgData + offset, it->second.pageData, it->second.pageLength);
- pCbMsg->msgLength += it->second.pageLength;
- offset = pCbMsg->msgLength;
- }
- }
- }
- }
-
-#if 0
- pCbMsg->msgLength = tmpStr.size();
-
- memcpy(pCbMsg->msgData, tmpStr.c_str(), tmpStr.size());
- pCbMsg->msgData[tmpStr.size()] = '\0';
-
- MSG_DEBUG("SIZE : [%d] TOTAL MSG : %s", tmpStr.size(), tmpStr.c_str());
-#endif
-}
-
-
-void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex)
-{
- pMsgInfo->msgId = (msg_message_id_t)pCbMsg->msgId;
- pMsgInfo->serialNum = pCbMsg->serialNum;
-
- pMsgInfo->folderId = MSG_CBMSGBOX_ID;
-
- /* Convert Type values */
- pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
-
- if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_CBS) {
- int cmas_Type = getCMASType(pCbMsg->msgId);
-
- if (cmas_Type == 0)
- pMsgInfo->msgType.subType = MSG_CB_SMS;
- else
- pMsgInfo->msgType.subType = (MSG_SUB_TYPE_T)cmas_Type;
- } else if (pCbMsg->cbMsgType == SMS_CBMSG_TYPE_JAVACBS) {
- pMsgInfo->msgType.subType = MSG_JAVACB_SMS;
- }
-
- switch (pCbMsg->classType) {
- case SMS_MSG_CLASS_0:
- pMsgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- pMsgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- pMsgInfo->msgType.classType = MSG_CLASS_2;
- break;
- case SMS_MSG_CLASS_3:
- pMsgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- pMsgInfo->msgType.classType = MSG_CLASS_NONE;
- break;
- }
-
- pMsgInfo->storageId = MSG_STORAGE_PHONE;
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
- /* Temporary */
- pMsgInfo->nAddressCnt = 1;
-
- pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
- pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
- pMsgInfo->sim_idx = simIndex;
-
- /* TODO :: MSG ID should be used to get CB message type */
- getDisplayName(pCbMsg->msgId, pMsgInfo->addressList[0].addressVal, simIndex);
- MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
-
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-
- pMsgInfo->displayTime = pCbMsg->recvTime;
- MSG_DEBUG("recvTime is %ld", pMsgInfo->displayTime);
-
- int bufSize = pCbMsg->msgLength*2;
-
- char tmpBuf[bufSize];
- memset(tmpBuf, 0x00, sizeof(tmpBuf));
-
- while (pCbMsg->msgLength > 0) {
- if (pCbMsg->msgData[pCbMsg->msgLength-1] == ' ' ||
- pCbMsg->msgData[pCbMsg->msgLength-1] == '\r' ||
- pCbMsg->msgData[pCbMsg->msgLength-1] == '\n') {
- pCbMsg->msgLength--;
- } else {
- break;
- }
- }
- pCbMsg->msgData[pCbMsg->msgLength] = '\0';
-
- MSG_DEBUG("LENGTH %d CB MSG %s", pCbMsg->msgLength, pCbMsg->msgData);
-
- /* Convert Data values */
- pMsgInfo->dataSize = convertTextToUtf8((unsigned char*)tmpBuf, bufSize, pCbMsg);
-
- if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
- pMsgInfo->bTextSms = false;
-
- /* Save Message Data into File */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
-
- MSG_SEC_DEBUG("Save Message Data into file : size[%zu] name[%s]\n", pMsgInfo->dataSize, fileName);
- if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
-
- strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
- } else {
- pMsgInfo->bTextSms = true;
-
- memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
- memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
- pMsgInfo->dataSize = strlen(pMsgInfo->msgText);
- MSG_SEC_DEBUG("CB MSG %s", pMsgInfo->msgText);
- }
-}
-
-
-void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex)
-{
- pMsgInfo->msgId = (msg_message_id_t)EtwsMsg->pageHeader.msgId;
-
- pMsgInfo->folderId = MSG_CBMSGBOX_ID;
-
- /* Convert Type values */
- pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
-
- if (EtwsMsg->cbMsgType == SMS_CBMSG_TYPE_ETWS)
- pMsgInfo->msgType.subType = MSG_ETWS_SMS;
-
- pMsgInfo->storageId = MSG_STORAGE_PHONE;
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
- /* Temporary */
- pMsgInfo->nAddressCnt = 1;
-
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN;
- pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN;
-
- getDisplayName(EtwsMsg->pageHeader.msgId, pMsgInfo->addressList[0].addressVal, simIndex);
- MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal);
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-
- pMsgInfo->displayTime = EtwsMsg->pageHeader.recvTime;
- MSG_DEBUG("recvTime is %ld", pMsgInfo->displayTime);
- MSG_DEBUG("LENGTH %d", EtwsMsg->pageLength);
- pMsgInfo->bTextSms = true;
- pMsgInfo->dataSize = EtwsMsg->pageLength;
- memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
- memcpy(pMsgInfo->msgData, EtwsMsg->pageData, pMsgInfo->dataSize);
-}
-
-int SmsPluginCbMsgHandler::convertTextToUtf8(unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg)
-{
- int convertedTextSize = 0;
- MSG_LANG_INFO_S langInfo = {0, };
-
- MsgTextConvert *textCvt = MsgTextConvert::instance();
-
- if (!outBuf || !pCbMsg) {
- MSG_DEBUG("invalid param.\n");
- return 0;
- }
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
-
- /* Convert Data values */
- if (pCbMsg->codingScheme == SMS_CHARSET_7BIT)
- convertedTextSize = textCvt->convertGSM7bitToUTF8(outBuf, outBufSize, (unsigned char*)pCbMsg->msgData, pCbMsg->msgLength, &langInfo);
- else if (pCbMsg->codingScheme == SMS_CHARSET_UCS2)
- convertedTextSize = textCvt->convertUCS2ToUTF8(outBuf, outBufSize, (unsigned char*)pCbMsg->msgData, pCbMsg->msgLength);
-
- return convertedTextSize;
-}
-
-void SmsPluginCbMsgHandler::addToPageList(SMS_CBMSG_PAGE_S *CbPage)
-{
- CB_PAGE_INFO_S tmpInfo;
-
- tmpInfo.geoScope = CbPage->pageHeader.serialNum.geoScope;
- tmpInfo.msgCode = CbPage->pageHeader.serialNum.msgCode;
- tmpInfo.updateNum = CbPage->pageHeader.serialNum.updateNum;
- tmpInfo.msgId = CbPage->pageHeader.msgId;
- tmpInfo.totalPages = CbPage->pageHeader.totalPages;
-
- tmpInfo.pageCnt = 1;
- tmpInfo.totalSize = CbPage->pageLength;
-
- pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage);
- tmpInfo.data.insert(newData);
-
- MSG_DEBUG("MSG DATA : %s", CbPage->pageData);
- MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData);
-
- pageList.push_back(tmpInfo);
-}
-
-
-void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S *CbPage)
-{
- unsigned int index;
-
- for (index = 0; index < pageList.size(); index++) {
- if (pageList[index].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage->pageHeader.serialNum.msgCode) {
- MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[index].geoScope, pageList[index].msgCode);
-
- if (pageList[index].msgId == CbPage->pageHeader.msgId)
- break;
- }
- }
-
- MSG_DEBUG("remove index [%d]", index);
-
- pageList.erase(pageList.begin()+index);
-}
-
-
-void SmsPluginCbMsgHandler::decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs)
-{
- pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
- pDcs->classType = SMS_MSG_CLASS_NONE;
- pDcs->bCompressed = false;
- pDcs->codingScheme = SMS_CHARSET_7BIT;
- pDcs->langType = SMS_CBMSG_LANG_UNSPECIFIED;
- memset(pDcs->iso639Lang, 0x00, sizeof(pDcs->iso639Lang));
- pDcs->bUDH = false;
- pDcs->rawData = dcsData;
-
- unsigned char codingGrp = (dcsData & 0xF0) >> 4;
-
- switch (codingGrp) {
- case 0x00:
- case 0x02:
- case 0x03: {
- pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
- pDcs->langType = (SMS_CBMSG_LANG_TYPE_T)dcsData;
- }
- break;
-
- case 0x01: {
- if (dcsData == 0x10 || dcsData == 0x11) {
- pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
- pDcs->codingScheme = (dcsData & 0x01) ? SMS_CHARSET_UCS2 : SMS_CHARSET_7BIT;
- pDcs->langType = SMS_CBMSG_LANG_ISO639;
- MSG_DEBUG("codingScheme: [%d]", pDcs->codingScheme);
- if (pMsgData[0] && pMsgData[1]) {
- pDcs->iso639Lang[0] = pMsgData[0] & 0x7F;
- pDcs->iso639Lang[1] = (pMsgData[0] & 0X80) >> 7;
- pDcs->iso639Lang[1] |= (pMsgData[1] & 0X3F) << 1;
- pDcs->iso639Lang[2] = 0x13; /* CR */
- } else {
- /* Default it to English if pMsgData is NULL */
- pDcs->iso639Lang[0] = 0x45; /* E */
- pDcs->iso639Lang[1] = 0x4E; /* N */
- pDcs->iso639Lang[2] = 0x13; /* CR */
- }
- }
- }
- break;
-
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07: {
- pDcs->codingGroup = SMS_CBMSG_CODGRP_GENERAL_DCS;
-
- pDcs->bCompressed = (dcsData & 0x20) ? true : false;
-
- if (dcsData & 0x10)
- pDcs->classType = (SMS_MSG_CLASS_T)(dcsData & 0x03);
-
- unsigned char tmpScheme = (dcsData & 0x0C) >> 2;
-
- switch (tmpScheme) {
- case 0x00:
- pDcs->codingScheme = SMS_CHARSET_7BIT;
- break;
- case 0x01:
- pDcs->codingScheme = SMS_CHARSET_8BIT;
- break;
- case 0x02:
- pDcs->codingScheme = SMS_CHARSET_UCS2;
- break;
- default:
- MSG_DEBUG("tmpScheme: [%d]", tmpScheme);
- break;
- }
- }
- break;
-
- case 0x09: {
- pDcs->bUDH = true;
- pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
- pDcs->codingScheme = (SMS_CODING_SCHEME_T)((dcsData & 0x0C) >> 2);
- }
- break;
-
- case 0x0E: {
- pDcs->codingGroup = SMS_CBMSG_CODGRP_WAP;
- }
- break;
-
- case 0x0F: {
- pDcs->codingGroup = SMS_CBMSG_CODGRP_CLASS_CODING;
- pDcs->codingScheme = (dcsData & 0x04) ? SMS_CHARSET_8BIT : SMS_CHARSET_7BIT;
- pDcs->classType = (MSG_CLASS_TYPE_T)(dcsData & 0x03);
- }
- break;
- default:
- MSG_DEBUG("codingGrp: [0x%x]", codingGrp);
- break;
- }
-}
-
-
-void SmsPluginCbMsgHandler::convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType)
-{
- switch (InType) {
- case SMS_CBMSG_LANG_GERMAN :
- *pOutType = MSG_CBLANG_TYPE_GER;
- break;
-
- case SMS_CBMSG_LANG_ENGLISH :
- *pOutType = MSG_CBLANG_TYPE_ENG;
- break;
-
- case SMS_CBMSG_LANG_ITALIAN :
- *pOutType = MSG_CBLANG_TYPE_ITA;
- break;
-
- case SMS_CBMSG_LANG_FRENCH :
- *pOutType = MSG_CBLANG_TYPE_FRE;
- break;
-
- case SMS_CBMSG_LANG_SPANISH :
- *pOutType = MSG_CBLANG_TYPE_SPA;
- break;
-
- case SMS_CBMSG_LANG_DUTCH :
- *pOutType = MSG_CBLANG_TYPE_NED;
- break;
-
- case SMS_CBMSG_LANG_SWEDISH :
- *pOutType = MSG_CBLANG_TYPE_SWE;
- break;
-
- case SMS_CBMSG_LANG_PORTUGUESE :
- *pOutType = MSG_CBLANG_TYPE_POR;
- break;
-
- case SMS_CBMSG_LANG_TURKISH :
- *pOutType = MSG_CBLANG_TYPE_TUR;
- break;
-
- default :
- *pOutType = MSG_CBLANG_TYPE_MAX;
- break;
- }
-}
-
-
-unsigned long SmsPluginCbMsgHandler::getRecvTime()
-{
- time_t recvTime;
-
- recvTime = time(NULL);
-
- return (unsigned long)recvTime;
-}
-
-
-void SmsPluginCbMsgHandler::getDisplayName(unsigned short MsgId, char *pDisplayName, msg_sim_slot_id_t simIndex)
-{
- MSG_CB_CHANNEL_S cbChannelInfo = {0, };
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler *dbHandle = getDbHandle();
-
- err = MsgStoGetCBChannelInfo(dbHandle, &cbChannelInfo, simIndex);
- MSG_DEBUG("MsgStoGetCBChannelInfo [err = %d]", err);
-
- for (int i = 0; i < cbChannelInfo.channelCnt; i++) {
- if (MsgId >= cbChannelInfo.channelInfo[i].from && MsgId <= cbChannelInfo.channelInfo[i].to) {
- MSG_DEBUG("FIND MSG ID = [%d]", MsgId);
-#if 0
- char strTmp[CB_CHANNEL_NAME_MAX + 1];
- memset(strTmp, 0x00, sizeof(strTmp));
-
- strncpy(strTmp, cbChannelInfo.channelInfo[i].name, CB_CHANNEL_NAME_MAX);
-
- if (strlen(strTmp) > 0)
- snprintf(pDisplayName, sizeof(strTmp), "[%s]", strTmp);
- else
- snprintf(pDisplayName, sizeof(unsigned short), "[%d]", MsgId);
-#else
-
-#ifdef MSG_NOTI_INTEGRATION
- snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "CB message");
-#else
- snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId);
-#endif
-
-#endif
- return;
- }
- }
-
- snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgDebug.h"
-#include "MsgException.h"
-#include "MsgCppTypes.h"
-#include "MsgUtilFile.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginWapPushHandler.h"
-#include "SmsPluginConcatHandler.h"
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginDSHandler.h"
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginConcatHandler - Member Functions
-==================================================================================================*/
-SmsPluginConcatHandler* SmsPluginConcatHandler::pInstance = NULL;
-
-
-SmsPluginConcatHandler::SmsPluginConcatHandler()
-{
- concatList.clear();
-}
-
-
-SmsPluginConcatHandler::~SmsPluginConcatHandler()
-{
- concatList.clear();
-}
-
-
-SmsPluginConcatHandler* SmsPluginConcatHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginConcatHandler();
-
- return pInstance;
-}
-
-
-bool SmsPluginConcatHandler::IsConcatMsg(SMS_USERDATA_S *pUserData)
-{
- MSG_BEGIN();
-
- MSG_DEBUG("headerCnt [%d]", pUserData->headerCnt);
-
- for (int i = 0; i < pUserData->headerCnt; i++) {
- /** Handler Concatenated Message */
- if (pUserData->header[i].udhType == SMS_UDH_CONCAT_8BIT) {
- return true;
- } else if (pUserData->header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- return true;
- }
- }
-
- MSG_END();
-
- return false;
-}
-
-
-void SmsPluginConcatHandler::handleConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
- bool noneConcatTypeHeader = true;
-
- if (pTpdu->tpduType != SMS_TPDU_DELIVER) {
- MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
- return;
- }
-
- SMS_CONCAT_MSG_S msg = {0};
-
- msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
- if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
- msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
- msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
-
- memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
-
-#if 0
- if (msg.totalSeg > MAX_SEGMENT_NUM) {
- MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
- return;
- }
-#endif
- /** check noneConcatTypeHeader */
- noneConcatTypeHeader = false;
-
- break;
- } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
- msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
- msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
-
- memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
-#if 0
- if (msg.totalSeg > MAX_SEGMENT_NUM) {
- MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
- return;
- }
-#endif
-
- /** check noneConcatTypeHeader */
- noneConcatTypeHeader = false;
-
- break;
- }
- }
-
- unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
-
- MSG_DEBUG("segCnt [%d]", segCnt);
- MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
-
- if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
- MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
-
- int dataSize = 0;
- char* pUserData = NULL;
- bool simSlotSizeOver = false;
- unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
-
- MSG_MESSAGE_INFO_S msgInfo = {0};
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
- msgInfo.sim_idx = msg.simIndex;
-
- dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
-
- if (dataSize > 0) {
- if (SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(pTpdu->data.deliver.userData)) == true) {
- SmsPluginWapPushHandler::instance()->copyDeliverData(&(pTpdu->data.deliver));
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- if (err == MSG_SUCCESS) {
- time_t sent_time = 0;
- if (pTpdu->data.deliver.timeStamp.format == SMS_TIME_ABSOLUTE) {
- sent_time = time(NULL);
- }
-
- SmsPluginWapPushHandler::instance()->handleWapPushMsg(pUserData, dataSize, msg.simIndex, sent_time);
- }
- } else {
- convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
-
- if (msgInfo.msgType.classType == MSG_CLASS_2) {
- msgInfo.storageId = MSG_STORAGE_SIM;
- SmsPluginSimMsg::instance()->setSmsTpduTotalSegCount(msg.totalSeg);
- }
-
- if (msgInfo.msgPort.valid == true) {
- if ((msgInfo.msgPort.dstPort >= 0x23F4 && msgInfo.msgPort.dstPort <= 0x23F7) || /** Check unsupported message (Vcalendar WAP push) **/
- (msgInfo.msgPort.dstPort == 0x1581)) { /** Check unsupported message (ringtone smart message) **/
- memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "<<Content not supported>>");
- msgInfo.dataSize = strlen(msgInfo.msgText);
- msgInfo.msgPort.valid = false;
- }
- }
-
- if (msgInfo.msgPort.valid == false) {
- /** Add Concat Msg into DB */
-
- /* check Class2 Normal SMS is longer than SIM slot full size and send DeliveryReport SUCCESS because that Class2 msg cannot be saved on SIM
- * It MUST be done before calling addClass2Message(thread) beause 10+ page message body ipc file is deleted after SmsPluginTransport::instance()->msgInfoToSubmitData() */
- if (msgInfo.msgType.subType == MSG_NORMAL_SMS && msgInfo.msgType.classType == MSG_CLASS_2 &&
- (SmsPluginSimMsg::instance()->checkSimMsgFull(msg.simIndex, segCnt) == true)) {
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, msg.simIndex);
- int totalCnt;
- if (MsgSettingGetInt(keyName, &totalCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
-
- if (segCnt > totalCnt) {
- /* send DeliveryResport as MSG_SUCCESS and return when total sim storage cnt is less than segment cnt. */
- MSG_INFO("SIM slot total count [%d] is less than total sement count of Class2 message [%d], send delivery report as SUCCESS and save it only PHONE", totalCnt, segCnt);
-
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
-
- MsgInsertTicker("Message is too large to store as a single message to SIM card.", SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE, false, 0);
-
- simSlotSizeOver = true;
- }
- } else {
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
- }
- }
-
- if (err == MSG_SUCCESS) {
- if (simSlotSizeOver || (msgInfo.msgType.classType != MSG_CLASS_2)) {
- if (simSlotSizeOver)
- msgInfo.storageId = MSG_STORAGE_PHONE;
-
- /** Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS) {
- MSG_WARN("callbackMsgIncoming() Error !! [%d]", err);
- }
- }
- } else {
- MSG_DEBUG("addMessage() Error !! [%d]", err);
- }
- }
- }
-
- removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
- }
-
- /** Send Deliver Report */
- SmsPluginTransport::instance()->sendDeliverReport(handle, err);
-
- MSG_END();
-}
-
-void SmsPluginConcatHandler::handleSimConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList)
-{
- MSG_BEGIN();
-
- bool noneConcatTypeHeader = true;
-
- if (pTpdu->tpduType == SMS_TPDU_DELIVER) {
- SMS_CONCAT_MSG_S msg = {0};
-
- msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
- if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
- msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
- msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
- msg.simId = msgId;
- memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
-
-
- /** check noneConcatTypeHeader */
- noneConcatTypeHeader = false;
-
- break;
- } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
- msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
- msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
- msg.simId = msgId;
- memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
-
- /** check noneConcatTypeHeader */
- noneConcatTypeHeader = false;
-
- break;
- }
- }
-
- unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
- MSG_DEBUG("segCnt [%d]", segCnt);
- MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
-
- if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
- MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
-
- int dataSize = 0;
- char* pUserData = NULL;
- unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
-
- MSG_MESSAGE_INFO_S msgInfo = {0};
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
- msgInfo.sim_idx = msg.simIndex;
-
- dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
-
- if (dataSize > 0) {
- convertConcatToMsginfo(&(pTpdu->data.deliver), pUserData, dataSize, &msgInfo);
- /* set Sim Message ID */
- msgInfo.msgId = msgId;
-
- /* set read status */
- msgInfo.bRead = bRead;
- /* set storage id */
- msgInfo.storageId = MSG_STORAGE_SIM;
- }
- for (int index = concatList.size(); index >= 0 ; index--) {
- if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex
- && g_strcmp0(concatList[index].originAddress.address, msg.originAddress.address) == 0) {
- memcpy(simIdList, concatList[index].simIdList, sizeof(int) * MAX_SIM_SMS_NUM);
- for (int i = 0; i < 255; ++i) {
- MSG_DEBUG("sim id [%d]", simIdList[i]);
- }
- break;
- }
- }
- removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
- /* Call Event Handler */
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
- return;
- }
- /* Call Event Handler */
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
- } else {
- SMS_CONCAT_MSG_S msg = {0};
-
- msg.simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- for (int i = 0; i < pTpdu->data.submit.userData.headerCnt; i++) {
- if (pTpdu->data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.submit.userData.header[i].udh.concat8bit.msgRef;
- msg.totalSeg = pTpdu->data.submit.userData.header[i].udh.concat8bit.totalSeg;
- msg.seqNum = pTpdu->data.submit.userData.header[i].udh.concat8bit.seqNum;
- msg.simId = msgId;
- memcpy(&(msg.originAddress), &(pTpdu->data.submit.destAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.submit.dcs), sizeof(SMS_DCS_S));
-
-
- /** check noneConcatTypeHeader */
- noneConcatTypeHeader = false;
-
- break;
- } else if (pTpdu->data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.submit.userData.header[i].udh.concat16bit.msgRef;
- msg.totalSeg = pTpdu->data.submit.userData.header[i].udh.concat16bit.totalSeg;
- msg.seqNum = pTpdu->data.submit.userData.header[i].udh.concat16bit.seqNum;
- msg.simId = msgId;
- memcpy(&(msg.originAddress), &(pTpdu->data.submit.destAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.submit.dcs), sizeof(SMS_DCS_S));
-
- /** check noneConcatTypeHeader */
- noneConcatTypeHeader = false;
-
- break;
- }
- }
-
- unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.submit.userData));
-
- MSG_DEBUG("segCnt [%d]", segCnt);
- MSG_DEBUG("msg.totalSeg [%d]", msg.totalSeg);
-
- if ((segCnt == msg.totalSeg) || noneConcatTypeHeader) {
- MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
-
- int dataSize = 0;
- char* pUserData = NULL;
- unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
-
- MSG_MESSAGE_INFO_S msgInfo = {0};
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
- msgInfo.sim_idx = msg.simIndex;
-
- dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData, msg.originAddress.address);
-
- if (dataSize > 0) {
- convertConcatToMsginfo(&(pTpdu->data.submit), pUserData, dataSize, &msgInfo);
-
- /* set Sim Message ID */
- msgInfo.msgId = msgId;
- /* set read status */
- msgInfo.bRead = bRead;
-
- msgInfo.msgType.subType = MSG_CONCAT_SIM_SMS;
-
- /* set storage id */
- msgInfo.storageId = MSG_STORAGE_SIM;
- }
- for (int index = concatList.size(); index >= 0 ; index--) {
- if (concatList[index].msgRef == msg.msgRef && concatList[index].simIndex == msg.simIndex
- && g_strcmp0(concatList[index].originAddress.address, msg.originAddress.address) == 0) {
- memcpy(simIdList, concatList[index].simIdList, sizeof(int) * MAX_SIM_SMS_NUM);
- break;
- }
- }
- /* Call Event Handler */
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, &msgInfo, true);
- removeFromConcatList(msg.msgRef, msg.simIndex, msg.originAddress.address);
- return;
- }
- /* Call Event Handler */
- SmsPluginSimMsg::instance()->setSimMsgEvent(handle, NULL, false);
- }
-
- MSG_END();
-}
-
-#ifdef CONCAT_SIM_MSG_OPERATION
-void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead)
-{
- MSG_BEGIN();
-
- if (pTpdu->tpduType != SMS_TPDU_DELIVER) {
- MSG_DEBUG("The TPDU type is not deliver [%d]", pTpdu->tpduType);
- return;
- }
-
- SMS_CONCAT_MSG_S msg;
- memset(&msg, 0x00, sizeof(SMS_CONCAT_MSG_S));
-
- for (int i = 0; i < pTpdu->data.deliver.userData.headerCnt; i++) {
- if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat8bit.msgRef;
- msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat8bit.totalSeg;
- msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat8bit.seqNum;
-
- memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
-
- msg.bRead = bRead;
-
- if (msg.totalSeg > MAX_SEGMENT_NUM) {
- MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
- return;
- }
-
- break;
- } else if (pTpdu->data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT) {
- msg.msgRef = (unsigned short)pTpdu->data.deliver.userData.header[i].udh.concat16bit.msgRef;
- msg.totalSeg = pTpdu->data.deliver.userData.header[i].udh.concat16bit.totalSeg;
- msg.seqNum = pTpdu->data.deliver.userData.header[i].udh.concat16bit.seqNum;
-
- memcpy(&(msg.timeStamp.time.absolute), &(pTpdu->data.deliver.timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(pTpdu->data.deliver.originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(pTpdu->data.deliver.dcs), sizeof(SMS_DCS_S));
-
- msg.bRead = bRead;
-
- if (msg.totalSeg > MAX_SEGMENT_NUM) {
- MSG_DEBUG("Total Segment Count is over Maximum [%d]", msg.totalSeg);
- return;
- }
-
- break;
- }
- }
-
- unsigned char segCnt = checkConcatMsg(&msg, &(pTpdu->data.deliver.userData));
-
- addToSimIdList(msg.msgRef, SimMsgId);
-
- if (segCnt == msg.totalSeg) {
- MSG_DEBUG("RECEIVED LAST CONCAT : %d", segCnt);
-
- int dataSize = 0;
- char* pUserData = NULL;
- unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
-
- MSG_MESSAGE_INFO_S msgInfo = {0};
-
- dataSize = makeConcatUserData(msg.msgRef, &pUserData);
-
- if (dataSize >= 0) {
- MSG_DEBUG("TOTAL DATA : %s", pUserData);
-
- convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
-
- /* set Sim Message ID */
- msgInfo.msgId = SimMsgId;
-
- /* set read status */
- msgInfo.bRead = bRead;
-
- /* Print MSG_MESSAGE_INFO_S */
- MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
-
- MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
- MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
- MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
- MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
- MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
- MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
- MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
- MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
- MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
- MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
- MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
- MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
- MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
- MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
-
- if (msgInfo.bTextSms == true)
- MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
- else
- MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
-
- MSG_DEBUG("###############################################################");
-
- /* Remove from List */
- removeFromConcatList(msg.msgRef);
- removeFromSimIdList(msg.msgRef);
-
- /* add msgInfo to msg list */
- SmsPluginStorage::instance()->addSimMsgToList(&msgInfo, true);
-
- /* Callback to MSG FW */
- SmsPluginEventHandler::instance()->callbackGetSimMsg();
- }
- } else {
- /* add index count to msg list */
- SmsPluginStorage::instance()->addSimMsgToList(NULL, false);
-
- /* Callback to MSG FW */
- SmsPluginEventHandler::instance()->callbackGetSimMsg();
- }
-
- MSG_END();
-}
-
-
-void SmsPluginConcatHandler::handleBrokenMsg()
-{
- if (concatList.size() <= 0 || simIdList.size() <= 0) {
- MSG_DEBUG("No Broken Concatenated Message");
- return;
- }
-
- do {
- int index = 0, dataSize = 0;
- char* pUserData = NULL;
- unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter);
-
- MSG_MESSAGE_INFO_S msgInfo = {0};
-
- dataSize = makeConcatUserData(concatList[index].msgRef, &pUserData);
-
- if (dataSize > 0) {
- MSG_DEBUG("TOTAL DATA : %s", pUserData);
-
- SMS_CONCAT_MSG_S msg;
- memset(&msg, 0x00, sizeof(SMS_CONCAT_MSG_S));
-
- msg.msgRef = concatList[index].msgRef;
- msg.totalSeg = concatList[index].totalSeg;
-
- memcpy(&(msg.timeStamp.time.absolute), &(concatList[index].timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(msg.originAddress), &(concatList[index].originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(msg.dcs), &(concatList[index].dcs), sizeof(SMS_DCS_S));
-
- convertSimMsgToMsginfo(&msg, pUserData, dataSize, &msgInfo);
-
- /* set Sim Message ID */
- msgInfo.msgId = 0;
-
- /* set read status */
- msgInfo.bRead = concatList[index].bRead;
-
- /* Print MSG_MESSAGE_INFO_S */
- MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
- MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
- MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
- MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
- MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
- MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
- MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
- MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
- MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
- MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
- MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
- MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
- MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
- MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
- MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
- if (msgInfo.bTextSms == true)
- MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
- else
- MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
- MSG_DEBUG("###############################################################");
-
- /* add msgInfo to msg list */
- SmsPluginStorage::instance()->addSimMsgToList(&msgInfo, true);
- }
-
- removeFromConcatList(concatList[index].msgRef);
- removeFromSimIdList(concatList[index].msgRef);
- } while (concatList.size() > 0);
-}
-#endif
-
-
-unsigned char SmsPluginConcatHandler::checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMsg, SMS_USERDATA_S *pUserData)
-{
- if (pConcatMsg == NULL || pUserData == NULL) {
- MSG_DEBUG("In Parameter is NULL");
- return 0;
- }
-
- unsigned char currSegCnt = 0;
-
- bool bFind = false;
-
- for (unsigned int i = 0; i < concatList.size(); i++) {
- if (concatList[i].msgRef == pConcatMsg->msgRef && concatList[i].simIndex == pConcatMsg->simIndex
- && g_strcmp0(concatList[i].originAddress.address, pConcatMsg->originAddress.address) == 0) {
- if (concatList[i].data.count(pConcatMsg->seqNum) != 0) {
- MSG_DEBUG("The Sequence Number already exists [%d]", pConcatMsg->seqNum);
- return 0;
- }
- CONCAT_DATA_S concatData = {0};
-
- memcpy(concatData.data, pUserData->data, pUserData->length);
- concatData.length = pUserData->length;
-
- pair<unsigned char, CONCAT_DATA_S> newData(pConcatMsg->seqNum, concatData);
- concatList[i].data.insert(newData);
- concatList[i].simIdList[concatList[i].segCnt] = pConcatMsg->simId + 1;
-
- MSG_DEBUG("MSG DATA : %s", pUserData->data);
- MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
-
- concatList[i].segCnt++;
- concatList[i].totalSize += pUserData->length;
- currSegCnt = concatList[i].segCnt;
-
- bFind = true;
-
- break;
- }
- }
-
- /** New Concat Msg */
- if (bFind == false) {
- SMS_CONCAT_INFO_S tmpInfo;
- memset(tmpInfo.simIdList, 0x00, sizeof(int) * MAX_SIM_SMS_NUM);
- tmpInfo.msgRef = pConcatMsg->msgRef;
- tmpInfo.totalSeg = pConcatMsg->totalSeg;
- tmpInfo.segCnt = 1;
- tmpInfo.simIdList[0] = pConcatMsg->simId + 1;
- tmpInfo.simIndex = pConcatMsg->simIndex;
- tmpInfo.bRead = false;
-
- memcpy(&(tmpInfo.timeStamp.time.absolute), &(pConcatMsg->timeStamp.time.absolute), sizeof(SMS_TIME_ABS_S));
- memcpy(&(tmpInfo.originAddress), &(pConcatMsg->originAddress), sizeof(SMS_ADDRESS_S));
- memcpy(&(tmpInfo.dcs), &(pConcatMsg->dcs), sizeof(SMS_DCS_S));
-
- tmpInfo.totalSize = pUserData->length;
- tmpInfo.display_time = time(NULL);
-
- CONCAT_DATA_S concatData = {0};
-
- memcpy(concatData.data, pUserData->data, pUserData->length);
- concatData.length = pUserData->length;
-
- pair<unsigned char, CONCAT_DATA_S> newData(pConcatMsg->seqNum, concatData);
- tmpInfo.data.insert(newData);
-
- MSG_DEBUG("MSG DATA : %s", pUserData->data);
- MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.data);
-
- concatList.push_back(tmpInfo);
-
- currSegCnt = tmpInfo.segCnt;
- }
-
- return currSegCnt;
-}
-
-
-int SmsPluginConcatHandler::makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData, char *originAddress)
-{
- concatDataMap::iterator it;
-
- int totalSize = 0, offset = 0;
-
- for (unsigned int i = 0; i < concatList.size(); i++) {
- if (concatList[i].msgRef == MsgRef && concatList[i].simIndex == simIndex
- && g_strcmp0(concatList[i].originAddress.address, originAddress) == 0) {
- totalSize = concatList[i].totalSize;
-
- if (totalSize <= 0) {
- MSG_DEBUG("Size Error : totalSize <= 0");
- return 0;
- }
-
- MSG_DEBUG("totalSize [%d]", totalSize);
-
- if (*ppTotalData == NULL)
- *ppTotalData = new char[totalSize];
-
- for (it = concatList[i].data.begin(); it != concatList[i].data.end(); it++) {
- memcpy(*ppTotalData+offset, it->second.data, it->second.length);
- offset += it->second.length;
- }
- }
- }
-
- return totalSize;
-}
-
-
-void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- /** Convert Type values */
- pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
- pMsgInfo->msgType.subType = SmsPluginEventHandler::instance()->convertMsgSubType(pTpdu->pid);
-
- /** set folder id */
- pMsgInfo->folderId = MSG_INBOX_ID;
-
- /** set storage id */
- pMsgInfo->storageId = MSG_STORAGE_PHONE;
-
- switch (pTpdu->dcs.msgClass) {
- case SMS_MSG_CLASS_0:
- pMsgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- pMsgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- pMsgInfo->msgType.classType = MSG_CLASS_2;
- break;
- case SMS_MSG_CLASS_3:
- pMsgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- pMsgInfo->msgType.classType = MSG_CLASS_NONE;
- break;
- }
-
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
-
- time_t rawtime = time(NULL);
-
-/*** Comment below lines to save local UTC time..... (it could be used later.)
-
- if (pTpdu->timeStamp.format == SMS_TIME_ABSOLUTE) {
-
- MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
- MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
- MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
- MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
- MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
- MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
- MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
-
- char displayTime[32];
- struct tm * timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
- timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
- timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
- timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
- timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
- timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%d]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
-
-***/
-
- pMsgInfo->displayTime = rawtime;
-
- /** Convert Address values */
- pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- pMsgInfo->nAddressCnt = 1;
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(pMsgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-
- for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
- /** Convert UDH values - Port Number */
- if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
- pMsgInfo->msgPort.valid = true;
- pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
- pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
- pMsgInfo->msgPort.valid = true;
- pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
- pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
- }
- }
-
- /* For UTF8 */
- int bufSize = (DataSize*4) + 1;
-
- char tmpBuf[bufSize];
- memset(tmpBuf, 0x00, sizeof(tmpBuf));
-
- /** Convert Data values */
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
- MSG_LANG_INFO_S langInfo = {0, };
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
- pMsgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
- pMsgInfo->encodeType = MSG_ENCODE_8BIT;
- memcpy(tmpBuf, pUserData, DataSize);
- pMsgInfo->dataSize = DataSize;
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
- pMsgInfo->encodeType = MSG_ENCODE_UCS2;
- pMsgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
- }
-
- MSG_DEBUG("Data Size [%zu]", pMsgInfo->dataSize);
- MSG_DEBUG("Data [%s]", tmpBuf);
-
-#ifdef MSG_FW_FOR_DEBUG
-printf("\n");
-
-for (int i = 0; i < pMsgInfo->dataSize; i++)
-{
- printf("[%02x]", tmpBuf[i]);
-}
-
-printf("\n");
-#endif
-
- if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
- pMsgInfo->bTextSms = false;
-
- /** Save Message Data into File */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "######## MsgCreateFileName Fail !!! #######");
-
- MSG_SEC_DEBUG("Save Message Data into file : size[%zu] name[%s]\n", pMsgInfo->dataSize, fileName);
- if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
- THROW(MsgException::FILE_ERROR, "######## MsgWriteIpcFile Fail !!! #######");
-
- strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
- } else {
- pMsgInfo->bTextSms = true;
-
- memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
- memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
- }
-}
-
-
-void SmsPluginConcatHandler::convertConcatToMsginfo(const SMS_SUBMIT_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- /** Convert Type values */
- pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
- pMsgInfo->msgType.subType = SmsPluginEventHandler::instance()->convertMsgSubType(pTpdu->pid);
-
- /** set folder id */
- pMsgInfo->folderId = MSG_INBOX_ID;
-
- /** set storage id */
- pMsgInfo->storageId = MSG_STORAGE_PHONE;
-
- switch (pTpdu->dcs.msgClass) {
- case SMS_MSG_CLASS_0:
- pMsgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- pMsgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- pMsgInfo->msgType.classType = MSG_CLASS_2;
- break;
- case SMS_MSG_CLASS_3:
- pMsgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- pMsgInfo->msgType.classType = MSG_CLASS_NONE;
- break;
- }
-
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
-
- time_t rawtime = time(NULL);
- pMsgInfo->displayTime = rawtime;
-
- /** Convert Address values */
- pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- pMsgInfo->nAddressCnt = 1;
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(pMsgInfo->addressList[0].addressVal, pTpdu->destAddress.address, MAX_ADDRESS_VAL_LEN);
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-
- for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
- /** Convert UDH values - Port Number */
- if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
- pMsgInfo->msgPort.valid = true;
- pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
- pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
- pMsgInfo->msgPort.valid = true;
- pMsgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
- pMsgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
- }
- }
-
- /* For UTF8 */
- int bufSize = (DataSize*4) + 1;
-
- char tmpBuf[bufSize];
- memset(tmpBuf, 0x00, sizeof(tmpBuf));
-
- /** Convert Data values */
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
- MSG_LANG_INFO_S langInfo = {0, };
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
- pMsgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
- pMsgInfo->encodeType = MSG_ENCODE_8BIT;
- memcpy(tmpBuf, pUserData, DataSize);
- pMsgInfo->dataSize = DataSize;
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
- pMsgInfo->encodeType = MSG_ENCODE_UCS2;
- pMsgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
- }
-
- MSG_DEBUG("Data Size [%zu]", pMsgInfo->dataSize);
- MSG_DEBUG("Data [%s]", tmpBuf);
-
- if (pMsgInfo->dataSize > MAX_MSG_TEXT_LEN) {
- pMsgInfo->bTextSms = false;
-
- /** Save Message Data into File */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "######## MsgCreateFileName Fail !!! #######");
-
- MSG_SEC_DEBUG("Save Message Data into file : size[%zu] name[%s]\n", pMsgInfo->dataSize, fileName);
- if (MsgWriteIpcFile(fileName, tmpBuf, pMsgInfo->dataSize) == false)
- THROW(MsgException::FILE_ERROR, "######## MsgWriteIpcFile Fail !!! #######");
-
- strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
- } else {
- pMsgInfo->bTextSms = true;
-
- memset(pMsgInfo->msgText, 0x00, sizeof(pMsgInfo->msgText));
- memcpy(pMsgInfo->msgText, tmpBuf, pMsgInfo->dataSize);
- }
-}
-
-#ifdef CONCAT_SIM_MSG_OPERATION
-void SmsPluginConcatHandler::convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pConcatMsg, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- /* Convert Type values */
- pMsgInfo->msgType.mainType = MSG_SMS_TYPE;
- pMsgInfo->msgType.subType = MSG_CONCAT_SIM_SMS;
-
- /* set folder id (temporary) */
- pMsgInfo->folderId = MSG_INBOX_ID;
-
- pMsgInfo->storageId = MSG_STORAGE_SIM;
-
- switch (pConcatMsg->dcs.msgClass) {
- case SMS_MSG_CLASS_0:
- pMsgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- pMsgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- pMsgInfo->msgType.classType = MSG_CLASS_2;
- break;
- case SMS_MSG_CLASS_3:
- pMsgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- pMsgInfo->msgType.classType = MSG_CLASS_NONE;
- }
-
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
- time_t rawtime = time(NULL);
-
-/*** Comment below lines to save local UTC time..... (it could be used later.)
-
- if (pTpdu->timeStamp.format == SMS_TIME_ABSOLUTE) {
-
- MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
- MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
- MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
- MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
- MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
- MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
- MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
-
- char displayTime[32];
- struct tm * timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
- timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
- timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
- timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
- timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
- timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%d]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
- rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
-
-***/
-
- pMsgInfo->displayTime = rawtime;
-
- /* Convert Address values */
- pMsgInfo->nAddressCnt = 1;
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(pMsgInfo->addressList[0].addressVal, pConcatMsg->originAddress.address, MAX_ADDRESS_VAL_LEN);
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-
- /* Insert SMS_CONCAT_SIM_MSG_S into File */
- SMS_CONCAT_SIM_MSG_S concatSimMsg = {0};
-
- for (unsigned int i = 0; i < simIdList.size(); i++) {
- if (simIdList[i].msgRef == pConcatMsg->msgRef) {
- MSG_DEBUG("Get SIM ID [%d] - List Index [%d]", simIdList[i].simId, concatSimMsg.simIdCnt);
-
- concatSimMsg.simIdList[concatSimMsg.simIdCnt] = simIdList[i].simId;
- concatSimMsg.simIdCnt++;
- }
- }
-
- int bufSize = (MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM) + 1;
-
- char tmpBuf[bufSize];
- memset(tmpBuf, 0x00, sizeof(tmpBuf));
-
- /* Convert Data values */
- if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_7BIT) {
- SMS_LANG_INFO_S langInfo = {0};
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- pMsgInfo->encodeType = MSG_ENCODE_GSM7BIT;
- pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertGSM7bitToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize, &langInfo);
- } else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_8BIT) {
- pMsgInfo->encodeType = MSG_ENCODE_8BIT;
- memcpy(tmpBuf, pUserData, DataSize);
- pMsgInfo->dataSize = DataSize;
- } else if (pConcatMsg->dcs.codingScheme == SMS_CHARSET_UCS2) {
- pMsgInfo->encodeType = MSG_ENCODE_UCS2;
- pMsgInfo->dataSize = SmsPluginTextConvert::instance()->convertUCS2ToUTF8((unsigned char*)tmpBuf, bufSize, (unsigned char*)pUserData, DataSize);
- }
-
- MSG_DEBUG("Data Size [%d]", pMsgInfo->dataSize);
-
- pMsgInfo->bTextSms = false;
-
- if (pMsgInfo->dataSize > 0)
- memcpy(concatSimMsg.msgData, tmpBuf, pMsgInfo->dataSize);
-
- /* Save Message Data into File */
- char fileName[MAX_COMMON_INFO_SIZE+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
-
- if (MsgWriteIpcFile(fileName, (char*)(&concatSimMsg), sizeof(SMS_CONCAT_SIM_MSG_S)) == false)
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
-
- memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData));
- strncpy(pMsgInfo->msgData, fileName, MAX_MSG_DATA_LEN);
-
- MSG_SEC_DEBUG("Save Message Data into file : size[%d] name[%s]", pMsgInfo->dataSize, fileName);
-}
-#endif
-
-
-void SmsPluginConcatHandler::removeFromConcatList(unsigned short MsgRef, int simIndex, char *originAddress)
-{
- for (int index = concatList.size()-1; index >= 0 ; index--) {
- if (concatList[index].msgRef == MsgRef && concatList[index].simIndex == simIndex
- && g_strcmp0(concatList[index].originAddress.address, originAddress) == 0) {
- MSG_DEBUG("remove concatlist of the index [%d]", index);
- concatList.erase(concatList.begin()+index);
- break;
- }
- }
-}
-
-#ifdef CONCAT_SIM_MSG_OPERATION
-void SmsPluginConcatHandler::addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId)
-{
- SMS_SIM_ID_S simIdStruct;
-
- simIdStruct.msgRef = MsgRef;
- simIdStruct.simId = SimMsgId;
-
- simIdList.push_back(simIdStruct);
-}
-
-
-void SmsPluginConcatHandler::removeFromSimIdList(unsigned short MsgRef)
-{
- for (int index = simIdList.size()-1; index >= 0 ; index--) {
- if (simIdList[index].msgRef == MsgRef) {
- MSG_DEBUG("remove simIdList of the index [%d]", index);
-
- simIdList.erase(simIdList.begin()+index);
- }
- }
-}
-#endif
* limitations under the License.
*/
-#include <errno.h>
+#include <utility>
+#include <telephony_common.h>
+#include <telephony_sim.h>
+#include <ITapiNetwork.h>
+#include <ITapiSim.h>
+#include <TelSms.h>
+
#include "MsgDebug.h"
#include "MsgException.h"
-#include "SmsPluginDSHandler.h"
#include "MsgGconfWrapper.h"
+#include "MsgUtilFunction.h"
-extern "C" {
- #include <tapi_common.h>
- #include <TelNetwork.h>
- #include <ITapiNetwork.h>
- #include <ITapiSim.h>
- #include <telephony_common.h>
- #include <telephony_sim.h>
-}
+#include "SmsPluginDSHandler.h"
/*==================================================================================================
- IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
+ Variables
==================================================================================================*/
SmsPluginDSHandler* SmsPluginDSHandler::pInstance = NULL;
-
-SmsPluginDSHandler::SmsPluginDSHandler()
-{
- cp_list = NULL;
- memset(&handle_list, 0x00, sizeof(handle_list));
-}
-
-
-SmsPluginDSHandler::~SmsPluginDSHandler()
-{
-}
-
-
+/*==================================================================================================
+ Methods of SmsPluginDSHandler
+==================================================================================================*/
SmsPluginDSHandler* SmsPluginDSHandler::instance()
{
- if (!pInstance)
+ if (!pInstance) {
pInstance = new SmsPluginDSHandler();
+ }
return pInstance;
}
int SmsPluginDSHandler::initTelHandle()
{
- int cnt = 0;
- cp_list = tel_get_cp_name_list();
+ HandleType type = (MsgCheckFeatureSupport(MSG_TELEPHONY_CDMA_FEATURE) == false) ? HandleType::H_3GPP : HandleType::H_3GPP2;
- if (!cp_list) {
- MSG_FATAL("tel_get_cp_name_list returns null");
- goto FINISH;
- }
+ char **cpNameList = tel_get_cp_name_list();
+ MSG_ERR_RET_VM(!cpNameList, 0, "tel_get_cp_name_list() returns null!");
- while (cp_list[cnt] && cnt < MAX_TELEPHONY_HANDLE_CNT) {
- MSG_SEC_INFO("cp_list[%d]:[%s]", cnt, cp_list[cnt]);
- handle_list.handle[cnt]= tel_init(cp_list[cnt]);
+ int cnt = 0;
+ while (cpNameList[cnt] && cnt < MAX_TELEPHONY_HANDLE_CNT) {
+ MSG_SEC_INFO("cpNameList[%d]: (%s)", cnt, cpNameList[cnt]);
+ TapiHandle *handle = tel_init(cpNameList[cnt]);
+ tapiHandles.push_back(std::pair<TapiHandle *, HandleType>(handle, type));
cnt++;
- }
- g_strfreev(cp_list);
+ int smsFormat = 0x03;
+ //in SR Tapi side, TAPI_PROP_SMS_FORMAT is not defined.
+ //So setting the SMS format from MEssage Service side.
+ //Will change the below comments after discussing with HQ Team.
+ /*int tRet = tel_get_property_int(handle, TAPI_PROP_SMS_FORMAT, &smsFormat);
+ if (tRet != TAPI_API_SUCCESS) {
+ MSG_ERR("tel_get_property_int() failed (%d)", tRet);
+ //0x03 means Default SMS format - real format should be determined by msg-service side
+ smsFormat = 0x03;
+ }*/
+
+ setSmsFormat(handle, smsFormat);
+ }
+ g_strfreev(cpNameList);
-FINISH:
- handle_list.count = cnt;
return cnt;
}
void SmsPluginDSHandler::deinitTelHandle()
{
- int ret = 0;
+ int tRet = 0;
- for (int i = 0; i < handle_list.count; i++) {
- ret = tel_deinit(handle_list.handle[i]);
- MSG_DEBUG("tel_deinit ret=[%d]", ret);
- handle_list.handle[i] = NULL;
+ for (const std::pair<TapiHandle *, HandleType> &handleInfo : tapiHandles) {
+ tRet = tel_deinit(handleInfo.first);
+ MSG_WARN_M(tRet != TAPI_API_SUCCESS, "tel_deinit() failed: (%d)", tRet);
}
-
- handle_list.count = 0;
- cp_list = NULL;
-
- return;
+ tapiHandles.clear();
}
-TapiHandle *SmsPluginDSHandler::getTelHandle(int sim_idx)
+TapiHandle *SmsPluginDSHandler::getTelHandle(int simIndex)
{
- if (sim_idx > 0 && sim_idx < MAX_TELEPHONY_HANDLE_CNT) {
- return handle_list.handle[sim_idx-1];
- } else {
- int SIM_Status = 0;
- if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT, &SIM_Status) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- if (SIM_Status == 1) {
- return handle_list.handle[0];
+ if (tapiHandles.size() > 0) {
+ if (simIndex > 0 && simIndex <= static_cast<int>(tapiHandles.size())) {
+ return tapiHandles[simIndex - 1].first;
+ } else {
+ int simStatus = 0;
+ if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT, &simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
+ }
+
+ if (simStatus == 1) {
+ return tapiHandles[0].first;
+ }
+
+ if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT2, &simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
+ }
+
+ if (simStatus == 1) {
+ return tapiHandles[1].first;
+ }
}
- if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT2, &SIM_Status) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- if (SIM_Status == 1) {
- return handle_list.handle[1];
- }
+ return tapiHandles[tapiHandles.size() - 1].first;
+ } else {
+ MSG_ERR("Error tapiHandles.size [%d]", tapiHandles.size());
+ return NULL;
}
-
- return handle_list.handle[handle_list.count - 1];
}
int SmsPluginDSHandler::getSimIndex(TapiHandle *handle)
{
- for (int index = 0; index < handle_list.count; ++index) {
- if (handle_list.handle[index] == handle)
- return index+1;
+ for (unsigned int index = 0; index < tapiHandles.size(); index++) {
+ if (tapiHandles[index].first == handle) {
+ return index + 1;
+ }
}
+
return 0;
}
+int SmsPluginDSHandler::getTelHandleCount()
+{
+ return tapiHandles.size();
+}
-void SmsPluginDSHandler::getDefaultNetworkSimId(int *simId)
+int SmsPluginDSHandler::getActiveSimCount()
{
- TelNetworkDefaultDataSubs_t defaultSimId = TAPI_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN;
+ int activeSimCount = 0;
+ int simStatus = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
+
+ if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT, &simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
+ }
- int tapi_ret = TAPI_API_SUCCESS;
+ if (simStatus == VCONFKEY_TELEPHONY_SIM_INSERTED)
+ activeSimCount++;
- if (handle_list.count == 1) {
- *simId = 1;
- return;
+ if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT2, &simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
}
- tapi_ret = tel_get_network_default_data_subscription(handle_list.handle[0], &defaultSimId);
+ if (simStatus == VCONFKEY_TELEPHONY_SIM_INSERTED)
+ activeSimCount++;
- MSG_INFO("Default network subscription = [SIM %d]", (int)defaultSimId+1);
+ MSG_DEBUG("active sim count: (%d)", activeSimCount);
- if (tapi_ret != TAPI_API_SUCCESS) {
- *simId = 0;
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_network_default_data_subscription Fail !!! return : %d #######", tapi_ret);
- } else {
- *simId = (int)defaultSimId + 1;
- }
+ return activeSimCount;
}
-int SmsPluginDSHandler::getTelHandleCount()
+void SmsPluginDSHandler::getDefaultNetworkSimId(int *simIndex)
{
- return handle_list.count;
+ if (tapiHandles.size() == 1) {
+ *simIndex = 1;
+ return;
+ }
+
+ *simIndex = 0;
+
+ TelNetworkDefaultDataSubs_t defaultSimIndex = TAPI_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN;
+ int tRet = tel_get_network_default_data_subscription(tapiHandles[0].first, &defaultSimIndex);
+
+ MSG_INFO("Default network subscription = [SIM %d]", (int)defaultSimIndex + 1);
+
+ if (tRet != TAPI_API_SUCCESS) {
+ THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_network_default_data_subscription Fail !!! return : %d #######", tRet);
+ } else {
+ if (defaultSimIndex == TAPI_NETWORK_DEFAULT_DATA_SUBS_SIM1) {
+ *simIndex = 1;
+ } else if (defaultSimIndex == TAPI_NETWORK_DEFAULT_DATA_SUBS_SIM2) {
+ *simIndex = 2;
+ }
+ }
}
-int SmsPluginDSHandler::getActiveSimCount()
+msg_error_t SmsPluginDSHandler::getSubscriberId(int simIndex, char **subscriber_id)
{
- int active_count = 0;
- int sim_status = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
+ MSG_ERR_RET_VM(simIndex <= 0 || simIndex > static_cast<int>(tapiHandles.size()), MSG_ERR_INVALID_PARAMETER, "Invalid parameter: simIndex: (%d)", simIndex);
- if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT, &sim_status) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- MSG_DEBUG("sim1 status : %d", sim_status);
- if (sim_status == VCONFKEY_TELEPHONY_SIM_INSERTED)
- active_count++;
+ telephony_handle_list_s capi_tel_handle_list;
- sim_status = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
- if (MsgSettingGetInt(VCONFKEY_TELEPHONY_SIM_SLOT2, &sim_status) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- MSG_DEBUG("sim2 status : %d", sim_status);
- if (sim_status == VCONFKEY_TELEPHONY_SIM_INSERTED)
- active_count++;
+ int tRet = telephony_init(&capi_tel_handle_list);
+ MSG_ERR_RET_VM(tRet != TELEPHONY_ERROR_NONE, MSG_ERR_PLUGIN_TAPIINIT, "telephony_init() failed: (%d)", tRet);
- MSG_DEBUG("active sim count : %d", active_count);
+ tRet = telephony_sim_get_subscriber_id(capi_tel_handle_list.handle[simIndex - 1], subscriber_id);
+ MSG_WARN_M(tRet != TELEPHONY_ERROR_NONE, "telephony_sim_get_subscriber_id() failed: (%d)", tRet);
- return active_count;
-}
+ MSG_DEBUG("Subscriber ID is [%s]", *subscriber_id);
+ tRet = telephony_deinit(&capi_tel_handle_list);
+ MSG_WARN_M(tRet != TELEPHONY_ERROR_NONE, "telephony_deinit() failed: (%d)", tRet);
-int SmsPluginDSHandler::getSubscriberId(unsigned int simIndex, char **subscriber_id)
-{
- if (simIndex <= 0 || simIndex > (unsigned int)handle_list.count) {
- MSG_DEBUG("Invalid SIM index");
- return MSG_ERR_INVALID_PARAMETER;
- }
+ return MSG_SUCCESS;
+}
- int tel_ret = TELEPHONY_ERROR_NONE;
- telephony_handle_list_s capi_tel_handle_list;
+int SmsPluginDSHandler::getSmsFormat(TapiHandle *handle)
+{
+ return smsFormatInfo[handle];
+}
- tel_ret = telephony_init(&capi_tel_handle_list);
- if (tel_ret != TELEPHONY_ERROR_NONE) {
- MSG_DEBUG("Initialize failed!!!");
- return MSG_ERR_PLUGIN_TAPIINIT;
+void SmsPluginDSHandler::setSmsFormat(TapiHandle *handle, int smsFormat)
+{
+ MSG_INFO("Sms format: (%d)", smsFormat);
+
+ /* SMS Format
+ * 3gpp : TAPI_NETTEXT_NETTYPE_3GPP
+ * 3gpp2 : TAPI_NETTEXT_NETTYPE_3GPP2
+ * default : Default SMS format - real format should be determined by msg-service side
+ */
+
+ if (smsFormat == TAPI_NETTEXT_NETTYPE_3GPP || smsFormat == TAPI_NETTEXT_NETTYPE_3GPP2) {
+ smsFormatInfo[handle] = smsFormat;
+ } else if (smsFormat == 0x03) {
+ if (getHandleType(handle) == HandleType::H_3GPP) {
+ smsFormatInfo[handle] = TAPI_NETTEXT_NETTYPE_3GPP;
+ } else {
+ smsFormatInfo[handle] = TAPI_NETTEXT_NETTYPE_3GPP2;
+ }
+ } else {
+ MSG_ERR("Invalid sms format: (%d) - set as default!", smsFormat);
+ smsFormatInfo[handle] = TAPI_NETTEXT_NETTYPE_3GPP;
}
+}
- tel_ret = telephony_sim_get_subscriber_id(capi_tel_handle_list.handle[simIndex-1], subscriber_id);
- if (tel_ret != TELEPHONY_ERROR_NONE) {
- MSG_DEBUG("telephony_sim_get_subscriber_id() failed!!! [%d]", tel_ret);
+bool SmsPluginDSHandler::getNeedToInitializeSim(TapiHandle *handle)
+{
+ auto search = _needToInitializeSim.find(handle);
+ if (search != _needToInitializeSim.end()) {
+ return search->second;
} else {
- MSG_DEBUG("Subscriber ID is [%s]", *subscriber_id);
+ return false;
}
+}
- tel_ret = telephony_deinit(&capi_tel_handle_list);
- if (tel_ret != TELEPHONY_ERROR_NONE) {
- MSG_DEBUG("Deinitialize failed!!!");
- }
+void SmsPluginDSHandler::setNeedToInitializeSim(TapiHandle *handle, bool needToInitialize)
+{
+ _needToInitializeSim[handle] = needToInitialize;
+}
- return MSG_SUCCESS;
+SmsPluginDSHandler::HandleType SmsPluginDSHandler::getHandleType(TapiHandle *handle)
+{
+ for (const std::pair<TapiHandle *, HandleType> &handleInfo : tapiHandles) {
+ if (handleInfo.first == handle) {
+ return handleInfo.second;
+ }
+ }
+ return SmsPluginDSHandler::HandleType::H_3GPP;
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <bundle.h>
-#include <eventsystem.h>
-
-#include "MsgDebug.h"
-#include "MsgUtilFile.h"
-#include "MsgUtilFunction.h"
-#include "MsgCppTypes.h"
-#include "MsgContact.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-#include "MsgDevicedWrapper.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginSetting.h"
-#include "SmsPluginConcatHandler.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginDSHandler.h"
-#include "SmsPluginParamCodec.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginEventHandler - Member Functions
-==================================================================================================*/
-SmsPluginEventHandler* SmsPluginEventHandler::pInstance = NULL;
-
-
-SmsPluginEventHandler::SmsPluginEventHandler()
-{
- /** Initialize global parameters */
- memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S));
- memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S));
-
- pSimCnt = NULL;
- devStatus = false;
- bUdhMwiMethod = false;
- udhMwiCnt = 0;
- devHandle = NULL;
-}
-
-
-SmsPluginEventHandler::~SmsPluginEventHandler()
-{
-}
-
-
-SmsPluginEventHandler* SmsPluginEventHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginEventHandler();
-
- return pInstance;
-}
-
-
-void SmsPluginEventHandler::registerListener(MSG_PLUGIN_LISTENER_S *pListener)
-{
- listener = *pListener;
-}
-
-
-void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
-{
- MSG_DEBUG("NetStatus[%d]", NetStatus);
-
- if (sentInfo.bLast == true || NetStatus != MSG_NETWORK_SEND_SUCCESS) {
- /** Update Msg Status */
- if (sentInfo.reqInfo.msgInfo.msgPort.valid == false) {
- /*SmsPluginStorage::instance()->updateSentMsg(&(sentInfo.reqInfo.msgInfo), NetStatus); */
-
- sentInfo.reqInfo.msgInfo.networkStatus = NetStatus;
-
- if (NetStatus == MSG_NETWORK_SEND_SUCCESS) {
- /* contacts-service is not used for gear */
-#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
- MSG_DEBUG("Add phone log");
- MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
-#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
- sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID; /* It should be set after adding phone log. */
- /* Send system event */
- bundle *b = NULL;
- b = bundle_create();
- if (b) {
- if (sentInfo.reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE)
- bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_SMS);
- else
- bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_OUT_MSG_MMS);
-
- char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
- snprintf(msgId, sizeof(msgId), "%u", sentInfo.reqInfo.msgInfo.msgId);
- bundle_add_str(b, EVT_KEY_OUT_MSG_ID, msgId);
- eventsystem_send_system_event(SYS_EVENT_OUTGOING_MSG, b);
- bundle_free(b);
- }
- } else {
- sentInfo.reqInfo.msgInfo.bRead = false;
- }
-
- SmsPluginStorage::instance()->updateSmsMessage(&(sentInfo.reqInfo.msgInfo));
-
- callbackStorageChange(MSG_STORAGE_CHANGE_UPDATE, &(sentInfo.reqInfo.msgInfo));
- }
-
- MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bSetting [%d]", sentInfo.reqInfo.sendOptInfo.bSetting);
- MSG_DEBUG("sentInfo.reqInfo.sendOptInfo.bKeepCopy [%d]", sentInfo.reqInfo.sendOptInfo.bKeepCopy);
- /** Check sending options */
- if (sentInfo.reqInfo.sendOptInfo.bSetting && !sentInfo.reqInfo.sendOptInfo.bKeepCopy && NetStatus == MSG_NETWORK_SEND_SUCCESS) {
- SmsPluginStorage::instance()->deleteSmsMessage(sentInfo.reqInfo.msgInfo.msgId);
- callbackStorageChange(MSG_STORAGE_CHANGE_DELETE, &(sentInfo.reqInfo.msgInfo));
- }
-
- /** Callback to MSG FW */
- MSG_SENT_STATUS_S msgStatus;
-
- msgStatus.reqId = sentInfo.reqInfo.reqId;
- msgStatus.status = NetStatus;
-
- MSG_DEBUG("sentStatus.reqId : %d", msgStatus.reqId);
- MSG_DEBUG("sentStatus.status : %d", msgStatus.status);
-
- listener.pfSentStatusCb(&msgStatus);
- }
-}
-
-
-void SmsPluginEventHandler::handleMsgIncoming(TapiHandle *handle, SMS_TPDU_S *pTpdu)
-{
- /** Make MSG_MESSAGE_INFO_S */
- MSG_MESSAGE_INFO_S msgInfo;
- MSG_MESSAGE_INFO_S stored_msgInfo;
-
- /** initialize msgInfo */
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
-
- if (pTpdu->tpduType == SMS_TPDU_DELIVER) {
- /** check unsupported message */
- if (pTpdu->data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && pTpdu->data.deliver.pid == 0x11) {
- MSG_DEBUG("Unsupported message!!");
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
- return;
- }
- }
-
- bUdhMwiMethod = false;
- udhMwiCnt = 0;
-
- if (pTpdu->data.deliver.dcs.msgClass == SMS_MSG_CLASS_2)
- msgInfo.storageId = MSG_STORAGE_UNKNOWN;
- else
- msgInfo.storageId = MSG_STORAGE_PHONE;
-
- msgInfo.sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- /** convert to msgInfo */
- convertTpduToMsginfo(pTpdu, &msgInfo);
-
- if (msgInfo.msgPort.valid == true) {
- if ((msgInfo.msgPort.dstPort >= 0x23F4 && msgInfo.msgPort.dstPort <= 0x23F7) || /** Check unsupported message (Vcard WAP push) **/
- (msgInfo.msgPort.dstPort == 0x1581)) { /** Check unsupported message (ringtone smart message) **/
- memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "<Unsupported message>");
- msgInfo.dataSize = strlen(msgInfo.msgText);
- msgInfo.msgPort.valid = false;
- }
- }
-
- bool bStoreVoiceMsg = false;
-
- if (bUdhMwiMethod == false) {
- /** check MWI and set info to SIM for DCS & Address method */
- if (pTpdu->tpduType == SMS_TPDU_DELIVER && pTpdu->data.deliver.dcs.bMWI == true) {
- int MwiCnt = 0;
- MSG_DEBUG("MWI message - DCS method");
-
- if (pTpdu->data.deliver.dcs.bIndActive == false) {
- SmsPluginSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 0);
- MwiCnt = 0;
- } else {
- SmsPluginSetting::instance()->setMwiInfo(msgInfo.sim_idx, msgInfo.msgType.subType, 1);
- MwiCnt = 1;
-
- /* For address method */
- if (pTpdu->data.deliver.pid == 0x20 && pTpdu->data.deliver.originAddress.ton == SMS_TON_ALPHANUMERIC) {
- MSG_DEBUG("MWI message - Address method");
- char *voiceNumber = NULL;
- char *voiceAlphaId = NULL;
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msgInfo.sim_idx);
- if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msgInfo.sim_idx);
- if (MsgSettingGetString(keyName, &voiceAlphaId) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- memset(msgInfo.addressList[0].addressVal, 0x00, sizeof(msgInfo.addressList[0].addressVal));
- memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
-
- if (voiceNumber) {
- snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNumber);
- free(voiceNumber);
- voiceNumber = NULL;
- }
-
- if (voiceAlphaId) {
- snprintf(msgInfo.addressList[0].displayName, sizeof(msgInfo.addressList[0].displayName), "%s", voiceAlphaId);
- free(voiceAlphaId);
- voiceAlphaId = NULL;
- }
- }
- }
-
- if (pTpdu->data.deliver.dcs.codingGroup == SMS_GROUP_STORE) {
- bStoreVoiceMsg = true;
- memset(&stored_msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
- memcpy(&stored_msgInfo, &msgInfo, sizeof(MSG_MESSAGE_INFO_S));
- stored_msgInfo.msgType.subType = MSG_NORMAL_SMS;
- }
-
- memset(msgInfo.msgText, 0x00, sizeof(msgInfo.msgText));
- switch (msgInfo.msgType.subType) {
- case MSG_MWI_VOICE_SMS :
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", MwiCnt);
- break;
- case MSG_MWI_FAX_SMS :
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new fax message", MwiCnt);
- break;
- case MSG_MWI_EMAIL_SMS :
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new email message", MwiCnt);
- break;
- default :
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new special message", MwiCnt);
- break;
- }
- msgInfo.dataSize = strlen(msgInfo.msgText);
-
- if (pTpdu->data.deliver.dcs.codingGroup == SMS_GROUP_DISCARD)
- msgInfo.bStore = false;
- }
- }
-
- /** Short Message Type 0 - Just Send Deliver Report */
- if (msgInfo.msgType.subType == MSG_TYPE0_SMS) {
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
- return;
- }
-
- /** Print MSG_MESSAGE_INFO_S */
- MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
- MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
- if (msgInfo.nAddressCnt > 0) {
- MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
- MSG_SEC_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
- MSG_SEC_DEBUG("msgInfo.addressList[0].displayName : %s", msgInfo.addressList[0].displayName);
- }
- MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
- MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
- MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
- MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
- MSG_DEBUG("msgInfo.bStore : %d", msgInfo.bStore);
- MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
- MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
- MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
- MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
- MSG_DEBUG("msgInfo.displayTime : %ld", msgInfo.displayTime);
- MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid);
- MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType);
- MSG_DEBUG("msgInfo.dataSize : %zu", msgInfo.dataSize);
- MSG_DEBUG("msgInfo.sim_idx : %d", msgInfo.sim_idx);
-
- if (msgInfo.bTextSms == true) {
- MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
- } else {
- MSG_SEC_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
- }
-
- MSG_DEBUG("###############################################################");
-
- msg_error_t err = MSG_SUCCESS;
-
- if (msgInfo.msgType.subType == MSG_STATUS_REPORT_SMS) {
- /** Status Report Message */
- err = SmsPluginStorage::instance()->updateMsgDeliverStatus(&msgInfo, pTpdu->data.statusRep.msgRef);
-
- if (err == MSG_SUCCESS)
- err = listener.pfMsgIncomingCb(&msgInfo);
- else
- MSG_DEBUG("updateMsgDeliverStatus is failed [%d]", err);
-
- /** Handling of Fail Case ?? */
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
- } else { /** SMS Deliver */
- /** Class 2 Msg */
- if (msgInfo.msgType.classType == MSG_CLASS_2) {
- if (msgInfo.bTextSms == false) { /** Concat Msg cannot be saved in SIM */
- msgInfo.msgType.classType = MSG_CLASS_NONE;
- msgInfo.storageId = MSG_STORAGE_PHONE;
- } else {
- /** set total segment of Class2 message as 1 */
- SmsPluginSimMsg::instance()->setSmsTpduTotalSegCount(1);
- }
- }
-
- /** Add message to DB */
- if (msgInfo.msgPort.valid == false) {
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
- }
-
- /** Callback to MSG FW */
- if (msgInfo.msgType.classType == MSG_CLASS_2) {
- if (((msgInfo.msgType.subType >= MSG_MWI_VOICE_SMS) && (msgInfo.msgType.subType <= MSG_MWI_OTHER_SMS)) &&
- (msgInfo.bStore == false)) {
- if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
- MSG_DEBUG("listener.pfMsgIncomingCb is failed!");
-
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
- }
- } else {
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("callback to msg fw");
- err = listener.pfMsgIncomingCb(&msgInfo);
- if (bStoreVoiceMsg) {
- err = listener.pfMsgIncomingCb(&stored_msgInfo);
- }
- } else {
- if (msgInfo.msgType.classType == MSG_CLASS_0) {
- MSG_DEBUG("callback for class0 message to msg fw");
- if (listener.pfMsgIncomingCb(&msgInfo) != MSG_SUCCESS)
- MSG_DEBUG("listener.pfMsgIncomingCb is failed!");
- }
- }
-
- /** Send Deliver Report */
- if (msgInfo.msgType.classType == MSG_CLASS_0)
- SmsPluginTransport::instance()->sendClass0DeliverReport(handle, err);
- else
- SmsPluginTransport::instance()->sendDeliverReport(handle, err);
- }
-
- /* Tizen Validation System */
- char *msisdn = NULL;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, msgInfo.sim_idx);
- if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- MSG_SMS_VLD_INFO("%d, SMS Receive, %s->%s, %s", msgInfo.msgId, \
- msgInfo.addressList[0].addressVal, \
- (msisdn == NULL)?"ME":msisdn, \
- (err == MSG_SUCCESS)?"Success":"Fail");
-
- MSG_SMS_VLD_TXT("%d, [%s]", msgInfo.msgId, msgInfo.msgText);
-
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
- }
-}
-
-void SmsPluginEventHandler::handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *application_id, char *content_type)
-{
- MSG_PUSH_MESSAGE_DATA_S pushData;
-
- memset(&pushData, 0x00, sizeof(MSG_PUSH_MESSAGE_DATA_S));
-
- /** set PUSH data */
- memcpy(pushData.pushHeader, pPushHeader, strlen(pPushHeader));
-
- pushData.pushBodyLen = pushBodyLen;
- memcpy(pushData.pushBody, pPushBody, pushBodyLen);
-
- memcpy(pushData.pushAppId, application_id, MAX_WAPPUSH_ID_LEN);
- memcpy(pushData.pushContentType, content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
-
- /** Callback to MSG FW */
- listener.pfPushMsgIncomingCb(&pushData);
-}
-
-
-void SmsPluginEventHandler::handleResendMessage(void)
-{
- listener.pfResendMessageCb();
-}
-
-
-void SmsPluginEventHandler::handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, int simIndex)
-{
- MSG_SYNCML_MESSAGE_DATA_S syncMLData;
-
- memset(&syncMLData, 0x00, sizeof(MSG_SYNCML_MESSAGE_DATA_S));
-
- /** set syncML data */
- syncMLData.syncmlType = msgType;
-
- syncMLData.simIndex = simIndex;
-
- syncMLData.pushBodyLen = PushBodyLen;
- memcpy(syncMLData.pushBody, pPushBody, PushBodyLen);
-
- syncMLData.wspHeaderLen = WspHeaderLen;
- memcpy(syncMLData.wspHeader, pWspHeader, WspHeaderLen);
-
- /** Callback to MSG FW */
- listener.pfSyncMLMsgIncomingCb(&syncMLData);
-}
-
-
-void SmsPluginEventHandler::handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen)
-{
- MSG_LBS_MESSAGE_DATA_S lBSData;
-
- memset(&lBSData, 0x00, sizeof(MSG_LBS_MESSAGE_DATA_S));
-
- /** set LBA data */
- memcpy(lBSData.pushHeader, pPushHeader, strlen(pPushHeader));
-
- lBSData.pushBodyLen = pushBodyLen;
- memcpy(lBSData.pushBody, pPushBody, pushBodyLen);
-
- /** Callback to MSG FW */
- listener.pfLBSMsgIncomingCb(&lBSData);
-}
-
-msg_error_t SmsPluginEventHandler::callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Callback to MSG FW */
- err = listener.pfMsgIncomingCb(pMsgInfo);
-
- MSG_END();
-
- return err;
-}
-
-msg_error_t SmsPluginEventHandler::callbackCBMsgIncoming(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Callback to MSG FW */
- err = listener.pfCBMsgIncomingCb(pCbMsg, pMsgInfo);
-
- MSG_END();
-
- return err;
-}
-
-
-msg_error_t SmsPluginEventHandler::callbackInitSimBySat()
-{
- /** Callback to MSG FW */
- return listener.pfInitSimBySatCb();
-}
-
-
-msg_error_t SmsPluginEventHandler::callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- msg_id_list_s msgIdList;
- msg_message_id_t msgIds[1];
- memset(&msgIdList, 0x00, sizeof(msg_id_list_s));
-
- msgIdList.nCount = 1;
- msgIds[0] = pMsgInfo->msgId;
- msgIdList.msgIdList = msgIds;
-
- /* Callback to MSG FW */
- listener.pfStorageChangeCb(storageChangeType, &msgIdList);
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginEventHandler::callbackThreadChange(msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId)
-{
- /* Callback to MSG FW */
- listener.pfThreadChangeCb(storageChangeType, threadId);
-
- return MSG_SUCCESS;
-}
-
-
-void SmsPluginEventHandler::convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
-{
- switch (pTpdu->tpduType) {
- case SMS_TPDU_SUBMIT :
- convertSubmitTpduToMsginfo(&pTpdu->data.submit, msgInfo);
- break;
- case SMS_TPDU_DELIVER :
- convertDeliverTpduToMsginfo(&pTpdu->data.deliver, msgInfo);
- break;
- case SMS_TPDU_STATUS_REP :
- convertStatusRepTpduToMsginfo(&pTpdu->data.statusRep, msgInfo);
- break;
- }
-}
-
-
-void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
-{
- int addressListCnt = 0;
-
- /** Convert Type values */
- msgInfo->msgType.mainType = MSG_SMS_TYPE;
- msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
-
- /** set folder id (temporary) */
- msgInfo->folderId = MSG_SENTBOX_ID;
-
- switch (pTpdu->dcs.msgClass) {
- case SMS_MSG_CLASS_0:
- msgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- msgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- msgInfo->msgType.classType = MSG_CLASS_2;
- break;
- case SMS_MSG_CLASS_3:
- msgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- msgInfo->msgType.classType = MSG_CLASS_NONE;
- break;
- }
-
- msgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
- msgInfo->bRead = false;
- msgInfo->bProtected = false;
- msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- msgInfo->direction = MSG_DIRECTION_TYPE_MO;
- msgInfo->bTextSms = true;
-
- memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
-
- /** What kind of time has to be saved?? (temporary store time) */
- msgInfo->displayTime = time(NULL);
-
- /** Convert Address values */
- msgInfo->nAddressCnt = 1;
-
- msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- msgInfo->addressList[addressListCnt].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(msgInfo->addressList[addressListCnt].addressVal, pTpdu->destAddress.address, MAX_ADDRESS_VAL_LEN);
-
- /**exception operation for none userdata */
- if (pTpdu->userData.length == 0) {
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]");
- msgInfo->dataSize = strlen(msgInfo->msgText);
- return;
- }
-
- /** Convert Data values */
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
- MSG_LANG_INFO_S langInfo = {0, };
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- msgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
- msgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
- }
-}
-
-
-void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
-{
- MSG_BEGIN();
-
- /** Convert Type values */
- msgInfo->msgType.mainType = MSG_SMS_TYPE;
- msgInfo->msgType.subType = convertMsgSubType(pTpdu->pid);
-
- /** set folder id (temporary) */
- msgInfo->folderId = MSG_INBOX_ID;
-
- time_t rawtime = 0;
- if (msgInfo->storageId == MSG_STORAGE_SIM) {
- /*** Comment below lines to save local UTC time..... (it could be used later.)
- ***/
- if (pTpdu->timeStamp.format == SMS_TIME_ABSOLUTE) {
- MSG_DEBUG("year : %d", pTpdu->timeStamp.time.absolute.year);
- MSG_DEBUG("month : %d", pTpdu->timeStamp.time.absolute.month);
- MSG_DEBUG("day : %d", pTpdu->timeStamp.time.absolute.day);
- MSG_DEBUG("hour : %d", pTpdu->timeStamp.time.absolute.hour);
- MSG_DEBUG("minute : %d", pTpdu->timeStamp.time.absolute.minute);
- MSG_DEBUG("second : %d", pTpdu->timeStamp.time.absolute.second);
- MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone);
-
- char displayTime[32];
- struct tm timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- timeinfo.tm_year = (pTpdu->timeStamp.time.absolute.year + 100);
- timeinfo.tm_mon = (pTpdu->timeStamp.time.absolute.month - 1);
- timeinfo.tm_mday = pTpdu->timeStamp.time.absolute.day;
- timeinfo.tm_hour = pTpdu->timeStamp.time.absolute.hour;
- timeinfo.tm_min = pTpdu->timeStamp.time.absolute.minute;
- timeinfo.tm_sec = pTpdu->timeStamp.time.absolute.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%lu]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4));
-
- localtime_r(&rawtime, &timeTM);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- localtime_r(&rawtime, &timeTM);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
- } else {
- rawtime = time(NULL);
- }
-
- msgInfo->displayTime = rawtime;
-
- switch (pTpdu->dcs.msgClass) {
- case SMS_MSG_CLASS_0:
- msgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- msgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- msgInfo->msgType.classType = MSG_CLASS_2;
- msgInfo->storageId = MSG_STORAGE_SIM;
- break;
- case SMS_MSG_CLASS_3:
- msgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- msgInfo->msgType.classType = MSG_CLASS_NONE;
- break;
- }
-
- if (pTpdu->dcs.bMWI) {
- if (pTpdu->dcs.indType == SMS_VOICE_INDICATOR)
- msgInfo->msgType.subType = MSG_MWI_VOICE_SMS;
- else if (pTpdu->dcs.indType == SMS_VOICE2_INDICATOR)
- msgInfo->msgType.subType = MSG_MWI_VOICE2_SMS;
- else if (pTpdu->dcs.indType == SMS_FAX_INDICATOR)
- msgInfo->msgType.subType = MSG_MWI_FAX_SMS;
- else if (pTpdu->dcs.indType == SMS_EMAIL_INDICATOR)
- msgInfo->msgType.subType = MSG_MWI_EMAIL_SMS;
- else if (pTpdu->dcs.indType == SMS_OTHER_INDICATOR)
- msgInfo->msgType.subType = MSG_MWI_OTHER_SMS;
- }
-
- msgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- msgInfo->bRead = false;
- msgInfo->bProtected = false;
- msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- msgInfo->direction = MSG_DIRECTION_TYPE_MT;
- msgInfo->bTextSms = true;
-
- memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
-
- /** Convert Address values */
- msgInfo->nAddressCnt = 1;
-
- msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(msgInfo->addressList[0].addressVal, pTpdu->originAddress.address, MAX_ADDRESS_VAL_LEN);
-
- msgInfo->msgPort.valid = false;
- msgInfo->msgPort.dstPort = 0;
- msgInfo->msgPort.srcPort = 0;
-
- for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
- /** Convert UDH values - Port Number */
- if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
- msgInfo->msgPort.valid = true;
- msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
- msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
- msgInfo->msgPort.valid = true;
- msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
- msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_SPECIAL_SMS) {
- msgInfo->msgType.subType = (pTpdu->userData.header[i].udh.specialInd.msgInd+MSG_MWI_VOICE_SMS);
- msgInfo->bStore = pTpdu->userData.header[i].udh.specialInd.bStore;
-
- bUdhMwiMethod = true;
-
- if (pTpdu->dcs.codingGroup == SMS_GROUP_DISCARD)
- msgInfo->bStore = false;
-
- udhMwiCnt = pTpdu->userData.header[i].udh.specialInd.waitMsgNum;
-
- if (udhMwiCnt < 0) {
- MSG_DEBUG("Message waiting number is smaller than 0. It will be treated as 0. [%d]", udhMwiCnt);
- udhMwiCnt = 0;
- }
-
- MSG_DEBUG("Message waiting number : [%d]", udhMwiCnt);
-
- SmsPluginSetting::instance()->setMwiInfo(msgInfo->sim_idx, msgInfo->msgType.subType, udhMwiCnt);
-
- if (udhMwiCnt > 0 && (msgInfo->msgType.subType >= MSG_MWI_VOICE_SMS && msgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
- switch (msgInfo->msgType.subType) {
- case MSG_MWI_VOICE_SMS :
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d", udhMwiCnt);
- break;
- case MSG_MWI_FAX_SMS :
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d new fax message", udhMwiCnt);
- break;
- case MSG_MWI_EMAIL_SMS :
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d new email message", udhMwiCnt);
- break;
- default :
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%d new special message", udhMwiCnt);
- break;
- }
- msgInfo->dataSize = strlen(msgInfo->msgText);
- return;
- }
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_ALTERNATE_REPLY_ADDRESS) {
- strncpy(msgInfo->addressList[0].addressVal, pTpdu->userData.header[i].udh.alternateAddress.address, MAX_ADDRESS_VAL_LEN);
- } else if (pTpdu->userData.header[i].udhType >= SMS_UDH_EMS_FIRST && pTpdu->userData.header[i].udhType <= SMS_UDH_EMS_LAST) {
- /* TODO: Raw text should be changed to string design id. Currently there's no design id in message-app-lite */
-/* char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSGF_POP_ERROR_UNSUPPORTED_MSG");
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
-*/
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "Unsupported Message");
- msgInfo->dataSize = strlen(msgInfo->msgText);
-/* if (msg_text) {
- free(msg_text);
- msg_text = NULL;
- }
-*/
- return;
- }
- }
-
- /**length 0 - no user data - msg should be received */
- if (pTpdu->userData.length <= 0) {
- memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
- msgInfo->dataSize = 0;
-
- switch (pTpdu->dcs.codingScheme) {
- case SMS_CHARSET_7BIT:
- msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
- break;
- case SMS_CHARSET_8BIT:
- msgInfo->encodeType = MSG_ENCODE_8BIT;
- break;
- case SMS_CHARSET_UCS2:
- msgInfo->encodeType = MSG_ENCODE_UCS2;
- break;
- default:
- msgInfo->encodeType = MSG_ENCODE_8BIT;
- break;
- }
-
- return;
- } else if (pTpdu->userData.length > MAX_MSG_TEXT_LEN) {
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]");
- msgInfo->dataSize = strlen(msgInfo->msgData);
- return;
- }
-
- /** Convert Data values */
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- if (pTpdu->dcs.codingScheme == SMS_CHARSET_7BIT) {
- MSG_LANG_INFO_S langInfo = {0, };
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
- if (pTpdu->userData.header[i].udhType == SMS_UDH_SINGLE_SHIFT) {
- langInfo.bSingleShift = true;
- langInfo.singleLang = pTpdu->userData.header[i].udh.singleShift.langId;
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_LOCKING_SHIFT) {
- langInfo.bLockingShift = true;
- langInfo.lockingLang = pTpdu->userData.header[i].udh.lockingShift.langId;
- }
- }
-
- msgInfo->encodeType = MSG_ENCODE_GSM7BIT;
- msgInfo->dataSize = textCvt->convertGSM7bitToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length, &langInfo);
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_8BIT) {
- msgInfo->encodeType = MSG_ENCODE_8BIT;
- memcpy(msgInfo->msgText, pTpdu->userData.data, sizeof(pTpdu->userData.data));
- msgInfo->dataSize = pTpdu->userData.length;
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_UCS2) {
- msgInfo->encodeType = MSG_ENCODE_UCS2;
- msgInfo->dataSize = textCvt->convertUCS2ToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
- } else if (pTpdu->dcs.codingScheme == SMS_CHARSET_EUCKR) {
- msgInfo->encodeType = MSG_ENCODE_8BIT;
- msgInfo->dataSize = textCvt->convertEUCKRToUTF8((unsigned char*)msgInfo->msgText, MAX_MSG_TEXT_LEN, (unsigned char*)pTpdu->userData.data, pTpdu->userData.length);
- return;
- }
-
- MSG_END();
-}
-
-
-void SmsPluginEventHandler::convertStatusRepTpduToMsginfo(const SMS_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo)
-{
- /** Convert Type values */
- msgInfo->msgType.mainType = MSG_SMS_TYPE;
- msgInfo->msgType.subType = MSG_STATUS_REPORT_SMS;
-
- /** set folder id */
- msgInfo->folderId = MSG_INBOX_ID;
-
- /** set storage id */
- if (msgInfo->storageId == MSG_STORAGE_UNKNOWN) {
- msgInfo->storageId = MSG_STORAGE_PHONE;
- }
-
- switch (pTpdu->dcs.msgClass) {
- case SMS_MSG_CLASS_0:
- msgInfo->msgType.classType = MSG_CLASS_0;
- break;
- case SMS_MSG_CLASS_1:
- msgInfo->msgType.classType = MSG_CLASS_1;
- break;
- case SMS_MSG_CLASS_2:
- msgInfo->msgType.classType = MSG_CLASS_2;
- break;
- case SMS_MSG_CLASS_3:
- msgInfo->msgType.classType = MSG_CLASS_3;
- break;
- default:
- msgInfo->msgType.classType = MSG_CLASS_NONE;
- break;
- }
-
- MSG_DEBUG("delivery status : [%d]", pTpdu->status);
-
- if (pTpdu->status == SMS_STATUS_RECEIVE_SUCCESS)
- msgInfo->networkStatus = MSG_NETWORK_DELIVER_SUCCESS;
- else if (pTpdu->status == SMS_STATUS_TRY_REQUEST_PENDING)
- msgInfo->networkStatus = MSG_NETWORK_DELIVER_PENDING;
- else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED)
- msgInfo->networkStatus = MSG_NETWORK_DELIVER_EXPIRED;
- else
- msgInfo->networkStatus = MSG_NETWORK_DELIVER_FAIL;
-
- msgInfo->bRead = false;
- msgInfo->bProtected = false;
- msgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- msgInfo->direction = MSG_DIRECTION_TYPE_MT;
- msgInfo->bTextSms = true;
-
- memset(msgInfo->subject, 0x00, MAX_SUBJECT_LEN+1);
-
- msgInfo->displayTime = time(NULL);
-
- /** Convert Address values */
- msgInfo->nAddressCnt = 1;
-
- msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- msgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(msgInfo->addressList[0].addressVal, pTpdu->recipAddress.address, MAX_ADDRESS_VAL_LEN);
-
- msgInfo->msgPort.valid = false;
- msgInfo->msgPort.dstPort = 0;
- msgInfo->msgPort.srcPort = 0;
-
- for (int i = 0; i < pTpdu->userData.headerCnt; i++) {
- /** Convert UDH values - Port Number */
- if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
- msgInfo->msgPort.valid = true;
- msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort8bit.destPort;
- msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort8bit.originPort;
- } else if (pTpdu->userData.header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
- msgInfo->msgPort.valid = true;
- msgInfo->msgPort.dstPort = pTpdu->userData.header[i].udh.appPort16bit.destPort;
- msgInfo->msgPort.srcPort = pTpdu->userData.header[i].udh.appPort16bit.originPort;
- }
- }
-
- memset(msgInfo->msgText, 0x00, sizeof(msgInfo->msgText));
- msgInfo->dataSize = 0;
-
- if (pTpdu->status <= SMS_STATUS_SMSC_SPECIFIC_LAST) {
- char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSG_SBODY_MESSAGE_DELIVERED_M_STATUS_ABB");
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
- msgInfo->dataSize = strlen(msgInfo->msgText);
- if (msg_text) {
- free(msg_text);
- msg_text = NULL;
- }
- } else if (pTpdu->status == SMS_STATUS_TEMP_SERVICE_REJECTED) {
- char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSG_SBODY_MESSAGE_REJECTED_M_STATUS_ABB");
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
- msgInfo->dataSize = strlen(msgInfo->msgText);
- if (msg_text) {
- free(msg_text);
- msg_text = NULL;
- }
- } else if (pTpdu->status == SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED) {
- char *msg_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, "IDS_MSG_SBODY_MESSAGE_EXPIRED_M_STATUS_ABB");
- snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "%s", msg_text);
- msgInfo->dataSize = strlen(msgInfo->msgText);
- if (msg_text) {
- free(msg_text);
- msg_text = NULL;
- }
- } else {
- strncpy(msgInfo->msgText, "Message delivery failed.", MAX_MSG_TEXT_LEN);
- msgInfo->dataSize = strlen(msgInfo->msgText);
- }
-}
-
-
-MSG_SUB_TYPE_T SmsPluginEventHandler::convertMsgSubType(SMS_PID_T pid)
-{
- switch (pid) {
- case SMS_PID_TYPE0 :
- return MSG_TYPE0_SMS;
- case SMS_PID_REPLACE_TYPE1 :
- return MSG_REPLACE_TYPE1_SMS;
- case SMS_PID_REPLACE_TYPE2 :
- return MSG_REPLACE_TYPE2_SMS;
- case SMS_PID_REPLACE_TYPE3 :
- return MSG_REPLACE_TYPE3_SMS;
- case SMS_PID_REPLACE_TYPE4 :
- return MSG_REPLACE_TYPE4_SMS;
- case SMS_PID_REPLACE_TYPE5 :
- return MSG_REPLACE_TYPE5_SMS;
- case SMS_PID_REPLACE_TYPE6 :
- return MSG_REPLACE_TYPE6_SMS;
- case SMS_PID_REPLACE_TYPE7 :
- return MSG_REPLACE_TYPE7_SMS;
- case SMS_PID_RETURN_CALL :
- return MSG_MWI_OTHER_SMS;
- default :
- return MSG_NORMAL_SMS;
- }
-}
-
-
-void SmsPluginEventHandler::SetSentInfo(SMS_SENT_INFO_S *pSentInfo)
-{
- memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S));
- memcpy(&sentInfo, pSentInfo, sizeof(SMS_SENT_INFO_S));
-
- MSG_DEBUG("sentInfo.reqId : %d", sentInfo.reqInfo.reqId);
- MSG_DEBUG("sentInfo.bLast : %d", sentInfo.bLast);
-}
-
-
-void SmsPluginEventHandler::setDeviceStatus(TapiHandle *handle)
-{
- if (handle == devHandle) {
- mx.lock();
- devStatus = true;
- cv.signal();
- mx.unlock();
- }
-}
-
-
-bool SmsPluginEventHandler::getDeviceStatus(TapiHandle *handle)
-{
- int ret = 0;
-
- mx.lock();
- devHandle = handle;
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- if (ret == ETIMEDOUT) {
- MSG_WARN("WARNING: DEVICE STATUS TIME-OUT");
- devStatus = false;
- }
- devHandle = NULL;
- mx.unlock();
- return devStatus;
-}
-
-
-msg_error_t SmsPluginEventHandler::handleSimMsg(MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList, msg_message_id_t *retMsgId, int listSize)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Callback to MSG FW */
- err = listener.pfSimMsgIncomingCb(pMsgInfo, simIdList, retMsgId, listSize);
-
- MSG_END();
-
- return err;
-}
-
-msg_error_t SmsPluginEventHandler::updateIMSI(int sim_idx)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Callback to MSG FW */
- err = listener.pfSimInitImsiCb(sim_idx);
-
- MSG_END();
-
- return err;
-}
-
-void SmsPluginEventHandler::handleSimMemoryFull(int simIndex)
-{
- char keyName[MAX_VCONFKEY_NAME_LEN];
- bool bSimSst = true;
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, simIndex);
- if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS)
- MSG_ERR("MsgSettingGetBool [%s] failed", keyName);
-
- if (bSimSst == true)
- MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
-}
* limitations under the License.
*/
-#include <errno.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <tapi_common.h>
+#include <ITapiNetText.h>
+#include <TelSms.h>
+#include <tzplatform_config.h>
#include "MsgDebug.h"
#include "MsgException.h"
#include "MsgGconfWrapper.h"
+#include "MsgPluginInterface.h"
-#include "MsgMutex.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginSetting.h"
-#include "SmsPluginCallback.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginUAManager.h"
#include "SmsPluginMain.h"
#include "SmsPluginDSHandler.h"
-#include <gio/gio.h>
-#include <tzplatform_config.h>
-
-
-extern "C" {
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiSim.h>
- #include <ITapiNetText.h>
-}
+#include "SmsPluginCallback.h"
+#include "SmsPluginStorage.h"
+#include "Sms3gppEventHandler.h"
+#include "Sms3gppSetting.h"
+#include "Sms3gppSimMsg.h"
+#include "Sms3gppStorage.h"
+#include "Sms3gppTapiEventHandler.h"
+#include "Sms3gppTransport.h"
+#include "Sms3gpp2EventHandler.h"
+#include "Sms3gpp2Setting.h"
+#include "Sms3gpp2TapiEventHandler.h"
+#include "Sms3gpp2Transport.h"
#define BUS_NAME "org.tizen.system.storage"
#define PATH_NAME "/Org/Tizen/System/Storage/Lowmem"
#define MEMBER_NAME "NeedCleanup"
#define SIGNAL_VAL "Full"
-
+gint subs_id = 0;
GDBusConnection *gdbus_conn = NULL;
GDBusProxy *gdbus_proxy = NULL;
-gint subs_id = 0;
-
-bool isMemAvailable = true;
-
-MsgMutex mx;
-MsgCndVar cv;
-
-void MsgResourceMonitorInit(void);
-void MsgResourceMonitorDeinit(void);
+static void MsgResourceMonitorInit(void);
+static void MsgResourceMonitorDeinit(void);
/*==================================================================================================
FUNCTION IMPLEMENTATION
==================================================================================================*/
-
-msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
+EXPORT_API msg_error_t MsgPlgCreateHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
{
- if (pPluginHandle == NULL) {
- MSG_DEBUG("SMS plugin: create handler error ");
- return MSG_ERR_NULL_POINTER;
- } else {
- pPluginHandle->pfInitialize = SmsPlgInitialize;
- pPluginHandle->pfFinalize = SmsPlgFinalize;
- pPluginHandle->pfRegisterListener = SmsPlgRegisterListener;
- pPluginHandle->pfSubmitRequest = SmsPlgSubmitRequest;
- pPluginHandle->pfSaveSimMessage = SmsPlgSaveSimMessage;
- pPluginHandle->pfDeleteSimMessage = SmsPlgDeleteSimMessage;
- pPluginHandle->pfSetReadStatus = SmsPlgSetReadStatus;
- pPluginHandle->pfSetMemoryStatus = SmsPlgSetMemoryStatus;
- pPluginHandle->pfSetConfigData = SmsPlgSetConfigData;
- pPluginHandle->pfGetConfigData = SmsPlgGetConfigData;
- pPluginHandle->pfAddMessage = SmsPlgAddMessage;
- pPluginHandle->pfGetDefaultNetworkSimId = SmsPlgGetDefaultNetworkSimId;
-
- MSG_DEBUG("SMS plugin: create handler OK");
- MSG_DEBUG("SMS plugin %p", pPluginHandle);
- }
+ MSG_ERR_RET_VM(pPluginHandle == NULL, MSG_ERR_NULL_POINTER, "Invalid parameter: pPluginHandle is null!");
+
+ pPluginHandle->pfInitialize = SmsPlgInitialize;
+ pPluginHandle->pfFinalize = SmsPlgFinalize;
+ pPluginHandle->pfRegisterListener = SmsPlgRegisterListener;
+ pPluginHandle->pfSubmitRequest = SmsPlgSubmitRequest;
+ pPluginHandle->pfSaveSimMessage = SmsPlgSaveSimMessage;
+ pPluginHandle->pfDeleteSimMessage = SmsPlgDeleteSimMessage;
+ pPluginHandle->pfSetReadStatus = SmsPlgSetReadStatus;
+ pPluginHandle->pfSetMemoryStatus = SmsPlgSetMemoryStatus;
+ pPluginHandle->pfSetConfigData = SmsPlgSetConfigData;
+ pPluginHandle->pfGetConfigData = SmsPlgGetConfigData;
+ pPluginHandle->pfAddMessage = SmsPlgAddMessage;
+ pPluginHandle->pfGetDefaultNetworkSimId = SmsPlgGetDefaultNetworkSimId;
+
+ MSG_DEBUG("SMS plugin: create handler OK");
return MSG_SUCCESS;
}
-
-msg_error_t MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
+EXPORT_API msg_error_t MsgPlgDestroyHandle(MSG_PLUGIN_HANDLER_S *pPluginHandle)
{
if (pPluginHandle != NULL) {
free(pPluginHandle);
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgInitialize()
{
MSG_BEGIN();
- bool bReady = false;
+ bool isTelephonyReady = false;
for (int i = 0; i < 100; i++) {
- if (MsgSettingGetBool(VCONFKEY_TELEPHONY_READY, &bReady) != MSG_SUCCESS)
+ if (MsgSettingGetBool(VCONFKEY_TELEPHONY_READY, &isTelephonyReady) != MSG_SUCCESS) {
MSG_INFO("MsgSettingGetBool() is failed");
+ }
- MSG_DEBUG("Get VCONFKEY_TELEPHONY_READY [%d].", bReady ? 1 : 0);
+ MSG_DEBUG("VCONFKEY_TELEPHONY_READY: (%d)", isTelephonyReady);
- if (bReady)
+ if (isTelephonyReady) {
break;
-
+ }
sleep(1);
}
+ MSG_ERR_RET_VM(!isTelephonyReady, MSG_ERR_PLUGIN_TAPIINIT, "Failed to wait telephony init complete!");
- if (!bReady) {
- MSG_ERR("Fail to wait telephony init complete.");
- return MSG_ERR_PLUGIN_TAPIINIT;
- }
-
- int simCnt = 0;
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- SmsPluginDSHandler::instance()->initTelHandle();
- simCnt = SmsPluginDSHandler::instance()->getTelHandleCount();
-
- MSG_DEBUG("simCnt [%d]", simCnt);
+ int simCount = SmsPluginDSHandler::instance()->initTelHandle();
- for (int i = 1; i <= simCnt; i++) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, i);
- MSG_DEBUG("set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND.");
- if (MsgSettingSetInt(keyName, MSG_SIM_STATUS_NOT_FOUND) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetInt is failed!!");
- }
+ SmsPluginCallbacks::registerEvents();
- SmsPluginCallback::instance()->registerEvent();
+ for (int i = 1; i <= simCount; i++) {
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(i);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ char keyName[MAX_VCONFKEY_NAME_LEN] = {};
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, i);
+ if (MsgSettingSetInt(keyName, MSG_SIM_STATUS_NOT_FOUND) != MSG_SUCCESS) {
+ MSG_ERR("MsgSettingSetInt() failed![%s]", keyName);
+ }
- for (int i = 1; i <= simCnt; ++i) {
- TapiHandle *handle;
- handle = SmsPluginDSHandler::instance()->getTelHandle(i);
- SmsPluginSetting::instance()->setSimChangeStatus(handle, true);
+ Sms3gppSetting::instance()->setSimChangeStatus(tHandle);
+ } else {
+ Sms3gpp2Setting::instance()->setSimChangeStatus(tHandle);
+ }
}
- /* set resource monitor */
MsgResourceMonitorInit();
MSG_END();
-
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgFinalize()
{
MSG_BEGIN();
MsgResourceMonitorDeinit();
-
- SmsPluginCallback::instance()->deRegisterEvent();
-
+ SmsPluginCallbacks::deRegisterEvents();
SmsPluginDSHandler::instance()->deinitTelHandle();
MSG_END();
-
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgRegisterListener(MSG_PLUGIN_LISTENER_S *pListener)
{
MSG_BEGIN();
- SmsPluginEventHandler::instance()->registerListener(pListener);
+ Sms3gppEventHandler::instance()->registerListener(pListener);
+ Sms3gpp2EventHandler::instance()->registerListener(pListener);
MSG_END();
-
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo)
{
- msg_error_t err = MSG_SUCCESS;
-
- /* Add Submit SMS into DB */
- if (pReqInfo->msgInfo.msgId == 0) {
- if (pReqInfo->msgInfo.msgPort.valid == false) {
- err = SmsPluginStorage::instance()->checkMessage(&(pReqInfo->msgInfo));
-
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("######## checkMessage Fail !! [err=%d]", err);
- return MSG_ERR_PLUGIN_STORAGE;
- }
-
- err = SmsPluginStorage::instance()->addSmsMessage(&(pReqInfo->msgInfo));
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("######## addSmsMessage Fail !! [err=%d]", err);
- return MSG_ERR_PLUGIN_STORAGE;
- }
-
- if (SmsPluginStorage::instance()->addSmsSendOption(&(pReqInfo->msgInfo), &(pReqInfo->sendOptInfo)) != MSG_SUCCESS) {
- MSG_DEBUG("######## addSmsSendOption Fail !!");
- return MSG_ERR_PLUGIN_STORAGE;
- }
- }
- }
-
- /* Check SIM is present or not */
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx);
- int tmpValue = 0;
- if (MsgSettingGetInt(keyName, &tmpValue) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)tmpValue;
-
- if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("SIM is not present..");
-
- /* Update Msg Status */
- if (pReqInfo->msgInfo.msgPort.valid == false)
- SmsPluginStorage::instance()->updateSentMsg(&(pReqInfo->msgInfo), MSG_NETWORK_SEND_FAIL);
-
- return MSG_ERR_NO_SIM;
- }
-
- SMS_REQUEST_INFO_S *request = NULL;
-
- request = (SMS_REQUEST_INFO_S *)calloc(1, sizeof(SMS_REQUEST_INFO_S));
-
- if (request != NULL) {
- request->reqId = pReqInfo->reqId;
-
- memcpy(&(request->msgInfo), &(pReqInfo->msgInfo), sizeof(MSG_MESSAGE_INFO_S));
- memcpy(&(request->sendOptInfo), &(pReqInfo->sendOptInfo), sizeof(MSG_SENDINGOPT_INFO_S));
+ MSG_BEGIN();
- /* Add Request into Queue and Start UA Manger */
- SmsPluginUAManager::instance()->addReqEntity(request);
+ msg_error_t ret = MSG_SUCCESS;
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(pReqInfo->msgInfo.sim_idx);
- free(request);
+ if (SmsPluginDSHandler::instance()->getSmsFormat(tHandle) == TAPI_NETTEXT_NETTYPE_3GPP) {
+ ret = Sms3gppSubmitRequest(pReqInfo);
+ } else {
+ ret = Sms3gpp2SubmitRequest(pReqInfo);
}
-
- return MSG_SUCCESS;
+ MSG_END();
+ return ret;
}
-
msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
{
- /* Check SIM is present or not */
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pMsgInfo->sim_idx);
- int tmpValue = 0;
- if (MsgSettingGetInt(keyName, &tmpValue) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
+ MSG_BEGIN();
+
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP2) {
+ MSG_WARN("CDMA does not support sim card operations.");
+ return MSG_SUCCESS;
}
- MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)tmpValue;
- if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("SIM is not present..");
- return MSG_ERR_NO_SIM;
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pMsgInfo->sim_idx);
+
+ MSG_SIM_STATUS_T simStatus = 0;
+ if (MsgSettingGetInt(keyName, (int*)&simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
}
+ MSG_ERR_RET_VM(simStatus == MSG_SIM_STATUS_NOT_FOUND, MSG_ERR_NO_SIM, "SIM (%d) is not present!", pMsgInfo->sim_idx);
msg_error_t err = MSG_SUCCESS;
try {
- err = SmsPluginSimMsg::instance()->saveSimMessage(pMsgInfo, pSimIdList);
+ err = Sms3gppSimMsg::instance()->saveSimMessage(pMsgInfo, pSimIdList);
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
return MSG_ERR_PLUGIN_STORAGE;
return MSG_ERR_PLUGIN_STORAGE;
}
+ MSG_END();
return err;
}
-
-msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
+msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t simIndex, msg_sim_id_t SimMsgId)
{
- /* Check SIM is present or not */
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx);
- int tmpValue = 0;
- if (MsgSettingGetInt(keyName, &tmpValue) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
+ MSG_BEGIN();
+
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP2) {
+ MSG_WARN("CDMA does not support sim card operations.");
+ return MSG_SUCCESS;
}
- MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)tmpValue;
- if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("SIM is not present..");
- return MSG_ERR_NO_SIM;
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
+
+ MSG_SIM_STATUS_T simStatus = 0;
+ if (MsgSettingGetInt(keyName, (int*)&simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
}
+ MSG_ERR_RET_VM(simStatus == MSG_SIM_STATUS_NOT_FOUND, MSG_ERR_NO_SIM, "SIM (%d) is not present!", simIndex);
try {
- SmsPluginSimMsg::instance()->deleteSimMessage(sim_idx, SimMsgId);
+ Sms3gppSimMsg::instance()->deleteSimMessage(simIndex, SimMsgId);
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
return MSG_ERR_PLUGIN_STORAGE;
return MSG_ERR_PLUGIN_STORAGE;
}
+ MSG_END();
return MSG_SUCCESS;
}
-
-msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
+msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t simIndex, msg_sim_id_t SimMsgId)
{
- /* Check SIM is present or not */
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx);
- int tmpValue = 0;
- if (MsgSettingGetInt(keyName, &tmpValue) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
+ MSG_BEGIN();
+
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP2) {
+ MSG_WARN("CDMA does not support sim card operations.");
+ return MSG_SUCCESS;
}
- MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)tmpValue;
- if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("SIM is not present..");
- return MSG_ERR_NO_SIM;
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
+
+ MSG_SIM_STATUS_T simStatus = 0;
+ if (MsgSettingGetInt(keyName, (int*)&simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
}
+ MSG_ERR_RET_VM(simStatus == MSG_SIM_STATUS_NOT_FOUND, MSG_ERR_NO_SIM, "SIM (%d) is not present!", simIndex);
try {
- SmsPluginSimMsg::instance()->setReadStatus(sim_idx, SimMsgId);
+ Sms3gppSimMsg::instance()->setReadStatus(simIndex, SimMsgId);
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
return MSG_ERR_PLUGIN_STORAGE;
return MSG_ERR_PLUGIN_STORAGE;
}
+ MSG_END();
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgSetMemoryStatus(msg_sim_slot_id_t simIndex, msg_error_t Error)
{
- /* Check SIM is present or not */
- char keyName[MAX_VCONFKEY_NAME_LEN];
+ MSG_BEGIN();
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
- int tmpValue = 0;
- if (MsgSettingGetInt(keyName, &tmpValue) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)tmpValue;
+ tapi_response_cb responseCallback = NULL;
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ char keyName[MAX_VCONFKEY_NAME_LEN] = { 0, };
+ snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
+
+ MSG_SIM_STATUS_T simStatus = 0;
+ if (MsgSettingGetInt(keyName, (int*)&simStatus) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetInt() failed!");
+ }
+ MSG_ERR_RET_VM(simStatus == MSG_SIM_STATUS_NOT_FOUND, MSG_ERR_NO_SIM, "SIM (%d) is not present!", simIndex);
- if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("SIM is not present..");
- return MSG_ERR_NO_SIM;
+ responseCallback = Sms3gppTapiEventHandler::respSetMemoryStatus;
+ } else {
+ responseCallback = Sms3gpp2TapiEventHandler::respSetMemoryStatus;
}
- int tapiRet = TAPI_API_SUCCESS;
int status = TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE;
-
- if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL)
+ if (Error == MSG_ERR_SIM_STORAGE_FULL || Error == MSG_ERR_MESSAGE_COUNT_FULL) {
status = TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL;
+ }
- MSG_DEBUG("Set Status : [%d]", status);
-
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
-
- tapiRet = tel_set_sms_memory_status(handle, status, TapiEventMemoryStatus, NULL);
+ MSG_INFO("Set Status : [%d]", status);
- if (tapiRet == TAPI_API_SUCCESS)
+ int tRet = tel_set_sms_memory_status(tHandle, status, responseCallback, NULL);
+ if (tRet == TAPI_API_SUCCESS) {
MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
+ } else {
+ MSG_ERR("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tRet);
+ }
+ MSG_END();
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting)
{
+ MSG_BEGIN();
+
+ int simIndex = 0;
+ switch (pSetting->type) {
+ case MSG_SMSC_LIST :
+ simIndex = pSetting->option.smscList.simIndex;
+ break;
+ case MSG_CBMSG_OPT :
+ simIndex = pSetting->option.cbMsgOpt.simIndex;
+ break;
+ case MSG_VOICEMAIL_OPT:
+ simIndex = pSetting->option.voiceMailOpt.simIndex;
+ break;
+ default :
+ THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+ break;
+ }
+
+ MSG_DEBUG("Sim index: (%d)", simIndex);
+
+ /* SIM presence was already checked in framework layer */
+
try {
- SmsPluginSetting::instance()->setConfigData(pSetting);
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ Sms3gppSetting::instance()->setConfigData(pSetting);
+ } else {
+ Sms3gpp2Setting::instance()->setConfigData(pSetting);
+ }
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
return MSG_ERR_PLUGIN_SETTING;
return MSG_ERR_PLUGIN_SETTING;
}
+ MSG_END();
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgGetConfigData(MSG_SETTING_S *pSetting)
{
+ MSG_BEGIN();
+
+ int simIndex = 0;
+ switch (pSetting->type) {
+ case MSG_SMSC_LIST :
+ simIndex = pSetting->option.smscList.simIndex;
+ break;
+ case MSG_CBMSG_OPT :
+ simIndex = pSetting->option.cbMsgOpt.simIndex;
+ break;
+ case MSG_VOICEMAIL_OPT:
+ simIndex = pSetting->option.voiceMailOpt.simIndex;
+ break;
+ default :
+ THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
+ break;
+ }
+
+ MSG_DEBUG("Sim index: (%d)", simIndex);
+
+ /* SIM presence was already checked in framework layer */
+
try {
- SmsPluginSetting::instance()->getConfigData(pSetting);
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP) {
+ Sms3gppSetting::instance()->getConfigData(pSetting);
+ } else {
+ Sms3gpp2Setting::instance()->getConfigData(pSetting);
+ }
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
return MSG_ERR_PLUGIN_SETTING;
return MSG_ERR_PLUGIN_SETTING;
}
+ MSG_END();
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char* pFileData)
{
+ MSG_BEGIN();
+
+ TapiHandle *tHandle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
+ if (SmsPluginDSHandler::instance()->getHandleType(tHandle) == SmsPluginDSHandler::HandleType::H_3GPP2) {
+ MSG_WARN("CDMA does not support sim card operations.");
+ return MSG_SUCCESS;
+ }
+
int *simIdList = (int*)pFileData;
try {
SmsPluginStorage::instance()->addSmsSendOption(pMsgInfo, pSendOptInfo);
- if (simIdList)
- SmsPluginStorage::instance()->addSimMessage(pMsgInfo, simIdList);
+ if (simIdList) {
+ Sms3gppStorage::instance()->addSimMessage(pMsgInfo, simIdList);
+ }
} catch (MsgException& e) {
MSG_FATAL("%s", e.what());
return MSG_ERR_PLUGIN_SETTING;
return MSG_ERR_PLUGIN_SETTING;
}
+ MSG_END();
return MSG_SUCCESS;
}
-
msg_error_t SmsPlgGetDefaultNetworkSimId(int *simId)
{
+ MSG_BEGIN();
+
try {
SmsPluginDSHandler::instance()->getDefaultNetworkSimId(simId);
} catch (MsgException& e) {
return MSG_ERR_PLUGIN_SETTING;
}
+ MSG_END();
return MSG_SUCCESS;
}
-
static void on_change_received(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data)
MSG_DEBUG("path = [%i] and str_val = [%s]", path , str_val);
if (path == TZ_SYS_USER && g_strcmp0(str_val, SIGNAL_VAL) == 0)
{
- int sim_count = SmsPluginDSHandler::instance()->getTelHandleCount();
-
- for (int i = 0; i < sim_count; i++) {
+ int handleCount = SmsPluginDSHandler::instance()->getTelHandleCount();
+ for (int i = 0; i < handleCount; i++) {
SmsPlgSetMemoryStatus(i, MSG_ERR_SIM_STORAGE_FULL);
}
}
}
MSG_END();
- return;
}
-
void MsgResourceMonitorDeinit(void)
{
MSG_BEGIN();
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <stdio.h>
-#include <string.h>
-
-#include "MsgDebug.h"
-#include "MsgTextConvert.h"
-#include "SmsPluginUDCodec.h"
-#include "SmsPluginParamCodec.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginParamCodec - Member Functions
-==================================================================================================*/
-SmsPluginParamCodec::SmsPluginParamCodec()
-{
-}
-
-
-SmsPluginParamCodec::~SmsPluginParamCodec()
-{
-}
-
-
-/*==================================================================================================
- Encode Functions
-==================================================================================================*/
-int SmsPluginParamCodec::encodeAddress(const SMS_ADDRESS_S *pAddress, char **ppParam)
-{
- int offset = 0, length = 0;
- char *temp = (char *)pAddress->address;
-
- SMS_TON_T ton;
-
- char *tempParam = new char[MAX_ADD_PARAM_LEN];
- if (tempParam == NULL)
- return 0;
-
- memset(tempParam, 0x00, sizeof(char)*MAX_ADD_PARAM_LEN);
-
- /* Set Address Length */
- if (temp[0] == '+') {
- tempParam[offset++] = strlen(temp) - 1;
- temp++;
-
- ton = SMS_TON_INTERNATIONAL;
- } else {
- tempParam[offset++] = strlen(temp);
-
- ton = pAddress->ton;
- }
-
- /* Set TON, NPI */
- tempParam[offset++] = 0x80 + (ton << 4) + pAddress->npi;
-
- MSG_DEBUG("Address length is %d.", tempParam[0]);
- MSG_DEBUG("pAddress->ton : %d.", ton);
- MSG_DEBUG("pAddress->npi : %d.", pAddress->npi);
-
- length = convertDigitToBcd(temp, strlen(temp), (unsigned char *) &(tempParam[offset]));
-
- offset += length;
-
- *ppParam = tempParam;
-
- return offset ;
-}
-
-
-int SmsPluginParamCodec::encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **ppParam)
-{
- int offset = 0;
-
- if (pTimeStamp->format == SMS_TIME_ABSOLUTE) {
- int timeZone = pTimeStamp->time.absolute.timeZone;
- *ppParam = new char[MAX_ABS_TIME_PARAM_LEN];
-
- (*ppParam)[offset++] = ((pTimeStamp->time.absolute.year % 10) << 4) + (pTimeStamp->time.absolute.year / 10);
- (*ppParam)[offset++] = ((pTimeStamp->time.absolute.month % 10) << 4) + (pTimeStamp->time.absolute.month / 10);
- (*ppParam)[offset++] = ((pTimeStamp->time.absolute.day % 10) << 4) + (pTimeStamp->time.absolute.day / 10);
- (*ppParam)[offset++] = ((pTimeStamp->time.absolute.hour % 10) << 4) + (pTimeStamp->time.absolute.hour / 10);
- (*ppParam)[offset++] = ((pTimeStamp->time.absolute.minute % 10) << 4) + (pTimeStamp->time.absolute.minute / 10);
- (*ppParam)[offset++] = ((pTimeStamp->time.absolute.second % 10) << 4) + (pTimeStamp->time.absolute.second / 10);
-
- if (timeZone < 0) {
- timeZone *= -1;
- (*ppParam)[offset] = 0x08;
- }
- (*ppParam)[offset++] += ((pTimeStamp->time.absolute.timeZone % 10) << 4) + (pTimeStamp->time.absolute.timeZone / 10);
-
-
- return offset;
- } else if (pTimeStamp->format == SMS_TIME_RELATIVE) {
- *ppParam = new char[MAX_REL_TIME_PARAM_LEN+1];
-
- memcpy(*ppParam, &(pTimeStamp->time.relative.time), MAX_REL_TIME_PARAM_LEN);
-
- return MAX_REL_TIME_PARAM_LEN;
- }
-
- return offset;
-}
-
-
-int SmsPluginParamCodec::encodeDCS(const SMS_DCS_S *pDCS, char **ppParam)
-{
- *ppParam = new char[MAX_DCS_PARAM_LEN];
-
- **ppParam = 0x00;
-
- switch (pDCS->codingGroup) {
- case SMS_GROUP_GENERAL: {
- if (pDCS->msgClass != SMS_MSG_CLASS_NONE)
- **ppParam = 0x10 + pDCS->msgClass;
-
- if (pDCS->bCompressed)
- **ppParam |= 0x20;
- }
- break;
-
- case SMS_GROUP_CODING_CLASS: {
- **ppParam = 0xF0 + pDCS->msgClass;
- }
- break;
-
- case SMS_GROUP_DELETION:
- /* not supported */
- break;
-
- case SMS_GROUP_DISCARD:
- /* not supported */
- break;
-
- case SMS_GROUP_STORE:
- /* not supported */
- break;
-
- default:
- return 0;
- }
-
- switch (pDCS->codingScheme) {
- case SMS_CHARSET_7BIT:
-
- break;
-
- case SMS_CHARSET_8BIT:
- **ppParam |= 0x04;
- break;
-
- case SMS_CHARSET_UCS2:
- **ppParam |= 0x08;
- break;
-
- default:
- return 0;
- }
-
- return MAX_DCS_PARAM_LEN;
-}
-
-
-int SmsPluginParamCodec::encodeSMSC(const char *pAddress, unsigned char *pEncodeAddr)
-{
- char newAddr[MAX_SMSC_LEN+1];
- memset(newAddr, 0x00, sizeof(newAddr));
-
-/* MSG_DEBUG("SMSC [%s]", pAddress);
-*/
- if (pAddress[0] == '+')
- strncpy(newAddr, pAddress+1, MAX_SMSC_LEN);
- else
- strncpy(newAddr, pAddress, MAX_SMSC_LEN);
-
- /* Set Address */
- int encodeLen = convertDigitToBcd(newAddr, strlen(newAddr), pEncodeAddr);
-
- pEncodeAddr[encodeLen] = '\0';
-
- return encodeLen;
-}
-
-
-int SmsPluginParamCodec::encodeSMSC(const SMS_ADDRESS_S *pAddress, unsigned char *pSMSC)
-{
- char newAddr[MAX_SMSC_LEN+1];
- memset(newAddr, 0x00, sizeof(newAddr));
-
- int dataSize = 0, addrLen = 0;
-
- if (pAddress->address[0] == '+')
- memcpy(newAddr, pAddress->address+1, strlen(pAddress->address)-1);
- else
- memcpy(newAddr, pAddress->address, strlen(pAddress->address));
-
- addrLen = strlen(newAddr);
-
- if (addrLen % 2 == 0)
- dataSize = 2 + (addrLen/2);
- else
- dataSize = 2 + (addrLen/2) + 1;
-
- if (dataSize > MAX_SMSC_LEN) {
- MSG_DEBUG("addrLen is too long [%d]", addrLen);
- MSG_DEBUG("dataSize is too long [%d]", dataSize);
-
- return 0;
- }
-
- /* Set Address Length
- Check IPC 4.0 -> addrLen/2 */
- pSMSC[0] = addrLen;
-
- /* Set TON, NPI */
- pSMSC[1] = 0x80 + (pAddress->ton << 4) + pAddress->npi;
-
- /* Set Address */
- convertDigitToBcd(newAddr, addrLen, &(pSMSC[2]));
-
- pSMSC[dataSize] = '\0';
-
- return dataSize;
-}
-
-
-/*==================================================================================================
- Decode Functions
-==================================================================================================*/
-int SmsPluginParamCodec::decodeAddress(const unsigned char *pTpdu, SMS_ADDRESS_S *pAddress)
-{
- int offset = 0, addrLen = 0, bcdLen = 0;
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- memset(pAddress->address, 0x00, sizeof(pAddress->address));
-
- addrLen = (int)pTpdu[offset++];
-
- if (addrLen % 2 == 0)
- bcdLen = addrLen/2;
- else
- bcdLen = addrLen/2 + 1;
-
- pAddress->ton = (pTpdu[offset] & 0x70) >> 4;
- pAddress->npi = pTpdu[offset++] & 0x0F;
-
- MSG_DEBUG("ton [%d]", pAddress->ton);
- MSG_DEBUG("npi [%d]", pAddress->npi);
-
- if (pAddress->ton == SMS_TON_ALPHANUMERIC) {
- MSG_DEBUG("Alphanumeric address");
-
- char* tmpAddress = new char[MAX_ADDRESS_LEN];
- int tmplength = 0;
-
- tmplength = SmsPluginUDCodec::unpack7bitChar(&(pTpdu[offset]), (addrLen*4)/7, 0, tmpAddress);
-
- MSG_LANG_INFO_S langInfo = {0, };
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- textCvt->convertGSM7bitToUTF8((unsigned char*)pAddress->address, MAX_ADDRESS_LEN, (unsigned char*)tmpAddress, tmplength, &langInfo);
-
- if (tmpAddress)
- delete[] tmpAddress;
- } else if (pAddress->ton == SMS_TON_INTERNATIONAL) {
- convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[1]));
- if (pAddress->address[1] != '\0')
- pAddress->address[0] = '+';
- } else {
- convertBcdToDigit(&(pTpdu[offset]), bcdLen, &((pAddress->address)[0]));
- }
-
- offset += bcdLen;
-
-/* MSG_DEBUG("address [%s]", pAddress->address);
-*/
- return offset;
-}
-
-
-int SmsPluginParamCodec::decodeTime(const unsigned char *pTpdu, SMS_TIMESTAMP_S *pTimeStamp)
-{
- int offset = 0;
-
- /* decode in ABSOLUTE time type. */
- pTimeStamp->format = SMS_TIME_ABSOLUTE;
-
- pTimeStamp->time.absolute.year = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
- offset++;
-
- pTimeStamp->time.absolute.month = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
- offset++;
-
- pTimeStamp->time.absolute.day = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
- offset++;
-
- pTimeStamp->time.absolute.hour = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
- offset++;
-
- pTimeStamp->time.absolute.minute = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
- offset++;
-
- pTimeStamp->time.absolute.second = (pTpdu[offset] & 0x0F)*10 + ((pTpdu[offset] & 0xF0) >> 4);
- offset++;
-
- pTimeStamp->time.absolute.timeZone = (pTpdu[offset] & 0x07)*10 + ((pTpdu[offset] & 0xF0) >> 4);
-
- if (pTpdu[offset] & 0x08)
- pTimeStamp->time.absolute.timeZone *= (-1);
-
- offset++;
-
- return offset;
-}
-
-
-int SmsPluginParamCodec::decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS)
-{
- int offset = 0;
- char dcs = pTpdu[offset++];
-
- pDCS->bMWI = false;
- pDCS->bIndActive = false;
- pDCS->indType = SMS_OTHER_INDICATOR;
-
- if (((dcs & 0xC0) >> 6) == 0) {
- pDCS->codingGroup = SMS_GROUP_GENERAL;
- pDCS->bCompressed = (dcs & 0x20) >> 5;
- pDCS->codingScheme = (dcs & 0x0C) >> 2;
-
- if (((dcs & 0x10) >> 4) == 0)
- pDCS->msgClass = SMS_MSG_CLASS_NONE;
- else
- pDCS->msgClass = dcs & 0x03;
- } else if (((dcs & 0xF0) >> 4) == 0x0F) {
- pDCS->codingGroup = SMS_GROUP_CODING_CLASS;
- pDCS->bCompressed = false;
- pDCS->codingScheme = (dcs & 0x0C) >> 2;
-
- pDCS->msgClass = dcs & 0x03;
- } else if (((dcs & 0xC0) >> 6) == 1) {
- pDCS->codingGroup = SMS_GROUP_DELETION;
- pDCS->bCompressed = false;
- pDCS->msgClass = SMS_MSG_CLASS_NONE;
-
- /* TODO: finish here. ?? */
- } else if (((dcs & 0xF0) >> 4) == 0x0C) {
- pDCS->codingGroup = SMS_GROUP_DISCARD;
- pDCS->bCompressed = false;
- pDCS->msgClass = SMS_MSG_CLASS_NONE;
-
- pDCS->bMWI = true;
- pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? true:false;
- pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
- } else if (((dcs & 0xF0) >> 4) == 0x0D) {
- pDCS->codingGroup = SMS_GROUP_STORE;
- pDCS->codingScheme = SMS_CHARSET_7BIT;
- pDCS->bCompressed = false;
- pDCS->msgClass = SMS_MSG_CLASS_NONE;
-
- pDCS->bMWI = true;
- pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? true:false;
- pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
- } else if (((dcs & 0xF0) >> 4) == 0x0E) {
- pDCS->codingGroup = SMS_GROUP_STORE;
- pDCS->codingScheme = SMS_CHARSET_UCS2;
- pDCS->bCompressed = false;
- pDCS->msgClass = SMS_MSG_CLASS_NONE;
-
- pDCS->bMWI = true;
- pDCS->bIndActive = (((dcs & 0x08) >> 3) == 1)? true:false;
- pDCS->indType = (SMS_INDICATOR_TYPE_T)(dcs & 0x03);
- } else {
- pDCS->codingGroup = SMS_GROUP_UNKNOWN;
-
- pDCS->bCompressed = (dcs & 0x20) >> 5;
- pDCS->codingScheme = (dcs & 0x0C) >> 2;
-
- pDCS->msgClass = SMS_MSG_CLASS_NONE;
- }
-
- return offset;
-}
-
-
-void SmsPluginParamCodec::decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_SMS_TON_T ton, char *pDecodeAddr)
-{
- if (pAddress == NULL || AddrLen == 0)
- return;
-
- if (ton == SMS_TON_INTERNATIONAL) {
- pDecodeAddr[0] = '+';
- convertBcdToDigit(pAddress, AddrLen, &(pDecodeAddr[1]));
- } else {
- convertBcdToDigit(pAddress, AddrLen, pDecodeAddr);
- }
-}
-
-
-/*==================================================================================================
- Util Functions
-==================================================================================================*/
-int SmsPluginParamCodec::convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd)
-{
- int offset = 0;
- unsigned char temp;
-
-/* MSG_DEBUG("DigitLen [%d]", DigitLen);
- MSG_DEBUG("pDigit [%s]", pDigit); */
-
- for (int i = 0; i < DigitLen; i++) {
- if (pDigit[i] == '*')
- temp = 0x0A;
- else if (pDigit[i] == '#')
- temp = 0x0B;
- else if (pDigit[i] == 'P' || pDigit[i] == 'p')
- temp = 0x0C;
- else
- temp = pDigit[i] - '0';
-
- if ((i%2) == 0)
- pBcd[offset] = temp & 0x0F;
- else
- pBcd[offset++] |= ((temp & 0x0F) << 4);
- }
-
- if ((DigitLen%2) == 1)
- pBcd[offset++] |= 0xF0;
-
- return offset;
-}
-
-
-int SmsPluginParamCodec::convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit)
-{
- int offset = 0;
- unsigned char temp;
-
- for (int i = 0; i < BcdLen; i++) {
- temp = pBcd[i] & 0x0F;
-
- if (temp == 0x0A)
- pDigit[offset++] = '*';
- else if (temp == 0x0B)
- pDigit[offset++] = '#';
- else if (temp == 0x0C)
- pDigit[offset++] = 'P';
- else
- pDigit[offset++] = temp + '0';
-
- temp = (pBcd[i] & 0xF0) >> 4;
-
- if (temp == 0x0F) {
- pDigit[offset] = '\0';
- return offset;
- }
-
- if (temp == 0x0A)
- pDigit[offset++] = '*';
- else if (temp == 0x0B)
- pDigit[offset++] = '#';
- else if (temp == 0x0C)
- pDigit[offset++] = 'P';
- else
- pDigit[offset++] = temp + '0';
- }
-
- pDigit[offset] = '\0';
-
- return offset;
-}
-
-bool SmsPluginParamCodec::checkCphsVmiMsg(const unsigned char *pTpdu, int *setType, int *indType)
-{
- bool ret = false;
-
- int offset = 0;
- int addrLen = 0;
-
- addrLen = (int)pTpdu[offset++];
-
- if (addrLen == 0x04 && pTpdu[offset++] == 0xD0) {
- if (pTpdu[offset] == 0x11 || pTpdu[offset] == 0x10) {
- MSG_DEBUG("####### VMI msg ######");
- *setType = (int)(pTpdu[offset] & 0x01); /* 0 : clear, 1 : set */
-
- *indType = (int)(pTpdu[offset+1] & 0x01); /* 0 : indicator 1, 1 : indicator 2 */
-
- ret = true;
- }
- }
-
- return ret;
-}
-
-time_t SmsPluginParamCodec::convertTime(const SMS_TIMESTAMP_S *time_stamp)
-{
- time_t rawtime;
-
- if (time_stamp->format == SMS_TIME_ABSOLUTE) {
- MSG_DEBUG("year : %d", time_stamp->time.absolute.year);
- MSG_DEBUG("month : %d", time_stamp->time.absolute.month);
- MSG_DEBUG("day : %d", time_stamp->time.absolute.day);
- MSG_DEBUG("hour : %d", time_stamp->time.absolute.hour);
- MSG_DEBUG("minute : %d", time_stamp->time.absolute.minute);
- MSG_DEBUG("second : %d", time_stamp->time.absolute.second);
- MSG_DEBUG("timezone : %d", time_stamp->time.absolute.timeZone);
-
- char displayTime[32];
- struct tm timeTM;
- memset(&timeTM, 0x00, sizeof(tm));
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- timeinfo.tm_year = (time_stamp->time.absolute.year + 100);
- timeinfo.tm_mon = (time_stamp->time.absolute.month - 1);
- timeinfo.tm_mday = time_stamp->time.absolute.day;
- timeinfo.tm_hour = time_stamp->time.absolute.hour;
- timeinfo.tm_min = time_stamp->time.absolute.minute;
- timeinfo.tm_sec = time_stamp->time.absolute.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%ld]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (time_stamp->time.absolute.timeZone * (3600/4));
-
- localtime_r(&rawtime, &timeTM);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
-/* timezone value is tiemzone + daylight. So should not add daylight */
-#ifdef __MSG_DAYLIGHT_APPLIED__
- rawtime -= (timezone - daylight*3600);
-#else
- rawtime -= timezone;
-#endif
-
- memset(&timeTM, 0x00, sizeof(tm));
- localtime_r(&rawtime, &timeTM);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- } else {
- rawtime = time(NULL);
- }
-
- return rawtime;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-#include "MsgUtilStorage.h"
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginUDCodec.h"
-#include "SmsPluginTpduCodec.h"
-#include "SmsPluginSetting.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginCallback.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginSatHandler.h"
-#include "SmsPluginDSHandler.h"
-
-extern "C" {
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
- #include <ITapiSat.h>
-}
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginCbMsgHandler - Member Functions
-==================================================================================================*/
-SmsPluginSatHandler* SmsPluginSatHandler::pInstance = NULL;
-
-
-SmsPluginSatHandler::SmsPluginSatHandler()
-{
- commandId = 0;
-
- bInitSim = false;
- bSMSPChanged = false;
- bCBMIChanged = false;
-}
-
-
-SmsPluginSatHandler::~SmsPluginSatHandler()
-{
-}
-
-
-SmsPluginSatHandler* SmsPluginSatHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginSatHandler();
-
- return pInstance;
-}
-
-
-void SmsPluginSatHandler::refreshSms(TapiHandle *handle, void *pData)
-{
- /*
- TelSatRefreshInd_t* pRefreshData = (TelSatRefreshInd_t*)pData;
-
- if (pRefreshData->appType != TAPI_SAT_REFRESH_MSG)
- {
- MSG_DEBUG("App Type is wrong. [%d]", pRefreshData->appType);
- return;
- }
-
- commandId = pRefreshData->commandId;
-
- switch (pRefreshData->refreshMode)
- {
- case TAPI_SAT_REFRESH_SIM_INIT_AND_FULL_FCN :
- case TAPI_SAT_REFRESH_SIM_INIT_AND_FCN :
- {
- for (int i = 0; i < pRefreshData->fileCount; i++)
- {
- if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
- (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
- {
- bSMSPChanged = true;
- }
- else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
- (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
- {
- bCBMIChanged = true;
- }
- }
-
- initSim();
- }
- break;
-
- case TAPI_SAT_REFRESH_FCN :
- {
- for (int i = 0; i < pRefreshData->fileCount; i++)
- {
- if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_SMSP ||
- (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_SMSP)
- {
- bSMSPChanged = true;
- }
- else if ((SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_USIM_CBMI ||
- (SMS_SIM_EFILE_NAME_T)pRefreshData->fileId[i].FileName == SMS_SIM_EFILE_CBMI)
- {
- bCBMIChanged = true;
- }
- }
- }
- break;
-
- case TAPI_SAT_REFRESH_SIM_INIT :
- {
- initSim();
- }
- break;
-
- default:
- break;
- }
- */
-}
-
-
-void SmsPluginSatHandler::sendSms(TapiHandle *handle, void *pData)
-{
- TelSatSendSmsIndSmsData_t* pSmsData = (TelSatSendSmsIndSmsData_t*)pData;
-
- commandId = pSmsData->commandId;
-
- MSG_DEBUG("commandId [%d]", commandId);
-
- /* The TPDU Maximum Length at SAT side is 175
- This is because Sat can send 160 bytes unpacked and header */
- unsigned char tpdu[MAX_SAT_TPDU_LEN+1];
- int tpduLen = 0;
-
- memset(tpdu, 0x00, sizeof(tpdu));
- memcpy(tpdu, pSmsData->smsTpdu.data, pSmsData->smsTpdu.dataLen);
-
- /* Modify Parameters, Pack User Data */
- tpduLen = handleSatTpdu(tpdu, pSmsData->smsTpdu.dataLen, pSmsData->bIsPackingRequired);
-
- if (tpduLen <= 0) {
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
- return;
- } else if (tpduLen > MAX_SAT_TPDU_LEN) {
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
- return;
- }
-
- /* Make Telephony Structure */
- TelSmsDatapackageInfo_t pkgInfo;
-
- /* Set TPDU data */
- memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
- memcpy((void*)pkgInfo.szData, tpdu, tpduLen);
-
- pkgInfo.szData[tpduLen] = '\0';
- pkgInfo.MsgLength = tpduLen;
- pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
-
- /* Set SMSC Address */
- SMS_ADDRESS_S smsc = {0, };
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (pSmsData->address.diallingNumberLen > 0) {
- smsc.ton = pSmsData->address.ton;
- smsc.npi = pSmsData->address.npi;
- int wrn = snprintf(smsc.address, sizeof(smsc.address), "%s", pSmsData->address.diallingNumber);
- if(wrn<0)
- MSG_DEBUG("snprintf was failed");
-
- MSG_SEC_DEBUG("SCA TON[%d], NPI[%d], LEN[%zu], ADDR[%s]", smsc.ton, smsc.npi, strlen(smsc.address), smsc.address);
- } else {
- /* Set SMSC Options */
- SmsPluginTransport::instance()->setSmscOptions(simIndex, &smsc);
- }
-
- unsigned char smscAddr[MAX_SMSC_LEN];
- int smscLen = 0;
-
- memset(smscAddr, 0x00, sizeof(smscAddr));
- smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
-
- if (smscLen <= 0)
- return;
-
- /* Set SMSC Address */
- memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
- memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
- pkgInfo.Sca[smscLen] = '\0';
-
- int tapiRet = TAPI_API_SUCCESS;
-
- /* Send SMS */
- tapiRet = tel_send_sms(handle, &pkgInfo, 0, TapiEventSatSmsSentStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## TelTapiSmsSend Success !!! return : %d #######", tapiRet);
-
- } else {
- MSG_DEBUG("######## TelTapiSmsSend Fail !!! return : %d #######", tapiRet);
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_BEYOND_ME_CAPABILITIES);
- }
-}
-
-
-void SmsPluginSatHandler::ctrlSms(TapiHandle *handle, void *pData)
-{
- if (!pData) {
- MSG_DEBUG("pData is NULL");
- return;
- }
-
- TelSatMoSmCtrlIndData_t* pCtrlData = (TelSatMoSmCtrlIndData_t*)pData;
-
-#if 0
- if (bSendSmsbySat == true) {
- /* Send SMS By SAT */
- MSG_DEBUG("Event Noti for sending message by SAT : result = [%d]", pCtrlData->moSmsCtrlResult);
- } else {
- /* Send SMS By APP */
- SmsPluginTransport::instance()->setMoCtrlStatus(pCtrlData);
- }
-#else
- if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
- MsgInsertTicker("Sending message failed : blocked by call control", NULL, true, 0);
- }
-#endif
-
- return;
-
-#if 0
- if (bSendSms == true) { /* Send SMS By SAT */
- if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
- MSG_DEBUG("SIM does not allow to send SMS");
-
- sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM);
- } else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
- MSG_DEBUG("SIM allows to send SMS with modification");
-
- sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
- }
- } else { /* Send SMS By APP */
- msg_network_status_t netStatus = MSG_NETWORK_NOT_SEND;
-
- if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED) {
- MSG_DEBUG("SIM does not allow to send SMS");
-
- netStatus = MSG_NETWORK_SEND_FAIL;
- } else if (pCtrlData->moSmsCtrlResult == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
- MSG_DEBUG("SIM allows to send SMS with modification");
-
- netStatus = MSG_NETWORK_SEND_SUCCESS;
- }
-
- /* Call Event Handler */
- SmsPluginEventHandler::instance()->handleSentStatus(netStatus);
- }
-#endif
-}
-
-
-void SmsPluginSatHandler::ctrlSms(TapiHandle *handle, SMS_NETWORK_STATUS_T smsStatus)
-{
- MSG_DEBUG("SMS network status = [%d]", smsStatus);
-
- if (smsStatus == SMS_NETWORK_SEND_SUCCESS) {
- MSG_DEBUG("Sending SMS by SAT is OK");
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
- } else if (smsStatus == SMS_NETWORK_SEND_FAIL) {
- MSG_ERR("Sending SMS by SAT is failed");
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SMS_RP_ERROR);
- } else if (smsStatus == SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING) {
- MSG_ERR("Sending SMS by SAT is failed, but result is 'success'");
- /* sendResult(SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_ERROR_REQUIRED_VALUES_ARE_MISSING); */
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SUCCESS);
- } else if (smsStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED) {
- MSG_ERR("Sending SMS is failed by MO control");
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM);
- } else if (smsStatus == SMS_NETWORK_SEND_FAIL_NO_ROUTING) {
- MSG_ERR("Sending SMS is failed by no routing");
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_NETWORK_UNABLE_TO_PROCESS_COMMAND);
- } else {
- /*Default case*/
- MSG_ERR("Sending SMS by SAT is failed");
- sendResult(handle, SMS_SAT_CMD_SEND_SMS, TAPI_SAT_R_SMS_RP_ERROR);
- }
-
-#if 0 /* no ticker and sound for sending SAT sms failure case. */
- if (smsStatus != SMS_NETWORK_SEND_SUCCESS) {
- MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, 0);
- }
-#endif
-}
-
-#if 0
-void SmsPluginSatHandler::finishSimMsgInit(msg_error_t Err)
-{
- /* SAT Handler is initializing SIM now */
- if (bInitSim == true) {
- /* Init SMSC List and CB ID Info */
- try {
- if (bSMSPChanged == true) initSMSCList();
- } catch (MsgException& e) {
- /* Send Result to TAPI */
- sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
-
- MSG_FATAL("%s", e.what());
- return;
- }
-
- try {
- if (bCBMIChanged == true) initCBConfig();
- } catch (MsgException& e) {
- /* Send Result to TAPI */
- sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
-
- MSG_FATAL("%s", e.what());
- return;
- }
-
- /* Send Result to TAPI */
- sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_SUCCESS);
- }
-}
-
-
-void SmsPluginSatHandler::initSim()
-{
- bInitSim = true;
-
- /* Init SIM Message */
- if (SmsPluginEventHandler::instance()->callbackInitSimBySat() != MSG_SUCCESS) {
- MSG_DEBUG("Init Sim Error");
-
- /* Send Result to TAPI */
- sendResult(SMS_SAT_CMD_REFRESH, TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND);
- }
-}
-
-
-void SmsPluginSatHandler::initSMSCList()
-{
- MSG_SETTING_S settingData;
-
- settingData.type = MSG_SMSC_LIST;
-
- /* Get Data From SIM */
- SmsPluginSetting::instance()->getConfigData(&settingData);
-
- MSG_DEBUG("total_count[%d]", settingData.option.smscList.totalCnt);
- MSG_DEBUG("selected[%d]", settingData.option.smscList.selected);
-
- for (int i = 0; i < settingData.option.smscList.totalCnt; i++) {
- MSG_DEBUG("pid[%d]", settingData.option.smscList.smscData[i].pid);
- MSG_DEBUG("val_period[%d]", settingData.option.smscList.smscData[i].valPeriod);
- MSG_SEC_DEBUG("name[%s]", settingData.option.smscList.smscData[i].name);
-
- MSG_DEBUG("ton[%d]", settingData.option.smscList.smscData[i].smscAddr.ton);
- MSG_DEBUG("npi[%d]", settingData.option.smscList.smscData[i].smscAddr.npi);
- MSG_SEC_DEBUG("address[%s]", settingData.option.smscList.smscData[i].smscAddr.address);
- }
-
- if (MsgSettingSetInt(SMSC_SELECTED, settingData.option.smscList.selected) != MSG_SUCCESS) {
- THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", SMSC_SELECTED);
- return;
- }
-
- if (MsgSettingSetInt(SMSC_TOTAL_COUNT, settingData.option.smscList.totalCnt) != MSG_SUCCESS) {
- THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", SMSC_TOTAL_COUNT);
- return;
- }
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- msg_error_t err = MSG_SUCCESS;
-
- for (int i = 0; i < settingData.option.smscList.totalCnt; i++) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_PID, i);
-
- if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].pid)) != MSG_SUCCESS)
- break;
-
-#if 0
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_DCS, i);
-
- if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].dcs)) != MSG_SUCCESS)
- break;
-#endif
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_VAL_PERIOD, i);
-
- if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].valPeriod)) != MSG_SUCCESS)
- break;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_NAME, i);
-
- if ((err = MsgSettingSetString(keyName, settingData.option.smscList.smscData[i].name)) != MSG_SUCCESS)
- break;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_TON, i);
-
- if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].smscAddr.ton)) != MSG_SUCCESS)
- break;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_NPI, i);
-
- if ((err = MsgSettingSetInt(keyName, (int)settingData.option.smscList.smscData[i].smscAddr.npi)) != MSG_SUCCESS)
- break;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SMSC_ADDRESS, i);
-
- if ((err = MsgSettingSetString(keyName, settingData.option.smscList.smscData[i].smscAddr.address)) != MSG_SUCCESS)
- break;
- }
-
- if (err != MSG_SUCCESS) {
- THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", keyName);
- }
-}
-
-
-void SmsPluginSatHandler::initCBConfig()
-{
- MSG_SETTING_S settingData;
-
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler *dbHandle = getDbHandle();
-
- settingData.type = MSG_CBMSG_OPT;
-
- /* Get Data From SIM */
- SmsPluginSetting::instance()->getConfigData(&settingData);
-
- if (MsgSettingSetBool(CB_RECEIVE, settingData.option.cbMsgOpt.bReceive) != MSG_SUCCESS) {
- THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_RECEIVE);
- return;
- }
-
- if (MsgSettingSetInt(CB_MAX_SIM_COUNT, settingData.option.cbMsgOpt.maxSimCnt) != MSG_SUCCESS) {
- THROW(MsgException::SMS_PLG_ERROR, "Error to set config data [%s]", CB_MAX_SIM_COUNT);
- return;
- }
-
- err = MsgStoAddCBChannelInfo(dbHandle, &(settingData.option.cbMsgOpt.channelData), settingData.option.cbMsgOpt.simIndex);
- MSG_DEBUG("MsgStoAddCBChannelInfo : err=[%d]", err);
-
- if (err != MSG_SUCCESS) {
- THROW(MsgException::SMS_PLG_ERROR, "Error to set config data");
- }
-}
-#endif
-
-int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired)
-{
- if (pTpdu == NULL)
- THROW(MsgException::SMS_PLG_ERROR, "SAT TPDU is NULL");
-
- int pos = 0;
-
- /* TP-MTI, TP-RD, TP-VPF, TP-RP, TP-UDHI, TP-SRR */
- /* TP-VPF */
- SMS_VPF_T vpf = (SMS_VPF_T)(pTpdu[pos++] & 0x18) >> 3;
-
- /* TP-MR */
- unsigned char tmpRef = pTpdu[pos];
-
- MSG_DEBUG("current Msg Ref : %d", tmpRef);
-
- pTpdu[pos] = tmpRef + 1;
-
- MSG_DEBUG("new Msg Ref : %d", pTpdu[pos]);
-
- pos++;
-
- /*pTpdu[pos++] = SmsPluginTransport::instance()->getMsgRef(); */
-
-
- /* TP-DA */
- SMS_ADDRESS_S destAddr = {0};
- int addrLen = SmsPluginParamCodec::decodeAddress(&pTpdu[pos], &destAddr);
-
- pos += addrLen;
-
- /* TP-PID */
- pos++;
-
- /* TP-DCS */
- SMS_DCS_S dcs = {0};
-
- int dcsLen = SmsPluginParamCodec::decodeDCS(&pTpdu[pos], &dcs);
-
- if (bIsPackingRequired == true) {
- dcs.codingScheme = SMS_CHARSET_7BIT;
-
- char* pDcs = NULL;
- unique_ptr<char*, void(*)(char**)> dcsBuf(&pDcs, unique_ptr_deleter);
-
- SmsPluginParamCodec::encodeDCS(&dcs, &pDcs);
-
- memcpy(&(pTpdu[pos]), pDcs, dcsLen);
- }
-
- pos++;
-
- /* TP-VP */
- if (vpf == SMS_VPF_RELATIVE)
- pos += MAX_REL_TIME_PARAM_LEN;
- else if (vpf == SMS_VPF_ABSOLUTE)
- pos += MAX_ABS_TIME_PARAM_LEN;
-
- /* TP-UDL */
- int udl = pTpdu[pos];
- int retLen = 0;
-
- if (bIsPackingRequired == true) {
- SMS_USERDATA_S userData = {0};
-
- userData.headerCnt = 0;
- userData.length = udl;
- memcpy(userData.data, &pTpdu[pos+1], udl);
- userData.data[udl] = '\0';
-
- MSG_DEBUG("user data : [%s]", userData.data);
-
- /* check for user data whether it is 7-bit packed or not. */
- bool is7bitPacked = false;
- int bitValue = 0;
- for (int i = 0; i < userData.length; i++) {
- bitValue = userData.data[i] & (1 << 7);
- if (bitValue != 0) {
- is7bitPacked = true;
- MSG_DEBUG("user data is already 7-bit packed !!");
- break;
- }
- }
-
- if (!is7bitPacked) {
- MSG_DEBUG("packing 8-bit user data to 7-bit charset !!");
- int encodeSize = SmsPluginUDCodec::encodeUserData(&userData, dcs.codingScheme, (char*)&pTpdu[pos]);
- retLen = pos + encodeSize;
- } else {
- retLen = TpduLen;
- }
- } else {
- retLen = TpduLen;
- }
-
- return retLen;
-}
-
-
-void SmsPluginSatHandler::sendResult(TapiHandle *handle, SMS_SAT_CMD_TYPE_T CmdType, int ResultType)
-{
- TelSatAppsRetInfo_t satRetInfo;
- memset(&satRetInfo, 0, sizeof(TelSatAppsRetInfo_t));
-
- satRetInfo.commandId = commandId;
-
- MSG_INFO("satRetInfo.commandId [%d]", satRetInfo.commandId);
-
- if (CmdType == SMS_SAT_CMD_REFRESH) {
- satRetInfo.commandType = TAPI_SAT_CMD_TYPE_REFRESH;
-
- satRetInfo.appsRet.refresh.appType = TAPI_SAT_REFRESH_MSG;
- satRetInfo.appsRet.refresh.resp = (TelSatResultType_t)ResultType;
- } else if (CmdType == SMS_SAT_CMD_SEND_SMS) {
- satRetInfo.commandType = TAPI_SAT_CMD_TYPE_SEND_SMS;
-
- satRetInfo.appsRet.sendSms.resp = (TelSatResultType_t)ResultType;
- }
-
- int tapiRet = TAPI_API_SUCCESS;
-
- tapiRet = tel_send_sat_app_exec_result(handle, &satRetInfo);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("TelTapiSatSendAppExecutionResult() SUCCESS");
- else
- MSG_ERR("TelTapiSatSendAppExecutionResult() FAIL [%d]", tapiRet);
-
- bInitSim = false;
- bSMSPChanged = false;
- bCBMIChanged = false;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-#include <pthread.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "MsgNotificationWrapper.h"
-#include "MsgContact.h"
-#include "MsgUtilStorage.h"
-#include "MsgTextConvert.h"
-#include "MsgDevicedWrapper.h"
-
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginCallback.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginMain.h"
-#include "SmsPluginSetting.h"
-#include "SmsPluginDSHandler.h"
-
-extern "C" {
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
- #include <ITapiSim.h>
- #include <ITapiModem.h>
-}
-
-/*==================================================================================================
- INTERNAL FUNCTION
-==================================================================================================*/
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginSetting - Member Functions
-==================================================================================================*/
-SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
-
-
-SmsPluginSetting::SmsPluginSetting()
-{
- /* Initialize member variables */
- for (int i = 0; i <= MAX_TELEPHONY_HANDLE_CNT; i++) {
- simStatus[i] = MSG_SIM_STATUS_NOT_FOUND;
- }
- smscList.clear();
- simMailboxList.clear();
- simMwiInfo.clear();
- cbOpt.clear();
- memset(&meImei, 0x00, sizeof(meImei));
- memset(&smscData, 0x00, sizeof(smscData));
-
- bTapiResult = false;
- paramCnt = 0;
- selectedParam = 0;
- selectedSimIndex = 0;
-
- for (int i = 0; i < MAX_TELEPHONY_HANDLE_CNT; i++)
- bMbdnEnable[i] = false;
-}
-
-
-SmsPluginSetting::~SmsPluginSetting()
-{
- smscList.erase(smscList.begin(), smscList.end());
- simMailboxList.erase(simMailboxList.begin(), simMailboxList.end());
- simMwiInfo.erase(simMwiInfo.begin(), simMwiInfo.end());
- cbOpt.erase(cbOpt.begin(), cbOpt.end());
-}
-
-
-SmsPluginSetting* SmsPluginSetting::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginSetting();
-
- return pInstance;
-}
-
-
-void* SmsPluginSetting::initSimInfo(void *data)
-{
- static MsgMutex mm;
- MsgMutexLocker lock(mm);
-
- instance()->processInitSimInfo(data);
-
- return NULL;
-}
-
-void* SmsPluginSetting::processInitSimInfo(void *data)
-{
- MSG_BEGIN();
-
- /* Handle sim info initialization separately */
- TapiHandle *handle = (TapiHandle *)data;
- instance()->updateSimStatus(handle);
-
- MSG_END();
- return NULL;
-}
-
-
-void SmsPluginSetting::updateSimStatus(TapiHandle *handle)
-{
- MSG_BEGIN();
-
- if (!handle) {
- MSG_DEBUG("handle is NULL.");
- return;
- }
-
- int status = 0;
- int tapiRet = TAPI_API_SUCCESS;
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- /* Get IMSI */
- TelSimImsiInfo_t imsiInfo;
- memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
-
- tapiRet = tel_get_sim_imsi(handle, &imsiInfo);
- if (tapiRet != TAPI_API_SUCCESS) {
- MSG_SEC_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
- }
-
- /* Save Subcriber ID */
- char *subscriberId = NULL;
- memset(keyName, 0x00, sizeof(keyName));
-
- if (SmsPluginDSHandler::instance()->getSubscriberId(simIndex, &subscriberId) != MSG_SUCCESS) {
- MSG_DEBUG("getSubscriberId() is failed");
- } else {
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, simIndex);
- if (MsgSettingSetString(keyName, subscriberId) != MSG_SUCCESS)
- MSG_DEBUG("Fail MsgSettingSetString");
- }
-
- g_free(subscriberId); subscriberId = NULL;
-
- /* Check device status */
- tapiRet = tel_check_sms_device_status(handle, &status);
-
- if (tapiRet != TAPI_API_SUCCESS) {
- MSG_DEBUG("tel_check_sms_device_status() Error! [%d], Status [%d]", tapiRet, status);
- return;
- }
-
- if (status == TAPI_NETTEXT_READY_STATUS_3GPP) {
- MSG_DEBUG("Device Is Ready");
- } else {
- MSG_DEBUG("Device Is Not Ready.. Waiting For Ready Callback");
-
- if (SmsPluginEventHandler::instance()->getDeviceStatus(handle) == true) {
- MSG_DEBUG("Device Is Ready");
- } else {
- MSG_DEBUG("Device Is Not Ready.");
- return;
- }
- }
-
- /* init config data. */
- initConfigData(handle);
-
- try {
- /* init sim messages. */
- SmsPluginSimMsg::instance()->initSimMessage(handle);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
- return;
- }
-
-
- MSG_END();
-
- return;
-}
-
-
-void SmsPluginSetting::initConfigData(TapiHandle *handle)
-{
- MSG_BEGIN();
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
- /*==================== SMSC setting ====================*/
- /* Init SMS Parameter */
- int paramCnt = 0;
- int failCnt = 0;
- bool bSelectedFound = false;
- bool bAPReceive = false;
-
- paramCnt = getParamCount(handle);
-
- MSG_INFO("Parameter Count [%d]", paramCnt);
-
- MSG_SMSC_DATA_S tmpSmscData = {};
- MSG_SMSC_LIST_S tmpSmscList = {0, };
-
- for (int index = 0; index < paramCnt; index++) {
- memset(&tmpSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
- if (getParam(handle, index, &tmpSmscData) == false) {
- failCnt++;
- continue;
- }
-
- memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
-
- MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid);
- MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod);
- MSG_SEC_DEBUG("name[%s]", tmpSmscList.smscData[index].name);
-
- MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton);
- MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
- MSG_SEC_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
-
- /* First smsc is selected index */
- if (!bSelectedFound) {
- tmpSmscList.selected = selectedParam;
- bSelectedFound = !bSelectedFound;
- }
- }
-
- tmpSmscList.totalCnt = (paramCnt - failCnt);
- tmpSmscList.simIndex = sim_idx;
-
- if (paramCnt > 0) {
- MSG_DEBUG("######## Add SMSC ist #######");
- addSMSCList(&tmpSmscList);
- }
-
- /*==================== CB configuration ====================*/
- if (simStatus[sim_idx] != MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("simStatus == [%d]", simStatus[sim_idx]);
-
- MSG_CBMSG_OPT_S cbMsgOpt = {0, };
- cbMsgOpt.simIndex = sim_idx;
-
- if (getCbConfig(&cbMsgOpt) == true) {
- cbMsgOpt.simIndex = sim_idx;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, sim_idx);
- if (MsgSettingGetBool(keyName, &bAPReceive) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if (cbMsgOpt.bReceive == false && bAPReceive == false) {
- MSG_DEBUG("CB is off in CP and in AP. No need to send CB request to CP. ");
- } else {
- MSG_DEBUG("######## Add CB Option Success !!! #######");
- MSG_SETTING_S cbSetting;
- getCbOpt(&cbSetting, sim_idx);
- setCbConfig(&(cbSetting.option.cbMsgOpt));
- }
- } else {
- MSG_WARN("######## getCbConfig Fail !!! #######");
- }
-
- /*==================== Default Voice mail Setting ====================*/
- if (simStatus[sim_idx] == MSG_SIM_STATUS_CHANGED) {
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- MSG_INFO("=================SIM CHANGED===================");
- /* reset voicemail number */
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
- if (MsgSettingSetString(keyName, "") != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetString is failed!!");
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx);
- if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetInt is failed!!");
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, sim_idx);
- if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetString is failed!!");
-
- MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_1, sim_idx);
- MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, sim_idx);
- }
-
- /*==================== Voice mail information update ====================*/
- if (getVoiceMailInfo(handle) == true) {
- MSG_DEBUG("######## getVoiceMailInfo Success !!! #######");
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
-
- char *voiceNumber = NULL;
- if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- if (!voiceNumber || (voiceNumber && voiceNumber[0] == '\0')) {
- MSG_WARN("Voice Number is Empty!!");
- }
-
- if (voiceNumber) {
- free(voiceNumber);
- voiceNumber = NULL;
- }
- } else {
- MSG_WARN("######## getVoiceMailInfo Fail !!! #######");
- }
-
- /*==================== Voice mail count update ====================*/
- if (getMwiInfo(handle) == true) {
- MSG_DEBUG("######## getMwiInfo Success !!! #######");
- } else {
- MSG_WARN("######## getMwiInfo Fail !!! #######");
-
- /* Get MWI from vconf and insert notification */
- int mwiCnt = 0;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx);
- if (MsgSettingGetInt(keyName, &mwiCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- if (mwiCnt > 0)
- deliverVoiceMsgNoti(sim_idx, mwiCnt);
- }
-
- /*==================== MSISDN update ====================*/
- if (getMsisdnInfo(handle) == true) {
- MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
- } else {
- MSG_WARN("######## getMsisdnInfo Fail !!! #######");
- }
-
- /*==================== SST(SIM Service Table) update ====================*/
- if (getSimServiceTable(handle) == true) {
- MSG_DEBUG("######## getSimServiceTable Success !!! #######");
- } else {
- MSG_WARN("######## getSimServiceTable Fail !!! #######");
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::SimRefreshCb(TapiHandle *handle)
-{
- pthread_t thd;
-
- if (pthread_create(&thd, NULL, &init_config_data, handle) < 0) {
- MSG_ERR("pthread_create() error");
- return;
- }
-
- pthread_detach(thd);
-}
-
-
-void* SmsPluginSetting::init_config_data(void *data)
-{
- TapiHandle *handle = (TapiHandle *)data;
- instance()->initConfigData(handle);
- return NULL;
-}
-
-
-void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
-{
- MSG_DEBUG("Setting Type : [%d]", pSetting->type);
-
- switch (pSetting->type) {
-#if 0
- case MSG_SMS_SENDOPT :
- setNetworkMode(&pSetting->option.smsSendOpt);
- break;
-#endif
- case MSG_SMSC_LIST :
- setParamList(&pSetting->option.smscList);
- addSMSCList((MSG_SMSC_LIST_S *)(&pSetting->option.smscList));
- break;
- case MSG_CBMSG_OPT :
- if (setCbConfig(&pSetting->option.cbMsgOpt) == false) {
- THROW(MsgException::SMS_PLG_ERROR, "Failed to set config.");
- }
- break;
- case MSG_VOICEMAIL_OPT:
- setVoiceMailInfo(&pSetting->option.voiceMailOpt);
- break;
- default :
- THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
- break;
- }
-}
-
-
-void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
-{
- MSG_DEBUG("Setting Type : [%d]", pSetting->type);
-
- switch (pSetting->type) {
- case MSG_SMSC_LIST :
- getSmscListInfo(pSetting->option.smscList.simIndex, &(pSetting->option.smscList));
- break;
-
- case MSG_CBMSG_OPT :
- if (getCbConfig(&pSetting->option.cbMsgOpt) == false) {
- THROW(MsgException::SMS_PLG_ERROR, "Get CB config option failed.");
- }
- break;
-
- default :
- THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
- break;
- }
-}
-
-
-void SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
-{
- MSG_BEGIN();
-
- int sim_index = -1;
-
- MSG_DEBUG("SIM index[%d]", pSmscList->simIndex);
- MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
- MSG_DEBUG("selected index[%d]", pSmscList->selected);
-
- for (int i = 0; i < pSmscList->totalCnt; i++) {
- MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
- MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
- MSG_SEC_DEBUG("name[%s]", pSmscList->smscData[i].name);
-
- MSG_DEBUG("ton[%d]", pSmscList->smscData[i].smscAddr.ton);
- MSG_DEBUG("npi[%d]", pSmscList->smscData[i].smscAddr.npi);
- MSG_SEC_DEBUG("address[%s]", pSmscList->smscData[i].smscAddr.address);
- }
-
- sim_index = pSmscList->simIndex;
-
- smscListMap::iterator it = smscList.find(pSmscList->simIndex);
- if (it == smscList.end()) {
- pair<int, MSG_SMSC_LIST_S> newList(sim_index, *pSmscList);
- smscList.insert(newList);
- } else {
- /* update the list. */
- MSG_SMSC_LIST_S &pTmpSmscList = it->second;
- pTmpSmscList.simIndex = pSmscList->simIndex;
- pTmpSmscList.totalCnt = pSmscList->totalCnt;
- pTmpSmscList.selected = pSmscList->selected;
-
- for (int i = 0; i < pSmscList->totalCnt; i++) {
- pTmpSmscList.smscData[i].pid = pSmscList->smscData[i].pid;
- pTmpSmscList.smscData[i].valPeriod = pSmscList->smscData[i].valPeriod;
- memset(pTmpSmscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1);
- memcpy(pTmpSmscList.smscData[i].name, pSmscList->smscData[i].name, SMSC_NAME_MAX);
-
- memset(pTmpSmscList.smscData[i].smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
- memcpy(pTmpSmscList.smscData[i].smscAddr.address, pSmscList->smscData[i].smscAddr.address, SMSC_ADDR_MAX);
-
- if (pTmpSmscList.smscData[i].smscAddr.address[0] == '+')
- pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
- else
- pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
-
- pTmpSmscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; /* app cannot set this value */
- }
- }
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList)
-{
- if (pSmscList == NULL) {
- MSG_DEBUG("pSmscList is NULL!");
- return;
- }
-
- if (simIndex <= 0) {
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
- simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
- }
-
- memset(pSmscList, 0x00, sizeof(MSG_SMSC_LIST_S));
-
- if (simIndex != -1) {
- smscListMap::iterator it = smscList.find(simIndex);
- if (it != smscList.end()) {
- MSG_SMSC_LIST_S &pTmpSmscList = it->second;
- memcpy(pSmscList, &pTmpSmscList, sizeof(MSG_SMSC_LIST_S));
- MSG_SEC_DEBUG("SMSC number for sim index [%d] is [%s]", pSmscList->simIndex, pSmscList->smscData[pSmscList->selected].smscAddr.address);
- }
- }
-
- return;
-}
-
-
-msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
-{
- msg_error_t err = MSG_SUCCESS;
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt);
-
- MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
-
- for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
- MSG_DEBUG("Channel FROM [%d], Channel TO [%d]", pCbOpt->channelData.channelInfo[i].from, pCbOpt->channelData.channelInfo[i].to);
- }
-
-#if 0
- /* Set Setting Data into Vconf */
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, pCbOpt->simIndex);
- if (MsgSettingSetBool(keyName, pCbOpt->bReceive) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", keyName);
- return MSG_ERR_SET_SETTING;
- }
-#endif
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, pCbOpt->simIndex);
- if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", keyName);
- return MSG_ERR_SET_SETTING;
- }
-
-#if 0
- MsgDbHandler *dbHandle = getDbHandle();
- err = MsgStoAddCBChannelInfo(dbHandle, &pCbOpt->channelData);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("MsgStoGetCBChannelInfo is failed [%d]", err);
- return MSG_ERR_SET_SETTING;
- }
-#endif
-
- return err;
-}
-
-
-void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting, int simIndex)
-{
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler *dbHandle = getDbHandle();
-
- memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
-
- pSetting->type = MSG_CBMSG_OPT;
- pSetting->option.cbMsgOpt.simIndex = simIndex;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex);
- if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bReceive) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
- int maxSimCnt = 0;
- if (MsgSettingGetInt(keyName, &maxSimCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- pSetting->option.cbMsgOpt.maxSimCnt = maxSimCnt;
-
- err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex);
- if (err != MSG_SUCCESS)
- MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
-
- for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_LANGUAGE, i);
-
- if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
- }
-}
-
-
-void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
-{
- MSG_BEGIN();
-
- MsgMutexLocker lock(mx);
-
- TelSmsParams_t smsParam = {0};
-
- int ret = TAPI_API_SUCCESS;
-
- int index = pSMSCList->index;
- MSG_DEBUG("SMSC Index to be set in SIM = %d", index);
-
- /*Setting the SMSP Record index value*/
- smsParam.RecordIndex = (unsigned char)index;
-
- /*Setting the SMSP Record Length value = 28 + alphaId_len*/
- smsParam.RecordLen = 28 + strlen(pSMSCList->smscData[index].name);
-
- /*Setting the SMSP Alpha ID value*/
- smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
- MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
-
- if (smsParam.AlphaIdLen > 0 && smsParam.AlphaIdLen <= SMSC_NAME_MAX) {
- memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
- smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
- MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
- }
-
- smsParam.ParamIndicator = 0x00;
-
- if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
- smsParam.ParamIndicator |= 0x02 ; /* enable 2nd Bit */
- MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
-
- if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
- smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_INTERNATIONAL;
- else
- smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
-
- smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
-
- MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
-
- MSG_SEC_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
-
- smsParam.TpSvcCntrAddr.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
- } else {
- MSG_DEBUG("SMSC Addr is not present");
- }
-
- /*Setting the PID value*/
- smsParam.ParamIndicator |= 0x04 ; /* enable 3rd Bit */
- MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
-
- smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
-
- /*Setting the ValidityPeriod value*/
- smsParam.ParamIndicator |= 0x10 ; /* enable 5th Bit */
- MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
-
- smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
-
- smsParam.ParamIndicator = ~(smsParam.ParamIndicator);
- MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
-
- /* Get TAPI handle */
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
-
- ret = tel_set_sms_parameters(handle, (const TelSmsParams_t*)&smsParam, TapiEventSetConfigData, NULL);
-
- if (ret != TAPI_API_SUCCESS)
- THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Error. [%d]", ret);
-
- if (!getResultFromSim())
- THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Result Error.");
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
-{
- MSG_BEGIN();
-
- int paramCnt = 0;
-
- MSG_SEC_DEBUG("SIM index [%d]", pSMSCList->simIndex);
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
- paramCnt = getParamCount(handle);
-
- MSG_DEBUG("Parameter Count [%d]", paramCnt);
-
- int ret = TAPI_API_SUCCESS;
-
- MSG_SMSC_DATA_S tmpSmscData = {};
-
- for (int index = 0; index < paramCnt; index++) {
- ret = tel_get_sms_parameters(handle, index, TapiEventGetParam, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
- } else {
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
- }
-
- if (getParamEvent(handle, &tmpSmscData) == true) {
- MSG_DEBUG("######## Get Parameter was Successful !!! #######");
-
- memcpy(&(pSMSCList->smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
-
- MSG_DEBUG("pid[%d]", pSMSCList->smscData[index].pid);
- MSG_DEBUG("val_period[%d]", pSMSCList->smscData[index].valPeriod);
- MSG_SEC_DEBUG("name[%s]", pSMSCList->smscData[index].name);
-
- MSG_DEBUG("ton[%d]", pSMSCList->smscData[index].smscAddr.ton);
- MSG_DEBUG("npi[%d]", pSMSCList->smscData[index].smscAddr.npi);
- MSG_SEC_DEBUG("address[%s]", pSMSCList->smscData[index].smscAddr.address);
- } else {
- MSG_DEBUG("######## Get Parameter was Failed !!! #######");
- }
- }
-
- pSMSCList->totalCnt = paramCnt;
- pSMSCList->selected = selectedParam;
-
- MSG_DEBUG("total_count[%d]", pSMSCList->totalCnt);
-
- MSG_END();
-}
-
-
-int SmsPluginSetting::getParamCount(TapiHandle *handle)
-{
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sms_parameter_count(handle, TapiEventGetParamCnt, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
- } else {
- THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
- }
-
- return getParamCntEvent();
-}
-
-
-bool SmsPluginSetting::getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData)
-{
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sms_parameters(handle, Index, TapiEventGetParam, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
- } else {
- MSG_ERR("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getParamEvent(handle, pSmscData) == true) {
- MSG_DEBUG("######## Get Parameter was Successful !!! #######");
- } else {
- MSG_ERR("######## Get Parameter was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-void SmsPluginSetting::setSmscInfo(const MSG_SMSC_LIST_S *pSmscList)
-{
- MSG_BEGIN();
-
- MsgMutexLocker lock(mx);
-
- int ret = TAPI_API_SUCCESS;
-
- TapiHandle *handle = NULL;
-
- handle = SmsPluginDSHandler::instance()->getTelHandle(pSmscList->simIndex);
-
- int select_id = pSmscList->selected;
- const MSG_SMSC_DATA_S *pSmscData = (const MSG_SMSC_DATA_S *)&(pSmscList->smscData[select_id]);
-
- MSG_DEBUG("Select SMSC id = [%d]", select_id);
-
- TelSmsAddressInfo_t sca;
- memset(&sca, 0x00, sizeof(TelSmsAddressInfo_t));
-
- if (strlen(pSmscData->smscAddr.address) > 0) {
- if (pSmscData->smscAddr.address[0] == '+')
- sca.Ton = TAPI_SIM_TON_INTERNATIONAL;
- else
- sca.Ton = TAPI_SIM_TON_NATIONAL;
-
- sca.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
-
- MSG_SEC_DEBUG("SMSC TON = [%d], NPI = [%d], Address = [%s]", sca.Ton, sca.Npi, pSmscData->smscAddr.address);
-
- sca.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSmscData->smscAddr.address, sca.szDiallingNum);
- } else {
- MSG_DEBUG("SMSC Addr is not present");
- }
-
- ret = tel_set_sms_sca(handle, (const TelSmsAddressInfo_t *)&sca, 0, TapiEventSetSmscInfo, NULL);
-
- if (ret != TAPI_API_SUCCESS)
- THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_sca() Error. [%d]", ret);
-
- if (!getResultFromSim())
- THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_sca() Result Error.");
-
- MSG_END();
-}
-
-
-bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
-{
- TapiHandle *handle = NULL;
- int simCnt = SmsPluginDSHandler::instance()->getTelHandleCount();
-
- TelSmsCbConfig_t cbConfig = {};
-
- int cbEnabled = 0;
- int ret = TAPI_API_SUCCESS;
-
- if (pCbOpt->bReceive == true)
- cbEnabled = 2;/* Need to get a Enumeration from TAPI, currently it is not available */
-
- MSG_DEBUG("simIndex:%d, cbEnabled:%d", pCbOpt->simIndex, cbEnabled);
-
- if (pCbOpt->simIndex == 0) {
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NOT_FOUND;
-
- for (int i = 1; i <= simCnt; i++) {
- MsgMutexLocker lock(mx);
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, i);
- int tmpVal = 0;
- if (MsgSettingGetInt(keyName, &tmpVal) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- simStatus = (MSG_SIM_STATUS_T)tmpVal;
-
- if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
- MSG_DEBUG("SIM %d is not present..", i);
- continue;
- }
-
- handle = SmsPluginDSHandler::instance()->getTelHandle(i);
- memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
- cbConfig.CBEnabled = cbEnabled;
- cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
-
- /*MSG_SETTING_S cbSetting;
- getCbOpt(&cbSetting, i);
-
- cbConfig.CBEnabled = (int)pCbOpt->bReceive;
- cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
- cbConfig.MsgIdMaxCount = cbSetting.option.cbMsgOpt.maxSimCnt;
- cbConfig.MsgIdRangeCount = cbSetting.option.cbMsgOpt.channelData.channelCnt;
-
- for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
- cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].bActivate;
- cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].from;
- cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].to;
- }*/
-
- ret = tel_set_sms_cb_config(handle, &cbConfig, TapiEventSetConfigData, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
- } else {
- MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
- } else {
- MSG_ERR("######## Set Cb Config was Failed !!! #######");
- return false;
- }
-
- msg_error_t err = MSG_SUCCESS;
- MsgDbHandler *dbHandle = getDbHandle();
- err = MsgStoAddCBChannelInfo(dbHandle, const_cast<MSG_CB_CHANNEL_S*>(&pCbOpt->channelData), i);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("MsgStoAddCBChannelInfo is failed [%d]", err);
- return false;
- }
- }
-
- MSG_DEBUG("SIM Index = [0], Set CB Receive is done");
- return true;
- } else {
- MsgMutexLocker lock(mx);
-
- handle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
-
- memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
- cbConfig.CBEnabled = cbEnabled;
- cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
- /* cbConfig.CBEnabled = (int)pCbOpt->bReceive;
- cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
- cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
- cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
-
- for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
- cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
- cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].from;
- cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].to;
-
- MSG_DEBUG("FROM: %d, TO: %d", cbConfig.MsgIDs[i].Net3gpp.FromMsgId, cbConfig.MsgIDs[i].Net3gpp.ToMsgId);
- }
- MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);*/
-
- ret = tel_set_sms_cb_config(handle, &cbConfig, TapiEventSetConfigData, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
- } else {
- MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
- } else {
- MSG_ERR("######## Set Cb Config was Failed !!! #######");
- return false;
- }
- }
-
- return true;
-}
-
-
-bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
-{
- int ret = TAPI_API_SUCCESS;
-
- TapiHandle *handle = NULL;
-
- if (pCbOpt->simIndex == 0) {
- MSG_DEBUG("SIM Index for getCBConfig = 0, CANNOT get cbconfig from SIM 0");
- return false;
- }
-
- handle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
-
- ret = tel_get_sms_cb_config(handle, TapiEventGetCBConfig, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
- } else {
- MSG_ERR("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getCbConfigEvent(pCbOpt) == true) {
- MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
- } else {
- MSG_ERR("######## Get Cb Config was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
-{
- MSG_BEGIN();
- MsgMutexLocker lock(mx);
-
- int ret = TAPI_API_SUCCESS;
- bool *bShowError = NULL; /* When invalid voicemail data exists on SIM, update error should not be handled. */
-
- int simIndex = pVoiceOpt->simIndex;
-
- if (bMbdnEnable[simIndex] == false) {
- MSG_DEBUG("MBDN service is disable.");
- return;
- }
-
- TelSimMailBoxNumber_t mailboxInfo = {0, };
- bool bExistVoicetype = false;
- int i = 0;
-
- smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
- if (it == simMailboxList.end()) {
- return;
- }
-
- SMS_SIM_MAILBOX_LIST_S &pTmpSimMailboxList = it->second;
- if (pTmpSimMailboxList.count < 0) { /* Not available */
- return;
- }
-
- bShowError = (bool*)calloc(1, sizeof(bool));
- if (!bShowError)
- return;
-
- if (pTmpSimMailboxList.count == 0) {
- char num[MAX_PHONE_NUMBER_LEN + 1] = {0, };
-
- mailboxInfo.mb_type = TAPI_SIM_MAILBOX_VOICE;
- mailboxInfo.rec_index = 1;
- mailboxInfo.ton = TAPI_SIM_TON_UNKNOWN;
-
- snprintf(num, sizeof(num), "%s", pVoiceOpt->mailNumber);
- MSG_DEBUG("Mailbox number config [%s]", num);
-
- if (num[0] == '+') {
- snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(num[1]));
- mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
- } else {
- snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", num);
- }
-
- MSG_SEC_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
-
- *bShowError = false;
-
- } else {
- for (i = 0; i < pTmpSimMailboxList.count; i++) {
- if (pTmpSimMailboxList.list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
- bExistVoicetype = true;
- break;
- }
- }
-
- if (bExistVoicetype == false) {
- *bShowError = false;
- /* There is no mailbox information for voicemail type on SIM. */
- for (i = 0; i < pTmpSimMailboxList.count; i++) {
- if (pTmpSimMailboxList.list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pTmpSimMailboxList.list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
- pTmpSimMailboxList.list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
- break;
- }
- }
- }
-
- /* if strlen of voicemail number retrieved from SIM is zero, error is not shown */
- if (pTmpSimMailboxList.list[i].num_len == 0) {
- MSG_DEBUG("In SIM voicemail does not exist");
- *bShowError = false;
- } else if (pTmpSimMailboxList.list[i].num_len > 0) {
- MSG_DEBUG("In SIM voicemail exist");
- *bShowError = true;
- }
-
- MSG_INFO("bShowError = %d", *bShowError);
-
- memset(&pTmpSimMailboxList.list[i].num, 0x00, sizeof(pTmpSimMailboxList.list[i].num));
- snprintf(pTmpSimMailboxList.list[i].num, sizeof(pTmpSimMailboxList.list[i].num), "%s", pVoiceOpt->mailNumber);
- MSG_DEBUG("Mailbox number config [%s]", pTmpSimMailboxList.list[i].num);
-
- mailboxInfo.b_cphs = pTmpSimMailboxList.list[i].b_cphs;
- mailboxInfo.alpha_id_max_len = pTmpSimMailboxList.list[i].alpha_id_max_len;
- mailboxInfo.mb_type = (TelSimMailboxType_t)pTmpSimMailboxList.list[i].mb_type;
- mailboxInfo.profile_num = pTmpSimMailboxList.list[i].profile_num;
- mailboxInfo.rec_index = (pTmpSimMailboxList.list[i].rec_index == 0) ? 1 : pTmpSimMailboxList.list[i].rec_index;
- mailboxInfo.ton = (TelSimTypeOfNum_t)pTmpSimMailboxList.list[i].ton;
- mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)pTmpSimMailboxList.list[i].npi;
- snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", pTmpSimMailboxList.list[i].alpha_id);
-
- if (pTmpSimMailboxList.list[i].num[0] == '+') {
- snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(pTmpSimMailboxList.list[i].num[1]));
- mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
- } else {
- snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", pTmpSimMailboxList.list[i].num);
- }
- MSG_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
-
- mailboxInfo.cc_id = pTmpSimMailboxList.list[i].cc_id;
- mailboxInfo.ext1_id = pTmpSimMailboxList.list[i].ext1_id;
- }
-
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
-
- ret = tel_set_sim_mailbox_info(handle, &mailboxInfo, TapiEventSetMailboxInfo, (void*)bShowError);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sim_mailbox_info() Success !!! #######");
- } else {
- MSG_ERR("######## tel_set_sim_mailbox_info() Fail !!! return : %d #######", ret);
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Set mailbox info Success !!! #######");
- } else {
- if (bShowError)
- free(bShowError);
- THROW(MsgException::SMS_PLG_ERROR, "######## Set mailbox info Failed !!!#######");
- MSG_ERR("######## Set mailbox info Failed !!! #######");
- }
-
- if (bShowError)
- free(bShowError);
-
- MSG_END();
- return;
-}
-
-
-bool SmsPluginSetting::getVoiceMailInfo(TapiHandle *handle)
-{
- MsgMutexLocker lock(mx);
-
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sim_mailbox_info(handle, TapiEventGetMailboxInfo, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sim_mailbox_info() Success !!! #######");
- } else {
- MSG_ERR("######## tel_get_sim_mailbox_info() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getMailboxInfoEvent() == true) {
- MSG_DEBUG("######## Get mailbox info was Successful !!! #######");
- } else {
- MSG_ERR("######## Get mailbox info was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-void SmsPluginSetting::getMeImei(char *pImei)
-{
- int ret = TAPI_API_SUCCESS;
-
- TapiHandle *handle = NULL;
- handle = SmsPluginDSHandler::instance()->getTelHandle(1);
-
- if (handle == NULL) {
- MSG_DEBUG("Tapi Handle is NULL!");
- return;
- }
-
- ret = tel_get_misc_me_imei(handle, TapiEventGetMeImei, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Success !!! #######");
-
- if (getResultImei(pImei) == true) {
- MSG_SEC_DEBUG("######## Get ME IMEI was Successful !!! #######");
- } else {
- MSG_SEC_DEBUG("######## Get ME IMEI was Failed !!! #######");
- }
- } else {
- MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Fail !!! return : %d #######", ret);
- }
-}
-
-
-void SmsPluginSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
-{
- MSG_DEBUG("SET MWI INFO, type=[%d]", type);
- MSG_DEBUG("SET MWI INFO, count=[%d]", count);
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, simIndex);
-
- if (MsgSettingSetInt(keyName, count) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetInt is failed!!");
-
- if (count <= 0) {
- if (type == MSG_MWI_VOICE_SMS)
- MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_1, simIndex);
- else if (type == MSG_MWI_VOICE2_SMS)
- MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, simIndex);
- }
-
- if (bMbdnEnable[simIndex] == false) {
- MSG_DEBUG("MBDN service is disable.");
- return;
- }
-
- int ret = TAPI_API_SUCCESS;
- TelSimMessageWaitingReq_t mwReq = {0, };
-
- simMwiInfoMap::iterator iter = simMwiInfo.find(simIndex);
- if(iter == simMwiInfo.end()) {
- MSG_DEBUG("IT is not present");
- return;
- }
-
- MSG_DEBUG("IT is present");
-
- SMS_SIM_MWI_INFO_S &pTmpsimMwiInfo = iter->second;
-
- MSG_DEBUG("SET MWI INFO, CPHS? [%s]", pTmpsimMwiInfo.b_cphs?"Yes":"No");
-
- if (pTmpsimMwiInfo.b_cphs) {
- MSG_DEBUG("b_cphs is set");
- if (type == MSG_MWI_VOICE_SMS) {
- pTmpsimMwiInfo.cphs_mwi.b_voice1 = (count > 0 ? 1:0);
- } else if (type == MSG_MWI_VOICE2_SMS) {
- pTmpsimMwiInfo.cphs_mwi.b_voice2 = (count > 0 ? 1:0);
- } else if (type == MSG_MWI_FAX_SMS) {
- pTmpsimMwiInfo.cphs_mwi.b_fax = (count > 0 ? 1:0);
- } else {
- MSG_DEBUG("There is no type [%d] in CPHS.", type);
- return;
- }
-
- mwReq.mw_data_u.cphs_mw.b_voice1 = pTmpsimMwiInfo.cphs_mwi.b_voice1;
- mwReq.mw_data_u.cphs_mw.b_voice2 = pTmpsimMwiInfo.cphs_mwi.b_voice2;
- mwReq.mw_data_u.cphs_mw.b_fax = pTmpsimMwiInfo.cphs_mwi.b_fax;
- mwReq.mw_data_u.cphs_mw.b_data = pTmpsimMwiInfo.cphs_mwi.b_data;
-
- MSG_DEBUG("MWI voice 1 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice1);
- MSG_DEBUG("MWI voice 2 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice2);
- MSG_DEBUG("MWI fax = [%d]", mwReq.mw_data_u.cphs_mw.b_fax);
- MSG_DEBUG("MWI data = [%d]", mwReq.mw_data_u.cphs_mw.b_data);
-
- } else {
- MSG_DEBUG("b_cphs is not set");
-
- if (type == MSG_MWI_VOICE_SMS)
- pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count = count;
- else if (type == MSG_MWI_FAX_SMS)
- pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count = count;
- else if (type == MSG_MWI_EMAIL_SMS)
- pTmpsimMwiInfo.mwi_list.mw_info[0].email_count = count;
- else /* MSG_MWI_OTHER_SMS */
- pTmpsimMwiInfo.mwi_list.mw_info[0].other_count = count;
-
- mwReq.mw_data_u.mw.rec_index = pTmpsimMwiInfo.mwi_list.mw_info[0].rec_index;
-
- if (count <= 0)
- mwReq.mw_data_u.mw.indicator_status = 0x00;
- else
- mwReq.mw_data_u.mw.indicator_status = 0x01;
-
- mwReq.mw_data_u.mw.voice_count = pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count;
- mwReq.mw_data_u.mw.fax_count = pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count;
- mwReq.mw_data_u.mw.email_count = pTmpsimMwiInfo.mwi_list.mw_info[0].email_count;
- mwReq.mw_data_u.mw.other_count = pTmpsimMwiInfo.mwi_list.mw_info[0].other_count;
- mwReq.mw_data_u.mw.video_count = pTmpsimMwiInfo.mwi_list.mw_info[0].video_count;
-
- MSG_DEBUG("MWI record index = [%d]", mwReq.mw_data_u.mw.rec_index);
- MSG_DEBUG("MWI ind status = [%d]", mwReq.mw_data_u.mw.indicator_status);
- MSG_DEBUG("MWI voice = [%d]", mwReq.mw_data_u.mw.voice_count);
- MSG_DEBUG("MWI fax = [%d]", mwReq.mw_data_u.mw.fax_count);
- MSG_DEBUG("MWI email = [%d]", mwReq.mw_data_u.mw.email_count);
- MSG_DEBUG("MWI other = [%d]", mwReq.mw_data_u.mw.other_count);
- MSG_DEBUG("MWI video = [%d]", mwReq.mw_data_u.mw.video_count);
- }
-
- mwReq.b_cphs = pTmpsimMwiInfo.b_cphs;
-
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
-
- ret = tel_set_sim_messagewaiting_info(handle, &mwReq, TapiEventSetMwiInfo, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
- }
-
- return;
-}
-
-
-bool SmsPluginSetting::getMwiInfo(TapiHandle *handle)
-{
- MsgMutexLocker lock(mx);
-
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sim_messagewaiting_info(handle, TapiEventGetMwiInfo, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Get Mainbox info was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Get Mainbox info was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-bool SmsPluginSetting::getMsisdnInfo(TapiHandle *handle)
-{
- MsgMutexLocker lock(mx);
-
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sim_msisdn(handle, TapiEventGetMsisdnInfo, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Get Sim msisdn was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Get Sim msisdn was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-bool SmsPluginSetting::getSimServiceTable(TapiHandle *handle)
-{
- MsgMutexLocker lock(mx);
-
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sim_service_table(handle, TapiEventGetSimServiceTable, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_get_sim_service_table() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_get_sim_service_table() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getResultFromSim() == true) {
- MSG_DEBUG("######## Get SST info was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Get SST info was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-void SmsPluginSetting::setParamCntEvent(int ParamCnt)
-{
- mx.lock();
-
- paramCnt = ParamCnt;
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-int SmsPluginSetting::getParamCntEvent()
-{
- int ret = 0;
-
- mx.lock();
-
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_ERR("WARNING: TAPI callback TIME-OUT");
- return 0;
- }
-
- return paramCnt;
-}
-
-
-void SmsPluginSetting::setParamEvent(struct tapi_handle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess)
-{
- mx.lock();
-
- bTapiResult = bSuccess;
-
- int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- memset(&smscData[sim_idx], 0x00, sizeof(MSG_SMSC_DATA_S));
-
- if (bTapiResult == true) {
- MSG_DEBUG("Success to get parameter data");
-
- selectedParam = RecordIdx;
-
- memcpy(&smscData[sim_idx], pSmscData, sizeof(MSG_SMSC_DATA_S));
- }
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSetting::getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData)
-{
- int ret = 0;
-
- mx.lock();
-
- bTapiResult = false;
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
-
- if (bTapiResult == true) {
- int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
- memcpy(pSmscData, &smscData[index], sizeof(MSG_SMSC_DATA_S));
- }
-
- return bTapiResult;
-}
-
-
-void SmsPluginSetting::setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
-{
- MSG_BEGIN();
-
- mx.lock();
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- bTapiResult = bSuccess;
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (bTapiResult == true) {
- MSG_DEBUG("Success to get cb config data");
-
- pair <int, MSG_CBMSG_OPT_S> newCbOpt(simIndex, *pCbOpt);
- cbOptMap::iterator it = cbOpt.find(simIndex);
-
- if (it == cbOpt.end()) {
- MSG_DEBUG("IT is not present");
- } else {
- MSG_DEBUG("IT present");
- cbOpt.erase(it);
- }
- cbOpt.insert(newCbOpt);
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
- if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", keyName);
- }
- } else {
- MSG_DEBUG("Failed to get cb config data");
-
- cbOptMap::iterator it = cbOpt.find(simIndex);
-
- if (it == cbOpt.end()) {
- MSG_DEBUG("IT not present");
- MSG_CBMSG_OPT_S pTmpCbOpt;
-
- memset(&pTmpCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
- pair <int, MSG_CBMSG_OPT_S> newCbOpt(simIndex, pTmpCbOpt);
-
- cbOpt.insert(newCbOpt);
- }
- }
-
- cv.signal();
-
- mx.unlock();
- MSG_END();
-}
-
-
-bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
-{
- MSG_BEGIN();
-
- int ret = 0;
-
- mx.lock();
-
- bTapiResult = false;
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- int simIndex = pCbOpt->simIndex;
-
- memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
-
- if (bTapiResult == true) {
- cbOptMap::iterator it = cbOpt.find(simIndex);
-
- if (it == cbOpt.end()) {
- MSG_DEBUG("IT is not present");
- return false;
- }
-
- MSG_DEBUG("IT is present");
-
- MSG_CBMSG_OPT_S &pTmpCbOpt = it->second;
- memcpy(pCbOpt, &pTmpCbOpt, sizeof(MSG_CBMSG_OPT_S));
- }
-
- MSG_END();
- return bTapiResult;
-}
-
-
-void SmsPluginSetting::setMailboxInfoEvent(TapiHandle *handle, SMS_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess, bool bMbdn)
-{
- MSG_BEGIN();
-
- MSG_DEBUG("bSuccess = %d, bMbdn = %d", bSuccess, bMbdn);
- mx.lock();
-
- bTapiResult = bSuccess;
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- bMbdnEnable[simIndex] = bMbdn;
-
- /* print incoming mailbox list */
- if (pMailboxList) {
- MSG_DEBUG("Input list is count = %d ", pMailboxList->count);
-
- for (int i = 0; i < pMailboxList->count; i++) {
- MSG_DEBUG("List index = %d", i);
- MSG_DEBUG("ton = %d, num = %s, alpha_id = %s", pMailboxList->list[i].ton, pMailboxList->list[i].num, pMailboxList->list[i].alpha_id);
- }
- } else {
- MSG_INFO("pMailboxList is NULL");
- }
-
- if (bTapiResult == true) {
- int i = 0;
- bool bExistMailboxType = false;
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- if (pMailboxList && pMailboxList->count > 0) {
- pair <int, SMS_SIM_MAILBOX_LIST_S> newList(simIndex, *pMailboxList);
-
- smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
- if (it == simMailboxList.end()) {
- MSG_DEBUG("IT not present !!!");
- simMailboxList.insert(newList);
- } else {
- MSG_DEBUG("IT present !!!");
- simMailboxList.erase(it);
- simMailboxList.insert(newList);
- }
-
- /* Temp :: Save voicemail number with VOICE1 line number */
- for (i = 0; i < pMailboxList->count ; i++) {
- MSG_SEC_DEBUG("Mailbox list[%d] type=[%d]", i, pMailboxList->list[i].mb_type);
-
- if (pMailboxList->list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
- bExistMailboxType = true;
- break;
- }
- }
-
- if (bExistMailboxType == false) {
- MSG_DEBUG("There is no voice mailbox type.");
- for (i = 0; i < simMailboxList[simIndex].count; i++) {
- if (pMailboxList->list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pMailboxList->list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
- pMailboxList->list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
- break;
- }
- }
- }
-
- smsSimMailboxListMap::iterator iter = simMailboxList.find(simIndex);
-
- SMS_SIM_MAILBOX_LIST_S &pTmpMailboxList = iter->second;
-
- char mailNumber[MAX_PHONE_NUMBER_LEN+1];
- memset(mailNumber, 0x00 , sizeof(mailNumber));
-
- MSG_SEC_DEBUG("Mailbox list[%d] ton=[%d], address=[%s], alpha_id=[%s]", \
- i, pTmpMailboxList.list[i].ton, pTmpMailboxList.list[i].num, \
- pTmpMailboxList.list[i].alpha_id);
-
- if (pTmpMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && pTmpMailboxList.list[i].num[0] != '+') {
- snprintf(mailNumber, sizeof(mailNumber), "+%s", pTmpMailboxList.list[i].num);
- MSG_WARN("MSG_TON_INTERNATIONAL [%s]", mailNumber);
- } else {
- snprintf(mailNumber, sizeof(mailNumber), "%s", pTmpMailboxList.list[i].num);
- MSG_DEBUG("[%s]", mailNumber);
- }
-
- if (mailNumber[0] != '\0') {
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
- if (MsgSettingSetString(keyName, mailNumber) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetString is failed!!");
- }
-
- if (pTmpMailboxList.list[i].alpha_id[0] != '\0') {
- char unpackAlphaId[MAX_SIM_XDN_ALPHA_ID_LEN+8];
- int tmpLen = 0;
- MSG_LANG_INFO_S langInfo = {0, };
-
- memset(unpackAlphaId, 0x00, sizeof(unpackAlphaId));
-
- langInfo.bSingleShift = false;
- langInfo.bLockingShift = false;
-
- tmpLen = strlen(pTmpMailboxList.list[i].alpha_id);
-
- MsgTextConvert *textCvt = MsgTextConvert::instance();
- textCvt->convertGSM7bitToUTF8((unsigned char*)unpackAlphaId, sizeof(unpackAlphaId), (unsigned char*)pTmpMailboxList.list[i].alpha_id, tmpLen, &langInfo);
-
- MSG_DEBUG("UTF8 ALPHA_ID = [%s]", unpackAlphaId);
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, simIndex);
- if (MsgSettingSetString(keyName, unpackAlphaId) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetString is failed!!");
- }
- }
- } else {
- /* insert empty list with sim index */
- SMS_SIM_MAILBOX_LIST_S pDummySimMailboxList;
-
- memset(&pDummySimMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
- pair <int, SMS_SIM_MAILBOX_LIST_S> newTmpList(simIndex, pDummySimMailboxList);
- simMailboxList.insert(newTmpList);
- }
-
- cv.signal();
-
- mx.unlock();
- MSG_END();
-}
-
-bool SmsPluginSetting::getMailboxInfoEvent()
-{
- int ret = 0;
-
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- return bTapiResult;
-}
-
-void SmsPluginSetting::setMwiInfoEvent(struct tapi_handle *handle, SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess)
-{
- MSG_BEGIN();
-
- mx.lock();
-
- bTapiResult = bSuccess;
-
- int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (bTapiResult == true) {
- int mwiCnt = 0;
- char keyName[MAX_VCONFKEY_NAME_LEN];
-
- pair <int, SMS_SIM_MWI_INFO_S> newList(index, *pMwiInfo);
- simMwiInfoMap::iterator it = simMwiInfo.find(index);
-
- if (it == simMwiInfo.end()) {
- MSG_DEBUG("IT not present");
- } else {
- MSG_DEBUG("IT present");
- simMwiInfo.erase(it);
- }
- simMwiInfo.insert(newList);
-
- simMwiInfoMap::iterator iter = simMwiInfo.find(index);
-
- SMS_SIM_MWI_INFO_S &pTmpsimMwiInfoList = iter->second;
-
- /* Save MW count with VOICE line1 number */
- if (pTmpsimMwiInfoList.b_cphs == true) {
- mwiCnt = pTmpsimMwiInfoList.cphs_mwi.b_voice1;
- } else {
- mwiCnt = pTmpsimMwiInfoList.mwi_list.mw_info[0].voice_count;
- }
- /* TODO :: Add operation for voice mail of line 2 */
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, index);
- if (MsgSettingSetInt(keyName, mwiCnt) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingSetInt is failed!!");
-
- MSG_DEBUG("MWI count = [%d]", mwiCnt);
-
- if (mwiCnt > 0) {
- deliverVoiceMsgNoti(index, mwiCnt);
- }
- } else {
- SMS_SIM_MWI_INFO_S pTmpsimMwiInfo;
-
- memset(&pTmpsimMwiInfo, 0x00, sizeof(SMS_SIM_MWI_INFO_S));
-
- pair <int, SMS_SIM_MWI_INFO_S> newList(index, pTmpsimMwiInfo);
- simMwiInfoMap::iterator it = simMwiInfo.find(index);
-
- if (it == simMwiInfo.end()) {
- MSG_DEBUG("IT not present");
- } else {
- MSG_DEBUG("IT present");
- simMwiInfo.erase(it);
- }
- simMwiInfo.insert(newList);
- }
-
- cv.signal();
-
- mx.unlock();
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::setResultImei(bool bResult, char *pImei)
-{
- mx.lock();
-
- bTapiResult = bResult;
-
- memset(&meImei, 0x00, sizeof(meImei));
-
- if (bTapiResult == true && pImei) {
- snprintf(meImei, sizeof(meImei), "%s", pImei);
- }
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSetting::getResultImei(char *pImei)
-{
- int ret = 0;
-
- mx.lock();
-
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- if (bTapiResult == true && pImei) {
- snprintf(pImei, sizeof(meImei), "%s", meImei);
- }
-
- return bTapiResult;
-}
-
-
-void SmsPluginSetting::setResultFromSim(bool bResult)
-{
- mx.lock();
-
- bTapiResult = bResult;
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSetting::getResultFromSim()
-{
- int ret = 0;
-
- MSG_DEBUG("getResultFromSim() is called .");
-
- ret = cv.timedwait(mx.pMsgMutex(), MAX_TAPI_SIM_API_TIMEOUT);
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- return bTapiResult;
-}
-
-
-SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
-{
- SMS_PID_T retPid;
-
- switch (pid) {
- case MSG_PID_TEXT :
- retPid = SMS_PID_NORMAL;
- break;
- case MSG_PID_VOICE :
- retPid = SMS_PID_VOICE;
- break;
- case MSG_PID_FAX :
- retPid = SMS_PID_TELEX;
- break;
- case MSG_PID_X400 :
- retPid = SMS_PID_x400;
- break;
- case MSG_PID_ERMES :
- retPid = SMS_PID_ERMES;
- break;
- case MSG_PID_EMAIL :
- retPid = SMS_PID_EMAIL;
- break;
- default :
- retPid = SMS_PID_NORMAL;
- break;
- }
-
- return retPid;
-}
-
-
-void SmsPluginSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt)
-{
- MSG_BEGIN();
-
- MSG_MESSAGE_INFO_S msgInfo = {0, };
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(msgInfo.addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- msgInfo.nAddressCnt = 1;
-
- msgInfo.displayTime = time(NULL);
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- char *voiceNum = NULL;
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
- if (MsgSettingGetString(keyName, &voiceNum) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- if (voiceNum) {
- snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNum);
- free(voiceNum);
- voiceNum = NULL;
- }
- memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
- msgInfo.sim_idx = simIndex;
-
-#if 0
- if (simMwiInfo.b_cphs == false) {
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new voice message", mwiCnt);
- } else {
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "New voice message");
- }
-#else
- snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", mwiCnt);
-#endif
-
-#if 0
- if (SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo) != MSG_SUCCESS)
- MSG_DEBUG("callbackIncoming is failed.");
-#else
- MsgInsertNotification(&msgInfo);
- MsgChangePmState();
-#endif
-
- MSG_END();
-}
-
-
-void SmsPluginSetting::setSimChangeStatus(TapiHandle *handle, bool bInitializing)
-{
- MSG_BEGIN();
-
- int tapiRet = TAPI_API_SUCCESS;
- TelSimCardStatus_t status = TAPI_SIM_STATUS_CARD_ERROR;
-
- int cardChanged = 0;
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- pthread_t thd;
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
-
- tapiRet = tel_get_sim_init_info(handle, &status, &cardChanged);
- MSG_INFO("Tapi Ret=[%d], SIM index [%d], SIM status [%d], CardChanged [%d]", tapiRet, simIndex, status, cardChanged);
-
- if (status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
- if (simStatus[simIndex] == MSG_SIM_STATUS_NOT_FOUND) {
- if (cardChanged == 1) {
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
- MsgSettingSetInt(keyName, MSG_SIM_STATUS_CHANGED);
- simStatus[simIndex] = MSG_SIM_STATUS_CHANGED;
- } else {
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
- MsgSettingSetInt(keyName, MSG_SIM_STATUS_NORMAL);
- simStatus[simIndex] = MSG_SIM_STATUS_NORMAL;
- }
-
- /* Modified to call initSimInfo for SIM separately */
- MSG_DEBUG("calling initSimInfo");
- if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
- MSG_DEBUG("pthread_create() error");
- } else {
- pthread_detach(thd);
- }
- } else {
- MSG_DEBUG("SIM init was already done!");
- }
- } else {
- MSG_DEBUG("It doesn't initialize yet!!");
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
- MSG_DEBUG("Set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND");
- if (MsgSettingSetInt(keyName, MSG_SIM_STATUS_NOT_FOUND) != MSG_SUCCESS)
- MSG_DEBUG("Fail to set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND");
-
- simStatus[simIndex] = MSG_SIM_STATUS_NOT_FOUND;
- }
-
- MSG_END();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginTpduCodec.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginCallback.h"
-#include "MsgUtilStorage.h"
-#include "MsgNotificationWrapper.h"
-
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginDSHandler.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginSimMsg - Member Functions
-==================================================================================================*/
-SmsPluginSimMsg* SmsPluginSimMsg::pInstance = NULL;
-
-
-SmsPluginSimMsg::SmsPluginSimMsg()
-{
- /* Initialize member variables */
- simMsgId = 0;
- delSimMsgId = -1;
- usedCnt = 0;
- totalCnt = 0;
- bTapiResult = false;
- memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo));
- memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
- memset(&simMsgCnt, 0x00, sizeof(simMsgCnt));
- memset(&simMsgInfo, 0x00, sizeof(simMsgInfo));
- memset(&simAddrInfo, 0x00, sizeof(simAddrInfo));
-}
-
-
-SmsPluginSimMsg::~SmsPluginSimMsg()
-{
-}
-
-
-SmsPluginSimMsg* SmsPluginSimMsg::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginSimMsg();
-
- return pInstance;
-}
-
-
-void SmsPluginSimMsg::initSimMessage(TapiHandle *handle)
-{
- MSG_BEGIN();
-
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
- int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
- /* Set SIM count of vconf to 0 */
- if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", keyName);
- }
- memset(keyName, 0, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
-
- if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS) {
- MSG_DEBUG("Error to set config data [%s]", keyName);
- }
-
- MSG_SIM_COUNT_S tmpMsgCnt;
- memset(&tmpMsgCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
- getSimMsgCount(handle, &tmpMsgCnt);
-
- MSG_MESSAGE_INFO_S tmpMsgInfo;
- int simIdList[MAX_SIM_SMS_NUM];
- int unreadSimMsg = 0;
-
- for (int i = 0; i < tmpMsgCnt.usedCount; i++) {
- memset(&tmpMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
- memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
-
- /* Get SIM Msg */
- if (getSimMsg(handle, tmpMsgCnt.indexList[i], &tmpMsgInfo, simIdList) == false)
- continue;
-
- if (tmpMsgInfo.bRead == false)
- unreadSimMsg++;
-
- if (SmsPluginEventHandler::instance()->handleSimMsg(&tmpMsgInfo, simIdList, NULL, MAX_SIM_SMS_NUM) < 0) {
- MSG_DEBUG("Fail to handleSimMsg()");
- }
-
- if (tmpMsgInfo.addressList) {
- free(tmpMsgInfo.addressList);
- tmpMsgInfo.addressList = NULL;
- }
- }
-
- MSG_DEBUG("Unread SIM message count = [%d]", unreadSimMsg);
-#ifndef MSG_NOTI_INTEGRATION
- if (unreadSimMsg > 0) {
- MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, MSG_ACTIVE_NOTI_TYPE_NONE);
- }
-#endif
-
- if (SmsPluginEventHandler::instance()->updateIMSI(sim_idx) != MSG_SUCCESS) {
- MSG_ERR("Fail to handleSimMsg()");
- }
-
- MSG_END();
-}
-
-
-msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList)
-{
- bool bSimSst = true;
-
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
- if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
- /* No return, default value is true. */
-
- if (bSimSst == false)
- return MSG_ERR_STORE_RESTRICT;
-
- /* Reset Out Parameter */
- pSimIdList->count = 0;
-
- SMS_TPDU_S tpdu;
- memset(&tpdu, 0x00, sizeof(SMS_TPDU_S));
- if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) {
- tpdu.tpduType = SMS_TPDU_SUBMIT;
- tpdu.data.submit.dcs.msgClass = SMS_MSG_CLASS_NONE;
- /*SmsPluginTransport::instance()->setSmsSendOptions(&(tpdu.data.submit));*/
- tpdu.data.submit.vpf = SMS_VPF_NOT_PRESENT;
- tpdu.data.submit.dcs.codingScheme = SMS_CHARSET_AUTO;
- } else {
- tpdu.tpduType = SMS_TPDU_DELIVER;
- setSmsOptions(pMsgInfo, &(tpdu.data.deliver));
- /* Set TimeStamp */
- convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
- tpdu.data.deliver.dcs.codingScheme = SMS_CHARSET_AUTO;
- }
-
- for (int i = 0; i <pMsgInfo->nAddressCnt; ++i) {
- SMS_SUBMIT_DATA_S submitData;
- memset(&submitData, 0x00, sizeof(SMS_SUBMIT_DATA_S));
- int bufLen = 0;
- char buf[MAX_TPDU_DATA_LEN];
-
- if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) { /* SUBMIT MSG */
- SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.submit.dcs.codingScheme), i);
-
- int addLen = strlen(submitData.destAddress.address);
-
- tpdu.data.submit.destAddress.ton = submitData.destAddress.ton;
- tpdu.data.submit.destAddress.npi = submitData.destAddress.npi;
-
- if (addLen < MAX_ADDRESS_LEN) {
- memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen);
- tpdu.data.submit.destAddress.address[addLen] = '\0';
- } else {
- memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
- tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
- }
-
- } else { /* DELIVER MSG */
- SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme), i);
-
- int addLen = strlen(submitData.destAddress.address);
-
- tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
- tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
-
- if (addLen < MAX_ADDRESS_LEN) {
- memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addLen);
- tpdu.data.deliver.originAddress.address[addLen] = '\0';
- } else {
- memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
- tpdu.data.deliver.originAddress.address[MAX_ADDRESS_LEN] = '\0';
- }
- }
-
- /* Check sim message full. */
- if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true) {
- MSG_DEBUG("SIM storage is full.");
- MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
-
- return MSG_ERR_SIM_STORAGE_FULL;
- }
-
- if (submitData.segCount > 1) {
- if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) { /* SUBMIT MSG */
- tpdu.data.submit.bHeaderInd = true;
- } else {
- tpdu.data.deliver.bHeaderInd = true;
- }
- }
-
- for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
- if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MO) {
- memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
- } else {
- memcpy(&(tpdu.data.deliver.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
- }
-
- memset(buf, 0x00, sizeof(buf));
-
- /* Encode SMS-DELIVER TPDU */
- bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
-
- /* Make Telephony Structure */
- TelSmsData_t simSmsData;
- memset((void*)&simSmsData, 0x00, sizeof(simSmsData));
-
- /* Set TPDU data */
- memcpy((void*)simSmsData.SmsData.szData, buf, bufLen);
-
- simSmsData.SmsData.szData[bufLen] = 0;
- simSmsData.SmsData.MsgLength = bufLen;
- simSmsData.SmsData.format = TAPI_NETTEXT_NETTYPE_3GPP;
-
- if (pMsgInfo->direction == MSG_DIRECTION_TYPE_MT) { /* MT messages */
- if (pMsgInfo->bRead == true)
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_READ;
- else
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
- } else { /* MO messages */
- if (pMsgInfo->networkStatus == MSG_NETWORK_SEND_SUCCESS)
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_SENT;
- else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS)
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_DELIVERED;
- else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL)
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_DELIVERY_UNCONFIRMED;
- else
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNSENT;
- }
-
- /* Save SMS in SIM */
- int ret = 0;
-
- ret = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveSimMsg, NULL);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_write_sms_in_sim Success !!!#######");
- } else {
- MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", ret);
-
- return MSG_ERR_PLUGIN_STORAGE;
- }
-
- msg_sim_id_t SimId = 0;
-
- bool bResult = false;
-
- bResult = getSimEvent(&SimId);
-
- int usedCnt = 0;
-
- if (bResult == true) {
- MSG_DEBUG("######## Saving Msg was Successful !!! SIM ID : [%d] #######", SimId);
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx);
- if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- usedCnt++;
-
- if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
- MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
-
- pSimIdList->simId[pSimIdList->count] = SimId;
- pSimIdList->count++;
- } else {
- MSG_DEBUG("######## Saving Msg was Failed !!! SIM ID : [%d] #######", SimId);
-
- return MSG_ERR_PLUGIN_STORAGE;
- }
- }
- }
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- msg_error_t err = MSG_SUCCESS;
- bool bSimSst = true;
- int tapiRet = TAPI_API_SUCCESS;
- int simId = -1;
- int replaceSimId = -1;
- int replaceMsgId = 0;
-
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pMsgInfo->sim_idx);
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
- if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
- /* No return, default value is true. */
-
- if (bSimSst == false) {
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_SUCCESS);
- return MSG_SUCCESS;
- }
-
- /* Reset Flag */
- SMS_TPDU_S tpdu;
-
- tpdu.tpduType = SMS_TPDU_DELIVER;
-
- convertTimeStamp(pMsgInfo, &(tpdu.data.deliver));
-
- /* Set SMS TPDU Options */
- setSmsOptions(pMsgInfo, &(tpdu.data.deliver));
-
- SMS_SUBMIT_DATA_S submitData;
- int bufLen = 0;
- char buf[MAX_TPDU_DATA_LEN];
-
- SmsPluginTransport::instance()->msgInfoToSubmitData(pMsgInfo, &submitData, &(tpdu.data.deliver.dcs.codingScheme), 0);
-
- if (pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS && pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS) {
- err = SmsPluginStorage::instance()->getReplaceSimMsg(pMsgInfo, &replaceMsgId, &replaceSimId);
- MSG_DEBUG("getReplaceSimMsg(): err=[%d], Replace Sim Id = [%d], Replace message id = [%d]", err, replaceSimId, replaceMsgId);
- if (replaceMsgId < 0)
- replaceMsgId = 0;
- }
-
- /* Check SIM ID */
- if (replaceSimId < 0) { /* Normal message type */
- /* Check sim message full. */
- if (checkSimMsgFull(pMsgInfo->sim_idx, submitData.segCount) == true) {
- MSG_ERR("SIM storage is full.");
-
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_SIM_STORAGE_FULL);
-
- return MSG_ERR_SIM_STORAGE_FULL;
- }
-
- int addLen = strlen(submitData.destAddress.address);
-
- tpdu.data.deliver.originAddress.ton = submitData.destAddress.ton;
- tpdu.data.deliver.originAddress.npi = submitData.destAddress.npi;
-
- if (addLen < MAX_ADDRESS_LEN) {
- memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, addLen);
- tpdu.data.deliver.originAddress.address[addLen] = '\0';
- } else {
- memcpy(tpdu.data.deliver.originAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
- tpdu.data.deliver.originAddress.address[MAX_ADDRESS_LEN] = '\0';
- }
-
- if (submitData.segCount > 1)
- tpdu.data.deliver.bHeaderInd = true;
- } else { /* Replace message type */
- tapiRet = tel_delete_sms_in_sim(handle, replaceSimId, TapiEventDeleteSimMsg, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_delete_sms_in_sim Success !!! #######");
-
- simId = -1;
- if (getDelSimEvent(&simId) == true) {
- err = SmsPluginStorage::instance()->deleteSimMessage(pMsgInfo->sim_idx, replaceSimId);
- }
- MSG_DEBUG("tel_delete_sms_in_sim() : Err=[%d], Replace Sim Id=[%d], Result Sim id=[%d]", err, replaceSimId, simId);
-
- } else {
- MSG_DEBUG("######## tel_delete_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
- }
- }
-
- for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
- /* Create TelSmsData_t data */
- TelSmsData_t simSmsData = {0, };
-
- if (submitData.segCount == 1) {
- memcpy(&simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca)-1);
- memcpy(&simSmsData.SmsData.szData, &simMsgDataInfo.szData, sizeof(simSmsData.SmsData.szData)-1);
- simSmsData.SmsData.MsgLength = simMsgDataInfo.msgLength;
-
- } else {
- memcpy(&(tpdu.data.deliver.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
-
- memset(buf, 0x00, sizeof(buf));
-
- /* Encode SMS-DELIVER TPDU */
- bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
-
- /* Set TPDU data */
- int copyLen = (bufLen > TAPI_NETTEXT_SMDATA_SIZE_MAX) ? TAPI_NETTEXT_SMDATA_SIZE_MAX : bufLen;
- memcpy((void*)simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca)-1);
- memcpy((void*)simSmsData.SmsData.szData, buf, (size_t)copyLen);
- simSmsData.SmsData.szData[copyLen] = 0;
- simSmsData.SmsData.MsgLength = copyLen;
- }
-
- simSmsData.SmsData.format = TAPI_NETTEXT_NETTYPE_3GPP;
- simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD;
-
- MSG_MESSAGE_INFO_S *tmpSimMsgInfo = (MSG_MESSAGE_INFO_S *)calloc(1, sizeof(MSG_MESSAGE_INFO_S));
- if (tmpSimMsgInfo) {
- memcpy(tmpSimMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
-
- tmpSimMsgInfo->msgId = replaceMsgId;
-
- tmpSimMsgInfo->addressList = NULL;
- tmpSimMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memcpy(&tmpSimMsgInfo->addressList[0], &pMsgInfo->addressList[0], sizeof(MSG_ADDRESS_INFO_S));
-
- tapiRet = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveClass2Msg, tmpSimMsgInfo);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_write_sms_in_sim Success !!!, segNum = [%d] #######", segCnt);
- } else {
- MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
-
- SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_STORAGE_ERROR);
-
- if (tmpSimMsgInfo) {
- if (tmpSimMsgInfo->addressList) {
- delete[] tmpSimMsgInfo->addressList;
- tmpSimMsgInfo->addressList = NULL;
- }
- free(tmpSimMsgInfo);
- tmpSimMsgInfo = NULL;
- }
-
- return MSG_ERR_PLUGIN_STORAGE;
- }
- }
-
- msg_sim_id_t retSimId;
- if (!getSimEvent(&retSimId))
- return MSG_ERR_PLUGIN_STORAGE;
- }
-
- return MSG_SUCCESS;
-}
-
-
-void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
-{
- int tapiRet = TAPI_API_SUCCESS;
-
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
- tapiRet = tel_delete_sms_in_sim(handle, (int)SimMsgId, TapiEventDeleteSimMsg, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_delete_sms_in_sim Success !!! #######");
- else
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_delete_sms_in_sim Fail !!! return : [%d] #######", tapiRet);
-
- int SimId = 0;
- bool bResult = false;
-
- bResult = getDelSimEvent(&SimId);
-
- int usedCnt = 0, totalCnt = 0;
-
- if (bResult == true) {
- MSG_DEBUG("######## Deleting Msg was Successful !!! SIM ID : [%d] #######", SimId);
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
- if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
- if (MsgSettingGetInt(keyName, &totalCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
-
- if (usedCnt == totalCnt) {
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, NULL, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! return : [%d] #######", tapiRet);
- }
-
- usedCnt--;
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
-
- if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
- MSG_DEBUG("Error to set config data [%s]", keyName);
- } else {
- THROW(MsgException::SMS_PLG_ERROR, "######## Deleting Msg was Failed !!! SIM ID : [%d] #######", SimId);
- }
-}
-
-
-bool SmsPluginSimMsg::checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int SegCnt)
-{
- int usedCnt = 0, totalCnt = 0;
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
- if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
- if (MsgSettingGetInt(keyName, &totalCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
-
- MSG_DEBUG("Segment Count [%d]", SegCnt);
- MSG_DEBUG("usedCnt [%d], totalCnt [%d]", usedCnt, totalCnt);
-
- if ((usedCnt + (int)SegCnt) <= totalCnt)
- return false;
- else
- return true;
-}
-
-
-void SmsPluginSimMsg::setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId)
-{
- MSG_DEBUG("Sim Message ID [%d]", SimMsgId);
-
- int ret = TAPI_API_SUCCESS;
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(sim_idx);
-
- ret = tel_set_sms_message_status(handle, (int)SimMsgId, TAPI_NETTEXT_STATUS_READ, TapiEventSetMsgStatus, (void *)&SimMsgId);
-
- if (ret == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_message_status Success !!! return : %d #######", ret);
- else
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_set_sms_message_status Fail !!! return : %d #######", ret);
-
- msg_sim_id_t SimId = 0;
- bool bResult = false;
-
- bResult = getSimEvent(&SimId);
-
- if (bResult == true)
- MSG_DEBUG("######## Setting Read Status was Successful !!!, sim id=[%d] #######", SimId);
- else
- THROW(MsgException::SMS_PLG_ERROR, "######## Setting Read Status was Failed !!! #######");
-}
-
-
-void SmsPluginSimMsg::getSimMsgCount(TapiHandle *handle, MSG_SIM_COUNT_S *pSimMsgCnt)
-{
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_get_sms_count(handle, TapiEventGetSimMsgCnt, NULL);
-
- if (ret == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_get_sms_count() Success !!! #######");
- else
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_count() Fail !!! return : %d #######", ret);
-
- if (getSimMsgCntEvent(handle, pSimMsgCnt) == true)
- MSG_DEBUG("######## Get Sim Msg Count was Successful !!! #######");
- else
- THROW(MsgException::SMS_PLG_ERROR, "######## Get Sim Msg Count was Failed !!! #######");
-}
-
-
-bool SmsPluginSimMsg::getSimMsg(TapiHandle *handle, msg_sim_id_t SimMsgId, MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList)
-{
- int ret = TAPI_API_SUCCESS;
-
- ret = tel_read_sms_in_sim(handle, SimMsgId, TapiEventGetSimMsg, simIdList);
-
- if (ret == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_read_sms_in_sim() Success !!! Sim ID : [%d] #######", SimMsgId);
- } else {
- MSG_DEBUG("######## tel_read_sms_in_sim() Fail !!! return : %d #######", ret);
- return false;
- }
-
- if (getSimMsgEvent(handle, pMsgInfo) == true) {
- MSG_DEBUG("######## Get Sim Msg was Successful !!! #######");
- } else {
- MSG_DEBUG("######## Get Sim Msg was Failed !!! #######");
- return false;
- }
-
- return true;
-}
-
-
-void SmsPluginSimMsg::setSmsOptions(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_DELIVER_S *pDeliver)
-{
- pDeliver->bMoreMsg = false;
- pDeliver->bStatusReport = false;
- pDeliver->bHeaderInd = false;
- pDeliver->bReplyPath = false;
-
- pDeliver->dcs.bCompressed = false;
- pDeliver->dcs.msgClass = SMS_MSG_CLASS_NONE;
- pDeliver->dcs.codingGroup = SMS_GROUP_GENERAL;
-
- pDeliver->dcs.codingScheme = pMsgInfo->encodeType;
-
- MSG_DEBUG("DCS : %d", pDeliver->dcs.codingScheme);
-
- pDeliver->pid = SMS_PID_NORMAL;
-
- MSG_DEBUG("PID : %d", pDeliver->pid);
-}
-
-
-void SmsPluginSimMsg::convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_DELIVER_S *pDeliver)
-{
- MSG_BEGIN();
-
- /* encode time stamp */
- pDeliver->timeStamp.format = SMS_TIME_ABSOLUTE;
-
- /* encode absolute time */
- struct tm timeinfo = {0, };
- tzset();
- localtime_r(&pMsgInfo->displayTime, &timeinfo);
-
- pDeliver->timeStamp.time.absolute.year = timeinfo.tm_year - 100;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.year is %d", pDeliver->timeStamp.time.absolute.year);
-
- pDeliver->timeStamp.time.absolute.month = timeinfo.tm_mon + 1;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.month is %d", pDeliver->timeStamp.time.absolute.month);
-
- pDeliver->timeStamp.time.absolute.day = timeinfo.tm_mday;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.day is %d", pDeliver->timeStamp.time.absolute.day);
-
- pDeliver->timeStamp.time.absolute.hour = timeinfo.tm_hour;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.hour is %d", pDeliver->timeStamp.time.absolute.hour);
-
- pDeliver->timeStamp.time.absolute.minute = timeinfo.tm_min;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.minute is %d", pDeliver->timeStamp.time.absolute.minute);
-
- pDeliver->timeStamp.time.absolute.second = timeinfo.tm_sec;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.second is %d", pDeliver->timeStamp.time.absolute.second);
-
- pDeliver->timeStamp.time.absolute.timeZone = 0;
- MSG_DEBUG("pDeliver->timeStamp.time.absolute.timeZone is %d", pDeliver->timeStamp.time.absolute.timeZone);
-
- MSG_END();
-}
-
-
-void SmsPluginSimMsg::setSimMsgCntEvent(TapiHandle *handle, const MSG_SIM_COUNT_S *pSimMsgCnt)
-{
- mx.lock();
-
- MSG_INFO("Sim Message Count is %d.", pSimMsgCnt->usedCount);
-
- int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
- char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
-
- for (int i = 0; i < pSimMsgCnt->usedCount; i++) {
- MSG_DEBUG("Sim Message Index is %d.", pSimMsgCnt->indexList[i]);
- }
-
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx);
- if (MsgSettingSetInt(keyName, pSimMsgCnt->usedCount) != MSG_SUCCESS)
- MSG_ERR("Error to set config data [%s]", SIM_USED_COUNT);
-
- memset(keyName, 0, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx);
- if (MsgSettingSetInt(keyName, (int)pSimMsgCnt->totalCount) != MSG_SUCCESS)
- MSG_ERR("Error to set config data [%s]", SIM_TOTAL_COUNT);
-
- memset(&simMsgCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
- memcpy(&simMsgCnt, pSimMsgCnt, sizeof(MSG_SIM_COUNT_S));
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSimMsg::getSimMsgCntEvent(TapiHandle *handle, MSG_SIM_COUNT_S *pSimMsgCnt)
-{
- int ret = 0;
-
- mx.lock();
-
- ret = cv.timedwait(mx.pMsgMutex(), 10);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_ERR("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- memcpy(pSimMsgCnt, &simMsgCnt, sizeof(MSG_SIM_COUNT_S));
-
- return true;
-}
-
-void SmsPluginSimMsg::setSimMsgEvent(TapiHandle *handle, const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess)
-{
- mx.lock();
-
- bTapiResult = bSuccess;
-
- memset(&simMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
- memset(&simAddrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- if (bTapiResult == true) {
- MSG_DEBUG("Success to get sim msg - Id : [%d]", pMsgInfo->msgId);
-
- memcpy(&simMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
- simMsgInfo.addressList = &simAddrInfo;
- memcpy(&simAddrInfo, pMsgInfo->addressList, sizeof(MSG_ADDRESS_INFO_S));
- }
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSimMsg::getSimMsgEvent(TapiHandle *handle, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- int ret = 0;
-
- mx.lock();
-
- bTapiResult = false;
- ret = cv.timedwait(mx.pMsgMutex(), 10);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- memset(pMsgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- if (bTapiResult == true) {
- memcpy(pMsgInfo, &simMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
- pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)calloc(1, sizeof(MSG_ADDRESS_INFO_S));
- memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
- memcpy(pMsgInfo->addressList, simMsgInfo.addressList, sizeof(MSG_ADDRESS_INFO_S));
- pMsgInfo->sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
- }
-
-
- return bTapiResult;
-}
-
-
-void SmsPluginSimMsg::setSaveSimMsgEvent(TapiHandle *handle, int simId, int result)
-{
- msg_error_t err = MSG_SUCCESS;
-
- mx.lock();
-
- if (result != TAPI_NETTEXT_SENDSMS_SUCCESS) {
- if (result == TAPI_NETTEXT_ROUTING_NOT_AVAILABLE || result == TAPI_NETTEXT_SIM_FULL)
- err = MSG_ERR_SIM_STORAGE_FULL;
- else
- err = MSG_ERR_UNKNOWN;
- }
-
- if (err == MSG_SUCCESS)
- bTapiResult = true;
- else
- bTapiResult = false;
-
- simMsgId = simId;
-
- cv.signal();
-
- mx.unlock();
-
- int tapiRet = TAPI_API_SUCCESS;
-
- if (err == MSG_SUCCESS) {
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
- } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
- } else {
- return;
- }
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- }
-}
-
-
-void SmsPluginSimMsg::setSaveClass2MsgEvent(TapiHandle *handle, int simId, int result, MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- msg_error_t err = MSG_SUCCESS;
- /*int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle); */
-
- if (result == TAPI_NETTEXT_SENDSMS_SUCCESS && simId >= 0 && pMsgInfo) {
- bool isNewSimMsg = true;
-
- for (int i = 0; i < MAX_SIM_SMS_NUM; i++) {
- if (simIdList[i] != 0) {
- MSG_DEBUG("simIdList[%d] is exist [%d]", i, simIdList[i]);
- continue;
- } else {
- simIdList[i] = simId + 1;
- MSG_DEBUG("simIdList[%d] is assigned [%d]", i, simId + 1);
- break;
- }
- }
-
- if (pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS && pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS) {
- if (pMsgInfo->msgId > 0) {
- isNewSimMsg = false;
- }
- }
-
- if (simMsgDataInfo.totalSegment >= 1 && simIdList[simMsgDataInfo.totalSegment-1] != 0) {
- msg_message_id_t saved_msg_id = 0;
- SmsPluginEventHandler::instance()->handleSimMsg(pMsgInfo, simIdList, &saved_msg_id, MAX_SIM_SMS_NUM);
-
- MSG_DEBUG("Saved message ID = [%d]", saved_msg_id);
-
- if (saved_msg_id > 0)
- pMsgInfo->msgId = saved_msg_id;
-
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(pMsgInfo);
-
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
- }
-
- if (isNewSimMsg == true) {
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx);
- if (MsgSettingGetInt(keyName, &usedCnt) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- usedCnt++;
-
- if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS)
- MSG_DEBUG("Error to set config data [%s]", SIM_USED_COUNT);
- }
-
- if (simMsgDataInfo.totalSegment >= 1 && simIdList[simMsgDataInfo.totalSegment-1] != 0) {
- memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM);
- }
- } else {
- if (result == TAPI_NETTEXT_SIM_FULL)
- err = MSG_ERR_SIM_STORAGE_FULL;
- else
- err = MSG_ERR_UNKNOWN;
- }
-
- /* Send Deliver Report */
- SmsPluginTransport::instance()->sendDeliverReport(handle, err);
-}
-
-
-void SmsPluginSimMsg::setSimEvent(msg_sim_id_t SimId, bool bResult)
-{
- mx.lock();
-
- simMsgId = SimId;
- bTapiResult = bResult;
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSimMsg::getSimEvent(msg_sim_id_t *pSimId)
-{
- int ret = 0;
-
- mx.lock();
-
- bTapiResult = false;
- ret = cv.timedwait(mx.pMsgMutex(), 10);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- *pSimId = simMsgId;
-
- MSG_DEBUG("Returned SimMsgId is %d.", simMsgId);
-
- return bTapiResult;
-}
-
-
-void SmsPluginSimMsg::setDelSimEvent(int SimId, bool bResult)
-{
- mx.lock();
-
- delSimMsgId = SimId;
- bTapiResult = bResult;
-
- cv.signal();
-
- mx.unlock();
-}
-
-
-bool SmsPluginSimMsg::getDelSimEvent(int *pSimId)
-{
- int ret = 0;
-
- mx.lock();
-
- delSimMsgId = -1;
- bTapiResult = false;
- ret = cv.timedwait(mx.pMsgMutex(), 10);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
- return false;
- }
-
- *pSimId = delSimMsgId;
-
- MSG_DEBUG("Returned delSimMsgId is %d.", delSimMsgId);
-
- return bTapiResult;
-}
-
-
-void SmsPluginSimMsg::setSmsData(const char *sca, const char *szData, int msgLength)
-{
- MSG_DEBUG("Set SMS data(class2 message)");
-
- memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo));
-
- memcpy(&simMsgDataInfo.sca, sca, sizeof(simMsgDataInfo.sca)-1);
- memcpy(&simMsgDataInfo.szData, szData, sizeof(simMsgDataInfo.szData)-1);
- simMsgDataInfo.msgLength = msgLength;
-}
-
-void SmsPluginSimMsg::setSmsTpduTotalSegCount(int totalSeg)
-{
- MSG_DEBUG("Set SMS Segements Info");
-
- simMsgDataInfo.totalSegment = totalSeg;
-}
-
#include "MsgUtilFunction.h"
#include "MsgGconfWrapper.h"
#include "MsgNotificationWrapper.h"
+
+#include "SmsPluginTypes.h"
#include "SmsPluginMain.h"
-#include "SmsPluginSimMsg.h"
-#include "SmsPluginEventHandler.h"
#include "SmsPluginStorage.h"
-
+#include "Sms3gppStorage.h"
+#include "Sms3gppEventHandler.h"
/*==================================================================================================
- IMPLEMENTATION OF SmsPluginStorage - Member Functions
+ Variables
==================================================================================================*/
SmsPluginStorage* SmsPluginStorage::pInstance = NULL;
-
-SmsPluginStorage::SmsPluginStorage()
-{
- memset(&msgInfo, 0x00, sizeof(msgInfo));
- memset(&addrInfo, 0x00, sizeof(addrInfo));
-}
-
-
-SmsPluginStorage::~SmsPluginStorage()
-{
-}
-
-
+/*==================================================================================================
+ Methods of SmsPluginStorage
+==================================================================================================*/
SmsPluginStorage* SmsPluginStorage::instance()
{
if (!pInstance) {
}
-msg_error_t SmsPluginStorage::insertMsgRef(MSG_MESSAGE_INFO_S *pMsg, unsigned char msgRef, int index)
-{
- MSG_BEGIN();
-
- time_t curTime = time(NULL);
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1];
- char *normalNum = NULL;
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
- normalNum = msg_normalize_number(pMsg->addressList[index].addressVal);
-
- MSG_SEC_DEBUG("Insert MsgID=[%d], Address=[%s], MsgRef=[%d], Time=[%d]", \
- pMsg->msgId, normalNum, (int)msgRef, (int)curTime);
-
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %s, %d, 0, -1, %d);",
- MSGFW_SMS_REPORT_TABLE_NAME, pMsg->msgId, normalNum, (int)msgRef, (int)curTime);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("MsgExecQuery() : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInfo, unsigned char msgRef)
-{
- MSG_BEGIN();
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1];
-
- msg_message_id_t msgId = 0;
- int rowCnt = 0;
- char *normalNum = NULL;
-
- normalNum = msg_normalize_number(pMsgInfo->addressList[0].addressVal);
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE ADDRESS_VAL = %s AND MSG_REF > 0 ORDER BY TIME ASC;",
- MSGFW_SMS_REPORT_TABLE_NAME, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
- return MSG_ERR_DB_PREPARE;
-
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
- msgId = dbHandle->columnInt(0);
-
- dbHandle->finalizeQuery();
-
- pMsgInfo->msgId = msgId;
-
- /** Update Status - MSG_MESSAGE_TABLE */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;",
- MSGFW_SMS_REPORT_TABLE_NAME, msgId);
-
- if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) {
- dbHandle->freeTable();
- return MSG_ERR_DB_GETTABLE;
- }
-
- dbHandle->freeTable();
-
- MSG_DEBUG("Selected row count = [%d]", rowCnt);
-
- if (rowCnt == 1 && pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d WHERE MSG_ID = %d;",
- MSGFW_MESSAGE_TABLE_NAME, (int)pMsgInfo->networkStatus, msgId);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- }
-
- /** Update Status - MSG_REPORT_TABLE */
- if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_SUCCESS) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 1, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_EXPIRED) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 0, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_PENDING) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 3, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- } else if (pMsgInfo->networkStatus == MSG_NETWORK_DELIVER_FAIL) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, STATUS = %d, TIME = %d WHERE MSG_ID = %d and ADDRESS_VAL = '%s';",
- MSGFW_SMS_REPORT_TABLE_NAME, 8, (int)pMsgInfo->displayTime, msgId, normalNum);
- MSG_DEBUG("[SQL Query] %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
msg_error_t SmsPluginStorage::updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t status)
{
MSG_BEGIN();
- if (!pMsgInfo || (pMsgInfo && pMsgInfo->msgId <= 0)) {
- MSG_DEBUG("Invalid message id");
- return MSG_ERR_INVALID_MESSAGE_ID;
- }
+ MSG_ERR_RET_VM(!pMsgInfo, MSG_ERR_INVALID_MESSAGE_ID, "Invalid parameter: pMsgInfo is NULL!");
+ MSG_ERR_RET_VM(pMsgInfo->msgId <= 0, MSG_ERR_INVALID_MESSAGE_ID, "Invalid parameter: msgId: (%d)", pMsgInfo->msgId);
-/*** Comment below line to not save the time value after sent status (it could be used later.)
- time_t curTime = time(NULL);
-***/
MsgDbHandler *dbHandle = getDbHandle();
-
char sqlQuery[MAX_QUERY_LEN+1];
memset(sqlQuery, 0x00, sizeof(sqlQuery));
MSG_DEBUG("Update Msg ID : [%d], Network Status : [%d] ", pMsgInfo->msgId, status);
- /** Move Msg to SENTBOX */
+ /* Move Msg to SENTBOX */
if (status == MSG_NETWORK_SEND_SUCCESS) {
snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET NETWORK_STATUS = %d, FOLDER_ID = %d WHERE MSG_ID = %d;",
MSGFW_MESSAGE_TABLE_NAME, status, MSG_SENTBOX_ID, pMsgInfo->msgId);
}
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("MsgExecQuery() : [%s]", sqlQuery);
+ MSG_ERR("MsgExecQuery() : [%s]", sqlQuery);
return MSG_ERR_DB_EXEC;
}
}
#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
MSG_END();
-
return MSG_SUCCESS;
}
-#ifdef SMS_REPORT_OPERATION
-msg_error_t SmsPluginStorage::updateMsgRef(msg_message_id_t MsgId, unsigned char MsgRef)
-{
- MSG_BEGIN();
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1];
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = %d WHERE MSG_ID = %d;",
- MSGFW_REPORT_TABLE_NAME, (int)MsgRef, MsgId);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
-
- /** Set Message Reference for updating report table */
- tmpMsgRef = MsgRef;
-
- MSG_DEBUG("MsgRef : %d", MsgRef);
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::updateStatusReport(unsigned char MsgRef, msg_delivery_report_status_t Status, time_t DeliveryTime)
-{
- MSG_BEGIN();
-
- MSG_DEBUG("tmpMsgRef : %d", tmpMsgRef);
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1];
-
- /** Get Msg Id for Quickpanel Noti */
- msg_message_id_t msgId = 0;
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE MSG_REF = %d;",
- MSGFW_REPORT_TABLE_NAME, (int)tmpMsgRef);
-
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
- return MSG_ERR_DB_PREPARE;
-
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
- msgId = dbHandle->columnInt(0);
-
- dbHandle->finalizeQuery();
-
- /** Update Status */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET MSG_REF = -1, DELIVERY_REPORT_STATUS = %d, DELIVERY_REPORT_TIME = %lu WHERE MSG_REF = %d;",
- MSGFW_REPORT_TABLE_NAME, Status, DeliveryTime, (int)tmpMsgRef);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_DEBUG("Query Failed : [%s]", sqlQuery);
- return MSG_ERR_DB_EXEC;
- }
-
- /** Insert Quickpanel Noti */
- msg_error_t ret = MSG_SUCCESS;
-
- ret = MsgInsertSmsNotiToQuickpanel(dbHandle, msgId, Status);
-
- if (ret != MSG_SUCCESS) {
- MSG_DEBUG("MsgInsertSmsNotiToQuickpanel() Failed : [%d]", ret);
- return ret;
- }
-
- MSG_END();
-
- return MSG_SUCCESS;
-}
-#endif
-
-msg_error_t SmsPluginStorage::addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo, int *simIdList)
+msg_error_t SmsPluginStorage::addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
{
msg_error_t err = MSG_SUCCESS;
+ unsigned int rowId = 0;
+ msg_thread_id_t convId = 0;
- unsigned int simId = 0;
MsgDbHandler *dbHandle = getDbHandle();
+ dbHandle->beginTrans();
- char sqlQuery[MAX_QUERY_LEN+1];
-
- if (simIdList) {
- MSG_DEBUG("simIdList exist.");
- for (int i = 0; i < MAX_SIM_SMS_NUM; ++i) {
- if (simIdList[i]) {
- simId = simIdList[i] - 1;
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);",
- MSGFW_SIM_MSG_TABLE_NAME, simId, pSimMsgInfo->msgId);
-
- MSG_DEBUG("QUERY : %s", sqlQuery);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- return MSG_ERR_DB_EXEC;
- }
- } else {
- break;
- }
+ if (pMsgInfo->nAddressCnt > 0) {
+ err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("MsgStoAddAddress() failed: (%d)", err);
+ dbHandle->endTrans(false);
+ return err;
}
- }
-
- return err;
-}
-
-
-msg_error_t SmsPluginStorage::insertSimMessage(int simId, int msgId)
-{
- MSG_BEGIN();
-
- MsgDbHandler *dbHandle = getDbHandle();
- char sqlQuery[MAX_QUERY_LEN+1];
-
- dbHandle->beginTrans();
-
- /** Insert Message into msg_sim table */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d);", MSGFW_SIM_MSG_TABLE_NAME, simId, msgId);
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
+ pMsgInfo->threadId = convId;
}
- dbHandle->endTrans(true);
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::deleteSimMessage(int sim_idx, int simId)
-{
- MSG_BEGIN();
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1];
-
- dbHandle->beginTrans();
-
- /** Delete Message from msg_sim table */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE SIM_ID = %d AND SIM_SLOT_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, simId, sim_idx);
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ /** Add Message Table */
+ rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo);
+ if (rowId <= 0) {
+ MSG_ERR("MsgStoAddMessageTable() failed: rowId:(%d)", rowId);
dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
+ return MSG_ERR_DB_ROW;
}
- dbHandle->endTrans(true);
-
- return MSG_SUCCESS;
-}
-
-
-msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Check whether storage is full or not */
- err = checkStorageStatus(pMsgInfo);
-
+ /** Update conversation table */
+ err = MsgStoUpdateConversation(dbHandle, convId);
if (err != MSG_SUCCESS) {
- if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
- pMsgInfo->folderId = 0;
- err = MSG_SUCCESS;
- } else if (pMsgInfo->msgType.classType == MSG_CLASS_2 &&
- (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS)) {
- err = addClass2Message(pMsgInfo);
- } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
- err = MSG_SUCCESS;
- }
+ MSG_ERR("MsgStoUpdateConversation() failed: (%d)", err);
+ dbHandle->endTrans(false);
return err;
}
- /** Amend message information for type **/
- if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS) {
- MSG_DEBUG("Normal SMS");
-
- if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
- err = addClass2Message(pMsgInfo);
- } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
- /** Class 0 Msg should be saved in hidden folder */
- pMsgInfo->folderId = 0;
- }
-
- } else if ((pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS) && (pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS)) {
- MSG_DEBUG("Replace SM Type [%d]", pMsgInfo->msgType.subType-3);
-
- if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
- err = addClass2Message(pMsgInfo);
- } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
- /** Class 0 Msg should be saved in hidden folder */
- pMsgInfo->folderId = 0;
- pMsgInfo->msgType.subType = MSG_NORMAL_SMS;
- }
-
- } else if ((pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS) && (pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
- if (pMsgInfo->bStore == true) {
- MSG_DEBUG("MWI Message");
-
- if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
- err = addClass2Message(pMsgInfo);
- }
- }
- } else {
- MSG_DEBUG("No matching type [%d]", pMsgInfo->msgType.subType);
+ err = dbHandle->endTrans(true);
+ if (err != MSG_SUCCESS) {
+ MSG_ERR("endTrans() failed: (%d)", err);
+ return err;
}
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("Success to check message !!");
- } else {
- MSG_DEBUG("fail to check message !! : [%d]", err);
- }
+ pMsgInfo->msgId = (msg_message_id_t)rowId;
- return err;
+ MSG_END();
+ return MSG_SUCCESS;
}
-msg_error_t SmsPluginStorage::addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
+msg_error_t SmsPluginStorage::updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
{
- msg_error_t err = MSG_SUCCESS;
-
- unsigned int rowId = 0;
- msg_thread_id_t convId = 0;
-
+ MSG_BEGIN();
MsgDbHandler *dbHandle = getDbHandle();
+ char sqlQuery[MAX_QUERY_LEN+1] = {0, };
+ msg_thread_id_t convId = 0;
dbHandle->beginTrans();
if (pMsgInfo->nAddressCnt > 0) {
- err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId);
+ pMsgInfo->threadId = 0;
+ msg_error_t err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId);
if (err != MSG_SUCCESS) {
dbHandle->endTrans(false);
return err;
}
-
- pMsgInfo->threadId = convId;
}
- /** Add Message Table */
- rowId = MsgStoAddMessageTable(dbHandle, pMsgInfo);
+ int fileSize = 0;
- if (rowId <= 0) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_ROW;
+ char *pFileData = NULL;
+ unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
+
+ /* Get File Data */
+ if (pMsgInfo->bTextSms == false) {
+ if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) {
+ dbHandle->endTrans(false);
+ return MSG_ERR_STORAGE_ERROR;
+ }
}
- /** Update conversation table */
- err = MsgStoUpdateConversation(dbHandle, convId);
+ snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET CONV_ID = %d, FOLDER_ID = %d, STORAGE_ID = %d, MAIN_TYPE = %d, SUB_TYPE = %d, \
+ DISPLAY_TIME = %lu, DATA_SIZE = %zu, NETWORK_STATUS = %d, READ_STATUS = %d, PROTECTED = %d, PRIORITY = %d, MSG_DIRECTION = %d, \
+ BACKUP = %d, SUBJECT = ?, MSG_TEXT = ?, SIM_INDEX = %d \
+ WHERE MSG_ID = %d;",
+ MSGFW_MESSAGE_TABLE_NAME, convId, pMsgInfo->folderId, pMsgInfo->storageId, pMsgInfo->msgType.mainType, pMsgInfo->msgType.subType, pMsgInfo->displayTime, pMsgInfo->dataSize,
+ pMsgInfo->networkStatus, pMsgInfo->bRead, pMsgInfo->bProtected, pMsgInfo->priority, pMsgInfo->direction, pMsgInfo->bBackup, pMsgInfo->sim_idx, pMsgInfo->msgId);
- if (err != MSG_SUCCESS) {
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
dbHandle->endTrans(false);
- return err;
+ return MSG_ERR_DB_EXEC;
}
- err = dbHandle->endTrans(true);
- if (err != MSG_SUCCESS) {
- return err;
+ dbHandle->bindText(pMsgInfo->subject, 1);
+
+ if (pMsgInfo->bTextSms == false)
+ dbHandle->bindText(pFileData, 2);
+ else
+ dbHandle->bindText(pMsgInfo->msgText, 2);
+
+ MSG_DEBUG("%s", sqlQuery);
+
+ if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
+ dbHandle->finalizeQuery();
+ dbHandle->endTrans(false);
+ return MSG_ERR_DB_EXEC;
}
- pMsgInfo->msgId = (msg_message_id_t)rowId;
+ dbHandle->finalizeQuery();
+ dbHandle->endTrans(true);
MSG_END();
-
return MSG_SUCCESS;
}
MSG_BEGIN();
MsgDbHandler *dbHandle = getDbHandle();
-
char sqlQuery[MAX_QUERY_LEN+1];
- /** Get SUB_TYPE, STORAGE_ID */
+ /* Get SUB_TYPE, STORAGE_ID */
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MAIN_TYPE, SUB_TYPE, FOLDER_ID, CONV_ID, SIM_INDEX \
FROM %s WHERE MSG_ID = %d;",
MSGFW_MESSAGE_TABLE_NAME, msgId);
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
return MSG_ERR_DB_PREPARE;
+ }
MSG_MESSAGE_TYPE_S msgType;
msg_folder_id_t folderId;
MSG_DEBUG("Main Type:[%d] SubType:[%d] FolderId:[%d] ConversationId:[%d]", msgType.mainType, msgType.subType, folderId, convId);
} else {
- MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
+ MSG_ERR("MsgStepQuery() Failed [%s]", sqlQuery);
dbHandle->finalizeQuery();
return MSG_ERR_DB_STEP;
}
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_SENDOPT_TABLE_NAME, msgId);
- /** Delete SMS Send Option */
+ /* Delete SMS Send Option */
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
dbHandle->endTrans(false);
return MSG_ERR_DB_EXEC;
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_CB_MSG_TABLE_NAME, msgId);
- /** Delete Push Message from push table */
+ /* Delete Push Message from push table */
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
dbHandle->endTrans(false);
return MSG_ERR_DB_EXEC;
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_PUSH_MSG_TABLE_NAME, msgId);
- /** Delete Push Message from push table */
+ /* Delete Push Message from push table */
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
dbHandle->endTrans(false);
return MSG_ERR_DB_EXEC;
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SYNCML_MSG_TABLE_NAME, msgId);
- /** Delete SyncML Message from syncML table */
+ /* Delete SyncML Message from syncML table */
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
dbHandle->endTrans(false);
return MSG_ERR_DB_EXEC;
}
}
- /** Delete Message from msg table */
+ /* Delete Message from msg table */
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId);
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
return MSG_ERR_DB_EXEC;
}
- /** Delete Message from msg_report table */
+ /* Delete Message from msg_report table */
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SMS_REPORT_TABLE_NAME, msgId);
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
return MSG_ERR_DB_EXEC;
}
- /** Delete Message from msg_sim table */
+ /* Delete Message from msg_sim table */
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s WHERE MSG_ID = %d;", MSGFW_SIM_MSG_TABLE_NAME, msgId);
if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
return MSG_ERR_DB_EXEC;
}
- /** Clear Conversation table */
+ /* Clear Conversation table */
if (MsgStoClearConversationTable(dbHandle) != MSG_SUCCESS) {
dbHandle->endTrans(false);
return MSG_ERR_DB_EXEC;
}
- /** Update conversation table.*/
+ /* Update conversation table.*/
if (MsgStoUpdateConversation(dbHandle, convId) != MSG_SUCCESS) {
dbHandle->endTrans(false);
return MSG_ERR_STORAGE_ERROR;
memset(sqlQuery, 0x00, sizeof(sqlQuery));
snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONV_ID FROM %s WHERE CONV_ID = %d;", MSGFW_CONVERSATION_TABLE_NAME, convId);
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS)
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
return MSG_ERR_DB_PREPARE;
+ }
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW)
- SmsPluginEventHandler::instance()->callbackThreadChange(MSG_STORAGE_CHANGE_UPDATE, convId);
- else
- SmsPluginEventHandler::instance()->callbackThreadChange(MSG_STORAGE_CHANGE_DELETE, convId);
+ if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+ Sms3gppEventHandler::instance()->callbackThreadChange(MSG_STORAGE_CHANGE_UPDATE, convId);
+ } else {
+ Sms3gppEventHandler::instance()->callbackThreadChange(MSG_STORAGE_CHANGE_DELETE, convId);
+ }
dbHandle->finalizeQuery();
if (folder_id == MSG_INBOX_ID) {
msgType.classType = MSG_CLASS_NONE;
- /** Set memory status in SIM */
+ /* Set memory status in SIM */
if (MsgStoCheckMsgCntFull(dbHandle, &msgType, folderId) == MSG_SUCCESS) {
MSG_DEBUG("Set Memory Status");
SmsPlgSetMemoryStatus(simIndex, MSG_SUCCESS);
}
-msg_error_t SmsPluginStorage::addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo)
+msg_error_t SmsPluginStorage::addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo)
{
- MSG_BEGIN();
-
msg_error_t err = MSG_SUCCESS;
- bool bSimSst = true;
-
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SERVICE_TABLE, pMsgInfo->sim_idx);
-
- if (MsgSettingGetBool(keyName, &bSimSst) != MSG_SUCCESS) {
- MSG_ERR("MsgSettingGetBool [%s] failed", keyName);
- }
-
- if (bSimSst == false) {
- return MSG_ERR_SIM_STORAGE_FULL;
- }
- pthread_t thd;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
- memset(&addrInfo, 0, sizeof(MSG_ADDRESS_INFO_S));
- memcpy(&msgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S));
- memcpy(&addrInfo, pMsgInfo->addressList, sizeof(MSG_ADDRESS_INFO_S));
- msgInfo.addressList = &addrInfo;
-
- if (pthread_create(&thd, NULL, &class2_thread, (void *)&msgInfo) < 0)
- MSG_DEBUG("pthread_create() error");
- else
- pthread_detach(thd);
-
-#if 0
- err = SmsPluginSimMsg::instance()->saveClass2Message(pMsgInfo);
-
-
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("Success to saveClass2Message.");
- } else {
- MSG_DEBUG("Fail to saveClass2Message : [%d]", err);
- }
-#endif
-
- MSG_END();
-
- return err;
-}
-void* SmsPluginStorage::class2_thread(void *data)
-{
- MSG_BEGIN();
+ if (pSendOptInfo->bSetting == false) {
+ if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetBool() is failed");
+ }
- msg_error_t err = MSG_SUCCESS;
- MSG_MESSAGE_INFO_S *pMsgInfo = (MSG_MESSAGE_INFO_S *)data;
+ if (MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSendOptInfo->option.smsSendOptInfo.bReplyPath) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetBool() is failed");
+ }
- err = SmsPluginSimMsg::instance()->saveClass2Message(pMsgInfo);
- if (err == MSG_SUCCESS) {
- MSG_DEBUG("Success to saveClass2Message.");
- } else {
- MSG_ERR("Fail to saveClass2Message : [%d]", err);
+ if (MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy) != MSG_SUCCESS) {
+ MSG_INFO("MsgSettingGetBool() is failed");
+ }
}
- MSG_END();
- return NULL;
-}
-
-
-msg_error_t SmsPluginStorage::getReplaceSimMsg(const MSG_MESSAGE_INFO_S *pMsg, int *pMsgId, int *pSimId)
-{
- MSG_BEGIN();
-
MsgDbHandler *dbHandle = getDbHandle();
-
char sqlQuery[MAX_QUERY_LEN+1];
- msg_thread_id_t convId = 0;
- msg_message_id_t msgId = 0;
dbHandle->beginTrans();
- if (MsgExistAddress(dbHandle, pMsg, &convId) == true) {
- MSG_DEBUG("Address Info. exists [%d]", convId);
-
- /** Find Replace Type Msg : Same Replace Type, Same Origin Address, Same Storage ID */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s \
- WHERE CONV_ID = %d AND SUB_TYPE = %d AND STORAGE_ID = %d \
- ORDER BY DISPLAY_TIME ASC;",
- MSGFW_MESSAGE_TABLE_NAME, (int)convId, pMsg->msgType.subType, MSG_STORAGE_SIM);
-
- MSG_DEBUG("Query=[%s]", sqlQuery);
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_PREPARE;
- }
-
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
- *pMsgId = dbHandle->columnInt(0);
- } else {
- dbHandle->finalizeQuery();
- dbHandle->endTrans(false);
- return MSG_ERR_DB_STEP;
- }
-
- dbHandle->finalizeQuery();
-
- } else {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_NORECORD;
- }
-
memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
+ MSGFW_SMS_SENDOPT_TABLE_NAME, pMsg->msgId, pSendOptInfo->bDeliverReq,
+ pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->encodeType);
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_ID FROM %s \
- WHERE MSG_ID = %d;",
- MSGFW_SIM_MSG_TABLE_NAME, *pMsgId);
-
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_PREPARE;
- }
+ MSG_DEBUG("Query = [%s]", sqlQuery);
- if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
- *pSimId = dbHandle->columnInt(0);
- } else {
- dbHandle->finalizeQuery();
+ if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ MSG_ERR("execQuery() is failed");
dbHandle->endTrans(false);
- return MSG_ERR_DB_STEP;
+ return MSG_ERR_DB_EXEC;
}
- MSG_DEBUG("Replace Msg Id=[%d], Sim Id=[%d]", *pMsgId, *pSimId);
-
- dbHandle->finalizeQuery();
-
dbHandle->endTrans(true);
MSG_END();
- return msgId;
+ return err;
}
-msg_error_t SmsPluginStorage::addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo)
+
+msg_error_t SmsPluginStorage::checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
{
MSG_BEGIN();
msg_error_t err = MSG_SUCCESS;
- if (pSendOptInfo->bSetting == false) {
- if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSendOptInfo->bDeliverReq) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
+ /* Check whether storage is full or not */
+ err = checkStorageStatus(pMsgInfo);
- if (MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSendOptInfo->option.smsSendOptInfo.bReplyPath) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
+ if (err != MSG_SUCCESS) {
+ if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
+ pMsgInfo->folderId = 0;
+ err = MSG_SUCCESS;
+ } else if (pMsgInfo->msgType.classType == MSG_CLASS_2 &&
+ (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS)) {
+ err = Sms3gppStorage::instance()->addClass2Message(pMsgInfo);
+ } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
+ err = MSG_SUCCESS;
+ }
- if (MsgSettingGetBool(MSG_KEEP_COPY, &pSendOptInfo->bKeepCopy) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
+ return err;
}
- MsgDbHandler *dbHandle = getDbHandle();
+ /** Amend message information for type **/
+ if (pMsgInfo->msgType.subType == MSG_NORMAL_SMS || pMsgInfo->msgType.subType == MSG_REJECT_SMS) {
+ MSG_DEBUG("Normal SMS");
- char sqlQuery[MAX_QUERY_LEN+1];
+ if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
+ err = Sms3gppStorage::instance()->addClass2Message(pMsgInfo);
+ } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
+ /* Class 0 Msg should be saved in hidden folder */
+ pMsgInfo->folderId = 0;
+ }
- dbHandle->beginTrans();
+ } else if ((pMsgInfo->msgType.subType >= MSG_REPLACE_TYPE1_SMS) && (pMsgInfo->msgType.subType <= MSG_REPLACE_TYPE7_SMS)) {
+ MSG_DEBUG("Replace SM Type [%d]", pMsgInfo->msgType.subType-3);
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
- MSGFW_SMS_SENDOPT_TABLE_NAME, pMsg->msgId, pSendOptInfo->bDeliverReq,
- pSendOptInfo->bKeepCopy, pSendOptInfo->option.smsSendOptInfo.bReplyPath, pMsg->encodeType);
+ if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
+ err = Sms3gppStorage::instance()->addClass2Message(pMsgInfo);
+ } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) {
+ /* Class 0 Msg should be saved in hidden folder */
+ pMsgInfo->folderId = 0;
+ pMsgInfo->msgType.subType = MSG_NORMAL_SMS;
+ }
- MSG_DEBUG("Query = [%s]", sqlQuery);
+ } else if ((pMsgInfo->msgType.subType >= MSG_MWI_VOICE_SMS) && (pMsgInfo->msgType.subType <= MSG_MWI_OTHER_SMS)) {
+ if (pMsgInfo->bStore == true) {
+ MSG_DEBUG("MWI Message");
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- MSG_ERR("execQuery() is failed");
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
+ if (pMsgInfo->msgType.classType == MSG_CLASS_2) {
+ err = Sms3gppStorage::instance()->addClass2Message(pMsgInfo);
+ }
+ }
+ } else {
+ MSG_INFO("No matching type [%d]", pMsgInfo->msgType.subType);
}
- dbHandle->endTrans(true);
+ if (err == MSG_SUCCESS) {
+ MSG_DEBUG("Success to check message !!");
+ } else {
+ MSG_ERR("fail to check message !! : [%d]", err);
+ }
MSG_END();
-
return err;
}
}
-#if 0
-
-msg_error_t SmsPluginStorage::isReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage)
-{
- msg_error_t err = MSG_SUCCESS;
-
- int rowCnt = 0;
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1] = {0, };
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
-
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE GEO_SCOPE = %d AND MSG_CODE = %d AND MESSAGE_ID = %d AND UPDATE_NUM = %d",
- MSGFW_RECEIVED_CB_MSG_TABLE_NAME, CbPage.pageHeader.serialNum.geoScope,
- CbPage.pageHeader.serialNum.msgCode, CbPage.pageHeader.msgId, CbPage.pageHeader.serialNum.updateNum);
-
- err = dbHandle->getTable(sqlQuery, &rowCnt, NULL);
- MSG_DEBUG("rowCnt: %d", rowCnt);
-
- dbHandle->freeTable();
- return err;
-}
-
-msg_error_t SmsPluginStorage::insertReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage)
-{
- msg_error_t err = MSG_SUCCESS;
-
- unsigned int rowId = 0;
-
- MsgDbHandler *dbHandle = getDbHandle();
-
- char sqlQuery[MAX_QUERY_LEN+1];
-
- err = dbHandle->getRowId(MSGFW_RECEIVED_CB_MSG_TABLE_NAME, &rowId);
-
- if (err != MSG_SUCCESS)
- return err;
-
- /* Add Folder */
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, %d);",
- MSGFW_RECEIVED_CB_MSG_TABLE_NAME, rowId, CbPage.pageHeader.serialNum.geoScope,
- CbPage.pageHeader.serialNum.msgCode, CbPage.pageHeader.msgId, CbPage.pageHeader.serialNum.updateNum);
-
- if (dbHandle->execQuery(sqlQuery) != MSG_SUCCESS)
- return MSG_ERR_DB_EXEC;
-
- return MSG_SUCCESS;
-}
-
-#endif
-
msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *count, char *application_id, int app_id_len, char *content_type, int content_type_len)
{
msg_error_t err = MSG_SUCCESS;
char *_content_type = NULL, *_app_id = NULL;
*count = 0;
-
for (int i = 0; i < rowCnt; i++) {
memset(contentType, 0, MAX_WAPPUSH_CONTENT_TYPE_LEN);
memset(appId, 0, MAX_WAPPUSH_ID_LEN);
}
-msg_error_t SmsPluginStorage::updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo)
-{
- MSG_BEGIN();
- MsgDbHandler *dbHandle = getDbHandle();
- char sqlQuery[MAX_QUERY_LEN+1] = {0, };
- msg_thread_id_t convId = 0;
-
- dbHandle->beginTrans();
-
- if (pMsgInfo->nAddressCnt > 0) {
- pMsgInfo->threadId = 0;
- msg_error_t err = MsgStoAddAddress(dbHandle, pMsgInfo, &convId);
-
- if (err != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return err;
- }
- }
-
- int fileSize = 0;
-
- char *pFileData = NULL;
- unique_ptr<char*, void(*)(char**)> buf(&pFileData, unique_ptr_deleter);
-
- /* Get File Data */
- if (pMsgInfo->bTextSms == false) {
- if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) {
- dbHandle->endTrans(false);
- return MSG_ERR_STORAGE_ERROR;
- }
- }
-
- snprintf(sqlQuery, sizeof(sqlQuery), "UPDATE %s SET CONV_ID = %d, FOLDER_ID = %d, STORAGE_ID = %d, MAIN_TYPE = %d, SUB_TYPE = %d, \
- DISPLAY_TIME = %lu, DATA_SIZE = %zu, NETWORK_STATUS = %d, READ_STATUS = %d, PROTECTED = %d, PRIORITY = %d, MSG_DIRECTION = %d, \
- BACKUP = %d, SUBJECT = ?, MSG_TEXT = ?, SIM_INDEX = %d \
- WHERE MSG_ID = %d;",
- MSGFW_MESSAGE_TABLE_NAME, convId, pMsgInfo->folderId, pMsgInfo->storageId, pMsgInfo->msgType.mainType, pMsgInfo->msgType.subType, pMsgInfo->displayTime, pMsgInfo->dataSize,
- pMsgInfo->networkStatus, pMsgInfo->bRead, pMsgInfo->bProtected, pMsgInfo->priority, pMsgInfo->direction, pMsgInfo->bBackup, pMsgInfo->sim_idx, pMsgInfo->msgId);
-
- if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- dbHandle->bindText(pMsgInfo->subject, 1);
-
- if (pMsgInfo->bTextSms == false)
- dbHandle->bindText(pFileData, 2);
- else
- dbHandle->bindText(pMsgInfo->msgText, 2);
-
- MSG_DEBUG("%s", sqlQuery);
-
- if (dbHandle->stepQuery() != MSG_ERR_DB_DONE) {
- dbHandle->finalizeQuery();
- dbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- dbHandle->finalizeQuery();
- dbHandle->endTrans(true);
-
- MSG_END();
- return MSG_SUCCESS;
-}
-
-
bool SmsPluginStorage::isDuplicatedCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo)
{
msg_error_t err = MSG_SUCCESS;
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <stdio.h>
-#include <string.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-
-#include "SmsPluginTpduCodec.h"
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginUDCodec.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginTpduCodec - Member Functions
-==================================================================================================*/
-SmsPluginTpduCodec::SmsPluginTpduCodec()
-{
-}
-
-
-SmsPluginTpduCodec::~SmsPluginTpduCodec()
-{
-}
-
-
-int SmsPluginTpduCodec::encodeTpdu(const SMS_TPDU_S *pSmsTpdu, char *pTpdu)
-{
- int tpduLen = 0;
-
- switch (pSmsTpdu->tpduType) {
- case SMS_TPDU_SUBMIT:
- tpduLen = encodeSubmit(&(pSmsTpdu->data.submit), pTpdu);
- break;
-
- case SMS_TPDU_DELIVER:
- tpduLen = encodeDeliver(&(pSmsTpdu->data.deliver), pTpdu);
- break;
-
- case SMS_TPDU_DELIVER_REP:
- tpduLen = encodeDeliverReport(&(pSmsTpdu->data.deliverRep), pTpdu);
- break;
-
- case SMS_TPDU_STATUS_REP:
- tpduLen = encodeStatusReport(&(pSmsTpdu->data.statusRep), pTpdu);
- break;
- }
-
- return tpduLen;
-}
-
-
-int SmsPluginTpduCodec::decodeTpdu(const unsigned char *pTpdu, int TpduLen, SMS_TPDU_S *pSmsTpdu)
-{
- int decodeLen = 0;
-
- char mti = pTpdu[0] & 0x03;
-
- switch (mti) {
- case 0x00:
- pSmsTpdu->tpduType = SMS_TPDU_DELIVER;
- decodeLen = decodeDeliver(pTpdu, TpduLen, &(pSmsTpdu->data.deliver));
- break;
-
- case 0x01:
- pSmsTpdu->tpduType = SMS_TPDU_SUBMIT;
- decodeLen = decodeSubmit(pTpdu, TpduLen, &(pSmsTpdu->data.submit));
- break;
-
- case 0x02:
- pSmsTpdu->tpduType = SMS_TPDU_STATUS_REP;
- decodeLen = decodeStatusReport(pTpdu, TpduLen, &(pSmsTpdu->data.statusRep));
- break;
- }
-
- return decodeLen;
-}
-
-
-int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu)
-{
- int offset = 0, length = 0, encodeSize = 0;
-
- char* address = NULL;
- unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
-
- char* dcs = NULL;
- unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
-
- char* vpTime = NULL;
- unique_ptr<char*, void(*)(char**)> vpBuf(&vpTime, unique_ptr_deleter);
-
- /* TP-MTI */
- pTpdu[offset] = 0x01;
-
- /* TP-RD */
- if (pSubmit->bRejectDup == true)
- pTpdu[offset] |= 0x04;
-
- /* TP-VPF */
- switch (pSubmit->vpf) {
- case SMS_VPF_NOT_PRESENT:
- break;
- case SMS_VPF_ENHANCED:
- pTpdu[offset] |= 0x08;
- break;
- case SMS_VPF_RELATIVE:
- pTpdu[offset] |= 0x10;
- break;
- case SMS_VPF_ABSOLUTE:
- pTpdu[offset] |= 0x18;
- break;
- default:
- break;
- }
-
- /* TP-SRR */
- if (pSubmit->bStatusReport == true)
- pTpdu[offset] |= 0x20;
-
- MSG_DEBUG("TP-SRR pSubmit->bStatusReport : %d.", pSubmit->bStatusReport);
-
- /* TP-UDHI */
- if (pSubmit->bHeaderInd == true)
- pTpdu[offset] |= 0x40;
-
- /* TP-RP */
- if (pSubmit->bReplyPath == true)
- pTpdu[offset] |= 0x80;
-
- offset++;
-
- /* TP-MR */
- pTpdu[offset++] = pSubmit->msgRef;
-
- MSG_DEBUG("TP-MR pSubmit->msgRef : %d.", pSubmit->msgRef);
-
- /* TP-DA */
- length = SmsPluginParamCodec::encodeAddress(&pSubmit->destAddress, &address);
- memcpy(&(pTpdu[offset]), address, length);
- offset += length;
-
- MSG_DEBUG("TP-DA length : %d.", length);
-
- /* TP-PID */
- pTpdu[offset++] = pSubmit->pid;
-
- MSG_DEBUG("TP-PID pSubmit->pid : %d.", pSubmit->pid);
-
- /* TP-DCS */
- length = SmsPluginParamCodec::encodeDCS(&pSubmit->dcs, &dcs);
- memcpy(&(pTpdu[offset]), dcs, length);
- offset += length;
-
- MSG_DEBUG("TP-DCS length : %d.", length);
-
- /* TP-VP */
- if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
- length = SmsPluginParamCodec::encodeTime(&pSubmit->validityPeriod, &vpTime);
-
- if (length > 0) {
- memcpy(&(pTpdu[offset]), vpTime, length);
- offset += length;
- }
- }
-
- encodeSize = SmsPluginUDCodec::encodeUserData(&(pSubmit->userData), pSubmit->dcs.codingScheme, &(pTpdu[offset]));
-
- MSG_DEBUG("encodeSize : %d", encodeSize);
-
- offset += encodeSize;
-
-#if 0
- printf("\n\n[encodeSubmit] pTpdu data.\n");
- for (int i = 0; i < offset; i++) {
- printf(" [%02x]", pTpdu[i]);
- }
- printf("\n\n");
-#endif
-
- return offset;
-}
-
-
-int SmsPluginTpduCodec::encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu)
-{
- int offset = 0, length = 0, encodeSize = 0;
-
- char* address = NULL;
- unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
-
- char* dcs = NULL;
- unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
-
- char* scts = NULL;
- unique_ptr<char*, void(*)(char**)> timeBuf(&scts, unique_ptr_deleter);
-
- /* TP-MTI : 00 */
- pTpdu[offset] = 0x00;
-
- /* TP-MMS */
- if (pDeliver->bMoreMsg == false)
- pTpdu[offset] |= 0x04;
-
- /* TP-SRI */
- if (pDeliver->bStatusReport == true)
- pTpdu[offset] |= 0x20;
-
- /* TP-UDHI */
- if (pDeliver->bHeaderInd == true)
- pTpdu[offset] |= 0x40;
-
- /* TP-RP */
- if (pDeliver->bReplyPath == true)
- pTpdu[offset] |= 0x80;
-
- offset++;
-
- /* TP-OA */
- length = SmsPluginParamCodec::encodeAddress(&pDeliver->originAddress, &address);
- memcpy(&(pTpdu[offset]), address, length);
- offset += length;
-
- /* TP-PID */
- pTpdu[offset++] = pDeliver->pid;
-
- /* TP-DCS */
- length = SmsPluginParamCodec::encodeDCS(&pDeliver->dcs, &dcs);
- memcpy(&(pTpdu[offset]), dcs, length);
- offset += length;
-
- /* TP-SCTS */
- length = SmsPluginParamCodec::encodeTime(&pDeliver->timeStamp, &scts);
- memcpy(&(pTpdu[offset]), scts, length);
- offset += length;
-
- /* TP-UDL & TP-UD */
- encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliver->userData), pDeliver->dcs.codingScheme, &(pTpdu[offset]));
-
- MSG_DEBUG("encodeSize : %d", encodeSize);
-
- offset += encodeSize;
-
- return offset;
-}
-
-
-int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliverRep, char *pTpdu)
-{
- int offset = 0;
-
- /* TP-MTI : 00 */
- pTpdu[offset] = 0x00;
-
- /* TP-UDHI */
- if (pDeliverRep->bHeaderInd == true)
- pTpdu[offset] |= 0x40;
-
- offset++;
-
- /* TP-FCS */
- if (pDeliverRep->reportType == SMS_REPORT_NEGATIVE) {
- pTpdu[offset++] = pDeliverRep->failCause;
- MSG_DEBUG("Delivery report : fail cause = [%02x]", pDeliverRep->failCause);
- }
-
- /* TP-PI */
- pTpdu[offset++] = pDeliverRep->paramInd;
-
- /* TP-PID */
- if (pDeliverRep->paramInd & 0x01)
- pTpdu[offset++] = pDeliverRep->pid;
-
- /* TP-DCS */
- if (pDeliverRep->paramInd & 0x02) {
- int length = 0;
-
- char* dcs = NULL;
- unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
-
- length = SmsPluginParamCodec::encodeDCS(&pDeliverRep->dcs, &dcs);
- memcpy(&(pTpdu[offset]), dcs, length);
-
- offset += length;
- }
-
- /* TP-UDL & TP-UD */
- if (pDeliverRep->paramInd & 0x04) {
- int encodeSize = 0;
-
- encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliverRep->userData), pDeliverRep->dcs.codingScheme, &(pTpdu[offset]));
-
- MSG_DEBUG("encodeSize : %d", encodeSize);
-
- offset += encodeSize;
- }
-
- pTpdu[offset] = '\0';
-
- return offset;
-}
-
-
-int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep, char *pTpdu)
-{
- int offset = 0, length = 0;
-
- char* address = NULL;
- unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
-
- char* scts = NULL;
- unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter);
-
- char* dt = NULL;
- unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
-
- /* TP-MTI : 10 */
- pTpdu[offset] = 0x02;
-
- /* TP-MMS */
- if (pStatusRep->bMoreMsg == true)
- pTpdu[offset] |= 0x04;
-
- /* TP-SRQ */
- if (pStatusRep->bStatusReport == true)
- pTpdu[offset] |= 0x20;
-
- /* TP-UDHI */
- if (pStatusRep->bHeaderInd == true)
- pTpdu[offset] |= 0x40;
-
- offset++;
-
- /* TP-MR */
- pTpdu[offset++] = pStatusRep->msgRef;
-
- /* TP-RA */
- length = SmsPluginParamCodec::encodeAddress(&pStatusRep->recipAddress, &address);
- memcpy(&(pTpdu[offset]), address, length);
- offset += length;
-
- /* TP-SCTS */
- length = SmsPluginParamCodec::encodeTime(&pStatusRep->timeStamp, &scts);
- memcpy(&(pTpdu[offset]), scts, length);
- offset += length;
-
- /* TP-DT */
- length = SmsPluginParamCodec::encodeTime(&pStatusRep->dischargeTime, &dt);
- memcpy(&(pTpdu[offset]), dt, length);
- offset += length;
-
- /* TP-Status */
- pTpdu[offset++] = pStatusRep->status;
-
- /* TP-PI */
- pTpdu[offset++] = pStatusRep->paramInd;
-
- /* TP-PID */
- if (pStatusRep->paramInd & 0x01)
- pTpdu[offset++] = pStatusRep->pid;
-
- /* TP-DCS */
- if (pStatusRep->paramInd & 0x02) {
- int length = 0;
-
- char* dcs = NULL;
- unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
-
- length = SmsPluginParamCodec::encodeDCS(&pStatusRep->dcs, &dcs);
- memcpy(&(pTpdu[offset]), dcs, length);
-
- offset += length;
- }
-
- /* TP-UDL & TP-UD */
- if (pStatusRep->paramInd & 0x04) {
- int encodeSize = 0;
-
- encodeSize = SmsPluginUDCodec::encodeUserData(&(pStatusRep->userData), pStatusRep->dcs.codingScheme, &(pTpdu[offset]));
-
- MSG_DEBUG("encodeSize : %d", encodeSize);
-
- offset += encodeSize;
- }
-
- pTpdu[offset] = '\0';
-
- return offset;
-}
-
-
-int SmsPluginTpduCodec::decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_SUBMIT_S *pSubmit)
-{
- int offset = 0, udLen = 0;
-
- char tpduTmp[(TpduLen*2)+1];
- memset(tpduTmp, 0x00, sizeof(tpduTmp));
- for (int i = 0; i < TpduLen; i++) {
- snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
- }
- MSG_DEBUG("Sumbit TPDU.");
- MSG_INFO("[%s]", tpduTmp);
-
- /* TP-RD */
- if (pTpdu[offset] & 0x04)
- pSubmit->bRejectDup = false;
- else
- pSubmit->bRejectDup = true;
-
- /* TP-VPF */
- pSubmit->vpf = (SMS_VPF_T)(pTpdu[offset] & 0x18);
-
- /* TP-SRR */
- if (pTpdu[offset] & 0x20)
- pSubmit->bStatusReport = true;
- else
- pSubmit->bStatusReport = false;
-
- /* TP-UDHI */
- if (pTpdu[offset] & 0x40)
- pSubmit->bHeaderInd = true;
- else
- pSubmit->bHeaderInd = false;
-
- /* TP-RP */
- if (pTpdu[offset] & 0x80)
- pSubmit->bReplyPath = true;
- else
- pSubmit->bReplyPath = false;
-
- offset++;
-
- /* TP-MR */
- pSubmit->msgRef = pTpdu[offset++];
-
- /* TP-DA */
- offset += SmsPluginParamCodec::decodeAddress(pTpdu+offset, &(pSubmit->destAddress));
-
- /* TP-PID */
- pSubmit->pid = pTpdu[offset++];
-
- /* TP-DCS */
- offset += SmsPluginParamCodec::decodeDCS(pTpdu+offset, &(pSubmit->dcs));
-
- /* TP-VP */
- if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
- /* Decode VP */
- }
-
- /* TP-UDL & TP-UD */
- udLen = SmsPluginUDCodec::decodeUserData(pTpdu+offset, TpduLen, pSubmit->bHeaderInd, pSubmit->dcs.codingScheme, &(pSubmit->userData));
-
- return udLen;
-}
-
-
-int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, SMS_DELIVER_S *pDeliver)
-{
- int offset = 0, udLen = 0, tmpOffset = 0;
-
-
- char tpduTmp[(TpduLen*2)+1];
- memset(tpduTmp, 0x00, sizeof(tpduTmp));
- for (int i = 0; i < TpduLen; i++) {
- snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
- }
- MSG_DEBUG("Deliver TPDU.");
- MSG_INFO("[%s]", tpduTmp);
-
-
- /* TP-MMS */
- if (pTpdu[offset] & 0x04)
- pDeliver->bMoreMsg = false;
- else
- pDeliver->bMoreMsg = true;
-
- /* TP-SRI */
- if (pTpdu[offset] & 0x20)
- pDeliver->bStatusReport = true;
- else
- pDeliver->bStatusReport = false;
-
- /* TP-UDHI */
- if (pTpdu[offset] & 0x40)
- pDeliver->bHeaderInd = true;
- else
- pDeliver->bHeaderInd = false;
-
- /* TP-RP */
- if (pTpdu[offset] & 0x80)
- pDeliver->bReplyPath = true;
- else
- pDeliver->bReplyPath = false;
-
- offset++;
-
- tmpOffset = offset;
-#if 1
- /* TP-OA */
- offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
-
- /* TP-PID */
- pDeliver->pid = pTpdu[offset++];
-
- /* TP-DCS */
- offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pDeliver->dcs));
-
- /* Support KSC5601 :: Coding group bits == 0x84 */
- if (pTpdu[offset-1] == 0x84) {
- pDeliver->dcs.codingScheme = SMS_CHARSET_EUCKR;
- }
-
-#else
- /* For alphanumeric address test */
-
- offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
-
- char* address = new char[15];
- address[0] = 0x04;
- address[1] = 0xd0;
- address[2] = 0x11;
- address[3] = 0x00;
- address[4] = 0x20;
- address[5] = 0xF2;
- address[6] = 0x01;
- address[7] = 0x01;
- address[8] = 0x11;
- address[9] = 0x61;
- address[10] = 0x40;
- address[11] = 0x82;
- address[12] = 0x2b;
- address[13] = 0x01;
- address[14] = 0x20;
-
- SmsPluginParamCodec::decodeAddress((unsigned char*)address, &(pDeliver->originAddress));
-
- pDeliver->pid = 0x20;
- offset++;
- offset += SmsPluginParamCodec::decodeDCS((unsigned char*)address, &(pDeliver->dcs));
- /* end test */
-#endif
-
- if (pDeliver->pid == 0x20 && pDeliver->originAddress.ton == SMS_TON_ALPHANUMERIC) {
- int setType = -1;
- int indType = -1;
-
- bool bVmi = SmsPluginParamCodec::checkCphsVmiMsg(&pTpdu[tmpOffset], &setType, &indType);
-
- MSG_DEBUG("bVmi = [%d], setType=[%d], indType=[%d]", bVmi, setType, indType);
-
- if (bVmi) {
- pDeliver->dcs.bMWI = true;
-
- if (setType == 0) {
- pDeliver->dcs.bIndActive = false;
- } else {
- pDeliver->dcs.bIndActive = true;
- }
-
- if (indType == 0)
- pDeliver->dcs.indType = SMS_VOICE_INDICATOR;
- else if (indType == 1)
- pDeliver->dcs.indType = SMS_VOICE2_INDICATOR;
- }
- }
-
- /* TP-SCTS */
- offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pDeliver->timeStamp));
-
- /* TP-UD */
- udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pDeliver->bHeaderInd, pDeliver->dcs.codingScheme, &(pDeliver->userData), &(pDeliver->udData));
-
- return udLen;
-}
-
-
-int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep)
-{
-#ifdef LOG_ENABLE
- printf("\n\n[decodeStatusReport] pTpdu data - Length [%d]\n", TpduLen);
-
- for (int i = 0; i < TpduLen; i++) {
- printf(" [%02x]", pTpdu[i]);
- }
- printf("\n\n");
-#endif
-
- int offset = 0, udLen = 0;
-
- char* address = NULL;
- unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
-
- char* scts = NULL;
- unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter);
-
- char* dt = NULL;
- unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
-
- /* TP-MMS */
- if (pTpdu[offset] & 0x04)
- pStatusRep->bMoreMsg = false;
- else
- pStatusRep->bMoreMsg = true;
-
- /* TP-SRQ */
- if (pTpdu[offset] & 0x20)
- pStatusRep->bStatusReport = true;
- else
- pStatusRep->bStatusReport = false;
-
- /* TP-UDHI */
- if (pTpdu[offset] & 0x40)
- pStatusRep->bHeaderInd = true;
- else
- pStatusRep->bHeaderInd = false;
-
- offset++;
-
- /* TP-MR */
- pStatusRep->msgRef = pTpdu[offset++];
-
- /* TP-RA */
- offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pStatusRep->recipAddress));
-
- /* TP-SCTS */
- /* Decode timestamp */
- offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->timeStamp));
-
- /* TP-DT */
- /* Decode timestamp */
- offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->dischargeTime));
-
- /* TP-Status */
- pStatusRep->status = pTpdu[offset++];
-
- /* TP-PI */
- pStatusRep->paramInd = pTpdu[offset++];
-
- /* No Parameters */
- if (pStatusRep->paramInd == 0) {
- pStatusRep->pid = SMS_PID_NORMAL;
-
- pStatusRep->dcs.bCompressed = false;
- pStatusRep->dcs.bMWI = false;
- pStatusRep->dcs.bIndActive = false;
-
- pStatusRep->dcs.msgClass = MSG_CLASS_NONE;
- pStatusRep->dcs.codingScheme = SMS_CHARSET_7BIT;
- pStatusRep->dcs.codingGroup = SMS_GROUP_GENERAL;
- pStatusRep->dcs.indType = SMS_OTHER_INDICATOR;
-
- pStatusRep->userData.headerCnt = 0;
- pStatusRep->userData.length = 0;
- memset(pStatusRep->userData.data, 0x00, MAX_USER_DATA_LEN+1);
- }
-
- /* TP-PID */
- if (pStatusRep->paramInd & 0x01)
- pStatusRep->pid = pTpdu[offset++];
-
- /* TP-DCS */
- if (pStatusRep->paramInd & 0x02)
- offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pStatusRep->dcs));
-
- /* TP-UDL & TP-UD */
- if (pStatusRep->paramInd & 0x04)
- /* Decode User Data */
- udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pStatusRep->bHeaderInd, pStatusRep->dcs.codingScheme, &(pStatusRep->userData));
-
- return udLen;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include <errno.h>
-#include <math.h>
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "MsgGconfWrapper.h"
-#include "MsgUtilFile.h"
-#include "MsgNotificationWrapper.h"
-#include "MsgUtilStorage.h"
-
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginTpduCodec.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginCallback.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginDSHandler.h"
-#include "SmsPluginSetting.h"
-
-extern "C" {
- #include <ITapiNetText.h>
- #include <TelNetwork.h>
-}
-
-
-extern bool isMemAvailable;
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginTransport - Member Functions
-==================================================================================================*/
-SmsPluginTransport* SmsPluginTransport::pInstance = NULL;
-
-
-SmsPluginTransport::SmsPluginTransport()
-{
- msgRef = 0x00;
- msgRef8bit = 0x00;
- msgRef16bit = 0x0000;
- curStatus = 0x00;
- memset(&curMoCtrlData, 0x00, sizeof(curMoCtrlData));
-}
-
-
-SmsPluginTransport::~SmsPluginTransport()
-{
-}
-
-
-SmsPluginTransport* SmsPluginTransport::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginTransport();
-
- return pInstance;
-}
-
-
-void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
-{
- MSG_BEGIN();
-
- SMS_TPDU_S tpdu = {0, };
-
- tpdu.tpduType = SMS_TPDU_SUBMIT;
-
- /* Get SMS Send Options - Setting */
- getSmsSendOption(pReqInfo->msgInfo.sim_idx, &(tpdu.data.submit));
-
- /* Set SMS Send Options - Each Message */
- setSmsSendOption(pReqInfo, &tpdu);
-
- /* Set coding scheme */
- setSmsDcsOption(pReqInfo, &tpdu);
-
- /* Set SMS report request */
- setSmsReportOption(pReqInfo, &tpdu);
-
- /* Set SMSC Options */
- SMS_ADDRESS_S smsc = {0, };
- setSmscOptions(pReqInfo->msgInfo.sim_idx, &smsc);
-
- /* Get TAPI handle */
- TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pReqInfo->msgInfo.sim_idx);
-
- /* Get address informations. */
- MsgDbHandler *dbHandle = getDbHandle();
- MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList);
- MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt);
-
- /* Get MSISDN */
- char *msisdn = NULL;
- char keyName[MAX_VCONFKEY_NAME_LEN];
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pReqInfo->msgInfo.sim_idx);
- if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetString() is failed");
- }
-
- int failedIndex = SmsPluginStorage::instance()->getFailedIndex(dbHandle, pReqInfo->msgInfo.msgId);
-
- for (int i = failedIndex; i < pReqInfo->msgInfo.nAddressCnt; i++) {
- /* Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S */
- SMS_SUBMIT_DATA_S submitData = {{0}, };
- msgInfoToSubmitData(&(pReqInfo->msgInfo), &submitData, &(tpdu.data.submit.dcs.codingScheme), i);
-
- /* Insert message reference into db */
- if (tpdu.data.submit.bStatusReport == true) {
- SmsPluginStorage::instance()->insertMsgRef(&(pReqInfo->msgInfo), tpdu.data.submit.msgRef, i);
- }
-
- /* Encode SMSC Address */
- unsigned char smscAddr[MAX_SMSC_LEN];
- memset(smscAddr, 0x00, sizeof(smscAddr));
-
- int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
-
- if (smscLen <= 0) {
- MSG_DEBUG("smscLen <= 0");
- goto _RETURN_FUNC;
- }
-
- char smscAddrTmp[(smscLen*2)+1];
- memset(smscAddrTmp, 0x00, sizeof(smscAddrTmp));
- for (int j = 0; j < smscLen; j++) {
- snprintf(smscAddrTmp+(j*2), sizeof(smscAddrTmp)-(j*2), "%02X", smscAddr[j]);
- }
- MSG_DEBUG("pSCAInfo [%s]", smscAddrTmp);
-
- int bufLen = 0;
-
- char buf[MAX_TPDU_DATA_LEN];
-
- int addLen = strlen(submitData.destAddress.address);
-
- tpdu.data.submit.destAddress.ton = submitData.destAddress.ton;
- tpdu.data.submit.destAddress.npi = submitData.destAddress.npi;
-
- if (addLen < MAX_ADDRESS_LEN) {
- memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen);
- tpdu.data.submit.destAddress.address[addLen] = '\0';
- } else {
- if (submitData.destAddress.address[0] == '+')
- memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
- else
- memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN-1);
-
- tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
- }
-
- MSG_DEBUG("ton [%d]", tpdu.data.submit.destAddress.ton);
- MSG_DEBUG("npi [%d]", tpdu.data.submit.destAddress.npi);
- MSG_SEC_DEBUG("address [%s]", tpdu.data.submit.destAddress.address);
-
- bool bStatusReport = false;
-
- for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) {
- if (submitData.userData[segCnt].headerCnt > 0) {
- tpdu.data.submit.bHeaderInd = true;
- } else {
- tpdu.data.submit.bHeaderInd = false;
- }
-
- if (segCnt == 0 && submitData.segCount > 1) {
- bStatusReport = tpdu.data.submit.bStatusReport;
- tpdu.data.submit.bStatusReport = false;
- } else if ((segCnt+1 == submitData.segCount) && submitData.segCount > 1) {
- tpdu.data.submit.bStatusReport = bStatusReport;
- }
-
- memset(&(tpdu.data.submit.userData), 0x00, sizeof(SMS_USERDATA_S));
- memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S));
-
- SMS_NETWORK_STATUS_T retStatus = SMS_NETWORK_SENDING;
-
- bool bMoreMsg = false;
-
- int retMoCtrlStatus = TAPI_SAT_CALL_CTRL_R_ALLOWED_NO_MOD;
- bool bRetryByMoCtrl = false;
- bool bSatMoCtrl = false;
-
- for (int cnt = 0; cnt < MAX_SMS_SEND_RETRY; ++cnt) {
- /* Encode SMS-SUBMIT TPDU */
- memset(buf, 0x00, sizeof(buf));
-
- if (cnt > 0)
- tpdu.data.submit.bRejectDup = true;
-
- bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
-
- /* Make Telephony Structure */
- TelSmsDatapackageInfo_t pkgInfo;
-
- /* Set TPDU data */
- memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
- memcpy((void*)pkgInfo.szData, buf, bufLen);
-
- pkgInfo.szData[bufLen] = 0;
- pkgInfo.MsgLength = bufLen;
- pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
-
- /* Set SMSC data */
- memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
- memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
- pkgInfo.Sca[smscLen] = '\0';
-
-
- char pkgInfoTmp[(pkgInfo.MsgLength*2)+1];
- memset(pkgInfoTmp, 0x00, sizeof(pkgInfoTmp));
- for (int j = 0; j < pkgInfo.MsgLength; j++) {
- snprintf(pkgInfoTmp+(j*2), sizeof(pkgInfoTmp)-(j*2), "%02X", pkgInfo.szData[j]);
- }
- MSG_INFO("Submit Request TPDU. try cnt : %d", cnt+1);
- MSG_INFO("[%s]", pkgInfoTmp);
-
- SMS_SENT_INFO_S sentInfo;
- memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S));
-
- bMoreMsg = FALSE;
-
- memcpy(&(sentInfo.reqInfo), pReqInfo, sizeof(SMS_REQUEST_INFO_S));
-
- if ((segCnt + 1) == submitData.segCount && (i + 1) == pReqInfo->msgInfo.nAddressCnt) {
- sentInfo.bLast = true;
- bMoreMsg = FALSE;
- } else {
- sentInfo.bLast = false;
- bMoreMsg = TRUE;
- }
-
- SmsPluginEventHandler::instance()->SetSentInfo(&sentInfo);
-
- int svc_type;
- tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &svc_type);
-
- if (svc_type < TAPI_NETWORK_SERVICE_TYPE_2G) {
- MSG_DEBUG("Network service is not available : [%d]", svc_type);
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_PENDING);
- MsgInsertTicker("Network not available. Message will be sent when connected to network.", SMS_MESSAGE_SENDING_PENDING, false, 0);
- goto _RETURN_FUNC;
- }
-
- curStatus = SMS_NETWORK_SENDING;
-
- /* Send SMS */
- int tapiRet = TAPI_API_SUCCESS;
-
- tapiRet = tel_send_sms(handle, &pkgInfo, bMoreMsg, TapiEventSentStatus, (void *)&curMoCtrlData);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_send_sms Success !!! return : [%d] #######", tapiRet);
-
- memset(keyName, 0x00, sizeof(keyName));
- snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MO_CONTROL, pReqInfo->msgInfo.sim_idx);
- if (MsgSettingGetBool(keyName, &bSatMoCtrl) != MSG_SUCCESS)
- MSG_DEBUG("MsgSettingGetBool [%s] failed", keyName);
-
- if (bSatMoCtrl) {
- /* Get SAT MO SM control */
- retMoCtrlStatus = getMoCtrlStatus();
- MSG_DEBUG("retMoCtrlStatus = [%d]", retMoCtrlStatus);
-
- if (retMoCtrlStatus == TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD) {
- if (bRetryByMoCtrl == false) {
- bRetryByMoCtrl = true;
-
- /* Modify Address with control data */
- memset(smsc.address, 0x00, sizeof(smsc.address));
- memcpy(smsc.address, curMoCtrlData.rpDestAddr.string, sizeof(smsc.address)-1);
-
- memset(smscAddr, 0x00, sizeof(smscAddr));
- smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
-
- MSG_SEC_DEBUG("SMSC address=[%s], Encoded length=[%d]", smsc.address, smscLen);
-
- if (curMoCtrlData.tpDestAddr.stringLen < MAX_ADDRESS_LEN) {
- memcpy(tpdu.data.submit.destAddress.address, curMoCtrlData.tpDestAddr.string, curMoCtrlData.tpDestAddr.stringLen);
- tpdu.data.submit.destAddress.address[curMoCtrlData.tpDestAddr.stringLen] = '\0';
- } else {
- memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN);
- tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0';
- }
- } else {
- curMoCtrlData.moSmsCtrlResult = TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED;
- }
- }
- }
- } else {
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
- SmsPluginStorage::instance()->setFailedIndex(dbHandle, pReqInfo->msgInfo.msgId, i);
-
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
- THROW(MsgException::SMS_PLG_ERROR, "######## tel_send_sms Fail !!! return : [%d] #######", tapiRet);
- }
-
- /* Tizen Validation System */
- MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s", pReqInfo->msgInfo.msgId, \
- (msisdn == NULL)?"ME":msisdn, \
- pReqInfo->msgInfo.addressList[i].addressVal, \
- "Success");
-
- MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
-
- retStatus = getNetStatus();
-
- if (retStatus != SMS_NETWORK_SEND_FAIL_TEMPORARY && retStatus != SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD)
- break;
- }
-
-#ifdef MSG_SMS_REPORT
- if (err == MSG_SUCCESS && tmpInfo.msgInfo.msgPort.valid == false) {
- if (pReqInfo->sendOptInfo.bDeliverReq == true) {
- MSG_DEBUG("Update Delivery Report Status : [%d] Msg ID : [%d]", err, tmpInfo.msgInfo.msgId);
-
- /* Adding delivery report status info. */
- MsgStoAddDeliveryReportStatus(tmpInfo.msgInfo.msgId, (unsigned char)tmpInfo.msgInfo.referenceId);
- }
- }
-#endif
-
- MSG_SMS_VLD_INFO("%d, SMS Send End, %s->%s, %s", pReqInfo->msgInfo.msgId, \
- (msisdn == NULL)?"ME":msisdn, \
- pReqInfo->msgInfo.addressList[0].addressVal, \
- (retStatus == SMS_NETWORK_SEND_SUCCESS)?"Success":"Fail");
-
- if (retStatus == SMS_NETWORK_SEND_SUCCESS) {
- bool bTTS = false;
-
- if (MsgSettingGetBool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &bTTS) != MSG_SUCCESS) {
- MSG_DEBUG("MsgSettingGetBool is failed.");
- }
-
- if (bTTS) {
- if (bMoreMsg == false) {
- MsgInsertTicker("SMS is sent", SMS_MESSAGE_SENT, false, 0);
- }
- MSG_DEBUG("######## Msg Sent was Successful !!! #######");
- }
- } else {
- if (retStatus == SMS_NETWORK_SEND_FAIL_TIMEOUT || retStatus == SMS_NETWORK_SEND_FAIL_TEMPORARY || retStatus == SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD)
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
- else if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED)
- /* SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL_FDN_ENABLED); */
- SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL);
-
- if (retStatus == SMS_NETWORK_SEND_FAIL_FDN_RESTRICED) {
- MsgInsertTicker("Unable to send the message while Fixed dialling mode is enabled", SMS_FDN_RESTRICTED, true, 0);
- } else {
- MsgInsertTicker("Sending SMS is failed", SMS_MESSAGE_SENDING_FAIL, true, pReqInfo->msgInfo.msgId);
- }
-
- SmsPluginStorage::instance()->setFailedIndex(dbHandle, pReqInfo->msgInfo.msgId, i);
-
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
- THROW(MsgException::SMS_PLG_ERROR, "######## Msg Sent was Failed !!! return : [%d] #######", retStatus);
- }
-
- if (tpdu.data.submit.userData.headerCnt > 0)
- tpdu.data.submit.userData.headerCnt--;
- }
- }
-
- SmsPluginStorage::instance()->deleteFailedIndex(dbHandle, pReqInfo->msgInfo.msgId);
-
-_RETURN_FUNC :
- if (msisdn) {
- free(msisdn);
- msisdn = NULL;
- }
- MSG_END();
- return;
-}
-
-
-void SmsPluginTransport::sendDeliverReport(TapiHandle *handle, msg_error_t err)
-{
- MSG_BEGIN();
-
- SMS_TPDU_S tpdu;
-
- tpdu.tpduType = SMS_TPDU_DELIVER_REP;
-
- TelSmsResponse_t response;
-
- int tapiRet = TAPI_API_SUCCESS;
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (err == MSG_SUCCESS) {
- tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
- response = TAPI_NETTEXT_SENDSMS_SUCCESS;
-
- if (isMemAvailable == false) {
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- }
- } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
- tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
- tpdu.data.deliverRep.failCause = SMS_FC_SIM_STORAGE_FULL;
-
- response = TAPI_NETTEXT_SIM_FULL;
- MsgInsertTicker("Sim memory full. Delete some items", SMS_MESSAGE_SIM_MESSAGE_FULL, true, 0);
-
-#if 0
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS) {
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- } else {
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- }
-#endif
- } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
- tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
- tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED;
- response = TAPI_NETTEXT_ME_FULL;
- MsgInsertTicker("Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL, true, 0);
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- } else {
- tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
- tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
- /*response = TAPI_NETTEXT_PROTOCOL_ERROR;
- For gcf test [34.2.5.3 class2 message] */
- response = TAPI_NETTEXT_SIM_FULL;
- }
-
- MSG_DEBUG("err : [%d], response : [%02x]", err, response);
-
- tpdu.data.deliverRep.bHeaderInd = false;
- tpdu.data.deliverRep.paramInd = 0x00;
-
- /* Encode SMS-DELIVER-REPORT TPDU */
- int bufLen = 0;
-
- char buf[MAX_TPDU_DATA_LEN];
- memset(buf, 0x00, sizeof(buf));
-
- bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
-
-#ifdef MSG_FOR_DEBUG
- /* print DeliverReport tpdu */
- printf("\n\n######## DeliverReport tpdu #########\n");
- for (int i=0; i < bufLen; i++) {
- printf("[%02x] ", buf[i]);
- }
- printf("\n#################################\n\n");
-#endif
-
- /* Make Telephony Structure */
- TelSmsDatapackageInfo_t pkgInfo;
-
- /* Set TPDU data */
- memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
- memcpy((void*)pkgInfo.szData, buf, bufLen);
-
- pkgInfo.szData[bufLen] = 0;
- pkgInfo.MsgLength = bufLen;
- pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
-
- /* Set SMSC Address */
- SMS_ADDRESS_S smsc;
-
- /* Set SMSC Options */
- setSmscOptions(simIndex, &smsc);
-
- /* Encode SMSC Address */
- unsigned char smscAddr[MAX_SMSC_LEN];
- memset(smscAddr, 0x00, sizeof(smscAddr));
-
- int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
-
- if (smscLen <= 0) return;
-
- /* Set SMSC data */
- memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
- memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
- pkgInfo.Sca[smscLen] = '\0';
-
- /* Send Deliver Report */
- tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! #######");
- else
- MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
-
- MSG_END();
-}
-
-void SmsPluginTransport::sendClass0DeliverReport(TapiHandle *handle, msg_error_t err)
-{
- MSG_BEGIN();
-
- SMS_TPDU_S tpdu;
-
- tpdu.tpduType = SMS_TPDU_DELIVER_REP;
-
- TelSmsResponse_t response;
-
- int tapiRet = TAPI_API_SUCCESS;
-
- int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
-
- if (err == MSG_SUCCESS) {
- tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
- response = TAPI_NETTEXT_SENDSMS_SUCCESS;
-
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- } else if (err == MSG_ERR_SIM_STORAGE_FULL) {
- tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
- response = TAPI_NETTEXT_SENDSMS_SUCCESS;
-
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) {
- tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE;
- response = TAPI_NETTEXT_SENDSMS_SUCCESS;
-
- tapiRet = tel_set_sms_memory_status(handle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, TapiEventMemoryStatus, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! #######");
- else
- MSG_DEBUG("######## tel_set_sms_memory_status() Failed !!! return : [%d] #######", tapiRet);
- } else {
- tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE;
- tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR;
- /*response = TAPI_NETTEXT_PROTOCOL_ERROR;
- For gcf test [34.2.5.3 class2 message] */
- response = TAPI_NETTEXT_SIM_FULL;
- }
-
- MSG_DEBUG("err : [%d], response : [%02x]", err, response);
-
- tpdu.data.deliverRep.bHeaderInd = false;
- tpdu.data.deliverRep.paramInd = 0x00;
-
- /* Encode SMS-DELIVER-REPORT TPDU */
- int bufLen = 0;
-
- char buf[MAX_TPDU_DATA_LEN];
- memset(buf, 0x00, sizeof(buf));
-
- bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf);
-
- /* Make Telephony Structure */
- TelSmsDatapackageInfo_t pkgInfo;
-
- /* Set TPDU data */
- memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData));
- memcpy((void*)pkgInfo.szData, buf, bufLen);
-
- pkgInfo.szData[bufLen] = 0;
- pkgInfo.MsgLength = bufLen;
- pkgInfo.format = TAPI_NETTEXT_NETTYPE_3GPP;
-
- /* Set SMSC Address */
- SMS_ADDRESS_S smsc;
-
- /* Set SMSC Options */
- setSmscOptions(simIndex, &smsc);
-
- /* Encode SMSC Address */
- unsigned char smscAddr[MAX_SMSC_LEN];
- memset(smscAddr, 0x00, sizeof(smscAddr));
-
- int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr);
-
- if (smscLen <= 0) return;
-
- /* Set SMSC data */
- memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca));
- memcpy((void*)pkgInfo.Sca, smscAddr, smscLen);
- pkgInfo.Sca[smscLen] = '\0';
-
- /* Send Deliver Report */
- tapiRet = tel_send_sms_deliver_report(handle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL);
-
- if (tapiRet == TAPI_API_SUCCESS)
- MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! #######");
- else
- MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! return : [%d] #######", tapiRet);
-
- MSG_END();
-}
-
-
-void SmsPluginTransport::getSmsSendOption(int simIndex, SMS_SUBMIT_S *pSubmit)
-{
- /* Set SMS Send Options */
- pSubmit->bRejectDup = false;
- pSubmit->bHeaderInd = false;
-
- if (MsgSettingGetBool(SMS_SEND_DELIVERY_REPORT, &pSubmit->bStatusReport) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if (MsgSettingGetBool(SMS_SEND_REPLY_PATH, &pSubmit->bReplyPath) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- pSubmit->msgRef = msgRef++;
-
- pSubmit->dcs.bCompressed = false;
- pSubmit->dcs.msgClass = SMS_MSG_CLASS_NONE;
- pSubmit->dcs.codingGroup = SMS_GROUP_GENERAL;
-
- int codingScheme = 0;
- if (MsgSettingGetInt(SMS_SEND_DCS, &codingScheme) != MSG_SUCCESS) {
- MSG_INFO("MsgSettingGetInt() is failed");
- }
- pSubmit->dcs.codingScheme = (SMS_CODING_SCHEME_T)codingScheme;
- MSG_DEBUG("DCS : %d", pSubmit->dcs.codingScheme);
-
- MSG_SMSC_LIST_S smscList = {0, };
- SmsPluginSetting::instance()->getSmscListInfo(simIndex, &smscList);
-
- int selectIdx = smscList.selected;
- int valPeriod = 0;
-
- if (selectIdx < SMSC_LIST_MAX) {
- MSG_SMS_PID_T pid = smscList.smscData[selectIdx].pid;
- pSubmit->pid = convertPid(pid);
-
- valPeriod = smscList.smscData[selectIdx].valPeriod;
- } else {
- MSG_WARN("Invalid case");
- pSubmit->pid = SMS_PID_NORMAL;
- valPeriod = 255;
- }
-
- MSG_DEBUG("PID : %d", pSubmit->pid);
-
- pSubmit->vpf = SMS_VPF_NOT_PRESENT; /* default value */
-
- MSG_DEBUG("valPeriod : %d", valPeriod);
- MSG_DEBUG("vpf : %d", pSubmit->vpf);
-}
-
-
-void SmsPluginTransport::setSmsSendOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_S* pSmsTpdu)
-{
- if (!pReqInfo || !pSmsTpdu) {
- MSG_DEBUG("Input param is NULL");
- return;
- }
-
- if (pReqInfo->sendOptInfo.bSetting == true) {
- pSmsTpdu->data.submit.bStatusReport = pReqInfo->sendOptInfo.bDeliverReq;
- pSmsTpdu->data.submit.bReplyPath = pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath;
- }
-}
-
-
-void SmsPluginTransport::setSmsDcsOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_S* pSmsTpdu)
-{
- if (!pReqInfo || !pSmsTpdu) {
- MSG_DEBUG("Input param is NULL");
- return;
- }
-
- if (pReqInfo->msgInfo.msgPort.valid == true) {
- /* Set Coding Scheme for apps that use port number */
- pSmsTpdu->data.submit.dcs.codingScheme = (SMS_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
- MSG_DEBUG("DCS is changed by application : [%d]", pSmsTpdu->data.submit.dcs.codingScheme);
- } else {
- /* Change coding scheme if it is set coding scheme by apps */
- if (pSmsTpdu->data.submit.dcs.codingScheme == SMS_CHARSET_7BIT && pReqInfo->msgInfo.encodeType != MSG_ENCODE_GSM7BIT) {
- pSmsTpdu->data.submit.dcs.codingScheme = (SMS_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType;
- MSG_DEBUG("DCS is changed by application : [%d]", pSmsTpdu->data.submit.dcs.codingScheme);
- }
- }
-}
-
-
-void SmsPluginTransport::setSmsReportOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_S* pSmsTpdu)
-{
- if (!pReqInfo || !pSmsTpdu) {
- MSG_DEBUG("Input param is NULL");
- return;
- }
-
-#ifdef MSG_SMS_REPORT
- /* Update Msg Ref into Report Table */
- if (pSmsTpdu->data.submit.bStatusReport == true) {
- MSG_DEBUG("Update Msg Ref [%d] in Report Table", pSmsTpdu->data.submit.msgRef);
-
- SmsPluginStorage::instance()->updateMsgRef(pReqInfo->msgInfo.msgId, pSmsTpdu->data.submit.msgRef);
- }
-#endif
-
- /* Set Message Reference */
- if (pSmsTpdu->data.submit.bStatusReport == true) {
- pSmsTpdu->data.submit.msgRef = (pReqInfo->msgInfo.msgId % 256);
- }
-}
-
-
-void SmsPluginTransport::setSmscOptions(int simIndex, SMS_ADDRESS_S *pSmsc)
-{
- /* Set SMSC Options */
- MSG_SMSC_LIST_S smscList = {0, };
- SmsPluginSetting::instance()->getSmscListInfo(simIndex, &smscList);
-
- int selectIdx = smscList.selected;
-
- if (selectIdx < SMSC_LIST_MAX) {
- if (smscList.smscData[selectIdx].smscAddr.address[0] != '\0') {
- memset(pSmsc->address, 0x00, sizeof(pSmsc->address));
- strncpy(pSmsc->address, smscList.smscData[selectIdx].smscAddr.address, MAX_ADDRESS_LEN);
-
- MSG_SEC_DEBUG("address : %s", pSmsc->address);
- } else {
- memset(pSmsc->address, 0x00, MAX_ADDRESS_LEN);
- }
-
- pSmsc->ton = (SMS_TON_T)smscList.smscData[selectIdx].smscAddr.ton;
- MSG_DEBUG("ton : %d", pSmsc->ton);
-
- pSmsc->npi = (SMS_NPI_T)smscList.smscData[selectIdx].smscAddr.npi;
- MSG_DEBUG("npi : %d", pSmsc->npi);
- }
-}
-
-
-void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SUBMIT_DATA_S *pData, SMS_CODING_SCHEME_T *pCharType, int addrIndex)
-{
- /* Destination Address */
- pData->destAddress.ton = SMS_TON_UNKNOWN;
- pData->destAddress.npi = SMS_NPI_ISDN;
-
- memset(pData->destAddress.address, 0x00, MAX_ADDRESS_LEN+1);
- memcpy(pData->destAddress.address, pMsgInfo->addressList[addrIndex].addressVal, MAX_ADDRESS_LEN);
-
- MSG_DEBUG("ton [%d]", pData->destAddress.ton);
- MSG_DEBUG("npi [%d]", pData->destAddress.npi);
- MSG_SEC_DEBUG("address [%s]", pData->destAddress.address);
-
- int decodeLen = 0, bufSize = (MAX_GSM_7BIT_DATA_LEN*MAX_SEGMENT_NUM) + 1; /* SMS_CHARSET_7BIT */
-
- unsigned char decodeData[bufSize];
- memset(decodeData, 0x00, sizeof(decodeData));
-
- MsgTextConvert *textCvt = MsgTextConvert::instance();
-
- msg_encode_type_t encodeType = MSG_ENCODE_GSM7BIT;
-
- MSG_LANGUAGE_ID_T langId = MSG_LANG_ID_RESERVED;
-
- bool bAbnormal = false;
-
- /* User Data */
- if (pMsgInfo->bTextSms == true) {
- if (*pCharType == SMS_CHARSET_7BIT) {
- decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &langId, &bAbnormal);
- } else if (*pCharType == SMS_CHARSET_8BIT) {
- memcpy(decodeData, pMsgInfo->msgText, pMsgInfo->dataSize);
- decodeLen = pMsgInfo->dataSize;
- } else if (*pCharType == SMS_CHARSET_UCS2) {
- decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize);
- } else if (*pCharType == SMS_CHARSET_AUTO) {
- decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pMsgInfo->msgText, (int)pMsgInfo->dataSize, &encodeType);
- *pCharType = encodeType;
- }
- } else {
- int fileSize = 0;
-
- char* pFileData = NULL;
- unique_ptr<char*, void(*)(char**)> FileBuf(&pFileData, unique_ptr_deleter);
-
- /* Read Message Data from File */
- if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false)
- THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error");
-
- MSG_DEBUG("file size : [%d] file data : [%s]", fileSize, pFileData);
-
- if (*pCharType == SMS_CHARSET_7BIT) {
- decodeLen = textCvt->convertUTF8ToGSM7bit(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &langId, &bAbnormal);
- } else if (*pCharType == SMS_CHARSET_8BIT) {
- memcpy(decodeData, pFileData, fileSize);
- decodeLen = fileSize;
- } else if (*pCharType == SMS_CHARSET_UCS2) {
- decodeLen = textCvt->convertUTF8ToUCS2(decodeData, bufSize, (unsigned char*)pFileData, fileSize);
- } else if (*pCharType == SMS_CHARSET_AUTO) {
- decodeLen = textCvt->convertUTF8ToAuto(decodeData, bufSize, (unsigned char*)pFileData, fileSize, &encodeType);
- *pCharType = encodeType;
- }
-
- /* Delete File */
- if (pMsgInfo->nAddressCnt == (addrIndex + 1))
- MsgDeleteFile(pMsgInfo->msgData);
- }
-
- MSG_DEBUG("decode length : [%d]", decodeLen);
- MSG_DEBUG("character type : [%d]", *pCharType);
- MSG_DEBUG("Language Identifier : [%d]", langId);
- MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress);
-
- int addrLen = 0;
-
- char* encodedAddr = NULL;
- unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter);
-
- if (strlen(pMsgInfo->replyAddress) > 0) {
- SMS_ADDRESS_S replyAddr = {};
-
- replyAddr.ton = SMS_TON_NATIONAL;
- replyAddr.npi = SMS_NPI_ISDN;
-
- memset(replyAddr.address, 0x00, MAX_ADDRESS_LEN+1);
- memcpy(replyAddr.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
-
- addrLen = SmsPluginParamCodec::encodeAddress(&replyAddr, &encodedAddr);
-
- MSG_DEBUG("reply addr length : [%d]", addrLen);
- }
-
- int segSize = 0, index = 0;
-
- segSize = getSegmentSize(*pCharType, decodeLen, pMsgInfo->msgPort.valid, langId, addrLen);
-
- if (segSize == 0) {
- if (decodeLen == 0) /* to handle empty message -> (pMsgInfo->msgText = NULL) */
- pData->segCount = 1;
- else
- THROW(MsgException::SMS_PLG_ERROR, "DIVIDE_BY_ZERO : %d", segSize);
- } else {
- pData->segCount = ceil((double)decodeLen/(double)segSize);
- }
-
- MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount);
-
- if (pData->segCount > MAX_SEGMENT_NUM)
- THROW(MsgException::SMS_PLG_ERROR, "Segment Count is over maximum : %d", pData->segCount);
-
- int headerCnt = 0;
-
- for (unsigned int i = 0; i < pData->segCount; i++) {
- headerCnt = 0;
-
- if ((i + 1) == pData->segCount)
- pData->userData[i].length = decodeLen - (i*segSize);
- else
- pData->userData[i].length = segSize;
-
- memset(pData->userData[i].data, 0x00, MAX_USER_DATA_LEN+1);
- memcpy(pData->userData[i].data, &(decodeData[index]), pData->userData[i].length);
- pData->userData[i].data[pData->userData[i].length] = 0;
-
- MSG_DEBUG("user data len [%d]", pData->userData[i].length);
- MSG_DEBUG("user data [%s]", pData->userData[i].data);
-
- index += segSize;
-
- /* Set User Data Header for Concatenated Message */
- if (pData->segCount > 1) {
- pData->userData[i].header[headerCnt].udhType = SMS_UDH_CONCAT_8BIT;
- pData->userData[i].header[headerCnt].udh.concat8bit.msgRef = msgRef8bit;
- pData->userData[i].header[headerCnt].udh.concat8bit.totalSeg = pData->segCount;
- pData->userData[i].header[headerCnt].udh.concat8bit.seqNum = i + 1;
-
- headerCnt++;
- }
-
- /* Set User Data Header Port Information */
- if (pMsgInfo->msgPort.valid == true) {
- pData->userData[i].header[headerCnt].udhType = SMS_UDH_APP_PORT_16BIT;
- pData->userData[i].header[headerCnt].udh.appPort16bit.destPort = pMsgInfo->msgPort.dstPort;
- pData->userData[i].header[headerCnt].udh.appPort16bit.originPort = pMsgInfo->msgPort.srcPort;
-
- headerCnt++;
- }
-
- /* Set User Data Header for Alternate Reply Address */
- if (strlen(pMsgInfo->replyAddress) > 0) {
- pData->userData[i].header[headerCnt].udhType = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
-
- pData->userData[i].header[headerCnt].udh.alternateAddress.ton = SMS_TON_NATIONAL;
- pData->userData[i].header[headerCnt].udh.alternateAddress.npi = SMS_NPI_ISDN;
-
- memset(pData->userData[i].header[headerCnt].udh.alternateAddress.address, 0x00, MAX_ADDRESS_LEN+1);
- memcpy(pData->userData[i].header[headerCnt].udh.alternateAddress.address, pMsgInfo->replyAddress, MAX_ADDRESS_LEN);
-
- headerCnt++;
- }
-
- /* Set User Data Header for National Language Single Shift */
- if (*pCharType == SMS_CHARSET_7BIT && langId != MSG_LANG_ID_RESERVED) {
- pData->userData[i].header[headerCnt].udhType = SMS_UDH_SINGLE_SHIFT;
- pData->userData[i].header[headerCnt].udh.singleShift.langId = langId;
-
- headerCnt++;
- }
-
- pData->userData[i].headerCnt = headerCnt;
- }
-
- msgRef8bit++;
-}
-
-
-int SmsPluginTransport::getSegmentSize(SMS_CODING_SCHEME_T CodingScheme, int DataLen, bool bPortNum, MSG_LANGUAGE_ID_T LangId, int ReplyAddrLen)
-{
- int headerLen = 1, concat = 5, port = 6, lang = 3, reply = 2;
- int headerSize = 0, segSize = 0, maxSize = 0;
-
- if (CodingScheme == SMS_CHARSET_7BIT) {
- MSG_DEBUG("SMS_CHARSET_7BIT");
- maxSize = MAX_GSM_7BIT_DATA_LEN;
- } else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2) {
- MSG_DEBUG("SMS_CHARSET_8BIT or SMS_CHARSET_UCS2 [%d]", CodingScheme);
- maxSize = MAX_UCS2_DATA_LEN;
- }
-
- if (bPortNum == true) {
- MSG_DEBUG("Port Number Exists");
- headerSize += port;
- }
-
- if (LangId != MSG_LANG_ID_RESERVED) {
- MSG_DEBUG("National Language Exists");
- headerSize += lang;
- }
-
- if (ReplyAddrLen > 0) {
- MSG_DEBUG("Reply Address Exists");
- headerSize += reply;
- headerSize += ReplyAddrLen;
- }
-
- if (CodingScheme == SMS_CHARSET_7BIT) {
- if ((DataLen+headerSize) > maxSize)
- segSize = ((140*8) - ((headerLen + concat + headerSize)*8)) / 7;
- else
- segSize = DataLen;
- } else if (CodingScheme == SMS_CHARSET_8BIT || CodingScheme == SMS_CHARSET_UCS2) {
- if ((DataLen+headerSize) > maxSize)
- segSize = 140 - (headerLen + concat + headerSize);
- else
- segSize = DataLen;
- }
-
- return segSize;
-}
-
-
-void SmsPluginTransport::setConcatHeader(SMS_UDH_S *pSrcHeader, SMS_UDH_S *pDstHeader)
-{
- pDstHeader->udhType = pSrcHeader->udhType;
-
- switch (pDstHeader->udhType) {
- case SMS_UDH_CONCAT_8BIT: {
- pDstHeader->udh.concat8bit.msgRef = pSrcHeader->udh.concat8bit.msgRef;
- pDstHeader->udh.concat8bit.totalSeg = pSrcHeader->udh.concat8bit.totalSeg;
- pDstHeader->udh.concat8bit.seqNum = pSrcHeader->udh.concat8bit.seqNum;
- }
- break;
-
- case SMS_UDH_CONCAT_16BIT: {
- pDstHeader->udh.concat16bit.msgRef = pSrcHeader->udh.concat16bit.msgRef;
- pDstHeader->udh.concat16bit.totalSeg = pSrcHeader->udh.concat16bit.totalSeg;
- pDstHeader->udh.concat16bit.seqNum = pSrcHeader->udh.concat16bit.seqNum;
- }
- break;
- }
-}
-
-
-void SmsPluginTransport::setNetStatus(SMS_NETWORK_STATUS_T sentStatus)
-{
- mx.lock();
- curStatus = sentStatus;
- cv.signal();
- mx.unlock();
-}
-
-
-SMS_NETWORK_STATUS_T SmsPluginTransport::getNetStatus()
-{
- mx.lock();
-
- int ret = 0;
-
- if (curStatus == SMS_NETWORK_SENDING)
- ret = cv.timedwait(mx.pMsgMutex(), 125);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
- curStatus = SMS_NETWORK_SEND_FAIL_TIMEOUT;
- }
-
- return curStatus;
-}
-
-
-void SmsPluginTransport::setMoCtrlStatus(TelSatMoSmCtrlIndData_t *moCtrlData)
-{
- mx.lock();
-
- if (moCtrlData) {
- memset(&curMoCtrlData, 0x00, sizeof(TelSatMoSmCtrlIndData_t));
- memcpy(&curMoCtrlData, moCtrlData, sizeof(TelSatMoSmCtrlIndData_t));
- MSG_DEBUG("MO Control Data is set by Tapi Event Noti");
- }
-
- cv.signal();
- mx.unlock();
-}
-
-
-int SmsPluginTransport::getMoCtrlStatus()
-{
- mx.lock();
-
- int ret = 0;
-
- ret = cv.timedwait(mx.pMsgMutex(), 10);
-
- mx.unlock();
-
- if (ret == ETIMEDOUT) {
- MSG_DEBUG("WARNING: SENT STATUS TIME-OUT");
- return -1;
- }
-
- return (curMoCtrlData.moSmsCtrlResult);
-}
-
-
-unsigned char SmsPluginTransport::getMsgRef()
-{
- return msgRef++;
-}
-
-
-SMS_PID_T SmsPluginTransport::convertPid(MSG_SMS_PID_T pid)
-{
- SMS_PID_T retPid;
-
- switch (pid) {
- case MSG_PID_TEXT :
- retPid = SMS_PID_NORMAL;
- break;
- case MSG_PID_VOICE :
- retPid = SMS_PID_VOICE;
- break;
- case MSG_PID_FAX :
- retPid = SMS_PID_TELEX;
- break;
- case MSG_PID_X400 :
- retPid = SMS_PID_x400;
- break;
- case MSG_PID_ERMES :
- retPid = SMS_PID_ERMES;
- break;
- case MSG_PID_EMAIL :
- retPid = SMS_PID_EMAIL;
- break;
- default :
- retPid = SMS_PID_NORMAL;
- break;
- }
-
- return retPid;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgException.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginWapPushHandler.h"
-#include "SmsPluginConcatHandler.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginUAManager.h"
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginUAManager - Member Functions
-==================================================================================================*/
-SmsPluginUAManager* SmsPluginUAManager::pInstance = NULL;
-
-
-SmsPluginUAManager::SmsPluginUAManager() : mx(), cv()
-{
- start();
-}
-
-
-SmsPluginUAManager::~SmsPluginUAManager()
-{
-}
-
-
-SmsPluginUAManager* SmsPluginUAManager::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginUAManager();
-
- return pInstance;
-}
-
-
-void SmsPluginUAManager::run()
-{
- while (1) {
- lock();
- while (smsTranQ.empty()) {
- wait();
- }
- SMS_REQUEST_INFO_S request;
- smsTranQ.front(&request);
- unlock();
-
- request.msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter);
-
- try {
- SmsPluginTransport::instance()->submitRequest(&request);
- } catch (MsgException& e) {
- MSG_FATAL("%s", e.what());
-
- lock();
- smsTranQ.pop_front();
- unlock();
- continue;
- } catch (exception& e) {
- MSG_FATAL("%s", e.what());
- lock();
- smsTranQ.pop_front();
- unlock();
- continue;
- }
-
- lock();
- smsTranQ.pop_front();
- unlock();
- }
-}
-
-
-void SmsPluginUAManager::addReqEntity(SMS_REQUEST_INFO_S *request)
-{
- SMS_REQUEST_INFO_S reqTmp = {0, };
-
- memcpy(&reqTmp, request, sizeof(SMS_REQUEST_INFO_S));
-
- lock();
-
- smsTranQ.push_back(reqTmp);
- cv.signal();
-
- unlock();
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "SmsPluginParamCodec.h"
-#include "SmsPluginUDCodec.h"
-
-using namespace std;
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginUDCodec - Member Functions
-==================================================================================================*/
-SmsPluginUDCodec::SmsPluginUDCodec()
-{
-}
-
-
-SmsPluginUDCodec::~SmsPluginUDCodec()
-{
-}
-
-
-int SmsPluginUDCodec::encodeUserData(const SMS_USERDATA_S *pUserData, SMS_CODING_SCHEME_T CodingScheme, char *pEncodeData)
-{
- int encodeSize = 0;
-
- switch (CodingScheme) {
- case SMS_CHARSET_7BIT:
- encodeSize = encodeGSMData(pUserData, pEncodeData);
- break;
- case SMS_CHARSET_8BIT:
- encodeSize = encode8bitData(pUserData, pEncodeData);
- break;
- case SMS_CHARSET_UCS2:
- encodeSize = encodeUCS2Data(pUserData, pEncodeData);
- break;
- }
-
- return encodeSize;
-}
-
-
-int SmsPluginUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData)
-{
- int decodeSize = 0;
-
- memset(pUserData, 0x00, sizeof(SMS_USERDATA_S));
-
- switch (CodingScheme) {
- case SMS_CHARSET_7BIT:
- decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
- break;
- case SMS_CHARSET_8BIT:
- decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, NULL);
- break;
- case SMS_CHARSET_UCS2:
- decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, NULL);
- break;
- }
-
- return decodeSize;
-}
-
-
-int SmsPluginUDCodec::decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
-{
- int decodeSize = 0;
-
- memset(pUserData, 0x00, sizeof(SMS_USERDATA_S));
-
- switch (CodingScheme) {
- case SMS_CHARSET_7BIT:
- decodeSize = decodeGSMData(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
- break;
- case SMS_CHARSET_8BIT:
- decodeSize = decode8bitData(pTpdu, bHeaderInd, pUserData, pTPUD);
- break;
- case SMS_CHARSET_UCS2:
- decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
- break;
- case SMS_CHARSET_EUCKR:
- decodeSize = decodeUCS2Data(pTpdu, tpduLen, bHeaderInd, pUserData, pTPUD);
- break;
- }
-
- return decodeSize;
-}
-
-
-int SmsPluginUDCodec::encodeGSMData(const SMS_USERDATA_S *pUserData, char *pEncodeData)
-{
- int headerLen = 0, offset = 0, fillBits = 0, packSize = 0, encodeLen = 0;
- unsigned char udhl = 0x00;
-
- if (pUserData->headerCnt > 0)
- offset = 2;
- else
- offset = 1;
-
- MSG_DEBUG("pUserData->headerCnt [%d]", pUserData->headerCnt);
-
- /* Encode User Data Header */
- for (int i = 0; i < pUserData->headerCnt; i++) {
- headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
-
- MSG_DEBUG("headerLen [%d]", headerLen);
-
- udhl += headerLen;
- offset += headerLen;
- }
-
- MSG_DEBUG("udhl [%d]", udhl);
-
- if (udhl > 0)
- fillBits = ((udhl+1)*8)%7; /* + UDHL */
-
- if (fillBits > 0)
- fillBits = 7 - fillBits;
-
- MSG_DEBUG("fillBits [%d]", fillBits);
- MSG_DEBUG("dataLen [%d]", pUserData->length);
-
- /* Set UDL, UDHL */
- if (udhl > 0) {
- pEncodeData[0] = (((udhl+1)*8) + fillBits + (pUserData->length*7)) / 7;
- pEncodeData[1] = udhl;
- } else {
- pEncodeData[0] = (char)pUserData->length;
- }
-
- packSize = pack7bitChar((unsigned char*)pUserData->data, pUserData->length, fillBits, &(pEncodeData[offset]));
-
- encodeLen = offset + packSize;
-
- MSG_DEBUG("packSize [%d]", packSize);
- MSG_DEBUG("encodeLen [%d]", encodeLen);
-
-#if 0
-printf("\n\n[encodeGSMData] userData data.\n");
-for (int j = 0; j < encodeLen; j++)
-{
- printf(" [%02x]", pEncodeData[j]);
-}
-printf("\n\n");
-#endif
-
- return encodeLen;
-}
-
-
-int SmsPluginUDCodec::encode8bitData(const SMS_USERDATA_S *pUserData, char *pEncodeData)
-{
- int headerLen = 0, offset = 2, fillBits = 0, encodeLen = 0;
- unsigned char udhl = 0x00;
-
- if (pUserData->headerCnt > 0)
- offset = 2;
- else
- offset = 1;
-
- /* Encode User Data Header */
- for (int i = 0; i < pUserData->headerCnt; i++) {
- headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
-
- udhl += headerLen;
- offset += headerLen;
- }
-
- MSG_DEBUG("fillBits [%d]", fillBits);
- MSG_DEBUG("dataLen [%d]", pUserData->length);
-
- /* Set UDL, UDHL */
- if (udhl > 0) {
- pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
- pEncodeData[1] = udhl;
- } else {
- pEncodeData[0] = (char)pUserData->length;
- }
-
- memcpy(&(pEncodeData[offset]), pUserData->data, pUserData->length);
-
- encodeLen = offset + pUserData->length;
-
- return encodeLen;
-}
-
-
-int SmsPluginUDCodec::encodeUCS2Data(const SMS_USERDATA_S *pUserData, char *pEncodeData)
-{
- int headerLen = 0, offset = 2, fillBits = 0, encodeLen = 0;
- unsigned char udhl = 0x00;
-
- if (pUserData->headerCnt > 0)
- offset = 2;
- else
- offset = 1;
-
- /* Encode User Data Header */
- for (int i = 0; i < pUserData->headerCnt; i++) {
- headerLen = encodeHeader(pUserData->header[i], &(pEncodeData[offset]));
-
- udhl += headerLen;
- offset += headerLen;
- }
-
- MSG_DEBUG("fillBits [%d]", fillBits);
- MSG_DEBUG("dataLen [%d]", pUserData->length);
-
- /* Set UDL, UDHL */
- if (udhl > 0) {
- pEncodeData[0] = (udhl+1) + fillBits + pUserData->length;
- pEncodeData[1] = udhl;
- } else {
- pEncodeData[0] = (char)pUserData->length;
- }
-
- memcpy(&(pEncodeData[offset]), pUserData->data, pUserData->length);
-
- encodeLen = offset + pUserData->length;
-
-#if 0
-printf("\n\n[encodeUCS2Data] userData data.\n");
-for (int j = 0; j < encodeLen; j++)
-{
- printf(" [%02x]", pEncodeData[j]);
-}
-printf("\n\n");
-#endif
-
- return encodeLen;
-}
-
-
-int SmsPluginUDCodec::decodeGSMData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
-{
- int offset = 0, udl = 0, udhl = 0, headerLen = 0, fillBits = 0, octetUdl = 0;
-
- /* UDL */
- udl = pTpdu[offset++];
- octetUdl = (udl*7)/8;
-
- MSG_DEBUG("udl = %d, tpdulen = %d, octetUdl = %d.", udl, tpduLen, octetUdl);
- MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
-
- if (udl > MAX_GSM_7BIT_DATA_LEN || octetUdl > tpduLen) {
- pUserData->length = 0;
- pUserData->headerCnt = 0;
- return 0;
- }
-
- /* Setting for Wap Push */
- if (pTPUD != NULL) {
- pTPUD->udl = udl;
-
- memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
- pTPUD->ud[udl] = '\0';
- }
-
- /* Decode User Data Header */
- if (bHeaderInd == true) {
- /* UDHL */
- udhl = pTpdu[offset++];
-
- MSG_DEBUG("udhl = %d", udhl);
-
- pUserData->headerCnt = 0;
-
- for (int i = 0; offset < udhl; i++) {
- headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
-
- if (headerLen <= 0) {
- MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
-
- pUserData->length = 0;
- memset(pUserData->data, 0x00, sizeof(pUserData->data));
-
- return 0;
- }
-
- offset += headerLen;
-
- if (offset > (udhl+2)) {
- MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
-
- pUserData->length = 0;
- memset(pUserData->data, 0x00, sizeof(pUserData->data));
-
- return 0;
- }
-
- pUserData->headerCnt++;
- }
- } else {
- pUserData->headerCnt = 0;
- }
-
- MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
-
- if (udhl > 0) {
- fillBits = ((udl*7) - ((udhl+1)*8)) % 7;
- udl = ((udl*7) - ((udhl+1)*8)) / 7;
- }
-
- MSG_DEBUG("fillBits = %d", fillBits);
- MSG_DEBUG("udhl = %d", udhl);
- MSG_DEBUG("udl = %d", udl);
-
- MSG_DEBUG("offset = %d", offset);
-
- pUserData->length = unpack7bitChar(&(pTpdu[offset]), udl, fillBits, pUserData->data);
-
- return pUserData->length;
-}
-
-
-int SmsPluginUDCodec::decode8bitData(const unsigned char *pTpdu, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
-{
- int offset = 0, udl = 0, udhl = 0, headerLen = 0;
-
- /* UDL */
- udl = pTpdu[offset++];
-
- if (udl > MAX_UCS2_DATA_LEN) {
- pUserData->length = 0;
- return 0;
- }
-
- /* Setting for Wap Push */
- if (pTPUD != NULL) {
- pTPUD->udl = udl;
-
- memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
- pTPUD->ud[udl] = '\0';
- }
-
- MSG_DEBUG("udl = %d", udl);
- MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
-
- /* Decode User Data Header */
- if (bHeaderInd == true) {
- /* UDHL */
- udhl = pTpdu[offset++];
-
- MSG_DEBUG("udhl = %d", udhl);
-
- pUserData->headerCnt = 0;
-
- for (int i = 0; offset < udhl; i++) {
- headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
-
- if (headerLen <= 0) {
- MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
-
- pUserData->length = 0;
- memset(pUserData->data, 0x00, sizeof(pUserData->data));
-
- return 0;
- }
-
- offset += headerLen;
-
- if (offset > (udhl+2)) {
- MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
-
- pUserData->length = 0;
- memset(pUserData->data, 0x00, sizeof(pUserData->data));
-
- return 0;
- }
-
- pUserData->headerCnt++;
- }
- } else {
- pUserData->headerCnt = 0;
- }
-
- MSG_DEBUG("headerCnt = %d", pUserData->headerCnt);
-
- if (udhl > 0)
- pUserData->length = (udl) - (udhl+1);
- else
- pUserData->length = udl;
-
- MSG_DEBUG("pUserData->length = %d", pUserData->length);
- MSG_DEBUG("offset = %d", offset);
-
- memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
-
- return pUserData->length;
-}
-
-
-int SmsPluginUDCodec::decodeUCS2Data(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD)
-{
- int offset = 0, udl = 0, udhl = 0, headerLen = 0;
-
- /* UDL */
- udl = pTpdu[offset++];
-
- MSG_DEBUG("udl = %d, tpdulen = %d.", udl, tpduLen);
- MSG_DEBUG("bHeaderInd = %d", bHeaderInd);
-
- if (udl > MAX_UCS2_DATA_LEN || udl > tpduLen) {
- pUserData->length = 0;
- pUserData->headerCnt = 0;
- return 0;
- }
-
- /* Setting for Wap Push */
- if (pTPUD != NULL) {
- pTPUD->udl = udl;
-
- memcpy(pTPUD->ud, &(pTpdu[offset]), udl);
- pTPUD->ud[udl] = '\0';
- }
-
- /* Decode User Data Header */
- if (bHeaderInd == true) {
- /* UDHL */
- udhl = pTpdu[offset++];
-
- MSG_DEBUG("udhl = %d", udhl);
-
- pUserData->headerCnt = 0;
-
- for (int i = 0; offset < udhl; i++) {
- headerLen = decodeHeader(&(pTpdu[offset]), &(pUserData->header[i]));
-
- if (headerLen <= 0) {
- MSG_DEBUG("Error to decode User Data Header. headerLen [%d]", headerLen);
-
- pUserData->length = 0;
- memset(pUserData->data, 0x00, sizeof(pUserData->data));
-
- return 0;
- }
-
- offset += headerLen;
-
- if (offset > (udhl+2)) {
- MSG_DEBUG("Error to decode User Data Header. offset [%d] > (udhl [%d] + 2)", offset, udhl);
-
- pUserData->length = 0;
- memset(pUserData->data, 0x00, sizeof(pUserData->data));
-
- return 0;
- }
-
- pUserData->headerCnt++;
- }
- } else {
- pUserData->headerCnt = 0;
- }
-
- if (udhl > 0)
- pUserData->length = (udl) - (udhl+1);
- else
- pUserData->length = udl;
-
- MSG_DEBUG("pUserData->length = %d", pUserData->length);
- MSG_DEBUG("offset = %d", offset);
-
- memcpy(pUserData->data, &(pTpdu[offset]), pUserData->length);
- pUserData->data[pUserData->length] = 0;
-
- return pUserData->length;
-}
-
-
-int SmsPluginUDCodec::encodeHeader(const SMS_UDH_S header, char *pEncodeHeader)
-{
- int offset = 0, addrLen = 0;
-
- char* encodedAddr = NULL;
- unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter);
-
- switch (header.udhType) {
- case SMS_UDH_CONCAT_8BIT :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_CONCAT_8BIT;
-
- /* IEDL */
- pEncodeHeader[offset++] = 0x03;
-
- /* Reference Number */
- pEncodeHeader[offset++] = header.udh.concat8bit.msgRef;
-
- /* Number of Segments */
- pEncodeHeader[offset++] = header.udh.concat8bit.totalSeg;
-
- /* Sequence Number */
- pEncodeHeader[offset++] = header.udh.concat8bit.seqNum;
-
- break;
-
- case SMS_UDH_CONCAT_16BIT :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_CONCAT_16BIT;
-
- /* IEDL */
- pEncodeHeader[offset++] = 0x04;
-
- /* Reference Number */
- pEncodeHeader[offset++] = (char)(header.udh.concat16bit.msgRef >> 8);
- pEncodeHeader[offset++] = header.udh.concat16bit.msgRef & 0x00FF;
-
- /* Number of Segments */
- pEncodeHeader[offset++] = header.udh.concat16bit.totalSeg;
-
- /* Sequence Number */
- pEncodeHeader[offset++] = header.udh.concat16bit.seqNum;
-
- break;
-
- case SMS_UDH_APP_PORT_8BIT :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_APP_PORT_8BIT;
-
- /* IEDL */
- pEncodeHeader[offset++] = 0x02;
-
- /* Dest Port */
- pEncodeHeader[offset++] = header.udh.appPort8bit.destPort;
-
- /* Origin Port */
- pEncodeHeader[offset++] = header.udh.appPort8bit.originPort;
-
- break;
-
- case SMS_UDH_APP_PORT_16BIT :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_APP_PORT_16BIT;
-
- /* IEDL */
- pEncodeHeader[offset++] = 0x04;
-
- /* Dest Port */
- pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.destPort >> 8);
- pEncodeHeader[offset++] = header.udh.appPort16bit.destPort & 0x00FF;
-
- /* Origin Port */
- pEncodeHeader[offset++] = (char)(header.udh.appPort16bit.originPort >> 8);
- pEncodeHeader[offset++] = header.udh.appPort16bit.originPort & 0x00FF;
-
- break;
-
- case SMS_UDH_ALTERNATE_REPLY_ADDRESS :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_ALTERNATE_REPLY_ADDRESS;
-
- addrLen = SmsPluginParamCodec::encodeAddress(&(header.udh.alternateAddress), &encodedAddr);
-
- /* IEDL */
- pEncodeHeader[offset++] = addrLen;
-
- /* Alternate Reply Address */
- memcpy(&pEncodeHeader[offset], encodedAddr, addrLen);
-
- offset += addrLen;
-
- break;
-
- case SMS_UDH_SINGLE_SHIFT :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_SINGLE_SHIFT;
-
- /* IEDL */
- pEncodeHeader[offset++] = 0x01;
-
- /* National Language Identifier */
- pEncodeHeader[offset++] = header.udh.singleShift.langId;
-
- break;
-
- case SMS_UDH_LOCKING_SHIFT :
- /* IEI */
- pEncodeHeader[offset++] = SMS_UDH_LOCKING_SHIFT;
-
- /* IEDL */
- pEncodeHeader[offset++] = 0x01;
-
- /* National Language Identifier */
- pEncodeHeader[offset++] = header.udh.lockingShift.langId;
-
- break;
-
- case SMS_UDH_NONE :
- default :
- break;
- }
-
- return offset;
-}
-
-
-int SmsPluginUDCodec::decodeHeader(const unsigned char *pTpdu, SMS_UDH_S *pHeader)
-{
- int offset = 0;
- unsigned char IEDL = 0;
-
- pHeader->udhType = pTpdu[offset++];
-
- switch (pHeader->udhType) {
- case SMS_UDH_CONCAT_8BIT: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- pHeader->udh.concat8bit.msgRef = pTpdu[offset++];
- pHeader->udh.concat8bit.totalSeg = pTpdu[offset++];
- pHeader->udh.concat8bit.seqNum = pTpdu[offset++];
-
- MSG_DEBUG("concat8bit.msgRef [%02x]", pHeader->udh.concat8bit.msgRef);
- MSG_DEBUG("concat8bit.totalSeg [%02x]", pHeader->udh.concat8bit.totalSeg);
- MSG_DEBUG("concat8bit.seqNum [%02x]", pHeader->udh.concat8bit.seqNum);
- }
- break;
-
- case SMS_UDH_CONCAT_16BIT: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- pHeader->udh.concat16bit.msgRef = pTpdu[offset++];
- pHeader->udh.concat16bit.msgRef = (unsigned short)((pHeader->udh.concat16bit.msgRef << 8) | pTpdu[offset++]);
- pHeader->udh.concat16bit.totalSeg = pTpdu[offset++];
- pHeader->udh.concat16bit.seqNum = pTpdu[offset++];
-
- MSG_DEBUG("concat16bit.msgRef [%04x]", pHeader->udh.concat16bit.msgRef);
- MSG_DEBUG("concat16bit.totalSeg [%02x]", pHeader->udh.concat16bit.totalSeg);
- MSG_DEBUG("concat16bit.seqNum [%02x]", pHeader->udh.concat16bit.seqNum);
- }
- break;
-
- case SMS_UDH_APP_PORT_8BIT: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- pHeader->udh.appPort8bit.destPort = pTpdu[offset++];
- pHeader->udh.appPort8bit.originPort = pTpdu[offset++];
-
- MSG_DEBUG("appPort8bit.destPort [%02x]", pHeader->udh.appPort8bit.destPort);
- MSG_DEBUG("appPort8bit.originPort [%02x]", pHeader->udh.appPort8bit.originPort);
- }
- break;
-
- case SMS_UDH_APP_PORT_16BIT: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- pHeader->udh.appPort16bit.destPort = pTpdu[offset++];
- pHeader->udh.appPort16bit.destPort = (unsigned short)((pHeader->udh.appPort16bit.destPort << 8) | pTpdu[offset++]);
- pHeader->udh.appPort16bit.originPort = pTpdu[offset++];
- pHeader->udh.appPort16bit.originPort = (unsigned short)((pHeader->udh.appPort16bit.originPort << 8) | pTpdu[offset++]);
-
- MSG_DEBUG("appPort16bit.destPort [%04x]", pHeader->udh.appPort16bit.destPort);
- MSG_DEBUG("appPort16bit.originPort [%04x]", pHeader->udh.appPort16bit.originPort);
- }
- break;
-
- case SMS_UDH_SPECIAL_SMS: {
- IEDL = pTpdu[offset++];
-
- if (IEDL != 2)
- return 0;
-
- MSG_DEBUG("Decoding special sms udh.");
-
- pHeader->udh.specialInd.bStore = (bool) (pTpdu[offset] & 0x80);
- pHeader->udh.specialInd.msgInd = (unsigned short) (pTpdu[offset++] & 0x7F);
- pHeader->udh.specialInd.waitMsgNum = (unsigned short) pTpdu[offset];
- }
- break;
-
- case SMS_UDH_ALTERNATE_REPLY_ADDRESS: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pHeader->udh.alternateAddress));
-
- MSG_SEC_DEBUG("alternate reply address [%s]", pHeader->udh.alternateAddress.address);
- }
- break;
-
- case SMS_UDH_SINGLE_SHIFT: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- pHeader->udh.singleShift.langId = pTpdu[offset++];
-
- MSG_DEBUG("singleShift.langId [%02x]", pHeader->udh.singleShift.langId);
- }
- break;
-
- case SMS_UDH_LOCKING_SHIFT: {
- IEDL = pTpdu[offset++];
-
- if (IEDL == 0)
- return 0;
-
- pHeader->udh.lockingShift.langId = pTpdu[offset++];
-
- MSG_DEBUG("lockingShift.langId [%02x]", pHeader->udh.lockingShift.langId);
- }
- break;
-
- default: {
- MSG_DEBUG("Not Supported Header Type [%02x]", pHeader->udhType);
-
- IEDL = pTpdu[offset++];
-
- MSG_DEBUG("IEDL [%d]", IEDL);
- return (offset + IEDL);
- }
- break;
- }
-
- return offset;
-}
-
-
-int SmsPluginUDCodec::pack7bitChar(const unsigned char *pUserData, int dataLen, int fillBits, char *pPackData)
-{
- int srcIdx = 0, dstIdx = 0, shift = fillBits;
-
- if (shift > 0)
- dstIdx = 1;
-
- while (srcIdx < dataLen) {
- if (shift == 0) {
- pPackData[dstIdx] = pUserData[srcIdx];
-
- shift = 7;
- srcIdx++;
- dstIdx++;
-
- if (srcIdx >= dataLen)
- break;
- }
-
- if (shift > 1) {
- pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
- pPackData[dstIdx] = pUserData[srcIdx] >> (8-shift);
- shift--;
-
- srcIdx++;
- dstIdx++;
- } else if (shift == 1) {
- pPackData[dstIdx-1] |= pUserData[srcIdx] << shift;
-
- srcIdx++;
-
- shift--;
- }
- }
-
- return dstIdx;
-}
-
-
-int SmsPluginUDCodec::unpack7bitChar(const unsigned char *pTpdu, unsigned char dataLen, int fillBits, char *pUnpackData)
-{
- int srcIdx = 0, dstIdx = 0, shift = fillBits;
-
-MSG_DEBUG("dataLen = %d", dataLen);
-
- if (shift > 0)
- srcIdx = 1;
-
- for (; dstIdx < dataLen; dstIdx++) {
- if (shift == 0) {
- pUnpackData[dstIdx] = pTpdu[srcIdx] & 0x7F;
-
- shift = 7;
- srcIdx++;
- dstIdx++;
-
- if (dstIdx >= dataLen)
- break;
- }
-
- if (shift > 0) {
- pUnpackData[dstIdx] = (pTpdu[srcIdx-1] >> shift) + (pTpdu[srcIdx] << (8 - shift));
-
- pUnpackData[dstIdx] &= 0x7F;
-
- shift--;
-
- if (shift > 0)
- srcIdx++;
- }
- }
-
- return dstIdx;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#include "MsgDebug.h"
-#include "MsgCppTypes.h"
-#include "MsgGconfWrapper.h"
-#include "MsgException.h"
-#include "MsgUtilFile.h"
-#include "SmsPluginStorage.h"
-#include "SmsPluginTransport.h"
-#include "SmsPluginEventHandler.h"
-#include "SmsPluginWapPushHandler.h"
-
-#include <glib.h>
-#include <gio/gio.h>
-#if MSG_DRM_SUPPORT
-#include <drm_client.h>
-#endif
-
-static unsigned short wapPushPortList[] = {0x0b84, 0x0b85, 0x23F0, 0x23F1, 0x23F2, 0x23F3, 0xC34F};
-
-#if 0
-const SMS_PUSH_APP_INFO_S pushDefaultApplication[] =
-{
- {(char*)"text/vnd.wap.si", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SI},
- {(char*)"application/vnd.wap.sic", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SIC},
- {(char*)"text/vnd.wap.sl", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SL},
- {(char*)"application/vnd.wap.slc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_SLC},
- {(char*)"text/vnd.wap.co", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_CO},
- {(char*)"application/vnd.wap.coc", (char*)"X-Wap-Application-Id: x-wap-application:wml.ua\r\n", SMS_WAP_APPLICATION_PUSH_COC},
-
- {(char*)"application/vnd.wap.mms-message", (char*)"X-Wap-Application-Id: x-wap-application:mms.ua\r\n", SMS_WAP_APPLICATION_MMS_UA},
-
- {(char*)"application/vnd.wap.sia", (char*)"X-Wap-Application-Id: x-wap-application:push.sia\r\n", SMS_WAP_APPLICATION_PUSH_SIA},
-
- {(char*)"application/vnd.syncml.dm+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP},
- {(char*)"application/vnd.syncml.dm+xml", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML},
- {(char*)"application/vnd.syncml.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.dm\r\n", SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION},
- {(char*)"application/vnd.syncml.ds.notification", (char*)"X-Wap-Application-Id: x-wap-application:push.syncml.ds\r\n", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION},
- {(char*)"application/vnd.syncml+wbxml", (char*)"X-Wap-Application-Id:x-wap-application:push.syncml", SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML},
-
- {(char*)"application/vnd.wap.locc+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_WBXML},
- {(char*)"application/vnd.wap.loc+xml", (char*)"X-Wap-Application-Id: x-wap-application:loc.ua\r\n", SMS_WAP_APPLICATION_LOC_UA_XML},
-
- {(char*)"application/vnd.oma.dd+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_XML},
- {(char*)"application/vnd.oma.drm.message", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_MESSAGE},
- {(char*)"application/vnd.oma.drm.content", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_CONETENT},
- {(char*)"application/vnd.oma.drm.rights+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML},
- {(char*)"application/vnd.oma.drm.rights+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML},
- {(char*)"application/vnd.oma.drm.ro+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_RO_XML},
- {(char*)"application/vnd.oma.drm.roap-pdu+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML},
- {(char*)"application/vnd.oma.drm.roap-trigger+xml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML},
- {(char*)"application/vnd.oma.drm.roap-trigger+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:drm.ua\r\n", SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML},
-
- {(char*)"text/vnd.wap.connectivity-xml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML},
- {(char*)"application/vnd.wap.connectivity-wbxml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML},
-
- {(char*)"application/x-wap-prov.browser-settings", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS},
- {(char*)"application/x-wap-prov.browser-bookmarks", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS},
- {(char*)"application/x-wap-prov.syncset+xml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_SYNCSET_WBXML},
- {(char*)"application/x-wap-prov.syncset+wbxml", (char*)"X-Wap-Application-Id: x-wap-samsung:provisioning.ua\r\n", SMS_WAP_APPLICATION_PUSH_SYNCSET_XML},
- {(char*)"text/vnd.wap.emn+xml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_XML},
- {(char*)"application/vnd.wap.emn+wbxml", (char*)"X-Wap-Application-Id: x-wap-application:emn.ua\r\n", SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML},
- {(char*)"application/vnd.wv.csp.cir", (char*)"X-Wap-Application-Id: x-wap-application:wv.ua\r\n", SMS_WAP_APPLICATION_PUSH_IMPS_CIR},
- {(char*)"application/vnd.omaloc-supl-init", (char*)"X-Wap-Application-Id: x-oma-application:ulp.ua\r\n", SMS_WAP_APPLICATION_LBS},
- {NULL, NULL}
-};
-#endif
-
-char gWapCodeBufferLeft[WSP_CODE_BUFFER_LEFT_LEN_MAX];
-char gWapCodeBufferRight[WSP_CODE_BUFFER_RIGHT_LEN_MAX];
-
-const unsigned long wspUintvarDecodeTable[] = { 0x00000001, 0x00000080, 0x00004000, 0x00200000, 0x10000000 };
-
-const unsigned char wspHeaderFieldCount = 0x43;
-const unsigned char wspContentsTypeCount = 0x34;
-const unsigned long wspLanguageCount = 0x11a;
-const unsigned char wspSecurityTypeCount = 0x04;
-
-
-static const SMS_WSP_CONTENTS_TYPE_S wspExtendedContentsType[] = {
- { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
- { (char*)"application/vnd.wap.connectivity-wbxml", 0x36 },
- { (char*)"application/pkcs7-mime", 0x37 },
- { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
- { (char*)"application/vnd.wap.signed-certificate", 0x39 },
- { (char*)"application/vnd.wap.cert-response", 0x3A },
- { (char*)"application/xhtml+xml", 0x3B },
- { (char*)"application/wml+xml", 0x3C },
- { (char*)"text/css", 0x3D },
-
- { (char*)"application/vnd.wap.mms-message", 0x3E },
-
- { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
- { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
- { (char*)"application/vnd.wap.loc+xml", 0x41 },
- { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
- { (char*)"application/vnd.syncml.dm+xml", 0x43 },
- { (char*)"application/vnd.syncml.notification", 0x44 },
- { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
- { (char*)"application/vnd.wv.csp.cir", 0x46 },
-
- { (char*)"application/vnd.oma.dd+xml", 0x47},
- { (char*)"application/vnd.oma.drm.message", 0x48 },
- { (char*)"application/vnd.oma.drm.content", 0x49 },
- { (char*)"application/vnd.oma.drm.rights+xml", 0x4A },
- { (char*)"application/vnd.oma.drm.rights+wbxml", 0x4B },
- { (char*)"application/vnd.syncml.ds.notification", 0x4E},
- { (char*)"application/mikey", 0x52},
- { (char*)"", 0xff }
-};
-
-
-const char* wspHeaderFieldName[] = {
- (char*)"Accept", /* 0x00 */
- (char*)"Accept-Charset",
- (char*)"Accept-Encoding",
- (char*)"Accept-Language",
- (char*)"Accept-Ranges",
- (char*)"Age", /* 0x05 */
- (char*)"Allow",
- (char*)"Authorization",
- (char*)"Cache-Control",
- (char*)"Connection",
- (char*)"Content-Base", /* 0x0a */
- (char*)"Content-Encoding",
- (char*)"Content-Language",
- (char*)"Content-Length",
- (char*)"Content-Location",
- (char*)"Content-MD5",
- (char*)"Content-Range", /* 0x10 */
- (char*)"Content-Type",
- (char*)"Date",
- (char*)"ETag",
- (char*)"Expires",
- (char*)"From", /* 0x15 */
- (char*)"Host",
- (char*)"If-Modified-Since",
- (char*)"If-Match",
- (char*)"If-None-Match",
- (char*)"If-Range", /* 0x1a */
- (char*)"If-Unmodified-Since",
- (char*)"Location",
- (char*)"Last-Modified",
- (char*)"Max-Forwards",
- (char*)"Pragma",
- (char*)"Proxy-Authenticate", /* 0x20 */
- (char*)"Proxy-Authorization",
- (char*)"Public",
- (char*)"Range",
- (char*)"Referer",
- (char*)"Retry-After", /* 0x25 */
- (char*)"Server",
- (char*)"Transfer-Encodig",
- (char*)"Upgrade",
- (char*)"User-Agent",
- (char*)"Vary", /* 0x2a */
- (char*)"Via",
- (char*)"Warning",
- (char*)"Www-Authenticate",
- (char*)"Content-Disposition",
- (char*)"X-Wap-Application-Id",
- (char*)"X-Wap-Content-URI", /* 0x30 */
- (char*)"X-Wap-Iinitiator-URI",
- (char*)"Accept-Application", /* Back */
- (char*)"Bearer-Indication",
- (char*)"Push-Flag",
- (char*)"Profile", /* 0x35 */
- (char*)"Profile-Diff",
- (char*)"Profile-Warning", /* end of WAP 1.2 */
- (char*)"Expect",
- (char*)"Te",
- (char*)"Trailer", /* 0x3a */
- (char*)"Accept-Charset", /* Back */
- (char*)"Accept-Encoding", /* Back */
- (char*)"Cache-Control", /* back */
- (char*)"Content-Range",
- (char*)"X-Wap-Tod",
- (char*)"Content-ID", /* 0x40 */
- (char*)"Set-Cookie",
- (char*)"Cookie",
- (char*)"Encoding-Version"
-};
-
-
-const SMS_WSP_CHARSET_S wspCharset[] = {
- { (char*)"big5", 0x07ea },
- { (char*)"iso-10646-ucs-2", 0x03e8 },
- { (char*)"iso-8859-1", 0x04 },
- { (char*)"iso-8859-2", 0x05 },
- { (char*)"iso-8859-3", 0x06 },
- { (char*)"iso-8859-4", 0x07 },
- { (char*)"iso-8859-5", 0x08 },
- { (char*)"iso-8859-6", 0x09 },
- { (char*)"iso-8859-7", 0x0a },
- { (char*)"iso-8859-8", 0x0b },
- { (char*)"iso-8859-9", 0x0c },
- { (char*)"shift-JIS", 0x11 },
- { (char*)"us-ascii", 0x03 },
- { (char*)"utf-8", 0x6a },
- { (char*)"none", 0x26 },
- { (char*)"", 0xffff }
-};
-
-
-
-const char* wspEncodeMethod[] = {
- (char*)"Gzip",
- (char*)"Compress",
- (char*)"Deflate"
-};
-
-
-const SMS_WSP_CONTENTS_TYPE_S wspContentsType[] = {
- { (char*)"*/*", 0x00 },
- { (char*)"text/*", 0x01 },
- { (char*)"text/html", 0x02 },
- { (char*)"text/plain", 0x03 },
- { (char*)"text/x-hdml", 0x04 },
- { (char*)"text/x-ttml", 0x05 },
- { (char*)"text/x-vCalendar", 0x06 },
- { (char*)"text/x-vCard", 0x07 },
- { (char*)"text/vnd.wap.wml", 0x08 },
- { (char*)"text/vnd.wap.wmlscript", 0x09 },
- { (char*)"text/vnd.wap.wta-event", 0x0a },
- { (char*)"multipart/*", 0x0b },
- { (char*)"multipart/mixed", 0x0c },
- { (char*)"multipart/form-data", 0x0d },
- { (char*)"multipart/byteranges", 0x0e },
- { (char*)"multipart/alternative", 0x0f },
- { (char*)"application/*", 0x10 },
- { (char*)"application/java-vm", 0x11 },
- { (char*)"application/x-www-form-urlencoded", 0x12 },
- { (char*)"application/x-hdmlc", 0x13 },
- { (char*)"application/vnd.wap.wmlc", 0x14 },
- { (char*)"application/vnd.wap.wmlscriptc", 0x15 },
- { (char*)"application/vnd.wap.wta-eventc", 0x16 },
- { (char*)"application/vnd.wap.uaprof", 0x17 },
- { (char*)"application/vnd.wap.wtls-ca-certificate", 0x18 },
- { (char*)"application/vnd.wap.wtls-user-certificate", 0x19 },
- { (char*)"application/x-x509-ca-cert", 0x1a },
- { (char*)"application/x-x509-user-cert", 0x1b },
- { (char*)"image/*", 0x1c },
- { (char*)"image/gif", 0x1d },
- { (char*)"image/jpeg", 0x1e },
- { (char*)"image/tiff", 0x1f },
- { (char*)"image/png", 0x20 },
- { (char*)"image/vnd.wap.wbmp", 0x21 },
- { (char*)"application/vnd.wap.multipart.*", 0x22 },
- { (char*)"application/vnd.wap.multipart.mixed", 0x23 },
- { (char*)"application/vnd.wap.multipart.form-data", 0x24 },
- { (char*)"application/vnd.wap.multipart.byteranges", 0x25 },
- { (char*)"application/vnd.wap.multipart.alternative", 0x26 },
- { (char*)"application/xml", 0x27 },
- { (char*)"text/xml", 0x28 },
- { (char*)"application/vnd.wap.wbxml", 0x29 },
- { (char*)"application/x-x968-cross-cert", 0x2a },
- { (char*)"application/x-x968-ca-cert", 0x2b },
- { (char*)"application/x-x968-user-cert", 0x2c },
- { (char*)"text/vnd.wap.si", 0x2d },
- { (char*)"application/vnd.wap.sic", 0x2e },
- { (char*)"text/vnd.wap.sl", 0x2f },
- { (char*)"application/vnd.wap.slc", 0x30 },
- { (char*)"text/vnd.wap.co", 0x31 },
- { (char*)"application/vnd.wap.coc", 0x32 },
- { (char*)"application/vnd.wap.multipart.related", 0x33 },
- { (char*)"application/vnd.wap.sia", 0x34 },
-
- { (char*)"text/vnd/wap/connectivity-xml", 0x35 },
- { (char*)"application/vnd.connectivity-wbxml", 0x36 },
- { (char*)"application/pkcs7-mime", 0x37 },
- { (char*)"application/vnd.wap.hashed-certificate", 0x38 },
- { (char*)"application/vnd.wap.signed-certificate", 0x39 },
- { (char*)"application/vnd.wap.cert-response", 0x3A },
- { (char*)"application/xhtml+xml", 0x3B },
- { (char*)"application/wml+xml", 0x3C },
- { (char*)"text/css", 0x3D },
-
- { (char*)"application/vnd.wap.mms-message", 0x3E },
-
- { (char*)"application/vnd.wap.rollover-certificate", 0x3F },
- { (char*)"application/vnd.wap.locc+wbxml", 0x40 },
- { (char*)"application/vnd.wap.loc+xml", 0x41 },
- { (char*)"application/vnd.syncml.dm+wbxml", 0x42 },
- { (char*)"application/vnd.syncml.dm+xml", 0x43 },
- { (char*)"application/vnd.syncml.notification", 0x44 },
- { (char*)"application/vnd.wap.xhtml+xml", 0x45 },
- { (char*)"application/vnd.wv.csp.cir", 0x46 }
-};
-
-static const SMS_WAP_UNREGISTER_CONTENTS_TYPE_S wspUnregisterContentsType[]= {
- { (char*)"application/vnd.wap.emn+wbxml", 0x30A},
- { (char*)"application/vnd.omaloc-supl-init", 0x312},
- { (char*)"application/vnd.oma.drm.roap-trigger+wbxml", 0x316}
-};
-
-const unsigned long wspUnregisteredContentsTypeCount = sizeof(wspUnregisterContentsType)/sizeof(SMS_WAP_UNREGISTER_CONTENTS_TYPE_S);
-
-const SMS_WSP_LANGUAGE_S wspLanguage[] = {
- { (char*)"English", 0x19 },
- { (char*)"en", 0x19 },
- { (char*)"Korean", 0x3d },
- { (char*)"*", 0x00 },
- { (char*)"Afar", 0x01 },
- { (char*)"aa", 0x01 },
- { (char*)"Abkhazian", 0x02 },
- { (char*)"ab", 0x02 },
- { (char*)"Afrikaans", 0x03 },
- { (char*)"af", 0x03 },
- { (char*)"Amharic", 0x04 },
- { (char*)"am", 0x04 },
- { (char*)"Arabic", 0x05 },
- { (char*)"ar", 0x05 },
- { (char*)"Assamese", 0x06 },
- { (char*)"as", 0x06 },
- { (char*)"Aymara", 0x07 },
- { (char*)"ay", 0x07 },
- { (char*)"Azerbaijani", 0x08 },
- { (char*)"az", 0x08 },
- { (char*)"Bashkir", 0x09 },
- { (char*)"ba", 0x09 },
- { (char*)"Byelorussian", 0x0a },
- { (char*)"be", 0x0a },
- { (char*)"Bulgarian", 0x0b },
- { (char*)"bg", 0x0b },
- { (char*)"Bihari", 0x0c },
- { (char*)"bh", 0x0c },
- { (char*)"Bislama", 0x0d },
- { (char*)"bi", 0x0f },
- { (char*)"Bengali", 0x0e },
- { (char*)"Bangla", 0x0e },
- { (char*)"bn", 0x0e },
- { (char*)"Tibetan", 0x0f },
- { (char*)"bo", 0x0f },
- { (char*)"Breton", 0x10 },
- { (char*)"br", 0x10 },
- { (char*)"Catalan", 0x11 },
- { (char*)"ca", 0x11 },
- { (char*)"Corsican", 0x12 },
- { (char*)"co", 0x12 },
- { (char*)"Czech", 0x13 },
- { (char*)"cs", 0x13 },
- { (char*)"Welsh", 0x14 },
- { (char*)"cy", 0x14 },
- { (char*)"Denish", 0x15 },
- { (char*)"da", 0x15 },
- { (char*)"German", 0x16 },
- { (char*)"de", 0x16 },
- { (char*)"Bhutani", 0x17 },
- { (char*)"dz", 0x17 },
- { (char*)"Greek", 0x18 },
- { (char*)"el", 0x18 },
- { (char*)"Esperanto", 0x81 },
- { (char*)"eo", 0x1a },
- { (char*)"Spanish", 0x1b },
- { (char*)"es", 0x1b },
- { (char*)"Estonian", 0x1c },
- { (char*)"et", 0x1c },
- { (char*)"Basque", 0x1d },
- { (char*)"eu", 0x1d },
- { (char*)"Persian", 0x1e },
- { (char*)"fa", 0x1e },
- { (char*)"Finnish", 0x1f },
- { (char*)"fi", 0x1f },
- { (char*)"Fiji", 0x20 },
- { (char*)"fj", 0x20 },
- { (char*)"Faeroese", 0x82 },
- { (char*)"fo", 0x82 },
- { (char*)"French", 0x22 },
- { (char*)"fr", 0x22 },
- { (char*)"Frisian", 0x83 },
- { (char*)"fy", 0x83 },
- { (char*)"Irish", 0x24 },
- { (char*)"ga", 0x24 },
- { (char*)"Scots Gaelic", 0x25 },
- { (char*)"gd", 0x25 },
- { (char*)"Galician", 0x26 },
- { (char*)"gl", 0x26 },
- { (char*)"Guarani", 0x27 },
- { (char*)"gn", 0x27 },
- { (char*)"Gujarati", 0x28 },
- { (char*)"gu", 0x28 },
- { (char*)"Hausa", 0x29 },
- { (char*)"ha", 0x29 },
- { (char*)"Hebrew", 0x2a },
- { (char*)"he", 0x2a },
- { (char*)"Hindi", 0x2b },
- { (char*)"hi", 0x2b },
- { (char*)"Croatian", 0x2c },
- { (char*)"hr", 0x2c },
- { (char*)"Hungarian", 0x2d },
- { (char*)"hu", 0x2d },
- { (char*)"Armenian", 0x2e },
- { (char*)"hy", 0x2e },
- { (char*)"Interlingua", 0x84 },
- { (char*)"ia", 0x84 },
- { (char*)"Indonesian", 0x30 },
- { (char*)"id", 0x30 },
- { (char*)"Interlingue", 0x86 },
- { (char*)"ie", 0x86 },
- { (char*)"Maori", 0x47 },
- { (char*)"mi", 0x47 },
- { (char*)"Macedonian", 0x48 },
- { (char*)"mk", 0x48 },
- { (char*)"Malayalam", 0x49 },
- { (char*)"ml", 0x49 },
- { (char*)"Mongolian", 0x4a },
- { (char*)"mn", 0x4a },
- { (char*)"Moldavian", 0x4b },
- { (char*)"mo", 0x4d },
- { (char*)"Marathi", 0x4c },
- { (char*)"mr", 0x4c },
- { (char*)"Malay", 0x4d },
- { (char*)"ms", 0x4d },
- { (char*)"Maltese", 0x4e },
- { (char*)"mt", 0x4e },
- { (char*)"Burmese", 0x4f },
- { (char*)"my", 0x4f },
- { (char*)"Nauru", 0x50 },
- { (char*)"na", 0x50 },
- { (char*)"Nepali", 0x51 },
- { (char*)"ne", 0x51 },
- { (char*)"Dutch", 0x52 },
- { (char*)"nl", 0x52 },
- { (char*)"Norwegian", 0x53 },
- { (char*)"no", 0x53 },
- { (char*)"Occitan", 0x54 },
- { (char*)"oc", 0x54 },
- { (char*)"(Afan) Oromo", 0x55 },
- { (char*)"(Afan)Oromo", 0x55 },
- { (char*)"om", 0x55 },
- { (char*)"Oriya", 0x56 },
- { (char*)"or", 0x56 },
- { (char*)"Punjabi", 0x57 },
- { (char*)"pa", 0x57 },
- { (char*)"Polish", 0x58 },
- { (char*)"po", 0x58 },
- { (char*)"Pashto", 0x59 },
- { (char*)"Pushto", 0x59 },
- { (char*)"ps", 0x59 },
- { (char*)"Portugurse", 0x5a },
- { (char*)"pt", 0x5a },
- { (char*)"Quechua", 0x5b },
- { (char*)"qu", 0x5b },
- { (char*)"Rhaeto-Romance", 0x8c },
- { (char*)"rm", 0x8c },
- { (char*)"Kirundi", 0x5d },
- { (char*)"rn", 0x5d },
- { (char*)"Romanian", 0x5e },
- { (char*)"ro", 0x5e },
- { (char*)"Russian", 0x5f },
- { (char*)"ru", 0x5f },
- { (char*)"Kinyarwanda", 0x60 },
- { (char*)"rw", 0x60 },
- { (char*)"Sanskrit", 0x61 },
- { (char*)"sa", 0x61 },
- { (char*)"Sindhi", 0x62 },
- { (char*)"sd", 0x62 },
- { (char*)"Sangho", 0x63 },
- { (char*)"sg", 0x63 },
- { (char*)"Serbo-Croatian", 0x64 },
- { (char*)"sh", 0x64 },
- { (char*)"Sinhalese", 0x65 },
- { (char*)"si", 0x65 },
- { (char*)"Slovak", 0x66 },
- { (char*)"sk", 0x66 },
- { (char*)"Slovenian", 0x67 },
- { (char*)"sl", 0x67 },
- { (char*)"Samoan", 0x68 },
- { (char*)"sm", 0x68 },
- { (char*)"Shona", 0x69 },
- { (char*)"sn", 0x69 },
- { (char*)"Somali", 0x6a },
- { (char*)"so", 0x6a },
- { (char*)"Albanian", 0x6b },
- { (char*)"sq", 0x6b },
- { (char*)"Serbian", 0x6c },
- { (char*)"sr", 0x6c },
- { (char*)"Siswati", 0x6d },
- { (char*)"ss", 0x6d },
- { (char*)"Sesotho", 0x6e },
- { (char*)"st", 0x6e },
- { (char*)"Sundanese", 0x6f },
- { (char*)"su", 0x6f },
- { (char*)"Swedish", 0x70 },
- { (char*)"sv", 0x70 },
- { (char*)"Swahili", 0x71 },
- { (char*)"sw", 0x71 },
- { (char*)"Tamil", 0x72 },
- { (char*)"ta", 0x72 },
- { (char*)"Telugu", 0x73 },
- { (char*)"te", 0x73 },
- { (char*)"Tajik", 0x74 },
- { (char*)"tg", 0x74 },
- { (char*)"Thai", 0x75 },
- { (char*)"th", 0x75 },
- { (char*)"Tigrinya", 0x76 },
- { (char*)"ti", 0x76 },
- { (char*)"Turkmen", 0x77 },
- { (char*)"tk", 0x77 },
- { (char*)"Inupiak", 0x87 },
- { (char*)"ik", 0x87 },
- { (char*)"Icelandic", 0x33 },
- { (char*)"is", 0x33 },
- { (char*)"Italian", 0x34 },
- { (char*)"it", 0x34 },
- { (char*)"Inuktitut", 0x89 },
- { (char*)"iu", 0x89 },
- { (char*)"Japanese", 0x36 },
- { (char*)"ja", 0x36 },
- { (char*)"Javanese", 0x37 },
- { (char*)"jw", 0x37 },
- { (char*)"Georgian", 0x38 },
- { (char*)"ka", 0x38 },
- { (char*)"Kazakh", 0x39 },
- { (char*)"kk", 0x39 },
- { (char*)"Gerrnlandic", 0x8a },
- { (char*)"kl", 0x8a },
- { (char*)"Cambodian", 0x3b },
- { (char*)"km", 0x3b },
- { (char*)"Kannada", 0x3c },
- { (char*)"kn", 0x3c },
- { (char*)"Kashmiri", 0x3e },
- { (char*)"ks", 0x3e },
- { (char*)"Kurdish", 0x3f },
- { (char*)"ku", 0x3f },
- { (char*)"Kirghiz", 0x40 },
- { (char*)"ky", 0x40 },
- { (char*)"Latin", 0x8b },
- { (char*)"la", 0x8b },
- { (char*)"Lingala", 0x42 },
- { (char*)"ln", 0x42 },
- { (char*)"Laothian", 0x43 },
- { (char*)"lo", 0x43 },
- { (char*)"Lithuanian", 0x44 },
- { (char*)"lt", 0x44 },
- { (char*)"Lavian", 0x45 },
- { (char*)"Lettish", 0x45 },
- { (char*)"lv", 0x45 },
- { (char*)"Malagasy", 0x46 },
- { (char*)"mg", 0x46 },
- { (char*)"Tagalog", 0x78 },
- { (char*)"tl", 0x78 },
- { (char*)"Setswana", 0x79 },
- { (char*)"tn", 0x79 },
- { (char*)"Tonga", 0x7a },
- { (char*)"to", 0x7a },
- { (char*)"Turkish", 0x7b },
- { (char*)"tr", 0x7b },
- { (char*)"Tsonga", 0x7c },
- { (char*)"ts", 0x7c },
- { (char*)"Tatar", 0x7d },
- { (char*)"tt", 0x7d },
- { (char*)"Twi", 0x7e },
- { (char*)"tw", 0x7e },
- { (char*)"Uighur", 0x7f },
- { (char*)"ug", 0x7f },
- { (char*)"Ukrainian", 0x1a },
- { (char*)"uk", 0x1a },
- { (char*)"Urdu", 0x21 },
- { (char*)"ur", 0x21 },
- { (char*)"Uzbek", 0x23 },
- { (char*)"uz", 0x23 },
- { (char*)"Vietnamese", 0x2f },
- { (char*)"vi", 0x2f },
- { (char*)"Volapuk", 0x85 },
- { (char*)"vo", 0x85 },
- { (char*)"Wolof", 0x31 },
- { (char*)"wo" , 0x31 },
- { (char*)"Xhosa", 0x32 },
- { (char*)"xh", 0x32 },
- { (char*)"Yiddish", 0x88 },
- { (char*)"yi", 0x88 },
- { (char*)"Yoruba", 0x35 },
- { (char*)"yo", 0x35 },
- { (char*)"Zhuang", 0x3a },
- { (char*)"z", 0x3a },
- { (char*)"Chinese", 0x41 },
- { (char*)"ch", 0x41 },
- { (char*)"Zulu", 0x5c },
- { (char*)"zu", 0x5c },
- { (char*)"Ko", 0x3d }
-};
-
-
-const SMS_WSP_HEADER_PARAMETER_S wspHeaderApplId[] = {
- { (char*)"x-wap-application:*", 0x00 },
- { (char*)"x-wap-application:push.sia", 0x01},
- { (char*)"x-wap-application:wml.ua", 0x02 },
- { (char*)"x-wap-application:wta.ua", 0x03 },
- { (char*)"x-wap-application:mms.ua", 0x04 },
- { (char*)"x-wap-application:push.syncml", 0x05 },
- { (char*)"x-wap-application:loc.ua", 0x06 },
- { (char*)"x-wap-application:syncml.dm", 0x07 },
- { (char*)"x-wap-application:drm.ua", 0x08 },
- { (char*)"x-wap-application:emn.ua", 0x09 },
- { (char*)"x-oma-application:ulp.ua ", 0x10 },
- { (char*)"x-oma-docomo:open.ctl", 0x9055 },
- { (char*)"x-oma-docomo:xmd.mail.ua", 0x905C },
- { (char*)"x-oma-docomo:xmd.storage.ua", 0x905F },
- { (char*)"x-oma-docomo:xmd.lcsapp.ua", 0x9060 },
- { (char*)"x-oma-docomo:xmd.info.ua", 0x9061 },
- { (char*)"x-oma-docomo:xmd.agent.ua", 0x9062 },
- { (char*)"x-oma-docomo:xmd.sab.ua", 0x9063 },
- { (char*)"x-oma-docomo:xmd.am.ua", 0x9064 },
- { (char*)"x-oma-docomo:xmd.emdm.ua", 0x906B },
- { (char*)"x-oma-docomo:xmd.lac.ua", 0x906C },
- { (char*)"x-oma-docomo:xmd.osv.ua", 0x906D },
- { (char*)"x-oma-docomo:xmd.dcs.ua", 0x906E },
- { (char*)"x-oma-docomo:xmd.wipe.ua", 0x906F },
- { (char*)"x-oma-docomo:xmd.vdapp.ua ", 0x9070 },
-};
-
-
-const char* wspCacheControl[] = {
- (char*)"No-cache",
- (char*)"No-store",
- (char*)"Max-age",
- (char*)"Max-stale",
- (char*)"Min-fresh",
- (char*)"Only-if-cached",
- (char*)"Public",
- (char*)"Private",
- (char*)"No-transform",
- (char*)"Must-revalidate",
- (char*)"Proxy-revalidate"
-};
-
-const SMS_WSP_METHOD_TYPE_S wspMethodType[] = {
- { (char*)"GET", 0x40 },
- { (char*)"OPTIONS", 0x41 },
- { (char*)"HEAD", 0x42 },
- { (char*)"DELETE", 0x43 },
- { (char*)"TRACE", 0x44 },
- { (char*)"POST", 0x60 },
- { (char*)"PUT", 0x61 }
-};
-
-
-const SMS_WSP_SECURITY_TYPE_S wspSecurityType[] = {
- {(char*)"NETWPIN", 0x00},
- {(char*)"USERPIN", 0x01},
- {(char*)"USERNETWPIN", 0x02},
- {(char*)"USERPINMAC", 0x03}
-};
-
-
-
-const char* wspWeek[] = {
- (char*)"Sun",
- (char*)"Mon",
- (char*)"Tue",
- (char*)"Wed",
- (char*)"Thu",
- (char*)"Fri",
- (char*)"Sat"
-};
-
-
-const char* wspWeekDay[] = {
- (char*)"Sunday",
- (char*)"Monday",
- (char*)"Tuesday",
- (char*)"Wednesday",
- (char*)"Thursday",
- (char*)"Friday",
- (char*)"Saturday"
-};
-
-const char* wspMonth[] = {
- (char*)"Jan",
- (char*)"Feb",
- (char*)"Mar",
- (char*)"Apr",
- (char*)"May",
- (char*)"Jun",
- (char*)"Jul",
- (char*)"Aug",
- (char*)"Sep",
- (char*)"Oct",
- (char*)"Nov",
- (char*)"Dec"
-};
-
-
-
-/*==================================================================================================
- IMPLEMENTATION OF SmsPluginWapPushHandler - Member Functions
-==================================================================================================*/
-SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL;
-
-
-SmsPluginWapPushHandler::SmsPluginWapPushHandler()
-{
- memset(&tmpAddress, 0x00, sizeof(tmpAddress));
- memset(&tmpTimeStamp, 0x00, sizeof(tmpTimeStamp));
-}
-
-
-SmsPluginWapPushHandler::~SmsPluginWapPushHandler()
-{
-}
-
-
-SmsPluginWapPushHandler* SmsPluginWapPushHandler::instance()
-{
- if (!pInstance)
- pInstance = new SmsPluginWapPushHandler();
-
- return pInstance;
-}
-
-
-bool SmsPluginWapPushHandler::IsWapPushMsg(SMS_USERDATA_S *pUserData)
-{
- MSG_BEGIN();
-
- if (pUserData == NULL) {
- MSG_DEBUG("pUserData is NULL");
- return false;
- }
-
- int PortCount = sizeof(wapPushPortList) / sizeof(wapPushPortList[0]);
-
- MSG_DEBUG("Port Count [%d]", PortCount);
-
- for (int i = 0; i < pUserData->headerCnt; i++) {
- if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_8BIT) {
- /** Have to check something??? */
- } else if (pUserData->header[i].udhType == SMS_UDH_APP_PORT_16BIT) {
- for (int j = 0; j < PortCount; j++) {
- if (pUserData->header[i].udh.appPort16bit.destPort == wapPushPortList[j]) {
- MSG_DEBUG("Wap Push Msg : [%04x]", wapPushPortList[j]);
- return true;
- }
- }
- }
- }
-
- MSG_END();
-
- return false;
-}
-
-#if 0
-SMS_WAP_APP_CODE_T SmsPluginWapPushHandler::getAppCode(const char *pPushHeader)
-{
- int appCount = sizeof(pushDefaultApplication)/sizeof(pushDefaultApplication[0]) - 1;
-
- unsigned char *header = NULL;
- SMS_WAP_APP_CODE_T appCode = SMS_WAP_APPLICATION_DEFAULT;
-
- MSG_DEBUG("Application Count [%d]", appCount);
-
- for (int i = 0; i < appCount; i++) {
- header = (unsigned char*)strcasestr(pPushHeader, pushDefaultApplication[i].pContentType);
-
- if (header != NULL) {
- appCode = pushDefaultApplication[i].appCode;
- break;
- }
- }
-
- if (appCode == SMS_WAP_APPLICATION_DEFAULT) {
- MSG_DEBUG("Application Type is not supported");
- } else {
- MSG_DEBUG("Find Application [%d]", appCode);
- }
-
- return appCode;
-}
-#endif
-
-
-void SmsPluginWapPushHandler::copyDeliverData(SMS_DELIVER_S *pDeliver)
-{
- tmpAddress.ton = pDeliver->originAddress.ton;
- tmpAddress.npi = pDeliver->originAddress.npi;
-
- strncpy(tmpAddress.address, pDeliver->originAddress.address, MAX_ADDRESS_LEN);
-
- MSG_SEC_DEBUG("Address [%s]", tmpAddress.address);
-
- tmpTimeStamp.format = pDeliver->timeStamp.format;
-
- if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
- tmpTimeStamp.time.absolute.year = pDeliver->timeStamp.time.absolute.year;
- tmpTimeStamp.time.absolute.month = pDeliver->timeStamp.time.absolute.month;
- tmpTimeStamp.time.absolute.day = pDeliver->timeStamp.time.absolute.day;
- tmpTimeStamp.time.absolute.hour = pDeliver->timeStamp.time.absolute.hour;
- tmpTimeStamp.time.absolute.minute = pDeliver->timeStamp.time.absolute.minute;
- tmpTimeStamp.time.absolute.second = pDeliver->timeStamp.time.absolute.second;
- tmpTimeStamp.time.absolute.timeZone = pDeliver->timeStamp.time.absolute.timeZone;
- }
-}
-
-
-void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSize, int simIndex, time_t sent_time)
-{
- MSG_BEGIN();
-
-#ifdef MSG_FW_FOR_DEBUG
- MSG_DEBUG("DataSize [%d]", DataSize);
-
- MSG_DEBUG("[pUserData]");
- for (int i = 0; i < DataSize; i++) {
- printf("[%02x]", pUserData[i]);
- }
- printf("\n\n");
-#endif
-
- unsigned char* pPDUTypeData = (unsigned char*)pUserData;
- unsigned long PDUTypeDataLen = DataSize;
-
- char* pPushHeader = NULL;
- unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter);
- unsigned long pushHeaderLen = 0;
-
- char* pPushBody = NULL;
- unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter);
- unsigned long pushBodyLen = 0;
-
- unsigned long iPDU = 1;
-
- char* pWspHeader = NULL;
- unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter);
- unsigned long wspHeaderLen = 0;
-
- char* pWspBody = NULL;
- unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter);
- unsigned long wspBodyLen = 0;
-
- /** pass PDU type */
- iPDU++;
-
- pushHeaderLen = wspRetriveUintvarDecode(pPDUTypeData, &iPDU);
-
- MSG_DEBUG("PDUTypeDataLen [%lu]", PDUTypeDataLen);
- MSG_DEBUG("pushHeaderLen [%lu]", pushHeaderLen);
- MSG_DEBUG("iPDU [%lu]", iPDU);
-
- wspHeaderLen = pushHeaderLen + iPDU;
-
- MSG_DEBUG("wspBodyLen [%lu]", wspBodyLen);
-
- if (wspHeaderLen > 0) {
- pWspHeader = new char[wspHeaderLen];
-
- if (pWspHeader == NULL) {
- MSG_DEBUG("pWspHeader Memory Allocation Failed");
- return;
- } else {
- memcpy(pWspHeader, pPDUTypeData, wspHeaderLen);
- }
- }
-
-#ifdef MSG_FW_FOR_DEBUG
- MSG_DEBUG("wspHeaderLen [%d]", wspHeaderLen);
-
- MSG_DEBUG("[pWspHeader]");
- for (int i = 0; i < wspHeaderLen; i++) {
- printf("[%02x]", pWspHeader[i]);
- }
- printf("\n\n");
-#endif
-
- /** return if it is below case error */
- if (PDUTypeDataLen < wspHeaderLen) {
- MSG_DEBUG("PDUTypeDataLen < wspHeaderLen !!!");
- return;
- }
-
- /** Finding wspBody Information */
- wspBodyLen = PDUTypeDataLen - wspHeaderLen;
-
- if (wspBodyLen > 0) {
- pWspBody = new char[wspBodyLen];
-
- if (pWspBody == NULL) {
- MSG_DEBUG("pWspBody Memory Allocation Failed");
- return;
- } else {
- memcpy(pWspBody, pPDUTypeData + wspHeaderLen, wspBodyLen);
- }
- } else {
- pWspBody = NULL;
- }
-
- wspDecodeHeader(pPDUTypeData + iPDU, pushHeaderLen, PDUTypeDataLen - (iPDU + pushHeaderLen), TRUE, &pPushHeader);
-
- iPDU = iPDU + pushHeaderLen;
-
- pushBodyLen = PDUTypeDataLen - iPDU ;
-
- if (pushBodyLen > 0) {
- pPushBody = new char[pushBodyLen];
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody Memory Allocation Failed");
- return;
- } else {
- memcpy(pPushBody, pPDUTypeData+ iPDU, pushBodyLen);
- }
- } else {
- pPushBody = NULL;
- return;
- }
-
- handleWapPushCallback((char *)pPushHeader, (char *)pPushBody, (int)pushBodyLen, (char *)pWspHeader, (int)wspHeaderLen, (char *)pWspBody, (int)wspBodyLen, simIndex, sent_time);
-
- MSG_END();
-}
-
-#if 0
-void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen)
-{
- MSG_BEGIN();
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- SMS_WAP_APP_CODE_T appCode = getAppCode(pPushHeader);
-
- /** check Push message receive setting */
- bool bPushRecv = false;
-
- if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- if ((bPushRecv == false) && (appCode != SMS_WAP_APPLICATION_MMS_UA)) {
- MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
- return;
- }
-
- switch (appCode) {
- case SMS_WAP_APPLICATION_MMS_UA:
- MSG_DEBUG("Received MMS Notification");
- handleMMSNotification(pPushBody, PushBodyLen);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SI:
- MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
- handleSIMessage(pPushBody, PushBodyLen, true);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SIC:
- MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
- handleSIMessage(pPushBody, PushBodyLen, false);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SL:
- MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
- handleSLMessage(pPushBody, PushBodyLen, true);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SLC:
- MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
- handleSLMessage(pPushBody, PushBodyLen, false);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_CO:
- MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
- handleCOMessage(pPushBody, PushBodyLen, true);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_COC:
- MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
- handleCOMessage(pPushBody, PushBodyLen, false);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
- MSG_DEBUG("Received DM Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen);
- break;
-
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
- MSG_DEBUG("Received DRM UA");
-
- if (pPushBody != NULL)
- handleDrmVer1(pPushBody, PushBodyLen);
-
- break;
-
- case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
- MSG_DEBUG("Received DRM V2");
- /* TODO: DRM V2 */
- break;
-
- case SMS_WAP_APPLICATION_PUSH_EMAIL:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
- MSG_DEBUG("Received Email");
- /* TODO: Email */
- break;
-
- case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
- MSG_DEBUG("Received IMPS CIR");
- /* TODO: IMPS CIR */
- break;
-
- case SMS_WAP_APPLICATION_LBS :
- MSG_DEBUG("Received LBS related message");
- SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
- /* TODO: LBS */
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SIA :
- MSG_DEBUG("Received SIA");
- /* TODO: SIA */
- break;
-
- default:
- MSG_DEBUG("Unknown Application [%d]", appCode);
- break;
- }
-
- MSG_END();
-}
-#else
-
-static void launchProcessByAppcode(int appcode)
-{
- MSG_BEGIN();
- GError *error = NULL;
- GDBusConnection *connection_agent = NULL;
- GDBusProxy *dbus_proxy_agent = NULL;
- GDBusConnection *connection_service = NULL;
- GDBusProxy *dbus_proxy_service = NULL;
- GVariant *result_agent = NULL;
- GVariant *result_service = NULL;
-
- switch (appcode) {
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION: {
- connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
- NULL, "org.tizen.omadmagent", "/org/tizen/omadmagent",
- "org.tizen.omadmagent", NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) {
- MSG_DEBUG("invoking agent proxy call failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- connection_service = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- dbus_proxy_service = g_dbus_proxy_new_sync(connection_service, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
- "org.tizen.omadmservice", "/org/tizen/omadmservice",
- "org.tizen.omadmservice", NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to service proxy failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- result_service = g_dbus_proxy_call_sync(dbus_proxy_service, "wakeup", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) {
- MSG_DEBUG("invoking service proxy call failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- MsgMutex mx;
- MsgCndVar cv;
- mx.lock();
- cv.timedwait(mx.pMsgMutex(), 2);
- mx.unlock();
-
- MSG_END();
- }
- break;
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML: {
- connection_agent = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to system bus failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- dbus_proxy_agent = g_dbus_proxy_new_sync(connection_agent, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
- "org.tizen.omadsagent", "/org/tizen/omadsagent",
- "org.tizen.omadsagent", NULL, &error);
- if (error) {
- MSG_DEBUG("Connecting to agent proxy failed: %s\n", error->message);
- goto _DBUS_ERROR;
- }
-
- result_agent = g_dbus_proxy_call_sync(dbus_proxy_agent, "Hello_Agent", NULL,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (error) {
- MSG_DEBUG("invoking service error: %s\n", error->message);
- goto _DBUS_ERROR;
- }
- }
- break;
- default:
- break;
- }
-
-_DBUS_ERROR:
- if (error) {
- g_error_free(error);
- error = NULL;
- }
-
- if (connection_agent) {
- g_object_unref(connection_agent);
- connection_agent = NULL;
- }
-
- if (dbus_proxy_agent) {
- g_object_unref(dbus_proxy_agent);
- dbus_proxy_agent = NULL;
- }
-
- if (result_agent) {
- g_object_unref(result_service);
- result_service = NULL;
- }
-
- if (connection_service) {
- g_object_unref(connection_service);
- connection_service = NULL;
- }
-
- if (dbus_proxy_service) {
- g_object_unref(dbus_proxy_service);
- dbus_proxy_service = NULL;
- }
-
- if (result_service) {
- g_object_unref(result_service);
- result_service = NULL;
- }
-
- MSG_END();
-}
-
-
-void SmsPluginWapPushHandler::handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex, time_t sent_time)
-{
- MSG_BEGIN();
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- msg_error_t err = MSG_SUCCESS;
- int pushEvt_cnt = 0;
- char app_id[MAX_WAPPUSH_ID_LEN] = {0, };
- char content_type[MAX_WAPPUSH_CONTENT_TYPE_LEN] = {0, };
- SmsPluginStorage *storageHandler = SmsPluginStorage::instance();
-
- err = storageHandler->getRegisteredPushEvent(pPushHeader, &pushEvt_cnt, app_id, sizeof(app_id), content_type, sizeof(content_type));
- MSG_DEBUG("pushEvt_cnt: %d", pushEvt_cnt);
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("Fail to get registered push event");
- return;
- }
-
- for (int i = 0; i < pushEvt_cnt; ++i) {
- /* check Push message receive setting */
- bool bPushRecv = false;
- int appcode = 0;
- if (MsgSettingGetBool(PUSH_RECV_OPTION, &bPushRecv) != MSG_SUCCESS)
- MSG_INFO("MsgSettingGetBool() is failed");
-
- storageHandler->getnthPushEvent(i, &appcode);
- MSG_DEBUG("pushEvt_cnt: %d, appcode: %d", pushEvt_cnt, appcode);
- if ((bPushRecv == false) && (IsWapPushMsgInWhiteList(appcode) == false)) {
- MSG_DEBUG("Push Message Receive option is OFF. Drop Push Message.");
- return;
- }
-
-#ifdef FEATURE_MMS_DISABLE
- if (appcode == SMS_WAP_APPLICATION_MMS_UA) {
- MSG_DEBUG("Drop MMS Notification for DOCOMO");
- return;
- }
-
-#endif
- launchProcessByAppcode(appcode);
-
- switch (appcode) {
- case SMS_WAP_APPLICATION_MMS_UA:
- MSG_DEBUG("Received MMS Notification");
- handleMMSNotification(pPushBody, PushBodyLen, simIndex, sent_time);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SI:
- MSG_DEBUG("Received WAP Push (Service Indication Textual form)");
- handleSIMessage(pPushBody, PushBodyLen, true, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SIC:
- MSG_DEBUG("Received WAP Push (Service Indication Tokenised form)");
- handleSIMessage(pPushBody, PushBodyLen, false, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SL:
- MSG_DEBUG("Received WAP Push (Service Loading Textual form)");
- handleSLMessage(pPushBody, PushBodyLen, true, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SLC:
- MSG_DEBUG("Received WAP Push (Service Loading Tokenised form)");
- handleSLMessage(pPushBody, PushBodyLen, false, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_CO:
- MSG_DEBUG("Received WAP Push (Cache Operation Textual form)");
- handleCOMessage(pPushBody, PushBodyLen, true, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_COC:
- MSG_DEBUG("Received WAP Push (Cache Operation Tokenised form)");
- handleCOMessage(pPushBody, PushBodyLen, false, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- MSG_DEBUG("Received DM BOOTSTRAP");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_XML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(CP_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- MSG_DEBUG("Received Provisioning");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(OTHERS, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
- MSG_DEBUG("Received DM Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DM_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_NOTIFICATION, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
- MSG_DEBUG("Received DS Notification");
- SmsPluginEventHandler::instance()->handleSyncMLMsgIncoming(DS_WBXML, pPushBody, PushBodyLen, pWspHeader, WspHeaderLen, simIndex);
- break;
-
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_XML:
- case SMS_WAP_APPLICATION_DRM_UA_RIGHTS_WBXML:
- MSG_DEBUG("Received DRM UA");
-
- if (pPushBody != NULL)
- handleDrmVer1(pPushBody, PushBodyLen);
-
- break;
-
- case SMS_WAP_APPLICATION_DRM_V2_RO_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_PDU_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_XML:
- case SMS_WAP_APPLICATION_DRM_V2_ROAP_TRIGGER_WBXML:
- MSG_DEBUG("Received DRM V2");
- /* TODO: DRM V2 */
- break;
-
- case SMS_WAP_APPLICATION_PUSH_EMAIL:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_XML:
- case SMS_WAP_APPLICATION_PUSH_EMAIL_WBXML:
- MSG_DEBUG("Received Email");
- /* TODO: Email */
- break;
-
-
- case SMS_WAP_APPLICATION_PUSH_IMPS_CIR:
- MSG_DEBUG("Received IMPS CIR");
- /* TODO: IMPS CIR */
- break;
-
- case SMS_WAP_APPLICATION_LBS:
- MSG_DEBUG("Received LBS related message");
- SmsPluginEventHandler::instance()->handleLBSMsgIncoming(pPushHeader, pPushBody, PushBodyLen);
- /* TODO: LBS */
- break;
-
- case SMS_WAP_APPLICATION_PUSH_SIA:
- MSG_DEBUG("Received SIA");
- /* TODO: SIA */
- break;
-
- default:
- SmsPluginEventHandler::instance()->handlePushMsgIncoming(pPushHeader, pPushBody, PushBodyLen, app_id, content_type);
- break;
- }
- }
- storageHandler->releasePushEvent();
-
- MSG_END();
-}
-#endif
-
-bool SmsPluginWapPushHandler::IsWapPushMsgInWhiteList(int appCode)
-{
- MSG_BEGIN();
-
- bool isAllowed = false;
-
- switch (appCode) {
- case SMS_WAP_APPLICATION_MMS_UA:
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP:
- case SMS_WAP_APPLICATION_SYNCML_DM_BOOTSTRAP_XML:
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_XML:
- case SMS_WAP_APPLICATION_PUSH_PROVISIONING_WBXML:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_SETTINGS:
- case SMS_WAP_APPLICATION_PUSH_BROWSER_BOOKMARKS:
- case SMS_WAP_APPLICATION_SYNCML_DM_NOTIFICATION:
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION:
- case SMS_WAP_APPLICATION_SYNCML_DS_NOTIFICATION_WBXML:
- MSG_INFO("appcode[%d] is allowed even if push receive option is disabled.", appCode);
- isAllowed = true;
- break;
- default:
- MSG_DEBUG("appcode[%d] is not allowed when push receive option is disabled.", appCode);
- break;
- }
-
- return isAllowed;
-}
-
-void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex, time_t sent_time)
-{
- MSG_BEGIN();
-
-#ifdef MSG_FW_FOR_DEBUG
- printf("\n\n[handleMMSNotification] Push Body.\n");
-
- for (int i = 0; i < PushBodyLen; i++) {
- printf(" [%02x]", pPushBody[i]);
- }
- printf("\n\n");
-#endif
-
- /** Make MSG_MESSAGE_INFO_S */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- /** Convert Type values */
- msgInfo.msgType.mainType = MSG_MMS_TYPE;
- msgInfo.msgType.subType = MSG_NOTIFICATIONIND_MMS;
- msgInfo.msgType.classType = MSG_CLASS_NONE;
- msgInfo.storageId = MSG_STORAGE_PHONE;
- msgInfo.dataSize = PushBodyLen;
- msgInfo.sim_idx = simIndex;
-
- if (sent_time > 0)
- msgInfo.displayTime = sent_time;
-
- if (msgInfo.dataSize > MAX_MSG_TEXT_LEN) {
- msgInfo.bTextSms = false;
-
- /** Save Message Data into File */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
-
- if (MsgWriteIpcFile(fileName, pPushBody, msgInfo.dataSize) == false)
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
- } else {
- msgInfo.bTextSms = true;
-
- memcpy(msgInfo.msgText, pPushBody, msgInfo.dataSize);
- msgInfo.msgText[msgInfo.dataSize] = '\0';
- }
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Add MMS Noti Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /** Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS) {
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
- }
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- MSG_END();
-}
-
-void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex)
-{
- MSG_BEGIN();
-
- MSG_PUSH_MESSAGE_S pushMsg = {};
-
- xmlDocPtr xmlDoc = NULL;
- xmlNodePtr topNode = NULL;
- xmlNodePtr indNode = NULL;
-
- xmlChar* tmpXmlChar = NULL;
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
- getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
-
- if (xmlDoc == NULL) {
- MSG_DEBUG("xmlDoc is NULL");
- return;
- }
-
- topNode = xmlDocGetRootElement(xmlDoc);
-
- if (topNode == NULL) {
- MSG_DEBUG("topNode is NULL");
- xmlFreeDoc(xmlDoc);
- return;
- }
-
- indNode = topNode->xmlChildrenNode;
-
- while (indNode != NULL) {
- if (!xmlStrcmp(indNode->name, (const xmlChar*) "indication")) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
- break;
- }
-
- indNode = indNode->next;
- }
-
- if (indNode == NULL) {
- MSG_DEBUG("indNode is NULL.");
- return;
- }
-
- /** temporary set to max. */
- pushMsg.expires = 0xFFFFFFFF;
-
- /** setting received time */
- time_t t = time(NULL);
- time_t utfTime = time(&t);
-
- pushMsg.received = (unsigned long)utfTime;
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
-
- if (tmpXmlChar == NULL) {
- MSG_DEBUG("href is NULL.");
- return;
- }
-
- if (tmpXmlChar != NULL)
- strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_SI_ID_TAG);
-
- if (tmpXmlChar != NULL)
- strncpy(pushMsg.id, (char*)tmpXmlChar, MAX_WAPPUSH_ID_LEN-1);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CREATED_TAG);
-
- if (tmpXmlChar != NULL)
- pushMsg.created = convertXmlCharToSec((char*)tmpXmlChar);
-
- if (pushMsg.created == 0)
- pushMsg.created = pushMsg.received;
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_EXPIRES_TAG);
-
- if (tmpXmlChar != NULL)
- pushMsg.expires = convertXmlCharToSec((char*)tmpXmlChar);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
-
- pushMsg.action = convertSIActionStrToEnum((char*)tmpXmlChar);
-
- tmpXmlChar = xmlNodeListGetString(xmlDoc, indNode->xmlChildrenNode, 1);
-
- if (tmpXmlChar == NULL) {
- MSG_DEBUG("contents is NULL.");
- return;
- }
-
- strncpy(pushMsg.contents, (char*)tmpXmlChar, MAX_WAPPUSH_CONTENTS_LEN-1);
-
- /** Write push Msg to file */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false) {
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
- }
-
- if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false) {
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
- }
-
- /** Pack Message Info Structure */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-
- /** Convert Type values */
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_WAP_SI_SMS;
-
- msgInfo.dataSize = sizeof(pushMsg);
- msgInfo.sim_idx = simIndex;
- getDisplayName(msgInfo.msgType.subType, msgInfo.addressList[0].addressVal);
-
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Add WAP Push Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /** Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- MSG_END();
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex)
-{
- MSG_BEGIN();
-
- MSG_PUSH_MESSAGE_S pushMsg = {};
-
- xmlDocPtr xmlDoc = NULL;
- xmlNodePtr topNode = NULL;
- xmlNodePtr indNode = NULL;
-
- xmlChar* tmpXmlChar = NULL;
-
- msg_error_t err = MSG_SUCCESS;
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL \n");
- return;
- }
-
- getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
-
- if (xmlDoc == NULL) {
- MSG_DEBUG("xmlDoc is NULL \n");
- return;
- }
-
- topNode = xmlDocGetRootElement(xmlDoc);
-
- if (topNode == NULL) {
- MSG_DEBUG("Empty Document.");
- xmlFreeDoc(xmlDoc);
- return;
- } else {
- MSG_SEC_DEBUG("Not an empty Document and topNode->name = %s \n", topNode->name);
- }
-
- indNode = topNode;
-
- while (indNode != NULL) {
- if (!xmlStrcmp(indNode->name, (const xmlChar*)"sl")) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
- break;
- }
-
- indNode = indNode->next;
- }
-
- /** setting received time setting */
- time_t t = time(NULL);
- time_t utfTime = time(&t);
-
- pushMsg.received = (unsigned long)utfTime;
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_HREF_TAG);
-
- if (tmpXmlChar == NULL) {
- MSG_DEBUG("href is NULL.");
- return;
- }
-
- strncpy(pushMsg.href, (char*)tmpXmlChar, MAX_WAPPUSH_HREF_LEN-1);
-
- tmpXmlChar = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_ACTION_TAG);
- pushMsg.action = convertSLActionStrToEnum((char*)tmpXmlChar);
-
- /** Setting other parameters in default values */
- pushMsg.created = pushMsg.received;
- /** temporary set to MAX value. */
- pushMsg.expires = 0xFFFFFFFF;
-
- MSG_DEBUG("check pushMsg data");
- MSG_DEBUG("pushMsg.action : [%d]", pushMsg.action);
- MSG_DEBUG("pushMsg.received : [%lu]", pushMsg.received);
- MSG_DEBUG("pushMsg.created : [%lu]", pushMsg.created);
- MSG_DEBUG("pushMsg.expires : [%lu]", pushMsg.expires);
- MSG_SEC_DEBUG("pushMsg.id : [%s]", pushMsg.id);
- MSG_DEBUG("pushMsg.href : [%s]", pushMsg.href);
- MSG_DEBUG("pushMsg.contents : [%s]", pushMsg.contents);
-
- /** Write push Msg to file */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false)
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
-
- if (MsgWriteIpcFile(fileName, (char*)(&pushMsg), sizeof(pushMsg)) == false)
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
-
- /** Pack Message Info Structure */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-
- /** Convert Type values */
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_WAP_SL_SMS;
-
- /** Update Msg Text */
- strncpy(msgInfo.msgText, pushMsg.href, MAX_MSG_TEXT_LEN);
-
- msgInfo.dataSize = sizeof(pushMsg);
- msgInfo.sim_idx = simIndex;
- getDisplayName(msgInfo.msgType.subType, msgInfo.addressList[0].addressVal);
-
- MSG_DEBUG("dataSize : %zu", msgInfo.dataSize);
-
- /** Add WAP Push Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /** Callback to MSG FW */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming is failed, err=[%d]", err);
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- xmlFree(xmlDoc);
- xmlFree(tmpXmlChar);
-
- MSG_END();
-
- return;
-}
-
-void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex)
-{
- MSG_PUSH_CACHEOP_S cacheOp;
-
- xmlDocPtr xmlDoc = NULL;
- xmlNodePtr topNode = NULL;
- xmlNodePtr indNode = NULL;
-
- memset(&cacheOp, 0x00, sizeof(cacheOp));
-
- MSG_DEBUG("Enter handleCOMessage");
-
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL \n");
- return;
- }
-
- getXmlDoc(pPushBody, PushBodyLen, &xmlDoc, isText);
-
- if (xmlDoc == NULL) {
- MSG_DEBUG("xmlDoc is NULL \n");
- return;
- }
-
- topNode = xmlDocGetRootElement(xmlDoc);
- if (topNode == NULL) {
- MSG_DEBUG("Warning:Empty Document\n");
- xmlFreeDoc(xmlDoc);
- return;
- }
-
- indNode = topNode->xmlChildrenNode;
-
-
- while (indNode != NULL) {
- xmlChar* tmpUrl = NULL;
- if (!xmlStrcmp(indNode->name, (const xmlChar*)SMS_PUSH_XML_INVAL_OBJ)) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
-
- tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
-
- if (tmpUrl != NULL) {
- strncpy(cacheOp.invalObjectUrl[cacheOp.invalObjectCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
-
- MSG_DEBUG("%dth invalObjectUrl is <%s>\n", cacheOp.invalObjectCnt, cacheOp.invalObjectUrl[cacheOp.invalObjectCnt-1]);
- } else {
- MSG_DEBUG("NO href value from the xmlDoc\n");
- }
- } else if (!xmlStrcmp(indNode->name, (const xmlChar*)SMS_PUSH_XML_INVAL_SVC)) {
- MSG_SEC_DEBUG("indNode->name = %s\n", indNode->name);
- tmpUrl = xmlGetProp(indNode, (xmlChar*)SMS_PUSH_XML_CO_URI);
-
- if (tmpUrl != NULL) {
- strncpy(cacheOp.invalServiceUrl[cacheOp.invalServiceCnt++], (char*)tmpUrl, MAX_PUSH_CACHEOP_MAX_URL_LEN-1);
- MSG_DEBUG("%dth invalServiceUrl is <%s>\n", cacheOp.invalServiceCnt, cacheOp.invalServiceUrl[cacheOp.invalServiceCnt-1]);
- } else {
- MSG_DEBUG("NO href value from the xmlDoc\n");
- }
- }
-
- if (tmpUrl != NULL)
- xmlFree(tmpUrl);
-
- indNode = indNode->next;
- }
-
- /** Write push Msg to file */
- char fileName[MSG_FILENAME_LEN_MAX+1];
- memset(fileName, 0x00, sizeof(fileName));
-
- if (MsgCreateFileName(fileName) == false) {
- xmlFree(xmlDoc);
- THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
- }
-
- if (MsgWriteIpcFile(fileName, (char*)(&cacheOp), sizeof(cacheOp)) == false) {
- xmlFree(xmlDoc);
- THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
- }
-
- /** Pack Message Info Structure */
- MSG_MESSAGE_INFO_S msgInfo;
- memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S));
-
- msgInfo.addressList = NULL;
- unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
-
- createMsgInfo(&msgInfo);
-
- strncpy(msgInfo.msgData, fileName, MAX_MSG_DATA_LEN);
-
- /** Convert Type values */
- msgInfo.msgType.mainType = MSG_SMS_TYPE;
- msgInfo.msgType.subType = MSG_WAP_CO_SMS;
-
- msgInfo.dataSize = sizeof(cacheOp);
- msgInfo.sim_idx = simIndex;
-
- msg_error_t err = MSG_SUCCESS;
-
- /** Add WAP Push Msg into DB */
- err = SmsPluginStorage::instance()->checkMessage(&msgInfo);
-
- if (err == MSG_SUCCESS) {
- /** Callback */
- err = SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo);
-
- if (err != MSG_SUCCESS)
- MSG_DEBUG("callbackMsgIncoming() Error !! [%d]", err);
- } else {
- MSG_DEBUG("checkMessage() Error !! [%d]", err);
- }
-
- xmlFree(xmlDoc);
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen)
-{
-#if MSG_DRM_SUPPORT
- int drmRt = DRM_RETURN_SUCCESS;
- char* cid = NULL;
- unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter);
-
- MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message.");
- drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE;
- drm_register_lic_info_s lic_req_info;
- drm_register_lic_resp_s lic_resp_info;
-
- bzero(&lic_req_info, sizeof(drm_register_lic_info_s));
- bzero(&lic_resp_info, sizeof(drm_register_lic_resp_s));
- bzero(lic_req_info.lic_data, sizeof(lic_req_info.lic_data));
-
- memcpy(lic_req_info.lic_data, pPushBody, PushBodyLen);
-
- lic_req_info.lic_version = DRM_OMA_DRMV1_RIGHTS;
- lic_req_info.roap_init_src = DRM_ROAP_INIT_FROM_WAPPUSH;
- lic_req_info.operation_callback.callback = NULL;
-
- drmRt = drm_process_request(request_type, &lic_req_info, &lic_resp_info);
- if (drmRt == DRM_RETURN_SUCCESS) {
- MSG_DEBUG("DRM successfully registed to drm-service.");
- } else {
- MSG_DEBUG("Fail to regist DRM to drm-service.");
- }
-#endif
- return;
-}
-
-
-void SmsPluginWapPushHandler::createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo)
-{
- /** Convert class Type values */
- pMsgInfo->msgType.classType = MSG_CLASS_NONE;
-
- /** set folder id (temporary) */
- pMsgInfo->folderId = MSG_INBOX_ID;
-
- pMsgInfo->networkStatus = MSG_NETWORK_RECEIVED;
- pMsgInfo->bRead = false;
- pMsgInfo->bProtected = false;
- pMsgInfo->priority = MSG_MESSAGE_PRIORITY_NORMAL;
- pMsgInfo->direction = MSG_DIRECTION_TYPE_MT;
-
- time_t rawtime = time(NULL);
-
-/*** Comment below lines to save local UTC time..... (it could be used later.)
-
- if (tmpTimeStamp.format == SMS_TIME_ABSOLUTE) {
-
- MSG_DEBUG("year : %d", tmpTimeStamp.time.absolute.year);
- MSG_DEBUG("month : %d", tmpTimeStamp.time.absolute.month);
- MSG_DEBUG("day : %d", tmpTimeStamp.time.absolute.day);
- MSG_DEBUG("hour : %d", tmpTimeStamp.time.absolute.hour);
- MSG_DEBUG("minute : %d", tmpTimeStamp.time.absolute.minute);
- MSG_DEBUG("second : %d", tmpTimeStamp.time.absolute.second);
- MSG_DEBUG("timezone : %d", tmpTimeStamp.time.absolute.timeZone);
-
- char displayTime[32];
- struct tm * timeTM;
-
- struct tm timeinfo;
- memset(&timeinfo, 0x00, sizeof(tm));
-
- timeinfo.tm_year = (tmpTimeStamp.time.absolute.year + 100);
- timeinfo.tm_mon = (tmpTimeStamp.time.absolute.month - 1);
- timeinfo.tm_mday = tmpTimeStamp.time.absolute.day;
- timeinfo.tm_hour = tmpTimeStamp.time.absolute.hour;
- timeinfo.tm_min = tmpTimeStamp.time.absolute.minute;
- timeinfo.tm_sec = tmpTimeStamp.time.absolute.second;
- timeinfo.tm_isdst = 0;
-
- rawtime = mktime(&timeinfo);
-
- MSG_DEBUG("tzname[0] [%s]", tzname[0]);
- MSG_DEBUG("tzname[1] [%s]", tzname[1]);
- MSG_DEBUG("timezone [%d]", timezone);
- MSG_DEBUG("daylight [%d]", daylight);
-
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeinfo);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= (tmpTimeStamp.time.absolute.timeZone * (3600/4));
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
-
- rawtime -= timezone;
-
- timeTM = localtime(&rawtime);
- memset(displayTime, 0x00, sizeof(displayTime));
- strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM);
- MSG_DEBUG("displayTime [%s]", displayTime);
- }
-
-***/
-
- pMsgInfo->displayTime = rawtime;
-
- /** Convert Address values */
- pMsgInfo->nAddressCnt = 1;
-
- pMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
- memset(pMsgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
-
- pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
- strncpy(pMsgInfo->addressList[0].addressVal, tmpAddress.address, MAX_ADDRESS_VAL_LEN);
-
- pMsgInfo->msgPort.valid = false;
- pMsgInfo->msgPort.dstPort = 0;
- pMsgInfo->msgPort.srcPort = 0;
-}
-
-void SmsPluginWapPushHandler::getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText)
-{
- if (pPushBody == NULL) {
- MSG_DEBUG("pPushBody is NULL");
- return;
- }
-
-
- if (isText) {
- *pXmlDoc = xmlParseMemory(pPushBody, AcStrlen(pPushBody));
- } else {
- WB_UTINY* xmldata = NULL;
- WBXMLConvWBXML2XML *conv = NULL;
- WBXMLError ret = WBXML_OK;
-
- ret = wbxml_conv_wbxml2xml_create(&conv);
- if (ret != WBXML_OK)
- return;
-
- ret = wbxml_conv_wbxml2xml_run(conv, (WB_UTINY*)pPushBody, (WB_ULONG)PushBodyLen, &xmldata, NULL);
-
- wbxml_conv_wbxml2xml_destroy(conv);
-
- if (ret != WBXML_OK ||xmldata == NULL) {
- MSG_DEBUG("xmldata is NULL. Error code is [%d].\n", ret);
- return;
- }
-
- MSG_DEBUG("xmldata : \n%s\n", xmldata);
-
- *pXmlDoc = xmlParseMemory((char*)xmldata, AcStrlen((char*)xmldata));
- }
-}
-
-unsigned long SmsPluginWapPushHandler::convertXmlCharToSec(char* pDate)
-{
- struct tm timeStruct;
- time_t nTimeInSec = 0;
- char tmpBuf[10];
- int i = 0, index = 0;
-
- memset(tmpBuf, 0x00, sizeof(tmpBuf));
- memset(&timeStruct, 0x00, sizeof(struct tm));
-
- /** check pDate */
- if (AcStrlen(pDate) < 20)
- return 0;
-
- MSG_DEBUG("pDate [%s]", pDate);
-
- /** Year */
- for (i = 0; i < 4; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_year = (atoi(tmpBuf)-1900);
-
- /** Month */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_mon = (atoi(tmpBuf) - 1);
-
- /** Date */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_mday = atoi(tmpBuf);
-
- /** Hours */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_hour = atoi(tmpBuf);
-
- /** Minites */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_min = atoi(tmpBuf);
-
- /** Seconds */
- for (i = 0; i < 2; i++) {
- tmpBuf[i] = pDate[index++];
- }
- tmpBuf[i] = '\0';
- index++;
- timeStruct.tm_sec = atoi(tmpBuf);
-
- nTimeInSec = mktime(&timeStruct);
-
- return nTimeInSec;
-}
-
-msg_push_action_t SmsPluginWapPushHandler::convertSIActionStrToEnum(char* pAction)
-{
- int comp = 0;
-
- if (pAction == NULL) {
- MSG_DEBUG("pAction is NULL. Setting to default action type.");
- return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
- }
-
- /** compare with signal-none. */
- comp = g_strcmp0("signal-none", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_NONE;
-
- /** compare with signal-low. */
- comp = g_strcmp0("signal-low", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_LOW;
-
- /** compare with signal-medium. */
- comp = g_strcmp0("signal-medium", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
-
- /** compare with signal-high. */
- comp = g_strcmp0("signal-high", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_SIGNAL_HIGH;
-
- /** compare with delete. */
- comp = g_strcmp0("delete", pAction);
- if (comp == 0)
- return MSG_PUSH_SI_ACTION_DELETE;
-
- /** signal-medium is default action value. */
- return MSG_PUSH_SI_ACTION_SIGNAL_MEDIUM;
-}
-
-msg_push_action_t SmsPluginWapPushHandler::convertSLActionStrToEnum(char* pAction)
-{
- int comp = 0;
-
- if (pAction == NULL) {
- MSG_DEBUG("MSG_DEBUG is NULL. Setting to default action type.\n");
- return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
- }
-
- /** compare pSrcStr with execute-low. */
- comp = g_strcmp0("execute-low", pAction);
- if (comp == 0)
- return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
-
- /** compare pSrcStr with execute-high. */
- comp = g_strcmp0("execute-high", pAction);
- if (comp == 0)
- return MSG_PUSH_SL_ACTION_EXECUTE_HIGH;
-
- /** compare pSrcStr with cache. */
- comp = g_strcmp0("cache", pAction);
- if (comp == 0)
- return MSG_PUSH_SL_ACTION_CACHE;
-
- /** default SL action value is execute-low. */
- return MSG_PUSH_SL_ACTION_EXECUTE_LOW;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer)
-{
- unsigned long i = 0;
- unsigned long decodedValue;
-
- while (sourceData[*currentPointer + i] >= 0x80)
- i++;
-
- decodedValue = wspDecodeUintvar(i + 1, sourceData + *currentPointer);
- *currentPointer = *currentPointer + i + 1;
- MSG_DEBUG("wspRetriveUintvarDecode: decodedValue=%lu .\n", decodedValue);
- return decodedValue;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspDecodeUintvar(unsigned long length, unsigned char* userVar)
-{
- unsigned long i;
- unsigned long decodedUintvar = 0;
-
-
- for (i = 0 ; i < length; i++) {
- decodedUintvar = decodedUintvar + (wspUintvarDecodeTable[i] * (userVar[length-(i+1)] & 0x7f));
- }
-
- return decodedUintvar;
-}
-
-
-void SmsPluginWapPushHandler::wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader)
-{
- unsigned long iField = 0;
- bool continueField = FALSE;
- unsigned long currentLength;
-
- char* encodedHeader = NULL;
- unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter);
-
- char* outTemper = NULL;
-
- char* temper = NULL;
- unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter);
-
- unsigned char track;
- unsigned long iEncodedHeader = 0;
- unsigned char fieldCode = 0xff;
-
- /* outTemper is Decoded Headers.
- temper is Single Decoded Header.
- */
- if (NULL == (outTemper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ])) {
- MSG_DEBUG("outTemper Memory allocation is failed.\n");
- return;
- }
- memset(outTemper, 0, (WSP_STANDARD_STR_LEN_MAX * 5));
- currentLength = WSP_STANDARD_STR_LEN_MAX;
-
- MSG_DEBUG("wspDecodeHeader: Message header decoding started.\n");
-
- int loop;
- char szBuf[64];
-
- szBuf[0] = 0x00;
- MSG_DEBUG("wspDecodeHeader: RAW data \n");
- for (loop = 0 ; loop < (int)encodedHeaderLen; loop++) {
- char szTempBuf[5];
- szTempBuf[0] = 0x00;
- snprintf(szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop]);
-
- if (AcStrlen(szBuf) + 7 < 64) {
- strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
- } else {
- strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
- MSG_DEBUG("[%s]", szBuf);
- szBuf[0] = 0x00;
- strncat(szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1);
- }
- }
- strncat(szBuf, "\n", sizeof(szBuf)-AcStrlen(szBuf)-1);
- MSG_DEBUG("[%s]", szBuf);
- MSG_DEBUG("fContentType=%d \n", fContentType);
- /* operation for content-type */
- /* makes psuedo- content-type fieldcode */
- /* content - type is processed with header. But it's come without field code. So existence of fContentType can decide adding content type header field code whether ContentType + general header is or not. */
-
- if (fContentType) {
- encodedHeader = new char[ encodedHeaderLen + 1 ];
- if (encodedHeader == NULL) {
- MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
- return;
- }
- encodedHeader[0] = 0x91;
- memcpy(encodedHeader + 1, sEncodedHeader, (size_t)encodedHeaderLen);
- } else {
- encodedHeader = new char[ encodedHeaderLen ];
- if (encodedHeader == NULL) {
- MSG_DEBUG("encodedHeader Memory allocation is failed.\n");
- return;
- }
-
- memcpy(encodedHeader, sEncodedHeader, (size_t)encodedHeaderLen);
- }
-
- /* Is it reacehd end of header? */
- while (iEncodedHeader < encodedHeaderLen) {
- /* Get memory for single header */
- if (temper == NULL) {
- temper = new char[ WSP_STANDARD_STR_LEN_MAX * 5 ];
-
- if (temper == NULL) {
- MSG_DEBUG("temper Memory allocation is failed.\n");
- return;
- }
- memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
- } else {
- memset(temper, 0x00, (WSP_STANDARD_STR_LEN_MAX * 5));
- }
-
- /* this section presents header code page shifting procedure
- This part can be implemented by future request.
- if (track == 0x 7f)
- */
- track = encodedHeader[iEncodedHeader];
-
- if (track == 0x00) {
- MSG_DEBUG("WspLDecodeHeader: fieldcode is 0 \n");
- strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
- fieldCode = 0xff;
- iEncodedHeader++;
- } else if ((track > 0) && (track < 0x20)) {
- iEncodedHeader++;
- } else if ((track < 0x7f) && (track > 0x1f)) { /* In this case, first byte is normal string. So it's considered to unknown header. */
- unsigned char* fieldName = (unsigned char*)gWapCodeBufferLeft;
- unsigned char* fieldValue = (unsigned char*)gWapCodeBufferRight;
-
- strncpy((char*)fieldName, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_LEFT_LEN_MAX-1);
- fieldName[WSP_CODE_BUFFER_LEFT_LEN_MAX-1] = '\0';
- iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldName) + 1;
- strncpy((char*)fieldValue, (char*)(encodedHeader + iEncodedHeader), WSP_CODE_BUFFER_RIGHT_LEN_MAX-1);
- fieldValue[WSP_CODE_BUFFER_RIGHT_LEN_MAX-1] = '\0';
- iEncodedHeader = iEncodedHeader + AcStrlen((char*)fieldValue) + 1;
-
- strncat((char*)temper, (char*)fieldName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- /* this means 'don't process anymore.' */
- fieldCode = 0xff;
-
- } else if (track > 0x7f) {
- /* In case of first byte is field code, else case is error. */
-
- /*if ((track & 0x7f) <= wspHeaderFieldCount) { */
- unsigned long fieldValueLen = encodedHeader[iEncodedHeader + 1];
- unsigned char fieldValue[1275];
- fieldCode = track & 0x7f;
- /*
- if ((fieldValueLen == 0) || (fieldValueLen == 0x80))
- {
- dprint(DNET_WAP,DNET_DBG_HIGH, "%X %X %X %X %X %X\n" , fieldCode, encodedHeader[iEncodedHeader + 1], encodedHeader[iEncodedHeader + 2],encodedHeader[iEncodedHeader + 3],encodedHeader[iEncodedHeader + 4], encodedHeader[iEncodedHeader + 5]);
- }
- */
- memset(fieldValue, 0, 1275);
- /* add field name */
- /* This continueField flag show whether previous field code and current field code are same or not. If it's same, there are some sequential display effect by omitting field name addition process. The reason why it should be do that can be found in encoding example of spec. */
- if (!continueField) {
- strncat((char*)temper, (char*)wspHeaderFieldName[fieldCode], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, ": ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- continueField = FALSE;
- }
-
- /* field value is string */
- /* In this case, it just copy field value. */
- if ((fieldValueLen > LENGTH_QUOTE) && (fieldValueLen < 0x80)) {
- /* string field value should be NULL terminated */
- strncat((char*)temper, (char*)(encodedHeader + iEncodedHeader + 1), (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- iEncodedHeader = iEncodedHeader + AcStrlen((char*)encodedHeader + iEncodedHeader + 1) + 2;
- fieldCode = 0xff;
- }
- /* first field value is length */
- /* If first byte of field value is length value, allocate field value by the length.
- In field value, data is
- 1D 03 8F 24 24 - Then 8F 24 24 is field value.
- 1D 1F 33.... - Then allocate 33H for FieldValue.
- 1D 8F - Then 8F
- 1D 'Hi man!' Like 00, if string is come, then process without calculating field value.
- 1D 8F 24 24 - In this case, original data is wrong.
- If accept-charset: ISO-10646-ucs-2;Q=0.7 is
- 01 03 03 E8 47
- 01 - field code
- 03 - field value length
- 03 E8 47 - field value
- it's decoded by above value.
- */
- if (fieldValueLen < 0x20) {
- if (fieldValueLen == LENGTH_QUOTE) {
- /* field length is encoded in UINTVAR */
- unsigned long uintvarLen = 0;
- fieldValueLen = wspRetriveUintvarDecode((unsigned char*) encodedHeader + iEncodedHeader + 2, &uintvarLen);
- memcpy(fieldValue, encodedHeader + iEncodedHeader + 2 + uintvarLen, (size_t)fieldValueLen);
- iEncodedHeader = iEncodedHeader + fieldValueLen + uintvarLen + 2;
-
- } else {
- if (fieldValueLen == 1) {
- /* field value is one byte integer over 0x80 */
- /** make it two byte integer */
- fieldValue[0] = 0x00;
- memcpy(fieldValue + 1, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
- fieldValueLen = 2;
- iEncodedHeader = iEncodedHeader + 1 + 2;
- } else {
- memcpy(fieldValue, encodedHeader + iEncodedHeader + 2, (size_t)fieldValueLen);
- fieldValue[fieldValueLen] = 0;
- iEncodedHeader = iEncodedHeader + fieldValueLen + 2;
- if ((fieldValueLen == 0) || (fieldValueLen == 0x80)) {
- MSG_DEBUG("%X \n", encodedHeader[iEncodedHeader]);
- }
- }
- }
- }
- /* field value is single encoded */
- if (fieldValueLen > 0x7f) {
- fieldValue[0] = encodedHeader[iEncodedHeader + 1];
- fieldValueLen = 1;
- iEncodedHeader = iEncodedHeader + 2;
- }
- /* processing normal pre-defined field decoding */
-
- MSG_DEBUG("WspLDecodeHeader: FieldCode %X\n", fieldCode);
- MSG_DEBUG("WspLDecodeHeader: fieldSize %lu\n", fieldValueLen);
-
- if ((fieldCode > wspHeaderFieldCount) && (fieldCode != 0xff)) {
- MSG_DEBUG("WspLDecodeHeader: unknown fieldcode %X \n", track);
- strncpy((char*) temper, (char*)"", (WSP_STANDARD_STR_LEN_MAX * 5)-1);
- fieldCode = 0xff;
- }
-
-
- switch (fieldCode) {
- /* accept charset */
- /* It's normal way of field process. */
- case 0x01: {
- unsigned long i = 0;
- unsigned long code;
-
- /* Case of length of charset greater than 1 are two thigins.
- 1. code length of charset is greater than 1.
- 2. It include parameter.
- 3. Or both of two
- */
- if (1 != fieldValueLen) {
- code = wspHeaderDecodeInteger(fieldValue);
- /* Calculate iField. */
- if (fieldValue[0] < 0x80)
- iField = fieldValue[0];
- else
- iField = 1;
-
- while (wspCharset[i].charsetCode != code)
- i++;
- strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- /* If parameter exist */
- if (iField < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeQValue(fieldValueLen - iField, fieldValue + iField, ¶m);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- } else {
- code = fieldValue[0] & 0x7f;
-
- while ((wspCharset[i].charsetCode != code) && (wspCharset[i].charsetCode != 0xffff )) i++;
- strncat((char*)temper, (char*)wspCharset[i].charsetName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- break;
-
- /* type encoding */
- /* Like below routine, Same decoding routine process together. */
- /* Accept-encoding */
- case 0x02:
- /* content-encoding */
- case 0x0b: {
- int integerValue;
-
- integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
- if (integerValue > 2) {
- MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(2).\n");
- break;
- }
- strncat((char*)temper, (char*)wspEncodeMethod[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* contents type decoder */
- /* accept */
- case 0x00:
- /* content-type */
- case 0x11: {
- unsigned long contentsTypeCode;
- unsigned long i = 0;
- /* encoded content type length body */
- unsigned long tempLen;
- MSG_DEBUG("fieldValueLen: %lu", fieldValueLen);
-
- /* Like HTTP result state 304, it's for processing without Content type. This part doesn't defined. */
- if (0 == fieldValueLen) {
- strncat((char*)temper, (char*)"None" , (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- break;
- }
- /* 01 AE --> 00 AE --> AE*/
- if (fieldValueLen == 2 && fieldValue[0] == 0) {
- memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
- MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
- }
-
- if ((fieldValue[0] < 0x20) || (fieldValue[0] >= 0x80)) {
- if (fieldValue[0] >= 0x80) {
- tempLen = 1;
- } else if (fieldValueLen == 2 && fieldValue[0] == 0x03 && fieldValue[1] == 0x0A) { /** 06 05 02 03 0A AF 89 */
- fieldValue[3] = fieldValue[2];
- fieldValue[2] = fieldValue[1];
- fieldValue[1] = fieldValue[0];
- fieldValue[0] = 0x02;
- tempLen = 2;
- fieldValueLen = 3;
- MSG_DEBUG("WspLDecodeHeader:For CPE problem\r\n");
- } else {
- tempLen = fieldValue[0]; /** 06 06 03 02 03 16 AF 88 */
- }
-
- if (tempLen == 1) {
- char* szExtendedContent;
-
- contentsTypeCode = fieldValue[0] & 0x7f;
- while ((wspContentsType[i].contentsTypeCode != contentsTypeCode) && (i < wspContentsTypeCount)) i++;
-
- /* If specified content type doesn't exist */
- if (i < wspContentsTypeCount)
- strncat((char*)temper, (char*)wspContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- szExtendedContent = wspExtendedDecodeType((char)contentsTypeCode);
-
- if (szExtendedContent != NULL) {
- MSG_DEBUG("WspLDecodeHeader: Tele2 server problem \n ");
- strncat((char*)temper, (char*)szExtendedContent, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- } else {
- contentsTypeCode = wspHeaderDecodeInteger(fieldValue);
-
- while ((i < wspUnregisteredContentsTypeCount) && (wspUnregisterContentsType[i].contentsTypeCode != contentsTypeCode)) i++;
-
- /** If there is a Content-Type assigned, */
- if (i < wspUnregisteredContentsTypeCount)
- strncat((char*)temper, (char*)wspUnregisterContentsType[i].contentsTypeName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- tempLen +=1;
- }
- } else {
- tempLen = AcStrlen((char*)fieldValue) + 1;
-
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- MSG_DEBUG("WspLDecodeHeader: Attention, Decoding Check of Content-Type %lu\n ", tempLen);
- }
-
- /* If there is a parameter */
- if (tempLen < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + tempLen, fieldValueLen - tempLen, ¶m);
- if (param != NULL) {
- strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- }
- break;
-
- /* language */
- /* content-language */
- case 0x0c:
- /* accept-language */
- case 0x03: {
- unsigned long i = 0;
- unsigned long code;
- unsigned long tempLen;
- if ((fieldValue[0] < 0x20) || (fieldValue[0] > 0x80)) {
- if (fieldValue[0] > 0x80)
- tempLen = 1;
- else
- tempLen = fieldValue[0];
- } else {
- tempLen = AcStrlen((char*)fieldValue) + 1;
- }
-
- if (tempLen == 1) {
- code = wspHeaderDecodeInteger(fieldValue);
- while (wspLanguage[i].languageCode != code) {
- i++;
- if (i == wspLanguageCount)
- break;
- }
-
- if (i < wspLanguageCount) {
- strncat((char*)temper, (char*)wspLanguage[i].languageName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- } else {
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
-
- if (tempLen < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeQValue(fieldValueLen - tempLen, fieldValue + tempLen, ¶m);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- break;
-
- /* integer */
- /* Max-forwards */
- case 0x1e:
- /* content-length */
- case 0x0d:
- /* age */
- case 0x05:
- /* Bearer-indication */
- case 0x33:
- /* Push-Flag */
- case 0x34: {
- unsigned char temp[16];
- /*
- if ((fieldValueLen == 2) && (fieldValue[0] > 0x7f))
- AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[1]);
- else
- */
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* X-Wap-Application-Id */
- case 0x2f: {
- unsigned char temp[64];
- int integerValue;
-
- if (track == 0xaf) { /* WAP short-integer-encoded */
- if (fieldValueLen == 2 && fieldValue[0] == 0) {
- memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen);
- }
- integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
- } else {
- if (fieldValueLen == 2 && fieldValue[0] == 0) {
- memcpy(fieldValue, encodedHeader + iEncodedHeader -1, (size_t)fieldValueLen-1);
- MSG_DEBUG("WspLDecodeHeader:For mmO2 problem\r\n");
- fieldValueLen = 1;
- }
- integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
- }
-
- MSG_DEBUG("integerValue = [%02x]", integerValue);
-
- int count = sizeof(wspHeaderApplId)/sizeof(SMS_WSP_HEADER_PARAMETER_S);
- for (int i = 0; i < count ; ++i) {
- if ((unsigned int)integerValue == wspHeaderApplId[i].parameterCode) {
- snprintf((char*)temp, 64, "%s", wspHeaderApplId[i].parameterToken);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- break;
- }
- }
- }
- break;
- /* Accept-Application */
- case 0x32:
- if (0x80 == fieldValue[0]) {
- strncat((char*)temper, "*", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- } else {
- unsigned char temp[16];
- /*
- if ((fieldValueLen == 2) && (fieldValue[0] == 1))
- AcSprintf((char*)temp, "%u", (unsigned int)fieldValue[0]);
- else
- */
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- }
- break;
-
-
- /* date */
- /* last-modified */
- case 0x1d:
- /* if-unmodified-since */
- case 0x1b:
- /* if-range */
- case 0x1a:
- /* if-modified-since */
- case 0x17:
- /* expires */
- case 0x14:
- /* date */
- case 0x12: {
- char* decodedString = NULL;
- unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
- wspHeaderDecodeDateValue(fieldValueLen, fieldValue, &decodedString);
- strncat((char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- }
- break;
-
- /* connection */
- case 0x09:
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "Close", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- break;
- /* accept-ranges */
- case 0x04:
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "None", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- if (fieldValue[0] == 0x81)
- strncat((char*)temper, "Bytes", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1);
- break;
- /* content-md5 */
- case 0x0f: {
- unsigned char temp[1275];
- memcpy(temp, fieldValue, (size_t)fieldValueLen);
- temp[fieldValueLen] = 0;
- wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
- }
- break;
- /* Credential */
- /* authorization */
- case 0x07:
- /* proxy - authorization */
- case 0x21:
- if (fieldValue[0] == 0x80) {
- char* addString = NULL;
- unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
- wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString);
- strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- } else {
- iField = AcStrlen((char*)fieldValue) + 1;
-
- strncat((char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- if (iField < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
- if (param != NULL) {
- strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- }
- break;
-
-
- /* Challenge */
- /* www - auth */
- case 0x2d:
- /* Proxy-authenticate */
- case 0x20:
- if (0 == fieldValueLen)
- break;
- if (fieldValue[0] == 0x80) {
- char* addString = NULL;
- unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter);
- wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString);
- strncat((char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- } else {
- unsigned char authScheme[WSP_STANDARD_STR_LEN_MAX + 1];
- unsigned char realmValue[WSP_STANDARD_STR_LEN_MAX];
- unsigned char addedString[WSP_STANDARD_STR_LEN_MAX];
-
- strncpy((char*)authScheme, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX -1);
- iField = AcStrlen((char*)authScheme) + 1;
- strncpy((char*)realmValue, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
- iField = iField + AcStrlen((char*)realmValue) + 1;
- int wrn = snprintf((char*)addedString, sizeof(addedString), "%s %s", authScheme, realmValue);
- if(wrn<0)
- MSG_DEBUG("snprintf was failed");
- wspHeaderCopyDecodedString(addedString, ¤tLength, &temper);
-
- if (iField < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + iField, fieldValueLen - iField, ¶m);
- if (param != NULL) {
- strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- wspHeaderCopyDecodedString((unsigned char*)param, ¤tLength, &temper);
- }
- }
- }
- break;
-
- /* content -range */
- case 0x10: {
- unsigned long first, len, last;
-
- unsigned char temp[16];
- iField = 0;
-
- strncat((char*)temper, " bytes ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- first = wspRetriveUintvarDecode(fieldValue, &iField);
- len = wspRetriveUintvarDecode(fieldValue, &iField);
- /* Originally range of HTTP include entity length. But WSP omit it. Finally to calculate this, it should be get content length from export. If this field is included without content length, then it can get wrong result. This content length can be get by calculating PDU length.
- */
- last = first + contentsLength - 1;
-
- snprintf((char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
-
- /* cache-control */
- case 0x08: {
- char* cacheString = NULL;
- unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter);
-
- wspHeaderDecodeCacheControl(fieldValue, fieldValueLen, &cacheString);
- strncat((char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
-
- /* pragma */
- case 0x1f:
- if (fieldValue[0] == 0x80) {
- strncat((char*)temper, (char*)wspCacheControl[0], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- } else {
- if (1 < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue, fieldValueLen, ¶m);
-
- if (param != NULL) {
- strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- }
-
- break;
- /* public */
- case 0x22:
- /* allow */
- case 0x06: {
- unsigned long i = 0;
- while (wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen) != wspMethodType[i].methodCode) i++;
- strncat((char*)temper, (char*)wspMethodType[i].methodName, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* range */
- case 0x23:
- strncat((char*)temper, "bytes=", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- if (fieldValue[0] == 0x80) {
- unsigned char temp[16];
- unsigned long first, last;
- iField = 0;
-
- first = wspRetriveUintvarDecode(fieldValue, &iField);
- last = wspRetriveUintvarDecode(fieldValue, &iField);
-
- snprintf((char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- if (fieldValue[0] == 0x81) {
- unsigned char temp[16];
- unsigned long suffix;
-
- suffix = wspRetriveUintvarDecode(fieldValue, &iField);
-
- snprintf((char*)temp, sizeof(temp), "-%u", (unsigned int)suffix);
- }
- break;
- /* retry-after */
- case 0x25:
- if (fieldValue[0] == 0x80) {
- char* temp = NULL;
- unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter);
-
- wspHeaderDecodeDateValue(fieldValueLen - 1, fieldValue + 1, &temp);
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
-
- if (fieldValue[0] == 0x81) {
- unsigned char temp[16];
-
- snprintf((char*)temp, 16, "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* transfer-encoding */
- case 0x27:
- /* No other cases allowed */
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "chunked", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- break;
- /* vary */
- case 0x2a: {
- int integerValue = wspHeaderDecodeIntegerByLength(fieldValue, fieldValueLen);
- if (integerValue > wspHeaderFieldCount) {
- MSG_DEBUG("WspLDecodeHeader: integerValue is over limit(0x%x).\n", wspHeaderFieldCount);
- break;
- }
- strncat((char*)temper, (char*)wspHeaderFieldName[integerValue], (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
- /* warning */
- case 0x2c: {
- unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
- if (fieldValue[0] < 0x20)
- iField = fieldValue[0];
- else
- iField = 1;
-
- snprintf((char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength(fieldValue, iField));
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- if (iField < fieldValueLen) {
- unsigned char agent[WSP_STANDARD_STR_LEN_MAX];
- unsigned char text[WSP_STANDARD_STR_LEN_MAX];
- strncpy((char*)agent, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
- iField = iField + AcStrlen((char*)agent) + 1;
- strncpy((char*)text, (char*)(fieldValue + iField), WSP_STANDARD_STR_LEN_MAX-1);
- int wrn = snprintf((char*)temp, sizeof(temp), " %s %s", agent, text);
- if(wrn<0)
- MSG_DEBUG("snprintf was failed");
- wspHeaderCopyDecodedString(temp, ¤tLength, &temper);
- }
- }
- break;
- /* content-disposition */
- case 0x2e:
- if (fieldValue[0] == 0x80)
- strncat((char*)temper, "form-data", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- if (fieldValue[0] == 0x81)
- strncat((char*)temper, "attachment", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
-
- if (1 < fieldValueLen) {
- char* param = NULL;
- unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter);
- wspHeaderDecodeParameter(fieldValue + 1, fieldValueLen - 1, ¶m);
-
- if (param != NULL) {
- strncat((char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- strncat((char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- }
- break;
- /* Profile-diff */
- case 0x36:
- temper[AcStrlen((char*)temper) + fieldValueLen] = '\0';
- memcpy(temper, fieldValue, (size_t)fieldValueLen);
- break;
- /* Profile-Warning */
- case 0x37: {
- unsigned char temp[WSP_STANDARD_STR_LEN_MAX];
-
- snprintf((char*)temp, sizeof(temp), "%lX", wspHeaderDecodeInteger(fieldValue));
- temp[2] = temp[1];
- temp[1] = (unsigned char)0x30;
- temp[3] = '\0';
- if (fieldValueLen > 1) {
- /* copy warn-target - URI */
- strncat((char*)temp, (char*)(fieldValue + 1), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
- if (fieldValueLen > (AcStrlen((char*)(fieldValue + 1)) + 1)) {
- /* copy warn-date */
- char* decodedString = NULL;
- unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter);
- wspHeaderDecodeDateValue(fieldValueLen - (AcStrlen((char*)(fieldValue + 1)) + 2), fieldValue + AcStrlen((char*)(fieldValue + 1)) + 1, &decodedString);
- strncat((char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1);
- }
- }
- strncat((char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
- break;
-
- default:
- break;
- }
- /*}*/
- }
- /* It deosn't finished decoding yet. */
- if ((iEncodedHeader < encodedHeaderLen) && (fieldCode != 0xff)) {
- /* In here, iEncodedHeader already point next field code to be decoded. */
- /* If this code is same, then set continueField else add CRLF. */
- if (fieldCode == (encodedHeader[iEncodedHeader] & 0x7f)) {
- strncat((char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- continueField = TRUE;
- } else {
- strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- continueField = FALSE;
- }
- } else {
- strncat((char*)temper, "\r\n", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1);
- }
-
- /* add single header to total headers */
- strncat((char*)outTemper, (char*)temper, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)outTemper)-1);
- MSG_DEBUG("WspLDecodeHeader: Single Header : %s\r\n", temper);
- }
-
-
- MSG_DEBUG("WspLDecodeHeader: Header decoding ended.\n");
-
- *pHeader = outTemper;
-
- return;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspHeaderDecodeInteger(unsigned char* data)
-{
- /* we only can handle max 32bit integer */
- unsigned long i;
-
- union {
- unsigned long integer;
- unsigned char seg[4];
- } returner;
-
- returner.integer = 0;
-
- if (data[0] < 0x80) {
- unsigned long IntLen = 0;
-
- IntLen = (data[0] > 0x04) ? 0x04:data[0];
-
- MSG_DEBUG("WspLHeaderDecodeInteger: input %d , length %lu\n", data[0], IntLen);
-
- for (i = 0; i < IntLen; i++)
- returner.seg[IntLen-(i+1)] = data[i+1];
-
- return returner.integer;
- }
-
- return data[0] & 0x7f;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString)
-{
- unsigned short qBase = 0;
- float qValue;
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeQValue:MemAlloc failed\n");
- return;
- }
-
- memcpy(&qBase, data, (size_t)length);
- qValue = (float)qBase;
- if (qValue > 100) {
- qValue = qValue - 100;
- qValue = qValue / 1000;
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue);
- } else {
- /* qValue variable is divided by 100. And it's multiplied by 100.
- It's to resolve problem of changed 0.01 of qValue. */
- unsigned long qValueTemp;
- qValue = qValue - 1;
- qValue = qValue / 100;
- qValueTemp = (unsigned long)(qValue * 100);
- if (0 == (qValueTemp % 10))
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue);
- else
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue);
- }
- return;
-}
-
-
-unsigned long SmsPluginWapPushHandler::wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length)
-{
- unsigned long i;
-
- union {
- unsigned long integer;
- unsigned short seg[4];
- } returner;
-
- returner.integer = 0;
-
- if (length == 1)
- return data[0] & 0x7f;
-
- returner.integer = 0;
-
- for (i = 0 ; i < length; i++) {
- returner.integer = returner.integer + (data[i] * (0x1 << ((length - (i + 1)) * 8)));
- MSG_DEBUG("WspLHeaderDecodeIntegerByLength: %lu \n", returner.integer);
- }
-
- return returner.integer;
-}
-
-
-char* SmsPluginWapPushHandler::wspExtendedDecodeType(char contentType)
-{
- int i = 0;
-
- while (wspExtendedContentsType[i].contentsTypeCode != contentType) {
- if (wspExtendedContentsType[i].contentsTypeCode == 0xff)
- return NULL;
- i++;
- }
-
- return (char*)wspExtendedContentsType[i].contentsTypeName;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam)
-{
- char* param = *pParam;
-
- unsigned long SecurityTypeCode;
- unsigned long i = 0;
-
- if (data[0] < 0x80) {
- /* unknown parameter type */
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:MemAlloc failed\n");
- return;
- }
-
- strncpy((char*)param, (char*)data, WSP_STANDARD_STR_LEN_MAX - 1);
-
- if (NO_VALUE == data[AcStrlen((char*)param) + 1]) {
- *pParam = param;
- return;
- }
-
- strncat((char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- strncat((char*)param, (char*)(data + strlen((char*)param)), WSP_STANDARD_STR_LEN_MAX-strlen((char*)param)-1);
-
- *pParam = param;
-
- return;
- }
-
- switch (data[0] & 0x7f) {
- case 0x00:
- wspHeaderDecodeQValue(length - 1, data + 1, ¶m);
- break;
- case 0x01:
- wspHeaderDecodeCharset(length - 1 , data + 1, ¶m);
- break;
- case 0x02:
- wspHeaderDecodeVersion(length - 1, data + 1, ¶m);
- break;
- /* integer */
- case 0x03:
- /* param = (unsigned char *)malloc((size_t)WSP_STANDARD_STR_LEN_MAX); */
- param = new char[WSP_STANDARD_STR_LEN_MAX];
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n");
- return;
- } else {
- snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger(data + 1));
- }
- break;
- case 0x08:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n");
- return;
- } else {
- snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger(data + 1));
- }
- break;
- case 0x05:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x05 MemAlloc failed\n");
- return;
- } else {
- strncpy((char*)param, "Name=", WSP_STANDARD_STR_LEN_MAX-1);
- memcpy(param + 5, data + 1, length - 1);
- param[5 + length - 1] = '\0';
- }
- break;
- case 0x06:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x06 MemAlloc failed\n");
- return;
- } else {
- strncpy((char*)param, "Filename=", WSP_STANDARD_STR_LEN_MAX-1);
- memcpy(param + 9, (char*)(data + 1), (size_t)(length - 1));
- param[9 + length - 1] = '\0';
- }
- break;
- case 0x07:
- param = NULL;
- /* TBI */
- break;
- /*OMA Provisioning*/
- case 0x11:
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeParameter:0x11 MemAlloc failed\n");
- return;
- } else {
- strncpy((char*)param, "SEC=", WSP_STANDARD_STR_LEN_MAX-1);
- SecurityTypeCode = data[1] & 0x7f;
- while ((i < wspSecurityTypeCount) && (wspSecurityType[i].SecurityTypeCode != SecurityTypeCode)) i++;
-
- if (i < wspSecurityTypeCount) {
- strncat((char*)param, (char*)wspSecurityType[i].SecurityTypeName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- }
-
- if (0x12 == (data[2] & 0x7f)) {
- strncat((char*)param, "; MAC=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- memcpy(param+AcStrlen((char*)param), (char*)(data+3), (size_t)length-3);
- }
- }
- break;
-
- default:
- param = NULL;
- break;
- }
-
- *pParam = param;
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString)
-{
- char* param = NULL;
-
- param = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (param == NULL) {
- MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n");
- *pDecodedString = NULL;
- return;
- }
-
- strncpy((char*)param, "charset=", WSP_STANDARD_STR_LEN_MAX-1);
-
- if (data[0] > 0x80) {
- unsigned long code = wspHeaderDecodeInteger(data);
- unsigned long i = 0;
- while (wspCharset[i].charsetCode != code) {
- if (wspCharset[i].charsetCode == 0xffff) {
- *pDecodedString = param;
- return;
- }
- i++;
- }
- strncat((char*)param, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1);
- } else {
- unsigned long lastLen = AcStrlen((char*)param);
- if (length + lastLen < WSP_STANDARD_STR_LEN_MAX - 1) {
- memcpy((char*)(param + lastLen), data, (size_t)length);
- param[length + lastLen] = '\0';
- } else {
- memcpy((char*)(param + lastLen), data, WSP_STANDARD_STR_LEN_MAX - lastLen - 1);
- param[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
- }
- }
-
- *pDecodedString = param;
- return;
-}
-
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString)
-{
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeVersion:MemAlloc failed\n");
- return;
- }
-
- if (length > 1) {
- /* untyped version */
- memcpy(*pDecodedString, data, (size_t)length);
- } else {
- /* typed version */
- unsigned char majorVer = ((data[0] & 0x7f) >> 4);
- unsigned char minorVer = data[0] & 0x0f;
- snprintf((char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer);
- }
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString)
-{
- time_t lTime;
- struct tm pTMData;
-
- MSG_DEBUG("WspLHeaderDecodeDateValue: \n");
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeDateValue:MemAlloc failed\n");
- return;
- }
-
- lTime = wspHeaderDecodeIntegerByLength(data, length);
-
- (struct tm*)gmtime_r((const time_t*)&lTime, &pTMData);
-
- /* check date value validity */
- if ((pTMData.tm_wday > 6) || (pTMData.tm_mon > 11) || (pTMData.tm_mday > 31)) {
- MSG_DEBUG("WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData.tm_wday, pTMData.tm_mon, pTMData.tm_mday);
- strncpy((char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1);
- return;
- }
-
-#ifdef MSG_FW_FOR_DEBUG
- /** Date type selection */
- switch (wspMachineStatus.dateType) {
- /* UNIX asciitime function */
- case UNIX_DATE_TYPE:
- snprintf((char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
- pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900);
- break;
- case RFC1123_DATE_TYPE:
- snprintf((char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData.tm_wday], pTMData.tm_mday,
- wspMonth[pTMData.tm_mon], pTMData.tm_year + 1900, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec);
- break;
- case RFC850_DATE_TYPE:
- /* Have some Y2K Problems */
- /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */
- snprintf((char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData.tm_wday], pTMData.tm_mday,
- wspMonth[pTMData.tm_mon], pTMData.tm_year % CENTURY, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec);
-
- break;
- }
-#endif
- /**UNIX_DATE_TYPE : */
- snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon],
- pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900);
-
- return;
-}
-
-void SmsPluginWapPushHandler::wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper)
-{
- unsigned long elementLen = AcStrlen((char*)szDecodedString);
- char* temper2 = NULL;
-
- /** CR+LF */
- *currentLen = *currentLen + elementLen + 2;
-
- if (*currentLen > AcStrlen((char*)* pTemper) + 2) {
- temper2 = new char[(*currentLen + 1)];
-
- if (temper2 == NULL) {
- MSG_DEBUG("WspLHeaderCopyDecodedString:MemAlloc failed\n");
- return;
- }
- strncpy((char*)temper2, (char*)* pTemper, *currentLen);
- delete[] *pTemper;
- strncpy((char*)temper2, (char*)szDecodedString, *currentLen);
- }
-
- *pTemper = temper2;
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
-{
- unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
- unsigned char passWd[WSP_STANDARD_STR_LEN_MAX];
- unsigned long iField = 0;
- char authStr[256];
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX * 2];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeAuth:MemAlloc failed\n");
- return;
- }
-
- /* skip 'basic' code */
- iField++;
- memset(authStr, 0x00, sizeof(authStr));
- snprintf(authStr, sizeof(authStr), "%%%zus", sizeof(userId));
- sscanf((char*)(fieldValue + iField), authStr, userId);
- iField = iField + AcStrlen((char*)userId) + 1;
- memset(authStr, 0x00, sizeof(authStr));
- snprintf(authStr, sizeof(authStr), "%%%zus", sizeof(passWd));
- sscanf((char*)(fieldValue + iField), authStr, passWd);
- iField = iField + AcStrlen((char*)userId) + 1;
- int wrn = snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd);
- if(wrn<0)
- MSG_DEBUG("snprintf was failed\n");
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString)
-{
- unsigned char userId[WSP_STANDARD_STR_LEN_MAX];
- unsigned long iField = 0;
- char authStr[256];
-
- *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX];
-
- if (*pDecodedString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeChallenge:MemAlloc failed\n");
- return;
- }
-
- /* skip 'basic' code */
- iField++;
- memset(authStr, 0x00, sizeof(authStr));
- snprintf(authStr, sizeof(authStr), "%%%zus", sizeof(userId));
- sscanf((char*)(fieldValue + iField), authStr, userId);
- iField = iField + AcStrlen((char*)userId) + 1;
-
- int wrn = snprintf((char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "basic realm=\"%s\"", userId);
- if(wrn<0)
- MSG_DEBUG("snprintf was failed\n");
-
- return;
-}
-
-
-void SmsPluginWapPushHandler::wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString)
-{
- unsigned char paramString[WSP_STANDARD_STR_LEN_MAX];
- unsigned char cacheCode;
- int wrn =0;
-
- *pCacheString = new char[WSP_STANDARD_STR_LEN_MAX];
- if (*pCacheString == NULL) {
- MSG_DEBUG("WspLHeaderDecodeCacheControl:MemAlloc failed\n");
- return;
- }
-
- if (1 == fieldValueLen) {
- /* only one directive */
- if (fieldValue[0] > 0x8b) {
- return; /* It's error detection. can be omitted. */
- }
- strncpy((char*)*pCacheString, (char*)wspCacheControl[fieldValue[0] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
- return;
- }
-
- if (fieldValue[0] > 0x7f) {
- /* directive that has parameter */
- cacheCode = fieldValue[0] & 0x7f;
- switch (cacheCode) {
- /* field name */
- /* no-cache */
- case 0x00 :
- /* private */
- case 0x07 :
- if (fieldValue[1] > 0x7f) {
- /* well known field name */
- strncpy((char*)paramString, (char*)wspHeaderFieldName[fieldValue[1] & 0x7f], WSP_STANDARD_STR_LEN_MAX-1);
- paramString[WSP_STANDARD_STR_LEN_MAX-1] = '\0';
- } else {
- /* unknown field name */
- strncpy((char*)paramString, (char*)fieldValue + 1 , WSP_STANDARD_STR_LEN_MAX-1);
- }
- break;
- /* secound */
- /* max-age */
- case 0x02 :
- /* max- stale */
- case 0x03 :
- /* min-fresh */
- case 0x04 :
- snprintf((char*)paramString, sizeof(paramString), "%u", (unsigned int)wspHeaderDecodeInteger(fieldValue + 1));
- break;
-
- default :
- break;
- }
- wrn = snprintf((char*)*pCacheString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s=%s", (char*)wspCacheControl[cacheCode], (char*)paramString);
- if(wrn<0)
- MSG_DEBUG("snprintf was failed");
- } else {
- /* cache extentions */
- /* In case of come directive of doesn't specified string style */
-
- unsigned long stringLen;
- char szString[32];
- strncpy((char*)*pCacheString, (char*)fieldValue, WSP_STANDARD_STR_LEN_MAX-1);
- stringLen = AcStrlen((char*)*pCacheString);
-
- if (stringLen + 1 < fieldValueLen) {
- if (fieldValue[stringLen+ 1] > 0x7f) {
- int untyped = (int)wspHeaderDecodeIntegerByLength(fieldValue + stringLen + 1, fieldValueLen - (stringLen + 1));
-
- snprintf(szString, sizeof(szString), "%d", untyped);
- strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- strncat((char*)*pCacheString, (char*)szString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- } else {
- if (fieldValue[fieldValueLen] == 0) {
- strncat((char*)*pCacheString, (char*)"=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- strncat((char*)*pCacheString, (char*)fieldValue + stringLen + 1 , WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pCacheString)-1);
- }
- }
- }
- }
-
- return;
-}
-
-void SmsPluginWapPushHandler::getDisplayName(MSG_SUB_TYPE_T subType, char* displayName)
-{
- if (subType == MSG_WAP_SL_SMS || subType == MSG_WAP_SI_SMS)
- snprintf(displayName, MAX_ADDRESS_VAL_LEN + 1, "Push message");
- return;
-}
#ifndef SMS_PLUGIN_CALLBACK_H
#define SMS_PLUGIN_CALLBACK_H
-
/*==================================================================================================
INCLUDE FILES
==================================================================================================*/
-#include <map>
-#include <vector>
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TelSim.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
- #include <ITapiNetwork.h>
-}
-
-/*==================================================================================================
- FUNCTION PROTOTYPES
-==================================================================================================*/
-void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventSatSmsSentStatus(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-void TapiEventCbMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-void TapiEventEtwsMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSetSmscInfo(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data);
+#include <tapi_common.h>
-void TapiEventSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetSimServiceTable(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetParamCnt(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSatSmsRefresh(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventSatSendSms(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventSatMoSmsCtrl(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSimFileInfo(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventSimReadFile(TapiHandle *handle, int result, void *data, void *user_data);
-void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventGetMeImei(TapiHandle *handle, int result, void *data, void *user_data);
-
-void TapiEventSimStatusChange(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-void TapiEventSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-
-SMS_NETWORK_STATUS_T convertTapiRespToSmsPlugin(int result);
+#include "SmsPluginTypes.h"
/*==================================================================================================
CLASS DEFINITIONS
==================================================================================================*/
-class SmsPluginCallback
+class SmsPluginCallbacks
{
public:
- static SmsPluginCallback* instance();
+ static void registerEvents();
+ static void deRegisterEvents();
+
+ static void tapiNotiSmsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void tapiNotiSmsCbIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void tapiNotiSmsEtwsIncomMsg(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
- void registerEvent();
- void deRegisterEvent();
+ static void tapiNotiSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void tapiNotiSatMoSmControlResult(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void tapiNotiSimStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void tapiNotiSimRefreshed(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
-private:
- SmsPluginCallback();
- ~SmsPluginCallback();
+ static void tapiNotiSmsDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void tapiNotiNetworkRegistrationStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
- static SmsPluginCallback* pInstance;
+ static void tapiNotiSmsMemoryStatus(TapiHandle *handle, const char *noti_id, void *data, void *user_data);
+ static void vconfDnetStateChanged(keynode_t *key, void* data);
};
#endif /* SMS_PLUGIN_CALLBACK_H */
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_CBMSG_HANDLER_H
-#define SMS_PLUGIN_CBMSG_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include <map>
-#include <vector>
-
-using namespace std;
-
-#include "MsgTextConvert.h"
-#include "SmsPluginTypes.h"
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <ITapiNetText.h>
-}
-
-
-/*==================================================================================================
- VARIABLES
-==================================================================================================*/
-typedef map<unsigned char, SMS_CBMSG_PAGE_S> cbPageMap;
-
-
-typedef struct _CB_PAGE_INFO_S {
- unsigned char geoScope;
- unsigned char updateNum;
- unsigned short msgCode;
- unsigned short msgId;
- unsigned char totalPages;
-
- unsigned char pageCnt;
- unsigned int totalSize;
- cbPageMap data;
-} CB_PAGE_INFO_S;
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginCbMsgHandler
-{
-public:
- static SmsPluginCbMsgHandler* instance();
-
- void handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMsg);
- void handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *pEtwsMsg);
-
-private:
- SmsPluginCbMsgHandler();
- virtual ~SmsPluginCbMsgHandler();
-
- static SmsPluginCbMsgHandler* pInstance;
-
- void Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage);
- void Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage);
- void DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PRIMARY_S *pEtwsPn);
- unsigned short encodeCbSerialNum(SMS_CBMSG_SERIAL_NUM_S snFields);
- int getCMASType(unsigned short message_id);
-
- bool checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex);
- unsigned char checkCbPage(SMS_CBMSG_PAGE_S *CbPage);
- void MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg);
- void convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex);
- void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex);
- int convertTextToUtf8(unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg);
- void addToPageList(SMS_CBMSG_PAGE_S *CbPage);
- void removeFromPageList(SMS_CBMSG_PAGE_S *CbPage);
-
- void decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs);
- void convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType);
- unsigned long getRecvTime();
- void getDisplayName(unsigned short MsgId, char *pDisplayName, msg_sim_slot_id_t simIndex);
-
- vector<CB_PAGE_INFO_S> pageList;
-};
-
-#endif /* SMS_PLUGIN_CBMSG_HANDLER_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_CONCAT_HANDLER_H
-#define SMS_PLUGIN_CONCAT_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include <string>
-#include <map>
-#include <vector>
-
-using namespace std;
-
-#include "MsgTextConvert.h"
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- VARIABLES AND DEFINES
-==================================================================================================*/
-#define MAX_CONCAT_LIST 10
-
-struct CONCAT_DATA_S {
- int length;
- char data[MAX_USER_DATA_LEN+1];
-};
-
-typedef map<unsigned char, CONCAT_DATA_S> concatDataMap;
-
-typedef struct _SMS_CONCAT_MSG_S {
- unsigned short msgRef;
- unsigned char totalSeg;
- unsigned char seqNum;
-
- SMS_TIMESTAMP_S timeStamp;
- SMS_ADDRESS_S originAddress;
- SMS_DCS_S dcs;
- bool bRead;
- int simId;
- int simIndex;
-} SMS_CONCAT_MSG_S;
-
-typedef struct _SMS_CONCAT_INFO_S {
- unsigned short msgRef;
- unsigned char totalSeg;
- unsigned char segCnt;
-
- SMS_TIMESTAMP_S timeStamp;
- SMS_ADDRESS_S originAddress;
- SMS_DCS_S dcs;
- bool bRead;
-
- unsigned int totalSize;
- concatDataMap data;
- int simIdList[MAX_SIM_SMS_NUM];
- unsigned int display_time;
- int simIndex;
-} SMS_CONCAT_INFO_S;
-
-typedef struct _SMS_SIM_ID_S {
- unsigned short msgRef;
- msg_sim_id_t simId;
-} SMS_SIM_ID_S;
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginConcatHandler
-{
-public:
- static SmsPluginConcatHandler* instance();
-
- bool IsConcatMsg(SMS_USERDATA_S *pUserData);
- void handleConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu);
- void handleSimConcatMsg(TapiHandle *handle, SMS_TPDU_S *pTpdu, int msgId, int bRead, int *simIdList);
-/* void handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t SimMsgId, bool bRead); */
-/* void handleBrokenMsg(); */
-
-private:
- SmsPluginConcatHandler();
- virtual ~SmsPluginConcatHandler();
-
- static SmsPluginConcatHandler* pInstance;
-
- unsigned char checkConcatMsg(SMS_CONCAT_MSG_S *pConcatMsg, SMS_USERDATA_S *pUserData);
- int makeConcatUserData(unsigned short MsgRef, int simIndex, char **ppTotalData, char *originAddress);
-
- void convertConcatToMsginfo(const SMS_DELIVER_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
- void convertConcatToMsginfo(const SMS_SUBMIT_S *pTpdu, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo);
-/* void convertSimMsgToMsginfo(const SMS_CONCAT_MSG_S *pConcatMsg, const char *pUserData, int DataSize, MSG_MESSAGE_INFO_S *pMsgInfo); */
-
- void removeFromConcatList(unsigned short MsgRef, int simIndex, char *originAddress);
-
-/* void addToSimIdList(unsigned short MsgRef, msg_sim_id_t SimMsgId); */
-/* void removeFromSimIdList(unsigned short MsgRef); */
-
- vector<SMS_CONCAT_INFO_S> concatList;
-/* vector<SMS_SIM_ID_S> simIdList; */
-};
-
-#endif /* SMS_PLUGIN_CONCAT_HANDLER_H */
#ifndef SMS_PLUGIN_DS_HANDLER_H
#define SMS_PLUGIN_DS_HANDLER_H
-
/*==================================================================================================
INCLUDE FILES
==================================================================================================*/
-#include "SmsPluginTypes.h"
+#include <map>
+#include <vector>
+#include <tapi_common.h>
+#include "SmsPluginTypes.h"
/*==================================================================================================
CLASS DEFINITIONS
class SmsPluginDSHandler
{
public:
+ enum HandleType {
+ H_3GPP,
+ H_3GPP2
+ };
+
static SmsPluginDSHandler* instance();
+
int initTelHandle();
void deinitTelHandle();
- TapiHandle *getTelHandle(int sim_idx);
+
+ TapiHandle *getTelHandle(int simIndex);
+ int getSimIndex(TapiHandle *handle);
int getTelHandleCount();
int getActiveSimCount();
- int getSimIndex(TapiHandle *handle);
- void getDefaultNetworkSimId(int *simId);
+ void getDefaultNetworkSimId(int *simIndex);
+ msg_error_t getSubscriberId(int simIndex, char **subscriber_id);
+
+
+ int getSmsFormat(TapiHandle *handle);
+ void setSmsFormat(TapiHandle *handle, int smsFormat);
- int getSubscriberId(unsigned int simIndex, char **subscriber_id);
+ bool getNeedToInitializeSim(TapiHandle *handle);
+ void setNeedToInitializeSim(TapiHandle *handle, bool needToInitialize);
+
+ HandleType getHandleType(TapiHandle *handle);
private:
+ SmsPluginDSHandler() = default;
+ ~SmsPluginDSHandler() = default;
+
static SmsPluginDSHandler* pInstance;
- SmsPluginDSHandler();
- virtual ~SmsPluginDSHandler();
- char **cp_list;
- SMS_TELEPHONY_HANDLE_LIST_S handle_list;
+ std::vector<std::pair<TapiHandle *, HandleType>> tapiHandles;
+ std::map<TapiHandle *, int> smsFormatInfo;
+ std::map<TapiHandle *, bool> _needToInitializeSim;
};
#endif /* SMS_PLUGIN_DS_HANDLER_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_EVENT_HANDLER_H
-#define SMS_PLUGIN_EVENT_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-#include "MsgTextConvert.h"
-#include "MsgPluginInterface.h"
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginEventHandler
-{
-public:
- static SmsPluginEventHandler* instance();
-
- void registerListener(MSG_PLUGIN_LISTENER_S *pListener);
- void handleSentStatus(msg_network_status_t NetStatus);
- void handleMsgIncoming(TapiHandle *handle, SMS_TPDU_S *pTpdu);
- void handleSyncMLMsgIncoming(msg_syncml_message_type_t msgType, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, int simIndex);
- void handleLBSMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen);
- void handlePushMsgIncoming(char* pPushHeader, char* pPushBody, int pushBodyLen, char *app_id, char *content_type);
- void handleResendMessage(void);
-
- msg_error_t callbackMsgIncoming(MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t callbackCBMsgIncoming(MSG_CB_MSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t callbackInitSimBySat();
- msg_error_t callbackStorageChange(msg_storage_change_type_t storageChangeType, MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t callbackThreadChange(msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId);
- msg_error_t handleSimMsg(MSG_MESSAGE_INFO_S *pMsgInfo, int *simIdList, msg_message_id_t *retMsgId, int listSize);
- msg_error_t updateIMSI(int sim_idx);
- void handleSimMemoryFull(int simIndex);
-
- void SetSentInfo(SMS_SENT_INFO_S *pSentInfo);
-
- void setDeviceStatus(TapiHandle *handle);
- bool getDeviceStatus(TapiHandle *handle);
-
- /* temp */
- void convertTpduToMsginfo(SMS_TPDU_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
-
- MSG_SUB_TYPE_T convertMsgSubType(SMS_PID_T pid);
-
-private:
- SmsPluginEventHandler();
- virtual ~SmsPluginEventHandler();
-
- void convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
- void convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
- void convertStatusRepTpduToMsginfo(const SMS_STATUS_REPORT_S *pTpdu, MSG_MESSAGE_INFO_S *msgInfo);
-
- static SmsPluginEventHandler* pInstance;
-
- MSG_PLUGIN_LISTENER_S listener;
- MSG_SIM_COUNT_S* pSimCnt;
- SMS_SENT_INFO_S sentInfo;
-
- bool devStatus;
- bool bUdhMwiMethod;
- int udhMwiCnt;
-
- MsgMutex mx;
- MsgCndVar cv;
- TapiHandle *devHandle;
-};
-
-#endif /* SMS_PLUGIN_EVENT_HANDLER_H */
-
#ifndef SMS_PLUGIN_MAIN_H
#define SMS_PLUGIN_MAIN_H
-
/*==================================================================================================
INCLUDE FILES
==================================================================================================*/
-#include "SmsPluginTypes.h"
#include "MsgPluginInterface.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
/*==================================================================================================
FUNCTION PROTOTYPES
==================================================================================================*/
msg_error_t SmsPlgInitialize();
-
msg_error_t SmsPlgFinalize();
-
msg_error_t SmsPlgRegisterListener(MSG_PLUGIN_LISTENER_S *pListener);
-
msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo);
-
msg_error_t SmsPlgSaveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
-
-msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
-
-msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
-
+msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t simIndex, msg_sim_id_t SimMsgId);
+msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t simIndex, msg_sim_id_t SimMsgId);
msg_error_t SmsPlgSetMemoryStatus(msg_sim_slot_id_t simIndex, msg_error_t Error);
-
msg_error_t SmsPlgSetConfigData(const MSG_SETTING_S *pSetting);
-
msg_error_t SmsPlgGetConfigData(MSG_SETTING_S *pSetting);
-
msg_error_t SmsPlgAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo, char* pFileData);
-
msg_error_t SmsPlgGetDefaultNetworkSimId(int *simId);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* SMS_PLUGIN_MAIN_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_PARAMCODEC_H
-#define SMS_PLUGIN_PARAMCODEC_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginParamCodec
-{
-public:
- SmsPluginParamCodec();
- virtual ~SmsPluginParamCodec();
-
- static int encodeAddress(const SMS_ADDRESS_S *pAddress, char **ppParam);
- static int encodeTime(const SMS_TIMESTAMP_S *pTimeStamp, char **ppParam);
- static int encodeDCS(const SMS_DCS_S *pDCS, char **ppParam);
- static int encodeSMSC(const char *pAddress, unsigned char *pEncodeAddr);
- static int encodeSMSC(const SMS_ADDRESS_S *pAddress, unsigned char *pSMSC);
-
- static int decodeAddress(const unsigned char *pTpdu, SMS_ADDRESS_S *pAddress);
- static int decodeTime(const unsigned char *pTpdu, SMS_TIMESTAMP_S *pTimeStamp);
- static int decodeDCS(const unsigned char *pTpdu, SMS_DCS_S *pDCS);
- static void decodeSMSC(unsigned char* pAddress, int AddrLen, MSG_SMS_TON_T ton, char *pDecodeAddr);
-
- static bool checkCphsVmiMsg(const unsigned char *pTpdu, int *setType, int *indType);
-
- static time_t convertTime(const SMS_TIMESTAMP_S *time_stamp);
-
-private:
- static int convertDigitToBcd(char *pDigit, int DigitLen, unsigned char *pBcd);
- static int convertBcdToDigit(const unsigned char *pBcd, int BcdLen, char *pDigit);
-};
-
-#endif /* SMS_PLUGIN_PARAMCODEC_H */
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_SAT_HANDLER_H
-#define SMS_PLUGIN_SAT_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsPluginTypes.h"
-#include "MsgMutex.h"
-
-extern "C"
-{
- #include <TelSat.h>
-}
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginSatHandler
-{
-public:
- static SmsPluginSatHandler* instance();
-
- void refreshSms(TapiHandle *handle, void *pData);
- void sendSms(TapiHandle *handle, void *pData);
- void ctrlSms(TapiHandle *handle, void *pData);
- void ctrlSms(TapiHandle *handle, SMS_NETWORK_STATUS_T netStatus);
-
- void finishSimMsgInit(msg_error_t Err);
-
-private:
- SmsPluginSatHandler();
- virtual ~SmsPluginSatHandler();
-
- void initSim();
-
- void initSMSCList();
- void initCBConfig();
-
- int handleSatTpdu(unsigned char *pTpdu, unsigned char TpduLen, int bIsPackingRequired);
-
- void sendResult(TapiHandle *handle, SMS_SAT_CMD_TYPE_T CmdType, int ResultType);
-
- static SmsPluginSatHandler* pInstance;
-
- int commandId;
-
- bool bInitSim;
- bool bSMSPChanged;
- bool bCBMIChanged;
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_PLUGIN_SAT_HANDLER_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_SETTING_H
-#define SMS_PLUGIN_SETTING_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-#include "MsgSettingTypes.h"
-#include <list>
-#include <map>
-
-extern "C"
-{
- #include <tapi_common.h>
-}
-
-typedef map <int, MSG_SMSC_LIST_S> smscListMap;
-typedef map <int, SMS_SIM_MAILBOX_LIST_S> smsSimMailboxListMap;
-typedef map <int, SMS_SIM_MWI_INFO_S> simMwiInfoMap;
-typedef map <int, MSG_CBMSG_OPT_S> cbOptMap;
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginSetting
-{
-public:
- static SmsPluginSetting* instance();
-
- void setConfigData(const MSG_SETTING_S *pSetting);
- void getConfigData(MSG_SETTING_S *pSetting);
- void getMeImei(char *pImei);
-
- void setParamCntEvent(int ParamCnt);
- void setParamEvent(TapiHandle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess);
- void setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess);
- void setMailboxInfoEvent(TapiHandle *handle, SMS_SIM_MAILBOX_LIST_S *pVoiceOpt, bool bSuccess, bool bMbdn);
- void setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count);
- void setMwiInfoEvent(TapiHandle *handle, SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess);
- void setResultFromSim(bool bResult);
- void setResultImei(bool bResult, char *pImei);
-
- void setSmscInfo(const MSG_SMSC_LIST_S *pSmscList);
-
- void setSimChangeStatus(TapiHandle *handle, bool bInitializing);
- void getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList);
- void SimRefreshCb(TapiHandle *handle);
-
-private:
- SmsPluginSetting();
- ~SmsPluginSetting();
-
- void updateSimStatus(TapiHandle *handle);
-
- void initConfigData(TapiHandle *handle);
- static void* init_config_data(void *data);
- static void* initSimInfo(void *data);
- void* processInitSimInfo(void *data);
-
- void addSMSCList(MSG_SMSC_LIST_S *pSmscList);
-
- msg_error_t addCbOpt(MSG_CBMSG_OPT_S *pCbOpt);
- void getCbOpt(MSG_SETTING_S *pSetting, int simIndex);
-
- void setParamList(const MSG_SMSC_LIST_S *pSMSCList);
- void getParamList(MSG_SMSC_LIST_S *pSMSCList);
-
- int getParamCount(TapiHandle *handle);
- bool getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData);
-
- bool setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt);
- bool getCbConfig(MSG_CBMSG_OPT_S *pCbOpt);
-
- void setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt);
- bool getVoiceMailInfo(TapiHandle *handle);
-
- bool getMwiInfo(TapiHandle *handle);
- bool getMsisdnInfo(TapiHandle *handle);
- bool getSimServiceTable(TapiHandle *handle);
- bool getResultImei(char *pImei);
-
- int getParamCntEvent();
- bool getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData);
- bool getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt);
-
- bool getMailboxInfoEvent();
-
- bool getResultFromSim();
-
- SMS_PID_T convertPid(MSG_SMS_PID_T pid);
- void deliverVoiceMsgNoti(int simIndex, int mwiCnt);
-
- static SmsPluginSetting* pInstance;
- std::list<TapiHandle *> tel_handle_list;
-
- /* Setting values for keeping in setting instance */
- smscListMap smscList;
- MSG_SIM_STATUS_T simStatus[MAX_TELEPHONY_HANDLE_CNT+1];
- MSG_SMSC_DATA_S smscData[MAX_TELEPHONY_HANDLE_CNT+1];
- smsSimMailboxListMap simMailboxList;
- simMwiInfoMap simMwiInfo;
- cbOptMap cbOpt;
-
- /* Local values for getting from SIM(TAPI) */
- bool bTapiResult;
- int paramCnt;
- int selectedParam;
- int selectedSimIndex;
- char meImei[MAX_ME_IMEI_LEN + 1];
-
- bool bMbdnEnable[MAX_TELEPHONY_HANDLE_CNT+1];
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_PLUGIN_SETTING_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_SIMMSG_H
-#define SMS_PLUGIN_SIMMSG_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-
-#include "MsgStorageTypes.h"
-#include "SmsPluginTypes.h"
-#include "MsgInternalTypes.h"
-
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
-}
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginSimMsg
-{
-public:
- static SmsPluginSimMsg* instance();
-
- void initSimMessage(struct tapi_handle *handle);
- msg_error_t saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList);
- msg_error_t saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo);
- void deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
- void setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId);
- bool checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int SegCnt);
-
- void setSimMsgCntEvent(struct tapi_handle *handle, const MSG_SIM_COUNT_S *pSimMsgCnt);
- void setSimMsgEvent(struct tapi_handle *handle, const MSG_MESSAGE_INFO_S *pMsgInfo, bool bSuccess);
- void setSaveSimMsgEvent(struct tapi_handle *handle, int simId, int result);
- void setSaveClass2MsgEvent(struct tapi_handle *handle, int simId, int result, MSG_MESSAGE_INFO_S *data);
- void setSimEvent(msg_sim_id_t SimId, bool bResult);
- void setUpdateSimEvent(int SimId, bool bResult);
- void setDelSimEvent(int SimId, bool bResult);
-
- void setSmsData(const char *sca, const char *szData, int msgLength);
- void setSmsTpduTotalSegCount(int totalSeg);
-
-private:
- SmsPluginSimMsg();
- ~SmsPluginSimMsg();
-
- void getSimMsgCount(struct tapi_handle *handle, MSG_SIM_COUNT_S *pSimMsgCnt);
- bool getSimMsg(struct tapi_handle *handle, msg_sim_id_t SimMsgId, MSG_MESSAGE_INFO_S* pMsgInfo, int *simIdList);
-
- void setSmsOptions(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_DELIVER_S *pDeliver);
- void convertTimeStamp(const MSG_MESSAGE_INFO_S* pMsgInfo, SMS_DELIVER_S *pDeliver);
-
- bool getSimMsgCntEvent(struct tapi_handle *handle, MSG_SIM_COUNT_S *pSimMsgCnt);
- bool getSimMsgEvent(struct tapi_handle *handle, MSG_MESSAGE_INFO_S *pMsgInfo);
- bool getSimEvent(msg_sim_id_t *pSimId);
- bool getUpdateSimEvent();
- bool getDelSimEvent(int *pSimId);
-
-
- static SmsPluginSimMsg* pInstance;
-
- msg_sim_id_t simMsgId;
- int delSimMsgId;
- int simIdList[MAX_SIM_SMS_NUM]; /** send total simIds to handleSimMsg **/
-
- MSG_SIM_COUNT_S simMsgCnt;
-
- MSG_MESSAGE_INFO_S simMsgInfo;
- MSG_ADDRESS_INFO_S simAddrInfo;
-
- int usedCnt;
- int totalCnt;
-
- bool bTapiResult;
-
- SMS_DATA_INFO_S simMsgDataInfo;
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_PLUGIN_SIMMSG_H */
-
#ifndef SMS_PLUGIN_STORAGE_H
#define SMS_PLUGIN_STORAGE_H
-
/*==================================================================================================
INCLUDE FILES
==================================================================================================*/
-#include "MsgMutex.h"
+#include <list>
#include "MsgStorageTypes.h"
-#include "SmsPluginTypes.h"
#include "MsgInternalTypes.h"
#include "MsgSqliteWrapper.h"
-#include <list>
-extern "C"
-{
- #include <tapi_common.h>
- #include <TelSms.h>
- #include <TapiUtility.h>
- #include <ITapiNetText.h>
-}
/*==================================================================================================
CLASS DEFINITIONS
public:
static SmsPluginStorage* instance();
- msg_error_t insertMsgRef(MSG_MESSAGE_INFO_S *pMsg, unsigned char msgRef, int index);
- msg_error_t updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInfo, unsigned char msgRef);
-
msg_error_t updateSentMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_network_status_t Status);
-/* msg_error_t updateMsgRef(msg_message_id_t MsgId, unsigned char MsgRef); */
-/* msg_error_t updateStatusReport(unsigned char MsgRef, msg_delivery_report_status_t Status, time_t DeliveryTime); */
-
- msg_error_t addSimMessage(MSG_MESSAGE_INFO_S *pSimMsgInfo, int *simIdList);
- msg_error_t insertSimMessage(int simId, int msgId);
- msg_error_t deleteSimMessage(int sim_idx, int simId);
- msg_error_t checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
msg_error_t addSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
+ msg_error_t updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
msg_error_t deleteSmsMessage(msg_message_id_t msgId);
-#if 0
- msg_error_t isReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage);
- msg_error_t insertReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage);
-#endif
msg_error_t addSmsSendOption(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo);
- msg_error_t getReplaceSimMsg(const MSG_MESSAGE_INFO_S *pMsg, int *pMsgId, int *pSimId);
-
+ msg_error_t checkMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
msg_error_t checkStorageStatus(MSG_MESSAGE_INFO_S *pMsgInfo);
+
+ msg_error_t deleteFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId);
+ msg_error_t setFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int failedIndex);
+ int getFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId);
+ bool isDuplicatedCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo);
+
msg_error_t getRegisteredPushEvent(char* pPushHeader, int *count, char *app_id, int app_id_len, char *content_type, int content_type_len);
msg_error_t getnthPushEvent(int index, int *appcode);
msg_error_t releasePushEvent();
- msg_error_t updateSmsMessage(MSG_MESSAGE_INFO_S *pMsgInfo);
- bool isDuplicatedCBMsg(MSG_MESSAGE_INFO_S *pMsgInfo);
- msg_error_t setFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId, int failedIndex);
- int getFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId);
- msg_error_t deleteFailedIndex(MsgDbHandler *pDbHandle, msg_message_id_t msgId);
private:
- SmsPluginStorage();
- ~SmsPluginStorage();
-
- msg_error_t addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo);
+ SmsPluginStorage() = default;
+ ~SmsPluginStorage() = default;
static SmsPluginStorage* pInstance;
- static void* class2_thread(void *data);
-
- MSG_MESSAGE_INFO_S msgInfo;
- MSG_ADDRESS_INFO_S addrInfo;
-
std::list<PUSH_APPLICATION_INFO_S> pushAppInfoList;
- /* unsigned char tmpMsgRef; */
};
#endif /* SMS_PLUGIN_STORAGE_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_TPDU_CODEC_H
-#define SMS_PLUGIN_TPDU_CODEC_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginTpduCodec
-{
-public:
- SmsPluginTpduCodec();
- virtual ~SmsPluginTpduCodec();
-
- static int encodeTpdu(const SMS_TPDU_S *pSmsTpdu, char *pTpdu);
- static int decodeTpdu(const unsigned char *pTpdu, int TpduLen, SMS_TPDU_S *pSmsTpdu);
-
-private:
- static int encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu);
- static int encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu);
- static int encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliverRep, char *pTpdu);
- static int encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep, char *pTpdu);
-
- static int decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_SUBMIT_S *pSubmit);
- static int decodeDeliver(const unsigned char *pTpdu, int TpduLen, SMS_DELIVER_S *pDeliver);
- static int decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep);
-};
-
-#endif /* SMS_PLUGIN_TPDU_CODEC_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_TRANSPORT_H
-#define SMS_PLUGIN_TRANSPORT_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-#include "MsgTextConvert.h"
-#include "MsgTransportTypes.h"
-#include "MsgSettingTypes.h"
-#include "SmsPluginTypes.h"
-#include "MsgInternalTypes.h"
-
-extern "C"
-{
- #include <TelSat.h>
-}
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginTransport
-{
-public:
- static SmsPluginTransport* instance();
-
- void submitRequest(SMS_REQUEST_INFO_S *pReqInfo);
- void sendDeliverReport(struct tapi_handle *handle, msg_error_t err);
- void sendClass0DeliverReport(struct tapi_handle *handle, msg_error_t err);
-
- void setSmscOptions(int simIndex, SMS_ADDRESS_S *pSmsc);
-
- void msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SUBMIT_DATA_S *pData, SMS_CODING_SCHEME_T *pCharType, int addrIndex);
- void setConcatHeader(SMS_UDH_S *pSrcHeader, SMS_UDH_S *pDstHeader);
-
- void setNetStatus(SMS_NETWORK_STATUS_T sentStatus);
- SMS_NETWORK_STATUS_T getNetStatus();
-
- void setMoCtrlStatus(TelSatMoSmCtrlIndData_t *moCtrlData);
- int getMoCtrlStatus();
-
- unsigned char getMsgRef();
-
-private:
- SmsPluginTransport();
- ~SmsPluginTransport();
-
- void getSmsSendOption(int simIndex, SMS_SUBMIT_S *pSubmit);
- void setSmsSendOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_S* pSmsTpdu);
- void setSmsDcsOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_S* pSmsTpdu);
- void setSmsReportOption(SMS_REQUEST_INFO_S *pReqInfo, SMS_TPDU_S* pSmsTpdu);
-
- int getSegmentSize(SMS_CODING_SCHEME_T CodingScheme, int DataLen, bool bPortNum, MSG_LANGUAGE_ID_T LangId, int ReplyAddrLen);
- SMS_PID_T convertPid(MSG_SMS_PID_T pid);
-
- static SmsPluginTransport* pInstance;
-
- unsigned char msgRef;
-
- unsigned char msgRef8bit;
- unsigned short msgRef16bit;
-
- SMS_NETWORK_STATUS_T curStatus;
- TelSatMoSmCtrlIndData_t curMoCtrlData;
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_PLUGIN_TRANSPORT_H */
-
#ifndef SMS_PLUGIN_TYPES_H
#define SMS_PLUGIN_TYPES_H
-
/*==================================================================================================
INCLUDE FILES
==================================================================================================*/
#include "MsgStorageTypes.h"
#include "MsgSettingTypes.h"
-extern "C"
-{
- #include <tapi_common.h>
-}
-
/*==================================================================================================
DEFINES
==================================================================================================*/
-#define MAX_ADDRESS_LEN 21 /* including '+' */
-#define MAX_USER_DATA_LEN 160
-#define MAX_GSM_7BIT_DATA_LEN 160
-#define MAX_UCS2_DATA_LEN 140
-/* #define MAX_TPDU_DATA_LEN 165 */
-#define MAX_TPDU_DATA_LEN 255
-#define MAX_SMS_SEND_RETRY 4
-#define MAX_SMSC_LEN 20
-#define MAX_ADD_PARAM_LEN 12
-#define MAX_DCS_PARAM_LEN 1
-#define MAX_ABS_TIME_PARAM_LEN 7
-#define MAX_REL_TIME_PARAM_LEN 1
-#define MAX_UD_HEADER_NUM 7
-#define MAX_SAT_TPDU_LEN 175
-#define MAX_CBMSG_PAGE_SIZE 82
-#define MAX_CBMSG_TOTAL_PAGE_SIZE 1252 /* 6 + 1 + (MAX_CBMSG_PAGE_SIZE + 1) * MAX_CBMSG_PAGE_NUM = 1252 */
-#define MAX_ETWS_SIZE 56
-#define MAX_CBMSG_PAGE_NUM 15
-#define MAX_SIM_SMS_NUM 255
-#define MAX_SIM_IMSI_NUM 20
-#define MAX_SIM_MSP_CNT 2
-
-#define SMS_PUSH_XML_HREF_TAG "href"
-#define SMS_PUSH_XML_SI_ID_TAG "si-id"
-#define SMS_PUSH_XML_CREATED_TAG "created"
-#define SMS_PUSH_XML_EXPIRES_TAG "si-expires"
-#define SMS_PUSH_XML_ACTION_TAG "action"
-
-#define SMS_PUSH_XML_INVAL_OBJ "invalidate-object"
-#define SMS_PUSH_XML_INVAL_SVC "invalidate-service"
-#define SMS_PUSH_XML_CO_URI "uri"
+#define MAX_SMS_SEND_RETRY 4
+#define MAX_SMS_SEND_RETRY_FOR_3GPP2 2
/*==================================================================================================
TYPES
==================================================================================================*/
-typedef unsigned char SMS_TPDU_TYPE_T; /* _SMS_TPDU_TYPE_E */
-
-typedef unsigned char SMS_VPF_T; /* _SMS_VPF_E */
-
-typedef unsigned char SMS_TON_T; /* _SMS_TON_E */
-
-typedef unsigned char SMS_NPI_T; /* _SMS_NPI_E */
-
-typedef unsigned char SMS_PID_T; /* _SMS_PID_E */
-
-typedef unsigned char SMS_MSG_CLASS_T; /* _SMS_MSG_CLASS_E */
-
-typedef unsigned char SMS_CODING_SCHEME_T; /* _SMS_CODING_SCHEME_E */
-
-typedef unsigned char SMS_CODING_GROUP_T; /* _SMS_CODING_GROUP_E */
-
-typedef unsigned char SMS_INDICATOR_TYPE_T; /* _SMS_INDICATOR_TYPE_E */
-
-typedef unsigned char SMS_TIME_FORMAT_T; /* _SMS_TIME_FORMAT_E */
-
-typedef unsigned char SMS_FAIL_CAUSE_T; /* _SMS_FAIL_CAUSE_E */
-
-typedef unsigned char SMS_STATUS_T; /* _SMS_STATUS_E */
-
-typedef unsigned char SMS_REF_NUMBER_T; /* _SMS_REF_NUMBER_E */
-
-typedef unsigned char SMS_REPORT_TYPE_T; /* _SMS_REPORT_TYPE_E */
-
-typedef unsigned char SMS_UDH_TYPE_T; /* _SMS_UDH_TYPE_E */
-
-typedef unsigned char SMS_WAP_APP_CODE_T; /* _SMS_WAP_APP_CODE_E */
-
-typedef unsigned char SMS_CB_NETWORK_TYPE_T; /* _SMS_CB_NETWORK_TYPE_E */
-
-typedef unsigned char SMS_CBMSG_TYPE_T; /* _SMS_CBMSG_TYPE_E */
-
-typedef unsigned char SMS_CBMSG_LANG_TYPE_T; /* _SMS_CBMSG_LANG_TYPE_E */
-
-typedef unsigned char SMS_CBMSG_CODING_GROUP_T; /* _SMS_CBMSG_CODING_GROUP_E */
-
-typedef unsigned char SMS_SAT_CMD_TYPE_T; /* _SMS_SAT_CMD_TYPE_E */
-
-typedef unsigned short SMS_SIM_EFILE_NAME_T; /* _SMS_SIM_EFILE_NAME_E */
-
-typedef unsigned char SMS_SIM_MAILBOX_TYPE_T; /* _SMS_SIM_MAILBOX_TYPE_E */
-
-typedef unsigned char SMS_NETWORK_STATUS_T; /* _SMS_NETWORK_STATUS_E */
-
/*==================================================================================================
ENUMS
==================================================================================================*/
-enum _SMS_TPDU_TYPE_E {
- SMS_TPDU_SUBMIT,
- SMS_TPDU_DELIVER,
- SMS_TPDU_DELIVER_REP,
- SMS_TPDU_STATUS_REP,
-};
-
-
-enum _SMS_VPF_E {
- SMS_VPF_NOT_PRESENT = 0,
- SMS_VPF_ENHANCED,
- SMS_VPF_RELATIVE,
- SMS_VPF_ABSOLUTE,
-};
-
-
-enum _SMS_TON_E {
- SMS_TON_UNKNOWN = 0, /* unknown */
- SMS_TON_INTERNATIONAL, /* international */
- SMS_TON_NATIONAL, /* national */
- SMS_TON_NETWORK, /* network */
- SMS_TON_SUBSCRIBER, /* subscriber */
- SMS_TON_ALPHANUMERIC, /* alpha numberic */
- SMS_TON_ABBREVIATED, /* abbreviated */
- SMS_TON_RESERVE, /* reserve */
-};
-
-
-enum _SMS_NPI_E {
- SMS_NPI_UNKNOWN = 0, /* unknown */
- SMS_NPI_ISDN = 1, /* idsn */
- SMS_NPI_DATA = 3, /* data */
- SMS_NPI_TELEX = 4, /* telex */
- SMS_NPI_SMSC = 5, /* smsc */
- SMS_NPI_NATIONAL = 8, /* national */
- SMS_NPI_PRIVATE = 9, /* private */
- SMS_NPI_ERMES = 10, /* ermes */
-};
-
-
-enum _SMS_PID_E {
- SMS_PID_NORMAL = 0x00,
-
- SMS_PID_TELEX = 0x21,
- SMS_PID_GROUP3_TELEX = 0x22,
- SMS_PID_GROUP4_TELEX = 0x23,
- SMS_PID_VOICE = 0x24,
- SMS_PID_ERMES = 0x25,
- SMS_PID_NPS = 0x26,
- SMS_PID_VIDEO = 0x27,
- SMS_PID_TELETEX_UNSPEC = 0x28,
- SMS_PID_TELETEX_PSPDN = 0x29,
- SMS_PID_TELETEX_CSPDN = 0x2A,
- SMS_PID_TELETEX_PSTN = 0x2B,
- SMS_PID_TELETEX_ISDN = 0x2C,
- SMS_PID_UCI = 0x2D,
- SMS_PID_x400 = 0x31,
- SMS_PID_EMAIL = 0x32,
-
- SMS_PID_TYPE0 = 0x40,
- SMS_PID_REPLACE_TYPE1 = 0x41,
- SMS_PID_REPLACE_TYPE2 = 0x42,
- SMS_PID_REPLACE_TYPE3 = 0x43,
- SMS_PID_REPLACE_TYPE4 = 0x44,
- SMS_PID_REPLACE_TYPE5 = 0x45,
- SMS_PID_REPLACE_TYPE6 = 0x46,
- SMS_PID_REPLACE_TYPE7 = 0x47,
-
- SMS_PID_RETURN_CALL = 0x5F,
-};
-
-
-enum _SMS_MSG_CLASS_E {
- SMS_MSG_CLASS_0 = 0,
- SMS_MSG_CLASS_1,
- SMS_MSG_CLASS_2,
- SMS_MSG_CLASS_3,
- SMS_MSG_CLASS_NONE,
-};
-
-
-enum _SMS_CODING_SCHEME_E {
- SMS_CHARSET_7BIT = 0,
- SMS_CHARSET_8BIT,
- SMS_CHARSET_UCS2,
- SMS_CHARSET_AUTO,
- SMS_CHARSET_EUCKR,
-};
-
-
-enum _SMS_CODING_GROUP_E {
- SMS_GROUP_GENERAL = 0,
- SMS_GROUP_CODING_CLASS,
- SMS_GROUP_DELETION,
- SMS_GROUP_DISCARD,
- SMS_GROUP_STORE,
- SMS_GROUP_UNKNOWN,
-};
-
-
-enum _SMS_INDICATOR_TYPE_E {
- SMS_VOICE_INDICATOR = 0,
- SMS_VOICE2_INDICATOR, /* Only for CPSH */
- SMS_FAX_INDICATOR,
- SMS_EMAIL_INDICATOR,
- SMS_OTHER_INDICATOR,
-};
-
-
-enum _SMS_TIME_FORMAT_E {
- SMS_TIME_RELATIVE = 0,
- SMS_TIME_ABSOLUTE
-};
-
-
-enum _SMS_FAIL_CAUSE_E {
- SMS_FC_MSG_TYPE0_NOT_SUPPORTED = 0x81,
- SMS_FC_SM_CANNOT_BE_REPLACED = 0x82,
- SMS_FC_UNSPEC_PID_ERROR = 0x8F,
- SMS_FC_MSG_CLASS_NOT_SUPPORTED = 0x91,
- SMS_FC_UNSPEC_DCS_ERROR = 0x9F,
- SMS_FC_TPDU_NOT_SUPPORTED = 0xB0,
- SMS_FC_SIM_STORAGE_FULL = 0xD0,
- SMS_FC_NO_STORAGE_IN_SIM = 0xD1,
- SMS_FC_ERROR_IN_MS = 0xD2,
- SMS_FC_MSG_CAPA_EXCEEDED = 0xD3,
- SMS_FC_SAT_BUSY = 0xD4,
- SMS_FC_SIM_DOWNLOAD_ERROR = 0xD5,
- SMS_FC_UNSPEC_ERROR = 0xFF,
-};
-
-
-enum _SMS_STATUS_E {
- SMS_STATUS_RECEIVE_SUCCESS = 0x00,
- SMS_STATUS_UNABLE_TO_CONFIRM_DELIVER = 0x01,
- SMS_STATUS_REPLACED = 0x02,
- SMS_STATUS_SMSC_SPECIFIC_LAST = 0x1F,
-
- SMS_STATUS_TRY_CONGESTION = 0x20,
- SMS_STATUS_TRY_SME_BUSY = 0x21,
- SMS_STATUS_TRY_NO_RESPONSE = 0x22,
- SMS_STATUS_TRY_SERVICE_REJECTED = 0x23,
- SMS_STATUS_TRY_QOS_NOT_AVAILABLE = 0x24,
- SMS_STATUS_TRY_REQUEST_PENDING = 0x30,
-
- SMS_STATUS_PERM_REMOTE_ERROR = 0x40,
- SMS_STATUS_PERM_IMCOMPATIBLE_DEST = 0x41,
- SMS_STATUS_PERM_CONNECTION_REJECTED = 0x42,
- SMS_STATUS_PERM_NOT_OBTAINABLE = 0x43,
- SMS_STATUS_PERM_QOS_NOT_AVAILABLE = 0x44,
- SMS_STATUS_PERM_NO_INTERWORK_AVAILABLE = 0x45,
- SMS_STATUS_PERM_MSG_VAL_PERIOD_EXPIRED = 0x46,
- SMS_STATUS_PERM_MSG_DEL_BY_ORIGIN_SME = 0x47,
- SMS_STATUS_PERM_MSG_DEL_BY_SMSC_ADMIN = 0x48,
- SMS_STATUS_PERM_MSG_NOT_EXIST = 0x49,
-
- SMS_STATUS_TEMP_CONGESTION = 0x60,
- SMS_STATUS_TEMP_SME_BUSY = 0x61,
- SMS_STATUS_TEMP_NO_RESPONSE = 0x62,
- SMS_STATUS_TEMP_SERVICE_REJECTED = 0x63,
- SMS_STATUS_TEMP_QOS_NOT_AVAILABLE = 0x64,
- SMS_STATUS_TEMP_ERROR_IN_SME = 0x65,
-};
-
-
-enum _SMS_REF_NUMBER_E {
- SMS_REF_NUM_8BIT = 0,
- SMS_REF_NUM_16BIT
-};
-
-
-enum _SMS_REPORT_TYPE_E {
- SMS_REPORT_POSITIVE = 0,
- SMS_REPORT_NEGATIVE
-};
-
-
-enum _SMS_UDH_TYPE_E {
- SMS_UDH_CONCAT_8BIT = 0x00,
- SMS_UDH_SPECIAL_SMS = 0x01,
- /* 0x02, 0x03 - Reserved */
- SMS_UDH_APP_PORT_8BIT = 0x04,
- SMS_UDH_APP_PORT_16BIT = 0x05,
- SMS_UDH_SC_CONTROL = 0x06,
- SMS_UDH_SRC_IND = 0x07,
- SMS_UDH_CONCAT_16BIT = 0x08,
- SMS_UDH_WCMP = 0x09,
- SMS_UDH_EMS_FIRST = 0x0a,
- SMS_UDH_EMS_LAST = 0x1f,
- SMS_UDH_ALTERNATE_REPLY_ADDRESS = 0x22,
- SMS_UDH_SINGLE_SHIFT = 0x24,
- SMS_UDH_LOCKING_SHIFT = 0x25,
- SMS_UDH_NONE = 0xFF,
-};
+typedef enum {
+ SMS_NETWORK_SEND_SUCCESS = 0x00,
+ SMS_NETWORK_SENDING,
+ SMS_NETWORK_SEND_PENDING,
+ SMS_NETWORK_SEND_FAIL,
+ SMS_NETWORK_SEND_FAIL_TIMEOUT,
+ SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING,
+ SMS_NETWORK_SEND_FAIL_TEMPORARY,
+ SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD,
+ SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED,
+ SMS_NETWORK_SEND_FAIL_FDN_RESTRICED,
+ SMS_NETWORK_SEND_FAIL_NO_ROUTING,
+ SMS_NETWORK_SEND_FAIL_UNKNOWN_SUBSCRIBER,
+ SMS_NETWORK_SEND_FAIL_MS_DISABLED,
+ SMS_NETWORK_SEND_FAIL_NETWORK_NOT_READY,
+} SMS_NETWORK_STATUS_T;
-enum _SMS_WAP_APP_CODE_E {
+typedef enum {
SMS_WAP_APPLICATION_DEFAULT = 0x00,
SMS_WAP_APPLICATION_PUSH_SI,
SMS_OMA_APPLICATION_DLOTA_UA,
SMS_WAP_APPLICATION_LBS,
-};
-
-
-enum _SMS_CB_NETWORK_TYPE_E {
- SMS_CB_NETWORK_TYPE_2G_GSM = 1,
- SMS_CB_NETWORK_TYPE_3G_UMTS,
-};
-
-
-enum _SMS_CBMSG_TYPE_E {
- SMS_CBMSG_TYPE_CBS = 1, /**< CBS */
- SMS_CBMSG_TYPE_SCHEDULE, /**< Schedule */
- SMS_CBMSG_TYPE_CBS41, /**< CBS41 */
- SMS_CBMSG_TYPE_JAVACBS, /**< JAVA-CB Message*/
- SMS_CBMSG_TYPE_ETWS,
-};
-
-
-enum _SMS_CBMSG_LANG_TYPE_E {
- SMS_CBMSG_LANG_GERMAN = 0x00,
- SMS_CBMSG_LANG_ENGLISH = 0x01,
- SMS_CBMSG_LANG_ITALIAN = 0x02,
- SMS_CBMSG_LANG_FRENCH = 0x03,
- SMS_CBMSG_LANG_SPANISH = 0x04,
- SMS_CBMSG_LANG_DUTCH = 0x05,
- SMS_CBMSG_LANG_SWEDISH = 0x06,
- SMS_CBMSG_LANG_DANISH = 0x07,
- SMS_CBMSG_LANG_PORTUGUESE = 0x08,
- SMS_CBMSG_LANG_FINNISH = 0x09,
- SMS_CBMSG_LANG_NORWEGIAN = 0x0a,
- SMS_CBMSG_LANG_GREEK = 0x0b,
- SMS_CBMSG_LANG_TURKISH = 0x0c,
- SMS_CBMSG_LANG_HUNGARIAN = 0x0d,
- SMS_CBMSG_LANG_POLISH = 0x0e,
- SMS_CBMSG_LANG_UNSPECIFIED = 0x0f,
-
- SMS_CBMSG_LANG_ISO639 = 0x10,
-
- SMS_CBMSG_LANG_CZECH = 0x20,
- SMS_CBMSG_LANG_HEBREW = 0x21,
- SMS_CBMSG_LANG_ARABIC = 0x22,
- SMS_CBMSG_LANG_RUSSIAN = 0x23,
- SMS_CBMSG_LANG_ICELANDIC = 0x24,
- SMS_CBMSG_LANG_RESERVED_25 = 0x25,
- SMS_CBMSG_LANG_RESERVED_26 = 0x26,
- SMS_CBMSG_LANG_RESERVED_27 = 0x27,
- SMS_CBMSG_LANG_RESERVED_28 = 0x28,
- SMS_CBMSG_LANG_RESERVED_29 = 0x29,
- SMS_CBMSG_LANG_RESERVED_2A = 0x2a,
- SMS_CBMSG_LANG_RESERVED_2B = 0x2b,
- SMS_CBMSG_LANG_RESERVED_2C = 0x2c,
- SMS_CBMSG_LANG_RESERVED_2D = 0x2d,
- SMS_CBMSG_LANG_RESERVED_2E = 0x2e,
- SMS_CBMSG_LANG_RESERVED_2F = 0x2f,
-
- SMS_CBMSG_LANG_DUMMY = 0xFF
-};
-
-
-enum _SMS_CBMSG_CODING_GROUP_E {
- SMS_CBMSG_CODGRP_GENERAL_DCS, /**< Bits 7..4 00xx */
- SMS_CBMSG_CODGRP_WAP, /**< 1110 Cell Broadcast */
- SMS_CBMSG_CODGRP_CLASS_CODING, /**< 1111 Cell Broadcast */
-};
-
-
-enum _SMS_SAT_CMD_TYPE_E {
- SMS_SAT_CMD_REFRESH,
- SMS_SAT_CMD_SEND_SMS,
- SMS_SAT_CMD_SMS_CTRL,
-};
-
-
-enum _SMS_SIM_EFILE_NAME_E {
- SMS_SIM_EFILE_USIM_SMS = 0x6A3C, /** < USIM Short Messages file */
- SMS_SIM_EFILE_USIM_SMSP = 0x6A42, /** < USIM SMS parameter */
- SMS_SIM_EFILE_USIM_SMSS = 0x6A43, /** < USIM SMS status */
- SMS_SIM_EFILE_USIM_CBMI = 0x6A45, /** < USIM Cell Broadcast Message Identifier */
- SMS_SIM_EFILE_USIM_MBDN = 0x6FC7, /** < USIM Mail Box Dialing Number */
- SMS_SIM_EFILE_SMS = 0x6F3C, /** < Short Messages file */
- SMS_SIM_EFILE_SMSP = 0x6F42, /** < SMS Parameter */
- SMS_SIM_EFILE_SMSS = 0x6F43, /** < SMS Status */
- SMS_SIM_EFILE_CBMI = 0x6F45, /** < Cell Broadcast Message Identifier */
- SMS_SIM_EFILE_MBDN = 0x6FC7, /** < Mail Box Dialing Number */
-};
-
-
-enum _SMS_SIM_MAILBOX_TYPE_E {
- SMS_SIM_MAILBOX_VOICE = 0x01,
- SMS_SIM_MAILBOX_VOICE2 = 0x02,
- SMS_SIM_MAILBOX_FAX = 0x03,
- SMS_SIM_MAILBOX_DATA = 0x04,
- SMS_SIM_MAILBOX_EMAIL = 0x05,
- SMS_SIM_MAILBOX_OTHER = 0x06,
-};
-
-
-enum _SMS_NETWORK_STATUS_E {
- SMS_NETWORK_SEND_SUCCESS = 0x00,
- SMS_NETWORK_SENDING,
- SMS_NETWORK_SEND_FAIL,
- SMS_NETWORK_SEND_FAIL_TIMEOUT,
- SMS_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING,
- SMS_NETWORK_SEND_FAIL_TEMPORARY,
- SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD,
- SMS_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED,
- SMS_NETWORK_SEND_FAIL_FDN_RESTRICED,
- SMS_NETWORK_SEND_FAIL_NO_ROUTING,
- SMS_NETWORK_SEND_PENDING,
-};
+} SMS_WAP_APP_CODE_T;
/*==================================================================================================
STRUCTURES
==================================================================================================*/
-typedef struct _SMS_ADDRESS_S {
- SMS_TON_T ton;
- SMS_NPI_T npi;
- char address[MAX_ADDRESS_LEN+1]; /* < null terminated string */
-} SMS_ADDRESS_S;
-
-
-typedef struct _SMS_DCS_S {
- bool bCompressed;
- bool bMWI;
- bool bIndActive;
- SMS_MSG_CLASS_T msgClass;
- SMS_CODING_SCHEME_T codingScheme;
- SMS_CODING_GROUP_T codingGroup;
- SMS_INDICATOR_TYPE_T indType;
-} SMS_DCS_S;
-
-
-typedef struct _SMS_TIME_REL_S {
- unsigned char time;
-} SMS_TIME_REL_S;
-
-
-typedef struct _SMS_TIME_ABS_S {
- unsigned char year;
- unsigned char month;
- unsigned char day;
- unsigned char hour;
- unsigned char minute;
- unsigned char second;
- int timeZone;
-} SMS_TIME_ABS_S;
-
-
-typedef struct _SMS_TIMESTAMP_S {
- SMS_TIME_FORMAT_T format;
-
- union {
- SMS_TIME_REL_S relative;
- SMS_TIME_ABS_S absolute;
- } time;
-} SMS_TIMESTAMP_S;
-
-
-typedef struct _SMS_CONCAT_8BIT_S {
- unsigned char msgRef;
- unsigned char totalSeg;
- unsigned char seqNum;
-} SMS_CONCAT_8BIT_S;
-
-
-typedef struct _SMS_CONCAT_16BIT_S {
- unsigned short msgRef;
- unsigned char totalSeg;
- unsigned char seqNum;
-} SMS_CONCAT_16BIT_S;
-
-
-typedef struct _SMS_APP_PORT_8BIT_S {
- unsigned char destPort;
- unsigned char originPort;
-} SMS_APP_PORT_8BIT_S;
-
-
-typedef struct _SMS_APP_PORT_16BIT_S {
- unsigned short destPort;
- unsigned short originPort;
-} SMS_APP_PORT_16BIT_S;
-
-
-typedef struct _SMS_SPECIAL_INDICATION_S {
- bool bStore;
- unsigned short msgInd;
- unsigned short waitMsgNum;
-} SMS_SPECIAL_INDICATION_S;
-
-
-typedef struct _SMS_UDH_S {
- SMS_UDH_TYPE_T udhType;
-
- union {
- SMS_CONCAT_8BIT_S concat8bit;
- SMS_CONCAT_16BIT_S concat16bit;
- SMS_APP_PORT_8BIT_S appPort8bit;
- SMS_APP_PORT_16BIT_S appPort16bit;
- SMS_SPECIAL_INDICATION_S specialInd;
- MSG_SINGLE_SHIFT_S singleShift;
- MSG_LOCKING_SHIFT_S lockingShift;
- SMS_ADDRESS_S alternateAddress;
- } udh;
-} SMS_UDH_S;
-
-
-typedef struct _SMS_USERDATA_S {
- int headerCnt;
- SMS_UDH_S header[MAX_UD_HEADER_NUM];
- int length;
- char data[MAX_USER_DATA_LEN+1];
-} SMS_USERDATA_S;
-
-
-typedef struct _SMS_TPUD_S {
- int udl;
- char ud[MAX_USER_DATA_LEN+1];
-} SMS_TPUD_S;
-
-
-typedef struct _SMS_SUBMIT_S {
- bool bRejectDup;
- bool bStatusReport;
- bool bHeaderInd;
- bool bReplyPath;
- unsigned char msgRef;
- SMS_VPF_T vpf;
- SMS_ADDRESS_S destAddress;
- SMS_PID_T pid;
- SMS_DCS_S dcs;
- SMS_TIMESTAMP_S validityPeriod;
- SMS_USERDATA_S userData;
-} SMS_SUBMIT_S;
-
-
-typedef struct _SMS_SUBMIT_DATA_S {
- SMS_ADDRESS_S destAddress;
- unsigned int segCount;
- SMS_USERDATA_S userData[MAX_SEGMENT_NUM];
-} SMS_SUBMIT_DATA_S;
-
-
-typedef struct _SMS_DELIVER_S {
- bool bMoreMsg;
- bool bStatusReport;
- bool bHeaderInd;
- bool bReplyPath;
- SMS_ADDRESS_S originAddress;
- SMS_PID_T pid;
- SMS_DCS_S dcs;
- SMS_TIMESTAMP_S timeStamp;
- SMS_USERDATA_S userData;
- SMS_TPUD_S udData;
-} SMS_DELIVER_S;
-
-
-typedef struct _SMS_DELIVER_REPORT_S {
- SMS_REPORT_TYPE_T reportType;
- bool bHeaderInd;
- SMS_FAIL_CAUSE_T failCause;
- unsigned char paramInd;
- SMS_PID_T pid;
- SMS_DCS_S dcs;
- SMS_USERDATA_S userData;
-} SMS_DELIVER_REPORT_S;
-
-
-typedef struct _SMS_STATUS_REPORT_S {
- bool bMoreMsg;
- bool bStatusReport;
- bool bHeaderInd;
- unsigned char msgRef;
- SMS_ADDRESS_S recipAddress;
- SMS_TIMESTAMP_S timeStamp;
- SMS_TIMESTAMP_S dischargeTime;
- SMS_STATUS_T status;
- unsigned char paramInd;
- SMS_PID_T pid;
- SMS_DCS_S dcs;
- SMS_USERDATA_S userData;
-} SMS_STATUS_REPORT_S;
-
-
-typedef struct _SMS_TPDU_S {
- SMS_TPDU_TYPE_T tpduType;
-
- union {
- SMS_SUBMIT_S submit;
- SMS_DELIVER_S deliver;
- SMS_DELIVER_REPORT_S deliverRep;
- SMS_STATUS_REPORT_S statusRep;
- } data;
-} SMS_TPDU_S;
-
-
-typedef struct {
- msg_request_id_t reqId; /**< Indicates the request ID, which is unique. When applications submit a request to the framework, this value will be set by the framework. */
- MSG_MESSAGE_INFO_S msgInfo; /**< Indicates the message structure to be sent by applications. */
- MSG_SENDINGOPT_INFO_S sendOptInfo;
-} SMS_REQUEST_INFO_S;
-
-
-typedef struct _SMS_SENT_INFO_S {
- SMS_REQUEST_INFO_S reqInfo; /**< Indicates the corresponding request structure. */
- bool bLast;
-} SMS_SENT_INFO_S;
-
-
-typedef struct _SMS_PUSH_APP_INFO_S {
- char* pContentType;
- char* pAppId;
- SMS_WAP_APP_CODE_T appCode;
-} SMS_PUSH_APP_INFO_S;
-
-
-typedef struct _SMS_CBMSG_SERIAL_NUM_S {
- unsigned char geoScope;
- unsigned char updateNum;
- unsigned short msgCode;
-} SMS_CBMSG_SERIAL_NUM_S;
-
-
-typedef struct _SMS_CBMSG_DCS_S {
- SMS_CBMSG_CODING_GROUP_T codingGroup; /**< Coding group, GSM 03.38 */
- SMS_MSG_CLASS_T classType; /**< The message class */
- bool bCompressed; /**< if text is compressed this is TRUE */
- SMS_CODING_SCHEME_T codingScheme; /**< How to encode a message. */
- SMS_CBMSG_LANG_TYPE_T langType;
- unsigned char iso639Lang[3]; /* 2 GSM chars and a CR char */
- bool bUDH;
- unsigned char rawData;
-} SMS_CBMSG_DCS_S;
-
-
-typedef struct _SMS_CBMSG_HEADER_S {
- SMS_CBMSG_SERIAL_NUM_S serialNum; /**< Cell Broadcast Serial number */
- unsigned short msgId; /**< Message identifier code */
- MSG_CB_LANGUAGE_TYPE_T langType; /**< Languages in CB Messages */
- SMS_CBMSG_DCS_S dcs; /**< Data coding scheme */
- unsigned char page; /**< current page number */
- unsigned char totalPages; /**< Total number of pages in this messages */
- time_t recvTime; /**< Msg Recv Time */
-} SMS_CBMSG_HEADER_S;
-
-
-typedef struct _SMS_CBMSG_PAGE_S {
- SMS_CBMSG_TYPE_T cbMsgType; /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
- SMS_CBMSG_HEADER_S pageHeader; /**< CB Message Header */
- int pageLength; /**< message string length */
- char pageData[MAX_CBMSG_TOTAL_PAGE_SIZE*8/7+1]; /**< user data */
-} SMS_CBMSG_PAGE_S;
-
-
-typedef struct _SMS_CBMSG_S {
- SMS_CBMSG_TYPE_T cbMsgType; /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
- unsigned short msgId; /**< Message identifier code */
- unsigned short serialNum; /* Serial number */
- SMS_MSG_CLASS_T classType; /**< The message class */
- SMS_CODING_SCHEME_T codingScheme; /**< How to encode a message. */
- time_t recvTime; /**< Msg Recv Time */
- int msgLength; /**< message string length */
- char msgData[MAX_CBMSG_TOTAL_PAGE_SIZE*8/7+1]; /**< user data */
-} SMS_CBMSG_S;
-
-typedef struct _SMS_ETWS_PRIMARY_S {
- time_t recvTime;
- SMS_CBMSG_SERIAL_NUM_S serialNum;
- unsigned short msgId;
- unsigned short warningType;
- unsigned char warningSecurityInfo[MAX_ETWS_SIZE-6];
-} SMS_ETWS_PRIMARY_S;
-
-
-typedef struct _SMS_WSP_CONTENTS_TYPE_S {
- char* contentsTypeName;
- unsigned char contentsTypeCode;
-} SMS_WSP_CONTENTS_TYPE_S;
-
-
-typedef struct _SMS_WSP_CHARSET_S {
- char* charsetName;
- unsigned short charsetCode;
-} SMS_WSP_CHARSET_S;
-
-
-typedef struct _SMS_WAP_UNREGISTER_CONTENTS_TYPE_S {
- char* contentsTypeName;
- unsigned short contentsTypeCode;
-} SMS_WAP_UNREGISTER_CONTENTS_TYPE_S;
-
-
-typedef struct _SMS_WSP_LANGUAGE_S {
- char* languageName;
- unsigned char languageCode;
-} SMS_WSP_LANGUAGE_S;
-
-
-typedef struct _SMS_WSP_HEADER_PARAMETER_S {
- char* parameterToken;
- unsigned int parameterCode;
-} SMS_WSP_HEADER_PARAMETER_S;
-
-
-typedef struct _SMS_WSP_METHOD_TYPE_S {
- char* methodName;
- unsigned char methodCode;
-} SMS_WSP_METHOD_TYPE_S;
-
-
-typedef struct _SMS_WSP_SECURITY_TYPE_S {
- char* SecurityTypeName;
- unsigned char SecurityTypeCode;
-} SMS_WSP_SECURITY_TYPE_S;
-
-
-/**
- * @brief Represents SIM count information.
- */
-typedef struct {
- unsigned int totalCount; /**< The total number of SIM */
- int usedCount; /**< The used number of SIM */
- int indexList[MAX_SIM_SMS_NUM]; /**< The SIM index list */
-} MSG_SIM_COUNT_S;
-
-
-/**
- * @brief Represents Concat SIM Msg information.
- */
-typedef struct {
- unsigned int simIdCnt; /**< The total number of SIM Msg ID*/
- msg_sim_id_t simIdList[MAX_SEGMENT_NUM]; /**< The SIM Msg ID List */
- char msgData[(MAX_MSG_DATA_LEN*MAX_SEGMENT_NUM)+1]; /**< user data */
-} SMS_CONCAT_SIM_MSG_S;
-
-
-/**
- * @brief Represents Sim Mailbox information
- */
-typedef struct {
- int b_cphs;
- int rec_index; /**< index which stands for the location where record is saved in SIM*/
- int profile_num; /**< SIM profile index*/
- SMS_SIM_MAILBOX_TYPE_T mb_type;
- int alpha_id_max_len; /**< alpha max length in SIM - READ ONLY*/
- char alpha_id[MAX_SIM_XDN_ALPHA_ID_LEN + 1]; /**< Alpha Identifier */
- MSG_SMS_TON_T ton; /**< Type Of Number */
- MSG_SMS_NPI_T npi; /**< Number Plan Identity */
- char num[MAX_PHONE_NUMBER_LEN + 1]; /**< Dialing Number/SSC String */
- unsigned char cc_id; /**< Capability/Configuration Identifier */
- unsigned char ext1_id; /**< Extensiion1 Record Identifier */
- int num_len; /**< Length of the original number read from SIM*/
-} SMS_SIM_MAILBOX_INFO_S;
-
-
-/**
- * @brief Represents Sim Mailbox list
- */
-typedef struct {
- int count;
- SMS_SIM_MAILBOX_INFO_S list[MAX_SIM_MSP_CNT*5]; /* max is 10 */
-} SMS_SIM_MAILBOX_LIST_S;
-
-
-/**
- * @brief Represents Message Waiting Indication
- */
-typedef struct {
- int rec_index;
- unsigned char indicator_status; /**< Indicator Type*/
- int voice_count; /**< VoiceMail Count*/
- int fax_count; /**< FAX Count*/
- int email_count; /**< Email Count*/
- int other_count; /**< Other Count*/
- int video_count; /**< VideoMail Count*/
-} SMS_SIM_MWI_NORMAL_INFO_S;
-
-
-/**
- * @brief Represents Message Waiting Indication list
- */
-typedef struct {
- int profile_count;
- SMS_SIM_MWI_NORMAL_INFO_S mw_info[MAX_SIM_MSP_CNT];
-} SMS_SIM_MWI_LIST_S;
-
-
-/**
- * @brief Represents Message Waiting Indication for CPHS
- */
-typedef struct {
- int b_voice1; /**< VoiceMsgLine1 message waiting flag */
- int b_voice2; /**< VoiceMsgLine2 message waiting flag */
- int b_fax; /**< FAX message waiting flag */
- int b_data; /**< Data message waiting flag */
-} SMS_SIM_MWI_CPHS_INFO_S;
-
-
-/**
- * @brief Represents Message Waiting Indication Information
- */
-typedef struct {
- int b_cphs;
- SMS_SIM_MWI_LIST_S mwi_list;
- SMS_SIM_MWI_CPHS_INFO_S cphs_mwi;
-} SMS_SIM_MWI_INFO_S;
-
-/**
- * @brief Represents SIM MSISDN Information
- */
-typedef struct {
- char simMsisdn[MAX_SIM_MSISDN_LEN + 1];
- int sim_index;
-} SMS_SIM_MSISDN_INFO_S;
-
-
-/**
- * @brief Represents Message Data Information from Telephony.
- */
-typedef struct {
- unsigned char sca[MAX_ADDRESS_LEN]; /**< Service Center address */
- int msgLength; /**< Size of array szData (which is actual TPDU message) */
- unsigned char szData[MAX_TPDU_DATA_LEN + 1]; /**< SMS TPDU message */
- int totalSegment; /** total segment count of TPDU message */
-} SMS_DATA_INFO_S;
-
-
-/**
- * @brief Represents Telephony Handle from Telephony.
- */
-typedef struct {
- int count;
- struct tapi_handle *handle[MAX_TELEPHONY_HANDLE_CNT]; /* max is 3 */
-} SMS_TELEPHONY_HANDLE_LIST_S;
#endif /* SMS_PLUGIN_TYPES_H */
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_UA_MANAGER_H
-#define SMS_PLUGIN_UA_MANAGER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "MsgMutex.h"
-#include "MsgQueue.h"
-#include "MsgThread.h"
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginUAManager : public MsgThread
-{
-public:
- static SmsPluginUAManager* instance();
-
- /* virtual void start(); */
-
- void addReqEntity(SMS_REQUEST_INFO_S *request);
-
-private:
- SmsPluginUAManager();
- ~SmsPluginUAManager();
- void lock() { mx.lock(); };
- void unlock() { mx.unlock(); };
- void wait() { cv.wait(mx.pMsgMutex()); };
- void signal() { cv.signal(); };
-
- virtual void run();
-
- static SmsPluginUAManager* pInstance;
-
- MsgSimpleQ <SMS_REQUEST_INFO_S> smsTranQ;
-
- MsgMutex mx;
- MsgCndVar cv;
-};
-
-#endif /* SMS_PLUGIN_UA_MANAGER_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_UDCODEC_H
-#define SMS_PLUGIN_UDCODEC_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginUDCodec
-{
-public:
- SmsPluginUDCodec();
- virtual ~SmsPluginUDCodec();
-
- static int encodeUserData(const SMS_USERDATA_S *pUserData, SMS_CODING_SCHEME_T CodingScheme, char *pEncodeData);
- static int decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData);
- static int decodeUserData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_CODING_SCHEME_T CodingScheme, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
-
- static int pack7bitChar(const unsigned char *pUserData, int dataLen, int fillBits, char *pPackData);
- static int unpack7bitChar(const unsigned char *pTpdu, unsigned char dataLen, int fillBits, char *pUnpackData);
-
-private:
- static int encodeGSMData(const SMS_USERDATA_S *pUserData, char *pEncodeData);
- static int encode8bitData(const SMS_USERDATA_S *pUserData, char *pEncodeData);
- static int encodeUCS2Data(const SMS_USERDATA_S *pUserData, char *pEncodeData);
-
- static int decodeGSMData(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
- static int decode8bitData(const unsigned char *pTpdu, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
- static int decodeUCS2Data(const unsigned char *pTpdu, const int tpduLen, bool bHeaderInd, SMS_USERDATA_S *pUserData, SMS_TPUD_S *pTPUD);
-
- static int encodeHeader(const SMS_UDH_S header, char *pEncodeHeader);
- static int decodeHeader(const unsigned char *pTpdu, SMS_UDH_S *pHeader);
-};
-
-#endif /* SMS_PLUGIN_UDCODEC_H */
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-#ifndef SMS_PLUGIN_WAPPUSH_HANDLER_H
-#define SMS_PLUGIN_WAPPUSH_HANDLER_H
-
-
-/*==================================================================================================
- INCLUDE FILES
-==================================================================================================*/
-#include <wbxml/wbxml.h>
-#include <libxml/parser.h>
-
-
-#include "SmsPluginTypes.h"
-
-
-/*==================================================================================================
- DEFINES
-==================================================================================================*/
-#define WSP_STANDARD_STR_LEN_MAX 255
-#define LENGTH_QUOTE 0x1F
-#define NO_VALUE 0x00
-
-#define WSP_CODE_BUFFER_LEFT_LEN_MAX 1024
-#define WSP_CODE_BUFFER_RIGHT_LEN_MAX 2048
-
-#define AcStrlen(x) ((x == NULL) ? 0 : strlen(x))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
-
-/*==================================================================================================
- CLASS DEFINITIONS
-==================================================================================================*/
-class SmsPluginWapPushHandler
-{
-public:
- static SmsPluginWapPushHandler* instance();
-
- bool IsWapPushMsg(SMS_USERDATA_S *pUserData);
-
- void copyDeliverData(SMS_DELIVER_S *pDeliver);
- void handleWapPushMsg(const char *pUserData, int DataSize, int simIndex, time_t sent_time);
- void handleWapPushCallback(char* pPushHeader, char* pPushBody, int PushBodyLen, char* pWspHeader, int WspHeaderLen, char* pWspBody, int WspBodyLen, int simIndex, time_t sent_time);
-
-private:
- SmsPluginWapPushHandler();
- virtual ~SmsPluginWapPushHandler();
-
- static SmsPluginWapPushHandler* pInstance;
-
- SMS_WAP_APP_CODE_T getAppCode(const char *pPushHeader);
- bool IsWapPushMsgInWhiteList(int appCode);
-
- void handleMMSNotification(const char *pPushBody, int PushBodyLen, int simIndex, time_t sent_time);
- void handleSIMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
- void handleSLMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
- void handleCOMessage(char* pPushBody, int PushBodyLen, bool isText, int simIndex);
- void handleDrmVer1(char* pPushBody, int PushBodyLen);
- void getXmlDoc(const char* pPushBody, const int PushBodyLen, xmlDocPtr *pXmlDoc, const bool isText);
- void createMsgInfo(MSG_MESSAGE_INFO_S* pMsgInfo);
- void getDisplayName(MSG_SUB_TYPE_T subType, char* displayName);
- unsigned long convertXmlCharToSec(char* pDate);
- msg_push_action_t convertSIActionStrToEnum(char* pAction);
- msg_push_action_t convertSLActionStrToEnum(char* pAction);
-
- unsigned long wspRetriveUintvarDecode(unsigned char* sourceData, unsigned long* currentPointer);
- unsigned long wspDecodeUintvar(unsigned long length, unsigned char* userVar);
- void wspDecodeHeader(unsigned char* sEncodedHeader, unsigned long encodedHeaderLen, unsigned long contentsLength, bool fContentType, char** pHeader);
- unsigned long wspHeaderDecodeInteger(unsigned char* data);
- void wspHeaderDecodeQValue(unsigned long length, unsigned char* data, char** pDecodedString);
- unsigned long wspHeaderDecodeIntegerByLength(unsigned char* data, unsigned long length);
- char* wspExtendedDecodeType(char contentType);
- void wspHeaderDecodeParameter(unsigned char* data, unsigned long length, char** pParam);
- void wspHeaderDecodeCharset(unsigned long length, unsigned char* data, char**pDecodedString);
- void wspHeaderDecodeVersion(unsigned long length, unsigned char* data, char** pDecodedString);
- void wspHeaderDecodeDateValue(unsigned long length, unsigned char* data, char** pDecodedString);
- void wspHeaderCopyDecodedString(unsigned char* szDecodedString, unsigned long* currentLen, char** pTemper);
- void wspHeaderDecodeAuth(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
- void wspHeaderDecodeChallenge(unsigned long fieldValueLen, unsigned char* fieldValue, char** pDecodedString);
- void wspHeaderDecodeCacheControl(unsigned char* fieldValue, unsigned long fieldValueLen, char** pCacheString);
-
- SMS_ADDRESS_S tmpAddress;
- SMS_TIMESTAMP_S tmpTimeStamp;
-};
-
-#endif /* SmsPluginWapPushHandler */
-
return "MSG_CMD_UPDATE_IMSI";
case MSG_CMD_SET_TEMP_ADDRESS_TABLE:
return "MSG_CMD_SET_TEMP_ADDRESS_TABLE";
-
-#ifdef FEATURE_SMS_CDMA
+/* 85 */
case MSG_CMD_PLG_CHECK_UNIQUENESS:
return "MSG_CMD_PLG_CHECK_UNIQUENESS";
-#endif
case MSG_CMD_ALLOW_TCS_MESSAGE:
return "MSG_CMD_ALLOW_TCS_MESSAGE";
case MSG_CMD_CHECK_PERMISSION:
return "MSG_EVENT_UPDATE_IMSI";
case MSG_EVENT_SET_TEMP_ADDRESS_TABLE:
return "MSG_EVENT_SET_TEMP_ADDRESS_TABLE";
-
-#ifdef FEATURE_SMS_CDMA
+/* 85 */
case MSG_EVENT_PLG_CHECK_UNIQUENESS:
return "MSG_EVENT_PLG_CHECK_UNIQUENESS";
-#endif
case MSG_EVENT_ALLOW_TCS_MESSAGE:
return "MSG_EVENT_ALLOW_TCS_MESSAGE";
case MSG_EVENT_CHECK_PERMISSION:
}
-int MsgTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT msg_encode_type_t *pCharType)
+int MsgTextConvert::convertUTF8ToAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, IN msg_encode_type_t defaultEncodingType, OUT msg_encode_type_t *pCharType)
{
int utf8Length = 0;
int gsm7bitLength = 0;
ucs2Length = convertUTF8ToUCS2((unsigned char*)pUCS2Text, maxUCS2Length * sizeof(WCHAR), pSrcText, srcTextLen);
- if(ucs2Length < 0) {
+ if (ucs2Length < 0) {
*pCharType = MSG_ENCODE_8BIT;
if (srcTextLen <= maxLength) {
return maxLength;
}
} else {
-#ifndef FEATURE_SMS_CDMA
- gsm7bitLength = convertUCS2ToGSM7bitAuto(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
-#else
- gsm7bitLength = convertUCS2ToASCII(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
-#endif
+ if (defaultEncodingType == MSG_ENCODE_ASCII7BIT) {
+ gsm7bitLength = convertUCS2ToASCII(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
+ *pCharType = MSG_ENCODE_ASCII7BIT;
+ } else {
+ gsm7bitLength = convertUCS2ToGSM7bitAuto(pDestText, maxLength, (unsigned char*)pUCS2Text, ucs2Length, &bUnknown);
+ *pCharType = MSG_ENCODE_GSM7BIT;
+ }
if (bUnknown == true) {
*pCharType = MSG_ENCODE_UCS2;
return maxLength;
}
}
- } else {
-#ifndef FEATURE_SMS_CDMA
- *pCharType = MSG_ENCODE_GSM7BIT;
-#else
- *pCharType = MSG_ENCODE_ASCII7BIT;
-#endif
}
return gsm7bitLength;
return outTextLen;
}
-#ifndef FEATURE_SMS_CDMA
int MsgTextConvert::convertUCS2ToGSM7bitAuto(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown)
{
/* for UNICODE */
return outTextLen;
}
-#else
+
int MsgTextConvert::convertUCS2ToASCII(OUT unsigned char *pDestText, IN int maxLength, IN const unsigned char *pSrcText, IN int srcTextLen, OUT bool *pUnknown)
{
/* for UNICODE */
return outTextLen;
}
-#endif
+
/**
args :
#include "MsgUtilStorage.h"
#include "MsgException.h"
-
static int msgCntLimit[MSG_COUNT_LIMIT_MAILBOX_TYPE_MAX][MSG_COUNT_LIMIT_MSG_TYPE_MAX] = {{10, 10, 0, 10, 10}, {5, 10, 0, 0, 0}, {10, 10, 0, 0, 0}, {10, 10, 0, 0, 0}, {0, 0, 10, 0, 0}};
using namespace std;
msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex)
{
-#ifndef FEATURE_SMS_CDMA
MSG_BEGIN();
char sqlQuery[MAX_QUERY_LEN] = {0, };
MSG_END();
return MSG_SUCCESS;
-#else /* TODO: Add multisim for CDMA */
- MSG_BEGIN();
-
- char sqlQuery[MAX_QUERY_LEN] = {0, };
-
- pDbHandle->beginTrans();
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME);
-
- if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- pDbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
-
- for (int i = 0; i < pCBChannel->channelCnt; i++) {
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s');", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME,
- i, pCBChannel->channelInfo[i].bActivate, pCBChannel->channelInfo[i].ctg,
- pCBChannel->channelInfo[i].lang, pCBChannel->channelInfo[i].name);
-
- if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
- pDbHandle->endTrans(false);
- return MSG_ERR_DB_EXEC;
- }
- }
-
- pDbHandle->endTrans(true);
-
- MSG_END();
-
- return MSG_SUCCESS;
-#endif
}
msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel, msg_sim_slot_id_t simIndex)
{
-#ifndef FEATURE_SMS_CDMA
MSG_BEGIN();
int rowCnt = 0, index = 0;
MSG_END();
return MSG_SUCCESS;
-#else /* TODO: Add multisim for CDMA */
+}
+
+
+msg_error_t MsgStoAddCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel)
+{
+ MSG_BEGIN();
+
+ char sqlQuery[MAX_QUERY_LEN] = {0,};
+
+ pDbHandle->beginTrans();
+
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "DELETE FROM %s;", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME);
+
+ if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ pDbHandle->endTrans(false);
+ return MSG_ERR_DB_EXEC;
+ }
+
+ for (int i = 0; i < pCBChannel->channelCnt; i++) {
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "INSERT INTO %s VALUES (%d, %d, %d, %d, '%s');", MSGFW_CDMA_CB_CHANNEL_INFO_TABLE_NAME,
+ i, pCBChannel->channelInfo[i].bActivate, pCBChannel->channelInfo[i].ctg,
+ pCBChannel->channelInfo[i].lang, pCBChannel->channelInfo[i].name);
+
+ if (pDbHandle->execQuery(sqlQuery) != MSG_SUCCESS) {
+ pDbHandle->endTrans(false);
+ return MSG_ERR_DB_EXEC;
+ }
+ }
+
+ pDbHandle->endTrans(true);
+
+ MSG_END();
+
+ return MSG_SUCCESS;
+}
+
+
+msg_error_t MsgStoGetCBChannelInfo(MsgDbHandler *pDbHandle, MSG_CB_CHANNEL_S *pCBChannel)
+{
MSG_BEGIN();
int rowCnt = 0, index = 0;
pDbHandle->freeTable();
return MSG_ERR_DB_NORECORD;
} else if (err != MSG_SUCCESS) {
- MSG_DEBUG("Fail to getTable().");
+ MSG_ERR("Fail to getTable().");
pDbHandle->freeTable();
return MSG_ERR_DB_GETTABLE;
}
pCBChannel->channelInfo[i].lang = pDbHandle->getColumnToInt(index++);
pDbHandle->getColumnToString(index++, CB_CHANNEL_NAME_MAX, pCBChannel->channelInfo[i].name);
- MSG_DEBUG("CH_ACT = %d", pCBChannel->channelInfo[i].bActivate);
- MSG_DEBUG("CH_CTG = %d", pCBChannel->channelInfo[i].ctg);
- MSG_DEBUG("CH_LANG = %d", pCBChannel->channelInfo[i].lang);
- MSG_DEBUG("CH_NAME = %s", pCBChannel->channelInfo[i].name);
+ MSG_DEBUG("CH_ACT: [%d], CH_CTG: [%d], CH_LANG: [%d], CH_NAME: [%s]",
+ pCBChannel->channelInfo[i].bActivate, pCBChannel->channelInfo[i].ctg, pCBChannel->channelInfo[i].lang, pCBChannel->channelInfo[i].name);
}
pDbHandle->freeTable();
MSG_END();
return MSG_SUCCESS;
-#endif
}
+
+
msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct_list_s *pThreadViewList)
{
MsgDbHandler *dbHandle = getDbHandle();
}
-#ifdef FEATURE_SMS_CDMA
msg_error_t MsgStoClearUniquenessTable()
{
MSG_BEGIN();
return err;
}
-#endif
+
+
+msg_error_t MsgStoGetSimIndexByMsgId(msg_message_id_t msgId, int* simIndex)
+{
+ MSG_BEGIN();
+
+ msg_error_t err = MSG_SUCCESS;
+
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ char sqlQuery[MAX_QUERY_LEN+1];
+ memset(sqlQuery, 0x00, sizeof(sqlQuery));
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT SIM_INDEX FROM %s WHERE MSG_ID = %d;", MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+ return MSG_ERR_DB_PREPARE;
+ }
+
+ if (dbHandle->stepQuery() == MSG_ERR_DB_ROW) {
+ *simIndex = dbHandle->columnInt(0);
+ dbHandle->finalizeQuery();
+ } else {
+ MSG_DEBUG("MsgStepQuery() Error [%s]", sqlQuery);
+ dbHandle->finalizeQuery();
+ err = MSG_ERR_DB_STEP;
+ }
+
+ MSG_END();
+
+ return err;
+}
+
+
+msg_error_t MsgStoGetNetworkStatusByMsgId(msg_message_id_t msgId, int *networkStatus)
+{
+ char sqlQuery[MAX_QUERY_LEN + 1] = {0,};
+ MsgDbHandler *dbHandle = getDbHandle();
+
+ snprintf(sqlQuery, sizeof(sqlQuery), "SELECT NETWORK_STATUS FROM %s WHERE MSG_ID = %d;",
+ MSGFW_MESSAGE_TABLE_NAME, msgId);
+
+ if (dbHandle->prepareQuery(sqlQuery) != MSG_SUCCESS) {
+ return MSG_ERR_DB_PREPARE;
+ }
+
+ if (dbHandle->stepQuery() != MSG_ERR_DB_ROW) {
+ dbHandle->finalizeQuery();
+ return MSG_ERR_STORAGE_ERROR;
+ }
+
+ *networkStatus = dbHandle->columnInt(0);
+ dbHandle->finalizeQuery();
+
+ return MSG_SUCCESS;
+}