MMS code clean up about En/Decode
authorSeunghwan Lee <sh.cat.lee@samsung.com>
Fri, 14 Dec 2012 07:35:47 +0000 (16:35 +0900)
committerSeunghwan Lee <sh.cat.lee@samsung.com>
Fri, 14 Dec 2012 07:35:47 +0000 (16:35 +0900)
23 files changed:
plugin/mms_plugin/CMakeLists.txt
plugin/mms_plugin/MmsPluginCodecCommon.cpp [moved from plugin/mms_plugin/MmsPluginCodec.cpp with 54% similarity]
plugin/mms_plugin/MmsPluginContentCodec.cpp [deleted file]
plugin/mms_plugin/MmsPluginDecode.cpp
plugin/mms_plugin/MmsPluginDrm.cpp
plugin/mms_plugin/MmsPluginEncode.cpp
plugin/mms_plugin/MmsPluginInternal.cpp
plugin/mms_plugin/MmsPluginMain.cpp
plugin/mms_plugin/MmsPluginMessage.cpp
plugin/mms_plugin/MmsPluginSmil.cpp
plugin/mms_plugin/MmsPluginStorage.cpp
plugin/mms_plugin/MmsPluginTextConvert.cpp
plugin/mms_plugin/MmsPluginUserAgent.cpp
plugin/mms_plugin/include/MmsPluginCodec.h
plugin/mms_plugin/include/MmsPluginCodecCommon.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginCodecTypes.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginData.h [deleted file]
plugin/mms_plugin/include/MmsPluginDecode.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginEncode.h [new file with mode: 0755]
plugin/mms_plugin/include/MmsPluginMessage.h
plugin/mms_plugin/include/MmsPluginSetup.h [deleted file]
plugin/mms_plugin/include/MmsPluginStorage.h
plugin/mms_plugin/include/MmsPluginTextConvert.h

index 1a0b0ce..3e0cdd6 100755 (executable)
@@ -14,6 +14,9 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 ##########################################################
 
 SET(MMS-PLUGIN-SRCS
+       MmsPluginCodecCommon.cpp
+       MmsPluginDecode.cpp
+       MmsPluginEncode.cpp
        MmsPluginTextConvert.cpp
        MmsPluginTransport.cpp
        MmsPluginMain.cpp
@@ -21,16 +24,12 @@ SET(MMS-PLUGIN-SRCS
        MmsPluginStorage.cpp
        MmsPluginMessage.cpp
        MmsPluginMIME.cpp
-       MmsPluginDecode.cpp
        MmsPluginAvCodec.cpp
        MmsPluginDebug.cpp
        MmsPluginConnManWrapper.cpp
        MmsPluginUserAgent.cpp
        MmsPluginHttp.cpp
-       MmsPluginEncode.cpp
-       MmsPluginCodec.cpp
        MmsPluginInternal.cpp
-       MmsPluginContentCodec.cpp
        MmsPluginSmil.cpp
        MmsPluginSMILValidate.cpp
        MmsPluginDrm.cpp
@@ -60,6 +59,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 #ADD_DEFINITIONS("-DWno-write-strings")
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
 
 ADD_LIBRARY(${MMS-PLUGIN-LIB} SHARED ${MMS-PLUGIN-SRCS})
 TARGET_LINK_LIBRARIES(${MMS-PLUGIN-LIB} ${mms_plugin_pkgs_LDFLAGS} ${UTILS-LIB})
similarity index 54%
rename from plugin/mms_plugin/MmsPluginCodec.cpp
rename to plugin/mms_plugin/MmsPluginCodecCommon.cpp
index 173770e..90fe694 100755 (executable)
 * limitations under the License.
 */
 
-#include "MmsPluginCodec.h"
-#include "MsgMmsTypes.h"
-#include "MmsPluginMessage.h"
-#include "MmsPluginMIME.h"
+#include <ctype.h>
 #include "MsgDebug.h"
+#include "MmsPluginCodecCommon.h"
+#include "MmsPluginMIME.h"
+#include "MmsPluginUtil.h"
+#include "MmsPluginTextConvert.h"
+
+#define        MMS_MAX_FIELD_VALUE_COUNT       74
+#define        MMS_MAX_FIELD_TYPE_COUNT        21
+
+typedef struct {
+       const char *szText;
+       UINT16 binary;
+} MmsField;
 
 /* Reference : MMS-209-Encapsulation & WAP-203-WSP-20000504.pdf Table 39 */
 const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
@@ -491,63 +500,60 @@ const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT] =
        }
 };
 
-/* global variables */
-static char    gszMmsVersion[5] = {0, };
-
-char *_MmsGetTextValue(MmsCode i, int j)
+const char *MmsGetTextValue(MmsCode i, int j)
 {
        if (i == MmsCodeContentType) {
                //apply UtyMime
                return MimeGetMimeStringFromMimeInt(j);
        }
 
-       return (char *)gMmsField[i][j].szText;
+       return (const char *)gMmsField[i][j].szText;
 }
 
-char *_MmsGetTextValuebyField(int field, int value)
+const char *MmsGetTextValuebyField(int field, int value)
 {
-       char *szValue = NULL;
+       const char *szValue = NULL;
 
        switch (field) {
        case MMS_CODE_MSGTYPE:
-               szValue = _MmsGetTextValue(MmsCodeMsgType, value);
+               szValue = MmsGetTextValue(MmsCodeMsgType, value);
                break;
 
        case MMS_CODE_MSGCLASS:
-               szValue = _MmsGetTextValue(MmsCodeMsgClass, value);
+               szValue = MmsGetTextValue(MmsCodeMsgClass, value);
                break;
 
        case MMS_CODE_PRIORITY:
-               szValue = _MmsGetTextValue(MmsCodePriority, value);
+               szValue = MmsGetTextValue(MmsCodePriority, value);
                break;
 
        case MMS_CODE_SENDERVISIBILLITY:
-               szValue = _MmsGetTextValue(MmsCodeSenderVisibility, value);
+               szValue = MmsGetTextValue(MmsCodeSenderVisibility, value);
                break;
 
        case MMS_CODE_DELIVERYREPORT:
-               szValue = _MmsGetTextValue(MmsCodeDeliveryReport, value);
+               szValue = MmsGetTextValue(MmsCodeDeliveryReport, value);
                break;
 
        case MMS_CODE_READREPLY:
-               szValue = _MmsGetTextValue(MmsCodeReadReply, value);
+               szValue = MmsGetTextValue(MmsCodeReadReply, value);
                break;
 
        case MMS_CODE_MSGSTATUS:
-               szValue = _MmsGetTextValue(MmsCodeMsgStatus, value);
+               szValue = MmsGetTextValue(MmsCodeMsgStatus, value);
                break;
 
        case MMS_CODE_REPORTALLOWED:
-               szValue = _MmsGetTextValue(MmsCodeReportAllowed, value);
+               szValue = MmsGetTextValue(MmsCodeReportAllowed, value);
                break;
 
        case MMS_CODE_RESPONSESTATUS:
-               szValue = _MmsGetTextValue(MmsCodeResponseStatus, value);
+               szValue = MmsGetTextValue(MmsCodeResponseStatus, value);
                break;
 
        /* Add by MMSENC v1.1 */
        case MMS_CODE_READSTATUS:
-               szValue = _MmsGetTextValue(MmsCodeReadStatus, value);
+               szValue = MmsGetTextValue(MmsCodeReadStatus, value);
                break;
 
        default:
@@ -558,7 +564,7 @@ char *_MmsGetTextValuebyField(int field, int value)
        return szValue;
 }
 
-UINT16 _MmsGetBinaryValue(MmsCode i, int j)
+UINT16 MmsGetBinaryValue(MmsCode i, int j)
 {
        if (i == MmsCodeContentType) {
                return MimeGetBinaryValueFromMimeInt((MimeType)j);
@@ -568,7 +574,7 @@ UINT16 _MmsGetBinaryValue(MmsCode i, int j)
 }
 
 // getting mime type (int) by binary type
-int _MmsGetBinaryType(MmsCode i, UINT16 value)
+int MmsGetBinaryType(MmsCode i, UINT16 value)
 {
        MSG_BEGIN();
 
@@ -588,7 +594,7 @@ int _MmsGetBinaryType(MmsCode i, UINT16 value)
        return MIME_UNKNOWN;
 }
 
-int _MmsGetTextType(MmsCode i, char *pValue)
+int MmsGetTextType(MmsCode i, char *pValue)
 {
        int j = 0;
 
@@ -608,27 +614,520 @@ int _MmsGetTextType(MmsCode i, char *pValue)
        return -1;
 }
 
-UINT8 _MmsGetVersion(MmsMsg *pMsg)
+const char *MmsGetTextByCode(MmsCode i, UINT16 code)
+{
+       for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) {
+               if (gMmsField[i][j].binary == code) {
+                       return gMmsField[i][j].szText;
+               }
+       }
+       return NULL;
+}
+
+
+
+/* ==================================================================
+ *     Decode/Encode inline base64 string
+ *
+ * base64 : 3*8bit -> 4*6bit & convert the value into A~Z, a~z, 0~9, +, or /
+ * pad(=) is needed when the end of the string is < 24bit.
+ *
+ *     Value Encoding  Value Encoding  Value Encoding  Value Encoding
+ *         0 A            17 R            34 i            51 z
+ *         1 B            18 S            35 j            52 '0'
+ *         2 C            19 T            36 k            53 1
+ *         3 D            20 U            37 l            54 2
+ *         4 E            21 V            38 m            55 3
+ *         5 F            22 W            39 n            56 4
+ *         6 G            23 X            40 o            57 5
+ *         7 H            24 Y            41 p            58 6
+ *         8 I            25 Z            42 q            59 7
+ *         9 J            26 a            43 r            60 8
+ *        10 K            27 b            44 s            61 9
+ *        11 L            28 c            45 t            62 +
+ *        12 M            29 d            46 u            63 /
+ *        13 N            30 e            47 v
+ *        14 O            31 f            48 w         (pad) =
+ *        15 P            32 g            49 x
+ *        16 Q            33 h            50 y
+ *
+ * (1) the final quantum = 24 bits : no "=" padding,
+ * (2) the final quantum = 8 bits : two "=" + two characters
+ * (3) the final quantum = 16 bits : one "=" + three characters
+ * ================================================================== */
+
+void *MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len)
 {
-       if (pMsg == NULL) {
-               return MMS_VERSION;
+       char c;
+       void *ret = NULL;
+       char *d = NULL;
+       short e = 0;
+
+       ret = malloc((size_t)(*len = 4 + ((srcLen * 3) / 4)));
+       d = (char *)ret;
+
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgDecodeBase64: ret malloc Fail \n");
+               return NULL;
+       }
+
+       memset(ret, 0, (size_t)*len);
+       *len = 0;
+
+       while (srcLen-- > 0) {
+               c = *pSrc++;
+
+               /* Convert base64 character into original value */
+
+               if (isupper(c))
+                       c -= 'A';
+               else if (islower(c))
+                       c -= 'a' - 26;
+               else if (isdigit(c))
+                       c -= '0' - 52;
+               else if (c == '+')
+                       c = 62;
+               else if (c == '/')
+                       c = 63;
+               else if (c == '=') {
+                       switch (e++) {
+                       case 2:
+                               if (*pSrc != '=') {
+                                       *len = d - (char *)ret;
+                                       return ret;
+                               }
+                               break;
+                       case 3:
+                               e = 0;
+                               break;
+                       default:
+                               *len = d - (char *)ret;
+                               return ret;
+                       }
+                       continue;
+               } else
+                       continue;                                       // Actually, never get here
+
+               /* Pad 4*6bit character into 3*8bit character */
+
+               switch (e++) {
+               case 0:
+                       *d = c << 2;                    // byte 1: high 6 bits
+                       break;
+
+               case 1:
+                       *d++ |= c >> 4;                 // byte 1: low 2 bits
+                       *d = c << 4;                    // byte 2: high 4 bits
+                       break;
+
+               case 2:
+                       *d++ |= c >> 2;                 // byte 2: low 4 bits
+                       *d = c << 6;                    // byte 3: high 2 bits
+                       break;
+
+               case 3:
+                       *d++ |= c;                              // byte 3: low 6 bits
+                       e = 0;                                  // Calculate next unit.
+                       break;
+
+               default:
+                       MSG_DEBUG("_MsgDecodeBase64: Unknown paremeter\n");
+                       break;
+               }
        }
 
-       return pMsg->mmsAttrib.version;
+       *len = d - (char *)ret;                 // Calculate the size of decoded string.
+
+       return ret;
 }
 
-bool _MmsSetVersion(int majorVer, int minorVer)
+
+
+/* ==========================================
+ *     Decode/Encode inline base64 string
+ *
+ * quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)
+ *       ; Maximum line length of 76 characters excluding CRLF
+ *
+ * ptext := octet /<any ASCII character except "=", SPACE, or TAB>
+ *       ; characters not listed as "mail-safe" in Appendix B
+ *       ; are also not recommended.
+ *
+ * octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
+ *       ; octet must be used for characters > 127, =, SPACE, or TAB.
+ *
+ * ==========================================*/
+
+
+unsigned char *MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len)
 {
-       snprintf(gszMmsVersion, sizeof(gszMmsVersion), "%d.%d", majorVer, minorVer);
+       unsigned char *ret = NULL;
+       unsigned char *d = NULL;
+       unsigned char *s = NULL;                                        /* last non-blank */
+       unsigned char c;
+       unsigned char e;
+
+       d = s = ret = (unsigned char *)malloc((size_t)srcLen + 1);
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgDecodeQuotePrintable: ret malloc Fail \n");
+               return NULL;
+       }
+
+       *len = 0;
+       pSrc[srcLen] = '\0';
+
+       while ((c = *pSrc++)!= '\0') {
+               switch (c) {
+               case '=':                                                       /* octet characters (> 127, =, SPACE, or TAB) */
+                       switch (c = *pSrc++) {
+                       case '\0':                                      /* end of string -> postpone to while */
+                               break;
+
+                       case '\015':                            /* CRLF */
+                               if (*pSrc == '\012')
+                                       pSrc++;
+                               break;
+
+                       default:                                        /* two hexes */
+                               if (!isxdigit(c)) {
+                                       *d = '\0';
+                                       *len = d - ret;
+                                       return ret;
+                               }
+
+                               if (isdigit(c))
+                                       e = c - '0';
+                               else
+                                       e = c - (isupper(c) ? 'A' - 10 : 'a' - 10);
+
+                               c = *pSrc++;
+                               if (!isxdigit(c)) {
+                                       *d = '\0';
+                                       *len = d - ret;
+                                       return ret;
+                               }
+
+                               if (isdigit(c))
+                                       c -= '0';
+                               else
+                                       c -= (isupper(c) ? 'A' - 10 : 'a' - 10);
+
+                               *d++ = c + (e << 4);
+                               s = d;
+                               break;
+                       }
+                       break;
+
+               case ' ':                                                       /* skip the blank */
+                       *d++ = c;
+                       break;
+
+               case '\015':                                            /* Line Feedback : to last non-blank character */
+                       d = s;
+                       break;
+
+               default:
+                       *d++ = c;                                               /* ASCII character */
+                       s = d;
+                       break;
+               }
+       }
+
+       *d = '\0';
+       *len = d - ret;
+
+       return ret;
+}
+
+
+/* ========================================
+ * Decode/Encode inline base64 string
+ * Inline base64 has no "\r\n" in it,
+ * and has charset and encoding sign in it
+ * ======================================== */
+bool MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
+{
+       unsigned char *d = NULL;
+       unsigned char *s = (unsigned char *)pSrc;
+       char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+       unsigned long i = ((srcLen + 2) / 3) * 4;
+
+       i += 2 * ((i / 60) + 1);
+       *len = i;
+
+       if (ret == NULL) {
+               MSG_DEBUG("_MsgEncode2Base64: ret Memory Alloc Fail \n");
+               return false;
+       }
+       memset(ret, 0, i);
+
+       d = ret;
+
+       /* Convert 3*8bit into 4*6bit */
+       for (i = 0; srcLen > 0; s += 3) {
+               *d++ = v[s[0] >> 2];                                                                                                                    // byte 1: high 6 bits of character-1
+               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  // byte 2: low 2 bits of character-1 and high 4 bits of character-2
+               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3
+               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   // byte 4: low 6 bits of character-3
+
+               if (srcLen)
+                       srcLen--;
+       }
+
+       *d = '\0';
+
+       if (((unsigned long)(d - ret)) != *len) {
+               *len = d - ret;
+               MSG_DEBUG("base64 encoding length = %d \n", *len);
+       }
+
        return true;
 }
 
-const char *MmsGetTextByCode(MmsCode i, UINT16 code)
+
+char *MsgDecodeText(char *pOri)
 {
-       for (int j = 0; j < MMS_MAX_FIELD_VALUE_COUNT; j++) {
-               if (gMmsField[i][j].binary == code) {
-                       return gMmsField[i][j].szText;
+       MSG_BEGIN();
+
+       int size = 0;
+       int cnt = 0;
+       char *pSrc = NULL;
+       char *pTemp = NULL;
+       char *pRe = NULL;
+       char *pStrEnd = NULL;
+       char *pDecStart = NULL;
+       char *pDecEnd = NULL;
+       char *pDecQ = NULL;
+       char *pDecQ2 = NULL;
+       bool bEncoding = false;
+       int     nCharset = MSG_CHARSET_UTF8;
+       int     nTemp = 0;
+       char *pReturnStr = NULL;
+       char *pConvertedStr = NULL;
+
+       char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE] = {0};
+
+       // copy original string
+       if (strlen(pOri) >= MSG_LOCAL_TEMP_BUF_SIZE) {
+               pSrc = MsgStrCopy( pOri );
+       } else {
+               memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE);
+               strcpy(szTempBuf, pOri);
+
+               pSrc = szTempBuf;
+       }
+
+       // it can be one or more encoding methods in a line
+       while (1) {
+               cnt++;
+
+               bEncoding = false;
+
+               /*
+                 (ex) "=?euc-kr?B?Y2NqMjEyMw==?="
+
+                 pDecStart: charset                    (=?euc-kr?B?Y2NqMjEyMw==?=)
+                 pDecQ : Encoding type         (B?Y2NqMjEyMw==?=)
+                 pDecQ2        : Encoded text          (Y2NqMjEyMw==?=)
+                 pDecEnd       : Encoded of text       (?=)
+                */
+               if (pSrc == NULL)
+                       goto __CATCH;
+
+               if (((pDecStart = strstr(pSrc, MSG_STR_DEC_START)) != NULL)     //"=?"
+                    && ((pDecQ = strchr(pDecStart + 2, MSG_CH_QUESTION)) != NULL)      // '?'
+                    && ((pDecQ2 = strchr(pDecQ + 1, MSG_CH_QUESTION))!= NULL)          // '?'
+                    && ((pDecEnd = strstr(pDecQ2 + 1, MSG_STR_DEC_END))!= NULL)) {     //"=?"
+                       bEncoding = true;
+
+                       /* fixme: charset problem
+                        * pDecStart ~ pDecQ : charSet & MSG_CHARSET_USC2 ~ MSG_CHARSET_UTF8 & LATIN
+                        */
+
+                       *pDecQ = '\0';
+                       nCharset = _MsgGetCode(MSG_CHARSET, pDecStart + 2);
+                       *pDecQ = MSG_CH_QUESTION;
+               }
+
+               // End of encoding
+               if (!bEncoding)
+                       goto __RETURN;
+
+               // find end of string
+               pStrEnd = pSrc + strlen(pSrc);
+
+               // Decoding
+               if ((*(pDecQ2 - 1) == MSG_CH_BASE64_UPPER) ||
+                       (*(pDecQ2 - 1) == MSG_CH_BASE64_LOWER) ||
+                       (*(pDecQ + 1) == MSG_CH_BASE64_UPPER) ||
+                       (*(pDecQ + 1) == MSG_CH_BASE64_LOWER)) {
+                       pTemp = (char *)MsgDecodeBase64((UCHAR *)(pDecQ2 + 1), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size);
+
+                       if (pTemp != NULL) {
+                               pTemp[size] = MSG_CH_NULL;
+
+                               if(pRe) {
+                                       free(pRe);
+                                       pRe = NULL;
+                               }
+
+                               pRe = (char *)malloc((pDecStart-pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1);
+                               if (pRe == NULL) {
+                                       MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n");
+                                       free(pTemp);
+                                       pTemp = NULL;
+
+                                       goto __RETURN;
+                               }
+
+                               memcpy(pRe, pSrc, pDecStart - pSrc);
+                               memcpy(&pRe[pDecStart-pSrc], pTemp, size);
+                               memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2));
+                               pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL;
+
+                               free(pTemp);
+                               pTemp = NULL;
+
+                               if (pSrc != NULL && pSrc != szTempBuf) {
+                                       free(pSrc);
+                                       pSrc = NULL;
+                               }
+                       }
+               } else if ((*(pDecQ2-1) == MSG_CH_QPRINT_UPPER) ||
+                               (*(pDecQ2-1) == MSG_CH_QPRINT_LOWER) ||
+                               (*(pDecQ+1) == MSG_CH_QPRINT_UPPER) ||
+                               (*(pDecQ+1) == MSG_CH_QPRINT_LOWER)) {
+
+                       pTemp = (char *)MsgDecodeQuotePrintable((UCHAR *)( pDecQ2 + 1 ), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size);
+
+                       if (pTemp != NULL) {
+                               int i;
+                               pTemp[size] = MSG_CH_NULL;
+
+                               for (i = 0; i < size; i++) {
+                                       if (pTemp[i] == MSG_CH_UNDERLINE) {
+                                               pTemp[i] = MSG_CH_SP;                         // change '_' to ' '
+                                       }
+                               }
+
+                               if(pRe) {
+                                       free(pRe);
+                                       pRe = NULL;
+                               }
+
+                               pRe = (char *)malloc((pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1);
+                               if (pRe == NULL) {
+                                       MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n");
+                                       free(pTemp);
+                                       pTemp = NULL;
+
+                                       goto __RETURN;
+                               }
+
+                               memcpy(pRe, pSrc, pDecStart - pSrc);
+                               memcpy(&pRe[pDecStart - pSrc], pTemp, size);
+                               memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2));
+                               pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL;
+
+                               if (pTemp) {
+                                       free(pTemp);
+                                       pTemp = NULL;
+                               }
+
+                               if (pSrc != NULL && pSrc != szTempBuf) {
+                                       free(pSrc);
+                                       pSrc = NULL;
+                               }
+                       }
+               } else {
+                       goto __RETURN;
                }
        }
+
+
+
+__RETURN:
+
+       pTemp = strdup(pSrc);
+       nTemp = strlen(pSrc);
+
+       {//temp brace;
+               const char *pToCharSet = "UTF-8";
+
+               UINT16 charset_code =  MmsGetBinaryValue(MmsCodeCharSet, nCharset);
+
+               const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code);
+
+               if (pFromCharSet != NULL && strcmp(pFromCharSet, pToCharSet) != 0) {//Not UTF-8
+                       char *pDest = NULL;
+                       int destLen = 0;
+
+                       if (MmsPluginTextConvert(pToCharSet, pFromCharSet, pTemp, nTemp, &pDest, &destLen) == false) {
+                               MSG_DEBUG("MmsPluginTextConvert Fail");
+                       }
+
+                       if (pDest) {
+                               free(pTemp);
+                               pTemp = strdup(pDest);
+                               nTemp = destLen;
+                               free(pDest);
+                       }
+               }
+
+       }
+
+       pReturnStr = (char *)malloc(nTemp + 1);
+
+       if (pReturnStr == NULL) {
+               goto __CATCH;
+       }
+
+       memset(pReturnStr, 0, nTemp + 1);
+
+       if (pTemp) {
+               memcpy(pReturnStr, pTemp, nTemp);
+               free(pTemp);
+               pTemp = NULL;
+       }
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       if(pRe) {
+               free(pRe);
+               pRe = NULL;
+       }
+
+       if (pSrc != NULL && pSrc != szTempBuf) {
+               free(pSrc);
+               pSrc = NULL;
+       }
+
+       return pReturnStr;
+
+__CATCH:
+
+       if (pConvertedStr) {
+               free(pConvertedStr);
+               pConvertedStr = NULL;
+       }
+
+       if(pRe) {
+               free(pRe);
+               pRe = NULL;
+       }
+
+       if (pSrc != NULL && pSrc != szTempBuf) {
+               free(pSrc);
+               pSrc = NULL;
+       }
+
+       if (pTemp) {
+               free(pTemp);
+               pTemp = NULL;
+       }
+
        return NULL;
 }
diff --git a/plugin/mms_plugin/MmsPluginContentCodec.cpp b/plugin/mms_plugin/MmsPluginContentCodec.cpp
deleted file mode 100755 (executable)
index 720d5fd..0000000
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
-* Copyright 2012  Samsung Electronics Co., Ltd
-*
-* Licensed under the Flora License, Version 1.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*    http://www.tizenopensource.org/license
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <stdlib.h>
-#include <ctype.h>
-#include "MsgDebug.h"
-#include "MmsPluginCodec.h"
-#include "MmsPluginTextConvert.h"
-#include "MmsPluginMIME.h"
-#include "MmsPluginMessage.h"
-#include "MmsPluginUtil.h"
-const int MSG_MAX_CH_PER_LINE = 75;
-
-/* ==================================================================
- *     Decode/Encode inline base64 string
- *
- * base64 : 3*8bit -> 4*6bit & convert the value into A~Z, a~z, 0~9, +, or /
- * pad(=) is needed when the end of the string is < 24bit.
- *
- *     Value Encoding  Value Encoding  Value Encoding  Value Encoding
- *         0 A            17 R            34 i            51 z
- *         1 B            18 S            35 j            52 '0'
- *         2 C            19 T            36 k            53 1
- *         3 D            20 U            37 l            54 2
- *         4 E            21 V            38 m            55 3
- *         5 F            22 W            39 n            56 4
- *         6 G            23 X            40 o            57 5
- *         7 H            24 Y            41 p            58 6
- *         8 I            25 Z            42 q            59 7
- *         9 J            26 a            43 r            60 8
- *        10 K            27 b            44 s            61 9
- *        11 L            28 c            45 t            62 +
- *        12 M            29 d            46 u            63 /
- *        13 N            30 e            47 v
- *        14 O            31 f            48 w         (pad) =
- *        15 P            32 g            49 x
- *        16 Q            33 h            50 y
- *
- * (1) the final quantum = 24 bits : no "=" padding,
- * (2) the final quantum = 8 bits : two "=" + two characters
- * (3) the final quantum = 16 bits : one "=" + three characters
- * ================================================================== */
-
-bool _MsgEncodeBase64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
-{
-       unsigned char *d = NULL;
-       unsigned char *s = (unsigned char *)pSrc;
-
-       char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-       unsigned long i = ((srcLen + 2) / 3) * 4;
-
-       i += 2 * ((i / 60) + 1);
-       *len = i;
-
-       if (ret == NULL) {
-               MSG_DEBUG("_MsgEncodeBase64: ret Memory Alloc Fail \n");
-               return false;
-       }
-       memset(ret, 0, i);
-
-       d = ret;
-
-       /* Convert 3*8bit into 4*6bit */
-       for (i = 0; srcLen > 0; s += 3) {
-               *d++ = v[s[0] >> 2];                                                                                                                    // byte 1: high 6 bits of character-1
-               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  // byte 2: low 2 bits of character-1 and high 4 bits of character-2
-               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3
-               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   // byte 4: low 6 bits of character-3
-
-               if (srcLen)
-                       srcLen--;
-
-               /* Insert CRLF at every 60 characters */
-               if ((++i) == 15) {
-                       i = 0;
-                       *d++ = '\015';
-                       *d++ = '\012';
-               }
-       }
-
-       if (i == 15) {
-               *d++ = '\015';
-               *d++ = '\012';
-       }
-       *d = '\0';
-
-       if (((unsigned long)(d - ret)) != *len) {
-               *len = d - ret;
-               MSG_DEBUG("base64 encoding length = %d \n", *len);
-       }
-
-       return true;
-}
-
-
-void *_MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len)
-{
-       char c;
-       void *ret = NULL;
-       char *d = NULL;
-       short e = 0;
-
-       ret = malloc((size_t)(*len = 4 + ((srcLen * 3) / 4)));
-       d = (char *)ret;
-
-       if (ret == NULL) {
-               MSG_DEBUG("_MsgDecodeBase64: ret malloc Fail \n");
-               return NULL;
-       }
-
-       memset(ret, 0, (size_t)*len);
-       *len = 0;
-
-       while (srcLen-- > 0) {
-               c = *pSrc++;
-
-               /* Convert base64 character into original value */
-
-               if (isupper(c))
-                       c -= 'A';
-               else if (islower(c))
-                       c -= 'a' - 26;
-               else if (isdigit(c))
-                       c -= '0' - 52;
-               else if (c == '+')
-                       c = 62;
-               else if (c == '/')
-                       c = 63;
-               else if (c == '=') {
-                       switch (e++) {
-                       case 2:
-                               if (*pSrc != '=') {
-                                       *len = d - (char *)ret;
-                                       return ret;
-                               }
-                               break;
-                       case 3:
-                               e = 0;
-                               break;
-                       default:
-                               *len = d - (char *)ret;
-                               return ret;
-                       }
-                       continue;
-               } else
-                       continue;                                       // Actually, never get here
-
-               /* Pad 4*6bit character into 3*8bit character */
-
-               switch (e++) {
-               case 0:
-                       *d = c << 2;                    // byte 1: high 6 bits
-                       break;
-
-               case 1:
-                       *d++ |= c >> 4;                 // byte 1: low 2 bits
-                       *d = c << 4;                    // byte 2: high 4 bits
-                       break;
-
-               case 2:
-                       *d++ |= c >> 2;                 // byte 2: low 4 bits
-                       *d = c << 6;                    // byte 3: high 2 bits
-                       break;
-
-               case 3:
-                       *d++ |= c;                              // byte 3: low 6 bits
-                       e = 0;                                  // Calculate next unit.
-                       break;
-
-               default:
-                       MSG_DEBUG("_MsgDecodeBase64: Unknown paremeter\n");
-                       break;
-               }
-       }
-
-       *len = d - (char *)ret;                 // Calculate the size of decoded string.
-
-       return ret;
-}
-
-
-
-/* ==========================================
- *     Decode/Encode inline base64 string
- *
- * quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)
- *       ; Maximum line length of 76 characters excluding CRLF
- *
- * ptext := octet /<any ASCII character except "=", SPACE, or TAB>
- *       ; characters not listed as "mail-safe" in Appendix B
- *       ; are also not recommended.
- *
- * octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
- *       ; octet must be used for characters > 127, =, SPACE, or TAB.
- *
- * ==========================================*/
-
-bool _MsgEncodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
-{
-       unsigned long lp = 0;
-       unsigned char *d = ret;
-       char *hex = (char *)"0123456789ABCDEF";
-       unsigned char c;
-
-       if (ret == NULL) {
-               MSG_DEBUG("_MsgEncodeQuotePrintable: ret malloc Fail \n");
-               return false;
-       }
-
-       d = ret;
-
-       /*
-        * The type of srcLen is unsigned long
-        * The value of srcLen is decreased by 1 -> We can't check by "srcLen > 0".
-        */
-       while (srcLen-- > 0) {
-               /* Just copy CRLF */
-               if (((c = *pSrc++) == '\015') && (*pSrc == '\012') && srcLen) {
-                       *d++ = '\015';
-                       *d++ = *pSrc++;
-                       srcLen--;
-                       lp = 0;
-               } else {
-                       if (iscntrl(c) || (c == 0x7f) || (c & 0x80) || (c == '=') || ((c == ' ') && (*pSrc == '\015'))) {
-                               if ((lp += 3) > (unsigned long)MSG_MAX_CH_PER_LINE) {
-                                       *d++ = '=';
-                                       *d++ = '\015';
-                                       *d++ = '\012';
-                                       lp = 3;
-                               }
-
-                               *d++ = '=';                             /* quote character */
-                               *d++ = hex[c >> 4];             /* high order 4 bits */
-                               *d++ = hex[c & 0xf];    /* low order 4 bits */
-                       } else {
-                               /* Just copy ASCII character */
-                               if ((++lp) > (unsigned long)MSG_MAX_CH_PER_LINE) {
-                                       *d++ = '=';
-                                       *d++ = '\015';
-                                       *d++ = '\012';
-                                       lp = 1;
-                               }
-                               *d++ = c;
-                       }
-               }
-       }
-
-       *d = '\0';
-       *len = d - ret;
-
-       return true;
-}
-
-
-unsigned char *_MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len)
-{
-       unsigned char *ret = NULL;
-       unsigned char *d = NULL;
-       unsigned char *s = NULL;                                        /* last non-blank */
-       unsigned char c;
-       unsigned char e;
-
-       d = s = ret = (unsigned char *)malloc((size_t)srcLen + 1);
-       if (ret == NULL) {
-               MSG_DEBUG("_MsgDecodeQuotePrintable: ret malloc Fail \n");
-               return NULL;
-       }
-
-       *len = 0;
-       pSrc[srcLen] = '\0';
-
-       while ((c = *pSrc++)!= '\0') {
-               switch (c) {
-               case '=':                                                       /* octet characters (> 127, =, SPACE, or TAB) */
-                       switch (c = *pSrc++) {
-                       case '\0':                                      /* end of string -> postpone to while */
-                               break;
-
-                       case '\015':                            /* CRLF */
-                               if (*pSrc == '\012')
-                                       pSrc++;
-                               break;
-
-                       default:                                        /* two hexes */
-                               if (!isxdigit(c)) {
-                                       *d = '\0';
-                                       *len = d - ret;
-                                       return ret;
-                               }
-
-                               if (isdigit(c))
-                                       e = c - '0';
-                               else
-                                       e = c - (isupper(c) ? 'A' - 10 : 'a' - 10);
-
-                               c = *pSrc++;
-                               if (!isxdigit(c)) {
-                                       *d = '\0';
-                                       *len = d - ret;
-                                       return ret;
-                               }
-
-                               if (isdigit(c))
-                                       c -= '0';
-                               else
-                                       c -= (isupper(c) ? 'A' - 10 : 'a' - 10);
-
-                               *d++ = c + (e << 4);
-                               s = d;
-                               break;
-                       }
-                       break;
-
-               case ' ':                                                       /* skip the blank */
-                       *d++ = c;
-                       break;
-
-               case '\015':                                            /* Line Feedback : to last non-blank character */
-                       d = s;
-                       break;
-
-               default:
-                       *d++ = c;                                               /* ASCII character */
-                       s = d;
-                       break;
-               }
-       }
-
-       *d = '\0';
-       *len = d - ret;
-
-       return ret;
-}
-
-
-/* ========================================
- * Decode/Encode inline base64 string
- * Inline base64 has no "\r\n" in it,
- * and has charset and encoding sign in it
- * ======================================== */
-bool _MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret)
-{
-       unsigned char *d = NULL;
-       unsigned char *s = (unsigned char *)pSrc;
-       char *v = (char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-       unsigned long i = ((srcLen + 2) / 3) * 4;
-
-       i += 2 * ((i / 60) + 1);
-       *len = i;
-
-       if (ret == NULL) {
-               MSG_DEBUG("_MsgEncode2Base64: ret Memory Alloc Fail \n");
-               return false;
-       }
-       memset(ret, 0, i);
-
-       d = ret;
-
-       /* Convert 3*8bit into 4*6bit */
-       for (i = 0; srcLen > 0; s += 3) {
-               *d++ = v[s[0] >> 2];                                                                                                                    // byte 1: high 6 bits of character-1
-               *d++ = v[((s[0] << 4) + (--srcLen ? (s[1] >> 4) : 0)) & 0x3f];                                  // byte 2: low 2 bits of character-1 and high 4 bits of character-2
-               *d++ = srcLen ? v[((s[1] << 2) + (--srcLen ? (s[2] >> 6) : 0)) & 0x3f] : '=';   // byte 3: low 4 bits of charcter-2 and high 2 bits of character-3
-               *d++ = srcLen ? v[s[2] & 0x3f] : '=';                                                                                   // byte 4: low 6 bits of character-3
-
-               if (srcLen)
-                       srcLen--;
-       }
-
-       *d = '\0';
-
-       if (((unsigned long)(d - ret)) != *len) {
-               *len = d - ret;
-               MSG_DEBUG("base64 encoding length = %d \n", *len);
-       }
-
-       return true;
-}
-
-
-char *_MsgDecodeText(char *pOri)
-{
-       MSG_BEGIN();
-
-       int size = 0;
-       int cnt = 0;
-       char *pSrc = NULL;
-       char *pTemp = NULL;
-       char *pRe = NULL;
-       char *pStrEnd = NULL;
-       char *pDecStart = NULL;
-       char *pDecEnd = NULL;
-       char *pDecQ = NULL;
-       char *pDecQ2 = NULL;
-       bool bEncoding = false;
-       int     nCharset = MSG_CHARSET_UTF8;
-       int     nTemp = 0;
-       char *pReturnStr = NULL;
-       char *pConvertedStr = NULL;
-
-       char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE] = {0};
-
-       // copy original string
-       if (strlen(pOri) >= MSG_LOCAL_TEMP_BUF_SIZE) {
-               pSrc = MsgStrCopy( pOri );
-       } else {
-               memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE);
-               strcpy(szTempBuf, pOri);
-
-               pSrc = szTempBuf;
-       }
-
-       // it can be one or more encoding methods in a line
-       while (1) {
-               cnt++;
-
-               bEncoding = false;
-
-               /*
-                 (ex) "=?euc-kr?B?Y2NqMjEyMw==?="
-
-                 pDecStart: charset                    (=?euc-kr?B?Y2NqMjEyMw==?=)
-                 pDecQ : Encoding type         (B?Y2NqMjEyMw==?=)
-                 pDecQ2        : Encoded text          (Y2NqMjEyMw==?=)
-                 pDecEnd       : Encoded of text       (?=)
-                */
-               if (pSrc == NULL)
-                       goto __CATCH;
-
-               if (((pDecStart = strstr(pSrc, MSG_STR_DEC_START)) != NULL)     //"=?"
-                    && ((pDecQ = strchr(pDecStart + 2, MSG_CH_QUESTION)) != NULL)      // '?'
-                    && ((pDecQ2 = strchr(pDecQ + 1, MSG_CH_QUESTION))!= NULL)          // '?'
-                    && ((pDecEnd = strstr(pDecQ2 + 1, MSG_STR_DEC_END))!= NULL)) {     //"=?"
-                       bEncoding = true;
-
-                       /* fixme: charset problem
-                        * pDecStart ~ pDecQ : charSet & MSG_CHARSET_USC2 ~ MSG_CHARSET_UTF8 & LATIN
-                        */
-
-                       *pDecQ = '\0';
-                       nCharset = _MsgGetCode(MSG_CHARSET, pDecStart + 2);
-                       *pDecQ = MSG_CH_QUESTION;
-               }
-
-               // End of encoding
-               if (!bEncoding)
-                       goto __RETURN;
-
-               // find end of string
-               pStrEnd = pSrc + strlen(pSrc);
-
-               // Decoding
-               if ((*(pDecQ2 - 1) == MSG_CH_BASE64_UPPER) ||
-                       (*(pDecQ2 - 1) == MSG_CH_BASE64_LOWER) ||
-                       (*(pDecQ + 1) == MSG_CH_BASE64_UPPER) ||
-                       (*(pDecQ + 1) == MSG_CH_BASE64_LOWER)) {
-                       pTemp = (char *)_MsgDecodeBase64((UCHAR *)(pDecQ2 + 1), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size);
-
-                       if (pTemp != NULL) {
-                               pTemp[size] = MSG_CH_NULL;
-
-                               if(pRe) {
-                                       free(pRe);
-                                       pRe = NULL;
-                               }
-
-                               pRe = (char *)malloc((pDecStart-pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1);
-                               if (pRe == NULL) {
-                                       MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n");
-                                       free(pTemp);
-                                       pTemp = NULL;
-
-                                       goto __RETURN;
-                               }
-
-                               memcpy(pRe, pSrc, pDecStart - pSrc);
-                               memcpy(&pRe[pDecStart-pSrc], pTemp, size);
-                               memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2));
-                               pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL;
-
-                               free(pTemp);
-                               pTemp = NULL;
-
-                               if (pSrc != NULL && pSrc != szTempBuf) {
-                                       free(pSrc);
-                                       pSrc = NULL;
-                               }
-                       }
-               } else if ((*(pDecQ2-1) == MSG_CH_QPRINT_UPPER) ||
-                               (*(pDecQ2-1) == MSG_CH_QPRINT_LOWER) ||
-                               (*(pDecQ+1) == MSG_CH_QPRINT_UPPER) ||
-                               (*(pDecQ+1) == MSG_CH_QPRINT_LOWER)) {
-
-                       pTemp = (char *)_MsgDecodeQuotePrintable((UCHAR *)( pDecQ2 + 1 ), (ULONG)(pDecEnd - pDecQ2 - 1), (ULONG *)&size);
-
-                       if (pTemp != NULL) {
-                               int i;
-                               pTemp[size] = MSG_CH_NULL;
-
-                               for (i = 0; i < size; i++) {
-                                       if (pTemp[i] == MSG_CH_UNDERLINE) {
-                                               pTemp[i] = MSG_CH_SP;                         // change '_' to ' '
-                                       }
-                               }
-
-                               if(pRe) {
-                                       free(pRe);
-                                       pRe = NULL;
-                               }
-
-                               pRe = (char *)malloc((pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2)) + 1);
-                               if (pRe == NULL) {
-                                       MSG_DEBUG("_MsgDecodeText: pRemalloc fail \n");
-                                       free(pTemp);
-                                       pTemp = NULL;
-
-                                       goto __RETURN;
-                               }
-
-                               memcpy(pRe, pSrc, pDecStart - pSrc);
-                               memcpy(&pRe[pDecStart - pSrc], pTemp, size);
-                               memcpy(&pRe[(pDecStart - pSrc) + size], pDecEnd + 2, pStrEnd - (pDecEnd + 2));
-                               pRe[(pDecStart - pSrc) + size + (pStrEnd - (pDecEnd + 2))] = MSG_CH_NULL;
-
-                               if (pTemp) {
-                                       free(pTemp);
-                                       pTemp = NULL;
-                               }
-
-                               if (pSrc != NULL && pSrc != szTempBuf) {
-                                       free(pSrc);
-                                       pSrc = NULL;
-                               }
-                       }
-               } else {
-                       goto __RETURN;
-               }
-       }
-
-
-
-__RETURN:
-
-       pTemp = strdup(pSrc);
-       nTemp = strlen(pSrc);
-
-       {//temp brace;
-               const char *pToCharSet = "UTF-8";
-
-               UINT16 charset_code =  _MmsGetBinaryValue(MmsCodeCharSet, nCharset);
-
-               const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code);
-
-               if (pFromCharSet != NULL && strcmp(pFromCharSet, pToCharSet) != 0) {//Not UTF-8
-                       char *pDest = NULL;
-                       int destLen = 0;
-
-                       if (MmsPluginTextConvert(pToCharSet, pFromCharSet, pTemp, nTemp, &pDest, &destLen) == false) {
-                               MSG_DEBUG("MmsPluginTextConvert Fail");
-                       }
-
-                       if (pDest) {
-                               free(pTemp);
-                               pTemp = strdup(pDest);
-                               nTemp = destLen;
-                               free(pDest);
-                       }
-               }
-
-       }
-
-       pReturnStr = (char *)malloc(nTemp + 1);
-
-       if (pReturnStr == NULL) {
-               goto __CATCH;
-       }
-
-       memset(pReturnStr, 0, nTemp + 1);
-
-       if (pTemp) {
-               memcpy(pReturnStr, pTemp, nTemp);
-               free(pTemp);
-               pTemp = NULL;
-       }
-
-       if (pConvertedStr) {
-               free(pConvertedStr);
-               pConvertedStr = NULL;
-       }
-
-       if(pRe) {
-               free(pRe);
-               pRe = NULL;
-       }
-
-       if (pSrc != NULL && pSrc != szTempBuf) {
-               free(pSrc);
-               pSrc = NULL;
-       }
-
-       return pReturnStr;
-
-__CATCH:
-
-       if (pConvertedStr) {
-               free(pConvertedStr);
-               pConvertedStr = NULL;
-       }
-
-       if(pRe) {
-               free(pRe);
-               pRe = NULL;
-       }
-
-       if (pSrc != NULL && pSrc != szTempBuf) {
-               free(pSrc);
-               pSrc = NULL;
-       }
-
-       if (pTemp) {
-               free(pTemp);
-               pTemp = NULL;
-       }
-
-       return NULL;
-}
-
-
-char *MsgEncodeText(char *pOri)
-{
-       ULONG nLen = 0;
-       char *szBuff = NULL;
-       int length  = 0;
-
-       length = (strlen(pOri) * 4) / 3 + 2 + 12 + 1 + 30;
-       szBuff = (char *)malloc(length + 1);
-
-       if (szBuff == NULL) {
-               // error handling
-               MSG_DEBUG("_MsgEncodeText: szBuff alloc is failed \n");
-               goto __CATCH;
-       }
-
-       memset(szBuff, 0 , length + 1);
-
-       snprintf(szBuff, length+1, "%s%s%c%c%c", MSG_STR_DEC_START, "utf-8", MSG_CH_QUESTION, MSG_CH_BASE64_LOWER, MSG_CH_QUESTION);
-
-       if (_MsgEncode2Base64((unsigned char *)pOri, strlen(pOri), &nLen, (unsigned char *)szBuff + 10) == false) {
-               MSG_DEBUG("_MsgEncodeText: MsgEncodeBase64() is failed \n");
-               goto __CATCH;
-       }
-
-       strcat(szBuff, MSG_STR_DEC_END);
-
-       return szBuff;
-
-__CATCH:
-       if (szBuff) {
-               free(szBuff);
-       }
-
-       return false;
-}
-
index 08f3729..e70258b 100755 (executable)
@@ -14,7 +14,7 @@
 * limitations under the License.
 */
 
-#include<stdio.h>
+#include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <stdlib.h>
 
 #include "MsgDebug.h"
 #include "MsgException.h"
-#include "MmsPluginMessage.h"
+#include "MmsPluginDecode.h"
+#include "MmsPluginCodecCommon.h"
 #include "MmsPluginStorage.h"
 #include "MsgUtilFile.h"
-#include "MmsPluginCodec.h"
 #include "MmsPluginDebug.h"
 #include "MsgSettingTypes.h"
-#include "MsgSettingHandler.h"
-#include "MmsPluginInternal.h"
 #include "MmsPluginAvCodec.h"
-#include "MmsPluginStorage.h"
 #include "MmsPluginSmil.h"
 #ifdef __SUPPORT_DRM__
 #include "MmsPluginDrm.h"
 #include "MmsPluginTextConvert.h"
 #include "MmsPluginUtil.h"
 
-static bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);          /* bufLen < gMmsDecodeMaxLen */
-static bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);      /* no bufLen limit */
-static bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength);
+/*Decode wsp*/
+static int __MmsGetDecodeOffset(void);
+static bool __MmsDecodeInitialize(void);
+static void __MmsCleanDecodeBuff(void);
+static bool __MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength);
+static bool    __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength);
+
+static bool __MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);         /* bufLen < gMmsDecodeMaxLen */
+static bool __MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength);     /* no bufLen limit */
+static bool __MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength);
+
+static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength);
 
+static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength);
+static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength);
 static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLength);
 static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLength);
 static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalLength);
+static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength);
+static char *__MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength);
 static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, int totalLength);
 static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen, int totalLength);
-static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen, int totalLength);
+
 static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSetLen, int totalLength);
-static char *__MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength);
-static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int totalLength);
-static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int totalLength);
-static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalLength);
 static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int totalLength);
 static MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength);
 
+static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength);
+static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength);
+static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength);
+static bool __MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength);
+static bool __MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength);
+static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength);
+
+static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength);
+
 #ifdef __SUPPORT_DRM__
-bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength);
-bool __MmsParseDCFHdr(FILE *pFile, MsgDRMInfo *pDrmInfo, UINT32 headerLen, int totalLength);
-bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int fullBodyLength, int totalLength);
-bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength);
+static bool __MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength);
 #endif
 
-static bool MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength);
-bool MmsBinaryIsTextEncodedPart(FILE *pFile, int totalLength);
-static bool    __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength);
+static bool __MsgInitMsgBody(MsgBody *pMsgBody);
+static bool __MsgInitMsgType(MsgType *pMsgType);
+
+//util funcion
+static void __MsgRemoveFilePath(char *pSrc);
+static bool __MsgChangeSpace(char *pOrg, char **ppNew);
+static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo);
+static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char* szStart, MimeType typeParam);
+static bool __MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *npRead, int endOfFile);
+static bool __MsgFreeHeaderAddress(MsgHeaderAddress *pAddr);
+static bool __MsgCheckFileNameHasInvalidChar(char *szName);
+
+static bool __MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar);
+static char *__MsgGetStringUntilDelimiter(char *pszString, char delimiter);
+static bool __MsgParseParameter(MsgType *pType, char *pSrc);
+static char *__MsgSkipWS(char *s);
+static char *__MsgSkipComment(char *s, long trim);
+static MsgMultipart *__MsgAllocMultipart(void);
+
+static char *__MsgConvertLatin2UTF8FileName(char *pSrc);
+static bool __MsgIsUTF8String(unsigned char *szSrc, int nChar);
+static bool __MsgIsPercentSign(char *pSrc);
+static bool __MsgIsMultipartRelated(int type);
+static bool __MsgIsPresentablePart(int type);
+static bool __MsgIsText(int type);
+static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody);
+static bool __MsgIsHexChar(char *pSrc);
+static char __MsgConvertHexValue(char *pSrc);
+static int __MsgConvertCharToInt(char ch);
+static bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam);
+static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2);
+static bool __MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2);
+static bool __MsgIsMultipartMixed(int type);
+
+static bool __MsgIsInvalidFileNameChar(char ch);
+
+static int __MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar);
+static int __MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+static int __MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar);
+static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+static int __MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+static int __MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar);
+static int __MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar);
+static int __MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar);
+static bool __MmsAddrUtilCheckEmailAddress(char *pszAddr);
+static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
+static void __MsgMIMERemoveQuote(char *szSrc);
+static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave);
+
+static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE *pFile);
+static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead);
+
+#ifndef        __SUPPORT_DRM__
+static bool __MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex);
+#else
+static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex);
+#endif
 
-bool __MmsTextDecodeMsgHeader(FILE *pFile);
-bool MmsTextDecodeMsgBody(FILE *pFile);
+static bool __MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index);
 
-char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, };
-char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, };
+static char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, };
+static char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1] = {0, };
 
 static char *gpCurMmsDecodeBuff = NULL;
 static int gCurMmsDecodeBuffPos = 0;   /* next decoding position in gpCurMmsDecodeBuff  */
@@ -143,48 +208,16 @@ MmsHeader mmsHeader =
 const UINT32 MMS_UINTVAR_LENGTH_1 =  0x0000007f;               //7bit
 const UINT32 MMS_UINTVAR_LENGTH_2 =  0x00003fff;               //14bit
 const UINT32 MMS_UINTVAR_LENGTH_3 =  0x001fffff;               //21bit
-
 #endif
 
-
-bool _MmsDecodeInitialize(void)
+static bool __MmsDecodeInitialize(void)
 {
        MmsInitMsgType(&mmsHeader.msgType);
        MmsInitMsgBody(&mmsHeader.msgBody);
-
-       return true;
-}
-
-bool __MmsSetMmsHeaderOwner(int msgID, char* pszNewOwner)
-{
-       if (pszNewOwner) {
-               // set new owner
-               MSG_DEBUG("__MmsSetMmsHeaderOwner: set (%s, msgID=%d)\n", pszNewOwner, msgID);
-
-               if ((mmsHeader.pszOwner = (char*)malloc(strlen(pszNewOwner) + 1)) == NULL)
-                       return false;
-
-               memset (mmsHeader.pszOwner, 0, strlen(pszNewOwner) + 1) ;
-
-               strcpy(mmsHeader.pszOwner, pszNewOwner);
-               mmsHeader.bActive = true;
-               mmsHeader.msgID = msgID;
-       } else {
-               // delete current owner
-               if (mmsHeader.pszOwner) {
-                       MSG_DEBUG("__MmsSetMmsHeaderOwner: free (%s %d)\n", mmsHeader.pszOwner, msgID);
-                       free(mmsHeader.pszOwner);
-                       mmsHeader.pszOwner = NULL;
-               }
-               mmsHeader.bActive = false;
-               mmsHeader.msgID = -1;
-       }
-
        return true;
 }
 
-
-void _MmsInitHeader()
+void MmsInitHeader()
 {
        mmsHeader.type = MMS_MSGTYPE_ERROR;
 
@@ -192,10 +225,10 @@ void _MmsInitHeader()
        mmsHeader.version = MMS_VERSION;
        mmsHeader.date = 0;
 
-       MsgFreeHeaderAddress(mmsHeader.pFrom);
-       MsgFreeHeaderAddress(mmsHeader.pTo);
-       MsgFreeHeaderAddress(mmsHeader.pCc);
-       MsgFreeHeaderAddress(mmsHeader.pBcc);
+       __MsgFreeHeaderAddress(mmsHeader.pFrom);
+       __MsgFreeHeaderAddress(mmsHeader.pTo);
+       __MsgFreeHeaderAddress(mmsHeader.pCc);
+       __MsgFreeHeaderAddress(mmsHeader.pBcc);
 
        mmsHeader.pFrom = NULL;
        mmsHeader.pTo = NULL;
@@ -239,12 +272,10 @@ void _MmsInitHeader()
        mmsHeader.drmType = MSG_DRM_TYPE_NONE;
 #endif
 
-       _MmsDecodeInitialize();
+       __MmsDecodeInitialize();
 }
 
-
-
-void _MmsCleanDecodeBuff(void)
+static void __MmsCleanDecodeBuff(void)
 {
        memset(gpMmsDecodeBuf1, 0, gMmsDecodeMaxLen + 1);
        memset(gpMmsDecodeBuf2, 0, gMmsDecodeMaxLen + 1);
@@ -253,19 +284,18 @@ void _MmsCleanDecodeBuff(void)
        gMmsDecodeBufLen = 0;
 }
 
-
-void _MmsRegisterDecodeBuffer(char *pInBuff1, char *pInBuff2, int maxLen)
+void MmsRegisterDecodeBuffer()
 {
-       gpMmsDecodeBuf1 = pInBuff1;
-       gpMmsDecodeBuf2 = pInBuff2;
+       gpMmsDecodeBuf1 = gszMmsLoadBuf1;
+       gpMmsDecodeBuf2 = gszMmsLoadBuf2;
        gpCurMmsDecodeBuff = NULL;
        gCurMmsDecodeBuffPos = 0;
-       gMmsDecodeMaxLen = maxLen;
+       gMmsDecodeMaxLen = MSG_MMS_DECODE_BUFFER_MAX;
        gMmsDecodeCurOffset = 0;
        gMmsDecodeBufLen = 0;
 }
 
-void _MmsUnregisterDecodeBuffer(void)
+void MmsUnregisterDecodeBuffer(void)
 {
        gpMmsDecodeBuf1 = NULL;
        gpMmsDecodeBuf2 = NULL;
@@ -277,12 +307,11 @@ void _MmsUnregisterDecodeBuffer(void)
 }
 
 
-int _MmsGetDecodeOffset(void)
+static int __MmsGetDecodeOffset(void)
 {
        return (gMmsDecodeCurOffset - gMmsDecodeBufLen + gCurMmsDecodeBuffPos);
 }
 
-
 static bool __MmsBinaryDecodeCheckAndDecreaseLength(int *pLength, int valueLength)
 {
        if (*pLength <= valueLength) {
@@ -356,32 +385,32 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
        char *pLimitData = NULL;
        int nRead = 0;
 
-       MSG_DEBUG("MmsBinaryDecodeMsgHeader: pFile=%d, total len=%d\n", pFile, totalLength);
+       MSG_DEBUG("pFile=%d, total len=%d\n", pFile, totalLength);
 
-       _MmsCleanDecodeBuff();
+       __MmsCleanDecodeBuff();
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
                                                                   &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
                                                                   gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
-               MSG_DEBUG("MmsBinaryDecodeMsgHeader: fail to load to buffer \n");
+               MSG_DEBUG("fail to load to buffer \n");
                goto __CATCH;
        }
 
-       while (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength)) {
+       while (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength)) {
                fieldCode = oneByte & 0x7f;
 
-               switch (_MmsGetBinaryType(MmsCodeFieldCode, fieldCode)) {
+               switch (MmsGetBinaryType(MmsCodeFieldCode, fieldCode)) {
                case MMS_CODE_RESPONSESTATUS:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("responseStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       fieldValue = _MmsGetBinaryType(MmsCodeResponseStatus, (UINT16)(oneByte & 0x7F));
+                       fieldValue = MmsGetBinaryType(MmsCodeResponseStatus, (UINT16)(oneByte & 0x7F));
 
                        if (fieldValue == 0xFFFF) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus error\n");
+                               MSG_DEBUG("responseStatus error\n");
                                goto __CATCH;
                        }
 
@@ -393,21 +422,21 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        mmsHeader.responseStatus = (MmsResponseStatus)fieldValue;
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: response status = %s\n", MmsDebugGetResponseStatus(mmsHeader.responseStatus));
+                       MSG_DEBUG("response status = %s\n", MmsDebugGetResponseStatus(mmsHeader.responseStatus));
 
                        break;
 
                case MMS_CODE_RETRIEVESTATUS:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieveStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("retrieveStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       fieldValue = _MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(oneByte & 0x7F));
+                       fieldValue = MmsGetBinaryType(MmsCodeRetrieveStatus, (UINT16)(oneByte & 0x7F));
 
                        if (fieldValue == 0xFFFF) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieveStatus error\n");
+                               MSG_DEBUG("retrieveStatus error\n");
                                goto __CATCH;
                        }
 
@@ -419,7 +448,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        mmsHeader.retrieveStatus = (MmsRetrieveStatus)fieldValue;
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieve status = %s\n",
+                       MSG_DEBUG("retrieve status = %s\n",
                                                                                                                        MmsDebugGetRetrieveStatus(mmsHeader.retrieveStatus));
 
                        break;
@@ -427,53 +456,53 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                case MMS_CODE_RESPONSETEXT:
 
                        if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szResponseText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RESPONSETEXT \n");
+                               MSG_DEBUG("invalid MMS_CODE_RESPONSETEXT \n");
                                goto __CATCH;
                        }
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: response text = %s\n", mmsHeader.szResponseText);
+                       MSG_DEBUG("response text = %s\n", mmsHeader.szResponseText);
                        break;
 
                case MMS_CODE_RETRIEVETEXT:
 
                        if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szRetrieveText, MMS_LOCALE_RESP_TEXT_LEN + 1, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RETRIEVETEXT \n");
+                               MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT \n");
                                goto __CATCH;
                        }
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: retrieve text = %s\n", mmsHeader.szResponseText);
+                       MSG_DEBUG("retrieve text = %s\n", mmsHeader.szResponseText);
                        break;
 
                case MMS_CODE_MSGID:
 
                        if (__MmsBinaryDecodeText(pFile, mmsHeader.szMsgID, MMS_MSG_ID_LEN + 1, totalLength) < 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_MSGID is invalid\n");
+                               MSG_DEBUG("MMS_CODE_MSGID is invalid\n");
                                goto __CATCH;
                        }
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg id = %s\n", mmsHeader.szMsgID);
+                       MSG_DEBUG("msg id = %s\n", mmsHeader.szMsgID);
 
                        if (MsgStrlen (mmsHeader.szMsgID) > 2)
-                               MsgMIMERemoveQuote (mmsHeader.szMsgID);
+                               __MsgMIMERemoveQuote (mmsHeader.szMsgID);
 
                        break;
 
                case MMS_CODE_SUBJECT:
 
                        if (__MmsBinaryDecodeEncodedString(pFile, mmsHeader.szSubject, MSG_LOCALE_SUBJ_LEN + 1, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_SUBJECT \n");
+                               MSG_DEBUG("invalid MMS_CODE_SUBJECT \n");
                                goto __CATCH;
                        }
 
                        pLimitData = (char *)malloc(MSG_LOCALE_SUBJ_LEN + 1);
 
                        if (pLimitData == NULL) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : pLimitData malloc fail \n");
+                               MSG_DEBUG("pLimitData malloc fail \n");
                                goto __CATCH;
                        }
 
-                       nRead = MsgCutUTFString((unsigned char*)pLimitData, MSG_LOCALE_SUBJ_LEN + 1, (unsigned char*)mmsHeader.szSubject, MSG_SUBJ_LEN);
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : Subject edit.. \n");
+                       nRead = __MsgCutUTFString((unsigned char*)pLimitData, MSG_LOCALE_SUBJ_LEN + 1, (unsigned char*)mmsHeader.szSubject, MSG_SUBJ_LEN);
+                       MSG_DEBUG("Subject edit.. \n");
 
                        if (nRead > MSG_LOCALE_SUBJ_LEN) {
                                memset(mmsHeader.szSubject, 0 , sizeof(mmsHeader.szSubject));
@@ -488,7 +517,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                pLimitData = NULL;
                        }
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: subject = %s\n", mmsHeader.szSubject);
+                       MSG_DEBUG("subject = %s\n", mmsHeader.szSubject);
                        break;
 
                case MMS_CODE_FROM:
@@ -496,12 +525,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("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM is invalid\n");
+                               MSG_DEBUG("MMS_CODE_FROM is invalid\n");
                                goto __CATCH;
                        }
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: MMS_CODE_FROM GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("MMS_CODE_FROM GetOneByte fail\n");
                                goto __CATCH;
                        }
 
@@ -509,11 +538,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        valueLength--;
 
-                       if (oneByte == (_MmsGetBinaryValue(MmsCodeAddressType, MMS_ADDRESS_PRESENT_TOKEN)|0x80)) {
+                       if (oneByte == (MmsGetBinaryValue(MmsCodeAddressType, MMS_ADDRESS_PRESENT_TOKEN)|0x80)) {
                                if (valueLength > 0) {
                                        mmsHeader.pFrom = __MmsDecodeEncodedAddress(pFile, totalLength);
                                        if (mmsHeader.pFrom == NULL) {
-                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM __MmsDecodeEncodedAddress fail\n");
+                                               MSG_DEBUG("MMS_CODE_FROM __MmsDecodeEncodedAddress fail\n");
                                                goto __CATCH;
                                        }
                                } else {
@@ -532,14 +561,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                        mmsHeader.pFrom->pNext = NULL;
                                }
 
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: from = %s\n", mmsHeader.pFrom->szAddr);
+                               MSG_DEBUG("from = %s\n", mmsHeader.pFrom->szAddr);
                                // DRM_TEMPLATE - end
-                       } else if (oneByte == (_MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) {
+                       } else if (oneByte == (MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN)|0x80)) {
                                /* Present Token only */
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_FROM insert token\n");
+                               MSG_DEBUG("MMS_CODE_FROM insert token\n");
                        } else {
                                /* from data broken */
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: from addr broken\n");
+                               MSG_DEBUG("from addr broken\n");
                                gCurMmsDecodeBuffPos--;
                                goto __CATCH;
                        }
@@ -549,7 +578,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
                        if (pAddr == NULL) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_TO __MmsDecodeEncodedAddress fail\n");
+                               MSG_DEBUG("MMS_CODE_TO __MmsDecodeEncodedAddress fail\n");
                                goto __CATCH;
                        }
 
@@ -562,14 +591,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                pLastTo = pAddr;
                        }
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: to = %s\n", mmsHeader.pTo->szAddr);
+                       MSG_DEBUG("to = %s\n", mmsHeader.pTo->szAddr);
                        break;
 
                case MMS_CODE_BCC:
 
                        pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
                        if (pAddr == NULL) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_BCC __MmsDecodeEncodedAddress fail\n");
+                               MSG_DEBUG("MMS_CODE_BCC __MmsDecodeEncodedAddress fail\n");
                                goto __CATCH;
                        }
 
@@ -582,14 +611,14 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                pLastBcc = pAddr;
                        }
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: bcc = %s\n", mmsHeader.pBcc->szAddr);
+                       MSG_DEBUG("bcc = %s\n", mmsHeader.pBcc->szAddr);
                        break;
 
                case MMS_CODE_CC:
 
                        pAddr = __MmsDecodeEncodedAddress(pFile, totalLength);
                        if (pAddr == NULL) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_CC __MmsDecodeEncodedAddress fail\n");
+                               MSG_DEBUG("MMS_CODE_CC __MmsDecodeEncodedAddress fail\n");
                                goto __CATCH;
                        }
 
@@ -601,44 +630,44 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                        pLastCc->pNext = pAddr;
                                pLastCc = pAddr;
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: cc = %s\n", mmsHeader.pCc->szAddr);
+                       MSG_DEBUG("cc = %s\n", mmsHeader.pCc->szAddr);
                        break;
 
                case MMS_CODE_CONTENTLOCATION:
 
                        if (__MmsBinaryDecodeText(pFile, mmsHeader.szContentLocation, MMS_LOCATION_LEN + 1, totalLength) < 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_CONTENTLOCATION is invalid\n");
+                               MSG_DEBUG("MMS_CODE_CONTENTLOCATION is invalid\n");
                                goto __CATCH;
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: content location = %s\n", mmsHeader.szContentLocation);
+                       MSG_DEBUG("content location = %s\n", mmsHeader.szContentLocation);
                        break;
 
                case MMS_CODE_DATE:
 
                        if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.date, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_DATE is invalid\n");
+                               MSG_DEBUG("MMS_CODE_DATE is invalid\n");
                                goto __CATCH;
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: date = %d\n", mmsHeader.date);
+                       MSG_DEBUG("date = %d\n", mmsHeader.date);
                        break;
 
                case MMS_CODE_DELIVERYREPORT:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: deliveryReport GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("deliveryReport GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       fieldValue = _MmsGetBinaryType(MmsCodeDeliveryReport, (UINT16)(oneByte & 0x7F));
+                       fieldValue = MmsGetBinaryType(MmsCodeDeliveryReport, (UINT16)(oneByte & 0x7F));
 
                        if (fieldValue == 0xFFFF) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: deliveryReport error\n");
+                               MSG_DEBUG("deliveryReport error\n");
                                goto __CATCH;
                        }
 
                        mmsHeader.deliveryReport = (MmsReport)fieldValue;
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery report=%s\n", MmsDebugGetMmsReport(mmsHeader.deliveryReport));
+                       MSG_DEBUG("delivery report=%s\n", MmsDebugGetMmsReport(mmsHeader.deliveryReport));
                        break;
 
                case MMS_CODE_DELIVERYTIME:
@@ -646,24 +675,24 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        /* value_length (absolute-token Long-integer | Relative-token Long-integer) */
 
                        if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_DELIVERYTIME \n");
+                               MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME \n");
                                goto __CATCH;
                        }
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery time GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("delivery time GetOneByte fail\n");
                                goto __CATCH;
                        }
 
                        //DRM_TEMPLATE - start
                        valueLength--;
 
-                       if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
+                       if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
                                mmsHeader.deliveryTime.type = MMS_TIMETYPE_ABSOLUTE;
 
                                if (valueLength > 0) {
                                        if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.deliveryTime.time, totalLength) == false) {
-                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_DELIVERYTIME\n");
+                                               MSG_DEBUG("invalid MMS_CODE_DELIVERYTIME\n");
                                                goto __CATCH;
                                        }
                                }
@@ -672,11 +701,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("MmsBinaryDecodeMsgHeader : __MmsBinaryDecodeInteger fail...\n");
+                                       MSG_DEBUG("__MmsBinaryDecodeInteger fail...\n");
                                        goto __CATCH;
                                }
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: delivery type=%d, time=%d\n", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time);
+                       MSG_DEBUG("delivery type=%d, time=%d\n", mmsHeader.deliveryTime.type, mmsHeader.deliveryTime.time);
                        break;
 
                case MMS_CODE_EXPIRYTIME:
@@ -684,24 +713,24 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        /* value_length(absolute-token Long-integer | Relative-token Long-integer) */
 
                        if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_EXPIRYTIME \n");
+                               MSG_DEBUG("invalid MMS_CODE_EXPIRYTIME \n");
                                goto __CATCH;
                        }
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: expiry time GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("expiry time GetOneByte fail\n");
                                goto __CATCH;
                        }
 
                        // DRM_TEMPLATE - start
                        valueLength--;
 
-                       if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
+                       if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE)|0x80)) {
                                mmsHeader.expiryTime.type = MMS_TIMETYPE_ABSOLUTE;
 
                                if (valueLength > 0) {
                                        if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, totalLength) == false) {
-                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_EXPIRYTIME is invalid\n");
+                                               MSG_DEBUG("MMS_CODE_EXPIRYTIME is invalid\n");
                                                goto __CATCH;
                                        }
                                }
@@ -710,103 +739,103 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                mmsHeader.expiryTime.type = MMS_TIMETYPE_RELATIVE;
 
                                if (__MmsBinaryDecodeInteger(pFile, (UINT32*)&mmsHeader.expiryTime.time, &tmpIntLen, totalLength) == false) {
-                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : __MmsBinaryDecodeInteger fail...\n");
+                                       MSG_DEBUG("__MmsBinaryDecodeInteger fail...\n");
                                        goto __CATCH;
                                }
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: expiry = %d\n", mmsHeader.expiryTime.time);
+                       MSG_DEBUG("expiry = %d\n", mmsHeader.expiryTime.time);
                        break;
 
                case MMS_CODE_MSGCLASS:
 
                        /* Class-value = Class-identifier | Token Text */
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgClass GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgClass GetOneByte fail\n");
                                goto __CATCH;
                        }
 
                        if (oneByte > 0x7f) {
                                /* Class-identifier */
-                               mmsHeader.msgClass = (MmsMsgClass)_MmsGetBinaryType(MmsCodeMsgClass, (UINT16)(oneByte & 0x7F));
+                               mmsHeader.msgClass = (MmsMsgClass)MmsGetBinaryType(MmsCodeMsgClass, (UINT16)(oneByte & 0x7F));
                        } else {
                                if (__MmsBinaryDecodeText(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) < 0) {
-                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: 1. __MmsBinaryDecodeText fail. (class)\n");
+                                       MSG_DEBUG("1. __MmsBinaryDecodeText fail. (class)\n");
                                        goto __CATCH;
                                }
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg class=%s\n", MmsDebugGetMsgClass(mmsHeader.msgClass));
+                       MSG_DEBUG("msg class=%s\n", MmsDebugGetMsgClass(mmsHeader.msgClass));
                        break;
 
                case MMS_CODE_MSGSIZE:
 
                        if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.msgSize, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_MSGSIZE is invalid\n");
+                               MSG_DEBUG("MMS_CODE_MSGSIZE is invalid\n");
                                goto __CATCH;
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg size = %d\n", mmsHeader.msgSize);
+                       MSG_DEBUG("msg size = %d\n", mmsHeader.msgSize);
                        break;
 
                case MMS_CODE_MSGSTATUS:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       mmsHeader.msgStatus =  (msg_delivery_report_status_t)_MmsGetBinaryType(MmsCodeMsgStatus, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg status=%s \n", MmsDebugGetMsgStatus(mmsHeader.msgStatus)) ;
+                       mmsHeader.msgStatus =  (msg_delivery_report_status_t)MmsGetBinaryType(MmsCodeMsgStatus, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("msg status=%s \n", MmsDebugGetMsgStatus(mmsHeader.msgStatus)) ;
                        break;
 
                case MMS_CODE_MSGTYPE:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       mmsHeader.type = (MmsMsgType)_MmsGetBinaryType(MmsCodeMsgType, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: msg type=%s\n", MmsDebugGetMsgType(mmsHeader.type));
+                       mmsHeader.type = (MmsMsgType)MmsGetBinaryType(MmsCodeMsgType, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("msg type=%s\n", MmsDebugGetMsgType(mmsHeader.type));
                        break;
 
                case MMS_CODE_PRIORITY:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
-                       mmsHeader.priority = (MmsPriority)_MmsGetBinaryType(MmsCodePriority, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: priority=%d\n", mmsHeader.priority);
+                       mmsHeader.priority = (MmsPriority)MmsGetBinaryType(MmsCodePriority, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("priority=%d\n", mmsHeader.priority);
                        break;
 
                case MMS_CODE_READREPLY:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
-                       mmsHeader.readReply = (MmsReport)_MmsGetBinaryType(MmsCodeReadReply, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: read reply=%s \n", MmsDebugGetMmsReport(mmsHeader.readReply));
+                       mmsHeader.readReply = (MmsReport)MmsGetBinaryType(MmsCodeReadReply, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("read reply=%s \n", MmsDebugGetMmsReport(mmsHeader.readReply));
                        break;
 
                case MMS_CODE_REPORTALLOWED:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
-                       mmsHeader.reportAllowed =  (MmsReportAllowed)_MmsGetBinaryType(MmsCodeReportAllowed, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: mmsHeader.reportAllowed=%d\n", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed));
+                       mmsHeader.reportAllowed =  (MmsReportAllowed)MmsGetBinaryType(MmsCodeReportAllowed, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("mmsHeader.reportAllowed=%d\n", MmsDebugGetMmsReportAllowed(mmsHeader.reportAllowed));
                        break;
 
                case MMS_CODE_SENDERVISIBILLITY:
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
-                       mmsHeader.hideAddress= (MmsSenderVisible)!(_MmsGetBinaryType(MmsCodeSenderVisibility, (UINT16)(oneByte &0x7F)));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: sender visible=%d \n", mmsHeader.hideAddress);
+                       mmsHeader.hideAddress= (MmsSenderVisible)!(MmsGetBinaryType(MmsCodeSenderVisibility, (UINT16)(oneByte &0x7F)));
+                       MSG_DEBUG("sender visible=%d \n", mmsHeader.hideAddress);
                        break;
 
                case MMS_CODE_TRID:
@@ -815,17 +844,17 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                                MSG_DEBUG("Transaction ID Too Long \n");
                                goto __CATCH;
                        }
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: trID = %s\n", mmsHeader.szTrID);
+                       MSG_DEBUG("trID = %s\n", mmsHeader.szTrID);
                        break;
 
                case MMS_CODE_VERSION:
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
                        mmsHeader.version = oneByte;
 
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: ver = 0x%x\n", mmsHeader.version);
+                       MSG_DEBUG("ver = 0x%x\n", mmsHeader.version);
                        break;
 
                case MMS_CODE_CONTENTTYPE:
@@ -844,26 +873,26 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        /* Read-status-value = Read | Deleted without being read */
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       mmsHeader.readStatus =  (msg_read_report_status_t)_MmsGetBinaryType(MmsCodeReadStatus, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: read status=%s\n", MmsDebugGetMmsReadStatus(mmsHeader.readStatus));
+                       mmsHeader.readStatus =  (msg_read_report_status_t)MmsGetBinaryType(MmsCodeReadStatus, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("read status=%s\n", MmsDebugGetMmsReadStatus(mmsHeader.readStatus));
                        break;
 
                case MMS_CODE_REPLYCHARGING:
 
                        /* Reply-charging-value = Requested | Requested text only | Accepted | Accepted text only */
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       mmsHeader.replyCharge.chargeType =  (MmsReplyChargeType)_MmsGetBinaryType(MmsCodeReplyCharging, (UINT16)(oneByte & 0x7F));
-                       MSG_DEBUG("MmsBinaryDecodeMsgHeader: mmsHeader.reply charge=%d\n", mmsHeader.replyCharge.chargeType);
+                       mmsHeader.replyCharge.chargeType =  (MmsReplyChargeType)MmsGetBinaryType(MmsCodeReplyCharging, (UINT16)(oneByte & 0x7F));
+                       MSG_DEBUG("mmsHeader.reply charge=%d\n", mmsHeader.replyCharge.chargeType);
                        break;
 
                case MMS_CODE_REPLYCHARGINGDEADLINE:
@@ -871,16 +900,16 @@ 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("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_REPLYCHARGINGDEADLINE \n");
+                               MSG_DEBUG("invalid MMS_CODE_REPLYCHARGINGDEADLINE \n");
                                goto __CATCH;
                        }
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: msgStatus GetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("msgStatus GetOneByte fail\n");
                                goto __CATCH;
                        }
 
-                       if (oneByte == (_MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80)) {
+                       if (oneByte == (MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80)) {
                                mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_ABSOLUTE;
                        } else {
                                mmsHeader.replyCharge.deadLine.type = MMS_TIMETYPE_RELATIVE;
@@ -891,7 +920,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                        if (valueLength > 0) {
                                if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.deadLine.time, totalLength) == false) {
-                                       MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_REPLYCHARGINGDEADLINE is invalid\n");
+                                       MSG_DEBUG("MMS_CODE_REPLYCHARGINGDEADLINE is invalid\n");
                                        goto __CATCH;
                                }
                        }
@@ -903,7 +932,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        /* Reply-charging-ID-value = Text-string */
 
                        if (__MmsBinaryDecodeText(pFile, mmsHeader.replyCharge.szChargeID, MMS_MSG_ID_LEN + 1, totalLength) < 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: 1. __MmsBinaryDecodeText fail. (szReplyChargingID)\n");
+                               MSG_DEBUG("1. __MmsBinaryDecodeText fail. (szReplyChargingID)\n");
                                goto __CATCH;
                        }
                        break;
@@ -913,7 +942,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        /* Reply-charging-size-value = Long-integer */
 
                        if (__MmsDecodeLongInteger(pFile, (UINT32*)&mmsHeader.replyCharge.chargeSize, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : MMS_CODE_REPLYCHARGINGSIZE is invalid\n");
+                               MSG_DEBUG("MMS_CODE_REPLYCHARGINGSIZE is invalid\n");
                                goto __CATCH;
                        }
                        break;
@@ -932,17 +961,17 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                         */
 
                        if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
+                               MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
                                goto __CATCH;
                        }
 
                        if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 2. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
+                               MSG_DEBUG("2. invalid MMS_CODE_PREVIOUSLYSENTBY \n");
                                goto __CATCH;
                        }
 
                        if (__MmsBinaryDecodeEncodedString(pFile, szGarbageBuff, MSG_STDSTR_LONG, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : invalid MMS_CODE_RETRIEVETEXT \n");
+                               MSG_DEBUG("invalid MMS_CODE_RETRIEVETEXT \n");
                                goto __CATCH;
                        }
                        break;
@@ -961,22 +990,21 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                         */
 
                        if (__MmsDecodeValueLength(pFile, &valueLength, totalLength) <= 0) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+                               MSG_DEBUG("1. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
                                goto __CATCH;
                        }
 
                        if (__MmsBinaryDecodeInteger(pFile, &tmpInteger, &tmpIntLen, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 2. invalid MS_CODE_PREVIOUSLYSENTDATE \n");
+                               MSG_DEBUG("2. invalid MS_CODE_PREVIOUSLYSENTDATE \n");
                                goto __CATCH;
                        }
 
                        if (__MmsDecodeLongInteger(pFile, (UINT32*)&tmpInteger, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeMsgHeader : 3. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
+                               MSG_DEBUG("3. invalid MMS_CODE_PREVIOUSLYSENTDATE \n");
                                goto __CATCH;
                        }
                        break;
 
-
                default:
 
                        /*
@@ -994,7 +1022,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                                oneByte = 0x00;
 
-                               offset = _MmsGetDecodeOffset();
+                               offset = __MmsGetDecodeOffset();
                                if (offset >= totalLength)
                                        goto __RETURN;
 
@@ -1002,11 +1030,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
 
                                while ((oneByte < 0x80) && (remainLength > 0)) {
                                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&remainLength, 1) == false) {
-                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: __MmsBinaryDecodeCheckAndDecreaseLength fail\n");
+                                               MSG_DEBUG("__MmsBinaryDecodeCheckAndDecreaseLength fail\n");
                                                goto __CATCH;
                                        }
-                                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                                               MSG_DEBUG("MmsBinaryDecodeMsgHeader: responseStatus GetOneByte fail\n");
+                                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                               MSG_DEBUG("responseStatus GetOneByte fail\n");
                                                goto __CATCH;
                                        }
                                }
@@ -1017,7 +1045,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength)
                        break;
                }       /* switch */
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
@@ -1038,7 +1066,7 @@ __RETURN:
                free(pLastBcc);
        }
 
-       MSG_DEBUG("MmsBinaryDecodeMsgHeader: success\n");
+       MSG_DEBUG("success\n");
        return true;
 
 
@@ -1056,78 +1084,40 @@ __CATCH:
                free(pLastBcc);
        }
 
-       MSG_DEBUG("MmsBinaryDecodeMsgHeader: failed\n");
+       MSG_DEBUG("failed\n");
 
        return false;
 }
 
-#ifdef FEATURE_JAVA_MMS
-// for JAVA MMS AppId - check later whether it can be handled by MmsBinaryDecodeMsgHeader
-bool MmsBinaryDecodeContentType(FILE *pFile, char *szFilePath, int totalLength)
-{
-       int length      = 0;
-
-       MSG_DEBUG("MmsBinaryDecodeContentType:\n");
-
-       if (szFilePath != NULL)
-               strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath, strlen(szFilePath));
-       mmsHeader.msgType.offset = _MmsGetDecodeOffset() - 1;           // + Content-Type code value
-
-       // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
-                                                                       &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
-                                                                       gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
-               MSG_DEBUG("MmsBinaryDecodeContentType: fail to load to buffer \n");
-               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("MmsBinaryDecodeContentType: MMS_CODE_CONTENTTYPE is fail\n");
-               goto __CATCH;
-       }
-       MSG_DEBUG("Content-Type: Application-ID:%s Reply-To-Application-ID:%s",mmsHeader.msgType.param.szApplicationID, mmsHeader.msgType.param.szReplyToApplicationID);
-
-       return true;
-
-__CATCH:
-
-       /* fixme: Delete multipart using MmsDeleteMsg() */
-
-       return false;
-}
-#endif
-
 bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
 {
+       MSG_BEGIN();
+
        int length = 0;
        int offset = 0;
 
-       MSG_DEBUG("MmsBinaryDecodeMsgBody:\n");
-
        if (szFilePath != NULL)
                strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath , strlen(szFilePath));
 
-       mmsHeader.msgType.offset = _MmsGetDecodeOffset() - 1;           // + Content-Type code value
+       mmsHeader.msgType.offset = __MmsGetDecodeOffset() - 1;          // + Content-Type code value
 
        // read data(2K) from msg file(/User/Msg/Inbox/5) to gpCurMmsDecodeBuff for decoding
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos,
                                                                        &gMmsDecodeCurOffset, gpMmsDecodeBuf1, gpMmsDecodeBuf2,
                                                                        gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
-               MSG_DEBUG("MmsBinaryDecodeMsgBody: fail to load to buffer \n");
+               MSG_DEBUG("fail to load to buffer \n");
                goto __CATCH;
        }
 
        // msg's type [ex] related, mixed, single part (jpg, amr and etc)
-       length = MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength);
+       length = __MmsBinaryDecodeContentType(pFile, &mmsHeader.msgType, totalLength);
        if (length == -1) {
-               MSG_DEBUG("MmsBinaryDecodeMsgBody: MMS_CODE_CONTENTTYPE is fail\n");
+               MSG_DEBUG("MMS_CODE_CONTENTTYPE is fail\n");
                goto __CATCH;
        }
 
-       mmsHeader.msgType.size   = length + 1;                                          // + Content-Type code value
-       mmsHeader.msgBody.offset = _MmsGetDecodeOffset();
+       mmsHeader.msgType.size   = length + 1; // + Content-Type code value
+       mmsHeader.msgBody.offset = __MmsGetDecodeOffset();
 
        switch (mmsHeader.msgType.type) {
        case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED:
@@ -1141,14 +1131,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("__MmsBinaryMsgBodyDecode: Decode multipart\n");
+               MSG_DEBUG("Decode multipart\n");
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
-               if (MmsBinaryDecodeMultipart(pFile, szFilePath, &mmsHeader.msgType, &mmsHeader.msgBody, totalLength) == false) {
-                       MSG_DEBUG("__MmsBinaryMsgBodyDecode: MmsBinaryDecodeMultipart is fail.\n");
+               if (__MmsBinaryDecodeMultipart(pFile, szFilePath, &mmsHeader.msgType, &mmsHeader.msgBody, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeMultipart is fail.\n");
                        goto __CATCH;
                }
                break;
@@ -1159,12 +1149,12 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
                if (szFilePath != NULL)
                        strcpy(mmsHeader.msgBody.szOrgFilePath, szFilePath);
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
-               if (MmsBinaryDecodePartBody(pFile, totalLength - mmsHeader.msgBody.offset, totalLength) == false) {
-                       MSG_DEBUG("__MmsBinaryMsgBodyDecode: MmsBinaryDecodePartBody is fail.(Single Part)\n");
+               if (__MmsBinaryDecodePartBody(pFile, totalLength - mmsHeader.msgBody.offset, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodePartBody is fail.(Single Part)\n");
                        goto __CATCH;
                }
 
@@ -1179,27 +1169,14 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength)
 #endif
 
 __RETURN:
-
+       MSG_END();
        return true;
 
 __CATCH:
-
        return false;
 }
 
-#if MMS_ENABLE_EXTEND_CFM
-// DRM (Extended)CFM
-//     Get Extended CFM value.
-static bool __MmsConvertString2Bool(char *pszValue)
-{
-       if (!strcasecmp(pszValue, "no"))
-               return true;
-
-       return false;
-}
-#endif
-
-bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength)
+static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, int totalLength)
 {
        UINT8 oneByte = 0;
        int charSetLen = 0;
@@ -1216,11 +1193,11 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
         * WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.107)
         */
 
-       MSG_DEBUG("MmsBinaryDecodeParameter: \n");
+       MSG_BEGIN();
 
        while (valueLength > 0) {
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                       MSG_DEBUG("MmsBinaryDecodeContentType: paramCode _MmsBinaryDecodeGetOneByte fail\n");
+               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("paramCode _MmsBinaryDecodeGetOneByte fail\n");
                        goto __CATCH;
                }
 
@@ -1251,8 +1228,8 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
                                goto __CATCH;
                        }
 
-                       if (MsgCheckFileNameHasInvalidChar(pMsgType->param.szName)) {
-                               _MsgReplaceInvalidFileNameChar(pMsgType->param.szName, '_');
+                       if (__MsgCheckFileNameHasInvalidChar(pMsgType->param.szName)) {
+                               __MsgReplaceInvalidFileNameChar(pMsgType->param.szName, '_');
                        }
 
                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, length) == false)
@@ -1269,8 +1246,8 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
                                goto __CATCH;
                        }
 
-                       if (MsgCheckFileNameHasInvalidChar(pMsgType->param.szFileName)) {
-                               _MsgReplaceInvalidFileNameChar(pMsgType->param.szFileName, '_');
+                       if (__MsgCheckFileNameHasInvalidChar(pMsgType->param.szFileName)) {
+                               __MsgReplaceInvalidFileNameChar(pMsgType->param.szFileName, '_');
                        }
 
                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, length) == false)
@@ -1280,13 +1257,13 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
 
                case 0x89: //type = Constrained-encoding = Extension-Media | Short-integer
 
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                               MSG_DEBUG("MmsBinaryDecodeContentType: type _MmsBinaryDecodeGetOneByte fail\n");
+                       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                               MSG_DEBUG("type _MmsBinaryDecodeGetOneByte fail\n");
                                goto __CATCH;
                        }
 
                        if (oneByte > 0x7f) {
-                               pMsgType->param.type = _MmsGetBinaryType(MmsCodeContentType,
+                               pMsgType->param.type = MmsGetBinaryType(MmsCodeContentType,
                                                                                                                  (UINT16)(oneByte & 0x7f));
                                if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, 1) == false)
                                        goto __RETURN;
@@ -1295,7 +1272,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
 
                                textLength = 0;
                                szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
-                               pMsgType->param.type = _MmsGetTextType(MmsCodeContentType, szTypeString);
+                               pMsgType->param.type = MmsGetTextType(MmsCodeContentType, szTypeString);
 
                                if (szTypeString) {
                                        free(szTypeString);
@@ -1347,7 +1324,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
                default:
 
                        if (paramCode > 0x7F) {
-                               MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter\n");
+                               MSG_DEBUG("Unsupported parameter\n");
 
                                // In case of the last byte of Parameter field, it should be returned without decreasing the gCurMmsDecodeBuffPos value.
                                valueLength++;
@@ -1378,7 +1355,7 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
                                /* Text-value */
 
                                if (__MmsBinaryDecodeInteger(pFile, &integer, &intLen, totalLength) == true) {
-                                       MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%d)\n", integer);
+                                       MSG_DEBUG("Unsupported parameter(%d)\n", integer);
                                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, intLen) == false)
                                                goto __RETURN;
                                } else {
@@ -1406,14 +1383,14 @@ bool MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int valueLength, i
                                                free(szTypeValue);
                                                szTypeValue = NULL;
 
-                                               MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%s)\n", szTypeValue);
+                                               MSG_DEBUG("Unsupported parameter(%s)\n", szTypeValue);
                                                if (__MmsBinaryDecodeCheckAndDecreaseLength(&valueLength, textLength) == false)
                                                        goto __RETURN;
                                        }
                                }
 
                                if (szTypeString) {
-                                       MSG_DEBUG("MmsBinaryDecodeContentType: Unsupported parameter(%s)\n", szTypeString);
+                                       MSG_DEBUG("Unsupported parameter(%s)\n", szTypeString);
                                        free(szTypeString);
                                        szTypeString = NULL;
                                }
@@ -1438,8 +1415,6 @@ __CATCH:
        return false;
 }
 
-
-
 /**
  * Decode Encoded Content type
  *
@@ -1447,7 +1422,7 @@ __CATCH:
  * @param      pMsgType                [out] Decoded MsgType
  * @return     Decoded address list
  */
-int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
+static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
 {
        UINT8 oneByte = 0;
        char *szTypeString = NULL;
@@ -1466,8 +1441,7 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
         * Media-type                   = (Well-known-media | Extension-Media) *(Parameter)
         */
 
-       MSG_DEBUG("MmsBinaryDecodeContentType: decoding content type..\n");
-
+       MSG_DEBUG("decoding content type..\n");
 
        length = __MmsDecodeValueLength(pFile, (UINT32*)&valueLength, totalLength);
        if (length <= 0) {
@@ -1478,14 +1452,14 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
                 * Short-integer     = OCTET(1xxx xxxx)
                 */
 
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                       MSG_DEBUG("MmsBinaryDecodeContentType: Constrained-media _MmsBinaryDecodeGetOneByte fail\n");
+               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("Constrained-media _MmsBinaryDecodeGetOneByte fail\n");
                        goto __CATCH;
                }
 
                if (oneByte > 0x7F) {
                        /* Short-integer */
-                       pMsgType->type = _MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F));
+                       pMsgType->type = MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F));
                        length = 1;
                } else {
                        char *pszTemp = NULL;
@@ -1497,14 +1471,14 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
                        szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
 
                        if (szTypeString && (strchr(szTypeString, ';')) != NULL) {
-                               pszTemp = _MsgGetStringUntilDelimiter(szTypeString, ';');
+                               pszTemp = __MsgGetStringUntilDelimiter(szTypeString, ';');
                                if (pszTemp) {
                                        free(szTypeString);
                                        szTypeString = pszTemp;
                                }
                        }
 
-                       pMsgType->type = _MmsGetTextType(MmsCodeContentType, szTypeString);
+                       pMsgType->type = MmsGetTextType(MmsCodeContentType, szTypeString);
 
                        length = textLength;
 
@@ -1521,14 +1495,14 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
 
                length += valueLength;
 
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                       MSG_DEBUG("MmsBinaryDecodeContentType: Well-known-media _MmsBinaryDecodeGetOneByte fail\n");
+               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("Well-known-media _MmsBinaryDecodeGetOneByte fail\n");
                        goto __CATCH;
                }
 
                if (oneByte > 0x7F) {
                        /* Well-known-media */
-                       pMsgType->type = _MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F));
+                       pMsgType->type = MmsGetBinaryType(MmsCodeContentType, (UINT16)(oneByte & 0x7F));
                        valueLength--;
                } else {
                        /* Extension-Media */
@@ -1536,7 +1510,7 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
 
                        textLength = 0;
                        szTypeString = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
-                       pMsgType->type = _MmsGetTextType(MmsCodeContentType, szTypeString);
+                       pMsgType->type = MmsGetTextType(MmsCodeContentType, szTypeString);
                        valueLength -= textLength;
 
                        if (szTypeString) {
@@ -1545,11 +1519,11 @@ int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength)
                        }
                }
 
-               MSG_DEBUG("MmsBinaryDecodeContentType: content type=%s\n", MmsDebugGetMimeType((MimeType)pMsgType->type));
+               MSG_DEBUG("content type=%s\n", MmsDebugGetMimeType((MimeType)pMsgType->type));
 
 
-               if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
-                       MSG_DEBUG("MmsBinaryDecodeContentType: Content-Type parameter fail\n");
+               if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
+                       MSG_DEBUG("Content-Type parameter fail\n");
                        goto __CATCH;
                }
        }
@@ -1560,8 +1534,7 @@ __CATCH:
        return -1;
 }
 
-
-bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength)
+static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength)
 {
        UINT8 fieldCode = 0xff;
        int length = 0;
@@ -1591,8 +1564,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
         */
 
        while (headerLen > 0) {
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                       MSG_DEBUG("MmsBinaryDecodePartHeader: field code GetOneByte fail\n");
+               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                       MSG_DEBUG("field code GetOneByte fail\n");
                        goto __CATCH;
                }
 
@@ -1628,8 +1601,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
 
                                textLength = strlen(pLatinBuff);
 
-                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
-                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                               if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
+                                       MSG_DEBUG("MsgLatin2UTF fail \n");
                                        goto __CATCH;
                                }
 
@@ -1663,8 +1636,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                }
 
                                textLength = strlen(pLatinBuff);
-                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
-                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                               if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, textLength) < 0) {
+                                       MSG_DEBUG("MsgLatin2UTF fail \n");
                                        goto __CATCH;
                                }
                                free(pLatinBuff);
@@ -1694,8 +1667,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
 
                                }
 
-                               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                                       MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition value GetOneByte fail\n");
+                               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                       MSG_DEBUG("Disposition value GetOneByte fail\n");
                                        goto __CATCH;
                                }
 
@@ -1703,18 +1676,18 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                        valueLength--;
 
                                if (oneByte >= 0x80) {
-                                       pMsgType->disposition = _MmsGetBinaryType(MmsCodeMsgDisposition, (UINT16)(oneByte & 0x7F));
+                                       pMsgType->disposition = MmsGetBinaryType(MmsCodeMsgDisposition, (UINT16)(oneByte & 0x7F));
 
                                        if (pMsgType->disposition == INVALID_HOBJ) {
-                                               MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition _MmsGetBinaryType fail.\n");
+                                               MSG_DEBUG("MmsBinaryDecodePartHeader : Content-Disposition MmsGetBinaryType fail.\n");
                                                pMsgType->disposition = MSG_DISPOSITION_ATTACHMENT;             // default
                                        }
 
                                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, 1) == false)
                                                goto __RETURN;
 
-                                       if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
-                                               MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition parameter fail\n");
+                                       if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false) {
+                                               MSG_DEBUG("Disposition parameter fail\n");
                                                goto __CATCH;
                                        }
 
@@ -1743,9 +1716,9 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
 
                                        valueLength -= textLength;
 
-                                       if (MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false)
+                                       if (__MmsBinaryDecodeParameter(pFile, pMsgType, valueLength, totalLength) == false)
                                        {
-                                               MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition parameter fail\n");
+                                               MSG_DEBUG("Disposition parameter fail\n");
                                                goto __CATCH;
                                        }
 
@@ -1758,8 +1731,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
 
                        case 0x0B:      //Content-Encoding
 
-                               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
-                                       MSG_DEBUG("MmsBinaryDecodePartHeader: Disposition value GetOneByte fail\n");
+                               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+                                       MSG_DEBUG("Disposition value GetOneByte fail\n");
                                        goto __CATCH;
                                }
 
@@ -1867,7 +1840,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                        }
 
                                        if (charset > 0)
-                                               _MmsGetBinaryType(MmsCodeCharSet, (UINT16)charset);
+                                               MmsGetBinaryType(MmsCodeCharSet, (UINT16)charset);
 
                                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, charSetLen) == false)
                                                goto __RETURN;
@@ -1894,7 +1867,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                if (szTemp == NULL)
                                        goto __CATCH;
 
-                               if (_MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) == false) {
+                               if (__MmsBinaryDecodeGetBytes(pFile, szTemp, valueLength, totalLength) == false) {
                                        MSG_DEBUG("MmsBinaryDecodePartHeader : default _MmsBinaryDecodeGetBytes() fail\n");
                                        if (szTemp) {
                                                free(szTemp);
@@ -1914,7 +1887,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                         * Application-specific-value = Text-string
                         */
 
-                       MSG_DEBUG(" MmsBinaryDecodePartHeader: Application-header = Token-text Application-specific-value \n");
+                       MSG_DEBUG(" Application-header = Token-text Application-specific-value \n");
 
                        gCurMmsDecodeBuffPos--;
 
@@ -1923,14 +1896,14 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                        textLength = 0;
                        pCode = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
                        if (pCode == NULL) {
-                               MSG_DEBUG("MmsBinaryDecodePartHeader: pCode is null\n");
+                               MSG_DEBUG("pCode is null\n");
                                goto __CATCH;
                        }
 
                        if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, textLength) == false)
                                goto __RETURN;
 
-                       MSG_DEBUG(" MmsBinaryDecodePartHeader: Token-text (%s) \n", pCode);
+                       MSG_DEBUG(" Token-text (%s) \n", pCode);
 
 
                        /* Application-specific-value */
@@ -1938,11 +1911,11 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                        textLength = 0;
                        pValue = __MmsBinaryDecodeText2(pFile, totalLength, &textLength);
                        if (pValue == NULL) {
-                               MSG_DEBUG("MmsBinaryDecodePartHeader: pValue is null\n");
+                               MSG_DEBUG("pValue is null\n");
                                goto __CATCH;
                        }
 
-                       MSG_DEBUG(" MmsBinaryDecodePartHeader: Application-specific-value (%s) \n", pValue);
+                       MSG_DEBUG(" Application-specific-value (%s) \n", pValue);
 
 
                        pParam = strchr(pValue, MSG_CH_ADDR_DELIMETER);
@@ -1951,9 +1924,9 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                *pParam = '\0';
                        }
 
-                       switch (_MmsGetTextType(MmsCodeMsgBodyHeaderCode, pCode)) {
+                       switch (MmsGetTextType(MmsCodeMsgBodyHeaderCode, pCode)) {
                        case MMS_BODYHDR_TRANSFERENCODING:              // Content-Transfer-Encoding
-                               pMsgType->encoding = _MmsGetTextType(MmsCodeContentTransferEncoding, pValue);
+                               pMsgType->encoding = MmsGetTextType(MmsCodeContentTransferEncoding, pValue);
                                break;
 
                        case MMS_BODYHDR_CONTENTID:                             // Content-ID
@@ -1964,13 +1937,13 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                        goto __CATCH;
                                }
 
-                               MsgMIMERemoveQuote (pValue);
+                               __MsgMIMERemoveQuote (pValue);
                                strncpy(pLatinBuff, pValue, MMS_MSG_ID_LEN);
 
                                length = strlen(pLatinBuff);
-                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0)
+                               if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentID, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0)
                                {
-                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                                       MSG_DEBUG("MsgLatin2UTF fail \n");
                                        goto __CATCH;
                                }
 
@@ -1987,8 +1960,8 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                strncpy(pLatinBuff, pValue, MMS_MSG_ID_LEN);
 
                                length = strlen(pLatinBuff);
-                               if (MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) {
-                                       MSG_DEBUG("MmsBinaryDecodePartHeader: MsgLatin2UTF fail \n");
+                               if (__MsgLatin2UTF ((unsigned char*)pMsgType->szContentLocation, MMS_CONTENT_ID_LEN + 1, (unsigned char*)pLatinBuff, length) < 0) {
+                                       MSG_DEBUG("MsgLatin2UTF fail \n");
                                        goto __CATCH;
                                }
 
@@ -1997,7 +1970,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                                break;
 
                        case MMS_BODYHDR_DISPOSITION:                   // Content-Disposition
-                               pMsgType->disposition = _MmsGetTextType(MmsCodeMsgDisposition, pValue);
+                               pMsgType->disposition = MmsGetTextType(MmsCodeMsgDisposition, pValue);
                                break;
 
                        case MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY:   // DRM RO WAITING
@@ -2009,7 +1982,7 @@ bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, in
                        }
 
                        if (pParam) {
-                               _MsgParseParameter(pMsgType, pParam + 1);
+                               __MsgParseParameter(pMsgType, pParam + 1);
                                *pParam = ch;
                        }
                        if (pCode) {
@@ -2069,8 +2042,7 @@ __CATCH:
        return false;
 }
 
-
-bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength)
+static bool __MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength)
 {
        int length = 0;
 
@@ -2079,7 +2051,7 @@ bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength)
                goto __CATCH;
        }
 
-       MSG_DEBUG("MmsBinaryDecodeEntries: Number of Entries = %d\n", *npEntries);
+       MSG_DEBUG("Number of Entries = %d\n", *npEntries);
 
        return true;
 
@@ -2087,9 +2059,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength)
+static bool __MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength)
 {
        int offset = 0;
 
@@ -2098,27 +2068,26 @@ bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength)
         * the only information used with msgBody.
         * If you need, add here more information
         */
+       MSG_BEGIN();
 
-       MSG_DEBUG("MmsBinaryDecodePartBody: \n");
-
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        offset += bodyLength;
 
        if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
-               MSG_DEBUG("MmsBinaryDecodePartBody: fail to seek file pointer \n");
+               MSG_DEBUG("fail to seek file pointer \n");
                goto __CATCH;
        }
 
-       _MmsCleanDecodeBuff();
+       __MmsCleanDecodeBuff();
 
        gMmsDecodeCurOffset = offset;
 
        if (offset >= totalLength)
                goto __RETURN;
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+       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 \n");
                goto __CATCH;
        }
 
@@ -2131,27 +2100,26 @@ __CATCH:
        return false;
 }
 
-
-static bool MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength)
+static bool __MmsBinaryDecodeMovePointer(FILE *pFile, int offset, int totalLength)
 {
        if (offset > totalLength)
                goto __RETURN;
 
        if (MsgFseek(pFile, offset, SEEK_SET) < 0) {
-               MSG_DEBUG("MmsBinaryDecodeMovePointer: fail to seek file pointer \n");
+               MSG_DEBUG("fail to seek file pointer \n");
                goto __CATCH;
        }
 
-       _MmsCleanDecodeBuff();
+       __MmsCleanDecodeBuff();
 
        gMmsDecodeCurOffset = offset;
 
        if (offset == totalLength)
                goto __RETURN;
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                        gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
-               MSG_DEBUG("MmsBinaryDecodeMovePointer: fail to load to buffer \n");
+               MSG_DEBUG("fail to load to buffer \n");
                goto __CATCH;
        }
 
@@ -2162,71 +2130,7 @@ __CATCH:
        return false;
 }
 
-
-bool MmsBinaryIsTextEncodedPart(FILE *pFile, int totalLength)
-{
-       UINT8 oneByte   = 0;
-       int byteCount = 0;
-
-       byteCount++;                            //check 0x0D
-
-       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
-               goto __CATCH;
-
-       if (oneByte != 0x0D) {
-               //it can be started "--" without 0x0D 0x0A
-               if (oneByte != 0x2D) {
-                       goto __CATCH;
-               } else {
-                       byteCount++;            // check 0x2D ('-')
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
-                               goto __CATCH;
-
-                       if (oneByte != 0x2D) {
-                               goto __CATCH;
-                       } else {
-                               goto __RETURN;
-                       }
-               }
-       } else {
-               byteCount++;                    //check 0x0A
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
-                       goto __CATCH;
-
-               if (oneByte != 0x0A) {
-                       goto __CATCH;
-               } else {
-                       byteCount++;            // check 0x2D ('-')
-                       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
-                               goto __CATCH;
-
-                       if (oneByte != 0x2D) {
-                               goto __CATCH;
-                       } else {
-                               byteCount++;    // check 0x2D ('-')
-                               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
-                                       goto __CATCH;
-
-                               if (oneByte != 0x2D) {
-                                       goto __CATCH;
-                               } else {
-                                       goto __RETURN;
-                               }
-                       }
-               }
-       }
-
-__RETURN:
-       gCurMmsDecodeBuffPos -= byteCount;
-       return true;
-
-__CATCH:
-       gCurMmsDecodeBuffPos -= byteCount;
-       return false;
-}
-
-
-bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength)
+static bool __MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength)
 {
        UINT32 nEntries = 0;
        MsgMultipart *pMultipart = NULL;
@@ -2238,36 +2142,36 @@ bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType,
        MsgPresentationFactor factor = MSG_PRESENTATION_NONE;
        MsgPresentaionInfo presentationInfo;
 
-       MSG_DEBUG("MmsBinaryDecodeMultipart: total length=%d\n", totalLength);
+       MSG_DEBUG("total length=%d\n", totalLength);
 
        presentationInfo.factor = MSG_PRESENTATION_NONE;
        presentationInfo.pCurPresentation = NULL;
        presentationInfo.pPrevPart = NULL;
 
-       if (MmsBinaryDecodeEntries(pFile, &nEntries, totalLength) == false) {
-               MSG_DEBUG("MmsBinaryDecodeMultipart: MmsBinaryDecodeEntries is fail.\n");
+       if (__MmsBinaryDecodeEntries(pFile, &nEntries, totalLength) == false) {
+               MSG_DEBUG("MmsBinaryDecodeEntries is fail.\n");
                goto __CATCH;
        }
 
        while (nEntries) {
-               MSG_DEBUG("MmsBinaryDecodeMultipart: decoding %dth multipart\n", index);
+               MSG_DEBUG("decoding %dth multipart\n", index);
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
-               if ((pMultipart = MsgAllocMultipart()) == NULL) {
-                       MSG_DEBUG("MmsBinaryDecodeMultipart: MsgAllocMultipart Fail \n");
+               if ((pMultipart = __MsgAllocMultipart()) == NULL) {
+                       MSG_DEBUG("MsgAllocMultipart Fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryDecodeEachPart(pFile, szFilePath, &(pMultipart->type), pMultipart->pBody, totalLength) == false) {
-                       MSG_DEBUG("MmsBinaryDecodeMultipart: MmsBinaryDecodeEachPart is fail.(nEntries = %d)\n", nEntries);
+               if (__MmsBinaryDecodeEachPart(pFile, szFilePath, &(pMultipart->type), pMultipart->pBody, totalLength) == false) {
+                       MSG_DEBUG("MmsBinaryDecodeEachPart is fail.(nEntries = %d)\n", nEntries);
                        goto __CATCH;
                }
 
                if (pMsgType->param.type == MIME_APPLICATION_SMIL) {
-                       factor = MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type);
+                       factor = __MsgIsPresentationEx(&(pMultipart->type), pMsgType->param.szStart, (MimeType)pMsgType->param.type);
                } else {
                        factor = MSG_PRESENTATION_NONE;
                }
@@ -2296,7 +2200,7 @@ bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType,
 
                nEntries--;
 
-               MmsDebugPrintMulitpartEntry(pMultipart, index++);
+               __MmsDebugPrintMulitpartEntry(pMultipart, index++);
 
        }
 
@@ -2305,9 +2209,9 @@ bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType,
 #ifdef __SUPPORT_DRM__
        if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED)
 #endif
-               MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo);
+               __MsgConfirmPresentationPart(pMsgType, pMsgBody, &presentationInfo);
 
-       if (MsgResolveNestedMultipart(pMsgType, pMsgBody) == false) {
+       if (__MsgResolveNestedMultipart(pMsgType, pMsgBody) == false) {
                MSG_DEBUG("MmsBinaryDecodeMultipart : MsgResolveNestedMultipart failed \n");
                goto __CATCH;
        }
@@ -2319,8 +2223,7 @@ __CATCH:
        return false;
 }
 
-
-bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength)
+static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength)
 {
        int     length = 0;
        bool bSuccess = false;
@@ -2337,7 +2240,7 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
                goto __CATCH;
        }
 
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        if (offset >= totalLength)
                goto __RETURN;
 
@@ -2350,7 +2253,7 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
        }
 
 
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        if (offset >= totalLength)
                goto __RETURN;
 
@@ -2359,32 +2262,32 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
        if (szFilePath != NULL)
                strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath));
 
-       pMsgType->offset = _MmsGetDecodeOffset();
+       pMsgType->offset = __MmsGetDecodeOffset();
        pMsgType->size = headerLength;
        pMsgType->contentSize = bodyLength;
 
        if (pMsgType->offset > totalLength)
                goto __RETURN;
 
-       length = MmsBinaryDecodeContentType(pFile, pMsgType, totalLength);
+       length = __MmsBinaryDecodeContentType(pFile, pMsgType, totalLength);
        if (length <= 0) {
                MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentType Fail \n");
                goto __CATCH;
        }
 
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        if (offset >= totalLength)
                goto __RETURN;
 
 
        /* Part Header */
 
-       if (MmsBinaryDecodePartHeader(pFile, pMsgType, headerLength - length, totalLength) == false) {
+       if (__MmsBinaryDecodePartHeader(pFile, pMsgType, headerLength - length, totalLength) == false) {
                MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentHeader Fail \n");
                goto __CATCH;
        }
 
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        if (offset >= totalLength)
                goto __RETURN;
 
@@ -2393,7 +2296,7 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
        if (szFilePath != NULL)
                strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath));
 
-       pMsgBody->offset = _MmsGetDecodeOffset();
+       pMsgBody->offset = __MmsGetDecodeOffset();
        pMsgBody->size   = bodyLength;
 
        if (pMsgBody->offset > totalLength)
@@ -2411,12 +2314,12 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
 
                MSG_DEBUG("MmsBinaryDecodeEachPart: Decode multipart\n");
 
-               if (MmsBinaryDecodeMultipart(pFile, szFilePath, pMsgType, pMsgBody, totalLength) == false) {
+               if (__MmsBinaryDecodeMultipart(pFile, szFilePath, pMsgType, pMsgBody, totalLength) == false) {
                        MSG_DEBUG("MmsBinaryDecodeEachPart: MmsBinaryDecodeMultipart is fail.\n");
                        goto __CATCH;
                }
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
@@ -2430,18 +2333,18 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
 
                if (MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_NOT_FIXED && MmsDrm2GetConvertState() != MMS_DRM2_CONVERT_REQUIRED) {
 
-                       if (MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
+                       if (__MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
                                goto __CATCH;
                } else {
                        MmsDrm2SetConvertState(MMS_DRM2_CONVERT_REQUIRED);
 
-                       bSuccess = MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
+                       bSuccess = __MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
                        if (bSuccess == false) {
                                MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n");
                                goto __CATCH;
                        }
                }
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
@@ -2451,10 +2354,10 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
 
                MSG_DEBUG("MmsBinaryDecodeEachPart: MIME_APPLICATION_VND_OMA_DRM_CONTENT Part \n");
 
-               if (MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
+               if (__MmsBinaryDecodeDRMContent(pFile, szFilePath, pMsgType, pMsgBody, bodyLength, totalLength) == false)
                        goto __CATCH;
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
@@ -2464,13 +2367,13 @@ bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, M
        default:
                MSG_DEBUG("MmsBinaryDecodeEachPart: Other normal Part \n");
 
-               bSuccess = MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
+               bSuccess = __MmsBinaryDecodePartBody(pFile, bodyLength, totalLength);
                if (bSuccess == false) {
                        MSG_DEBUG("MmsBinaryDecodeEachPart: Decode contentBody Fail \n");
                        goto __CATCH;
                }
 
-               offset = _MmsGetDecodeOffset();
+               offset = __MmsGetDecodeOffset();
                if (offset >= totalLength)
                        goto __RETURN;
 
@@ -2489,149 +2392,7 @@ __CATCH:
 }
 
 #ifdef __SUPPORT_DRM__
-bool __MmsParseDCFInfo(FILE *pFile, MsgDRMInfo *pDrmInfo, int totalLength)
-{
-       UINT8 version = 0;
-       UINT8 contentTypeLen = 0;
-       UINT8 contentURILen = 0;
-       char *szContentType     = NULL;
-       char *szContentURI = NULL;
-
-       if (_MmsBinaryDecodeGetOneByte(pFile, &version, totalLength) == false) {
-               MSG_DEBUG("__MmsParseDCFInfo: [version] GetOneByte fail\n");
-               goto __CATCH;
-       }
-
-       if (_MmsBinaryDecodeGetOneByte(pFile, &contentTypeLen, totalLength) == false) {
-               MSG_DEBUG("__MmsParseDCFInfo: [contentTypeLen] GetOneByte fail\n");
-               goto __CATCH;
-       }
-
-       if (_MmsBinaryDecodeGetOneByte(pFile, &contentURILen, totalLength) == false) {
-               MSG_DEBUG("__MmsParseDCFInfo: [contentURILen] GetOneByte fail\n");
-               goto __CATCH;
-       }
-
-       //Get media content-type (mime-type)
-       szContentType = (char *)malloc(contentTypeLen + 1);
-       if (szContentType == NULL)
-               goto __CATCH;
-
-       memset(szContentType, 0, contentTypeLen + 1);
-
-       if (_MmsBinaryDecodeGetBytes(pFile, szContentType, contentTypeLen + 1, totalLength) < 0) {
-               MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n");
-               goto __CATCH;
-       }
-       gCurMmsDecodeBuffPos--;
-       pDrmInfo->contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szContentType);
-
-
-       //Get content-ID - 1.remover "cid:",   2.resolve "%hexa",   3.and copy the string
-       szContentURI = (char *)malloc(contentURILen + 1);
-       if (szContentURI == NULL)
-               goto __CATCH;
-
-       memset(szContentURI, 0, contentURILen + 1);
-
-       if (_MmsBinaryDecodeGetBytes(pFile, szContentURI, contentURILen + 1, totalLength) == false) {
-               MSG_DEBUG("__MmsParseDCFInfo : contentType is invalid\n");
-               goto __CATCH;
-       }
-       gCurMmsDecodeBuffPos--;
-       pDrmInfo->szContentURI = MsgResolveContentURI(szContentURI);
-
-
-       if (szContentType) {
-               free(szContentType);
-               szContentType = NULL;
-       }
-
-       if (szContentURI) {
-               free(szContentURI);
-               szContentURI = NULL;
-       }
-       return true;
-
-
-__CATCH:
-
-       if (szContentType) {
-               free(szContentType);
-               szContentType = NULL;
-       }
-
-       if (szContentURI) {
-               free(szContentURI);
-               szContentURI = NULL;
-       }
-       return false;
-
-}
-
-
-bool __MmsParseDCFHdr(FILE *pFile, MsgDRMInfo *pDrmInfo, UINT32 headerLen, int totalLength)
-{
-       char *szDCFHdr = NULL;
-       MsgType partType;
-       ULONG nRead = 0;
-       int offset = 0;
-
-       /* add to parse DCF header such as,
-        *  Right-Issuer, Content-Name, and Content-Description.
-        */
-
-       szDCFHdr = (char *)malloc(headerLen + 1);
-       if (szDCFHdr == NULL) {
-               MSG_DEBUG("__MmsParseDCFHdr: szDCFHdr alloc fail\n");
-               goto __CATCH;
-       }
-       memset(szDCFHdr, 0, headerLen + 1);
-
-       offset = _MmsGetDecodeOffset();
-       if (offset >= totalLength)
-               goto __RETURN;
-
-       if (MsgFseek(pFile, offset, SEEK_SET) < 0)
-               goto __CATCH;
-
-       if ((nRead = MsgReadFile(szDCFHdr, sizeof(char), headerLen, pFile)) == 0){
-               goto __CATCH;
-       }
-       szDCFHdr[nRead] = '\0';
-
-       _MsgInitMsgType(&partType);
-       _MsgParsePartHeader(&partType, szDCFHdr, headerLen);
-
-       pDrmInfo->szContentName = partType.drmInfo.szContentName;
-       pDrmInfo->szContentVendor = partType.drmInfo.szContentVendor;
-       pDrmInfo->szContentDescription = partType.drmInfo.szContentDescription;
-       pDrmInfo->szRightIssuer = partType.drmInfo.szRightIssuer;
-
-       if (MmsBinaryDecodeMovePointer(pFile, offset + headerLen, totalLength) == false)
-               goto __CATCH;
-
-__RETURN:
-
-       if (szDCFHdr) {
-               free(szDCFHdr);
-               szDCFHdr = NULL;
-       }
-
-       return true;
-
-__CATCH:
-
-       if (szDCFHdr) {
-               free(szDCFHdr);
-               szDCFHdr = NULL;
-       }
-
-       return false;
-}
-
-
-bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength)
+static bool __MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength)
 {
        int offset = 0;
        char szTempFilePath[MSG_FILEPATH_LEN_MAX] = MSG_DATA_PATH"drm.dcf";
@@ -2640,7 +2401,7 @@ bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType,
 
        MSG_DEBUG("bodyLength: %d\n", bodyLength);
 
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
 
        if (offset >= totalLength)
                goto __RETURN;
@@ -2684,7 +2445,7 @@ bool MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType,
        remove(szTempFilePath);
        isFileCreated = false;
 
-       if (MmsBinaryDecodeMovePointer(pFile, offset + bodyLength, totalLength) == false)
+       if (__MmsBinaryDecodeMovePointer(pFile, offset + bodyLength, totalLength) == false)
                goto __CATCH;
 
 __RETURN:
@@ -2708,88 +2469,6 @@ __CATCH:
        return false;
 }
 
-
-bool MmsBinaryDecodeDRMMessage(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int fullBodyLength, int totalLength)
-{
-       int offset = 0;
-       char szTempFilePath[MSG_FILEPATH_LEN_MAX] = "/User/Msg/Mms/Temp/drm.dm";
-       char *pRawData = NULL;
-       bool isFileCreated = false;
-
-       offset = _MmsGetDecodeOffset();
-       if (offset >= totalLength)
-               goto __RETURN;
-
-       if (szFilePath != NULL)
-               strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath));
-       if (szFilePath != NULL)
-               strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath));
-
-       pRawData = (char *)malloc(fullBodyLength);
-       if (pRawData == NULL) {
-               MSG_DEBUG("pRawData alloc FAIL \n");
-               goto __CATCH;
-       }
-
-       if (MsgFseek(pFile, offset,  SEEK_SET) < 0) {
-               MSG_DEBUG("MsgFseek() returns -1 \n");
-               goto __CATCH;
-       }
-
-       if (MsgReadFile(pRawData, sizeof(char), fullBodyLength, pFile)!= (size_t)fullBodyLength) {
-               MSG_DEBUG("FmReadFile() returns false \n");
-               goto __CATCH;
-       }
-
-       if (MsgOpenCreateAndOverwriteFile(szTempFilePath, pRawData, fullBodyLength) == false) {
-               MSG_DEBUG("MsgOpenCreateAndOverwriteFile() returns false \n");
-               goto __CATCH;
-       }
-       isFileCreated = true;
-
-       if (strstr(szTempFilePath, ".dm")) {
-               char szConvertedFilePath[MSG_FILEPATH_LEN_MAX] = {0,};
-
-               if (MsgDrmConvertDmtoDcfType(szTempFilePath, szConvertedFilePath)) {
-                       remove(szTempFilePath);
-                       memset(szTempFilePath, 0, MSG_FILEPATH_LEN_MAX);
-                       strncpy(szTempFilePath, szConvertedFilePath, MSG_FILEPATH_LEN_MAX-1);
-               }
-       }
-
-       if (MsgDRM2GetDRMInfo(szTempFilePath, pMsgType) == false) {
-               MSG_DEBUG("MsgDRM2GetDRMInfo() returns false \n");
-               goto __CATCH;
-       }
-
-       if (remove(szTempFilePath) != 0)
-               MSG_DEBUG("remove fail");
-
-       isFileCreated = false;
-
-       if (MmsBinaryDecodeMovePointer(pFile, offset + fullBodyLength, totalLength) == false)
-               goto __CATCH;
-
-__RETURN:
-
-       if (pRawData) {
-               free(pRawData);
-               pRawData = NULL;
-       }
-       return true;
-
-__CATCH:
-       if (isFileCreated) {
-               if (remove(szTempFilePath) != 0)
-                       MSG_DEBUG("remove fail");
-       }
-       if (pRawData) {
-               free(pRawData);
-               pRawData = NULL;
-       }
-       return false;
-}
-
 static int __MmsDrm2BinaryEncodeUintvarLen(UINT32 integer)
 {
        UINT32 length   = 0;
@@ -2812,7 +2491,6 @@ static int __MmsDrm2BinaryEncodeUintvarLen(UINT32 integer)
        return length;
 }
 
-
 static bool __MmsDrm2BinaryEncodeUintvar(UINT32 integer, int length, char *pszOutput)
 {
        const char ZERO = 0x00;
@@ -2849,7 +2527,6 @@ static bool __MmsDrm2BinaryEncodeUintvar(UINT32 integer, int length, char *pszOu
        return true;
 }
 
-
 static int __MmsDrm2GetEntriesValueLength(FILE *pFile, int orgOffset)
 {
        char szEntries[5] = {0, };
@@ -2877,7 +2554,6 @@ static int __MmsDrm2GetEntriesValueLength(FILE *pFile, int orgOffset)
        return j;
 }
 
-
 static bool __MmsDrm2WriteDataToConvertedFile(FILE *pSrcFile, FILE *pDestinationFile, char *pszMmsLoadTempBuf, int length, int bufLen)
 {
        int loadLen = 0, totalLoadLen = 0, nRead = 0;
@@ -2903,7 +2579,6 @@ static bool __MmsDrm2WriteDataToConvertedFile(FILE *pSrcFile, FILE *pDestination
        return true;
 }
 
-
 /*************************************************************************
  * description : make new message file converting CD & FL part of original message file to SD type
  * argument : void
@@ -3196,84 +2871,24 @@ __CATCH:
        return false;
 }
 
-
 /*************************************************************************
  * description : Function for decoding a converted file
  * argument : void
  * return value
     - bool :  result of converting
 **************************************************************************/
-bool MmsDrm2DecodeConvertedMsg(int msgID, char *pszFullPath)
-{
-       FILE *hConvertedFile = NULL;
-       int     nSize = 0;
-
-       MSG_DEBUG("MmsDrm2DecodeConvertedMsg: start re-decoding~~~~~~\n");
-
-       // free
-       _MsgFreeDRMInfo(&mmsHeader.msgType.drmInfo);
-       _MsgFreeBody(&mmsHeader.msgBody, mmsHeader.msgType.type);
-
-       _MmsInitHeader();
-       _MmsUnregisterDecodeBuffer();
-
-       // start decoding
-       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
-
-       // open converted file
-       if ((hConvertedFile = MsgOpenFile(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, "rb")) == NULL) {
-               MSG_DEBUG("MmsDrm2ReDecodeMsg: opening temporary file failed\n");
-               goto __CATCH;
-       }
-
-       if (MsgGetFileSize(MMS_DECODE_DRM_CONVERTED_TEMP_FILE, &nSize) == false) {
-               MSG_DEBUG("MsgGetFileSize: failed\n");
-               goto __CATCH;
-       }
-
-       if (!MmsBinaryDecodeMsgHeader(hConvertedFile, nSize)) {
-               MSG_DEBUG("MmsDrm2ReDecodeMsg: decoding header(binary mode) failed\n");
-               goto __CATCH;
-       }
-
-       if (!MmsBinaryDecodeMsgBody(hConvertedFile, pszFullPath, nSize)) {
-               MSG_DEBUG("MmsDrm2ReDecodeMsg: decoding body failed\n");
-               goto __CATCH;
-       }
-
-       if (hConvertedFile != NULL) {
-               MsgCloseFile(hConvertedFile);
-               hConvertedFile = NULL;
-       }
-
-       return true;
-
-__CATCH:
-
-       if (hConvertedFile != NULL) {
-               MsgCloseFile(hConvertedFile);
-
-               if (remove(MMS_DECODE_DRM_CONVERTED_TEMP_FILE) != 0)
-                       MSG_DEBUG("remove fail");
-
-               hConvertedFile = NULL;
-       }
-
-       return false;
-}
-
 
 bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath)
 {
        MmsMsg *pMmsMsg;
        MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg);
-       _MmsUnregisterDecodeBuffer();
+       MmsUnregisterDecodeBuffer();
 #ifdef __SUPPORT_DRM__
-       _MsgFreeDRMInfo(&pMmsMsg->msgType.drmInfo);
+       MsgFreeDRMInfo(&pMmsMsg->msgType.drmInfo);
 #endif
-       _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
+       MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
 
-       if (_MmsReadMsgBody(pMsg->msgId, bSavePartsAsTempFiles, bRetrieved, retrievedPath) == false) {
+       if (MmsReadMsgBody(pMsg->msgId, bSavePartsAsTempFiles, bRetrieved, retrievedPath) == false) {
                MSG_DEBUG("MmsDrm2ReadMsgConvertedBody: _MmsReadMsgBody with converted file is failed\n");
                return false;
        }
@@ -3289,7 +2904,7 @@ bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTemp
  *
  * --------------------------------------------------------------------*/
 
-bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength)
+bool __MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength)
 {
        int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos;
 
@@ -3300,7 +2915,7 @@ bool _MmsBinaryDecodeGetOneByte(FILE *pFile, UINT8 *pOneByte, int totalLength)
        }
 
        if (length < 1) {
-               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+               if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                           gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                        MSG_DEBUG("_MmsBinaryDecodeGetOneByte: fail to load to buffer \n");
                        goto __CATCH;
@@ -3315,11 +2930,10 @@ __CATCH:
        return false;
 }
 
-
 /*
  * @remark: bufLen < gMmsDecodeMaxLen
  */
-bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+bool __MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength)
 {
        int length = gMmsDecodeMaxLen - gCurMmsDecodeBuffPos;
        int i = 0;
@@ -3331,7 +2945,7 @@ bool _MmsBinaryDecodeGetBytes(FILE *pFile, char *szBuff, int bufLen, int totalLe
        memset(szBuff, 0, bufLen);
 
        if (length < bufLen) {
-               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+               if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                           gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                        MSG_DEBUG("_MmsBinaryDecodeGetBytes: fail to load to buffer \n");
                        goto __CATCH;
@@ -3350,9 +2964,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength)
+bool __MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int totalLength)
 {
        int iPos = 0;
 
@@ -3361,14 +2973,14 @@ bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int tot
 
        memset(szBuff, 0, bufLen);
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                   gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: fail to load to buffer \n");
                goto __CATCH;
        }
 
        while ((bufLen - iPos) >= gMmsDecodeMaxLen) {
-               if (_MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, gMmsDecodeMaxLen, totalLength) == false) {
+               if (__MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, gMmsDecodeMaxLen, totalLength) == false) {
                        MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 1. _MmsBinaryDecodeGetBytes fail \n");
                        goto __CATCH;
                }
@@ -3377,7 +2989,7 @@ bool _MmsBinaryDecodeGetLongBytes(FILE *pFile, char *szBuff, int bufLen, int tot
        }
 
        if ((bufLen - iPos) > 0) {
-               if (_MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, (bufLen - iPos), totalLength) == false) {
+               if (__MmsBinaryDecodeGetBytes(pFile, szBuff + iPos, (bufLen - iPos), totalLength) == false) {
                        MSG_DEBUG("_MmsBinaryDecodeGetLongBytes: 2. _MmsBinaryDecodeGetBytes fail \n");
                        goto __CATCH;
                }
@@ -3391,7 +3003,6 @@ __CATCH:
        return false;
 }
 
-
 /**
  * Decode uintvar to 32bit unsigned integer
  *
@@ -3417,7 +3028,7 @@ static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLeng
                return -1;
 
        if (length < 5) {
-               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+               if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                           gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                        MSG_DEBUG("__MmsBinaryDecodeUintvar: fail to load to buffer \n");
                        goto __CATCH;
@@ -3425,7 +3036,7 @@ static int __MmsBinaryDecodeUintvar(FILE *pFile, UINT32 *pUintVar, int totalLeng
        }
 
        while (true) {
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
                        goto __CATCH;
 
                if (oneByte > 0x7f)     {
@@ -3453,7 +3064,6 @@ __CATCH:
        return -1;
 }
 
-
 /**
  * Decode uintvar to 32bit unsigned integer by uintvar length
  *
@@ -3478,7 +3088,7 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t
 
        if (length == 1)
        {
-               if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+               if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
                        MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n");
                        return oneByte;
                }
@@ -3500,7 +3110,7 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t
        }
        memset(pData, 0, length + 1);
 
-       if (_MmsBinaryDecodeGetBytes(pFile, pData, length + 1, totalLength) == false) {
+       if (__MmsBinaryDecodeGetBytes(pFile, pData, length + 1, totalLength) == false) {
                MSG_DEBUG("__MmsHeaderDecodeIntegerByLength: _MmsBinaryDecodeGetOneByte fail\n");
                goto __CATCH;
        }
@@ -3527,7 +3137,6 @@ __CATCH:
        return returner.integer;
 }
 
-
 /**
  * Decode uintvar to 32bit unsigned integer by uintvar length
  *
@@ -3551,7 +3160,7 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen
        returner.integer = 0;
        *pIntLen                 = 0;
 
-       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
                MSG_DEBUG("__MmsBinaryDecodeInteger: GetOneByte fail\n");
                return false;
        }
@@ -3566,7 +3175,7 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen
                memset(pData, 0, oneByte + 1);
 
                // Even NULL is copied in the _MmsBinaryDecodeGetBytes
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) {
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, oneByte + 1, totalLength) == false) {
                        MSG_DEBUG("__MmsBinaryDecodeInteger: GetBytes fail\n");
                        goto __CATCH;
                }
@@ -3613,7 +3222,6 @@ __CATCH:
        return false;
 }
 
-
 /**
  * Decode uintvar to 32bit unsigned integer by uintvar length
  *
@@ -3638,7 +3246,7 @@ static int __MmsDecodeValueLength(FILE *pFile, UINT32 *pValueLength, int totalLe
 
        *pValueLength = 0;
 
-       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
                gCurMmsDecodeBuffPos--;
                goto __CATCH;
        }
@@ -3671,8 +3279,6 @@ __CATCH:
        return -1;
 }
 
-
-
 /**
  * Decode uintvar to 32bit unsigned integer by uintvar length
  *
@@ -3698,7 +3304,7 @@ static int __MmsDecodeValueLength2(FILE *pFile, UINT32 *pValueLength, int totalL
 
        *pValueLength = 0;
 
-       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
+       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false) {
                gCurMmsDecodeBuffPos--;
                goto __CATCH;
        }
@@ -3731,8 +3337,6 @@ __CATCH:
        return -1;
 }
 
-
-
 /**
  * Decode QuotedString
  *
@@ -3759,7 +3363,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
 
        memset(szBuff, 0, bufLen);
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                         gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                MSG_DEBUG("__MmsBinaryDecodeQuotedString: 1. fail to load to buffer \n");
                goto __CATCH;
@@ -3794,7 +3398,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
 
                memset(pData, 0, gMmsDecodeBufLen + 1);
 
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
                        goto __CATCH;
 
                returnLength += gMmsDecodeBufLen;
@@ -3817,7 +3421,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
                        pData = NULL;
                }
 
-               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+               if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                                gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                        MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
                        goto __CATCH;
@@ -3830,7 +3434,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen,
                if (pData == NULL)
                        goto __CATCH;
 
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false)
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false)
                        goto __CATCH;
 
                returnLength += length;
@@ -3872,7 +3476,6 @@ __CATCH:
        return -1;
 }
 
-
 /**
  * Decode Text
  *
@@ -3900,13 +3503,13 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
        if (pFile == NULL || szBuff == NULL || bufLen <= 0)
                return -1;
 
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        if (offset >= totalLength)
                goto __RETURN;
 
        memset(szBuff, 0, bufLen);
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                        gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                MSG_DEBUG("__MmsBinaryDecodeText: 1. fail to load to buffer \n");
                goto __CATCH;
@@ -3937,7 +3540,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
 
                memset(pData, 0, gMmsDecodeBufLen + 1);
 
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
                        goto __CATCH;
 
                if ((bufLen - iPos) > 0) {
@@ -3961,7 +3564,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
 
                returnLength += gMmsDecodeBufLen;
 
-               if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+               if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                           gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                        MSG_DEBUG("__MmsBinaryDecodeText: 2. fail to load to buffer \n");
                        goto __CATCH;
@@ -3976,7 +3579,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota
 
                memset(pData, 0, length);
 
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false)
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false)
                        goto __CATCH;
 
                if ((bufLen - iPos) > 0) {
@@ -4010,7 +3613,7 @@ __RETURN:
        szBuff[0] = '\0';
        length = 0;
 
-       MmsBinaryDecodeMovePointer(pFile, offset, totalLength);
+       __MmsBinaryDecodeMovePointer(pFile, offset, totalLength);
 
        return length;
 
@@ -4024,7 +3627,6 @@ __CATCH:
        return -1;
 }
 
-
 static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
 {
        int length = 0;
@@ -4045,11 +3647,11 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
                goto __CATCH;
 
        *pLength = 0;
-       offset = _MmsGetDecodeOffset();
+       offset = __MmsGetDecodeOffset();
        if (offset >= totalLength)
                goto __RETURN;
 
-       if (MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
+       if (__MsgLoadDataToDecodeBuffer(pFile, &gpCurMmsDecodeBuff, &gCurMmsDecodeBuffPos, &gMmsDecodeCurOffset,
                                                                   gpMmsDecodeBuf1, gpMmsDecodeBuf2, gMmsDecodeMaxLen, &gMmsDecodeBufLen, totalLength) == false) {
                MSG_DEBUG("__MmsBinaryDecodeTextLen: 1. fail to load to buffer \n");
                goto __CATCH;
@@ -4084,7 +3686,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
 
                memset(pData, 0, gMmsDecodeBufLen + 1);
 
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, gMmsDecodeBufLen, totalLength) == false)
                        goto __CATCH;
 
                if (szBuff == NULL)     {
@@ -4122,7 +3724,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
 
                *pLength += gMmsDecodeBufLen;
 
-               if (MsgLoadDataToDecodeBuffer(pFile,
+               if (__MsgLoadDataToDecodeBuffer(pFile,
                                                           &gpCurMmsDecodeBuff,
                                                           &gCurMmsDecodeBuffPos,
                                                           &gMmsDecodeCurOffset,
@@ -4144,7 +3746,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength)
                        goto __CATCH;
                }
 
-               if (_MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) {
+               if (__MmsBinaryDecodeGetBytes(pFile, pData, length, totalLength) == false) {
                        goto __CATCH;
                }
 
@@ -4191,7 +3793,7 @@ __RETURN:
 
        *pLength = 1;
 
-       MmsBinaryDecodeMovePointer(pFile, offset, totalLength);
+       __MmsBinaryDecodeMovePointer(pFile, offset, totalLength);
 
        return szBuff;
 
@@ -4210,7 +3812,6 @@ __CATCH:
        return NULL;
 }
 
-
 /**
  * Decode Charset
  *
@@ -4245,10 +3846,10 @@ static bool __MmsBinaryDecodeCharset(FILE *pFile, UINT32 *nCharSet, int *pCharSe
                return true;
        }
 
-       *nCharSet = _MmsGetBinaryType(MmsCodeCharSet, (UINT16)integer);
+       *nCharSet = MmsGetBinaryType(MmsCodeCharSet, (UINT16)integer);
 
        if (*nCharSet == MIME_UNKNOWN) {
-               MSG_DEBUG("__MmsBinaryDecodeCharset : _MmsGetBinaryType fail..\n");
+               MSG_DEBUG("__MmsBinaryDecodeCharset : MmsGetBinaryType fail..\n");
                *nCharSet = MSG_CHARSET_UNKNOWN;
        }
 
@@ -4258,8 +3859,6 @@ __CATCH:
        return false;
 }
 
-
-
 /**
  * Decode EncodedString
  *
@@ -4327,7 +3926,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
                                goto __CATCH;
                        }
 
-                       if (_MmsBinaryDecodeGetLongBytes(pFile, pData, valueLength - charSetLen, totalLength) == false) {
+                       if (__MmsBinaryDecodeGetLongBytes(pFile, pData, valueLength - charSetLen, totalLength) == false) {
                                MSG_DEBUG("__MmsBinaryDecodeEncodedString : _MmsBinaryDecodeGetLongBytes fail.\n");
                                goto __CATCH;
                        }
@@ -4341,7 +3940,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen
 
                        const char *pToCharSet = "UTF-8";
 
-                       UINT16 charset_code =  _MmsGetBinaryValue(MmsCodeCharSet, charSet);
+                       UINT16 charset_code =  MmsGetBinaryValue(MmsCodeCharSet, charSet);
 
                        const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code);
                        if (pFromCharSet == NULL || !strcmp(pFromCharSet, pToCharSet)) {
@@ -4477,7 +4076,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength)
                                goto __CATCH;
                        }
 
-                       if (_MmsBinaryDecodeGetLongBytes(pFile, pAddrStr, valueLength - charSetLen, totalLength) == false) {
+                       if (__MmsBinaryDecodeGetLongBytes(pFile, pAddrStr, valueLength - charSetLen, totalLength) == false) {
                                MSG_DEBUG("__MmsDecodeEncodedAddress : _MmsBinaryDecodeGetLongBytes fail.\n");
                                goto __CATCH;
                        }
@@ -4530,7 +4129,7 @@ static bool __MmsDecodeLongInteger(FILE *pFile, UINT32 *pLongInteger, int totalL
 
        *pLongInteger = 0;
 
-       if (_MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
+       if (__MmsBinaryDecodeGetOneByte(pFile, &oneByte, totalLength) == false)
                goto __CATCH;
 
        if (oneByte > 31)
@@ -4585,11 +4184,11 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot
                        szSrc2 = NULL;
                }
 
-               if (MsgIsUTF8String((unsigned char*)pLatinBuff, strlen(pLatinBuff)) == false) {
+               if (__MsgIsUTF8String((unsigned char*)pLatinBuff, strlen(pLatinBuff)) == false) {
                        length = strlen(pLatinBuff);
 
                        int             utf8BufSize = 0;
-                       utf8BufSize = MsgGetLatin2UTFCodeSize((unsigned char*)pLatinBuff, length);
+                       utf8BufSize = __MsgGetLatin2UTFCodeSize((unsigned char*)pLatinBuff, length);
                        if (utf8BufSize < 3)
                                utf8BufSize = 3;//min value
 
@@ -4599,14 +4198,14 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot
                                goto __CATCH;
                        }
 
-                       if (MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pLatinBuff, length) < 0) {
+                       if (__MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pLatinBuff, length) < 0) {
                                MSG_DEBUG("__MmsDecodeGetFilename: MsgLatin2UTF fail \n");
                                goto __CATCH;
                        }
                        free(pLatinBuff);
                        pLatinBuff = NULL;
                } else {
-                       pTmpBuff = _MsgDecodeText(pLatinBuff);
+                       pTmpBuff = MsgDecodeText(pLatinBuff);
                        pUTF8Buff = pTmpBuff;
                        free (pLatinBuff);
                        pLatinBuff = NULL;
@@ -4649,26 +4248,6 @@ __CATCH:
        return -1;
 }
 
-
-/* ==========================================================
-
-          T  E  X  T         D  E  C  O  D  I  N  G
-
-   ==========================================================*/
-
-
-bool MmsTextDecodeMsgBody(FILE *pFile)
-{
-       MSG_DEBUG("MmsTextDecodeMsgBody: \n");
-       return false;
-}
-
-bool __MmsTextDecodeMsgHeader(FILE *pFile)
-{
-       return true;
-}
-
-
 /* ==========================================================
 
           M  M  S        D  E  C  O  D  I  N  G
@@ -4676,7 +4255,7 @@ bool __MmsTextDecodeMsgHeader(FILE *pFile)
    ==========================================================*/
 
 //  to get message body this function should be modified from message raw file.
-bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath)
+bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath)
 {
        FILE *pFile     = NULL;
        MmsMsg *pMsg = NULL;
@@ -4691,7 +4270,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
        MmsPluginStorage::instance()->getMmsMessage(&pMsg);
        memset(pMsg, 0, sizeof(MmsMsg));
 
-       _MmsInitHeader();
+       MmsInitHeader();
 
        if (bRetrieved && (retrievedPath != NULL)) {
                strncpy(szFullPath, retrievedPath, (strlen(retrievedPath) > MSG_FILEPATH_LEN_MAX ? MSG_FILEPATH_LEN_MAX:strlen(retrievedPath)));
@@ -4718,7 +4297,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
                goto __CATCH;
        }
 
-       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1, gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+       MmsRegisterDecodeBuffer();
 
        if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
                MSG_DEBUG("_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
@@ -4744,7 +4323,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
 
        /* Set mmsHeader.msgType & msgBody to pMsg ----------- */
 
-       pMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type;
+       pMsg->mmsAttrib.contentType = (MimeType)mmsHeader.msgType.type;
 
        memcpy(&(pMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
        memcpy(&(pMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
@@ -4782,7 +4361,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
 
                        if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED)||(mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
                                if ((pMsg->nPartCount >= attachmax)&&(pMultipart->pNext != NULL)) {
-                                       _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
+                                       MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
 
                                        free(pMultipart->pNext->pBody);
                                        pMultipart->pNext->pBody= NULL;
@@ -4803,12 +4382,6 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
        /*      make temporary  */
        snprintf(szTempMediaDir, MSG_FILEPATH_LEN_MAX, MSG_DATA_PATH"%s.dir", pMsg->szFileName);
 
-       ///////////////////////////////////////////////
-       // call before processing urgent event.
-       //_MmsInitHeader();
-       //_MmsUnregisterDecodeBuffer();
-       ///////////////////////////////////////////////
-
        if (MsgIsMultipart(pMsg->msgType.type) == true) {
                int partIndex = 0;
                pMultipart = pMsg->msgBody.body.pMultipart;
@@ -4826,7 +4399,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
 
                while (pMultipart) {
 
-                       if (_MmsMultipartSaveAsTempFile(&pMultipart->type, pMultipart->pBody,
+                       if (__MmsMultipartSaveAsTempFile(&pMultipart->type, pMultipart->pBody,
                                                                                        (char*)MSG_DATA_PATH, pMsg->szFileName, partIndex, bSavePartsAsTempFiles) == false)
                                goto __CATCH;
 
@@ -4848,7 +4421,7 @@ bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bR
                                }
                        }
 
-                       if (_MmsMultipartSaveAsTempFile( &pMsg->msgType, &pMsg->msgBody,
+                       if (__MmsMultipartSaveAsTempFile( &pMsg->msgType, &pMsg->msgBody,
                                                                                        (char*)MSG_DATA_PATH, pMsg->szFileName, 0, bSavePartsAsTempFiles) == false)
                                goto __CATCH;
                }
@@ -4871,8 +4444,8 @@ RETURN:
 
 __CATCH:
 
-       _MmsInitHeader();
-       _MmsUnregisterDecodeBuffer();
+       MmsInitHeader();
+       MmsUnregisterDecodeBuffer();
 
        if (pFile != NULL) {
                MsgCloseFile(pFile);
@@ -4880,17 +4453,16 @@ __CATCH:
        }
 
 #ifdef __SUPPORT_DRM__
-       _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+       MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
 #endif
 
-       _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+       MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
        MSG_DEBUG("_MmsReadMsgBody:    E  N  D    (fail)    ******************** \n");
 
        return false;
 }
 
-
-bool MsgFreeHeaderAddress(MsgHeaderAddress *pAddr)
+static bool __MsgFreeHeaderAddress(MsgHeaderAddress *pAddr)
 {
        MsgHeaderAddress *pTempAddr = NULL;
 
@@ -4910,7 +4482,7 @@ bool MsgFreeHeaderAddress(MsgHeaderAddress *pAddr)
        return true;
 }
 
-bool MsgCheckFileNameHasInvalidChar(char *szName)
+static bool __MsgCheckFileNameHasInvalidChar(char *szName)
 {
        int     strLen = 0;
        int i = 0;
@@ -4925,7 +4497,7 @@ bool MsgCheckFileNameHasInvalidChar(char *szName)
        return false;
 }
 
-bool _MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar)
+static bool __MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar)
 {
        int nCount = 0;
        int totalLength = 0;
@@ -4946,7 +4518,7 @@ bool _MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar)
        return true;
 }
 
-char *_MsgGetStringUntilDelimiter(char *pszString, char delimiter)
+static char *__MsgGetStringUntilDelimiter(char *pszString, char delimiter)
 {
        char *pszBuffer = NULL;
        char *pszStrDelimiter = NULL;
@@ -5000,8 +4572,8 @@ char *MsgChangeHexString(char *pOrg)
                        if (pOrg[cIndex+1] != 0 && pOrg[cIndex+2] != 0)         {
                                snprintf(szBuf, sizeof(szBuf), "%c%c", pOrg[cIndex+1], pOrg[cIndex+2]); // read two chars after '%'
 
-                               if (MsgIsHexChar(szBuf) == true) { // check the two character is between  0 ~ F
-                                       OneChar = _MsgConvertHexValue(szBuf);
+                               if (__MsgIsHexChar(szBuf) == true) { // check the two character is between  0 ~ F
+                                       OneChar = __MsgConvertHexValue(szBuf);
 
                                        pNew[index] = OneChar;
                                        index++;
@@ -5015,7 +4587,7 @@ char *MsgChangeHexString(char *pOrg)
        return pNew;
 }
 
-bool _MsgParseParameter(MsgType *pType, char *pSrc)
+static bool __MsgParseParameter(MsgType *pType, char *pSrc)
 {
        char *pName = NULL;
        char *pValue = NULL;
@@ -5031,7 +4603,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
        char *pUTF8Buff = NULL;
 
        while (pSrc != NULL) {
-               pSrc = _MsgSkipWS(pSrc);
+               pSrc = __MsgSkipWS(pSrc);
                if (pSrc == NULL) {
                        /* End of parse parameter */
                        return true;
@@ -5069,9 +4641,9 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
                                if ((pTest = strchr(pValue, MSG_CH_QUOT)) != NULL)
                                        *pTest = MSG_CH_NULL;
 
-                               pDec = _MsgDecodeText(pValue);          // Api is to long, consider Add to another file (MsgMIMECodec.c)
+                               pDec = MsgDecodeText(pValue);           // Api is to long, consider Add to another file (MsgMIMECodec.c)
                        } else {
-                               pDec = _MsgDecodeText(pName);
+                               pDec = MsgDecodeText(pName);
                        }
 
                        switch (_MsgGetCode(MSG_PARAM, pSrc)) {
@@ -5097,7 +4669,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
 
                                memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1);
 
-                               pUTF8Buff = MsgConvertLatin2UTF8FileName(pDec);
+                               pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec);
 
                                if (pUTF8Buff) {
                                        if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) {
@@ -5115,7 +4687,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
                                        free(pUTF8Buff);
                                        pUTF8Buff = NULL;
 
-                                       if (_MsgChangeSpace(pType->param.szName, &szSrc) == true) {
+                                       if (__MsgChangeSpace(pType->param.szName, &szSrc) == true) {
                                                if (szSrc)
                                                        strncpy(pType->param.szName, szSrc , strlen(szSrc));
                                        }
@@ -5126,7 +4698,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
                                        }
 
                                        // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
-                                       _MsgRemoveFilePath(pType->param.szName);
+                                       __MsgRemoveFilePath(pType->param.szName);
                                } else {
                                        MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec);
                                }
@@ -5138,7 +4710,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
 
                                memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1);
 
-                               pUTF8Buff = MsgConvertLatin2UTF8FileName(pDec);
+                               pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec);
 
                                if (pUTF8Buff) {
                                        if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) {
@@ -5156,7 +4728,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
                                        free(pUTF8Buff);
                                        pUTF8Buff = NULL;
 
-                                       if (_MsgChangeSpace(pType->param.szFileName, &szSrc) == true)
+                                       if (__MsgChangeSpace(pType->param.szFileName, &szSrc) == true)
                                                strcpy(pType->param.szFileName, szSrc);
 
                                        if (szSrc) {
@@ -5165,7 +4737,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
                                        }
 
                                        // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
-                                       _MsgRemoveFilePath(pType->param.szFileName);
+                                       __MsgRemoveFilePath(pType->param.szFileName);
                                } else {
                                        MSG_DEBUG("_MsgParseParameter: MsgConvertLatin2UTF8FileName(%s) return NULL\n", pDec);
                                }
@@ -5234,7 +4806,7 @@ bool _MsgParseParameter(MsgType *pType, char *pSrc)
        return true;
 }
 
-char *_MsgSkipWS(char *s)
+static char *__MsgSkipWS(char *s)
 {
        while (true) {
                if ((*s == MSG_CH_CR) || (*s == MSG_CH_LF) || (*s == MSG_CH_SP) || (*s == MSG_CH_TAB)) {
@@ -5245,7 +4817,7 @@ char *_MsgSkipWS(char *s)
        }
 }
 
-char *__MsgSkipComment (char *s,long trim)
+static char *__MsgSkipComment (char *s,long trim)
 {
 
        char *ret;
@@ -5291,19 +4863,19 @@ char *__MsgSkipComment (char *s,long trim)
        return NULL;
 }
 
-char *MsgConvertLatin2UTF8FileName(char *pSrc)
+static char *__MsgConvertLatin2UTF8FileName(char *pSrc)
 {
        char *pUTF8Buff  = NULL;
        char *pData = NULL;
 
 
        //convert utf8 string
-       if (MsgIsUTF8String((unsigned char*)pSrc, strlen(pSrc)) == false) {
+       if (__MsgIsUTF8String((unsigned char*)pSrc, strlen(pSrc)) == false) {
                int length  = 0;
                int utf8BufSize = 0;
 
                length = strlen(pSrc);
-               utf8BufSize = MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length);
+               utf8BufSize = __MsgGetLatin2UTFCodeSize((unsigned char*)pSrc, length);
                if (utf8BufSize < 3)
                        utf8BufSize = 3; //min value
 
@@ -5314,7 +4886,7 @@ char *MsgConvertLatin2UTF8FileName(char *pSrc)
                        goto __CATCH;
                }
 
-               if (MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pSrc, length) < 0) {
+               if (__MsgLatin2UTF ((unsigned char*)pUTF8Buff, utf8BufSize + 1, (unsigned char*)pSrc, length) < 0) {
                        MSG_DEBUG("MsgConvertLatin2UTF8FileName: MsgLatin2UTF fail \n");
                        goto __CATCH;
                }
@@ -5331,7 +4903,7 @@ char *MsgConvertLatin2UTF8FileName(char *pSrc)
        }
 
        //convert hex string
-       if (MsgIsPercentSign(pUTF8Buff) == true) {
+       if (__MsgIsPercentSign(pUTF8Buff) == true) {
                pData = MsgChangeHexString(pUTF8Buff);
                if (pData) {
                        strcpy(pUTF8Buff, pData);
@@ -5352,7 +4924,7 @@ __CATCH:
        return NULL;
 }
 
-bool _MsgChangeSpace(char *pOrg, char **ppNew)
+static bool __MsgChangeSpace(char *pOrg, char **ppNew)
 {
        char *pNew = NULL;
        int cLen = 0;
@@ -5385,7 +4957,7 @@ bool _MsgChangeSpace(char *pOrg, char **ppNew)
        return true;
 }
 
-void _MsgRemoveFilePath(char *pSrc)
+static void __MsgRemoveFilePath(char *pSrc)
 {
        // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif"
        char *pPath = NULL;
@@ -5421,7 +4993,7 @@ void _MsgRemoveFilePath(char *pSrc)
        }
 }
 
-bool MsgIsUTF8String(unsigned char *szSrc, int nChar)
+static bool __MsgIsUTF8String(unsigned char *szSrc, int nChar)
 {
        MSG_DEBUG("MsgIsUTF8String: --------------- \n");
 
@@ -5467,7 +5039,7 @@ __CATCH:
        return false;
 }
 
-bool MsgIsPercentSign(char *pSrc)
+static bool __MsgIsPercentSign(char *pSrc)
 {
        char *pCh = NULL;
        bool bRet = false;
@@ -5483,7 +5055,7 @@ bool MsgIsPercentSign(char *pSrc)
        return bRet;
 }
 
-MsgMultipart *MsgAllocMultipart(void)
+static MsgMultipart *__MsgAllocMultipart(void)
 {
        MsgMultipart *pMultipart = NULL;
 
@@ -5501,8 +5073,8 @@ MsgMultipart *MsgAllocMultipart(void)
                goto __CATCH;
        }
 
-       _MsgInitMsgType(&pMultipart->type);
-       _MsgInitMsgBody(pMultipart->pBody);
+       __MsgInitMsgType(&pMultipart->type);
+       __MsgInitMsgBody(pMultipart->pBody);
 
        pMultipart->pNext = NULL;
 
@@ -5523,7 +5095,7 @@ __CATCH:
        return NULL;
 }
 
-bool _MsgInitMsgType(MsgType *pMsgType)
+static bool __MsgInitMsgType(MsgType *pMsgType)
 {
        pMsgType->offset = 0;
        pMsgType->size = 0;
@@ -5552,8 +5124,7 @@ bool _MsgInitMsgType(MsgType *pMsgType)
        return true;
 }
 
-
-bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam)
+static bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam)
 {
        pMsgContentParam->charset = MSG_CHARSET_UNKNOWN;
        pMsgContentParam->type = MIME_UNKNOWN;
@@ -5573,15 +5144,14 @@ bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam)
        return true;
 }
 
-
-bool _MsgInitMsgBody(MsgBody *pMsgBody)
+static bool __MsgInitMsgBody(MsgBody *pMsgBody)
 {
        pMsgBody->offset = 0;
        pMsgBody->size = 0;
        pMsgBody->body.pText = NULL;
        pMsgBody->szOrgFilePath[0] = '\0';
 
-       _MsgInitMsgType(&pMsgBody->presentationType);
+       __MsgInitMsgType(&pMsgBody->presentationType);
        pMsgBody->pPresentationBody = NULL;
 
        memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX);
@@ -5589,8 +5159,7 @@ bool _MsgInitMsgBody(MsgBody *pMsgBody)
        return true;
 }
 
-
-MsgPresentationFactor MsgIsPresentationEx(MsgType *multipartType, char* szStart, MsgContentType typeParam)
+static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char* szStart, MimeType typeParam)
 {
        char szTmpStart[MSG_MSG_ID_LEN + 3] = { 0, };
        char szTmpContentID[MSG_MSG_ID_LEN + 3] = { 0, };
@@ -5652,13 +5221,13 @@ MsgPresentationFactor MsgIsPresentationEx(MsgType *multipartType, char* szStart,
        }
 }
 
-void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo)
+static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo)
 {
        MSG_BEGIN();
        MsgMultipart *pNextPart = NULL;
        MsgMultipart *pRemovePart = NULL;
 
-       if (MsgIsMultipartRelated(pMsgType->type)) {
+       if (__MsgIsMultipartRelated(pMsgType->type)) {
                // assign the multipart to presentation part
                // remove the multipart(pCurPresentation) which is presentation part from the linked list.
                // if there is no presentation part -> assign first multipart to presentation part by force.
@@ -5668,7 +5237,7 @@ void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresent
                        pPresentationInfo->factor                       = MSG_PRESENTATION_NONE;
                }
 
-               if (pPresentationInfo->pCurPresentation != NULL && MsgIsPresentablePart(pPresentationInfo->pCurPresentation->type.type)) {
+               if (pPresentationInfo->pCurPresentation != NULL && __MsgIsPresentablePart(pPresentationInfo->pCurPresentation->type.type)) {
                        /* Presentable Part is some MARK-UP page, such as SMIL, HTML, WML, XHTML.
                         * In this case, COPY the Presentation part and leave other multiparts.
                         */
@@ -5683,7 +5252,7 @@ void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresent
                                pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size;
                                if (pPresentationInfo->pCurPresentation) {
 #ifdef __SUPPORT_DRM__
-                                       _MsgFreeDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo);
+                                       MsgFreeDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo);
 #endif
                                        free(pPresentationInfo->pCurPresentation);
                                        pPresentationInfo->pCurPresentation = NULL;
@@ -5698,7 +5267,7 @@ void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresent
                                        pPresentationInfo->pCurPresentation = NULL;
                                }
                        }
-               } else if (pPresentationInfo->pCurPresentation != NULL && MsgIsText(pPresentationInfo->pCurPresentation->type.type)) {
+               } else if (pPresentationInfo->pCurPresentation != NULL && __MsgIsText(pPresentationInfo->pCurPresentation->type.type)) {
                        /* NON-Presentable Part is some PLAIN part such as, text/plain, multipart/alternative.
                         * In this case, leave the Presentation part as a multipart and remove other multiparts.
                         */
@@ -5716,7 +5285,7 @@ void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresent
                                pNextPart = pNextPart->pNext;
 
                                if (pRemovePart->pBody) {
-                                       _MsgFreeBody(pRemovePart->pBody, pRemovePart->type.type);
+                                       MsgFreeBody(pRemovePart->pBody, pRemovePart->type.type);
                                        free(pRemovePart->pBody);
                                        pRemovePart->pBody = NULL;
                                }
@@ -5726,16 +5295,16 @@ void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresent
                        }
                } else {
 #ifdef __SUPPORT_DRM__
-                       _MsgFreeDRMInfo(&pMsgBody->presentationType.drmInfo);
+                       MsgFreeDRMInfo(&pMsgBody->presentationType.drmInfo);
 #endif
-                       _MsgInitMsgType(&pMsgBody->presentationType);
+                       __MsgInitMsgType(&pMsgBody->presentationType);
                        pMsgBody->pPresentationBody = NULL;
                }
        }
        MSG_END();
 }
 
-bool MsgIsMultipartRelated(int type)
+static bool __MsgIsMultipartRelated(int type)
 {
        if (type == MIME_MULTIPART_RELATED || type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
                return true;
@@ -5744,7 +5313,7 @@ bool MsgIsMultipartRelated(int type)
        }
 }
 
-bool MsgIsPresentablePart(int type)
+static bool __MsgIsPresentablePart(int type)
 {
        if (type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML || type == MIME_APPLICATION_SMIL) {
                return true;
@@ -5754,7 +5323,7 @@ bool MsgIsPresentablePart(int type)
 }
 
 #ifdef __SUPPORT_DRM__
-void _MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo)
+void MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo)
 {
        MSG_DEBUG("_MsgFreeDRMInfo: S T A R T  !!! \n");
 
@@ -5793,14 +5362,6 @@ void _MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo)
                pDrmInfo->szDrm2FullPath = NULL;
        }
 
-#if MMS_ENABLE_EXTEND_CFM
-       // DRM (Extended)CFM
-       if (pDrmInfo->pszContentType) {
-               free(pDrmInfo->pszContentType);
-               pDrmInfo->pszContentType = NULL;
-       }
-#endif
-
        pDrmInfo->contentType = MIME_UNKNOWN;
        pDrmInfo->drmType = MSG_DRM_TYPE_NONE;
 }
@@ -5846,7 +5407,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);
                }
        }
 
@@ -5855,7 +5416,7 @@ bool MsgCopyDrmInfo(MsgType *pPartType)
 
 #endif
 
-bool MsgIsText(int type)
+static bool __MsgIsText(int type)
 {
        if (type == MIME_TEXT_PLAIN || type == MIME_TEXT_HTML || type == MIME_TEXT_VND_WAP_WML ||
                type == MIME_TEXT_X_VNOTE || type == MIME_APPLICATION_SMIL || type == MIME_TEXT_X_IMELODY) {
@@ -5913,7 +5474,7 @@ bool MsgFreeAttrib(MmsAttrib *pAttrib)
        return true;
 }
 
-bool _MsgFreeBody(MsgBody *pBody, int type)
+bool MsgFreeBody(MsgBody *pBody, int type)
 {
        MSG_DEBUG("_MsgFreeBody: S T A R T  !!! \n") ;
 
@@ -5945,7 +5506,7 @@ bool _MsgFreeBody(MsgBody *pBody, int type)
 
                                if (pCurrPart) {
 #ifdef __SUPPORT_DRM__
-                                       _MsgFreeDRMInfo(&pCurrPart->type.drmInfo);
+                                       MsgFreeDRMInfo(&pCurrPart->type.drmInfo);
 #endif
 
                                        if (pCurrPart->pBody) {
@@ -5972,7 +5533,7 @@ bool _MsgFreeBody(MsgBody *pBody, int type)
                                pBody->pPresentationBody = NULL;
                        }
 
-                       _MsgInitMsgType(&pBody->presentationType);
+                       __MsgInitMsgType(&pBody->presentationType);
 
                        break;
                }
@@ -5994,7 +5555,7 @@ bool _MsgFreeBody(MsgBody *pBody, int type)
 
 }
 
-bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
+static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 {
        MSG_BEGIN();
        MsgMultipart *pTmpMultipart = NULL;
@@ -6059,15 +5620,15 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                if (pRemoveList) {
 #ifdef __SUPPORT_DRM__
-                       _MsgFreeDRMInfo(&pRemoveList->type.drmInfo);
+                       MsgFreeDRMInfo(&pRemoveList->type.drmInfo);
 #endif
-                       _MsgFreeBody(pRemoveList->pBody, pRemoveList->type.type);
+                       MsgFreeBody(pRemoveList->pBody, pRemoveList->type.type);
 
                        free(pRemoveList->pBody);
                        free(pRemoveList);
                }
 
-               if (MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
+               if (__MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
                        MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n");
                        goto __CATCH;
                }
@@ -6077,7 +5638,7 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                if (pSelectedPart != NULL) {
 #ifdef __SUPPORT_DRM__
-                       _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+                       MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
 #endif
 
                        if (pSelectedPart->pBody != NULL) {
@@ -6098,7 +5659,7 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
                pSelectedPart = pPartBody->body.pMultipart;
 
                while (pSelectedPart) {
-                       if (MsgIsMultipartMixed(pSelectedPart->type.type)) {
+                       if (__MsgIsMultipartMixed(pSelectedPart->type.type)) {
 
                                if (pSelectedPart->pBody == NULL) {
                                        MSG_DEBUG("MsgResolveNestedMultipart :pSelectedPart->pBody(1) is NULL\n");
@@ -6133,15 +5694,15 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                                if (pSelectedPart) {
 #ifdef __SUPPORT_DRM__
-                                       _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+                                       MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
 #endif
                                        free(pSelectedPart->pBody);
                                        free(pSelectedPart);
                                }
                                pSelectedPart = pTmpMultipart;
-                       } else if (MsgIsMultipartRelated(pSelectedPart->type.type) && pPrevPart != NULL) {
+                       } else if (__MsgIsMultipartRelated(pSelectedPart->type.type) && pPrevPart != NULL) {
                                pPrevPart->pNext = pTmpMultipart = pSelectedPart->pNext;
-                               _MsgFreeBody(pSelectedPart->pBody, pSelectedPart->type.type);
+                               MsgFreeBody(pSelectedPart->pBody, pSelectedPart->type.type);
 
                                free(pSelectedPart->pBody);
                                free(pSelectedPart);
@@ -6206,7 +5767,7 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
                                pPartType->type = pSelectedPart->type.type;
 
 #ifdef __SUPPORT_DRM__
-                               _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+                               MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
 #endif
                                free(pSelectedPart->pBody);
                                free(pSelectedPart);
@@ -6267,9 +5828,9 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                while (pTmpMultipart) {
 #ifdef __SUPPORT_DRM__
-                       _MsgFreeDRMInfo(&pTmpMultipart->type.drmInfo);
+                       MsgFreeDRMInfo(&pTmpMultipart->type.drmInfo);
 #endif
-                       _MsgFreeBody(pTmpMultipart->pBody, pTmpMultipart->type.type);
+                       MsgFreeBody(pTmpMultipart->pBody, pTmpMultipart->type.type);
                        pNextRemovePart = pTmpMultipart->pNext;
 
                        free(pTmpMultipart->pBody);
@@ -6277,7 +5838,7 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
                        pTmpMultipart = pNextRemovePart;
                }
 
-               if (MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
+               if (__MsgCopyNestedMsgType(pPartType, &(pSelectedPart->type)) == false) {
                        MSG_DEBUG("MsgResolveNestedMultipart : MsgPriorityCopyMsgType failed \n");
                        goto __CATCH;
                }
@@ -6287,7 +5848,7 @@ bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody)
 
                if (pSelectedPart != NULL) {
 #ifdef __SUPPORT_DRM__
-                       _MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
+                       MsgFreeDRMInfo(&pSelectedPart->type.drmInfo);
 #endif
                        if (pSelectedPart->pBody != NULL) {
                                free(pSelectedPart->pBody);
@@ -6355,257 +5916,6 @@ __CATCH:
        return NULL;
 }
 
-bool _MsgParsePartHeader(MsgType *pType, const char *pRawData, int nRawData)
-{
-       char ch = '\0';
-       int cRaw = nRawData;
-       char *pFieldLine = NULL;
-       char *pFieldValue = NULL;
-       char *szFieldValue = NULL;
-       char *szSrc = NULL;
-       int nLen = 0;
-       char fieldLine[MSG_LINE_LEN] = {0, }; //temporary line buffer
-       int length = 0;
-
-       char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE];
-
-       while ((cRaw > 0) && *pRawData != MSG_CH_LF) {
-               memset(fieldLine, 0, MSG_LINE_LEN);
-               pFieldLine = fieldLine;
-
-               ch = MSG_CH_SP; //remember previous character.
-
-               while (ch) {
-                       switch (ch = *pRawData++) {
-                       case MSG_CH_CR: //'\r'
-                               if (*pRawData == MSG_CH_LF)
-                                       break;
-
-                       case MSG_CH_LF: //'\n'
-                               if (*pRawData != MSG_CH_SP && *pRawData != MSG_CH_TAB) {
-                                       ch = MSG_CH_NULL;
-                                       *pFieldLine = ch;
-                                       pFieldLine++;
-                               }
-                               break;
-
-                       case MSG_CH_TAB: //'\t'
-                               *pFieldLine = MSG_CH_SP;
-                               pFieldLine++;
-                               break;
-
-                       default:
-                               *pFieldLine = ch;
-                               pFieldLine++;
-                               break;
-                       }
-
-                       if (--cRaw <= 0) {  //If is the last character of header
-                               *pFieldLine = MSG_CH_NULL;
-                               pFieldLine++;
-                       }
-               }
-
-
-               if ((pFieldValue =  strchr(fieldLine, MSG_CH_COLON)) != NULL) {
-                       char*   pTemp = pFieldValue;
-                       char*   pValue = NULL;
-
-                       *pFieldValue++ = MSG_CH_NULL; //remove ':'
-
-                       while (*pFieldValue == MSG_CH_SP) //remove space ' '
-                               pFieldValue++;
-
-                       while ((fieldLine < pTemp--) && (*pTemp == MSG_CH_SP))
-                               *pTemp = MSG_CH_NULL;
-
-                       nLen = strlen(pFieldValue);
-
-                       if (nLen >= MSG_LOCAL_TEMP_BUF_SIZE) {
-                               szFieldValue = (char *)malloc(nLen + 1);
-                               memset(szFieldValue, 0 , nLen + 1);
-                               memcpy(szFieldValue, pFieldValue, nLen + 1);
-                       } else {
-                               memset(szTempBuf, 0, MSG_LOCAL_TEMP_BUF_SIZE);
-                               strcpy(szTempBuf, pFieldValue);
-                               szFieldValue = szTempBuf;
-                       }
-
-                       if (MsgStrcpyWithoutCRLF(szFieldValue, &szSrc) == true) {
-                               if (szSrc != NULL)
-                                       strncpy(szFieldValue, szSrc, strlen(szSrc));
-                       }
-                       if (szSrc) {
-                               free(szSrc);
-                               szSrc = NULL;
-                       }
-
-                       switch (_MsgGetCode(MSG_FIELD, fieldLine)) {
-                       case MSG_FIELD_CONTENT_ID:
-                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) != NULL)
-                                       *pTemp++ = MSG_CH_NULL;
-
-                               pValue = _MsgDecodeText(szFieldValue);
-                               memset (pType->szContentID, 0, MSG_MSG_ID_LEN + 1);
-
-                               if (pValue) {
-                                       // support CD & SD
-                                       length = MsgStrlen(pValue);
-                                       if (pValue[0] == '<' && pValue[length-1] == '>') {
-                                               strncpy(pType->szContentID, pValue + 1, length - 2);
-                                       } else {
-                                               strncpy(pType->szContentID, pValue, MSG_MSG_ID_LEN);
-                                       }
-
-                                       MSG_DEBUG("_MsgParsePartHeader: Content-ID = %s     %s\n", pFieldValue, pType->szContentID);
-
-                                       if (pTemp != NULL)
-                                               _MsgParseParameter(pType, pTemp);
-
-                                       free(pValue);
-                                       pValue = NULL;
-                               }
-
-                               break;
-
-                       case MSG_FIELD_CONTENT_LOCATION:
-                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) != NULL)
-                                       *pTemp++ = MSG_CH_NULL;
-
-                               pValue = _MsgDecodeText(szFieldValue);
-                               memset (pType->szContentLocation, 0, MSG_MSG_ID_LEN + 1);
-
-                               if (pValue) {
-                                       strncpy(pType->szContentLocation, pValue, MSG_MSG_ID_LEN);
-
-                                       MSG_DEBUG("_MsgParsePartHeader: Content-Location = %s     %s\n", pFieldValue, pType->szContentLocation);
-
-                                       if (pTemp != NULL)
-                                               _MsgParseParameter(pType, pTemp);
-
-                                       free(pValue);
-                                       pValue = NULL;
-                               }
-
-                               break;
-
-                       case MSG_FIELD_CONTENT_TYPE:
-                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) {
-                                       if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL)
-                                               *pTemp++ = MSG_CH_NULL;
-                               } else {
-                                       *pTemp++ = MSG_CH_NULL;
-                               }
-
-                               pType->type = _MsgGetCode(MSG_TYPE, szFieldValue);
-
-                               MSG_DEBUG("_MsgParsePartHeader: Content-Type = %s     %d\n", pFieldValue, pType->type);
-
-                               if (pType->type == INVALID_HOBJ)
-                                       pType->type = MIME_UNKNOWN;
-
-                               if (pTemp != NULL)
-                                       _MsgParseParameter(pType, pTemp);
-
-                               break;
-
-                       case MSG_FIELD_CONTENT_TRANSFER_ENCODING:
-                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) {
-                                       if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL)
-                                               *pTemp++ = MSG_CH_NULL;
-                               } else {
-                                       *pTemp++ = MSG_CH_NULL;
-                               }
-
-                               pType->encoding = _MsgGetCode(MSG_ENCODING, szFieldValue);
-
-                               MSG_DEBUG("_MsgParsePartHeader: Content-Encoding = %s     %d\n", pFieldValue, pType->encoding);
-
-                               if (pTemp != NULL)
-                                       _MsgParseParameter(pType, pTemp);
-
-                               break;
-
-                       case MSG_FIELD_CONTENT_DISPOSITION:
-                               if ((pTemp = strchr(szFieldValue, MSG_CH_SEMICOLON)) == NULL) {
-                                       if ((pTemp = strchr(szFieldValue, MSG_CH_SP)) != NULL)
-                                               *pTemp++ = MSG_CH_NULL;
-                               } else {
-                                       *pTemp++ = MSG_CH_NULL;
-                               }
-
-                               pType->disposition = _MsgGetCode(MSG_DISPOSITION, szFieldValue);
-
-                               MSG_DEBUG("_MsgParsePartHeader: Content-Disposition = %s     %d\n", pFieldValue, pType->disposition);
-
-                               if (pTemp != NULL)
-                                       _MsgParseParameter(pType, pTemp);
-
-                               break;
-
-#ifdef __SUPPORT_DRM__
-
-                       case MSG_FIELD_CONTENT_NAME:
-                               /* add to parse DCF header such as,
-                                * Right-Issuer, Content-Name, and Content-Description.
-                                */
-                               MsgMIMERemoveQuote(szFieldValue);
-                               pType->drmInfo.szContentName = MsgStrCopy(szFieldValue);
-                               break;
-
-                       case MSG_FIELD_CONTENT_DESCRIPTION:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               pType->drmInfo.szContentDescription = MsgStrCopy(szFieldValue);
-                               break;
-
-                       case MSG_FIELD_CONTENT_VENDOR:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               pType->drmInfo.szContentVendor = MsgStrCopy(szFieldValue);
-                               break;
-
-                       case MSG_FIELD_RIGHT_ISSUER:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               pType->drmInfo.szRightIssuer = MsgStrCopy(szFieldValue);
-                               break;
-
-
-                       case MSG_FIELD_DRM_CONVERTED:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               pType->nDrmConvertedStatus = atoi(szFieldValue);
-                               break;
-
-#endif
-                       case MSG_FILED_CONTENT_REPLACE_POS:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               strncpy(pType->szContentRepPos, szFieldValue, sizeof(pType->szContentRepPos) - 1);
-                               break;
-
-                       case MSG_FILED_CONTENT_REPLACE_SIZE:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               strncpy(pType->szContentRepSize, szFieldValue, sizeof(pType->szContentRepSize) - 1);
-                               break;
-
-                       case MSG_FILED_CONTENT_REPLACE_INDEX:
-                               MsgMIMERemoveQuote(szFieldValue);
-                               strncpy(pType->szContentRepIndex, szFieldValue, sizeof(pType->szContentRepIndex) - 1);
-                               break;
-
-                       default:
-                               MSG_DEBUG("_MsgParsePartHeader: Unhandled field \n");
-                               break;
-                       }
-               }
-
-               if (szFieldValue != NULL && szFieldValue != szTempBuf) {
-                       free(szFieldValue);
-                       szFieldValue = NULL;
-               }
-
-       }
-
-       return true;
-}
-
 char *MsgRemoveQuoteFromFilename(char *pSrc)
 {
        int cLen = 0;   // length of pBuff
@@ -6660,7 +5970,7 @@ bool MsgIsMultipart(int type)
 }
 
 
-bool MsgIsHexChar(char *pSrc)
+static bool __MsgIsHexChar(char *pSrc)
 {
        int cIndex = 0;
        int cLen = 0;
@@ -6680,7 +5990,7 @@ bool MsgIsHexChar(char *pSrc)
        return bRet;
 }
 
-char _MsgConvertHexValue(char *pSrc)
+static char __MsgConvertHexValue(char *pSrc)
 {
        int ch = 0;
        int cIndex = 0;
@@ -6701,7 +6011,7 @@ char _MsgConvertHexValue(char *pSrc)
        return ResultChar;
 }
 
-int __MsgConvertCharToInt(char ch)
+static int __MsgConvertCharToInt(char ch)
 {
        if (ch>='0' && ch<='9') {
                return ch - '0';
@@ -6714,7 +6024,7 @@ int __MsgConvertCharToInt(char ch)
        }
 }
 
-bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2)
+static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2)
 {
        if (pMsgType1->section == INVALID_HOBJ)
                pMsgType1->section = pMsgType2->section;
@@ -6768,7 +6078,7 @@ bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2)
        pMsgType1->size = pMsgType2->size;
        pMsgType1->type = pMsgType2->type;
 
-       MsgCopyNestedMsgParam(&(pMsgType1->param), &(pMsgType2->param));
+       __MsgCopyNestedMsgParam(&(pMsgType1->param), &(pMsgType2->param));
 
        if (pMsgType1->param.szName[0]) {
 #ifdef __SUPPORT_DRM__
@@ -6779,8 +6089,7 @@ bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2)
        return true;
 }
 
-
-bool MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2)
+static bool __MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2)
 {
        if (pParam1->charset == MSG_CHARSET_UNKNOWN)
                pParam1->charset = pParam2->charset;
@@ -6809,7 +6118,7 @@ bool MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2)
        return true;
 }
 
-bool MsgIsMultipartMixed(int type)
+static bool __MsgIsMultipartMixed(int type)
 {
        if (type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED || type == MIME_MULTIPART_MIXED) {
                return true;
@@ -6818,40 +6127,6 @@ bool MsgIsMultipartMixed(int type)
        }
 }
 
-bool MsgStrcpyWithoutCRLF(char *pOrg, char **ppNew)
-{
-       int nLen = 0;
-       int     i = 0;
-       int index = 0;
-       char*   pDest = NULL;
-
-
-       nLen = strlen(pOrg);
-
-       pDest = (char *)malloc(nLen + 1);
-
-       if (pDest == NULL) {
-               MSG_DEBUG("MsgStrcpyWithoutCRLF: malloc is failed\n");
-               return false;
-       }
-
-       memset(pDest, 0 , (nLen + 1));
-
-       for (i = 0; i < nLen ; i++) {
-               if (i < nLen - 2) {
-                       if ((pOrg[i] == MSG_CH_CR && pOrg[i+1] == MSG_CH_LF && pOrg[i+2] == MSG_CH_TAB) ||
-                               (pOrg[i] == MSG_CH_CR && pOrg[i+1] == MSG_CH_LF && pOrg[i+2] == MSG_CH_SP)) {
-                               i+=2;
-                               continue;
-                       }
-               }
-               pDest[index++] = pOrg[i];
-       }
-       *ppNew = pDest;
-
-       return true;
-}
-
 bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib* pAttrib)
 {
        MmsMsg *pMsg = NULL;
@@ -6869,7 +6144,7 @@ bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib* pAttrib)
        return true;
 }
 
-bool __MsgIsInvalidFileNameChar(char ch)
+static bool __MsgIsInvalidFileNameChar(char ch)
 {
        if ((ch == 0x5C /* \ */) ||
                (ch == 0x2F /* / */) ||
@@ -6885,7 +6160,7 @@ bool __MsgIsInvalidFileNameChar(char ch)
        return false;
 }
 
-bool _MmsDataUpdateLastStatus(MmsMsg *pMsg)
+bool MmsDataUpdateLastStatus(MmsMsg *pMsg)
 {
        MmsMsgMultiStatus*      pStatus = NULL;
 
@@ -6930,7 +6205,7 @@ bool MmsAddrUtilCompareAddr(char *pszAddr1, char *pszAddr2)
        return false;
 }
 
-int MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar)
+static int __MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar)
 {
        int nCount = 0;
 
@@ -6956,7 +6231,7 @@ int MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar)
        return nCount;
 }
 
-int MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+static int __MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
 {
        unsigned char *org;
        unsigned char t1;
@@ -7106,7 +6381,7 @@ __RETURN:
        return(des-org);
 }
 
-int MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
+static int __MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
 {
        int nCount = 0;
 
@@ -7135,7 +6410,7 @@ int MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar)
        return nCount;
 }
 
-int MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+static int __MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
 {
        unsigned char*  org;
        unsigned char   t1, t2;
@@ -7184,7 +6459,7 @@ __RETURN:
 }
 
 
-int MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+static int __MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
 {
        unsigned char *org;
        unsigned char t1;
@@ -7347,7 +6622,7 @@ __RETURN:
        return(des - org);
 }
 
-int MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar)
+static int __MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar)
 {
        int nCount = 0;
 
@@ -7379,7 +6654,7 @@ int MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar)
        return nCount;
 }
 
-int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar)
+static int __MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar)
 {
        unsigned char *org;
        unsigned char t1;
@@ -7447,7 +6722,7 @@ __RETURN:
        return (des - org);
 }
 
-int MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar)
+static int __MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar)
 {
        int nCount = 0;
 
@@ -7477,7 +6752,7 @@ int MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar)
        return nCount;
 }
 
-bool MmsAddrUtilCheckEmailAddress(char *pszAddr)
+static bool __MmsAddrUtilCheckEmailAddress(char *pszAddr)
 {
        if (!pszAddr || pszAddr[0] == 0)
                return false;
@@ -7518,7 +6793,7 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr)
                char*   pszStrEnd = NULL;
                int             addressLen = 0;
 
-               if (MmsAddrUtilCheckEmailAddress(pszAddrCopy))
+               if (__MmsAddrUtilCheckEmailAddress(pszAddrCopy))
                        pszStrEnd = strstr(pszStrStart, "/TYPE=PLMN");
                else
                        pszStrEnd = strstr(pszStrStart, "/");
@@ -7569,7 +6844,7 @@ bool MmsAddrUtilRemovePlmnString(char *pszAddr)
        return true;
 }
 
-int MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
+static int __MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar)
 {
        unsigned char *org;
 
@@ -7628,7 +6903,7 @@ __RETURN:
        return (des - org);
 }
 
-void MsgMIMERemoveQuote(char *szSrc)
+static void __MsgMIMERemoveQuote(char *szSrc)
 {
        int             length = 0;
 
@@ -7642,7 +6917,7 @@ void MsgMIMERemoveQuote(char *szSrc)
        }
 }
 
-bool MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *pBufLen, int endOfFile)
+static bool __MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *pBufLen, int endOfFile)
 {
        MSG_BEGIN();
        int nRead = 0;
@@ -7789,7 +7064,7 @@ __CATCH:
  *     @param  index                   : used for file naming
  *     @param  bSave                   : if true, file will be save otherwise just filename will be stored.
  */
-bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave)
+static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave)
 {
        FILE *pFile = NULL;
 //     char *pExt = NULL;
@@ -7814,9 +7089,9 @@ bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *p
 
 
 #ifndef __SUPPORT_DRM__
-       MsgMakeFileName(pPartType->type, szFileName, 0);        //FL & CD -> extension(.dm) SD -> extension(.dcf)
+       __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);  //FL & CD -> extension(.dm) SD -> extension(.dcf)
        if (MsgDRMIsForwardLockType(pPartType->drmInfo.drmType))
                MsgChangeDrm2FileName(szFileName);
 #endif
@@ -7835,7 +7110,7 @@ bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *p
                        goto __CATCH;
                }
 
-               if (MmsGetMediaPartData(pPartType, pPartBody, pFile) == false) {
+               if (__MmsGetMediaPartData(pPartType, pPartBody, pFile) == false) {
                        MSG_DEBUG("MmsGetMediaPartData fail [index:%d]\n", index);
                        goto __CATCH;
                }
@@ -7867,9 +7142,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile)
+static bool __MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile)
 {
        int nRead = 0;
        int nRead2 = 0;
@@ -7912,10 +7185,10 @@ bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE* pFile)
                goto __RETURN;
        }
 
-       pNewData = MmsGetBinaryUTF8Data(pData, nRead, msgEncodingValue, msgTypeValue, msgCharsetValue, &nRead2);
+       pNewData = __MmsGetBinaryUTF8Data(pData, nRead, msgEncodingValue, msgTypeValue, msgCharsetValue, &nRead2);
        pPartType->encoding = MSG_ENCODING_BINARY;
 
-       if (MsgIsText(msgTypeValue))
+       if (__MsgIsText(msgTypeValue))
                pPartType->param.charset = MSG_CHARSET_UTF8;
 
        if (MsgWriteFile(pNewData, sizeof(char), nRead2,  pFile) != (size_t)nRead2) {
@@ -7953,7 +7226,7 @@ __CATCH:
        return false;
 }
 
-char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead)
+static char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead)
 {
        int nChar = 0;
        int nByte = 0;
@@ -7969,7 +7242,7 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
        switch (msgEncodingValue) {
        case MSG_ENCODING_BASE64:
 
-               pConvertedData = (char*)_MsgDecodeBase64((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
+               pConvertedData = (char*)MsgDecodeBase64((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
                MSG_DEBUG("MmsGetBinaryUTF8Data : MSG_ENCODING_BASE64     bodyLength = %d \n", nByte);
 
                pTemp = pConvertedData;
@@ -7979,7 +7252,7 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
 
        case MSG_ENCODING_QUOTE_PRINTABLE:
 
-               pConvertedData = (char*)_MsgDecodeQuotePrintable((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
+               pConvertedData = (char*)MsgDecodeQuotePrintable((UCHAR*)pData, (ULONG)nRead, (ULONG*)&nByte);
                MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_ENCODING_QUOTE_PRINTABLE     bodyLength = %d \n", nByte);
 
                pTemp = pConvertedData;
@@ -7997,7 +7270,7 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
                break;
        }
 
-       if (MsgIsText(msgTypeValue)) {
+       if (__MsgIsText(msgTypeValue)) {
                /* charset converting */
 
                switch (msgCharsetValue) {
@@ -8017,13 +7290,13 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
 
                                memcpy(mszTempStr, ((unsigned short*)pTemp + 1), nChar * sizeof(unsigned short));
 
-                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp + 1), nChar);
+                               nByte = __MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp + 1), nChar);
                                if (nByte < 3)
                                        nByte = 3; //min value
 
                                pConvertedStr = (char *)malloc(nByte + 1);
                                if (pConvertedStr != NULL)
-                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                                       __MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
                        } else {
                                nChar = (nTemp / 2);
 
@@ -8035,11 +7308,11 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
 
                                memcpy(mszTempStr, ((unsigned short*)pTemp), nChar * sizeof(unsigned short));
 
-                               nByte = MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp), nChar);
+                               nByte = __MsgGetUnicode2UTFCodeSize(((unsigned short*)pTemp), nChar);
 
                                pConvertedStr = (char *)malloc(nByte + 1);
                                if (pConvertedStr)
-                                       MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
+                                       __MsgUnicode2UTF ((unsigned char*)pConvertedStr, nByte + 1, mszTempStr, nChar);
                        }
 
                        if (pConvertedStr != NULL)
@@ -8077,10 +7350,10 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
 
                        MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_7 \n");
 
-                       nByte = MsgGetLatin72UTFCodeSize((unsigned char*)pTemp, nTemp);
+                       nByte = __MsgGetLatin72UTFCodeSize((unsigned char*)pTemp, nTemp);
                        pConvertedStr = (char *)malloc(nByte + 1);
                        if (pConvertedStr)
-                               MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
+                               __MsgLatin7code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
 
                        pNewData = pConvertedStr;
                        *npRead = nByte + 1;
@@ -8092,10 +7365,10 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
                        /* Turkish */
                        MSG_DEBUG("MmsGetBinaryUTF8Data: MSG_CHARSET_ISO_8859_9 \n");
 
-                       nByte = MsgGetLatin52UTFCodeSize((unsigned char*)pTemp, nTemp);
+                       nByte = __MsgGetLatin52UTFCodeSize((unsigned char*)pTemp, nTemp);
                        pConvertedStr = (char *)malloc(nByte + 1);
                        if (pConvertedStr)
-                                       MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
+                                       __MsgLatin5code2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
 
                        pNewData = pConvertedStr;
                        *npRead = nByte + 1;
@@ -8106,10 +7379,10 @@ char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msg
 
                        MSG_DEBUG("MmsGetBinaryUTF8Data: Other charsets \n");
 
-                       nByte = MsgGetLatin2UTFCodeSize((unsigned char*)pTemp, nTemp);
+                       nByte = __MsgGetLatin2UTFCodeSize((unsigned char*)pTemp, nTemp);
                        pConvertedStr = (char *)malloc(nByte + 1);
                        if (pConvertedStr)
-                               MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
+                               __MsgLatin2UTF((unsigned char*)pConvertedStr, nByte + 1, (unsigned char*)pTemp, nTemp);
 
                        pNewData = pConvertedStr;
                        *npRead = nByte + 1;
@@ -8171,7 +7444,7 @@ __CATCH:
 }
 
 #ifndef __SUPPORT_DRM__
-bool MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex)
+static bool __MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex)
 {
        char szText[MSG_FILENAME_LEN_MAX+1]={0,};
        char szTemp[MSG_FILENAME_LEN_MAX+1]={0,};
@@ -8237,7 +7510,7 @@ __CATCH:
        }
 }
 #else
-bool MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex)
+static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex)
 {
        char szText[MSG_FILENAME_LEN_MAX+1]={0,};
        char szTemp[MSG_FILENAME_LEN_MAX+1]={0,};
@@ -8370,7 +7643,7 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
 
        MmsPluginStorage::instance()->getMmsMessage(&pMsg);
 
-       _MsgInitMsgType(pHeader);
+       __MsgInitMsgType(pHeader);
 
 
        /* Requires header of non-presentation */
@@ -8396,7 +7669,7 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader)
        return true;
 }
 
-bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index)
+static bool __MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index)
 {
        MSG_DEBUG("------------------------------\n");
        MSG_DEBUG("%dth multipart info\n", index);
@@ -8423,4 +7696,3 @@ bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index)
        MSG_DEBUG("------------------------------\n");
        return true;
 }
-
index 598aca6..6718795 100755 (executable)
@@ -78,7 +78,7 @@ bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType)
        switch (drmType) {
        case MSG_DRM_FORWARD_LOCK:
                pMsgType->drmInfo.drmType = MSG_DRM_TYPE_FL;
-               pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType);
+               pMsgType->drmInfo.contentType = (MimeType)_MsgGetCode(MSG_TYPE, szMimeType);
                if (MsgCopyDrmInfo(pMsgType) == false) {
                        MSG_DEBUG("MsgDRM2GetDRMInfo : MsgCopyDrmInfo failed");
                        return false;
@@ -93,7 +93,7 @@ bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType)
        case MSG_DRM_SEPARATE_DELIVERY:
                pMsgType->drmInfo.drmType = MSG_DRM_TYPE_SD;
 
-               pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType);
+               pMsgType->drmInfo.contentType = (MimeType)_MsgGetCode(MSG_TYPE, szMimeType);
 
                drm_content_info_s dcfHdrInfo;
                bzero(&dcfHdrInfo, sizeof(drm_content_info_s));
index 2b9b577..2d94a49 100755 (executable)
 #include <time.h>
 #include <stdlib.h>
 
-#include "MmsPluginMessage.h"
-#include "MmsPluginCodec.h"
+#include "MmsPluginEncode.h"
+#include "MmsPluginCodecTypes.h"
+#include "MmsPluginCodecCommon.h"
 #include "MsgDebug.h"
 #include "MsgUtilFile.h"
 #include "MmsPluginMIME.h"
 #include "MmsPluginUtil.h"
 
-gint _g_time_rev_set = 0;
-gint _g_time_rev = 0;
-
 /**  Sending message related variables  ------------------------ */
-
 static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
 static int gCurMmsEncodeBuffPos = 0;   /* number of characters on gpMmsEncodeBuf */
 static int     gMmsEncodeMaxLen = 0;
 static int     gMmsEncodeCurOffset = 0;        /* offset in file */
 static char *gpMmsEncodeBuf = NULL;
 
-
 /* Acknowledge.ind & NotifyResp.ind related variables ------------------------ */
-
 static char gszMmsEncodeBuf2[MSG_MMS_ENCODE_BUFFER_MAX] = {0, };
 static int     gCurMmsEncodeBuffPos2 = 0;      /* number of characters on gpMmsEncodeBuf */
 static int     gMmsEncodeMaxLen2 = 0;
 static int     gMmsEncodeCurOffset2 = 0;       /* offset in file */
 static char *gpMmsEncodeBuf2 = NULL;
 
-
-bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg);
-bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *pTrID, bool bReportAllowed);
-bool _MmsBinaryEncodeNotiRespIndHdr(FILE* pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed);
-bool _MmsBinaryEncodeForwardReqHdr(FILE *pFile, char *szContentLocation, char *szForwardTo, char *szForwardCc, char *szForwardBcc);
-bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
-bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
-
-static         bool __MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg, bool bIncludeSendReqHeader);
-static int MmsBinaryEncodeUintvarLen(UINT32 integer);
-static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length);
-static int MmsBinaryEncodeValueLengthLen(UINT32 integer);
-static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length);
-static int     MmsBinaryEncodeIntegerLen(UINT32 integer);
-static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length);
-static int     MmsBinaryEncodeLongIntegerLen(UINT32 integer);
-static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length);
-static int     MmsBinaryEncodeTextStringLen(UINT8 *source);
-static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length);
-static int     MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc);
-static bool MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length);
-static int     MmsBinaryEncodeEncodedStringLen(UINT8 *source);
-static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length);
-bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg);
-bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID);
-
-static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
+static int __MmsGetEncodeOffset(void);
+static void __MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen);
+static void __MmsUnregisterEncodeBuffer2(void);
+
+static int __MmsBinaryEncodeUintvarLen(UINT32 integer);
+static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length);
+static int __MmsBinaryEncodeValueLengthLen(UINT32 integer);
+static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length);
+static int     __MmsBinaryEncodeIntegerLen(UINT32 integer);
+static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length);
+static int     __MmsBinaryEncodeLongIntegerLen(UINT32 integer);
+static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length);
+static int     __MmsBinaryEncodeTextStringLen(UINT8 *source);
+static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length);
+static int     __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc);
+static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length);
+static int     __MmsBinaryEncodeEncodedStringLen(UINT8 *source);
+static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length);
+
+static int __MmsBinaryEncodeContentTypeLen(MsgType *pType);
+static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength);
+static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pType, bool bMultipart);
+static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, MsgType *pType, bool bMultipart);
+
+static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody);
+static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody);
 
 static bool __MmsBinaryEncodeMmsVersion(FILE *pFile);
 static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen);
@@ -81,20 +75,25 @@ static      bool __MmsBinaryEncodeDate(FILE *pFile);
 static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr);
 static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr);
 
+static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
+static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg);
+static bool __MmsBinaryEncodeAckIndHdr(FILE *pFile, char *pTrID, bool bReportAllowed);
+static bool __MmsBinaryEncodeNotiRespIndHdr(FILE* pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed);
+static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
+static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
 
-/* Functions for Acknowledge.ind & NotifyResp.ind  ------------------------ */
+static bool __MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate);//NEW_TEMPLATE
+static bool __MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg, bool bIncludeSendReqHeader);
 
-static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length);
+/* Functions for Acknowledge.ind & NotifyResp.ind  ------------------------ */
+static bool __MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length);
 static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile);
 static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue);
-extern int MsgProcessUrgentEvent(int iMode);
-
 
 /** -----------------------------------------------------------------
  *                                     M   M   S       E   N   C   O   D   E
  * * -----------------------------------------------------------------*/
 
-
 static void __MmsCleanEncodeBuff(void)
 {
        memset(gpMmsEncodeBuf, 0, MSG_MMS_ENCODE_BUFFER_MAX);
@@ -102,7 +101,7 @@ static      void __MmsCleanEncodeBuff(void)
 }
 
 
-void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen)
+void MmsRegisterEncodeBuffer(char *pInBuff, int maxLen)
 {
        gpMmsEncodeBuf = pInBuff;
        gCurMmsEncodeBuffPos = 0;
@@ -110,7 +109,7 @@ void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen)
        gMmsEncodeCurOffset = 0;
 }
 
-void _MmsUnregisterEncodeBuffer(void)
+void MmsUnregisterEncodeBuffer(void)
 {
        gpMmsEncodeBuf = NULL;
        gCurMmsEncodeBuffPos = 0;
@@ -118,53 +117,42 @@ void _MmsUnregisterEncodeBuffer(void)
        gMmsEncodeCurOffset = 0;
 }
 
-int _MmsGetEncodeOffset(void)
+static int __MmsGetEncodeOffset(void)
 {
        return (gMmsEncodeCurOffset + gCurMmsEncodeBuffPos);
 }
 
-
-bool _MmsEncodeMsg(void)
-{
-       MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now ============= \n");
-       return true;
-}
-
-
-bool _MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg)
+bool MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg)
 {
        return __MmsEncodeSendReq(pFile, pMsg, true);
 }
 
-
-bool _MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg)
+bool MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg)
 {
        return __MmsEncodeSendReq(pFile, pMsg, false);
 }
 
-
 static bool __MmsEncodeSendReq(FILE* pFile, MmsMsg* pMsg, bool bIncludeSendReqHeader)
 {
-       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+       MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
 
        if (bIncludeSendReqHeader) {
-               if (_MmsBinaryEncodeSendReqHdr(pFile, pMsg) == false) {
-                       _MmsUnregisterEncodeBuffer();
+               if (__MmsBinaryEncodeSendReqHdr(pFile, pMsg) == false) {
+                       MmsUnregisterEncodeBuffer();
                        return false;
                }
        }
 
-       if (MmsBinaryEncodeMsgBody(pFile, &pMsg->msgType, &pMsg->msgBody, pMsg->nPartCount, !bIncludeSendReqHeader) == false) {
-               _MmsUnregisterEncodeBuffer();
+       if (__MmsBinaryEncodeMsgBody(pFile, &pMsg->msgType, &pMsg->msgBody, pMsg->nPartCount, !bIncludeSendReqHeader) == false) {
+               MmsUnregisterEncodeBuffer();
                return false;
        }
 
-       _MmsUnregisterEncodeBuffer();
+       MmsUnregisterEncodeBuffer();
 
        return true;
 }
 
-
 /* Functions for Acknowledge.ind & NotifyResp.ind ------------------------ */
 
 static void __MmsCleanEncodeBuff2(void)
@@ -173,8 +161,7 @@ static      void __MmsCleanEncodeBuff2(void)
        gCurMmsEncodeBuffPos2 = 0;
 }
 
-
-void _MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen)
+static void __MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen)
 {
        gpMmsEncodeBuf2 = pInBuff;
        gCurMmsEncodeBuffPos2 = 0;
@@ -182,7 +169,7 @@ void _MmsRegisterEncodeBuffer2(char *pInBuff, int maxLen)
        gMmsEncodeCurOffset2 = 0;
 }
 
-void _MmsUnregisterEncodeBuffer2(void)
+static void __MmsUnregisterEncodeBuffer2(void)
 {
        gpMmsEncodeBuf2 = NULL;
        gCurMmsEncodeBuffPos2 = 0;
@@ -190,14 +177,13 @@ void _MmsUnregisterEncodeBuffer2(void)
        gMmsEncodeCurOffset2 = 0;
 }
 
-
 /**
  * @param      source [in] originam string
  * @param      length [in] gotten from MmsBinaryEncodeTextStringLen()
  * @param      dest [in] buffer to store quted string
  * @return     changed string length
 */
-static bool MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length)
+static bool __MmsBinaryEncodeTextString2(FILE *pFile, UINT8 *source, int length)
 {
        MSG_DEBUG("MmsBinaryEncodeTextString2: \n");
 
@@ -238,7 +224,6 @@ __CATCH:
        return false;
 }
 
-
 static bool __MmsBinaryEncodeFieldCodeAndValue2(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
 {
        if ((gMmsEncodeMaxLen2 - gCurMmsEncodeBuffPos2) < 2) {
@@ -268,7 +253,6 @@ __CATCH:
        return false;
 }
 
-
 static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile)
 {
        UINT8 majorVer = MMS_MAJOR_VERSION;
@@ -289,7 +273,7 @@ static bool __MmsBinaryEncodeMmsVersion2(FILE *pFile)
                }
        }
 
-       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80;
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80;
        gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2] = (majorVer << 4) | (minorVer & 0x0f) | MSB;
 
        if (gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2] < 0x80) {
@@ -304,8 +288,7 @@ __CATCH:
        return false;
 }
 
-
-bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed)
+static bool __MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed)
 {
        int length = 0;
        UINT8 fieldCode = 0xff;
@@ -317,15 +300,15 @@ bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed)
        __MmsCleanEncodeBuff2();
 
        /* msgType */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_ACKNOWLEDGE_IND) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_ACKNOWLEDGE_IND) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: msgType error\n");
                goto __CATCH;
        }
 
        /* trID (other type of message) */
-       length = MmsBinaryEncodeTextStringLen((UINT8*)szTrID);
+       length = __MmsBinaryEncodeTextStringLen((UINT8*)szTrID);
        if (length == -1) {
                MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MmsBinaryEncodeTextStringLen fail \n");
                goto __CATCH;
@@ -339,9 +322,9 @@ bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed)
                }
        }
 
-       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
 
-       if (MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) {
+       if (__MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) {
                MSG_DEBUG("_MmsBinaryEncodeAckIndHdr: MmsBinaryEncodeTextString fail\n");
                goto __CATCH;
        }
@@ -354,12 +337,12 @@ bool _MmsBinaryEncodeAckIndHdr(FILE *pFile, char *szTrID, bool bReportAllowed)
 
 
        /* Report Allowed */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
 
        if (bReportAllowed) {
-               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80;
        } else {
-               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80;
        }
 
        if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
@@ -381,9 +364,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed)
+static bool __MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed)
 {
        int length = 0;
        UINT8 fieldCode = 0xff;
@@ -396,8 +377,8 @@ bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_repo
        __MmsCleanEncodeBuff2();
 
        /* msgType */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_NOTIFYRESP_IND) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_NOTIFYRESP_IND) | 0x80;
 
        if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: msgType error\n");
@@ -406,7 +387,7 @@ bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_repo
 
 
        /* trID (other type of message) */
-       length = MmsBinaryEncodeTextStringLen((UINT8*)szTrID);
+       length = __MmsBinaryEncodeTextStringLen((UINT8*)szTrID);
        if (length == -1) {
                MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MmsBinaryEncodeTextStringLen fail \n");
                goto __CATCH;
@@ -420,8 +401,8 @@ bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_repo
                }
        }
 
-       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
-       if (MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) {
+       gpMmsEncodeBuf2[gCurMmsEncodeBuffPos2++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
+       if (__MmsBinaryEncodeTextString2(pFile, (UINT8*)szTrID, length) == false) {
                MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MmsBinaryEncodeTextString fail\n");
                goto __CATCH;
        }
@@ -437,8 +418,8 @@ bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_repo
        MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgStatus = %d\n", iStatus);
 
        if (iStatus != MSG_DELIVERY_REPORT_NONE) {
-               fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGSTATUS) | 0x80;
-               fieldValue = _MmsGetBinaryValue(MmsCodeMsgStatus, iStatus) | 0x80;
+               fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGSTATUS) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeMsgStatus, iStatus) | 0x80;
                if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
                        MSG_DEBUG("_MmsBinaryEncodeNotiRespIndHdr: MsgStatus error\n");
                        goto __CATCH;
@@ -447,12 +428,12 @@ bool _MmsBinaryEncodeNotiRespIndHdr(FILE *pFile, char *szTrID, msg_delivery_repo
 
 
        /* Report Allowed */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
 
        if (bReportAllowed) {
-               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_YES) | 0x80;
        } else {
-               fieldValue = _MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReportAllowed, MMS_REPORTALLOWED_NO) | 0x80;
        }
 
        if (__MmsBinaryEncodeFieldCodeAndValue2(pFile, fieldCode, fieldValue) == false) {
@@ -474,44 +455,41 @@ __CATCH:
        return false;
 }
 
-
-bool _MmsEncodeAckInd(FILE *pFile, char *pTrID, bool bReportAllowed)
+bool MmsEncodeAckInd(FILE *pFile, char *pTrID, bool bReportAllowed)
 {
-       _MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX);
+       __MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX);
 
        MSG_DEBUG("_MmsEncodeAckInd: Start Binary Encoding now ============= \n");
 
-       if (_MmsBinaryEncodeAckIndHdr(pFile, pTrID, bReportAllowed) == false) {
+       if (__MmsBinaryEncodeAckIndHdr(pFile, pTrID, bReportAllowed) == false) {
                MSG_DEBUG("_MmsEncodeAckInd: SendReq Binary encoding fail \n");
                goto __CATCH;
        }
 
-       _MmsUnregisterEncodeBuffer2();
+       __MmsUnregisterEncodeBuffer2();
 
        return true;
 
 __CATCH:
 
        MSG_DEBUG("## _MmsEncodeAckInd: failed");
-       _MmsUnregisterEncodeBuffer2();
+       __MmsUnregisterEncodeBuffer2();
 
        return false;
 }
 
-
-
-bool _MmsEncodeNotiRespInd(FILE *pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed)
+bool MmsEncodeNotiRespInd(FILE *pFile, char *pTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed)
 {
-       _MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX);
+       __MmsRegisterEncodeBuffer2(gszMmsEncodeBuf2, MSG_MMS_ENCODE_BUFFER_MAX);
 
        MSG_DEBUG("_MmsEncodeNotiRespInd: Start Binary Encoding now ============= \n");
 
-       if (_MmsBinaryEncodeNotiRespIndHdr(pFile, pTrID, iStatus, bReportAllowed) == false) {
+       if (__MmsBinaryEncodeNotiRespIndHdr(pFile, pTrID, iStatus, bReportAllowed) == false) {
                MSG_DEBUG("_MmsEncodeNotiRespInd: SendReq Binary encoding fail \n");
                goto __CATCH;
        }
 
-       _MmsUnregisterEncodeBuffer2();
+       __MmsUnregisterEncodeBuffer2();
 
        return true;
 
@@ -520,9 +498,8 @@ __CATCH:
        return false;
 }
 
-
 /* Functions for Acknowledge.ind & NotifyResp.ind  (END) ------------------------ */
-bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
+bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
 {
        char *pText = NULL;
        MsgMultipart *pPart = NULL;
@@ -536,11 +513,11 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t
        time_t  RawTime = 0;
        time_t  dateSec = 0;
 
-       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+       MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
 
        MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now V1.0============= \n");
 
-       if (_MmsBinaryEncodeReadReport10Hdr(pFile, pMsg, mmsReadStatus) == false) {
+       if (__MmsBinaryEncodeReadReport10Hdr(pFile, pMsg, mmsReadStatus) == false) {
                MSG_DEBUG("_MmsEncodeReadReport10: SendReq Binary encoding fail \n");
                goto __CATCH;
        }
@@ -603,7 +580,7 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t
 
        msgBody.body.pMultipart = pPart;
 
-       if (MmsBinaryEncodeMsgBody(pFile, &msgType, &msgBody, 1, false) == false) {
+       if (__MmsBinaryEncodeMsgBody(pFile, &msgType, &msgBody, 1, false) == false) {
                MSG_DEBUG("__MmsSendReadReportV10: MmsBinaryEncodeMsgBody fail \n");
                goto __CATCH;
        }
@@ -624,7 +601,7 @@ bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t
                pPart = NULL;
        }
 
-       _MmsUnregisterEncodeBuffer();
+       MmsUnregisterEncodeBuffer();
 
        return true;
 
@@ -644,35 +621,32 @@ __CATCH:
                pPart = NULL;
        }
 
-       _MmsUnregisterEncodeBuffer();
+       MmsUnregisterEncodeBuffer();
 
        return false;
 }
 
-
-bool _MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
+bool MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
 {
-       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
+       MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
 
        MSG_DEBUG("_MmsEncodeMsg: Start Binary Encoding now V1.1============= \n");
 
-       if (_MmsBinaryEncodeReadReport11Hdr(pFile, pMsg, mmsReadStatus) == false) {
+       if (__MmsBinaryEncodeReadReport11Hdr(pFile, pMsg, mmsReadStatus) == false) {
                MSG_DEBUG("_MmsEncodeMsg: SendReq Binary encoding fail \n");
                goto __CATCH;
        }
 
-       _MmsUnregisterEncodeBuffer();
+       MmsUnregisterEncodeBuffer();
 
        return true;
 
 __CATCH:
-       _MmsUnregisterEncodeBuffer();
+       MmsUnregisterEncodeBuffer();
 
        return false;
 }
 
-
-
 /* ==========================================================
 
                                        B  I  N  A  R  Y         E  N  C  O  D  I  N  G
@@ -711,8 +685,7 @@ __CATCH:
  *                                                                                     |                       Data                    |  | Data Length
  *                                                                                     -----------------------------  -
  */
-
-bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
+static bool __MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
 {
        UINT8 fieldCode = 0xff;
        UINT8 fieldValue        = 0xff;
@@ -721,8 +694,8 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
        __MmsCleanEncodeBuff();
 
        /* msgType */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: msgType error\n");
                goto __CATCH;
@@ -775,7 +748,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
 
        /* Subject = Encoded-string-value */
        if (pMsg->mmsAttrib.szSubject[0]) {
-               length = MmsBinaryEncodeEncodedStringLen((UINT8*)pMsg->mmsAttrib.szSubject);
+               length = __MmsBinaryEncodeEncodedStringLen((UINT8*)pMsg->mmsAttrib.szSubject);
                if (length == -1) {
                        MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MmsBinaryEncodeEncodedStringLen fail \n");
                        goto __CATCH;
@@ -789,9 +762,9 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                        }
                }
 
-               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80;
+               fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80;
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
-               if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)pMsg->mmsAttrib.szSubject, length) == false) {
+               if (__MmsBinaryEncodeEncodedString(pFile, (UINT8*)pMsg->mmsAttrib.szSubject, length) == false) {
                        MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: subject MmsBinaryEncodeEncodedString fail \n");
                        goto __CATCH;
                }
@@ -799,8 +772,8 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
 
        /* MMS-1.3-con-739 */
        /* Msg class */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgClass,  (int)pMsg->mmsAttrib.msgClass) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgClass,  (int)pMsg->mmsAttrib.msgClass) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: msgClass error\n");
                goto __CATCH;
@@ -844,8 +817,8 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
        if (pMsg->mmsAttrib.priority!= MMS_PRIORITY_ERROR && pMsg->mmsAttrib.priority!= MMS_PRIORITY_NORMAL) {
                /* MMS_PRIORITY_NORMAL is default : don't send optional field */
 
-               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_PRIORITY)|0x80;
-               fieldValue = _MmsGetBinaryValue(MmsCodePriority, pMsg->mmsAttrib.priority)|0x80;
+               fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_PRIORITY)|0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodePriority, pMsg->mmsAttrib.priority)|0x80;
 
                if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                        MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: priority error\n");
@@ -855,8 +828,8 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
 
        /* Sender Visible (hide | show) */
        if (pMsg->mmsAttrib.bHideAddress == true) {
-               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | MSB;
-               fieldValue = _MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_HIDE) | 0x80;
+               fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | MSB;
+               fieldValue = MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_HIDE) | 0x80;
 
                if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                        MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: sender visibility error\n");
@@ -865,12 +838,12 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
        }
 
        /* Delivery Report (yes | no) */
-       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT)|0x80;
+       fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT)|0x80;
 
        if (pMsg->mmsAttrib.bAskDeliveryReport) {
-               fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_YES) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_YES) | 0x80;
        } else {
-               fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80;
        }
 
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
@@ -879,11 +852,11 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
        }
 
        /* Read Reply (Yes | no) */
-       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY)|0x80;
+       fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY)|0x80;
        if (pMsg->mmsAttrib.bAskReadReply) {
-               fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_YES)|0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_YES)|0x80;
        } else {
-               fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO)|0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO)|0x80;
        }
 
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
@@ -895,8 +868,8 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                (pMsg->mmsAttrib.replyCharge.chargeType == MMS_REPLY_REQUESTED_TEXT_ONLY)) {
 
                // reply charging
-               fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGING)|0x80;
-               fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, pMsg->mmsAttrib.replyCharge.chargeType)|0x80;
+               fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGING)|0x80;
+               fieldValue = MmsGetBinaryValue(MmsCodeReadReply, pMsg->mmsAttrib.replyCharge.chargeType)|0x80;
 
                if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                        MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyCharging error\n");
@@ -913,7 +886,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
 
                /** fixme: Reply-charging-size */
                if (pMsg->mmsAttrib.replyCharge.chargeSize > 0) {
-                       length = MmsBinaryEncodeIntegerLen(pMsg->mmsAttrib.replyCharge.chargeSize);
+                       length = __MmsBinaryEncodeIntegerLen(pMsg->mmsAttrib.replyCharge.chargeSize);
 
                        if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) {
                                if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
@@ -923,9 +896,9 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                                }
                        }
 
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGSIZE) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGSIZE) | 0x80;
 
-                       if (MmsBinaryEncodeInteger(pFile, pMsg->mmsAttrib.replyCharge.chargeSize, length) == false)     {
+                       if (__MmsBinaryEncodeInteger(pFile, pMsg->mmsAttrib.replyCharge.chargeSize, length) == false)   {
                                MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: replyChargingSize MmsBinaryEncodeInteger error\n");
                                goto __CATCH;
                        }
@@ -933,7 +906,7 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
 
                /** fixme: Reply-charging-ID  ----> used only when reply message  */
                if (pMsg->mmsAttrib.replyCharge.szChargeID[0]) {
-                       length = MmsBinaryEncodeTextStringLen((UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID);
+                       length = __MmsBinaryEncodeTextStringLen((UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID);
                        if (length == -1) {
                                MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: szReplyChargingID MmsBinaryEncodeTextStringLen fail\n");
                                goto __CATCH;
@@ -947,10 +920,10 @@ bool _MmsBinaryEncodeSendReqHdr(FILE *pFile, MmsMsg *pMsg)
                                }
                        }
 
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGID) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPLYCHARGINGID) | 0x80;
 
-                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID, length) == false) {
-                               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextString fail\n");
+                       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pMsg->mmsAttrib.replyCharge.szChargeID, length) == false) {
+                               MSG_DEBUG("szContentLocation MmsBinaryEncodeTextString fail\n");
                                goto __CATCH;
                        }
                }
@@ -970,267 +943,7 @@ __CATCH:
        return false;
 }
 
-bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg)
-{
-       bool ret = false;
-
-       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
-       ret = _MmsBinaryEncodeSendReqHdr(pFile, pMsg);
-       _MmsUnregisterEncodeBuffer();
-
-       return ret;
-}
-
-bool _MmsBinaryEncodeContentTypeFieldCode(FILE *pFile, int msgID)
-{
-       if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
-               if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
-                                                                                       gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
-                       MSG_DEBUG("__MmsBinaryEncodeMmsVersion: MsgWriteDataFromEncodeBuffer fail \n");
-                       return false;
-               }
-       }
-
-       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80;
-
-       if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
-               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
-               return false;
-       }
-
-       return true;
-}
-
-bool MmsBinaryEncodeSendReqHdrContTypeFildCode(FILE *pFile, int msgID)
-{
-       bool ret = false;
-
-       _MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX);
-
-       ret = _MmsBinaryEncodeContentTypeFieldCode(pFile, msgID);
-
-       _MmsUnregisterEncodeBuffer();
-
-
-       return ret;
-}
-
-#if 0
-bool
-_MmsBinaryEncodeForwardReqHdr(FILE* pFile, char* szContentLocation, char* szForwardTo, char* szForwardCc, char* szForwardBcc)
-{
-       int             length  = 0;
-       UINT8   fieldCode = 0xff;
-       UINT8   fieldValue = 0xff;
-       UINT32  date    = 0;
-
-
-       __MmsCleanEncodeBuff();
-
-       /* msgType */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_FORWARD_REQ) | 0x80;
-       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: msgType error\n");
-               goto __CATCH;
-       }
-
-
-       /* trID (other type of message) */
-       if (__MmsBinaryEncodeTrID(pFile, NULL, 0) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: __MmsBinaryEncodeTrID error\n");
-               goto __CATCH;
-       }
-
-
-       /* MMS version (currently we use 1.0 : VDF Spain's version) */
-       if (__MmsBinaryEncodeMmsVersion(pFile) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: __MmsBinaryEncodeMmsVersion error\n");
-               goto __CATCH;
-       }
-
-
-       /* Date = Long-integer */
-       if (!__MmsBinaryEncodeDate(pFile))
-       {
-                       MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: __MmsBinaryEncodeDate error\n");
-                       goto __CATCH;
-       }
-
-       /* From : Insert Token mode */
-       if (__MmsBinaryEncodeFrom(pFile) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: __MmsBinaryEncodeFrom fail\n");
-               goto __CATCH;
-       }
-
-
-       /* To = Encoded-string */
-       if (__MmsBinaryEncodeAddress(pFile,
-                                                                 MMS_CODE_TO,
-                                                                 szForwardTo) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: To __MmsBinaryEncodeAddress fail\n");
-               goto __CATCH;
-       }
-
-
-       /* Cc = Encoded-string */
-       if (__MmsBinaryEncodeAddress(pFile,
-                                                                 MMS_CODE_CC,
-                                                                 szForwardCc) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Cc __MmsBinaryEncodeAddress fail\n");
-               goto __CATCH;
-       }
-
-
-       /* Bcc = Encoded-string */
-       if (__MmsBinaryEncodeAddress(pFile,
-                                                                 MMS_CODE_BCC,
-                                                                 szForwardBcc) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Bcc __MmsBinaryEncodeAddress fail\n");
-               goto __CATCH;
-       }
-
-
-       /* Expiry Time  : Value-length Absolute-token Date-value */
-       if (gMmsSetup.sendSetup.bExpiryUseCustomTime == true) //jhlee expiry time use custom time
-       {
-               if (__MmsBinaryEncodeTime(pFile,
-                                                          MMS_CODE_EXPIRYTIME,
-                                                          gMmsSetup.sendSetup.expiryCustomTime) == false)
-               {
-                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: expiryTime __MmsBinaryEncodeTime fail\n");
-                       goto __CATCH;
-               }
-       }
-       else
-       {
-               if (__MmsBinaryEncodeTime(pFile,
-                                                          MMS_CODE_EXPIRYTIME,
-                                                          gMmsSetup.sendSetup.expiryTime) == false)
-               {
-                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: expiryTime __MmsBinaryEncodeTime fail\n");
-                       goto __CATCH;
-               }
-
-       }
-
-
-       /* Delivery Time  : Value-length Absolute-token Date-value */
-       if (__MmsBinaryEncodeTime(pFile,
-                                                          MMS_CODE_DELIVERYTIME,
-                                                          gMmsSetup.sendSetup.deliveryTime) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: deliveryTime __MmsBinaryEncodeTime fail\n");
-               goto __CATCH;
-       }
-
-
-       /* Report Allowed */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_REPORTALLOWED) | 0x80;
-       if (gMmsSetup.recvSetup.bSendDeliveryReport)
-               fieldValue  = _MmsGetBinaryValue(MmsCodeReportAllowed,
-                                                                                 MMS_REPORTALLOWED_YES) | 0x80;
-       else
-               fieldValue  = _MmsGetBinaryValue(MmsCodeReportAllowed,
-                                                                                 MMS_REPORTALLOWED_NO) | 0x80;
-       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Report Allowed error\n");
-               goto __CATCH;
-       }
-
-
-       /* Delivery Report */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80;
-       if (gMmsSetup.recvSetup.bSendDeliveryReport)
-               fieldValue  = _MmsGetBinaryValue(MmsCodeDeliveryReport,
-                                                                                 MMS_REPORT_YES) | 0x80;
-       else
-               fieldValue  = _MmsGetBinaryValue(MmsCodeDeliveryReport,
-                                                                                 MMS_REPORT_NO) | 0x80;
-       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Report Allowed error\n");
-               goto __CATCH;
-       }
-
-
-       /* Read Reply */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80;
-       if (gMmsSetup.recvSetup.bSendDeliveryReport)
-               fieldValue  = _MmsGetBinaryValue(MmsCodeReadReply,
-                                                                                 MMS_REPORT_YES) | 0x80;
-       else
-               fieldValue  = _MmsGetBinaryValue(MmsCodeReadReply,
-                                                                                 MMS_REPORT_NO) | 0x80;
-       if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: Read Reply error\n");
-               goto __CATCH;
-       }
-
-
-       /* Content Location */
-       if (szContentLocation[0])
-       {
-               length = MmsBinaryEncodeTextStringLen((UINT8*)szContentLocation);
-               if (length == -1)
-               {
-                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextStringLen fail\n");
-                       goto __CATCH;
-               }
-
-               if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1))   // + fieldCode
-               {
-                       if (MsgWriteDataFromEncodeBuffer(pFile,
-                                                               gpMmsEncodeBuf,
-                                                               &gCurMmsEncodeBuffPos,
-                                                               gMmsEncodeMaxLen,
-                                                               &gMmsEncodeCurOffset) == false)
-                       {
-                               MSG_DEBUG("_MmsBinaryEncodeSendReqHdr: MsgWriteDataFromEncodeBuffer fail \n");
-                               goto __CATCH;
-                       }
-               }
-
-               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode,
-                                                                                                                                         MMS_CODE_CONTENTLOCATION) | 0x80;
-               if (MmsBinaryEncodeTextString(pFile, (UINT8*)szContentLocation, length) == false)
-               {
-                       MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: szContentLocation MmsBinaryEncodeTextString fail\n");
-                       goto __CATCH;
-               }
-       }
-
-       /* flush remained data on encoding file */
-       if (MsgWriteDataFromEncodeBuffer(pFile,
-                                                 gpMmsEncodeBuf,
-                                                 &gCurMmsEncodeBuffPos,
-                                                 gMmsEncodeMaxLen,
-                                                 &gMmsEncodeCurOffset) == false)
-       {
-               MSG_DEBUG("_MmsBinaryEncodeForwardReqHdr: remained data MsgWriteDataFromEncodeBuffer fail \n");
-               goto __CATCH;
-       }
-
-       return true;
-
-__CATCH:
-
-       MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset);
-       return false;
-}
-#endif
-
-
-bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
+static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
 {
        int length      = 0;
        char *szTo      = NULL;
@@ -1248,8 +961,8 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
        __MmsCleanEncodeBuff();
 
        /* msgType */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_SEND_REQ) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: msgType error\n");
                goto __CATCH;
@@ -1324,7 +1037,7 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
                }
        }
 
-       length = MmsBinaryEncodeEncodedStringLen((UINT8*)szSubject);
+       length = __MmsBinaryEncodeEncodedStringLen((UINT8*)szSubject);
        if (length == -1) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MmsBinaryEncodeEncodedStringLen fail \n");
                goto __CATCH;
@@ -1337,16 +1050,16 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
                }
        }
 
-       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80;
+       fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SUBJECT) | 0x80;
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
-       if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)szSubject, length) == false) {
+       if (__MmsBinaryEncodeEncodedString(pFile, (UINT8*)szSubject, length) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: subject MmsBinaryEncodeEncodedString fail \n");
                goto __CATCH;
        }
 
        /* Msg class */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgClass, MMS_MSGCLASS_AUTO) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGCLASS) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgClass, MMS_MSGCLASS_AUTO) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: msgClass error\n");
                goto __CATCH;
@@ -1354,8 +1067,8 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
 
 
        /* Delivery Report (yes | no) */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DELIVERYREPORT) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeDeliveryReport, MMS_REPORT_NO) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Delivery Report error\n");
                goto __CATCH;
@@ -1363,8 +1076,8 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
 
 
        /* Read Reply (Yes | no) */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READREPLY) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeReadReply, MMS_REPORT_NO) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Read Reply error\n");
                goto __CATCH;
@@ -1372,14 +1085,14 @@ bool _MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
 
 
        /* Sender Visible (hide | show) */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_SHOW) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_SENDERVISIBILLITY) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeSenderVisibility, MMS_SENDER_SHOW) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport10Hdr: Sender Visible error\n");
                goto __CATCH;
        }
 
-       /* fixme: msgContentType */
+       /* fixme: MimeType */
        /* fixme: msgHeader */
        /* fixme: msgBody */
 
@@ -1401,9 +1114,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
+static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus)
 {
        UINT8 fieldCode = 0xff;
        UINT8 fieldValue = 0xff;
@@ -1412,8 +1123,8 @@ bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
        __MmsCleanEncodeBuff();
 
        /* msgType */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_READREC_IND) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGTYPE) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeMsgType, MMS_MSGTYPE_READREC_IND) | 0x80;
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: msgType error\n");
                goto __CATCH;
@@ -1471,8 +1182,8 @@ bool _MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read_report_
        }
 
        /* Read Status (Yes | no) */
-       fieldCode  = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READSTATUS) | 0x80;
-       fieldValue = _MmsGetBinaryValue(MmsCodeReadStatus, mmsReadStatus) | 0x80;
+       fieldCode  = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_READSTATUS) | 0x80;
+       fieldValue = MmsGetBinaryValue(MmsCodeReadStatus, mmsReadStatus) | 0x80;
 
        if (__MmsBinaryEncodeFieldCodeAndValue(pFile, fieldCode, fieldValue) == false) {
                MSG_DEBUG("_MmsBinaryEncodeReadReport11Hdr: Read Status error\n");
@@ -1496,7 +1207,7 @@ __CATCH:
        return false;
 }
 
-bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate)
+static bool __MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate)
 {
        int length = 0;
        MsgMultipart *pMultipart = NULL;
@@ -1515,23 +1226,23 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa
                 *       Multipart message
                 * ---------------------------*/
 
-               pType->offset = _MmsGetEncodeOffset();
+               pType->offset = __MmsGetEncodeOffset();
 
                /* Content type */
-               length = MmsBinaryEncodeContentTypeLen(pType);
+               length = __MmsBinaryEncodeContentTypeLen(pType);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgBody: MmsBinaryEncodeContentTypeLen fail \n");
                        goto __CATCH;
                }
                if (bTemplate == false)
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_CONTENTTYPE) | 0x80;
 
-               if (MmsBinaryEncodeContentType(pFile, pType, length) == false) {
+               if (__MmsBinaryEncodeContentType(pFile, pType, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgBody: MmsBinaryEncodeContentType fail \n");
                        goto __CATCH;
                }
 
-               pBody->offset = _MmsGetEncodeOffset();
+               pBody->offset = __MmsGetEncodeOffset();
 
                /* nEntries */
                if (pBody->pPresentationBody) {
@@ -1541,22 +1252,22 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa
                }
 
                if (nEntries >= 0) {
-                       length = MmsBinaryEncodeUintvarLen(nEntries);
+                       length = __MmsBinaryEncodeUintvarLen(nEntries);
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeMsgBody: nEntries MmsBinaryEncodeUintvarLen fail \n");
                                goto __CATCH;
                        }
-                       if (MmsBinaryEncodeUintvar(pFile, nEntries, length) == false) {
+                       if (__MmsBinaryEncodeUintvar(pFile, nEntries, length) == false) {
                                MSG_DEBUG("MmsBinaryEncodeMsgBody: nEntries MmsBinaryEncodeUintvar fail \n");
                                goto __CATCH;
                        }
 
-                       pType->size = _MmsGetEncodeOffset() - pType->offset;
+                       pType->size = __MmsGetEncodeOffset() - pType->offset;
                }
 
                if (nEntries > 0) {
                        if (nEntries && pBody->pPresentationBody) {
-                               if (MmsBinaryEncodeMsgPart(pFile, pType->type, &pBody->presentationType, pBody->pPresentationBody) == false) {
+                               if (__MmsBinaryEncodeMsgPart(pFile, pType->type, &pBody->presentationType, pBody->pPresentationBody) == false) {
                                        MSG_DEBUG("MmsBinaryEncodeMsgBody: __MmsBinaryEncodeMsgPart fail \n");
                                        goto __CATCH;
                                }
@@ -1566,7 +1277,7 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa
 
                        pMultipart = pBody->body.pMultipart;
                        while (nEntries && pMultipart) {
-                               if (MmsBinaryEncodeMsgPart(pFile, pType->type, &pMultipart->type, pMultipart->pBody) == false) {
+                               if (__MmsBinaryEncodeMsgPart(pFile, pType->type, &pMultipart->type, pMultipart->pBody) == false) {
                                        MSG_DEBUG("MmsBinaryEncodeMsgBody: __MmsBinaryEncodeMsgPart fail \n");
                                        goto __CATCH;
                                }
@@ -1581,28 +1292,28 @@ bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPa
                        }
                }
 
-               pBody->size = _MmsGetEncodeOffset() - pBody->offset;
+               pBody->size = __MmsGetEncodeOffset() - pBody->offset;
        } else {
                /* ---------------------------
                 *       Singlepart message
                 * ---------------------------*/
-               pType->offset = _MmsGetEncodeOffset();
+               pType->offset = __MmsGetEncodeOffset();
 
-               if (MmsBinaryEncodeContentHeader(pFile, (MimeType)pType->type, pType, false) == false)
+               if (__MmsBinaryEncodeContentHeader(pFile, (MimeType)pType->type, pType, false) == false)
                        goto __CATCH;
 
-               length = MmsBinaryEncodeContentTypeLen(pType);
+               length = __MmsBinaryEncodeContentTypeLen(pType);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgBody: Singlepart MmsBinaryEncodeContentTypeLen fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeContentType(pFile, pType, length) == false)
+               if (__MmsBinaryEncodeContentType(pFile, pType, length) == false)
                        goto __CATCH;
 
-               pType->size = _MmsGetEncodeOffset() - pType->offset;
+               pType->size = __MmsGetEncodeOffset() - pType->offset;
 
-               if (MmsBinaryEncodeContentBody(pFile, pBody) == false)
+               if (__MmsBinaryEncodeContentBody(pFile, pBody) == false)
                        goto __CATCH;
        }
 
@@ -1614,13 +1325,12 @@ __CATCH:
        return false;
 }
 
-
-int MmsBinaryEncodeContentTypeLen(MsgType *pType)
+static int __MmsBinaryEncodeContentTypeLen(MsgType *pType)
 {
        int length = 0;
        int     totalLength = 0;
        UINT16 fieldValue = 0xffff;
-       char *szTextType = NULL;
+       const char *szTextType = NULL;
        int     contentType = MIME_UNKNOWN;
 
        MSG_DEBUG("MSmsBinaryEncodeContentTypeLen:  type\n");
@@ -1639,12 +1349,12 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
 
        contentType = pType->type;
 
-       fieldValue = _MmsGetBinaryValue(MmsCodeContentType, contentType);
+       fieldValue = MmsGetBinaryValue(MmsCodeContentType, contentType);
        if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049)     {
                /* Extension-media type */
-               szTextType = _MmsGetTextValue(MmsCodeContentType, contentType);
+               szTextType = MmsGetTextValue(MmsCodeContentType, contentType);
                if (szTextType != NULL) {
-                       length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+                       length  = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
                        if (length == -1) {
                                MSG_DEBUG("MSmsBinaryEncodeContentTypeLen: szTextType MmsBinaryEncodeTextStringLen fail \n");
                                goto __CATCH;
@@ -1664,8 +1374,8 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
        /* Well-known-charset = Any-charset | Integer-value ----------------------- */
 
        if (pType->param.charset != MSG_CHARSET_UNKNOWN) {
-               fieldValue = _MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset);
-               length     = MmsBinaryEncodeIntegerLen(fieldValue);
+               fieldValue = MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset);
+               length     = __MmsBinaryEncodeIntegerLen(fieldValue);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentTypeLen: charSet MmsBinaryEncodeIntegerLen fail \n");
                        goto __CATCH;
@@ -1719,7 +1429,7 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
                        MSG_DEBUG("MmsBinaryEncodeContentTypeLen: pszName : %s\n", pszName);
                }
 
-               length = MmsBinaryEncodeTextStringLen((UINT8*)pszName);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName);
                free(pszName);
 
                if (length == -1) {
@@ -1732,30 +1442,30 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
 
 #ifdef FEATURE_JAVA_MMS
        if (pType->param.szApplicationID) {
-               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szApplicationID);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szApplicationID);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szApplicationID MmsBinaryEncodeTextStrinLen fail \n");
                        goto __CATCH;
                }
 
                totalLength += (length);
-               if (_MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID) == UNDEFINED_BINARY) {
-                       totalLength += strlen(_MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID)) + 1; /* NULL */
+               if (MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID) == UNDEFINED_BINARY) {
+                       totalLength += strlen(MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID)) + 1; /* NULL */
                } else {
                        totalLength++;
                }
        }
 
        if (pType->param.szReplyToApplicationID) {
-               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szReplyToApplicationID);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szReplyToApplicationID);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentTypeLen: szApplicationID MmsBinaryEncodeTextStrinLen fail \n");
                        goto __CATCH;
                }
 
                totalLength += (length);
-               if (_MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID) == UNDEFINED_BINARY) {
-                       totalLength += strlen(_MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID)) + 1; /* NULL */
+               if (MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID) == UNDEFINED_BINARY) {
+                       totalLength += strlen(MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID)) + 1; /* NULL */
                } else {
                        totalLength++;
                }
@@ -1765,12 +1475,12 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
        /* type, start, & startInfo : multipart/related only parameters -------------- */
        if (contentType == MIME_MULTIPART_RELATED || contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
                /* type ------------------------------------- */
-               fieldValue = _MmsGetBinaryValue(MmsCodeContentType, pType->param.type);
+               fieldValue = MmsGetBinaryValue(MmsCodeContentType, pType->param.type);
                if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) {
                        /* Extension-media type */
-                       szTextType = _MmsGetTextValue(MmsCodeContentType, pType->param.type);
+                       szTextType = MmsGetTextValue(MmsCodeContentType, pType->param.type);
                        if (szTextType != NULL) {
-                               length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+                               length  = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
                                if (length == -1) {
                                        MSG_DEBUG("MmsBinaryEncodeContentTypeLen: type param MmsBinaryEncodeTextStringLen fail \n");
                                        goto __CATCH;
@@ -1786,7 +1496,7 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
                /* start = Text-string ----------------------- */
                if (pType->param.szStart[0]) {
                        /* start = Text-string */
-                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
+                       length  = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextStringLen fail \n");
                                goto __CATCH;
@@ -1799,7 +1509,7 @@ int MmsBinaryEncodeContentTypeLen(MsgType *pType)
                /* startInfo = Text-string -------------------- */
                if (pType->param.szStartInfo[0]) {
                        /* StartInfo (with multipart/related) = Text-string */
-                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo);
+                       length  = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo);
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextStringLen fail \n");
                                goto __CATCH;
@@ -1817,17 +1527,15 @@ __CATCH:
        return -1;
 }
 
-
-
-bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
+static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
 {
        int length = 0;
        UINT16 fieldValue = 0xffff;
-       char *szTextType = NULL;
+       const char *szTextType = NULL;
        int contentType = MIME_UNKNOWN;
 
 #ifdef FEATURE_JAVA_MMS
-       char *szParameter = NULL;
+       const char *szParameter = NULL;
 #endif
 
        MSG_DEBUG("************************************************************************************\n");
@@ -1850,23 +1558,23 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
 
        /* Content-Type = Content-general-form ------------------------------- */
 
-       length = MmsBinaryEncodeValueLengthLen(typeLength);
+       length = __MmsBinaryEncodeValueLengthLen(typeLength);
        if (length == -1) {
                MSG_DEBUG("MSmsBinaryEncodeContentType : MmsBinaryEncodeValueLengthLen fail.\n");
                goto __CATCH;
        }
 
-       if (MmsBinaryEncodeValueLength(pFile, typeLength, length) == false) {
+       if (__MmsBinaryEncodeValueLength(pFile, typeLength, length) == false) {
                MSG_DEBUG("MSmsBinaryEncodeContentType : MmsBinaryEncodeValueLength fail.\n");
                goto __CATCH;
        }
 
        contentType = pType->type;
 
-       fieldValue = _MmsGetBinaryValue(MmsCodeContentType, (int)contentType);
+       fieldValue = MmsGetBinaryValue(MmsCodeContentType, (int)contentType);
        if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) {
                /* Extension-media type */
-               szTextType = _MmsGetTextValue(MmsCodeContentType, (int)contentType);
+               szTextType = MmsGetTextValue(MmsCodeContentType, (int)contentType);
                if (szTextType == NULL)
                        fieldValue = 0x00;
        }
@@ -1874,13 +1582,13 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
        if (szTextType == NULL) {
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
        } else {
-               length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+               length  = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
                if (length == -1) {
                        MSG_DEBUG("MSmsBinaryEncodeContentType: szTextType MmsBinaryEncodeTextStringLen fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) {
+               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szTextType MmsBinaryEncodeTextString fail \n");
                        goto __CATCH;
                }
@@ -1930,15 +1638,15 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                        MSG_DEBUG("MmsBinaryEncodeContentType: pszName : %s\n", pszName);
                }
 
-               length = MmsBinaryEncodeTextStringLen((UINT8*)pszName);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szName MmsBinaryEncodeIntegerLen fail \n");
                        free(pszName);
                        goto __CATCH;
                }
-               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_NAME) | 0x80;
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_NAME) | 0x80;
 
-               if (MmsBinaryEncodeTextString(pFile, (UINT8*)pszName, length) == false) {
+               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pszName, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szName MmsBinaryEncodeTextString fail\n");
                        free(pszName);
                        goto __CATCH;
@@ -1950,16 +1658,16 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
 
        /* Application-ID: Text-string */
        if (pType->param.szApplicationID) {
-               length = MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szApplicationID);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szApplicationID);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeIntegerLen Fail \n");
                        goto __CATCH;
                }
 
-               fieldValue = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID);
+               fieldValue = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID);
 
                if (fieldValue == UNDEFINED_BINARY)
-                       szParameter = _MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID);
+                       szParameter = MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_APPLICATION_ID);
 
                if (szParameter == NULL) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szParameter is NULL \n");
@@ -1970,7 +1678,7 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                gCurMmsEncodeBuffPos += strlen(szParameter);
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] =(UINT8)NULL;
 
-               if (MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szApplicationID, length) == false) {
+               if (__MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szApplicationID, length) == false) {
                        MSG_DEBUG(" MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeTextString fail\n");
                        goto __CATCH;
                }
@@ -1979,16 +1687,16 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
 
        /* ReplyToApplicationID: Text-string */
        if (pType->param.szReplyToApplicationID) {
-               length = MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szReplyToApplicationID);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*) pType->param.szReplyToApplicationID);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szReplyToApplicationID MmsBinaryEncodeIntegerLen Fail \n");
                        goto __CATCH;
                }
 
-               fieldValue = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID);
+               fieldValue = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID);
 
                if (fieldValue == UNDEFINED_BINARY)
-                       szParameter = _MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID);
+                       szParameter = MmsGetTextValue(MmsCodeParameterCode, MSG_PARAM_REPLY_TO_APPLICATION_ID);
 
                if (szParameter == NULL) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: szParameter is NULL \n");
@@ -1999,7 +1707,7 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                gCurMmsEncodeBuffPos += strlen(szParameter);
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] =(UINT8)NULL;
 
-               if (MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szReplyToApplicationID, length) == false) {
+               if (__MmsBinaryEncodeTextString(pFile, (UINT8*) pType->param.szReplyToApplicationID, length) == false) {
                        MSG_DEBUG(" MmsBinaryEncodeContentType: szApplicationID MmsBinaryEncodeTextString fail\n");
                        goto __CATCH;
                }
@@ -2009,15 +1717,15 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
        /* Well-known-charset = Any-charset | Integer-value ----------------------- */
 
        if (pType->param.charset != MSG_CHARSET_UNKNOWN) {
-               fieldValue = _MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset);
-               length = MmsBinaryEncodeIntegerLen(fieldValue);
+               fieldValue = MmsGetBinaryValue(MmsCodeCharSet, pType->param.charset);
+               length = __MmsBinaryEncodeIntegerLen(fieldValue);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: charSet MmsBinaryEncodeIntegerLen fail \n");
                        goto __CATCH;
                }
 
-               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
-               if (MmsBinaryEncodeInteger(pFile, fieldValue, length) == false) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
+               if (__MmsBinaryEncodeInteger(pFile, fieldValue, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeContentType: charSet MmsBinaryEncodeInteger fail\n");
                        goto __CATCH;
                }
@@ -2025,7 +1733,7 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                /* Any-charset */
                if (MmsIsText(contentType)) {
                        if (!MmsIsVitemContent (contentType, pType->param.szName)) {
-                               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
+                               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_CHARSET) | 0x80;
                                fieldValue = 0x0000;    //laconic_warning, just to remove warning message
                                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
                        }
@@ -2035,26 +1743,26 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
        /* type, start, & startInfo : multipart/related only parameters -------------- */
        if (contentType == MIME_MULTIPART_RELATED || contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) {
                /* type ------------------------------------- */
-               fieldValue = _MmsGetBinaryValue(MmsCodeContentType, pType->param.type);
+               fieldValue = MmsGetBinaryValue(MmsCodeContentType, pType->param.type);
                if (fieldValue == UNDEFINED_BINARY || fieldValue == 0x0049) {
                        /* Extension-media type */
-                       szTextType = _MmsGetTextValue(MmsCodeContentType, pType->param.type);
+                       szTextType = MmsGetTextValue(MmsCodeContentType, pType->param.type);
                        if (szTextType == NULL)
                                fieldValue = 0x00;
                }
 
                if (szTextType == NULL) {
                        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)fieldValue | 0x80;
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80;
                } else {
-                       length  = MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
+                       length  = __MmsBinaryEncodeTextStringLen((UINT8*)szTextType);
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: type param MmsBinaryEncodeTextStringLen fail \n");
                                goto __CATCH;
                        }
 
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80;
-                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) {
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_TYPE) | 0x80;
+                       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szTextType, length) == false) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: type param MmsBinaryEncodeTextString fail \n");
                                goto __CATCH;
                        }
@@ -2063,15 +1771,15 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                /* start = Text-string ----------------------- */
                if (pType->param.szStart[0]) {
                        /* start = Text-string */
-                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
+                       length  = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStart);
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextStringLen fail \n");
                                goto __CATCH;
                        }
 
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode,
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode,
                                                                                                                                                 MSG_PARAM_START) | 0x80;
-                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStart, length) == false) {
+                       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStart, length) == false) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: szStart MmsBinaryEncodeTextString fail \n");
                                goto __CATCH;
                        }
@@ -2080,14 +1788,14 @@ bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength)
                /* startInfo = Text-string -------------------- */
                if (pType->param.szStartInfo[0]) {
                        /* StartInfo (with multipart/related) = Text-string */
-                       length  = MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo);
+                       length  = __MmsBinaryEncodeTextStringLen((UINT8*)pType->param.szStartInfo);
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextStringLen fail \n");
                                goto __CATCH;
                        }
 
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_START_INFO) | 0x80;
-                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStartInfo, length) == false) {
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeParameterCode, MSG_PARAM_START_INFO) | 0x80;
+                       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->param.szStartInfo, length) == false) {
                                MSG_DEBUG("MmsBinaryEncodeContentType: szStartInfo MmsBinaryEncodeTextString fail \n");
                                goto __CATCH;
                        }
@@ -2101,9 +1809,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody)
+static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody)
 {
        FILE *pFile2 = NULL;
        char *pData = NULL;
@@ -2113,24 +1819,24 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod
        if (pType->offset && pType->size) {
                /* header length & body length --------------------------- */
 
-               length = MmsBinaryEncodeUintvarLen(pType->size);
+               length = __MmsBinaryEncodeUintvarLen(pType->size);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. headerLeng MmsBinaryEncodeUintvarLen fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeUintvar(pFile, pType->size, length) == false) {
+               if (__MmsBinaryEncodeUintvar(pFile, pType->size, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. eaderLeng fail \n");
                        goto __CATCH;
                }
 
-               length = MmsBinaryEncodeUintvarLen(pBody->size);
+               length = __MmsBinaryEncodeUintvarLen(pBody->size);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. bodyLeng MmsBinaryEncodeUintvarLen fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) {
+               if (__MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. bodyLeng fail \n");
                        goto __CATCH;
                }
@@ -2154,7 +1860,7 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod
                                        MSG_DEBUG("MmsBinaryEncodeMsgPart: 1. header MsgWriteDataFromEncodeBuffer fail \n");
                                        goto __CATCH;
                                }
-                               pType->offset = _MmsGetEncodeOffset();
+                               pType->offset = __MmsGetEncodeOffset();
                                if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
                                        MSG_DEBUG("MsgWriteFile failed");
                                        goto __CATCH;
@@ -2175,9 +1881,9 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod
                int contentHdrLen  = 0;
 
                /* header length & body length --------------------------- */
-               contentTypeLen = MmsBinaryEncodeContentTypeLen(pType);
-               length = MmsBinaryEncodeValueLengthLen(contentTypeLen);
-               contentHdrLen  = MmsBinaryEncodeContentHeaderLen((MimeType)contentType, pType, true);
+               contentTypeLen = __MmsBinaryEncodeContentTypeLen(pType);
+               length = __MmsBinaryEncodeValueLengthLen(contentTypeLen);
+               contentHdrLen  = __MmsBinaryEncodeContentHeaderLen((MimeType)contentType, pType, true);
 
                if (contentTypeLen == -1 || length == -1 || contentHdrLen == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng calculation fail \n");
@@ -2185,24 +1891,24 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod
                }
 
                headerLeng = contentTypeLen + contentHdrLen + length;
-               length = MmsBinaryEncodeUintvarLen(headerLeng);
+               length = __MmsBinaryEncodeUintvarLen(headerLeng);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng MmsBinaryEncodeUintvarLen fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeUintvar(pFile, headerLeng, length) == false) {
+               if (__MmsBinaryEncodeUintvar(pFile, headerLeng, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: headerLeng fail \n");
                        goto __CATCH;
                }
 
-               length = MmsBinaryEncodeUintvarLen(pBody->size);
+               length = __MmsBinaryEncodeUintvarLen(pBody->size);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: bodyLeng MmsBinaryEncodeUintvarLen fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) {
+               if (__MmsBinaryEncodeUintvar(pFile, pBody->size, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: bodyLeng fail \n");
                        goto __CATCH;
                }
@@ -2214,19 +1920,19 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod
                }
 
                /* content-type & header --------------------------- */
-               pType->offset = _MmsGetEncodeOffset();
+               pType->offset = __MmsGetEncodeOffset();
 
-               if (MmsBinaryEncodeContentType(pFile, pType, contentTypeLen) == false) {
+               if (__MmsBinaryEncodeContentType(pFile, pType, contentTypeLen) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentType fail \n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeContentHeader(pFile, (MsgContentType)contentType, pType, true) == false)     {
+               if (__MmsBinaryEncodeContentHeader(pFile, (MimeType)contentType, pType, true) == false) {
                        MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentHeader fail \n");
                        goto __CATCH;
                }
 
-               pType->size = _MmsGetEncodeOffset() - pType->offset;
+               pType->size = __MmsGetEncodeOffset() - pType->offset;
        }
 
        if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos, gMmsEncodeMaxLen, &gMmsEncodeCurOffset) == false) {
@@ -2235,8 +1941,8 @@ bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBod
        }
 
        /* content-body --------------------------- */
-       if (MmsBinaryEncodeContentBody(pFile, pBody) == false) {
-               MSG_DEBUG("MmsBinaryEncodeMsgPart: MmsBinaryEncodeContentBody fail \n");
+       if (__MmsBinaryEncodeContentBody(pFile, pBody) == false) {
+               MSG_DEBUG("MmsBinaryEncodeMsgPart: __MmsBinaryEncodeContentBody fail \n");
                goto __CATCH;
        }
 
@@ -2263,12 +1969,11 @@ __CATCH:
        return false;
 }
 
-
-int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, bool bMultipart)
+static int __MmsBinaryEncodeContentHeaderLen(MimeType contentType, MsgType *pType, bool bMultipart)
 {
        int     length = 0;
        int     totalLength = 0;
-       char *szTextValue = NULL;
+       const char *szTextValue = NULL;
 
 
        MSG_DEBUG("MmsBinaryEncodeContentHeaderLen: S T A R T \n\n");
@@ -2279,7 +1984,7 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType,
                        totalLength++;
                } else {
                        /* content-id = Quoted-string */
-                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID");
+                       length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID");
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentHeaderLen: Content-ID MmsBinaryEncodeTextStringLen fail.\n");
                                goto __CATCH;
@@ -2288,7 +1993,7 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType,
                        totalLength += length;
                }
 
-               length = MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID);
+               length = __MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedStringLen fail.\n");
                        goto __CATCH;
@@ -2302,7 +2007,7 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType,
                        totalLength++;
                } else {
                        /* content-location = Quoted-string */
-                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location");
+                       length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location");
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextStringLen fail.\n");
                                goto __CATCH;
@@ -2311,7 +2016,7 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType,
                        totalLength += length;
                }
 
-               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextStringLen fail.\n");
                        goto __CATCH;
@@ -2339,10 +2044,10 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType,
                        totalLength += 3;
                } else {
                        /* content-disposition = Quoted-string */
-                       szTextValue = _MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition);
+                       szTextValue = MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition);
 
                        if (szTextValue) {
-                               length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition");
+                               length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition");
                                if (length == -1) {
                                        MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
                                        goto __CATCH;
@@ -2350,7 +2055,7 @@ int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType,
 
                                totalLength += length;
 
-                               length = MmsBinaryEncodeTextStringLen((UINT8*)szTextValue);
+                               length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextValue);
                                if (length == -1) {
                                        MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
                                        goto __CATCH;
@@ -2368,40 +2073,38 @@ __CATCH:
        return -1;
 }
 
-
-
-bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgType *pType, bool bMultipart)
+static bool __MmsBinaryEncodeContentHeader(FILE *pFile, MimeType contentType, MsgType *pType, bool bMultipart)
 {
        int     length = 0;
-       char *szTextValue = NULL;
+       const char *szTextValue = NULL;
 
        MSG_DEBUG("MmsBinaryEncodeContentHeader: S T A R T \n\n");
 
        /* content-id ------------------------------------------------- */
        if (pType->szContentID[0]) {
                if (bMultipart) { //Binary Encoding
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTID) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTID) | 0x80;
                } else {
                        /* content-id = Quoted-string */
-                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID");
+                       length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-ID");
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-ID MmsBinaryEncodeTextStringLen fail.\n");
                                goto __CATCH;
                        }
 
-                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-ID", length) == false) {
+                       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-ID", length) == false) {
                                MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-ID MmsBinaryEncodeTextString fail.\n");
                                goto __CATCH;
                        }
                }
 
-               length = MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID);
+               length = __MmsBinaryEncodeQuotedStringLen((UINT8*)pType->szContentID);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedStringLen fail.\n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeQuotedString(pFile, (UINT8*)pType->szContentID, length) == false) {
+               if (__MmsBinaryEncodeQuotedString(pFile, (UINT8*)pType->szContentID, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentID MmsBinaryEncodeQuotedString fail.\n");
                        goto __CATCH;
                }
@@ -2409,28 +2112,28 @@ bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgTy
 
        if (pType->szContentLocation[0]) {
                if (bMultipart) { //Binary Encoding
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTLOCATION) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_CONTENTLOCATION) | 0x80;
                } else {
                        /* content-location = Quoted-string */
-                       length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location");
+                       length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Location");
                        if (length == -1) {
                                MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextStringLen fail.\n");
                                goto __CATCH;
                        }
 
-                       if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Location", length) == false) {
+                       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Location", length) == false) {
                                MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Location MmsBinaryEncodeTextString fail.\n");
                                goto __CATCH;
                        }
                }
 
-               length = MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
+               length = __MmsBinaryEncodeTextStringLen((UINT8*)pType->szContentLocation);
                if (length == -1) {
                        MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextStringLen fail.\n");
                        goto __CATCH;
                }
 
-               if (MmsBinaryEncodeTextString(pFile, (UINT8*)pType->szContentLocation, length) == false) {
+               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)pType->szContentLocation, length) == false) {
                        MSG_DEBUG("MmsBinaryEncodeContentHeader: pType->szContentLocation MmsBinaryEncodeTextString fail.\n");
                        goto __CATCH;
                }
@@ -2453,9 +2156,9 @@ bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgTy
                if (bMultipart) {//Binary Encoding
 
                        UINT8 fieldValue  = 0xff;
-                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_DISPOSITION) | 0x80;
+                       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeMsgBodyHeaderCode, MMS_BODYHDR_DISPOSITION) | 0x80;
 
-                       fieldValue = _MmsGetBinaryValue(MmsCodeMsgDisposition, pType->disposition) | 0x80;
+                       fieldValue = MmsGetBinaryValue(MmsCodeMsgDisposition, pType->disposition) | 0x80;
 
                        if (fieldValue == 0xff)
                                fieldValue = 0x81;
@@ -2465,27 +2168,27 @@ bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgTy
                } else {
                        /* content-disposition = Disposition (no support parameter) */
 
-                       szTextValue = _MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition);
+                       szTextValue = MmsGetTextValue(MmsCodeMsgDisposition, pType->disposition);
 
                        if (szTextValue) {
-                               length = MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition");
+                               length = __MmsBinaryEncodeTextStringLen((UINT8*)"Content-Disposition");
                                if (length == -1) {
                                        MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
                                        goto __CATCH;
                                }
 
-                               if (MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Disposition", length) == false) {
+                               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)"Content-Disposition", length) == false) {
                                        MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextString fail.\n");
                                        goto __CATCH;
                                }
 
-                               length = MmsBinaryEncodeTextStringLen((UINT8*)szTextValue);
+                               length = __MmsBinaryEncodeTextStringLen((UINT8*)szTextValue);
                                if (length == -1) {
                                        MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextStringLen fail.\n");
                                        goto __CATCH;
                                }
 
-                               if (MmsBinaryEncodeTextString(pFile, (UINT8*)szTextValue, length) == false) {
+                               if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szTextValue, length) == false) {
                                        MSG_DEBUG("MmsBinaryEncodeContentHeader: Content-Disposition MmsBinaryEncodeTextString fail.\n");
                                        goto __CATCH;
                                }
@@ -2500,9 +2203,7 @@ __CATCH:
        return false;
 }
 
-
-
-bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
+static bool __MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
 {
        int nRead = 0;
        char *pData = NULL;
@@ -2519,7 +2220,7 @@ bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
                if (pData == NULL)
                        goto __CATCH;
 
-               pBody->offset = _MmsGetEncodeOffset();
+               pBody->offset = __MmsGetEncodeOffset();
                if(MsgWriteFile(pData, sizeof(char), nRead, pFile) != (size_t)nRead) {
                        MSG_DEBUG("MsgWriteFile failed");
                        goto __CATCH;
@@ -2536,7 +2237,7 @@ bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
                        pData = NULL;
                }
        } else if (pBody->body.pText && pBody->size) {
-               pBody->offset = _MmsGetEncodeOffset();
+               pBody->offset = __MmsGetEncodeOffset();
                if (MsgWriteFile(pBody->body.pText, sizeof(char),(size_t)pBody->size, pFile) != (size_t)pBody->size) {
                        MSG_DEBUG("MsgWriteFile failed");
                        goto __CATCH;
@@ -2552,7 +2253,7 @@ bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody)
        return true;
 
 __CATCH:
-       MSG_DEBUG("## MmsBinaryEncodeContentBody: failed\n");
+       MSG_DEBUG("## __MmsBinaryEncodeContentBody: failed\n");
        if (pData) {
                free(pData);
                pData = NULL;
@@ -2561,15 +2262,12 @@ __CATCH:
        return false;
 }
 
-
-
 /* =========================================================================
 
    B  I  N  A  R  Y       E  N  C  O  D  I  N  G      U  T  I  L  I  T  Y
 
    =========================================================================*/
-
-static int MmsBinaryEncodeIntegerLen(UINT32 integer)
+static int __MmsBinaryEncodeIntegerLen(UINT32 integer)
 {
        if (integer < 0x80) {
                /* short-integer */
@@ -2599,7 +2297,7 @@ static int MmsBinaryEncodeIntegerLen(UINT32 integer)
  *
  * @param      length [in] gotten from MmsBinaryEncodeIntegerLen()
  */
-static bool MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length)
+static bool __MmsBinaryEncodeInteger(FILE *pFile, UINT32 integer, int length)
 {
        union {
                UINT32 integer;
@@ -2646,8 +2344,7 @@ __CATCH:
        return false;
 }
 
-
-static int MmsBinaryEncodeLongIntegerLen(UINT32 integer)
+static int __MmsBinaryEncodeLongIntegerLen(UINT32 integer)
 {
        int length = 0;
 
@@ -2669,13 +2366,12 @@ static int MmsBinaryEncodeLongIntegerLen(UINT32 integer)
        return length;
 }
 
-
 /*
  * This makes value-length by specified integer value
  *
  * @param      length [in] gotten from MmsBinaryEncodeIntegerLen()
  */
-static bool MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length)
+static bool __MmsBinaryEncodeLongInteger(FILE *pFile, UINT32 integer, int length)
 {
        int i  = 0;
        union {
@@ -2718,9 +2414,7 @@ __CATCH:
        return false;
 }
 
-
-
-static int MmsBinaryEncodeTextStringLen(UINT8 *source)
+static int __MmsBinaryEncodeTextStringLen(UINT8 *source)
 {
        int      length = 0;
 
@@ -2741,14 +2435,13 @@ static int MmsBinaryEncodeTextStringLen(UINT8 *source)
        return length;
 }
 
-
 /*
  * @param      source [in] originam string
  * @param      length [in] gotten from MmsBinaryEncodeTextStringLen()
  * @param      dest [in] buffer to store quted string
  * @return     changed string length
 */
-static bool MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length)
+static bool __MmsBinaryEncodeTextString(FILE *pFile, UINT8 *source, int length)
 {
 
        MSG_DEBUG("MmsBinaryEncodeTextString: \n");
@@ -2790,8 +2483,6 @@ __CATCH:
        return false;
 }
 
-
-
 /*
  * Encode 28bit unsigned integer(Maximum) to uintvar
  *
@@ -2803,7 +2494,7 @@ const UINT32 UINTVAR_LENGTH_2 =  0x00003fff;              //14bit
 const UINT32 UINTVAR_LENGTH_3 =  0x001fffff;           //21bit
 
 
-static int MmsBinaryEncodeUintvarLen(UINT32 integer)
+static int __MmsBinaryEncodeUintvarLen(UINT32 integer)
 {
        UINT32          length  = 0;
 
@@ -2825,8 +2516,7 @@ static int MmsBinaryEncodeUintvarLen(UINT32 integer)
        return length;
 }
 
-
-static bool MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length)
+static bool __MmsBinaryEncodeUintvar(FILE *pFile, UINT32 integer, int length)
 {
        const char ZERO = 0x00;
        int i = 2;
@@ -2879,29 +2569,26 @@ __CATCH:
        return false;
 }
 
-
-
-static int MmsBinaryEncodeValueLengthLen(UINT32 integer)
+static int __MmsBinaryEncodeValueLengthLen(UINT32 integer)
 {
        int length = 0;
 
        if (integer < 0x1f) {
                length = 1;
        } else {
-               length = MmsBinaryEncodeUintvarLen(integer) + 1;                //LENGTH_QUOTE
+               length = __MmsBinaryEncodeUintvarLen(integer) + 1;              //LENGTH_QUOTE
        }
 
        return length;
 }
 
-
 /*
  * This makes value-length by specified integer value
  *
  * @param      length [in] from MmsBinaryEncodeValueLengthLen()
  * @return     encoded value-length
  */
-static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length)
+static bool __MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length)
 {
        /*
         * Value-length = Short-length | (Length-quote Length)
@@ -2928,7 +2615,7 @@ static bool MmsBinaryEncodeValueLength(FILE *pFile, UINT32 integer, int length)
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)integer;
        } else {
                gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = (UINT8)LENGTH_QUOTE;
-               if (MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) {      // LENGTH_QUOTE
+               if (__MmsBinaryEncodeUintvar(pFile, integer, length - 1) == false) {    // LENGTH_QUOTE
                        MSG_DEBUG("MmsBinaryEncodeValueLength: MmsBinaryEncodeUintvar fail\n");
                        goto __CATCH;
                }
@@ -2940,8 +2627,7 @@ __CATCH:
        return false;
 }
 
-
-static int MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc)
+static int __MmsBinaryEncodeQuotedStringLen(UINT8 *pSrc)
 {
        if (pSrc == NULL) {
                MSG_DEBUG("MmsBinaryEncodeQuotedStringLen: invalid file\n");
@@ -2954,7 +2640,6 @@ __CATCH:
        return -1;
 }
 
-
 /*
  * make quoted string
  * Quoted-string = <Octet 34> *TEXT End-of-string
@@ -2964,7 +2649,7 @@ __CATCH:
  * @param      dest [out] buffer to store quted string
  * @return     changed string length
 */
-static bool MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length)
+static bool __MmsBinaryEncodeQuotedString(FILE *pFile, UINT8 *source, int length)
 {
        if (source == NULL || pFile == NULL) {
                MSG_DEBUG("MmsBinaryEncodeQuotedString: invalid file\n");
@@ -2990,9 +2675,7 @@ __CATCH:
        return false;
 }
 
-
-
-static int MmsBinaryEncodeEncodedStringLen(UINT8 *source)
+static int __MmsBinaryEncodeEncodedStringLen(UINT8 *source)
 {
        UINT32 charset = 0x6A;          // default = utf-8
        int charLeng            = 0;
@@ -3004,19 +2687,19 @@ static int MmsBinaryEncodeEncodedStringLen(UINT8 *source)
 
        /* value-length charSet text-string */
        /* Estimate charset value length and text string length */
-       charLeng = MmsBinaryEncodeIntegerLen(charset);
+       charLeng = __MmsBinaryEncodeIntegerLen(charset);
        if (charLeng == -1) {
                MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : charLeng MmsBinaryEncodeTextStringLen fail.\n");
                goto __CATCH;;
        }
 
-       textLeng = MmsBinaryEncodeTextStringLen((UINT8*)source);
+       textLeng = __MmsBinaryEncodeTextStringLen((UINT8*)source);
        if (textLeng == -1)     {
                MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : textLeng MmsBinaryEncodeTextStringLen fail.\n");
                goto __CATCH;;
        }
 
-       valueLengthLen = MmsBinaryEncodeValueLengthLen(charLeng + textLeng);
+       valueLengthLen = __MmsBinaryEncodeValueLengthLen(charLeng + textLeng);
        if (valueLengthLen == -1) {
                MSG_DEBUG("MmsBinaryEncodeEncodedStringLen : valLengthLen MmsBinaryEncodeTextStringLen fail.\n");
                goto __CATCH;
@@ -3028,14 +2711,13 @@ __CATCH:
        return -1;
 }
 
-
 /*
  * This makes value-length by specified integer value
  *
  * @param      length [in] from MmsBinaryEncodeEncodedStringLen()
  * @return     encoded encoded-string
  */
-static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
+static bool __MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
 {
        UINT32 charset = 0x6A;          // default = utf-8
        int charLeng = 0;
@@ -3053,19 +2735,19 @@ static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
        }
 
        /* Estimate charset value length and text string length */
-       charLeng = MmsBinaryEncodeIntegerLen(charset);
+       charLeng = __MmsBinaryEncodeIntegerLen(charset);
        if (charLeng == -1) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : charLeng MmsBinaryEncodeTextStringLen fail.\n");
                goto __CATCH;;
        }
 
-       textLeng = MmsBinaryEncodeTextStringLen((UINT8*)source);
+       textLeng = __MmsBinaryEncodeTextStringLen((UINT8*)source);
        if (textLeng == -1) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : textLeng MmsBinaryEncodeTextStringLen fail.\n");
                goto __CATCH;;
        }
 
-       valLengthLen = MmsBinaryEncodeValueLengthLen(charLeng + textLeng);
+       valLengthLen = __MmsBinaryEncodeValueLengthLen(charLeng + textLeng);
        if (valLengthLen == -1) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeValueLengthLen fail.\n");
                goto __CATCH;
@@ -3086,20 +2768,20 @@ static bool MmsBinaryEncodeEncodedString(FILE *pFile, UINT8 *source, int length)
        }
 
        /* Value length of charset value and text string */
-       if (MmsBinaryEncodeValueLength(pFile, charLeng + textLeng, valLengthLen) == false) {
+       if (__MmsBinaryEncodeValueLength(pFile, charLeng + textLeng, valLengthLen) == false) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeValueLength fail.\n");
                goto __CATCH;
        }
 
        /* fixme: Write charset on buffer -> integer value not long-integer */
-       if (MmsBinaryEncodeInteger(pFile, charset, charLeng) == false) {
+       if (__MmsBinaryEncodeInteger(pFile, charset, charLeng) == false) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeInteger fail.\n");
                goto __CATCH;
        }
 
 
        /* Write text string on buffer */
-       if (MmsBinaryEncodeTextString(pFile, (UINT8*)source, textLeng) == false) {
+       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)source, textLeng) == false) {
                MSG_DEBUG("MmsBinaryEncodeEncodedString : MmsBinaryEncodeTextString fail.\n");
                goto __CATCH;
        }
@@ -3110,7 +2792,6 @@ __CATCH:
        return false;
 }
 
-
 static bool __MmsBinaryEncodeFieldCodeAndValue(FILE *pFile, UINT8 fieldCode, UINT8 fieldValue)
 {
        if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < 2) {
@@ -3140,8 +2821,6 @@ __CATCH:
        return false;
 }
 
-
-
 static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen)
 {
        int     length    = 0;
@@ -3156,7 +2835,7 @@ static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen)
        dateSec = mktime(dateTime);
 
 
-       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
+       fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80;
        if (fieldCode == 0xff) {
                MSG_DEBUG("__MmsBinaryEncodeTrID: invalid fieldCode \n");
                goto __CATCH;
@@ -3165,7 +2844,7 @@ static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen)
        snprintf(szBuff, MMS_TR_ID_LEN + 1, "%lu.%lu", dateSec, (unsigned long)random());
        MSG_DEBUG("__MmsBinaryEncodeTrID: 2. szBuff = %s\n", szBuff);
 
-       length = MmsBinaryEncodeTextStringLen((UINT8*)szBuff);
+       length = __MmsBinaryEncodeTextStringLen((UINT8*)szBuff);
        if (length == -1) {
                MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextStringLen fail \n");
                goto __CATCH;
@@ -3181,7 +2860,7 @@ static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen)
 
 
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
-       if (MmsBinaryEncodeTextString(pFile, (UINT8*)szBuff, length) == false) {
+       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szBuff, length) == false) {
                MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextString fail\n");
                goto __CATCH;
        }
@@ -3203,7 +2882,7 @@ static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID)
        int     length = 0;
        UINT8 fieldCode = 0xff;
 
-       fieldCode = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGID) | 0x80;
+       fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_MSGID) | 0x80;
        if (fieldCode == 0xff) {
                MSG_DEBUG("__MmsBinaryEncodeTrID: invalid fieldCode \n");
                goto __CATCH;
@@ -3211,7 +2890,7 @@ static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID)
 
        MSG_DEBUG("__MmsBinaryEncodeMsgID: 2. szBuff = %s\n", szMsgID);
 
-       length = MmsBinaryEncodeTextStringLen((UINT8*)szMsgID);
+       length = __MmsBinaryEncodeTextStringLen((UINT8*)szMsgID);
        if (length == -1) {
                MSG_DEBUG("__MmsBinaryEncodeMsgID: MmsBinaryEncodeTextStringLen fail \n");
                goto __CATCH;
@@ -3226,7 +2905,7 @@ static bool __MmsBinaryEncodeMsgID(FILE *pFile, const char *szMsgID)
        }
 
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = fieldCode;
-       if (MmsBinaryEncodeTextString(pFile, (UINT8*)szMsgID, length) == false) {
+       if (__MmsBinaryEncodeTextString(pFile, (UINT8*)szMsgID, length) == false)       {
                MSG_DEBUG("__MmsBinaryEncodeTrID: MmsBinaryEncodeTextString fail\n");
                goto __CATCH;
        }
@@ -3238,8 +2917,6 @@ __CATCH:
        return false;
 }
 
-
-
 static bool __MmsBinaryEncodeMmsVersion(FILE *pFile)
 {
        UINT8 majorVer = MMS_MAJOR_VERSION;
@@ -3260,7 +2937,7 @@ static bool __MmsBinaryEncodeMmsVersion(FILE *pFile)
                }
        }
 
-       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_VERSION) | 0x80;
 
        MSG_DEBUG("__MmsBinaryEncodeMmsVersion: major version (%d)\n", majorVer);
        MSG_DEBUG("__MmsBinaryEncodeMmsVersion: minor version (%d)\n", minorVer);
@@ -3279,8 +2956,6 @@ __CATCH:
        return false;
 }
 
-
-
 static bool __MmsBinaryEncodeDate(FILE *pFile)
 {
        struct  tm      *dateTime = NULL;
@@ -3294,7 +2969,7 @@ static bool __MmsBinaryEncodeDate(FILE *pFile)
 
        if (dateSec > 0) {
                int     length  = 0;
-               length = MmsBinaryEncodeLongIntegerLen(dateSec);
+               length = __MmsBinaryEncodeLongIntegerLen(dateSec);
 
                if ((gMmsEncodeMaxLen - gCurMmsEncodeBuffPos) < (length + 1)) { // + fieldCode
                        if (MsgWriteDataFromEncodeBuffer(pFile, gpMmsEncodeBuf, &gCurMmsEncodeBuffPos,
@@ -3304,9 +2979,9 @@ static bool __MmsBinaryEncodeDate(FILE *pFile)
                        }
                }
 
-               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DATE) | 0x80;
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_DATE) | 0x80;
 
-               if (MmsBinaryEncodeLongInteger(pFile, dateSec, length) == false) {
+               if (__MmsBinaryEncodeLongInteger(pFile, dateSec, length) == false) {
                        MSG_DEBUG("__MmsBinaryEncodeDate: date MmsBinaryEncodeLongInteger error\n");
                        goto __CATCH;
                }
@@ -3320,8 +2995,6 @@ __CATCH:
        return false;
 }
 
-
-
 static bool __MmsBinaryEncodeFrom(FILE *pFile)
 {
        if (pFile == NULL) {
@@ -3337,17 +3010,16 @@ static bool __MmsBinaryEncodeFrom(FILE *pFile)
                }
        }
 
-       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_FROM) | 0x80;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_FROM) | 0x80;
        /* length of MMS_INSERT_ADDRESS_TOKEN value */
        gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = 0x01;
-       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN) | 0x80;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeAddressType, MMS_INSERT_ADDRESS_TOKEN) | 0x80;
        return true;
 
 __CATCH:
        return false;
 }
 
-
 static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char *szAddrStr)
 {
        int length = 0;
@@ -3358,7 +3030,7 @@ static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char
        }
 
        /* EncodedString */
-       length = MmsBinaryEncodeEncodedStringLen((UINT8*)szAddrStr);
+       length = __MmsBinaryEncodeEncodedStringLen((UINT8*)szAddrStr);
 
        if (length == -1) {
                MSG_DEBUG("__MmsBinaryEncodeOneAddress: MmsBinaryEncodeEncodedStringLen fail \n");
@@ -3373,10 +3045,10 @@ static bool __MmsBinaryEncodeOneAddress(FILE *pFile, MmsFieldCode addrType, char
                }
        }
 
-       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, addrType) | 0x80;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, addrType) | 0x80;
 
 
-       if (MmsBinaryEncodeEncodedString(pFile, (UINT8*)szAddrStr, length) == false) {
+       if (__MmsBinaryEncodeEncodedString(pFile, (UINT8*)szAddrStr, length) == false) {
                MSG_DEBUG("__MmsBinaryEncodeOneAddress: MmsBinaryEncodeEncodedString fail \n");
                goto __CATCH;
        }
@@ -3387,7 +3059,6 @@ __CATCH:
        return false;
 }
 
-
 static bool __MmsBinaryEncodeAddress(FILE *pFile, MmsFieldCode addrType, char *szAddr)
 {
        char *pSingleAddr = NULL;
@@ -3431,8 +3102,6 @@ __CATCH:
        return false;
 }
 
-
-
 static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeStruct time)
 {
        int             timeLen  = 0;
@@ -3456,9 +3125,9 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt
         */
 
        if (time.type == MMS_TIMETYPE_RELATIVE) {
-               timeLen = MmsBinaryEncodeIntegerLen(time.time);
+               timeLen = __MmsBinaryEncodeIntegerLen(time.time);
        } else {
-               timeLen = MmsBinaryEncodeLongIntegerLen(time.time);
+               timeLen = __MmsBinaryEncodeLongIntegerLen(time.time);
        }
 
        if (timeLen <= 0) {
@@ -3466,7 +3135,7 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt
                goto __CATCH;
        }
 
-       length = MmsBinaryEncodeValueLengthLen(timeLen + 1);    //time length + time type token
+       length = __MmsBinaryEncodeValueLengthLen(timeLen + 1);  //time length + time type token
        if (length == -1) {
                MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeValueLengthLen fail \n");
                goto __CATCH;
@@ -3482,24 +3151,24 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt
        }
 
        /* fieldCode */
-       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeFieldCode, fieldCode) | 0x80;
+       gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeFieldCode, fieldCode) | 0x80;
 
        /* value length */
-       if (MmsBinaryEncodeValueLength(pFile, timeLen + 1, length) == false) {
+       if (__MmsBinaryEncodeValueLength(pFile, timeLen + 1, length) == false) {
                MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeValueLength fail \n");
                goto __CATCH;
        }
 
        /* time type & value */
        if (time.type == MMS_TIMETYPE_RELATIVE) {
-               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_RELATIVE) | 0x80;
-               if (MmsBinaryEncodeInteger(pFile, time.time, timeLen) == false) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_RELATIVE) | 0x80;
+               if (__MmsBinaryEncodeInteger(pFile, time.time, timeLen) == false)       {
                        MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongInteger fail \n");
                        goto __CATCH;
                }
        } else {
-               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = _MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80;
-               if (MmsBinaryEncodeLongInteger(pFile, time.time, timeLen) == false) {
+               gpMmsEncodeBuf[gCurMmsEncodeBuffPos++] = MmsGetBinaryValue(MmsCodeTimeType, MMS_TIMETYPE_ABSOLUTE) | 0x80;
+               if (__MmsBinaryEncodeLongInteger(pFile, time.time, timeLen) == false) {
                        MSG_DEBUG("__MmsBinaryEncodeTime: MmsBinaryEncodeLongInteger fail \n");
                        goto __CATCH;
                }
@@ -3510,4 +3179,3 @@ static bool __MmsBinaryEncodeTime(FILE *pFile, MmsFieldCode fieldCode, MmsTimeSt
 __CATCH:
        return false;
 }
-
index 262b089..c160d16 100755 (executable)
 #include "MsgStorageHandler.h"
 #include "MmsPluginTypes.h"
 #include "MmsPluginCodec.h"
-#include "MmsPluginSetup.h"
 #include "MmsPluginInternal.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginHttp.h"
 #include "MmsPluginCodec.h"
-
 #include "MsgNotificationWrapper.h"
 #include "MmsPluginSmil.h"
 
-MmsSetup gMmsSetup;
-
 /*==================================================================================================
                                      IMPLEMENTATION OF MmsPluginInternal - Member Functions
 ==================================================================================================*/
@@ -65,7 +61,7 @@ MmsPluginInternal *MmsPluginInternal::instance()
 
 void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest, bool *bReject)
 {
-       MSG_DEBUG("processReceivedInd \r\n");
+       MSG_BEGIN();
 
        FILE *pFile = NULL;
        char fileName[MSG_FILENAME_LEN_MAX] = {0,};
@@ -76,7 +72,7 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
                if(MsgCreateFileName(fileName) == false)
                        THROW(MsgException::FILE_ERROR, "MsgCreateFileName error");
 
-               MSG_DEBUG(" File name = %s", fileName);
+               MSG_DEBUG("File name = %s", fileName);
 
                if(MsgWriteIpcFile(fileName, pMsgInfo->msgText, pMsgInfo->dataSize) == false)
                        THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error");
@@ -90,8 +86,8 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
 
        MSG_DEBUG("MMS File Path = %s", pMsgInfo->msgData);
 
-       _MmsInitHeader();
-       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,  gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+       MmsInitHeader();
+       MmsRegisterDecodeBuffer();
 
        if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
                MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
@@ -104,7 +100,7 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
 
                switch (mmsHeader.type) {
                case MMS_MSGTYPE_NOTIFICATION_IND:
-                       MSG_DEBUG("MmsProcessNewMsgInd: process noti.ind\n");
+                       MSG_DEBUG("process noti.ind\n");
                        // For Set Value pMsgInfo
                        if (processNotiInd(pMsgInfo, pRequest) == false)
                                *bReject = true;
@@ -113,13 +109,13 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
                        break;
 
                case MMS_MSGTYPE_DELIVERY_IND:
-                       MSG_DEBUG("MmsProcessNewMsgInd: process delivery.ind\n");
+                       MSG_DEBUG("process delivery.ind\n");
                        // For Set Value pMsgInfo
                        processDeliveryInd(pMsgInfo);
                        break;
 
                case MMS_MSGTYPE_READORG_IND:
-                       MSG_DEBUG("MmsProcessNewMsgInd: process readorig.ind\n");
+                       MSG_DEBUG("process readorig.ind\n");
                        processReadOrgInd(pMsgInfo);
                        break;
                default:
@@ -128,7 +124,8 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ
 
                MsgCloseFile(pFile);
        }
-       //Check Msg Type & Process(Save ...)
+
+       MSG_END();
 }
 
 bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST_INFO_S *pRequest)
@@ -372,11 +369,11 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn
 
        MmsMsg *pMsg = NULL;
        MmsPluginStorage::instance()->getMmsMessage(&pMsg);
-       _MmsInitHeader();
+       MmsInitHeader();
 #ifdef __SUPPORT_DRM__
-       _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+       MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
 #endif
-       _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+       MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
 
 
        MSG_END();
@@ -563,11 +560,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 
        MmsMsg *pMsg = NULL;
        pStorage->getMmsMessage(&pMsg);
-       _MmsInitHeader();
+       MmsInitHeader();
 #ifdef __SUPPORT_DRM__
-       _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+       MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
 #endif
-       _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+       MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
 
        MSG_END();
 }
@@ -604,8 +601,8 @@ bool MmsPluginInternal::encodeNotifyRespInd(char *szTrID, msg_delivery_report_st
                return false;
        }
 
-       if (_MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) {
-               MSG_DEBUG("MmsEncodeNotifyRespInd: _MmsEncodeNotiRespInd fail");
+       if (MmsEncodeNotiRespInd(pFile, szTrID, iStatus, bReportAllowed) == false) {
+               MSG_DEBUG("MmsEncodeNotifyRespInd: MmsEncodeNotiRespInd fail");
                MsgCloseFile(pFile);
                return false;
        }
@@ -648,8 +645,8 @@ bool MmsPluginInternal::encodeAckInd(char *szTrID, bool bReportAllowed, char *pS
                return false;
        }
 
-       if (_MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
-               MSG_DEBUG("MmsEncodeAckInd: _MmsEncodeAckInd fail \n" );
+       if (MmsEncodeAckInd(pFile, szTrID, bReportAllowed) == false) {
+               MSG_DEBUG("MmsEncodeAckInd: MmsEncodeAckInd fail \n" );
                MsgCloseFile(pFile);
                return false;
        }
index 6d29df9..3aa6623 100755 (executable)
@@ -295,8 +295,9 @@ msg_error_t MmsRestoreMsg(MSG_MESSAGE_INFO_S *pMsgInfo, char *pRcvBody, int rcvd
 
        if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) {
                FILE *pFile;
-               _MmsInitHeader();
-               _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,  gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+
+               MmsInitHeader();
+               MmsRegisterDecodeBuffer();
 
                if ((pFile = MsgOpenFile(pMsgInfo->msgData, "rb+")) == NULL) {
                        MSG_DEBUG("File Open Error: %s", pMsgInfo->msgData);
index e11119a..22ef657 100755 (executable)
@@ -276,7 +276,7 @@ int MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char **pRawdata)
 }
 
 
-bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size)
+bool MmsInsertPresentation(MmsMsg *pMsg, MimeType mimeType, char *pData, int size)
 {
        MSG_DEBUG("MmsInsertPresentation");
 
@@ -335,7 +335,7 @@ bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath,
        MsgMultipart *pMultipart = NULL;
        MsgMultipart *pLastPart = NULL;
        int nFileSize;
-       MsgContentType mimeType = MIME_UNKNOWN;
+       MimeType mimeType = MIME_UNKNOWN;
        char *pExt = NULL;
 
        pExt = strrchr(szOrgFilePath, '.');
@@ -530,7 +530,7 @@ __CATCH:
 
 
 
-MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID)
+MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID)
 {
        MsgMultipart *pMultipart = NULL;
 
@@ -965,9 +965,7 @@ bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
                goto __CATCH;
        }
 
-       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,
-                                                         gszMmsLoadBuf2,
-                                                         MSG_MMS_DECODE_BUFFER_MAX);
+       MmsRegisterDecodeBuffer();
 
        if (MmsBinaryDecodeMsgHeader(pFile, nSize) == false) {
                MSG_DEBUG( "_MmsReadMsgBody: MmsBinaryDecodeMsgHeader fail...\n");
@@ -981,7 +979,7 @@ bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
 
        /* Set mmsHeader.msgType & msgBody to pMsg ----------- */
 
-       pMmsMsg->mmsAttrib.contentType = (MsgContentType)mmsHeader.msgType.type;
+       pMmsMsg->mmsAttrib.contentType = (MimeType)mmsHeader.msgType.type;
 
        memcpy(&(pMmsMsg->msgType), &(mmsHeader.msgType), sizeof(MsgType));
        memcpy(&(pMmsMsg->msgBody), &(mmsHeader.msgBody), sizeof(MsgBody));
@@ -1025,7 +1023,7 @@ bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
                        if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED) ||
                                (mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) {
                                if ((pMmsMsg->nPartCount >= attachmax ) && (pMultipart->pNext != NULL)) {
-                                       _MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
+                                       MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type);
 
                                        free(pMultipart->pNext->pBody);
                                        pMultipart->pNext->pBody = NULL;
@@ -1044,22 +1042,22 @@ bool MmsGetMmsMessageBody(MmsMsg *pMmsMsg, char *retrievedFilePath)
        }
 
        //call before processing urgent event.
-       _MmsInitHeader();
-       _MmsUnregisterDecodeBuffer();
+       MmsInitHeader();
+       MmsUnregisterDecodeBuffer();
 
        return true;
 
 __CATCH:
 
-       _MmsInitHeader();
-       _MmsUnregisterDecodeBuffer();
+       MmsInitHeader();
+       MmsUnregisterDecodeBuffer();
 
        if (pFile != NULL) {
                MsgCloseFile(pFile);
                pFile = NULL;
        }
 
-       _MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
+       MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type);
        MSG_DEBUG("_MmsReadMsgBody:    E  N  D    ( fail )    ******************** \n");
 
        return false;
index f4d8adf..694cbb4 100755 (executable)
 #include "MsgMmsMessage.h"
 
 #include "MsgTypes.h"
-#include "MmsPluginSetup.h"
 #include "MsgUtilFile.h"
 
+#define MSG_STDSTR_SHORT                       0x7F
+
 /* static variables */
 static char gszEmptyRawDoc[] = "<smil><head><layout></layout></head><body></body></smil>";
 static MmsSmilDoc *__gpaMmsSmilDoc[MMS_SMIL_MAX_DOC]={NULL, };
index 9d58de9..80ad7e6 100755 (executable)
@@ -24,9 +24,6 @@
 #include "MsgMmsMessage.h"
 #include "MsgNotificationWrapper.h"
 #include "MsgUtilStorage.h"
-
-#include "MmsPluginStorage.h"
-#include "MmsPluginSetup.h"
 #include "MmsPluginStorage.h"
 #include "MmsPluginCodec.h"
 #include "MmsPluginSmil.h"
@@ -96,7 +93,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                MMS_MESSAGE_DATA_S mmsMsgData;
                bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S));
                if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
 
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
@@ -113,7 +110,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
 
                if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
 
@@ -126,14 +123,14 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
 
                pFile = MsgOpenMMSFile(fileName);
                if (!pFile) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
                        THROW(MsgException::MMS_PLG_ERROR, "MMS File open Error");
                }
 
                if (fchmod(fileno(pFile), file_mode) < 0) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
                        MsgCloseFile(pFile);
@@ -141,8 +138,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                        THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
                }
 
-               if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               if (MmsEncodeSendReq(pFile, &mmsMsg) != true) {
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
                        MsgCloseFile(pFile);
@@ -163,7 +160,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
 
                pMsgInfo->dataSize = size;
 
-               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                MsgFreeAttrib(&mmsMsg.mmsAttrib);
                __MmsReleaseMmsLists(&mmsMsgData);
 
@@ -174,14 +171,14 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
 
                //Need to store mms specific data (contents location, TrID, ExpiryTime, Delivery Report, message ID)
                if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&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))
+               if (!MmsReadMsgBody(pMsgInfo->msgId, true, true, pFileData))
                        THROW(MsgException::MMS_PLG_ERROR, "_MmsReadMsgBody Error");
 
                MmsPluginStorage::instance()->getMmsMessage(&pMsg);
@@ -221,14 +218,14 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                }
 
                if (addMmsMsgToDB(pMsg, pMsgInfo) != MSG_SUCCESS) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&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);
 
-               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeBody(&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 ###########");
@@ -250,7 +247,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                MmsComposeReadReportMessage(&mmsMsg, pMsgInfo, selectedMsgId);
 
                if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
 
                        THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error");
@@ -259,7 +256,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID);
                pFile = MsgOpenMMSFile(filePath);
                if (!pFile) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        MsgCloseFile(pFile);
                        pFile = NULL;
@@ -268,7 +265,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                }
 
                if (fchmod(fileno(pFile), file_mode) < 0) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        MsgCloseFile(pFile);
                        pFile = NULL;
@@ -278,7 +275,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
 
                if (version == 0x90) {
                        MSG_DEBUG("### version 1.0 ###");
-                       if (_MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
+                       if (MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
                                MsgFreeAttrib(&mmsMsg.mmsAttrib);
                                MsgCloseFile(pFile);
                                pFile = NULL;
@@ -287,7 +284,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                        }
                } else {
                        MSG_DEBUG("### version 1.1 ###");
-                       if (_MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
+                       if (MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
                                MsgFreeAttrib(&mmsMsg.mmsAttrib);
                                MsgCloseFile(pFile);
                                pFile = NULL;
@@ -300,7 +297,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                MsgCloseFile(pFile);
                pFile = NULL;
 
-               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
 
                MsgFreeAttrib(&mmsMsg.mmsAttrib);
 
@@ -313,7 +310,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                MMS_MESSAGE_DATA_S mmsMsgData;
 
                if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
 
@@ -325,7 +322,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN + 1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId);
 
                if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
 
@@ -338,7 +335,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
 
                pFile = MsgOpenMMSFile(filePath);
                if (!pFile) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
                        MsgCloseFile(pFile);
@@ -348,7 +345,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                }
 
                if (fchmod(fileno(pFile), file_mode) < 0) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
                        MsgCloseFile(pFile);
@@ -357,8 +354,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                        THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno));
                }
 
-               if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) {
-                       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               if (MmsEncodeSendReq(pFile, &mmsMsg) != true) {
+                       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                        MsgFreeAttrib(&mmsMsg.mmsAttrib);
                        __MmsReleaseMmsLists(&mmsMsgData);
                        MsgCloseFile(pFile);
@@ -370,7 +367,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I
                MsgCloseFile(pFile);
                pFile = NULL;
 
-               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                MsgFreeAttrib(&mmsMsg.mmsAttrib);
                __MmsReleaseMmsLists(&mmsMsgData);
        }
@@ -407,13 +404,13 @@ void MmsPluginStorage::composeReadReport(MSG_MESSAGE_INFO_S *pMsgInfo)
 
        if (version == 0x90) {
                MSG_DEBUG("### version 1.0 ###");
-               if (_MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
+               if (MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) {
                        MsgCloseFile(pFile);
                        THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.0 Error");
                }
        } else {
                MSG_DEBUG("### version 1.1 ###");
-               if (_MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
+               if (MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) {
                        MsgCloseFile(pFile);
                        THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.1 Error");
                }
@@ -508,7 +505,7 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
                dbHandle.finalizeQuery();
        }
 
-       if (_MmsReadMsgBody(pMsg->msgId, true, false, NULL) == false) {
+       if (MmsReadMsgBody(pMsg->msgId, true, false, NULL) == false) {
                MSG_DEBUG("The MMS Message might include drm contents!!!");
 
 #ifdef __SUPPORT_DRM__
@@ -614,12 +611,12 @@ msg_error_t       MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN
 
        MmsMsg *pStoMmsMsg;
        MmsPluginStorage::instance()->getMmsMessage(&pStoMmsMsg);
-       _MmsInitHeader();
-       _MmsUnregisterDecodeBuffer();
+       MmsInitHeader();
+       MmsUnregisterDecodeBuffer();
 #ifdef __SUPPORT_DRM__
-       _MsgFreeDRMInfo(&pStoMmsMsg->msgType.drmInfo);
+       MsgFreeDRMInfo(&pStoMmsMsg->msgType.drmInfo);
 #endif
-       _MsgFreeBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type);
+       MsgFreeBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type);
 
        pMsg->dataSize = nSize;
 
@@ -638,13 +635,13 @@ L_CATCH:
        {
                MmsMsg *pMsg;
                MmsPluginStorage::instance()->getMmsMessage(&pMsg);
-               _MmsInitHeader();
+               MmsInitHeader();
 
-               _MmsUnregisterDecodeBuffer();
+               MmsUnregisterDecodeBuffer();
 #ifdef __SUPPORT_DRM__
-               _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+               MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
 #endif
-               _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+               MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
 
                return MSG_ERR_STORAGE_ERROR;
        }
@@ -677,7 +674,7 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
        MMS_MESSAGE_DATA_S mmsMsgData;
 
        if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) {
-               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+               MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                MsgFreeAttrib(&mmsMsg.mmsAttrib);
                __MmsReleaseMmsLists(&mmsMsgData);
 
@@ -688,8 +685,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
 
        pFile = MsgOpenMMSFile(filePath);
 
-       if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) {
-               _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+       if (MmsEncodeSendReq(pFile, &mmsMsg) != true) {
+               MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
                MsgFreeAttrib(&mmsMsg.mmsAttrib);
                __MmsReleaseMmsLists(&mmsMsgData);
                MsgCloseFile(pFile);
@@ -699,7 +696,7 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE
 
        MsgCloseFile(pFile);
 
-       _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
+       MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type);
        MsgFreeAttrib(&mmsMsg.mmsAttrib);
 
        __MmsReleaseMmsLists(&mmsMsgData);
@@ -1238,158 +1235,3 @@ msg_error_t MmsPluginStorage::insertPreviewInfo(int msgId, int type, char *value
 
        return MSG_SUCCESS;
 }
-
-/* This API is not used anywhere now */
-msg_error_t    MmsPluginStorage::plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg, char *filePath)
-{
-       MSG_BEGIN();
-
-       msg_error_t     err = MSG_SUCCESS;
-       int partCnt = 0;
-       MsgType partHeader;
-       MmsAttrib pMmsAttrib;
-       char szBuf[MSG_FILEPATH_LEN_MAX] = {0, };
-       unsigned int nSize;
-       bool bMultipartRelated = false;
-
-       if (_MmsReadMsgBody(pMsg->msgId, true, true, filePath) == 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);
-               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 - 1);
-                       } else {
-                               strcpy((char *)szBuf, partHeader.param.szFileName);
-                       }
-                       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);
-
-       __MmsReleaseMmsLists(pMmsMsg);
-
-       MmsMsg *pStoMmsMsg;
-       MmsPluginStorage::instance()->getMmsMessage(&pStoMmsMsg);
-       _MmsInitHeader();
-       _MmsUnregisterDecodeBuffer();
-#ifdef __SUPPORT_DRM__
-       _MsgFreeDRMInfo(&pStoMmsMsg->msgType.drmInfo);
-#endif
-       _MsgFreeBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type);
-
-
-       pMsg->dataSize = nSize;
-       MSG_END();
-
-       return err;
-
-FREE_CATCH:
-       if (bMultipartRelated) {
-               __MmsReleaseMmsLists(pMmsMsg);
-
-       }
-
-L_CATCH:
-       MSG_DEBUG("MmsPlgUpdateMessage : Update MMS Message Failed");
-       MSG_END();
-       {
-               MmsMsg *pMsg;
-               MmsPluginStorage::instance()->getMmsMessage(&pMsg);
-               _MmsInitHeader();
-
-               _MmsUnregisterDecodeBuffer();
-#ifdef __SUPPORT_DRM__
-               _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
-#endif
-               _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
-
-               return MSG_ERR_STORAGE_ERROR;
-       }
-}
-/* This API is not used anywhere now */
-
index 3980b50..f445741 100755 (executable)
@@ -14,8 +14,6 @@
 * limitations under the License.
 */
 #include <glib.h>
-#include <stdlib.h>
-#include <ctype.h>
 #include "MmsPluginMIME.h"
 #include "MmsPluginCodec.h"
 #include "MmsPluginTextConvert.h"
index 7851ff6..eb334e3 100755 (executable)
@@ -588,8 +588,8 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
 
        MSG_DEBUG(":::%d :%s ", rcvdBodyLen, pRcvdBody);
 
-       _MmsInitHeader();
-       _MmsRegisterDecodeBuffer(gszMmsLoadBuf1,  gszMmsLoadBuf2, MSG_MMS_DECODE_BUFFER_MAX);
+       MmsInitHeader();
+       MmsRegisterDecodeBuffer();
 
        if (MsgCreateFileName(fileName) == false)
                return false;
@@ -604,7 +604,7 @@ bool MmsPluginUaManager::processReceivedData(int msgId, char *pRcvdBody, int rcv
                return false;
        }
 
-       if (_MmsReadMsgBody(msgId, true, true, retrievedFilePath) == false) {
+       if (MmsReadMsgBody(msgId, true, true, retrievedFilePath) == false) {
                MSG_DEBUG("The MMS Message might include drm contents!!!");
 
 #ifdef __SUPPORT_DRM__
@@ -651,13 +651,13 @@ ERR_MMS_UA_PROCESS_CONF:
                MmsPluginStorage::instance()->getMmsMessage(&pMsg);
 
 
-               _MmsInitHeader();
-               _MmsUnregisterDecodeBuffer();
+               MmsInitHeader();
+               MmsUnregisterDecodeBuffer();
 
 #ifdef __SUPPORT_DRM__
-               _MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
+               MsgFreeDRMInfo(&pMsg->msgType.drmInfo);
 #endif
-               _MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
+               MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type);
 
                return false;
        }
index 0aaa4a0..743fb9d 100755 (executable)
 
 #ifndef MMS_PLUGIN_CODEC_H
 #define MMS_PLUGIN_CODEC_H
-
-
 /*==================================================================================================
                                                        HEADER
 ==================================================================================================*/
-
-#include <glib.h>
-#include <vconf.h>
-#include "MsgMmsTypes.h"
-#include "MmsPluginMessage.h"
-#include "MsgTransportTypes.h"
-
-/*==================================================================================================
-                                                       DEFINE
-==================================================================================================*/
-
-#define        MMS_MAJOR_VERSION                       1
-
-#if defined(MMS_V1_1)
-#define        MMS_MINOR_VERSION                       1
-#define        MMS_VERSION                                     0x91
-
-#elif defined(MMS_V1_2)
-#define        MMS_MINOR_VERSION                       2
-#define        MMS_VERSION                                     0x92
-
-#else
-#define        MMS_MINOR_VERSION                       0
-#define        MMS_VERSION                                     0x90
-#endif
-
-#define        MMS_SIGN_TEXT_LEN                       100
-#define        MMS_MAX_FIELD_VALUE_COUNT       74
-#define        MMS_MAX_FIELD_TYPE_COUNT        21
-#define        MSG_MMS_ENCODE_BUFFER_MAX       (2 * 1024)
-#define        MSG_MMS_DECODE_BUFFER_MAX       (2 * 1024)
-#define        MSB                                                             0x80
-#define        QUOTE                                                   0x7F
-#define        MARK                                                    0x22    // "
-#define        NO_VALUE                                                0x00
-#define        LENGTH_QUOTE                                    0x1F
-#define        MSG_STDSTR_LONG                         0xFF
-#define        INVALID_VALUE                                   -1
-#define        MSG_INVALID_VALUE                               -1
-
-#define        MMS_MAX_FIELD_VALUE_COUNT       74
-#define        MMS_MAX_FIELD_TYPE_COUNT        21
-
-#define MSG_LOCAL_TEMP_BUF_SIZE 1024
-#define MSG_INBOX_DIRECTORY                    "/User/Msg/Inbox"
-/*==================================================================================================
-                                                       ENUMS
-==================================================================================================*/
-
-typedef enum {
-       MMS_CODE_BCC,
-       MMS_CODE_CC,
-       MMS_CODE_CONTENTLOCATION,
-       MMS_CODE_CONTENTTYPE,
-       MMS_CODE_DATE,
-       MMS_CODE_DELIVERYREPORT,
-       MMS_CODE_DELIVERYTIME,
-       MMS_CODE_EXPIRYTIME,
-       MMS_CODE_FROM,
-       MMS_CODE_MSGCLASS,
-       MMS_CODE_MSGID,
-       MMS_CODE_MSGTYPE,
-       MMS_CODE_VERSION,
-       MMS_CODE_MSGSIZE,
-       MMS_CODE_PRIORITY,
-       MMS_CODE_READREPLY,
-       MMS_CODE_REPORTALLOWED,
-       MMS_CODE_RESPONSESTATUS,
-       MMS_CODE_RETRIEVESTATUS,                /* Add by MMSENC v1.1 */
-       MMS_CODE_RESPONSETEXT,
-       MMS_CODE_RETRIEVETEXT,                  /* Add by MMSENC v1.1 */
-       MMS_CODE_SENDERVISIBILLITY,
-       MMS_CODE_MSGSTATUS,
-       MMS_CODE_SUBJECT,
-       MMS_CODE_TO,
-       MMS_CODE_TRID,
-
-       /* Add by MMSENC v1.1 */
-       MMS_CODE_READSTATUS,
-       MMS_CODE_REPLYCHARGING,
-       MMS_CODE_REPLYCHARGINGDEADLINE,
-       MMS_CODE_REPLYCHARGINGID,
-       MMS_CODE_REPLYCHARGINGSIZE,
-       MMS_CODE_PREVIOUSLYSENTBY,
-       MMS_CODE_PREVIOUSLYSENTDATE,
-
-       MMS_CODE_TRANSFERENCODING,
-       MMS_CODE_DISPOSITION,
-       MMS_CODE_CONTENT_ID
-} MmsFieldCode;
-
-enum {
-       MMS_BODYHDR_TRANSFERENCODING,
-       MMS_BODYHDR_DISPOSITION,
-       MMS_BODYHDR_CONTENTID,
-       MMS_BODYHDR_CONTENTLOCATION,
-       MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY,        // DRM RO WAITING
-};
-
-typedef enum {
-       //code
-       MmsCodeFieldCode,
-       MmsCodeParameterCode,
-       MmsCodeMsgBodyHeaderCode,
-
-       //Data
-       MmsCodeMsgType,
-       MmsCodeDeliveryReport,
-       MmsCodeTimeType,
-       MmsCodeMsgClass,
-       MmsCodePriority,
-       MmsCodeResponseStatus,
-       MmsCodeRetrieveStatus,
-       MmsCodeReadReply,
-       MmsCodeReportAllowed,
-       MmsCodeSenderVisibility,
-       MmsCodeMsgStatus,
-       MmsCodeReadStatus,
-       MmsCodeAddressType,
-       MmsCodeCharSet,
-       MmsCodeReplyCharging,
-
-       MmsCodeContentType,
-
-       MmsCodeMsgDisposition,
-       MmsCodeContentTransferEncoding
-} MmsCode;
-
-typedef enum {
-       MSG_PRESENTATION_NONE = -1,
-       MSG_PRESENTATION_FIRSTPART,             //Content-type == type parameter
-       MSG_PRESENTATION_TYPE_BASE,             //Content-type == type parameter
-       MSG_PRESENTATION_LOCATION,              //Content-Location == start parameter
-       MSG_PRESENTATION_ID,                    //Content-ID == start parameter
-} MsgPresentationFactor;
-
-/*==================================================================================================
-                                                       Structures
-==================================================================================================*/
-
-typedef struct {
-       const char *szText;
-       UINT16 binary;
-} MmsField;
-
-
-typedef struct {
-       char *pData;
-       UINT32 length;
-} EncodedPData;
-
-typedef struct {
-       MsgPresentationFactor factor;
-       MsgMultipart *pPrevPart;
-       MsgMultipart *pCurPresentation;
-} MsgPresentaionInfo;
-
-// for Decoding & Encoding
-typedef struct {
-       bool bActive;
-       char *pszOwner;
-       int msgID;              // if noti.ind, msgID is -1.
-
-       MmsMsgType type;
-       char szTrID[MMS_TR_ID_LEN+1];
-       UINT8 version;
-       UINT32 date;
-
-       MsgHeaderAddress *pFrom;                //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
-       MsgHeaderAddress *pTo;
-       MsgHeaderAddress *pCc;
-       MsgHeaderAddress *pBcc;
-       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
-       MmsResponseStatus responseStatus;
-       MmsRetrieveStatus retrieveStatus;
-       char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
-       char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
-
-       MmsMsgClass msgClass;
-       MmsTimeStruct expiryTime;
-       MmsTimeStruct deliveryTime;
-       MmsPriority priority;
-       MmsSenderVisible hideAddress;
-       MmsReport deliveryReport;
-       MmsReport readReply;
-       MmsReportAllowed reportAllowed;
-       char szContentLocation[MMS_LOCATION_LEN + 1];
-
-       msg_delivery_report_status_t msgStatus;
-       msg_read_report_status_t readStatus;
-
-       MmsReplyCharge replyCharge;
-
-       // only used at Decoding module
-       char szMsgID[MMS_MSG_ID_LEN + 1];
-       UINT32 msgSize;
-
-#ifdef __SUPPORT_DRM__
-       MsgDrmType drmType;
-#endif
-
-       // dependent to Client implementation
-       MsgType msgType;
-       MsgBody msgBody;
-} MmsHeader;
-
-extern const MmsField gMmsField[MMS_MAX_FIELD_TYPE_COUNT][MMS_MAX_FIELD_VALUE_COUNT];
-extern char gszMmsLoadBuf1[MSG_MMS_DECODE_BUFFER_MAX + 1];
-extern char gszMmsLoadBuf2[MSG_MMS_DECODE_BUFFER_MAX + 1];
-
-extern MmsHeader mmsHeader;
-
-/* Common */
-char *_MmsGetTextValue(MmsCode i, int j);
-char *_MmsGetTextValuebyField(int field, int value);
-int _MmsGetTextType(MmsCode i, char *pValue);
-UINT16 _MmsGetBinaryValue(MmsCode i, int j);
-int _MmsGetBinaryType(MmsCode i, UINT16 value);
-UINT8 _MmsGetVersion(MmsMsg *pMsg);
-bool _MmsSetVersion(int majorVer, int minorVer);
-const char *MmsGetTextByCode(MmsCode i, UINT16 code);
-
-
-/* Decoding */
-void _MmsInitHeader();
-void _MmsCleanDecodeBuff(void);
-bool _MmsDecodeInitialize(void);
-void _MmsRegisterDecodeBuffer(char *pInBuff1, char *pInBuffer2, int maxLen);
-void _MmsUnregisterDecodeBuffer(void);
-int _MmsGetDecodeOffset(void);
-
-bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength);
-bool MmsBinaryDecodeContentType(FILE *pFile, char *szFilePath, int totalLength); // for JAVA MMS AppId
-
-bool MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength);
-int MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int totalLength);
-bool MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int headerLen, int totalLength);
-bool MmsBinaryDecodePartBody(FILE *pFile, UINT32 bodyLength, int totalLength);
-bool MmsBinaryDecodeEntries(FILE *pFile, UINT32 *npEntries, int totalLength);
-bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength);
-
-bool MmsBinaryDecodeMultipart(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, int totalLength);
-
-
-/* Encoding */
-void _MmsRegisterEncodeBuffer(char *pInBuff, int maxLen);
-void _MmsUnregisterEncodeBuffer(void);
-int _MmsGetEncodeOffset(void);
-
-bool _MmsEncodeMsg(void);
-bool _MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg);
-bool _MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg);    // just encode MMS Body without any header.
-bool _MmsEncodeAckInd(FILE *pFile, char *szTrID, bool bReportAllowed);
-bool _MmsEncodeNotiRespInd(FILE *pFile, char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed);
-bool _MmsEncodeForwardReq(FILE *pFile, char *szContentLocation, char *szForwardTo, char *szForwardCc, char *szForwardBcc);
-bool _MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
-bool _MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
-
-
-bool MmsBinaryEncodeMsgBody(FILE *pFile, MsgType *pType, MsgBody *pBody, int nPartCount, bool bTemplate);//NEW_TEMPLATE
-
-int MmsBinaryEncodeContentTypeLen(MsgType *pType);
-bool MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLength);
-int MmsBinaryEncodeContentHeaderLen(MsgContentType contentType, MsgType *pType, bool bMultipart);
-bool MmsBinaryEncodeContentHeader(FILE *pFile, MsgContentType contentType, MsgType *pType, bool bMultipart);
-bool MmsBinaryEncodeContentBody(FILE *pFile, MsgBody *pBody);
-bool MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pType, MsgBody *pBody);
-bool MmsBinaryEncodeSendReqHdrwithinBufRegi(FILE *pFile, MmsMsg *pMsg);
-bool MsgWriteDataFromEncodeBuffer(FILE *pFile, char *pInBuffer, int *pPtr, int maxLen, int *pOffset);
-bool MsgLoadDataToDecodeBuffer(FILE *pFile, char **ppBuf, int *pPtr, int *pOffset, char *pInBuf1, char *pInBuf2, int maxLen, int *npRead, int endOfFile);
-bool MsgFreeHeaderAddress(MsgHeaderAddress *pAddr);
-bool MsgCheckFileNameHasInvalidChar(char *szName);
-bool _MsgReplaceInvalidFileNameChar(char *szInText, char replaceChar);
-char *_MsgGetStringUntilDelimiter(char *pszString, char delimiter);
-char *MsgChangeHexString(char *pOrg);
-bool _MsgParseParameter(MsgType *pType, char *pSrc);
-char *_MsgSkipWS(char *s);
-char *__MsgSkipComment(char *s, long trim);
-int _MsgGetCode(MsgHeaderField tableId, char *pStr);
-char *MsgConvertLatin2UTF8FileName(char *pSrc);
-bool _MsgChangeSpace(char *pOrg, char **ppNew);
-void _MsgRemoveFilePath(char *pSrc);
-bool MsgIsUTF8String(unsigned char *szSrc, int nChar);
-bool MsgIsPercentSign(char *pSrc);
-MsgMultipart *MsgAllocMultipart(void);
-bool _MsgInitMsgType(MsgType *pMsgType);
-bool _MsgInitMsgBody(MsgBody *pMsgBody);
-MsgPresentationFactor MsgIsPresentationEx(MsgType *multipartType, char *szStart, MsgContentType typeParam);
-void MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, MsgPresentaionInfo *pPresentationInfo);
-bool MsgIsMultipartRelated(int type);
-bool MsgIsPresentablePart(int type);
-bool MsgIsText(int type);
-bool _MsgFreeBody(MsgBody *pBody, int type);
-bool MsgFreeAttrib(MmsAttrib *pAttrib);
-bool MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody);
-char *MsgResolveContentURI(char *szSrc);
-bool _MsgParsePartHeader(MsgType *pType, const char *pRawData, int nRawData);
-char *MsgRemoveQuoteFromFilename(char *pSrc);
-MmsMsg *MmsGetMsgById(MmsMsgID msgID, bool msgLock);
-bool MsgIsMultipart(int type);
-bool MsgIsHexChar(char *pSrc);
-char _MsgConvertHexValue(char *pSrc);
-int __MsgConvertCharToInt(char ch);
-bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam);
-bool MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2);
-bool MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2);
-bool MsgIsMultipartMixed(int type);
-bool MsgStrcpyWithoutCRLF(char *pOrg, char **ppNew);
-bool __MsgIsInvalidFileNameChar(char ch);
-bool MmsAddrUtilCompareAddr(char *pszAddr1, char *pszAddr2);
-bool _MmsDataUpdateLastStatus(MmsMsg *pMsg);
-
-bool _MsgEncodeBase64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
-void *_MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
-bool _MsgEncodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
-unsigned char *_MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
-bool _MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
-char *_MsgDecodeText(char *pOri);
-char *MsgEncodeText(char *pOri);
-int MsgGetLatin2UTFCodeSize(unsigned char *szSrc, int nChar);
-int MsgLatin5code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
-int MsgGetLatin52UTFCodeSize(unsigned char *szSrc, int nChar);
-int MsgLatin2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
-int MsgLatin7code2UTF(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
-int MsgGetLatin72UTFCodeSize(unsigned char *szSrc, int nChar);
-int MsgUnicode2UTF(unsigned char *des, int outBufSize, unsigned short *szSrc, int nChar);
-int MsgGetUnicode2UTFCodeSize(unsigned short *szSrc, int nChar);
-bool MmsAddrUtilCheckEmailAddress(char *pszAddr);
-bool MmsAddrUtilRemovePlmnString(char *pszAddr);
-int MsgCutUTFString(unsigned char *des, int outBufSize, unsigned char *szSrc, int nChar);
-void MsgMIMERemoveQuote(char *szSrc);
-bool _MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave);
-bool MsgGetTypeByFileName(int *type, char *szFileName);
-bool MmsGetMediaPartData(MsgType *pPartType, MsgBody *pPartBody, FILE *pFile);
-char *MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int msgTypeValue, int msgCharsetValue, int *npRead);
-#ifndef        __SUPPORT_DRM__
-bool MsgMakeFileName(int iMsgType, char *szFileName, int nUntitleIndex);
-#else
-bool MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType, int nUntitleIndex);
-#endif
-bool MsgGetFileNameWithoutExtension(char *szOutputName, char *szName);
-int MmsGetMediaPartCount(msg_message_id_t msgId);
-bool MmsGetMediaPartHeader(int index, MsgType *pHeader);
-bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib *pAttrib);
-bool _MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath);
-
-#ifdef __SUPPORT_DRM__
-void _MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo);
-bool MsgCopyDrmInfo(MsgType *pPartType);
-bool MmsDrm2ConvertMsgBody(char *szOriginFilePath);
-bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath);
-bool MmsDrm2DecodeConvertedMsg(int msgID, char *pszFullPath);
-#endif
-
-bool MmsDebugPrintMulitpartEntry(MsgMultipart *pMultipart, int index);
+#include "MmsPluginCodecTypes.h"
+#include "MmsPluginCodecCommon.h"
+#include "MmsPluginEncode.h"
+#include "MmsPluginDecode.h"
 
 #endif
diff --git a/plugin/mms_plugin/include/MmsPluginCodecCommon.h b/plugin/mms_plugin/include/MmsPluginCodecCommon.h
new file mode 100755 (executable)
index 0000000..9aaa0a8
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*    http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef MMS_PLUGIN_CODEC_COMMON_H
+#define MMS_PLUGIN_CODEC_COMMON_H
+
+#include "MmsPluginCodecTypes.h"
+
+const char *MmsGetTextByCode(MmsCode i, UINT16 code);
+const char *MmsGetTextValue(MmsCode i, int j);
+const char *MmsGetTextValuebyField(int field, int value);
+int MmsGetBinaryType(MmsCode i, UINT16 value);
+int MmsGetTextType(MmsCode i, char *pValue);
+UINT16 MmsGetBinaryValue(MmsCode i, int j);
+
+void *MsgDecodeBase64(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
+bool MsgEncode2Base64(void *pSrc, unsigned long srcLen, unsigned long *len, unsigned char *ret);
+unsigned char *MsgDecodeQuotePrintable(unsigned char *pSrc, unsigned long srcLen, unsigned long *len);
+
+char *MsgDecodeText(char *pOri);
+
+
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginCodecTypes.h b/plugin/mms_plugin/include/MmsPluginCodecTypes.h
new file mode 100755 (executable)
index 0000000..aa0267b
--- /dev/null
@@ -0,0 +1,554 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*    http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef MMS_PLUGIN_CODEC_TYPE_H
+#define MMS_PLUGIN_CODEC_TYPE_H
+
+#include "msg_types.h"
+#include "MsgTypes.h"
+
+#define        MMS_MAJOR_VERSION                       1
+
+#if defined(MMS_V1_1)
+#define        MMS_MINOR_VERSION                       1
+#define        MMS_VERSION                                     0x91
+
+#elif defined(MMS_V1_2)
+#define        MMS_MINOR_VERSION                       2
+#define        MMS_VERSION                                     0x92
+
+#else
+#define        MMS_MINOR_VERSION                       0
+#define        MMS_VERSION                                     0x90
+#endif
+
+#define        MSG_MMS_ENCODE_BUFFER_MAX       (2 * 1024)
+#define        MSG_MMS_DECODE_BUFFER_MAX       (2 * 1024)
+#define        MSB                                                             0x80
+#define        QUOTE                                                   0x7F
+#define        MARK                                                    0x22    // "
+#define        LENGTH_QUOTE                                    0x1F
+#define        MSG_STDSTR_LONG                         0xFF
+#define        INVALID_VALUE                                   -1
+
+#define        MMS_CONTENT_ID_LEN                              100
+#define        MSG_DATE_LEN                                            50
+#define        MSG_SUBJ_LEN                                            40
+#define        MSG_LOCALE_SUBJ_LEN                             (3 * MSG_SUBJ_LEN)
+#define        MSG_LOCAL_TEMP_BUF_SIZE 1024
+#define        MSG_ADDR_LEN                                            MAX_ADDRESS_VAL_LEN
+#define        MMS_LOCALE_RESP_TEXT_LEN                90
+#define        MSG_LOCALE_ADDR_LEN                             (3 * MAX_ADDRESS_VAL_LEN)
+#define        MSG_BOUNDARY_LEN                                        70
+#define        MSG_LOCALE_NAME_LEN                             150
+#define        MSG_LOCALE_FILENAME_LEN_MAX             (3 * 255)
+
+typedef unsigned int                   UINT;
+typedef unsigned long int              UINT32;
+typedef unsigned char                  UINT8;
+typedef unsigned short int             UINT16;
+typedef unsigned long                  ULONG;
+typedef unsigned char                  UCHAR;
+typedef unsigned short                 MCHAR;
+typedef unsigned short                 USHORT;
+
+typedef struct _MsgAddress             MsgAddress;
+typedef struct _MsgBody                        MsgBody;
+typedef struct _MsgMultipart   MsgMultipart;
+typedef struct _MsgMessage             MsgMessage;
+
+typedef enum {
+       MMS_CODE_BCC,
+       MMS_CODE_CC,
+       MMS_CODE_CONTENTLOCATION,
+       MMS_CODE_CONTENTTYPE,
+       MMS_CODE_DATE,
+       MMS_CODE_DELIVERYREPORT,
+       MMS_CODE_DELIVERYTIME,
+       MMS_CODE_EXPIRYTIME,
+       MMS_CODE_FROM,
+       MMS_CODE_MSGCLASS,
+       MMS_CODE_MSGID,
+       MMS_CODE_MSGTYPE,
+       MMS_CODE_VERSION,
+       MMS_CODE_MSGSIZE,
+       MMS_CODE_PRIORITY,
+       MMS_CODE_READREPLY,
+       MMS_CODE_REPORTALLOWED,
+       MMS_CODE_RESPONSESTATUS,
+       MMS_CODE_RETRIEVESTATUS,                /* Add by MMSENC v1.1 */
+       MMS_CODE_RESPONSETEXT,
+       MMS_CODE_RETRIEVETEXT,                  /* Add by MMSENC v1.1 */
+       MMS_CODE_SENDERVISIBILLITY,
+       MMS_CODE_MSGSTATUS,
+       MMS_CODE_SUBJECT,
+       MMS_CODE_TO,
+       MMS_CODE_TRID,
+
+       /* Add by MMSENC v1.1 */
+       MMS_CODE_READSTATUS,
+       MMS_CODE_REPLYCHARGING,
+       MMS_CODE_REPLYCHARGINGDEADLINE,
+       MMS_CODE_REPLYCHARGINGID,
+       MMS_CODE_REPLYCHARGINGSIZE,
+       MMS_CODE_PREVIOUSLYSENTBY,
+       MMS_CODE_PREVIOUSLYSENTDATE,
+
+       MMS_CODE_TRANSFERENCODING,
+       MMS_CODE_DISPOSITION,
+       MMS_CODE_CONTENT_ID
+} MmsFieldCode;
+
+enum {
+       MMS_BODYHDR_TRANSFERENCODING,
+       MMS_BODYHDR_DISPOSITION,
+       MMS_BODYHDR_CONTENTID,
+       MMS_BODYHDR_CONTENTLOCATION,
+       MMS_BODYHDR_X_OMA_DRM_SEPARATE_DELIVERY,        // DRM RO WAITING
+};
+
+typedef enum {
+       //code
+       MmsCodeFieldCode,
+       MmsCodeParameterCode,
+       MmsCodeMsgBodyHeaderCode,
+
+       //Data
+       MmsCodeMsgType,
+       MmsCodeDeliveryReport,
+       MmsCodeTimeType,
+       MmsCodeMsgClass,
+       MmsCodePriority,
+       MmsCodeResponseStatus,
+       MmsCodeRetrieveStatus,
+       MmsCodeReadReply,
+       MmsCodeReportAllowed,
+       MmsCodeSenderVisibility,
+       MmsCodeMsgStatus,
+       MmsCodeReadStatus,
+       MmsCodeAddressType,
+       MmsCodeCharSet,
+       MmsCodeReplyCharging,
+
+       MmsCodeContentType,
+
+       MmsCodeMsgDisposition,
+       MmsCodeContentTransferEncoding
+} MmsCode;
+
+typedef enum {
+       MMS_DATATYPE_NONE = -1,
+       MMS_DATATYPE_READ = 0,
+       MMS_DATATYPE_SENT = 1,
+       MMS_DATATYPE_NOTIFY = 2,
+       MMS_DATATYPE_UNSENT = 3,
+       MMS_DATATYPE_DRAFT = 4,
+       MMS_DATATYPE_SENDING = 6,
+       MMS_DATATYPE_RETRIEVING = 7,
+       MMS_DATATYPE_UNRETV = 8,
+       MMS_DATATYPE_TEMPLATE = 9,
+       MMS_DATATYPE_DRM_RO_WAITING = 10        // DRM RO WAITING
+} MmsDataType;
+
+typedef enum {
+       MMS_MSGTYPE_ERROR = -1, // error return in Get method
+       MMS_MSGTYPE_SEND_REQ = 0,       // default
+       MMS_MSGTYPE_SEND_CONF = 1,
+       MMS_MSGTYPE_NOTIFICATION_IND = 2,
+       MMS_MSGTYPE_NOTIFYRESP_IND = 3,
+       MMS_MSGTYPE_RETRIEVE_CONF = 4,
+       MMS_MSGTYPE_ACKNOWLEDGE_IND = 5,
+       MMS_MSGTYPE_DELIVERY_IND = 6,
+       MMS_MSGTYPE_READREC_IND = 7,
+       MMS_MSGTYPE_READORG_IND = 8,
+       MMS_MSGTYPE_FORWARD_REQ = 9,
+       MMS_MSGTYPE_FORWARD_CONF = 10,
+       MMS_MSGTYPE_READ_REPLY = 11,    // for internal use
+       MMS_MSGTYPE_MAX
+} MmsMsgType;
+
+typedef enum {
+       MMS_PRIORITY_ERROR = -1,                        // error return in Get method
+       MMS_PRIORITY_LOW = 0,                   // default
+       MMS_PRIORITY_NORMAL = 1,
+       MMS_PRIORITY_HIGH = 2
+} MmsPriority;
+
+typedef enum {
+       MMS_SENDER_VISIBLE_ERROR = -1,  // error return in Get method
+       MMS_SENDER_SHOW = 0,
+       MMS_SENDER_HIDE = 1
+} MmsSenderVisible;
+
+typedef enum {
+       MMS_REPORT_ERROR = -1,  // error return in Get method
+       MMS_REPORT_YES = 0,
+       MMS_REPORT_NO = 1
+} MmsReport;
+
+typedef enum {
+       MMS_REPORTALLOWED_ERROR = -1,   // error return in Get method
+       MMS_REPORTALLOWED_YES = 0,
+       MMS_REPORTALLOWED_NO = 1
+} MmsReportAllowed;
+
+typedef enum {
+       MMS_RECEIVE_READ_REPORT_ALLOWED,
+       MMS_RECEIVE_READ_REPORT_PROMPT,
+       MMS_RECEIVE_READ_REPORT_NOT_ALLOWED,
+} MmsRecvReadReportType ;
+
+typedef enum {
+       MMS_MSGSTATUS_NONE = -1,        // backward compatibility
+       MMS_MSGSTATUS_ERROR = -1,       // error return in Get method
+       MMS_MSGSTATUS_EXPIRED = 0,      // This value SHOULD not be used in the M-NotifyResp.ind PDU.
+       MMS_MSGSTATUS_RETRIEVED = 1,
+       MMS_MSGSTATUS_REJECTED = 2,
+       MMS_MSGSTATUS_DEFERRED = 3,
+       MMS_MSGSTATUS_UNRECOGNISED = 4, // This value SHALL not be used in the M-Delivery.ind PDU.
+       MMS_MSGSTATUS_INDETERMINATE = 5,
+       MMS_MSGSTATUS_FORWARDED = 6,
+       MMS_MSGSTATUS_UNREACHABLE = 7
+} MmsMsgStatus;
+
+typedef enum {
+       MMS_READSTATUS_NONE = -1,                       // no touch status
+       MMS_IS_READ = 0,
+       MMS_IS_DELETED = 1      // Deleted without being read
+} MmsReadStatus;
+
+typedef enum {
+       MMS_ADDRESS_PRESENT_TOKEN,
+       MMS_INSERT_ADDRESS_TOKEN
+} MmsAddressType;
+
+typedef enum {
+       MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS,
+       MSG_PARAM_REPORT_TYPE_NUM,
+       MSG_PARAM_REPORT_TYPE_UNKNOWN,
+} MsgParamReportType;
+
+/* Response status */
+typedef enum {
+       MMS_RESPSTATUS_ERROR = -1,      // error return in Get method
+       MMS_RESPSTATUS_OK = 0,  // default value
+       MMS_RESPSTAUTS_ERROR_UNSPECIFIED = 1,
+       MMS_RESPSTAUTS_ERROR_SERVICEDENIED = 2,
+       MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT = 3,
+       MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED = 4,
+       MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND = 5,
+       MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM = 6,
+       MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED = 7,
+       MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE = 8,
+
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE = 9,
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED = 10,
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 11,
+       MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM = 12,
+
+       MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE = 13,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED = 14,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 15,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED = 16,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 17,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED = 18,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET = 19,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED = 20,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED = 21,
+       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED = 22
+} MmsResponseStatus;
+
+typedef enum {
+       MMS_RETRSTATUS_ERROR = -1,      // error return in Get method
+       MMS_RETRSTATUS_OK = 0,
+       MMS_RETRSTATUS_TRANSIENT_FAILURE = 1,
+       MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND = 2,
+       MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM = 3,
+       MMS_RETRSTATUS_PERMANENT_FAILURE = 4,
+       MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED = 5,
+       MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND = 6,
+       MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT = 7
+} MmsRetrieveStatus;
+
+typedef enum {
+       MMS_REPLY_NONE = -1,    // error return in Get method
+       MMS_REPLY_REQUESTED = 0,
+       MMS_REPLY_REQUESTED_TEXT_ONLY = 1,
+       MMS_REPLY_ACCEPTED = 2,
+       MMS_REPLY_ACCEPTED_TEXT_ONLY = 3
+} MmsReplyChargeType;
+
+typedef enum {
+       MMS_STATUS_ERROR = -1,  // error return in Get method
+       MMS_STATUS_INITIAL = 0,
+       MMS_STATUS_REQUESTING = 1,
+       MMS_STATUS_SUCCESS = 2,
+       MMS_STATUS_FAIL = 3,
+       MMS_STATUS_NUM = 4,
+} MmsDataStatus;
+
+typedef enum {
+       MMS_EDIT_STYLE_THIS_PAGE = 0,
+       MMS_EDIT_STYLE_ALL_PAGE,
+} MmsEditStyleMode;
+
+typedef enum {
+       MMS_SPECIAL_MSG_TYPE_NONE = 0,
+       MMS_SPECIAL_MSG_TYPE_SYSTEM_TEMPLATE,   // system template .
+       MMS_SPECIAL_MSG_TYPE_VOICE_MESSAGE,             //voice message service
+
+       MMS_SPECIAL_MSG_TYPE_VDF_POSTCARD,              //postcard service, or Generic Postcard Service
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT1,     //Stickers Service
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT2,     //Photo 10x15
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT3,     //8 Photos
+       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT4,     // 4 Photos
+} MmsSpecialMsgType;
+
+typedef enum {
+       MMS_MM_CLASS_TEXT,
+       MMS_MM_CLASS_IMAGE_BASIC,
+       MMS_MM_CLASS_IMAGE_RICH,
+       MMS_MM_CLASS_VIDEO_BASIC,
+       MMS_MM_CLASS_VIDEO_RICH,
+       MMS_MM_CLASS_MEGAPIXEL,
+       MMS_MM_CLASS_CONTENT_BASIC,
+       MMS_MM_CLASS_CONTENT_RICH,
+       MMS_MM_CLASS_OTHER
+} MmsUiMmClass;
+
+typedef enum {
+       MMS_MSGCLASS_ERROR = -1,        // error return in Get method
+       MMS_MSGCLASS_PERSONAL = 0,      // default
+       MMS_MSGCLASS_ADVERTISEMENT = 1,
+       MMS_MSGCLASS_INFORMATIONAL = 2,
+       MMS_MSGCLASS_AUTO = 3
+} MmsMsgClass;
+
+
+/*==================================================================================================
+                                                       Structures
+==================================================================================================*/
+
+typedef struct {
+       MmsReplyChargeType chargeType;
+       MmsTimeStruct deadLine;
+       int chargeSize;
+       char szChargeID[MMS_MSG_ID_LEN + 1];
+} MmsReplyCharge;
+
+typedef struct _MmsMsgMultiStatus {
+       char szTo[MAX_ADDRESS_VAL_LEN + 1];
+       bool bDeliveryReportIsRead;
+       bool bDeliveyrReportIsLast;
+       msg_delivery_report_status_t msgStatus;
+       UINT32 handledTime;
+       bool bReadReplyIsRead;
+       bool bReadReplyIsLast;
+       msg_read_report_status_t readStatus;
+       UINT32 readTime;
+
+       struct _MmsMsgMultiStatus *pNext;
+} MmsMsgMultiStatus;
+
+typedef struct _MMS_ATTRIB_S {
+       MimeType contentType;
+       MmsDataType dataType;
+       UINT32 date;
+       UINT8 version;
+
+       char szFrom[MSG_LOCALE_ADDR_LEN + 11];          //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
+       char *szTo;
+       char *szCc;
+       char *szBcc;
+
+       MmsPriority priority;
+
+       MmsReplyCharge replyCharge;
+       bool bChargingMsgReplied;
+
+       bool bHideAddress;
+       bool bAskDeliveryReport;
+       bool bReportAllowed;
+       MmsRecvReadReportType readReportAllowedType;
+
+       bool bAskReadReply;
+       bool bRead;
+
+       MmsRecvReadReportSendStatus readReportSendStatus;
+
+       bool bReadReportSent;
+
+       bool bLeaveCopy;
+       bool bUseExpiryCustomTime;              // for expiry custom time
+       bool bUseDeliveryCustomTime;    // for expiry custom time
+       MmsEditStyleMode editStyleMode;                 //editStyle on All Page
+
+       MmsSpecialMsgType specialMsgType;                       // instead of bPostcard
+
+#ifdef __SUPPORT_DRM__
+       MsgDrmType drmType;
+       int roWaitingTimerMax;          // DRM RO WAITING
+       char *pszDrmData;                       // DRM Data to draw mailbox icon
+#endif
+
+       int msgSize;
+       MmsMsgClass msgClass;
+       MmsTimeStruct expiryTime;
+       MmsTimeStruct expiryCustomTime;
+       MmsTimeStruct deliveryTime;
+       MmsTimeStruct deliveryCustomTime;
+
+       //for ReadMsg, When Sending notifyResp.ind
+       msg_delivery_report_status_t msgStatus;
+
+       MmsResponseStatus responseStatus;
+       MmsRetrieveStatus retrieveStatus;
+       char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+       char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+
+       MmsMsgMultiStatus *pMultiStatus;
+       bool bRetrieveNow;
+} MmsAttrib;
+
+typedef struct _MsgContentParam {
+       int charset;
+       char szBoundary[MSG_BOUNDARY_LEN + 1];
+       char szFileName[MSG_FILENAME_LEN_MAX + 1];
+       char szName[MSG_LOCALE_FILENAME_LEN_MAX + 1];
+
+#ifdef FEATURE_JAVA_MMS
+       char *szApplicationID;
+       char *szReplyToApplicationID;
+#endif
+
+       int type;
+       void *pPresentation;
+       char szStart[MSG_MSG_ID_LEN + 1];
+       char szStartInfo[MSG_MSG_ID_LEN + 1];
+
+       MsgParamReportType reportType; //only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
+} MsgContentParam;
+
+#ifdef __SUPPORT_DRM__
+typedef struct _MsgDRMInfo {
+       MsgDrmType drmType;
+       MimeType contentType;
+       char *szContentURI;
+       char *szContentName;
+       char *szContentDescription;
+       char *szContentVendor;
+       char *szRightIssuer;
+       char *szDrm2FullPath;
+       int roWaitingTimerMax;          // DRM RO WAITING
+       bool bFwdLock;
+       char *pszContentType;
+       bool bNoRingTone;
+       bool bNoScreen;
+} MsgDRMInfo;
+#endif
+
+typedef struct _MsgType {
+       int offset;
+       int size;
+       int contentSize;
+       int section;
+       int type;
+#ifdef __SUPPORT_DRM__
+       MsgDRMInfo drmInfo;
+#endif
+       int encoding;
+       int disposition;
+       char szContentID[MSG_MSG_ID_LEN + 1];
+       char szContentLocation[MSG_MSG_ID_LEN + 1];
+       char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
+
+       char szContentRepPos[30];
+       char szContentRepSize[30];
+       char szContentRepIndex[8];
+#ifdef __SUPPORT_DRM__
+       int nDrmConvertedStatus;
+#endif
+
+       MsgContentParam param;
+} MsgType;
+
+struct _MsgAddress {
+       int type;                                       //MSG_ADDR_TYPE_PHONE/EMAIL/IPV4/IPV6
+       int recipientType;                      // TO, CC, BCC
+       char szName[MSG_LOCALE_NAME_LEN + 1];
+       char szAddr[MSG_ADDR_LEN + 1];
+       MsgAddress *pNext;
+       bool bDoNotShow;                                // temporary clip
+
+       // sorting
+       ULONG uLastRecentTime;          // last recent time save item
+       ULONG uMostUseCount;                    // most use count item.
+       int index;                                      // index sorting..
+};
+
+typedef struct _MsgHeader {
+       MsgAddress *pFrom;
+       MsgAddress *pTo;
+       MsgAddress *pCC;
+       char szReturnPath[MSG_ADDR_LEN + 1];
+       char szDate[MSG_DATE_LEN];
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
+       char szMsgID[MSG_MSG_ID_LEN + 1];
+} MsgHeader;
+
+struct _MsgBody {
+       int offset;
+       int size;
+       char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
+       MsgType presentationType;
+       MsgBody *pPresentationBody;
+
+       union {
+               char *pText;
+               void *pBinary;
+               MsgMultipart *pMultipart;
+               MsgMessage *pMessage;
+       } body;
+};
+
+struct _MsgMultipart {
+       MsgType type;
+       MsgBody *pBody;
+       MsgMultipart *pNext;
+};
+
+struct _MsgMessage {
+       MsgHeader header;
+       MsgType type;
+       MsgBody *pBody;
+};
+
+typedef struct _MMS_MESSAGE_S {
+       MmsAttrib mmsAttrib;
+       msg_message_id_t msgID;
+       int mailbox;            // mailbox type,MMS_MAILBOX_XXX
+       char szFileName[MSG_FILENAME_LEN_MAX];
+       char szTrID[MMS_TR_ID_LEN + 1];
+       char szMsgID[MMS_MSG_ID_LEN + 1];
+       char szForwardMsgID[MMS_MSG_ID_LEN + 1];
+       char szContentLocation[MMS_LOCATION_LEN + 1];
+       int nPartCount;
+       MsgType msgType;
+       MsgBody msgBody;
+} MmsMsg;
+
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginData.h b/plugin/mms_plugin/include/MmsPluginData.h
deleted file mode 100755 (executable)
index e15a223..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-* Copyright 2012  Samsung Electronics Co., Ltd
-*
-* Licensed under the Flora License, Version 1.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*    http://www.tizenopensource.org/license
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#define        MMS_INVALID_MSG_ID      -1
-
-/* Mailbox type */
-#define MSG_UI_MAILBOX_MY_FOLDER_MAX   10
-
-typedef enum {
-       MSG_MAILBOX_ROOT                = -1,
-       MSG_MAILBOX_WRITE               = 0,
-       MSG_MAILBOX_INBOX               = 1,
-       MSG_MAILBOX_DRAFT               = 2,
-       MSG_MAILBOX_SENT                = 3,
-       MSG_MAILBOX_MAILBOX             = 4,
-#ifdef _MSG_DB_INCLUDE_OUTBOX
-       MSG_MAILBOX_OUTBOX              = 5,
-#endif
-       MSG_MAILBOX_TEMPLATE            = 6,            //NEW_TEMPLATE
-       MSG_MAILBOX_MYFOLDER            = 7,
-       MSG_MAILBOX_MYFOLDER_LIST       = 8,
-
-
-       MSG_MAILBOX_PRESET                      = (MSG_MAILBOX_MYFOLDER_LIST  + MSG_UI_MAILBOX_MY_FOLDER_MAX),
-
-       MSG_MAILBOX_NONE
-
-} MsgMailboxType;
-
diff --git a/plugin/mms_plugin/include/MmsPluginDecode.h b/plugin/mms_plugin/include/MmsPluginDecode.h
new file mode 100755 (executable)
index 0000000..aedb5e5
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*    http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef MMS_PLUGIN_DECODE_H
+#define MMS_PLUGIN_DECODE_H
+
+#include "MmsPluginMessage.h"
+
+typedef struct _MsgHeaderAddress       MsgHeaderAddress;
+
+typedef int MmsMsgID;
+
+/*==================================================================================================
+                                                       Structures
+==================================================================================================*/
+typedef enum {
+       MSG_PRESENTATION_NONE = -1,
+       MSG_PRESENTATION_FIRSTPART,             //Content-type == type parameter
+       MSG_PRESENTATION_TYPE_BASE,             //Content-type == type parameter
+       MSG_PRESENTATION_LOCATION,              //Content-Location == start parameter
+       MSG_PRESENTATION_ID,                    //Content-ID == start parameter
+} MsgPresentationFactor;
+
+typedef struct {
+       char *pData;
+       UINT32 length;
+} EncodedPData;
+
+typedef struct {
+       MsgPresentationFactor factor;
+       MsgMultipart *pPrevPart;
+       MsgMultipart *pCurPresentation;
+} MsgPresentaionInfo;
+
+struct _MsgHeaderAddress {
+       char *szAddr;
+       MsgHeaderAddress *pNext;
+};
+
+// for Decoding & Encoding
+typedef struct {
+       bool bActive;
+       char *pszOwner;
+       int msgID;              // if noti.ind, msgID is -1.
+
+       MmsMsgType type;
+       char szTrID[MMS_TR_ID_LEN+1];
+       UINT8 version;
+       UINT32 date;
+
+       MsgHeaderAddress *pFrom;                //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
+       MsgHeaderAddress *pTo;
+       MsgHeaderAddress *pCc;
+       MsgHeaderAddress *pBcc;
+       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
+       MmsResponseStatus responseStatus;
+       MmsRetrieveStatus retrieveStatus;
+       char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+       char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
+
+       MmsMsgClass msgClass;
+       MmsTimeStruct expiryTime;
+       MmsTimeStruct deliveryTime;
+       MmsPriority priority;
+       MmsSenderVisible hideAddress;
+       MmsReport deliveryReport;
+       MmsReport readReply;
+       MmsReportAllowed reportAllowed;
+       char szContentLocation[MMS_LOCATION_LEN + 1];
+
+       msg_delivery_report_status_t msgStatus;
+       msg_read_report_status_t readStatus;
+
+       MmsReplyCharge replyCharge;
+
+       // only used at Decoding module
+       char szMsgID[MMS_MSG_ID_LEN + 1];
+       UINT32 msgSize;
+
+#ifdef __SUPPORT_DRM__
+       MsgDrmType drmType;
+#endif
+
+       // dependent to Client implementation
+       MsgType msgType;
+       MsgBody msgBody;
+} MmsHeader;
+
+extern MmsHeader mmsHeader;
+
+/* Decoding */
+void MmsInitHeader();
+void MmsRegisterDecodeBuffer();
+void MmsUnregisterDecodeBuffer(void);
+bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength);
+bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength);
+bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath);
+
+bool MsgFreeBody(MsgBody *pBody, int type);
+bool MsgFreeAttrib(MmsAttrib *pAttrib);
+
+char *MsgChangeHexString(char *pOrg);
+char *MsgResolveContentURI(char *szSrc);
+char *MsgRemoveQuoteFromFilename(char *pSrc);
+bool MsgIsMultipart(int type);
+bool MmsAddrUtilCompareAddr(char *pszAddr1, char *pszAddr2);
+bool MmsDataUpdateLastStatus(MmsMsg *pMsg);
+bool MmsAddrUtilRemovePlmnString(char *pszAddr);
+bool MsgGetTypeByFileName(int *type, char *szFileName);
+bool MsgGetFileNameWithoutExtension(char *szOutputName, char *szName);
+int MmsGetMediaPartCount(msg_message_id_t msgId);
+bool MmsGetMediaPartHeader(int index, MsgType *pHeader);
+bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib *pAttrib);
+
+#ifdef __SUPPORT_DRM__
+void MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo);
+bool MsgCopyDrmInfo(MsgType *pPartType);
+bool MmsDrm2ConvertMsgBody(char *szOriginFilePath);
+bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath);
+#endif
+
+#endif
diff --git a/plugin/mms_plugin/include/MmsPluginEncode.h b/plugin/mms_plugin/include/MmsPluginEncode.h
new file mode 100755 (executable)
index 0000000..b2de2d5
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*    http://www.tizenopensource.org/license
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef MMS_PLUGIN_ENCODE_H
+#define MMS_PLUGIN_ENCODE_H
+
+#include "MmsPluginCodecTypes.h"
+#include "MmsPluginCodecCommon.h"
+#include "MmsPluginMessage.h"
+
+/* Encoding */
+void MmsRegisterEncodeBuffer(char *pInBuff, int maxLen);
+void MmsUnregisterEncodeBuffer(void);
+
+bool MmsEncodeSendReq(FILE *pFile, MmsMsg *pMsg);
+bool MmsEncodeTemplate(FILE *pFile, MmsMsg *pMsg);
+bool MmsEncodeAckInd(FILE *pFile, char *szTrID, bool bReportAllowed);
+bool MmsEncodeNotiRespInd(FILE *pFile, char *szTrID, msg_delivery_report_status_t iStatus, bool bReportAllowed);
+
+bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
+bool MmsEncodeReadReport11(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t mmsReadStatus);
+
+#endif
index 10ef8ff..2dce303 100755 (executable)
 #include "MsgMmsTypes.h"
 #include "MsgSettingTypes.h"
 #include "MmsPluginMIME.h"
-#include "MsgMmsTypes.h"
-
+#include "MmsPluginCodec.h"
 /*==================================================================================================
                                                        DEFINES
 ==================================================================================================*/
-#define                MMS_CONTENT_ID_LEN                              100
-#define                MMS_LOCALE_RESP_TEXT_LEN                90
 #define                MMS_TEXT_LEN                                            2000
 #define                MMS_READ_REPORT_STRING_READ             "Read:"
 #define                MMS_READ_REPORT_STRING_DELETED  "Deleted:"
 
 #define                MSG_ATTACH_MAX          20
-#define                MSG_LINE_LEN                                            1024
-#define                MSG_SUBJ_LEN                                            40
-#define                MSG_DATE_LEN                                            50
-#define                MSG_BOUNDARY_LEN                                        70
-#define                MSG_LOCALE_NAME_LEN                             150
-#define                MSG_LOCALE_SUBJ_LEN                             (3 * MSG_SUBJ_LEN)
-#define                MSG_ADDR_LEN                                            MAX_ADDRESS_VAL_LEN
-#define                MSG_LOCALE_ADDR_LEN                             (3 * MAX_ADDRESS_VAL_LEN)
-#define                MSG_LOCALE_FILENAME_LEN_MAX             (3 * 255)
-#define                MSG_LOCALE_SIGN_LEN                                     (3 * MAX_SIGN_VAL_LEN)
-#define                MSG_MAILBOX_NAME_LEN            10
-
-#define                MsgContentType                                          MimeType
-#define                MsgRecipientType                                        msg_recipient_type_t
-#define                MMS_VERSION                                             0x92
 #define                MSG_STR_ADDR_DELIMETER                  ";"
 #define                MSG_CH_ADDR_DELIMETER                   ';'
-#ifdef __SUPPORT_DRM__
-#define                MSG_DRM_MAX_CMD                                 (2 * 1024)
-#endif
-
-#define                MSG_MMS_DECODE_BUFFER_MAX       (2 * 1024)
-#define                MSG_MMS_ENCODE_BUFFER_MAX       (2 * 1024)
-
-/*==================================================================================================
-                                                       TYPES
-==================================================================================================*/
-typedef unsigned int                   UINT;
-typedef unsigned long int              UINT32;
-typedef unsigned char                  UINT8;
-typedef unsigned short int             UINT16;
-typedef unsigned long                  ULONG;
-typedef unsigned char                  UCHAR;
-typedef unsigned short                 MCHAR;
-typedef unsigned short                 USHORT;
-
-typedef int                                            MmsMsgID;
-
-typedef        struct _MsgAddress      MsgAddress;
-typedef struct _MsgBody                MsgBody;
-typedef struct _MsgMultipart   MsgMultipart;
-typedef struct _MsgMessage     MsgMessage;
-
-typedef struct _MsgHeaderAddress       MsgHeaderAddress;
-
-/*==================================================================================================
-                                                       ENUMS
-==================================================================================================*/
-
-typedef enum {
-       MMS_DATATYPE_NONE = -1,
-       MMS_DATATYPE_READ = 0,
-       MMS_DATATYPE_SENT = 1,
-       MMS_DATATYPE_NOTIFY = 2,
-       MMS_DATATYPE_UNSENT = 3,
-       MMS_DATATYPE_DRAFT = 4,
-       MMS_DATATYPE_SENDING = 6,
-       MMS_DATATYPE_RETRIEVING = 7,
-       MMS_DATATYPE_UNRETV = 8,
-       MMS_DATATYPE_TEMPLATE = 9,
-       MMS_DATATYPE_DRM_RO_WAITING = 10        // DRM RO WAITING
-
-} MmsDataType;
-
-typedef        enum {
-       MMS_MSGTYPE_ERROR = -1, // error return in Get method
-       MMS_MSGTYPE_SEND_REQ = 0,       // default
-       MMS_MSGTYPE_SEND_CONF = 1,
-       MMS_MSGTYPE_NOTIFICATION_IND = 2,
-       MMS_MSGTYPE_NOTIFYRESP_IND = 3,
-       MMS_MSGTYPE_RETRIEVE_CONF = 4,
-       MMS_MSGTYPE_ACKNOWLEDGE_IND = 5,
-       MMS_MSGTYPE_DELIVERY_IND = 6,
-       MMS_MSGTYPE_READREC_IND = 7,
-       MMS_MSGTYPE_READORG_IND = 8,
-       MMS_MSGTYPE_FORWARD_REQ = 9,
-       MMS_MSGTYPE_FORWARD_CONF = 10,
-       MMS_MSGTYPE_READ_REPLY = 11,    // for internal use
-
-       MMS_MSGTYPE_MAX
-} MmsMsgType;
-
-typedef        enum {
-       MMS_PRIORITY_ERROR = -1,                        // error return in Get method
-       MMS_PRIORITY_LOW = 0,                   // default
-       MMS_PRIORITY_NORMAL = 1,
-       MMS_PRIORITY_HIGH = 2
-} MmsPriority;
-
-
-typedef enum {
-       MMS_SENDER_VISIBLE_ERROR = -1,  // error return in Get method
-       MMS_SENDER_SHOW = 0,
-       MMS_SENDER_HIDE = 1
-} MmsSenderVisible;
-
-
-typedef        enum {
-       MMS_REPORT_ERROR = -1,  // error return in Get method
-       MMS_REPORT_YES = 0,
-       MMS_REPORT_NO = 1
-} MmsReport;
-
-
-typedef enum {
-       MMS_REPORTALLOWED_ERROR = -1,   // error return in Get method
-       MMS_REPORTALLOWED_YES = 0,
-       MMS_REPORTALLOWED_NO = 1
-} MmsReportAllowed;
-
-
-typedef enum {
-       MMS_RECEIVE_READ_REPORT_ALLOWED,
-       MMS_RECEIVE_READ_REPORT_PROMPT,
-       MMS_RECEIVE_READ_REPORT_NOT_ALLOWED,
-} MmsRecvReadReportType ;
-
-
-typedef enum {
-       MMS_MSGSTATUS_NONE = -1,        // backward compatibility
-       MMS_MSGSTATUS_ERROR = -1,       // error return in Get method
-       MMS_MSGSTATUS_EXPIRED = 0,      // This value SHOULD not be used in the M-NotifyResp.ind PDU.
-       MMS_MSGSTATUS_RETRIEVED = 1,
-       MMS_MSGSTATUS_REJECTED = 2,
-       MMS_MSGSTATUS_DEFERRED = 3,
-       MMS_MSGSTATUS_UNRECOGNISED = 4, // This value SHALL not be used in the M-Delivery.ind PDU.
-       MMS_MSGSTATUS_INDETERMINATE = 5,
-       MMS_MSGSTATUS_FORWARDED = 6,
-       MMS_MSGSTATUS_UNREACHABLE = 7
-} MmsMsgStatus;
-
-
-typedef        enum {
-       MMS_READSTATUS_NONE = -1,                       // no touch status
-       MMS_IS_READ = 0,
-       MMS_IS_DELETED = 1      // Deleted without being read
-} MmsReadStatus;
-
-
-typedef enum {
-       MMS_ADDRESS_PRESENT_TOKEN,
-       MMS_INSERT_ADDRESS_TOKEN
-} MmsAddressType;
-
-typedef enum {
-       MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS,
-       MSG_PARAM_REPORT_TYPE_NUM,
-       MSG_PARAM_REPORT_TYPE_UNKNOWN,
-} MsgParamReportType;
-
-/* Response status */
-typedef        enum {
-       MMS_RESPSTATUS_ERROR = -1,      // error return in Get method
-       MMS_RESPSTATUS_OK = 0,  // default value
-       MMS_RESPSTAUTS_ERROR_UNSPECIFIED = 1,
-       MMS_RESPSTAUTS_ERROR_SERVICEDENIED = 2,
-       MMS_RESPSTAUTS_ERROR_MESSAGEFORMATCORRUPT = 3,
-       MMS_RESPSTAUTS_ERROR_SENDINGADDRESSUNRESOLVED = 4,
-       MMS_RESPSTAUTS_ERROR_MESSAGENOTFOUND = 5,
-       MMS_RESPSTAUTS_ERROR_NETWORKPROBLEM = 6,
-       MMS_RESPSTAUTS_ERROR_CONTENTNOTACCEPTED = 7,
-       MMS_RESPSTAUTS_ERROR_UNSUPPORTEDMESSAGE = 8,
-
-       MMS_RESPSTAUTS_ERROR_TRANSIENT_FAILURE = 9,
-       MMS_RESPSTAUTS_ERROR_TRANSIENT_SENDING_ADDRESS_UNRESOLVED = 10,
-       MMS_RESPSTAUTS_ERROR_TRANSIENT_MESSAGE_NOT_FOUND = 11,
-       MMS_RESPSTAUTS_ERROR_TRANSIENT_NETWORK_PROBLEM = 12,
-
-       MMS_RESPSTAUTS_ERROR_PERMANENT_FAILURE = 13,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_SERVICE_DENIED = 14,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_FORMAT_CORRUPT = 15,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_SENDING_ADDRESS_UNRESOLVED = 16,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_MESSAGE_NOT_FOUND = 17,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_CONTENT_NOT_ACCEPTED = 18,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_LIMITATIONS_NOT_MET = 19,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_REQUEST_NOT_ACCEPTED = 20,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_FORWARDING_DENIED = 21,
-       MMS_RESPSTAUTS_ERROR_PERMANENT_REPLY_CHARGING_NOT_SUPPORTED = 22
-} MmsResponseStatus;
-
-
-typedef        enum {
-       MMS_RETRSTATUS_ERROR = -1,      // error return in Get method
-       MMS_RETRSTATUS_OK = 0,
-       MMS_RETRSTATUS_TRANSIENT_FAILURE = 1,
-       MMS_RETRSTATUS_TRANSIENT_MESSAGE_NOT_FOUND = 2,
-       MMS_RETRSTATUS_TRANSIENT_NETWORK_PROBLEM = 3,
-       MMS_RETRSTATUS_PERMANENT_FAILURE = 4,
-       MMS_RETRSTATUS_PERMANENT_SERVICE_DENIED = 5,
-       MMS_RETRSTATUS_PERMANENT_MESSAGE_NOT_FOUND = 6,
-       MMS_RETRSTATUS_PERMANENT_CONTENT_UNSUPPORT = 7
-} MmsRetrieveStatus;
-
-
-typedef enum {
-       MMS_REPLY_NONE = -1,    // error return in Get method
-       MMS_REPLY_REQUESTED = 0,
-       MMS_REPLY_REQUESTED_TEXT_ONLY = 1,
-       MMS_REPLY_ACCEPTED = 2,
-       MMS_REPLY_ACCEPTED_TEXT_ONLY = 3
-} MmsReplyChargeType;
-
-
-typedef enum {
-       MMS_STATUS_ERROR = -1,  // error return in Get method
-       MMS_STATUS_INITIAL = 0,
-       MMS_STATUS_REQUESTING = 1,
-       MMS_STATUS_SUCCESS = 2,
-       MMS_STATUS_FAIL = 3,
-       MMS_STATUS_NUM = 4,
-} MmsDataStatus;
-
-
-typedef enum {
-       MMS_EDIT_STYLE_THIS_PAGE = 0,
-       MMS_EDIT_STYLE_ALL_PAGE,
-} MmsEditStyleMode;
-
-typedef enum {
-       MMS_SPECIAL_MSG_TYPE_NONE = 0,
-       MMS_SPECIAL_MSG_TYPE_SYSTEM_TEMPLATE,   // system template .
-       MMS_SPECIAL_MSG_TYPE_VOICE_MESSAGE,             //voice message service
-
-       MMS_SPECIAL_MSG_TYPE_VDF_POSTCARD,              //postcard service, or Generic Postcard Service
-       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT1,     //Stickers Service
-       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT2,     //Photo 10x15
-       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT3,     //8 Photos
-       MMS_SPECIAL_MSG_TYPE_POSTCARD_EXT4,     // 4 Photos
-} MmsSpecialMsgType;
-
-typedef enum {
-       MMS_MM_CLASS_TEXT,
-       MMS_MM_CLASS_IMAGE_BASIC,
-       MMS_MM_CLASS_IMAGE_RICH,
-       MMS_MM_CLASS_VIDEO_BASIC,
-       MMS_MM_CLASS_VIDEO_RICH,
-       MMS_MM_CLASS_MEGAPIXEL,
-       MMS_MM_CLASS_CONTENT_BASIC,
-       MMS_MM_CLASS_CONTENT_RICH,
-       MMS_MM_CLASS_OTHER
-} MmsUiMmClass;
-
-typedef enum {
-       MMS_MSGCLASS_ERROR = -1,        // error return in Get method
-       MMS_MSGCLASS_PERSONAL = 0,      // default
-       MMS_MSGCLASS_ADVERTISEMENT = 1,
-       MMS_MSGCLASS_INFORMATIONAL = 2,
-       MMS_MSGCLASS_AUTO = 3
-} MmsMsgClass;
-
-
-/*==================================================================================================
-                                                       Structures
-==================================================================================================*/
-
-typedef struct {
-       MmsReplyChargeType chargeType;
-       MmsTimeStruct deadLine;
-       int chargeSize;
-       char szChargeID[MMS_MSG_ID_LEN + 1];
-} MmsReplyCharge;
-
-
-typedef        struct _MmsMsgMultiStatus {
-       char szTo[MAX_ADDRESS_VAL_LEN + 1];
-       bool bDeliveryReportIsRead;
-       bool bDeliveyrReportIsLast;
-       msg_delivery_report_status_t msgStatus;
-       UINT32 handledTime;
-
-       bool bReadReplyIsRead;
-       bool bReadReplyIsLast;
-       msg_read_report_status_t readStatus;
-       UINT32 readTime;
-
-       struct _MmsMsgMultiStatus *pNext;
-} MmsMsgMultiStatus;
-
-typedef        struct _MMS_ATTRIB_S {
-       MsgContentType contentType;
-       MmsDataType dataType;
-       UINT32 date;
-       UINT8 version;
-
-       char szFrom[MSG_LOCALE_ADDR_LEN + 11];          //"/TYPE=PLMN", /"TYPE=IPv4", "/TYPE=IPv6"
-       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
-       char *szTo;
-       char *szCc;
-       char *szBcc;
-
-       MmsPriority priority;
-
-       MmsReplyCharge replyCharge;
-       bool bChargingMsgReplied;
-
-       bool bHideAddress;
-       bool bAskDeliveryReport;
-       bool bReportAllowed;
-       MmsRecvReadReportType readReportAllowedType;
-
-       bool bAskReadReply;
-       bool bRead;
-
-       MmsRecvReadReportSendStatus readReportSendStatus;
-
-       bool bReadReportSent;
-
-       bool bLeaveCopy;
-       bool bUseExpiryCustomTime;              // for expiry custom time
-       bool bUseDeliveryCustomTime;    // for expiry custom time
-       MmsEditStyleMode editStyleMode;                 //editStyle on All Page
-
-       MmsSpecialMsgType specialMsgType;                       // instead of bPostcard
-
-#ifdef __SUPPORT_DRM__
-       MsgDrmType drmType;
-       int roWaitingTimerMax;          // DRM RO WAITING
-       char *pszDrmData;                       // DRM Data to draw mailbox icon
-#endif
-
-       int msgSize;
-       MmsMsgClass msgClass;
-       MmsTimeStruct expiryTime;
-       MmsTimeStruct expiryCustomTime;
-       MmsTimeStruct deliveryTime;
-       MmsTimeStruct deliveryCustomTime;
-
-       //for ReadMsg, When Sending notifyResp.ind
-       msg_delivery_report_status_t msgStatus;
-
-       MmsResponseStatus responseStatus;
-       MmsRetrieveStatus retrieveStatus;
-       char szResponseText[MMS_LOCALE_RESP_TEXT_LEN + 1];
-       char szRetrieveText[MMS_LOCALE_RESP_TEXT_LEN + 1];
-
-       MmsMsgMultiStatus *pMultiStatus;
-       bool bRetrieveNow;
-} MmsAttrib;
-
-
-typedef struct _MsgContentParam {
-       int charset;
-       char szBoundary[MSG_BOUNDARY_LEN + 1];
-       char szFileName[MSG_FILENAME_LEN_MAX + 1];
-       char szName[MSG_LOCALE_FILENAME_LEN_MAX + 1];
-
-#ifdef FEATURE_JAVA_MMS
-       char *szApplicationID;
-       char *szReplyToApplicationID;
-#endif
-
-       int type;
-       void *pPresentation;
-       char szStart[MSG_MSG_ID_LEN + 1];
-       char szStartInfo[MSG_MSG_ID_LEN + 1];
-
-       MsgParamReportType reportType; //only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
-} MsgContentParam;
-
-#ifdef __SUPPORT_DRM__
-typedef struct _MsgDRMInfo {
-       MsgDrmType drmType;
-       MsgContentType contentType;
-       char *szContentURI;
-       char *szContentName;
-       char *szContentDescription;
-       char *szContentVendor;
-       char *szRightIssuer;
-       char *szDrm2FullPath;
-       int roWaitingTimerMax;          // DRM RO WAITING
-       bool bFwdLock;
-       char *pszContentType;
-       bool bNoRingTone;
-       bool bNoScreen;
-} MsgDRMInfo;
-#endif
-
-typedef struct _MsgType {
-       int offset;
-       int size;
-       int contentSize;
-       int section;
-       int type;
-#ifdef __SUPPORT_DRM__
-       MsgDRMInfo drmInfo;
-#endif
-       int encoding;
-       int disposition;
-       char szContentID[MSG_MSG_ID_LEN + 1];
-       char szContentLocation[MSG_MSG_ID_LEN + 1];
-       char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
-
-       char szContentRepPos[30];
-       char szContentRepSize[30];
-       char szContentRepIndex[8];
-#ifdef __SUPPORT_DRM__
-       int nDrmConvertedStatus;
-#endif
-
-       MsgContentParam param;
-} MsgType;
-
-struct _MsgAddress {
-       int type;                                       //MSG_ADDR_TYPE_PHONE/EMAIL/IPV4/IPV6
-       MsgRecipientType recipientType;                 // TO, CC, BCC
-       char szName[MSG_LOCALE_NAME_LEN + 1];
-       char szAddr[MSG_ADDR_LEN + 1];
-       MsgAddress *pNext;
-       bool bDoNotShow;                                // temporary clip
-
-       // sorting
-       ULONG uLastRecentTime;          // last recent time save item
-       ULONG uMostUseCount;                    // most use count item.
-       int index;                                      // index sorting..
-};
-
-typedef struct _MsgHeader {
-       MsgAddress *pFrom;
-       MsgAddress *pTo;
-       MsgAddress *pCC;
-       char szReturnPath[MSG_ADDR_LEN + 1];
-       char szDate[MSG_DATE_LEN];
-       char szSubject[MSG_LOCALE_SUBJ_LEN + 1];
-       char szMsgID[MSG_MSG_ID_LEN + 1];
-} MsgHeader;
-
-
-struct _MsgBody {
-       int offset;
-       int size;
-       char szOrgFilePath[MSG_FILEPATH_LEN_MAX];
-       MsgType presentationType;
-       MsgBody *pPresentationBody;
-
-       union {
-               char *pText;
-               void *pBinary;
-               MsgMultipart *pMultipart;
-               MsgMessage *pMessage;
-       } body;
-};
-
-struct _MsgMultipart {
-       MsgType type;
-       MsgBody *pBody;
-       MsgMultipart *pNext;
-};
-
-struct _MsgMessage {
-       MsgHeader header;
-       MsgType type;
-       MsgBody *pBody;
-};
-
-
-typedef        struct _MMS_MESSAGE_S {
-       MmsAttrib mmsAttrib;
-       msg_message_id_t msgID;
-       int mailbox;            // mailbox type,MMS_MAILBOX_XXX
-       char szFileName[MSG_FILENAME_LEN_MAX];
-       char szTrID[MMS_TR_ID_LEN + 1];
-       char szMsgID[MMS_MSG_ID_LEN + 1];
-       char szForwardMsgID[MMS_MSG_ID_LEN + 1];
-       char szContentLocation[MMS_LOCATION_LEN + 1];
-       int nPartCount;
-       MsgType msgType;
-       MsgBody msgBody;
-} MmsMsg;
-
-struct _MsgHeaderAddress {
-       char *szAddr;
-       MsgHeaderAddress *pNext;
-};
-
 
 bool MmsInitMsgType(MsgType *pMsgType);
 bool MmsInitMsgBody(MsgBody *pMsgBody);
@@ -521,11 +46,11 @@ bool MmsSetMsgAddressList(MmsAttrib *pAttrib, const MSG_MESSAGE_INFO_S *pMsgInfo
 char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType);
 bool MmsGetMsgBodyfromMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, MMS_MESSAGE_DATA_S *pMsgBody, char *pFileData);
 bool MmsGetSmilRawData(MMS_MESSAGE_DATA_S *pMsgBody, char *pRawData, int *nSize);
-bool MmsInsertPresentation(MmsMsg *pMsg, MsgContentType mimeType, char *pData, int size);
+bool MmsInsertPresentation(MmsMsg *pMsg, MimeType mimeType, char *pData, int size);
 bool MmsInsertPartFromFile(MmsMsg *pMsg, char *szTitleName, char *szOrgFilePath, char *szContentID);
 bool MmsIsMultipart(int type);
 bool MmsGetTypeByFileName(int *type, char *szFileName);
-MsgMultipart *MmsMakeMultipart(MsgContentType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID);
+MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrgFilePath, void *pData, int offset, int size, char *szContentID);
 bool MmsIsText(int type);
 bool MmsIsVitemContent(int type, char *pszName);
 bool MmsComposeMessage(MmsMsg *pMmsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMsgData, char *pFileData);
diff --git a/plugin/mms_plugin/include/MmsPluginSetup.h b/plugin/mms_plugin/include/MmsPluginSetup.h
deleted file mode 100755 (executable)
index 1e9db28..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
-* Copyright 2012  Samsung Electronics Co., Ltd
-*
-* Licensed under the Flora License, Version 1.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*    http://www.tizenopensource.org/license
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include "MmsPluginMessage.h"
-
-#define MSG_STDSTR_SHORT                       0x7F
-
-/*
- * structures for setup
- */
-
-typedef enum {
-       MMS_RECEIVE_AUTO,
-       MMS_RECEIVE_MANUAL,
-       MMS_RECEIVE_RESTRICT,
-       MMS_RECEIVE_REJECT,
-       MMS_RECEIVE_CNT,
-} MmsRecvType;
-
-typedef enum {
-       MMS_RESTRICTED_MODE,
-       MMS_WARNING_MODE,
-       MMS_FREE_MODE
-} MmsUiMsgCreationMode;
-
-typedef        enum {
-       MMS_OPCO_DEFAULT        = 0,
-       MMS_OPCO_FRANCE         = 1,
-       MMS_OPCO_GERMAN         = 2,
-       MMS_OPCO_GREECE         = 3,
-       MMS_OPCO_IRELANDS       = 4,
-       MMS_OPCO_ITALY          = 5,
-       MMS_OPCO_NETHERLANDS = 6,
-       MMS_OPCO_PORTUGAL       = 7,
-       MMS_OPCO_SPAIN          = 8,
-       MMS_OPCO_SWEDEN         = 9,
-       MMS_OPCO_SWISS          = 10,
-       MMS_OPCO_UK                     = 11,
-       MMS_OPCO_AUSTRIA        = 12,
-       MMS_OPCO_BELGIUM        = 13,
-       MMS_OPCO_HUNGARY        = 14,
-       MMS_OPCO_NUM
-} MmsOpCo;
-
-typedef        struct {
-       bool bHideAddress;
-       bool bAskDeliveyReport;
-       bool bAskReadReply;
-       MmsPriority priority;
-       char szFrom[MSG_LOCALE_ADDR_LEN + 10];
-       MmsMsgClass msgClass;
-       MmsTimeStruct expiryTime;
-       MmsTimeStruct deliveryTime;
-       bool bLeaveCopy;
-       bool bAttachVcard;
-       bool bAttachSign;
-       bool bExpiryUseCustomTime;
-
-       bool bDeliveryUseCustomTime;
-
-       MmsTimeStruct expiryCustomTime;
-       MmsTimeStruct deliveryCustomTime;
-
-       char szSign[MSG_LOCALE_SIGN_LEN + 1];
-
-       //MMS_V1_1
-       MmsReplyCharge replyCharge;
-
-       int creationMode; // Creation Mode
-} MmsSendSetup;
-
-typedef struct {
-       bool bSendDeliveryReport;
-       bool bSendReadReply;
-       bool bAnonymousReject;
-       bool bRejectAdvertisement;
-       MmsRecvType recvHomeNetwork;
-       MmsRecvType recvRoamingNetwork;
-} MmsRecvSetup;
-
-typedef        struct {
-       bool bUserSettingMsgMaxSize;
-       int msgMmsMaxSize;
-} MmsMsgSizeSetup;
-
-
-typedef struct {
-       MmsUiMsgCreationMode creationMode;
-} MmsCreationModeSetup;
-
-
-typedef struct {
-       bool bCustomTime;
-       int slideIntervalTime;
-       int customTime;
-} MmsSlideSetup;
-
-typedef struct {
-       int     postcardName;
-       int     postcardAdditionalInfo;
-       int     postcardStreet;
-       int     postcardZip;
-       int     postcardCity;
-       int     postcardStateNProvince;
-       int     postcardCountry;
-} MmsPostcardSetup;
-
-typedef struct {
-       MmsSendSetup sendSetup;
-       MmsRecvSetup recvSetup;
-       MmsMsgSizeSetup msgSizeSetup;
-       MmsPostcardSetup postcardSetup[5];                                                                      // ref) POSTCARD_EDIT_TYPE_EXTENDED4
-
-       MmsCreationModeSetup creationModeSetup;
-
-       int autoResizeSize;
-
-       /* UI not-visible fields ------------------------------------ */
-
-       MmsOpCo nOpCo;
-       int maxSendSize;
-       char szPostcardOffice[MSG_STDSTR_SHORT + 1];                            // Only Privosioning can change this field
-       char szPostcardOfficeExtend01[MSG_STDSTR_SHORT + 1];
-       char szPostcardOfficeExtend02[MSG_STDSTR_SHORT + 1];
-       char szPostcardOfficeExtend03[MSG_STDSTR_SHORT + 1];
-       char szPostcardOfficeExtend04[MSG_STDSTR_SHORT + 1];
-       bool bPostcardAvailable;                                                                        // Only Privosioning can change this field
-       char szMmlUrl[MSG_STDSTR_SHORT + 1];                                    //MML Home Url
-       char szMmlPhoneNumber[MSG_STDSTR_SHORT + 1];                    //MML Upload phonenumber
-
-       char szMmsTmplDownloadURL[MSG_STDSTR_SHORT + 1];        //  for MMS More Templates
-
-} MmsSetup;
-
-/* global Setting */
-extern MmsSetup gMmsSetup;
-
index 7b1c9f9..797554b 100755 (executable)
@@ -24,7 +24,6 @@
 #include "MsgSqliteWrapper.h"
 #include "MmsPluginMessage.h"
 
-
 /*==================================================================================================
                                                        CLASS DEFINITIONS
 ==================================================================================================*/
@@ -59,7 +58,7 @@ public:
        msg_error_t plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg,  MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg);
        msg_error_t getContentLocation(MSG_MESSAGE_INFO_S *pMsgInfo);
        msg_error_t getMmsRawFilePath(msg_message_id_t msgId, char *pFilepath);
-       msg_error_t plgGetRestoreMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SENDINGOPT_INFO_S *pSendOptInfo, MMS_MESSAGE_DATA_S *pMmsMsg, char **pDestMsg, char *filePath);
+
        /* reject_msg_support */
        msg_error_t getTrID(MSG_MESSAGE_INFO_S *pMsgInfo, char *pszTrID, int nBufferLen);
        /* reject_msg_support */
index a63e0c5..5f0741c 100755 (executable)
 
 #include <glib.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 const char *MmsPluginTextConvertGetCharSet(int MIBEnum);
 
 bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeSet, const char *pSrc, int srcLen, char **ppDest, int *pDestLen);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif