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

MTK

开发平台:

C/C++

  1.                 jdd_MemFree(g_jmms_context->pSendContent->pBuffer);
  2.                 g_jmms_context->pSendContent->pBuffer = NULL;
  3.             }
  4.             if (g_jmms_context->pSendContent->pStream != NULL)
  5.             {
  6.                 if (g_jmms_context->jmms_fs_handle == NULL)
  7.                 {
  8.                     jdd_FSInitialize(&g_jmms_context->jmms_fs_handle);
  9.                 }
  10.                 jdd_FSDelete(g_jmms_context->jmms_fs_handle, g_jmms_context->pSendContent->pStream);
  11.                 jdd_MemFree(g_jmms_context->pSendContent->pStream);
  12.             }
  13.             jdd_MemFree(g_jmms_context->pSendContent);
  14.             g_jmms_context->pSendContent = NULL;
  15.         }
  16.         if (g_jmms_context->pSaveContent != NULL)
  17.         {
  18.             if (g_jmms_context->pSaveContent->bIsStream == E_FALSE)
  19.             {
  20.                 jdd_MemFree(g_jmms_context->pSaveContent->pBuffer);
  21.                 g_jmms_context->pSaveContent->pBuffer = NULL;
  22.             }
  23.             if (g_jmms_context->pSaveContent->pStream != NULL)
  24.             {
  25.                 if (g_jmms_context->jmms_fs_handle == NULL)
  26.                 {
  27.                     jdd_FSInitialize(&g_jmms_context->jmms_fs_handle);
  28.                 }
  29.                 jdd_FSDelete(g_jmms_context->jmms_fs_handle, g_jmms_context->pSaveContent->pStream);
  30.                 jdd_MemFree(g_jmms_context->pSaveContent->pStream);
  31.             }
  32.             jdd_MemFree(g_jmms_context->pSaveContent);
  33.             g_jmms_context->pSaveContent = NULL;
  34.         }
  35.         if (g_jmms_context->pParseContent != NULL)
  36.         {
  37.             if (g_jmms_context->pParseContent->pFileName != NULL)
  38.             {
  39.                 jdd_MemFree(g_jmms_context->pParseContent->pFileName);
  40.             }
  41.             jdd_MemFree(g_jmms_context->pParseContent);
  42.             g_jmms_context->pParseContent = NULL;
  43.         }
  44.         mmi_jmms_deinit_view();
  45.         
  46.     //#ifdef __MMI_MMS_SIGNATURE__
  47.         mmi_jmms_reset_fw_flag_of_inbox();
  48.         g_jmms_context->auto_signature_added = MMI_FALSE;
  49.     //#endif /* __MMI_MMS_SIGNATURE__ */ 
  50.     #ifdef __MMI_UNIFIED_MESSAGE__
  51.         mmi_jmms_reset_fw_flag_of_message();
  52.     #endif 
  53.         if (g_jmms_context->async_send_context.params != NULL)
  54.         {
  55.             jdd_MemFree(g_jmms_context->async_send_context.params);
  56.             g_jmms_context->async_send_context.params = NULL;
  57.         }
  58.         if (g_jmms_context->async_save_context.params != NULL)
  59.         {
  60.             jdd_MemFree(g_jmms_context->async_save_context.params);
  61.             g_jmms_context->async_save_context.params = NULL;
  62.         }
  63.         mmi_jmms_delete_compose_temp_files();
  64.         if (g_jmms_context->compose_context != NULL)
  65.         {
  66.             jdd_MemFree(g_jmms_context->compose_context);
  67.             g_jmms_context->compose_context = NULL;
  68.         }
  69.         if (g_jmms_context->jmms_fs_handle != NULL)
  70.         {
  71.             jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  72.             g_jmms_context->jmms_fs_handle = NULL;
  73.         }
  74.     }
  75.     /* Himanshu 21/11/2006 Free the media buffer used in Compose Screen */
  76.     if(g_media_buffer_p != NULL)
  77.     {
  78.         jdd_MemFree(g_media_buffer_p);
  79.         g_media_buffer_p = NULL;
  80.     }
  81.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_deinit_mms_context END"));
  82. }
  83. /*****************************************************************************
  84.  * FUNCTION
  85.  *  mmi_jmms_free_message_header
  86.  * DESCRIPTION
  87.  *  
  88.  * PARAMETERS
  89.  *  void
  90.  * RETURNS
  91.  *  void
  92.  *****************************************************************************/
  93. void mmi_jmms_free_message_header(void)
  94. {
  95.     /*----------------------------------------------------------------*/
  96.     /* Local Variables                                                */
  97.     /*----------------------------------------------------------------*/
  98.     /*----------------------------------------------------------------*/
  99.     /* Code Body                                                      */
  100.     /*----------------------------------------------------------------*/
  101.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_free_message_header"));
  102.     if (g_jmms_context->last_scr_id == SCR_ID_JMMS_OUTBOX_OPTIONS
  103.         || g_jmms_context->last_scr_id == SCR_ID_JMMS_DRAFTS_OPTIONS)
  104.     {
  105.         ///it menas MMS Sent was from "Sent" in Drafts or 
  106.         //"Resent" in Outbox
  107.         mmi_jmms_deinit_mms_context(g_jmms_context);
  108.         g_jmms_context->nSent_retry_counter = 0;
  109.         return;
  110.     }
  111.     else
  112.     {
  113.         if (g_jmms_context->msg_handle != NULL)
  114.         {
  115.             MESSAGING_HANDLER *pMessagingHandler = NULL;
  116.             pMessagingHandler = (MESSAGING_HANDLER*) (g_jmms_context->msg_handle);
  117.             if (pMessagingHandler->pMessageHeaders != NULL)
  118.             {
  119.                 FreeMessageHeaders(&(pMessagingHandler->pMessageHeaders));
  120.                 pMessagingHandler->pMessageHeaders = NULL;
  121.                 g_jmms_context->to_p = NULL;
  122.                 g_jmms_context->Cc_p = NULL;
  123.                 g_jmms_context->bcc_p = NULL;
  124.                 g_jmms_context->MsgHeader_type_p = NULL;
  125.                 g_jmms_context->MsgHeaders_p = NULL;
  126.                 g_jmms_context->subject = NULL;
  127.                 g_jmms_context->version = NULL;
  128.                 /* / 7 March */
  129.                 if (g_jmms_context->jmms_fs_handle != NULL)
  130.                 {
  131.                     jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  132.                     g_jmms_context->jmms_fs_handle = NULL;
  133.                 }
  134.                 g_jmms_context->nSent_retry_counter = 0;
  135.             }
  136.         }
  137.     }
  138. }
  139. /*****************************************************************************
  140.  * FUNCTION
  141.  *  mmi_jmms_free_mms_pdu_memory
  142.  * DESCRIPTION
  143.  *  
  144.  * PARAMETERS
  145.  *  jmms_context        [?]     [?]     [?]
  146.  * RETURNS
  147.  *  void
  148.  *****************************************************************************/
  149. void mmi_jmms_free_mms_pdu_memory(jmms_context_struct *jmms_context)
  150. {
  151.     /*----------------------------------------------------------------*/
  152.     /* Local Variables                                                */
  153.     /*----------------------------------------------------------------*/
  154.     /*----------------------------------------------------------------*/
  155.     /* Code Body                                                      */
  156.     /*----------------------------------------------------------------*/
  157.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_free_mms_pdu_memory"));
  158.     if (jmms_context->to_p != NULL)
  159.     {
  160.         jdd_MemFree(jmms_context->to_p);
  161.         jmms_context->to_p = NULL;
  162.     }
  163.     if (jmms_context->Cc_p != NULL)
  164.     {
  165.         jdd_MemFree(jmms_context->Cc_p);
  166.         jmms_context->Cc_p = NULL;
  167.     }
  168.     if (jmms_context->bcc_p != NULL)
  169.     {
  170.         jdd_MemFree(jmms_context->bcc_p);
  171.         jmms_context->bcc_p = NULL;
  172.     }
  173.     if (jmms_context->MsgHeader_type_p != NULL)
  174.     {
  175.         jdd_MemFree(jmms_context->MsgHeader_type_p);
  176.         jmms_context->MsgHeader_type_p = NULL;
  177.     }
  178.     if (jmms_context->MsgHeaders_p != NULL)
  179.     {
  180.         jdd_MemFree(jmms_context->MsgHeaders_p);
  181.         jmms_context->MsgHeaders_p = NULL;
  182.     }
  183.     if (jmms_context->subject != NULL)
  184.     {
  185.         jdd_MemFree(jmms_context->subject);
  186.         jmms_context->subject = NULL;
  187.     }
  188.     if (jmms_context->version != NULL)
  189.     {
  190.         jdd_MemFree(jmms_context->version);
  191.         jmms_context->version = NULL;
  192.     }
  193.     if (jmms_context->activated_mmsc_url != NULL)
  194.     {
  195.         jdd_MemFree(jmms_context->activated_mmsc_url);
  196.         jmms_context->activated_mmsc_url = NULL;
  197.     }
  198.     if (jmms_context->from_p != NULL)
  199.     {
  200.         jdd_MemFree(jmms_context->from_p);
  201.         jmms_context->from_p = NULL;
  202.     }
  203.     jmms_context->nSent_retry_counter = 0;
  204. }
  205. /*****************************************************************************
  206.  * FUNCTION
  207.  *  mmi_jmms_comm_stop_callback
  208.  * DESCRIPTION
  209.  *  
  210.  * PARAMETERS
  211.  *  jmms_context        [?]         [?]         [?]
  212.  *  uiReferenceID       [IN]        
  213.  *  eRetCode            [IN]        
  214.  * RETURNS
  215.  *  void
  216.  *****************************************************************************/
  217. void mmi_jmms_comm_stop_callback(jmms_context_struct *jmms_context, JC_UINT32 uiReferenceID, JC_RETCODE eRetCode)
  218. {
  219.     /*----------------------------------------------------------------*/
  220.     /* Local Variables                                                */
  221.     /*----------------------------------------------------------------*/
  222.     jmms_communication_state_node *comm_node = NULL;
  223. // sandeep start to fix bug number PMT005980
  224. //#ifdef __MMI_UNIFIED_MESSAGE__
  225.     JC_RETCODE eRet = JC_OK;
  226. //#endif 
  227. // sandeep end to fix bug number PMT005980
  228.     JC_CHAR *pFolderName = NULL;
  229.     JC_CHAR pOutBox[7 * ENCODING_LENGTH];
  230.     /*----------------------------------------------------------------*/
  231.     /* Code Body                                                      */
  232.     /*----------------------------------------------------------------*/
  233.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d %s%d", "mmi_jmms_comm_stop_callback, Reference id: ", uiReferenceID,
  234.                          "Error code: ", eRetCode));
  235. #ifdef __MMI_UNIFIED_MESSAGE__
  236.     comm_node = mmi_jmms_get_comm_state(jmms_context, uiReferenceID);
  237. #endif 
  238.     if (eRetCode == JC_ERR_USER_CANCELLED)
  239.     {
  240.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS User Cancelled the Comunication Request"));
  241.     #ifdef MMI_JMMS_JAVA_MMS_SUPPORT
  242.     #ifndef __MMI_UNIFIED_MESSAGE__
  243.         comm_node = mmi_jmms_get_comm_state(jmms_context, uiReferenceID);
  244.     #endif 
  245.         if (comm_node == NULL)
  246.         {
  247.             return;
  248.         }
  249.         if (comm_node->mms_communication_state == E_TYPE_NEW_JAVA_MMS_SEND)
  250.         {
  251.             mmi_jmms_free_comm_node(jmms_context, uiReferenceID);
  252.             if (jmms_context->jsr_mms_send_cancel_callback != NULL)
  253.             {
  254.                 (*(jmms_context->jsr_mms_send_cancel_callback)) (JSR_RESULT_OK);
  255.             }
  256.             return;
  257.         }
  258.     #endif /* MMI_JMMS_JAVA_MMS_SUPPORT */ 
  259.         /* 2 March- need care */
  260.     #ifdef __MMI_UNIFIED_MESSAGE__
  261.         if (mmi_um_get_current_msg_box_type() != UM_MSG_BOX_TYPE_UNSENT
  262.             && g_jmms_context->save_mms == TRUE && g_jmms_context->last_scr_id == IDLE_SCREEN_ID)
  263.         {
  264.             eRet = mmi_jmms_send_and_store_mms("Outbox", jmms_context->msg_handle, comm_node);
  265.             if (eRet == JC_OK)
  266.             {
  267.                 DisplayPopup(
  268.                     (U8*) GetString(STR_ID_JMMS_COMM_ABORTED_MMS_STORED),
  269.                     IMG_GLOBAL_ERROR,
  270.                     1,
  271.                     JMMS_POPUP_TIME,
  272.                     (U8) ERROR_TONE);
  273.             }
  274.             else
  275.             {
  276.                 if (eRet == E_MEMORY_FULL_ERROR)
  277.                 {
  278.                     mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_COMM_ABORTED_AND_FAIL_STORE_MEMORY);
  279.                 }
  280.                 else if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
  281.                 {
  282.                     mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_COMM_ABORTED_AND_FAIL_STORE_MEM_FULL);
  283.                 }
  284.                 else
  285.                 {
  286.                     mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_COMM_ABORTED_AND_FAIL_STORE);
  287.                 }
  288.             }
  289.         }
  290.         else
  291.         {
  292.             DisplayPopup(
  293.                 (U8*) GetString(STR_ID_JMMS_COMM_ABORTED),
  294.                 IMG_GLOBAL_INFO,
  295.                 1,
  296.                 JMMS_POPUP_TIME,
  297.                 (U8) SUCCESS_TONE);
  298.         }
  299.         if (IsScreenPresent(SCR_ID_JMMS_WRITE_MMS))
  300.         {
  301.             DeleteUptoScrID(g_jmms_context->last_scr_id);
  302.         }
  303.         else if (IsScreenPresent(SCR_ID_UM_UNSENT))
  304.         {
  305.             DeleteUptoScrID(SCR_ID_UM_UNSENT);
  306.         }
  307.         else if (IsScreenPresent(SCR_ID_UM_DRAFT))
  308.         {
  309.             DeleteUptoScrID(SCR_ID_UM_DRAFT);
  310.         }
  311.         else if (IsScreenPresent(SCR_ID_UM_INBOX))
  312.         {
  313.             DeleteUptoScrID(SCR_ID_UM_INBOX);
  314.         }
  315.         else if(IsScreenPresent(SCR_ID_UM_SENT))
  316.         {
  317.             DeleteUptoScrID(SCR_ID_UM_SENT);
  318.         }
  319.         else if (g_jmms_context->last_scr_id == IDLE_SCREEN_ID)
  320.         {
  321.             
  322.             /*Dilip 8th Sept 2006  to remove memory leak*/
  323.             if(g_end_key_processing_handler) g_end_key_processing_handler();
  324. //DisplayIdleScreen();
  325.             /*Dilip End 8th sept 2006 */
  326.         }
  327.         mmi_jmms_free_message_header();
  328.         mmi_jmms_free_comm_node(jmms_context, uiReferenceID);
  329.     #else /* __MMI_UNIFIED_MESSAGE__ */ 
  330. // sandeep start to fix bug number PMT005980
  331.         eRet = mmi_jmms_jdi_get_active_folder(g_jmms_context->hStoreHandle, &(pFolderName), NULL);
  332.         if(eRet == JC_OK)
  333.         {
  334.             AnsiiToUnicodeString((PS8)pOutBox, (PS8)MMI_JMMS_OUTBOX);
  335.             if ( 
  336.                 (jc_tcscmp(pOutBox, pFolderName) != 0) 
  337.                 && (g_jmms_context->save_mms == TRUE )
  338.                 && (g_jmms_context->last_scr_id == IDLE_SCREEN_ID))
  339.         {
  340.             eRet = mmi_jmms_send_and_store_mms("Outbox", g_jmms_context->msg_handle, comm_node);
  341.             if (eRet == JC_OK)
  342.             {
  343.                 DisplayPopup(
  344.                     (U8*) GetString(STR_ID_JMMS_COMM_ABORTED_MMS_STORED),
  345. /* MAUI_00018340 Start */                     
  346. IMG_GLOBAL_INFO,
  347. /* MAUI_00018340 End */ 
  348.                     1,
  349.                     JMMS_POPUP_TIME,
  350.                     (U8) ERROR_TONE);
  351.             }
  352.             else
  353.             {
  354.                 if (eRet == E_MEMORY_FULL_ERROR)
  355.                 {
  356.                     mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_COMM_ABORTED_AND_FAIL_STORE_MEMORY);
  357.                 }
  358.                 else if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
  359.                 {
  360.                     mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_COMM_ABORTED_AND_FAIL_STORE_MEM_FULL);
  361.                 }
  362.                 else
  363.                 {
  364.                     mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_COMM_ABORTED_AND_FAIL_STORE);
  365.                 }
  366.             }
  367.         }
  368.             else
  369.             {
  370.                 DisplayPopup((U8*) GetString(STR_ID_JMMS_COMM_ABORTED), IMG_GLOBAL_INFO, 1, JMMS_POPUP_TIME, (U8) SUCCESS_TONE);
  371.             }
  372.         }
  373. else
  374. {
  375.         DisplayPopup((U8*) GetString(STR_ID_JMMS_COMM_ABORTED), IMG_GLOBAL_INFO, 1, JMMS_POPUP_TIME, (U8) SUCCESS_TONE);
  376. }
  377.         DeleteUptoScrID(g_jmms_context->last_scr_id);
  378. mmi_jmms_free_message_header();
  379. // sandeep end to fix bug number PMT005980
  380.         mmi_jmms_free_comm_node(jmms_context, uiReferenceID);
  381.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  382.     }
  383.     else
  384.     {
  385.     #ifdef MMI_JMMS_JAVA_MMS_SUPPORT
  386.         comm_node = mmi_jmms_get_comm_state(jmms_context, uiReferenceID);
  387.         if (comm_node == NULL)
  388.         {
  389.             return;
  390.         }
  391.         if ((comm_node->mms_communication_state == E_TYPE_NEW_JAVA_MMS_SEND) &&
  392.             (jmms_context->jsr_mms_send_cancel_callback != NULL))
  393.         {
  394.             mmi_jmms_free_comm_node(jmms_context, uiReferenceID);
  395.             (*(jmms_context->jsr_mms_send_cancel_callback)) (JSR_RESULT_ERROR);
  396.             return;
  397.         }
  398.     #endif /* MMI_JMMS_JAVA_MMS_SUPPORT */ 
  399.         /* /error in cancelling the send/download */
  400.     }
  401. }
  402. /*****************************************************************************
  403.  * FUNCTION
  404.  *  mmi_jmms_error_ind_callback
  405.  * DESCRIPTION
  406.  *  
  407.  * PARAMETERS
  408.  *  jmms_context        [?]         [?]         [?]
  409.  *  uiReferenceID       [IN]        
  410.  *  eRetCode            [IN]        
  411.  * RETURNS
  412.  *  void
  413.  *****************************************************************************/
  414. void mmi_jmms_error_ind_callback(jmms_context_struct *jmms_context, JC_UINT32 uiReferenceID, JC_RETCODE eRetCode)
  415. {
  416.     /*----------------------------------------------------------------*/
  417.     /* Local Variables                                                */
  418.     /*----------------------------------------------------------------*/
  419.     JC_RETCODE eRet = JC_OK;
  420.     JC_EVENT_DATA eventData = {0, };
  421.     mmi_jmms_temp_event_struct info = {0, };
  422.     /*----------------------------------------------------------------*/
  423.     /* Code Body                                                      */
  424.     /*----------------------------------------------------------------*/
  425.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "mmi_jmms_error_ind_callback, Reference ID: ", uiReferenceID));
  426.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Error Ind Error Code:", eRetCode));
  427.     eventData.destTaskInfo.iAppID = E_TASK_MMS_UI;
  428.     eventData.destTaskInfo.iTaskID = E_TASK_MMS_UI;
  429.     eventData.srcTaskInfo.iAppID = E_TASK_MMS_UI;
  430.     eventData.srcTaskInfo.iTaskID = E_TASK_MMS_UI;
  431.     eventData.uiEventInfoSize = sizeof(mmi_jmms_temp_event_struct);
  432.     eventData.iEventType = E_COMM_ERROR_INDICATION_EVENT;
  433.     eRet = jdd_QueueAlloc(&eventData);
  434.     if (JC_OK != eRet)
  435.     {
  436.         return;
  437.     }
  438.     info.jmms_context = jmms_context;
  439.     info.uiReferenceID = uiReferenceID;
  440.     info.eRetCode = eRetCode;
  441.     jc_memcpy(eventData.pEventInfo, &info, sizeof(mmi_jmms_temp_event_struct));
  442.     jdd_QueueSend(&eventData);
  443.     jdi_CommunicationFreeReference(jmms_context->hCommHandle, uiReferenceID);
  444. }
  445. /*****************************************************************************
  446.  * FUNCTION
  447.  *  mmi_jmms_retry_for_error_in_comm
  448.  * DESCRIPTION
  449.  *  
  450.  * PARAMETERS
  451.  *  pEventData      [?]     [?]     [?]
  452.  * RETURNS
  453.  *  void
  454.  *****************************************************************************/
  455. void mmi_jmms_retry_for_error_in_comm(mmi_jmms_temp_event_struct *pEventData)
  456. {
  457.     /*----------------------------------------------------------------*/
  458.     /* Local Variables                                                */
  459.     /*----------------------------------------------------------------*/
  460.     mmi_jmms_temp_event_struct *info = {0, };
  461.     /*----------------------------------------------------------------*/
  462.     /* Code Body                                                      */
  463.     /*----------------------------------------------------------------*/
  464.     info = (mmi_jmms_temp_event_struct*) (pEventData);
  465.     mmi_jmms_retry_communication(info->jmms_context, E_FROM_ERROR_CALLBACK, info->uiReferenceID, info->eRetCode);
  466.     mmi_jmms_free_comm_node(info->jmms_context, info->uiReferenceID);
  467. }
  468. /*****************************************************************************
  469.  * FUNCTION
  470.  *  mmi_jmms_create_and_send_new_mms
  471.  * DESCRIPTION
  472.  *  
  473.  * PARAMETERS
  474.  *  message_setting         [IN]        
  475.  *  jmms_context            [?]         [?]         [?]
  476.  *  is_create_for_send      [IN]        
  477.  * RETURNS
  478.  *  
  479.  *****************************************************************************/
  480. JC_RETCODE mmi_jmms_create_and_send_new_mms(
  481.             U16 message_setting,
  482.             jmms_context_struct *jmms_context,
  483.             MMI_BOOL is_create_for_send)
  484. {
  485.     /*----------------------------------------------------------------*/
  486.     /* Local Variables                                                */
  487.     /*----------------------------------------------------------------*/
  488.     JC_RETCODE eRet = JC_OK;
  489.     MESSAGE_SEND *pMessageSend = NULL;
  490.     MESSAGE_HEADERS *pMsgHeaders = NULL;
  491.     U8 ret = 0;
  492.     S32 len = 0;
  493.     MSG_HANDLE hMsgHandle = jmms_context->msg_handle;
  494.     /*----------------------------------------------------------------*/
  495.     /* Code Body                                                      */
  496.     /*----------------------------------------------------------------*/
  497.     /* free any allocated memory */
  498.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_create_and_send_new_mms"));
  499.     mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  500.     g_jmms_context->MsgHeaders_p = (MESSAGE_HEADERS*) jdd_MemAlloc(sizeof(MESSAGE_HEADERS), 1);
  501.     if (NULL == g_jmms_context->MsgHeaders_p)
  502.     {
  503.         mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  504.         return JC_ERR_MEMORY_ALLOCATION;
  505.     }
  506.     g_jmms_context->MsgHeader_type_p = (MESSAGE_SEND*) jdd_MemAlloc(sizeof(MESSAGE_SEND), 1);
  507.     if (NULL == g_jmms_context->MsgHeader_type_p)
  508.     {
  509.         mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  510.         return JC_ERR_MEMORY_ALLOCATION;
  511.     }
  512.     pMsgHeaders = g_jmms_context->MsgHeaders_p;
  513.     pMessageSend = g_jmms_context->MsgHeader_type_p;
  514.     eRet = mmi_jmms_set_mmsc_version();
  515.     if (eRet != JC_OK)
  516.     {
  517.         mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  518.         return eRet;
  519.     }
  520.     pMessageSend->pVersion = (JC_INT8*) g_jmms_context->version;
  521.     if (wap_get_user_agent_brand() == EM_WAP_USERAGENT_BRAND_SE)
  522.     {
  523.         pMessageSend->uiDate = get_current_utc_time();
  524.     }
  525. /* MAUI_00227929 Start */
  526.  //   if (message_setting == E_USE_LOCAL_SETTINGS)    /* /used when mms send is called from write message and send options are used */
  527.   //  {
  528.         pMessageSend->bDeliveryReport =
  529.             (g_jmms_context->sending_settings.delivery_report == 1) ? E_TRUE : E_FALSE;
  530.         pMessageSend->bReadReport =
  531.             (g_jmms_context->sending_settings.read_report == 1) ? E_TRUE : E_FALSE;
  532.         pMessageSend->bHideSender =
  533.             (g_jmms_context->sending_settings.hide_sender == 1) ? E_TRUE : E_FALSE;
  534.         pMessageSend->uiExpiryTime = 0;
  535.         switch (g_jmms_context->sending_settings.validity_period)
  536.         {
  537.             case E_VALIDITY_PERIOD_MAX:
  538.                 if (wap_get_user_agent_brand() != EM_WAP_USERAGENT_BRAND_SE)
  539.                 {
  540.                     pMessageSend->uiExpiryTime = MAX_VALIDITY_PERIOD_VALUE;
  541.                 }
  542.                 break;
  543.             case E_VALIDITY_PERIOD_1HR:
  544.                 pMessageSend->uiExpiryTime = 3600;
  545.                 break;
  546.             case E_VALIDITY_PERIOD_12HRS:
  547.                 pMessageSend->uiExpiryTime = 12 * 3600;
  548.                 break;
  549.             case E_VALIDITY_PERIOD_1DAY:
  550.                 pMessageSend->uiExpiryTime = 1 * 24 * 3600;
  551.                 break;
  552.             case E_VALIDITY_PERIOD_1WEEK:
  553.                 pMessageSend->uiExpiryTime = 1 * 7 * 24 * 3600;
  554.                 break;
  555.             default:
  556.                 if (wap_get_user_agent_brand() != EM_WAP_USERAGENT_BRAND_SE)
  557.                 {
  558.                     pMessageSend->uiExpiryTime = MAX_VALIDITY_PERIOD_VALUE;
  559.                 }
  560.                 break;
  561.         }
  562.         switch (g_jmms_context->sending_settings.delivery_time)
  563.         {
  564.             case E_IMMEDIATE:
  565.                 pMessageSend->uiDeliveryTime = 0;
  566.                 break;
  567.             case E_1_HR:
  568.                 pMessageSend->uiDeliveryTime = 3600;
  569.                 break;
  570.             case E_12_HRS:
  571.                 pMessageSend->uiDeliveryTime = 12 * 3600;
  572.                 break;
  573.             case E_24_HRS:
  574.                 pMessageSend->uiDeliveryTime = 24 * 3600;
  575.                 break;
  576.             default:
  577.                 pMessageSend->uiDeliveryTime = 0;
  578.                 break;
  579.         }
  580.         
  581. /* MAUI_00018625 Start */
  582. pMessageSend->eMsgPriority = (g_jmms_context->sending_settings.priority) ;
  583. /* MAUI_00018625 End */
  584.         if (g_jmms_context->sending_settings.reply_charging == E_ON)
  585.         {
  586.             pMessageSend->pReplyChargingInfo = (REPLY_CHARGING*) jdd_MemAlloc(sizeof(REPLY_CHARGING), 1);
  587.             if (pMessageSend->pReplyChargingInfo == NULL)
  588.             {
  589.                 mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  590.                 return JC_ERR_MEMORY_ALLOCATION;
  591.             }
  592.             switch (g_jmms_context->sending_settings.request_type)
  593.             {
  594.                 case E_FULL_MMS:
  595.                     pMessageSend->pReplyChargingInfo->eReplyCharging = E_REQUEST_REPLY_CHARGING;
  596.                     break;
  597.                 case E_TEXT_ONLY:
  598.                     pMessageSend->pReplyChargingInfo->eReplyCharging = E_REQUEST_TEXT_ONLY_REPLY_CHARGING;
  599.                     break;
  600.                 default:
  601.                     pMessageSend->pReplyChargingInfo->eReplyCharging = E_REQUEST_REPLY_CHARGING;
  602.                     break;
  603.             }
  604.             pMessageSend->pReplyChargingInfo->uiRelativeTime =
  605.                 (JC_UINT32) (gui_atoi
  606.                              ((UI_string_type) g_jmms_context->sending_settings.
  607.                               deadline_for_reply_buffer) * 3600);
  608.             pMessageSend->pReplyChargingInfo->uiSize =
  609.                 ((JC_UINT32)
  610.                  gui_atoi((UI_string_type) g_jmms_context->sending_settings.
  611.                           reply_msg_size_buffer)) * 1000;
  612.         }
  613.     //}
  614. /*    else if (message_setting == E_USE_NVRAM_SETTINGS)
  615.     {
  616.         pMessageSend->bDeliveryReport = (mmi_jmms_sending_settings_delivery_report() == 1) ? E_TRUE : E_FALSE;
  617.         pMessageSend->bReadReport = (mmi_jmms_sending_settings_read_report() == 1) ? E_TRUE : E_FALSE;
  618.         pMessageSend->bHideSender = (mmi_jmms_sending_settings_hide_sender() == 1) ? E_TRUE : E_FALSE;
  619.         pMessageSend->uiExpiryTime = (JC_UINT32) mmi_jmms_sending_settings_validity_period();
  620.         if (pMessageSend->uiExpiryTime == MAX_VALIDITY_PERIOD_VALUE)
  621.         {
  622.             if (wap_get_user_agent_brand() == EM_WAP_USERAGENT_BRAND_SE)
  623.             {
  624.                 pMessageSend->uiExpiryTime = 0;
  625.             }
  626.         }
  627.         pMessageSend->uiDeliveryTime = (JC_UINT32) mmi_jmms_sending_settings_delivery_time();
  628.         pMessageSend->eMsgPriority = mmi_jmms_sending_settings_priority();
  629.         if (mmi_jmms_sending_settings_reply_charging_status() == E_ON)
  630.         {
  631.             pMessageSend->pReplyChargingInfo = (REPLY_CHARGING*) jdd_MemAlloc(sizeof(REPLY_CHARGING), 1);
  632.             if (pMessageSend->pReplyChargingInfo == NULL)
  633.             {
  634.                 mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  635.                 return JC_ERR_MEMORY_ALLOCATION;
  636.             }
  637.             pMessageSend->pReplyChargingInfo->eReplyCharging = mmi_jmms_sending_settings_reply_charging_request_type();
  638.             pMessageSend->pReplyChargingInfo->uiRelativeTime =
  639.                 ((JC_UINT32) mmi_jmms_sending_settings_deadline_for_reply()) * 3600;
  640.             pMessageSend->pReplyChargingInfo->uiSize =
  641.                 ((JC_UINT32) mmi_jmms_sending_settings_reply_charging_size()) * 1024;
  642.         }
  643.     }*/
  644. /* MAUI_00227929 End */
  645.     /* Added by Deepali for reply charging. */
  646.     if (g_jmms_context->rc_info != NULL)
  647.     {
  648.         pMessageSend->pReplyChargingInfo->pszReplyId =
  649.             (JC_INT8*) jdi_UtilsStrdup(g_jmms_context->rc_info->pReplyMsgID);
  650.         if (g_jmms_context->rc_info != NULL)
  651.         {
  652.             if (g_jmms_context->rc_info->pReplyMsgID != NULL)
  653.             {
  654.                 jdd_MemFree(g_jmms_context->rc_info->pReplyMsgID);
  655.             }
  656.             jdd_MemFree(g_jmms_context->rc_info);
  657.             g_jmms_context->rc_info = NULL;
  658.         }
  659.     }
  660.     pMessageSend->bExpiryAbs = E_FALSE;
  661.     pMessageSend->bDeliveryAbs = E_FALSE;
  662.     if (g_jmms_context->num_to_addresses > 0)
  663.     {
  664.         g_jmms_context->to_p = mmi_jmms_get_to_addresses();
  665.         if (g_jmms_context->to_p == NULL)
  666.         {
  667.             mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  668.             return JC_ERR_MEMORY_ALLOCATION;
  669.         }
  670.         pMessageSend->pTo = (JC_CHAR*) g_jmms_context->to_p;
  671.     }
  672.     if (g_jmms_context->num_cc_addresses > 0)
  673.     {
  674.         g_jmms_context->Cc_p = mmi_jmms_get_cc_addresses();
  675.         if (JC_OK != ret)
  676.         {
  677.             mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  678.             return JC_ERR_MEMORY_ALLOCATION;
  679.         }
  680.         pMessageSend->pCc = (JC_CHAR*) g_jmms_context->Cc_p;
  681.     }
  682.     if (g_jmms_context->num_bcc_addresses > 0)
  683.     {
  684.         g_jmms_context->bcc_p = mmi_jmms_get_bcc_addresses();
  685.         if (JC_OK != ret)
  686.         {
  687.             mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  688.             return JC_ERR_MEMORY_ALLOCATION;
  689.         }
  690.         pMessageSend->pBcc = (JC_CHAR*) g_jmms_context->bcc_p;
  691.     }
  692.     len = pfnUnicodeStrlen((S8*) g_jmms_context->subject_input_buffer);
  693.     g_jmms_context->subject = (S8*) jdd_MemAlloc(sizeof(S8), (len + 1) * ENCODING_LENGTH);
  694.     if ((g_jmms_context->subject == NULL) && (len != 0))
  695.     {
  696.         mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  697.         return JC_ERR_MEMORY_ALLOCATION;
  698.     }
  699.     if (g_jmms_context->subject)
  700.     {
  701.         if (GetUCS2Flag((S8*) g_jmms_context->subject_input_buffer) == FALSE)
  702.         {
  703.             U8 count = 0;
  704.             U32 str_len = 0;
  705.             S8 temp[MAX_SUBJECT_LENGTH + 1];
  706.             UnicodeToAnsii(temp, (S8*) g_jmms_context->subject_input_buffer);
  707.             str_len = strlen(temp);
  708.             for (count = 0; count < (str_len); count++)
  709.             {
  710.                 if (temp[count] == 0x0D && temp[count + 1] == 0x0A)
  711.                 {
  712.                     temp[count] = 0x20;
  713.                     strcpy((S8*) (temp + count + 1), (S8*) (temp + count + 2));
  714.                     str_len--;
  715.                 }
  716.             }
  717.             AnsiiToUnicodeString(g_jmms_context->subject, temp);
  718.         }
  719.         else
  720.         {
  721.             pfnUnicodeStrcpy((S8*) g_jmms_context->subject, (S8*) g_jmms_context->subject_input_buffer);
  722.         }
  723.         pMessageSend->pSubject = (JC_CHAR*) g_jmms_context->subject;
  724.     }
  725.     pMsgHeaders->eMsgType = E_MSG_TYPE_SEND;
  726.     pMsgHeaders->pHeaders = pMessageSend;
  727.     if (is_create_for_send == MMI_TRUE)
  728.     {
  729.         g_jmms_context->progress_screen_title = STR_ID_PROGRESS_SENDING;
  730.         memset(g_jmms_context->g_jmms_progress_str, 0x00, MAX_PROGRESS_SCREEN_HINT_LEN * ENCODING_LENGTH);
  731.         mmi_jmms_entry_communication_progress_screen();
  732.         /* PMT VIKAS START 20060325 */
  733.     //#ifdef __MMI_MMS_SIGNATURE__
  734.         mmi_jmms_insert_auto_signature();
  735.     //#endif 
  736. //        mmi_jmms_entry_communication_progress_screen();
  737.         eRet = mmi_jmms_jdi_set_msg_headers(hMsgHandle, pMsgHeaders);
  738.         if (JC_OK != eRet)
  739.         {
  740.             mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  741.             return eRet;
  742.         }
  743.         /* PMT VIKAS END 20060325 */
  744. /******************************************************************************
  745.  This part of the function is modified to make the MMS send process asynch.
  746.  Modified By          : Raj Kumar Gupta
  747.  Date of Modification : 09 June 2006
  748.  *****************************************************************************/
  749.         /* Register the function that to be execute after the completion of the 
  750.            encapsulation */
  751.         mmi_jmms_add_send_callback_node(mmi_jmms_create_and_send_new_mms_async_callback);
  752.         mmi_jmms_send_mms(hMsgHandle, E_TYPE_NEW_MMS, E_TRUE, 1, E_TRUE);
  753.     }
  754.     /* PMT VIKAS START 20060325 */
  755.     else
  756.     {
  757.         eRet = mmi_jmms_jdi_set_msg_headers(hMsgHandle, pMsgHeaders);
  758.         if (JC_OK != eRet)
  759.         {
  760.             mmi_jmms_free_mms_pdu_memory(g_jmms_context);
  761.             return eRet;
  762.         }
  763.     }
  764.     /* PMT VIKAS END 20060325 */
  765.     return JC_OK;
  766. }
  767. /*****************************************************************************
  768.  * FUNCTION
  769.  *  mmi_jmms_create_and_send_new_mms_async_callback
  770.  * DESCRIPTION
  771.  *  
  772.  * PARAMETERS
  773.  *  eRet        [IN]        
  774.  * RETURNS
  775.  *  void
  776.  *****************************************************************************/
  777. void mmi_jmms_create_and_send_new_mms_async_callback(JC_RETCODE eRet)
  778. {
  779.     /*----------------------------------------------------------------*/
  780.     /* Local Variables                                                */
  781.     /*----------------------------------------------------------------*/
  782.     /*----------------------------------------------------------------*/
  783.     /* Code Body                                                      */
  784.     /*----------------------------------------------------------------*/
  785.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_create_and_send_new_mms_async_callback, Ret Code:", eRet));
  786.     if (JC_OK != eRet)
  787.     {
  788.         /* PMT VIKAS START 20060405 */
  789.     //#ifdef __MMI_MMS_SIGNATURE__
  790.         mmi_jmms_del_inserted_auto_signature_slide();
  791.     //#endif 
  792.         /* PMT VIKAS END 20060405 */
  793.         if (eRet == E_JMMS_STORAGE_FULL)
  794.         {
  795.             mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_ERROR_MMS_SENT_STORE_FUL);
  796.         }
  797.         /* Added by - Raj Kumar Gupta on 31 August, 2006 */
  798.         else if(eRet == E_COMMUNICATION_ABORTED)
  799.         {
  800.             DisplayPopup(
  801.                     (U8*) GetString(STR_ID_JMMS_COMM_ABORTED),
  802.                     IMG_GLOBAL_INFO,
  803.                     1,
  804.                     JMMS_POPUP_TIME,
  805.                     (U8) SUCCESS_TONE);
  806.         }
  807.         else
  808.         {
  809.             mmi_jmms_handle_pop_up_for_interupt(STR_ID_JMMS_ERROR_MMS_SENT);
  810.         }
  811.         mmi_jmms_free_message_header();
  812.         DeleteFromScrUptoScr(SCR_ID_JMMS_PROGRESS, g_jmms_context->last_scr_id);
  813.     }
  814. }
  815. /*****************************************************************************
  816.  * FUNCTION
  817.  *  mmi_jmms_save_mms
  818.  * DESCRIPTION
  819.  *  
  820.  * PARAMETERS
  821.  *  folder_name         [?]         [?]         [?]
  822.  *  hMsgHandle          [IN]        
  823.  *  is_store_update     [IN]        
  824.  *  msg_index           [IN]        
  825.  *  err_cb              [IN]        
  826.  * RETURNS
  827.  *  
  828.  *****************************************************************************/
  829. /* IN THIS we have message handle as input, directly save from handle, first make file then save. */
  830. JC_RETCODE mmi_jmms_save_mms(
  831.             S8 *folder_name,
  832.             MSG_HANDLE hMsgHandle,
  833.             MMI_BOOL is_store_update,
  834.             JC_UINT32 msg_index,
  835.             error_callback err_cb)
  836. {
  837.     /*----------------------------------------------------------------*/
  838.     /* Local Variables                                                */
  839.     /*----------------------------------------------------------------*/
  840.     /* CONTENT_DATA EncapsulatedContent = {0, }; */
  841.     JC_RETCODE eRet = JC_OK;
  842.     /*----------------------------------------------------------------*/
  843.     /* Code Body                                                      */
  844.     /*----------------------------------------------------------------*/
  845.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_save_mms"));
  846.     if (g_jmms_context->pSaveContent != NULL)
  847.     {
  848.         jdd_MemFree(g_jmms_context->pSaveContent);
  849.     }
  850.     g_jmms_context->pSaveContent = (CONTENT_DATA*) jdd_MemAlloc(sizeof(CONTENT_DATA), 1);
  851.     if (g_jmms_context->async_save_context.params != NULL)
  852.     {
  853.         jdd_MemFree(g_jmms_context->async_save_context.params);
  854.     }
  855.     g_jmms_context->async_save_context.params =
  856.         (jmms_async_save_params_struct*) jdd_MemAlloc(sizeof(jmms_async_save_params_struct), 1);
  857.     memcpy(g_jmms_context->async_save_context.params->folder_name, folder_name, strlen(folder_name) + 1);
  858.     g_jmms_context->async_save_context.params->is_store_update = is_store_update;
  859.     g_jmms_context->async_save_context.params->msg_index = msg_index;
  860.     g_jmms_context->async_save_context.params->hMsgHandle = hMsgHandle;
  861.     g_jmms_context->pSaveContent->bIsStream = E_TRUE;
  862.     g_jmms_context->pSaveContent->cbWriteCallback = mmi_jmms_write_callback;
  863.     jdi_UtilsCharToTchar(
  864.         (JC_CHAR **) & (g_jmms_context->pSaveContent->pStream),
  865.         "@mms\temp\jmms_tempEncFile.bin");
  866.     g_jmms_context->pSaveContent->pFileName = g_jmms_context->pSaveContent->pStream;
  867.     eRet = mmi_jmms_jdi_encapsulate_buffer(hMsgHandle, g_jmms_context->pSaveContent);
  868.     mmi_jmms_add_save_callback_node(err_cb);
  869.     mmi_jmms_add_save_callback_node(mmi_jmms_save_mms_async_callback);
  870.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS ENCODING START"));
  871.     if (eRet == JC_ERR_MMS_ENCODE_PENDING)
  872.     {
  873.         mmi_jmms_save_continue_start_timer(hMsgHandle);
  874.         return eRet;
  875.     }
  876.     mmi_jmms_decrement_save_callback_node(eRet);
  877.     return eRet;
  878. }
  879. /*****************************************************************************
  880.  * FUNCTION
  881.  *  mmi_jmms_save_mms_async_callback
  882.  * DESCRIPTION
  883.  *  
  884.  * PARAMETERS
  885.  *  eRet        [IN]        
  886.  * RETURNS
  887.  *  void
  888.  *****************************************************************************/
  889. void mmi_jmms_save_mms_async_callback(JC_RETCODE eRet)
  890. {
  891.     /*----------------------------------------------------------------*/
  892.     /* Local Variables                                                */
  893.     /*----------------------------------------------------------------*/
  894.     MESSAGE_HEADERS *MsgHeaders = NULL;
  895.     jmms_async_save_params_struct save_params;
  896.     // CONTENT_DATA content = {0, }; // COMPILER WARNING  REMOVAL
  897. //sandeep starts
  898. RETRIEVE_FILTERS StoreRetFilter = {0, };
  899. MESSAGE_LIST *pMessageList=NULL;
  900. //sandeep ends
  901.     /*----------------------------------------------------------------*/
  902.     /* Code Body                                                      */
  903.     /*----------------------------------------------------------------*/
  904.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "mmi_jmms_save_mms_async_callback with Ret Code: ", eRet));
  905.     memcpy(&save_params, (g_jmms_context->async_save_context.params), sizeof(jmms_async_save_params_struct));
  906.     if (JC_OK != eRet || g_jmms_context->async_save_context.params == NULL)
  907.     {
  908.         goto ERROR_HANDLE;
  909.     }
  910.     g_jmms_context->pSaveContent->cbWriteCallback = NULL;
  911.     g_jmms_context->pSaveContent->cbReadCallback = mmi_jmms_read_callback;
  912.     eRet = mmi_jmms_jdi_get_msg_headers(save_params.hMsgHandle, &MsgHeaders);
  913.     if (eRet != JC_OK || MsgHeaders == NULL)
  914.     {
  915.         goto ERROR_HANDLE;
  916.     }
  917.     if (save_params.is_store_update == MMI_FALSE)
  918.     {
  919.     #ifdef __MMI_UNIFIED_MESSAGE__
  920.         {
  921.             JC_UINT32 temp_extrabyte1 = 0x01000000, temp_extrabyte2 = 0x02000000;
  922.             if (g_jmms_context->num_attachments > 0)
  923.             {
  924.                 eRet = mmi_jmms_save_message_buffer_in_Store(
  925.                         save_params.folder_name,
  926.                         &(save_params.msg_index),
  927.                         MsgHeaders,
  928.                         g_jmms_context->pSaveContent,
  929.                         &temp_extrabyte1);
  930.             }
  931.             else
  932.             {
  933.                 eRet = mmi_jmms_save_message_buffer_in_Store(
  934.                         save_params.folder_name,
  935.                         &(save_params.msg_index),
  936.                         MsgHeaders,
  937.                         g_jmms_context->pSaveContent,
  938.                         &temp_extrabyte2);
  939.             }
  940.         }
  941.     #else /* __MMI_UNIFIED_MESSAGE__ */ 
  942.         eRet = mmi_jmms_save_message_buffer_in_Store(
  943.                 save_params.folder_name,
  944.                 &(save_params.msg_index),
  945.                 MsgHeaders,
  946.                 g_jmms_context->pSaveContent,
  947.                 NULL);
  948.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  949.     }
  950.     else
  951.     {
  952.     #ifdef __MMI_UNIFIED_MESSAGE__
  953.         if (g_jmms_context->num_attachments > 0)
  954.         {
  955.             eRet = mmi_jmms_store_update_message(
  956.                     save_params.folder_name,
  957.                     &(save_params.msg_index),
  958.                     MsgHeaders,
  959.                     g_jmms_context->pSaveContent,
  960.                     0x01000000);
  961.         }
  962.         else
  963.         {
  964.             eRet = mmi_jmms_store_update_message(
  965.                     save_params.folder_name,
  966.                     &(save_params.msg_index),
  967.                     MsgHeaders,
  968.                     g_jmms_context->pSaveContent,
  969.                     0x02000000);
  970.         }
  971.     #else /* __MMI_UNIFIED_MESSAGE__ */ 
  972.         eRet = mmi_jmms_store_update_message(
  973.                 save_params.folder_name,
  974.                 &(save_params.msg_index),
  975.                 MsgHeaders,
  976.                 g_jmms_context->pSaveContent,
  977.                 0);
  978.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  979.     }
  980.     if (eRet != JC_OK)
  981.     {
  982.         goto ERROR_HANDLE;
  983.     }
  984. //sandeep starts
  985.     //eRet = mmi_jmms_get_message(save_params.folder_name, &content, save_params.msg_index);
  986. StoreRetFilter.uiStartIndex = 1;
  987.     StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
  988.     StoreRetFilter.uiNumMessage = 0;
  989. eRet=mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle,&pMessageList,&StoreRetFilter);
  990. //sandeep ends
  991.     if(eRet == JC_OK)
  992.     {
  993.         eRet = mmi_jmms_jdi_store_update_extra_byte_1(g_jmms_context->hStoreHandle, save_params.msg_index, get_current_utc_time());
  994.     }
  995.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "JMMS Store Save API returned with Ret Code: ", eRet));
  996.   ERROR_HANDLE:
  997.     if (g_jmms_context->pSaveContent != NULL)
  998.     {
  999.         if (g_jmms_context->pSaveContent->bIsStream == E_FALSE)
  1000.         {
  1001.             jdd_MemFree(g_jmms_context->pSaveContent->pBuffer);
  1002.             g_jmms_context->pSaveContent->pBuffer = NULL;
  1003.         }
  1004.         if (g_jmms_context->pSaveContent->pStream != NULL)
  1005.         {
  1006.             if (g_jmms_context->jmms_fs_handle == NULL)
  1007.             {
  1008.                 if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1009.                 {
  1010.                     jdd_MemFree(g_jmms_context->async_save_context.params);
  1011.                     g_jmms_context->async_save_context.params = NULL;
  1012.                     mmi_jmms_decrement_save_callback_node(JC_ERR_FILE_SYS_INIT);
  1013.                     return;
  1014.                 }
  1015.             }
  1016.             jdd_FSDelete(g_jmms_context->jmms_fs_handle, g_jmms_context->pSaveContent->pStream);
  1017.             if (g_jmms_context->jmms_fs_handle != NULL)
  1018.             {
  1019.                 jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1020.                 g_jmms_context->jmms_fs_handle = NULL;
  1021.             }
  1022.             jdd_MemFree(g_jmms_context->pSaveContent->pStream);
  1023.         }
  1024.         jdd_MemFree(g_jmms_context->pSaveContent);
  1025.         g_jmms_context->pSaveContent = NULL;
  1026.     }
  1027.     jdd_MemFree(g_jmms_context->async_save_context.params);
  1028.     g_jmms_context->async_save_context.params = NULL;
  1029.     mmi_jmms_decrement_save_callback_node(eRet);
  1030. }
  1031. /*****************************************************************************
  1032.  * FUNCTION
  1033.  *  mmi_jmms_send_and_store_mms
  1034.  * DESCRIPTION
  1035.  *  
  1036.  * PARAMETERS
  1037.  *  folder_name     [?]         [?]         [?]
  1038.  *  hMsgHandle      [IN]        
  1039.  *  comm_node       [?]         [?]         [?]
  1040.  * RETURNS
  1041.  *  
  1042.  *****************************************************************************/
  1043. /* It is called in case of send and save, PDU is already in file. */
  1044. JC_RETCODE mmi_jmms_send_and_store_mms(
  1045.             S8 *folder_name,
  1046.             MSG_HANDLE hMsgHandle,
  1047.             jmms_communication_state_node *comm_node)
  1048. {
  1049.     /*----------------------------------------------------------------*/
  1050.     /* Local Variables                                                */
  1051.     /*----------------------------------------------------------------*/
  1052.     JC_UINT32 msg_index = 0;
  1053.     CONTENT_DATA EncapsulatedContent = {0, };
  1054.     MESSAGE_HEADERS *MsgHeaders = NULL;
  1055.     JC_RETCODE eRet = JC_OK;
  1056.     JC_UINT32 uiFileLength = 0;
  1057.     JDD_FILE hFile = NULL;
  1058. //sandeep starts
  1059. RETRIEVE_FILTERS StoreRetFilter = {0, };
  1060. MESSAGE_LIST *pMessageList=NULL;
  1061. //sandeep ends
  1062.     /*----------------------------------------------------------------*/
  1063.     /* Code Body                                                      */
  1064.     /*----------------------------------------------------------------*/
  1065.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_send_and_store_mms"));
  1066.     EncapsulatedContent.bIsStream = E_TRUE;
  1067.     EncapsulatedContent.cbWriteCallback = NULL;
  1068.     EncapsulatedContent.cbReadCallback = mmi_jmms_read_callback;
  1069.     EncapsulatedContent.pStream = comm_node->pFileName_used_for_Send;
  1070.     EncapsulatedContent.pFileName = comm_node->pFileName_used_for_Send;
  1071.     if (g_jmms_context->jmms_fs_handle == NULL)
  1072.     {
  1073.         if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1074.         {
  1075.             eRet = JC_ERR_FILE_OPEN;
  1076.             goto ERROR_HANDLE;
  1077.         }
  1078.     }
  1079.     hFile = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (JC_CHAR*) EncapsulatedContent.pStream, E_OPEN_READ_MODE);
  1080.     if (hFile == NULL)
  1081.     {
  1082.         eRet = JC_ERR_FILE_OPEN;
  1083.         goto ERROR_HANDLE;
  1084.     }
  1085.     eRet = jdd_FSGetSize(hFile, &uiFileLength);
  1086.     if (JC_OK != eRet)
  1087.     {
  1088.         eRet = JC_ERR_FILE_OPEN;
  1089.         goto ERROR_HANDLE;
  1090.     }
  1091.     EncapsulatedContent.uiTotalSize = uiFileLength;
  1092.     if (hFile != NULL)
  1093.     {
  1094.         jdd_FSClose(hFile);
  1095.         hFile = NULL;
  1096.     }
  1097.     if (g_jmms_context->jmms_fs_handle != NULL)
  1098.     {
  1099.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1100.         g_jmms_context->jmms_fs_handle = NULL;
  1101.     }
  1102.     eRet = mmi_jmms_jdi_get_msg_headers(hMsgHandle, &MsgHeaders);
  1103.     if (eRet != JC_OK || MsgHeaders == NULL)
  1104.     {
  1105.         goto ERROR_HANDLE;
  1106.     }
  1107. #ifdef __MMI_UNIFIED_MESSAGE__
  1108.     {
  1109.         JC_UINT32 temp_extrabyte1 = 0x01000000, temp_extrabyte2 = 0x02000000;
  1110.         if (g_jmms_context->num_attachments > 0)
  1111.         {
  1112.             eRet = mmi_jmms_save_message_buffer_in_Store(
  1113.                     folder_name,
  1114.                     &msg_index,
  1115.                     MsgHeaders,
  1116.                     &EncapsulatedContent,
  1117.                     &temp_extrabyte1);
  1118.         }
  1119.         else
  1120.         {
  1121.             eRet = mmi_jmms_save_message_buffer_in_Store(
  1122.                     folder_name,
  1123.                     &msg_index,
  1124.                     MsgHeaders,
  1125.                     &EncapsulatedContent,
  1126.                     &temp_extrabyte2);
  1127.         }
  1128.     }
  1129. #else /* __MMI_UNIFIED_MESSAGE__ */ 
  1130.     eRet = mmi_jmms_save_message_buffer_in_Store(folder_name, &msg_index, MsgHeaders, &EncapsulatedContent, 0);
  1131. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1132.     if (eRet != JC_OK)
  1133.     {
  1134.         goto ERROR_HANDLE;
  1135.     }
  1136. //sandeep starts
  1137.     //eRet = mmi_jmms_get_message(save_params.folder_name, &content, save_params.msg_index);
  1138. StoreRetFilter.uiStartIndex = 1;
  1139.     StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
  1140.     StoreRetFilter.uiNumMessage = 0;
  1141. eRet=mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle,&pMessageList,&StoreRetFilter);
  1142. //sandeep ends
  1143.     
  1144.     if(eRet == JC_OK)
  1145.     {
  1146.         eRet = mmi_jmms_jdi_store_update_extra_byte_1(g_jmms_context->hStoreHandle, msg_index, get_current_utc_time());
  1147.     }
  1148.   ERROR_HANDLE:
  1149.     if (hFile != NULL)
  1150.     {
  1151.         jdd_FSClose(hFile);
  1152.         hFile = NULL;
  1153.     }
  1154.     if (g_jmms_context->jmms_fs_handle != NULL)
  1155.     {
  1156.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1157.         g_jmms_context->jmms_fs_handle = NULL;
  1158.     }
  1159.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "mmi_jmms_send_and_store_mms returns: ", eRet));
  1160.     return eRet;
  1161. }
  1162. /*****************************************************************************
  1163.  * FUNCTION
  1164.  *  mmi_jmms_send_mms
  1165.  * DESCRIPTION
  1166.  *  
  1167.  * PARAMETERS
  1168.  *  hMsgHandle          [IN]        
  1169.  *  comm_state          [IN]        
  1170.  *  bIsStream           [IN]        
  1171.  *  retry_counter       [IN]        
  1172.  *  bIsAsynch           [IN]        
  1173.  * RETURNS
  1174.  *  
  1175.  *****************************************************************************/
  1176. JC_RETCODE mmi_jmms_send_mms(
  1177.             MSG_HANDLE hMsgHandle,
  1178.             U16 comm_state,
  1179.             JC_BOOLEAN bIsStream,
  1180.             U8 retry_counter,
  1181.             JC_BOOLEAN bIsAsynch)
  1182. {
  1183.     /*----------------------------------------------------------------*/
  1184.     /* Local Variables                                                */
  1185.     /*----------------------------------------------------------------*/
  1186.     JC_RETCODE eRet = JC_OK;
  1187.     static U32 unique_value = 0;
  1188.     jmms_async_send_params_struct *paramList = NULL;
  1189.     /*----------------------------------------------------------------*/
  1190.     /* Code Body                                                      */
  1191.     /*----------------------------------------------------------------*/
  1192.     /* PMT VIKAS START 20060401 */
  1193.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_send_mms"));
  1194.     if((comm_state == E_TYPE_NOTIFICATION_RESPONSE) ||
  1195.         (comm_state == E_TYPE_READ_REPORT_PDU) ||
  1196.         (comm_state == E_TYPE_READ_REPORT_MMS) ||
  1197.         (comm_state == E_TYPE_ACK_RESPONSE))
  1198.     {
  1199.         eRet = mmi_jmms_send_synchronous_mms(
  1200.                             hMsgHandle,
  1201.                             comm_state,bIsStream,retry_counter,bIsAsynch,&unique_value);
  1202.         return eRet;
  1203.         
  1204.     }
  1205.     /* PMT VIKAS END 20060401 */
  1206.     if (bIsStream == E_TRUE)
  1207.     {
  1208.         JC_INT8 Temp[50] = {0, };
  1209.         unique_value++;
  1210.         if (unique_value > 200000)
  1211.         {
  1212.             unique_value = 0;
  1213.         }
  1214.         jc_sprintf(Temp, "%s%d", "@mms\temp\jmms_tempSendBuff", unique_value);
  1215.         if (g_jmms_context->pSendContent != NULL)
  1216.         {
  1217.             jdd_MemFree(g_jmms_context->pSendContent);
  1218.         }
  1219.         g_jmms_context->pSendContent = (CONTENT_DATA*) jdd_MemAlloc(sizeof(CONTENT_DATA), 1);
  1220.         jdi_UtilsCharToTchar(&(g_jmms_context->pSendContent->pFileName), Temp);
  1221.         g_jmms_context->pSendContent->pStream = (void*)g_jmms_context->pSendContent->pFileName;
  1222.         g_jmms_context->pSendContent->bIsStream = E_TRUE;
  1223.         g_jmms_context->pSendContent->cbWriteCallback = mmi_jmms_write_callback;
  1224.     }
  1225. /******************************************************************************
  1226.  This modification is made to make the send MMS process async.
  1227.  Modified By          : Raj Kumar Gupta
  1228.  Date of Modification : 08 June 2006
  1229.  *****************************************************************************/
  1230.     if (g_jmms_context->async_send_context.params != NULL)
  1231.     {
  1232.         jdd_MemFree(g_jmms_context->async_send_context.params);
  1233.     }
  1234.     paramList = (jmms_async_send_params_struct*) jdd_MemAlloc(sizeof(jmms_async_send_params_struct), 1);
  1235.     paramList->bIsStream = bIsStream;
  1236.     paramList->comm_state = comm_state;
  1237.     paramList->hMsgHandle = hMsgHandle;
  1238.     paramList->retry_counter = retry_counter;
  1239.     g_jmms_context->async_send_context.params = paramList;
  1240.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS ENCAPSULATION START"));
  1241.     eRet = mmi_jmms_jdi_encapsulate_buffer(hMsgHandle, g_jmms_context->pSendContent);
  1242.     /* Register the function that to be execute after the completion of the 
  1243.        encapsulation */
  1244.     mmi_jmms_add_send_callback_node(mmi_jmms_send_mms_async_callback);
  1245.     /* Check whether Encapsulation is completed or not */
  1246.     if (eRet == JC_ERR_MMS_ENCODE_PENDING)
  1247.     {
  1248.         if (bIsAsynch == E_TRUE)
  1249.         {
  1250.             /* Start the Timer */
  1251.             mmi_jmms_send_continue_start_timer(hMsgHandle);
  1252.         }
  1253.         else
  1254.         {
  1255.             while (eRet == JC_ERR_MMS_ENCODE_PENDING)
  1256.             {
  1257.                 eRet = mmi_jmms_jdi_msg_encapsulate_continue(hMsgHandle);
  1258.             }
  1259.             /* To execute the function that to be called after the completion of 
  1260.                the encapsulation */
  1261.             mmi_jmms_decrement_send_callback_node(eRet);
  1262.         }
  1263.     }
  1264.     else
  1265.     {
  1266.         /* To execute the function that to be called after the completion of 
  1267.            the encapsulation */
  1268.         mmi_jmms_decrement_send_callback_node(eRet);
  1269.     }
  1270.     return eRet;
  1271. }
  1272. /*****************************************************************************
  1273.  * FUNCTION
  1274.  *  mmi_jmms_send_synchronous_mms
  1275.  * DESCRIPTION
  1276.  *  
  1277.  * PARAMETERS
  1278.  *  hMsgHandle          [IN]        
  1279.  *  comm_state          [IN]        
  1280.  *  bIsStream           [IN]        
  1281.  *  retry_counter       [IN]        
  1282.  *  bIsAsynch           [IN]    
  1283.  *  unique_id_p         [IN]
  1284.  * RETURNS
  1285.  *  JC_RETCODE
  1286.  *****************************************************************************/
  1287. JC_RETCODE mmi_jmms_send_synchronous_mms(
  1288.             MSG_HANDLE hMsgHandle,
  1289.             U16 comm_state,
  1290.             JC_BOOLEAN bIsStream,
  1291.             U8 retry_counter, 
  1292.             JC_BOOLEAN bIsAsynch,U32* unique_id_p)
  1293. {
  1294.     
  1295.     /*----------------------------------------------------------------*/
  1296.     /* Local Variables                                                */
  1297.     /*----------------------------------------------------------------*/
  1298.     JC_RETCODE eRet = JC_OK;
  1299.     CONTENT_DATA*   content_data_p  =   NULL;
  1300.     JC_UINT32 uiReferenceID = 1;
  1301.     COMM_FETCH_URL fetchUrlInfo = {0, };
  1302.     U32 fs_not_init =0;
  1303.     JC_CHAR *fileptr = NULL;
  1304.     U8 *temp = NULL;
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Code Body                                                      */
  1307.     /*----------------------------------------------------------------*/
  1308.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_send_synchronous_mms"));
  1309.     if (bIsStream == E_TRUE)
  1310.     {
  1311.         JC_INT8 Temp[50] = {0, };
  1312.         
  1313.         (*unique_id_p)++;
  1314.         if ((*unique_id_p) > 200000)
  1315.         {
  1316.             (*unique_id_p) = 0;
  1317.         }
  1318.         jc_sprintf(Temp, "%s%d", "@mms\temp\jmms_tempSendBuff", (*unique_id_p));
  1319.         content_data_p = (CONTENT_DATA*) jdd_MemAlloc(sizeof(CONTENT_DATA), 1);
  1320.         jdi_UtilsCharToTchar(&(content_data_p->pFileName), Temp);
  1321.         content_data_p->pStream = (void*)content_data_p->pFileName;
  1322.         content_data_p->bIsStream = E_TRUE;
  1323.         content_data_p->cbWriteCallback = mmi_jmms_write_callback;
  1324.     }
  1325.     else
  1326.         ASSERT(0);
  1327.     eRet = mmi_jmms_jdi_encapsulate_buffer(hMsgHandle, content_data_p);
  1328.     while (eRet == JC_ERR_MMS_ENCODE_PENDING)
  1329.     {
  1330.         eRet = mmi_jmms_jdi_msg_encapsulate_continue(hMsgHandle);
  1331.     }
  1332.     if (JC_OK != eRet)
  1333.     {
  1334.         if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
  1335.         {
  1336.             eRet = E_JMMS_STORAGE_FULL;
  1337.         }
  1338.         
  1339.     }
  1340.     else
  1341.     {
  1342.         fetchUrlInfo.eContentMode = E_COMM_BUFFER;
  1343.         temp = mmi_jmms_get_activated_mmsc_url(g_jmms_context);
  1344.         fetchUrlInfo.pszURL = (JC_CHAR*) temp;
  1345.         fetchUrlInfo.pszContentType = "application/vnd.wap.mms-message";
  1346.         fetchUrlInfo.bIsFile = E_TRUE;
  1347.         fetchUrlInfo.uUserDataMode.pmFileName = content_data_p->pFileName;
  1348.         fetchUrlInfo.uiPostLen = content_data_p->uiTotalSize;
  1349.         fetchUrlInfo.pHeadersInfo = (COMM_HEADERS *)jdd_MemAlloc(sizeof(COMM_HEADERS), 1); 
  1350.         fetchUrlInfo.pHeadersInfo->pszName = "Accept";
  1351.         fetchUrlInfo.pHeadersInfo->psValue = "*/*";
  1352.         fetchUrlInfo.pHeadersInfo->uiValueSize = 3;
  1353.         fetchUrlInfo.pHeadersInfo->pszCharset = "utf-8";
  1354.         fetchUrlInfo.pHeadersInfo->pNext = NULL;
  1355.         fetchUrlInfo.eCommFetchType = E_COMM_FETCH_POST;
  1356.         eRet = jdi_CommunicationFetchURL(g_jmms_context->hCommHandle, &fetchUrlInfo, &uiReferenceID);
  1357.         if (eRet == JC_OK)
  1358.         {
  1359.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Synch Send , Request id",
  1360.                                  uiReferenceID));
  1361.             fileptr = jdi_UtilsTcsDup(content_data_p->pFileName);
  1362.             eRet = mmi_jmms_add_comm_node(
  1363.                     g_jmms_context,
  1364.                     uiReferenceID,
  1365.                     comm_state,
  1366.                     fileptr,
  1367.                     0,
  1368.                     retry_counter,
  1369.                     NULL);
  1370.             if (eRet != JC_OK)
  1371.             {
  1372.                 jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, uiReferenceID);
  1373.                 eRet = E_JMMS_GENERAL_ERROR;
  1374.             }
  1375.         }
  1376.         else
  1377.         {
  1378.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d %s %d",
  1379.                                  "mmi_jmms_send_synchronous_mms with request Id",
  1380.                                  g_jmms_context->uiReferenceID, "Returned error code: ", eRet));
  1381.         }
  1382.         if (eRet == JC_OK)
  1383.         {
  1384.             switch (comm_state)
  1385.             {
  1386.                 case E_TYPE_NOTIFICATION_RESPONSE:
  1387.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "Synch Send Request for Notf-Response", uiReferenceID));
  1388.                     break;
  1389.                 case E_TYPE_ACK_RESPONSE:
  1390.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "Synch Send Request for Ack-Response", uiReferenceID));
  1391.                     break;
  1392.                 case E_TYPE_READ_REPORT_PDU:
  1393.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "Synch Send Request for Read Report PDU", uiReferenceID));
  1394.                     break;
  1395.                 case E_TYPE_READ_REPORT_MMS:
  1396.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "Synch Send Request for Read Report MMS", uiReferenceID));
  1397.                     break;
  1398.             }
  1399.         }
  1400.     if (eRet != JC_OK)
  1401.     {
  1402.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "Sync Sending returns, Error Code:", eRet));
  1403.         if (content_data_p != NULL && content_data_p->pStream != NULL)
  1404.         {
  1405.             if (g_jmms_context->jmms_fs_handle == NULL)
  1406.             {
  1407.                 if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1408.                 {
  1409.                     fs_not_init = 1;
  1410.                 }
  1411.             }
  1412.             
  1413.             if(!fs_not_init)
  1414.             {
  1415.                 jdd_FSDelete(g_jmms_context->jmms_fs_handle, content_data_p->pStream);
  1416.                 if (g_jmms_context->jmms_fs_handle != NULL)
  1417.                 {
  1418.                     jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1419.                     g_jmms_context->jmms_fs_handle = NULL;
  1420.                 }
  1421.             }
  1422.         }
  1423.         if (fileptr != NULL)
  1424.         {
  1425.             jdd_MemFree(fileptr);
  1426.         }
  1427.     }
  1428.     if (content_data_p != NULL)
  1429.     {
  1430.         if (content_data_p->pStream != NULL)
  1431.         {
  1432.             jdd_MemFree(content_data_p->pStream);
  1433.         }
  1434.         if (content_data_p->pBuffer != NULL)
  1435.         {
  1436.             jdd_MemFree(content_data_p->pBuffer);
  1437.         }
  1438.         jdd_MemFree(content_data_p);
  1439.      }
  1440.      if(fetchUrlInfo.pHeadersInfo != NULL)
  1441.      {
  1442.         jdd_MemFree(fetchUrlInfo.pHeadersInfo);
  1443.      }
  1444.       if (g_jmms_context->activated_mmsc_url != NULL)
  1445.       {
  1446.         jdd_MemFree(g_jmms_context->activated_mmsc_url);
  1447.         g_jmms_context->activated_mmsc_url = NULL;
  1448.       }
  1449.     }
  1450.     return eRet;
  1451. }
  1452. /*****************************************************************************
  1453.  * FUNCTION
  1454.  *  mmi_jmms_send_mms_async_callback
  1455.  * DESCRIPTION
  1456.  *  
  1457.  * PARAMETERS
  1458.  *  eRet        [IN]        
  1459.  * RETURNS
  1460.  *  void
  1461.  *****************************************************************************/
  1462. void mmi_jmms_send_mms_async_callback(JC_RETCODE eRet)
  1463. {
  1464.     /*----------------------------------------------------------------*/
  1465.     /* Local Variables                                                */
  1466.     /*----------------------------------------------------------------*/
  1467.     U8 *temp = NULL;
  1468.     JC_UINT32 uiReferenceID = 1;
  1469.     COMM_FETCH_URL fetchUrlInfo = {0, };
  1470.     jmms_async_send_params_struct *paramList = NULL;
  1471.     JC_CHAR *fileptr = NULL;
  1472.     /*----------------------------------------------------------------*/
  1473.     /* Code Body                                                      */
  1474.     /*----------------------------------------------------------------*/
  1475.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_send_mms_async_callback, Return Code:", eRet));
  1476.     if (g_jmms_context->async_send_context.params == NULL)
  1477.     {
  1478.         return;
  1479.     }
  1480.     paramList = g_jmms_context->async_send_context.params;
  1481.     if (JC_OK != eRet)
  1482.     {
  1483.         if (eRet == JC_ERR_MEMORY_ALLOCATION || eRet == JC_ERR_FILE_WRITE)
  1484.         {
  1485.             eRet = E_JMMS_STORAGE_FULL;
  1486.         }
  1487.         goto END;
  1488.     }
  1489.     fetchUrlInfo.eContentMode = E_COMM_BUFFER;
  1490.     temp = mmi_jmms_get_activated_mmsc_url(g_jmms_context);
  1491.     fetchUrlInfo.pszURL = (JC_CHAR*) temp;
  1492.     fetchUrlInfo.pszContentType = "application/vnd.wap.mms-message";
  1493.     if (g_jmms_context->pSendContent->bIsStream == E_FALSE)
  1494.     {
  1495.         fetchUrlInfo.bIsFile = E_FALSE;
  1496.         fetchUrlInfo.uUserDataMode.pucPostData = g_jmms_context->pSendContent->pBuffer;
  1497.     }
  1498.     else
  1499.     {
  1500.         fetchUrlInfo.bIsFile = E_TRUE;
  1501.         fetchUrlInfo.uUserDataMode.pmFileName = g_jmms_context->pSendContent->pFileName;
  1502.     }
  1503.     fetchUrlInfo.uiPostLen = g_jmms_context->pSendContent->uiTotalSize;
  1504.     //fetchUrlInfo.pHeadersInfo = NULL;
  1505.     fetchUrlInfo.pHeadersInfo = (COMM_HEADERS *)jdd_MemAlloc(sizeof(COMM_HEADERS), 1); 
  1506.     fetchUrlInfo.pHeadersInfo->pszName = "Accept";
  1507.     fetchUrlInfo.pHeadersInfo->psValue = "*/*";
  1508.     fetchUrlInfo.pHeadersInfo->uiValueSize = 3;
  1509.     fetchUrlInfo.pHeadersInfo->pszCharset = "utf-8";
  1510.     fetchUrlInfo.pHeadersInfo->pNext = NULL;
  1511.     
  1512.     fetchUrlInfo.eCommFetchType = E_COMM_FETCH_POST;
  1513.     if (paramList->comm_state == E_TYPE_NEW_MMS || paramList->comm_state == E_TYPE_NEW_JAVA_MMS_SEND)       /* both java mms and normal mms should not */
  1514.     {   /* sent together otherwise refrece id will */
  1515.         /* /overlapped */
  1516.         /*
  1517.          * For New MMS Send need to use the g_jmms_context->uiReferenceID variable beacuse Sending screen
  1518.          * is there and Sending can be cancelled. Also don't use this variable for Immediate Retrieval etc.
  1519.          * because during Sending/Defered Downlaod there can be immediate retrieval so this varaiable can be overwritten.
  1520.          * 
  1521.          * This variable is used during Sending/Deffered Downloading beacause Sending/Deffered Downlaoding can be 
  1522.          * cancelled by user and so we require this value in jdi_CommunicationStopReq().
  1523.          * Also there is no harm on using the same varaible for sending and deffered retrieval because sending and 
  1524.          * deffered retrieval cann't be both together.
  1525.          */
  1526.         g_jmms_context->uiReferenceID = 0;
  1527.         eRet = jdi_CommunicationFetchURL(g_jmms_context->hCommHandle, &fetchUrlInfo, &(g_jmms_context->uiReferenceID));
  1528.         if (eRet == JC_OK)
  1529.         {
  1530.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Comm Fetch URL for New MMS SEND, Request Id: ",
  1531.                                  g_jmms_context->uiReferenceID));
  1532.             fileptr = jdi_UtilsTcsDup(g_jmms_context->pSendContent->pFileName);
  1533.             eRet = mmi_jmms_add_comm_node(
  1534.                     g_jmms_context,
  1535.                     g_jmms_context->uiReferenceID,
  1536.                     paramList->comm_state,
  1537.                     fileptr,
  1538.                     0,
  1539.                     paramList->retry_counter,
  1540.                     NULL);
  1541.             if (eRet != JC_OK)
  1542.             {
  1543.                 jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1544.                 g_jmms_context->uiReferenceID = 0;
  1545.                 eRet = E_JMMS_GENERAL_ERROR;
  1546.                 goto END;
  1547.             }
  1548.         }
  1549.         else
  1550.         {
  1551.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d %s %d",
  1552.                                  "JMMS jdi_CommunicationFetchURL for NEW MMS Send with request Id",
  1553.                                  g_jmms_context->uiReferenceID, "Returned error code: ", eRet));
  1554.         }
  1555.     }
  1556.     else
  1557.     {
  1558.         eRet = jdi_CommunicationFetchURL(g_jmms_context->hCommHandle, &fetchUrlInfo, &uiReferenceID);
  1559.         if (eRet == JC_OK)
  1560.         {
  1561.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Comm Fetch URL for MMS Send, Request id",
  1562.                                  uiReferenceID));
  1563.             fileptr = jdi_UtilsTcsDup(g_jmms_context->pSendContent->pFileName);
  1564.             eRet = mmi_jmms_add_comm_node(
  1565.                     g_jmms_context,
  1566.                     uiReferenceID,
  1567.                     paramList->comm_state,
  1568.                     fileptr,
  1569.                     0,
  1570.                     paramList->retry_counter,
  1571.                     NULL);
  1572.             if (eRet != JC_OK)
  1573.             {
  1574.                 jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, uiReferenceID);
  1575.                 eRet = E_JMMS_GENERAL_ERROR;
  1576.                 goto END;
  1577.             }
  1578.         }
  1579.         else
  1580.         {
  1581.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d %s %d",
  1582.                                  "JMMS jdi_CommunicationFetchURL for Send MMS with request Id",
  1583.                                  g_jmms_context->uiReferenceID, "Returned error code: ", eRet));
  1584.         }
  1585.     }
  1586.     if (eRet == JC_OK)
  1587.     {
  1588.         switch (paramList->comm_state)
  1589.         {
  1590.             case E_TYPE_NEW_MMS:
  1591.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Send Request for New MMS",
  1592.                                      g_jmms_context->uiReferenceID));
  1593.                 break;
  1594.             case E_TYPE_NEW_JAVA_MMS_SEND:
  1595.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Send Request for New Java MMS",
  1596.                                      g_jmms_context->uiReferenceID));
  1597.                 break;
  1598.             case E_TYPE_NOTIFICATION_RESPONSE:
  1599.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Send Request for Notf-Response", uiReferenceID));
  1600.                 break;
  1601.             case E_TYPE_ACK_RESPONSE:
  1602.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Send Request for Ack-Response", uiReferenceID));
  1603.                 break;
  1604.             case E_TYPE_READ_REPORT_PDU:
  1605.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Send Request for Read Report PDU", uiReferenceID));
  1606.                 break;
  1607.             case E_TYPE_READ_REPORT_MMS:
  1608.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Send Request for Read Report MMS", uiReferenceID));
  1609.                 break;
  1610.         }
  1611.     }
  1612.   END:
  1613.     if (eRet != JC_OK)
  1614.     {
  1615.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "mmi_jmms_send_mms_async_callback, Error Code:", eRet));
  1616.         if (g_jmms_context->pSendContent != NULL && g_jmms_context->pSendContent->pStream != NULL)
  1617.         {
  1618.             if (g_jmms_context->jmms_fs_handle == NULL)
  1619.             {
  1620.                 if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1621.                 {
  1622.                     jdd_MemFree(g_jmms_context->async_send_context.params);
  1623.                     g_jmms_context->async_send_context.params = NULL;
  1624.                     mmi_jmms_decrement_send_callback_node(JC_ERR_FILE_SYS_INIT);
  1625.                     return;
  1626.                 }
  1627.             }
  1628.             jdd_FSDelete(g_jmms_context->jmms_fs_handle, g_jmms_context->pSendContent->pStream);
  1629.             if (g_jmms_context->jmms_fs_handle != NULL)
  1630.             {
  1631.                 jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1632.                 g_jmms_context->jmms_fs_handle = NULL;
  1633.             }
  1634.         }
  1635.         if (fileptr != NULL)
  1636.         {
  1637.             jdd_MemFree(fileptr);
  1638.         }
  1639.     }
  1640.     if (g_jmms_context->pSendContent != NULL)
  1641.     {
  1642.         if (g_jmms_context->pSendContent->pStream != NULL)
  1643.         {
  1644.             jdd_MemFree(g_jmms_context->pSendContent->pStream);
  1645.         }
  1646.         if (g_jmms_context->pSendContent->pBuffer != NULL)
  1647.         {
  1648.             jdd_MemFree(g_jmms_context->pSendContent->pBuffer);
  1649.         }
  1650.         jdd_MemFree(g_jmms_context->pSendContent);
  1651.         g_jmms_context->pSendContent = NULL;
  1652.     }
  1653.     if(fetchUrlInfo.pHeadersInfo != NULL)
  1654.     {
  1655.         jdd_MemFree(fetchUrlInfo.pHeadersInfo);
  1656.     }
  1657.     if (g_jmms_context->activated_mmsc_url != NULL)
  1658.     {
  1659.         jdd_MemFree(g_jmms_context->activated_mmsc_url);
  1660.         g_jmms_context->activated_mmsc_url = NULL;
  1661.     }
  1662.     jdd_MemFree(g_jmms_context->async_send_context.params);
  1663.     g_jmms_context->async_send_context.params = NULL;
  1664.     mmi_jmms_decrement_send_callback_node(eRet);
  1665. }
  1666. /*****************************************************************************
  1667.  * FUNCTION
  1668.  *  mmi_jmms_resend_mms
  1669.  * DESCRIPTION
  1670.  *  
  1671.  * PARAMETERS
  1672.  *  comm_node           [?]         [?]         [?]
  1673.  *  retry_counter       [IN]        
  1674.  * RETURNS
  1675.  *  
  1676.  *****************************************************************************/
  1677. JC_RETCODE mmi_jmms_resend_mms(jmms_communication_state_node *comm_node, U8 retry_counter)
  1678. {
  1679.     /*----------------------------------------------------------------*/
  1680.     /* Local Variables                                                */
  1681.     /*----------------------------------------------------------------*/
  1682.     COMM_FETCH_URL fetchUrlInfo = {0, };
  1683.     JC_UINT32 uiReferenceID = 1;
  1684.     JC_RETCODE eRet = JC_OK;
  1685.     CONTENT_DATA EncapsulatedContent = {0, };
  1686.     U8 *temp = NULL;
  1687.     JC_UINT32 uiFileLength = 0;
  1688.     JDD_FILE hFile = NULL;
  1689.     /*----------------------------------------------------------------*/
  1690.     /* Code Body                                                      */
  1691.     /*----------------------------------------------------------------*/
  1692.     /* PMT VIKAS START 20060401 */
  1693.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_resend_mms"));
  1694.     /* PMT VIKAS END 20060401 */
  1695.     if (comm_node->pFileName_used_for_Send == NULL)
  1696.     {
  1697.         eRet = JC_ERR_FILE_OPEN;
  1698.         goto END;
  1699.     }
  1700.     EncapsulatedContent.pStream = comm_node->pFileName_used_for_Send;
  1701.     EncapsulatedContent.pFileName = EncapsulatedContent.pStream;
  1702.     EncapsulatedContent.bIsStream = E_TRUE;
  1703.     EncapsulatedContent.cbWriteCallback = mmi_jmms_write_callback;
  1704.     if (g_jmms_context->jmms_fs_handle == NULL)
  1705.     {
  1706.         if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1707.         {
  1708.             eRet = JC_ERR_FILE_OPEN;
  1709.             goto END;
  1710.         }
  1711.     }
  1712.     hFile = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (JC_CHAR*) EncapsulatedContent.pStream, E_OPEN_READ_MODE);
  1713.     if (hFile == NULL)
  1714.     {
  1715.         eRet = JC_ERR_FILE_OPEN;
  1716.         goto END;
  1717.     }
  1718.     eRet = jdd_FSGetSize(hFile, &uiFileLength);
  1719.     if (JC_OK != eRet)
  1720.     {
  1721.         eRet = JC_ERR_FILE_OPEN;
  1722.         goto END;
  1723.     }
  1724.     EncapsulatedContent.uiTotalSize = uiFileLength;
  1725.     if (hFile != NULL)
  1726.     {
  1727.         jdd_FSClose(hFile);
  1728.         hFile = NULL;
  1729.     }
  1730.     /* / 7 March */
  1731.     if (g_jmms_context->jmms_fs_handle != NULL)
  1732.     {
  1733.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  1734.         g_jmms_context->jmms_fs_handle = NULL;
  1735.     }
  1736.     fetchUrlInfo.eContentMode = E_COMM_BUFFER;
  1737.     temp = mmi_jmms_get_activated_mmsc_url(g_jmms_context);
  1738.     fetchUrlInfo.pszURL = (JC_CHAR*) temp;
  1739.     /* if(EncapsulatedContent.VIEW_MODE.contentInline.pBuffer!=NULL) */
  1740.     fetchUrlInfo.pszContentType = "application/vnd.wap.mms-message";
  1741.     fetchUrlInfo.bIsFile = E_TRUE;
  1742.     fetchUrlInfo.uUserDataMode.pmFileName = EncapsulatedContent.pFileName;
  1743.     fetchUrlInfo.uiPostLen = EncapsulatedContent.uiTotalSize;
  1744.     //fetchUrlInfo.pHeadersInfo = NULL;
  1745.     fetchUrlInfo.pHeadersInfo = (COMM_HEADERS *)jdd_MemAlloc(sizeof(COMM_HEADERS), 1); 
  1746.     fetchUrlInfo.pHeadersInfo->pszName = "Accept";
  1747.     fetchUrlInfo.pHeadersInfo->psValue = "*/*";
  1748.     fetchUrlInfo.pHeadersInfo->uiValueSize = 3;
  1749.     fetchUrlInfo.pHeadersInfo->pszCharset = "utf-8";
  1750.     fetchUrlInfo.pHeadersInfo->pNext = NULL;
  1751.     fetchUrlInfo.eCommFetchType = E_COMM_FETCH_POST;
  1752.     if (comm_node->mms_communication_state == E_TYPE_NEW_MMS
  1753.         || comm_node->mms_communication_state == E_TYPE_NEW_JAVA_MMS_SEND)
  1754.     {
  1755.         g_jmms_context->uiReferenceID = 0;
  1756.         eRet = jdi_CommunicationFetchURL(g_jmms_context->hCommHandle, &fetchUrlInfo, &(g_jmms_context->uiReferenceID));
  1757.         if (eRet == JC_OK)
  1758.         {
  1759.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Comm Fetch Resend MMS",
  1760.                                  g_jmms_context->uiReferenceID));
  1761.             eRet = mmi_jmms_update_comm_node(
  1762.                     g_jmms_context,
  1763.                     g_jmms_context->uiReferenceID,
  1764.                     comm_node->uiReferenceID,
  1765.                     retry_counter);
  1766.             if (eRet != JC_OK)
  1767.             {
  1768.                 jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1769.                 g_jmms_context->uiReferenceID = 0;
  1770.                 eRet = JC_ERR_MEMORY_ALLOCATION;
  1771.             }
  1772.         }
  1773.     }
  1774.     else
  1775.     {
  1776.         eRet = jdi_CommunicationFetchURL(g_jmms_context->hCommHandle, &fetchUrlInfo, &(uiReferenceID));
  1777.         if (eRet == JC_OK)
  1778.         {
  1779.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d)", "JMMS Comm Fetch Resend", uiReferenceID));
  1780.             eRet = mmi_jmms_update_comm_node(g_jmms_context, uiReferenceID, comm_node->uiReferenceID, retry_counter);
  1781.             if (eRet != JC_OK)
  1782.             {
  1783.                 jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, uiReferenceID);
  1784.                 eRet = JC_ERR_MEMORY_ALLOCATION;
  1785.             }
  1786.             /* PRINT_INFORMATION_2(( MMI_TRACE_INFO, "%s(%d)","JMMS Comm Node Updated",uiReferenceID)); */
  1787.         }
  1788.     }
  1789.   END:
  1790.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "mmi_jmms_resend_mms Returns with:", eRet));
  1791.     if(fetchUrlInfo.pHeadersInfo != NULL)
  1792.     {
  1793.         jdd_MemFree(fetchUrlInfo.pHeadersInfo);
  1794.     }
  1795.     return eRet;
  1796. }
  1797. /*****************************************************************************
  1798.  * FUNCTION
  1799.  *  mmi_jmms_entry_communication_progress_screen
  1800.  * DESCRIPTION
  1801.  *  
  1802.  * PARAMETERS
  1803.  *  void
  1804.  * RETURNS
  1805.  *  void
  1806.  *****************************************************************************/
  1807. void mmi_jmms_entry_communication_progress_screen(void)
  1808. {
  1809.     /*----------------------------------------------------------------*/
  1810.     /* Local Variables                                                */
  1811.     /*----------------------------------------------------------------*/
  1812.     U32 len = 0;
  1813.     /*----------------------------------------------------------------*/
  1814.     /* Code Body                                                      */
  1815.     /*----------------------------------------------------------------*/
  1816.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_entry_communication_progress_screen"));
  1817.     EntryNewScreen(SCR_ID_JMMS_PROGRESS, NULL, mmi_jmms_entry_communication_progress_screen, NULL);
  1818.     if (g_jmms_context->g_jmms_progress_str[0] == 0x00)
  1819.     {
  1820.         len = pfnUnicodeStrlen((S8*) GetString(STR_ID_JMMS_PLEASE_WAIT));
  1821.         if (len > (MAX_PROGRESS_SCREEN_HINT_LEN - 1))
  1822.         {
  1823.             pfnUnicodeStrncpy(
  1824.                 g_jmms_context->g_jmms_progress_str,
  1825.                 GetString(STR_ID_JMMS_PLEASE_WAIT),
  1826.                 (MAX_PROGRESS_SCREEN_HINT_LEN - 1));
  1827.         }
  1828.         else
  1829.         {
  1830.             pfnUnicodeStrcpy(g_jmms_context->g_jmms_progress_str, GetString(STR_ID_JMMS_PLEASE_WAIT));
  1831.             if ((len + 1) < (MAX_PROGRESS_SCREEN_HINT_LEN))
  1832.             {
  1833.                 pfnUnicodeStrcat(g_jmms_context->g_jmms_progress_str, "n");
  1834.             }
  1835.         }
  1836.     }
  1837.     ShowCategory66Screen(
  1838.         STR_MMS_MENUENTRY,
  1839.         GetRootTitleIcon(MAIN_MENU_MESSAGES_MENUID),
  1840.         0,
  1841.         0,
  1842.         STR_GLOBAL_ABORT,
  1843.         IMG_GLOBAL_BACK,
  1844.         (U8*) (g_jmms_context->g_jmms_progress_str),
  1845.         IMG_GLOBAL_PROGRESS,
  1846.         NULL);
  1847.     ClearAllKeyHandler();
  1848.     SetRightSoftkeyFunction(mmi_jmms_cancel_mms_sending, KEY_EVENT_UP);
  1849.     mmi_jmms_set_end_key_progressing_handler();
  1850. //    SetKeyHandler(mmi_jmms_end_comm, KEY_END, KEY_EVENT_DOWN);
  1851. }
  1852. /*****************************************************************************
  1853.  * FUNCTION
  1854.  *  mmi_jmms_end_comm
  1855.  * DESCRIPTION
  1856.  *  
  1857.  * PARAMETERS
  1858.  *  void
  1859.  * RETURNS
  1860.  *  void
  1861.  *****************************************************************************/
  1862. void mmi_jmms_end_comm(void)
  1863. {
  1864.     /*----------------------------------------------------------------*/
  1865.     /* Local Variables                                                */
  1866.     /*----------------------------------------------------------------*/
  1867.     jmms_communication_state_node *comm_node = NULL;
  1868.     /*----------------------------------------------------------------*/
  1869.     /* Code Body                                                      */
  1870.     /*----------------------------------------------------------------*/
  1871.     /* PMT VIKAS START 20060325 */
  1872.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_end_comm"));
  1873. #if defined (__USB_IN_NORMAL_MODE__)
  1874.     if (mmi_usb_is_in_mass_storage_mode())
  1875.     {
  1876.         mmi_jmms_cancel_comm_in_usb_mode();
  1877.         return;
  1878.     }
  1879. #endif 
  1880.     if (g_jmms_context->uiReferenceID != 0)
  1881.     {
  1882.     //#ifdef __MMI_MMS_SIGNATURE__
  1883.         mmi_jmms_del_inserted_auto_signature_slide();
  1884.     //#endif 
  1885.         /* PMT VIKAS END 20060325 */
  1886.     #ifndef __MMI_UNIFIED_MESSAGE__
  1887. // sandeep start to fix bug number PMT005980
  1888. //        mmi_jmms_deinit_mms_context(g_jmms_context);
  1889. // sandeep end to fix bug number PMT005980
  1890.     #endif 
  1891.         jdi_CommunicationStopReq(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1892.         jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1893.         comm_node = mmi_jmms_get_comm_state(g_jmms_context,  g_jmms_context->uiReferenceID);
  1894.         if(comm_node) /* Vikram : This is required to stop retry incase of user abort*/
  1895.             comm_node->retry_counter = STOP_RETRY_COUNTER;
  1896.         g_jmms_context->uiReferenceID = 0;
  1897. // sandeep start to fix bug number PMT005980
  1898. //    #ifdef __MMI_UNIFIED_MESSAGE__ 
  1899.         if (g_jmms_context->last_scr_id != SCR_ID_JMMS_OUTBOX_OPTIONS)
  1900.         {
  1901.             g_jmms_context->save_mms = MMI_TRUE;
  1902.         }
  1903. //    #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1904. // sandeep start to fix bug number PMT005980
  1905.         g_jmms_context->last_scr_id = IDLE_SCREEN_ID;
  1906.     }
  1907.     /* By Raj Kumar Gupta to enable the End Key on Connecting Screen */
  1908.     else if( GetActiveScreenId() == SCR_ID_JMMS_PROGRESS )
  1909.     {
  1910. //        StopTimer(JMMS_ASYNC_PROCESS_TIMER);
  1911.         mmi_jmms_decrement_send_callback_node(E_COMMUNICATION_ABORTED);
  1912.         
  1913.     }
  1914. }
  1915. /*****************************************************************************
  1916.  * FUNCTION
  1917.  *  mmi_jmms_cancel_comm_in_usb_mode
  1918.  * DESCRIPTION
  1919.  *  
  1920.  * PARAMETERS
  1921.  *  void
  1922.  * RETURNS
  1923.  *  void
  1924.  *****************************************************************************/
  1925. void mmi_jmms_cancel_comm_in_usb_mode(void)
  1926. {
  1927.     /*----------------------------------------------------------------*/
  1928.     /* Local Variables                                                */
  1929.     /*----------------------------------------------------------------*/
  1930.    jmms_communication_state_node *comm_node = NULL;
  1931.     /*----------------------------------------------------------------*/
  1932.     /* Code Body                                                      */
  1933.     /*----------------------------------------------------------------*/
  1934.    PRINT_INFORMATION_2((MMI_TRACE_INFO, "USB Mode: Stop All Comm"));
  1935.    comm_node = g_jmms_context->comm_state;
  1936.    while(comm_node)
  1937.    {
  1938.         if(comm_node->mms_communication_state != E_TYPE_NOTIFICATION_RESPONSE &&
  1939.                 comm_node->mms_communication_state != E_TYPE_READ_REPORT_PDU &&
  1940.                     comm_node->mms_communication_state != E_TYPE_ACK_RESPONSE &&
  1941.                     comm_node->mms_communication_state != E_TYPE_READ_REPORT_MMS)
  1942.         {
  1943.             jdi_CommunicationStopReq(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1944.             mmi_jmms_free_comm_node(g_jmms_context, comm_node->uiReferenceID);
  1945.             comm_node = g_jmms_context->comm_state;
  1946.          }
  1947.          else
  1948.          {
  1949.                comm_node = comm_node->next; 
  1950.          }
  1951.    }
  1952.    mmi_jmms_stop_download_busy();/* Added incase the download blinking is started but the comm node is not added to the list*/
  1953.    mmi_jmms_update_status_icon_indicator();
  1954. }
  1955. /*****************************************************************************
  1956.  * FUNCTION
  1957.  *  mmi_jmms_cancel_mms_sending
  1958.  * DESCRIPTION
  1959.  *  
  1960.  * PARAMETERS
  1961.  *  void
  1962.  * RETURNS
  1963.  *  void
  1964.  *****************************************************************************/
  1965. void mmi_jmms_cancel_mms_sending(void)
  1966. {
  1967.     /*----------------------------------------------------------------*/
  1968.     /* Local Variables                                                */
  1969.     /*----------------------------------------------------------------*/
  1970.     jmms_communication_state_node *comm_node = NULL;
  1971.     /*----------------------------------------------------------------*/
  1972.     /* Code Body                                                      */
  1973.     /*----------------------------------------------------------------*/
  1974.     /* PMT VIKAS START 20060325 */
  1975. //#ifdef __MMI_MMS_SIGNATURE__
  1976.     mmi_jmms_del_inserted_auto_signature_slide();
  1977. //#endif 
  1978.     //PMT VIKAS END 20060325
  1979.     ///abort the communication
  1980.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s (%d)", "mmi_jmms_cancel_mms_sending, Reference id",
  1981.                          g_jmms_context->uiReferenceID));
  1982.     /* Added by - Raj Kumar Gupta on 31 August, 2006 */
  1983.     if( g_jmms_context->uiReferenceID != 0 )
  1984.     {
  1985.         jdi_CommunicationStopReq(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1986.         jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, g_jmms_context->uiReferenceID);
  1987.         comm_node = mmi_jmms_get_comm_state(g_jmms_context,  g_jmms_context->uiReferenceID);
  1988.         if(comm_node) /* Vikram : This is required to stop retry incase of user abort*/
  1989.             comm_node->retry_counter = STOP_RETRY_COUNTER;
  1990.     }
  1991.     else
  1992.     {
  1993.         StopTimer(JMMS_ASYNC_SEND_TIMER);
  1994.         mmi_jmms_decrement_send_callback_node(E_COMMUNICATION_ABORTED);
  1995.         goto END;
  1996.     }
  1997.     g_jmms_context->uiReferenceID = 0;
  1998.     mmi_jmms_update_status_icon_indicator();
  1999. END:
  2000. /*Dilip Start 4 sept 2006*/                 
  2001. #ifdef __MMI_UNIFIED_MESSAGE__
  2002. if(IsScreenPresent(SCR_ID_JMMS_WRITE_MMS))
  2003. {
  2004. DeleteUptoScrID(SCR_ID_JMMS_WRITE_MMS);
  2005. }
  2006.     else if (IsScreenPresent(SCR_ID_UM_UNSENT))
  2007.     {
  2008.         DeleteUptoScrID(SCR_ID_UM_UNSENT);
  2009.     }
  2010.     else if (IsScreenPresent(SCR_ID_UM_DRAFT))
  2011.     {
  2012.         DeleteUptoScrID(SCR_ID_UM_DRAFT);
  2013.     }
  2014.     else if (IsScreenPresent(SCR_ID_UM_INBOX))
  2015.     {
  2016.         DeleteUptoScrID(SCR_ID_UM_INBOX);
  2017.     }
  2018.     else if(IsScreenPresent(SCR_ID_UM_SENT))
  2019.     {
  2020.         DeleteUptoScrID(SCR_ID_UM_SENT);
  2021.     }
  2022. #else
  2023.     return;
  2024. #endif
  2025. /*Dilip End 4 sept 2006*/
  2026. }
  2027. /*****************************************************************************
  2028.  * FUNCTION
  2029.  *  mmi_jmms_get_to_addresses
  2030.  * DESCRIPTION
  2031.  *  
  2032.  * PARAMETERS
  2033.  *  void
  2034.  * RETURNS
  2035.  *  
  2036.  *****************************************************************************/
  2037. S8 *mmi_jmms_get_to_addresses(void)
  2038. {
  2039.     /*----------------------------------------------------------------*/
  2040.     /* Local Variables                                                */
  2041.     /*----------------------------------------------------------------*/
  2042.     U32 len = 0;
  2043.     jmms_address_list *address_node;
  2044.     S8 *pTo = NULL;
  2045.     /*----------------------------------------------------------------*/
  2046.     /* Code Body                                                      */
  2047.     /*----------------------------------------------------------------*/
  2048.     address_node = g_jmms_context->to_address_p;
  2049.     while (address_node != NULL)
  2050.     {
  2051.         len = len + (pfnUnicodeStrlen(address_node->address)) * ENCODING_LENGTH + ENCODING_LENGTH;
  2052.         address_node = address_node->next;
  2053.     }
  2054.     pTo = (S8*) jdd_MemAlloc(sizeof(S8), len);
  2055.     if (NULL == pTo)
  2056.     {
  2057.         return NULL;
  2058.     }
  2059.     address_node = g_jmms_context->to_address_p;
  2060.     while (address_node != NULL)
  2061.     {
  2062.         pfnUnicodeStrcat((S8*) pTo, (const S8*)address_node->address);
  2063.         address_node = address_node->next;
  2064.         if (address_node != NULL)
  2065.         {
  2066.             pfnUnicodeStrcat((S8*) pTo, (const S8*)";");
  2067.         }
  2068.     }
  2069.     return pTo;
  2070. }
  2071. /*****************************************************************************
  2072.  * FUNCTION
  2073.  *  mmi_jmms_get_cc_addresses
  2074.  * DESCRIPTION
  2075.  *  
  2076.  * PARAMETERS
  2077.  *  void
  2078.  * RETURNS
  2079.  *  
  2080.  *****************************************************************************/
  2081. S8 *mmi_jmms_get_cc_addresses(void)
  2082. {
  2083.     /*----------------------------------------------------------------*/
  2084.     /* Local Variables                                                */
  2085.     /*----------------------------------------------------------------*/
  2086.     U32 len = 0;
  2087.     jmms_address_list *address_node;
  2088.     S8 *pCc = NULL;
  2089.     /*----------------------------------------------------------------*/
  2090.     /* Code Body                                                      */
  2091.     /*----------------------------------------------------------------*/
  2092.     address_node = g_jmms_context->cc_address_p;
  2093.     while (address_node != NULL)
  2094.     {
  2095.         len = len + (pfnUnicodeStrlen(address_node->address)) * ENCODING_LENGTH + ENCODING_LENGTH;
  2096.         address_node = address_node->next;
  2097.     }
  2098.     pCc = (S8*) jdd_MemAlloc(sizeof(S8), len);
  2099.     if (NULL == pCc)
  2100.     {
  2101.         return NULL;
  2102.     }
  2103.     address_node = g_jmms_context->cc_address_p;
  2104.     while (address_node != NULL)
  2105.     {
  2106.         pfnUnicodeStrcat((S8*) pCc, (const S8*)address_node->address);
  2107.         address_node = address_node->next;
  2108.         if (address_node != NULL)
  2109.         {
  2110.             pfnUnicodeStrcat((S8*) pCc, (const S8*)";");
  2111.         }
  2112.     }
  2113.     return pCc;
  2114. }
  2115. /*****************************************************************************
  2116.  * FUNCTION
  2117.  *  mmi_jmms_get_bcc_addresses
  2118.  * DESCRIPTION
  2119.  *  
  2120.  * PARAMETERS
  2121.  *  void
  2122.  * RETURNS
  2123.  *  
  2124.  *****************************************************************************/
  2125. S8 *mmi_jmms_get_bcc_addresses(void)
  2126. {
  2127.     /*----------------------------------------------------------------*/
  2128.     /* Local Variables                                                */
  2129.     /*----------------------------------------------------------------*/
  2130.     U32 len = 0;
  2131.     jmms_address_list *address_node;
  2132.     S8 *pBcc = NULL;
  2133.     /*----------------------------------------------------------------*/
  2134.     /* Code Body                                                      */
  2135.     /*----------------------------------------------------------------*/
  2136.     address_node = g_jmms_context->bcc_address_p;
  2137.     while (address_node != NULL)
  2138.     {
  2139.         len = len + (pfnUnicodeStrlen(address_node->address)) * ENCODING_LENGTH + ENCODING_LENGTH;
  2140.         address_node = address_node->next;
  2141.     }
  2142.     pBcc = (S8*) jdd_MemAlloc(sizeof(S8), len);
  2143.     if (NULL == pBcc)
  2144.     {
  2145.         return NULL;
  2146.     }
  2147.     address_node = g_jmms_context->bcc_address_p;
  2148.     while (address_node != NULL)
  2149.     {
  2150.         pfnUnicodeStrcat((S8*) pBcc, (const S8*)address_node->address);
  2151.         address_node = address_node->next;
  2152.         if (address_node != NULL)
  2153.         {
  2154.             pfnUnicodeStrcat((S8*) pBcc, (const S8*)";");
  2155.         }
  2156.     }
  2157.     return pBcc;
  2158. }
  2159. /*****************************************************************************
  2160.  * FUNCTION
  2161.  *  mmi_jmms_check_for_idle_screen
  2162.  * DESCRIPTION
  2163.  *  
  2164.  * PARAMETERS
  2165.  *  void
  2166.  * RETURNS
  2167.  *  void
  2168.  *****************************************************************************/
  2169. void mmi_jmms_check_for_idle_screen(void)
  2170. {
  2171.     /*----------------------------------------------------------------*/
  2172.     /* Local Variables                                                */
  2173.     /*----------------------------------------------------------------*/
  2174.     U16 currScrenID;
  2175.     /*----------------------------------------------------------------*/
  2176.     /* Code Body                                                      */
  2177.     /*----------------------------------------------------------------*/
  2178.     currScrenID = GetActiveScreenId();
  2179.     if (currScrenID == IDLE_SCREEN_ID)
  2180.     {
  2181.         g_jmms_context->store_context->current_folder_name = 0;
  2182.         if (mmi_jmms_need_mms_ind())
  2183.         {
  2184.             TurnOnBacklight(GPIO_BACKLIGHT_SHORT_TIME);
  2185. mmi_jmms_entry_new_mms_ind();
  2186.         }
  2187.     }
  2188. }
  2189. /*****************************************************************************
  2190.  * FUNCTION
  2191.  *  mmi_jmms_show_new_mms_pop_up
  2192.  * DESCRIPTION
  2193.  *  
  2194.  * PARAMETERS
  2195.  *  void
  2196.  * RETURNS
  2197.  *  void
  2198.  *****************************************************************************/
  2199. void mmi_jmms_show_new_mms_pop_up(void)
  2200. {
  2201.     /*----------------------------------------------------------------*/
  2202.     /* Local Variables                                                */
  2203.     /*----------------------------------------------------------------*/
  2204.     U16 currScrenID;
  2205.     /*----------------------------------------------------------------*/
  2206.     /* Code Body                                                      */
  2207.     /*----------------------------------------------------------------*/
  2208.     currScrenID = GetActiveScreenId();
  2209.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_show_new_mms_pop_up"));
  2210. #if defined (__USB_IN_NORMAL_MODE__) && !defined (__MMI_UNIFIED_MESSAGE__)
  2211.     if (mmi_jmms_check_usb_mode() == 0)
  2212. #endif 
  2213.     {
  2214. #if defined (__MMI_UNIFIED_MESSAGE__)
  2215.         if ((currScrenID == IDLE_SCREEN_ID) || (currScrenID == SCR_ID_UM_NEW_MSG_IND)|| (currScrenID == SCR_ID_UM_NEW_MSG_DUMMY_IND))
  2216. #else
  2217.         if (currScrenID == IDLE_SCREEN_ID)
  2218. #endif
  2219.         {
  2220.             if (mmi_jmms_need_mms_ind())
  2221.             {
  2222. TurnOnBacklight(GPIO_BACKLIGHT_SHORT_TIME);
  2223.                 mmi_jmms_entry_new_mms_ind();
  2224.                 PlayMessageArrivalTone();
  2225.             }
  2226.         }
  2227.         else
  2228.         {
  2229.             /* manish as part of bug Fixing */
  2230.             if ((!isInCall()) && (!AlmIsTonePlaying())) /* if no call is there only then show it */
  2231.             {
  2232. TurnOnBacklight(GPIO_BACKLIGHT_SHORT_TIME);
  2233.                 mmi_msg_entry_new_msg_popup(MSG_NEW_JMMS_MMS);
  2234.             }
  2235.             /*Dilip Start 12th sept 2006 to give beep sound when MMS is recievd in call*/
  2236.             else if(isInCall() == MMI_TRUE)
  2237.             {
  2238.                 playRequestedTone(SMS_IN_CALL_TONE);
  2239.             }
  2240.             /*Dilip END 12th sept 2006 to give beep sound when MMS is recievd in call*/
  2241.         }
  2242.     }
  2243. }
  2244. /*****************************************************************************
  2245.  * FUNCTION
  2246.  *  mmi_jmms_retry_communication
  2247.  * DESCRIPTION
  2248.  *  
  2249.  * PARAMETERS
  2250.  *  jmms_context            [?]         [?]         [?]
  2251.  *  calling_function        [IN]        
  2252.  *  uiReferenceID           [IN]        
  2253.  *  error_code              [IN]        
  2254.  * RETURNS
  2255.  *  
  2256.  *****************************************************************************/
  2257. JC_RETCODE mmi_jmms_retry_communication(
  2258.             jmms_context_struct *jmms_context,
  2259.             U16 calling_function,
  2260.             JC_UINT32 uiReferenceID,
  2261.             JC_RETCODE error_code)
  2262. {
  2263.     /*----------------------------------------------------------------*/
  2264.     /* Local Variables                                                */
  2265.     /*----------------------------------------------------------------*/
  2266.     JC_RETCODE eRet = JC_OK;
  2267.     jmms_communication_state_node *comm_node = NULL;
  2268.     /*----------------------------------------------------------------*/
  2269.     /* Code Body                                                      */
  2270.     /*----------------------------------------------------------------*/
  2271.     /* PMT VIKAS START 20060401 */
  2272.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "mmi_jmms_retry_communication, Reference Id:", uiReferenceID));
  2273.     /* PMT VIKAS END 20060401 */
  2274.     comm_node = mmi_jmms_get_comm_state(jmms_context, uiReferenceID);
  2275. /* To avoid crash incase comm_node is NULL*/
  2276.     if (comm_node == NULL)
  2277.     {
  2278.         return E_UNKNOWN_MSG;
  2279.     }
  2280.     if(comm_node->retry_counter == STOP_RETRY_COUNTER)
  2281.         return eRet;
  2282.     switch (comm_node->mms_communication_state)
  2283.     {
  2284.         case E_TYPE_NEW_MMS:
  2285.     #ifdef MMI_JMMS_JAVA_MMS_SUPPORT
  2286.         case E_TYPE_NEW_JAVA_MMS_SEND:
  2287.     #endif 
  2288.             if (comm_node->retry_counter < MAX_MMS_SEND_TRY_COUNTER)
  2289.             {
  2290.                 comm_node->retry_counter++;
  2291.                 eRet = mmi_jmms_resend_mms(comm_node, comm_node->retry_counter);
  2292.                 if (JC_OK != eRet)
  2293.                 {
  2294.                     goto END;
  2295.                 }
  2296.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Resending New MMS Try No",
  2297.                                      comm_node->retry_counter));
  2298.             }
  2299.             else
  2300.             {
  2301.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Resending New MMS Try Complete"));
  2302.                 eRet = E_JMMS_RETRY_COMPLETE;
  2303.                 goto END;
  2304.             }
  2305.             break;
  2306.         case E_TYPE_READ_REPORT_PDU:
  2307.         case E_TYPE_READ_REPORT_MMS:
  2308.             if (comm_node->retry_counter < MAX_MMS_SIGNAL_TRY_COUNTER)
  2309.             {
  2310.                 comm_node->retry_counter++;
  2311.                 eRet = mmi_jmms_resend_mms(comm_node, comm_node->retry_counter);
  2312.                 if (JC_OK != eRet)
  2313.                 {
  2314.                     goto END;
  2315.                 }
  2316.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Resending Read Report Try No",
  2317.                                      comm_node->retry_counter));
  2318.             }
  2319.             else
  2320.             {
  2321.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Resending Read Report Try Complete"));
  2322.                 eRet = E_JMMS_RETRY_COMPLETE;   /* /no try counter left */
  2323.                 goto END;
  2324.             }
  2325.             break;
  2326.         case E_TYPE_ACK_RESPONSE:
  2327.         case E_TYPE_NOTIFICATION_RESPONSE:
  2328.             if (comm_node->retry_counter < MAX_MMS_SIGNAL_TRY_COUNTER)
  2329.             {
  2330.                 comm_node->retry_counter++;
  2331.                 eRet = mmi_jmms_resend_mms(comm_node, comm_node->retry_counter);
  2332.                 if (JC_OK != eRet)
  2333.                 {
  2334.                     goto END;
  2335.                 }
  2336.                 if (comm_node->mms_communication_state == E_TYPE_ACK_RESPONSE)
  2337.                 {
  2338.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Resending ACK Try No",
  2339.                                          comm_node->retry_counter));
  2340.                 }
  2341.                 else
  2342.                 {
  2343.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Resending Notify-Response Try No",
  2344.                                          comm_node->retry_counter));
  2345.                 }
  2346.             }
  2347.             else
  2348.             {
  2349.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Resending ACK Try Complete"));
  2350.                 eRet = E_JMMS_RETRY_COMPLETE;   /* /no try counter left */
  2351.                 goto END;
  2352.             }
  2353.             break;
  2354.         case E_TYPE_IMMEDIATE_RETRIEVAL_FETCH:
  2355.         case E_TYPE_DEFFERED_RETRIEVAL_FETCH:
  2356.             if (comm_node->retry_counter < MAX_MMS_DOWNLOAD_TRY_COUNTER)
  2357.             {
  2358.                 if (comm_node->mms_content_location != NULL)
  2359.                 {
  2360.                     comm_node->retry_counter++;
  2361.                     eRet = mmi_jmms_download_mms(
  2362.                             comm_node->mms_content_location,
  2363.                             comm_node->mms_communication_state,
  2364.                             comm_node->msg_index,
  2365.                             comm_node->retry_counter);
  2366.                     if (JC_OK != eRet)
  2367.                     {
  2368.                         goto END;
  2369.                     }
  2370.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s: %d", "JMMS Redownlaoding MMS Try No:",
  2371.                                          comm_node->retry_counter));
  2372.                 }
  2373.             }
  2374.             else
  2375.             {
  2376.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Redownloading MMS Try Complete"));
  2377.                 eRet = E_JMMS_RETRY_COMPLETE;   /* /no try counter left */
  2378.                 goto END;
  2379.             }
  2380.             break;
  2381.     }   /* /switch(jmms_context->mms_communication_state) */
  2382.     if (eRet == JC_OK)
  2383.     {
  2384.         if (GetActiveScreenId() == SCR_ID_JMMS_PROGRESS)
  2385.         {
  2386.             ChangeTitleString((U8*)GetString(STR_ID_JMMS_RETRY));
  2387.             draw_title();
  2388.             cat66_update_progress_string();
  2389.         }
  2390.     }
  2391.   END:
  2392.     if (eRet != JC_OK)
  2393.     {
  2394.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s %d", "Error in mmi_jmms_retry_communication, Error Code: ", eRet));
  2395.         mmi_jmms_handle_error_in_communication(jmms_context, calling_function, comm_node, error_code);
  2396. /*Vikram: For communication retry, DeleteUptoScrId is not correct as this will delete the CM marker screen or other screen*/
  2397. /*Dilip Start 24 Aug 2006*/                 
  2398. /*
  2399. #ifdef __MMI_UNIFIED_MESSAGE__
  2400.         if (IsScreenPresent(SCR_ID_UM_UNSENT))
  2401.            {
  2402.                 DeleteUptoScrID(SCR_ID_UM_UNSENT);
  2403.             }
  2404.         else if (IsScreenPresent(SCR_ID_UM_DRAFT))
  2405.            {
  2406.               DeleteUptoScrID(SCR_ID_UM_DRAFT);
  2407.            }
  2408.         else if (IsScreenPresent(SCR_ID_UM_INBOX))
  2409.            {
  2410.               DeleteUptoScrID(SCR_ID_UM_INBOX);
  2411.            }
  2412.         else if(IsScreenPresent(SCR_ID_UM_SENT))
  2413.            {
  2414.               DeleteUptoScrID(SCR_ID_UM_SENT);
  2415.            }
  2416. #endif
  2417. */
  2418. /*Dilip End 24 Aug 2006*/
  2419.         mmi_jmms_free_comm_node(jmms_context, comm_node->uiReferenceID);
  2420.     }
  2421.     return eRet;
  2422. }
  2423. /*****************************************************************************
  2424.  * FUNCTION
  2425.  *  mmi_jmms_handle_error_in_communication
  2426.  * DESCRIPTION
  2427.  *  
  2428.  * PARAMETERS
  2429.  *  jmms_context            [?]         [?]         [?]
  2430.  *  calling_function        [IN]        
  2431.  *  comm_node               [?]         [?]         [?]
  2432.  *  error_code              [IN]        
  2433.  * RETURNS
  2434.  *  void
  2435.  *****************************************************************************/
  2436. void mmi_jmms_handle_error_in_communication(
  2437.         jmms_context_struct *jmms_context,
  2438.         U16 calling_function,
  2439.         jmms_communication_state_node *comm_node,
  2440.         JC_RETCODE error_code)
  2441. {
  2442.     /*----------------------------------------------------------------*/
  2443.     /* Local Variables                                                */
  2444.     /*----------------------------------------------------------------*/
  2445.     JC_RETCODE eRet = JC_OK;
  2446.     /*----------------------------------------------------------------*/
  2447.     /* Code Body                                                      */
  2448.     /*----------------------------------------------------------------*/
  2449.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_handle_error_in_communication"));
  2450.     switch (comm_node->mms_communication_state)
  2451.     {
  2452.         case E_TYPE_NEW_MMS:
  2453.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS Communication state: NEW MMS"));
  2454.             if (calling_function == E_FROM_ERROR_CALLBACK)
  2455.             {
  2456.             #ifdef __MMI_UNIFIED_MESSAGE__
  2457.                 if (!IsScreenPresent(SCR_ID_JMMS_OUTBOX_OPTIONS))
  2458.             #else 
  2459.                 if (g_jmms_context->last_scr_id != SCR_ID_JMMS_OUTBOX_OPTIONS)
  2460.             #endif 
  2461.                 {
  2462.                 #ifndef __MMI_UNIFIED_MESSAGE__
  2463.                     if (g_jmms_context->save_mms == MMI_TRUE)
  2464.                     {
  2465.                 #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2466.                         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s",
  2467.                                              "JMMS, MMS not from Outbox, so Sending and storing the MMS in Outbox"));
  2468.                         /********** Raj Kumar Gupta on September 20, 2006 */
  2469.                         if (comm_node->uiReferenceID != 0)
  2470.                         {   
  2471.                             jdi_CommunicationFreeReference(g_jmms_context->hCommHandle, comm_node->uiReferenceID);
  2472.                         }
  2473.                         /********** Raj Kumar Gupta on September 20, 2006 */
  2474.                         eRet = mmi_jmms_send_and_store_mms("Outbox", jmms_context->msg_handle, comm_node);