summaryrefslogtreecommitdiff
path: root/plugin/mms_plugin
diff options
context:
space:
mode:
authorSangkoo Kim <sangkoo.kim@samsung.com>2014-02-18 13:08:00 +0900
committerSangkoo Kim <sangkoo.kim@samsung.com>2014-02-18 13:58:23 +0900
commit32e5be91b19c52ec7c4b568267b11a95e4811593 (patch)
tree1430857bcec2e64c30c37276888a2ee7f3bd65ea /plugin/mms_plugin
parentc988cc8b55b9f0ce2623cb266288fe35143df635 (diff)
downloadmsg-service-32e5be91b19c52ec7c4b568267b11a95e4811593.tar.gz
msg-service-32e5be91b19c52ec7c4b568267b11a95e4811593.tar.bz2
msg-service-32e5be91b19c52ec7c4b568267b11a95e4811593.zip
Sync with tizen_2.2
Change-Id: I3acbde088f5dae01d5ac588fbde10cf27fcb3afa Signed-off-by: Sangkoo Kim <sangkoo.kim@samsung.com>
Diffstat (limited to 'plugin/mms_plugin')
-rwxr-xr-xplugin/mms_plugin/CMakeLists.txt2
-rwxr-xr-xplugin/mms_plugin/MmsPluginConnManWrapper.cpp718
-rwxr-xr-xplugin/mms_plugin/MmsPluginDecode.cpp958
-rwxr-xr-xplugin/mms_plugin/MmsPluginHttp.cpp567
-rwxr-xr-xplugin/mms_plugin/MmsPluginMain.cpp2
-rwxr-xr-xplugin/mms_plugin/MmsPluginMessage.cpp56
-rwxr-xr-xplugin/mms_plugin/MmsPluginStorage.cpp658
-rwxr-xr-xplugin/mms_plugin/MmsPluginUserAgent.cpp166
-rwxr-xr-xplugin/mms_plugin/include/MmsPluginConnManWrapper.h25
-rwxr-xr-xplugin/mms_plugin/include/MmsPluginDecode.h2
-rwxr-xr-xplugin/mms_plugin/include/MmsPluginHttp.h63
11 files changed, 1434 insertions, 1783 deletions
diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt
index ee1f975..a0f874a 100755
--- a/plugin/mms_plugin/CMakeLists.txt
+++ b/plugin/mms_plugin/CMakeLists.txt
@@ -45,7 +45,7 @@ INCLUDE_DIRECTORIES(
)
INCLUDE(FindPkgConfig)
-pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 network libxml-2.0 drm-client libcurl mm-fileinfo mmutil-jpeg vconf dlog media-thumbnail)
+pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 network libxml-2.0 drm-client libcurl mm-fileinfo mmutil-jpeg vconf dlog media-thumbnail capi-network-connection)
FOREACH(flag ${mms_plugin_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp
index 3e26517..5dac38c 100755
--- a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp
+++ b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp
@@ -17,122 +17,353 @@
#include <errno.h>
#include "MmsPluginConnManWrapper.h"
#include "MmsPluginDebug.h"
+#include "MmsPluginHttp.h"
+#include <glib.h>
+#include "net_connection.h"
-void network_print_profile(net_profile_info_t *ProfInfo)
+#define MMS_CONTEXT_INVOKE_WAIT_TIME 30
+#define MMS_CONNECTION_API_WAIT_TIME 50
+
+#define MMS_FREE(obj)\
+ if (obj){\
+ free(obj);\
+ obj = NULL;\
+ }
+
+
+static Mutex g_mx;
+static CndVar g_cv;
+static connection_h connection = NULL;
+
+void __connection_profile_print(connection_profile_h profile)
{
- int di = 0;
-
- unsigned char *ipaddr;
- unsigned char *netmaskaddr;
- unsigned char *gwaddr;
- net_dev_info_t *net_info;
-
- if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
- ipaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.IpAddr.Data.Ipv4.s_addr;
- netmaskaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.SubnetMask.Data.Ipv4.s_addr;
- gwaddr = (unsigned char *)&ProfInfo->ProfileInfo.Pdp.net_info.GatewayAddr.Data.Ipv4.s_addr;
- net_info = &(ProfInfo->ProfileInfo.Pdp.net_info);
+ int ret;
+ char *profile_id = NULL;
+ char *profile_name = NULL;
+ char *interface_name = NULL;
+ char *ip_address = NULL;
+ char *subnet_mask = NULL;
+ char *gateway_address = NULL;
+ char *dns_address = NULL;
+ char *proxy_address = NULL;
+ char *apn = NULL;
+ char *user_name = NULL;
+ char *password = NULL;
+ char *home_url = NULL;
+ bool is_roaming;
+
+ connection_profile_type_e profile_type;
+ connection_profile_state_e profile_state;
+ connection_ip_config_type_e ip_type = CONNECTION_IP_CONFIG_TYPE_NONE;
+ connection_proxy_type_e proxy_type;
+ connection_cellular_service_type_e service_type = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+ connection_cellular_auth_type_e auth_type = CONNECTION_CELLULAR_AUTH_TYPE_NONE;
+
+ MSG_DEBUG("**************************************************************************************************");
+ ret = connection_profile_get_id(profile, &profile_id);
+ MSG_DEBUG("Profile Id = [%s]", profile_id);
+
+ ret = connection_profile_get_name(profile, &profile_name);
+ MSG_DEBUG("Profile Name = [%s]", profile_name);
+
+ ret = connection_profile_get_type(profile, &profile_type);
+
+ if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
+ MSG_DEBUG("Profile Type = [CELLULAR]");
+ } else if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) {
+ MSG_DEBUG("Profile Type = [WIFI]");
+ } else if (profile_type == CONNECTION_PROFILE_TYPE_ETHERNET) {
+ MSG_DEBUG("Profile Type = [ETHERNET]");
+ } else if (profile_type == CONNECTION_PROFILE_TYPE_BT) {
+ MSG_DEBUG("Profile Type = [BT]");
+ } else {
+ MSG_DEBUG("Profile Type = Unknown [%d]", profile_type);
+ }
+
+ ret = connection_profile_get_network_interface_name(profile, &interface_name);
+ MSG_DEBUG("Profile Interface Name = [%s]", interface_name);
+
+ ret = connection_profile_get_state(profile, &profile_state);
+ if (profile_state == CONNECTION_PROFILE_STATE_DISCONNECTED) {
+ MSG_DEBUG("Profile State = [DISCONNECTED]");
+ } else if (profile_state == CONNECTION_PROFILE_STATE_ASSOCIATION) {
+ MSG_DEBUG("Profile State = [ASSOCIATION]");
+ } else if (profile_state == CONNECTION_PROFILE_STATE_CONFIGURATION) {
+ MSG_DEBUG("Profile State = [CONFIGURATION]");
+ } else if (profile_state == CONNECTION_PROFILE_STATE_CONNECTED) {
+ MSG_DEBUG("Profile State = [CONNECTED]");
} else {
- MSG_DEBUG("Error!!! Invalid profile type\n");
- return;
+ MSG_DEBUG("Profile State = Unknown [%d]", profile_state);
}
+ ret = connection_profile_get_ip_config_type(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_type);
+ MSG_DEBUG("Profile Ip Config Type = [%d]", ip_type);
+
+ ret = connection_profile_get_ip_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_address);
+ MSG_DEBUG("Profile Ip Address = [%s]", ip_address);
+
+ ret = connection_profile_get_subnet_mask(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &subnet_mask);
+ MSG_DEBUG("Profile Subnet Mask = [%s]", subnet_mask);
+
+ ret = connection_profile_get_gateway_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &gateway_address);
+ MSG_DEBUG("Profile Gateway Address = [%s]", gateway_address);
+
+ ret = connection_profile_get_dns_address(profile, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &dns_address);
+ MSG_DEBUG("Profile Dns Address = [%s]", dns_address);
+
+ ret = connection_profile_get_proxy_type(profile, &proxy_type);
+ MSG_DEBUG("Profile Proxy Type = [%d]", proxy_type);
+
+ ret = connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_address);
+ MSG_DEBUG("Profile Proxy Address = [%s]", proxy_address);
+
+ ret = connection_profile_get_cellular_service_type(profile, &service_type);
+ if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET) {
+ MSG_DEBUG("Profile Service Type = [INTERNET]");
+ } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_MMS) {
+ MSG_DEBUG("Profile Service Type = [MMS]");
+ } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET) {
+ MSG_DEBUG("Profile Service Type = [PREPAID_INTERNET]");
+ } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS) {
+ MSG_DEBUG("Profile Service Type = [PREPAID_MMS]");
+ } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING) {
+ MSG_DEBUG("Profile Service Type = [TETHERING]");
+ } else if (service_type == CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION) {
+ MSG_DEBUG("Profile Service Type = [APPLICATION]");
+ } else {
+ MSG_DEBUG("Profile Service Type = [Unknown][%d]", service_type);
+ }
+
+ ret = connection_profile_get_cellular_apn(profile, &apn);
+ MSG_DEBUG("Profile Apn = [%s]", apn);
+
+ ret = connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password);
+ MSG_DEBUG("Profile Auth Type = [%d]", &auth_type);
+ MSG_DEBUG("Profile Auth Name = [%s]", &user_name);
+ MSG_DEBUG("Profile Auth Passward = [%s]", &password);
+
+ ret = connection_profile_get_cellular_home_url(profile, &home_url);
+ MSG_DEBUG("Profile Home Url = [%s]", home_url);
+
+ ret = connection_profile_is_cellular_roaming(profile, &is_roaming);
+ MSG_DEBUG("Profile Roaming = [%d]", is_roaming);
MSG_DEBUG("**************************************************************************************************");
- MSG_DEBUG("Profile Name = [%s]\n", ProfInfo->ProfileName);
-
- if (ProfInfo->ProfileState == NET_STATE_TYPE_IDLE)
- MSG_DEBUG("Profile State = [idle]\n");
- else if (ProfInfo->ProfileState == NET_STATE_TYPE_FAILURE)
- MSG_DEBUG("Profile State = [failure]\n");
- else if (ProfInfo->ProfileState == NET_STATE_TYPE_ASSOCIATION)
- MSG_DEBUG("Profile State = [association]\n");
- else if (ProfInfo->ProfileState == NET_STATE_TYPE_CONFIGURATION)
- MSG_DEBUG("Profile State = [configuration]\n");
- else if (ProfInfo->ProfileState == NET_STATE_TYPE_READY)
- MSG_DEBUG("Profile State = [ready]\n");
- else if (ProfInfo->ProfileState == NET_STATE_TYPE_ONLINE)
- MSG_DEBUG("Profile State = [online]\n");
- else if (ProfInfo->ProfileState == NET_STATE_TYPE_DISCONNECT)
- MSG_DEBUG("Profile State = [disconnect]\n");
- else
- MSG_DEBUG("Profile State = [unknown]\n");
+ MMS_FREE(profile_id);
+ MMS_FREE(profile_name);
+ MMS_FREE(interface_name);
+ MMS_FREE(ip_address);
+ MMS_FREE(subnet_mask);
+ MMS_FREE(gateway_address);
+ MMS_FREE(dns_address);
+ MMS_FREE(proxy_address);
+ MMS_FREE(apn);
+ MMS_FREE(user_name);
+ MMS_FREE(password);
+ MMS_FREE(home_url);
+}
+
+static void __connection_type_changed_cb(connection_type_e type, void* user_data)
+{
+ MSG_DEBUG("Type changed callback, connection type : %d", type);
+}
+
+static void __connection_ip_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data)
+{
+ MSG_DEBUG("IP changed callback, IPv4 address : %s, IPv6 address : %s",
+ ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
+}
- MSG_DEBUG("Profile Type = [pdp]\n");
+static void __connection_proxy_changed_cb(const char* ipv4_address, const char* ipv6_address, void* user_data)
+{
+ MSG_DEBUG("Proxy changed callback, IPv4 address : %s, IPv6 address : %s",
+ ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
+}
- if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_GPRS)
- MSG_DEBUG("Profile Protocol Type = [GPRS]\n");
- else if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_EDGE)
- MSG_DEBUG("Profile Protocol Type = [EDGE]\n");
- else if (ProfInfo->ProfileInfo.Pdp.ProtocolType == NET_PDP_TYPE_UMTS)
- MSG_DEBUG("Profile Protocol Type = [UMTS]\n");
+static void __connection_profile_opened_cb(connection_error_e result, void* user_data)
+{
+ if (result == CONNECTION_ERROR_NONE || result == CONNECTION_ERROR_ALREADY_EXISTS)
+ MSG_DEBUG("Connection open Succeeded [%d]", result);
else
- MSG_DEBUG("Profile Protocol Type = [NONE]\n");
+ MSG_DEBUG("Connection open Failed, err : %d", result);
- MSG_DEBUG("Profile APN = [%s]\n", ProfInfo->ProfileInfo.Pdp.Apn);
+ MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance();
- if (ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType == NET_PDP_AUTH_PAP)
- MSG_DEBUG("Profile Auth Type = [PAP]\n");
- else if (ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType == NET_PDP_AUTH_CHAP)
- MSG_DEBUG("Profile Auth Type = [CHAP]\n");
+ cmAgent->open_callback(result, user_data);
+}
+
+static void __connection_profile_closed_cb(connection_error_e result, void* user_data)
+{
+ if (result == CONNECTION_ERROR_NONE)
+ MSG_DEBUG("Connection close Succeeded");
else
- MSG_DEBUG("Profile Auth Type = [NONE]\n");
-
- MSG_DEBUG("Profile Auth UserName = [%s]\n", ProfInfo->ProfileInfo.Pdp.AuthInfo.UserName);
- MSG_DEBUG("Profile Auth Password = [%s]\n", ProfInfo->ProfileInfo.Pdp.AuthInfo.Password);
- MSG_DEBUG("Profile Home URL = [%s]\n", ProfInfo->ProfileInfo.Pdp.HomeURL);
- MSG_DEBUG("Profile MCC = [%s]\n", ProfInfo->ProfileInfo.Pdp.Mcc);
- MSG_DEBUG("Profile MNC = [%s]\n", ProfInfo->ProfileInfo.Pdp.Mnc);
- MSG_DEBUG("Profile Roaming = [%d]\n", (int)ProfInfo->ProfileInfo.Pdp.Roaming);
- MSG_DEBUG("Profile Setup Required = [%d]\n", (int)ProfInfo->ProfileInfo.Pdp.SetupRequired);
- MSG_DEBUG("Profile Favourite = [%d]\n", (int)ProfInfo->Favourite);
- MSG_DEBUG("Profile Device Name = [%s]\n", net_info->DevName);
- MSG_DEBUG("Profile DNS Count = [%d]\n", net_info->DnsCount);
- for (di = 0; di < net_info->DnsCount; di++) {
- unsigned char *dns = (unsigned char *)&net_info->DnsAddr[di].Data.Ipv4.s_addr;
- MSG_DEBUG("Profile DNS Address %d = [%d.%d.%d.%d]\n", di+1, dns[0], dns[1], dns[2], dns[3]);
+ MSG_DEBUG("Connection close Failed, err : %d", result);
+
+ MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance();
+
+ cmAgent->close_callback(result, user_data);
+}
+
+static gboolean __connection_create(void *pVoid)
+{
+ MSG_BEGIN();
+
+ bool ret = false;
+ bool *ret_val = (bool *)pVoid;
+
+ if (connection) {
+ MSG_DEBUG("connection already exist");
+ ret = true;
+ } else {
+ int err = connection_create(&connection);
+
+ if (CONNECTION_ERROR_NONE == err) {
+ connection_set_type_changed_cb(connection, __connection_type_changed_cb, NULL);
+ connection_set_ip_address_changed_cb(connection, __connection_ip_changed_cb, NULL);
+ connection_set_proxy_address_changed_cb(connection, __connection_proxy_changed_cb, NULL);
+ ret = true;
+ MSG_DEBUG("Client registration success [%p] ", connection);
+ } else {
+ MSG_DEBUG("Client registration failed %d", err);
+ }
}
- if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC)
- MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_DYNAMIC]\n");
- else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC)
- MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_STATIC]\n");
- else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_FIXED)
- MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_FIXED]\n");
- else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_OFF)
- MSG_DEBUG("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_OFF]\n");
- else
- MSG_DEBUG("Profile IPv4 Method = [UNKNOWN]\n");
-
- MSG_DEBUG("Profile IP Address = [%d.%d.%d.%d]\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
- MSG_DEBUG("Profile Netmask = [%d.%d.%d.%d]\n", netmaskaddr[0], netmaskaddr[1], netmaskaddr[2], netmaskaddr[3]);
- MSG_DEBUG("Profile Gateway = [%d.%d.%d.%d]\n", gwaddr[0], gwaddr[1], gwaddr[2], gwaddr[3]);
-
- if (net_info->ProxyMethod == NET_PROXY_TYPE_DIRECT)
- MSG_DEBUG("Proxy Method = [direct]\n");
- else if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO)
- MSG_DEBUG("Proxy Method = [auto]\n");
- else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL)
- MSG_DEBUG("Proxy Method = [manual]\n");
- else
- MSG_DEBUG("Proxy Method = [unknown]\n");
+ if (ret_val) {
+ *ret_val = ret;
+ }
+
+ MSG_END();
+ return FALSE;
+}
- MSG_DEBUG("Profile Proxy = [%s]\n", net_info->ProxyAddr);
+static gboolean __connection_destroy(void *pVoid)
+{
+ MSG_BEGIN();
- MSG_DEBUG("**************************************************************************************************");
+ int rv;
+ int netOpenResult = NET_ERR_NONE;
+
+ if (connection != NULL) {
+ rv = connection_destroy(connection);
+ connection = NULL;
+ MSG_DEBUG("connection destory !!");
+ } else {
+ MSG_DEBUG("Cannot connection destroy : Handle is NULL");
+ rv = CONNECTION_ERROR_INVALID_OPERATION;
+ }
+
+ MSG_END();
+ return FALSE;
}
+static gboolean __connection_profile_open(void *pVoid)
+{
+ MSG_BEGIN();
+
+ int netOpenResult = NET_ERR_NONE;
+ int *ret_val = (int *)pVoid;
+ connection_profile_h profile;
+ int err;
-void network_evt_cb (net_event_info_t *event_cb, void *user_data)
+ err = connection_get_default_cellular_service_profile(connection, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &profile);
+
+ if (err != CONNECTION_ERROR_NONE) {
+ MSG_DEBUG("connection_get_default_cellular_service_profile Failed!! [%d]", err);
+ netOpenResult = NET_ERR_UNKNOWN;
+ } else {
+
+ if (connection_open_profile(connection, profile, __connection_profile_opened_cb, NULL) != CONNECTION_ERROR_NONE) {
+ MSG_DEBUG("Connection open Failed!!");
+ netOpenResult = NET_ERR_UNKNOWN;
+ }
+ }
+
+ connection_profile_destroy(profile);
+
+ if (ret_val) {
+ *ret_val = netOpenResult;
+ }
+
+ MSG_END();
+
+ return FALSE;
+}
+
+static gboolean __connection_profile_close(void *pVoid)
{
MSG_BEGIN();
- MmsPluginCmAgent::instance()->processCBdatas(event_cb, user_data);
+ int netOpenResult = NET_ERR_NONE;
+
+ int *ret_val = (int *)pVoid;
+
+ connection_profile_h profile;
+ int err;
+
+ err = connection_get_default_cellular_service_profile(connection, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &profile);
+
+ if (err != CONNECTION_ERROR_NONE) {
+ MSG_DEBUG("connection_get_default_cellular_service_profile Failed!! [%d]", err);
+ netOpenResult = NET_ERR_UNKNOWN;
+ } else {
+
+ if (connection_close_profile(connection, profile, __connection_profile_closed_cb, NULL) != CONNECTION_ERROR_NONE) {
+ MSG_DEBUG("Connection close Failed!!");
+ netOpenResult = NET_ERR_UNKNOWN;
+ }
+
+ }
+
+ connection_profile_destroy(profile);
+
+ if (ret_val) {
+ *ret_val = netOpenResult;
+ }
MSG_END();
+
+ return FALSE;
+}
+
+
+void context_invoke_end_cb(gpointer data)
+{
+ g_mx.lock();
+
+ MSG_DEBUG("@@ SIGNAL @@");
+
+ g_cv.signal();
+
+ g_mx.unlock();
}
+/*
+ * Network api should run at g_main_loop to receive callback
+ * */
+void context_invoke(GSourceFunc func, void *ret)
+{
+ MSG_BEGIN();
+
+ int time_ret = 0;
+
+ g_mx.lock();
+
+ g_main_context_invoke_full(NULL, G_PRIORITY_HIGH, func, ret, context_invoke_end_cb);
+
+ MSG_DEBUG("@@ WAIT @@");
+
+ time_ret = g_cv.timedwait(g_mx.pMutex(), MMS_CONTEXT_INVOKE_WAIT_TIME);
+ g_mx.unlock();
+
+ if (time_ret == ETIMEDOUT) {
+ MSG_DEBUG("@@ WAKE by timeout@@");
+ } else {
+ MSG_DEBUG("@@ WAKE by signal@@");
+ }
+
+ MSG_END();
+}
MmsPluginCmAgent *MmsPluginCmAgent::pInstance = NULL;
@@ -149,77 +380,77 @@ MmsPluginCmAgent::MmsPluginCmAgent()
MSG_BEGIN();
isCmOpened = false;
- bzero(&mmsProfile, sizeof (net_profile_info_t));
+ isCmRegistered = false;
+
+ home_url = NULL;
+ interface_name = NULL;
+ proxy_address = NULL;
MSG_END();
}
MmsPluginCmAgent::~MmsPluginCmAgent()
{
-
+ MMS_FREE(home_url);
+ MMS_FREE(interface_name);
+ MMS_FREE(proxy_address);
}
-bool MmsPluginCmAgent::registration()
+bool MmsPluginCmAgent::open()
{
MSG_BEGIN();
- bool registResult = true;
+ int netOpenResult = NET_ERR_NONE;
- if (net_register_client((net_event_cb_t) network_evt_cb, NULL) != NET_ERR_NONE) {
- MSG_DEBUG("Error!! net_register_client() failed.\n");
- registResult = false;
- }
+ lock();
- MSG_END();
+ if (isCmOpened == false) {
- return registResult;
-}
+ isCmRegistered = false;
-bool MmsPluginCmAgent::open()
-{
- MSG_BEGIN();
+ context_invoke(__connection_create, &isCmRegistered);
- if (!isCmOpened) {
- if (!registration())
- return false;
+ if (isCmRegistered == true) {
- int netOpenResult = NET_ERR_NONE;
- net_service_type_t service_type = NET_SERVICE_MMS;
+ MSG_DEBUG("net_open_connection for MMS");
- netOpenResult = net_open_connection_with_preference(service_type);
- if (netOpenResult != NET_ERR_NONE) {
- MSG_DEBUG("Error!! net_open_connection_with_profile() failed. [%d]", netOpenResult);
- deregistration();
- return false;
- }
+ context_invoke(__connection_profile_open, &netOpenResult);
- MSG_DEBUG("WAITING UNTIL Network Connection Open.");
+ if (netOpenResult == NET_ERR_NONE) {
- lock();
+ MSG_DEBUG("## WAITING UNTIL Network Connection Open. ##");
- int time_ret = 0;
- time_ret = cv.timedwait(mx.pMutex(), 50);
+ int time_ret = 0;
- unlock();
+ time_ret = cv.timedwait(mx.pMutex(), MMS_CONNECTION_API_WAIT_TIME); // isCmOpened will changed by processCBdatas
- if (time_ret == ETIMEDOUT) {
- MSG_DEBUG("Network Connection Open Time Out.");
- deregistration();
- return false;
- } else {
- if(!isCmOpened) {
- MSG_DEBUG("Network connection open failed");
- deregistration();
- return false;
+ MSG_DEBUG("## WAKE ##");
+
+ if (time_ret == ETIMEDOUT) {
+ MSG_DEBUG("Network Connection Open Time Out.");
+ }
+
+ if(!isCmOpened) {
+ MSG_DEBUG("Network Connection Open Failed");
+ }
+
+ } else { //error
+ MSG_FATAL("Error!! net_open_connection_with_profile() failed. [%d]", netOpenResult);
}
+
+ if (isCmOpened == false) {
+ context_invoke( __connection_destroy, NULL);
+ }
+
+ } else {
+ MSG_FATAL("## Failed network callback registration ##");
}
} else {
MSG_DEBUG("Network is already opened.");
- return false;
}
+ unlock();
MSG_END();
-
return isCmOpened;
}
@@ -228,221 +459,142 @@ void MmsPluginCmAgent::close()
{
MSG_BEGIN();
+ lock();
+
if (isCmOpened) {
int netOpenResult = NET_ERR_NONE;
- netOpenResult = net_close_connection(mmsProfile.ProfileName);
- if (netOpenResult != NET_ERR_NONE) {
- MSG_DEBUG("Error!! net_close_connection() failed.\n");
- deregistration();
- return;
- }
+ context_invoke(__connection_profile_close, &netOpenResult);
+
+ if (netOpenResult == NET_ERR_NONE) {
- MSG_DEBUG("WAITING UNTIL Network Connection Close.");
+ MSG_DEBUG("## WAITING UNTIL Network Connection Close. ##");
- lock();
+ int time_ret = 0;
- int time_ret = 0;
- time_ret = cv.timedwait(mx.pMutex(), 50);
+ time_ret = cv.timedwait(mx.pMutex(), MMS_CONNECTION_API_WAIT_TIME);
- unlock();
+ MSG_DEBUG("## WAKE ##");
- if (time_ret == ETIMEDOUT) {
- MSG_DEBUG("Network Connection Close Timed Out.");
+ if (time_ret == ETIMEDOUT) {
+ MSG_DEBUG("Network Connection Close Timed Out.");
+ }
+
+ } else {
+ MSG_DEBUG("Error!! net_close_connection() failed");
}
- deregistration();
isCmOpened = false;
} else {
MSG_DEBUG ("Network Connection is not opened.");
- return;
}
-}
-
-
-void MmsPluginCmAgent::deregistration()
-{
- MSG_BEGIN();
- int netOpenResult = NET_ERR_NONE;
+ if (isCmRegistered == true) {
+ context_invoke(__connection_destroy, NULL);
+ isCmRegistered = false;
+ }
- netOpenResult = net_deregister_client();
- if (netOpenResult != NET_ERR_NONE)
- MSG_DEBUG("Error!! net_deregister_client() failed. [%d]", netOpenResult);
- else
- MSG_DEBUG ("net_deregister_client() Success.");
+ unlock();
MSG_END();
}
-
-void MmsPluginCmAgent::processCBdatas(net_event_info_t *event_cb, void *user_data)
+void MmsPluginCmAgent::open_callback(connection_error_e result, void* user_data)
{
- MSG_BEGIN();
+ lock();
- net_dev_info_t *dev_info = NULL;
- net_profile_info_t *prof_info = NULL;
-
- switch (event_cb->Event) {
- case NET_EVENT_NET_CONFIGURE_RSP:
- MSG_DEBUG("Received Network Configuration response: %d \n", event_cb->Error);
- dev_info = (net_dev_info_t *)event_cb->Data;
-
- /*Successful PDP Activation*/
- if (event_cb->Error == NET_ERR_NONE) {
- char *ip = (char *)&dev_info->IpAddr.Data.Ipv4;
- char *netmask = (char *)&dev_info->SubnetMask.Data.Ipv4;
- char *gateway = (char *)&dev_info->GatewayAddr.Data.Ipv4;
- char *dns1 = (char *)&dev_info->DnsAddr[0].Data.Ipv4.s_addr;
- char *dns2 = (char *)&dev_info->DnsAddr[1].Data.Ipv4.s_addr;
-
- MSG_DEBUG("= IP address [%d.%d.%d.%d]\n",
- (int)ip[0], ip[1], ip[2], ip[3]);
- MSG_DEBUG("= Netmask [%d.%d.%d.%d]\n",
- (int)netmask[0], netmask[1], netmask[2], netmask[3]);
- MSG_DEBUG("= Gateway [%d.%d.%d.%d]\n",
- (int)gateway[0], gateway[1], gateway[2], gateway[3]);
- MSG_DEBUG("= DNS address [%d.%d.%d.%d]\n",
- (int)dns1[0], dns1[1], dns1[2], dns1[3]);
- MSG_DEBUG("= DNS2 address [%d.%d.%d.%d]\n",
- (int)dns2[0], dns2[1], dns2[2], dns2[3]);
- MSG_DEBUG("= Device name [%s]\n", dev_info->DevName);
- MSG_DEBUG("= Profile name [%s]\n", dev_info->ProfileName);
- } else {
- MSG_DEBUG("Error!!! Network Configuration Failed %d \n", event_cb->Error);
- }
- break;
+ connection_profile_h profile;
+ connection_cellular_state_e state;
+ int err;
- /*Response from Datacom for PDP Activation Request*/
- case NET_EVENT_OPEN_IND:
- MSG_DEBUG("Got Open Indication\n");
- MSG_DEBUG("Received ACTIVATION response: %d \n", event_cb->Error);
- break;
- case NET_EVENT_OPEN_RSP:
- MSG_DEBUG("Got Open RSP\n");
- MSG_DEBUG("Received ACTIVATION response: %d \n", event_cb->Error);
- prof_info = (net_profile_info_t *)event_cb->Data;
+ if (result == CONNECTION_ERROR_NONE || result == CONNECTION_ERROR_ALREADY_EXISTS) {
- /*Successful PDP Activation*/
- if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
- network_print_profile(prof_info);
+ err = connection_get_cellular_state(connection, &state);
- lock();
+ MSG_DEBUG("connection_get_cellular_state ret [%d], state [%d]", err, state);
- memcpy(&mmsProfile, prof_info, sizeof(net_profile_info_t));
+ err = connection_get_default_cellular_service_profile(connection, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &profile);
+ if (err != CONNECTION_ERROR_NONE) {
+ MSG_DEBUG("connection_get_default_cellular_service_profile Failed!! [%d]", err);
+ }
+
+ if (profile) {
isCmOpened = true;
- signal();
- unlock();
- } else {
- MSG_DEBUG("Activation Failed %d \n", event_cb->Error); // open failed
- lock();
- isCmOpened = false;
- signal();
- unlock();
- }
- break;
+ MMS_FREE(this->home_url);
+ MMS_FREE(this->interface_name);
+ MMS_FREE(this->proxy_address);
- case NET_EVENT_CLOSE_RSP:
- MSG_DEBUG("Got Close RSP\n");
+ err = connection_profile_get_cellular_home_url(profile, &this->home_url);
+ err = connection_profile_get_network_interface_name(profile, &this->interface_name);
+ err = connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &this->proxy_address);
- lock();
+ __connection_profile_print(profile);
- bzero(&mmsProfile, sizeof(net_profile_info_t));
- isCmOpened = false;
- signal();
-
- unlock();
- break;
-
- case NET_EVENT_CLOSE_IND:
- MSG_DEBUG("Got Close IND\n");
- break;
- case NET_EVENT_PROFILE_MODIFY_IND:
- MSG_DEBUG("Received Profile modified Indication\n");
- MSG_DEBUG("No. of profile [%d]\n", event_cb->Datalength);
- break;
- case NET_EVENT_NET_STATE_IND:
- MSG_DEBUG("Received NET_EVENT_NET_STATE_IND\n");
- break;
- default :
- MSG_DEBUG("Error! Unknown Event = %d\n\n", event_cb->Event);
- break;
+ connection_profile_destroy(profile);
+ }
+
+ } else {
+ MSG_DEBUG("connection open profile Failed!! [%d]", result);
}
- MSG_END();
-}
+ MSG_DEBUG("## SIGNAL ##");
+ signal();
+ unlock();
+}
-bool MmsPluginCmAgent::getDeviceName(char *deviceName)
+void MmsPluginCmAgent::close_callback(connection_error_e result, void* user_data)
{
- if (!isCmOpened)
- return false;
+ lock();
- int deviceNameLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.DevName);
+ MMS_FREE(this->home_url);
+ MMS_FREE(this->interface_name);
+ MMS_FREE(this->proxy_address);
- if (deviceNameLength > 0) {
- strncpy(deviceName, mmsProfile.ProfileInfo.Pdp.net_info.DevName, deviceNameLength);
- deviceName[deviceNameLength] = '\0';
- return true;
- }
+ isCmOpened = false;
+ MSG_DEBUG("## SIGNAL ##");
+ signal();
- return false;
+ unlock();
}
-
-bool MmsPluginCmAgent::getHomeURL(char *homeURL)
+bool MmsPluginCmAgent::getInterfaceName(const char **deviceName)
{
if (!isCmOpened)
return false;
- int homeURLLength = strlen(mmsProfile.ProfileInfo.Pdp.HomeURL);
+ if (deviceName == NULL)
+ return false;
- if (homeURLLength > 0) {
- strncpy(homeURL, mmsProfile.ProfileInfo.Pdp.HomeURL, homeURLLength);
- homeURL[homeURLLength] = '\0';
- return true;
- }
+ *deviceName = interface_name;
- return false;
+ return true;
}
-
-bool MmsPluginCmAgent::getProxyAddr(char *proxyAddr)
+bool MmsPluginCmAgent::getHomeUrl(const char **homeURL)
{
if (!isCmOpened)
return false;
- int proxyAddrLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr);
-
- if (proxyAddrLength > 0) {
- if (strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':') == NULL)
- return false;
+ if (homeURL == NULL)
+ return false;
- proxyAddrLength = proxyAddrLength - strlen(strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':'));
- strncpy(proxyAddr, mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, proxyAddrLength);
- proxyAddr[proxyAddrLength] = '\0';
+ *homeURL = home_url;
- return true;
- }
-
- return false;
+ return true;
}
-int MmsPluginCmAgent::getProxyPort()
+bool MmsPluginCmAgent::getProxyAddr(const char **proxyAddr)
{
if (!isCmOpened)
- return -1;
+ return false;
- int proxyAddrLength = strlen(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr);
+ if (proxyAddr == NULL)
+ return false;
- if (proxyAddrLength > 0) {
- char *pPort = strchr(mmsProfile.ProfileInfo.Pdp.net_info.ProxyAddr, ':') + 1;
- /* pPort cannot be NULL */
- return atoi(pPort);
- }
+ *proxyAddr = proxy_address;
- return -1;
+ return true;
}
-
diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp
index 3b66c0a..b7851f9 100755
--- a/plugin/mms_plugin/MmsPluginDecode.cpp
+++ b/plugin/mms_plugin/MmsPluginDecode.cpp
@@ -130,7 +130,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
#ifndef __SUPPORT_DRM__
static bool __MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex);
#else
-static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex);
+static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex, char *outBuf, int outBufLen);
#endif
static bool __MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index);
@@ -147,7 +147,7 @@ static int gMmsDecodeBufLen = 0; /* number of last read characters */
static char *gpMmsDecodeBuf1 = NULL;
static char *gpMmsDecodeBuf2 = NULL;
-MmsHeader mmsHeader =
+__thread MmsHeader mmsHeader =
{
false, //bActive
NULL, //pszOwner
@@ -378,6 +378,7 @@ static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLengt
*/
bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
{
+ MSG_BEGIN();
UINT16 fieldCode = 0xffff;
UINT16 fieldValue = 0xffff;
UINT8 oneByte = 0xff;
@@ -397,14 +398,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
char *pLimitData = NULL;
int nRead = 0;
- MSG_DEBUG("pFile=%d, total len=%d\n", pFile, totalLength);
+ MSG_DEBUG("pFile ptr : [%p], total len = [%d]", pFile, totalLength);
__MmsCleanDecodeBuff();
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
&gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("fail to load to buffer \n");
+ MSG_FATAL("fail to load to buffer");
goto __CATCH;
}
@@ -415,7 +416,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
case MMS_CODE_RESPONSESTATUS:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("responseStatus GetOneByte fail\n");
+ MSG_DEBUG("responseStatus GetOneByte fail");
goto __CATCH;
}
@@ -427,34 +428,29 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
fieldValue = 0x0060;
}
- MSG_DEBUG("response status code = 0x%02x", oneByte);
-
fieldValue = MmsGetBinaryType(MmsCodeResponseStatus, (UINT16)(oneByte & 0x7F));
if (fieldValue == 0xFFFF) {
- MSG_DEBUG("responseStatus error\n");
+ MSG_DEBUG("responseStatus error");
goto __CATCH;
}
mmsHeader.responseStatus = (MmsResponseStatus)fieldValue;
- MSG_DEBUG("response status text = %s\n", MmsDebugGetResponseStatus(mmsHeader.responseStatus));
-
+ MSG_DEBUG("X-Mms-Response-Status = [0x%02x][%s]", oneByte, MmsDebugGetResponseStatus(mmsHeader.responseStatus));
break;
case MMS_CODE_RETRIEVESTATUS:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("retrieveStatus GetOneByte fail\n");
+ MSG_DEBUG("retrieveStatus GetOneByte fail");
goto __CATCH;
}
- MSG_DEBUG("retrieve status code = 0x%02x", oneByte);
-
fieldValue = MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(oneByte & 0x7F));
if (fieldValue == 0xFFFF) {
- MSG_DEBUG("retrieveStatus error\n");
+ MSG_DEBUG("retrieveStatus error");
goto __CATCH;
}
@@ -466,38 +462,38 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
mmsHeader.retrieveStatus = (MmsRetrieveStatus)fieldValue;
- MSG_DEBUG("retrieve status = %s\n", MmsDebugGetRetrieveStatus(mmsHeader.retrieveStatus));
+ MSG_DEBUG("X-Mms-Retrieve-Status = [0x%02x][%s]", oneByte, MmsDebugGetRetrieveStatus(mmsHeader.retrieveStatus));
break;
case MMS_CODE_RESPONSETEXT:
if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szResponseText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) {
- MSG_DEBUG("invalid MMS_CODE_RESPONSETEXT \n");
+ MSG_DEBUG("invalid MMS_CODE_RESPONSETEXT");
goto __CATCH;
}
- MSG_DEBUG("response text = %s\n", mmsHeader.szResponseText);
+ MSG_DEBUG("X-Mms-Response-Text = [%s]", mmsHeader.szResponseText);
break;
case MMS_CODE_RETRIEVETEXT:
if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szRetrieveText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) {
- MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT \n");
+ MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT");
goto __CATCH;
}
- MSG_DEBUG("retrieve text = %s\n", mmsHeader.szRetrieveText);
+ MSG_DEBUG("X-Mms-Retrieve-Text = [%s]", mmsHeader.szRetrieveText);
break;
case MMS_CODE_MSGID:
if (__MmsBinaryDecodeText(pFile, mmsHeader.szMsgID, MMS_MSG_ID_LEN + 1, totalLength) < 0) {
- MSG_DEBUG("MMS_CODE_MSGID is invalid\n");
+ MSG_DEBUG("MMS_CODE_MSGID is invalid");
goto __CATCH;
}
- MSG_DEBUG("msg id = %s\n", mmsHeader.szMsgID);
+ MSG_DEBUG("Message-ID =[%s]", mmsHeader.szMsgID);
if (MsgStrlen (mmsHeader.szMsgID) > 2)
__MsgMIMERemoveQuote (mmsHeader.szMsgID);
@@ -507,19 +503,19 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
case MMS_CODE_SUBJECT:
if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN + 1, totalLength) == false) {
- MSG_DEBUG("invalid MMS_CODE_SUBJECT \n");
+ MSG_DEBUG("invalid MMS_CODE_SUBJECT");
goto __CATCH;
}
pLimitData = (char *)malloc(MSG_LOCALE_SUBJ_LEN + 1);
if (pLimitData == NULL) {
- MSG_DEBUG("pLimitData malloc fail \n");
+ MSG_DEBUG("pLimitData malloc fail");
goto __CATCH;
}
nRead = __MsgCutUTFString((unsigned char*)pLimitData, MSG_LOCALE_SUBJ_LEN + 1, (unsigned char*)mmsHeader.szSubject, MSG_SUBJ_LEN);
- MSG_DEBUG("Subject edit.. \n");
+ MSG_DEBUG("Subject edit..");
if (nRead > MSG_LOCALE_SUBJ_LEN) {
memset(mmsHeader.szSubject, 0 , sizeof(mmsHeader.szSubject));
@@ -534,7 +530,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
pLimitData = NULL;
}
- MSG_DEBUG("subject = %s\n", mmsHeader.szSubject);
+ MSG_DEBUG("Subject = [%s]", mmsHeader.szSubject);
break;
case MMS_CODE_FROM:
@@ -542,12 +538,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* Value-length (Address-present-token Encoded-string-value | Insert-address-token) */
if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
- MSG_DEBUG("MMS_CODE_FROM is invalid\n");
+ MSG_DEBUG("MMS_CODE_FROM is invalid");
goto __CATCH;
}
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("MMS_CODE_FROM GetOneByte fail\n");
+ MSG_DEBUG("MMS_CODE_FROM GetOneByte fail");
goto __CATCH;
}
@@ -559,7 +555,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
if (valueLength > 0) {
mmsHeader.pFrom = __MmsDecodeEncodedAddress(pFile, totalLength);
if (mmsHeader.pFrom == NULL) {
- MSG_DEBUG("MMS_CODE_FROM __MmsDecodeEncodedAddress fail\n");
+ MSG_DEBUG("MMS_CODE_FROM __MmsDecodeEncodedAddress fail");
goto __CATCH;
}
} else {
@@ -578,14 +574,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
mmsHeader.pFrom->pNext = NULL;
}
- MSG_DEBUG("from = %s\n", mmsHeader.pFrom->szAddr);
+ MSG_DEBUG("From = [%s]", mmsHeader.pFrom->szAddr);
// DRM_TEMPLATE - end
} else if (oneByte == (MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) {
/* Present Token only */
- MSG_DEBUG("MMS_CODE_FROM insert token\n");
+ MSG_DEBUG("From = [insert token]");
} else {
/* from data broken */
- MSG_DEBUG("from addr broken\n");
+ MSG_DEBUG("from addr broken");
gCurMmsDecodeBuffPos--;
goto __CATCH;
}
@@ -595,7 +591,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
if (pAddr == NULL) {
- MSG_DEBUG("MMS_CODE_TO __MmsDecodeEncodedAddress fail\n");
+ MSG_DEBUG("MMS_CODE_TO __MmsDecodeEncodedAddress fail");
goto __CATCH;
}
@@ -608,14 +604,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
pLastTo = pAddr;
}
- MSG_DEBUG("to = %s\n", mmsHeader.pTo->szAddr);
+ MSG_DEBUG("To = [%s]", mmsHeader.pTo->szAddr);
break;
case MMS_CODE_BCC:
pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
if (pAddr == NULL) {
- MSG_DEBUG("MMS_CODE_BCC __MmsDecodeEncodedAddress fail\n");
+ MSG_DEBUG("MMS_CODE_BCC __MmsDecodeEncodedAddress fail");
goto __CATCH;
}
@@ -628,14 +624,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
pLastBcc = pAddr;
}
- MSG_DEBUG("bcc = %s\n", mmsHeader.pBcc->szAddr);
+ MSG_DEBUG("Bcc = [%s]", mmsHeader.pBcc->szAddr);
break;
case MMS_CODE_CC:
pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
if (pAddr == NULL) {
- MSG_DEBUG("MMS_CODE_CC __MmsDecodeEncodedAddress fail\n");
+ MSG_DEBUG("MMS_CODE_CC __MmsDecodeEncodedAddress fail");
goto __CATCH;
}
@@ -647,44 +643,45 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
pLastCc->pNext = pAddr;
pLastCc = pAddr;
}
- MSG_DEBUG("cc = %s\n", mmsHeader.pCc->szAddr);
+ MSG_DEBUG("Cc = [%s]", mmsHeader.pCc->szAddr);
break;
case MMS_CODE_CONTENTLOCATION:
if (__MmsBinaryDecodeText(pFile, mmsHeader.szContentLocation, MMS_LOCATION_LEN + 1, totalLength) < 0) {
- MSG_DEBUG("MMS_CODE_CONTENTLOCATION is invalid\n");
+ MSG_DEBUG("MMS_CODE_CONTENTLOCATION is invalid");
goto __CATCH;
}
- MSG_DEBUG("content location = %s\n", mmsHeader.szContentLocation);
+ MSG_DEBUG("X-Mms-Content-Location = [%s]", mmsHeader.szContentLocation);
break;
case MMS_CODE_DATE:
if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.date, totalLength) == false) {
- MSG_DEBUG("MMS_CODE_DATE is invalid\n");
+ MSG_DEBUG("MMS_CODE_DATE is invalid");
goto __CATCH;
}
- MSG_DEBUG("date = %d\n", mmsHeader.date);
+
+ MSG_DEBUG("Date = [%u]", mmsHeader.date);
break;
case MMS_CODE_DELIVERYREPORT:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("deliveryReport GetOneByte fail\n");
+ MSG_DEBUG("deliveryReport GetOneByte fail");
goto __CATCH;
}
fieldValue = MmsGetBinaryType(MmsCodeDeliveryReport, (UINT16)(oneByte & 0x7F));
if (fieldValue == 0xFFFF) {
- MSG_DEBUG("deliveryReport error\n");
+ MSG_DEBUG("deliveryReport error");
goto __CATCH;
}
mmsHeader.deliveryReport = (MmsReport)fieldValue;
- MSG_DEBUG("delivery report=%s\n", MmsDebugGetMmsReport(mmsHeader.deliveryReport));
+ MSG_DEBUG("X-Mms-Delivery-Report =[0x%02x][%s]", oneByte, MmsDebugGetMmsReport(mmsHeader.deliveryReport));
break;
case MMS_CODE_DELIVERYTIME:
@@ -692,12 +689,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* value_length (absolute-token Long-integer | Relative-token Long-integer) */
if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
- MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME \n");
+ MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME");
goto __CATCH;
}
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("delivery time GetOneByte fail\n");
+ MSG_DEBUG("delivery time GetOneByte fail");
goto __CATCH;
}
@@ -709,7 +706,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
if (valueLength > 0) {
if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, totalLength) == false) {
- MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME\n");
+ MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME");
goto __CATCH;
}
}
@@ -718,11 +715,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
mmsHeader.deliveryTime.type = MMS_TIMETYPE_RELATIVE;
if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, &tmpIntLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeInteger fail...\n");
+ MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
goto __CATCH;
}
}
- MSG_DEBUG("delivery type=%d, time=%d\n", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time);
+ MSG_DEBUG("X-Mms-Delivery-Time : type = [%d], time= [%u]", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time);
break;
case MMS_CODE_EXPIRYTIME:
@@ -730,12 +727,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* value_length(absolute-token Long-integer | Relative-token Long-integer) */
if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
- MSG_DEBUG("invalid MMS_CODE_EXPIRYTIME \n");
+ MSG_DEBUG("invalid MMS_CODE_EXPIRYTIME");
goto __CATCH;
}
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("expiry time GetOneByte fail\n");
+ MSG_DEBUG("expiry time GetOneByte fail");
goto __CATCH;
}
@@ -747,7 +744,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
if (valueLength > 0) {
if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, totalLength) == false) {
- MSG_DEBUG("MMS_CODE_EXPIRYTIME is invalid\n");
+ MSG_DEBUG("MMS_CODE_EXPIRYTIME is invalid");
goto __CATCH;
}
}
@@ -756,11 +753,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
mmsHeader.expiryTime.type = MMS_TIMETYPE_RELATIVE;
if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, &tmpIntLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeInteger fail...\n");
+ MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
goto __CATCH;
}
}
- MSG_DEBUG("expiry = %d\n", mmsHeader.expiryTime.time);
+
+ MSG_DEBUG("X-Mms-Expiry : type = [%d], time = [%u]", mmsHeader.expiryTime.type, mmsHeader.expiryTime.time);
break;
case MMS_CODE_MSGCLASS:
@@ -768,7 +766,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* Class-value = Class-identifier | Token Text */
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgClass GetOneByte fail\n");
+ MSG_DEBUG("msgClass GetOneByte fail");
goto __CATCH;
}
@@ -777,101 +775,103 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
mmsHeader.msgClass = (MmsMsgClass)MmsGetBinaryType(MmsCodeMsgClass, (UINT16)(oneByte & 0x7F));
} else {
if (__MmsBinaryDecodeText(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) < 0) {
- MSG_DEBUG("1. __MmsBinaryDecodeText fail. (class)\n");
+ MSG_DEBUG("1. __MmsBinaryDecodeText fail. (class)");
goto __CATCH;
}
}
- MSG_DEBUG("msg class=%s\n", MmsDebugGetMsgClass(mmsHeader.msgClass));
+
+ MSG_DEBUG("X-Mms-Message-Class =[%s]", MmsDebugGetMsgClass(mmsHeader.msgClass));
break;
case MMS_CODE_MSGSIZE:
if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.msgSize, totalLength) == false) {
- MSG_DEBUG("MMS_CODE_MSGSIZE is invalid\n");
+ MSG_DEBUG("MMS_CODE_MSGSIZE is invalid");
goto __CATCH;
}
- MSG_DEBUG("msg size = %d\n", mmsHeader.msgSize);
+
+ MSG_DEBUG("X-Mms-Message-Size = [%d]", mmsHeader.msgSize);
break;
case MMS_CODE_MSGSTATUS:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.msgStatus = (msg_delivery_report_status_t)MmsGetBinaryType(MmsCodeMsgStatus, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("msg status=%s \n", MmsDebugGetMsgStatus(mmsHeader.msgStatus)) ;
+ MSG_DEBUG("X-Mms-Status = [%s]", MmsDebugGetMsgStatus(mmsHeader.msgStatus));
break;
case MMS_CODE_MSGTYPE:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.type = (MmsMsgType)MmsGetBinaryType(MmsCodeMsgType, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("msg type=%s\n", MmsDebugGetMsgType(mmsHeader.type));
+ MSG_DEBUG("X-Mms-Message-Type = [%s]", MmsDebugGetMsgType(mmsHeader.type));
break;
case MMS_CODE_PRIORITY:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.priority = (MmsPriority)MmsGetBinaryType(MmsCodePriority, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("priority=%d\n", mmsHeader.priority);
+ MSG_DEBUG("X-Mms-Priority = [%d]", mmsHeader.priority);
break;
case MMS_CODE_READREPLY:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.readReply = (MmsReport)MmsGetBinaryType(MmsCodeReadReply, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("read reply=%s \n", MmsDebugGetMmsReport(mmsHeader.readReply));
+ MSG_DEBUG("X-Mms-Read-Report = [0x%02x][%s]", oneByte, MmsDebugGetMmsReport(mmsHeader.readReply));
break;
case MMS_CODE_REPORTALLOWED:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.reportAllowed = (MmsReportAllowed)MmsGetBinaryType(MmsCodeReportAllowed, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("mmsHeader.reportAllowed=%d\n", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed));
+ MSG_DEBUG("X-Mms-Report-Allowed = [%d]", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed));
break;
case MMS_CODE_SENDERVISIBILLITY:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.hideAddress= (MmsSenderVisible)!(MmsGetBinaryType(MmsCodeSenderVisibility, (UINT16)(oneByte &0x7F)));
- MSG_DEBUG("sender visible=%d \n", mmsHeader.hideAddress);
+ MSG_DEBUG("X-Mms-Sender-Visibility = [%d]", mmsHeader.hideAddress);
break;
case MMS_CODE_TRID:
if (__MmsBinaryDecodeText(pFile, mmsHeader.szTrID, MMS_TR_ID_LEN + 1, totalLength) < 0) {
- MSG_DEBUG("Transaction ID Too Long \n");
+ MSG_DEBUG("Transaction ID Too Long");
goto __CATCH;
}
- MSG_DEBUG("trID = %s\n", mmsHeader.szTrID);
+ MSG_DEBUG("X-Mms-Transaction-Id = [%s]", mmsHeader.szTrID);
break;
case MMS_CODE_VERSION:
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.version = oneByte;
- MSG_DEBUG("ver = 0x%x\n", mmsHeader.version);
+ MSG_DEBUG("X-Mms-MMS-Version = [0x%02x]", mmsHeader.version);
break;
case MMS_CODE_CONTENTTYPE:
@@ -891,12 +891,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* Read-status-value = Read | Deleted without being read */
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.readStatus = (msg_read_report_status_t)MmsGetBinaryType(MmsCodeReadStatus, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("read status=%s\n", MmsDebugGetMmsReadStatus(mmsHeader.readStatus));
+ MSG_DEBUG("X-Mms-Read-Status = [%s]", MmsDebugGetMmsReadStatus(mmsHeader.readStatus));
break;
case MMS_CODE_REPLYCHARGING:
@@ -904,12 +904,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* Reply-charging-value = Requested | Requested text only | Accepted | Accepted text only */
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
mmsHeader.replyCharge.chargeType = (MmsReplyChargeType)MmsGetBinaryType(MmsCodeReplyCharging, (UINT16)(oneByte & 0x7F));
- MSG_DEBUG("mmsHeader.reply charge=%d\n", mmsHeader.replyCharge.chargeType);
+ MSG_DEBUG("X-Mms-Reply-Charging = [%d]", mmsHeader.replyCharge.chargeType);
break;
case MMS_CODE_REPLYCHARGINGDEADLINE:
@@ -917,12 +917,12 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
/* Reply-charging-deadline-value = Value-length (Absolute-token Date-value | Relative-token Delta-seconds-value) */
if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
- MSG_DEBUG("invalid MMS_CODE_REPLYCHARGINGDEADLINE \n");
+ MSG_DEBUG("invalid MMS_CODE_REPLYCHARGINGDEADLINE");
goto __CATCH;
}
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("msgStatus GetOneByte fail\n");
+ MSG_DEBUG("msgStatus GetOneByte fail");
goto __CATCH;
}
@@ -937,31 +937,33 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
if (valueLength > 0) {
if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.deadLine.time, totalLength) == false) {
- MSG_DEBUG("MMS_CODE_REPLYCHARGINGDEADLINE is invalid\n");
+ MSG_DEBUG("MMS_CODE_REPLYCHARGINGDEADLINE is invalid");
goto __CATCH;
}
}
+
+ MSG_DEBUG("X-Mms-Reply-Charging-Deadline : type = [%d], time = [%u]", mmsHeader.replyCharge.deadLine.type, mmsHeader.replyCharge.deadLine.time);
// DRM_TEMPLATE - end
break;
case MMS_CODE_REPLYCHARGINGID:
/* Reply-charging-ID-value = Text-string */
-
if (__MmsBinaryDecodeText(pFile, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN + 1, totalLength) < 0) {
- MSG_DEBUG("1. __MmsBinaryDecodeText fail. (szReplyChargingID)\n");
+ MSG_DEBUG("1. __MmsBinaryDecodeText fail. (szReplyChargingID)");
goto __CATCH;
}
+ MSG_DEBUG("X-Mms-Reply-Charging-ID = [%s]", mmsHeader.replyCharge.szChargeID);
break;
case MMS_CODE_REPLYCHARGINGSIZE:
/* Reply-charging-size-value = Long-integer */
-
if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.chargeSize, totalLength) == false) {
- MSG_DEBUG("MMS_CODE_REPLYCHARGINGSIZE is invalid\n");
+ MSG_DEBUG("MMS_CODE_REPLYCHARGINGSIZE is invalid");
goto __CATCH;
}
+ MSG_DEBUG("X-Mms-Reply-Charging-Size = [%d]", mmsHeader.replyCharge.chargeSize);
break;
case MMS_CODE_PREVIOUSLYSENTBY:
@@ -978,17 +980,17 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
*/
if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
- MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
+ MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTBY");
goto __CATCH;
}
if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) {
- MSG_DEBUG("2. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
+ MSG_DEBUG("2. invalid MMS_CODE_PREVIOUSLYSENTBY");
goto __CATCH;
}
if (__MmsBinaryDecodeEncodedString(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) == false) {
- MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT \n");
+ MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT");
goto __CATCH;
}
break;
@@ -1007,17 +1009,17 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
*/
if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
- MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+ MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTDATE");
goto __CATCH;
}
if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) {
- MSG_DEBUG("2. invalid MS_CODE_PREVIOUSLYSENTDATE \n");
+ MSG_DEBUG("2. invalid MS_CODE_PREVIOUSLYSENTDATE");
goto __CATCH;
}
if (__MmsDecodeLongInteger(pFile, (UINT32*)&tmpInteger, totalLength) == false) {
- MSG_DEBUG("3. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+ MSG_DEBUG("3. invalid MMS_CODE_PREVIOUSLYSENTDATE");
goto __CATCH;
}
break;
@@ -1047,11 +1049,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
while ((oneByte < 0x80) && (remainLength > 0)) {
if (__MmsBinaryDecodeCheckAndDecreaseLength(&remainLength, 1) == false) {
- MSG_DEBUG("__MmsBinaryDecodeCheckAndDecreaseLength fail\n");
+ MSG_DEBUG("__MmsBinaryDecodeCheckAndDecreaseLength fail");
goto __CATCH;
}
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("responseStatus GetOneByte fail\n");
+ MSG_DEBUG("responseStatus GetOneByte fail");
goto __CATCH;
}
}
@@ -1083,7 +1085,8 @@ __RETURN:
free(pLastBcc);
}
- MSG_DEBUG("success\n");
+ MSG_DEBUG("## Decode Header Success ##");
+ MSG_END();
return true;
@@ -1101,8 +1104,8 @@ __CATCH:
free(pLastBcc);
}
- MSG_DEBUG("failed\n");
-
+ MSG_FATAL("## Decode Header Fail ##");
+ MSG_END();
return false;
}
@@ -1122,14 +1125,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
&gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
// msg's type [ex] related, mixed, single part (jpg, amr and etc)
length = __MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength);
if (length == -1) {
- MSG_DEBUG("MMS_CODE_CONTENTTYPE is fail\n");
+ MSG_DEBUG("MMS_CODE_CONTENTTYPE is fail");
goto __CATCH;
}
@@ -1148,14 +1151,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
case MIME_APPLICATION_VND_OMA_DRM_MESSAGE:
case MIME_APPLICATION_VND_OMA_DRM_CONTENT:
- MSG_DEBUG("Decode multipart\n");
+ MSG_DEBUG("Decode Multipart");
offset = __MmsGetDecodeOffset();
if (offset >= totalLength)
goto __RETURN;
if (__MmsBinaryDecodeMultipart(pFile, szFilePath, &mmsHeader.msgType, &mmsHeader.msgBody, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodeMultipart is fail.\n");
+ MSG_DEBUG("MmsBinaryDecodeMultipart is fail.");
goto __CATCH;
}
break;
@@ -1163,15 +1166,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
default:
/* Single part message ---------------------------------------------- */
- if (szFilePath != NULL)
- strcpy(mmsHeader.msgBody.szOrgFilePath, szFilePath);
+ MSG_DEBUG("Decode Singlepart");
offset = __MmsGetDecodeOffset();
if (offset >= totalLength)
goto __RETURN;
if (__MmsBinaryDecodePartBody(pFile, totalLength - mmsHeader.msgBody.offset, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodePartBody is fail.(Single Part)\n");
+ MSG_DEBUG("MmsBinaryDecodePartBody is fail.(Single Part)");
goto __CATCH;
}
@@ -1195,6 +1197,7 @@ __CATCH:
static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength)
{
+ MSG_BEGIN();
UINT8 oneByte = 0;
int charSetLen = 0;
char *szTypeString = NULL;
@@ -1210,11 +1213,9 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
* WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.107)
*/
- MSG_BEGIN();
-
while (valueLength > 0) {
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("paramCode _MmsBinaryDecodeGetOneByte fail\n");
+ MSG_DEBUG("paramCode _MmsBinaryDecodeGetOneByte fail");
goto __CATCH;
}
@@ -1225,7 +1226,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
case 0x81: // charset
if (__MmsBinaryDecodeCharset(pFile, (UINT32*)&(pMsgType->param.charset), &charSetLen, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodeContentType : __MmsBinaryDecodeCharset fail.\n");
+ MSG_DEBUG("__MmsBinaryDecodeCharset fail.");
goto __CATCH;
}
@@ -1241,7 +1242,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
MSG_FILENAME_LEN_MAX -5, // MSG_LOCALE_FILENAME_LEN_MAX + 1, : change @ 110(Ui code have to change for this instead of DM)
totalLength);
if (length < 0) {
- MSG_DEBUG("MmsBinaryDecodeContentType : __MmsDecodeGetFilename fail. (name parameter)\n");
+ MSG_DEBUG("__MmsDecodeGetFilename fail. (name parameter)");
goto __CATCH;
}
@@ -1259,7 +1260,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
memset(pMsgType->param.szFileName, 0, sizeof(pMsgType->param.szFileName));
length = __MmsDecodeGetFilename(pFile, pMsgType->param.szFileName, MSG_FILENAME_LEN_MAX -5, totalLength);
if (length < 0) {
- MSG_DEBUG("MmsBinaryDecodeContentType : __MmsDecodeGetFilename fail. (filename parameter)\n");
+ MSG_DEBUG("__MmsDecodeGetFilename fail. (filename parameter)");
goto __CATCH;
}
@@ -1275,7 +1276,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
case 0x89: //type = Constrained-encoding = Extension-Media | Short-integer
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("type _MmsBinaryDecodeGetOneByte fail\n");
+ MSG_DEBUG("type _MmsBinaryDecodeGetOneByte fail");
goto __CATCH;
}
@@ -1341,7 +1342,7 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value
default:
if (paramCode > 0x7F) {
- MSG_DEBUG("Unsupported parameter\n");
+ MSG_DEBUG("Unsupported parameter");
// In case of the last byte of Parameter field, it should be returned without decreasing the gCurMmsDecodeBuffPos value.
valueLength++;
@@ -1425,10 +1426,11 @@ __RETURN:
szTypeString = NULL;
}
+ MSG_END();
return true;
__CATCH:
-
+ MSG_END();
return false;
}
@@ -1441,6 +1443,7 @@ __CATCH:
*/
static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
{
+ MSG_BEGIN();
UINT8 oneByte = 0;
char *szTypeString = NULL;
int valueLength = 0;
@@ -1458,8 +1461,6 @@ static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int tota
* Media-type = (Well-known-media | Extension-Media) *(Parameter)
*/
- MSG_DEBUG("decoding content type..\n");
-
length = __MmsDecodeValueLength(pFile, (UINT32*)&valueLength, totalLength);
if (length <= 0) {
/*
@@ -1470,7 +1471,7 @@ static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int tota
*/
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("Constrained-media _MmsBinaryDecodeGetOneByte fail\n");
+ MSG_DEBUG("Constrained-media _MmsBinaryDecodeGetOneByte fail");
goto __CATCH;
}
@@ -1513,7 +1514,7 @@ static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int tota
length += valueLength;
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("Well-known-media _MmsBinaryDecodeGetOneByte fail\n");
+ MSG_DEBUG("Well-known-media _MmsBinaryDecodeGetOneByte fail");
goto __CATCH;
}
@@ -1536,18 +1537,19 @@ static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int tota
}
}
- MSG_DEBUG("content type=%s\n", MmsDebugGetMimeType((MimeType)pMsgType->type));
-
+ MSG_DEBUG("Content-Type = [%s]", MmsDebugGetMimeType((MimeType)pMsgType->type));
if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
- MSG_DEBUG("Content-Type parameter fail\n");
+ MSG_DEBUG("Content-Type parameter fail");
goto __CATCH;
}
}
+ MSG_END();
return length;
__CATCH:
+ MSG_END();
return -1;
}
@@ -1582,7 +1584,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
while (headerLen > 0) {
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("field code GetOneByte fail\n");
+ MSG_DEBUG("field code GetOneByte fail");
goto __CATCH;
}
@@ -1604,7 +1606,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_CONTENT_ID_LEN + 1, totalLength);
if (length == -1) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeQuotedString fail.\n");
+ MSG_DEBUG("__MmsBinaryDecodeQuotedString fail.");
goto __CATCH;
}
@@ -1619,7 +1621,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
textLength = strlen(pLatinBuff);
if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
- MSG_DEBUG("MsgLatin2UTF fail \n");
+ MSG_DEBUG("MsgLatin2UTF fail");
goto __CATCH;
}
@@ -1642,7 +1644,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
length = __MmsBinaryDecodeQuotedString(pFile, pLatinBuff, MMS_CONTENT_ID_LEN + 1, totalLength);
if (length == -1) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : Content-ID __MmsBinaryDecodeQuotedString fail.\n");
+ MSG_DEBUG("Content-ID __MmsBinaryDecodeQuotedString fail.");
goto __CATCH;
}
@@ -1656,7 +1658,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
textLength = strlen(pLatinBuff);
if (__MsgLatin2UTF ((unsigned char*)szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
- MSG_DEBUG("MsgLatin2UTF fail \n");
+ MSG_DEBUG("MsgLatin2UTF fail");
goto __CATCH;
}
free(pLatinBuff);
@@ -1689,7 +1691,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
}
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("Disposition value GetOneByte fail\n");
+ MSG_DEBUG("Disposition value GetOneByte fail");
goto __CATCH;
}
@@ -1700,7 +1702,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
pMsgType->disposition = MmsGetBinaryType(MmsCodeMsgDisposition, (UINT16)(oneByte & 0x7F));
if (pMsgType->disposition == INVALID_HOBJ) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition MmsGetBinaryType fail.\n");
+ MSG_DEBUG("Content-Disposition MmsGetBinaryType fail.");
pMsgType->disposition = MSG_DISPOSITION_ATTACHMENT; // default
}
@@ -1708,7 +1710,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
goto __RETURN;
if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
- MSG_DEBUG("Disposition parameter fail\n");
+ MSG_DEBUG("Disposition parameter fail");
goto __CATCH;
}
@@ -1726,7 +1728,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
if (textLength < 0) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition decodingfail. \n");
+ MSG_DEBUG("Content-Disposition decodingfail.");
goto __CATCH;
}
free(pLatinBuff);
@@ -1739,7 +1741,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false)
{
- MSG_DEBUG("Disposition parameter fail\n");
+ MSG_DEBUG("Disposition parameter fail");
goto __CATCH;
}
@@ -1753,7 +1755,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
case 0x0B: //Content-Encoding
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("Disposition value GetOneByte fail\n");
+ MSG_DEBUG("Disposition value GetOneByte fail");
goto __CATCH;
}
@@ -1773,7 +1775,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
cTemp = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
if (cTemp == NULL) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeText2 fail...\n");
+ MSG_DEBUG("__MmsBinaryDecodeText2 fail...");
goto __CATCH;
}
@@ -1793,7 +1795,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
case 0x0D: //Content-Length
if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&tmpInt, &tmpIntLen, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeInteger fail...\n");
+ MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
goto __CATCH;
}
@@ -1804,7 +1806,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
case 0x30: //X-Wap-Content-URI skip this value
- MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header.\n");
+ MSG_DEBUG("X-Wap-Content-URI header.");
pLatinBuff = (char *)malloc(MMS_TEXT_LEN);
if (pLatinBuff == NULL)
goto __CATCH;
@@ -1812,18 +1814,18 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
length = __MmsBinaryDecodeText(pFile, pLatinBuff, MMS_TEXT_LEN, totalLength);
if (length == -1) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeQuotedString fail.\n");
+ MSG_DEBUG(" __MmsBinaryDecodeQuotedString fail.");
goto __CATCH;
}
- MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header decoded. Value length %d\n", length);
+ MSG_DEBUG("X-Wap-Content-URI header decoded. Value length %d\n", length);
free(pLatinBuff);
pLatinBuff = NULL;
if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false)
goto __RETURN;
- MSG_DEBUG("MmsBinaryDecodePartHeader : X-Wap-Content-URI header skipped.\n");
+ MSG_DEBUG("X-Wap-Content-URI header skipped.");
break;
@@ -1845,7 +1847,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
int charset = 0;
int charSetLen = 0;
- MSG_DEBUG("MmsBinaryDecodePartHeader : Accept-charset. \n");
+ MSG_DEBUG("Accept-charset.");
length = __MmsDecodeValueLength(pFile, &valueLength, totalLength);
if (length > 0) {
@@ -1856,7 +1858,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&charset, &charSetLen, totalLength) == false) {
// We only support the well-known-charset format
- MSG_DEBUG("MmsBinaryDecodePartHeader : __MmsBinaryDecodeInteger fail...\n");
+ MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
goto __CATCH;
}
@@ -1873,11 +1875,11 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
/* Other Content-xxx headers : Have valueLength */
- MSG_DEBUG("MmsBinaryDecodePartHeader : unknown Value = 0x%x\n", oneByte);
+ MSG_DEBUG("unknown Value = 0x%x\n", oneByte);
length = __MmsDecodeValueLength(pFile, &valueLength, totalLength);
if (length <= 0) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+ MSG_DEBUG("invalid MMS_CODE_PREVIOUSLYSENTDATE");
goto __CATCH;
}
@@ -1889,7 +1891,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
goto __CATCH;
if (__MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodePartHeader : default _MmsBinaryDecodeGetBytes() fail\n");
+ MSG_DEBUG("default _MmsBinaryDecodeGetBytes() fail");
if (szTemp) {
free(szTemp);
szTemp = NULL;
@@ -1908,7 +1910,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
* Application-specific-value = Text-string
*/
- MSG_DEBUG(" Application-header = Token-text Application-specific-value \n");
+ MSG_DEBUG(" Application-header = Token-text Application-specific-value");
gCurMmsDecodeBuffPos--;
@@ -1917,7 +1919,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
textLength = 0;
pCode = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
if (pCode == NULL) {
- MSG_DEBUG("pCode is null\n");
+ MSG_DEBUG("pCode is null");
goto __CATCH;
}
@@ -1932,7 +1934,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
textLength = 0;
pValue = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
if (pValue == NULL) {
- MSG_DEBUG("pValue is null\n");
+ MSG_DEBUG("pValue is null");
goto __CATCH;
}
@@ -1966,7 +1968,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
length = strlen(pLatinBuff);
if (__MsgLatin2UTF ((unsigned char*)szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0)
{
- MSG_DEBUG("MsgLatin2UTF fail \n");
+ MSG_DEBUG("MsgLatin2UTF fail");
goto __CATCH;
}
@@ -1986,7 +1988,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
length = strlen(pLatinBuff);
if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) {
- MSG_DEBUG("MsgLatin2UTF fail \n");
+ MSG_DEBUG("MsgLatin2UTF fail");
goto __CATCH;
}
@@ -2026,12 +2028,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head
} //while
__RETURN:
-/* DEADCODE
- if (pLatinBuff) {
- free(pLatinBuff);
- pLatinBuff = NULL;
- }
-*/
+
if (szTemp) {
free(szTemp);
szTemp = NULL;
@@ -2076,7 +2073,7 @@ static bool __MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLe
goto __CATCH;
}
- MSG_DEBUG("Number of Entries = %d\n", *npEntries);
+ MSG_DEBUG("Number of Entries = [%d]", *npEntries);
return true;
@@ -2099,7 +2096,7 @@ static bool __MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalL
offset += bodyLength;
if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
- MSG_DEBUG("fail to seek file pointer \n");
+ MSG_DEBUG("fail to seek file pointer");
goto __CATCH;
}
@@ -2112,7 +2109,7 @@ static bool __MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalL
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
@@ -2131,7 +2128,7 @@ static bool __MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLengt
goto __RETURN;
if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
- MSG_DEBUG("fail to seek file pointer \n");
+ MSG_DEBUG("fail to seek file pointer");
goto __CATCH;
}
@@ -2144,7 +2141,7 @@ static bool __MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLengt
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
@@ -2167,33 +2164,33 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
MsgPresentationFactor factor = MSG_PRESENTATION_NONE;
MsgPresentaionInfo presentationInfo;
- MSG_DEBUG("total length=%d\n", totalLength);
+ MSG_DEBUG("pdu length = [%d]", totalLength);
presentationInfo.factor = MSG_PRESENTATION_NONE;
presentationInfo.pCurPresentation = NULL;
presentationInfo.pPrevPart = NULL;
if (__MmsBinaryDecodeEntries(pFile, &nEntries, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodeEntries is fail.\n");
+ MSG_DEBUG("MmsBinaryDecodeEntries is fail.");
goto __CATCH;
}
if (pMsgBody->body.pMultipart != NULL) {
pLastMultipart = pMsgBody->body.pMultipart;
- MSG_DEBUG("pMsgBody->body.pMultipart exist \n");
+ MSG_DEBUG("previous multipart exist [%p]", pMsgBody->body.pMultipart);
} else {
- MSG_DEBUG("pMsgBody->body.pMultipart == NULL\n");
+ MSG_DEBUG("first multipart");
}
while (nEntries) {
- MSG_DEBUG("decoding %dth multipart\n", index);
+ MSG_DEBUG("decoding [%d]th multipart", index);
offset = __MmsGetDecodeOffset();
if (offset >= totalLength)
goto __RETURN;
if ((pMultipart = __MsgAllocMultipart()) == NULL) {
- MSG_DEBUG("MsgAllocMultipart Fail \n");
+ MSG_DEBUG("MsgAllocMultipart Fail");
goto __CATCH;
}
@@ -2202,16 +2199,20 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
goto __CATCH;
}
- if (pMsgType->param.type == MIME_APPLICATION_SMIL) {
+ if (pMultipart->type.type == MIME_APPLICATION_SMIL) {
factor = __MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type);
+ if (factor == MSG_PRESENTATION_NONE) {
+ factor = MSG_PRESENTATION_TYPE_BASE;
+ }
} else {
factor = MSG_PRESENTATION_NONE;
}
+
// priority 1 : content type match, 2: content location, 3: type
if (presentationInfo.factor < factor) {
// Presentation part
presentationInfo.factor = factor;
- presentationInfo.pPrevPart = pPreMultipart;
+ presentationInfo.pPrevPart = pLastMultipart;
presentationInfo.pCurPresentation = pMultipart;
}
@@ -2236,13 +2237,10 @@ static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *p
pMsgBody->size = totalLength - pMsgBody->offset;
-#ifdef __SUPPORT_DRM__
- if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED)
-#endif
- __MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo);
+ __MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo);
if (__MsgResolveNestedMultipart(pMsgType, pMsgBody) == false) {
- MSG_DEBUG("MmsBinaryDecodeMultipart : MsgResolveNestedMultipart failed \n");
+ MSG_DEBUG("MsgResolveNestedMultipart failed");
goto __CATCH;
}
@@ -2271,12 +2269,11 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
UINT32 bodyLength = 0;
int offset = 0;
- MSG_DEBUG("MmsBinaryDecodeEachPart: total length=%d\n", totalLength);
+ MSG_DEBUG("pdu length = [%d]", totalLength);
/* header length */
-
if (__MmsBinaryDecodeUintvar(pFile, &headerLength, totalLength) <= 0) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: Get header length fail \n");
+ MSG_DEBUG("Get header length fail");
goto __CATCH;
}
@@ -2284,20 +2281,16 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
if (offset >= totalLength)
goto __RETURN;
-
/* body length */
-
if (__MmsBinaryDecodeUintvar(pFile, &bodyLength, totalLength) <= 0) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: Get body length fail\n");
+ MSG_DEBUG("Get body length fail");
goto __CATCH;
}
-
offset = __MmsGetDecodeOffset();
if (offset >= totalLength)
goto __RETURN;
-
/* Content Type */
if (szFilePath != NULL)
strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath));
@@ -2311,7 +2304,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
length = __MmsBinaryDecodeContentType(pFile, pMsgType, totalLength);
if (length <= 0) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentType Fail \n");
+ MSG_DEBUG("Decode contentType Fail");
goto __CATCH;
}
@@ -2323,7 +2316,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
/* Part Header */
if (__MmsBinaryDecodePartHeader(pFile, pMsgType, headerLength - length, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentHeader Fail \n");
+ MSG_DEBUG("Decode contentHeader Fail");
goto __CATCH;
}
@@ -2352,10 +2345,9 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
case MIME_MULTIPART_RELATED:
case MIME_MULTIPART_ALTERNATIVE:
- MSG_DEBUG("MmsBinaryDecodeEachPart: Decode multipart\n");
-
+ MSG_DEBUG("Multipart");
if (__MmsBinaryDecodeMultipart(pFile, szFilePath, pMsgType, pMsgBody, totalLength) == false) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: MmsBinaryDecodeMultipart is fail.\n");
+ MSG_DEBUG("MmsBinaryDecodeMultipart is fail");
goto __CATCH;
}
@@ -2369,21 +2361,11 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
#ifdef __SUPPORT_DRM__
case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: /* Contains forwardLock OR combined-delivery media part */
- MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_MESSAGE Part \n");
-
- if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_NOT_FIXED && MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED) {
+ MSG_DEBUG("MIME_APPLICATION_VND_OMA_DRM_MESSAGE Part");
- if (__MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
- goto __CATCH;
- } else {
- MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED);
+ if (__MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
+ goto __CATCH;
- bSuccess = __MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
- if (bSuccess == false) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n");
- goto __CATCH;
- }
- }
offset = __MmsGetDecodeOffset();
if (offset >= totalLength)
goto __RETURN;
@@ -2392,7 +2374,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
case MIME_APPLICATION_VND_OMA_DRM_CONTENT: /* Contains seperate-delivery media part (DCF) */
- MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_CONTENT Part \n");
+ MSG_DEBUG("MIME_APPLICATION_VND_OMA_DRM_CONTENT Part");
if (__MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
goto __CATCH;
@@ -2405,11 +2387,11 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
#endif
default:
- MSG_DEBUG("MmsBinaryDecodeEachPart: Other normal Part \n");
+ MSG_DEBUG("Normal Part");
bSuccess = __MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
if (bSuccess == false) {
- MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n");
+ MSG_DEBUG("Decode contentBody Fail");
goto __CATCH;
}
@@ -2420,14 +2402,15 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM
break;
}
+ MSG_END();
return true;
__RETURN:
-
+ MSG_END();
return true;
__CATCH:
-
+ MSG_END();
return false;
}
@@ -2453,31 +2436,28 @@ static bool __MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *
pRawData = (char *)malloc(bodyLength);
if (pRawData == NULL) {
- MSG_DEBUG("pRawData alloc FAIL \n");
+ MSG_DEBUG("pRawData alloc FAIL");
goto __CATCH;
}
if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
- MSG_DEBUG("MsgFseek() returns -1 \n");
+ MSG_DEBUG("MsgFseek() returns -1");
goto __CATCH;
}
if (MsgReadFile(pRawData, sizeof(char), bodyLength, pFile) != (size_t)bodyLength) {
- MSG_DEBUG("FmReadFile() returns false \n");
+ MSG_DEBUG("FmReadFile() returns false");
goto __CATCH;
}
if (MsgOpenCreateAndOverwriteFile(szTempFilePath, pRawData, bodyLength) == false) {
- MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false \n");
+ MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false");
goto __CATCH;
}
isFileCreated = true;
- MSG_DEBUG("MmsDrm2GetConvertState() [%d]", MmsDrm2GetConvertState());
- if (pMsgType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE && (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_FINISH)) {
- MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED);
- } else {
+ if (pMsgType->type == MIME_APPLICATION_VND_OMA_DRM_MESSAGE) {
if (MsgDRM2GetDRMInfo(szTempFilePath, pMsgType) == false) {
- MSG_DEBUG("MsgDRM2GetDRMInfo() returns false \n");
+ MSG_DEBUG("MsgDRM2GetDRMInfo() returns false");
goto __CATCH;
}
}
@@ -2576,7 +2556,7 @@ static int __MmsDrm2GetEntriesValueLength(FILE *pFile, int orgOffset)
int j = 0; //j is the length of nEntries value
if (MsgReadFile(szEntries, sizeof(char), 4, pFile) != (size_t)4) {
- MSG_DEBUG("__MmsDrm2GetEntriesValueLength: FmReadFile() returns false \n");
+ MSG_DEBUG("FmReadFile() returns false");
return false;
}
@@ -2589,7 +2569,7 @@ static int __MmsDrm2GetEntriesValueLength(FILE *pFile, int orgOffset)
//move file pointer to point nEntries
if (MsgFseek(pFile, orgOffset, SEEK_SET) < 0) {
- MSG_DEBUG("__MmsDrm2GetEntriesValueLength: fail to seek file pointer\n");
+ MSG_DEBUG("fail to seek file pointer");
return false;
}
@@ -2605,13 +2585,13 @@ static bool __MmsDrm2WriteDataToConvertedFile(FILE *pSrcFile, FILE *pDestination
memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1);
- if (MsgReadFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pSrcFile) != (size_t)loadLen) {
- MSG_DEBUG("__MmsDrm2WriteDataToConvertedFile: FmReadFile() returns false \n");
- return false;
+ nRead = MsgReadFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pSrcFile);
+ if (nRead != (size_t)loadLen) {
+ MSG_DEBUG("FmReadFile() returns false, nRead = %d, loadLen = %d", nRead, loadLen);
}
- if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), loadLen, pDestinationFile) != (size_t)loadLen) {
- MSG_DEBUG("__MmsDrm2WriteDataToConvertedFile: File Writing is failed.\n");
+ if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), nRead, pDestinationFile) != (size_t)nRead) {
+ MSG_DEBUG("File Writing is failed.");
return false;
}
@@ -2642,23 +2622,23 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
int bufLen = MMS_DRM2_CONVERT_BUFFER_MAX;
int curOffset = 0;
- MSG_DEBUG("start convert~~~~~~\n");
+ MSG_DEBUG("start convert~~~~~~");
pFile = MsgOpenFile(szOriginFilePath, "rb");
if (pFile == NULL) {
- MSG_DEBUG("Open decode temporary file fail\n");
+ MSG_DEBUG("Open decode temporary file fail");
goto __CATCH;
}
hConvertedFile = MsgOpenFile(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, "wb+");
if (hConvertedFile == NULL) {
- MSG_DEBUG("Open decode temporary file fail\n");
+ MSG_DEBUG("Open decode temporary file fail");
goto __CATCH;
}
pszMmsLoadTempBuf = (char*)malloc(MMS_DRM2_CONVERT_BUFFER_MAX + 1);
if (pszMmsLoadTempBuf == NULL) {
- MSG_DEBUG("malloc for pszMmsLoadTempBuf failed\n");
+ MSG_DEBUG("malloc for pszMmsLoadTempBuf failed");
goto __CATCH;
}
memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1);
@@ -2666,7 +2646,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
// MMS Header copy
length = mmsHeader.msgBody.offset;
if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
- MSG_DEBUG("Write header data fail\n");
+ MSG_DEBUG("Write header data fail");
goto __CATCH;
}
@@ -2679,7 +2659,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
length = __MmsDrm2GetEntriesValueLength(pFile, curOffset); // getting nEntries value's length
if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
- MSG_DEBUG("Write nEntries fail\n");
+ MSG_DEBUG("Write nEntries fail");
goto __CATCH;
}
@@ -2697,19 +2677,19 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
pszOrgData = (char *)malloc(orgDataLen + 1);
if (pszOrgData == NULL) {
- MSG_DEBUG("pszOrgData is NULL \n");
+ MSG_DEBUG("pszOrgData is NULL");
goto __CATCH;
}
memset(pszOrgData, 0, orgDataLen + 1);
// move file pointer to data
if (MsgFseek(pFile, pMultipart->pBody->offset, SEEK_SET) < 0) {
- MSG_DEBUG("fail to seek file pointer 1\n");
+ MSG_DEBUG("fail to seek file pointer 1");
goto __CATCH;
}
if (MsgReadFile(pszOrgData, sizeof(char), orgDataLen, pFile) != (size_t)orgDataLen) {
- MSG_DEBUG("FmReadFile() returns false for orgData\n");
+ MSG_DEBUG("FmReadFile() returns false for orgData");
goto __CATCH;
}
@@ -2734,7 +2714,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
hFile = NULL;
// --> invoking drm agent api, converting data part start
- MSG_DEBUG("start data part convert by callling drm agent api\n");
+ MSG_DEBUG("start data part convert by callling drm agent api");
int ret = 0;
ret = MsgDrmConvertDmtoDcfType(szTempFile, szTempFilePath);
@@ -2748,7 +2728,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
// move file pointer to the head of multipart
if (MsgFseek(pFile, curOffset, SEEK_SET) < 0) {
- MSG_DEBUG("fail to seek file pointer 2\n");
+ MSG_DEBUG("fail to seek file pointer 2");
goto __CATCH;
}
@@ -2756,7 +2736,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
length = pMultipart->type.offset - curOffset;
memset(pszMmsLoadTempBuf, 0, MMS_DRM2_CONVERT_BUFFER_MAX + 1);
if (MsgReadFile(pszMmsLoadTempBuf, sizeof(char), length, pFile) != (size_t)length) {
- MSG_DEBUG("FmReadFile() returns false for headerLen, dataLen\n");
+ MSG_DEBUG("FmReadFile() returns false for headerLen, dataLen");
goto __CATCH;
}
@@ -2783,7 +2763,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
pszMmsLoadTempBuf[j+encodeLen] = '\0';
if (MsgWriteFile(pszMmsLoadTempBuf, sizeof(char), length, hConvertedFile) != (size_t)length) {
- MSG_DEBUG("Drm2WriteConvertData: FmWriteFile() returns false for dateLen\n");
+ MSG_DEBUG("FmWriteFile() returns false for dateLen");
goto __CATCH;
}
}
@@ -2792,7 +2772,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
length = pMultipart->pBody->offset - pMultipart->type.offset;
if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
- MSG_DEBUG("Drm2WriteConvertData: Write content type, headers fail\n");
+ MSG_DEBUG("Write content type, headers fail");
goto __CATCH;
}
@@ -2801,14 +2781,14 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
// write converted data
hTempFile = MsgOpenFile(szTempFilePath, "rb");
if (hTempFile == NULL) {
- MSG_DEBUG("Open decode temporary file fail\n");
+ MSG_DEBUG("Open decode temporary file fail");
goto __CATCH;
}
length = nSize;
if (__MmsDrm2WriteDataToConvertedFile(hTempFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
- MSG_DEBUG("Write converted data fail\n");
+ MSG_DEBUG("Write converted data fail");
goto __CATCH;
}
@@ -2821,16 +2801,16 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
// move file pointer to the head of multipart
if (MsgFseek(pFile, curOffset, SEEK_SET) < 0) {
- MSG_DEBUG("fail to seek file pointer \n");
+ MSG_DEBUG("fail to seek file pointer");
goto __CATCH;
}
} else { // it doesn't need to convert if it is not CD or FL
- MSG_DEBUG("Write normal multipart data\n");
+ MSG_DEBUG("Write normal multipart data");
length = pMultipart->pBody->offset + pMultipart->pBody->size - curOffset;
if (__MmsDrm2WriteDataToConvertedFile(pFile, hConvertedFile, pszMmsLoadTempBuf, length, bufLen) == false) {
- MSG_DEBUG("Write multipart data fail \n");
+ MSG_DEBUG("Write multipart data fail");
goto __CATCH;
}
@@ -2841,7 +2821,7 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath)
}
}
- MSG_DEBUG("end convert~~~~~~\n");
+ MSG_DEBUG("end convert~~~~~~");
if (pFile != NULL) {
MsgCloseFile(pFile);
@@ -2928,7 +2908,7 @@ bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTemp
MmsReleaseMsgBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
if (MmsReadMsgBody(pMsg->msgId, bSavePartsAsTempFiles, bRetrieved, retrievedPath) == false) {
- MSG_DEBUG("MmsDrm2ReadMsgConvertedBody: _MmsReadMsgBody with converted file is failed\n");
+ MSG_DEBUG("_MmsReadMsgBody with converted file is failed");
return false;
}
@@ -2949,14 +2929,14 @@ bool __MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength)
if (pFile == NULL || pOneByte == NULL)
{
- MSG_DEBUG("_MmsBinaryDecodeGetOneByte: invalid file or buffer\n");
+ MSG_DEBUG("invalid file or buffer");
goto __CATCH;
}
if (length < 1) {
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("_MmsBinaryDecodeGetOneByte: fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
}
@@ -2986,7 +2966,7 @@ bool __MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalL
if (length < bufLen) {
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("_MmsBinaryDecodeGetBytes: fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
}
@@ -3014,13 +2994,13 @@ bool __MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int to
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
while ((bufLen - iPos) >= gMmsDecodeMaxLen) {
if (__MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, gMmsDecodeMaxLen, totalLength) == false) {
- MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 1. _MmsBinaryDecodeGetBytes fail \n");
+ MSG_DEBUG("__MmsBinaryDecodeGetBytes fail");
goto __CATCH;
}
@@ -3029,7 +3009,7 @@ bool __MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int to
if ((bufLen - iPos) > 0) {
if (__MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, (bufLen - iPos), totalLength) == false) {
- MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 2. _MmsBinaryDecodeGetBytes fail \n");
+ MSG_DEBUG("__MmsBinaryDecodeGetBytes fail");
goto __CATCH;
}
@@ -3069,7 +3049,7 @@ static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLeng
if (length < 5) {
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeUintvar: fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
}
@@ -3086,7 +3066,7 @@ static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLeng
}
if (count > 4) {
- MSG_DEBUG("__MmsBinaryDecodeUintvar : legnth is too long\n");
+ MSG_DEBUG("legnth is too long");
goto __CATCH;
}
}
@@ -3128,7 +3108,7 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t
if (length == 1)
{
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n");
+ MSG_DEBUG("_MmsBinaryDecodeGetOneByte fail");
return oneByte;
}
@@ -3144,13 +3124,13 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t
pData = (char *)malloc(length + 1);
if (pData == NULL) {
- MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: pData alloc fail\n");
+ MSG_DEBUG("pData alloc fail");
goto __CATCH;
}
memset(pData, 0, length + 1);
if (__MmsBinaryDecodeGetBytes(pFile, pData, length + 1, totalLength) == false) {
- MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n");
+ MSG_DEBUG("_MmsBinaryDecodeGetOneByte fail");
goto __CATCH;
}
@@ -3200,7 +3180,7 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen
*pIntLen = 0;
if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeInteger: GetOneByte fail\n");
+ MSG_DEBUG("GetOneByte fail");
return false;
}
@@ -3208,14 +3188,14 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen
{
pData = (char *)malloc(oneByte + 1);
if (pData == NULL) {
- MSG_DEBUG("__MmsBinaryDecodeInteger: pData memalloc fail\n");
+ MSG_DEBUG("pData memalloc fail");
goto __CATCH;
}
memset(pData, 0, oneByte + 1);
// Even NULL is copied in the _MmsBinaryDecodeGetBytes
if (__MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeInteger: GetBytes fail\n");
+ MSG_DEBUG("GetBytes fail");
goto __CATCH;
}
@@ -3300,13 +3280,13 @@ static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLe
length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength);
if (length == -1) {
- MSG_DEBUG("__MmsDecodeValueLength: __MmsBinaryDecodeUintvar fail..\n");
+ MSG_DEBUG(" __MmsBinaryDecodeUintvar fail..");
goto __CATCH;
}
length ++; // + length-quote
*pValueLength = uintvar;
} else {
- MSG_DEBUG("__MmsDecodeValueLength: not a value length type data\n");
+ MSG_DEBUG("not a value length type data");
gCurMmsDecodeBuffPos--;
return 0;
}
@@ -3314,7 +3294,7 @@ static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLe
return length;
__CATCH:
- MSG_DEBUG("__MmsDecodeValueLength: getting data fail\n");
+ MSG_DEBUG("getting data fail");
return -1;
}
@@ -3358,13 +3338,13 @@ static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalL
length = __MmsBinaryDecodeUintvar(pFile, &uintvar, totalLength);
if (length == -1) {
- MSG_DEBUG("__MmsDecodeValueLength2: __MmsBinaryDecodeUintvar fail..\n");
+ MSG_DEBUG("__MmsBinaryDecodeUintvar fail..");
goto __CATCH;
}
length ++; // + length-quote
*pValueLength = uintvar;
} else {
- MSG_DEBUG("__MmsDecodeValueLength2: there is not length-quote, consider it as short length.\n");
+ MSG_DEBUG("there is not length-quote, consider it as short length.");
*pValueLength = oneByte;
length = 1;
}
@@ -3372,7 +3352,7 @@ static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalL
return length;
__CATCH:
- MSG_DEBUG("__MmsDecodeValueLength2: getting data fail\n");
+ MSG_DEBUG("getting data fail");
return -1;
}
@@ -3404,7 +3384,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: 1. fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
@@ -3415,17 +3395,17 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
while (length > gMmsDecodeBufLen) {
if (gMmsDecodeBufLen <= 0) {
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n");
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("gMmsDecodeBufLen <= 0");
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]);
goto __CATCH;
@@ -3462,7 +3442,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL
@@ -3550,7 +3530,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeText: 1. fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
@@ -3561,14 +3541,14 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
while (length > gMmsDecodeBufLen) {
if (gMmsDecodeBufLen <= 0) {
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n");
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
+ MSG_DEBUG("gMmsDecodeBufLen <= 0");
+ MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
+ MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
+ MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n", gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
+ MSG_DEBUG("%x %x %x %x %x", gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]);
goto __CATCH;
}
@@ -3605,7 +3585,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
length = strlen(gpCurMmsDecodeBuff) + 1; // + NULL
@@ -3692,7 +3672,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeTextLen: 1. fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
@@ -3703,17 +3683,17 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
while (length > gMmsDecodeBufLen) {
if (gMmsDecodeBufLen <= 0) {
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: gMmsDecodeBufLen <= 0 \n");
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("gMmsDecodeBufLen <= 0");
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[0], gpCurMmsDecodeBuff[1], gpCurMmsDecodeBuff[2],
gpCurMmsDecodeBuff[3], gpCurMmsDecodeBuff[4]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[5], gpCurMmsDecodeBuff[6], gpCurMmsDecodeBuff[7],
gpCurMmsDecodeBuff[8], gpCurMmsDecodeBuff[9]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("%x %x %x %x %x",
gpCurMmsDecodeBuff[10], gpCurMmsDecodeBuff[11], gpCurMmsDecodeBuff[12],
gpCurMmsDecodeBuff[13], gpCurMmsDecodeBuff[14]);
- MSG_DEBUG("__MmsBinaryDecodeQuotedString: %x %x %x %x %x\n",
+ MSG_DEBUG("%x %x %x %x %x\n",
gpCurMmsDecodeBuff[15], gpCurMmsDecodeBuff[16], gpCurMmsDecodeBuff[17],
gpCurMmsDecodeBuff[18], gpCurMmsDecodeBuff[19]);
goto __CATCH;
@@ -3773,7 +3753,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
&gMmsDecodeBufLen,
totalLength) == false)
{
- MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
+ MSG_DEBUG("fail to load to buffer");
goto __CATCH;
}
length = strlen(gpCurMmsDecodeBuff) + 1;
@@ -3875,7 +3855,7 @@ static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSe
return false;
if (__MmsBinaryDecodeInteger(pFile, &integer, pCharSetLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeCharset : __MmsBinaryDecodeInteger fail...\n");
+ MSG_DEBUG("__MmsBinaryDecodeInteger fail...");
goto __CATCH;
}
@@ -3888,7 +3868,7 @@ static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSe
*nCharSet = MmsGetBinaryType(MmsCodeCharSet, (UINT16)integer);
if (*nCharSet == MIME_UNKNOWN) {
- MSG_DEBUG("__MmsBinaryDecodeCharset : MmsGetBinaryType fail..\n");
+ MSG_DEBUG("MmsGetBinaryType fail..");
*nCharSet = MSG_CHARSET_UNKNOWN;
}
@@ -3914,10 +3894,10 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
int nTemp = 0;
char *pData = NULL;
- MSG_DEBUG("__MmsBinaryDecodeEncodedString: decode string..\n");
+ MSG_DEBUG(" decode string..");
if (pFile == NULL || szBuff == NULL || bufLen <= 0) {
- MSG_DEBUG("__MmsBinaryDecodeEncodedString: invalid file or buffer\n");
+ MSG_DEBUG("invalid file or buffer");
goto __CATCH;
}
@@ -3938,7 +3918,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
/* Text-string = [Quote]*TEXT End-of-string */
if (__MmsBinaryDecodeText(pFile, szBuff, bufLen, totalLength) < 0) {
- MSG_DEBUG("__MmsBinaryDecodeEncodedString : 1. __MmsBinaryDecodeText fail.\n");
+ MSG_DEBUG("__MmsBinaryDecodeText fail.");
goto __CATCH;
}
break;
@@ -3948,7 +3928,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
/* Value-length Charset Text_string */
if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeEncodedString : __MmsBinaryDecodeCharset error\n");
+ MSG_DEBUG(" __MmsBinaryDecodeCharset error");
goto __CATCH; /* (valueLength + valueLengthLen) */
}
@@ -3958,12 +3938,12 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
pData = (char *)malloc(valueLength - charSetLen);
if (pData == NULL) {
- MSG_DEBUG("__MmsBinaryDecodeEncodedString : pData alloc fail.\n");
+ MSG_DEBUG("pData alloc fail.");
goto __CATCH;
}
if (__MmsBinaryDecodeGetLongBytes(pFile, pData, valueLength - charSetLen, totalLength) == false) {
- MSG_DEBUG("__MmsBinaryDecodeEncodedString : _MmsBinaryDecodeGetLongBytes fail.\n");
+ MSG_DEBUG("_MmsBinaryDecodeGetLongBytes fail.");
goto __CATCH;
}
@@ -3999,6 +3979,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
snprintf(szBuff, destLen, "%s", pDest);
}
}
+ break;
}
if (pData) {
@@ -4036,10 +4017,10 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
char *pAddrStr = NULL;
MsgHeaderAddress *pAddr = NULL;
- MSG_DEBUG("__MmsDecodeEncodedAddress: decoding address..\n");
+ MSG_DEBUG("decoding address..");
if (pFile == NULL) {
- MSG_DEBUG("__MmsDecodeEncodedAddress: invalid file or buffer\n");
+ MSG_DEBUG("invalid file or buffer");
goto __CATCH;
}
@@ -4060,7 +4041,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
textLength = 0;
pAddrStr = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
if (pAddrStr == NULL) {
- MSG_DEBUG("__MmsDecodeEncodedAddress : 1. __MmsBinaryDecodeText2 fail.\n");
+ MSG_DEBUG(" __MmsBinaryDecodeText2 fail.");
goto __CATCH;
}
break;
@@ -4070,7 +4051,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
/* Value-length Charset Text_string */
if (__MmsBinaryDecodeCharset(pFile, &charSet, &charSetLen, totalLength) == false) {
- MSG_DEBUG("__MmsDecodeEncodedAddress : __MmsBinaryDecodeCharset error\n");
+ MSG_DEBUG(" __MmsBinaryDecodeCharset error");
goto __CATCH;
}
@@ -4081,12 +4062,12 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
pAddrStr = (char *)malloc(valueLength - charSetLen);
if (pAddrStr == NULL) {
- MSG_DEBUG("__MmsDecodeEncodedAddress : pData alloc fail.\n");
+ MSG_DEBUG("pData alloc fail.");
goto __CATCH;
}
if (__MmsBinaryDecodeGetLongBytes(pFile, pAddrStr, valueLength - charSetLen, totalLength) == false) {
- MSG_DEBUG("__MmsDecodeEncodedAddress : _MmsBinaryDecodeGetLongBytes fail.\n");
+ MSG_DEBUG(" _MmsBinaryDecodeGetLongBytes fail.");
goto __CATCH;
}
}
@@ -4203,12 +4184,12 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot
pUTF8Buff = (char *)malloc(utf8BufSize + 1);
if (pUTF8Buff == NULL) {
- MSG_DEBUG("__MmsDecodeGetFilename: pUTF8Buff alloc fail \n");
+ MSG_DEBUG("pUTF8Buff alloc fail");
goto __CATCH;
}
if (__MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pLatinBuff, length) < 0) {
- MSG_DEBUG("__MmsDecodeGetFilename: MsgLatin2UTF fail \n");
+ MSG_DEBUG("MsgLatin2UTF fail");
goto __CATCH;
}
free(pLatinBuff);
@@ -4272,10 +4253,8 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
int nSize = 0;
char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, };
char szTempMediaDir[MSG_FILEPATH_LEN_MAX] = {0, };
- int attachmax = MSG_ATTACH_MAX;
MSG_BEGIN();
- MSG_DEBUG("msg id : %d", msgID);
MmsPluginStorage::instance()->getMmsMessage(&pMsg);
memset(pMsg, 0, sizeof(MmsMsg));
@@ -4293,44 +4272,32 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
/* read from MMS raw file */
strncpy(pMsg->szFileName, szFullPath + strlen(MSG_DATA_PATH), strlen(szFullPath + strlen(MSG_DATA_PATH)));
- MSG_DEBUG("szFullPath = (%s)", szFullPath);
+ MSG_DEBUG("msg_id = [%d]", msgID);
+ MSG_DEBUG("raw file path = [%s]", szFullPath);
if (MsgGetFileSize(szFullPath, &nSize) == false) {
- MSG_DEBUG("MsgGetFileSize: failed");
+ MSG_FATAL("Fail MsgGetFileSize");
goto __CATCH;
}
pFile = MsgOpenFile(szFullPath, "rb");
-
if (pFile == NULL) {
- MSG_DEBUG("_MmsReadMsgBody: invalid mailbox\n");
+ MSG_DEBUG("Fail MsgOpenFile [%s]", szFullPath);
goto __CATCH;
}
MmsRegisterDecodeBuffer();
if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
- MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
+ MSG_FATAL("Fail to MmsBinaryDecodeMsgHeader");
goto __CATCH;
}
-#ifdef __SUPPORT_DRM__
- if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_FINISH)
- MmsDrm2SetConvertState(MMS_DRM2_CONVERT_NONE); //initialize convertState
-#endif
-
if (MmsBinaryDecodeMsgBody(pFile, szFullPath, nSize) == false) {
- MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgBody fail\n");
+ MSG_FATAL("Fail to MmsBinaryDecodeMsgBody");
goto __CATCH;
}
-#ifdef __SUPPORT_DRM__
- if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
- MSG_DEBUG("_MmsReadMsgBody: MmsDrm2GetConvertState returns MMS_DRM2_CONVERT_REQUIRED.\n");
- goto RETURN;
- }
-#endif
-
/* Set mmsHeader.msgType & msgBody to pMsg ----------- */
memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
@@ -4394,7 +4361,6 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
MsgCloseFile(pFile);
pFile = NULL;
-
/* nPartCount */
pMsg->nPartCount = 0;
@@ -4402,23 +4368,6 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
pMultipart = pMsg->msgBody.body.pMultipart;
while (pMultipart) {
pMsg->nPartCount++;
-
- if (pMultipart->type.type == MIME_TEXT_PLAIN)
- attachmax++;
-
- if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED)||(mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
- if ((pMsg->nPartCount >= attachmax)&&(pMultipart->pNext != NULL)) {
- MmsReleaseMsgBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
-
- free(pMultipart->pNext->pBody);
- pMultipart->pNext->pBody= NULL;
-
- free(pMultipart->pNext);
-
- pMultipart->pNext = NULL;
- break;
- }
- }
pMultipart = pMultipart->pNext;
}
} else {
@@ -4436,11 +4385,13 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
if (bSavePartsAsTempFiles) {
if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
if (errno == EEXIST) {
- MSG_DEBUG("The %s already exists", szTempMediaDir);
+ MSG_DEBUG("exist dir : [%s]", szTempMediaDir);
} else {
MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
goto __CATCH;
}
+ } else {
+ MSG_DEBUG("make dir : [%s]", szTempMediaDir);
}
}
@@ -4466,35 +4417,25 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe
if (bSavePartsAsTempFiles) {
if (mkdir(szTempMediaDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
if (errno == EEXIST) {
- MSG_DEBUG("The %s already exists", szTempMediaDir);
+ MSG_DEBUG("exist dir : [%s]", szTempMediaDir);
} else {
MSG_DEBUG("Fail to Create Dir [%s]", szTempMediaDir);
goto __CATCH;
}
+ } else {
+ MSG_DEBUG("make dir : [%s]", szTempMediaDir);
}
}
- if (__MmsMultipartSaveAsTempFile( &pMsg->msgType, &pMsg->msgBody,
+ if (__MmsMultipartSaveAsTempFile(&pMsg->msgType, &pMsg->msgBody,
(char*)MSG_DATA_PATH, pMsg->szFileName, 0, bSavePartsAsTempFiles) == false)
goto __CATCH;
}
}
- MSG_DEBUG("**** _MmsReadMsgBody: E N D (Success) ***\n");
+ MSG_DEBUG("### Success ###");
+ MSG_END();
return true;
-#ifdef __SUPPORT_DRM__
-
-RETURN:
-
- if (pFile != NULL) {
- MsgCloseFile(pFile);
- pFile = NULL;
- }
-
- return false;
-
-#endif
-
__CATCH:
MmsInitHeader();
@@ -4510,8 +4451,9 @@ __CATCH:
#endif
MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type);
- MSG_DEBUG("_MmsReadMsgBody: E N D (fail) ******************** \n");
+ MSG_DEBUG("### Fail ###");
+ MSG_END();
return false;
}
@@ -4578,12 +4520,12 @@ static char *__MsgGetStringUntilDelimiter(char *pszString, char delimiter)
int bufLength = 0;
if (!pszString) {
- MSG_DEBUG("_MsgGetStringUntilDelimiter: pszString == NULL \n");
+ MSG_DEBUG("pszString == NULL");
return NULL;
}
if ((pszStrDelimiter = strchr(pszString, delimiter)) == NULL) {
- MSG_DEBUG("_MsgGetStringUntilDelimiter: There is no %c in %s. \n", delimiter, pszString);
+ MSG_DEBUG("There is no %c in %s. \n", delimiter, pszString);
return NULL;
}
@@ -4706,7 +4648,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
memset (pType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1);
strncpy(pType->param.szBoundary, pDec, MSG_BOUNDARY_LEN);
- MSG_DEBUG("_MsgParseParameter: szBoundary = %s \n", pType->param.szBoundary);
+ MSG_DEBUG("szBoundary = [%s]", pType->param.szBoundary);
break;
case MSG_PARAM_CHARSET:
@@ -4715,7 +4657,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
if (pType->param.charset == INVALID_HOBJ)
pType->param.charset = MSG_CHARSET_UNKNOWN;
- MSG_DEBUG("_MsgParseParameter: type = %d [charset] = %d \n", pType->type, pType->param.charset);
+ MSG_DEBUG("type = %d [charset] = %d", pType->type, pType->param.charset);
break;
case MSG_PARAM_NAME:
@@ -4753,10 +4695,10 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
// Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
__MsgRemoveFilePath(pType->param.szName);
} else {
- MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec);
+ MSG_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec);
}
- MSG_DEBUG("_MsgParseParameter: szName = %s \n", pType->param.szName);
+ MSG_DEBUG("szName = %s", pType->param.szName);
break;
case MSG_PARAM_FILENAME:
@@ -4792,10 +4734,10 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
// Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
__MsgRemoveFilePath(pType->param.szFileName);
} else {
- MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec);
+ MSG_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec);
}
- MSG_DEBUG("_MsgParseParameter: szFileName = %s \n", pType->param.szFileName);
+ MSG_DEBUG("szFileName = %s", pType->param.szFileName);
break;
@@ -4804,7 +4746,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
/* type/subtype of root. Only if content-type is multipart/related */
pType->param.type = _MsgGetCode(MSG_TYPE, pDec);
- MSG_DEBUG("_MsgParseParameter: type = %d \n", pType->param.type);
+ MSG_DEBUG("type = %d", pType->param.type);
break;
@@ -4815,7 +4757,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1);
strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN);
- MSG_DEBUG("_MsgParseParameter: szStart = %s \n", pType->param.szStart);
+ MSG_DEBUG("szStart = %s", pType->param.szStart);
break;
@@ -4826,7 +4768,7 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1);
strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN);
- MSG_DEBUG("_MsgParseParameter: szStartInfo = %s \n", pType->param.szStartInfo);
+ MSG_DEBUG("szStartInfo = %s", pType->param.szStartInfo);
break;
@@ -4840,12 +4782,12 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc)
pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN;
}
- MSG_DEBUG("_MsgParseParameter: reportType = %s \n", pDec);
+ MSG_DEBUG("reportType = %s", pDec);
break;
default:
- MSG_DEBUG("_MsgParseParameter: Unknown paremeter (%s)\n", pDec);
+ MSG_DEBUG("Unknown paremeter (%s)", pDec);
break;
}
@@ -4937,12 +4879,12 @@ static char *__MsgConvertLatin2UTF8FileName(char *pSrc)
pUTF8Buff = (char *)malloc(utf8BufSize + 1);
if (pUTF8Buff == NULL) {
- MSG_DEBUG("MsgConvertLatin2UTF8FileName: pUTF8Buff alloc fail \n");
+ MSG_DEBUG("pUTF8Buff alloc fail");
goto __CATCH;
}
if (__MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pSrc, length) < 0) {
- MSG_DEBUG("MsgConvertLatin2UTF8FileName: MsgLatin2UTF fail \n");
+ MSG_DEBUG("MsgLatin2UTF fail");
goto __CATCH;
}
} else {
@@ -4950,7 +4892,7 @@ static char *__MsgConvertLatin2UTF8FileName(char *pSrc)
pUTF8Buff = (char *)calloc(1, length+1);
if (pUTF8Buff == NULL) {
- MSG_DEBUG("MsgConvertLatin2UTF8FileName: pUTF8Buff alloc fail \n");
+ MSG_DEBUG("pUTF8Buff alloc fail");
goto __CATCH;
}
@@ -5030,7 +4972,7 @@ static void __MsgRemoveFilePath(char *pSrc)
}
if (pPath) {
- MSG_DEBUG("_MsgRemoveFilePath: filename(%s)\n", pSrc);
+ MSG_DEBUG("filename(%s)", pSrc);
// case : images/vf7.gif -> vf7.gif
if (pPath != NULL && *(pPath+1) != '\0') {
@@ -5050,10 +4992,10 @@ static void __MsgRemoveFilePath(char *pSrc)
static bool __MsgIsUTF8String(unsigned char *szSrc, int nChar)
{
- MSG_DEBUG("MsgIsUTF8String: --------------- \n");
+ MSG_DEBUG("MsgIsUTF8String: ---------------");
if (szSrc == NULL) {
- MSG_DEBUG("MsgIsUTF8String: szSrc is NULL !!!! --------------- \n");
+ MSG_DEBUG("szSrc is NULL !!!! ---------------");
return true;
}
@@ -5066,7 +5008,7 @@ static bool __MsgIsUTF8String(unsigned char *szSrc, int nChar)
szSrc += 2;
nChar -= 2;
} else {
- MSG_DEBUG("MsgIsUTF8String: 1. NOT utf8 range!\n");
+ MSG_DEBUG("1. NOT utf8 range!");
goto __CATCH;
}
} else if (*szSrc >= 0xE0) {
@@ -5075,15 +5017,15 @@ static bool __MsgIsUTF8String(unsigned char *szSrc, int nChar)
szSrc += 3;
nChar -= 3;
} else {
- MSG_DEBUG("MsgIsUTF8String: 2. NOT utf8 range!\n");
+ MSG_DEBUG("2. NOT utf8 range!");
goto __CATCH;
}
} else {
- MSG_DEBUG("MsgIsUTF8String: 3. NOT utf8 range!\n");
+ MSG_DEBUG("3. NOT utf8 range!");
goto __CATCH;
}
} else {
- MSG_DEBUG("MsgIsUTF8String: 4. NOT utf8 range!\n");
+ MSG_DEBUG("4. NOT utf8 range!");
goto __CATCH;
}
}
@@ -5114,17 +5056,17 @@ static MsgMultipart *__MsgAllocMultipart(void)
{
MsgMultipart *pMultipart = NULL;
- MSG_DEBUG("MsgAllocMultipart: --------- \n");
+ MSG_BEGIN();
pMultipart = (MsgMultipart*)malloc(sizeof(MsgMultipart));
if (pMultipart == NULL) {
- MSG_DEBUG("MsgAllocMultipart: pMultipart malloc Fail \n");
+ MSG_DEBUG("pMultipart malloc Fail");
goto __CATCH;
}
pMultipart->pBody = (MsgBody*)malloc(sizeof(MsgBody));
if (pMultipart->pBody == NULL) {
- MSG_DEBUG("MsgAllocMultipart: pMultipart->pBody malloc Fail \n");
+ MSG_DEBUG("pMultipart->pBody malloc Fail");
goto __CATCH;
}
@@ -5133,6 +5075,7 @@ static MsgMultipart *__MsgAllocMultipart(void)
pMultipart->pNext = NULL;
+ MSG_END();
return pMultipart;
__CATCH:
@@ -5357,7 +5300,7 @@ bool MsgCopyDrmInfo(MsgType *pPartType)
strcpy (pPartType->param.szName + fileNameLen, pExt);
} else {
strncpy(pPartType->param.szName, pTmpBuf, MSG_LOCALE_FILENAME_LEN_MAX);
- __MsgMakeFileName(pPartType->type, pPartType->param.szName, MSG_DRM_TYPE_NONE, 0);
+ __MsgMakeFileName(pPartType->type, pPartType->param.szName, MSG_DRM_TYPE_NONE, 0, pPartType->param.szName, sizeof(pPartType->param.szName));
}
}
@@ -5400,13 +5343,13 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
* to the selected media part.
*/
- MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE\n");
+ MSG_DEBUG("MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE");
pSelectedPart = pPartBody->body.pMultipart;
// NULL Pointer check!!
if (pSelectedPart == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart : multipart(ALTERNATIVE) does not exist\n");
+ MSG_DEBUG("multipart(ALTERNATIVE) does not exist");
break;
}
@@ -5452,7 +5395,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
}
if (__MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
- MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n");
+ MSG_DEBUG("MsgPriorityCopyMsgType failed");
goto __CATCH;
}
@@ -5477,7 +5420,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED:
case MIME_MULTIPART_RELATED:
- MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_RELATED\n");
+ MSG_DEBUG("MIME_APPLICATION_VND_WAP_MULTIPART_RELATED");
pSelectedPart = pPartBody->body.pMultipart;
@@ -5485,14 +5428,14 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
if (__MsgIsMultipartMixed(pSelectedPart->type.type)) {
if (pSelectedPart->pBody == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(1) is NULL\n");
+ MSG_DEBUG("pSelectedPart->pBody(1) is NULL");
break;
}
pFirstPart = pSelectedPart->pBody->body.pMultipart;
if (pFirstPart == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart : multipart(RELATED) does not exist\n");
+ MSG_DEBUG("multipart(RELATED) does not exist");
break;
}
@@ -5542,7 +5485,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
case MIME_MULTIPART_MIXED:
- MSG_DEBUG("MsgResolveNestedMultipart : MIME_APPLICATION_VND_WAP_MULTIPART_MIXED\n");
+ MSG_DEBUG("MIME_APPLICATION_VND_WAP_MULTIPART_MIXED");
pPrevPart = NULL;
pSelectedPart = pPartBody->body.pMultipart;
@@ -5550,7 +5493,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
while (pSelectedPart) {
if (MsgIsMultipart(pSelectedPart->type.type)) {
if (pSelectedPart->pBody == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(2) is NULL\n");
+ MSG_DEBUG("pSelectedPart->pBody(2) is NULL");
break;
}
@@ -5558,7 +5501,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
// NULL Pointer check!!
if (pFirstPart == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart : multipart does not exist\n");
+ MSG_DEBUG("multipart does not exist");
break;
}
@@ -5606,13 +5549,13 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
case MIME_MULTIPART_REPORT:
- MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT \n");
+ MSG_DEBUG("MIME_MULTIPART_REPORT");
pTmpMultipart = pPartBody->body.pMultipart;
pPrevPart = NULL;
if (pTmpMultipart == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart : pTmpMultipart == NULL \n");
+ MSG_DEBUG("pTmpMultipart == NULL");
return false;
}
@@ -5627,7 +5570,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
}
if (pSelectedPart == NULL) {
- MSG_DEBUG("MsgResolveNestedMultipart : MIME_MULTIPART_REPORT [no selected part]\n");
+ MSG_DEBUG("MIME_MULTIPART_REPORT [no selected part]");
pRemoveList = pPartBody->body.pMultipart->pNext;
if (pPartBody->body.pMultipart != NULL) {
@@ -5662,7 +5605,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
}
if (__MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
- MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n");
+ MSG_DEBUG("MsgPriorityCopyMsgType failed");
goto __CATCH;
}
@@ -5719,7 +5662,7 @@ char *MsgResolveContentURI(char *szSrc)
szTemp = (char *)malloc(length);
if (szTemp == NULL) {
- MSG_DEBUG("MsgResolveContentURI: memory full\n");
+ MSG_DEBUG("memory full");
goto __CATCH;
}
@@ -5746,7 +5689,7 @@ char *MsgRemoveQuoteFromFilename(char *pSrc)
char *pBuff = NULL;
if (pSrc == NULL) {
- MSG_DEBUG("MsgRemoveQuoteFromFilename: pSrc is Null\n");
+ MSG_DEBUG("pSrc is Null");
return NULL;
}
@@ -5755,7 +5698,7 @@ char *MsgRemoveQuoteFromFilename(char *pSrc)
pBuff = (char *)malloc(cLen + 1);
if (pBuff == NULL) {
- MSG_DEBUG("MsgRemoveQuoteFromFilename: pBuff mem alloc fail!\n");
+ MSG_DEBUG("pBuff mem alloc fail!");
return NULL;
}
memset(pBuff, 0 , sizeof(char)*(cLen + 1));
@@ -5962,7 +5905,7 @@ bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib* pAttrib)
MmsPluginStorage::instance()->getMmsMessage(&pMsg);
memcpy(pAttrib, &(pMsg->mmsAttrib), sizeof(MmsAttrib));
- MSG_DEBUG("MmsGetMsgAttrib: msgID = %lu ---------------------\n", msgID);
+ MSG_DEBUG("msgID = %lu ---------------------\n", msgID);
if ('\0' != pMsg->szTrID[0])
MSG_DEBUG("szTrID = %s \n", pMsg->szTrID);
@@ -6036,10 +5979,10 @@ static int __MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar)
{
int nCount = 0;
- MSG_DEBUG("MsgGetLatin2UTFCodeSize: --------------- \n");
+ MSG_DEBUG("---------------");
if ((szSrc == NULL) || (nChar <= 0)) {
- MSG_DEBUG("MsgGetLatin2UTFCodeSize: szSrc is NULL !!!! --------------- \n");
+ MSG_DEBUG("szSrc is NULL !!!! ---------------");
return 0;
}
@@ -6212,7 +6155,7 @@ static int __MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
{
int nCount = 0;
- MSG_DEBUG("MsgGetLatin52UTFCodeSize: --------------- \n");
+ MSG_DEBUG("---------------");
if ((szSrc == NULL) || (nChar <= 0))
return 0;
@@ -6223,7 +6166,7 @@ static int __MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
szSrc++;
nChar--;
} else if (*szSrc == 0x00 || (*szSrc >= 0x80 && *szSrc <= 0x9F) ||
- (*szSrc >= 0xA0 && *szSrc <= 0xCF) || (*szSrc >= 0xD1 && *szSrc <= 0xDC) |
+ (*szSrc >= 0xA0 && *szSrc <= 0xCF) || (*szSrc >= 0xD1 && *szSrc <= 0xDC) ||
(*szSrc >= 0xDF && *szSrc <= 0xEF) || (*szSrc >= 0xF1 && *szSrc <= 0xFC) ||
*szSrc == 0xD0 || *szSrc == 0xDD || *szSrc == 0xDE || *szSrc == 0xF0 ||
*szSrc == 0xFD || *szSrc == 0xFE || *szSrc == 0xFF) { //uni 0x00A0 ~ 0x00CF
@@ -6242,7 +6185,7 @@ static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szS
unsigned char* org;
unsigned char t1, t2;
- MSG_DEBUG("MsgLatin2UTF: --------------- \n");
+ MSG_DEBUG("---------------");
org = des;
outBufSize--; // NULL character
@@ -6294,7 +6237,7 @@ static int __MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char
unsigned char t3;
unsigned short temp = 0;
- MSG_DEBUG("MsgUnicode2UTF: --------------- \n");
+ MSG_DEBUG("---------------");
org = des;
outBufSize--; //Null Character
@@ -6453,7 +6396,7 @@ static int __MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar)
{
int nCount = 0;
- MSG_DEBUG("MsgGetLatin72UTFCodeSize: --------------- \n");
+ MSG_DEBUG(" ---------------");
if ((szSrc == NULL) || (nChar <= 0))
return 0;
@@ -6488,7 +6431,7 @@ static int __MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *
unsigned char t2;
unsigned char t3;
- MSG_DEBUG("MsgUnicode2UTF: --------------- \n");
+ MSG_DEBUG(" ---------------");
org = des;
outBufSize--; // NULL character
@@ -6553,10 +6496,10 @@ static int __MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar)
{
int nCount = 0;
- MSG_DEBUG("MsgGetUnicode2UTFCodeSize: --------------- \n");
+ MSG_DEBUG(" ---------------");
if ((szSrc == NULL) || (nChar <= 0)) {
- MSG_DEBUG("MsgGetUnicode2UTFCodeSize: szSrc is NULL !!!! --------------- \n");
+ MSG_DEBUG("szSrc is NULL !!!! ---------------");
return 0;
}
@@ -6598,7 +6541,7 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr)
int strLen = 0;
if ((!pszAddr) || (pszAddr[0] == 0)) {
- MSG_DEBUG("MmsAddrUtilRemovePlmnString: pszAddr is null or zero\n");
+ MSG_DEBUG("pszAddr is null or zero");
return false;
}
@@ -6606,7 +6549,7 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr)
pszAddrCopy = (char*)calloc(1,strLen + 1);
if (!pszAddrCopy) {
- MSG_DEBUG("MmsAddrUtilRemovePlmnString: pszAddrCopy is NULL, mem alloc failed\n");
+ MSG_DEBUG("pszAddrCopy is NULL, mem alloc failed");
return false;
}
@@ -6675,7 +6618,7 @@ static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *
{
unsigned char *org;
- MSG_DEBUG("MsgCutUTFString: --------------- \n");
+ MSG_DEBUG("---------------");
org = des;
outBufSize--; // NULL character
@@ -6718,7 +6661,7 @@ static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *
*des = *szSrc;
des++;
szSrc++;
- MSG_DEBUG("MsgCutUTFString: utf8 incorrect range!\n");
+ MSG_DEBUG("utf8 incorrect range!");
}
nChar--;
@@ -6750,8 +6693,6 @@ static bool __MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, in
int nRead = 0;
int length= 0;
- MSG_DEBUG("MsgLoadDataToDecodeBuffer: \n");
-
if (pFile == NULL) {
MSG_DEBUG("Error");
@@ -6838,7 +6779,7 @@ bool MsgGetTypeByFileName(int *type, char *szFileName)
goto __CATCH;
AvType = AvGetFileCodecType(szFileName);
- MSG_DEBUG("MsgGetTypeByFileName:AvType(0x%x)\n", AvType);
+ MSG_DEBUG("AvType(0x%x)\n", AvType);
switch (AvType) {
case AV_DEC_AUDIO_MPEG4:
@@ -6868,15 +6809,13 @@ bool MsgGetTypeByFileName(int *type, char *szFileName)
}
*type = MimeGetMimeFromExtInt((const char*)pExt);
- MSG_DEBUG("MsgGetTypeByFileName: szFileName = %s type = %d \n", szFileName, type);
+ MSG_DEBUG("filename [%s], type [%d]", szFileName, *type);
return true;
-
__CATCH:
*type = MIME_UNKNOWN;
- MSG_DEBUG("MsgGetTypeByFileName: szFileName = %s type = %d \n", szFileName, type);
-
+ MSG_DEBUG("filename [%s], type [%d]", szFileName, *type);
return false;
}
@@ -6896,11 +6835,11 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
FILE *pFile = NULL;
char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, }; // file name of temp file
char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; // full absolute path of temp file.
-
- MSG_DEBUG("**** _MmsSaveMediaData: [Multi part] START ***\n");
+ bool bFileExist = false;
+ MSG_BEGIN();
if (!pPartType) {
- MSG_DEBUG("pPartType is NULL\n");
+ MSG_DEBUG("pPartType is NULL");
return false;
}
@@ -6920,7 +6859,7 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
#ifndef __SUPPORT_DRM__
__MsgMakeFileName(pPartType->type, szFileName, 0); //FL & CD -> extension(.dm) SD -> extension(.dcf)
#else
- __MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0); //FL & CD -> extension(.dm) SD -> extension(.dcf)
+ __MsgMakeFileName(pPartType->type, szFileName, pPartType->drmInfo.drmType, 0, szFileName, sizeof(szFileName)); //FL & CD -> extension(.dm) SD -> extension(.dcf)
if (MsgDRMIsForwardLockType(pPartType->drmInfo.drmType))
MsgChangeDrm2FileName(szFileName);
#endif
@@ -6938,7 +6877,12 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
MsgGetTypeByFileName(&pPartType->type, szFullPath);
// save file
- if (bSave) {
+ bFileExist = MsgAccessFile(szFullPath, F_OK);
+
+ MSG_DEBUG("save flag [%d], filepath [%s], file exist [%d]", bSave, szFullPath, bFileExist);
+
+ if (bSave == true && bFileExist == false) {
+
if ((pFile = MsgOpenFile(szFullPath, "wb+")) == NULL) {
MSG_DEBUG("MsgOpenFile failed");
goto __CATCH;
@@ -6956,7 +6900,6 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
pPartBody->offset = 0;
pPartBody->size = MsgGetFileSize(pPartBody->szOrgFilePath);
- MSG_DEBUG("Save Temp File to [%s]", pPartBody->szOrgFilePath);
if (pPartType->drmInfo.drmType != MSG_DRM_TYPE_NONE) {
MsgDrmRegisterFile(MSG_MODE_FILE, szFullPath, strlen(szFullPath));
@@ -6967,10 +6910,15 @@ static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody,
pPartType->drmInfo.szDrm2FullPath = MsgStrCopy(szFullPath);
}
}
-
+ MSG_DEBUG("Save Part File to [%s]", pPartBody->szOrgFilePath);
+ } else {
+ snprintf(pPartBody->szOrgFilePath, sizeof(pPartBody->szOrgFilePath), "%s", szFullPath);
+ pPartBody->offset = 0;
+ pPartBody->size = MsgGetFileSize(pPartBody->szOrgFilePath);
+ MSG_DEBUG("Set Part File to [%s]", pPartBody->szOrgFilePath);
}
- MSG_DEBUG("**** MmsGetMediaPartData: [Multi part] E N D (Successfully) ***\n");
+ MSG_END();
return true;
__CATCH:
@@ -6979,11 +6927,11 @@ __CATCH:
MsgCloseFile(pFile);
pFile = NULL;
}
-
+ MSG_END();
return false;
}
-static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile)
+bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile)
{
int nRead = 0;
int nRead2 = 0;
@@ -7011,7 +6959,7 @@ static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE*
pTempData = MsgOpenAndReadMmsFile(pPartBody->szOrgFilePath, offset, size, &nRead);
if (pTempData == NULL) {
- MSG_DEBUG("MmsGetMediaPartData : pTempData read fail\n");
+ MSG_DEBUG("pTempData read fail");
goto __CATCH;
}
@@ -7022,7 +6970,7 @@ static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE*
}
if (pData == NULL) {
- MSG_DEBUG("MmsGetMediaPartData : there is no data \n");
+ MSG_DEBUG("there is no data");
goto __RETURN;
}
@@ -7033,7 +6981,7 @@ static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE*
pPartType->param.charset = MSG_CHARSET_UTF8;
if (MsgWriteFile(pNewData, sizeof(char), nRead2, pFile) != (size_t)nRead2) {
- MSG_DEBUG("MmsGetMediaPartData: file writing fail \n");
+ MSG_DEBUG("file writing fail");
goto __CATCH;
}
@@ -7084,7 +7032,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
case MSG_ENCODING_BASE64:
pConvertedData = (char*)MsgDecodeBase64((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
- MSG_DEBUG("MmsGetBinaryUTF8Data : MSG_ENCODING_BASE64 bodyLength = %d \n", nByte);
+ MSG_DEBUG("MSG_ENCODING_BASE64 bodyLength [%d]", nByte);
pTemp = pConvertedData;
nTemp = nByte;
@@ -7094,7 +7042,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
case MSG_ENCODING_QUOTE_PRINTABLE:
pConvertedData = (char*)MsgDecodeQuotePrintable((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
- MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_ENCODING_QUOTE_PRINTABLE bodyLength = %d \n", nByte);
+ MSG_DEBUG("MSG_ENCODING_QUOTE_PRINTABLE bodyLength [%d]", nByte);
pTemp = pConvertedData;
nTemp = nByte;
@@ -7103,8 +7051,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
default:
- MSG_DEBUG("MmsGetBinaryUTF8Data: 8bit OR Binary bodyLength = %d \n", nRead);
-
+ MSG_DEBUG("encoding val [%d] bodyLength [%d]", msgEncodingValue, nRead);
pTemp = pData;
nTemp = nRead;
@@ -7118,14 +7065,14 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
case MSG_CHARSET_UTF16:
case MSG_CHARSET_USC2:
- MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_USC2 \n");
+ MSG_DEBUG("MSG_CHARSET_USC2");
if (((UINT8)pTemp[0]) == 0xFF && ((UINT8)pTemp[1]) == 0xFE) {
nChar = (nTemp / 2 - 1);
mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
if (mszTempStr == NULL) {
- MSG_DEBUG("MmsGetBinaryUTF8Data : 1. Memory Full !!! \n");
+ MSG_DEBUG("Memory Full !!!");
goto __CATCH;
}
@@ -7143,7 +7090,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
mszTempStr = (unsigned short*) malloc(nChar * sizeof(unsigned short));
if (mszTempStr == NULL) {
- MSG_DEBUG("MmsGetBinaryUTF8Data: 2. Memory Full !!! \n");
+ MSG_DEBUG("Memory Full !!!");
goto __CATCH;
}
@@ -7165,13 +7112,12 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
case MSG_CHARSET_US_ASCII:
- MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_US_ASCII \n");
+ MSG_DEBUG("MSG_CHARSET_US_ASCII");
/* fall through */
-
case MSG_CHARSET_UTF8:
- MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_UTF8 or Others \n");
+ MSG_DEBUG("MSG_CHARSET_UTF8 or Others");
// skip BOM (Byte Order Mark) bytes .. (Please refer to the http://www.unicode.org/faq/utf_bom.html#BOM)
if (nTemp >= 3) {
@@ -7189,7 +7135,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
/* Greek */
- MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_7 \n");
+ MSG_DEBUG("MSG_CHARSET_ISO_8859_7");
nByte = __MsgGetLatin72UTFCodeSize((unsigned char*)pTemp, nTemp);
pConvertedStr = (char *)malloc(nByte + 1);
@@ -7204,7 +7150,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
case MSG_CHARSET_ISO_8859_9:
/* Turkish */
- MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_9 \n");
+ MSG_DEBUG("MSG_CHARSET_ISO_8859_9");
nByte = __MsgGetLatin52UTFCodeSize((unsigned char*)pTemp, nTemp);
pConvertedStr = (char *)malloc(nByte + 1);
@@ -7218,7 +7164,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
default:
- MSG_DEBUG("MmsGetBinaryUTF8Data: Other charsets \n");
+ MSG_DEBUG("Other charsets");
nByte = __MsgGetLatin2UTFCodeSize((unsigned char*)pTemp, nTemp);
pConvertedStr = (char *)malloc(nByte + 1);
@@ -7237,7 +7183,7 @@ static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue
pReturnData = (char *)malloc(*npRead);
if (pReturnData == NULL) {
- MSG_DEBUG("MmsGetBinaryUTF8Data : pReturnData alloc fail. \n");
+ MSG_DEBUG("pReturnData alloc fail.");
goto __CATCH;
}
@@ -7293,7 +7239,7 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex)
char *pExt = NULL;
- MSG_DEBUG("MsgMakeFileName: iMsgType = %d szFileName = %s \n", iMsgType, szFileName);
+ MSG_DEBUG("iMsgType = %d, szFileName = %s", iMsgType, szFileName);
if (szFileName == NULL)
return false;
@@ -7319,13 +7265,13 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex)
}
if (iMsgType == MIME_APPLICATION_OCTET_STREAM) {
- MSG_DEBUG("MsgMakeFileName: unsupported MsgType\n");
+ MSG_DEBUG("unsupported MsgType");
goto __CATCH;
} else {
int nLen = 0;
strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5);
if (iMsgType == MIME_UNKNOWN || (pExt = MimeGetExtFromMimeInt((MimeType)iMsgType)) == NULL) {
- MSG_DEBUG("MsgMakeFileName: Failed to get extension of that mime data file. \n");
+ MSG_DEBUG("Failed to get extension of that mime data file.");
goto __CATCH;
}
nLen = MSG_FILENAME_LEN_MAX - strlen(szTemp);
@@ -7335,7 +7281,7 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex)
strcpy(szFileName, szTemp);
- MSG_DEBUG("MsgMakeFileName: made szFileName = %s \n", szFileName);
+ MSG_DEBUG("made szFileName = %s", szFileName);
return true;
@@ -7351,92 +7297,59 @@ __CATCH:
}
}
#else
-static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex)
+static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex, char *outBuf, int outBufLen)
{
- char szText[MSG_FILENAME_LEN_MAX+1]={0,};
char szTemp[MSG_FILENAME_LEN_MAX+1]={0,};
char szTempFileName[MSG_FILENAME_LEN_MAX+1]={0,};
char *pExt = NULL;
- MSG_DEBUG("MsgMakeFileName: iMsgType = 0x%x, drmType = %d, szFileName = %s \n", iMsgType, drmType, szFileName);
+ MSG_DEBUG("Input : type [0x%x], drmType [%d], filename [%s]", iMsgType, drmType, szFileName);
if (szFileName == NULL)
return false;
- if (szFileName && (szFileName[0] != '\0')) {
+ int inp_len = strlen(szFileName);
+ if (inp_len >0) {
MsgGetFileNameWithoutExtension (szTempFileName, szFileName);
-
- if (drmType != MSG_DRM_TYPE_NONE) {
- pExt = strrchr(szTempFileName, '.');
- if (pExt == NULL) {
- memset(szText, 0, MSG_FILENAME_LEN_MAX+1);
- strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1);
- strcat(szText, "."); // add '.'
- } else {
- memset(szText, 0, MSG_FILENAME_LEN_MAX+1);
- strncpy(szText, szTempFileName, pExt+1 - szFileName);
- }
- } else {
- pExt = strrchr(szTempFileName, '.');
- if (pExt == NULL) {
- memset(szText, 0, MSG_FILENAME_LEN_MAX+1);
- strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1);
- strcat(szText, ".");
- } else {
- return true;
- }
- }
} else {
if (nUntitleIndex >= 1) {
- snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s_%d.", "untitled", nUntitleIndex);
+ snprintf(szTempFileName, sizeof(szTempFileName), "%s_%d", "untitled", nUntitleIndex);
} else {
- snprintf(szText, MSG_FILENAME_LEN_MAX+1, "%s.", "untitled");
+ snprintf(szTempFileName, sizeof(szTempFileName), "%s", "untitled");
}
}
if (drmType == MSG_DRM_TYPE_SD) {
- strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5);
- strcat(szTemp, "dcf");
+ snprintf(szTemp, sizeof(szTemp), "%s.dcf", szTempFileName);
} else if (MsgDRMIsForwardLockType(drmType)) {
- strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 4);
- strcat(szTemp, "dm");
+ snprintf(szTemp, sizeof(szTemp), "%s.dm", szTempFileName);
} else {
if (iMsgType == MIME_APPLICATION_OCTET_STREAM) {
- MSG_DEBUG("MsgMakeFileName: unsupported MsgType\n");
+ MSG_DEBUG("unsupported MsgType");
goto __CATCH;
} else {
- int nLen = 0;
- strncpy(szTemp, szText, MSG_FILENAME_LEN_MAX - 5);
- //temporary commented to save file as original name.
- if (pExt == NULL) {
- if (iMsgType == MIME_UNKNOWN || (pExt = MimeGetExtFromMimeInt((MimeType)iMsgType)) == NULL) {
- MSG_DEBUG("MsgMakeFileName: Failed to get extension of that mime data file. \n");
- goto __CATCH;
- }
+ if (iMsgType == MIME_UNKNOWN) {
+ MSG_DEBUG("Failed to get extension of that mime data file.");
+ goto __CATCH;
}
- nLen = MSG_FILENAME_LEN_MAX - strlen(szTemp);
- strncat(szTemp, pExt, nLen);
+ pExt = MimeGetExtFromMimeInt((MimeType)iMsgType);
+ if (pExt) {
+ snprintf(szTemp, sizeof(szTemp), "%s.%s", szTempFileName, pExt);
+ } else {
+ MSG_DEBUG("Failed to get extension of that mime data file.");
+ goto __CATCH;
+ }
}
}
- strcpy(szFileName, szTemp);
-
- MSG_DEBUG("MsgMakeFileName: made szFileName = %s \n", szFileName);
-
+ snprintf(outBuf, outBufLen, "%s", szTemp);
+ MSG_DEBUG("Result : filename [%s]", outBuf);
return true;
__CATCH:
- {
- char *p = NULL;
- p = strrchr(szText, '.');
- if (p != NULL)
- *p = 0;
- snprintf(szFileName, MSG_FILENAME_LEN_MAX+1, "%s", szText);
-
- return false;
- }
+ return false;
}
#endif
@@ -7479,7 +7392,7 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
MsgMultipart *pPart = NULL;
if (pHeader == NULL) {
- MSG_DEBUG("MmsGetMediaPartHeader: Invalid pHeader input. It's null \n");
+ MSG_DEBUG("Invalid pHeader input. It's null");
return false;
}
@@ -7490,7 +7403,7 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
/* Requires header of non-presentation */
if (MsgIsMultipart(pMsg->msgType.type)) {
- MSG_DEBUG("MmsGetMediaPartHeader: Multipart header [index = %d] \n", index);
+ MSG_DEBUG("Multipart header [index = %d] \n", index);
pPart = pMsg->msgBody.body.pMultipart;
@@ -7498,13 +7411,13 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
pPart = pPart->pNext;
if (pPart == NULL) {
- MSG_DEBUG("MmsGetMediaPartHeader: There is no such msg part.\n");
+ MSG_DEBUG("There is no such msg part.");
return false;
}
memcpy(pHeader, &pPart->type, sizeof(MsgType));
} else {
- MSG_DEBUG("MmsGetMediaPartHeader: Requires singlepart header \n");
+ MSG_DEBUG("Requires singlepart header");
memcpy(pHeader, &pMsg->msgType, sizeof(MsgType));
}
@@ -7513,28 +7426,27 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
static bool __MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index)
{
- MSG_DEBUG("------------------------------\n");
- MSG_DEBUG("%dth multipart info\n", index);
- MSG_DEBUG("header size=%d\n", pMultipart->type.size);
- MSG_DEBUG("body size=%d\n", pMultipart->type.contentSize);
- MSG_DEBUG("content type=%s\n", MmsDebugGetMimeType((MimeType)pMultipart->type.type));
- MSG_DEBUG("content ID=%s\n", pMultipart->type.szContentID);
- MSG_DEBUG("content location=%s\n", pMultipart->type.szContentLocation);
+ MSG_DEBUG("------------------------------");
+ MSG_DEBUG("[%dth] multipart info", index);
+ MSG_DEBUG("header size [%d], body size [%d]", pMultipart->type.size, pMultipart->type.contentSize);
+ MSG_DEBUG("content type [%s]", MmsDebugGetMimeType((MimeType)pMultipart->type.type));
+ MSG_DEBUG("content ID [%s]", pMultipart->type.szContentID);
+ MSG_DEBUG("content location [%s]", pMultipart->type.szContentLocation);
+ MSG_DEBUG("parameter Name [%s]", pMultipart->type.param.szName);
+ MSG_DEBUG("parameter Filename[%s]", pMultipart->type.param.szFileName);
if (pMultipart->type.type == MIME_TEXT_PLAIN) {
- MSG_DEBUG("text info\n");
- MSG_DEBUG("charset=%d\n", pMultipart->type.param.charset);
- MSG_DEBUG("text file name=%s\n", pMultipart->type.param.szName);
+ MSG_DEBUG("text info : charset [%d], name [%s]", pMultipart->type.param.charset, pMultipart->type.param.szName);
}
#ifdef __SUPPORT_DRM__
if (pMultipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) {
- MSG_DEBUG("drm info\n");
- MSG_DEBUG("drm type=%d (0: NONE 1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery)\n", pMultipart->type.drmInfo.drmType);
- MSG_DEBUG("drm content type=%s\n", MmsDebugGetMimeType((MimeType)pMultipart->type.drmInfo.contentType));
- MSG_DEBUG("drm content URI=%s\n", pMultipart->type.drmInfo.szContentURI);
- MSG_DEBUG("drm2FullPath=%s\n", pMultipart->type.drmInfo.szDrm2FullPath);
+ MSG_DEBUG("drm info");
+ MSG_DEBUG("drm type [%d] (0: NONE 1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery)", pMultipart->type.drmInfo.drmType);
+ MSG_DEBUG("drm content type [%s]", MmsDebugGetMimeType((MimeType)pMultipart->type.drmInfo.contentType));
+ MSG_DEBUG("drm content URI [%s]", pMultipart->type.drmInfo.szContentURI);
+ MSG_DEBUG("drm2FullPath [%s]", pMultipart->type.drmInfo.szDrm2FullPath);
}
#endif
- MSG_DEBUG("------------------------------\n");
+ MSG_DEBUG("------------------------------");
return true;
}
diff --git a/plugin/mms_plugin/MmsPluginHttp.cpp b/plugin/mms_plugin/MmsPluginHttp.cpp
index cbdcd22..5d5a4f9 100755
--- a/plugin/mms_plugin/MmsPluginHttp.cpp
+++ b/plugin/mms_plugin/MmsPluginHttp.cpp
@@ -22,23 +22,42 @@
#include "MmsPluginUserAgent.h"
#include "MmsPluginConnManWrapper.h"
-static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *szHeaderBuffer);
-static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen);
-static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int ulContentLen);
-
-static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, void *userdata);
-static size_t __httpGetTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata);
-static size_t __httpPostTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata);
+#define MMS_FREE(obj)\
+ if (obj){\
+ free(obj);\
+ obj = NULL;\
+ }
-static int __httpCmdInitSession(MMS_PLUGIN_HTTP_DATA_S *httpConfig);
-static int __httpCmdPostTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig);
-static int __httpCmdGetTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig);
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);
/*==================================================================================================
FUNCTION IMPLEMENTATION
==================================================================================================*/
+static int __http_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
+{
+ MSG_DEBUG("download(%.0f/%.0f) : upload(%.0f/%.0f)", dlnow, dltotal, ulnow, ultotal);
+ return 0;
+}
+
+static int __http_debug_cb (CURL *input_curl, curl_infotype input_info_type, char *input_data , size_t input_size, void *input_void)
+{
+ MSG_DEBUG("curl_infotype [%d] : %s", input_info_type, input_data);
+ return 0;
+}
+
+static size_t __http_write_response_cb(void *ptr, size_t size, size_t nmemb, void *data)
+{
+ MSG_BEGIN();
+ FILE *writehere = (FILE *)data;
+ return fwrite(ptr, size, nmemb, writehere);
+}
+
static void __http_print_profile(CURL *curl)
{
double speed_upload, speed_download, total_time;
@@ -167,7 +186,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int
MSG_DEBUG("%s", pcheader);
*responseHeaders = curl_slist_append(*responseHeaders, pcheader);
}
-
+/* NOW not support gzip, deflate encoding in MMS Plugin
memset(szBuffer, 0, 1025);
memset(pcheader, 0, HTTP_REQUEST_LEN);
nResult = __httpGetHeaderField(MMS_HH_ACCEPT_ENCODING, szBuffer);
@@ -176,7 +195,7 @@ static void __httpAllocHeaderInfo(curl_slist **responseHeaders, char *szUrl, int
MSG_DEBUG("%s", pcheader);
*responseHeaders = curl_slist_append(*responseHeaders, pcheader);
}
-
+*/
memset(szBuffer, 0, 1025);
memset(pcheader, 0, HTTP_REQUEST_LEN);
nResult = __httpGetHeaderField(MMS_HH_USER_AGENT, szBuffer);
@@ -309,369 +328,373 @@ static void __httpGetHost(char *szUrl, char *szHost, int nBufferLen)
}
}
-static MMS_NET_ERROR_T __httpReceiveData(void *ptr, size_t size, size_t nmemb, void *userdata)
+static int __http_multi_perform(void *session)
{
- MMS_NET_ERROR_T httpRet = eMMS_UNKNOWN;
+ MSG_BEGIN();
- MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance();
- MMS_PLUGIN_HTTP_CONTEXT_S *pMmsPlgCd = pHttpAgent->getMmsPldCd();
- long length_received = size * nmemb;
+ CURLM *multi_handle;
+ CURLMcode rcm;
- if (length_received) {
- //Save the received buffer in a safe place.
- if (pMmsPlgCd->final_content_buf == NULL) {
- MSG_DEBUG("Body Lenghth Read = %d", length_received);
- pMmsPlgCd->final_content_buf = (unsigned char *)malloc((length_received + 1) * sizeof(unsigned char));
+ int still_running;
+ int ret = 0;
+ bool abort_flag = false;
- if (pMmsPlgCd->final_content_buf == NULL) {
- MSG_DEBUG("malloc fail");
- return eMMS_HTTP_EVENT_RECV_DATA_ERROR;
- }
+ CURLMsg *msg;
+ int msgs_left;
- memset(pMmsPlgCd->final_content_buf,0x0,((length_received + 1) * sizeof(unsigned char)));
- MSG_DEBUG(" Global g_final_content_buf=%0x", pMmsPlgCd->final_content_buf);
- } else {
- //realloc pHttpEvent->bodyLen extra and memset
+ multi_handle = curl_multi_init();
- unsigned char * buf = (unsigned char *)realloc(pMmsPlgCd->final_content_buf,
- (pMmsPlgCd->bufOffset + length_received + 1) * sizeof(unsigned char));
+ if (curl_multi_add_handle(multi_handle, session) != 0) {
+ MSG_DEBUG("curl_multi_add_handle is failed");
+ curl_multi_cleanup(multi_handle);
+ return -1;
+ }
- if (buf == NULL) {
- MSG_DEBUG("realloc fail");
- return eMMS_HTTP_EVENT_RECV_DATA_ERROR;
- }
+ /* we start some action by calling perform right away */
+ rcm = curl_multi_perform(multi_handle, &still_running);
+ MSG_DEBUG("curl_multi_perform first end : rcm = %d, still_running = %d", rcm, still_running);
+
+ do {
+ struct timeval timeout;
+ int rc; /* select() return code */
+
+ fd_set fdread;
+ fd_set fdwrite;
+ fd_set fdexcep;
+ int maxfd = -1;
+
+ long curl_timeo = -1;
+
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ /* set a suitable timeout to play around with */
+ timeout.tv_sec = 10;
+ timeout.tv_usec = 0;
+
+ curl_multi_timeout(multi_handle, &curl_timeo);
+ if(curl_timeo >= 0) {
+ MSG_DEBUG("curl_timeo = %ld", curl_timeo);
+ timeout.tv_sec = curl_timeo / 1000;
+ if(timeout.tv_sec > 1)
+ timeout.tv_sec = 1;
+ else
+ timeout.tv_usec = (curl_timeo % 1000) * 1000;
+ }
+
+ curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
- pMmsPlgCd->final_content_buf = buf;
- MSG_DEBUG("Body Lenghth Read = %d Content Length = %d", length_received, pMmsPlgCd->bufOffset);
- memset((pMmsPlgCd->final_content_buf +pMmsPlgCd->bufOffset), 0x0,
- ((length_received + 1) * sizeof(unsigned char)));
- MSG_DEBUG(" Global g_final_content_buf=%0x", pMmsPlgCd->final_content_buf);
+ /* In a real-world program you OF COURSE check the return code of the
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
+ rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+ switch(rc) {
+ case -1:
+ /* select error */
+ MSG_DEBUG("select error");
+ break;
+ case 0: /* timeout */
+ default: /* action */
+ rcm = curl_multi_perform(multi_handle, &still_running);
+ break;
}
- //copy body
- if (pMmsPlgCd->final_content_buf != NULL) {
- memcpy( pMmsPlgCd->final_content_buf + pMmsPlgCd->bufOffset, ptr, length_received);
- MSG_DEBUG("Current g_bufOffset =%d", pMmsPlgCd->bufOffset);
- /* Content Received */
- MSG_DEBUG("Total Content received PTR =%0X, Content Size =%d", pMmsPlgCd->final_content_buf,
- pMmsPlgCd->bufOffset);
- pMmsPlgCd->bufOffset = pMmsPlgCd->bufOffset + length_received;
- httpRet = eMMS_UNKNOWN;
+ abort_flag = MmsPluginHttpAgent::instance()->getAbortFlag();
+ if (abort_flag == true) {
+ MSG_DEBUG("abort flag is Set");
+ ret = -1;
}
- } else {
- MSG_DEBUG("End of Data transfer");
- MSG_DEBUG("MmsHttpReadData Buffer Size = %d", pMmsPlgCd->bufOffset);
- MSG_DEBUG("MmsHttpReadData Buffer = %s", pMmsPlgCd->final_content_buf);
- if (pMmsPlgCd->bufOffset == 0) {
- /* This is applicable when - M-ReadRec.inf,M-Ack.ind, M-NotifyResp.ind posted */
- MSG_DEBUG(" Content Size is Zero");
+ MSG_DEBUG("curl_multi_perform end : rcm = %d, still_running = %d, abort_flag = %d", rcm, still_running, abort_flag);
- if (pMmsPlgCd->final_content_buf != NULL) {
- free(pMmsPlgCd->final_content_buf );
- pMmsPlgCd->final_content_buf = NULL;
- }
+ } while(still_running && (abort_flag == false));
- httpRet = eMMS_HTTP_EVENT_SENT_ACK_COMPLETED;
- } else if (pMmsPlgCd->final_content_buf != NULL && pMmsPlgCd->bufOffset != 0) {
- // Process Http Data
- MSG_DEBUG(" Send Received Data to UA");
- httpRet = eMMS_HTTP_RECV_DATA; // eMMS_HTTP_RECV_DATA;
- } else {
- httpRet = eMMS_UNKNOWN; // check later
- }
+ while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
+ if (msg->msg == CURLMSG_DONE) {
- return httpRet;
+ if (msg->easy_handle == session) {
+ MSG_DEBUG("HTTP transfer completed with status %d", msg->data.result);
+ curl_multi_remove_handle(multi_handle, session);
+ } else {
+ MSG_DEBUG("Unknown handle HTTP transfer completed with status %d", msg->data.result);
+ }
+ }
}
- return httpRet;
-}
+ curl_multi_cleanup(multi_handle);
+ MSG_END();
+ return ret;
+}
-static size_t __httpPostTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata)
+MmsPluginHttpAgent *MmsPluginHttpAgent::pInstance = NULL;
+MmsPluginHttpAgent *MmsPluginHttpAgent::instance()
{
- MSG_DEBUG(" ====== HTTP_EVENT_SENT ========");
- long length_received = size * nmemb;
- __httpReceiveData(ptr, size, nmemb, userdata);
+ if (!pInstance)
+ {
+ pInstance = new MmsPluginHttpAgent();
+ }
- return length_received;
+ return pInstance;
}
-static size_t __httpGetTransactionCB(void *ptr, size_t size, size_t nmemb, void *userdata)
+
+MmsPluginHttpAgent::MmsPluginHttpAgent()
{
- MSG_DEBUG(" ====== HTTP_EVENT_RECEIVED ========");
- long length_received = size * nmemb;
- __httpReceiveData(ptr, size, nmemb, userdata);
+ MSG_BEGIN();
- return length_received;
+ abort = false;
+ respfile = NULL;
+ session_header = NULL;
+ session_option = NULL;
+
+ transaction_type = MMS_HTTP_TRANSACTION_TYPE_UNKNOWN;
+ MSG_END();
}
-static int __httpCmdInitSession(MMS_PLUGIN_HTTP_DATA_S *httpConfig)
+MmsPluginHttpAgent::~MmsPluginHttpAgent()
{
- MSG_DEBUG("HttpCmd Init Session");
-
- char proxyAddr[MAX_IPV4_LENGTH + 1] = {0};
-
- snprintf(proxyAddr, MAX_IPV4_LENGTH + 1, "%s:%d", httpConfig->mmscConfig.httpProxyIpAddr, httpConfig->mmscConfig.proxyPortNo);
- MSG_DEBUG("profileId [%d], proxyAddr [%s]", httpConfig->currentProfileId, proxyAddr);
+ MSG_BEGIN();
- CURL *curl_session = curl_easy_init();
- if (NULL == curl_session) {
- MSG_DEBUG("curl_easy_init() failed");
- return eMMS_HTTP_SESSION_OPEN_FAILED;
+ if (session_header) {
+ MSG_DEBUG("session header is exist : free session header");
+ curl_slist_free_all((curl_slist *)session_header);
+ session_header = NULL;
}
- int curl_status = curl_easy_setopt(curl_session, CURLOPT_PROXY, proxyAddr);
- if (curl_status != CURLM_OK) {
- MSG_DEBUG("curl_easy_setopt(): CURLOPT_PROXY failed");
- curl_easy_cleanup(curl_session);
- return eMMS_HTTP_SESSION_OPEN_FAILED;
+ if (session_option) {
+ MSG_DEBUG("session is exist : cleanup session");
+ curl_easy_cleanup(session_option);
+ session_option = NULL;
}
- httpConfig->session = curl_session;
-
- return eMMS_HTTP_SESSION_INIT;
+ MSG_END();
}
-
-static int __httpCmdPostTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig)
+void MmsPluginHttpAgent::initSession()
{
- int trId;
-
- MSG_DEBUG("HttpCmd Post Transaction");
- MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_POST_TRANSACTION");
-
- char deviceName[1024] = {0,};
-
- MmsPluginCmAgent::instance()->getDeviceName(deviceName);
-
- MSG_DEBUG("deviceName: [%s]", deviceName);
- int curl_status = curl_easy_setopt(httpConfig->session, CURLOPT_INTERFACE, deviceName);
+ MSG_BEGIN();
- if (curl_status != CURLM_OK) {
- MSG_DEBUG("curl_easy_setopt(): CURLOPT_INTERFACE failed");
+ this->transaction_type = MMS_HTTP_TRANSACTION_TYPE_UNKNOWN;
- return eMMS_EXCEPTIONAL_ERROR;
+ if (session_header) {
+ MSG_DEBUG("session header is exist : free session header");
+ curl_slist_free_all((curl_slist *)session_header);
+ session_header = NULL;
}
- CURLcode rc = curl_easy_perform(httpConfig->session);
-
- __http_print_profile(httpConfig->session);
-
- MmsPluginHttpAgent* httpAgent = MmsPluginHttpAgent::instance();
- MMS_PLUGIN_HTTP_DATA_S *httpConfigData = httpAgent->getHttpConfigData();
- if (httpConfigData->sessionHeader) {
- curl_slist_free_all((curl_slist *)httpConfigData->sessionHeader);
- httpConfigData->sessionHeader = NULL;
+ if (session_option) {
+ MSG_DEBUG("session is exist : cleanup session");
+ curl_easy_cleanup(session_option);
+ session_option = NULL;
}
- if (CURLE_OK != rc) {
- MSG_DEBUG("curl_easy_perform return error rc[%d]", rc);
-
- return eMMS_HTTP_ERROR_NETWORK;
+ if (respfile) {
+ fclose(respfile);
+ respfile = NULL;
}
- MSG_DEBUG("## End Transaction ##");
-
- srandom((unsigned int) time(NULL));
- trId = random() % 1000000000 + 1;
- MSG_DEBUG("############ trID = %d ###########", trId);
-
- httpConfig->transactionId = trId;
+ initAbortFlag();
- return eMMS_HTTP_SENT_SUCCESS;
+ MSG_END();
}
-static int __httpCmdGetTransaction(MMS_PLUGIN_HTTP_DATA_S *httpConfig)
+void MmsPluginHttpAgent::clearSession()
{
- int trId;
-
- MSG_DEBUG("HttpCmd Get Transaction");
- MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_GET_TRANSACTION");
-
- char deviceName[1024] = {0,};
- MmsPluginCmAgent::instance()->getDeviceName(deviceName);
- MSG_DEBUG("deviceName: [%s]", deviceName);
+ MSG_BEGIN();
- int curl_status = curl_easy_setopt(httpConfig->session, CURLOPT_INTERFACE, deviceName);
- if (curl_status != CURLM_OK) {
- MSG_DEBUG("curl_easy_setopt(): CURLOPT_INTERFACE failed");
+ this->transaction_type = MMS_HTTP_TRANSACTION_TYPE_UNKNOWN;
- return eMMS_EXCEPTIONAL_ERROR;
+ if (session_header) {
+ MSG_DEBUG("session header is exist : free session header");
+ curl_slist_free_all((curl_slist *)session_header);
+ session_header = NULL;
}
- CURLcode rc = curl_easy_perform(httpConfig->session);
-
- __http_print_profile(httpConfig->session);
-
- MmsPluginHttpAgent* httpAgent = MmsPluginHttpAgent::instance();
- MMS_PLUGIN_HTTP_DATA_S *httpConfigData = httpAgent->getHttpConfigData();
- if (httpConfigData->sessionHeader) {
- curl_slist_free_all((curl_slist *)httpConfigData->sessionHeader);
- httpConfigData->sessionHeader = NULL;
+ if (session_option) {
+ MSG_DEBUG("session is exist : cleanup session");
+ curl_easy_cleanup(session_option);
+ session_option = NULL;
}
- if (CURLE_OK != rc) {
- MSG_DEBUG("curl_easy_perform return error = %d", rc);
-
- return eMMS_HTTP_ERROR_NETWORK;
+ if (respfile) {
+ fclose(respfile);
+ respfile = NULL;
}
- MSG_DEBUG("## End Transaction ##");
-
- srandom((unsigned int) time(NULL));
- trId = random() % 1000000000 + 1;
- MSG_DEBUG("############ trID = %d ###########", trId);
-
- httpConfig->transactionId = trId;
-
- return eMMS_HTTP_SENT_SUCCESS;
+ initAbortFlag();
+ MSG_END();
}
-MmsPluginHttpAgent *MmsPluginHttpAgent::pInstance = NULL;
-MmsPluginHttpAgent *MmsPluginHttpAgent::instance()
+MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_info)
{
- if (!pInstance)
- pInstance = new MmsPluginHttpAgent();
-
- return pInstance;
-}
-
+ MSG_BEGIN();
+ MMS_HTTP_ERROR_E http_error = MMS_HTTP_ERROR_NONE;
+ int content_len = 0;
+ char *url = NULL;
-MmsPluginHttpAgent::MmsPluginHttpAgent()
-{
- MSG_DEBUG("MmsPluginHttpAgent()");
+ // Verify request info
+ if (request_info.transaction_type != MMS_HTTP_TRANSACTION_TYPE_GET
+ && request_info.transaction_type != MMS_HTTP_TRANSACTION_TYPE_POST)
+ {
+ MSG_ERR("transaction_type of request_info is Invaild [%d]", request_info.transaction_type);
+ goto __CATCH;
+ }
- bzero(&httpConfigData, sizeof(httpConfigData));
- bzero(&mmsPlgCd, sizeof(mmsPlgCd));
+ if (request_info.transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) {
- httpCmdHandler.clear();
+ if (request_info.post_data == NULL || request_info.post_data_len == 0) {
+ MSG_ERR("post data info is Invaild");
+ goto __CATCH;
+ }
+ }
- httpCmdHandler[eHTTP_CMD_INIT_SESSION] = &__httpCmdInitSession;
- httpCmdHandler[eHTTP_CMD_POST_TRANSACTION] = &__httpCmdPostTransaction;
- httpCmdHandler[eHTTP_CMD_GET_TRANSACTION] = &__httpCmdGetTransaction;
-}
+ if (request_info.url == NULL || request_info.proxy == NULL || request_info.interface == NULL) {
+ MSG_ERR("request_info parameter invalid url [%s], proxy [%s] interface [%s]", request_info.url, request_info.proxy, request_info.interface);
+ goto __CATCH;
+ }
-MmsPluginHttpAgent::~MmsPluginHttpAgent()
-{
+ //Set type
+ this->transaction_type = request_info.transaction_type;
+ MSG_DEBUG("set transaction type [%d]", this->transaction_type);
-}
+ //Set http Headers
+ if (this->transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) {
+ content_len = request_info.post_data_len;
+ } else { //MMS_HTTP_TRANSACTION_TYPE_GET
+ content_len = 0;
+ }
-void MmsPluginHttpAgent::SetMMSProfile()
-{
- MSG_BEGIN();
+ url = strdup(request_info.url);
- MMSC_CONFIG_DATA_S *mmscConfig = &(httpConfigData.mmscConfig);
+ if (url) {
+ __httpAllocHeaderInfo((curl_slist**)&session_header, url, content_len);
+ if (session_header == NULL) {
+ MSG_ERR("Failed to __httpAllocHeaderInfo");
+ goto __CATCH;
+ }
- MmsPluginCmAgent::instance()->getHomeURL(mmscConfig->mmscUrl);
- if (strlen(mmscConfig->mmscUrl) < 1) {
- MSG_DEBUG("##### get Home URL Error");
+ free(url);
+ url = NULL;
+ } else {
+ MSG_ERR("Failed to strdup");
+ goto __CATCH;
}
- MmsPluginCmAgent::instance()->getProxyAddr(mmscConfig->httpProxyIpAddr);
- mmscConfig->proxyPortNo = MmsPluginCmAgent::instance()->getProxyPort();
- MSG_END();
-}
+ //Set curl option
+ session_option = curl_easy_init();
+ if (session_option == NULL) {
+ MSG_DEBUG("curl_easy_init() failed");
+ goto __CATCH;
+ }
-int MmsPluginHttpAgent::cmdRequest(MMS_HTTP_CMD_TYPE_T cmdType)
-{
- MSG_DEBUG("cmdRequest:%x", cmdType);
+ curl_easy_setopt(session_option, CURLOPT_PROXY, request_info.proxy);
+ curl_easy_setopt(session_option, CURLOPT_VERBOSE, true);
+ curl_easy_setopt(session_option, CURLOPT_URL, request_info.url);
+ curl_easy_setopt(session_option, CURLOPT_NOPROGRESS, true);
+ curl_easy_setopt(session_option, CURLOPT_HTTPHEADER, session_header);
+ curl_easy_setopt(session_option, CURLOPT_DEBUGFUNCTION , __http_debug_cb);
+ curl_easy_setopt(session_option, CURLOPT_INTERFACE, request_info.interface);
+ //curl_easy_setopt(httpConfigData.session, CURLOPT_PROGRESSFUNCTION, __http_progress_cb); //for debug
+
+ if (respfile) {
+ curl_easy_setopt(session_option, CURLOPT_WRITEFUNCTION, __http_write_response_cb);
+ curl_easy_setopt(session_option, CURLOPT_WRITEDATA, respfile);
+ }
- int ret = 0;
+ if (transaction_type == MMS_HTTP_TRANSACTION_TYPE_POST) {
+ curl_easy_setopt(session_option, CURLOPT_POST, true);
+ curl_easy_setopt(session_option, CURLOPT_POSTFIELDS, request_info.post_data);
+ curl_easy_setopt(session_option, CURLOPT_POSTFIELDSIZE, request_info.post_data_len);
+ // curl_easy_setopt(session_option, CURLOPT_TCP_NODELAY, 1);
+ }
- ret = httpCmdHandler[cmdType](&httpConfigData);
+ MSG_END();
+ return http_error;
- return ret;
-}
+__CATCH:
-MMS_PLUGIN_HTTP_CONTEXT_S* MmsPluginHttpAgent::getMmsPldCd()
-{
- return &mmsPlgCd;
-}
+ clearSession();
-MMS_PLUGIN_HTTP_DATA_S *MmsPluginHttpAgent::getHttpConfigData()
-{
- return &httpConfigData;
+ MSG_END();
+ return http_error;
}
-int MmsPluginHttpAgent::setSession(mmsTranQEntity *qEntity)
+MMS_HTTP_ERROR_E MmsPluginHttpAgent::startTransaction()
{
- MSG_DEBUG("%s %d", qEntity->pPostData, qEntity->postDataLen);
+ MSG_BEGIN();
+ MMS_HTTP_ERROR_E http_error = MMS_HTTP_ERROR_NONE;
- if (qEntity->eHttpCmdType == eHTTP_CMD_POST_TRANSACTION) {
- MSG_DEBUG("HttpCmd Post Transaction");
- MSG_DEBUG(" === HTTP Agent Thread : Signal ==> eMMS_HTTP_SIGNAL_POST_TRANSACTION");
+ int rc = __http_multi_perform(session_option);
- curl_slist *responseHeaders = NULL;
+ __http_print_profile(session_option);
- __httpAllocHeaderInfo(&responseHeaders, httpConfigData.mmscConfig.mmscUrl, qEntity->postDataLen);
+ if (rc != 0) {
+ MSG_DEBUG("curl_easy_perform return error rc [%d]", rc);
+ http_error = MMS_HTTP_ERROR_TRANSACTION;
+ }
- MSG_DEBUG(" === MMSCURI = %s === ", httpConfigData.mmscConfig.mmscUrl);
+ MSG_END();
+ return http_error;
+}
- httpConfigData.sessionHeader = (void *)responseHeaders;
+MMS_HTTP_ERROR_E MmsPluginHttpAgent::httpRequest(http_request_info_s &request_info)
+{
+ MSG_BEGIN();
- MSG_DEBUG("## Start Transaction : Post ##");
- curl_easy_setopt(httpConfigData.session, CURLOPT_VERBOSE, true);
- curl_easy_setopt(httpConfigData.session, CURLOPT_POST, true);
- curl_easy_setopt(httpConfigData.session, CURLOPT_URL, httpConfigData.mmscConfig.mmscUrl);
- curl_easy_setopt(httpConfigData.session, CURLOPT_NOPROGRESS, true);
- curl_easy_setopt(httpConfigData.session, CURLOPT_HTTPHEADER, responseHeaders);
- curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDS, qEntity->pPostData);
- curl_easy_setopt(httpConfigData.session, CURLOPT_POSTFIELDSIZE, qEntity->postDataLen);
- curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, __httpPostTransactionCB);
- curl_easy_setopt(httpConfigData.session, CURLOPT_TCP_NODELAY, 1);
+ const char *conf_filename = MSG_DATA_PATH"mms.conf";
- } else if (qEntity->eHttpCmdType == eHTTP_CMD_GET_TRANSACTION) {
- MSG_DEBUG("MmsHttpInitTransactionGet %d pGetData (%s)", qEntity->getDataLen, qEntity->pGetData);
- MSG_DEBUG("MmsHttpInitTransactionGet mmscURL (%s) ", httpConfigData.mmscConfig.mmscUrl);
+ MMS_HTTP_ERROR_E http_error = MMS_HTTP_ERROR_NONE;
- char szUrl[MAX_MMSC_URL_LEN] = {0, };
+ this->initSession();
- memcpy(szUrl, qEntity->pGetData, qEntity->getDataLen);
+ respfile = fopen(conf_filename, "wb");
- MSG_DEBUG("MmsHttpInitTransactionGet szURL (%s)", szUrl);
+ //set session
+ http_error = this->setSession(request_info);
+ if (http_error != MMS_HTTP_ERROR_NONE) {
+ MSG_DEBUG("Fail to setSession");
+ goto __CATCH;
+ }
- curl_slist *responseHeaders = NULL;
+ //transaction
+ http_error = this->startTransaction();
+ if (http_error != MMS_HTTP_ERROR_NONE) {
+ MSG_DEBUG("Fail to startTransaction");
+ goto __CATCH;
+ }
- __httpAllocHeaderInfo(&responseHeaders, szUrl, 0);
+ //close conf file & load response data
+ if (respfile) {
- httpConfigData.sessionHeader = (void *)responseHeaders;
+ fclose(respfile);
+ respfile = NULL;
- MSG_DEBUG("## Start Transaction : Get ##");
- curl_easy_setopt(httpConfigData.session, CURLOPT_VERBOSE, true);
- curl_easy_setopt(httpConfigData.session, CURLOPT_URL, szUrl);
- curl_easy_setopt(httpConfigData.session, CURLOPT_NOPROGRESS, true);
- curl_easy_setopt(httpConfigData.session, CURLOPT_HTTPHEADER, responseHeaders);
- curl_easy_setopt(httpConfigData.session, CURLOPT_WRITEFUNCTION, __httpGetTransactionCB);
- } else {
- MSG_DEBUG("Unknown eHttpCmdType [%d]", qEntity->eHttpCmdType);
- return -1;
+ if (g_file_get_contents(conf_filename, &request_info.response_data, &request_info.response_data_len, NULL) == false) {
+ MSG_DEBUG("Fail to g_file_get_contents");
+ }
}
- return 0;
-}
-
+ this->clearSession();
-void MmsPluginHttpAgent::clearSession()
-{
- MSG_BEGIN();
+ MSG_END();
+ return http_error;
- if (httpConfigData.sessionHeader) {
- curl_slist_free_all((curl_slist *)httpConfigData.sessionHeader);
- httpConfigData.sessionHeader = NULL;
- }
+__CATCH:
- if (httpConfigData.session == NULL) {
- MSG_DEBUG("[Error]httpConfigData.session is NULL");
- return;
+ if (respfile) {
+ fclose(respfile);
+ respfile = NULL;
}
- curl_easy_cleanup(httpConfigData.session);
-
- httpConfigData.session = NULL;
+ this->clearSession();
MSG_END();
+ return http_error;
}
diff --git a/plugin/mms_plugin/MmsPluginMain.cpp b/plugin/mms_plugin/MmsPluginMain.cpp
index 40d0afe..ead9151 100755
--- a/plugin/mms_plugin/MmsPluginMain.cpp
+++ b/plugin/mms_plugin/MmsPluginMain.cpp
@@ -140,7 +140,7 @@ msg_error_t MmsAddMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p
return MSG_ERR_PLUGIN_TRANSPORT;
}
- MSG_END();
+ //MSG_END();
return MSG_SUCCESS;
}
diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp
index e6f2c76..17b223d 100755
--- a/plugin/mms_plugin/MmsPluginMessage.cpp
+++ b/plugin/mms_plugin/MmsPluginMessage.cpp
@@ -647,7 +647,7 @@ bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDIN
//setting adddress
MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo);
- MmsGetMsgBodyfromMsgInfo(pMsgInfo, pMsgData, pFileData);
+ //MmsGetMsgBodyfromMsgInfo(pMsgInfo, pMsgData, pFileData);
int pageCnt = _MsgMmsGetPageCount(pMsgData);
@@ -1539,16 +1539,23 @@ bool MmsComposeSendReq(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDIN
for (int j = 0; j < mediaCnt; ++j) {
MMS_MEDIA_S *pMedia = _MsgMmsGetMedia(pPage, j);
if (pMedia->szFilePath[0] != 0) {
- MMS_MULTIPART_DATA_S pMultipart;
- bzero(&pMultipart, sizeof(MMS_MULTIPART_DATA_S));
- snprintf(pMultipart.szContentID, sizeof(pMultipart.szContentID), "%s", pMedia->szContentID);
- snprintf(pMultipart.szContentLocation, sizeof(pMultipart.szContentLocation), "%s", pMedia->szContentLocation);
- snprintf(pMultipart.szFileName, sizeof(pMultipart.szFileName), "%s", pMedia->szFileName);
- snprintf(pMultipart.szFilePath, sizeof(pMultipart.szFilePath), "%s", pMedia->szFilePath);
- snprintf(pMultipart.szContentType, sizeof(pMultipart.szContentType), "%s", pMedia->szContentType);
-
- if (!MmsInsertPartFromMultipart(pMmsMsg, &pMultipart))
- return false;
+ MMS_MULTIPART_DATA_S *pMultipart = (MMS_MULTIPART_DATA_S *)calloc(1, sizeof(MMS_MULTIPART_DATA_S));
+ if (pMultipart) {
+ snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMedia->szContentID);
+ snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMedia->szContentLocation);
+ snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMedia->szFileName);
+ snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", pMedia->szFilePath);
+ snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pMedia->szContentType);
+
+ if (!MmsInsertPartFromMultipart(pMmsMsg, pMultipart)) {
+ free(pMultipart);
+ pMultipart = NULL;
+ return false;
+ }
+
+ free(pMultipart);
+ pMultipart = NULL;
+ }
}
}
}
@@ -1558,16 +1565,23 @@ bool MmsComposeSendReq(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDIN
for (int i = 0; i < _MsgMmsGetAttachCount(pMsgData); ++i) {
MMS_ATTACH_S *pMedia = _MsgMmsGetAttachment(pMsgData, i);
if (pMedia->szFilePath[0] != 0) {
- MMS_MULTIPART_DATA_S pMultipart;
- bzero(&pMultipart, sizeof(MMS_MULTIPART_DATA_S));
- snprintf(pMultipart.szContentID, sizeof(pMultipart.szContentID), "%s", pMedia->szFileName);
- snprintf(pMultipart.szContentLocation, sizeof(pMultipart.szContentLocation), "%s", pMedia->szFileName);
- snprintf(pMultipart.szFileName, sizeof(pMultipart.szFileName), "%s", pMedia->szFileName);
- snprintf(pMultipart.szFilePath, sizeof(pMultipart.szFilePath), "%s", pMedia->szFilePath);
- snprintf(pMultipart.szContentType, sizeof(pMultipart.szContentType), "%s", pMedia->szContentType);
-
- if (!MmsInsertPartFromMultipart(pMmsMsg, &pMultipart))
- return false;
+ MMS_MULTIPART_DATA_S *pMultipart = (MMS_MULTIPART_DATA_S *)calloc(1, sizeof(MMS_MULTIPART_DATA_S));
+ if (pMultipart) {
+ snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMedia->szFileName);
+ snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMedia->szFileName);
+ snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMedia->szFileName);
+ snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", pMedia->szFilePath);
+ snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", pMedia->szContentType);
+
+ if (!MmsInsertPartFromMultipart(pMmsMsg, pMultipart)) {
+ free(pMultipart);
+ pMultipart = NULL;
+ return false;
+ }
+
+ free(pMultipart);
+ pMultipart = NULL;
+ }
}
}
diff --git a/plugin/mms_plugin/MmsPluginStorage.cpp b/plugin/mms_plugin/MmsPluginStorage.cpp
index 91950ca..a439b85 100755
--- a/plugin/mms_plugin/MmsPluginStorage.cpp
+++ b/plugin/mms_plugin/MmsPluginStorage.cpp
@@ -29,6 +29,12 @@
#include "MmsPluginDrm.h"
#include "MmsPluginMIME.h"
+#define MMS_FREE(obj)\
+ if (obj){\
+ free(obj);\
+ obj = NULL;\
+ }
+
/*==================================================================================================
IMPLEMENTATION OF SmsPluginStorage - Member Functions
==================================================================================================*/
@@ -63,314 +69,6 @@ void MmsPluginStorage::getMmsMessage(MmsMsg **pMmsMsg)
*pMmsMsg = &mmsMsg;
}
-#if 0 //Unused code
-void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
-{
- MSG_BEGIN();
-
- msg_error_t err;
-
- MmsMsg mmsMsg;
-
- bzero(&mmsMsg, sizeof(mmsMsg));
-
- mode_t file_mode = (S_IRUSR | S_IWUSR);
-
- if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) {
-
- char szTemp[MAX_MSG_DATA_LEN + 1];
-
- MMS_MESSAGE_DATA_S mmsMsgData;
- bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S));
- if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
-
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error");
- }
-
- MmsPrintFileInfoForVLD(&mmsMsgData);
-
- char fileName[MSG_FILENAME_LEN_MAX+1] = {0,};
-
- FILE *pFile = NULL;
-
- strcpy(szTemp,pMsgInfo->msgData);
-
- snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
-
- if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
- }
-
- strcpy((char *)pMsgInfo->msgData,szTemp);
-
- snprintf(fileName, MSG_FILENAME_LEN_MAX+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
-
- pFile = MsgOpenMMSFile(fileName);
- if (!pFile) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- THROW(MsgException::MMS_PLG_ERROR, "MMS File open Error");
- }
-
- if (fchmod(fileno(pFile), file_mode) < 0) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- MsgCloseFile(pFile);
-
- THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
- }
-
- if (MmsEncodeSendReq(pFile, &mmsMsg) != true) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- MsgCloseFile(pFile);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error");
- }
-
- MsgFsync(pFile); //file is written to device immediately, it prevents missing file data from unexpected power off
- MsgCloseFile(pFile);
-
- char filepath[MSG_FILEPATH_LEN_MAX+1] = {0,};
- int size = 0;
-
- snprintf((char *)filepath, MSG_FILEPATH_LEN_MAX+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
- if (MsgGetFileSize(filepath, &size) == false) {
- THROW(MsgException::MMS_PLG_ERROR, "MMS Message MsgGetFileSize Error");
- }
-
- pMsgInfo->dataSize = size;
-
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
-
- } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
- MSG_DEBUG("######## MmsPlgAddMessage -> MSG_NOTIFICATIONIND_MMS ###########");
-
- MmsComposeNotiMessage(&mmsMsg, pMsgInfo->msgId);
-
- //Need to store mms specific data (contents location, TrID, ExpiryTime, Delivery Report, message ID)
- if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
- }
- } else if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS) {
- MmsMsg *pMsg = NULL;
- char szTemp[MAX_MSG_DATA_LEN + 1]= {0, };
-
- if (!MmsReadMsgBody(pMsgInfo->msgId, true, true, pFileData))
- THROW(MsgException::MMS_PLG_ERROR, "_MmsReadMsgBody Error");
-
- MmsPluginStorage::instance()->getMmsMessage(&pMsg);
-
- if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS)
- pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
- else
- pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
- strcpy(szTemp,pMsgInfo->msgData);
- memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
- strncpy(pMsgInfo->msgData, pFileData, MAX_MSG_DATA_LEN);
-
- MmsPluginStorage *pStorage = MmsPluginStorage::instance();
-
- MMS_MESSAGE_DATA_S mmsMsgData;
- bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S));
- if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
- char *pSmilDoc;
- char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
-
- mmsMsgData.regionCnt = 0;
- mmsMsgData.pageCnt = 0;
- mmsMsgData.attachCnt = 0;
- mmsMsgData.transitionCnt = 0;
- mmsMsgData.metaCnt = 0;
- memset(mmsMsgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
-
- pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
- if (pSmilDoc) {
- MmsSmilParseSmilDoc(&mmsMsgData, pSmilDoc);
-
- MmsPluginStorage::instance()->getMmsMessage(&pMsg);
- strcpy(szFileName, pMsg->szFileName);
-
- err = pStorage->getMsgText(&mmsMsgData, pMsgInfo->msgText);
- MmsMakePreviewInfo(pMsgInfo->msgId, &mmsMsgData);
- }
-
- MsgMmsReleaseMmsLists(&mmsMsgData);
- }
-
- if (addMmsMsgToDB(pMsg, pMsgInfo) != MSG_SUCCESS) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
- }
- memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
- strcpy((char *)pMsgInfo->msgData,szTemp);
-
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
-
- } else if (pMsgInfo->msgType.subType == MSG_READREPLY_MMS || pMsgInfo->msgType.subType == MSG_READRECIND_MMS) {
- MSG_DEBUG("######## MmsPlgAddMessage -> MSG_READREPLY_MMS || MSG_READRECIND_MMS ###########");
-
- char filePath[MAX_FULL_PATH_SIZE+1] = {0, };
- FILE *pFile = NULL;
-
- msg_read_report_status_t readStatus;
- msg_message_id_t selectedMsgId;
- int version;
-
- memcpy(&readStatus, pMsgInfo->msgData, sizeof(msg_read_report_status_t));
- memcpy(&selectedMsgId, pMsgInfo->msgData + sizeof(msg_read_report_status_t), sizeof(msg_message_id_t));
-
- version = MmsPluginStorage::instance()->getMmsVersion(selectedMsgId);
-
- snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
-
- MmsComposeReadReportMessage(&mmsMsg, pMsgInfo, selectedMsgId);
-
- if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
- }
-
- snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
- pFile = MsgOpenMMSFile(filePath);
- if (!pFile) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile error");
- }
-
- if (fchmod(fileno(pFile), file_mode) < 0) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
- }
-
- if (version == 0x90) {
- MSG_DEBUG("### version 1.0 ###");
- if (MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.0 Error");
- }
- } else {
- MSG_DEBUG("### version 1.1 ###");
- if (MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.1 Error");
- }
- }
-
- MsgFsync(pFile);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
-
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
-
- } else if (pMsgInfo->msgType.subType == MSG_FORWARD_MMS) {
- MSG_DEBUG("######## MmsPlgAddMessage -> MSG_FORWARD_MMS ###########");
-
- char filePath[MAX_FULL_PATH_SIZE + 1] = {0, };
- char szTemp[MAX_MSG_DATA_LEN + 1] = {0, };
- FILE *pFile = NULL;
- MMS_MESSAGE_DATA_S mmsMsgData;
-
- if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error");
- }
-
- strcpy(szTemp,pMsgInfo->msgData);
-
- snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN + 1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
-
- if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
- }
-
- strcpy((char *)pMsgInfo->msgData,szTemp);
-
- snprintf(filePath, MAX_FULL_PATH_SIZE + 1 , MSG_DATA_PATH"%d", mmsMsg.msgID);
-
- pFile = MsgOpenMMSFile(filePath);
- if (!pFile) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile error");
- }
-
- if (fchmod(fileno(pFile), file_mode) < 0) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
- }
-
- if (MmsEncodeSendReq(pFile, &mmsMsg) != true) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error");
- }
- MsgFsync(pFile);
- MsgCloseFile(pFile);
- pFile = NULL;
-
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
- MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib);
- __MmsReleaseMmsLists(&mmsMsgData);
- }
-
- MSG_END();
-}
-#endif
-
void MmsPluginStorage::composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
{
FILE *pFile = NULL;
@@ -469,205 +167,6 @@ msg_error_t MmsPluginStorage::addMmsMsgToDB(MmsMsg *pMmsMsg, const char *raw_fil
return MSG_SUCCESS;
}
-#if 0
-msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char **pDestMsg)
-{
- MSG_BEGIN();
-
- msg_error_t err = MSG_SUCCESS;
- MMS_MESSAGE_DATA_S tempMmsMsg = {0,};
- MMS_MESSAGE_DATA_S *pMmsMsg = &tempMmsMsg;
- int partCnt = 0;
- size_t nSize = 0;
-
- MsgType partHeader;
- MmsAttrib pMmsAttrib;
-
- char szBuf[MSG_FILEPATH_LEN_MAX + 1] = {0, };
- bool bMultipartRelated = false;
-
- if (pSendOptInfo != NULL) {
- char sqlQuery[MAX_QUERY_LEN + 1];
-
- memset(sqlQuery, 0x00, sizeof(sqlQuery));
- snprintf(sqlQuery, sizeof(sqlQuery), "SELECT ASK_DELIVERY_REPORT, KEEP_COPY, ASK_READ_REPLY, PRIORITY, EXPIRY_TIME, CUSTOM_DELIVERY_TIME, DELIVERY_TIME \
- FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, pMsg->msgId);
-
- MSG_DEBUG("### SQLQuery = %s ###", sqlQuery);
-
- if (dbHandle.prepareQuery(sqlQuery) != MSG_SUCCESS)
- MSG_DEBUG("MSG_ERR_DB_PREPARE");
-
- if (dbHandle.stepQuery() == MSG_ERR_DB_ROW) {
- pSendOptInfo->bDeliverReq = dbHandle.columnInt(0);
- MSG_DEBUG("## delivery = %d ##", pSendOptInfo->bDeliverReq);
-
- pSendOptInfo->bKeepCopy = dbHandle.columnInt(1);
- MSG_DEBUG("## bKeepCopy = %d ##", pSendOptInfo->bKeepCopy);
-
- pSendOptInfo->option.mmsSendOptInfo.bReadReq = dbHandle.columnInt(2);
- MSG_DEBUG("## bReadReq = %d ##", pSendOptInfo->option.mmsSendOptInfo.bReadReq);
-
- pSendOptInfo->option.mmsSendOptInfo.priority = dbHandle.columnInt(3);
- MSG_DEBUG("## priority = %d ##", pSendOptInfo->option.mmsSendOptInfo.priority);
-
- pSendOptInfo->option.mmsSendOptInfo.expiryTime.time = (unsigned int)dbHandle.columnInt(4);
- MSG_DEBUG("## expiryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.expiryTime.time);
-
- pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime = (unsigned int)dbHandle.columnInt(5);
- MSG_DEBUG("## bUseDeliveryCustomTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.bUseDeliveryCustomTime);
-
- pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time = (unsigned int)dbHandle.columnInt(6);
- MSG_DEBUG("## deliveryTime = %d ##", pSendOptInfo->option.mmsSendOptInfo.deliveryTime.time);
- } else {
- dbHandle.finalizeQuery();
- return MSG_ERR_DB_STEP;
- }
-
- dbHandle.finalizeQuery();
- }
-
- if (MmsReadMsgBody(pMsg->msgId, true, false, NULL) == false) {
- MSG_DEBUG("The MMS Message might include drm contents!!!");
-
-#ifdef __SUPPORT_DRM__
- if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
- bool bRetToConvert = true;
-
- bRetToConvert = MmsDrm2ConvertMsgBody(mmsHeader.msgType.szOrgFilePath);
-
- MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
-
- if (bRetToConvert) {
- int ret;
- ret = remove(mmsHeader.msgType.szOrgFilePath);
- if (ret != 0) {
- MSG_DEBUG("remove fail\n");
- }
-
- ret = rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
- if (ret != 0) {
- MSG_DEBUG("rename fail\n");
- }
-
- if (MmsDrm2ReadMsgConvertedBody(pMsg, true, false, NULL) == false) {
- MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
- goto L_CATCH;
- }
- } else {
- goto L_CATCH;
- }
- }
-#endif
- }
-
- MmsGetMsgAttrib(pMsg->msgId, &pMmsAttrib);
-
- pMmsMsg->regionCnt = 0;
- pMmsMsg->pageCnt = 0;
- pMmsMsg->attachCnt = 0;
- pMmsMsg->transitionCnt = 0;
- pMmsMsg->metaCnt = 0;
- memset(pMmsMsg->szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
-
- if (pMmsAttrib.contentType == MIME_MULTIPART_RELATED || pMmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
- char *pSmilDoc = NULL;
-
- pSmilDoc = MmsSmilGetPresentationData(pMsg->msgId);
- if (!pSmilDoc) {
- goto L_CATCH;
- }
-
- MmsSmilParseSmilDoc(pMmsMsg, pSmilDoc);
- MmsRemovePims(pMmsMsg);
- bMultipartRelated = true;
- }
-
- partCnt = MmsGetMediaPartCount(pMsg->msgId);
- MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt);
-
- if (partCnt < 0) {
- MSG_DEBUG("MmsUiGetMediaAttachInfo: partCnt=%d\n", partCnt);
- goto FREE_CATCH;
- }
-
- for (int i = 0; i < partCnt; ++i) {
- if (!MmsGetMediaPartHeader(i, &partHeader)) {
- MSG_DEBUG("MmsUiGetMediaAttachInfo: MmsGetMediaPartHeader failed\n");
- goto FREE_CATCH;
- }
-
- if (partHeader.contentSize > 0) {
- if (!strcasecmp(partHeader.param.szFileName, "cid:")) {
- strncpy((char *)szBuf, &partHeader.param.szFileName[4], MSG_FILEPATH_LEN_MAX);
- } else {
- strncpy((char *)szBuf, partHeader.param.szFileName, MSG_FILEPATH_LEN_MAX);
- }
- sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf);
-
- if (!bMultipartRelated || MmsCheckAdditionalMedia(pMmsMsg, &partHeader)) {
-
- MMS_ATTACH_S *attachment = NULL;
- int tempType;
-
- attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1);
-
- MsgGetTypeByFileName(&tempType, partHeader.param.szFileName);
- attachment->mediatype = (MimeType)tempType;
-
- strcpy(attachment->szFilePath, partHeader.param.szFileName);
-
- strncpy(attachment->szFileName, partHeader.param.szName, MSG_FILENAME_LEN_MAX -1);
-
- attachment->fileSize = partHeader.contentSize;
-
- _MsgMmsAddAttachment(pMmsMsg, attachment);
- }
- }
- }
-
- *pDestMsg = _MsgMmsSerializeMessageData(pMmsMsg, &nSize);
-
- MsgMmsReleaseMmsLists(pMmsMsg);
-
-
- MmsMsg *pStoMmsMsg;
- MmsPluginStorage::instance()->getMmsMessage(&pStoMmsMsg);
- MmsInitHeader();
- MmsUnregisterDecodeBuffer();
-#ifdef __SUPPORT_DRM__
- MmsReleaseMsgDRMInfo(&pStoMmsMsg->msgType.drmInfo);
-#endif
- MmsReleaseMsgBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type);
-
- pMsg->dataSize = nSize;
- MSG_END();
-
- return err;
-
-FREE_CATCH:
- if (bMultipartRelated) {
- MsgMmsReleaseMmsLists(pMmsMsg);
- }
-
-L_CATCH:
- MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
- MSG_END();
- {
- MmsMsg *pMsg;
- MmsPluginStorage::instance()->getMmsMessage(&pMsg);
- MmsInitHeader();
-
- MmsUnregisterDecodeBuffer();
-#ifdef __SUPPORT_DRM__
- MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo);
-#endif
- MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type);
-
- return MSG_ERR_STORAGE_ERROR;
- }
-}
-#endif
msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData)
{
@@ -678,7 +177,7 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
MmsMsg mmsMsg;
MMS_MESSAGE_DATA_S mmsMsgData = {0,};
char raw_filepath[MSG_FILENAME_LEN_MAX+1] = {0,};
-
+ char raw_filedir[MSG_FILENAME_LEN_MAX+1] = {0,};
bzero(&mmsMsg, sizeof(mmsMsg));
memset(sqlQuery, 0x00, sizeof(sqlQuery));
@@ -690,6 +189,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
if (dbHandle.execQuery(sqlQuery) != MSG_SUCCESS)
return MSG_ERR_DB_EXEC;
+ MSG_DEBUG("msg sub type = [%d]", pMsgInfo->msgType.subType);
+
if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) {
if (_MsgMmsDeserializeMessageData(&mmsMsgData, pFileData) == false) {
@@ -715,6 +216,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
}
//preview data
+ MmsPluginStorage::instance()->removePreviewInfo(pMsgInfo->msgId); //remove exist previnfo
+
err = MmsMakePreviewInfo(pMsgInfo->msgId, &mmsMsgData);
err = getMsgText(&mmsMsgData, pMsgInfo->msgText);
@@ -725,6 +228,10 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
}
}
+ snprintf(raw_filedir, sizeof(raw_filedir), MSG_DATA_PATH"%d.mms.dir", pMsgInfo->msgId);
+ MsgRmRf(raw_filedir);
+ rmdir(raw_filedir);
+
int size = 0;
if (MsgGetFileSize(raw_filepath, &size) == false) {
@@ -734,6 +241,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
}
pMsgInfo->dataSize = size;
+
+ MmsReadMsgBody(pMsgInfo->msgId, true, false, NULL);
}
MmsReleaseMmsMsg(&mmsMsg);
@@ -1040,8 +549,6 @@ int MmsPluginStorage::getMmsVersion(msg_message_id_t selectedMsgId)
snprintf(sqlQuery, sizeof(sqlQuery), "SELECT VERSION FROM %s WHERE MSG_ID = %d;",
MMS_PLUGIN_MESSAGE_TABLE_NAME, selectedMsgId);
- MSG_DEBUG("SqlQuery = %s", sqlQuery);
-
err = dbHandle.getTable(sqlQuery, &rowCnt);
if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) {
@@ -1425,9 +932,8 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
msg_error_t err = MSG_SUCCESS;
MMS_MESSAGE_DATA_S tempMmsMsgData = {0,};
MMS_MESSAGE_DATA_S *pMmsMsg = &tempMmsMsgData;
-
- size_t nSize = 0;
- bool bMultipartRelated = false;
+
+ unsigned int nSize = 0;
bzero(pMmsMsg, sizeof(MMS_MESSAGE_DATA_S));
pMmsMsg->regionCnt = 0;
@@ -1526,13 +1032,7 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
return err;
FREE_CATCH:
- /*
- if (bMultipartRelated) {
- MsgMmsReleaseMmsLists(pMmsMsg);
- }
- */
-L_CATCH:
MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
MSG_END();
{
@@ -1555,21 +1055,31 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
MSG_BEGIN();
msg_error_t err;
+ MmsMsg *pMmsMsg = NULL;
+ MMS_MESSAGE_DATA_S *pMmsMsgData = NULL;
+
char raw_filepath[MSG_FILENAME_LEN_MAX+1] = {0,};
- MmsMsg mmsMsg;
- MMS_MESSAGE_DATA_S mmsMsgData;
- bzero(&mmsMsgData, sizeof(MMS_MESSAGE_DATA_S));
- bzero(&mmsMsg, sizeof(mmsMsg));
+ pMmsMsg = (MmsMsg *)calloc(1, sizeof(MmsMsg));
+ if (pMmsMsg == NULL) {
+ MSG_DEBUG("memory allocation error");
+ goto __CATCH;
+ }
+
+ pMmsMsgData = (MMS_MESSAGE_DATA_S *)calloc(1, sizeof(MMS_MESSAGE_DATA_S));
+ if (pMmsMsgData == NULL) {
+ MSG_DEBUG("memory allocation error");
+ goto __CATCH;
+ }
if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) {
- if (_MsgMmsDeserializeMessageData(&mmsMsgData, pFileData) == false) {
+ if (_MsgMmsDeserializeMessageData(pMmsMsgData, pFileData) == false) {
MSG_DEBUG("Fail to Deserialize Message Data");
goto __CATCH;
}
- if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
+ if (MmsComposeSendReq(pMmsMsg, pMsgInfo, pSendOptInfo, pMmsMsgData) != true) {
MSG_DEBUG("Fail to Compose Message");
goto __CATCH;
}
@@ -1578,23 +1088,23 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
snprintf(raw_filepath, sizeof(raw_filepath), MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
//encode mms
- if (MmsEncodeMmsMessage(&mmsMsg, raw_filepath) == false) {
+ if (MmsEncodeMmsMessage(pMmsMsg, raw_filepath) == false) {
MSG_DEBUG("Fail to Encode Message");
goto __CATCH;
}
//add to db
- if (addMmsMsgToDB(&mmsMsg, raw_filepath) != MSG_SUCCESS) {
+ if (addMmsMsgToDB(pMmsMsg, raw_filepath) != MSG_SUCCESS) {
MSG_DEBUG("Fail to add db message");
goto __CATCH;
}
//preview data
- err = MmsMakePreviewInfo(pMsgInfo->msgId, &mmsMsgData);
- err = getMsgText(&mmsMsgData, pMsgInfo->msgText);
+ err = MmsMakePreviewInfo(pMsgInfo->msgId, pMmsMsgData);
+ err = getMsgText(pMmsMsgData, pMsgInfo->msgText);
- if (mmsMsgData.attachCnt > 0) {
- if (updateMmsAttachCount(mmsMsg.msgID, mmsMsgData.attachCnt) != MSG_SUCCESS) {
+ if (pMmsMsgData->attachCnt > 0) {
+ if (updateMmsAttachCount(pMmsMsg->msgID, pMmsMsgData->attachCnt) != MSG_SUCCESS) {
MSG_DEBUG("Fail to updateMmsAttachCount");
goto __CATCH;
}
@@ -1605,22 +1115,27 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
goto __CATCH;
}
- MmsReleaseMmsMsg(&mmsMsg);
- MsgMmsReleaseMmsLists(&mmsMsgData);
+ MmsReleaseMmsMsg(pMmsMsg);
+ MMS_FREE(pMmsMsg);
+
+ MsgMmsReleaseMmsLists(pMmsMsgData);
+ MMS_FREE(pMmsMsgData);
+
} else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
- MmsComposeNotiMessage(&mmsMsg, pMsgInfo->msgId);
+ MmsComposeNotiMessage(pMmsMsg, pMsgInfo->msgId);
//add to db
- if (addMmsMsgToDB(&mmsMsg, "") != MSG_SUCCESS) {
+ if (addMmsMsgToDB(pMmsMsg, "") != MSG_SUCCESS) {
MSG_DEBUG("Fail to add db message");
goto __CATCH;
}
- MmsReleaseMmsMsg(&mmsMsg);
+ MmsReleaseMmsMsg(pMmsMsg);
+ MMS_FREE(pMmsMsg);
} else if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS) {
+
MmsMsg *pMsg = NULL;
- char szTemp[MAX_MSG_DATA_LEN + 1]= {0, };
if (!MmsReadMsgBody(pMsgInfo->msgId, true, true, pFileData))
THROW(MsgException::MMS_PLG_ERROR, "_MmsReadMsgBody Error");
@@ -1631,62 +1146,55 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS;
else
pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS;
- strcpy(szTemp,pMsgInfo->msgData);
- memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
- strncpy(pMsgInfo->msgData, pFileData, MAX_MSG_DATA_LEN);
-
- MmsPluginStorage *pStorage = MmsPluginStorage::instance();
-
- MMS_MESSAGE_DATA_S mmsMsgData;
- bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S));
- if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
- char *pSmilDoc;
- char szFileName[MSG_FILENAME_LEN_MAX] = {0, };
-
- mmsMsgData.regionCnt = 0;
- mmsMsgData.pageCnt = 0;
- mmsMsgData.attachCnt = 0;
- mmsMsgData.transitionCnt = 0;
- mmsMsgData.metaCnt = 0;
- memset(mmsMsgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX);
-
- pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId);
- if (pSmilDoc) {
- MmsSmilParseSmilDoc(&mmsMsgData, pSmilDoc);
-
- MmsPluginStorage::instance()->getMmsMessage(&pMsg);
- strcpy(szFileName, pMsg->szFileName);
-
- err = pStorage->getMsgText(&mmsMsgData, pMsgInfo->msgText);
- MmsMakePreviewInfo(pMsgInfo->msgId, &mmsMsgData);
+
+
+ {//preview data
+ MMS_MESSAGE_DATA_S tempMmsMsgData = {0,};
+ if (MmsMakeMmsData(pMsg, &tempMmsMsgData) == false) {
+ MSG_DEBUG("Fail to makeMmsMessageData");
+ } else {
+ err = MmsMakePreviewInfo(pMsgInfo->msgId, &tempMmsMsgData);
+ err = getMsgText(&tempMmsMsgData, pMsgInfo->msgText);
}
- MsgMmsReleaseMmsLists(&mmsMsgData);
- }
+ if (tempMmsMsgData.attachCnt > 0) {
+ if (updateMmsAttachCount(pMsg->msgID, tempMmsMsgData.attachCnt) != MSG_SUCCESS) {
+ MSG_DEBUG("Fail to updateMmsAttachCount");
+ goto __CATCH;
+ }
+ }
+
+ MsgMmsReleaseMmsLists(&tempMmsMsgData);
+ }//end preview data
- if (addMmsMsgToDB(pMsg, pMsgInfo) != MSG_SUCCESS) {
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+ if (addMmsMsgToDB(pMsg, pFileData) != MSG_SUCCESS) {
+ MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type);
THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
}
- memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1);
- strcpy((char *)pMsgInfo->msgData,szTemp);
-
- MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+ MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type);
} else {
MSG_DEBUG("Not support msg sub type [%d]", pMsgInfo->msgType.subType);
goto __CATCH;
}
+ MmsReleaseMmsMsg(pMmsMsg);
+ MsgMmsReleaseMmsLists(pMmsMsgData);
+ MMS_FREE(pMmsMsg);
+ MMS_FREE(pMmsMsgData);
+
MSG_END();
return;
__CATCH:
removePreviewInfo(pMsgInfo->msgId);
- MmsReleaseMmsMsg(&mmsMsg);
- MsgMmsReleaseMmsLists(&mmsMsgData);
+
+ MmsReleaseMmsMsg(pMmsMsg);
+ MsgMmsReleaseMmsLists(pMmsMsgData);
+ MMS_FREE(pMmsMsg);
+ MMS_FREE(pMmsMsgData);
THROW(MsgException::MMS_PLG_ERROR, "MMS add Error");
}
diff --git a/plugin/mms_plugin/MmsPluginUserAgent.cpp b/plugin/mms_plugin/MmsPluginUserAgent.cpp
index 851c843..5ef83ef 100755
--- a/plugin/mms_plugin/MmsPluginUserAgent.cpp
+++ b/plugin/mms_plugin/MmsPluginUserAgent.cpp
@@ -30,8 +30,7 @@
#include "MmsPluginCodec.h"
#include "MmsPluginDrm.h"
#include "MmsPluginStorage.h"
-
-extern MmsHeader mmsHeader;
+#include "MmsPluginUtil.h"
void PRINT_PDU_TYPE(MMS_PDU_TYPE_T pduType)
{
@@ -183,6 +182,18 @@ void updatePduType(mmsTranQEntity *qEntity)
PRINT_PDU_TYPE(qEntity->eMmsPduType);
}
+bool compare_func(mmsTranQEntity const &a, mmsTranQEntity const &b)
+{
+ if (a.msgId == b.msgId) {
+ if ((a.eMmsPduType == eMMS_RETRIEVE_MANUAL || a.eMmsPduType == eMMS_RETRIEVE_AUTO)
+ &&(b.eMmsPduType == eMMS_RETRIEVE_MANUAL || b.eMmsPduType == eMMS_RETRIEVE_AUTO)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
MmsPluginUaManager *MmsPluginUaManager::pInstance = NULL;
MmsPluginUaManager::MmsPluginUaManager()
@@ -231,12 +242,65 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
MmsPluginHttpAgent* httpAgent = MmsPluginHttpAgent::instance();
+ http_request_info_s request_info = {};
+
+ char *http_url = NULL;
+
+ memset(&request_info, 0x00, sizeof(request_info));
+
+ const char *home_url = NULL;
+ const char *proxy_addr = NULL;
+ const char *interfaceName = NULL;
+
+ MmsPluginCmAgent::instance()->getProxyAddr(&proxy_addr);
+ MmsPluginCmAgent::instance()->getInterfaceName(&interfaceName);
+ MmsPluginCmAgent::instance()->getHomeUrl(&home_url);
+
+ if (qEntity->eHttpCmdType == eHTTP_CMD_POST_TRANSACTION) {
+
+ request_info.transaction_type = MMS_HTTP_TRANSACTION_TYPE_POST;
+
+ request_info.url = home_url;
+
+ request_info.proxy = proxy_addr;
+
+ request_info.interface = interfaceName;
+
+ request_info.post_data = qEntity->pPostData;
+
+ request_info.post_data_len = qEntity->postDataLen;
+
+ } else {
+ request_info.transaction_type = MMS_HTTP_TRANSACTION_TYPE_GET;
+
+ http_url = (char *)calloc(1, qEntity->getDataLen + 1);
+
+ memcpy(http_url, qEntity->pGetData, qEntity->getDataLen);
+
+ request_info.url = http_url;
+
+ request_info.proxy = proxy_addr;
+
+ request_info.interface = interfaceName;
+ }
+
+
while (retryCount < RETRY_MAX) {
- ret = httpAgent->cmdRequest(qEntity->eHttpCmdType);
+
+ ret = httpAgent->httpRequest(request_info);
// Process result
- if (ret == eMMS_HTTP_SENT_SUCCESS) {
+ if (ret == MMS_HTTP_ERROR_NONE) {
MSG_DEBUG("Submit request sent");
+
+ if (qEntity->pGetData) {
+ free(qEntity->pGetData);
+ qEntity->pGetData = NULL;
+ }
+
+ qEntity->pGetData = request_info.response_data;
+ qEntity->getDataLen = request_info.response_data_len;
+
break;
} else if (ret == eMMS_HTTP_ERROR_NETWORK) {
retryCount++;
@@ -248,34 +312,15 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity)
}
}
+ if (http_url)
+ free(http_url);
+
return ret;
}
MMS_NET_ERROR_T MmsPluginUaManager::waitingConf(mmsTranQEntity *qEntity)
{
- MMS_NET_ERROR_T ret = eMMS_HTTP_ERROR_UNKNOWN;
- MmsPluginHttpAgent *pHttpAgent = MmsPluginHttpAgent::instance();
- MMS_PLUGIN_HTTP_CONTEXT_S *pMmsPldCd = NULL;
-
- pMmsPldCd = pHttpAgent->getMmsPldCd();
-
- if (qEntity->pGetData) {
- free(qEntity->pGetData);
- qEntity->pGetData = NULL;
- }
- qEntity->getDataLen = pMmsPldCd->bufOffset;
- qEntity->pGetData = (char *)calloc(1, pMmsPldCd->bufOffset + 1);
-
- memcpy(qEntity->pGetData, pMmsPldCd->final_content_buf, pMmsPldCd->bufOffset);
- free(pMmsPldCd->final_content_buf);
- pMmsPldCd->final_content_buf = NULL;
- pMmsPldCd->bufOffset = 0;
-
- MSG_DEBUG("dataLen:%d pData:(%s)", qEntity->getDataLen, qEntity->pGetData);
-
- ret = eMMS_HTTP_CONF_SUCCESS;
-
- return ret;
+ return eMMS_HTTP_CONF_SUCCESS;
}
void MmsPluginUaManager::run()
@@ -283,10 +328,6 @@ void MmsPluginUaManager::run()
MSG_BEGIN();
MmsPluginCmAgent *cmAgent = MmsPluginCmAgent::instance();
- MmsPluginHttpAgent *httpAgent = MmsPluginHttpAgent::instance();
-
- int trId;
-// CURL *session = NULL;
int msgId;
@@ -362,8 +403,6 @@ void MmsPluginUaManager::run()
goto CLEANUP;
}
- httpAgent->SetMMSProfile();
-
while (!mmsTranQ.empty()) {
MSG_DEBUG("###### mmsTranQ.size [%d]", mmsTranQ.size());
@@ -382,21 +421,12 @@ void MmsPluginUaManager::run()
MmsPluginStorage::instance()->updateNetStatus(msgId, MSG_NETWORK_RETRIEVING);
}
- if (httpAgent->cmdRequest(eHTTP_CMD_INIT_SESSION) == eMMS_HTTP_SESSION_OPEN_FAILED) {
- MSG_DEBUG("HTTP session open failed");
- // cm close
- cmAgent->close();
- // delete all request from reqQEntities
- goto CLEANUP;
- }
-
// MMS Transaction
MSG_DEBUG("\n\n =================== MMS Transaction Start ========================");
do {
- httpAgent->setSession(&reqEntity);
- if (submitHandler(&reqEntity) != eMMS_HTTP_SENT_SUCCESS) {
+ if (submitHandler(&reqEntity) != MMS_HTTP_ERROR_NONE) {
MSG_DEBUG("Transaction Error: submit failed");
MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
@@ -406,7 +436,6 @@ void MmsPluginUaManager::run()
}
MSG_DEBUG("submitHandler(&reqEntity) success.");
- trId = httpAgent->getHttpConfigData()->transactionId;
MSG_DEBUG("#### MMS PDU TYPE = %d ####", reqEntity.eMmsPduType);
@@ -474,7 +503,7 @@ void MmsPluginUaManager::run()
break;
}
- MsgSettingGetBool(MMS_RECV_DELIVERY_RECEIPT, &bReportAllowed);
+ MsgSettingGetBool(MMS_SEND_REPORT_ALLOWED, &bReportAllowed);
MSG_DEBUG("conf received successfully -2");
MSG_DEBUG("reqEntity.eMmsPduType [%d]", reqEntity.eMmsPduType);
@@ -515,7 +544,9 @@ void MmsPluginUaManager::run()
mmsTranQ.push_front(reqEntity);
- remove(filepath);
+ if (remove(filepath) != 0) {
+ MSG_DEBUG("Error removing file");
+ }
MSG_DEBUG("Submit Ind");
} else if (reqEntity.eMmsPduType == eMMS_RETRIEVE_MANUAL_CONF) {
@@ -566,6 +597,7 @@ void MmsPluginUaManager::run()
MmsPluginEventHandler::instance()->handleMmsError(&reqEntity);
break;
}
+
} while (reqEntity.isCompleted == false);
MSG_DEBUG("==== MMS Transaction Completed ====\n\n");
@@ -580,8 +612,6 @@ void MmsPluginUaManager::run()
reqEntity.pGetData = NULL;
}
- // Http Session Close
- httpAgent->clearSession();
}
// Request CM Close
@@ -634,6 +664,11 @@ void MmsPluginUaManager::getMmsPduData(mmsTranQEntity *qEntity)
void MmsPluginUaManager::addMmsReqEntity(mmsTranQEntity req)
{
+ if (mmsTranQ.checkExist(req, compare_func) == true) {
+ MSG_DEBUG("request Already Exist, req_id = %d", req.msgId);
+ THROW(MsgException::REQ_EXIST_ERROR, "MMS request already exist");
+ }
+
MSG_DEBUG("New MMS Tran Added");
mmsTranQ.push_back(req);
lock();
@@ -667,39 +702,7 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
if (MmsReadMsgBody(msgId, true, true, retrievedFilePath) == false) {
MSG_DEBUG("The MMS Message might include drm contents!!!");
-
-#ifdef __SUPPORT_DRM__
- if (MmsDrm2GetConvertState() == MMS_DRM2_CONVERT_REQUIRED) {
- bool bRetToConvert = true;
- MSG_MESSAGE_INFO_S pMsg = {0, };
-
- pMsg.msgId = msgId;
-
- bRetToConvert = MmsDrm2ConvertMsgBody(mmsHeader.msgType.szOrgFilePath);
-
- MmsDrm2SetConvertState(MMS_DRM2_CONVERT_FINISH);
-
- if (bRetToConvert) {
- int ret;
- ret = remove(mmsHeader.msgType.szOrgFilePath);
- if (ret != 0) {
- MSG_DEBUG("remove fail\n");
- goto ERR_MMS_UA_PROCESS_CONF;
- }
-
- ret = rename(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, mmsHeader.msgType.szOrgFilePath);
- if (ret != 0) {
- MSG_DEBUG("rename fail\n");
- goto ERR_MMS_UA_PROCESS_CONF;
- }
-
- if (MmsDrm2ReadMsgConvertedBody(&pMsg, true, true, retrievedFilePath) == false) {
- MSG_DEBUG("MmsLoadMsg:MmsDrm2ReadMsgConvertedBody() returns false\n");
- goto ERR_MMS_UA_PROCESS_CONF;
- }
- }
- }
-#endif
+ goto ERR_MMS_UA_PROCESS_CONF;
}
MSG_END();
@@ -724,3 +727,4 @@ ERR_MMS_UA_PROCESS_CONF:
}
}
+
diff --git a/plugin/mms_plugin/include/MmsPluginConnManWrapper.h b/plugin/mms_plugin/include/MmsPluginConnManWrapper.h
index fb6a31a..eddbd69 100755
--- a/plugin/mms_plugin/include/MmsPluginConnManWrapper.h
+++ b/plugin/mms_plugin/include/MmsPluginConnManWrapper.h
@@ -20,6 +20,8 @@
#include <network-cm-intf.h>
#include <network-pm-intf.h>
#include "MsgMutex.h"
+#include <glib.h>
+#include "net_connection.h"
class MmsPluginCmAgent
{
@@ -32,36 +34,33 @@ public:
bool getCmStatus() { return isCmOpened; }
- void processCBdatas(net_event_info_t *event_cb, void *user_data);
-
- bool getDeviceName(char *deviceName);
- bool getHomeURL(char *homeURL);
- bool getProxyAddr(char *proxyAddr);
- int getProxyPort();
+ void open_callback(connection_error_e result, void* user_data);
+ void close_callback(connection_error_e result, void* user_data);
+ bool getInterfaceName(const char **deviceName);
+ bool getProxyAddr(const char **proxyAddr);
+ bool getHomeUrl(const char **homeURL);
private:
MmsPluginCmAgent();
~MmsPluginCmAgent();
static MmsPluginCmAgent *pInstance;
- /* register/deregister is called once at initialization/finalization of MMS plugin */
- bool registration();
- void deregistration();
-
-
void lock() { mx.lock(); }
void unlock() { mx.unlock(); }
void signal() { cv.signal(); }
void setCmStatus() { isCmOpened = true; }
void resetCmStatus() { isCmOpened = false; }
- // shared variable between CmAgent and Dnet callback
bool isCmOpened;
+ bool isCmRegistered;
+
+ char *home_url;
+ char *interface_name;
+ char *proxy_address;
Mutex mx;
CndVar cv;
- net_profile_info_t mmsProfile;
};
#endif //MMS_PLUGIN_CONNMAN_H
diff --git a/plugin/mms_plugin/include/MmsPluginDecode.h b/plugin/mms_plugin/include/MmsPluginDecode.h
index b150be6..36eda58 100755
--- a/plugin/mms_plugin/include/MmsPluginDecode.h
+++ b/plugin/mms_plugin/include/MmsPluginDecode.h
@@ -97,7 +97,7 @@ typedef struct {
MsgBody msgBody;
} MmsHeader;
-extern MmsHeader mmsHeader;
+extern __thread MmsHeader mmsHeader;
/* Decoding */
void MmsInitHeader();
diff --git a/plugin/mms_plugin/include/MmsPluginHttp.h b/plugin/mms_plugin/include/MmsPluginHttp.h
index ea3c9dd..d090de6 100755
--- a/plugin/mms_plugin/include/MmsPluginHttp.h
+++ b/plugin/mms_plugin/include/MmsPluginHttp.h
@@ -19,6 +19,7 @@
#include <map>
#include "MmsPluginTypes.h"
+#include "MsgMutex.h"
#define MSG_MMS_HH_CONTENT_TYPE "application/vnd.wap.mms-message"
#define MSG_MMS_HH_ACCEPT "application/vnd.wap.mms-message, */*"
@@ -43,23 +44,46 @@ enum _MMS_HTTP_HEADER_FIELD_E {
MMS_HH_WAP_PROFILE
};
+typedef enum _MMS_HTTP_TRANSACTION_TYPE_E {
+ MMS_HTTP_TRANSACTION_TYPE_UNKNOWN = 0,
+ MMS_HTTP_TRANSACTION_TYPE_GET,
+ MMS_HTTP_TRANSACTION_TYPE_POST,
+} MMS_HTTP_TRANSACTION_TYPE_E;
+
+typedef enum _MMS_HTTP_ERROR_E {
+ MMS_HTTP_ERROR_NONE = 0,
+ MMS_HTTP_ERROR_ABORT,
+ MMS_HTTP_ERROR_TRANSACTION_TYPE,
+ MMS_HTTP_ERROR_TRANSACTION,
+} MMS_HTTP_ERROR_E;
+
+typedef struct _http_session_info_s {
+ MMS_HTTP_TRANSACTION_TYPE_E transaction_type;
+ const char *url;
+ const char *proxy;
+ const char *interface;
+ const char *post_data;
+ unsigned int post_data_len;
+ char *response_data;
+ unsigned int response_data_len;
+} http_request_info_s;
+
class MmsPluginHttpAgent
{
public:
static MmsPluginHttpAgent *instance();
- int cmdRequest(MMS_HTTP_CMD_TYPE_T cmdType);
-
- int setSession(mmsTranQEntity *qEntity);
-
- void clearSession();
-
- void SetMMSProfile();
+ MMS_HTTP_ERROR_E httpRequest(http_request_info_s &request_info);
- MMS_PLUGIN_HTTP_DATA_S *getHttpConfigData();
- MMS_PLUGIN_HTTP_CONTEXT_S *getMmsPldCd();
+ void setAbortFlag(){
+ MutexLocker locker(mx);
+ abort = true;
+ };
- MMS_PLUGIN_HTTP_DATA_S httpConfigData;
+ bool getAbortFlag(){
+ MutexLocker locker(mx);
+ return abort;
+ };
private:
static MmsPluginHttpAgent *pInstance;
@@ -67,9 +91,24 @@ class MmsPluginHttpAgent
MmsPluginHttpAgent();
~MmsPluginHttpAgent();
- MMS_PLUGIN_HTTP_CONTEXT_S mmsPlgCd;
+ void initSession();
+ MMS_HTTP_ERROR_E setSession(http_request_info_s &request_info);
+ MMS_HTTP_ERROR_E startTransaction();
+ void clearSession();
+
+ void initAbortFlag(){
+ MutexLocker locker(mx);
+ abort = false;
+ };
+
+ MMS_HTTP_TRANSACTION_TYPE_E transaction_type;
+
+ void *session_header;
+ void *session_option;
- std::map<MMS_HTTP_CMD_TYPE_T,int(*)(MMS_PLUGIN_HTTP_DATA_S *)> httpCmdHandler;
+ FILE *respfile;
+ bool abort;
+ Mutex mx;
};
#endif //MMS_PLUGIN_HTTP_H