#include "Messaging.h"
#include "CallbackMgr.h"
#include "MsgServiceHandleMgr.h"
+#include "WidgetFilePathMgr.h"
#include <Logger.h>
+#include <vconf.h>
extern "C" {
#include <msg.h>
namespace {
const char* TEXT_AREA = "Text";
const char* TEXT_FILE_EXTENSION = ".txt";
-const char* TEXT_DIR_PREFIX = "/tmp/";
+const char* TEXT_DIR_SEPERATOR = "/";
const int WHITE_COLOR = 0xffffff;
const int BLACK_COLOR = 0x000000;
const int ROOT_LAYOUT_WIDTH = 100;
Mms::Mms(const string& id) :
IMessage(MMS, id),
-// m_bodyFilePath(string(tmpnam(NULL)) + TEXT_FILE_EXTENSION),
m_messageData(NULL)
{
LoggerD("m_id=" << getIdRef());
- LoggerD("m_msgType=" << getMessageType());
char buf[] = "XXXXXX";
mode_t mask = umask(S_IWGRP | S_IWOTH);
LoggerD("buf : " << buf << " i : " << i);
umask(mask);
m_bodyFilePath = buf;
- m_bodyFilePath = TEXT_DIR_PREFIX+m_bodyFilePath+TEXT_FILE_EXTENSION;
-
- LoggerD("m_bodyFilePath : " << m_bodyFilePath);
+ m_bodyFilePath = getWidgetPath()+TEXT_DIR_SEPERATOR+m_bodyFilePath+TEXT_FILE_EXTENSION;
if (getIdRef().empty()) {
- LoggerD("create new message");
createNewMessage();
} else {
- LoggerD("read existing message");
readExistingMessage();
}
}
Mms::Mms(const string& id, const msg_struct_t msg_data) :
IMessage(MMS, id),
-// m_bodyFilePath(string(tmpnam(NULL)) + TEXT_FILE_EXTENSION),
- m_messageData(msg_data)
+ m_messageData(NULL)
{
LoggerD("m_id=" << getIdRef());
- LoggerD("m_msgType=" << getMessageType());
+
+ m_messageData = createNewCopyOfPLatformMsgWithAddressList(msg_data);
char buf[] = "XXXXXX";
mode_t mask = umask(S_IWGRP | S_IWOTH);
LoggerD("buf : " << buf << " i : " << i);
umask(mask);
m_bodyFilePath = buf;
- m_bodyFilePath = TEXT_DIR_PREFIX+m_bodyFilePath+TEXT_FILE_EXTENSION;
-
- LoggerD("m_bodyFilePath : " << m_bodyFilePath);
-
+ m_bodyFilePath = getWidgetPath()+TEXT_DIR_SEPERATOR+m_bodyFilePath+TEXT_FILE_EXTENSION;
+
readConversationId(m_messageData);
readRecipientList(m_messageData);
readPriority(m_messageData);
readDateTime(m_messageData);
readReadStatus(m_messageData);
readMessageStatus(m_messageData);
-// setMessageStatus(MESSAGE_STATUS_LOADED);
}
LoggerD("attachment count: " << attachLen);
for (int a = 0; a < attachLen; ++a)
{
+ std::string tempString;
+ int tempInt;
+
attach = (msg_struct_t)msg_list_nth_data(attach_list, a);
if (NULL == attach)
{
msg_get_str_value(attach, MSG_MMS_ATTACH_FILEPATH_STR, szFilePath, sizeof(szFilePath));
msg_get_str_value(attach, MSG_MMS_ATTACH_FILENAME_STR, szFileName, sizeof(szFileName));
+
+ msg_get_int_value(attach, MSG_MMS_ATTACH_MIME_TYPE_INT, &tempInt);
+ tempString = indexIntToMimeTypeString((MimeType)tempInt);
IAttachmentPtr att = appendAttachment(szFilePath, false);
if ((szFileName[0] =! '\0') &&
LoggerD("renaming to " << szFileName);
att->rename(szFileName);
}
+ att->setMimeType(tempString);
+ att->setAttachmentID((int)a);
+ att->setDownloaded(true);
+ }
+ msg_release_struct(&mms_struct);
+}
+
+void Mms::readBody(msg_struct_t& messageData)
+{
+
+ int pageLen, mediaLen, tempInt, ret;
+
+ msg_struct_t mms_struct = NULL;
+
+ msg_list_handle_t page_list = NULL;
+ msg_list_handle_t media_list = NULL;
+
+ msg_struct_t page = NULL;
+ msg_struct_t media = NULL;
+
+ mms_struct = msg_create_struct(MSG_STRUCT_MMS);
+ ret = msg_get_mms_struct(messageData, mms_struct);
+
+ if (ret != MSG_SUCCESS)
+ {
+ LoggerE("cannot get mms struct");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "cannot get mms struct");
+ }
+
+ char szFilePath[MSG_FILEPATH_LEN_MAX] = {0,};
+ char szFileName[MSG_FILENAME_LEN_MAX] = {0,};
+
+ msg_get_list_handle(mms_struct, MSG_MMS_PAGE_LIST_HND, (void **)&page_list);
+ pageLen = msg_list_length(page_list);
+
+ if (pageLen > 0) {
+ setMmsType(MULTIPART_RELATED);
+ } else {
+ setMmsType(MULTIPART_MIXED);
+ }
+
+ LoggerD("page count: " << pageLen);
+
+ for (int p = 0; p < pageLen; ++p)
+ {
+ LoggerD("page " << p);
+ page = (msg_struct_t)msg_list_nth_data(page_list, p);
+
+ if (NULL == page) {
+ LoggerE("returned page is null, continue");
+ continue;
+ }
+
+ msg_get_list_handle(page, MSG_MMS_PAGE_MEDIA_LIST_HND, (void **)&media_list);
+ mediaLen = msg_list_length(media_list);
+
+ for (int m = 0; m < mediaLen; ++m)
+ {
+ LoggerD("media file " << m);
+ media = (msg_struct_t)msg_list_nth_data(media_list, m);
+ if (NULL == media)
+ {
+ LoggerE("returned media is null, continue");
+ continue;
+ }
+
+ msg_get_int_value(media, MSG_MMS_MEDIA_TYPE_INT, &tempInt);
+
+ memset(szFilePath, 0, sizeof(szFilePath));
+ msg_get_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, szFilePath, sizeof(szFilePath));
+
+ if ((0 == p) && (MMS_SMIL_MEDIA_TEXT == tempInt))
+ {
+ //text value on first page goes to body attribute
+ LoggerD("setting body from " << szFilePath);
+
+ FILE* f = NULL;
+ f = fopen(szFilePath, "r");
+ if (!f)
+ {
+ LoggerE("cannot read file with body" << szFilePath);
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Cannot read file with body");
+ }
+ fseek(f, 0, SEEK_END);
+ long int size = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ char* data = new (nothrow) char[size + 1];
+ size_t error;
+ if (data) {
+ memset(data, 0, size + 1);
+ error = fread(data, 1, size, f);
+ setBody(data);
+ delete[] data;
+ } else {
+ LoggerE("body is not set");
+ }
+ LoggerD("message body: '" << getBody() << "'");
+ fclose(f);
+ }
+ else
+ {
+ LoggerD("adding attachment " << szFilePath);
+
+ IAttachmentPtr attachment = appendAttachment(szFilePath, false);
+ //attachment->setMessage(this); //set IMessagePtr
+
+ memset(szFileName, 0, sizeof(szFileName));
+ msg_get_str_value(media, MSG_MMS_MEDIA_FILENAME_STR, szFileName, sizeof(szFileName));
+ if ((szFileName[0] =! '\0' )&& (strnlen(szFileName, MSG_FILENAME_LEN_MAX) > 0))
+ {
+ LoggerD("renaming to " << szFileName);
+ attachment->rename(szFileName);
+ }
+ else if (MMS_SMIL_MEDIA_TEXT == tempInt)
+ {
+ std::stringstream newName;
+ newName << "body_page_" << p + 1 << ".txt";
+ LoggerD("renaming to " << newName.str());
+ attachment->rename(newName.str());
+ }
+ }
+ }
}
msg_release_struct(&mms_struct);
}
+
bool Mms::hasAttachment()
{
std::size_t attachmentSize = getAttachmentsCount();
msg_struct_t attachment[20];
- for (size_t i = 0; i < getAttachmentsRef().size(); ++i) {
- IAttachmentPtr att = getAttachment(i);
+ for (size_t idx = 0; idx < getAttachmentsRef().size(); ++idx) {
+ IAttachmentPtr att = getAttachment(idx);
if (!att) {
continue;
}
}
//this function should return valid pointer
+ att->setMessage(SharedFromThis()); // setMessage to setMessageId
+ att->setAttachmentID((int)idx);
+ att->setDownloaded(true);
+
+ int ret = mimeTypeStringToIndexInt(att->getMimeType());
+
+ msg_mms_add_item(mms_struct, MSG_STRUCT_MMS_ATTACH, &attachment[idx]);
+ msg_set_str_value(attachment[idx], MSG_MMS_ATTACH_FILEPATH_STR, const_cast<char*>(att->getFullPath().c_str()), MSG_FILEPATH_LEN_MAX);
- msg_mms_add_item(mms_struct, MSG_STRUCT_MMS_ATTACH, &attachment[i]);
- msg_set_str_value(attachment[i], MSG_MMS_ATTACH_FILEPATH_STR, const_cast<char*>(att->getFullPath().c_str()), MSG_FILEPATH_LEN_MAX);
+ if(ret != MIME_UNKNOWN)
+ {
+ msg_set_int_value(attachment[idx], MSG_MMS_ATTACH_MIME_TYPE_INT, ret);
+ }
LoggerD("Attachment added");
{
LoggerD("updating m_id=" << getIdRef());
msg_error_t err = MSG_SUCCESS;
+ int tempInt = 0;
+
msg_struct_t msg = NULL;
msg_struct_t sendOpt = NULL;
if (err != MSG_SUCCESS)
{
- LoggerE("Get Message Failed!");
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+ LoggerE("msg_get_message() Failed!");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to get message for update");
}
if (this->getIdRef().empty()) {
ThrowMsg(WrtDeviceApis::Commons::PlatformException,
"existing msgId is zero, update msg not done");
}
-
+
+ err = msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, &tempInt);
+ if(err == MSG_SUCCESS)
+ {
+ msg_set_int_value(m_messageData, MSG_MESSAGE_NETWORK_STATUS_INT, tempInt);
+ }
+
+ err = msg_get_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, &tempInt);
+ if(err == MSG_SUCCESS)
+ {
+ msg_set_int_value(m_messageData, MSG_MESSAGE_FOLDER_ID_INT, tempInt);
+ }
+
update(TRUE);
if (MSG_SUCCESS != msg_update_message(MsgGetCommonHandle(), m_messageData, sendOpt))
{
- LoggerE("Failed to update message");
+ LoggerE("msg_update_message() Failed!");
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
}
msg_release_struct(&msg);
msg_release_struct(&msg);
msg_release_struct(&sendOpt);
LoggerE("platform error occurs");
+ ReThrow(WrtDeviceApis::Commons::PlatformException);
}
}
{
LoggerD("convert m_id= " << convertId(getIdRef()));
+ msg_struct_t sendOpt = NULL;
+
//prepare for add sms to draft folder
if (!m_messageData) {
//error if platform message not exists
Throw(WrtDeviceApis::Commons::PlatformException);
}
- //update all sms data
+ //update all mms data
if (getCurrentFolder() == DRAFTBOX) {
LoggerD("update all mms data");
updateSubject();
Try
{
int msgId = 0;
-// MSG_SENDINGOPT_S option = { false, false, false };
-// option.option.smsSendOpt.bReplyPath = true;
- // trying to get message from platform
+ sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+ // trying to add message
-// msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
-// msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false);
+// msg_set_int_value(m_messageData, MSG_MESSAGE_NETWORK_STATUS_INT, MSG_NETWORK_NOT_SEND);
+ int ret = msg_add_message(MsgGetCommonHandle(), m_messageData, sendOpt);
+ if (ret < MSG_SUCCESS) {
+ LoggerE("msg_add_message failed, error code=" << ret);
+ Throw(WrtDeviceApis::Commons::PlatformException);
+ }
+ else
+ {
+ msgId = ret;
+ }
-// const msg_folder_id_t platfromFolderId = Messaging::convertFolderToPlatform(DRAFTBOX);
+ LoggerD("Message ID : " << msgId);
-// msg_set_int_value(m_messageData, MSG_MESSAGE_ID_INT, msgId);
-// msg_set_int_value(m_messageData, MSG_MESSAGE_FOLDER_ID_INT, 4);
-// msg_set_int_value(m_messageData, MSG_MESSAGE_NETWORK_STATUS_INT, MSG_NETWORK_NOT_SEND);
+ msg_set_int_value(m_messageData, MSG_MESSAGE_ID_INT, msgId);
setId(convertId(msgId));
- setFolderType(DRAFTBOX);
+ loadDraftMessage();
+
+ setFolderType(OUTBOX);
setMessageStatus(MESSAGE_STATUS_DRAFT);
+
+ msg_release_struct(&sendOpt);
}
Catch(WrtDeviceApis::Commons::PlatformException) {
LoggerE("remove message error");
- if (m_messageData) {
- //releasing platform message structure
-// msg_release_message(&m_messageData);
- msg_release_struct(&m_messageData);
- }
+ msg_release_struct(&sendOpt);
throw;
}
-
}
void Mms::addMessageToDraft()
msg_set_int_value(m_messageData, MSG_MESSAGE_ID_INT, msgId);
setId(convertId(msgId));
- setFolderType(DRAFTBOX);
- setMessageStatus(MESSAGE_STATUS_DRAFT);
+ loadDraftMessage();
msg_release_struct(&sendOpt);
}
+void Mms::loadDraftMessage()
+{
+ LoggerD("entered");
+
+ if (getIdRef().empty() || (EMPTY_ID == getIdRef()))
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Empty id.");
+ }
+
+ msg_release_struct(&m_messageData);
+ m_messageData = NULL;
+ msg_struct_t sendOpt = NULL;
+
+ Try {
+
+ m_messageData = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+ sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+
+ // trying to get message from platform
+ if (MSG_SUCCESS != msg_get_message(MsgGetCommonHandle(), convertId(getIdRef()), m_messageData, sendOpt))
+ {
+ LoggerE("get message error");
+ Throw(WrtDeviceApis::Commons::PlatformException);
+ }
+ LoggerD("message found with msgId=" << getIdRef());
+
+ // read all mms dat to abstraction layer
+ readConversationId(m_messageData);
+ readPriority(m_messageData);
+ readSubject(m_messageData);
+ readFolder(m_messageData);
+ readDateTime(m_messageData);
+ readReadStatus(m_messageData);
+ readMessageStatus(m_messageData);
+ readBody(m_messageData);
+
+ msg_release_struct(&sendOpt);
+ }
+ Catch(WrtDeviceApis::Commons::PlatformException) {
+ LoggerE("exception");
+ // nothing to do
+ msg_release_struct(&sendOpt);
+ }
+
+}
+
void Mms::readAllData()
{
- readExistingMessage();
+ LoggerD("entered");
+
+ if (getIdRef().empty() || (EMPTY_ID == getIdRef()))
+ {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Empty id.");
+ }
+
+ msg_release_struct(&m_messageData);
+ m_messageData = NULL;
+ msg_struct_t sendOpt = NULL;
+
+ Try {
+
+ m_messageData = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+ sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+
+ // trying to get message from platform
+ if (MSG_SUCCESS != msg_get_message(MsgGetCommonHandle(), convertId(getIdRef()), m_messageData, sendOpt))
+ {
+ LoggerE("get message error");
+ Throw(WrtDeviceApis::Commons::PlatformException);
+ }
+ LoggerD("message found with msgId=" << getIdRef());
+
+ // read all mms dat to abstraction layer
+ readConversationId(m_messageData);
+// readRecipientList(m_messageData);
+ readPriority(m_messageData);
+ readSubject(m_messageData);
+ readBodyAndAttachments(m_messageData);
+ readFolder(m_messageData);
+ readDateTime(m_messageData);
+ readReadStatus(m_messageData);
+ readMessageStatus(m_messageData);
+
+ msg_release_struct(&sendOpt);
+ }
+ Catch(WrtDeviceApis::Commons::PlatformException) {
+ LoggerE("exception");
+ // nothing to do
+ msg_release_struct(&sendOpt);
+ }
+
}
void Mms::moveToFolder(const FolderType newFolder)
int Mms::send()
{
LoggerD("sending message, id=" << getIdRef());
+ msg_error_t err = MSG_SUCCESS;
+
Try
{
//prepare for sending sms/mms
update();
- LoggerD("Start Sending Message...");
-
LoggerD("trying to send mms");
- msg_error_t err = CallbackMgrSingleton::Instance().registerAndSend(msg_mms_send_message, m_messageData, this);
+ if (!getCellularOn())
+ {
+ err = MSG_ERR_TRANSPORT_ERROR;
+ LoggerW("MMS send error. No transport possible over network");
+ }
+ else
+ {
+ err = CallbackMgrSingleton::Instance().registerAndSend(msg_mms_send_message, m_messageData, this);
+ }
if (err != MSG_SUCCESS)
{
LoggerE("Sending Message (submit request) failed!!! err=" << err);
setMessageStatus(MESSAGE_STATUS_FAILED);
- goto ERROR;
+ Throw(WrtDeviceApis::Commons::PlatformException);
}
setMessageStatus(MESSAGE_STATUS_SENDING);
}
Catch(WrtDeviceApis::Commons::PlatformException) {
LoggerE("message is not send, manually run callback");
- goto ERROR;
+ ReqReceiverMessage *requestReceiver = getRequestReceiver();
+ if (requestReceiver) {
+ LoggerE("send Error");
+ EventMessagingServicePtr event = getMessagingServiceEvent();
+ if(err == MSG_ERR_TRANSPORT_ERROR)
+ {
+ event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::PlatformWrongStateException);
+ }
+ else
+ {
+ event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
+ }
+ requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventMessagingService>::ManualAnswer(event);
+ }
}
return 0;
-
- ERROR:
- ReqReceiverMessage *requestReceiver = getRequestReceiver();
- if (requestReceiver) {
- LoggerE("send Error");
- EventMessagingServicePtr event = getMessagingServiceEvent();
- event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
- requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventMessagingService>::ManualAnswer(event);
- }
- return 0;
}
void Mms::sendingCallback(msg_struct_t sent_status)
{
-// LoggerI("sendingCallback callback received. Req id = " <<
-// sent_status->reqId << " Status = " << (int)sent_status->status);
-// msg_struct_t request_data = NULL;
-// msg_get_struct_handle(sent_status, MSG_STRUCT_REQUEST_INFO, (void **)request_data);
-// msg_get_int_value(request_data, MSG_REQUEST_REQUESTID_INT, &tempInt);
int status = MSG_NETWORK_SEND_FAIL;
msg_get_int_value(sent_status, MSG_SENT_STATUS_NETWORK_STATUS_INT, &status);
for ( int index=0; index < nToCnt; index++)
{
- msg_get_str_value(addr_list->msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, MAX_ADDRESS_VAL_LEN);
+ msg_get_str_value(addr_list->msg_struct_info[index], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, MAX_ADDRESS_VAL_LEN);
event->m_successRecipients.push_back(strNumber);
}
}
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Invalid folder");
}
+
+bool Mms::getCellularOn()
+{
+ auto cellularOn = true;
+ int tempInt;
+ int tempbool;
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &tempInt);
+ vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &tempbool);
+ if(tempInt <= VCONFKEY_TELEPHONY_SVCTYPE_SEARCH || tempbool == TRUE)
+ {
+ LoggerE("VCONFKEY_TELEPHONY_SVCTYPE error " << tempInt);
+ LoggerE("VCONFKEY_TELEPHONY_FLIGHT_MODE error " << tempbool);
+ cellularOn = false;
+ return cellularOn;
+ }
+
+ vconf_get_bool(VCONFKEY_3G_ENABLE, &tempbool);
+ vconf_get_int(VCONFKEY_TELEPHONY_SVC_PS, &tempInt);
+ if(tempbool == FALSE || tempInt != VCONFKEY_TELEPHONY_SVC_PS_ON)
+ {
+ LoggerE("VCONFKEY_3G_ENABLE error " << tempbool);
+ LoggerE("VCONFKEY_TELEPHONY_SVC_PS_ON error " << tempInt);
+ cellularOn = false;
+ }
+ return cellularOn;
+}
+
+
+MimeType Mms::mimeTypeStringToIndexInt(std::string inputString)
+{
+ const char* szMimeStr = inputString.c_str();
+ MimeType retInt = MIME_UNKNOWN;
+
+ LoggerD("szMimeStr " << szMimeStr);
+
+ for(int idx =0; strcmp(mimeTable[idx].szMIME, "") != 0; idx++)
+ {
+ if (!strcmp(mimeTable[idx].szMIME, szMimeStr)) {
+ retInt = mimeTable[idx].mime;
+ break;
+ }
+ }
+ return retInt;
+
+}
+
+std::string Mms::indexIntToMimeTypeString(MimeType inputIndex)
+{
+ std::string retString;
+
+ for (int idx=0; mimeTable[idx].szMIME != NULL; idx++) {
+ if (inputIndex == mimeTable[idx].mime) {
+ retString = (char *)mimeTable[idx].szMIME;
+ }
+ }
+ return retString;
+}
+
+msg_struct_t Mms::createNewCopyOfPLatformMsgWithAddressList(const msg_struct_t src) const
+{
+ int tempInt, nCount, ret;
+ bool tempBool;
+ msg_struct_list_s *addr_list;
+ msg_struct_list_s *new_addr_list;
+
+ msg_struct_t mms_struct = NULL;
+ msg_struct_t mms_struct_dummy = NULL;
+
+ msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+
+ msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
+
+ char strSubject[MAX_SUBJECT_LEN] = {0};
+ msg_get_str_value(src, MSG_MESSAGE_SUBJECT_STR, strSubject, MAX_SUBJECT_LEN);
+ msg_set_str_value(msg, MSG_MESSAGE_SUBJECT_STR, strSubject, MAX_SUBJECT_LEN);
+
+ msg_get_int_value(src, MSG_MESSAGE_STORAGE_ID_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_STORAGE_ID_INT, tempInt);
+
+ msg_get_int_value(src, MSG_MESSAGE_THREAD_ID_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_THREAD_ID_INT, tempInt);
+
+ msg_get_int_value(src, MSG_MESSAGE_FOLDER_ID_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, tempInt);
+
+// msg_get_int_value(src, MSG_MESSAGE_DATA_SIZE_INT, &tempInt);
+// char tempStr[tempInt+1];
+// memset(tempStr, 0, tempInt+1);
+
+// msg_get_str_value(src, MSG_MESSAGE_SMS_DATA_STR, tempStr, tempInt);
+// msg_set_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, tempStr, strlen(tempStr));
+// copy mms body and attachment
+ mms_struct = msg_create_struct(MSG_STRUCT_MMS);
+ mms_struct_dummy = msg_create_struct(MSG_STRUCT_MMS);
+ ret = msg_get_mms_struct(src, mms_struct);
+ if (ret != MSG_SUCCESS)
+ {
+ LoggerE("cannot get mms struct");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "cannot get mms struct");
+ }
+
+ msg_set_mms_struct(src, mms_struct_dummy);
+ msg_set_mms_struct(msg, mms_struct);
+
+ msg_get_int_value(src, MSG_MESSAGE_DISPLAY_TIME_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, tempInt);
+
+// msg_set_network_status(msg, msg_get_network_status(src));
+ msg_get_int_value(src, MSG_MESSAGE_NETWORK_STATUS_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, tempInt);
+
+// msg_set_encode_type(msg, msg_get_encode_type(src));
+ msg_get_int_value(src, MSG_MESSAGE_ENCODE_TYPE_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_ENCODE_TYPE_INT, tempInt);
+
+// msg_set_read_status(msg, msg_is_read(src));
+ msg_get_bool_value(src, MSG_MESSAGE_READ_BOOL, &tempBool);
+ msg_set_bool_value(msg, MSG_MESSAGE_READ_BOOL, tempBool);
+
+// msg_set_protect_status(msg, msg_is_protected(src));
+ msg_get_bool_value(src, MSG_MESSAGE_PROTECTED_BOOL, &tempBool);
+ msg_set_bool_value(msg, MSG_MESSAGE_PROTECTED_BOOL, tempBool);
+
+// msg_set_priority_info(msg, msg_get_priority_info(src));
+ msg_get_int_value(src, MSG_MESSAGE_PRIORITY_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_PRIORITY_INT, tempInt);
+
+// msg_set_direction_info(msg, msg_get_direction_info(src));
+ msg_get_int_value(src, MSG_MESSAGE_DIRECTION_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_DIRECTION_INT, tempInt);
+
+// msg_set_port(msg, msg_get_dest_port(src), msg_get_src_port(src));
+ msg_get_int_value(src, MSG_MESSAGE_DEST_PORT_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_DEST_PORT_INT, tempInt);
+ msg_get_int_value(src, MSG_MESSAGE_SRC_PORT_INT, &tempInt);
+ msg_set_int_value(msg, MSG_MESSAGE_SRC_PORT_INT, tempInt);
+
+// copy addr list
+ msg_get_list_handle(src, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list);
+ msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&new_addr_list);
+
+ new_addr_list->nCount = addr_list->nCount;
+
+ for(int i=0; i<addr_list->nCount; i++)
+ {
+ msg_struct_t addr_info = NULL;
+ msg_struct_t new_addr_info = NULL;
+ char addr_value[MAX_ADDRESS_VAL_LEN] = {0,};
+
+ //get original address
+ addr_info = addr_list->msg_struct_info[i];
+ msg_get_str_value(addr_info, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr_value, MAX_ADDRESS_VAL_LEN);
+ msg_get_int_value(addr_info, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, &tempInt);
+
+ //copy original address
+ new_addr_info = new_addr_list->msg_struct_info[i];
+ msg_set_str_value(new_addr_info, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr_value, MAX_ADDRESS_VAL_LEN);
+ msg_set_int_value(new_addr_info, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, tempInt);
+ }
+
+ msg_release_struct(&mms_struct_dummy);
+ msg_release_struct(&mms_struct);
+
+ return msg;
+}
+
}
}