JMMSProtocol.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:298k
源码类别:
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_protocol.C
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file is for handling the send and recieve PDUs for MMS
- *
- * 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!
- * 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!
- * 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!
- *
- * 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!
- * 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!
- * 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!
- * 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!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- /* Include: MMI header file */
- #include "MMI_features.h"
- #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
- #include "stdC.h"
- #include "L4Dr1.h"
- #include "PixtelDataTypes.h"
- #include "HistoryGprot.h"
- #include "GlobalDefs.h"
- #include "SettingProfile.h"
- #include "DebugInitDef.h"
- #include "CommonScreens.h"
- #include "EventsGprot.h"
- #include "wgui_inputs.h"
- #include "wgui_categories.h"
- #include "wgui_categories_inputs.h"
- #include "MainMenuDef.h"
- #include <ddl.h>
- #include <jcal.h>
- #include <jcalnet.h>
- #include "jdi_wspdatatype.h"
- #include "jdi_transport.h"
- #include <jdi_communicator.h>
- #include <MessagingDatatypes.h>
- #include <MessagingAPI.h>
- #include "JMMSExdcl.h"
- #include "FileMgr.h" /* Should include FileMgr.h before ProfileMgrGprot.h */
- #include "Fat_fs.h"
- #include "FileSystemDef.h"
- #include "FileManagerGProt.h"
- #include "SmsGuiInterfaceType.h"
- #include "JProfileHandlerTypes.h"
- #include "JProfileHandlerProts.h"
- #include "JProfileHandlerDefs.h"
- #include "JsrTypes.h"
- #include "JMMSJSRHandler.h"
- #include <PrvMessagingDataTypes.h>
- #include "JMMSInbox.h"
- /* PMT VIKAS START 20060325 */
- #include"JMMSCompose.h"
- #include "MessagesResourceData.h"
- /* PMT VIKAS START 20060325 */
- #include "JBrowserMMIDefs.h"
- #include "TimerEvents.h"
- #include "DebugInitDef.h" /* Debug Info */
- #include "JMMSConfig.h"
- #include "JMMSMessageSettings.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 "miscutils.h"
- #include "CallManagementGprot.h"
- #include "AlarmFrameworkProt.h"
- #include "SmsGuiInterfaceProt.h"
- #include "JSRProts.h"
- #include "JMMSMainMMS.h"
- #include "wapadp.h"
- #include "JPushInboxCommonUI.h"
- #include "PhoneBookGprot.h"
- #include "MMI_features_camera.h"
- #include "CameraResDefs.h"
- #ifdef __USB_IN_NORMAL_MODE__
- #include "USBDeviceGprot.h"
- #endif
- #ifdef __MMI_UNIFIED_MESSAGE__
- #include "UnifiedMessageDef.h"
- #include "UnifiedMessageProt.h"
- #include "JMMSUMHandling.h"
- #include "FileManagerDef.h"
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- /* ... Add More MMI header */
- #include "gpioInc.h"
- /*****************************************************************************
- * Define
- *****************************************************************************/
- /*****************************************************************************
- * Typedef
- *****************************************************************************/
- /*****************************************************************************
- * Local Variable
- *****************************************************************************/
- /*****************************************************************************
- * Local Function
- *****************************************************************************/
- /* /manish */
- extern U16 DeleteScreenFromToNnodes(U16 ScrId, U16 num_nodes);
- extern U8 DeleteFromScrUptoScr(U16 beyondScrnid, U16 tillScrnid);
- extern int wap_is_ready(void);
- extern JC_RETCODE FreeMessageHeaders(MESSAGE_HEADERS **ppMessageHeaders);
- /*****************************************************************************
- * Global Variable
- *****************************************************************************/
- static U16 interupt_screen_title;
- static U8 g_mms_downloading_busy = 0;
- static FuncPtr g_end_key_processing_handler;
- extern U8 *g_media_buffer_p;
- /* Compiler warning removal */
- static void mmi_jmms_end_key_progressing(void);
- static void mmi_jmms_set_end_key_progressing_handler(void);
- /*****************************************************************************
- * Global Function
- *****************************************************************************/
- extern em_wap_user_agent_brand_enum wap_get_user_agent_brand(void);
- extern void TurnOnBacklight(gpio_backlight_time_enum timer_enum);
- extern void TurnOffBacklight(void);
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_create_mms_queue
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_create_mms_queue(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- jdd_QueueCreate(
- (JC_INT32) E_TASK_MMS_UI,
- "MMS UI QUEUE",
- sizeof(JC_EVENT_DATA),
- MAX_NUMBER_OF_EVENTS_IN_MMS_QUEUE,
- E_FALSE);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_ui_events_hdlr
- * DESCRIPTION
- *
- * PARAMETERS
- * pEventData [?] [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_ui_events_hdlr(JC_EVENT_DATA *pEventData)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_ui_events_hdlr"));
- switch (pEventData->iEventType)
- {
- case E_MMS_GET_MSG_LIST_EVENT:
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Event: E_MMS_GET_MSG_LIST_EVENT"));
- mmi_jmms_recieve_get_msg_list_event(pEventData->pEventInfo);
- break;
- }
- case E_COMM_ERROR_INDICATION_EVENT:
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Event: E_COMM_ERROR_INDICATION_EVENT"));
- mmi_jmms_retry_for_error_in_comm(pEventData->pEventInfo);
- break;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_init_protocol
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_init_protocol(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- JC_TASK_INFO appTaskInfo = {0, };
- JC_TASK_INFO transportTaskInfo = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_init_protocol"));
- appTaskInfo.iTaskID = (JC_INT32) E_TASK_MMS_UI;
- appTaskInfo.iAppID = (JC_INT32) E_TASK_MMS_UI;
- transportTaskInfo.iTaskID = (JC_INT32) E_TASK_TRANSPORT;
- transportTaskInfo.iAppID = (JC_INT32) E_TASK_TRANSPORT;
- eRet = jdi_CommunicationInitialize(&appTaskInfo, &transportTaskInfo, g_jmms_context, &g_jmms_context->hCommHandle);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = jdi_CommunicationRegisterHeaderCallback(
- g_jmms_context->hCommHandle,
- (COMM_URL_IND_HEADER_FNC) mmi_jmms_header_ind_callback);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = jdi_CommunicationRegisterURLIndCallback(
- g_jmms_context->hCommHandle,
- (COMM_URL_IND_RESPONSE_FNC) mmi_jmms_url_ind_callback);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = jdi_CommunicationRegisterStopIndCallback(
- g_jmms_context->hCommHandle,
- (COMM_STOP_IND_FNC) mmi_jmms_comm_stop_callback);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = jdi_CommunicationRegisterPushIndCallback(
- g_jmms_context->hCommHandle,
- (COMM_PUSH_IND_FNC) mmi_jmms_push_ind_callback);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = jdi_CommunicationRegisterErrIndCallback(
- g_jmms_context->hCommHandle,
- (COMM_ERR_IND_FNC) mmi_jmms_error_ind_callback);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = jdi_CommunicationRegisterProgressIndCallback(
- g_jmms_context->hCommHandle,
- (COMM_PROGRESS_IND_FNC) mmi_jmms_progress_ind_callback);
- if (JC_OK != eRet)
- {
- goto error;
- }
- eRet = mmi_jmms_set_profile();
- error:
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_progress_ind_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * uiReferenceID [IN]
- * pProgressInd [?] [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_progress_ind_callback(
- jmms_context_struct *jmms_context,
- JC_UINT32 uiReferenceID,
- COMM_PROGRESS_IND *pProgressInd)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_UINT32 percentage_of_progress = 0;
- S8 tmp_str_ascii[20] = {0, };
- S8 tmp_str_ucs2[40] = {0};
- S8 tmp_buff_ucs2[5] = {0};
- U32 len = 0, temp_len = 0;
- S32 size_kb = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* /update only for Deffered Downlaod/New MMS Send */
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS mmi_jmms_progress_ind_callback, with uiReferenceID", uiReferenceID));
- if (g_jmms_context->uiReferenceID == uiReferenceID)
- {
- if (g_jmms_context->progress_screen_title == STR_ID_PROGRESS_SENDING)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Screen ID: STR_ID_PROGRESS_SENDING"));
- if (pProgressInd->eStackStatus == E_COMM_STACK_CONNECTING)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Connecting Screen"));
- len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_CONNECTING));
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- len = (MAX_PROGRESS_SCREEN_HINT_LEN - 1);
- }
- memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
- pfnUnicodeStrncpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_CONNECTING), len);
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
- if ((S32)len <(MAX_PROGRESS_SCREEN_HINT_LEN - 1) - (pfnUnicodeStrlen((S8*) tmp_buff_ucs2)))
- {
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- }
- }
- else if(pProgressInd->eStackStatus == E_COMM_STACK_CONNECTED)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Connected for sending"));
- if(!isInCall() && (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS))
- {
- SetKeyHandler(mmi_jmms_end_comm, KEY_END, KEY_EVENT_DOWN);
- }
- else
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "End Key Not set in Progress_ind"));
- sprintf(tmp_str_ascii, "%d %%", percentage_of_progress);
- AnsiiToUnicodeString(tmp_str_ucs2, tmp_str_ascii);
- len = pfnUnicodeStrlen((S8*) GetString(STR_ID_PROGRESS_SENDING));
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- len = len + pfnUnicodeStrlen(tmp_str_ucs2);
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- len = 0;
- }
- memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
- if (len != 0)
- {
- pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_PROGRESS_SENDING));
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
- }
- else
- {
- pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
- }
- }
- else if (pProgressInd->eStackStatus == E_COMM_STACK_SENDING)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS E_COMM_STACK_SENDING"));
- if(!isInCall() && (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS))
- {
- SetKeyHandler(mmi_jmms_end_comm, KEY_END, KEY_EVENT_DOWN);
- }
- else
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "End Key Not set in Progress_ind")); if ((pProgressInd->uiTotalBytesToSend) != 0)
- {
- percentage_of_progress = (pProgressInd->uiBytesSent) * 100;
- percentage_of_progress = percentage_of_progress / (pProgressInd->uiTotalBytesToSend);
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "JMMS Sending Progress Percentage = ",
- percentage_of_progress));
- sprintf(tmp_str_ascii, "%d %%", percentage_of_progress);
- AnsiiToUnicodeString(tmp_str_ucs2, tmp_str_ascii);
- len = pfnUnicodeStrlen((S8*) GetString(STR_ID_PROGRESS_SENDING));
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- len = len + pfnUnicodeStrlen(tmp_str_ucs2);
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- len = 0;
- }
- memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
- if (len != 0)
- {
- pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_PROGRESS_SENDING));
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
- }
- else
- {
- pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
- }
- }
- else
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "Stack Status=%d Connect=%d Sent=%d",
- pProgressInd->eStackStatus,pProgressInd->eDataConnectionStatus,pProgressInd->uiBytesSent));
- }
- }
- else if (g_jmms_context->progress_screen_title == STR_ID_JMMS_MMS_DOWNLOADING)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Screen ID: STR_ID_PROGRESS_DOWNLOADING"));
- if (pProgressInd->eStackStatus == E_COMM_STACK_CONNECTING)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Connecting Screen"));
- memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
- len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_MMS_DOWNLOADING));
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncpy(
- g_jmms_context->g_jmms_progress_str,
- GetString(STR_ID_JMMS_CONNECTING),
- (MAX_PROGRESS_SCREEN_HINT_LEN - 1));
- }
- else
- {
- pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_CONNECTING));
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- }
- }
- else if (pProgressInd->eStackStatus == E_COMM_STACK_RECEIVING)
- {
- memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
- if ((pProgressInd->uiBytesRecvd) != 0)
- {
- percentage_of_progress = (pProgressInd->uiBytesRecvd);
- }
- size_kb = pProgressInd->uiBytesRecvd / 1024;
- if (size_kb >= 1)
- {
- size_kb++;
- sprintf(tmp_str_ascii, "%d", size_kb);
- }
- else
- {
- sprintf(tmp_str_ascii, "%d", percentage_of_progress);
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Downloading Bytes = ", percentage_of_progress));
- AnsiiToUnicodeString(tmp_str_ucs2, tmp_str_ascii);
- len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_MMS_DOWNLOADING));
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncpy(
- g_jmms_context->g_jmms_progress_str,
- GetString(STR_ID_JMMS_MMS_DOWNLOADING),
- (MAX_PROGRESS_SCREEN_HINT_LEN - 1));
- goto END;
- }
- pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_MMS_DOWNLOADING));
- temp_len = len;
- /*dilip 31st aug to add space after downloading on downloading progress screen*/
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) " ");
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat(
- g_jmms_context->g_jmms_progress_str,
- (S8*) tmp_buff_ucs2,
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- temp_len = len;
- len = len + pfnUnicodeStrlen(tmp_str_ucs2);
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat(
- g_jmms_context->g_jmms_progress_str,
- tmp_str_ucs2,
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
- temp_len = len;
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) " ");
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat(
- g_jmms_context->g_jmms_progress_str,
- (S8*) tmp_buff_ucs2,
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- temp_len = len;
- if(size_kb >=1)
- {
- len = len + pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_KB));
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat(
- g_jmms_context->g_jmms_progress_str,
- GetString(STR_ID_JMMS_KB),
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_KB));
- }
- else
- {
- len = len + pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_BYTES));
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat(
- g_jmms_context->g_jmms_progress_str,
- GetString(STR_ID_JMMS_BYTES),
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_BYTES));
- }
- temp_len = len;
- AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) " ");
- len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat(
- g_jmms_context->g_jmms_progress_str,
- (S8*) tmp_buff_ucs2,
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
- len = len + pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_BYTES_KB_RECIEVED));
- if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
- {
- pfnUnicodeStrncat( g_jmms_context->g_jmms_progress_str,
- GetString(STR_ID_JMMS_BYTES_KB_RECIEVED),
- ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
- goto END;
- }
- pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) GetString(STR_ID_JMMS_BYTES_KB_RECIEVED));
- }
- }
- else
- {
- return;
- }
- END:
- if (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS)
- {
- cat66_update_progress_string();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_set_profile
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_set_profile(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- COMM_PROFILE profile = {0, };
- JC_RETCODE eRet = JC_OK;
- U8 connect_type;
- GENERIC_DATA_CONN pDataConn;
- U8 ip_address[16] = {0x00};
- nvram_mms_profile_content_struct *activated_mms_profile;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_set_profile"));
- activated_mms_profile = mmi_ph_get_activated_mms_profile();
- connect_type = activated_mms_profile->conn_type;
- jc_memset(&profile, 0, sizeof(COMM_PROFILE));
- mmi_jmms_get_ip_address(ip_address, activated_mms_profile->proxy_ip);
- if (connect_type == PH_CONN_TYPE_HTTP)
- {
- if (activated_mms_profile->proxy_port == 0)
- {
- profile.eConnMode = E_COMM_WPHTTP_DIRECT;
- jc_strcpy(profile.szHostName, (JC_INT8*) ip_address);
- profile.uiPortNumber = activated_mms_profile->proxy_port;
- }
- else
- {
- profile.eConnMode = E_COMM_WPHTTP_PROXY;
- jc_strcpy(profile.szHostName, (JC_INT8*) ip_address);
- profile.uiPortNumber = activated_mms_profile->proxy_port;
- }
- }
- else if (connect_type == PH_CONN_TYPE_CONNECTION_OREINTED)
- {
- profile.eConnMode = E_COMM_WSP_CONNECTION_ORIENTED;
- jc_strcpy(profile.szHostName, (JC_INT8*) ip_address);
- profile.uiPortNumber = 0;
- }
- else
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- eRet = jdi_CommunicationProfile(g_jmms_context->hCommHandle, &profile);
- if (eRet != JC_OK)
- {
- goto ERROR_HANDLE;
- }
- pDataConn.account_id = activated_mms_profile->data_account;
- eRet = jdi_CommunicationDataConnection(g_jmms_context->hCommHandle, (const GENERIC_DATA_CONN*)&pDataConn);
- ERROR_HANDLE:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_set_profile return:", eRet));
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_ip_address
- * DESCRIPTION
- *
- * PARAMETERS
- * ip_address [?] [?] [?]
- * proxy_ip [?] [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_get_ip_address(U8 *ip_address, U8 *proxy_ip)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 temp[4] = {0x00};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf((S8*) ip_address, "%d", proxy_ip[0]);
- strcat((S8*) ip_address, ".");
- sprintf((S8*) temp, "%d", proxy_ip[1]);
- strcat((S8*) ip_address, (S8*) temp);
- strcat((S8*) ip_address, ".");
- memset(temp, 0x00, 4);
- sprintf((S8*) temp, "%d", proxy_ip[2]);
- strcat((S8*) ip_address, (S8*) temp);
- strcat((S8*) ip_address, ".");
- memset(temp, 0x00, 4);
- sprintf((S8*) temp, "%d", proxy_ip[3]);
- strcat((S8*) ip_address, (S8*) temp);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_activated_mmsc_url
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 *mmi_jmms_get_activated_mmsc_url(jmms_context_struct *jmms_context)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *mmsc_url = NULL;
- U32 len = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_get_activated_mmsc_url"));
- mmsc_url = mmi_ph_mms_get_activated_profile_mmsc_url(); /* //for getting the mmsc url */
- if (mmsc_url == NULL)
- {
- return NULL;
- }
- len = (strlen((S8*) mmsc_url) + 1) * ENCODING_LENGTH;
- if (jmms_context->activated_mmsc_url != NULL)
- {
- jdd_MemFree(jmms_context->activated_mmsc_url);
- }
- jmms_context->activated_mmsc_url = (U8*) jdd_MemAlloc(sizeof(U8), len);
- if (jmms_context->activated_mmsc_url == NULL)
- {
- return NULL;
- }
- AnsiiToUnicodeString((PS8) (jmms_context->activated_mmsc_url), (PS8) mmsc_url);
- return (jmms_context->activated_mmsc_url);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_push_ind_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * pCommArg [?] [?] [?]
- * pPushContentInd [?] [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_push_ind_callback(void *pCommArg, COMM_PUSH_IND *pPushContentInd)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- CONTENT_DATA ViewContent = {0, };
- MSG_HANDLE hMsgHandle = NULL;
- MESSAGE_HEADERS *pMsgHdrs = NULL;
- MESSAGE_NOTIFICATION *pNotifyIndHdrs;
- JC_UINT32 msg_index = 0;
- /* JC_UINT32 msgid = 0; */
- U8 number_mms = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_push_ind_callback"));
- if (!wap_is_ready())
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: WAP is not ready"));
- return;
- }
- if(g_jmms_context->init_done == JMMS_READY_WITHOUT_STORE)
- {
- interupt_screen_title=STR_ID_JMMS_MEMORY_ERROR_NEW_MMS_NOTIF_SAVING;
- mmi_jmms_entry_general_pop_screen_in_case_interupt();
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Store is not ready"));
- return;
- }
- eRet = mmi_jmms_get_total_number_of_messages(&number_mms);
- if (eRet != JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "JMMS Bad Store Module, Return Code: ", eRet));
- ASSERT(0) return;
- }
- if (number_mms >= MAX_POSSIBLE_MESSAGES_THRESHOLD)
- {
- mmi_jmms_update_status_icon_indicator();
- }
- if (number_mms >= MAX_POSSIBLE_MESSAGES)
- {
- mmi_jmms_add_memory_full_node_if_not_already();
- return;
- }
- if (NULL != pPushContentInd->pszContentType)
- {
- if (0 == jc_strcmp(pPushContentInd->pszContentType, "application/vnd.wap.mms-message"))
- {
- ViewContent.uiCurSize = ViewContent.uiTotalSize = pPushContentInd->uiLength;
- /* ViewContent.VIEW_MODE.contentInline.pBuffer = (JC_INT8 *)pPushContentInd->pBuffer ; */
- ViewContent.pBuffer = (JC_UINT8*) pPushContentInd->pBuffer;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Message parsing for Message header starts"));
- eRet = mmi_jmms_jdi_parse_msg_buffer(&hMsgHandle, &ViewContent, 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)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Error in parsing message headers, Error code: ",
- eRet));
- if (hMsgHandle != NULL)
- {
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- }
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_UNABLE_PARSE_PUSH,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- if (eRet == JC_OK)
- {
- mmi_jmms_check_for_idle_screen();
- }
- return;
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Message parsing for Message header SUCCESSFUL!!!"));
- eRet = mmi_jmms_jdi_get_msg_headers(hMsgHandle, &pMsgHdrs);
- if (JC_OK != eRet)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Error in getting message headers, Error code",
- eRet));
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_UNABLE_PARSE_PUSH,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- if (eRet == JC_OK)
- {
- mmi_jmms_check_for_idle_screen();
- }
- return;
- }
- if (pMsgHdrs->eMsgType == E_MSG_TYPE_DELIVERY_REPORT)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Push Indication for JMMS Delivery Report Received"));
- /* save the delivery report in inbox */
- #ifdef __MMI_UNIFIED_MESSAGE__
- {
- JC_UINT32 temp_extra_byte = 0x02000000;
- eRet = mmi_jmms_save_message_buffer_in_Store(
- "Inbox",
- &msg_index,
- pMsgHdrs,
- &ViewContent,
- &temp_extra_byte);
- }
- #else /* __MMI_UNIFIED_MESSAGE__ */
- mmi_jmms_save_message_buffer_in_Store("Inbox", &msg_index, pMsgHdrs, &ViewContent, NULL);
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- eRet = mmi_jmms_add_pending_mms_info_node((U16) msg_index, (U8) E_MSG_TYPE_DELIVERY_REPORT, NULL);
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_add_pending_mms_delivery_report_node(
- (U8) (((DELIVERY_REPORT*) pMsgHdrs->pHeaders)->eDeliveryStatus),
- (S8 *) (((DELIVERY_REPORT*) pMsgHdrs->pHeaders)->pTo),
- ((DELIVERY_REPORT*) pMsgHdrs->pHeaders)->uiDate);
- if (eRet == JC_OK)
- {
- mmi_jmms_show_new_mms_pop_up();
- }
- }
- if (eRet != JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)",
- "JMMS, Error in saving Delivery Report, Error code: ", eRet));
- if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
- {
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_MEMORY_ERROR_DELIVERY_SAVING,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- }
- else
- {
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_ERROR_DELIVERY_SAVING,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- }
- if (eRet == JC_OK)
- {
- mmi_jmms_check_for_idle_screen();
- }
- }
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- return;
- }
- else if (pMsgHdrs->eMsgType == E_MSG_TYPE_READ_REPORT_RESPONSE)
- {
- // TODO:::need to test the read report PDU
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Push Indication for JMMS Read Report received"));
- eRet = mmi_jmms_add_pending_mms_info_node((U16) msg_index, (U8) E_MSG_TYPE_READ_REPORT_RESPONSE, NULL);
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_add_pending_mms_read_report_node(
- (U8) (((READ_REPORT_RESPONSE*) pMsgHdrs->pHeaders)->eReadStatus),
- (S8 *) (((READ_REPORT_RESPONSE*) pMsgHdrs->pHeaders)->pFrom),
- ((READ_REPORT_RESPONSE*) pMsgHdrs->pHeaders)->uiReceivedTime);
- if (eRet == JC_OK)
- {
- mmi_jmms_show_new_mms_pop_up();
- }
- }
- /* /save the read report in inbox. */
- #ifdef __MMI_UNIFIED_MESSAGE__
- {
- JC_UINT32 temp_extra_byte = 0x02000000;
- eRet = mmi_jmms_save_message_buffer_in_Store(
- "Inbox",
- &msg_index,
- pMsgHdrs,
- &ViewContent,
- &temp_extra_byte);
- }
- #else /* __MMI_UNIFIED_MESSAGE__ */
- eRet = mmi_jmms_save_message_buffer_in_Store("Inbox", &msg_index, pMsgHdrs, &ViewContent, NULL);
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- if (eRet != JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Error in saving Read Report, Error code",
- eRet));
- if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
- {
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_MEMORY_ERROR_READ_REPORT_SAVING,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- }
- else
- {
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_ERROR_READ_REPORT_SAVING,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- }
- if (eRet == JC_OK)
- {
- mmi_jmms_check_for_idle_screen();
- }
- }
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- return;
- }
- else if (pMsgHdrs->eMsgType != E_MSG_TYPE_NOTIFICATION)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Invalid Message Type", pMsgHdrs->eMsgType));
- mmi_jmms_jdi_msg_deinit(hMsgHandle);
- hMsgHandle = NULL;
- eRet = mmi_jmms_add_pending_mms_info_node(
- (U16) STR_ID_JMMS_UNABLE_PARSE_PUSH,
- (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
- NULL);
- if (eRet == JC_OK)
- {
- mmi_jmms_check_for_idle_screen();
- }
- return;
- }
- ///Transaction ID should be in ASCII
- //otherwise need changes
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Push Indication for JMMS Notification received"));
- pNotifyIndHdrs = (MESSAGE_NOTIFICATION*) pMsgHdrs->pHeaders;
- if (g_jmms_context->pTransactionID != NULL)
- {
- if (strcmp(pNotifyIndHdrs->pTransactionID, g_jmms_context->pTransactionID) == 0)
- {
- mmi_jmms_jdi_msg_deinit(hMsgHandle); /* Deepali Review????? */
- hMsgHandle = NULL;
- return;
- }
- jdd_MemFree(g_jmms_context->pTransactionID);
- }
- g_jmms_context->pTransactionID =
- (JC_INT8*) jdd_MemAlloc(sizeof(JC_INT8), strlen(pNotifyIndHdrs->pTransactionID) + 1);
- if (g_jmms_context->pTransactionID != NULL)
- {
- strcpy(g_jmms_context->pTransactionID, pNotifyIndHdrs->pTransactionID);
- }
- mmi_jmms_handle_new_mms_notification(&ViewContent, hMsgHandle, pNotifyIndHdrs);
- if (NULL != hMsgHandle)
- {
- eRet = mmi_jmms_jdi_msg_deinit(hMsgHandle);
- if (JC_OK != eRet)
- {
- return;
- }
- hMsgHandle = NULL;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_add_pending_mms_delivery_report_node
- * DESCRIPTION
- *
- * PARAMETERS
- * status [IN]
- * to_address [?] [?] [?]
- * date [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_add_pending_mms_delivery_report_node(U8 status, S8 *to_address, JC_UINT32 date)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_pending_mms_delivery_reports_struct *node;
- U16 currScrenID;
- U32 len = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_add_pending_mms_delivery_report_node"));
- currScrenID = GetActiveScreenId();
- node =
- (jmms_pending_mms_delivery_reports_struct*) jdd_MemAlloc(sizeof(jmms_pending_mms_delivery_reports_struct), 1);
- if (node == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- node->status = status;
- node->date = date;
- if (to_address != NULL)
- {
- len = (pfnUnicodeStrlen((S8*) to_address) + 1) * ENCODING_LENGTH;
- node->to_p = (S8*) jdd_MemAlloc(sizeof(S8), len);
- if (node->to_p == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- memcpy(node->to_p, to_address, len);
- }
- else
- {
- node->to_p = NULL;
- }
- if (currScrenID == SCR_ID_JMMS_NEW_MMS_IND &&
- (g_jmms_context->pending_mms_info_list->type == E_MSG_TYPE_DELIVERY_REPORT))
- { /* /add as second node of link list */
- if (g_jmms_context->pending_delivery_reports == NULL) /* /not possible */
- {
- return E_JMMS_GENERAL_ERROR;
- }
- else
- {
- node->next = g_jmms_context->pending_delivery_reports->next;
- g_jmms_context->pending_delivery_reports->next = node;
- }
- }
- else /* /add as first node of link list */
- {
- node->next = g_jmms_context->pending_delivery_reports;
- g_jmms_context->pending_delivery_reports = node;
- }
- return JC_OK;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_add_pending_mms_read_report_node
- * DESCRIPTION
- *
- * PARAMETERS
- * status [IN]
- * from_address [?] [?] [?]
- * date [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_add_pending_mms_read_report_node(U8 status, S8 *from_address, JC_UINT32 date)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_pending_mms_read_reports_struct *node;
- U16 currScrenID;
- U32 len = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- currScrenID = GetActiveScreenId();
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_add_pending_mms_read_report_node"));
- node = (jmms_pending_mms_read_reports_struct*) jdd_MemAlloc(sizeof(jmms_pending_mms_read_reports_struct), 1);
- if (node == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- node->status = status;
- node->date = date;
- if (from_address != NULL)
- {
- len = (pfnUnicodeStrlen((S8*) from_address) + 1) * ENCODING_LENGTH;
- node->from_p = (S8*) jdd_MemAlloc(sizeof(S8), len);
- if (node->from_p == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- memcpy(node->from_p, from_address, len);
- }
- else
- {
- node->from_p = NULL;
- }
- if (currScrenID == SCR_ID_JMMS_NEW_MMS_IND &&
- (g_jmms_context->pending_mms_info_list->type == E_MSG_TYPE_READ_REPORT_RESPONSE))
- { /* /add as second node of link list */
- if (g_jmms_context->pending_read_reports == NULL) /* /not possible */
- {
- return E_JMMS_GENERAL_ERROR;
- }
- else
- {
- node->next = g_jmms_context->pending_read_reports->next;
- g_jmms_context->pending_read_reports->next = node;
- }
- }
- else /* /add as first node of link list */
- {
- node->next = g_jmms_context->pending_read_reports;
- g_jmms_context->pending_read_reports = node;
- }
- return JC_OK;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_add_pending_mms_info_node
- * DESCRIPTION
- *
- * PARAMETERS
- * msg_index [IN]
- * msg_type [IN]
- * content_location [?] [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_add_pending_mms_info_node(U16 msg_index, U8 msg_type, S8 *content_location)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_pending_mms_info_struct *node;
- U16 currScrenID;
- U32 len = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_add_pending_mms_info_node"));
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (msg_type != E_MSG_TYPE_IDLE_SCREEN_POP_UP)
- {
- TurnOnBacklight(GPIO_BACKLIGHT_SHORT_TIME);
- mmi_um_jmms_new_mms_message_ind(msg_index);
- return JC_OK;
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- currScrenID = GetActiveScreenId();
- node = (jmms_pending_mms_info_struct*) jdd_MemAlloc(sizeof(jmms_pending_mms_info_struct), 1);
- if (node == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- node->Index = msg_index;
- node->type = msg_type;
- if (content_location != NULL)
- {
- len = strlen((S8*) content_location) + 1;
- node->mms_url = (S8*) jdd_MemAlloc(sizeof(S8), len);
- if (node->mms_url == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- memcpy(node->mms_url, content_location, len);
- }
- else
- {
- node->mms_url = NULL;
- }
- if (currScrenID == SCR_ID_JMMS_NEW_MMS_IND)
- { /* /add as second node of link list */
- if (g_jmms_context->pending_mms_info_list == NULL) /* /not possible */
- {
- return E_JMMS_GENERAL_ERROR;
- }
- else
- {
- node->next = g_jmms_context->pending_mms_info_list->next;
- g_jmms_context->pending_mms_info_list->next = node;
- }
- }
- else /* /add as first node of link list */
- {
- node->next = g_jmms_context->pending_mms_info_list;
- g_jmms_context->pending_mms_info_list = node;
- }
- return JC_OK;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_header_ind_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * pCommHeaderInd [?] [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_header_ind_callback(jmms_context_struct *jmms_context, COMM_HEADER_INDICATION *pCommHeaderInd)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- jmms_communication_state_node *comm_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Header Ind Callback, Request Id:",
- pCommHeaderInd->uiRequestID));
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Header Ind HTTP Status:", pCommHeaderInd->eStatus));
- comm_node = mmi_jmms_get_comm_state(jmms_context, pCommHeaderInd->uiRequestID);
- if (comm_node == NULL)
- {
- if (pCommHeaderInd->uiRequestID)
- {
- jdi_CommunicationFreeReference(jmms_context->hCommHandle, pCommHeaderInd->uiRequestID);
- }
- pCommHeaderInd->uiRequestID = 0;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)",
- "JMMS: No commn node for this Header Indication, so free communication reference for request id:",
- pCommHeaderInd->uiRequestID));
- return E_JMMS_GENERAL_ERROR; /* error type doesn't matter */
- }
- if (pCommHeaderInd->eStatus != 200) /* /200 is HTTP OK */
- {
- if (pCommHeaderInd->uiRequestID)
- {
- eRet = jdi_CommunicationFreeReference(jmms_context->hCommHandle, pCommHeaderInd->uiRequestID);
- if (JC_OK != eRet)
- {
- mmi_jmms_handle_error_in_communication(
- jmms_context,
- E_FROM_URL_CALLBACK,
- comm_node,
- pCommHeaderInd->eStatus);
- mmi_jmms_free_comm_node(jmms_context, pCommHeaderInd->uiRequestID);
- pCommHeaderInd->uiRequestID = 0;
- return JC_ERR_MEMORY_ALLOCATION; /* error type doesn't matter */
- }
- }
- eRet = mmi_jmms_retry_communication(
- jmms_context,
- E_FROM_URL_CALLBACK,
- pCommHeaderInd->uiRequestID,
- pCommHeaderInd->eStatus);
- if (JC_OK != eRet)
- {
- mmi_jmms_handle_error_in_communication(
- jmms_context,
- E_FROM_URL_CALLBACK,
- comm_node,
- E_JMMS_DEAFULT_COMM_ERROR_CODE);
- mmi_jmms_free_comm_node(jmms_context, pCommHeaderInd->uiRequestID);
- pCommHeaderInd->uiRequestID = 0;
- // sandeep start to fix PMTSW00006618
- #ifdef __MMI_UNIFIED_MESSAGE__
- if((comm_node->mms_communication_state == E_TYPE_NOTIFICATION_RESPONSE) && IsScreenPresent(SCR_ID_UM_UNSENT))
- {
- DeleteUptoScrID(SCR_ID_UM_UNSENT);
- }
- #endif
- //sandeep end to fix PMTSW00006618
- return JC_ERR_MEMORY_ALLOCATION; /* error type doesn't matter */
- }
- mmi_jmms_free_comm_node(jmms_context, pCommHeaderInd->uiRequestID);
- return E_JMMS_GENERAL_ERROR; /* error type doesn't matter. By virtue of !=JC_OK value communicator will delete */
- /* /this request so that url Indication Callback will not be further called */
- }
- comm_node->pContentType = (JC_INT8*) jdi_UtilsStrdup(pCommHeaderInd->pszContentType);
- if(comm_node->mms_communication_state == E_TYPE_NOTIFICATION_RESPONSE ||
- comm_node->mms_communication_state == E_TYPE_READ_REPORT_PDU ||
- comm_node->mms_communication_state == E_TYPE_ACK_RESPONSE)
- {
- mmi_jmms_free_comm_node(g_jmms_context, pCommHeaderInd->uiRequestID);
- }
- return JC_OK;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_url_ind_callback
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * pURLInd [?] [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_url_ind_callback(jmms_context_struct *jmms_context, COMM_FETCH_URL_IND_RESP *pURLInd)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- CONTENT_DATA Content = {0, };
- JC_RETCODE error = JC_OK;
- jmms_communication_state_node *comm_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_url_ind_callback"));
- comm_node = mmi_jmms_get_comm_state(jmms_context, pURLInd->uiRequestID);
- if (comm_node == NULL)
- {
- if (pURLInd->uiRequestID)
- {
- eRet = jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
- }
- pURLInd->uiRequestID = 0;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)",
- "JMMS: No commn node for this id, call jdi_CommunicationFreeReference",
- pURLInd->uiRequestID));
- return E_JMMS_GENERAL_ERROR;
- }
- if (pURLInd->uiCurrentLength > 0)
- {
- if (comm_node->hFile == NULL)
- {
- JC_INT8 Temp[50] = {0, };
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Handle Url First Chunk, Request id",
- pURLInd->uiRequestID));
- if (comm_node->fs_handle == NULL)
- {
- if (jdd_FSInitialize(&comm_node->fs_handle) != JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "Error In Init File"));
- eRet = JC_ERR_FILE_OPEN;
- mmi_jmms_handle_error_in_communication(
- jmms_context,
- E_FROM_URL_CALLBACK,
- comm_node,
- E_JMMS_DEAFULT_COMM_ERROR_CODE);
- jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
- mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
- pURLInd->uiRequestID = 0;
- return eRet;
- }
- }
- /* manish for file path change */
- jc_sprintf(Temp, "%s%d", "@mms\temp\jmms_temp", pURLInd->uiRequestID);
- jdi_UtilsCharToTchar(&(comm_node->pFileName), Temp);
- comm_node->hFile = jdd_FSOpen(comm_node->fs_handle, comm_node->pFileName, E_CREATE_WRITE_MODE);
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Handle other Url Chunks, Request Id:",
- pURLInd->uiRequestID));
- #if defined (__USB_IN_NORMAL_MODE__)
- if (mmi_jmms_check_usb_mode() )
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "USB Mode: Write To File"));
- }
- #endif
- error = jdd_FSWrite(pURLInd->pucBuffer, pURLInd->uiCurrentLength, 1, comm_node->hFile);
- #if defined (__USB_IN_NORMAL_MODE__)
- if (mmi_jmms_check_usb_mode() )
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "USB Mode: Write To File return=%d", error));
- #endif
- if (error != 1)
- {
- if (error == JC_ERR_FILE_FULL || error == JC_ERR_FILE_WRITE)
- {
- mmi_jmms_handle_error_in_communication(jmms_context, E_FROM_URL_CALLBACK, comm_node, JC_ERR_FILE_FULL);
- }
- else
- {
- mmi_jmms_handle_error_in_communication(
- jmms_context,
- E_FROM_URL_CALLBACK,
- comm_node,
- E_JMMS_DEAFULT_COMM_ERROR_CODE);
- }
- if (comm_node->hFile != NULL)
- {
- jdd_FSClose(comm_node->hFile);
- }
- jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
- mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
- pURLInd->uiRequestID = 0;
- return JC_ERR_FILE_OPEN;
- }
- comm_node->reponse_size += pURLInd->uiCurrentLength;
- }
- if (pURLInd->bHasMoreData == E_FALSE)
- {
- if (comm_node->hFile)
- {
- if (comm_node->reponse_size > 0)
- {
- jdd_FSClose(comm_node->hFile);
- /* /7 March */
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- Content.bIsStream = E_TRUE;
- Content.cbReadCallback = mmi_jmms_read_callback;
- Content.uiTotalSize = comm_node->reponse_size;
- Content.uiCurSize = 0;
- Content.pStream = comm_node->pFileName;
- Content.pFileName = comm_node->pFileName;
- }
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS URL Chunks Finished. Request id:", pURLInd->uiRequestID));
- /* /When control is here then no problem with return eRet because after that */
- eRet = mmi_jmms_handle_url_repsonse(jmms_context, pURLInd, Content);
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_url_ind_callback return:", eRet));
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_handle_url_repsonse
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * pURLInd [?] [?] [?]
- * Content [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_handle_url_repsonse(
- jmms_context_struct *jmms_context,
- COMM_FETCH_URL_IND_RESP *pURLInd,
- CONTENT_DATA Content)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_communication_state_node *comm_node = NULL;
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_handle_url_repsonse"));
- comm_node = mmi_jmms_get_comm_state(jmms_context, pURLInd->uiRequestID);
- if (comm_node == NULL)
- {
- if (pURLInd->uiRequestID)
- {
- jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
- }
- pURLInd->uiRequestID = 0;
- return JC_ERR_MEMORY_ALLOCATION;
- }
- if (Content.uiTotalSize != 0) /* for notification response/ack response this value will be 0 and content type will return */
- {
- if (comm_node->pContentType == NULL ||
- jc_strcmp(comm_node->pContentType, "application/vnd.wap.mms-message") != 0)
- {
- if (pURLInd->uiRequestID)
- {
- jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
- }
- /* Todo: Need to pass approraite error code- last parameter */
- mmi_jmms_handle_error_in_communication(
- jmms_context,
- E_FROM_URL_CALLBACK,
- comm_node,
- JMMS_WRONG_CONTENT_TYPE_ERROR);
- mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
- pURLInd->uiRequestID = 0;
- return JC_ERR_MEMORY_ALLOCATION; /* error type does not matter */
- }
- }
- switch (comm_node->mms_communication_state)
- {
- case E_TYPE_ACK_RESPONSE:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS ACK Response, Request ID: ", pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_notification_ack_response(jmms_context, pURLInd, &Content);
- break;
- case E_TYPE_NOTIFICATION_RESPONSE:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Notification Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_notification_ack_response(jmms_context, pURLInd, &Content);
- break;
- case E_TYPE_READ_REPORT_PDU:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS READ Report PDU Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_read_report_pdu_response(jmms_context, pURLInd, &Content);
- break;
- case E_TYPE_READ_REPORT_MMS:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Read Report MMS Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_read_report_mms_response(jmms_context, pURLInd, &Content);
- break;
- case E_TYPE_IMMEDIATE_RETRIEVAL_FETCH:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Immdiate Download Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_immediate_downlaod_response(jmms_context, pURLInd, &Content);
- break;
- case E_TYPE_DEFFERED_RETRIEVAL_FETCH:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Deferred Download Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_deffered_downlaod_response(jmms_context, pURLInd, &Content);
- break;
- #ifdef MMI_JMMS_JAVA_MMS_SUPPORT
- case E_TYPE_NEW_JAVA_MMS_SEND:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS JSR New MMS Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_jsr_mms_send_response(jmms_context, pURLInd, Content);
- break;
- #endif /* MMI_JMMS_JAVA_MMS_SUPPORT */
- case E_TYPE_NEW_MMS:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS New MMS Send Response, Request ID: ",
- pURLInd->uiRequestID));
- eRet = mmi_jmms_handle_new_mms_send_response(jmms_context, pURLInd, &Content);
- break;
- default:
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Undefined Communication State, Request ID: ",
- pURLInd->uiRequestID));
- mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
- } /* /end of switch switch(jmms_context->mms_communication_state) */
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_handle_url_repsonse return:", eRet));
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_free_comm_node
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * uiReferenceID [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_free_comm_node(jmms_context_struct *jmms_context, JC_UINT32 uiReferenceID)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_communication_state_node *comm_node = NULL, *previous_node = NULL;
- jmms_communication_state_node *temp_comp_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- comm_node = jmms_context->comm_state;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_free_comm_node"));
- /* / 7 March */
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- return;
- }
- }
- while (comm_node != NULL)
- {
- if (comm_node->uiReferenceID == uiReferenceID)
- {
- if (comm_node->hFile)
- {
- jdd_FSClose(comm_node->hFile);
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName);
- comm_node->hFile = NULL;
- }
- if ((comm_node->pFileName) != NULL)
- {
- jdd_MemFree(comm_node->pFileName);
- comm_node->pFileName = NULL;
- }
- if ((comm_node->fs_handle) != NULL)
- {
- jdd_FSDeinitialize(comm_node->fs_handle);
- }
- if ((comm_node->pFileName_used_for_Send) != NULL)
- {
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName_used_for_Send);
- jdd_MemFree(comm_node->pFileName_used_for_Send);
- comm_node->pFileName_used_for_Send = NULL;
- }
- if ((comm_node->pContentType) != NULL)
- {
- jdd_MemFree(comm_node->pContentType);
- comm_node->pContentType = NULL;
- }
- if ((comm_node->mms_content_location) != NULL)
- {
- jdd_MemFree(comm_node->mms_content_location);
- comm_node->mms_content_location = NULL;
- }
- if((comm_node->mms_communication_state != E_TYPE_NOTIFICATION_RESPONSE) &&
- (comm_node->mms_communication_state != E_TYPE_READ_REPORT_PDU) &&
- (comm_node->mms_communication_state != E_TYPE_READ_REPORT_MMS) &&
- (comm_node->mms_communication_state != E_TYPE_ACK_RESPONSE))
- {
- mmi_jmms_reset_mms_downloading_busy();
- mmi_jmms_update_status_icon_indicator();
- }
- if (previous_node == NULL)
- {
- /*Vikram: The target is to set the g_jmms_context->uiReferenceID value. For the case, MMS Send->Notification
- MMS Send Retry, g_jmms_context->uiReferenceID will get 0 after Notification*/
- jmms_context->comm_state = comm_node->next;
- }
- else
- {
- previous_node->next = comm_node->next;
- }
- /* Cannot set the uiReferenceID as 0. The reason is that incase of MMS download retry, the new MMS retry is being done and after that
- the previous comm node is freed. So if we set the uiReferenceID as 0 here, the download abort will stop working. Also may other things
- will misbehave*/
- /* g_jmms_context->uiReferenceID = 0;*/
- temp_comp_node = jmms_context->comm_state;
- while(temp_comp_node &&
- !((temp_comp_node->mms_communication_state == E_TYPE_NEW_MMS)||
- (temp_comp_node->mms_communication_state == E_TYPE_DEFFERED_RETRIEVAL_FETCH)||
- (temp_comp_node->mms_communication_state == E_TYPE_NEW_JAVA_MMS_SEND)))
- {
- temp_comp_node = temp_comp_node->next;
- }
- if(temp_comp_node)
- g_jmms_context->uiReferenceID=temp_comp_node->uiReferenceID;
- else
- g_jmms_context->uiReferenceID = 0;
- temp_comp_node = jmms_context->comm_state;
- while(temp_comp_node)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "n%s%d", "g_jmms_context->uiReferenceID = ", g_jmms_context->uiReferenceID));
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "n%s%d", "Communication State = ", temp_comp_node->mms_communication_state));
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "n%s%d", "Reference Id = ", temp_comp_node->uiReferenceID));
- temp_comp_node = temp_comp_node->next;
- }
- jdd_MemFree(comm_node);
- break;
- }
- previous_node = comm_node;
- comm_node = comm_node->next;
- }
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- /* /added for disappearing the G icon */
- if (g_jmms_context->comm_state == NULL)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Timer for Disconnect "));
- StartTimer(JMMS_NO_COMM_TIMER_CHECK, 10000, mmi_jmms_comm_time_hdlr);
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Comm Node Free for Request ID", uiReferenceID));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_is_immediate_retrival_underway
- * DESCRIPTION
- * Returns whether any immediate retrival is underway
- * PARAMETERS
- * void
- * uiReferenceID(?) [IN]
- * jmms_context [?](?)
- * RETURNS
- * void
- *****************************************************************************/
- S32 mmi_jmms_is_immediate_retrival_underway(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_INT32 retrival_underway=E_FALSE;
- jmms_communication_state_node *comm_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- comm_node = g_jmms_context->comm_state;
- while (comm_node != NULL)
- {
- if(comm_node->mms_communication_state == E_TYPE_IMMEDIATE_RETRIEVAL_FETCH)
- {
- retrival_underway=E_TRUE;
- break;
- }
- comm_node = comm_node->next;
- }
- return retrival_underway;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_free_comm_node_list
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * uiReferenceID(?) [IN]
- * jmms_context [?](?)
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_free_comm_node_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_communication_state_node *comm_node = NULL, *previous_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- comm_node = g_jmms_context->comm_state;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_free_comm_node"));
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- return;
- }
- }
- while (comm_node != NULL)
- {
- if (comm_node->uiReferenceID != 0)
- {
- jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, comm_node->uiReferenceID);
- }
- if (comm_node->hFile)
- {
- jdd_FSClose(comm_node->hFile);
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName);
- comm_node->hFile = NULL;
- }
- if ((comm_node->pFileName) != NULL)
- {
- jdd_MemFree(comm_node->pFileName);
- comm_node->pFileName = NULL;
- }
- if ((comm_node->pFileName_used_for_Send) != NULL)
- {
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName_used_for_Send);
- jdd_MemFree(comm_node->pFileName_used_for_Send);
- comm_node->pFileName_used_for_Send = NULL;
- }
- if ((comm_node->pContentType) != NULL)
- {
- jdd_MemFree(comm_node->pContentType);
- comm_node->pContentType = NULL;
- }
- if ((comm_node->mms_content_location) != NULL)
- {
- jdd_MemFree(comm_node->mms_content_location);
- comm_node->mms_content_location = NULL;
- }
- comm_node->mms_communication_state = E_TYPE_NULL;
- if (previous_node == NULL)
- {
- g_jmms_context->comm_state = comm_node->next;
- }
- else
- {
- previous_node->next = comm_node->next;
- }
- jdd_MemFree(comm_node);
- comm_node = comm_node->next;
- mmi_jmms_stop_download_busy();
- mmi_jmms_update_status_icon_indicator();
- }
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- if (g_jmms_context->comm_state == NULL)
- {
- jdi_CommunicationDisconnect(g_jmms_context->hCommHandle);
- g_mms_downloading_busy = 0;
- mmi_jmms_update_status_icon_indicator();
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Comm list for File Format Issue"));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_comm_time_hdlr
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_comm_time_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_comm_time_hdlr"));
- if (g_jmms_context->comm_state == NULL)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_comm_time_hdlr : Disconnect"));
- jdi_CommunicationDisconnect(g_jmms_context->hCommHandle);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_add_comm_node
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * uiReferenceID [IN]
- * comm_state [IN]
- * file_name_for_send [?] [?] [?]
- * msg_index [IN]
- * retry_counter [IN]
- * content_location [?] [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_add_comm_node(
- jmms_context_struct *jmms_context,
- JC_UINT32 uiReferenceID,
- U16 comm_state,
- JC_CHAR *file_name_for_send,
- JC_UINT32 msg_index,
- U8 retry_counter,
- S8 *content_location)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_communication_state_node *comm_node = NULL;
- jmms_communication_state_node *temp_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- comm_node = (jmms_communication_state_node*) jdd_MemAlloc(1, sizeof(jmms_communication_state_node));
- if (comm_node == NULL)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- comm_node->hFile = NULL;
- comm_node->mms_communication_state = comm_state;
- comm_node->next = NULL;
- comm_node->pFileName = NULL;
- comm_node->reponse_size = 0;
- comm_node->uiReferenceID = uiReferenceID;
- comm_node->pFileName_used_for_Send = file_name_for_send;
- comm_node->msg_index = msg_index;
- comm_node->retry_counter = retry_counter;
- comm_node->mms_content_location = content_location;
- comm_node->fs_handle = NULL;
- if (jmms_context->comm_state == NULL)
- {
- jmms_context->comm_state = comm_node;
- }
- else
- {
- temp_node = jmms_context->comm_state;
- while (temp_node->next != NULL)
- {
- temp_node = temp_node->next;
- }
- temp_node->next = comm_node;
- }
- if((comm_node->mms_communication_state != E_TYPE_NOTIFICATION_RESPONSE) &&
- (comm_node->mms_communication_state != E_TYPE_READ_REPORT_PDU) &&
- (comm_node->mms_communication_state != E_TYPE_READ_REPORT_MMS) &&
- (comm_node->mms_communication_state != E_TYPE_ACK_RESPONSE))
- {
- mmi_jmms_set_mms_downloading_busy();
- mmi_jmms_update_status_icon_indicator();
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS New Comm Node Added for Request ID", uiReferenceID));
- return JC_OK;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_comm_state
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * uiReferenceID [IN]
- * RETURNS
- *
- *****************************************************************************/
- jmms_communication_state_node *mmi_jmms_get_comm_state(jmms_context_struct *jmms_context, JC_UINT32 uiReferenceID)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_communication_state_node *comm_node = NULL, *temp_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- temp_node = jmms_context->comm_state;
- while (temp_node != NULL)
- {
- if (temp_node->uiReferenceID == uiReferenceID)
- {
- comm_node = temp_node;
- break;
- }
- temp_node = temp_node->next;
- }
- return comm_node;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_update_comm_node
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * new_uiReferenceID [IN]
- * old_uiReferenceID [IN]
- * retry_counter [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_update_comm_node(
- jmms_context_struct *jmms_context,
- JC_UINT32 new_uiReferenceID,
- JC_UINT32 old_uiReferenceID,
- U8 retry_counter)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- jmms_communication_state_node *temp_node = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- temp_node = jmms_context->comm_state;
- while (temp_node != NULL)
- {
- if (temp_node->uiReferenceID == old_uiReferenceID)
- {
- temp_node->uiReferenceID = new_uiReferenceID;
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- }
- if (temp_node->hFile)
- {
- jdd_FSClose(temp_node->hFile);
- jdd_FSDelete(g_jmms_context->jmms_fs_handle, temp_node->pFileName);
- temp_node->hFile = NULL;
- }
- if ((temp_node->fs_handle) != NULL)
- {
- jdd_FSDeinitialize(temp_node->fs_handle);
- temp_node->fs_handle = NULL;
- }
- if ((temp_node->pFileName) != NULL)
- {
- jdd_MemFree(temp_node->pFileName);
- temp_node->pFileName = NULL;
- }
- if ((temp_node->pContentType) != NULL)
- {
- jdd_MemFree(temp_node->pContentType);
- temp_node->pContentType = NULL;
- }
- temp_node->reponse_size = 0;
- temp_node->retry_counter = retry_counter;
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- break;
- }
- temp_node = temp_node->next;
- }
- if (temp_node == NULL)
- {
- return E_JMMS_GENERAL_ERROR;
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Comm Node Updated Old Request Id", old_uiReferenceID));
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS New Request Id", new_uiReferenceID));
- return JC_OK;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_update_mmsc_url_version
- * DESCRIPTION
- *
- * PARAMETERS
- * mmsc_url_used [?] [?] [?]
- * mmsc_version [?] [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_update_mmsc_url_version(S8 *mmsc_url_used, S8 *mmsc_version)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JDD_FILE hFile = NULL;
- U32 read_len = 0, index, len, temp_len = 0;
- S8 *file_buffer = NULL;
- S8 file_name[(MAX_FILE_LENGTH + 1) * ENCODING_LENGTH];
- JC_INT32 write_len = 0;
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_update_mmsc_url_version"));
- AnsiiToUnicodeString((PS8) file_name, (PS8) MMS_MMSC_URLS_FILE_NAME);
- if (g_jmms_context->jmms_fs_handle == NULL)
- {
- if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
- {
- return;
- }
- }
- hFile = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (JC_CHAR*) file_name, E_CREATE_APPEND_WRITE_READ_MODE); /* /E_CREATE_APPEND_WRITE_READ_MODE) ; */
- if (hFile != NULL)
- {
- eRet = jdd_FSGetSize(hFile, &len);
- if (JC_OK != eRet)
- {
- goto END;
- }
- file_buffer = (S8*) jdd_MemAlloc(sizeof(S8), len);
- if ((NULL == file_buffer) && (len != 0))
- {
- goto END;
- }
- if (len > 0)
- {
- eRet = jdd_FSSeek(hFile, 0, E_FILE_SEEK_SET);
- if (eRet != JC_OK)
- {
- goto END;
- }
- /* /read_len = jdd_FSRead (file_buffer, sizeof(JC_INT8), len, hFile) ; */
- read_len = jdd_FSRead(file_buffer, len, 1, hFile);
- if (read_len != 1)
- {
- goto END;
- }
- read_len = len;
- }
- len = 0;
- index = 0;
- temp_len = 0;
- /* while(read_len!=0) */
- while (read_len != index)
- {
- len = (pfnUnicodeStrlen(file_buffer + index) + 1) * ENCODING_LENGTH;
- if (pfnUnicodeStrcmp((S8*) (file_buffer + index), (S8*) mmsc_url_used) == 0)
- {
- index = index + len;
- /*
- * Convert the string into Unicode string and then copy.
- *
- * Modified By : Raj Kumar Gupta
- * Date : July 27, 2006
- */
- /* /update the version */
- AnsiiToUnicodeString((S8*) (file_buffer + index), (S8*) (mmsc_version));
- if (hFile != NULL)
- {
- jdd_FSClose(hFile);
- }
- eRet = jdd_FSDelete(g_jmms_context->jmms_fs_handle, (const JC_CHAR*)file_name);
- if (eRet != JC_OK)
- {
- goto END;
- }
- hFile = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (JC_CHAR*) file_name, E_CREATE_APPEND_WRITE_READ_MODE);
- if (hFile == NULL)
- {
- goto END;
- }
- write_len = jdd_FSWrite(file_buffer, 1, read_len, hFile);
- if (write_len != read_len)
- {
- goto END;
- }
- break;
- }
- else
- {
- index = index + len;
- len = (pfnUnicodeStrlen(file_buffer + index) + 1) * ENCODING_LENGTH;
- index = index + len;
- temp_len = temp_len + index;
- }
- }
- if (file_buffer)
- {
- jdd_MemFree(file_buffer);
- file_buffer = NULL;
- }
- if (read_len == index) /* /entry not found */
- {
- S8 *temp_buffer = NULL;
- write_len = 0;
- len = (pfnUnicodeStrlen(mmsc_url_used) + 1) * ENCODING_LENGTH;
- len = len + (strlen(mmsc_version) + 1) * ENCODING_LENGTH;
- temp_buffer = (S8*) jdd_MemAlloc(sizeof(S8), len);
- if (NULL == temp_buffer)
- {
- return;
- }
- pfnUnicodeStrcpy((S8*) temp_buffer, (S8*) (mmsc_url_used));
- len = (pfnUnicodeStrlen(mmsc_url_used) + 1) * ENCODING_LENGTH; /* null char also need to be write into file */
- AnsiiToUnicodeString((S8*) (temp_buffer + len), (S8*) (mmsc_version));
- len = len + (strlen(mmsc_version) + 1) * ENCODING_LENGTH;
- write_len = 0;
- eRet = jdd_FSSeek(hFile, 0, E_FILE_SEEK_END);
- if (eRet != JC_OK)
- {
- goto END;
- }
- write_len = jdd_FSWrite(temp_buffer, 1, len, hFile);
- if (temp_buffer)
- {
- jdd_MemFree(temp_buffer);
- temp_buffer = NULL;
- }
- if (len != write_len)
- {
- goto END;
- }
- }
- if (hFile != NULL)
- {
- jdd_FSClose(hFile);
- }
- if (file_buffer)
- {
- jdd_MemFree(file_buffer);
- file_buffer = NULL;
- }
- }
- END:
- if (hFile != NULL)
- {
- jdd_FSClose(hFile);
- }
- if (g_jmms_context->jmms_fs_handle != NULL)
- {
- jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
- g_jmms_context->jmms_fs_handle = NULL;
- }
- if (file_buffer)
- {
- jdd_MemFree(file_buffer);
- file_buffer = NULL;
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_deinit_mms_context
- * DESCRIPTION
- *
- * PARAMETERS
- * jmms_context [?] [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_deinit_mms_context(jmms_context_struct *jmms_context)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_deinit_mms_context START"));
- if (jmms_context != NULL)
- {
- mmi_jmms_free_addresses_list();
- if (jmms_context->msg_handle)
- {
- eRet = mmi_jmms_jdi_msg_deinit(jmms_context->msg_handle);
- jmms_context->msg_handle = NULL;
- }
- /*
- * else
- * {
- * if (g_jmms_context->last_scr_id != SCR_ID_JMMS_OUTBOX_OPTIONS
- * && g_jmms_context->last_scr_id != SCR_ID_JMMS_DRAFTS_OPTIONS)
- * {
- * mmi_jmms_free_mms_pdu_memory(jmms_context);
- * }
- *
- * }
- */
- //jdi_MsgDeInit itself is freeing the memory allocated for PDU
- ///so we don't need to do that.so we should not call mmi_jmms_free_mms_pdu_memory()
- ///otherwise jdd_memfree will be called again and hang will occur
- jmms_context->to_p = NULL;
- jmms_context->Cc_p = NULL;
- jmms_context->bcc_p = NULL;
- jmms_context->from_p = NULL;
- jmms_context->MsgHeader_type_p = NULL;
- jmms_context->MsgHeaders_p = NULL;
- jmms_context->subject = NULL;
- jmms_context->version = NULL;
- jmms_context->nSent_retry_counter = 0;
- jmms_context->msg_handle = NULL;
- jmms_context->nCurr_focused_med_type = 0;
- jmms_context->num_attachments = 0;
- jmms_context->nSent_retry_counter = 0;
- jmms_context->is_unread_msg_deleted = 0;
- memset(jmms_context->subject_input_buffer, 0x00, (MAX_SUBJECT_LENGTH + 1) * ENCODING_LENGTH);
- if (g_jmms_context->rc_info != NULL)
- {
- if (g_jmms_context->rc_info->pReplyMsgID != NULL)
- {
- jdd_MemFree(g_jmms_context->rc_info->pReplyMsgID);
- }
- jdd_MemFree(g_jmms_context->rc_info);
- g_jmms_context->rc_info = NULL;
- }
- if (g_jmms_context->pSendContent != NULL)
- {
- if (g_jmms_context->pSendContent->bIsStream == E_FALSE)
- {