JMMSJsrHandler.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:133k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2002
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * jmms_jsr_handler.C
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file conains the store APIs for interacting with Jatayu Store module
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _MMI_JMMSJSRHANDLER_C
- #define _MMI_JMMSJSRHANDLER_C
- /*****************************************************************************
- * Include
- *****************************************************************************/
- #include "MMI_features.h"
- #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
- #include "JsrTypes.h"
- #include "JMMSJSRHandler.h"
- #include "PixtelDataTypes.h"
- #include "SettingProfile.h"
- #include "DebugInitDef.h"
- #include "FileManagerGProt.h" /* file path util function */
- #include <ddl.h>
- #include <jcal.h>
- #include <jcalnet.h>
- #include "jdi_wspdatatype.h"
- #include "jdi_transport.h"
- #include "JMMSCoreAPI.h"
- /* jataayu files */
- #include "ddlbase.h"
- #include "jcutils.h"
- #include "ddlutils.h"
- #include "jdi_MMSErr.h"
- #include "jcerror.h"
- #include <jdi_communicator.h>
- #include <miscutils.h>
- #include <MM1DataTypes.h>
- #include <MessagingDatatypes.h>
- #include <MessagingAPI.h>
- #include "JMMSExdcl.h"
- #include "JMMSMainMMS.h"
- #include "JMMSProtocols.h"
- #include "JMMSMessageSettings.h"
- #include "JMMSMessageSettingsUtils.h"
- #include "JMMSConfig.h"
- #include "JMMSResEnum.h"
- #include "JMMSWriteMMS.h"
- #include "JMMSStoreHandling.h"
- #include "PrvMessagingDataTypes.h"
- #include "MM1Api.h"
- #include "Msg_Utils.h"
- #include "Msg_Presentation.h"
- #include "JMMSPushHandling.h"
- #include "JMMSCoreAPI.h"
- #include "JMMSDrafts.h"
- #include "JMMSExdcl.h"
- /* /#include "JMMSGdcl.h" */
- #include "JMMSCompose.h"
- #include "JMMSGprot.h"
- #include "JMMSInbox.h"
- #include "JMMSJSRHandler.h"
- #include "JMMSMainMMS.h"
- #include "JMMSMessageSettingsUtils.h"
- #include "JMMSOutbox.h"
- #include "JMMSProtocols.h"
- #include "JMMSPushHandling.h"
- #include "JMMSResEnum.h"
- #include "JMMSSent.h"
- #include "JMMSStoreHandling.h"
- #include "JMMSStructs.h"
- #include "JMMSTemplates.h"
- #include "JMMSUseDetails.h"
- #include "JMMSView.h"
- #include "JMMSWriteMMS.h"
- #include "TimerEvents.h"
- #include "wapadp.h"
- #include "JPushInboxCommonUI.h"
- #ifdef __MMI_UNIFIED_MESSAGE__
- #include "UnifiedMessageDef.h"
- #include "UnifiedMessageProt.h"
- #include "JMMSUMHandling.h"
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- #ifdef MMI_JMMS_JAVA_MMS_SUPPORT
- /*****************************************************************************
- * Define
- *****************************************************************************/
- /*****************************************************************************
- * Typedef
- *****************************************************************************/
- /*****************************************************************************
- * Local Variable
- *****************************************************************************/
- static U32 media_obj_index = 1;
- /*****************************************************************************
- * Local Function
- *****************************************************************************/
- /*****************************************************************************
- * Global Variable
- *****************************************************************************/
- extern U64 g_jmms_normal_msgid;
- extern U64 g_jmms_java_msgid;
- /*****************************************************************************
- * Global Function
- *****************************************************************************/
- JsrResult mmi_jmms_java_mms_error(JC_RETCODE error_code);
- mmi_jmms_java_addresses_type mmi_jmms_java_map_address_type(MMSAddressTypes type);
- extern int mmi_charset_ucs2_to_utf8_length_in_bytes(const kal_uint8 *raw);
- extern int mmi_charset_utf8_to_ucs2_length_in_bytes(const kal_uint8 *raw);
- extern kal_int32 mmi_chset_utf8_to_ucs2_string(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
- extern kal_int32 mmi_chset_ucs2_to_utf8_string(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
- extern JC_RETCODE mmi_jmms_jsr_form_send_request_pdu(MM1_HANDLE hMM1, MESSAGING_HANDLER *pMessaging);
- extern void mmi_jmms_entry_inbox_screen(void);
- extern void mmi_jmms_entry_outbox_screen(void);
- extern void mmi_jmms_entry_sent_screen(void);
- extern void mmi_jmms_entry_drafts_screen(void);
- extern U8 *mmi_jmms_get_activated_mmsc_url(jmms_context_struct *jmms_context);
- void mmi_jmms_MM1_decode_continue_start_timer(JC_UINT32 total_obj, error_callback new_err_cb);
- extern em_wap_user_agent_brand_enum wap_get_user_agent_brand(void);
- /* AT Command functions */
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_folder_name_from_folderId
- * DESCRIPTION
- * Find the name of Folder corresponding to Folder Id.
- * PARAMETERS
- * folderId [IN] Id of folder
- * fname [?] [?] Corresponding folder name
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_get_folder_name_from_folderId(U8 folderId, S8 *fname)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (folderId)
- {
- case JSR_INBOX:
- strcpy((S8*) fname, (S8*) MMI_JMMS_INBOX);
- break;
- case JSR_OUTBOX:
- strcpy((S8*) fname, (S8*) MMI_JMMS_OUTBOX);
- break;
- case JSR_SENT:
- strcpy((S8*) fname, (S8*) MMI_JMMS_SENT);
- break;
- case JSR_DRAFTS:
- strcpy((S8*) fname, (S8*) MMI_JMMS_DRAFTS);
- break;
- case JSR_TEMPLATES:
- strcpy((S8*) fname, (S8*) MMI_JMMS_TEMPLATES);
- break;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_at_get_folder_info
- * DESCRIPTION
- * Sets the folder information correponding to given Folder Id.
- * PARAMETERS
- * folderId [IN] Id of Folder
- * folderInfo [?] [?] Folder information
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_at_get_folder_info(U8 folderId, JsrFolderInfo *folderInfo)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FOLDER_INFO *pFolderInfo = NULL;
- FOLDER_LIST *pFolderList = NULL;
- U32 len = 0;
- S8 *folder_name = NULL;
- S8 fname[100];
- JC_RETCODE eRet = JC_OK;
- U8 numOfUnreadMsg = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(fname, 0, 100);
- mmi_jmms_get_folder_name_from_folderId(folderId, fname);
- len = (strlen((PS8) fname) + 1) * ENCODING_LENGTH;
- folder_name = (PS8) jdd_MemAlloc(len, sizeof(S8));
- if (NULL == folder_name)
- {
- goto END;
- }
- AnsiiToUnicodeString((PS8) folder_name, (PS8) fname);
- eRet = mmi_jmms_get_folder_list(&pFolderInfo);
- if (eRet != JC_OK)
- {
- goto END;
- }
- pFolderList = pFolderInfo->pFolderList;
- while (pFolderList)
- {
- if (pfnUnicodeStrcmp((S8*) pFolderList->pFolderName, (S8*) folder_name) == 0)
- {
- folderInfo->numOfMsg = pFolderList->uiTotalMessages;
- //folderInfo->numOfUnreadMsg = (pFolderList->uiTotalMessages) - (pFolderList->uiTotalReadMessages);
- if(strcmp((S8*)fname, (S8*) MMI_JMMS_INBOX) == 0)
- {
- eRet = mmi_jmms_get_number_of_unread_messages_in_inbox(&numOfUnreadMsg);
- folderInfo->numOfUnreadMsg = numOfUnreadMsg;
- }
- else
- {
- folderInfo->numOfUnreadMsg = 0;
- }
- break;
- }
- pFolderList = pFolderList->pNext;
- }
- END:
- if (folder_name != NULL)
- {
- jdd_MemFree(folder_name);
- folder_name = NULL;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_at_get_address_and_subject
- * DESCRIPTION
- * Sets the folder information correponding to given Folder Id.
- * PARAMETERS
- * list [?] [?]
- * index [IN]
- * address [?] [?]
- * subject [?] [?]
- * U8 folderId Id of Folder(?)(?)
- * JsrFolderInfo* folderInfo folder information(?)(?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_at_get_address_and_subject(JsrMessageInfo *list, U32 index, S8 *address, S8 *subject)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (address != NULL)
- {
- if (strlen(address) > 39)
- {
- memcpy(list[index].address, address, 39);
- }
- else
- {
- strcpy((S8*) (list[index].address), (S8*) address);
- }
- }
- if (subject != NULL)
- {
- if (strlen(subject) > 39)
- {
- memcpy(list[index].subject, subject, 39);
- }
- else
- {
- strcpy((S8*) (list[index].subject), (S8*) subject);
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_at_get_message_list
- * DESCRIPTION
- *
- * PARAMETERS
- * folderId [IN]
- * list [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_at_get_message_list(U8 folderId, JsrMessageInfo *list)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MESSAGE_LIST *pMessageList = NULL;
- MESSAGE_LIST *pTempMessageList = NULL;
- S8 fname[100];
- U32 i = 0;
- S32 msgType = -1;
- U32 len = 0;
- S8 *address = NULL;
- S8 *subject = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /* for new phone suite */
- U32 index = 1;
- CONTENT_DATA Content = {0, };
- JC_RETCODE eRet = JC_OK;
- S8 *name_p = NULL;
- S8 temp[40];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(fname, 0, 100);
- mmi_jmms_get_folder_name_from_folderId(folderId, fname);
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- mmi_jmms_get_messages_list((S8*) fname, &pMessageList, &StoreRetFilter);
- pTempMessageList = pMessageList;
- while (pTempMessageList)
- {
- memset((S8*) & Content, 0, sizeof(CONTENT_DATA));
- #ifdef __MMI_UNIFIED_MESSAGE__
- list[i].msgId = pTempMessageList->uiExtraBytes & 0x00FFFFFF;
- #else
- list[i].msgId = pTempMessageList->uiExtraBytes;
- #endif
- //list[i].offset = 9; /* fixed 9 bytes */
- list[i].offset = 0; /* fixed 0 bytes */
- list[i].size = pTempMessageList->uiBufferLen;
- msgType = pTempMessageList->pMessageHeaders->eMsgType;
- /* for new phone suite */
- Content.bIsStream = E_TRUE;
- eRet = mmi_jmms_jdi_get_msg(g_jmms_context->hStoreHandle, index++, &Content);
- memset(temp, 0, 40);
- UnicodeToAnsii((S8*) temp, (S8*) Content.pFileName);
- name_p = strrchr(temp, '\');
- name_p++;
- strcpy((S8*) list[i].filename, (S8*) name_p);
- switch (msgType)
- {
- case E_MSG_TYPE_SEND:
- {
- MESSAGE_SEND *pHeader = (MESSAGE_SEND*) pTempMessageList->pMessageHeaders->pHeaders;
- list[i].date = pHeader->uiDate;
- /* discussed with Manish for Templates. */
- if (0 == strcmp((S8*) fname, (S8*) MMI_JMMS_TEMPLATES))
- {
- /* list[i].fileType = JSR_SUFFIX_TEMPLATE; */
- }
- else
- {
- /* list[i].fileType = JSR_SUFFIX_SEND_REQ; */
- }
- if (pHeader->pFrom != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pFrom)) + 1);
- address = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) address, len, (U8*) pHeader->pFrom);
- }
- if (pHeader->pSubject != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pSubject)) + 1);
- subject = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) subject, len, (U8*) pHeader->pSubject);
- }
- mmi_jmms_at_get_address_and_subject(list, i, (S8*) address, (S8*) subject);
- }
- break;
- case E_MSG_TYPE_NOTIFICATION:
- {
- MESSAGE_NOTIFICATION *pHeader = (MESSAGE_NOTIFICATION*) pTempMessageList->pMessageHeaders->pHeaders;
- list[i].date = 0; /* date is not available in notification. */
- if (pHeader->pFrom != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pFrom)) + 1);
- address = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) address, len, (U8*) pHeader->pFrom);
- }
- if (pHeader->pSubject != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pSubject)) + 1);
- subject = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) subject, len, (U8*) pHeader->pSubject);
- }
- mmi_jmms_at_get_address_and_subject(list, i, (S8*) address, (S8*) subject);
- }
- break;
- case E_MSG_TYPE_DELIVERY_REPORT:
- {
- DELIVERY_REPORT *pHeader = (DELIVERY_REPORT*) pTempMessageList->pMessageHeaders->pHeaders;
- list[i].date = pHeader->uiDate;
- /* delivery report doesn't have address and subject. */
- mmi_jmms_at_get_address_and_subject(list, i, NULL, NULL);
- }
- break;
- case E_MSG_TYPE_READ_REPORT:
- {
- READ_REPORT *pHeader = (READ_REPORT*) pTempMessageList->pMessageHeaders->pHeaders;
- list[i].date = pHeader->uiDate;
- if (pHeader->pFrom != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pFrom)) + 1);
- address = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) address, len, (U8*) pHeader->pFrom);
- }
- /* read report doesn't have subject. */
- mmi_jmms_at_get_address_and_subject(list, i, (S8*) address, NULL);
- }
- break;
- case E_MSG_TYPE_RECEIVE:
- {
- MESSAGE_RETRIEVAL *pHeader = (MESSAGE_RETRIEVAL*) pTempMessageList->pMessageHeaders->pHeaders;
- list[i].date = pHeader->uiDate;
- if (pHeader->pFrom != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pFrom)) + 1);
- address = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) address, len, (U8*) pHeader->pFrom);
- }
- if (pHeader->pSubject != NULL)
- {
- len = (mmi_charset_ucs2_to_utf8_length_in_bytes((U8*) (pHeader->pSubject)) + 1);
- subject = jdd_MemAlloc(len, sizeof(U8));
- mmi_chset_ucs2_to_utf8_string((U8*) subject, len, (U8*) pHeader->pSubject);
- }
- mmi_jmms_at_get_address_and_subject(list, i, (S8*) address, (S8*) subject);
- }
- break;
- default:
- break;
- }
- i++;
- if (address != NULL)
- {
- jdd_MemFree(address);
- address = NULL;
- }
- if (subject != NULL)
- {
- jdd_MemFree(subject);
- subject = NULL;
- }
- if(Content.pFileName != NULL)
- {
- jdd_MemFree(Content.pFileName);
- Content.pFileName = NULL;
- }
- pTempMessageList = pTempMessageList->pNext;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_at_save_mms
- * DESCRIPTION
- *
- * PARAMETERS
- * fname [?] [?]
- * msgId [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JsrResult mmi_jmms_at_save_mms(char *fname, U32 *msgId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 filename_length = 0;
- MSG_HANDLE hMsgHandle = NULL;
- CONTENT_DATA EncapsulatedContent = {0, };
- MESSAGE_HEADERS *MsgHeaders = NULL;
- JC_RETCODE eRet = JC_OK;
- JC_UINT32 msgIndex;
- S8 folder_name[100];
- JC_UINT32 uiFileLength = 0;
- JDD_FILE hFile = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(folder_name, 0, 100);
- mmi_jmms_get_folder_name_from_folderId(JSR_DRAFTS, folder_name);
- /* fname is in ASCII */
- filename_length = (strlen(fname) + 1) * ENCODING_LENGTH;
- EncapsulatedContent.bIsStream = E_TRUE;
- EncapsulatedContent.cbWriteCallback = NULL;
- EncapsulatedContent.cbReadCallback = mmi_jmms_read_callback;
- EncapsulatedContent.pStream = jdd_MemAlloc(sizeof(S8), filename_length);
- AnsiiToUnicodeString(EncapsulatedContent.pStream, fname);
- EncapsulatedContent.pFileName = EncapsulatedContent.pStream;
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- eRet = JC_ERR_FILE_OPEN;
- goto END;
- }
- }
- hFile = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (JC_CHAR*) EncapsulatedContent.pStream, E_OPEN_READ_MODE);
- if (hFile == NULL)
- {
- eRet = JC_ERR_FILE_OPEN;
- goto END;
- }
- eRet = jdd_FSGetSize(hFile, &uiFileLength);
- if (JC_OK != eRet)
- {
- eRet = JC_ERR_FILE_OPEN;
- goto END;
- }
- EncapsulatedContent.uiTotalSize = uiFileLength;
- if (hFile != NULL)
- {
- jdd_FSClose(hFile);
- hFile = NULL;
- }
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- eRet = mmi_jmms_jdi_parse_msg_buffer(&hMsgHandle, &EncapsulatedContent, E_TYPE_MMS, E_FALSE);
- /* Async changes start */
- while (eRet == JC_ERR_MMS_PARSE_PENDING)
- {
- eRet = mmi_jmms_jdi_msg_parse_continue(hMsgHandle);
- };
- /* Async changes end */
- if (JC_OK != eRet)
- {
- *msgId = 0;
- if (hMsgHandle != NULL)
- {
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- }
- goto END;
- }
- eRet = mmi_jmms_jdi_get_msg_headers(hMsgHandle, &MsgHeaders);
- if (JC_OK != eRet)
- {
- *msgId = 0;
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- goto END;
- }
- /* TO DO to be discussed. */
- eRet = mmi_jmms_save_message_buffer_in_Store((S8*) folder_name, &msgIndex, MsgHeaders, &EncapsulatedContent, msgId);
- if (JC_OK != eRet)
- {
- if (EncapsulatedContent.pStream != NULL)
- {
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- eRet = JC_ERR_FILE_OPEN;
- goto END;
- }
- }
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, EncapsulatedContent.pStream);
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- }
- }
- END:
- if (EncapsulatedContent.pStream != NULL)
- {
- jdd_MemFree(EncapsulatedContent.pStream);
- EncapsulatedContent.pStream = NULL;
- }
- if (hMsgHandle != NULL)
- {
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- }
- return mmi_jmms_java_mms_error(eRet);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_at_delete_mms
- * DESCRIPTION
- *
- * PARAMETERS
- * folderId [IN]
- * msgId [IN]
- * jmms_delete_callback [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_at_delete_mms(U8 folderId, U32 msgId, void (*jmms_delete_callback) (JsrResult result))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 msgIndex = 0;
- S8 fname[100];
- JC_RETCODE eRet = JC_OK;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* check if the MMS is open on phone. */
- if (folderId == 0)
- {
- FOLDER_INFO *pFolderInfo = NULL;
- FOLDER_LIST *pFolderList = NULL;
- MESSAGE_LIST *pMessageList = NULL;
- MESSAGE_LIST *pTempMessageList = NULL;
- MMI_BOOL is_message_deleted = MMI_FALSE;
- MMI_BOOL done = MMI_FALSE;
- /* /manish ading here */
- MMI_BOOL is_open = MMI_FALSE;
- eRet = mmi_jmms_get_folder_list(&pFolderInfo);
- if (eRet != JC_OK)
- {
- jmms_delete_callback(mmi_jmms_java_mms_error(eRet));
- return;
- }
- pFolderList = pFolderInfo->pFolderList;
- while (pFolderList)
- {
- memset(fname, 0, 100);
- msgIndex = 0;
- UnicodeToAnsii((S8*) fname, (S8*) pFolderList->pFolderName);
- /* /manish chnging here 0n 2 Feb */
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- mmi_jmms_get_messages_list((S8*) fname, &pMessageList, &StoreRetFilter);
- pTempMessageList = pMessageList;
- while (pTempMessageList)
- {
- msgIndex++;
- #ifdef __MMI_UNIFIED_MESSAGE__
- if ((pTempMessageList->uiExtraBytes & 0x00FFFFFF) == msgId) /* msgId is stored in the extra bytes of message list. */
- #else
- if (pTempMessageList->uiExtraBytes == msgId) /* msgId is stored in the extra bytes of message list. */
- #endif
- {
- is_message_deleted = MMI_TRUE;
- done = MMI_TRUE;
- is_open = mmi_jmms_is_msg_open((S8*) fname, msgId, msgIndex);
- if (is_open == MMI_FALSE)
- {
- eRet = mmi_jmms_delete_message(fname, msgIndex);
- if (eRet != JC_OK)
- {
- is_message_deleted = MMI_FALSE;
- break;
- }
- else
- {
- if (strcmp(fname, "Inbox") == 0)
- {
- mmi_jmms_free_pending_node_if_present(msgIndex);
- mmi_jmms_delete_msg_status((U8) (msgIndex - 1));
- }
- is_message_deleted = MMI_TRUE;
- break;
- }
- }
- else
- {
- is_message_deleted = MMI_FALSE;
- break;
- }
- }
- pTempMessageList = pTempMessageList->pNext;
- }
- if (done == MMI_TRUE)
- {
- break;
- }
- pFolderList = pFolderList->pNext;
- }
- if (is_message_deleted == MMI_FALSE)
- {
- eRet = JC_ERR_STORE_INVALID_MSG_INDEX;
- }
- }
- else
- {
- memset(fname, 0, 100);
- mmi_jmms_get_folder_name_from_folderId((U8) folderId, (S8*) fname);
- eRet = mmi_jmms_delete_all_message((S8*) fname);
- }
- /* Call the callback function */
- jmms_delete_callback(mmi_jmms_java_mms_error(eRet));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_is_msg_open
- * DESCRIPTION
- *
- * PARAMETERS
- * fname [?] [?]
- * msgId [IN]
- * msg_index [IN]
- * RETURNS
- *
- *****************************************************************************/
- MMI_BOOL mmi_jmms_is_msg_open(S8 *fname, U32 msgId, U32 msg_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_jmms_folder_name_enum folder_id;
- MMI_BOOL is_open = MMI_FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (strcmp(fname, "Inbox") == 0)
- {
- folder_id = E_JMMS_INBOX;
- }
- else if (strcmp(fname, "Outbox") == 0)
- {
- folder_id = E_JMMS_OUTBOX;
- }
- else if (strcmp(fname, "Drafts") == 0)
- {
- folder_id = E_JMMS_DRAFTS;
- }
- else if (strcmp(fname, "Sent") == 0)
- {
- folder_id = E_JMMS_SENT;
- }
- else
- {
- return is_open;
- }
- if ((g_jmms_context->msg_open_status[0] == folder_id
- && g_jmms_context->msg_open_status[1] == (U32) (msgId))
- || (g_jmms_context->msg_open_status[0] == folder_id && g_jmms_context->msg_open_status[1] == 0))
- {
- is_open = MMI_TRUE;
- return is_open;
- }
- if (folder_id == E_JMMS_INBOX)
- {
- if (GetActiveScreenId() == SCR_ID_JMMS_NEW_MMS_IND)
- {
- if (g_jmms_context->pending_mms_info_list != NULL)
- {
- if (g_jmms_context->pending_mms_info_list->Index == msg_index)
- {
- is_open = MMI_TRUE;
- }
- }
- }
- }
- return is_open;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_free_pending_node_if_present
- * DESCRIPTION
- *
- * PARAMETERS
- * msg_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_free_pending_node_if_present(U32 msg_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_pending_mms_info_struct *node = NULL;
- jmms_pending_mms_info_struct *pre_node = NULL;
- U8 type;
- JC_INT32 index = 0;
- U8 delivery_report_index = 0, read_report_index = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_jmms_context->pending_mms_info_list == NULL)
- {
- return;
- }
- node = g_jmms_context->pending_mms_info_list;
- pre_node = node;
- while (node != NULL)
- {
- index = (JC_INT32) (node->Index);
- type = node->type;
- if (type == E_MSG_TYPE_DELIVERY_REPORT)
- {
- delivery_report_index++;
- }
- else if (type == E_MSG_TYPE_READ_REPORT_RESPONSE)
- {
- read_report_index++;
- }
- if (index == msg_index)
- {
- break;
- }
- pre_node = node;
- node = node->next;
- }
- if (node == NULL)
- {
- return;
- }
- if (pre_node == node)
- {
- g_jmms_context->pending_mms_info_list = node->next;
- }
- else
- {
- pre_node->next = node->next;
- }
- if (node->mms_url != NULL)
- {
- jdd_MemFree(node->mms_url);
- }
- jdd_MemFree(node);
- node = NULL;
- if (type == E_MSG_TYPE_NOTIFICATION || type == E_MSG_TYPE_RECEIVE)
- {
- return;
- }
- switch (type)
- {
- case E_MSG_TYPE_DELIVERY_REPORT:
- {
- jmms_pending_mms_delivery_reports_struct *node1 = NULL;
- jmms_pending_mms_delivery_reports_struct *pre_node1 = NULL;
- node1 = g_jmms_context->pending_delivery_reports;
- if (g_jmms_context->pending_delivery_reports == NULL || delivery_report_index == 0)
- {
- return;
- }
- else
- {
- pre_node1 = node1;
- delivery_report_index--;
- while (delivery_report_index != 0 && node1 != NULL)
- {
- pre_node1 = node1;
- node1 = node1->next;
- delivery_report_index--;
- }
- if (node1 == NULL)
- {
- return;
- }
- if (pre_node1 == node1)
- {
- g_jmms_context->pending_delivery_reports = node1->next;
- }
- else
- {
- pre_node1->next = node1->next;
- }
- if (node1->to_p != NULL)
- {
- jdd_MemFree(node1->to_p);
- }
- jdd_MemFree(node1);
- node1 = NULL;
- }
- return;
- }
- case E_MSG_TYPE_READ_REPORT_RESPONSE:
- {
- jmms_pending_mms_read_reports_struct *node1 = NULL;
- jmms_pending_mms_read_reports_struct *pre_node1 = NULL;
- node1 = g_jmms_context->pending_read_reports;
- if (g_jmms_context->pending_read_reports == NULL || read_report_index == 0)
- {
- return;
- }
- else
- {
- pre_node1 = node1;
- read_report_index--;
- while (read_report_index != 0 && node1 != NULL)
- {
- pre_node1 = node1;
- node1 = node1->next;
- read_report_index--;
- }
- if (node1 == NULL)
- {
- return;
- }
- if (pre_node1 == node1)
- {
- g_jmms_context->pending_read_reports = node1->next;
- }
- else
- {
- pre_node1->next = node1->next;
- }
- if (node1->from_p != NULL)
- {
- jdd_MemFree(node1->from_p);
- }
- jdd_MemFree(node1);
- node1 = NULL;
- }
- return;
- }
- } /* /switch(type) */
- }
- /* /java functions */
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_create_mms
- * DESCRIPTION
- *
- * PARAMETERS
- * message [?] [?]
- * buffer [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JsrResult mmi_jmms_jsr_create_mms(wap_mmc_send_appmms_req_struct *message, U8 *buffer)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 datalen = 0;
- JC_RETCODE eRet = JC_OK;
- MESSAGE_SEND *pMessageSend = NULL;
- MESSAGE_HEADERS *pMsgHeaders = NULL;
- MSG_HANDLE hMsgHandle = NULL;
- MM1_HDR_PARAM *pContentTypeParams = NULL; /* For content type */
- MM1_HDR_PARAM *pTempContentTypeParams = NULL;
- MM1_HDR_PARAM *node = NULL;
- S8 *address = NULL;
- S8 *temp_address = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = mmi_jmms_jdi_msg_init(&hMsgHandle, NULL);
- if (JC_OK != eRet)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- eRet = mmi_jmms_jdi_set_msg_type(hMsgHandle, E_TYPE_MMS);
- if (JC_OK != eRet)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- if (message->mms_type == 0)
- {
- eRet = mmi_jmms_jdi_set_presentation_type(hMsgHandle, E_PRESENTATION_SMIL);
- }
- else if (message->mms_type == 1)
- {
- eRet = mmi_jmms_jdi_set_presentation_type(hMsgHandle, E_PRESENTATION_NONE);
- }
- if (JC_OK != eRet)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- g_jmms_context->MsgHeaders_p = (MESSAGE_HEADERS*) jdd_MemAlloc(sizeof(MESSAGE_HEADERS), 1);
- if (NULL == g_jmms_context->MsgHeaders_p)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- g_jmms_context->MsgHeader_type_p = (MESSAGE_SEND*) jdd_MemAlloc(sizeof(MESSAGE_SEND), 1);
- if (NULL == g_jmms_context->MsgHeader_type_p)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- pMsgHeaders = g_jmms_context->MsgHeaders_p;
- pMessageSend = g_jmms_context->MsgHeader_type_p;
- eRet = mmi_jmms_set_mmsc_version();
- if (eRet != JC_OK)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- pMessageSend->pVersion = (JC_INT8*) g_jmms_context->version;
- if (wap_get_user_agent_brand() != EM_WAP_USERAGENT_BRAND_SE)
- {
- pMessageSend->uiExpiryTime = MAX_VALIDITY_PERIOD_VALUE;
- }
- else
- {
- pMessageSend->uiExpiryTime = 0;
- pMessageSend->uiDate = get_current_utc_time();
- }
- /* PMT HIMANSHU START 20060425 */
- /* For fixing the date & time issue */
- if (message->delivery_time > 604800)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = E_JMMS_GENERAL_ERROR;
- goto END;
- }
- /* PMT HIMANSHU END 20060425 */
- pMessageSend->uiDeliveryTime = message->delivery_time;
- pMessageSend->eMsgPriority = (message->priority) + 1;
- pMessageSend->bDeliveryReport = E_FALSE;
- pMessageSend->bReadReport = E_FALSE;
- pMessageSend->bHideSender = E_FALSE;
- pMessageSend->bExpiryAbs = E_FALSE;
- pMessageSend->bDeliveryAbs = E_FALSE;
- mmi_jmms_free_addresses_list();
- if (buffer != NULL)
- {
- /* Retrieve Subject */
- {
- S8 *subject = NULL;
- U32 subject_len_ucs2 = 0;
- U32 subject_len = *(U32*) buffer;
- if (subject_len > 0)
- {
- subject = (S8*) jdd_MemAlloc(sizeof(S8), subject_len + 1);
- if (NULL == subject)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- memcpy(subject, buffer + 8, subject_len);
- datalen = subject_len + 8;
- subject_len_ucs2 = mmi_charset_utf8_to_ucs2_length_in_bytes((U8*) subject);
- g_jmms_context->subject = (S8*) jdd_MemAlloc(sizeof(S8), (subject_len_ucs2 + ENCODING_LENGTH));
- if (g_jmms_context->subject == NULL)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- if (subject != NULL)
- {
- jdd_MemFree(subject);
- subject = NULL;
- }
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- mmi_chset_utf8_to_ucs2_string(
- (U8*) g_jmms_context->subject,
- (subject_len_ucs2 + ENCODING_LENGTH),
- (U8*) subject);
- pMessageSend->pSubject = (JC_CHAR*) g_jmms_context->subject;
- if (subject != NULL)
- {
- jdd_MemFree(subject);
- subject = NULL;
- }
- }
- else
- {
- datalen = 4;
- }
- }
- /* Retrieve to addresses */
- while (message->to_addr_no > 0)
- {
- U32 address_len = 0;
- U32 addrType = 0;
- U8 ret = 0;
- memcpy(&addrType, (char*)(buffer + datalen), 4);
- memcpy(&address_len, (char*)(buffer + datalen + 4), 4);
- address = jdd_MemAlloc(sizeof(S8), address_len + 1);
- if (NULL == address)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- memcpy(address, buffer + datalen + 8, address_len);
- datalen += address_len + 8;
- temp_address = jdd_MemAlloc(sizeof(S8), (address_len + 1) * ENCODING_LENGTH);
- if (NULL == temp_address)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- AnsiiToUnicodeString((PS8) temp_address, (PS8) address);
- if((MMI_FALSE == mmi_jmms_check_address_input_format((U8*)temp_address))
- &&(MMI_FALSE == mmi_jmms_check_number_input_format((U8*)temp_address)))
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_INVALID_PARAMETER;
- goto END;
- }
- g_jmms_context->address_list_flag = E_TO_ADDRESSES;
- ret = mmi_jmms_add_address_in_addresse_list(temp_address);
- if (ret != 0)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- /* ASSERT(mmcAddrListToMms(addrType, address, &to)); */
- if (address != NULL)
- {
- jdd_MemFree(address);
- address = NULL;
- }
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- message->to_addr_no--;
- }
- if (g_jmms_context->to_address_p != NULL)
- {
- g_jmms_context->to_p = mmi_jmms_get_to_addresses();
- if (g_jmms_context->to_p == NULL)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- pMessageSend->pTo = (JC_CHAR*) g_jmms_context->to_p;
- }
- mmi_jmms_free_addresses_list();
- /* Retrieve cc addresses */
- while (message->cc_addr_no > 0)
- {
- U32 address_len = 0;
- U32 addrType = 0;
- U8 ret = 0;
- memcpy(&addrType, (char*)(buffer + datalen), 4);
- memcpy(&address_len, (char*)(buffer + datalen + 4), 4);
- address = jdd_MemAlloc(sizeof(S8), address_len + 1);
- if (NULL == address)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- memcpy(address, buffer + datalen + 8, address_len);
- datalen += address_len + 8;
- temp_address = jdd_MemAlloc(sizeof(S8), (address_len + 1) * ENCODING_LENGTH);
- if (NULL == temp_address)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- AnsiiToUnicodeString((PS8) temp_address, (PS8) address);
- if((MMI_FALSE == mmi_jmms_check_address_input_format((U8*)temp_address))
- &&(MMI_FALSE == mmi_jmms_check_number_input_format((U8*)temp_address)))
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_INVALID_PARAMETER;
- goto END;
- }
- g_jmms_context->address_list_flag = E_CC_ADDRESSES;
- ret = mmi_jmms_add_address_in_addresse_list(temp_address);
- if (ret != 0)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- if (address != NULL)
- {
- jdd_MemFree(address);
- address = NULL;
- }
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- message->cc_addr_no--;
- }
- if (g_jmms_context->cc_address_p != NULL)
- {
- g_jmms_context->Cc_p = mmi_jmms_get_cc_addresses();
- if (g_jmms_context->Cc_p == NULL)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- pMessageSend->pCc = (JC_CHAR*) g_jmms_context->Cc_p;
- }
- mmi_jmms_free_addresses_list();
- /* Retrieve bcc addresses */
- while (message->bcc_addr_no > 0)
- {
- U32 address_len = 0;
- U32 addrType = 0;
- U8 ret = 0;
- memcpy(&addrType, (char*)(buffer + datalen), 4);
- memcpy(&address_len, (char*)(buffer + datalen + 4), 4);
- address = jdd_MemAlloc(sizeof(S8), address_len + 1);
- if (address == NULL)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- memcpy(address, buffer + datalen + 8, address_len);
- datalen += address_len + 8;
- temp_address = jdd_MemAlloc(sizeof(S8), (address_len + 1) * ENCODING_LENGTH);
- if (temp_address == NULL)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- AnsiiToUnicodeString((PS8) temp_address, (PS8) address);
- if((MMI_FALSE == mmi_jmms_check_address_input_format((U8*)temp_address))
- &&(MMI_FALSE == mmi_jmms_check_number_input_format((U8*)temp_address)))
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_INVALID_PARAMETER;
- goto END;
- }
- g_jmms_context->address_list_flag = E_BCC_ADDRESSES;
- ret = mmi_jmms_add_address_in_addresse_list(temp_address);
- if (ret != 0)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- if (address != NULL)
- {
- jdd_MemFree(address);
- address = NULL;
- }
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- message->bcc_addr_no--;
- }
- if (g_jmms_context->bcc_address_p != NULL)
- {
- g_jmms_context->bcc_p = mmi_jmms_get_bcc_addresses();
- if (g_jmms_context->bcc_p == NULL)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto END;
- }
- pMessageSend->pBcc = (JC_CHAR*) g_jmms_context->bcc_p;
- }
- mmi_jmms_free_addresses_list();
- } /* /if(buffer!=NULL) */
- pMsgHeaders->eMsgType = E_MSG_TYPE_SEND;
- pMsgHeaders->pHeaders = pMessageSend;
- eRet = mmi_jmms_jdi_set_msg_headers(hMsgHandle, pMsgHeaders);
- if (JC_OK != eRet)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- /* Content type set here */
- jdi_MsgGetContentTypeParams(hMsgHandle, &pContentTypeParams);
- if (pContentTypeParams == NULL)
- {
- pContentTypeParams = (MM1_HDR_PARAM*) jdd_MemAlloc(sizeof(MM1_HDR_PARAM), 1);
- if (pContentTypeParams == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- pContentTypeParams->pszName = jdi_UtilsStrdup("Application-ID");
- pContentTypeParams->pszValue = jdi_UtilsStrdup((JC_INT8*) (message->app_id));
- if(message->reply_app_id_len > 0)
- {
- pContentTypeParams->pNext = (MM1_HDR_PARAM*) jdd_MemAlloc(sizeof(MM1_HDR_PARAM), 1);
- if (pContentTypeParams->pNext == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- while (pContentTypeParams != NULL)
- {
- node = pContentTypeParams->pNext;
- if (pContentTypeParams->pszName != NULL)
- {
- jdd_MemFree(pContentTypeParams->pszName);
- pContentTypeParams->pszName = NULL;
- }
- if (pContentTypeParams->pszValue != NULL)
- {
- jdd_MemFree(pContentTypeParams->pszValue);
- pContentTypeParams->pszValue = NULL;
- }
- jdd_MemFree(pContentTypeParams);
- pContentTypeParams = node;
- }
- goto END;
- }
- pTempContentTypeParams = pContentTypeParams->pNext;
- pTempContentTypeParams->pszName = jdi_UtilsStrdup("Reply-To-Application-ID");
- pTempContentTypeParams->pszValue = jdi_UtilsStrdup((JC_INT8*) (message->reply_app_id));
- }
- if(message->start_cnt_id_len > 0)
- {
- pTempContentTypeParams->pNext = (MM1_HDR_PARAM*) jdd_MemAlloc(sizeof(MM1_HDR_PARAM), 1);
- if (pTempContentTypeParams->pNext == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- while (pContentTypeParams != NULL)
- {
- node = pContentTypeParams->pNext;
- if (pContentTypeParams->pszName != NULL)
- {
- jdd_MemFree(pContentTypeParams->pszName);
- pContentTypeParams->pszName = NULL;
- }
- if (pContentTypeParams->pszValue != NULL)
- {
- jdd_MemFree(pContentTypeParams->pszValue);
- pContentTypeParams->pszValue = NULL;
- }
- jdd_MemFree(pContentTypeParams);
- pContentTypeParams = node;
- }
- goto END;
- }
- pTempContentTypeParams = pTempContentTypeParams->pNext;
- pTempContentTypeParams->pszName = jdi_UtilsStrdup("start");
- pTempContentTypeParams->pszValue = jdi_UtilsStrdup((JC_INT8*) (message->start_cnt_id));
- }
- if (pTempContentTypeParams != NULL)
- {
- pTempContentTypeParams->pNext = NULL;
- }
- jdi_MsgSetContentTypeParams(hMsgHandle, pContentTypeParams);
- }
- /* free any allocated memory */
- if (g_jmms_context->hMM1 != NULL)
- {
- /*eRet = jdi_MM1Cleanup(g_jmms_context->hMM1, E_FALSE);*/
- /* Memory Leak Fix: jdi_MM1Cleanup is allocating memory for data chunk after freeing the context */
- eRet = jdi_MM1DeInitialize(g_jmms_context->hMM1);
- g_jmms_context->hMM1 = NULL;
- }
- eRet = jdi_MM1Initialize(&(g_jmms_context->hMM1));
- eRet = mmi_jmms_jsr_form_send_request_pdu(g_jmms_context->hMM1, (MESSAGING_HANDLER*) hMsgHandle);
- if (eRet != JC_OK)
- {
- mmi_jmms_free_mms_pdu_memory(g_jmms_context);
- goto END;
- }
- if (hMsgHandle != NULL)
- {
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- /* /manish-changing on 24 May to prevent End Key Bug */
- g_jmms_context->to_p = NULL;
- g_jmms_context->Cc_p = NULL;
- g_jmms_context->bcc_p = NULL;
- g_jmms_context->from_p = NULL;
- g_jmms_context->MsgHeader_type_p = NULL;
- g_jmms_context->MsgHeaders_p = NULL;
- g_jmms_context->subject = NULL;
- g_jmms_context->version = NULL;
- }
- return mmi_jmms_java_mms_error(JC_OK);
- END:
- if (address != NULL)
- {
- jdd_MemFree(address);
- address = NULL;
- }
- if (temp_address != NULL)
- {
- jdd_MemFree(temp_address);
- temp_address = NULL;
- }
- if (hMsgHandle != NULL)
- {
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- /* /manish adding here on 24 May */
- g_jmms_context->to_p = NULL;
- g_jmms_context->Cc_p = NULL;
- g_jmms_context->bcc_p = NULL;
- g_jmms_context->from_p = NULL;
- g_jmms_context->MsgHeader_type_p = NULL;
- g_jmms_context->MsgHeaders_p = NULL;
- g_jmms_context->subject = NULL;
- g_jmms_context->version = NULL;
- }
- if (g_jmms_context->hMM1 != NULL)
- {
- /*jdi_MM1Cleanup(g_jmms_context->hMM1, E_FALSE);*/
- /* Memory Leak Fix: jdi_MM1Cleanup is allocating memory for data chunk after freeing the context */
- jdi_MM1DeInitialize(g_jmms_context->hMM1);
- g_jmms_context->hMM1 = NULL;
- }
- /* /manish adding here on 24 May */
- mmi_jmms_free_addresses_list();
- return mmi_jmms_java_mms_error(eRet);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_jsr_form_send_request_pdu
- * DESCRIPTION
- *
- * PARAMETERS
- * hMM1 [IN]
- * pMessaging [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_jsr_form_send_request_pdu(MM1_HANDLE hMM1, MESSAGING_HANDLER *pMessaging)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- MESSAGE_SEND *pSendInfo = NULL;
- JC_INT8 cMajorVersion = DEFAULT_MMS_MAJOR_VERSION;
- JC_INT8 cMinorVersion = E_MMS_MINOR_VERSION_2;
- /****** thanik 07-04-06 */
- MM1_HDR_PARAM *pContentTypeParams = NULL; /* For content type */
- MM1_HDR_PARAM *pTempContentTypeParams = NULL;
- MM1_HDR_PARAM *node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /**** thanik**/
- eRet = jdi_MM1SetMessageType(hMM1, E_MMS_SEND_REQUEST_VALUE);
- if (eRet != JC_OK)
- {
- goto error;
- }
- if (pMessaging->pMessageHeaders != NULL)
- {
- pSendInfo = (MESSAGE_SEND*) pMessaging->pMessageHeaders->pHeaders;
- }
- if (pSendInfo != NULL)
- {
- JC_CHAR *pFormattedAddress = NULL;
- if (pSendInfo->pVersion)
- {
- cMajorVersion = (JC_INT8) (jc_atoi(pSendInfo->pVersion));
- cMinorVersion = (JC_INT8) (jc_atoi((pSendInfo->pVersion) + 2));
- }
- eRet = jdi_MM1SetVersion(hMM1, cMajorVersion, cMinorVersion);
- if (eRet != JC_OK)
- {
- goto error;
- }
- if (pSendInfo->uiDate)
- {
- jdi_MM1SetDate(hMM1, pSendInfo->uiDate);
- }
- else
- {
- jdi_MM1SetDate(hMM1, jdd_TimerGetCurrentTime());
- }
- if (pSendInfo->pFrom)
- {
- GetFormattedAddress(&pFormattedAddress, pSendInfo->pFrom);
- if (pFormattedAddress != NULL)
- {
- eRet = jdi_MM1SetFromAddress(hMM1, E_FALSE, pFormattedAddress, E_NONE);
- jdd_MemFree(pFormattedAddress);
- pFormattedAddress = NULL;
- }
- else
- {
- eRet = jdi_MM1SetFromAddress(hMM1, E_FALSE, pSendInfo->pFrom, E_NONE);
- }
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->pTo)
- {
- GetFormattedAddress(&pFormattedAddress, pSendInfo->pTo);
- if (pFormattedAddress != NULL)
- {
- eRet = jdi_MM1SetToAddress(hMM1, pFormattedAddress, E_NONE);
- jdd_MemFree(pFormattedAddress);
- pFormattedAddress = NULL;
- }
- else
- {
- eRet = jdi_MM1SetToAddress(hMM1, pSendInfo->pTo, E_NONE);
- }
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->pCc)
- {
- GetFormattedAddress(&pFormattedAddress, pSendInfo->pCc);
- if (pFormattedAddress != NULL)
- {
- eRet = jdi_MM1SetCCAddress(hMM1, pFormattedAddress, E_NONE);
- jdd_MemFree(pFormattedAddress);
- pFormattedAddress = NULL;
- }
- else
- {
- eRet = jdi_MM1SetCCAddress(hMM1, pSendInfo->pCc, E_NONE);
- }
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->pBcc)
- {
- GetFormattedAddress(&pFormattedAddress, pSendInfo->pBcc);
- if (pFormattedAddress != NULL)
- {
- eRet = jdi_MM1SetBCCAddress(hMM1, pFormattedAddress, E_NONE);
- jdd_MemFree(pFormattedAddress);
- pFormattedAddress = NULL;
- }
- else
- {
- eRet = jdi_MM1SetBCCAddress(hMM1, pSendInfo->pBcc, E_NONE);
- }
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->pSubject)
- {
- eRet = jdi_MM1SetSubject(hMM1, pSendInfo->pSubject, E_NONE);
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- eRet = jdi_MM1SetMessageClass(hMM1, (EMM1MessageClass) pSendInfo->eMsgClass);
- if (eRet != JC_OK)
- {
- goto error;
- }
- if (pSendInfo->uiExpiryTime)
- {
- eRet = jdi_MM1SetExpiryTime(hMM1, pSendInfo->uiExpiryTime, E_FALSE);
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->uiDeliveryTime)
- {
- eRet = jdi_MM1SetDeliveryTime(hMM1, pSendInfo->uiDeliveryTime, E_FALSE);
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->eMsgPriority > 0)
- {
- eRet = jdi_MM1SetPriority(hMM1, (EMM1MessagePriority) (pSendInfo->eMsgPriority - 1));
- }
- else
- {
- eRet = jdi_MM1SetPriority(hMM1, E_NORMAL_MESSAGE_PRIORITY);
- }
- eRet = jdi_MM1SetSenderVisibility(hMM1, ((pSendInfo->bHideSender == E_TRUE) ? E_FALSE : E_TRUE));
- if (eRet != JC_OK)
- {
- goto error;
- }
- eRet = jdi_MM1SetDeliveryReport(hMM1, pSendInfo->bDeliveryReport);
- if (eRet != JC_OK)
- {
- goto error;
- }
- eRet = jdi_MM1SetReadReplyReport(hMM1, pSendInfo->bReadReport);
- if (eRet != JC_OK)
- {
- goto error;
- }
- #ifdef ENABLE_MMS_VER_1_2
- if (cMinorVersion >= E_MMS_MINOR_VERSION_2 && pSendInfo->pMBoxInfo)
- {
- if (pSendInfo->pMBoxInfo->bMBoxStore == E_TRUE)
- {
- eRet = jdi_MM1SetMMStore(hMM1, pSendInfo->pMBoxInfo->bMBoxStore);
- if (eRet != JC_OK)
- {
- goto error;
- }
- eRet = jdi_MM1SetMMState(hMM1, (EMM1StoreStates) pSendInfo->pMBoxInfo->eMBoxState);
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- if (pSendInfo->pMBoxInfo->pMBoxFlagsType && pSendInfo->pMBoxInfo->pMBoxFlagsType->pAddTokens)
- {
- eRet = jdi_MM1SetMMFlags(hMM1, E_ADD, pSendInfo->pMBoxInfo->pMBoxFlagsType->pAddTokens, E_UCS_2);
- }
- else if (pSendInfo->pMBoxInfo->pMBoxFlagsType && pSendInfo->pMBoxInfo->pMBoxFlagsType->pFilterTokens)
- {
- eRet = jdi_MM1SetMMFlags(hMM1, E_REMOVE, pSendInfo->pMBoxInfo->pMBoxFlagsType->pFilterTokens, E_UCS_2);
- }
- else if (pSendInfo->pMBoxInfo->pMBoxFlagsType && pSendInfo->pMBoxInfo->pMBoxFlagsType->pFilterTokens)
- {
- eRet = jdi_MM1SetMMFlags(hMM1, E_FILTER, pSendInfo->pMBoxInfo->pMBoxFlagsType->pFilterTokens, E_UCS_2);
- }
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- #endif /* ENABLE_MMS_VER_1_2 */
- if (cMinorVersion > E_MMS_MINOR_VERSION_0 && pSendInfo->pReplyChargingInfo != NULL)
- {
- MM1_REPLY_CHARGING MM1ReplyChargingInfo;
- jc_memset(&MM1ReplyChargingInfo, 0x00, sizeof(MM1_REPLY_CHARGING));
- MM1ReplyChargingInfo.eReplyCharging = (EMM1ReplyCharging) pSendInfo->pReplyChargingInfo->eReplyCharging;
- MM1ReplyChargingInfo.uiRelativeTime = pSendInfo->pReplyChargingInfo->uiRelativeTime;
- MM1ReplyChargingInfo.uiSize = pSendInfo->pReplyChargingInfo->uiSize;
- if (pSendInfo->pReplyChargingInfo->eReplyCharging == E_REPLY_CHARGING_NOT_SUPPORTED) /* i.e, if the message is a reply to a reply-charging req message */
- {
- MM1ReplyChargingInfo.pszReplyId = pSendInfo->pReplyChargingInfo->pszReplyId;
- }
- eRet = jdi_MM1SetReplyCharging(hMM1, &MM1ReplyChargingInfo);
- if (eRet != JC_OK)
- {
- goto error;
- }
- }
- /***** 27-03-06 ***/
- if (pMessaging->pParams != NULL)
- {
- /******** Thanik *** 07-04-06***/
- pContentTypeParams = (MM1_HDR_PARAM*) jdd_MemAlloc(sizeof(MM1_HDR_PARAM), 1);
- if (pContentTypeParams == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto error;
- }
- pContentTypeParams->pszName = jdi_UtilsStrdup(pMessaging->pParams->pszName);
- pContentTypeParams->pszValue = jdi_UtilsStrdup(pMessaging->pParams->pszValue);
- if(pMessaging->pParams->pNext != NULL)
- {
- pContentTypeParams->pNext = (MM1_HDR_PARAM*) jdd_MemAlloc(sizeof(MM1_HDR_PARAM), 1);
- if (pContentTypeParams->pNext == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto error;
- }
- pTempContentTypeParams = pContentTypeParams->pNext;
- pTempContentTypeParams->pszName = jdi_UtilsStrdup(pMessaging->pParams->pNext->pszName);
- pTempContentTypeParams->pszValue = jdi_UtilsStrdup(pMessaging->pParams->pNext->pszValue);
- }
- if(pMessaging->pParams->pNext != NULL && pMessaging->pParams->pNext->pNext != NULL)
- {
- pTempContentTypeParams->pNext = (MM1_HDR_PARAM*) jdd_MemAlloc(sizeof(MM1_HDR_PARAM), 1);
- if (pTempContentTypeParams->pNext == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto error;
- }
- pTempContentTypeParams = pTempContentTypeParams->pNext;
- pTempContentTypeParams->pszName = jdi_UtilsStrdup(pMessaging->pParams->pNext->pNext->pszName);
- pTempContentTypeParams->pszValue = jdi_UtilsStrdup(pMessaging->pParams->pNext->pNext->pszValue);
- }
- if (pTempContentTypeParams != NULL)
- {
- pTempContentTypeParams->pNext = NULL;
- }
- /************* Thanik 07-04-06******/
- eRet = jdi_MM1SetContentType(hMM1, NULL, NULL, NULL, pContentTypeParams);
- }
- /***** 27-03-06 ***/
- }
- eRet = JC_OK;
- error:
- if (eRet != JC_OK)
- {
- while (pContentTypeParams != NULL)
- {
- node = pContentTypeParams->pNext;
- if (pContentTypeParams->pszName != NULL)
- {
- jdd_MemFree(pContentTypeParams->pszName);
- pContentTypeParams->pszName = NULL;
- }
- if (pContentTypeParams->pszValue != NULL)
- {
- jdd_MemFree(pContentTypeParams->pszValue);
- pContentTypeParams->pszValue = NULL;
- }
- jdd_MemFree(pContentTypeParams);
- pContentTypeParams = node;
- }
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_java_mms_error
- * DESCRIPTION
- *
- * PARAMETERS
- * error_code [IN]
- * RETURNS
- *
- *****************************************************************************/
- JsrResult mmi_jmms_java_mms_error(JC_RETCODE error_code)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (error_code)
- {
- case JC_OK:
- return JSR_RESULT_OK;
- case JC_ERR_MEMORY_ALLOCATION:
- return JSR_RESULT_INSUFFICIENT_MEMORY;
- case JC_ERR_MSG_MAX_REACHED:
- return JSR_RESULT_EXCEED_MAX_MSGS;
- case JC_ERR_MMS_INVALID_HANDLE:
- case JC_ERR_MMS_INVALID_CONTENT_TYPE:
- case JC_ERR_MMS_INVALID_MMS_VERSION:
- case JC_ERR_MMS_INVALID_MESSAGE_TYPE:
- case JC_ERR_MMS_INVALID_HEADER:
- case JC_ERR_MSG_INVALID_HANDLE:
- case JC_ERR_MSG_INVALID_MESSAGING_TYPE:
- case JC_ERR_MSG_INVALID_PAGE_INDEX:
- case JC_ERR_MSG_INVALID_MEDIA_INDEX:
- return JSR_RESULT_INVALID_MESSAGE;
- case JC_ERR_STORE_INVALID_MSG_INDEX:
- return JSR_RESULT_MESSAGE_ID_NOT_FOUND;