JMMSProtocol.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:298k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2002
  8. *
  9. *****************************************************************************/
  10. /*****************************************************************************
  11.  *
  12.  * Filename:
  13.  * ---------
  14.  *  jmms_protocol.C
  15.  *
  16.  * Project:
  17.  * --------
  18.  *   MAUI
  19.  *
  20.  * Description:
  21.  * ------------
  22.  *   This file is for handling the send and recieve  PDUs for MMS
  23.  *
  24.  * Author:
  25.  * -------
  26.  * -------
  27.  *
  28.  *============================================================================
  29.  *             HISTORY
  30.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  31.  *------------------------------------------------------------------------------
  32.  * removed!
  33.  * removed!
  34.  * removed!
  35.  *
  36.  * removed!
  37.  * removed!
  38.  * removed!
  39.  *
  40.  * removed!
  41.  * removed!
  42.  * removed!
  43.  *
  44.  * removed!
  45.  * removed!
  46.  * removed!
  47.  *
  48.  * removed!
  49.  * removed!
  50.  * removed!
  51.  *
  52.  * removed!
  53.  * removed!
  54.  * removed!
  55.  *
  56.  * removed!
  57.  * removed!
  58.  * removed!
  59.  *
  60.  * removed!
  61.  * removed!
  62.  * removed!
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * removed!
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * removed!
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * removed!
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * removed!
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * removed!
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * removed!
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * removed!
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * removed!
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * removed!
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * removed!
  103.  *
  104.  * removed!
  105.  * removed!
  106.  * removed!
  107.  *
  108.  * removed!
  109.  * removed!
  110.  * removed!
  111.  *
  112.  * removed!
  113.  * removed!
  114.  * removed!
  115.  *
  116.  * removed!
  117.  * removed!
  118.  * removed!
  119.  *
  120.  * removed!
  121.  * removed!
  122.  * removed!
  123.  *
  124.  * removed!
  125.  * removed!
  126.  * removed!
  127.  *
  128.  * removed!
  129.  * removed!
  130.  * removed!
  131.  *
  132.  * removed!
  133.  * removed!
  134.  * removed!
  135.  *
  136.  * removed!
  137.  * removed!
  138.  * removed!
  139.  *
  140.  * removed!
  141.  * removed!
  142.  * removed!
  143.  *
  144.  * removed!
  145.  * removed!
  146.  * removed!
  147.  *
  148.  * removed!
  149.  * removed!
  150.  * removed!
  151.  *
  152.  * removed!
  153.  * removed!
  154.  * removed!
  155.  *
  156.  * removed!
  157.  * removed!
  158.  * removed!
  159.  *
  160.  * removed!
  161.  * removed!
  162.  * removed!
  163.  *
  164.  * removed!
  165.  * removed!
  166.  * removed!
  167.  *
  168.  * removed!
  169.  * removed!
  170.  * removed!
  171.  *
  172.  * removed!
  173.  * removed!
  174.  * removed!
  175.  *
  176.  * removed!
  177.  * removed!
  178.  * removed!
  179.  *
  180.  * removed!
  181.  * removed!
  182.  * removed!
  183.  *
  184.  * removed!
  185.  * removed!
  186.  * removed!
  187.  *
  188.  * removed!
  189.  * removed!
  190.  * removed!
  191.  * removed!
  192.  *
  193.  * removed!
  194.  * removed!
  195.  * removed!
  196.  *
  197.  * removed!
  198.  * removed!
  199.  * removed!
  200.  *
  201.  * removed!
  202.  * removed!
  203.  * removed!
  204.  *
  205.  * removed!
  206.  * removed!
  207.  * removed!
  208.  *
  209.  * removed!
  210.  * removed!
  211.  * removed!
  212.  *
  213.  * removed!
  214.  * removed!
  215.  * removed!
  216.  *
  217.  * removed!
  218.  * removed!
  219.  * removed!
  220.  *
  221.  * removed!
  222.  * removed!
  223.  * removed!
  224.  *
  225.  * removed!
  226.  * removed!
  227.  * removed!
  228.  *
  229.  * removed!
  230.  * removed!
  231.  * removed!
  232.  *
  233.  * removed!
  234.  * removed!
  235.  * removed!
  236.  * removed!
  237.  *
  238.  * removed!
  239.  * removed!
  240.  * removed!
  241.  *
  242.  * removed!
  243.  * removed!
  244.  * removed!
  245.  *
  246.  * removed!
  247.  * removed!
  248.  * removed!
  249.  *
  250.  * removed!
  251.  * removed!
  252.  * removed!
  253.  *
  254.  * removed!
  255.  * removed!
  256.  * removed!
  257.  *
  258.  * removed!
  259.  * removed!
  260.  * removed!
  261.  *
  262.  * removed!
  263.  * removed!
  264.  * removed!
  265.  *
  266.  * removed!
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  *------------------------------------------------------------------------------
  276.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  277.  *============================================================================
  278.  ****************************************************************************/
  279. /*  Include: MMI header file */
  280. #include "MMI_features.h"
  281. #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  282. #include "stdC.h"
  283. #include "L4Dr1.h"
  284. #include "PixtelDataTypes.h"
  285. #include "HistoryGprot.h"
  286. #include "GlobalDefs.h"
  287. #include "SettingProfile.h"
  288. #include "DebugInitDef.h"
  289. #include "CommonScreens.h"
  290. #include "EventsGprot.h"
  291. #include "wgui_inputs.h"
  292. #include "wgui_categories.h"
  293. #include "wgui_categories_inputs.h"
  294. #include "MainMenuDef.h"
  295. #include <ddl.h>
  296. #include <jcal.h>
  297. #include <jcalnet.h>
  298. #include "jdi_wspdatatype.h"
  299. #include "jdi_transport.h"
  300. #include <jdi_communicator.h>
  301. #include <MessagingDatatypes.h>
  302. #include <MessagingAPI.h>
  303. #include "JMMSExdcl.h"
  304. #include "FileMgr.h"    /* Should include FileMgr.h before ProfileMgrGprot.h */
  305. #include "Fat_fs.h"
  306. #include "FileSystemDef.h"
  307. #include "FileManagerGProt.h"
  308. #include "SmsGuiInterfaceType.h"
  309. #include "JProfileHandlerTypes.h"
  310. #include "JProfileHandlerProts.h"
  311. #include "JProfileHandlerDefs.h"
  312. #include "JsrTypes.h"
  313. #include "JMMSJSRHandler.h"
  314. #include <PrvMessagingDataTypes.h>
  315. #include "JMMSInbox.h"
  316. /* PMT VIKAS START 20060325 */
  317. #include"JMMSCompose.h"
  318. #include "MessagesResourceData.h"
  319. /* PMT VIKAS START 20060325 */
  320. #include "JBrowserMMIDefs.h"
  321. #include "TimerEvents.h"
  322. #include "DebugInitDef.h"       /* Debug Info */
  323. #include "JMMSConfig.h"
  324. #include "JMMSMessageSettings.h"
  325. #include "JMMSCoreAPI.h"
  326. #include "JMMSDrafts.h"
  327. #include "JMMSExdcl.h"
  328. /* /#include "JMMSGdcl.h" */
  329. #include "JMMSCompose.h"
  330. #include "JMMSGprot.h"
  331. #include "JMMSInbox.h"
  332. #include "JMMSJSRHandler.h"
  333. #include "JMMSMainMMS.h"
  334. #include "JMMSMessageSettingsUtils.h"
  335. #include "JMMSOutbox.h"
  336. #include "JMMSProtocols.h"
  337. #include "JMMSPushHandling.h"
  338. #include "JMMSResEnum.h"
  339. #include "JMMSSent.h"
  340. #include "JMMSStoreHandling.h"
  341. #include "JMMSStructs.h"
  342. #include "JMMSTemplates.h"
  343. #include "JMMSUseDetails.h"
  344. #include "JMMSView.h"
  345. #include "JMMSWriteMMS.h"
  346. #include "miscutils.h"
  347. #include "CallManagementGprot.h"
  348. #include "AlarmFrameworkProt.h"
  349. #include "SmsGuiInterfaceProt.h"
  350. #include "JSRProts.h"
  351. #include "JMMSMainMMS.h"
  352. #include "wapadp.h"
  353. #include "JPushInboxCommonUI.h"
  354. #include "PhoneBookGprot.h"
  355. #include "MMI_features_camera.h"
  356. #include "CameraResDefs.h"
  357. #ifdef __USB_IN_NORMAL_MODE__
  358. #include "USBDeviceGprot.h"
  359. #endif 
  360. #ifdef __MMI_UNIFIED_MESSAGE__
  361. #include "UnifiedMessageDef.h"
  362. #include "UnifiedMessageProt.h"
  363. #include "JMMSUMHandling.h"
  364. #include "FileManagerDef.h"
  365. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  366. /* ... Add More MMI header */
  367. #include "gpioInc.h"
  368. /***************************************************************************** 
  369. * Define
  370. *****************************************************************************/
  371. /***************************************************************************** 
  372. * Typedef 
  373. *****************************************************************************/
  374. /***************************************************************************** 
  375. * Local Variable
  376. *****************************************************************************/
  377. /***************************************************************************** 
  378. * Local Function
  379. *****************************************************************************/
  380. /* /manish */
  381. extern U16 DeleteScreenFromToNnodes(U16 ScrId, U16 num_nodes);
  382. extern U8 DeleteFromScrUptoScr(U16 beyondScrnid, U16 tillScrnid);
  383. extern int wap_is_ready(void);
  384. extern JC_RETCODE FreeMessageHeaders(MESSAGE_HEADERS **ppMessageHeaders);
  385. /***************************************************************************** 
  386. * Global Variable
  387. *****************************************************************************/
  388. static U16 interupt_screen_title;
  389. static U8 g_mms_downloading_busy = 0;
  390. static FuncPtr g_end_key_processing_handler;
  391. extern U8 *g_media_buffer_p;
  392. /* Compiler warning removal */
  393. static void mmi_jmms_end_key_progressing(void);
  394. static void mmi_jmms_set_end_key_progressing_handler(void);
  395. /***************************************************************************** 
  396. * Global Function
  397. *****************************************************************************/
  398. extern em_wap_user_agent_brand_enum wap_get_user_agent_brand(void);
  399. extern void TurnOnBacklight(gpio_backlight_time_enum timer_enum);
  400. extern void TurnOffBacklight(void);
  401. /*****************************************************************************
  402.  * FUNCTION
  403.  *  mmi_jmms_create_mms_queue
  404.  * DESCRIPTION
  405.  *  
  406.  * PARAMETERS
  407.  *  void
  408.  * RETURNS
  409.  *  void
  410.  *****************************************************************************/
  411. void mmi_jmms_create_mms_queue(void)
  412. {
  413.     /*----------------------------------------------------------------*/
  414.     /* Local Variables                                                */
  415.     /*----------------------------------------------------------------*/
  416.     /*----------------------------------------------------------------*/
  417.     /* Code Body                                                      */
  418.     /*----------------------------------------------------------------*/
  419.     jdd_QueueCreate(
  420.         (JC_INT32) E_TASK_MMS_UI,
  421.         "MMS UI QUEUE",
  422.         sizeof(JC_EVENT_DATA),
  423.         MAX_NUMBER_OF_EVENTS_IN_MMS_QUEUE,
  424.         E_FALSE);
  425. }
  426. /*****************************************************************************
  427.  * FUNCTION
  428.  *  mmi_jmms_ui_events_hdlr
  429.  * DESCRIPTION
  430.  *  
  431.  * PARAMETERS
  432.  *  pEventData      [?]     [?]     [?]
  433.  * RETURNS
  434.  *  void
  435.  *****************************************************************************/
  436. void mmi_jmms_ui_events_hdlr(JC_EVENT_DATA *pEventData)
  437. {
  438.     /*----------------------------------------------------------------*/
  439.     /* Local Variables                                                */
  440.     /*----------------------------------------------------------------*/
  441.     /*----------------------------------------------------------------*/
  442.     /* Code Body                                                      */
  443.     /*----------------------------------------------------------------*/
  444.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_ui_events_hdlr"));
  445.     switch (pEventData->iEventType)
  446.     {
  447.         case E_MMS_GET_MSG_LIST_EVENT:
  448.         {
  449.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Event: E_MMS_GET_MSG_LIST_EVENT"));
  450.             mmi_jmms_recieve_get_msg_list_event(pEventData->pEventInfo);
  451.             break;
  452.         }
  453.         case E_COMM_ERROR_INDICATION_EVENT:
  454.         {
  455.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Event: E_COMM_ERROR_INDICATION_EVENT"));
  456.             mmi_jmms_retry_for_error_in_comm(pEventData->pEventInfo);
  457.             break;
  458.         }
  459.     }
  460. }
  461. /*****************************************************************************
  462.  * FUNCTION
  463.  *  mmi_jmms_init_protocol
  464.  * DESCRIPTION
  465.  *  
  466.  * PARAMETERS
  467.  *  void
  468.  * RETURNS
  469.  *  
  470.  *****************************************************************************/
  471. JC_RETCODE mmi_jmms_init_protocol(void)
  472. {
  473.     /*----------------------------------------------------------------*/
  474.     /* Local Variables                                                */
  475.     /*----------------------------------------------------------------*/
  476.     JC_RETCODE eRet = JC_OK;
  477.     JC_TASK_INFO appTaskInfo = {0, };
  478.     JC_TASK_INFO transportTaskInfo = {0, };
  479.     /*----------------------------------------------------------------*/
  480.     /* Code Body                                                      */
  481.     /*----------------------------------------------------------------*/
  482.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_init_protocol"));
  483.     appTaskInfo.iTaskID = (JC_INT32) E_TASK_MMS_UI;
  484.     appTaskInfo.iAppID = (JC_INT32) E_TASK_MMS_UI;
  485.     transportTaskInfo.iTaskID = (JC_INT32) E_TASK_TRANSPORT;
  486.     transportTaskInfo.iAppID = (JC_INT32) E_TASK_TRANSPORT;
  487.     eRet = jdi_CommunicationInitialize(&appTaskInfo, &transportTaskInfo, g_jmms_context, &g_jmms_context->hCommHandle);
  488.     if (JC_OK != eRet)
  489.     {
  490.         goto error;
  491.     }
  492.     eRet = jdi_CommunicationRegisterHeaderCallback(
  493.             g_jmms_context->hCommHandle,
  494.             (COMM_URL_IND_HEADER_FNC) mmi_jmms_header_ind_callback);
  495.     if (JC_OK != eRet)
  496.     {
  497.         goto error;
  498.     }
  499.     eRet = jdi_CommunicationRegisterURLIndCallback(
  500.             g_jmms_context->hCommHandle,
  501.             (COMM_URL_IND_RESPONSE_FNC) mmi_jmms_url_ind_callback);
  502.     if (JC_OK != eRet)
  503.     {
  504.         goto error;
  505.     }
  506.     eRet = jdi_CommunicationRegisterStopIndCallback(
  507.             g_jmms_context->hCommHandle,
  508.             (COMM_STOP_IND_FNC) mmi_jmms_comm_stop_callback);
  509.     if (JC_OK != eRet)
  510.     {
  511.         goto error;
  512.     }
  513.     eRet = jdi_CommunicationRegisterPushIndCallback(
  514.             g_jmms_context->hCommHandle,
  515.             (COMM_PUSH_IND_FNC) mmi_jmms_push_ind_callback);
  516.     if (JC_OK != eRet)
  517.     {
  518.         goto error;
  519.     }
  520.     eRet = jdi_CommunicationRegisterErrIndCallback(
  521.             g_jmms_context->hCommHandle,
  522.             (COMM_ERR_IND_FNC) mmi_jmms_error_ind_callback);
  523.     if (JC_OK != eRet)
  524.     {
  525.         goto error;
  526.     }
  527.     eRet = jdi_CommunicationRegisterProgressIndCallback(
  528.             g_jmms_context->hCommHandle,
  529.             (COMM_PROGRESS_IND_FNC) mmi_jmms_progress_ind_callback);
  530.     if (JC_OK != eRet)
  531.     {
  532.         goto error;
  533.     }
  534.     eRet = mmi_jmms_set_profile();
  535.   error:
  536.     return eRet;
  537. }
  538. /*****************************************************************************
  539.  * FUNCTION
  540.  *  mmi_jmms_progress_ind_callback
  541.  * DESCRIPTION
  542.  *  
  543.  * PARAMETERS
  544.  *  jmms_context        [?]         [?]         [?]
  545.  *  uiReferenceID       [IN]        
  546.  *  pProgressInd        [?]         [?]         [?]
  547.  * RETURNS
  548.  *  void
  549.  *****************************************************************************/
  550. void mmi_jmms_progress_ind_callback(
  551.         jmms_context_struct *jmms_context,
  552.         JC_UINT32 uiReferenceID,
  553.         COMM_PROGRESS_IND *pProgressInd)
  554. {
  555.     /*----------------------------------------------------------------*/
  556.     /* Local Variables                                                */
  557.     /*----------------------------------------------------------------*/
  558.     JC_UINT32 percentage_of_progress = 0;
  559.     S8 tmp_str_ascii[20] = {0, };
  560.     S8 tmp_str_ucs2[40] = {0};
  561.     S8 tmp_buff_ucs2[5] = {0};
  562.     U32 len = 0, temp_len = 0;
  563.     S32 size_kb = 0;
  564.     /*----------------------------------------------------------------*/
  565.     /* Code Body                                                      */
  566.     /*----------------------------------------------------------------*/
  567.     /* /update only for Deffered Downlaod/New MMS Send */
  568.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS mmi_jmms_progress_ind_callback, with uiReferenceID", uiReferenceID));
  569.     if (g_jmms_context->uiReferenceID == uiReferenceID)
  570.     {
  571.         if (g_jmms_context->progress_screen_title == STR_ID_PROGRESS_SENDING)
  572.         {
  573.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Screen ID: STR_ID_PROGRESS_SENDING"));
  574.             if (pProgressInd->eStackStatus == E_COMM_STACK_CONNECTING)
  575.             {
  576.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Connecting Screen"));
  577.                 len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_CONNECTING));
  578.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  579.                 {
  580.                     len = (MAX_PROGRESS_SCREEN_HINT_LEN - 1);
  581.                 }
  582.                 memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
  583.                 pfnUnicodeStrncpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_CONNECTING), len);
  584.                 AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
  585.                 if ((S32)len <(MAX_PROGRESS_SCREEN_HINT_LEN - 1) - (pfnUnicodeStrlen((S8*) tmp_buff_ucs2)))
  586.                 {
  587.                     len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  588.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  589.                 }
  590.             }
  591.             else if(pProgressInd->eStackStatus == E_COMM_STACK_CONNECTED)
  592.             {
  593.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Connected for sending"));
  594.                 if(!isInCall() && (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS))
  595.                 {
  596.                 SetKeyHandler(mmi_jmms_end_comm, KEY_END, KEY_EVENT_DOWN);
  597.                 }
  598.                 else
  599.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "End Key Not set in Progress_ind"));
  600.                 sprintf(tmp_str_ascii, "%d %%", percentage_of_progress);
  601.                 AnsiiToUnicodeString(tmp_str_ucs2, tmp_str_ascii);
  602.                 len = pfnUnicodeStrlen((S8*) GetString(STR_ID_PROGRESS_SENDING));
  603.                 AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
  604.                 len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  605.                 len = len + pfnUnicodeStrlen(tmp_str_ucs2);
  606.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  607.                 {
  608.                     len = 0;
  609.                 }
  610.                 memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
  611.                 if (len != 0)
  612.                 {
  613.                     pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_PROGRESS_SENDING));
  614.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  615.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
  616.                 }
  617.                 else
  618.                 {
  619.                     pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
  620.                 }
  621.             }
  622.             else if (pProgressInd->eStackStatus == E_COMM_STACK_SENDING)
  623.             {
  624.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS E_COMM_STACK_SENDING"));
  625.                 if(!isInCall() && (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS))
  626.                 {
  627.                 SetKeyHandler(mmi_jmms_end_comm, KEY_END, KEY_EVENT_DOWN);
  628.                 }
  629.                 else
  630.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "End Key Not set in Progress_ind"));                if ((pProgressInd->uiTotalBytesToSend) != 0)
  631.                 {
  632.                     percentage_of_progress = (pProgressInd->uiBytesSent) * 100;
  633.                     percentage_of_progress = percentage_of_progress / (pProgressInd->uiTotalBytesToSend);
  634.                 }
  635.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "JMMS Sending Progress Percentage = ",
  636.                                      percentage_of_progress));
  637.                 sprintf(tmp_str_ascii, "%d %%", percentage_of_progress);
  638.                 AnsiiToUnicodeString(tmp_str_ucs2, tmp_str_ascii);
  639.                 len = pfnUnicodeStrlen((S8*) GetString(STR_ID_PROGRESS_SENDING));
  640.                 AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
  641.                 len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  642.                 len = len + pfnUnicodeStrlen(tmp_str_ucs2);
  643.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  644.                 {
  645.                     len = 0;
  646.                 }
  647.                 memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
  648.                 if (len != 0)
  649.                 {
  650.                     pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_PROGRESS_SENDING));
  651.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  652.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
  653.                 }
  654.                 else
  655.                 {
  656.                     pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
  657.                 }
  658.             }
  659.             else
  660.             {
  661.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "Stack Status=%d Connect=%d Sent=%d",
  662.                                      pProgressInd->eStackStatus,pProgressInd->eDataConnectionStatus,pProgressInd->uiBytesSent));
  663.             }
  664.         }
  665.         else if (g_jmms_context->progress_screen_title == STR_ID_JMMS_MMS_DOWNLOADING)
  666.         {
  667.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Screen ID: STR_ID_PROGRESS_DOWNLOADING"));
  668.             if (pProgressInd->eStackStatus == E_COMM_STACK_CONNECTING)
  669.             {
  670.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Connecting Screen"));
  671.                 memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
  672.                 len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_MMS_DOWNLOADING));
  673.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  674.                 {
  675.                     pfnUnicodeStrncpy(
  676.                         g_jmms_context->g_jmms_progress_str,
  677.                         GetString(STR_ID_JMMS_CONNECTING),
  678.                         (MAX_PROGRESS_SCREEN_HINT_LEN - 1));
  679.                 }
  680.                 else
  681.                 {
  682.                     pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_CONNECTING));
  683.                     AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) "n");
  684.                     len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  685.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  686.                 }
  687.             }
  688.             else if (pProgressInd->eStackStatus == E_COMM_STACK_RECEIVING)
  689.             {
  690.                 memset(g_jmms_context->g_jmms_progress_str, 0, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
  691.                 if ((pProgressInd->uiBytesRecvd) != 0)
  692.                 {
  693.                     percentage_of_progress = (pProgressInd->uiBytesRecvd);
  694.                 }
  695.                 size_kb = pProgressInd->uiBytesRecvd / 1024;
  696.                 if (size_kb >= 1)
  697.                 {
  698.                     size_kb++;
  699.                     sprintf(tmp_str_ascii, "%d", size_kb);
  700.                 }
  701.                 else
  702.                 {
  703.                     sprintf(tmp_str_ascii, "%d", percentage_of_progress);
  704.                 }
  705.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Downloading Bytes = ", percentage_of_progress));
  706.                 AnsiiToUnicodeString(tmp_str_ucs2, tmp_str_ascii);
  707.                 len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_MMS_DOWNLOADING));
  708.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  709.                 {
  710.                     pfnUnicodeStrncpy(
  711.                         g_jmms_context->g_jmms_progress_str,
  712.                         GetString(STR_ID_JMMS_MMS_DOWNLOADING),
  713.                         (MAX_PROGRESS_SCREEN_HINT_LEN - 1));
  714.                     goto END;
  715.                 }
  716.                 pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_MMS_DOWNLOADING));
  717.                 temp_len = len;
  718. /*dilip 31st aug to add space after downloading on downloading progress screen*/
  719.                 AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) " ");
  720.                 len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  721.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  722.                 {
  723.                     pfnUnicodeStrncat(
  724.                         g_jmms_context->g_jmms_progress_str,
  725.                         (S8*) tmp_buff_ucs2,
  726.                         ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  727.                     goto END;
  728.                 }
  729.                 pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  730.                 temp_len = len;
  731.                 len = len + pfnUnicodeStrlen(tmp_str_ucs2);
  732.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  733.                 {
  734.                     pfnUnicodeStrncat(
  735.                         g_jmms_context->g_jmms_progress_str,
  736.                         tmp_str_ucs2,
  737.                         ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  738.                     goto END;
  739.                 }
  740.                 pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, tmp_str_ucs2);
  741.                 temp_len = len;
  742.                 AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) " ");
  743.                 len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  744.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  745.                 {
  746.                     pfnUnicodeStrncat(
  747.                         g_jmms_context->g_jmms_progress_str,
  748.                         (S8*) tmp_buff_ucs2,
  749.                         ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  750.                     goto END;
  751.                 }
  752.                 pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  753.                 temp_len = len;
  754.                 if(size_kb >=1)
  755.                 {
  756.                     len = len + pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_KB));
  757.                     if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  758.                     {
  759.                         pfnUnicodeStrncat(
  760.                             g_jmms_context->g_jmms_progress_str,
  761.                             GetString(STR_ID_JMMS_KB),
  762.                             ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  763.                         goto END;
  764.                     }
  765.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_KB));
  766.                 }
  767.                 else
  768.                 {
  769.                     len = len + pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_BYTES));
  770.                     if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  771.                     {
  772.                         pfnUnicodeStrncat(
  773.                             g_jmms_context->g_jmms_progress_str,
  774.                             GetString(STR_ID_JMMS_BYTES),
  775.                             ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  776.                         goto END;
  777.                     }
  778.                     pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_BYTES));
  779.                 }
  780.                 temp_len = len;
  781.                 AnsiiToUnicodeString((S8*) tmp_buff_ucs2, (S8*) " ");
  782.                 len = len + pfnUnicodeStrlen((S8*) tmp_buff_ucs2);
  783.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  784.                 {
  785.                     pfnUnicodeStrncat(
  786.                         g_jmms_context->g_jmms_progress_str,
  787.                         (S8*) tmp_buff_ucs2,
  788.                         ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  789.                     goto END;
  790.                 }
  791.                 pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) tmp_buff_ucs2);
  792.                 len = len + pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_BYTES_KB_RECIEVED));
  793.                 if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  794.                 {
  795.                     pfnUnicodeStrncat( g_jmms_context->g_jmms_progress_str,
  796.                         GetString(STR_ID_JMMS_BYTES_KB_RECIEVED),
  797.                         ((MAX_PROGRESS_SCREEN_HINT_LEN - 1) - temp_len));
  798.                     goto END;
  799.                 }
  800.                 pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, (S8*) GetString(STR_ID_JMMS_BYTES_KB_RECIEVED));
  801.             }
  802.         }
  803.         else
  804.         {
  805.             return;
  806.         }
  807.       END:
  808.         if (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS)
  809.         {
  810.             cat66_update_progress_string();
  811.         }
  812.     }
  813. }
  814. /*****************************************************************************
  815.  * FUNCTION
  816.  *  mmi_jmms_set_profile
  817.  * DESCRIPTION
  818.  *  
  819.  * PARAMETERS
  820.  *  void
  821.  * RETURNS
  822.  *  
  823.  *****************************************************************************/
  824. JC_RETCODE mmi_jmms_set_profile(void)
  825. {
  826.     /*----------------------------------------------------------------*/
  827.     /* Local Variables                                                */
  828.     /*----------------------------------------------------------------*/
  829.     COMM_PROFILE profile = {0, };
  830.     JC_RETCODE eRet = JC_OK;
  831.     U8 connect_type;
  832.     GENERIC_DATA_CONN pDataConn;
  833.     U8 ip_address[16] = {0x00};
  834.     nvram_mms_profile_content_struct *activated_mms_profile;
  835.     /*----------------------------------------------------------------*/
  836.     /* Code Body                                                      */
  837.     /*----------------------------------------------------------------*/
  838.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_set_profile"));
  839.     activated_mms_profile = mmi_ph_get_activated_mms_profile();
  840.     connect_type = activated_mms_profile->conn_type;
  841.     jc_memset(&profile, 0, sizeof(COMM_PROFILE));
  842.     mmi_jmms_get_ip_address(ip_address, activated_mms_profile->proxy_ip);
  843.     if (connect_type == PH_CONN_TYPE_HTTP)
  844.     {
  845.         if (activated_mms_profile->proxy_port == 0)
  846.         {
  847.             profile.eConnMode = E_COMM_WPHTTP_DIRECT;
  848.             jc_strcpy(profile.szHostName, (JC_INT8*) ip_address);
  849.             profile.uiPortNumber = activated_mms_profile->proxy_port;
  850.         }
  851.         else
  852.         {
  853.             profile.eConnMode = E_COMM_WPHTTP_PROXY;
  854.             jc_strcpy(profile.szHostName, (JC_INT8*) ip_address);
  855.             profile.uiPortNumber = activated_mms_profile->proxy_port;
  856.         }
  857.     }
  858.     else if (connect_type == PH_CONN_TYPE_CONNECTION_OREINTED)
  859.     {
  860.         profile.eConnMode = E_COMM_WSP_CONNECTION_ORIENTED;
  861.         jc_strcpy(profile.szHostName, (JC_INT8*) ip_address);
  862.         profile.uiPortNumber = 0;
  863.     }
  864.     else
  865.     {
  866.         return JC_ERR_MEMORY_ALLOCATION;
  867.     }
  868.     eRet = jdi_CommunicationProfile(g_jmms_context->hCommHandle, &profile);
  869.     if (eRet != JC_OK)
  870.     {
  871.         goto ERROR_HANDLE;
  872.     }
  873.     pDataConn.account_id = activated_mms_profile->data_account;
  874.     eRet = jdi_CommunicationDataConnection(g_jmms_context->hCommHandle, (const GENERIC_DATA_CONN*)&pDataConn);
  875.   ERROR_HANDLE:
  876.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_set_profile return:", eRet));
  877.     return eRet;
  878. }
  879. /*****************************************************************************
  880.  * FUNCTION
  881.  *  mmi_jmms_get_ip_address
  882.  * DESCRIPTION
  883.  *  
  884.  * PARAMETERS
  885.  *  ip_address      [?]     [?]     [?]
  886.  *  proxy_ip        [?]     [?]     [?]
  887.  * RETURNS
  888.  *  void
  889.  *****************************************************************************/
  890. void mmi_jmms_get_ip_address(U8 *ip_address, U8 *proxy_ip)
  891. {
  892.     /*----------------------------------------------------------------*/
  893.     /* Local Variables                                                */
  894.     /*----------------------------------------------------------------*/
  895.     S8 temp[4] = {0x00};
  896.     /*----------------------------------------------------------------*/
  897.     /* Code Body                                                      */
  898.     /*----------------------------------------------------------------*/
  899.     sprintf((S8*) ip_address, "%d", proxy_ip[0]);
  900.     strcat((S8*) ip_address, ".");
  901.     sprintf((S8*) temp, "%d", proxy_ip[1]);
  902.     strcat((S8*) ip_address, (S8*) temp);
  903.     strcat((S8*) ip_address, ".");
  904.     memset(temp, 0x00, 4);
  905.     sprintf((S8*) temp, "%d", proxy_ip[2]);
  906.     strcat((S8*) ip_address, (S8*) temp);
  907.     strcat((S8*) ip_address, ".");
  908.     memset(temp, 0x00, 4);
  909.     sprintf((S8*) temp, "%d", proxy_ip[3]);
  910.     strcat((S8*) ip_address, (S8*) temp);
  911. }
  912. /*****************************************************************************
  913.  * FUNCTION
  914.  *  mmi_jmms_get_activated_mmsc_url
  915.  * DESCRIPTION
  916.  *  
  917.  * PARAMETERS
  918.  *  jmms_context        [?]     [?]     [?]
  919.  * RETURNS
  920.  *  
  921.  *****************************************************************************/
  922. U8 *mmi_jmms_get_activated_mmsc_url(jmms_context_struct *jmms_context)
  923. {
  924.     /*----------------------------------------------------------------*/
  925.     /* Local Variables                                                */
  926.     /*----------------------------------------------------------------*/
  927.     U8 *mmsc_url = NULL;
  928.     U32 len = 0;
  929.     /*----------------------------------------------------------------*/
  930.     /* Code Body                                                      */
  931.     /*----------------------------------------------------------------*/
  932.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_get_activated_mmsc_url"));
  933.     mmsc_url = mmi_ph_mms_get_activated_profile_mmsc_url(); /* //for getting the mmsc url */
  934.     if (mmsc_url == NULL)
  935.     {
  936.         return NULL;
  937.     }
  938.     len = (strlen((S8*) mmsc_url) + 1) * ENCODING_LENGTH;
  939.     if (jmms_context->activated_mmsc_url != NULL)
  940.     {
  941.         jdd_MemFree(jmms_context->activated_mmsc_url);
  942.     }
  943.     jmms_context->activated_mmsc_url = (U8*) jdd_MemAlloc(sizeof(U8), len);
  944.     if (jmms_context->activated_mmsc_url == NULL)
  945.     {
  946.         return NULL;
  947.     }
  948.     AnsiiToUnicodeString((PS8) (jmms_context->activated_mmsc_url), (PS8) mmsc_url);
  949.     return (jmms_context->activated_mmsc_url);
  950. }
  951. /*****************************************************************************
  952.  * FUNCTION
  953.  *  mmi_jmms_push_ind_callback
  954.  * DESCRIPTION
  955.  *  
  956.  * PARAMETERS
  957.  *  pCommArg            [?]     [?]     [?]
  958.  *  pPushContentInd     [?]     [?]     [?]
  959.  * RETURNS
  960.  *  void
  961.  *****************************************************************************/
  962. void mmi_jmms_push_ind_callback(void *pCommArg, COMM_PUSH_IND *pPushContentInd)
  963. {
  964.     /*----------------------------------------------------------------*/
  965.     /* Local Variables                                                */
  966.     /*----------------------------------------------------------------*/
  967.     JC_RETCODE eRet = JC_OK;
  968.     CONTENT_DATA ViewContent = {0, };
  969.     MSG_HANDLE hMsgHandle = NULL;
  970.     MESSAGE_HEADERS *pMsgHdrs = NULL;
  971.     MESSAGE_NOTIFICATION *pNotifyIndHdrs;
  972.     JC_UINT32 msg_index = 0;
  973.     /* JC_UINT32 msgid = 0; */
  974.     U8 number_mms = 0;
  975.     /*----------------------------------------------------------------*/
  976.     /* Code Body                                                      */
  977.     /*----------------------------------------------------------------*/
  978.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_push_ind_callback"));
  979.     if (!wap_is_ready())
  980.     {
  981.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: WAP is not ready"));
  982.         return;
  983.     }
  984. if(g_jmms_context->init_done == JMMS_READY_WITHOUT_STORE)
  985. {
  986.         interupt_screen_title=STR_ID_JMMS_MEMORY_ERROR_NEW_MMS_NOTIF_SAVING;
  987. mmi_jmms_entry_general_pop_screen_in_case_interupt();
  988. PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Store is not ready"));
  989.         return;
  990. }
  991.     eRet = mmi_jmms_get_total_number_of_messages(&number_mms);
  992.     if (eRet != JC_OK)
  993.     {
  994.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "JMMS Bad Store Module, Return Code: ", eRet));
  995.         ASSERT(0) return;
  996.     }
  997.     if (number_mms >= MAX_POSSIBLE_MESSAGES_THRESHOLD)
  998.     {
  999.         mmi_jmms_update_status_icon_indicator();
  1000.     }
  1001.     if (number_mms >= MAX_POSSIBLE_MESSAGES)
  1002.     {
  1003.         mmi_jmms_add_memory_full_node_if_not_already();
  1004.         return;
  1005.     }
  1006.     if (NULL != pPushContentInd->pszContentType)
  1007.     {
  1008.         if (0 == jc_strcmp(pPushContentInd->pszContentType, "application/vnd.wap.mms-message"))
  1009.         {
  1010.             ViewContent.uiCurSize = ViewContent.uiTotalSize = pPushContentInd->uiLength;
  1011.             /* ViewContent.VIEW_MODE.contentInline.pBuffer = (JC_INT8 *)pPushContentInd->pBuffer  ; */
  1012.             ViewContent.pBuffer = (JC_UINT8*) pPushContentInd->pBuffer;
  1013.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Message parsing for Message header starts"));
  1014.             eRet = mmi_jmms_jdi_parse_msg_buffer(&hMsgHandle, &ViewContent, E_TYPE_MMS, E_FALSE);
  1015.             /* Async changes start */
  1016.             while (eRet == JC_ERR_MMS_PARSE_PENDING)
  1017.             {
  1018.                 eRet = mmi_jmms_jdi_msg_parse_continue(hMsgHandle);
  1019.             };
  1020.             /* Async changes end */
  1021.             if (JC_OK != eRet)
  1022.             {
  1023.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Error in parsing message headers, Error code: ",
  1024.                                      eRet));
  1025.                 if (hMsgHandle != NULL)
  1026.                 {
  1027.                     mmi_jmms_jdi_msg_deinit(hMsgHandle);
  1028.                     hMsgHandle = NULL;
  1029.                 }
  1030.                 eRet = mmi_jmms_add_pending_mms_info_node(
  1031.                         (U16) STR_ID_JMMS_UNABLE_PARSE_PUSH,
  1032.                         (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1033.                         NULL);
  1034.                 if (eRet == JC_OK)
  1035.                 {
  1036.                     mmi_jmms_check_for_idle_screen();
  1037.                 }
  1038.                 return;
  1039.             }
  1040.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Message parsing for Message header SUCCESSFUL!!!"));
  1041.             eRet = mmi_jmms_jdi_get_msg_headers(hMsgHandle, &pMsgHdrs);
  1042.             if (JC_OK != eRet)
  1043.             {
  1044.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Error in getting message headers, Error code",
  1045.                                      eRet));
  1046.                 mmi_jmms_jdi_msg_deinit(hMsgHandle);
  1047.                 hMsgHandle = NULL;
  1048.                 eRet = mmi_jmms_add_pending_mms_info_node(
  1049.                         (U16) STR_ID_JMMS_UNABLE_PARSE_PUSH,
  1050.                         (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1051.                         NULL);
  1052.                 if (eRet == JC_OK)
  1053.                 {
  1054.                     mmi_jmms_check_for_idle_screen();
  1055.                 }
  1056.                 return;
  1057.             }
  1058.             if (pMsgHdrs->eMsgType == E_MSG_TYPE_DELIVERY_REPORT)
  1059.             {
  1060.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Push Indication for JMMS Delivery Report Received"));
  1061.                 /* save the delivery report in inbox */
  1062.             #ifdef __MMI_UNIFIED_MESSAGE__
  1063.                 {
  1064.                     JC_UINT32 temp_extra_byte = 0x02000000;
  1065.                     eRet = mmi_jmms_save_message_buffer_in_Store(
  1066.                             "Inbox",
  1067.                             &msg_index,
  1068.                             pMsgHdrs,
  1069.                             &ViewContent,
  1070.                             &temp_extra_byte);
  1071.                 }
  1072.             #else /* __MMI_UNIFIED_MESSAGE__ */ 
  1073.                 mmi_jmms_save_message_buffer_in_Store("Inbox", &msg_index, pMsgHdrs, &ViewContent, NULL);
  1074.             #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1075.                 eRet = mmi_jmms_add_pending_mms_info_node((U16) msg_index, (U8) E_MSG_TYPE_DELIVERY_REPORT, NULL);
  1076.                 if (eRet == JC_OK)
  1077.                 {
  1078.                     eRet = mmi_jmms_add_pending_mms_delivery_report_node(
  1079.                             (U8) (((DELIVERY_REPORT*) pMsgHdrs->pHeaders)->eDeliveryStatus),
  1080.                             (S8 *) (((DELIVERY_REPORT*) pMsgHdrs->pHeaders)->pTo),
  1081.                             ((DELIVERY_REPORT*) pMsgHdrs->pHeaders)->uiDate);
  1082.                     if (eRet == JC_OK)
  1083.                     {
  1084.                         mmi_jmms_show_new_mms_pop_up();
  1085.                     }
  1086.                 }
  1087.                 if (eRet != JC_OK)
  1088.                 {
  1089.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)",
  1090.                                          "JMMS, Error in saving Delivery Report, Error code: ", eRet));
  1091.                     if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
  1092.                     {
  1093.                         eRet = mmi_jmms_add_pending_mms_info_node(
  1094.                                 (U16) STR_ID_JMMS_MEMORY_ERROR_DELIVERY_SAVING,
  1095.                                 (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1096.                                 NULL);
  1097.                     }
  1098.                     else
  1099.                     {
  1100.                         eRet = mmi_jmms_add_pending_mms_info_node(
  1101.                                 (U16) STR_ID_JMMS_ERROR_DELIVERY_SAVING,
  1102.                                 (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1103.                                 NULL);
  1104.                     }
  1105.                     if (eRet == JC_OK)
  1106.                     {
  1107.                         mmi_jmms_check_for_idle_screen();
  1108.                     }
  1109.                 }
  1110.                 mmi_jmms_jdi_msg_deinit(hMsgHandle);
  1111.                 hMsgHandle = NULL;
  1112.                 return;
  1113.             }
  1114.             else if (pMsgHdrs->eMsgType == E_MSG_TYPE_READ_REPORT_RESPONSE)
  1115.             {
  1116.                 // TODO:::need to test the read report PDU
  1117.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Push Indication for JMMS Read Report received"));
  1118.                 eRet = mmi_jmms_add_pending_mms_info_node((U16) msg_index, (U8) E_MSG_TYPE_READ_REPORT_RESPONSE, NULL);
  1119.                 if (eRet == JC_OK)
  1120.                 {
  1121.                     eRet = mmi_jmms_add_pending_mms_read_report_node(
  1122.                             (U8) (((READ_REPORT_RESPONSE*) pMsgHdrs->pHeaders)->eReadStatus),
  1123.                             (S8 *) (((READ_REPORT_RESPONSE*) pMsgHdrs->pHeaders)->pFrom),
  1124.                             ((READ_REPORT_RESPONSE*) pMsgHdrs->pHeaders)->uiReceivedTime);
  1125.                     if (eRet == JC_OK)
  1126.                     {
  1127.                         mmi_jmms_show_new_mms_pop_up();
  1128.                     }
  1129.                 }
  1130.                 /* /save the read report in inbox. */
  1131.             #ifdef __MMI_UNIFIED_MESSAGE__
  1132.                 {
  1133.                     JC_UINT32 temp_extra_byte = 0x02000000;
  1134.                     eRet = mmi_jmms_save_message_buffer_in_Store(
  1135.                             "Inbox",
  1136.                             &msg_index,
  1137.                             pMsgHdrs,
  1138.                             &ViewContent,
  1139.                             &temp_extra_byte);
  1140.                 }
  1141.             #else /* __MMI_UNIFIED_MESSAGE__ */ 
  1142.                 eRet = mmi_jmms_save_message_buffer_in_Store("Inbox", &msg_index, pMsgHdrs, &ViewContent, NULL);
  1143.             #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1144.                 if (eRet != JC_OK)
  1145.                 {
  1146.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Error in saving Read Report, Error code",
  1147.                                          eRet));
  1148.                     if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
  1149.                     {
  1150.                         eRet = mmi_jmms_add_pending_mms_info_node(
  1151.                                 (U16) STR_ID_JMMS_MEMORY_ERROR_READ_REPORT_SAVING,
  1152.                                 (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1153.                                 NULL);
  1154.                     }
  1155.                     else
  1156.                     {
  1157.                         eRet = mmi_jmms_add_pending_mms_info_node(
  1158.                                 (U16) STR_ID_JMMS_ERROR_READ_REPORT_SAVING,
  1159.                                 (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1160.                                 NULL);
  1161.                     }
  1162.                     if (eRet == JC_OK)
  1163.                     {
  1164.                         mmi_jmms_check_for_idle_screen();
  1165.                     }
  1166.                 }
  1167.                 mmi_jmms_jdi_msg_deinit(hMsgHandle);
  1168.                 hMsgHandle = NULL;
  1169.                 return;
  1170.             }
  1171.             else if (pMsgHdrs->eMsgType != E_MSG_TYPE_NOTIFICATION)
  1172.             {
  1173.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS, Invalid Message Type", pMsgHdrs->eMsgType));
  1174.                 mmi_jmms_jdi_msg_deinit(hMsgHandle);
  1175.                 hMsgHandle = NULL;
  1176.                 eRet = mmi_jmms_add_pending_mms_info_node(
  1177.                         (U16) STR_ID_JMMS_UNABLE_PARSE_PUSH,
  1178.                         (U8) E_MSG_TYPE_IDLE_SCREEN_POP_UP,
  1179.                         NULL);
  1180.                 if (eRet == JC_OK)
  1181.                 {
  1182.                     mmi_jmms_check_for_idle_screen();
  1183.                 }
  1184.                 return;
  1185.             }
  1186.             ///Transaction ID should be in ASCII
  1187.             //otherwise need changes
  1188.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Push Indication for JMMS Notification received"));
  1189.             pNotifyIndHdrs = (MESSAGE_NOTIFICATION*) pMsgHdrs->pHeaders;
  1190.             if (g_jmms_context->pTransactionID != NULL)
  1191.             {
  1192.                 if (strcmp(pNotifyIndHdrs->pTransactionID, g_jmms_context->pTransactionID) == 0)
  1193.                 {
  1194.                     mmi_jmms_jdi_msg_deinit(hMsgHandle);    /* Deepali Review????? */
  1195.                     hMsgHandle = NULL;
  1196.                     return;
  1197.                 }
  1198.                 jdd_MemFree(g_jmms_context->pTransactionID);
  1199.             }
  1200.             g_jmms_context->pTransactionID =
  1201.                 (JC_INT8*) jdd_MemAlloc(sizeof(JC_INT8), strlen(pNotifyIndHdrs->pTransactionID) + 1);
  1202.             if (g_jmms_context->pTransactionID != NULL)
  1203.             {
  1204.                 strcpy(g_jmms_context->pTransactionID, pNotifyIndHdrs->pTransactionID);
  1205.             }
  1206.             mmi_jmms_handle_new_mms_notification(&ViewContent, hMsgHandle, pNotifyIndHdrs);
  1207.             if (NULL != hMsgHandle)
  1208.             {
  1209.                 eRet = mmi_jmms_jdi_msg_deinit(hMsgHandle);
  1210.                 if (JC_OK != eRet)
  1211.                 {
  1212.                     return;
  1213.                 }
  1214.                 hMsgHandle = NULL;
  1215.             }
  1216.         }
  1217.     }
  1218. }
  1219. /*****************************************************************************
  1220.  * FUNCTION
  1221.  *  mmi_jmms_add_pending_mms_delivery_report_node
  1222.  * DESCRIPTION
  1223.  *  
  1224.  * PARAMETERS
  1225.  *  status          [IN]        
  1226.  *  to_address      [?]         [?]         [?]
  1227.  *  date            [IN]        
  1228.  * RETURNS
  1229.  *  
  1230.  *****************************************************************************/
  1231. JC_RETCODE mmi_jmms_add_pending_mms_delivery_report_node(U8 status, S8 *to_address, JC_UINT32 date)
  1232. {
  1233.     /*----------------------------------------------------------------*/
  1234.     /* Local Variables                                                */
  1235.     /*----------------------------------------------------------------*/
  1236.     jmms_pending_mms_delivery_reports_struct *node;
  1237.     U16 currScrenID;
  1238.     U32 len = 0;
  1239.     /*----------------------------------------------------------------*/
  1240.     /* Code Body                                                      */
  1241.     /*----------------------------------------------------------------*/
  1242.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_add_pending_mms_delivery_report_node"));
  1243.     currScrenID = GetActiveScreenId();
  1244.     node =
  1245.         (jmms_pending_mms_delivery_reports_struct*) jdd_MemAlloc(sizeof(jmms_pending_mms_delivery_reports_struct), 1);
  1246.     if (node == NULL)
  1247.     {
  1248.         return JC_ERR_MEMORY_ALLOCATION;
  1249.     }
  1250.     node->status = status;
  1251.     node->date = date;
  1252.     if (to_address != NULL)
  1253.     {
  1254.         len = (pfnUnicodeStrlen((S8*) to_address) + 1) * ENCODING_LENGTH;
  1255.         node->to_p = (S8*) jdd_MemAlloc(sizeof(S8), len);
  1256.         if (node->to_p == NULL)
  1257.         {
  1258.             return JC_ERR_MEMORY_ALLOCATION;
  1259.         }
  1260.         memcpy(node->to_p, to_address, len);
  1261.     }
  1262.     else
  1263.     {
  1264.         node->to_p = NULL;
  1265.     }
  1266.     if (currScrenID == SCR_ID_JMMS_NEW_MMS_IND &&
  1267.         (g_jmms_context->pending_mms_info_list->type == E_MSG_TYPE_DELIVERY_REPORT))
  1268.     {   /* /add as second node of link list */
  1269.         if (g_jmms_context->pending_delivery_reports == NULL)   /* /not possible */
  1270.         {
  1271.             return E_JMMS_GENERAL_ERROR;
  1272.         }
  1273.         else
  1274.         {
  1275.             node->next = g_jmms_context->pending_delivery_reports->next;
  1276.             g_jmms_context->pending_delivery_reports->next = node;
  1277.         }
  1278.     }
  1279.     else    /* /add as first node of link list */
  1280.     {
  1281.         node->next = g_jmms_context->pending_delivery_reports;
  1282.         g_jmms_context->pending_delivery_reports = node;
  1283.     }
  1284.     return JC_OK;
  1285. }
  1286. /*****************************************************************************
  1287.  * FUNCTION
  1288.  *  mmi_jmms_add_pending_mms_read_report_node
  1289.  * DESCRIPTION
  1290.  *  
  1291.  * PARAMETERS
  1292.  *  status              [IN]        
  1293.  *  from_address        [?]         [?]         [?]
  1294.  *  date                [IN]        
  1295.  * RETURNS
  1296.  *  
  1297.  *****************************************************************************/
  1298. JC_RETCODE mmi_jmms_add_pending_mms_read_report_node(U8 status, S8 *from_address, JC_UINT32 date)
  1299. {
  1300.     /*----------------------------------------------------------------*/
  1301.     /* Local Variables                                                */
  1302.     /*----------------------------------------------------------------*/
  1303.     jmms_pending_mms_read_reports_struct *node;
  1304.     U16 currScrenID;
  1305.     U32 len = 0;
  1306.     /*----------------------------------------------------------------*/
  1307.     /* Code Body                                                      */
  1308.     /*----------------------------------------------------------------*/
  1309.     currScrenID = GetActiveScreenId();
  1310.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_add_pending_mms_read_report_node"));
  1311.     node = (jmms_pending_mms_read_reports_struct*) jdd_MemAlloc(sizeof(jmms_pending_mms_read_reports_struct), 1);
  1312.     if (node == NULL)
  1313.     {
  1314.         return JC_ERR_MEMORY_ALLOCATION;
  1315.     }
  1316.     node->status = status;
  1317.     node->date = date;
  1318.     if (from_address != NULL)
  1319.     {
  1320.         len = (pfnUnicodeStrlen((S8*) from_address) + 1) * ENCODING_LENGTH;
  1321.         node->from_p = (S8*) jdd_MemAlloc(sizeof(S8), len);
  1322.         if (node->from_p == NULL)
  1323.         {
  1324.             return JC_ERR_MEMORY_ALLOCATION;
  1325.         }
  1326.         memcpy(node->from_p, from_address, len);
  1327.     }
  1328.     else
  1329.     {
  1330.         node->from_p = NULL;
  1331.     }
  1332.     if (currScrenID == SCR_ID_JMMS_NEW_MMS_IND &&
  1333.         (g_jmms_context->pending_mms_info_list->type == E_MSG_TYPE_READ_REPORT_RESPONSE))
  1334.     {                                                       /* /add as second node of link list */
  1335.         if (g_jmms_context->pending_read_reports == NULL)   /* /not possible */
  1336.         {
  1337.             return E_JMMS_GENERAL_ERROR;
  1338.         }
  1339.         else
  1340.         {
  1341.             node->next = g_jmms_context->pending_read_reports->next;
  1342.             g_jmms_context->pending_read_reports->next = node;
  1343.         }
  1344.     }
  1345.     else    /* /add as first node of link list */
  1346.     {
  1347.         node->next = g_jmms_context->pending_read_reports;
  1348.         g_jmms_context->pending_read_reports = node;
  1349.     }
  1350.     return JC_OK;
  1351. }
  1352. /*****************************************************************************
  1353.  * FUNCTION
  1354.  *  mmi_jmms_add_pending_mms_info_node
  1355.  * DESCRIPTION
  1356.  *  
  1357.  * PARAMETERS
  1358.  *  msg_index               [IN]        
  1359.  *  msg_type                [IN]        
  1360.  *  content_location        [?]         [?]         [?]
  1361.  * RETURNS
  1362.  *  
  1363.  *****************************************************************************/
  1364. JC_RETCODE mmi_jmms_add_pending_mms_info_node(U16 msg_index, U8 msg_type, S8 *content_location)
  1365. {
  1366.     /*----------------------------------------------------------------*/
  1367.     /* Local Variables                                                */
  1368.     /*----------------------------------------------------------------*/
  1369.     jmms_pending_mms_info_struct *node;
  1370.     U16 currScrenID;
  1371.     U32 len = 0;
  1372.     /*----------------------------------------------------------------*/
  1373.     /* Code Body                                                      */
  1374.     /*----------------------------------------------------------------*/
  1375.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_add_pending_mms_info_node"));
  1376. #ifdef __MMI_UNIFIED_MESSAGE__
  1377.     if (msg_type != E_MSG_TYPE_IDLE_SCREEN_POP_UP)
  1378.     {
  1379.         TurnOnBacklight(GPIO_BACKLIGHT_SHORT_TIME);
  1380. mmi_um_jmms_new_mms_message_ind(msg_index);
  1381.         return JC_OK;
  1382.     }
  1383. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1384.     currScrenID = GetActiveScreenId();
  1385.     node = (jmms_pending_mms_info_struct*) jdd_MemAlloc(sizeof(jmms_pending_mms_info_struct), 1);
  1386.     if (node == NULL)
  1387.     {
  1388.         return JC_ERR_MEMORY_ALLOCATION;
  1389.     }
  1390.     node->Index = msg_index;
  1391.     node->type = msg_type;
  1392.     if (content_location != NULL)
  1393.     {
  1394.         len = strlen((S8*) content_location) + 1;
  1395.         node->mms_url = (S8*) jdd_MemAlloc(sizeof(S8), len);
  1396.         if (node->mms_url == NULL)
  1397.         {
  1398.             return JC_ERR_MEMORY_ALLOCATION;
  1399.         }
  1400.         memcpy(node->mms_url, content_location, len);
  1401.     }
  1402.     else
  1403.     {
  1404.         node->mms_url = NULL;
  1405.     }
  1406.     if (currScrenID == SCR_ID_JMMS_NEW_MMS_IND)
  1407.     {                                                       /* /add as second node of link list */
  1408.         if (g_jmms_context->pending_mms_info_list == NULL)  /* /not possible */
  1409.         {
  1410.             return E_JMMS_GENERAL_ERROR;
  1411.         }
  1412.         else
  1413.         {
  1414.             node->next = g_jmms_context->pending_mms_info_list->next;
  1415.             g_jmms_context->pending_mms_info_list->next = node;
  1416.         }
  1417.     }
  1418.     else    /* /add as first node of link list */
  1419.     {
  1420.         node->next = g_jmms_context->pending_mms_info_list;
  1421.         g_jmms_context->pending_mms_info_list = node;
  1422.     }
  1423.     return JC_OK;
  1424. }
  1425. /*****************************************************************************
  1426.  * FUNCTION
  1427.  *  mmi_jmms_header_ind_callback
  1428.  * DESCRIPTION
  1429.  *  
  1430.  * PARAMETERS
  1431.  *  jmms_context        [?]     [?]     [?]
  1432.  *  pCommHeaderInd      [?]     [?]     [?]
  1433.  * RETURNS
  1434.  *  
  1435.  *****************************************************************************/
  1436. JC_RETCODE mmi_jmms_header_ind_callback(jmms_context_struct *jmms_context, COMM_HEADER_INDICATION *pCommHeaderInd)
  1437. {
  1438.     /*----------------------------------------------------------------*/
  1439.     /* Local Variables                                                */
  1440.     /*----------------------------------------------------------------*/
  1441.     JC_RETCODE eRet = JC_OK;
  1442.     jmms_communication_state_node *comm_node = NULL;
  1443.     /*----------------------------------------------------------------*/
  1444.     /* Code Body                                                      */
  1445.     /*----------------------------------------------------------------*/
  1446.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Header Ind Callback, Request Id:",
  1447.                          pCommHeaderInd->uiRequestID));
  1448.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Header Ind HTTP Status:", pCommHeaderInd->eStatus));
  1449.     comm_node = mmi_jmms_get_comm_state(jmms_context, pCommHeaderInd->uiRequestID);
  1450.     if (comm_node == NULL)
  1451.     {
  1452.         if (pCommHeaderInd->uiRequestID)
  1453.         {
  1454.             jdi_CommunicationFreeReference(jmms_context->hCommHandle, pCommHeaderInd->uiRequestID);
  1455.         }
  1456.         pCommHeaderInd->uiRequestID = 0;
  1457.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)",
  1458.                              "JMMS: No commn node for this Header Indication, so free communication reference for request id:",
  1459.                              pCommHeaderInd->uiRequestID));
  1460.         return E_JMMS_GENERAL_ERROR;    /* error type doesn't matter */
  1461.     }
  1462.     if (pCommHeaderInd->eStatus != 200) /* /200 is HTTP OK */
  1463.     {
  1464.         if (pCommHeaderInd->uiRequestID)
  1465.         {
  1466.             eRet = jdi_CommunicationFreeReference(jmms_context->hCommHandle, pCommHeaderInd->uiRequestID);
  1467.             if (JC_OK != eRet)
  1468.             {
  1469.                 mmi_jmms_handle_error_in_communication(
  1470.                     jmms_context,
  1471.                     E_FROM_URL_CALLBACK,
  1472.                     comm_node,
  1473.                     pCommHeaderInd->eStatus);
  1474.                 mmi_jmms_free_comm_node(jmms_context, pCommHeaderInd->uiRequestID);
  1475.                 pCommHeaderInd->uiRequestID = 0;
  1476.                 return JC_ERR_MEMORY_ALLOCATION;    /* error type doesn't matter */
  1477.             }
  1478.         }
  1479.         eRet = mmi_jmms_retry_communication(
  1480.                 jmms_context,
  1481.                 E_FROM_URL_CALLBACK,
  1482.                 pCommHeaderInd->uiRequestID,
  1483.                 pCommHeaderInd->eStatus);
  1484.         if (JC_OK != eRet)
  1485.         {
  1486.             mmi_jmms_handle_error_in_communication(
  1487.                 jmms_context,
  1488.                 E_FROM_URL_CALLBACK,
  1489.                 comm_node,
  1490.                 E_JMMS_DEAFULT_COMM_ERROR_CODE);
  1491.             mmi_jmms_free_comm_node(jmms_context, pCommHeaderInd->uiRequestID);
  1492.             pCommHeaderInd->uiRequestID = 0;
  1493. // sandeep start to fix PMTSW00006618
  1494. #ifdef __MMI_UNIFIED_MESSAGE__
  1495. if((comm_node->mms_communication_state == E_TYPE_NOTIFICATION_RESPONSE) && IsScreenPresent(SCR_ID_UM_UNSENT))
  1496. {
  1497. DeleteUptoScrID(SCR_ID_UM_UNSENT);
  1498. }
  1499. #endif
  1500. //sandeep end to fix PMTSW00006618
  1501.             return JC_ERR_MEMORY_ALLOCATION;    /* error type doesn't matter */
  1502.         }
  1503.         mmi_jmms_free_comm_node(jmms_context, pCommHeaderInd->uiRequestID);
  1504.         return E_JMMS_GENERAL_ERROR;    /* error type doesn't matter. By virtue of !=JC_OK value communicator will delete */
  1505.         /* /this request so that url Indication Callback will not be further called */
  1506.     }
  1507.     comm_node->pContentType = (JC_INT8*) jdi_UtilsStrdup(pCommHeaderInd->pszContentType);
  1508.     if(comm_node->mms_communication_state == E_TYPE_NOTIFICATION_RESPONSE ||
  1509.         comm_node->mms_communication_state == E_TYPE_READ_REPORT_PDU ||
  1510.         comm_node->mms_communication_state == E_TYPE_ACK_RESPONSE)
  1511.     {
  1512.          mmi_jmms_free_comm_node(g_jmms_context, pCommHeaderInd->uiRequestID);
  1513.     }
  1514.     return JC_OK;
  1515. }
  1516. /*****************************************************************************
  1517.  * FUNCTION
  1518.  *  mmi_jmms_url_ind_callback
  1519.  * DESCRIPTION
  1520.  *  
  1521.  * PARAMETERS
  1522.  *  jmms_context        [?]     [?]     [?]
  1523.  *  pURLInd             [?]     [?]     [?]
  1524.  * RETURNS
  1525.  *  
  1526.  *****************************************************************************/
  1527. JC_RETCODE mmi_jmms_url_ind_callback(jmms_context_struct *jmms_context, COMM_FETCH_URL_IND_RESP *pURLInd)
  1528. {
  1529.     /*----------------------------------------------------------------*/
  1530.     /* Local Variables                                                */
  1531.     /*----------------------------------------------------------------*/
  1532.     JC_RETCODE eRet = JC_OK;
  1533.     CONTENT_DATA Content = {0, };
  1534.     JC_RETCODE error = JC_OK;
  1535.     jmms_communication_state_node *comm_node = NULL;
  1536.     /*----------------------------------------------------------------*/
  1537.     /* Code Body                                                      */
  1538.     /*----------------------------------------------------------------*/
  1539.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_url_ind_callback"));
  1540.     comm_node = mmi_jmms_get_comm_state(jmms_context, pURLInd->uiRequestID);
  1541.     if (comm_node == NULL)
  1542.     {
  1543.         if (pURLInd->uiRequestID)
  1544.         {
  1545.             eRet = jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
  1546.         }
  1547.         pURLInd->uiRequestID = 0;
  1548.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)",
  1549.                              "JMMS: No commn node for this id, call jdi_CommunicationFreeReference",
  1550.                              pURLInd->uiRequestID));
  1551.         return E_JMMS_GENERAL_ERROR;
  1552.     }
  1553.     if (pURLInd->uiCurrentLength > 0)
  1554.     {
  1555.         if (comm_node->hFile == NULL)
  1556.         {
  1557.             JC_INT8 Temp[50] = {0, };
  1558.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Handle Url First Chunk, Request id",
  1559.                                  pURLInd->uiRequestID));
  1560.             if (comm_node->fs_handle == NULL)
  1561.             {
  1562.                 if (jdd_FSInitialize(&comm_node->fs_handle) != JC_OK)
  1563.                 {
  1564.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "Error In Init File"));
  1565.                     eRet = JC_ERR_FILE_OPEN;
  1566.                     mmi_jmms_handle_error_in_communication(
  1567.                         jmms_context,
  1568.                         E_FROM_URL_CALLBACK,
  1569.                         comm_node,
  1570.                         E_JMMS_DEAFULT_COMM_ERROR_CODE);
  1571.                     jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
  1572.                     mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
  1573.                     pURLInd->uiRequestID = 0;
  1574.                     return eRet;
  1575.                 }
  1576.             }
  1577.             /* manish for file path change */
  1578.             jc_sprintf(Temp, "%s%d", "@mms\temp\jmms_temp", pURLInd->uiRequestID);
  1579.             jdi_UtilsCharToTchar(&(comm_node->pFileName), Temp);
  1580.             comm_node->hFile = jdd_FSOpen(comm_node->fs_handle, comm_node->pFileName, E_CREATE_WRITE_MODE);
  1581.         }
  1582.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Handle other Url Chunks, Request Id:",
  1583.                              pURLInd->uiRequestID));
  1584. #if defined (__USB_IN_NORMAL_MODE__) 
  1585.         if (mmi_jmms_check_usb_mode() )
  1586.         {
  1587.           PRINT_INFORMATION_2((MMI_TRACE_INFO, "USB Mode: Write To File"));
  1588.         }
  1589. #endif 
  1590.         error = jdd_FSWrite(pURLInd->pucBuffer, pURLInd->uiCurrentLength, 1, comm_node->hFile);
  1591. #if defined (__USB_IN_NORMAL_MODE__) 
  1592.         if (mmi_jmms_check_usb_mode() )
  1593.           PRINT_INFORMATION_2((MMI_TRACE_INFO, "USB Mode: Write To File return=%d", error));
  1594. #endif 
  1595.         if (error != 1)
  1596.         {
  1597.             if (error == JC_ERR_FILE_FULL || error == JC_ERR_FILE_WRITE)
  1598.             {
  1599.                 mmi_jmms_handle_error_in_communication(jmms_context, E_FROM_URL_CALLBACK, comm_node, JC_ERR_FILE_FULL);
  1600.             }
  1601.             else
  1602.             {
  1603.                 mmi_jmms_handle_error_in_communication(
  1604.                     jmms_context,
  1605.                     E_FROM_URL_CALLBACK,
  1606.                     comm_node,
  1607.                     E_JMMS_DEAFULT_COMM_ERROR_CODE);
  1608.             }
  1609.             if (comm_node->hFile != NULL)
  1610.             {
  1611.                 jdd_FSClose(comm_node->hFile);
  1612.             }
  1613.             jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
  1614.             mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
  1615.             pURLInd->uiRequestID = 0;
  1616.             return JC_ERR_FILE_OPEN;
  1617.         }
  1618.         comm_node->reponse_size += pURLInd->uiCurrentLength;
  1619.     }
  1620.     if (pURLInd->bHasMoreData == E_FALSE)
  1621.     {
  1622.         if (comm_node->hFile)
  1623.         {
  1624.             if (comm_node->reponse_size > 0)
  1625.             {
  1626.                 jdd_FSClose(comm_node->hFile);
  1627.                 /* /7 March */
  1628.                 if (g_jmms_context->jmms_fs_handle != NULL)
  1629.                 {
  1630.                     jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1631.                     g_jmms_context->jmms_fs_handle = NULL;
  1632.                 }
  1633.                 Content.bIsStream = E_TRUE;
  1634.                 Content.cbReadCallback = mmi_jmms_read_callback;
  1635.                 Content.uiTotalSize = comm_node->reponse_size;
  1636.                 Content.uiCurSize = 0;
  1637.                 Content.pStream = comm_node->pFileName;
  1638.                 Content.pFileName = comm_node->pFileName;
  1639.             }
  1640.         }
  1641.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS URL Chunks Finished. Request id:", pURLInd->uiRequestID));
  1642.         /* /When control is here then no problem with return eRet because after that */
  1643.         eRet = mmi_jmms_handle_url_repsonse(jmms_context, pURLInd, Content);
  1644.     }
  1645.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_url_ind_callback return:", eRet));
  1646.     return eRet;
  1647. }
  1648. /*****************************************************************************
  1649.  * FUNCTION
  1650.  *  mmi_jmms_handle_url_repsonse
  1651.  * DESCRIPTION
  1652.  *  
  1653.  * PARAMETERS
  1654.  *  jmms_context        [?]         [?]         [?]
  1655.  *  pURLInd             [?]         [?]         [?]
  1656.  *  Content             [IN]        
  1657.  * RETURNS
  1658.  *  
  1659.  *****************************************************************************/
  1660. JC_RETCODE mmi_jmms_handle_url_repsonse(
  1661.             jmms_context_struct *jmms_context,
  1662.             COMM_FETCH_URL_IND_RESP *pURLInd,
  1663.             CONTENT_DATA Content)
  1664. {
  1665.     /*----------------------------------------------------------------*/
  1666.     /* Local Variables                                                */
  1667.     /*----------------------------------------------------------------*/
  1668.     jmms_communication_state_node *comm_node = NULL;
  1669.     JC_RETCODE eRet = JC_OK;
  1670.     /*----------------------------------------------------------------*/
  1671.     /* Code Body                                                      */
  1672.     /*----------------------------------------------------------------*/
  1673.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_handle_url_repsonse"));
  1674.     comm_node = mmi_jmms_get_comm_state(jmms_context, pURLInd->uiRequestID);
  1675.     if (comm_node == NULL)
  1676.     {
  1677.         if (pURLInd->uiRequestID)
  1678.         {
  1679.             jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
  1680.         }
  1681.         pURLInd->uiRequestID = 0;
  1682.         return JC_ERR_MEMORY_ALLOCATION;
  1683.     }
  1684.     if (Content.uiTotalSize != 0)   /* for notification response/ack response this value will be 0 and content type will return */
  1685.     {
  1686.         if (comm_node->pContentType == NULL ||
  1687.             jc_strcmp(comm_node->pContentType, "application/vnd.wap.mms-message") != 0)
  1688.         {
  1689.             if (pURLInd->uiRequestID)
  1690.             {
  1691.                 jdi_CommunicationFreeReference(jmms_context->hCommHandle, pURLInd->uiRequestID);
  1692.             }
  1693.             /* Todo: Need to pass approraite error code- last  parameter */
  1694.             mmi_jmms_handle_error_in_communication(
  1695.                 jmms_context,
  1696.                 E_FROM_URL_CALLBACK,
  1697.                 comm_node,
  1698.                 JMMS_WRONG_CONTENT_TYPE_ERROR);
  1699.             mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
  1700.             pURLInd->uiRequestID = 0;
  1701.             return JC_ERR_MEMORY_ALLOCATION;    /* error type does not matter */
  1702.         }
  1703.     }
  1704.     switch (comm_node->mms_communication_state)
  1705.     {
  1706.         case E_TYPE_ACK_RESPONSE:
  1707.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS ACK Response, Request ID: ", pURLInd->uiRequestID));
  1708.             eRet = mmi_jmms_handle_notification_ack_response(jmms_context, pURLInd, &Content);
  1709.             break;
  1710.         case E_TYPE_NOTIFICATION_RESPONSE:
  1711.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Notification Response, Request ID: ",
  1712.                                  pURLInd->uiRequestID));
  1713.             eRet = mmi_jmms_handle_notification_ack_response(jmms_context, pURLInd, &Content);
  1714.             break;
  1715.         case E_TYPE_READ_REPORT_PDU:
  1716.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS READ Report PDU Response, Request ID: ",
  1717.                                  pURLInd->uiRequestID));
  1718.             eRet = mmi_jmms_handle_read_report_pdu_response(jmms_context, pURLInd, &Content);
  1719.             break;
  1720.         case E_TYPE_READ_REPORT_MMS:
  1721.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Read Report MMS Response, Request ID: ",
  1722.                                  pURLInd->uiRequestID));
  1723.             eRet = mmi_jmms_handle_read_report_mms_response(jmms_context, pURLInd, &Content);
  1724.             break;
  1725.         case E_TYPE_IMMEDIATE_RETRIEVAL_FETCH:
  1726.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Immdiate Download Response, Request ID: ",
  1727.                                  pURLInd->uiRequestID));
  1728.             eRet = mmi_jmms_handle_immediate_downlaod_response(jmms_context, pURLInd, &Content);
  1729.             break;
  1730.         case E_TYPE_DEFFERED_RETRIEVAL_FETCH:
  1731.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Deferred Download Response, Request ID: ",
  1732.                                  pURLInd->uiRequestID));
  1733.             eRet = mmi_jmms_handle_deffered_downlaod_response(jmms_context, pURLInd, &Content);
  1734.             break;
  1735.     #ifdef MMI_JMMS_JAVA_MMS_SUPPORT
  1736.         case E_TYPE_NEW_JAVA_MMS_SEND:
  1737.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS JSR New MMS Response, Request ID: ",
  1738.                                  pURLInd->uiRequestID));
  1739.             eRet = mmi_jmms_jsr_mms_send_response(jmms_context, pURLInd, Content);
  1740.             break;
  1741.     #endif /* MMI_JMMS_JAVA_MMS_SUPPORT */ 
  1742.         case E_TYPE_NEW_MMS:
  1743.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS New MMS Send Response, Request ID: ",
  1744.                                  pURLInd->uiRequestID));
  1745.             eRet = mmi_jmms_handle_new_mms_send_response(jmms_context, pURLInd, &Content);
  1746.             break;
  1747.         default:
  1748.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Undefined Communication State, Request ID: ",
  1749.                                  pURLInd->uiRequestID));
  1750.             mmi_jmms_free_comm_node(jmms_context, pURLInd->uiRequestID);
  1751.     }   /* /end of switch switch(jmms_context->mms_communication_state) */
  1752.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_handle_url_repsonse return:", eRet));
  1753.     return eRet;
  1754. }
  1755. /*****************************************************************************
  1756.  * FUNCTION
  1757.  *  mmi_jmms_free_comm_node
  1758.  * DESCRIPTION
  1759.  *  
  1760.  * PARAMETERS
  1761.  *  jmms_context        [?]         [?]         [?]
  1762.  *  uiReferenceID       [IN]        
  1763.  * RETURNS
  1764.  *  void
  1765.  *****************************************************************************/
  1766. void mmi_jmms_free_comm_node(jmms_context_struct *jmms_context, JC_UINT32 uiReferenceID)
  1767. {
  1768.     /*----------------------------------------------------------------*/
  1769.     /* Local Variables                                                */
  1770.     /*----------------------------------------------------------------*/
  1771.     jmms_communication_state_node *comm_node = NULL, *previous_node = NULL;
  1772.     jmms_communication_state_node *temp_comp_node = NULL;
  1773.     /*----------------------------------------------------------------*/
  1774.     /* Code Body                                                      */
  1775.     /*----------------------------------------------------------------*/
  1776.     comm_node = jmms_context->comm_state;
  1777.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_free_comm_node"));
  1778.     /* / 7 March */
  1779.     if (g_jmms_context->jmms_fs_handle == NULL)
  1780.     {
  1781.         if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1782.         {
  1783.             return;
  1784.         }
  1785.     }
  1786.     while (comm_node != NULL)
  1787.     {
  1788.         if (comm_node->uiReferenceID == uiReferenceID)
  1789.         {
  1790.             if (comm_node->hFile)
  1791.             {
  1792.                 jdd_FSClose(comm_node->hFile);
  1793.                 jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName);
  1794.                 comm_node->hFile = NULL;
  1795.             }
  1796.             if ((comm_node->pFileName) != NULL)
  1797.             {
  1798.                 jdd_MemFree(comm_node->pFileName);
  1799.                 comm_node->pFileName = NULL;
  1800.             }
  1801.             if ((comm_node->fs_handle) != NULL)
  1802.             {
  1803.                 jdd_FSDeinitialize(comm_node->fs_handle);
  1804.             }
  1805.             if ((comm_node->pFileName_used_for_Send) != NULL)
  1806.             {
  1807.                 jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName_used_for_Send);
  1808.                 jdd_MemFree(comm_node->pFileName_used_for_Send);
  1809.                 comm_node->pFileName_used_for_Send = NULL;
  1810.             }
  1811.             if ((comm_node->pContentType) != NULL)
  1812.             {
  1813.                 jdd_MemFree(comm_node->pContentType);
  1814.                 comm_node->pContentType = NULL;
  1815.             }
  1816.             if ((comm_node->mms_content_location) != NULL)
  1817.             {
  1818.                 jdd_MemFree(comm_node->mms_content_location);
  1819.                 comm_node->mms_content_location = NULL;
  1820.             }
  1821.             if((comm_node->mms_communication_state != E_TYPE_NOTIFICATION_RESPONSE) &&
  1822.                 (comm_node->mms_communication_state != E_TYPE_READ_REPORT_PDU) &&
  1823.                 (comm_node->mms_communication_state != E_TYPE_READ_REPORT_MMS) &&
  1824.                 (comm_node->mms_communication_state != E_TYPE_ACK_RESPONSE))
  1825.             {
  1826.                 mmi_jmms_reset_mms_downloading_busy();
  1827.                 mmi_jmms_update_status_icon_indicator();
  1828.             }
  1829.             if (previous_node == NULL)
  1830.             {
  1831.                 /*Vikram: The target is to set the g_jmms_context->uiReferenceID value. For the case, MMS Send->Notification
  1832.                    MMS Send Retry, g_jmms_context->uiReferenceID will get 0 after Notification*/
  1833.                 jmms_context->comm_state = comm_node->next;
  1834.             }
  1835.             else
  1836.             {
  1837.                 previous_node->next = comm_node->next;
  1838.             }
  1839.             /* 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
  1840.                     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
  1841.                     will misbehave*/
  1842.            /* g_jmms_context->uiReferenceID  = 0;*/
  1843.                temp_comp_node = jmms_context->comm_state;
  1844.                while(temp_comp_node && 
  1845.                    !((temp_comp_node->mms_communication_state == E_TYPE_NEW_MMS)||
  1846.                    (temp_comp_node->mms_communication_state == E_TYPE_DEFFERED_RETRIEVAL_FETCH)||
  1847.                    (temp_comp_node->mms_communication_state == E_TYPE_NEW_JAVA_MMS_SEND))) 
  1848.                {
  1849.                     temp_comp_node = temp_comp_node->next;
  1850.                }
  1851.                if(temp_comp_node)
  1852.                    g_jmms_context->uiReferenceID=temp_comp_node->uiReferenceID;
  1853.                else
  1854.             g_jmms_context->uiReferenceID  = 0;
  1855.                 temp_comp_node = jmms_context->comm_state;
  1856.                 while(temp_comp_node)
  1857.                 {
  1858.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "n%s%d", "g_jmms_context->uiReferenceID = ", g_jmms_context->uiReferenceID));
  1859.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "n%s%d", "Communication State = ", temp_comp_node->mms_communication_state));
  1860.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "n%s%d", "Reference Id = ", temp_comp_node->uiReferenceID));
  1861.                     temp_comp_node = temp_comp_node->next;
  1862.                     
  1863.                 }
  1864.             jdd_MemFree(comm_node);
  1865.             break;
  1866.         }
  1867.         previous_node = comm_node;
  1868.         comm_node = comm_node->next;
  1869.     }
  1870.     if (g_jmms_context->jmms_fs_handle != NULL)
  1871.     {
  1872.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1873.         g_jmms_context->jmms_fs_handle = NULL;
  1874.     }
  1875.     /* /added for disappearing the G icon */
  1876.     if (g_jmms_context->comm_state == NULL)
  1877.     {
  1878.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Timer for Disconnect "));
  1879.         StartTimer(JMMS_NO_COMM_TIMER_CHECK, 10000, mmi_jmms_comm_time_hdlr);
  1880.     }
  1881.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Comm Node Free for Request ID", uiReferenceID));
  1882. }
  1883. /*****************************************************************************
  1884.  * FUNCTION
  1885.  *  mmi_jmms_is_immediate_retrival_underway
  1886.  * DESCRIPTION
  1887.  *  Returns whether any immediate retrival is underway
  1888.  * PARAMETERS
  1889.  *  void
  1890.  *  uiReferenceID(?)        [IN]        
  1891.  *  jmms_context        [?](?)
  1892.  * RETURNS
  1893.  *  void
  1894.  *****************************************************************************/
  1895. S32 mmi_jmms_is_immediate_retrival_underway(void)
  1896. {
  1897.     /*----------------------------------------------------------------*/
  1898.     /* Local Variables                                                */
  1899.     /*----------------------------------------------------------------*/
  1900.     JC_INT32 retrival_underway=E_FALSE;
  1901.     jmms_communication_state_node *comm_node = NULL;
  1902.     /*----------------------------------------------------------------*/
  1903.     /* Code Body                                                      */
  1904.     /*----------------------------------------------------------------*/
  1905.     comm_node = g_jmms_context->comm_state;
  1906.     while (comm_node != NULL)
  1907.     {
  1908.         if(comm_node->mms_communication_state == E_TYPE_IMMEDIATE_RETRIEVAL_FETCH)
  1909.         {
  1910.             retrival_underway=E_TRUE;
  1911.             break;
  1912.         }
  1913.         comm_node = comm_node->next;
  1914.     }
  1915.     return retrival_underway;
  1916. }
  1917. /*****************************************************************************
  1918.  * FUNCTION
  1919.  *  mmi_jmms_free_comm_node_list
  1920.  * DESCRIPTION
  1921.  *  
  1922.  * PARAMETERS
  1923.  *  void
  1924.  *  uiReferenceID(?)        [IN]        
  1925.  *  jmms_context        [?](?)
  1926.  * RETURNS
  1927.  *  void
  1928.  *****************************************************************************/
  1929. void mmi_jmms_free_comm_node_list(void)
  1930. {
  1931.     /*----------------------------------------------------------------*/
  1932.     /* Local Variables                                                */
  1933.     /*----------------------------------------------------------------*/
  1934.     jmms_communication_state_node *comm_node = NULL, *previous_node = NULL;
  1935.     /*----------------------------------------------------------------*/
  1936.     /* Code Body                                                      */
  1937.     /*----------------------------------------------------------------*/
  1938.     comm_node = g_jmms_context->comm_state;
  1939.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_free_comm_node"));
  1940.     if (g_jmms_context->jmms_fs_handle == NULL)
  1941.     {
  1942.         if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1943.         {
  1944.             return;
  1945.         }
  1946.     }
  1947.     while (comm_node != NULL)
  1948.     {
  1949.         if (comm_node->uiReferenceID != 0)
  1950.         {
  1951.             jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, comm_node->uiReferenceID);
  1952.         }
  1953.         if (comm_node->hFile)
  1954.         {
  1955.             jdd_FSClose(comm_node->hFile);
  1956.             jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName);
  1957.             comm_node->hFile = NULL;
  1958.         }
  1959.         if ((comm_node->pFileName) != NULL)
  1960.         {
  1961.             jdd_MemFree(comm_node->pFileName);
  1962.             comm_node->pFileName = NULL;
  1963.         }
  1964.         if ((comm_node->pFileName_used_for_Send) != NULL)
  1965.         {
  1966.             jdd_FSDelete(g_jmms_context->jmms_fs_handle, comm_node->pFileName_used_for_Send);
  1967.             jdd_MemFree(comm_node->pFileName_used_for_Send);
  1968.             comm_node->pFileName_used_for_Send = NULL;
  1969.         }
  1970.         if ((comm_node->pContentType) != NULL)
  1971.         {
  1972.             jdd_MemFree(comm_node->pContentType);
  1973.             comm_node->pContentType = NULL;
  1974.         }
  1975.         if ((comm_node->mms_content_location) != NULL)
  1976.         {
  1977.             jdd_MemFree(comm_node->mms_content_location);
  1978.             comm_node->mms_content_location = NULL;
  1979.         }
  1980.         comm_node->mms_communication_state = E_TYPE_NULL;
  1981.         if (previous_node == NULL)
  1982.         {
  1983.             g_jmms_context->comm_state = comm_node->next;
  1984.         }
  1985.         else
  1986.         {
  1987.             previous_node->next = comm_node->next;
  1988.         }
  1989.         jdd_MemFree(comm_node);
  1990.         comm_node = comm_node->next;
  1991.         mmi_jmms_stop_download_busy(); 
  1992.         mmi_jmms_update_status_icon_indicator();
  1993.     }
  1994.     if (g_jmms_context->jmms_fs_handle != NULL)
  1995.     {
  1996.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1997.         g_jmms_context->jmms_fs_handle = NULL;
  1998.     }
  1999.     if (g_jmms_context->comm_state == NULL)
  2000.     {
  2001.         jdi_CommunicationDisconnect(g_jmms_context->hCommHandle);
  2002.         g_mms_downloading_busy = 0;
  2003.         mmi_jmms_update_status_icon_indicator();
  2004.     }
  2005.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Comm list for File Format Issue"));
  2006. }
  2007. /*****************************************************************************
  2008.  * FUNCTION
  2009.  *  mmi_jmms_comm_time_hdlr
  2010.  * DESCRIPTION
  2011.  *  
  2012.  * PARAMETERS
  2013.  *  void
  2014.  * RETURNS
  2015.  *  void
  2016.  *****************************************************************************/
  2017. void mmi_jmms_comm_time_hdlr(void)
  2018. {
  2019.     /*----------------------------------------------------------------*/
  2020.     /* Local Variables                                                */
  2021.     /*----------------------------------------------------------------*/
  2022.     /*----------------------------------------------------------------*/
  2023.     /* Code Body                                                      */
  2024.     /*----------------------------------------------------------------*/
  2025.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_comm_time_hdlr"));
  2026.     if (g_jmms_context->comm_state == NULL)
  2027.     {
  2028.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_comm_time_hdlr : Disconnect"));
  2029.         jdi_CommunicationDisconnect(g_jmms_context->hCommHandle);
  2030.     }
  2031. }
  2032. /*****************************************************************************
  2033.  * FUNCTION
  2034.  *  mmi_jmms_add_comm_node
  2035.  * DESCRIPTION
  2036.  *  
  2037.  * PARAMETERS
  2038.  *  jmms_context            [?]         [?]         [?]
  2039.  *  uiReferenceID           [IN]        
  2040.  *  comm_state              [IN]        
  2041.  *  file_name_for_send      [?]         [?]         [?]
  2042.  *  msg_index               [IN]        
  2043.  *  retry_counter           [IN]        
  2044.  *  content_location        [?]         [?]         [?]
  2045.  * RETURNS
  2046.  *  
  2047.  *****************************************************************************/
  2048. JC_RETCODE mmi_jmms_add_comm_node(
  2049.             jmms_context_struct *jmms_context,
  2050.             JC_UINT32 uiReferenceID,
  2051.             U16 comm_state,
  2052.             JC_CHAR *file_name_for_send,
  2053.             JC_UINT32 msg_index,
  2054.             U8 retry_counter,
  2055.             S8 *content_location)
  2056. {
  2057.     /*----------------------------------------------------------------*/
  2058.     /* Local Variables                                                */
  2059.     /*----------------------------------------------------------------*/
  2060.     jmms_communication_state_node *comm_node = NULL;
  2061.     jmms_communication_state_node *temp_node = NULL;
  2062.     /*----------------------------------------------------------------*/
  2063.     /* Code Body                                                      */
  2064.     /*----------------------------------------------------------------*/
  2065.     comm_node = (jmms_communication_state_node*) jdd_MemAlloc(1, sizeof(jmms_communication_state_node));
  2066.     if (comm_node == NULL)
  2067.     {
  2068.         return JC_ERR_MEMORY_ALLOCATION;
  2069.     }
  2070.     comm_node->hFile = NULL;
  2071.     comm_node->mms_communication_state = comm_state;
  2072.     comm_node->next = NULL;
  2073.     comm_node->pFileName = NULL;
  2074.     comm_node->reponse_size = 0;
  2075.     comm_node->uiReferenceID = uiReferenceID;
  2076.     comm_node->pFileName_used_for_Send = file_name_for_send;
  2077.     comm_node->msg_index = msg_index;
  2078.     comm_node->retry_counter = retry_counter;
  2079.     comm_node->mms_content_location = content_location;
  2080.     comm_node->fs_handle = NULL;
  2081.     if (jmms_context->comm_state == NULL)
  2082.     {
  2083.         jmms_context->comm_state = comm_node;
  2084.     }
  2085.     else
  2086.     {
  2087.         temp_node = jmms_context->comm_state;
  2088.         while (temp_node->next != NULL)
  2089.         {
  2090.             temp_node = temp_node->next;
  2091.         }
  2092.         temp_node->next = comm_node;
  2093.     }
  2094.    if((comm_node->mms_communication_state != E_TYPE_NOTIFICATION_RESPONSE) &&
  2095.             (comm_node->mms_communication_state != E_TYPE_READ_REPORT_PDU) &&
  2096.             (comm_node->mms_communication_state != E_TYPE_READ_REPORT_MMS) &&
  2097.            (comm_node->mms_communication_state != E_TYPE_ACK_RESPONSE))
  2098.     {
  2099.         mmi_jmms_set_mms_downloading_busy();
  2100.         mmi_jmms_update_status_icon_indicator();
  2101.     }
  2102.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS New Comm Node Added for Request ID", uiReferenceID));
  2103.     return JC_OK;
  2104. }
  2105. /*****************************************************************************
  2106.  * FUNCTION
  2107.  *  mmi_jmms_get_comm_state
  2108.  * DESCRIPTION
  2109.  *  
  2110.  * PARAMETERS
  2111.  *  jmms_context        [?]         [?]         [?]
  2112.  *  uiReferenceID       [IN]        
  2113.  * RETURNS
  2114.  *  
  2115.  *****************************************************************************/
  2116. jmms_communication_state_node *mmi_jmms_get_comm_state(jmms_context_struct *jmms_context, JC_UINT32 uiReferenceID)
  2117. {
  2118.     /*----------------------------------------------------------------*/
  2119.     /* Local Variables                                                */
  2120.     /*----------------------------------------------------------------*/
  2121.     jmms_communication_state_node *comm_node = NULL, *temp_node = NULL;
  2122.     /*----------------------------------------------------------------*/
  2123.     /* Code Body                                                      */
  2124.     /*----------------------------------------------------------------*/
  2125.     temp_node = jmms_context->comm_state;
  2126.     while (temp_node != NULL)
  2127.     {
  2128.         if (temp_node->uiReferenceID == uiReferenceID)
  2129.         {
  2130.             comm_node = temp_node;
  2131.             break;
  2132.         }
  2133.         temp_node = temp_node->next;
  2134.     }
  2135.     return comm_node;
  2136. }
  2137. /*****************************************************************************
  2138.  * FUNCTION
  2139.  *  mmi_jmms_update_comm_node
  2140.  * DESCRIPTION
  2141.  *  
  2142.  * PARAMETERS
  2143.  *  jmms_context            [?]         [?]         [?]
  2144.  *  new_uiReferenceID       [IN]        
  2145.  *  old_uiReferenceID       [IN]        
  2146.  *  retry_counter           [IN]        
  2147.  * RETURNS
  2148.  *  
  2149.  *****************************************************************************/
  2150. JC_RETCODE mmi_jmms_update_comm_node(
  2151.             jmms_context_struct *jmms_context,
  2152.             JC_UINT32 new_uiReferenceID,
  2153.             JC_UINT32 old_uiReferenceID,
  2154.             U8 retry_counter)
  2155. {
  2156.     /*----------------------------------------------------------------*/
  2157.     /* Local Variables                                                */
  2158.     /*----------------------------------------------------------------*/
  2159.     jmms_communication_state_node *temp_node = NULL;
  2160.     /*----------------------------------------------------------------*/
  2161.     /* Code Body                                                      */
  2162.     /*----------------------------------------------------------------*/
  2163.     temp_node = jmms_context->comm_state;
  2164.     while (temp_node != NULL)
  2165.     {
  2166.         if (temp_node->uiReferenceID == old_uiReferenceID)
  2167.         {
  2168.             temp_node->uiReferenceID = new_uiReferenceID;
  2169.             if (g_jmms_context->jmms_fs_handle == NULL)
  2170.             {
  2171.                 if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  2172.                 {
  2173.                     return JC_ERR_MEMORY_ALLOCATION;
  2174.                 }
  2175.             }
  2176.             if (temp_node->hFile)
  2177.             {
  2178.                 jdd_FSClose(temp_node->hFile);
  2179.                 jdd_FSDelete(g_jmms_context->jmms_fs_handle, temp_node->pFileName);
  2180.                 temp_node->hFile = NULL;
  2181.             }
  2182.             if ((temp_node->fs_handle) != NULL)
  2183.             {
  2184.                 jdd_FSDeinitialize(temp_node->fs_handle);
  2185.                 temp_node->fs_handle = NULL;
  2186.             }
  2187.             if ((temp_node->pFileName) != NULL)
  2188.             {
  2189.                 jdd_MemFree(temp_node->pFileName);
  2190.                 temp_node->pFileName = NULL;
  2191.             }
  2192.             if ((temp_node->pContentType) != NULL)
  2193.             {
  2194.                 jdd_MemFree(temp_node->pContentType);
  2195.                 temp_node->pContentType = NULL;
  2196.             }
  2197.             temp_node->reponse_size = 0;
  2198.             temp_node->retry_counter = retry_counter;
  2199.             if (g_jmms_context->jmms_fs_handle != NULL)
  2200.             {
  2201.                 jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  2202.                 g_jmms_context->jmms_fs_handle = NULL;
  2203.             }
  2204.             break;
  2205.         }
  2206.         temp_node = temp_node->next;
  2207.     }
  2208.     if (temp_node == NULL)
  2209.     {
  2210.         return E_JMMS_GENERAL_ERROR;
  2211.     }
  2212.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Comm Node Updated Old Request Id", old_uiReferenceID));
  2213.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS New Request Id", new_uiReferenceID));
  2214.     return JC_OK;
  2215. }
  2216. /*****************************************************************************
  2217.  * FUNCTION
  2218.  *  mmi_jmms_update_mmsc_url_version
  2219.  * DESCRIPTION
  2220.  *  
  2221.  * PARAMETERS
  2222.  *  mmsc_url_used       [?]     [?]     [?]
  2223.  *  mmsc_version        [?]     [?]     [?]
  2224.  * RETURNS
  2225.  *  void
  2226.  *****************************************************************************/
  2227. void mmi_jmms_update_mmsc_url_version(S8 *mmsc_url_used, S8 *mmsc_version)
  2228. {
  2229.     /*----------------------------------------------------------------*/
  2230.     /* Local Variables                                                */
  2231.     /*----------------------------------------------------------------*/
  2232.     JDD_FILE hFile = NULL;
  2233.     U32 read_len = 0, index, len, temp_len = 0;
  2234.     S8 *file_buffer = NULL;
  2235.     S8 file_name[(MAX_FILE_LENGTH + 1) * ENCODING_LENGTH];
  2236.     JC_INT32 write_len = 0;
  2237.     JC_RETCODE eRet = JC_OK;
  2238.     /*----------------------------------------------------------------*/
  2239.     /* Code Body                                                      */
  2240.     /*----------------------------------------------------------------*/
  2241.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_update_mmsc_url_version"));
  2242.     AnsiiToUnicodeString((PS8) file_name, (PS8) MMS_MMSC_URLS_FILE_NAME);
  2243.     if (g_jmms_context->jmms_fs_handle == NULL)
  2244.     {
  2245.         if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  2246.         {
  2247.             return;
  2248.         }
  2249.     }
  2250.     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) ; */
  2251.     if (hFile != NULL)
  2252.     {
  2253.         eRet = jdd_FSGetSize(hFile, &len);
  2254.         if (JC_OK != eRet)
  2255.         {
  2256.             goto END;
  2257.         }
  2258.         file_buffer = (S8*) jdd_MemAlloc(sizeof(S8), len);
  2259.         if ((NULL == file_buffer) && (len != 0))
  2260.         {
  2261.             goto END;
  2262.         }
  2263.         if (len > 0)
  2264.         {
  2265.             eRet = jdd_FSSeek(hFile, 0, E_FILE_SEEK_SET);
  2266.             if (eRet != JC_OK)
  2267.             {
  2268.                 goto END;
  2269.             }
  2270.             /* /read_len = jdd_FSRead (file_buffer, sizeof(JC_INT8), len, hFile) ; */
  2271.             read_len = jdd_FSRead(file_buffer, len, 1, hFile);
  2272.             if (read_len != 1)
  2273.             {
  2274.                 goto END;
  2275.             }
  2276.             read_len = len;
  2277.         }
  2278.         len = 0;
  2279.         index = 0;
  2280.         temp_len = 0;
  2281.         /* while(read_len!=0) */
  2282.         while (read_len != index)
  2283.         {
  2284.             len = (pfnUnicodeStrlen(file_buffer + index) + 1) * ENCODING_LENGTH;
  2285.             if (pfnUnicodeStrcmp((S8*) (file_buffer + index), (S8*) mmsc_url_used) == 0)
  2286.             {
  2287.                 index = index + len;
  2288.                 /*
  2289.                  * Convert the string into Unicode string and then copy.
  2290.                  * 
  2291.                  * Modified By :  Raj Kumar Gupta
  2292.                  * Date     :  July 27, 2006
  2293.                  */
  2294.                 /* /update the version */
  2295.                 AnsiiToUnicodeString((S8*) (file_buffer + index), (S8*) (mmsc_version));
  2296.                 if (hFile != NULL)
  2297.                 {
  2298.                     jdd_FSClose(hFile);
  2299.                 }
  2300.                 eRet = jdd_FSDelete(g_jmms_context->jmms_fs_handle, (const JC_CHAR*)file_name);
  2301.                 if (eRet != JC_OK)
  2302.                 {
  2303.                     goto END;
  2304.                 }
  2305.                 hFile = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (JC_CHAR*) file_name, E_CREATE_APPEND_WRITE_READ_MODE);
  2306.                 if (hFile == NULL)
  2307.                 {
  2308.                     goto END;
  2309.                 }
  2310.                 write_len = jdd_FSWrite(file_buffer, 1, read_len, hFile);
  2311.                 if (write_len != read_len)
  2312.                 {
  2313.                     goto END;
  2314.                 }
  2315.                 break;
  2316.             }
  2317.             else
  2318.             {
  2319.                 index = index + len;
  2320.                 len = (pfnUnicodeStrlen(file_buffer + index) + 1) * ENCODING_LENGTH;
  2321.                 index = index + len;
  2322.                 temp_len = temp_len + index;
  2323.             }
  2324.         }
  2325.         if (file_buffer)
  2326.         {
  2327.             jdd_MemFree(file_buffer);
  2328.             file_buffer = NULL;
  2329.         }
  2330.         if (read_len == index)  /* /entry not found */
  2331.         {
  2332.             S8 *temp_buffer = NULL;
  2333.             write_len = 0;
  2334.             len = (pfnUnicodeStrlen(mmsc_url_used) + 1) * ENCODING_LENGTH;
  2335.             len = len + (strlen(mmsc_version) + 1) * ENCODING_LENGTH;
  2336.             temp_buffer = (S8*) jdd_MemAlloc(sizeof(S8), len);
  2337.             if (NULL == temp_buffer)
  2338.             {
  2339.                 return;
  2340.             }
  2341.             pfnUnicodeStrcpy((S8*) temp_buffer, (S8*) (mmsc_url_used));
  2342.             len = (pfnUnicodeStrlen(mmsc_url_used) + 1) * ENCODING_LENGTH;      /* null char also need to be write into file */
  2343.             AnsiiToUnicodeString((S8*) (temp_buffer + len), (S8*) (mmsc_version));
  2344.             len = len + (strlen(mmsc_version) + 1) * ENCODING_LENGTH;
  2345.             write_len = 0;
  2346.             eRet = jdd_FSSeek(hFile, 0, E_FILE_SEEK_END);
  2347.             if (eRet != JC_OK)
  2348.             {
  2349.                 goto END;
  2350.             }
  2351.             write_len = jdd_FSWrite(temp_buffer, 1, len, hFile);
  2352.             if (temp_buffer)
  2353.             {
  2354.                 jdd_MemFree(temp_buffer);
  2355.                 temp_buffer = NULL;
  2356.             }
  2357.             if (len != write_len)
  2358.             {
  2359.                 goto END;
  2360.             }
  2361.         }
  2362.         if (hFile != NULL)
  2363.         {
  2364.             jdd_FSClose(hFile);
  2365.         }
  2366.         if (file_buffer)
  2367.         {
  2368.             jdd_MemFree(file_buffer);
  2369.             file_buffer = NULL;
  2370.         }
  2371.     }
  2372.   END:
  2373.     if (hFile != NULL)
  2374.     {
  2375.         jdd_FSClose(hFile);
  2376.     }
  2377.     if (g_jmms_context->jmms_fs_handle != NULL)
  2378.     {
  2379.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  2380.         g_jmms_context->jmms_fs_handle = NULL;
  2381.     }
  2382.     if (file_buffer)
  2383.     {
  2384.         jdd_MemFree(file_buffer);
  2385.         file_buffer = NULL;
  2386.     }
  2387.     return;
  2388. }
  2389. /*****************************************************************************
  2390.  * FUNCTION
  2391.  *  mmi_jmms_deinit_mms_context
  2392.  * DESCRIPTION
  2393.  *  
  2394.  * PARAMETERS
  2395.  *  jmms_context        [?]     [?]     [?]
  2396.  * RETURNS
  2397.  *  void
  2398.  *****************************************************************************/
  2399. void mmi_jmms_deinit_mms_context(jmms_context_struct *jmms_context)
  2400. {
  2401.     /*----------------------------------------------------------------*/
  2402.     /* Local Variables                                                */
  2403.     /*----------------------------------------------------------------*/
  2404.     JC_RETCODE eRet;
  2405.     /*----------------------------------------------------------------*/
  2406.     /* Code Body                                                      */
  2407.     /*----------------------------------------------------------------*/
  2408.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_deinit_mms_context START"));
  2409.     if (jmms_context != NULL)
  2410.     {
  2411.         mmi_jmms_free_addresses_list();
  2412.         if (jmms_context->msg_handle)
  2413.         {
  2414.             eRet = mmi_jmms_jdi_msg_deinit(jmms_context->msg_handle);
  2415.             jmms_context->msg_handle = NULL;
  2416.         }
  2417.         /*
  2418.          * else
  2419.          * {
  2420.          * if (g_jmms_context->last_scr_id != SCR_ID_JMMS_OUTBOX_OPTIONS
  2421.          * && g_jmms_context->last_scr_id != SCR_ID_JMMS_DRAFTS_OPTIONS)
  2422.          * {
  2423.          * mmi_jmms_free_mms_pdu_memory(jmms_context);
  2424.          * }
  2425.          * 
  2426.          * }
  2427.          */
  2428.         //jdi_MsgDeInit itself is freeing the memory allocated for PDU
  2429.         ///so we don't need to do that.so we should not call mmi_jmms_free_mms_pdu_memory()
  2430.         ///otherwise jdd_memfree will be called again and hang will occur
  2431.         jmms_context->to_p = NULL;
  2432.         jmms_context->Cc_p = NULL;
  2433.         jmms_context->bcc_p = NULL;
  2434.         jmms_context->from_p = NULL;
  2435.         jmms_context->MsgHeader_type_p = NULL;
  2436.         jmms_context->MsgHeaders_p = NULL;
  2437.         jmms_context->subject = NULL;
  2438.         jmms_context->version = NULL;
  2439.         jmms_context->nSent_retry_counter = 0;
  2440.         jmms_context->msg_handle = NULL;
  2441.         jmms_context->nCurr_focused_med_type = 0;
  2442.         jmms_context->num_attachments = 0;
  2443.         jmms_context->nSent_retry_counter = 0;
  2444.         jmms_context->is_unread_msg_deleted = 0;
  2445.         memset(jmms_context->subject_input_buffer, 0x00, (MAX_SUBJECT_LENGTH + 1) * ENCODING_LENGTH);
  2446.         if (g_jmms_context->rc_info != NULL)
  2447.         {
  2448.             if (g_jmms_context->rc_info->pReplyMsgID != NULL)
  2449.             {
  2450.                 jdd_MemFree(g_jmms_context->rc_info->pReplyMsgID);
  2451.             }
  2452.             jdd_MemFree(g_jmms_context->rc_info);
  2453.             g_jmms_context->rc_info = NULL;
  2454.         }
  2455.         if (g_jmms_context->pSendContent != NULL)
  2456.         {
  2457.             if (g_jmms_context->pSendContent->bIsStream == E_FALSE)
  2458.             {