#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();
}
}
m_messageData(NULL)
{
LoggerD("m_id=" << getIdRef());
- LoggerD("m_msgType=" << getMessageType());
- LoggerD("created msg_data : " << msg_data);
m_messageData = createNewCopyOfPLatformMsgWithAddressList(msg_data);
- LoggerD("created m_messageData : " << m_messageData);
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("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()
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)
{
if (requestReceiver) {
LoggerE("send Error");
EventMessagingServicePtr event = getMessagingServiceEvent();
- event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
+ 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);
}
}
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();
LoggerD("szMimeStr " << szMimeStr);
- for(int idx =0; mimeTable[idx].szMIME != NULL ; idx++)
+ for(int idx =0; strcmp(mimeTable[idx].szMIME, "") != 0; idx++)
{
if (!strcmp(mimeTable[idx].szMIME, szMimeStr)) {
retInt = mimeTable[idx].mime;
msg_struct_t Mms::createNewCopyOfPLatformMsgWithAddressList(const msg_struct_t src) const
{
- int tempInt, nCount;
+ int tempInt, nCount, ret;
bool tempBool;
msg_struct_list_s *addr_list;
msg_struct_list_s *new_addr_list;
- int pageLen, mediaLen, attachLen, ret;
-
msg_struct_t mms_struct = NULL;
msg_struct_t mms_struct_dummy = NULL;
- msg_list_handle_t page_list = NULL;
- msg_list_handle_t media_list = NULL;
- msg_list_handle_t attach_list = NULL;
-
- msg_struct_t page = NULL;
- msg_struct_t media = NULL;
- msg_struct_t attach = NULL;
-
- char szFilePath[MSG_FILEPATH_LEN_MAX] = {0,};
- char szFileName[MSG_FILENAME_LEN_MAX] = {0,};
-
msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
// copy mms body and attachment
mms_struct = msg_create_struct(MSG_STRUCT_MMS);
mms_struct_dummy = msg_create_struct(MSG_STRUCT_MMS);
- msg_get_mms_struct(src, mms_struct);
+ 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_release_struct(&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_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;
}