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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *****************************************************************************/
  10. /*****************************************************************************
  11.  *
  12.  * Filename:
  13.  * ---------
  14.  * mmi_jsr.c
  15.  *
  16.  * Project:
  17.  * --------
  18.  *   MAUI
  19.  *
  20.  * Description:
  21.  * ------------
  22.  *   
  23.  *
  24.  * Author:
  25.  * -------
  26.  * -------
  27.  *
  28.  *============================================================================
  29.  *             HISTORY
  30.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  31.  *------------------------------------------------------------------------------
  32.  * removed!
  33.  * removed!
  34.  * removed!
  35.  *
  36.  * removed!
  37.  * removed!
  38.  * removed!
  39.  *
  40.  * removed!
  41.  * removed!
  42.  * removed!
  43.  *
  44.  * removed!
  45.  * removed!
  46.  * removed!
  47.  *
  48.  * removed!
  49.  * removed!
  50.  * removed!
  51.  *
  52.  *------------------------------------------------------------------------------
  53.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  54.  *============================================================================
  55.  ****************************************************************************/
  56. #ifndef _MMI_JSR_C
  57. #define _MMI_JSR_C
  58. /*  Include: MMI header file */
  59. #include "MMI_features.h"
  60. #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  61. #include "stdC.h"
  62. #include "PixtelDataTypes.h"
  63. #include "Fat_fs.h"
  64. #include "QueueGProt.h"
  65. #include "EventsGprot.h"
  66. #include "ProtocolEvents.h"
  67. #include "DebugInitDef.h"       /* Debug Info */
  68. #include "JsrTypes.h"
  69. #include "JsrProts.h"
  70. #include "JMMSJSRHandler.h"
  71. #include "JMMSGprot.h"
  72. #include "jdd_memapi.h" /* JDD memory allocation functions */
  73. #include "JProfileHandlerTypes.h"
  74. #include "JProfileHandlerProts.h"
  75. #ifdef __MMI_UNIFIED_MESSAGE__
  76. #include "JMMSUMHandling.h"
  77. #endif
  78. #include "Unicodexdcl.h"        /* Unicode transform functions */
  79. #include "UCS2Prot.h"
  80. /***************************************************************************** 
  81. * Define
  82. *****************************************************************************/
  83. /***************************************************************************** 
  84. * Typedef 
  85. *****************************************************************************/
  86. /***************************************************************************** 
  87. * Local Variable
  88. *****************************************************************************/
  89. /***************************************************************************** 
  90. * Local Function
  91. *****************************************************************************/
  92. static JsrResult mmi_jsr_write_folder_status_to_file(U32 no_of_message, JsrMessageInfo *list);
  93. static void mmi_jsr_read_object_list_from_file(void);
  94. static MMI_BOOL mmi_jsr_write_object_list_to_file(void);
  95. static MMI_BOOL mmi_jsr_insert_appid_info_to_list(
  96.                     jsr_appid_msgid_list **appid_object_list,
  97.                     S8 *string,
  98.                     jsr_msg_info *msg_list);
  99. static MMI_BOOL mmi_jsr_remove_appid_info_from_list(jsr_appid_msgid_list **list, S8 *appId);
  100. static MMI_BOOL mmi_jsr_remove_appid_info_from_list_recursive(jsr_appid_msgid_list **list);
  101. static MMI_BOOL mmi_jsr_insert_msg_info_to_list(jsr_msg_info **msg_list, U32 msgId, U8 ischecked);
  102. static MMI_BOOL mmi_jsr_remove_msg_info_from_list(jsr_msg_info **list, U32 msgId);
  103. static MMI_BOOL mmi_jsr_remove_msg_info_from_list_recursive(jsr_msg_info **list);
  104. static U32 mmi_jsr_get_digit_of_integer(U32 msgId);
  105. static U32 mmi_jsr_get_current_size_of_object_list(jsr_appid_msgid_list *appid_object_list, U32 *max_chrs_in_line);
  106. static void mmi_jsr_read_line_from_file(U32 filehandle, S8 *buffer, U32 buf_length, U32 *line_length, S32 *ret);
  107. static MMI_BOOL mmi_jsr_check_appId(S8 *appId);
  108. /*****************************************************************************
  109. * Global Variable
  110. *****************************************************************************/
  111. jsr_context_struct jsr_cntx;
  112. jsr_context_struct *jsr_cntx_p = &jsr_cntx;
  113. jsr_appid_msgid_list *g_jsr_appid_object_list = NULL;
  114. jsr_appid_info_struct *jsr_appid_db[JSR_MAX_APP_ID_NUM];    /* for registered apps */
  115. /*****************************************************************************
  116. * Global Function
  117. *****************************************************************************/
  118. extern int mmi_charset_ucs2_to_utf8_length_in_bytes(const kal_uint8 *raw);
  119. extern kal_int32 mmi_chset_ucs2_to_utf8_string(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
  120. extern void mmi_jmms_reset_mms_downloading_busy(void);
  121. extern void mmi_jmms_update_status_icon_indicator(void);
  122. /*****************************************************************************
  123.  * FUNCTION
  124.  *  JsrCleanContext
  125.  * DESCRIPTION
  126.  *  Clear the JSR context information.
  127.  * PARAMETERS
  128.  *  void
  129.  * RETURNS
  130.  *  void
  131.  *****************************************************************************/
  132. void JsrCleanContext(void)
  133. {
  134.     /*----------------------------------------------------------------*/
  135.     /* Local Variables                                                */
  136.     /*----------------------------------------------------------------*/
  137.     /*----------------------------------------------------------------*/
  138.     /* Code Body                                                      */
  139.     /*----------------------------------------------------------------*/
  140.     if (JSR_CNTX)
  141.     {
  142.         JSR_CNTX->op = 0;
  143.         JSR_CNTX->state = 0;
  144.         JSR_CNTX->msgId = 0;
  145.         JSR_CNTX->curr_media_obj_no = 0;
  146.         JSR_CNTX->total_media_obj_no = 0;
  147.         JSR_CNTX->retrievalMode = 0;
  148.     }
  149. }
  150. /*****************************************************************************
  151.  * FUNCTION
  152.  *  mmi_jsr_init_appid_msgid_list
  153.  * DESCRIPTION
  154.  *  
  155.  * PARAMETERS
  156.  *  void
  157.  * RETURNS
  158.  *  void
  159.  *****************************************************************************/
  160. void mmi_jsr_init_appid_msgid_list(void)
  161. {
  162.     /*----------------------------------------------------------------*/
  163.     /* Local Variables                                                */
  164.     /*----------------------------------------------------------------*/
  165.     /*----------------------------------------------------------------*/
  166.     /* Code Body                                                      */
  167.     /*----------------------------------------------------------------*/
  168.     if (g_jsr_appid_object_list == NULL)
  169.     {
  170.         mmi_jsr_read_object_list_from_file();
  171.     }
  172. }
  173. //Testing Stubs start
  174. //wap_mmc_read_folder_status_req_ind_struct folder_status;
  175. //extern void mmi_jmms_get_msgid_value_from_nvram(void);
  176. //void mmi_jmms_java_mms_set_content_type_params(wap_mmc_recv_appmms_rsp_struct* resp,JC_INT8 *content_type);
  177. //wap_mmc_recv_appmms_rsp_struct recv_struct;
  178. //wap_mmc_delete_msg_req_ind_struct delete_struct;
  179. /* wap_mmc_upload_msg_req_ind_struct upload_struct; */
  180. /*****************************************************************************
  181.  * FUNCTION
  182.  *  mmi_jsr_testing
  183.  * DESCRIPTION
  184.  *  
  185.  * PARAMETERS
  186.  *  void
  187.  * RETURNS
  188.  *  void
  189.  *****************************************************************************/
  190. void mmi_jsr_testing(void)
  191. {
  192.     /*----------------------------------------------------------------*/
  193.     /* Local Variables                                                */
  194.     /*----------------------------------------------------------------*/
  195.     /*----------------------------------------------------------------*/
  196.     /* Code Body                                                      */
  197.     /*----------------------------------------------------------------*/
  198.     //      folder_status.folderId = JSR_DRAFTS;
  199.     //      folder_status.folderId = JSR_TEMPLATES;
  200.     //      folder_status.retrievalMode = JSR_FULL;
  201.     //      mmi_jsr_read_folder_status_req_hldr(&folder_status);
  202.     //      delete_struct.folderId = 0;
  203.     //      delete_struct.msgId = 6;
  204.     //      mmi_jsr_delete_msg_req_hldr(&delete_struct);
  205.     //      pfnUnicodeStrcpy(upload_struct.filePath,"C:\temp.m");
  206.     //      mmi_jsr_upload_msg_req_hldr((void*)&upload_struct);
  207.     //      mmi_jmms_get_msgid_value_from_nvram(); //tested
  208.     //      mmi_jmms_java_mms_set_content_type_params(&recv_struct, "application/vnd.wap.multipart.related; Type=application/smil; Start="<smil-part>"; Application-ID=com.siemens.Messenger; Reply-To-Application-ID=com.siemens.Messenger");//tested
  209. }
  210. /* Testing Stubs end. */
  211. /* AT COMMANDS API */
  212. /*****************************************************************************
  213.  * FUNCTION
  214.  *  mmi_jsr_write_folder_status_to_file
  215.  * DESCRIPTION
  216.  *  Write mms folder status to information file
  217.  * PARAMETERS
  218.  *  no_of_msgs      [IN]        Number of messages
  219.  *  list            [?]         List of messages
  220.  * RETURNS
  221.  *  JsrResult
  222.  *****************************************************************************/
  223. JsrResult mmi_jsr_write_folder_status_to_file(U32 no_of_msgs, JsrMessageInfo *list)
  224. {
  225.     /*----------------------------------------------------------------*/
  226.     /* Local Variables                                                */
  227.     /*----------------------------------------------------------------*/
  228.     U32 msg_no = 0;
  229.     int info_file_size = 0;
  230.     int result = JSR_RESULT_ERROR;
  231.     U32 bytes_written = 0;
  232.     JsrMessageInfo *msgInfo_p = NULL;
  233.     /* for new phone suite */
  234.     JDD_FSHANDLE file_handle = NULL;
  235.     JC_CHAR *pInFilename = NULL;
  236.     S8 buff[20];
  237.     JDD_FILE fh = NULL;
  238.     /*----------------------------------------------------------------*/
  239.     /* Code Body                                                      */
  240.     /*----------------------------------------------------------------*/
  241.     /* for new phone suite */
  242.     if (file_handle == NULL)
  243.     {
  244.         jdd_FSInitialize(&file_handle);
  245.     }
  246.     memset(buff, 0, 20);
  247.     pInFilename = jdd_MemAlloc(sizeof(S8), 100);
  248.     if (NULL == pInFilename)
  249.     {
  250.         result = JSR_RESULT_INSUFFICIENT_MEMORY;
  251.         goto END;
  252.     }
  253.     AnsiiToUnicodeString((S8*) pInFilename, (S8*) (JDD_FS_MMS_SYS_FOLDER));
  254.     AnsiiToUnicodeString((S8*) buff, (S8*) "\");
  255.     pfnUnicodeStrcat((S8*) pInFilename, (S8*) buff);
  256.     AnsiiToUnicodeString((S8*) buff, (S8*) (JSR_INFO));
  257.     pfnUnicodeStrcat((S8*) pInFilename, (S8*) buff);
  258.     jdd_FSDelete(file_handle, (JC_CHAR*) pInFilename);
  259.     if (no_of_msgs == 0)
  260.     {
  261.         result = JSR_RESULT_OK;
  262.         goto END;
  263.     }
  264.     fh = jdd_FSOpen(file_handle, (JC_CHAR*) pInFilename, E_CREATE_WRITE_MODE);
  265.     if (fh == NULL)
  266.     {
  267.         result = JSR_RESULT_FILE_OPERATION_ERROR;
  268.         goto END;
  269.     }
  270.     info_file_size = no_of_msgs * sizeof(JsrMessageInfo);
  271.     msgInfo_p = (JsrMessageInfo*) jdd_MemAlloc(no_of_msgs, sizeof(JsrMessageInfo));
  272.     if (NULL == msgInfo_p)
  273.     {
  274.         result = JSR_RESULT_INSUFFICIENT_MEMORY;
  275.         goto END;
  276.     }
  277.     memset(msgInfo_p, 0, (no_of_msgs * sizeof(JsrMessageInfo)));
  278.     for (msg_no = 0; msg_no < no_of_msgs; msg_no++)
  279.     {
  280.         msgInfo_p[msg_no].msgId = list[msg_no].msgId;
  281.         /* 180406 */
  282.         msgInfo_p[msg_no].offset = list[msg_no].offset;
  283.         msgInfo_p[msg_no].date = list[msg_no].date;
  284.         msgInfo_p[msg_no].size = list[msg_no].size;
  285.         /* msgInfo_p[msg_no].fileType = list[msg_no].fileType; */
  286.         strcpy((S8*) msgInfo_p[msg_no].filename, (S8*) list[msg_no].filename);
  287.         /* write address and subject only when retrieval mode is JSR_FULL */
  288.         if (JSR_CNTX->retrievalMode == JSR_FULL)
  289.         {
  290.             strcpy((S8*) msgInfo_p[msg_no].address, (S8*) list[msg_no].address);
  291.             strcpy((S8*) msgInfo_p[msg_no].subject, (S8*) list[msg_no].subject);
  292.         }
  293.     }
  294.     bytes_written = jdd_FSWrite(msgInfo_p, 1, info_file_size, fh);
  295.     if (bytes_written != info_file_size)
  296.     {
  297.         jdd_FSDelete(file_handle, (JC_CHAR*) pInFilename);
  298.         result = JSR_RESULT_INSUFFICIENT_MEMORY;
  299.         goto END;
  300.     }
  301.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JSR module write folder status to info.db file. n", __FILE__,
  302.                          __LINE__));
  303.     result = JSR_RESULT_OK;
  304.   END:
  305.     if (fh != NULL)
  306.     {
  307.         jdd_FSClose(fh);
  308.     }
  309.     if (file_handle != NULL)
  310.     {
  311.         jdd_FSDeinitialize(file_handle);
  312.         file_handle = NULL;
  313.     }
  314.     if (msgInfo_p != NULL)
  315.     {
  316.         jdd_MemFree(msgInfo_p);
  317.         msgInfo_p = NULL;
  318.     }
  319.     if (pInFilename != NULL)
  320.     {
  321.         jdd_MemFree(pInFilename);
  322.         pInFilename = NULL;
  323.     }
  324.     return result;
  325. }
  326. /*****************************************************************************
  327.  * FUNCTION
  328.  *  mmi_jsr_read_folder_status_req_hldr
  329.  * DESCRIPTION
  330.  *  Create a WAP_MMC_READ_FOLDER_STATUS_REQ_IND primitive to L4
  331.  * PARAMETERS
  332.  *  msg     [?]     Message received from L4
  333.  * RETURNS
  334.  *  void
  335.  *****************************************************************************/
  336. void mmi_jsr_read_folder_status_req_hldr(void *msg)
  337. {
  338.     /*----------------------------------------------------------------*/
  339.     /* Local Variables                                                */
  340.     /*----------------------------------------------------------------*/
  341.     wap_mmc_read_folder_status_req_ind_struct *Message;
  342.     JsrFolderInfo *folderInfo = NULL;
  343.     JsrMessageInfo *message_list = NULL;
  344.     JsrResult result = JSR_RESULT_OK;
  345.     /*----------------------------------------------------------------*/
  346.     /* Code Body                                                      */
  347.     /*----------------------------------------------------------------*/
  348.     Message = (wap_mmc_read_folder_status_req_ind_struct*) msg;
  349.     PRINT_INFORMATION_2((MMI_TRACE_INFO,
  350.                          "%s(%d):  MMI recives a wap_mmc_read_folder_status_req_ind signal, folder:%d and retrieval mode: %d. n",
  351.                          __FILE__, __LINE__, Message->folderId, Message->retrievalMode));
  352. #if defined(MMS_SUPPORT)
  353.     if (E_FALSE == jmms_is_ready())
  354.     {
  355.         mmi_jsr_read_folder_status_output_req_hldr(JSR_RESULT_MMS_NO_READY, NULL);
  356.         return;
  357.     }
  358. #endif
  359.     if (JSR_CNTX->state == JSR_STATE_IDLE)
  360.     {
  361.         if ((Message->folderId == JSR_INBOX)
  362.             || (Message->folderId == JSR_OUTBOX)
  363.             || (Message->folderId == JSR_SENT)
  364.             || (Message->folderId == JSR_DRAFTS) || (Message->folderId == JSR_TEMPLATES))
  365.         {
  366.             if ((Message->retrievalMode == JSR_BASIC) || (Message->retrievalMode == JSR_FULL))
  367.             {
  368.                 JSR_CNTX->state = JSR_STATE_READ_FOLDER;
  369.                 JSR_CNTX->retrievalMode = Message->retrievalMode;
  370.                 folderInfo = (JsrFolderInfo*) jdd_MemAlloc(sizeof(JsrFolderInfo), 1);
  371.                 if (folderInfo == NULL)
  372.                 {
  373.                     ASSERT(0);
  374.                 }
  375.                 memset(folderInfo, 0, sizeof(JsrFolderInfo));
  376.                 /* JMMS function */
  377.                 mmi_jmms_at_get_folder_info(Message->folderId, folderInfo);
  378.                 if (folderInfo->numOfMsg > 0)
  379.                 {
  380.                     message_list = (JsrMessageInfo*) jdd_MemAlloc((folderInfo->numOfMsg), sizeof(JsrMessageInfo));
  381.                     if (message_list == NULL)
  382.                     {
  383.                         ASSERT(0);
  384.                     }
  385.                     memset(message_list, 0, (folderInfo->numOfMsg) * sizeof(JsrMessageInfo));
  386.                 }
  387.                 /* JMMS function */
  388.                 mmi_jmms_at_get_message_list(Message->folderId, message_list);
  389.                 result = mmi_jsr_write_folder_status_to_file((folderInfo->numOfMsg), message_list);
  390.                 if (message_list != NULL)
  391.                 {
  392.                     jdd_MemFree(message_list);
  393.                     message_list = NULL;
  394.                 }
  395.                 /* This block will add the MMS root folder path 
  396.                    and JSR info file path into folderInfo. */
  397.                 {
  398.                     int len = 100;
  399.                     JDD_FSHANDLE filehandle = NULL;
  400.                     S8 *pInFilename = NULL;
  401.                     S8 *pOutFilename = NULL;
  402.                     S8 *info_file_path = NULL;
  403.                     /* for new phone suite */
  404.                     if (filehandle == NULL)
  405.                     {
  406.                         jdd_FSInitialize(&filehandle);
  407.                     }
  408.                     pInFilename = (S8*) jdd_MemAlloc(sizeof(S8), 40);
  409.                     AnsiiToUnicodeString((S8*) pInFilename, (S8*) "@mms");
  410.                     ASSERT(E_TRUE == jdd_FSGetAbsoluteFilePath(filehandle, (JC_CHAR*) pInFilename, (JC_CHAR **) & pOutFilename));
  411.                     if (filehandle != NULL)
  412.                     {
  413.                         jdd_FSDeinitialize(filehandle);
  414.                         filehandle = NULL;
  415.                     }
  416.                     len = UCS2Strlen((S8*) pOutFilename) * ENCODING_LENGTH;
  417.                     if (len <= 100)
  418.                     {
  419.                         memcpy(folderInfo->mmsHomeDirectory, pOutFilename, len);
  420.                     }
  421.                     else
  422.                     {
  423.                         memcpy(folderInfo->mmsHomeDirectory, pOutFilename, 100);
  424.                         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d):  The path of mms home directory  is too long.n",
  425.                                              __FILE__, __LINE__));
  426.                     }
  427.                     len = 0;
  428.                     /* for new phone suite */
  429.                     if (filehandle == NULL)
  430.                     {
  431.                         jdd_FSInitialize(&filehandle);
  432.                     }
  433.                     if(pOutFilename != NULL)
  434.                     {
  435.                         jdd_MemFree(pOutFilename);
  436.                         pOutFilename = NULL;
  437.                     }
  438.                     memset(pInFilename, 0, 40);
  439.                     AnsiiToUnicodeString((S8*) pInFilename, (S8*) JDD_FS_MMS_SYS_FOLDER);
  440.                     ASSERT(E_TRUE == jdd_FSGetAbsoluteFilePath(filehandle, (JC_CHAR*) pInFilename, (JC_CHAR **) & pOutFilename));
  441.                     info_file_path = jdd_MemAlloc(sizeof(S8), (pfnUnicodeStrlen((S8*) pOutFilename) + 9));
  442.                     UnicodeToAnsii((S8*) info_file_path, (S8*) pOutFilename);
  443.                     strcat(info_file_path, "\");
  444.                     strcat(info_file_path, JSR_INFO);
  445.                     if(pOutFilename != NULL)
  446.                     {
  447.                         jdd_MemFree(pOutFilename);
  448.                         pOutFilename = NULL;
  449.                     }
  450.                     
  451.                     pOutFilename = jdd_MemAlloc(((strlen(info_file_path) + 1) * ENCODING_LENGTH), sizeof(S8));
  452.                     AnsiiToUnicodeString((S8*) pOutFilename, (S8*) (info_file_path));
  453.                     if (filehandle != NULL)
  454.                     {
  455.                         jdd_FSDeinitialize(filehandle);
  456.                         filehandle = NULL;
  457.                     }
  458.                     len = UCS2Strlen((S8*) pOutFilename) * ENCODING_LENGTH;
  459.                     if (len <= 100)
  460.                     {
  461.                         memcpy(folderInfo->infoFilePath, pOutFilename, len);
  462.                     }
  463.                     else
  464.                     {
  465.                         memcpy(folderInfo->infoFilePath, pOutFilename, 100);
  466.                         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d):  The path of info.db file is too long.n",
  467.                                              __FILE__, __LINE__));
  468.                     }
  469.                     if (pInFilename != NULL)
  470.                     {
  471.                         jdd_MemFree(pInFilename);
  472.                         pInFilename = NULL;
  473.                     }
  474.                     if (info_file_path != NULL)
  475.                     {
  476.                         jdd_MemFree(info_file_path);
  477.                         info_file_path = NULL;
  478.                     }
  479.                     if (pOutFilename != NULL)
  480.                     {
  481.                         jdd_MemFree(pOutFilename);
  482.                         pOutFilename = NULL;
  483.                     }
  484.                 }
  485.                 mmi_jsr_read_folder_status_output_req_hldr(result, folderInfo);
  486.             }
  487.             else
  488.             {
  489.                 mmi_jsr_read_folder_status_output_req_hldr(JSR_RESULT_INVALID_PARAMETER, NULL);
  490.             }
  491.         }
  492.         else
  493.         {
  494.             mmi_jsr_read_folder_status_output_req_hldr(JSR_RESULT_INVALID_PARAMETER, NULL);
  495.         }
  496.     }
  497.     else
  498.     {
  499.         mmi_jsr_read_folder_status_output_req_hldr(JSR_RESULT_BUSY, NULL);
  500.     }
  501.     if (folderInfo != NULL)
  502.     {
  503.         jdd_MemFree(folderInfo);
  504.     }
  505. }
  506. /*****************************************************************************
  507.  * FUNCTION
  508.  *  mmi_jsr_read_folder_status_output_req_hldr
  509.  * DESCRIPTION
  510.  *  Create a WAP_MMC_READ_FOLDER_STATUS_OUTPUT_REQ primitive to L4
  511.  * PARAMETERS
  512.  *  result          [IN]        
  513.  *  folderInfo      [?]         
  514.  * RETURNS
  515.  *  void
  516.  *****************************************************************************/
  517. void mmi_jsr_read_folder_status_output_req_hldr(JsrResult result, JsrFolderInfo *folderInfo)
  518. {
  519.     /*----------------------------------------------------------------*/
  520.     /* Local Variables                                                */
  521.     /*----------------------------------------------------------------*/
  522.     wap_mmc_read_folder_status_output_req_struct *myMsgPtr;
  523.     ilm_struct *ilm_ptr = NULL;
  524.     /*----------------------------------------------------------------*/
  525.     /* Code Body                                                      */
  526.     /*----------------------------------------------------------------*/
  527.     myMsgPtr = (wap_mmc_read_folder_status_output_req_struct*)
  528.         OslConstructDataPtr(sizeof(wap_mmc_read_folder_status_output_req_struct));
  529.     if (myMsgPtr)
  530.     {
  531.         memset((char*)(myMsgPtr) + 4, 0x00, (sizeof(wap_mmc_read_folder_status_output_req_struct) - 4));
  532.         myMsgPtr->result = (U8) result;
  533.         if (folderInfo)
  534.         {
  535.             myMsgPtr->numOfMsg = folderInfo->numOfMsg;
  536.             myMsgPtr->numOfUnreadMsg = folderInfo->numOfUnreadMsg;
  537.             memset(myMsgPtr->mmsHomeDirectory, 0x00, 100);
  538.             memset(myMsgPtr->infoFilePath, 0x00, 100);
  539.             memcpy(
  540.                 myMsgPtr->mmsHomeDirectory,
  541.                 folderInfo->mmsHomeDirectory,
  542.                 (UCS2Strlen((char*)folderInfo->mmsHomeDirectory) * 2));
  543.             memcpy(
  544.                 myMsgPtr->infoFilePath,
  545.                 folderInfo->infoFilePath,
  546.                 (UCS2Strlen((char*)folderInfo->infoFilePath) * 2));
  547.         }
  548.         ilm_ptr = allocate_ilm(MOD_WAP);
  549.         ilm_ptr->src_mod_id = MOD_WAP;
  550.         ilm_ptr->sap_id = MMI_L4C_SAP;
  551.         ilm_ptr->dest_mod_id = MOD_L4C;
  552.         ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  553.         ilm_ptr->msg_id = MSG_ID_WAP_MMC_READ_FOLDER_STATUS_OUTPUT_REQ;
  554.         ilm_ptr->peer_buff_ptr = NULL;
  555.         msg_send_ext_queue(ilm_ptr);
  556.         if (result != JSR_RESULT_BUSY)
  557.         {
  558.             JsrCleanContext();
  559.         }
  560.         PRINT_INFORMATION_2((MMI_TRACE_INFO,
  561.                              "%s(%d): JSR module returns wap_mmc_read_folder_status_output_req with result: %d, nMsg: %d, and nUnreadMsg: %d n",
  562.                              __FILE__, __LINE__, result, myMsgPtr->numOfMsg, myMsgPtr->numOfUnreadMsg));
  563.     }
  564.     else
  565.     {
  566.         PRINT_INFORMATION_2((MMI_TRACE_INFO,
  567.                              "%s(%d): JSR module can't get memory for wap_mmc_upload_msg_output_req_struct n",
  568.                              __FILE__, __LINE__));
  569.         ASSERT(0);
  570.     }
  571. }
  572. /*****************************************************************************
  573.  * FUNCTION
  574.  *  mmi_jsr_upload_msg_req_hldr
  575.  * DESCRIPTION
  576.  *  Create a MSG_ID_WAP_MMC_UPLOAD_MSG_REQ_IND primitive to L4
  577.  * PARAMETERS
  578.  *  msg     [?]     
  579.  * RETURNS
  580.  *  void
  581.  *****************************************************************************/
  582. void mmi_jsr_upload_msg_req_hldr(void *msg)
  583. {
  584.     /*----------------------------------------------------------------*/
  585.     /* Local Variables                                                */
  586.     /*----------------------------------------------------------------*/
  587.     wap_mmc_upload_msg_req_ind_struct *Message;
  588.     int len = 0;
  589.     char *fname = NULL;
  590.     JsrResult result = JSR_RESULT_OK;
  591.     U32 msgId = 0;
  592.     /*----------------------------------------------------------------*/
  593.     /* Code Body                                                      */
  594.     /*----------------------------------------------------------------*/
  595.     Message = (wap_mmc_upload_msg_req_ind_struct*) msg;
  596. #if defined(MMS_SUPPORT)//DIlip
  597.     if (E_FALSE == jmms_is_ready())
  598.     {
  599.         mmi_jsr_upload_msg_output_req_hldr(JSR_RESULT_MMS_NO_READY, 0);
  600.         return;
  601.     }
  602. #endif
  603.     /* Check the MMS folder for Max messages. */
  604.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d):  MMI recives a wap_mmc_upload_msg_req_ind signal. n", __FILE__,
  605.                          __LINE__));
  606.     if (JSR_CNTX->state == JSR_STATE_IDLE)
  607.     {
  608.         JSR_CNTX->op = JSR_OP_UPLOAD_MSG;
  609.         JSR_CNTX->state = JSR_STATE_UPLOAD_MSG;
  610.         if (Message->filePath)
  611.         {
  612.             len = mmi_charset_ucs2_to_utf8_length_in_bytes(Message->filePath);
  613.             if (len < 100)
  614.             {
  615.                 fname = (S8*) jdd_MemAlloc(sizeof(S8), 100);
  616.                 if (NULL == fname)
  617.                 {
  618.                     mmi_jsr_upload_msg_output_req_hldr(JSR_RESULT_INSUFFICIENT_MEMORY, 0);
  619.                     return;
  620.                 }
  621.                 memset(fname, 0, 100);
  622.                 mmi_chset_ucs2_to_utf8_string((U8*) fname, (len + 1), (U8*) Message->filePath);
  623.                 //JMMS function call
  624.                 result = mmi_jmms_at_save_mms(fname, &msgId);
  625.                 mmi_jsr_upload_msg_output_req_hldr(result, msgId);
  626.                 if (fname != NULL)
  627.                 {
  628.                     jdd_MemFree(fname);
  629.                     fname = NULL;
  630.                 }
  631.             }
  632.             else
  633.             {
  634.                 ASSERT(0);  /* File path too long. */
  635.             }
  636.         }
  637.         else
  638.         {
  639.             mmi_jsr_upload_msg_output_req_hldr(JSR_RESULT_INVALID_PARAMETER, 0);
  640.         }
  641.     }
  642.     else
  643.     {
  644.         mmi_jsr_upload_msg_output_req_hldr(JSR_RESULT_BUSY, 0);
  645.     }
  646. }
  647. /*****************************************************************************
  648.  * FUNCTION
  649.  *  mmi_jsr_upload_msg_output_req_hldr
  650.  * DESCRIPTION
  651.  *  Create a MSG_ID_WAP_MMC_UPLOAD_MSG_OUTPUT_REQ primitive to L4
  652.  * PARAMETERS
  653.  *  result      [IN]        
  654.  *  msgId       [IN]        
  655.  * RETURNS
  656.  *  void
  657.  *****************************************************************************/
  658. void mmi_jsr_upload_msg_output_req_hldr(JsrResult result, U32 msgId)
  659. {
  660.     /*----------------------------------------------------------------*/
  661.     /* Local Variables                                                */
  662.     /*----------------------------------------------------------------*/
  663.     wap_mmc_upload_msg_output_req_struct *myMsgPtr;
  664.     ilm_struct *ilm_ptr = NULL;
  665.     /*----------------------------------------------------------------*/
  666.     /* Code Body                                                      */
  667.     /*----------------------------------------------------------------*/
  668.     myMsgPtr = (wap_mmc_upload_msg_output_req_struct*)
  669.         OslConstructDataPtr(sizeof(wap_mmc_upload_msg_output_req_struct));
  670.     if (myMsgPtr)
  671.     {
  672.         memset((char*)(myMsgPtr) + 4, 0x00, (sizeof(wap_mmc_upload_msg_output_req_struct) - 4));
  673.         myMsgPtr->result = (U8) result;
  674.         myMsgPtr->msgId = msgId;
  675.         ilm_ptr = allocate_ilm(MOD_WAP);
  676.         ilm_ptr->src_mod_id = MOD_WAP;
  677.         ilm_ptr->sap_id = MMI_L4C_SAP;
  678.         ilm_ptr->dest_mod_id = MOD_L4C;
  679.         ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  680.         ilm_ptr->msg_id = MSG_ID_WAP_MMC_UPLOAD_MSG_OUTPUT_REQ;
  681.         ilm_ptr->peer_buff_ptr = NULL;
  682.         msg_send_ext_queue(ilm_ptr);
  683.         if (result != JSR_RESULT_BUSY)
  684.         {
  685.             JsrCleanContext();
  686.             if (result == JSR_RESULT_OK)
  687.             {
  688.                 /* Refresh the MMS folder menu screen. */
  689. #ifdef __MMI_UNIFIED_MESSAGE__
  690. mmi_um_jmms_highlight_mms_message_ind();
  691. #endif
  692.                 mmi_jmms_update_folder();
  693.             }
  694.         }
  695.         PRINT_INFORMATION_2((MMI_TRACE_INFO,
  696.                              "%s(%d): JSR module returns wap_mmc_upload_msg_output_req with result %d and msgid %d n",
  697.                              __FILE__, __LINE__, result, msgId));
  698.     }
  699.     else
  700.     {
  701.         PRINT_INFORMATION_2((MMI_TRACE_INFO,
  702.                              "%s(%d): JSR module can't get memory for wap_mmc_upload_msg_output_req_struct n",
  703.                              __FILE__, __LINE__));
  704.         ASSERT(0);
  705.     }
  706. }
  707. /*****************************************************************************
  708.  * FUNCTION
  709.  *  mmi_jsr_delete_msg_req_hldr
  710.  * DESCRIPTION
  711.  *  Create a MSG_ID_WAP_MMC_DELETE_MSG_REQ_IND primitive to L4
  712.  * PARAMETERS
  713.  *  msg     [?]     
  714.  * RETURNS
  715.  *  void
  716.  *****************************************************************************/
  717. void mmi_jsr_delete_msg_req_hldr(void *msg)
  718. {
  719.     /*----------------------------------------------------------------*/
  720.     /* Local Variables                                                */
  721.     /*----------------------------------------------------------------*/
  722.     wap_mmc_delete_msg_req_ind_struct *Message;
  723.     /*----------------------------------------------------------------*/
  724.     /* Code Body                                                      */
  725.     /*----------------------------------------------------------------*/
  726.     Message = (wap_mmc_delete_msg_req_ind_struct*) msg;
  727.     PRINT_INFORMATION_2((MMI_TRACE_INFO,
  728.                          "%s(%d):  MMI recives a wap_mmc_deldete_msg_req_ind signal from l4c, msgid: %d and folderId: %d n",
  729.                          __FILE__, __LINE__, Message->msgId, Message->folderId));
  730. #if defined(MMS_SUPPORT)/*Dilip*/
  731.     if (E_FALSE == jmms_is_ready())
  732.     {
  733.         mmi_jsr_delete_msg_output_req_hldr(JSR_RESULT_MMS_NO_READY);
  734.         return;
  735.     }
  736. #endif
  737.     if (JSR_CNTX->state == JSR_STATE_IDLE)
  738.     {
  739.         JSR_CNTX->op = JSR_OP_DELETE_MSG;
  740.         JSR_CNTX->state = JSR_STATE_DELETE_MSG;
  741.         if (Message->folderId != 0)
  742.         {
  743.             if ((Message->folderId == JSR_INBOX)
  744.                 || (Message->folderId == JSR_OUTBOX)
  745.                 || (Message->folderId == JSR_SENT) || (Message->folderId == JSR_DRAFTS))
  746.             {
  747.                 /* JMMS function call */
  748.                 mmi_jmms_at_delete_mms(Message->folderId, Message->msgId, mmi_jsr_delete_msg_output_req_hldr);
  749.             }
  750.             else
  751.             {
  752.                 mmi_jsr_delete_msg_output_req_hldr(JSR_RESULT_INVALID_FOLDER);
  753.             }
  754.         }
  755.         else
  756.         {
  757.             //JMMS function call
  758.             // to do check if message is opened or folder is template.
  759.             if (JSR_RESULT_OK == mmi_jmms_java_mms_error(mmi_jmms_is_message_found(JSR_TEMPLATES, Message->msgId)))
  760.             {
  761.                 mmi_jsr_delete_msg_output_req_hldr(JSR_RESULT_ACCESS_DENY);
  762.             }
  763.             else
  764.             {
  765.                 mmi_jmms_at_delete_mms(Message->folderId, Message->msgId, mmi_jsr_delete_msg_output_req_hldr);
  766.             }
  767.         }
  768.     }
  769.     else
  770.     {
  771.         mmi_jsr_delete_msg_output_req_hldr(JSR_RESULT_BUSY);
  772.     }
  773. }
  774. /*****************************************************************************
  775.  * FUNCTION
  776.  *  mmi_jsr_delete_msg_output_req_hldr
  777.  * DESCRIPTION
  778.  *  Create a MSG_ID_WAP_MMC_DELETE_MSG_OUTPUT_REQ primitive to L4
  779.  * PARAMETERS
  780.  *  result      [IN]        
  781.  * RETURNS
  782.  *  void
  783.  *****************************************************************************/
  784. void mmi_jsr_delete_msg_output_req_hldr(JsrResult result)
  785. {
  786.     /*----------------------------------------------------------------*/
  787.     /* Local Variables                                                */
  788.     /*----------------------------------------------------------------*/
  789.     wap_mmc_delete_msg_output_req_struct *myMsgPtr;
  790.     ilm_struct *ilm_ptr = NULL;
  791.     /*----------------------------------------------------------------*/
  792.     /* Code Body                                                      */
  793.     /*----------------------------------------------------------------*/
  794.     myMsgPtr = (wap_mmc_delete_msg_output_req_struct*)
  795.         OslConstructDataPtr(sizeof(wap_mmc_delete_msg_output_req_struct));
  796.     if (myMsgPtr)
  797.     {
  798.         memset((char*)(myMsgPtr) + 4, 0x00, (sizeof(wap_mmc_delete_msg_output_req_struct) - 4));
  799.         myMsgPtr->result = (U8) result;
  800.         ilm_ptr = allocate_ilm(MOD_WAP);
  801.         ilm_ptr->src_mod_id = MOD_WAP;
  802.         ilm_ptr->sap_id = MMI_L4C_SAP;
  803.         ilm_ptr->dest_mod_id = MOD_L4C;
  804.         ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  805.         ilm_ptr->msg_id = MSG_ID_WAP_MMC_DELETE_MSG_OUTPUT_REQ;
  806.         ilm_ptr->peer_buff_ptr = NULL;
  807.         msg_send_ext_queue(ilm_ptr);
  808.         if (result != JSR_RESULT_BUSY)
  809.         {
  810.             JsrCleanContext();
  811.             if (result == JSR_RESULT_OK)
  812.             {
  813.                 /* Refresh the MMS folder menu screen. */
  814.                 mmi_jmms_update_folder();
  815.             }
  816.         }
  817.         PRINT_INFORMATION_2((MMI_TRACE_INFO,
  818.                              "%s(%d): JSR module returns wap_mmc_delete_msg_output_req_struct with result %d n",
  819.                              __FILE__, __LINE__, result));
  820.     }
  821.     else
  822.     {
  823.         PRINT_INFORMATION_2((MMI_TRACE_INFO,
  824.                              "%s(%d): JSR module can't get memory for wap_mmc_delete_msg_output_req_struct n",
  825.                              __FILE__, __LINE__));
  826.         ASSERT(0);
  827.     }
  828. }
  829. /* JSR MESSAGE HANDLER API */
  830. /*****************************************************************************
  831.  * FUNCTION
  832.  *  mmi_jsr_send_appmms_req_hldr
  833.  * DESCRIPTION
  834.  *  Create a MSG_ID_WAP_MMC_SEND_APPMMS_REQ primitive to Java
  835.  * PARAMETERS
  836.  *  msg         [?]         
  837.  *  mod_src     [IN]        
  838.  *  peerBuf     [?]         
  839.  * RETURNS
  840.  *  void
  841.  *****************************************************************************/
  842. void mmi_jsr_send_appmms_req_hldr(void *msg, int mod_src, void *peerBuf)
  843. {
  844.     /*----------------------------------------------------------------*/
  845.     /* Local Variables                                                */
  846.     /*----------------------------------------------------------------*/
  847.     wap_mmc_send_appmms_req_struct *Message;
  848.     U16 buffer_length = 0;
  849.     U8 *pdu = NULL;
  850.     peer_buff_struct *peer_ptr = peerBuf;
  851.     JsrResult result;
  852.     /*----------------------------------------------------------------*/
  853.     /* Code Body                                                      */
  854.     /*----------------------------------------------------------------*/
  855.     Message = (wap_mmc_send_appmms_req_struct*) msg;
  856.     if (JSR_CNTX->state != JSR_STATE_IDLE)
  857.     {
  858.         mmi_jsr_send_appmms_rsp(JSR_RESULT_BUSY);
  859.     }
  860.     else
  861.     {
  862.         JsrCleanContext();
  863.         JSR_CNTX->op = JSR_OP_SEND_MSG;
  864.         JSR_CNTX->state = JSR_STATE_PROCESS_SEND_MSG_HDR;
  865.         JSR_CNTX->total_media_obj_no = Message->bdy_part_no;
  866.         JSR_CNTX->curr_media_obj_no = 0;
  867.         pdu = (U8*) get_pdu_ptr(peer_ptr, &buffer_length);
  868.         //JMMS function call
  869.         result = mmi_jmms_jsr_create_mms(Message, pdu);
  870.         if (result != JSR_RESULT_OK)
  871.         {
  872.             result = JSR_RESULT_ERROR_FAIL_TO_GEN_MMS_HDR;
  873.             mmi_jsr_send_appmms_rsp(result);
  874.         }
  875.         else
  876.         {
  877.             if ((JSR_CNTX->curr_media_obj_no) < (JSR_CNTX->total_media_obj_no))
  878.             {
  879.                 JSR_CNTX->state = JSR_STATE_PROCESS_SEND_MSG_BDY;
  880.                 mmi_jsr_send_post_appmms_msg_part_ind(JSR_RESULT_OK);
  881.             }
  882.             else
  883.             {
  884.                 //JMMS function call
  885.                 mmi_jmms_jsr_send_mms(mmi_jsr_send_appmms_rsp);
  886.             }
  887.         }
  888.     }
  889. }
  890. /*****************************************************************************
  891.  * FUNCTION
  892.  *  mmi_jsr_send_appmms_rsp
  893.  * DESCRIPTION
  894.  *  Create a MSG_ID_WAP_MMC_SEND_APPMMS_RSP primitive to Java
  895.  * PARAMETERS
  896.  *  result      [IN]        
  897.  * RETURNS
  898.  *  void
  899.  *****************************************************************************/
  900. void mmi_jsr_send_appmms_rsp(JsrResult result)
  901. {
  902.     /*----------------------------------------------------------------*/
  903.     /* Local Variables                                                */
  904.     /*----------------------------------------------------------------*/
  905.     wap_mmc_send_appmms_rsp_struct *myMsgPtr;
  906.     ilm_struct *ilm_ptr = NULL;
  907.     /*----------------------------------------------------------------*/
  908.     /* Code Body                                                      */
  909.     /*----------------------------------------------------------------*/
  910.     myMsgPtr = (wap_mmc_send_appmms_rsp_struct*) OslConstructDataPtr(sizeof(wap_mmc_send_appmms_rsp_struct));
  911.     myMsgPtr->result = (U8) result;
  912.     ilm_ptr = allocate_ilm(MOD_WAP);
  913.     ilm_ptr->src_mod_id = MOD_WAP;
  914.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  915.     ilm_ptr->dest_mod_id = MOD_JASYN;
  916.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  917.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_SEND_APPMMS_RSP;
  918.     ilm_ptr->peer_buff_ptr = NULL;
  919.     msg_send_ext_queue(ilm_ptr);
  920.     /* Clean the Jsr Context */
  921.     JsrCleanContext();
  922.     /* PMT HIMANSHU START 20060425 */
  923.     mmi_jmms_reset_mms_downloading_busy();
  924.     mmi_jmms_update_status_icon_indicator();
  925.     /* PMT HIMANSHU END 20060425 */
  926.     mmi_jmms_jsr_delete_temp_media_files();
  927. }
  928. /*****************************************************************************
  929.  * FUNCTION
  930.  *  mmi_jsr_send_post_appmms_msg_part_ind
  931.  * DESCRIPTION
  932.  *  Create a MSG_ID_WAP_MMC_POST_APPMMS_MSG_PART_IND primitive to Java
  933.  * PARAMETERS
  934.  *  result      [IN]        
  935.  * RETURNS
  936.  *  void
  937.  *****************************************************************************/
  938. void mmi_jsr_send_post_appmms_msg_part_ind(JsrResult result)
  939. {
  940.     /*----------------------------------------------------------------*/
  941.     /* Local Variables                                                */
  942.     /*----------------------------------------------------------------*/
  943.     wap_mmc_post_appmms_msg_part_ind_struct *myMsgPtr;
  944.     ilm_struct *ilm_ptr = NULL;
  945.     /*----------------------------------------------------------------*/
  946.     /* Code Body                                                      */
  947.     /*----------------------------------------------------------------*/
  948.     myMsgPtr = (wap_mmc_post_appmms_msg_part_ind_struct*)
  949.         OslConstructDataPtr(sizeof(wap_mmc_post_appmms_msg_part_ind_struct));
  950.     myMsgPtr->result = (U8) result;
  951.     ilm_ptr = allocate_ilm(MOD_WAP);
  952.     ilm_ptr->src_mod_id = MOD_WAP;
  953.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  954.     ilm_ptr->dest_mod_id = MOD_JASYN;
  955.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  956.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_POST_APPMMS_MSG_PART_IND;
  957.     ilm_ptr->peer_buff_ptr = NULL;
  958.     msg_send_ext_queue(ilm_ptr);
  959. }
  960. /*****************************************************************************
  961.  * FUNCTION
  962.  *  mmi_jsr_send_post_appmms_msg_part_rsp
  963.  * DESCRIPTION
  964.  *  Create a MSG_ID_WAP_MMC_POST_APPMMS_MSG_PART_RES primitive to Java
  965.  * PARAMETERS
  966.  *  msg     [?]     
  967.  *  U8 result(?)
  968.  * RETURNS
  969.  *  void
  970.  *****************************************************************************/
  971. void mmi_jsr_send_post_appmms_msg_part_rsp(void *msg)
  972. {
  973.     /*----------------------------------------------------------------*/
  974.     /* Local Variables                                                */
  975.     /*----------------------------------------------------------------*/
  976.     JsrResult result = JSR_RESULT_OK;
  977.     wap_mmc_post_appmms_msg_part_res_struct *Message;
  978.     /*----------------------------------------------------------------*/
  979.     /* Code Body                                                      */
  980.     /*----------------------------------------------------------------*/
  981.     if (JSR_CNTX->state != JSR_STATE_PROCESS_SEND_MSG_BDY)
  982.     {
  983.         mmi_jsr_send_appmms_rsp(JSR_RESULT_ACCESS_DENY);
  984.         return;
  985.     }
  986.     Message = (wap_mmc_post_appmms_msg_part_res_struct*) msg;
  987.     /* add media object to MMS message */
  988.     result = mmi_jmms_jsr_add_media_object(JSR_CNTX->msgId, Message);
  989.     if (result != JSR_RESULT_OK)
  990.     {
  991.         mmi_jsr_send_appmms_rsp(result);
  992.         JsrCleanContext();
  993.         return;
  994.     }
  995.     /* increment current media object by 1 */
  996.     JSR_CNTX->curr_media_obj_no = JSR_CNTX->curr_media_obj_no + 1;
  997.     if ((JSR_CNTX->curr_media_obj_no) < (JSR_CNTX->total_media_obj_no))
  998.     {
  999.         JSR_CNTX->state = JSR_STATE_PROCESS_SEND_MSG_BDY;
  1000.         mmi_jsr_send_post_appmms_msg_part_ind(JSR_RESULT_OK);
  1001.     }
  1002.     else
  1003.     {
  1004.         //JMMS function call
  1005.         mmi_jmms_jsr_send_mms(mmi_jsr_send_appmms_rsp);
  1006.     }
  1007. }
  1008. /*****************************************************************************
  1009.  * FUNCTION
  1010.  *  mmi_jsr_check_recv_mms_for_java
  1011.  * DESCRIPTION
  1012.  *  Check if the message is a java message and send indication to java task.
  1013.  * PARAMETERS
  1014.  *  contentType     [?]         [?]
  1015.  *  msgId(?)        [IN]        
  1016.  *  char* appId(?)(?)
  1017.  * RETURNS
  1018.  *  void
  1019.  *****************************************************************************/
  1020. MMI_BOOL mmi_jsr_check_recv_mms_for_java(S8 *contentType)
  1021. {
  1022.     /*----------------------------------------------------------------*/
  1023.     /* Local Variables                                                */
  1024.     /*----------------------------------------------------------------*/
  1025.     S8 *str_pos = NULL;
  1026.     /*----------------------------------------------------------------*/
  1027.     /* Code Body                                                      */
  1028.     /*----------------------------------------------------------------*/
  1029.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "(%d) Content Type ( %s )", __LINE__, contentType));
  1030. //    if ((contentType == NULL) || ((str_pos = strstr(contentType, "application-id")) == NULL))
  1031.     if ((contentType == NULL) || ((str_pos = mmi_jmms_jsr_get_application_string_from_content_type(contentType, JSR_APPLICATION_ID)) == NULL))
  1032.     {
  1033.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d) Normal MMS", __FILE__, __LINE__));
  1034.         return FALSE;
  1035.     }
  1036.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d) JAVA MMS", __FILE__, __LINE__));
  1037.     return TRUE;
  1038. }
  1039. /*****************************************************************************
  1040.  * FUNCTION
  1041.  *  mmi_jsr_add_recv_java_mms_content
  1042.  * DESCRIPTION
  1043.  *  
  1044.  * PARAMETERS
  1045.  *  msgId           [IN]        
  1046.  *  contentType     [?]         
  1047.  * RETURNS
  1048.  *  
  1049.  *****************************************************************************/
  1050. MMI_BOOL mmi_jsr_add_recv_java_mms_content(U32 msgId, S8 *contentType)
  1051. {
  1052.     /*----------------------------------------------------------------*/
  1053.     /* Local Variables                                                */
  1054.     /*----------------------------------------------------------------*/
  1055.     S8 *str_pos = NULL;
  1056.     S8 *reply_str_pos = NULL;
  1057.     S8 *temp_str = NULL;
  1058.     S8 *appId = NULL;
  1059.     U32 len = 0;
  1060.     /*----------------------------------------------------------------*/
  1061.     /* Code Body                                                      */
  1062.     /*----------------------------------------------------------------*/
  1063. //    if ((contentType == NULL) || ((str_pos = strstr(contentType, "application-id")) == NULL))
  1064.     if ((contentType == NULL) || ((str_pos = mmi_jmms_jsr_get_application_string_from_content_type(contentType, JSR_APPLICATION_ID)) == NULL))
  1065.     {
  1066.         return FALSE;
  1067.     }
  1068.     else
  1069.     {
  1070. //        reply_str_pos = strstr(contentType, "reply-to-application-id");
  1071.         reply_str_pos = mmi_jmms_jsr_get_application_string_from_content_type(contentType, JSR_REPLY_TO_APPLICATION_ID);
  1072. /*        if (reply_str_pos == NULL)
  1073.         {
  1074.             return FALSE;
  1075.         }*/
  1076. /*        if (reply_str_pos < str_pos)*/
  1077.         if((reply_str_pos != NULL) && (reply_str_pos < str_pos))
  1078.         {
  1079. //            str_pos = strstr(str_pos + 1, "application-id");
  1080.             str_pos = mmi_jmms_jsr_get_application_string_from_content_type(str_pos + 1, JSR_APPLICATION_ID);
  1081.             if (str_pos == NULL)
  1082.             {
  1083.                 return FALSE;
  1084.             }
  1085.         }
  1086.         temp_str = str_pos;
  1087.         str_pos = strstr(temp_str, "=");
  1088.         temp_str = str_pos + 1;
  1089.         str_pos = strstr(temp_str, ";");
  1090.         if (str_pos != NULL)
  1091.         {
  1092.             len = strlen(temp_str) - strlen(str_pos);
  1093.         }
  1094.         else
  1095.         {
  1096.             len = strlen(temp_str);
  1097.         }
  1098.         appId = jdd_MemAlloc(sizeof(S8), (len + 1));
  1099.         memcpy(appId, temp_str, len);
  1100.         mmi_jsr_insert_msgId_to_appId_list(msgId, appId, FALSE);
  1101.         if (TRUE == mmi_jsr_check_appId(appId))
  1102.         {
  1103.             mmi_jsr_send_appmms_new_mms_ind(appId, (U32) strlen((S8*) appId));
  1104.         }
  1105.         jdd_MemFree(appId);
  1106.         return TRUE;
  1107.     }
  1108. }
  1109. /*****************************************************************************
  1110.  * FUNCTION
  1111.  *  mmi_jsr_send_appmms_new_mms_ind
  1112.  * DESCRIPTION
  1113.  *  Create a MSG_ID_WAP_MMC_APPMMS_NEW_MMS_IND primitive to Java
  1114.  * PARAMETERS
  1115.  *  appId       [?]         
  1116.  *  length      [IN]        
  1117.  * RETURNS
  1118.  *  void
  1119.  *****************************************************************************/
  1120. void mmi_jsr_send_appmms_new_mms_ind(char *appId, U32 length)
  1121. {
  1122.     /*----------------------------------------------------------------*/
  1123.     /* Local Variables                                                */
  1124.     /*----------------------------------------------------------------*/
  1125.     wap_mmc_appmms_new_mms_ind_struct *myMsgPtr;
  1126.     ilm_struct *ilm_ptr = NULL;
  1127.     /*----------------------------------------------------------------*/
  1128.     /* Code Body                                                      */
  1129.     /*----------------------------------------------------------------*/
  1130.     myMsgPtr = (wap_mmc_appmms_new_mms_ind_struct*) OslConstructDataPtr(sizeof(wap_mmc_appmms_new_mms_ind_struct));
  1131.     memcpy(myMsgPtr->app_id, appId, length);
  1132.     myMsgPtr->app_id_len = length;
  1133.     ilm_ptr = allocate_ilm(MOD_WAP);
  1134.     ilm_ptr->src_mod_id = MOD_WAP;
  1135.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  1136.     ilm_ptr->dest_mod_id = MOD_JASYN;
  1137.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1138.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_APPMMS_NEW_MMS_IND;
  1139.     ilm_ptr->peer_buff_ptr = NULL;
  1140.     msg_send_ext_queue(ilm_ptr);
  1141. }
  1142. /*****************************************************************************
  1143.  * FUNCTION
  1144.  *  mmi_jsr_insert_msgId_to_appId_list
  1145.  * DESCRIPTION
  1146.  *  Insert the message information in application object list.
  1147.  * PARAMETERS
  1148.  *  msgId           [IN]        
  1149.  *  appId           [?]         
  1150.  *  is_checked      [IN]        
  1151.  * RETURNS
  1152.  *  MMI_BOOL result
  1153.  *****************************************************************************/
  1154. MMI_BOOL mmi_jsr_insert_msgId_to_appId_list(U32 msgId, char *appId, BOOL is_checked)
  1155. {
  1156.     /*----------------------------------------------------------------*/
  1157.     /* Local Variables                                                */
  1158.     /*----------------------------------------------------------------*/
  1159.     jsr_appid_msgid_list *appid_list = NULL;
  1160.     jsr_msg_info *msg_list = NULL;
  1161.     MMI_BOOL result = FALSE;
  1162.     /*----------------------------------------------------------------*/
  1163.     /* Code Body                                                      */
  1164.     /*----------------------------------------------------------------*/
  1165.     if (g_jsr_appid_object_list == NULL)
  1166.     {
  1167.         mmi_jsr_read_object_list_from_file();
  1168.     }
  1169.     appid_list = g_jsr_appid_object_list;
  1170.     while (appid_list)
  1171.     {
  1172.         if ((appid_list->appId) && (strcmp((S8*) appid_list->appId, (S8*) appId) == 0))
  1173.         {
  1174.             result = mmi_jsr_insert_msg_info_to_list(&(appid_list->msgs), msgId, is_checked);
  1175.             break;
  1176.         }
  1177.         appid_list = appid_list->next;
  1178.     }
  1179.     if (appid_list == NULL)
  1180.     {
  1181.         if (mmi_jsr_insert_msg_info_to_list(&msg_list, msgId, is_checked))
  1182.         {
  1183.             result = mmi_jsr_insert_appid_info_to_list(&appid_list, appId, msg_list);
  1184.             g_jsr_appid_object_list = appid_list;
  1185.         }
  1186.     }
  1187.     if (result == TRUE)
  1188.     {
  1189.         mmi_jsr_write_object_list_to_file();
  1190.     }
  1191.     return result;
  1192. }
  1193. /*****************************************************************************
  1194.  * FUNCTION
  1195.  *  mmi_jsr_remove_msgId_from_appId_list
  1196.  * DESCRIPTION
  1197.  *  Delete the message information from application object list.
  1198.  * PARAMETERS
  1199.  *  msgId       [IN]        
  1200.  * RETURNS
  1201.  *  MMI_BOOL result
  1202.  *****************************************************************************/
  1203. MMI_BOOL mmi_jsr_remove_msgId_from_appId_list(U32 msgId)
  1204. {
  1205.     /*----------------------------------------------------------------*/
  1206.     /* Local Variables                                                */
  1207.     /*----------------------------------------------------------------*/
  1208.     jsr_appid_msgid_list *appid_list = NULL;
  1209.     /*----------------------------------------------------------------*/
  1210.     /* Code Body                                                      */
  1211.     /*----------------------------------------------------------------*/
  1212.     if (g_jsr_appid_object_list == NULL)
  1213.     {
  1214.         mmi_jsr_read_object_list_from_file();
  1215.     }
  1216.     appid_list = g_jsr_appid_object_list;
  1217.     while (appid_list)
  1218.     {
  1219.         if (appid_list->msgs)
  1220.         {
  1221.             jsr_msg_info *msg_list = appid_list->msgs;
  1222.             while (msg_list)
  1223.             {
  1224.                 if (msg_list->msgId == msgId)
  1225.                 {
  1226.                     mmi_jsr_remove_msg_info_from_list(&(appid_list->msgs), msgId);
  1227.                     if (appid_list->msgs == NULL)
  1228.                     {
  1229.                         mmi_jsr_remove_appid_info_from_list(&g_jsr_appid_object_list, appid_list->appId);
  1230.                     }
  1231.                     mmi_jsr_write_object_list_to_file();
  1232.                     return TRUE;
  1233.                 }
  1234.                 msg_list = msg_list->next;
  1235.             }
  1236.         }
  1237.         appid_list = appid_list->next;
  1238.     }
  1239.     return FALSE;
  1240. }
  1241. /*****************************************************************************
  1242.  * FUNCTION
  1243.  *  mmi_jsr_receive_appmms_req_hldr
  1244.  * DESCRIPTION
  1245.  *  Create a MSG_ID_WAP_MMC_RECV_APPMMS_REQ primitive to Java
  1246.  * PARAMETERS
  1247.  *  msg     [?]     
  1248.  * RETURNS
  1249.  *  void
  1250.  *****************************************************************************/
  1251. void mmi_jsr_receive_appmms_req_hldr(void *msg)
  1252. {
  1253.     /*----------------------------------------------------------------*/
  1254.     /* Local Variables                                                */
  1255.     /*----------------------------------------------------------------*/
  1256.     wap_mmc_recv_appmms_req_struct *Message = NULL;
  1257.     wap_mmc_recv_appmms_rsp_struct response;
  1258.     jsr_appid_msgid_list *appid_list = NULL;
  1259.     S8 *appId = NULL;
  1260.     U32 msgId = 0;
  1261.     /*----------------------------------------------------------------*/
  1262.     /* Code Body                                                      */
  1263.     /*----------------------------------------------------------------*/
  1264.     if (JSR_CNTX->state != JSR_STATE_IDLE)
  1265.     {
  1266.         memset(&response, 0, sizeof(wap_mmc_recv_appmms_rsp_struct));
  1267.         response.result = JSR_RESULT_BUSY;
  1268.         mmi_jsr_receive_appmms_rsp(&response, NULL, 0);
  1269.         return;
  1270.     }
  1271.     Message = (wap_mmc_recv_appmms_req_struct*) msg;
  1272.     *(Message->app_id + Message->app_id_len) = '';
  1273.     appId = (S8*) Message->app_id;
  1274.     JSR_CNTX->op = JSR_OP_RECV_MSG;
  1275.     JSR_CNTX->state = JSR_STATE_RECV_MSG_HDR;
  1276.     if (appId == NULL)
  1277.     {
  1278.         response.result = JSR_RESULT_INVALID_PARAMETER;
  1279.         mmi_jsr_receive_appmms_rsp(&response, NULL, 0);
  1280.         JsrCleanContext();
  1281.         return;
  1282.     }
  1283.     else if (g_jsr_appid_object_list == NULL)
  1284.     {
  1285.         mmi_jsr_read_object_list_from_file();
  1286.     }
  1287.     appid_list = g_jsr_appid_object_list;
  1288.     while (appid_list)
  1289.     {
  1290.         if ((appid_list->appId) && (strcmp((S8*) appid_list->appId, (S8*) appId) == 0))
  1291.         {
  1292.             ASSERT(appid_list->msgs);
  1293.             msgId = appid_list->msgs->msgId;
  1294.             if (JSR_RESULT_OK != mmi_jmms_java_mms_error(mmi_jmms_is_message_found(JSR_INBOX, msgId)))
  1295.             {
  1296.                 mmi_jsr_remove_msgId_from_appId_list(msgId);
  1297.                 response.result = JSR_RESULT_ERROR_MSG_CORRUPTED;
  1298.                 mmi_jsr_receive_appmms_rsp(&response, NULL, 0);
  1299.                 JsrCleanContext();
  1300.                 return;
  1301.             }
  1302.             JSR_CNTX->msgId = msgId;
  1303.             mmi_jmms_jsr_get_message_details(msgId, mmi_jsr_receive_appmms_post_req_hldr);
  1304.             return;
  1305.         }
  1306.         appid_list = appid_list->next;
  1307.     }
  1308.     response.result = JSR_RESULT_NO_MSG_FOR_JAVA;
  1309.     mmi_jsr_receive_appmms_rsp(&response, NULL, 0);
  1310.     JsrCleanContext();
  1311.     return;
  1312. }
  1313. /*****************************************************************************
  1314.  * FUNCTION
  1315.  *  mmi_jsr_receive_appmms_post_req_hldr
  1316.  * DESCRIPTION
  1317.  *  
  1318.  * PARAMETERS
  1319.  *  resp            [?]         
  1320.  *  buffer          [?]         
  1321.  *  buffer_size     [IN]        
  1322.  * RETURNS
  1323.  *  void
  1324.  *****************************************************************************/
  1325. void mmi_jsr_receive_appmms_post_req_hldr(void *resp, S8 *buffer, U16 buffer_size)
  1326. {
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Local Variables                                                */
  1329.     /*----------------------------------------------------------------*/
  1330.     wap_mmc_recv_appmms_rsp_struct *response = NULL;
  1331.     /*----------------------------------------------------------------*/
  1332.     /* Code Body                                                      */
  1333.     /*----------------------------------------------------------------*/
  1334.     response = (wap_mmc_recv_appmms_rsp_struct*) resp;
  1335.     response->result = JSR_RESULT_OK;
  1336.     mmi_jsr_receive_appmms_rsp(response, buffer, buffer_size);
  1337.     if (response->bdy_part_no != 0)
  1338.     {
  1339.         JSR_CNTX->total_media_obj_no = response->bdy_part_no;
  1340.         JSR_CNTX->curr_media_obj_no = 1;
  1341.         JSR_CNTX->state = JSR_STATE_RECV_MSG_BDY;
  1342.     }
  1343.     else
  1344.     {
  1345.         mmi_jsr_remove_msgId_from_appId_list(JSR_CNTX->msgId);
  1346.         mmi_jmms_jsr_delete_msg(JSR_CNTX->msgId);
  1347.         JsrCleanContext();
  1348.         mmi_jmms_update_folder();
  1349.     }
  1350.     if (response != NULL)
  1351.     {
  1352.         jdd_MemFree(response);
  1353.         response = NULL;
  1354.     }
  1355.     if (buffer != NULL)
  1356.     {
  1357.         jdd_MemFree(buffer);
  1358.         buffer = NULL;
  1359.     }
  1360. }
  1361. /*****************************************************************************
  1362.  * FUNCTION
  1363.  *  mmi_jsr_receive_appmms_rsp
  1364.  * DESCRIPTION
  1365.  *  Create a MSG_ID_WAP_MMC_RECV_APPMMS_RSP primitive to Java
  1366.  * PARAMETERS
  1367.  *  response_struct     [?]         
  1368.  *  buffer              [?]         
  1369.  *  buffer_size         [IN]        
  1370.  * RETURNS
  1371.  *  void
  1372.  *****************************************************************************/
  1373. void mmi_jsr_receive_appmms_rsp(wap_mmc_recv_appmms_rsp_struct *response_struct, S8 *buffer, U16 buffer_size)
  1374. {
  1375.     /*----------------------------------------------------------------*/
  1376.     /* Local Variables                                                */
  1377.     /*----------------------------------------------------------------*/
  1378.     wap_mmc_recv_appmms_rsp_struct *myMsgPtr = NULL;
  1379.     ilm_struct *ilm_ptr = NULL;
  1380.     peer_buff_struct *peer_buff_ptr = NULL;
  1381.     U16 peer_pdu_len = 0;
  1382.     U8 *peer_pdu = NULL;
  1383.     /*----------------------------------------------------------------*/
  1384.     /* Code Body                                                      */
  1385.     /*----------------------------------------------------------------*/
  1386.     myMsgPtr = (wap_mmc_recv_appmms_rsp_struct*) OslConstructDataPtr(sizeof(wap_mmc_recv_appmms_rsp_struct));
  1387.     memset((S8*)(myMsgPtr) + 4, 0, (sizeof(wap_mmc_recv_appmms_rsp_struct) - 4));
  1388.     myMsgPtr->result = response_struct->result;
  1389.     myMsgPtr->priority = response_struct->priority;
  1390.     myMsgPtr->date = response_struct->date;
  1391.     myMsgPtr->from_addr_no = response_struct->from_addr_no;
  1392.     myMsgPtr->to_addr_no = response_struct->to_addr_no;
  1393.     myMsgPtr->cc_addr_no = response_struct->cc_addr_no;
  1394.     myMsgPtr->bdy_part_no = response_struct->bdy_part_no;
  1395.     myMsgPtr->start_cnt_id_len = response_struct->start_cnt_id_len;
  1396.     memset(myMsgPtr->start_cnt_id, 0, 100);
  1397.     memcpy(myMsgPtr->start_cnt_id, response_struct->start_cnt_id, 100);
  1398.     myMsgPtr->reply_app_id_len = response_struct->reply_app_id_len;
  1399.     memset(myMsgPtr->reply_app_id, 0, 100);
  1400.     memcpy(myMsgPtr->reply_app_id, response_struct->reply_app_id, 100);
  1401.     if (buffer)
  1402.     {
  1403.         peer_buff_ptr = (peer_buff_struct*) construct_peer_buff(buffer_size, 0, 0, TD_CTRL);
  1404.         peer_pdu = (U8*) get_pdu_ptr(peer_buff_ptr, &peer_pdu_len);
  1405.         if (peer_pdu)
  1406.         {
  1407.             memcpy(peer_pdu, buffer, buffer_size);
  1408.         }
  1409.     }
  1410.     ilm_ptr = allocate_ilm(MOD_WAP);
  1411.     ilm_ptr->src_mod_id = MOD_WAP;
  1412.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  1413.     ilm_ptr->dest_mod_id = MOD_JASYN;
  1414.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1415.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_RECV_APPMMS_RSP;
  1416.     ilm_ptr->peer_buff_ptr = (peer_buff_struct*) peer_buff_ptr;
  1417.     msg_send_ext_queue(ilm_ptr);
  1418. }
  1419. /*****************************************************************************
  1420.  * FUNCTION
  1421.  *  mmi_jsr_read_appmms_msg_part_req
  1422.  * DESCRIPTION
  1423.  *  Create a MSG_ID_WAP_MMC_READ_APPMMS_MSG_PART_REQ primitive to Java
  1424.  * PARAMETERS
  1425.  *  void
  1426.  * RETURNS
  1427.  *  void
  1428.  *****************************************************************************/
  1429. void mmi_jsr_read_appmms_msg_part_req(void)
  1430. {
  1431.     /*----------------------------------------------------------------*/
  1432.     /* Local Variables                                                */
  1433.     /*----------------------------------------------------------------*/
  1434.     wap_mmc_read_appmms_msg_part_rsp_struct response;
  1435.     /*----------------------------------------------------------------*/
  1436.     /* Code Body                                                      */
  1437.     /*----------------------------------------------------------------*/
  1438.     if (JSR_CNTX->state != JSR_STATE_RECV_MSG_BDY)
  1439.     {
  1440.         memset(&response, 0, sizeof(wap_mmc_read_appmms_msg_part_rsp_struct));
  1441.         response.result = JSR_RESULT_ACCESS_DENY;
  1442.         mmi_jsr_read_appmms_msg_part_rsp(&response);
  1443.     }
  1444.     else
  1445.     {
  1446.         if (mmi_jmms_jsr_generate_recv_msg_body_part(
  1447.                 JSR_CNTX->msgId,
  1448.                 &(JSR_CNTX->curr_media_obj_no),
  1449.                 (JSR_CNTX->total_media_obj_no),
  1450.                 &response))
  1451.         {
  1452.             mmi_jsr_read_appmms_msg_part_rsp(&response);
  1453.             JSR_CNTX->curr_media_obj_no = JSR_CNTX->curr_media_obj_no + 1;
  1454.             if (JSR_CNTX->curr_media_obj_no > JSR_CNTX->total_media_obj_no)
  1455.             {
  1456.                 mmi_jsr_remove_msgId_from_appId_list(JSR_CNTX->msgId);
  1457.                 mmi_jmms_jsr_delete_msg(JSR_CNTX->msgId);
  1458.                 JsrCleanContext();
  1459.                 mmi_jmms_update_folder();
  1460.             }
  1461.         }
  1462.         else
  1463.         {
  1464.             memset(&response, 0, sizeof(wap_mmc_read_appmms_msg_part_rsp_struct));
  1465.             response.result = JSR_RESULT_INSUFFICIENT_PERSISTENT_STORAGE;
  1466.             mmi_jsr_read_appmms_msg_part_rsp(&response);
  1467.             JsrCleanContext();
  1468.         }
  1469.     }
  1470. }
  1471. /*****************************************************************************
  1472.  * FUNCTION
  1473.  *  mmi_jsr_read_appmms_msg_part_rsp
  1474.  * DESCRIPTION
  1475.  *  Create a MSG_ID_WAP_MMC_READ_APPMMS_MSG_PART_RSP primitive to Java
  1476.  * PARAMETERS
  1477.  *  response        [?]     
  1478.  * RETURNS
  1479.  *  void
  1480.  *****************************************************************************/
  1481. void mmi_jsr_read_appmms_msg_part_rsp(wap_mmc_read_appmms_msg_part_rsp_struct *response)
  1482. {
  1483.     /*----------------------------------------------------------------*/
  1484.     /* Local Variables                                                */
  1485.     /*----------------------------------------------------------------*/
  1486.     wap_mmc_read_appmms_msg_part_rsp_struct *myMsgPtr;
  1487.     ilm_struct *ilm_ptr = NULL;
  1488.     /*----------------------------------------------------------------*/
  1489.     /* Code Body                                                      */
  1490.     /*----------------------------------------------------------------*/
  1491.     myMsgPtr = (wap_mmc_read_appmms_msg_part_rsp_struct*)
  1492.         OslConstructDataPtr(sizeof(wap_mmc_read_appmms_msg_part_rsp_struct));
  1493.     myMsgPtr->result = response->result;
  1494.     myMsgPtr->encoding_scheme = response->encoding_scheme;
  1495.     /* Content-Type */
  1496.     myMsgPtr->content_type_value = response->content_type_value;
  1497.     myMsgPtr->content_type_len = response->content_type_len;
  1498.     memcpy(myMsgPtr->content_type, response->content_type, 100);
  1499.     /* Content-Id */
  1500.     myMsgPtr->content_id_len = response->content_id_len;
  1501.     memcpy(myMsgPtr->content_id, response->content_id, 100);
  1502.     /* Content-Location */
  1503.     myMsgPtr->content_location_len = response->content_location_len;
  1504.     memcpy(myMsgPtr->content_location, response->content_location, 100);
  1505.     /* Media object filepath */
  1506.     myMsgPtr->filepath_len = response->filepath_len;
  1507.     memcpy(myMsgPtr->filepath, response->filepath, 200);
  1508.     ilm_ptr = allocate_ilm(MOD_WAP);
  1509.     ilm_ptr->src_mod_id = MOD_WAP;
  1510.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  1511.     ilm_ptr->dest_mod_id = MOD_JASYN;
  1512.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1513.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_READ_APPMMS_MSG_PART_RSP;
  1514.     ilm_ptr->peer_buff_ptr = NULL;
  1515.     msg_send_ext_queue(ilm_ptr);
  1516. }
  1517. /*****************************************************************************
  1518.  * FUNCTION
  1519.  *  mmi_jsr_cfg_appmms_appid_req
  1520.  * DESCRIPTION
  1521.  *  Create a MSG_ID_WAP_MMC_CFG_APPMMS_APPID_REQ primitive to Java
  1522.  * PARAMETERS
  1523.  *  msg     [?]     
  1524.  * RETURNS
  1525.  *  void
  1526.  *****************************************************************************/
  1527. void mmi_jsr_cfg_appmms_appid_req(void *msg)
  1528. {
  1529.     /*----------------------------------------------------------------*/
  1530.     /* Local Variables                                                */
  1531.     /*----------------------------------------------------------------*/
  1532.     wap_mmc_cfg_appmms_appid_req_struct *Message;
  1533.     JsrResult result;
  1534.     /*----------------------------------------------------------------*/
  1535.     /* Code Body                                                      */
  1536.     /*----------------------------------------------------------------*/
  1537.     Message = (wap_mmc_cfg_appmms_appid_req_struct*) msg;
  1538.     result = mmi_jsr_cfg_app_id(Message->app_id, Message->app_id_len, Message->op);
  1539.     mmi_jsr_cfg_appmms_appid_rsp(result);
  1540. }
  1541. /*****************************************************************************
  1542.  * FUNCTION
  1543.  *  mmi_jsr_cfg_appmms_appid_rsp
  1544.  * DESCRIPTION
  1545.  *  Create a MSG_ID_WAP_MMC_CFG_APPMMS_APPID_RSP primitive to Java
  1546.  * PARAMETERS
  1547.  *  result      [IN]        
  1548.  * RETURNS
  1549.  *  void
  1550.  *****************************************************************************/
  1551. void mmi_jsr_cfg_appmms_appid_rsp(JsrResult result)
  1552. {
  1553.     /*----------------------------------------------------------------*/
  1554.     /* Local Variables                                                */
  1555.     /*----------------------------------------------------------------*/
  1556.     wap_mmc_cfg_appmms_appid_rsp_struct *myMsgPtr;
  1557.     ilm_struct *ilm_ptr = NULL;
  1558.     /*----------------------------------------------------------------*/
  1559.     /* Code Body                                                      */
  1560.     /*----------------------------------------------------------------*/
  1561.     myMsgPtr = (wap_mmc_cfg_appmms_appid_rsp_struct*) OslConstructDataPtr(sizeof(wap_mmc_cfg_appmms_appid_rsp_struct));
  1562.     myMsgPtr->result = (U8) result;
  1563.     ilm_ptr = allocate_ilm(MOD_WAP);
  1564.     ilm_ptr->src_mod_id = MOD_WAP;
  1565.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  1566.     ilm_ptr->dest_mod_id = MOD_JASYN;
  1567.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1568.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_CFG_APPMMS_APPID_RSP;
  1569.     ilm_ptr->peer_buff_ptr = NULL;
  1570.     msg_send_ext_queue(ilm_ptr);
  1571. }
  1572. /*****************************************************************************
  1573.  * FUNCTION
  1574.  *  mmi_jsr_cfg_app_id
  1575.  * DESCRIPTION
  1576.  *  Register/Deregister the Java application
  1577.  * PARAMETERS
  1578.  *  app_id              [?]         
  1579.  *  app_id_length       [IN]        
  1580.  *  is_remove           [IN]        
  1581.  * RETURNS
  1582.  *  void
  1583.  *****************************************************************************/
  1584. JsrResult mmi_jsr_cfg_app_id(U8 *app_id, U8 app_id_length, U8 is_remove)
  1585. {
  1586.     /*----------------------------------------------------------------*/
  1587.     /* Local Variables                                                */
  1588.     /*----------------------------------------------------------------*/
  1589.     S32 i;
  1590.     /*----------------------------------------------------------------*/
  1591.     /* Code Body                                                      */
  1592.     /*----------------------------------------------------------------*/
  1593.     if ((app_id == NULL) || (app_id_length == 0))
  1594.     {
  1595.         return JSR_RESULT_INVALID_PARAMETER;
  1596.     }
  1597.     if (is_remove == TRUE)
  1598.     {
  1599.         for (i = 0; i < JSR_MAX_APP_ID_NUM; i++)
  1600.         {
  1601.             if ((jsr_appid_db[i])
  1602.                 && (jsr_appid_db[i]->appId) && (strcmp((S8*) jsr_appid_db[i]->appId, (S8*) app_id) == 0))
  1603.             {
  1604.                 jdd_MemFree(jsr_appid_db[i]->appId);
  1605.                 jdd_MemFree(jsr_appid_db[i]);
  1606.                 jsr_appid_db[i] = NULL;
  1607.                 return JSR_RESULT_OK;
  1608.             }
  1609.         }
  1610.         return JSR_RESULT_ERROR_APPID_NOT_FOUND;
  1611.     }
  1612.     else
  1613.     {
  1614.         S32 empty_slot = -1;
  1615.         for (i = 0; i < JSR_MAX_APP_ID_NUM; i++)
  1616.         {
  1617.             if (jsr_appid_db[i] == NULL)
  1618.             {
  1619.                 empty_slot = i;
  1620.                 break;
  1621.             }
  1622.             else
  1623.             {
  1624.                 if ((jsr_appid_db[i]->appId) && (strcmp((S8*) jsr_appid_db[i]->appId, (S8*) app_id) == 0))
  1625.                 {
  1626.                     return JSR_RESULT_ERROR_APPID_EXIST;
  1627.                 }
  1628.             }
  1629.         }
  1630.         if (empty_slot < 0)
  1631.         {
  1632.             return JSR_RESULT_ERROR_APPID_FULL;
  1633.         }
  1634.         else
  1635.         {
  1636.             jsr_appid_db[i] = (jsr_appid_info_struct*) jdd_MemAlloc(1, sizeof(jsr_appid_info_struct));
  1637.             jsr_appid_db[i]->appId = (S8*) jdd_MemAlloc(1, app_id_length + 1);
  1638.             memcpy(jsr_appid_db[i]->appId, app_id, app_id_length);
  1639.             return JSR_RESULT_OK;
  1640.         }
  1641.     }
  1642. }
  1643. /*****************************************************************************
  1644.  * FUNCTION
  1645.  *  mmi_jsr_check_appmms_coming_req
  1646.  * DESCRIPTION
  1647.  *  Create a MSG_ID_WAP_MMC_CHECK_APPMMS_COMING_REQ primitive to Java
  1648.  * PARAMETERS
  1649.  *  msg     [?]     
  1650.  * RETURNS
  1651.  *  void
  1652.  *****************************************************************************/
  1653. void mmi_jsr_check_appmms_coming_req(void *msg)
  1654. {
  1655.     /*----------------------------------------------------------------*/
  1656.     /* Local Variables                                                */
  1657.     /*----------------------------------------------------------------*/
  1658.     wap_mmc_check_appmms_coming_req_struct *Message;
  1659.     MMI_BOOL result = FALSE;
  1660.     /*----------------------------------------------------------------*/
  1661.     /* Code Body                                                      */
  1662.     /*----------------------------------------------------------------*/
  1663.     Message = (wap_mmc_check_appmms_coming_req_struct*) msg;
  1664.     result = mmi_jsr_check_appid_msgs(Message->app_id, Message->app_id_len, (U8) Message->only_new);
  1665.     mmi_jsr_check_appmms_coming_rsp(result);
  1666. }
  1667. /*****************************************************************************
  1668.  * FUNCTION
  1669.  *  mmi_jsr_check_appmms_coming_rsp
  1670.  * DESCRIPTION
  1671.  *  Create a MSG_ID_WAP_MMC_CHECK_APPMMS_COMING_RSP primitive to Java
  1672.  * PARAMETERS
  1673.  *  result      [IN]        
  1674.  * RETURNS
  1675.  *  void
  1676.  *****************************************************************************/
  1677. void mmi_jsr_check_appmms_coming_rsp(MMI_BOOL result)
  1678. {
  1679.     /*----------------------------------------------------------------*/
  1680.     /* Local Variables                                                */
  1681.     /*----------------------------------------------------------------*/
  1682.     wap_mmc_check_appmms_coming_rsp_struct *myMsgPtr;
  1683.     ilm_struct *ilm_ptr = NULL;
  1684.     /*----------------------------------------------------------------*/
  1685.     /* Code Body                                                      */
  1686.     /*----------------------------------------------------------------*/
  1687.     myMsgPtr = (wap_mmc_check_appmms_coming_rsp_struct*)
  1688.         OslConstructDataPtr(sizeof(wap_mmc_check_appmms_coming_rsp_struct));
  1689.     myMsgPtr->result = (result) ? (1) : (0);
  1690.     ilm_ptr = allocate_ilm(MOD_WAP);
  1691.     ilm_ptr->src_mod_id = MOD_WAP;
  1692.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  1693.     ilm_ptr->dest_mod_id = MOD_JASYN;
  1694.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1695.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_CHECK_APPMMS_COMING_RSP;
  1696.     ilm_ptr->peer_buff_ptr = NULL;
  1697.     msg_send_ext_queue(ilm_ptr);
  1698. }
  1699. /*****************************************************************************
  1700.  * FUNCTION
  1701.  *  mmi_jsr_check_appid_msgs
  1702.  * DESCRIPTION
  1703.  *  Checks the application object list for specific application
  1704.  * PARAMETERS
  1705.  *  app_id              [?]         
  1706.  *  app_id_length       [IN]        
  1707.  *  is_new              [IN]        
  1708.  * RETURNS
  1709.  *  void
  1710.  *****************************************************************************/
  1711. MMI_BOOL mmi_jsr_check_appid_msgs(U8 *app_id, U8 app_id_length, U8 is_new)
  1712. {
  1713.     /*----------------------------------------------------------------*/
  1714.     /* Local Variables                                                */
  1715.     /*----------------------------------------------------------------*/
  1716.     /*----------------------------------------------------------------*/
  1717.     /* Code Body                                                      */
  1718.     /*----------------------------------------------------------------*/
  1719.     if (g_jsr_appid_object_list == NULL)
  1720.     {
  1721.         mmi_jsr_read_object_list_from_file();
  1722.     }
  1723.     if (g_jsr_appid_object_list)
  1724.     {
  1725.         jsr_appid_msgid_list *appid_list = g_jsr_appid_object_list;
  1726.         while (appid_list)
  1727.         {
  1728.             if ((appid_list->appId) && (strcmp((S8*) appid_list->appId, (S8*) app_id) == 0))
  1729.             {
  1730.                 jsr_msg_info *msg_list = appid_list->msgs;
  1731.                 while (msg_list)
  1732.                 {
  1733.                     if (msg_list->is_checked == FALSE)
  1734.                     {
  1735.                         msg_list->is_checked = TRUE;
  1736.                         mmi_jsr_write_object_list_to_file();
  1737.                         return TRUE;
  1738.                     }
  1739.                     else
  1740.                     {
  1741.                         if (is_new == FALSE)
  1742.                         {
  1743.                             return TRUE;
  1744.                         }
  1745.                     }
  1746.                     msg_list = msg_list->next;
  1747.                 }
  1748.                 return FALSE;
  1749.             }
  1750.             appid_list = appid_list->next;
  1751.         }
  1752.     }
  1753.     return FALSE;
  1754. }
  1755. /*****************************************************************************
  1756.  * FUNCTION
  1757.  *  mmi_jsr_abort_appmms_req
  1758.  * DESCRIPTION
  1759.  *  Create a MSG_ID_WAP_MMC_ABORT_APPMMS_REQ primitive to Java
  1760.  * PARAMETERS
  1761.  *  msg     [?]     
  1762.  * RETURNS
  1763.  *  void
  1764.  *****************************************************************************/
  1765. void mmi_jsr_abort_appmms_req(void *msg)
  1766. {
  1767.     /*----------------------------------------------------------------*/
  1768.     /* Local Variables                                                */
  1769.     /*----------------------------------------------------------------*/
  1770.     S8 *file_name_p = NULL;
  1771.     U32 file_path_len = 0;
  1772.     /*----------------------------------------------------------------*/
  1773.     /* Code Body                                                      */
  1774.     /*----------------------------------------------------------------*/
  1775.     if ((JSR_CNTX->op != JSR_OP_SEND_MSG) && (JSR_CNTX->op != JSR_OP_RECV_MSG))
  1776.     {
  1777.         mmi_jsr_abort_appmms_rsp(JSR_RESULT_ACCESS_DENY);
  1778.     }
  1779.     else
  1780.     {
  1781.         if (JSR_CNTX->op == JSR_OP_SEND_MSG)
  1782.         {
  1783.             if ((JSR_CNTX->state == JSR_STATE_PROCESS_SEND_MSG_HDR)
  1784.                 || (JSR_CNTX->state == JSR_STATE_PROCESS_SEND_MSG_BDY))
  1785.             {
  1786.                 file_path_len = (strlen((S8*) (JSR_MEDIA_OBJECT_FILE)) + 1) * ENCODING_LENGTH;
  1787.                 file_name_p = jdd_MemAlloc(sizeof(S8), file_path_len);
  1788.                 AnsiiToUnicodeString((S8*) file_name_p, (S8*) (JSR_MEDIA_OBJECT_FILE));
  1789.                 mmi_jsr_abort_appmms_rsp(JSR_RESULT_OK);
  1790.                 /* JMMS function call */
  1791.                 FS_Delete((U16*) file_name_p);
  1792.                 JsrCleanContext();
  1793.             }
  1794.             else
  1795.             {
  1796.                 /* JMMS function call */
  1797.                 mmi_jmms_jsr_cancel_send_mms(JSR_CNTX->msgId, mmi_jsr_abort_appmms_rsp);
  1798.             }
  1799.         }
  1800.         else
  1801.         {
  1802.             file_path_len = (strlen((S8*) (JSR_MEDIA_OBJECT_FILE)) + 1) * ENCODING_LENGTH;
  1803.             file_name_p = jdd_MemAlloc(sizeof(S8), file_path_len);
  1804.             AnsiiToUnicodeString((S8*) file_name_p, (S8*) (JSR_MEDIA_OBJECT_FILE));
  1805.             /* Aborting receiving of Java MMS by Java app. */
  1806.             mmi_jsr_abort_appmms_rsp(JSR_RESULT_OK);
  1807.             FS_Delete((U16*) file_name_p);
  1808.             JsrCleanContext();
  1809.         }
  1810.         if (file_name_p != NULL)
  1811.         {
  1812.             jdd_MemFree(file_name_p);
  1813.             file_name_p = NULL;
  1814.         }
  1815.     }
  1816. }
  1817. /*****************************************************************************
  1818.  * FUNCTION
  1819.  *  mmi_jsr_abort_appmms_rsp
  1820.  * DESCRIPTION
  1821.  *  Create a MSG_ID_WAP_MMC_ABORT_APPMMS_RSP primitive to Java
  1822.  * PARAMETERS
  1823.  *  result      [IN]        
  1824.  * RETURNS
  1825.  *  void
  1826.  *****************************************************************************/
  1827. void mmi_jsr_abort_appmms_rsp(JsrResult result)
  1828. {
  1829.     /*----------------------------------------------------------------*/
  1830.     /* Local Variables                                                */
  1831.     /*----------------------------------------------------------------*/
  1832.     wap_mmc_abort_appmms_rsp_struct *myMsgPtr;
  1833.     ilm_struct *ilm_ptr = NULL;
  1834.     /*----------------------------------------------------------------*/
  1835.     /* Code Body                                                      */
  1836.     /*----------------------------------------------------------------*/
  1837.     myMsgPtr = (wap_mmc_abort_appmms_rsp_struct*) OslConstructDataPtr(sizeof(wap_mmc_abort_appmms_rsp_struct));
  1838.     myMsgPtr->result = (U8) result;
  1839.     ilm_ptr = allocate_ilm(MOD_WAP);
  1840.     ilm_ptr->src_mod_id = MOD_WAP;
  1841.     ilm_ptr->sap_id = J2ME_WAP_SAP;
  1842.     ilm_ptr->dest_mod_id = MOD_JASYN;
  1843.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1844.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_ABORT_APPMMS_RSP;
  1845.     ilm_ptr->peer_buff_ptr = NULL;
  1846.     msg_send_ext_queue(ilm_ptr);
  1847. }
  1848. /* JAVA PROFILE SETTINGS API */
  1849. /*****************************************************************************
  1850.  * FUNCTION
  1851.  *  mmi_jsr_get_mms_profile_req
  1852.  * DESCRIPTION
  1853.  *  Create a MSG_ID_WAP_MMC_GET_MMS_PROF_REQ primitive to Java
  1854.  * PARAMETERS
  1855.  *  msg     [?]     
  1856.  * RETURNS
  1857.  *  void
  1858.  *****************************************************************************/
  1859. void mmi_jsr_get_mms_profile_req(void *msg)
  1860. {
  1861.     /*----------------------------------------------------------------*/
  1862.     /* Local Variables                                                */
  1863.     /*----------------------------------------------------------------*/
  1864.     wap_mmc_get_mms_prof_req_struct *Message;
  1865.     U8 result = 2;  /* invalid prof id. */
  1866.     U8 value_length = 0;
  1867.     U8 *value = NULL;
  1868.     U8 *temp = NULL;
  1869.     /*----------------------------------------------------------------*/
  1870.     /* Code Body                                                      */
  1871.     /*----------------------------------------------------------------*/
  1872.     Message = (wap_mmc_get_mms_prof_req_struct*) msg;
  1873.     switch (Message->access_id)
  1874.     {
  1875.         case JSR_WAP_MMS_PROF_MMSC_ADDRESS:
  1876.         {
  1877.             /* U8 mms_profile_id; */
  1878.             value = (U8*) jdd_MemAlloc(1, 256);
  1879. #if defined(MMS_SUPPORT)/*dilip*/
  1880.             temp = mmi_ph_mms_get_activated_profile_mmsc_url();
  1881.             if (NULL == temp)
  1882.             {
  1883.                 result = 1; /* MMS not ready yet. */
  1884.                 break;
  1885.             }
  1886. #endif
  1887.             value_length = strlen((S8*) temp) + 1;
  1888.             if (value_length > 256)
  1889.             {
  1890.                 ASSERT(0);  /* memory corruption */
  1891.             }
  1892.             memcpy(value, temp, value_length);
  1893.             result = 0;
  1894.             break;
  1895.         }
  1896.     }
  1897.     mmi_jsr_get_mms_profile_rsp(result, value, value_length);
  1898.     if (NULL != value)
  1899.     {
  1900.         jdd_MemFree(value);
  1901.     }
  1902. }
  1903. /*****************************************************************************
  1904.  * FUNCTION
  1905.  *  mmi_jsr_get_mms_profile_rsp
  1906.  * DESCRIPTION
  1907.  *  Create a MSG_ID_WAP_MMC_GET_MMS_PROF_RSP primitive to Java
  1908.  * PARAMETERS
  1909.  *  result              [IN]        
  1910.  *  value               [?]         
  1911.  *  value_length        [IN]        
  1912.  * RETURNS
  1913.  *  void
  1914.  *****************************************************************************/
  1915. void mmi_jsr_get_mms_profile_rsp(U8 result, U8 *value, U8 value_length)
  1916. {
  1917.     /*----------------------------------------------------------------*/
  1918.     /* Local Variables                                                */
  1919.     /*----------------------------------------------------------------*/
  1920.     wap_mmc_get_mms_prof_rsp_struct *myMsgPtr = NULL;
  1921.     ilm_struct *ilm_ptr = NULL;
  1922.     /*----------------------------------------------------------------*/
  1923.     /* Code Body                                                      */
  1924.     /*----------------------------------------------------------------*/
  1925.     myMsgPtr = (wap_mmc_get_mms_prof_rsp_struct*) OslConstructDataPtr(sizeof(wap_mmc_get_mms_prof_rsp_struct));
  1926.     myMsgPtr->result = result;
  1927.     myMsgPtr->value_len = value_length;
  1928.     if (value_length > 0 && value != NULL)
  1929.     {
  1930.         memcpy(myMsgPtr->value, value, value_length);
  1931.     }
  1932.     ilm_ptr = allocate_ilm(MOD_WAP);
  1933.     ilm_ptr->src_mod_id = MOD_WAP;
  1934.     ilm_ptr->sap_id = J2ME_MMI_SAP;
  1935.     ilm_ptr->dest_mod_id = MOD_J2ME;
  1936.     ilm_ptr->local_para_ptr = (local_para_struct*) myMsgPtr;
  1937.     ilm_ptr->msg_id = MSG_ID_WAP_MMC_GET_MMS_PROF_RSP;
  1938.     ilm_ptr->peer_buff_ptr = NULL;
  1939.     msg_send_ext_queue(ilm_ptr);
  1940. }
  1941. /* JSR INTERNAL APIs */
  1942. /*****************************************************************************
  1943.  * FUNCTION
  1944.  *  mmi_jsr_read_object_list_from_file
  1945.  * DESCRIPTION
  1946.  *  Read the application object list information from a file.
  1947.  * PARAMETERS
  1948.  *  void
  1949.  * RETURNS
  1950.  *  void
  1951.  *****************************************************************************/
  1952. void mmi_jsr_read_object_list_from_file(void)
  1953. {
  1954.     /*----------------------------------------------------------------*/
  1955.     /* Local Variables                                                */
  1956.     /*----------------------------------------------------------------*/
  1957.     S8 filename[100];
  1958.     int filehandle = -1;
  1959.     S8 *buff;
  1960.     U32 buf_size = 512;
  1961.     U32 line_length;
  1962.     S32 ret;
  1963.     MMI_BOOL update_file = FALSE;
  1964.     /*----------------------------------------------------------------*/
  1965.     /* Code Body                                                      */
  1966.     /*----------------------------------------------------------------*/
  1967.     AnsiiToUnicodeString((S8*) filename, (S8*) (JSR_APPID_LIST_FILE));
  1968.     filehandle = FS_Open((U16*) (filename), FS_READ_ONLY);
  1969.     if (filehandle < 0)
  1970.     {
  1971.         return;
  1972.     }
  1973.     buff = (S8*) jdd_MemAlloc(1, buf_size);
  1974.     while (1)
  1975.     {
  1976.         S8 *appid_string = NULL;
  1977.         jsr_msg_info *msg_list = NULL;
  1978.         U32 step = 1;
  1979.         for (step = 1; step < 4; step++)
  1980.         {
  1981.             /* applib_file_read_line(filehandle, buff, buf_size, &line_length, &ret); */
  1982.             mmi_jsr_read_line_from_file(filehandle, buff, buf_size, &line_length, &ret);
  1983.             if ((ret == 0) && (line_length == 0))
  1984.             {
  1985.                 FS_Close(filehandle);
  1986.                 jdd_MemFree(buff);
  1987.                 if (update_file == TRUE)
  1988.                 {
  1989.                     mmi_jsr_write_object_list_to_file();
  1990.                 }
  1991.                 return;
  1992.             }
  1993.             else if (ret < 0)
  1994.             {
  1995.                 FS_Close(filehandle);
  1996.                 jdd_MemFree(buff);
  1997.                 /* File format corrupted, so remove all the appid info. */
  1998.                 mmi_jsr_remove_appid_info_from_list_recursive(&g_jsr_appid_object_list);
  1999.                 return;
  2000.             }
  2001.             ASSERT(line_length > 2);
  2002.             /* replace 'r''n' with '''' */
  2003.             *(buff + line_length - 1) = '';
  2004.             *(buff + line_length - 2) = '';
  2005.             /* Read appid from file */
  2006.             if (step == 1)
  2007.             {
  2008.                 appid_string = (S8*) jdd_MemAlloc(1, (strlen((char*)buff) + 1));
  2009.                 ASSERT(appid_string);
  2010.                 strcpy((S8*) appid_string, (S8*) buff);
  2011.             }
  2012.             /* Read msgid and isChecked string */
  2013.             else if (step == 2)
  2014.             {
  2015.                 S8 *text = buff;
  2016.                 S8 *colon = NULL;
  2017.                 S8 *next_token = NULL;
  2018.                 U32 msgId;
  2019.                 U8 isChecked;
  2020.                 while (text)
  2021.                 {
  2022.                     next_token = (S8*) strchr((char*)text, ',');
  2023.                     if (next_token != NULL)
  2024.                     {
  2025.                         *(next_token++) = '';
  2026.                     }
  2027.                     colon = (S8*) strchr((char*)text, ':');
  2028.                     ASSERT(colon);
  2029.                     *(colon++) = '';
  2030.                     msgId = atoi((char*)text);
  2031.                     isChecked = atoi((char*)colon);
  2032.                     if (mmi_jmms_check_msg_id(msgId) == TRUE)
  2033.                     {
  2034.                         mmi_jsr_insert_msg_info_to_list(&msg_list, msgId, isChecked);
  2035.                     }
  2036.                     else
  2037.                     {
  2038.                         update_file = TRUE;
  2039.                     }
  2040.                     text = next_token;
  2041.                 }
  2042.             }
  2043.             /* 'r' and 'n' */
  2044.             else if (step == 3)
  2045.             {
  2046.                 if (msg_list != NULL)
  2047.                 {
  2048.                     mmi_jsr_insert_appid_info_to_list(&g_jsr_appid_object_list, appid_string, msg_list);
  2049.                 }
  2050.                 else
  2051.                 {
  2052.                     if (appid_string)
  2053.                     {
  2054.                         jdd_MemFree(appid_string);
  2055.                     }
  2056.                 }
  2057.             }
  2058.         }
  2059.     }
  2060. }
  2061. /*****************************************************************************
  2062.  * FUNCTION
  2063.  *  mmi_jsr_write_object_list_to_file
  2064.  * DESCRIPTION
  2065.  *  Write the application object list information to file.
  2066.  * PARAMETERS
  2067.  *  void
  2068.  * RETURNS
  2069.  *  MMI_BOOL result
  2070.  *****************************************************************************/
  2071. MMI_BOOL mmi_jsr_write_object_list_to_file(void)
  2072. {
  2073.     /*----------------------------------------------------------------*/
  2074.     /* Local Variables                                                */
  2075.     /*----------------------------------------------------------------*/
  2076.     S8 filename[100];
  2077.     S8 orig_file[100];
  2078.     S8 *buff = NULL;
  2079.     U32 buf_size = 0;
  2080.     U32 filesize = 0;
  2081.     U32 datalen = 0;
  2082.     int filehandle = -1;
  2083.     U32 written = 0;
  2084.     S32 result = -1;
  2085.     jsr_appid_msgid_list *appid_list;
  2086.     /*----------------------------------------------------------------*/
  2087.     /* Code Body                                                      */
  2088.     /*----------------------------------------------------------------*/
  2089.     if (g_jsr_appid_object_list == NULL)
  2090.     {
  2091.         return FALSE;
  2092.     }
  2093.     filesize = mmi_jsr_get_current_size_of_object_list(g_jsr_appid_object_list, &buf_size);
  2094.     ASSERT(filesize);
  2095.     AnsiiToUnicodeString((S8*) orig_file, (S8*) (JSR_APPID_LIST_FILE));
  2096.     AnsiiToUnicodeString((S8*) filename, (S8*) (JSR_APPID_LIST_FILE_TMP));
  2097.     FS_Delete((U16*) filename);
  2098.     filehandle = FS_Open((U16*) filename, FS_CREATE_ALWAYS | FS_READ_WRITE);
  2099.     if (filehandle < 0)
  2100.     {
  2101.         return FALSE;
  2102.     }
  2103.     buff = (S8*) jdd_MemAlloc(sizeof(S8), buf_size + 1);
  2104.     ASSERT(buff);
  2105.     appid_list = g_jsr_appid_object_list;
  2106.     while (appid_list)
  2107.     {
  2108.         ASSERT(appid_list->appId);
  2109.         {
  2110.             datalen = 0;
  2111.             sprintf((char*)buff, "%srn", appid_list->appId);
  2112.             datalen = strlen((char*)appid_list->appId) + 2;
  2113.             result = FS_Write(filehandle, buff, datalen, &written);
  2114.             if (result < 0)
  2115.             {
  2116.                 FS_Close(filehandle);
  2117.                 jdd_MemFree(buff);
  2118.                 return FALSE;
  2119.             }
  2120.         }
  2121.         ASSERT(appid_list->msgs);
  2122.         {
  2123.             jsr_msg_info *msg_list = appid_list->msgs;
  2124.             datalen = 0;
  2125.             while (msg_list)
  2126.             {
  2127.                 sprintf((char*)(buff + datalen), "%d:%1d", msg_list->msgId, msg_list->is_checked);
  2128.                 datalen += mmi_jsr_get_digit_of_integer(msg_list->msgId) + 2;
  2129.                 if (msg_list->next)
  2130.                 {
  2131.                     sprintf((char*)(buff + datalen), ",");
  2132.                     datalen += 1;
  2133.                 }
  2134.                 msg_list = msg_list->next;
  2135.             }
  2136.             sprintf((char*)(buff + datalen), "rn*rn");
  2137.             datalen += 5;
  2138.             ASSERT(buf_size >= datalen);
  2139.             result = FS_Write(filehandle, buff, datalen, &written);
  2140.             if (result < 0)
  2141.             {
  2142.                 FS_Close(filehandle);
  2143.                 jdd_MemFree(buff);
  2144.                 return FALSE;
  2145.             }
  2146.         }
  2147.         appid_list = appid_list->next;
  2148.     }
  2149.     FS_Close(filehandle);
  2150.     jdd_MemFree(buff);
  2151.     FS_Delete((U16*) orig_file);
  2152.     FS_Rename((U16*) filename, (U16*) orig_file);
  2153.     return TRUE;
  2154. }
  2155. /*****************************************************************************
  2156.  * FUNCTION
  2157.  *  mmi_jsr_insert_appid_info_to_list
  2158.  * DESCRIPTION
  2159.  *  Insert the application info to application object list.
  2160.  * PARAMETERS
  2161.  *  appid_object_list       [IN]        
  2162.  *  string                  [?]         
  2163.  *  msg_list                [?]         
  2164.  * RETURNS
  2165.  *  MMI_BOOL result
  2166.  *****************************************************************************/
  2167. MMI_BOOL mmi_jsr_insert_appid_info_to_list(
  2168.             jsr_appid_msgid_list **appid_object_list,
  2169.             S8 *string,
  2170.             jsr_msg_info *msg_list)
  2171. {
  2172.     /*----------------------------------------------------------------*/
  2173.     /* Local Variables                                                */
  2174.     /*----------------------------------------------------------------*/
  2175.     jsr_appid_msgid_list *node = NULL;
  2176.     /*----------------------------------------------------------------*/
  2177.     /* Code Body                                                      */
  2178.     /*----------------------------------------------------------------*/
  2179.     if (appid_object_list == NULL)
  2180.     {
  2181.         return FALSE;
  2182.     }
  2183.     node = (jsr_appid_msgid_list*) jdd_MemAlloc(1, sizeof(jsr_appid_msgid_list));
  2184.     ASSERT(node);
  2185.     node->appId = (S8*) jdd_MemAlloc(1, (strlen((S8*) string) + 1));
  2186.     ASSERT(node->appId);
  2187.     strcpy((S8*) node->appId, (S8*) string);
  2188.     node->msgs = msg_list;
  2189.     if (*appid_object_list == NULL)
  2190.     {
  2191.         node->prev = node;
  2192.         *appid_object_list = node;
  2193.         return TRUE;
  2194.     }
  2195.     else
  2196.     {
  2197.         jsr_appid_msgid_list *tempnode = *appid_object_list;
  2198.         while (tempnode->next)
  2199.         {
  2200.             tempnode = tempnode->next;
  2201.         }
  2202.         tempnode->next = node;
  2203.         node->prev = tempnode;
  2204.         return TRUE;
  2205.     }
  2206. }
  2207. /*****************************************************************************
  2208.  * FUNCTION
  2209.  *  mmi_jsr_remove_appid_info_from_list
  2210.  * DESCRIPTION
  2211.  *  Remove the application info from application object list.
  2212.  * PARAMETERS
  2213.  *  list        [IN]        
  2214.  *  appId       [?]         
  2215.  * RETURNS
  2216.  *  MMI_BOOL result
  2217.  *****************************************************************************/
  2218. MMI_BOOL mmi_jsr_remove_appid_info_from_list(jsr_appid_msgid_list **list, S8 *appId)
  2219. {
  2220.     /*----------------------------------------------------------------*/
  2221.     /* Local Variables                                                */
  2222.     /*----------------------------------------------------------------*/
  2223.     jsr_appid_msgid_list *appid_list;
  2224.     /*----------------------------------------------------------------*/
  2225.     /* Code Body                                                      */
  2226.     /*----------------------------------------------------------------*/
  2227.     if ((list == NULL) || (*(list) == NULL))
  2228.     {
  2229.         return FALSE;
  2230.     }
  2231.     appid_list = *list;
  2232.     while (appid_list)
  2233.     {
  2234.         if ((appid_list->appId) && (appId) && (strcmp((S8*) appid_list->appId, (S8*) appId) == 0))
  2235.         {
  2236.             if (appid_list == *list)
  2237.             {
  2238.                 *list = appid_list->next;
  2239.                 if (appid_list->next)
  2240.                 {
  2241.                     appid_list->next->prev = appid_list->next;
  2242.                 }
  2243.             }
  2244.             else
  2245.             {
  2246.                 appid_list->prev->next = appid_list->next;
  2247.                 if (appid_list->next)
  2248.                 {
  2249.                     appid_list->next->prev = appid_list->prev;
  2250.                 }
  2251.             }
  2252.             jdd_MemFree(appid_list->appId);
  2253.             mmi_jsr_remove_msg_info_from_list_recursive(&(appid_list->msgs));
  2254.             jdd_MemFree(appid_list);
  2255.             return TRUE;
  2256.         }
  2257.         appid_list = appid_list->next;
  2258.     }
  2259.     return FALSE;
  2260. }
  2261. /*****************************************************************************
  2262.  * FUNCTION
  2263.  *  mmi_jsr_remove_appid_info_from_list_recursive
  2264.  * DESCRIPTION
  2265.  *  Remove the appid info of all the messages in the application object list.
  2266.  * PARAMETERS
  2267.  *  list        [IN]        
  2268.  * RETURNS
  2269.  *  MMI_BOOL result
  2270.  *****************************************************************************/
  2271. MMI_BOOL mmi_jsr_remove_appid_info_from_list_recursive(jsr_appid_msgid_list **list)
  2272. {
  2273.     /*----------------------------------------------------------------*/
  2274.     /* Local Variables                                                */
  2275.     /*----------------------------------------------------------------*/
  2276.     jsr_appid_msgid_list *appid_list;
  2277.     jsr_appid_msgid_list *appid_list_temp = NULL;
  2278.     /*----------------------------------------------------------------*/
  2279.     /* Code Body                                                      */
  2280.     /*----------------------------------------------------------------*/
  2281.     if ((list == NULL) || (*list == NULL))
  2282.     {
  2283.         return FALSE;
  2284.     }
  2285.     appid_list = *list;
  2286.     while (appid_list)
  2287.     {
  2288.         appid_list_temp = appid_list->next;
  2289.         jdd_MemFree(appid_list->appId);
  2290.         mmi_jsr_remove_msg_info_from_list_recursive(&(appid_list->msgs));
  2291.         jdd_MemFree(appid_list);
  2292.         appid_list = appid_list_temp;
  2293.     }
  2294.     *list = NULL;
  2295.     return TRUE;
  2296. }
  2297. /*****************************************************************************
  2298.  * FUNCTION
  2299.  *  mmi_jsr_insert_msg_info_to_list
  2300.  * DESCRIPTION
  2301.  *  Insert the message info to application object list.
  2302.  * PARAMETERS
  2303.  *  msg_list        [IN]        
  2304.  *  msgId           [IN]        
  2305.  *  ischecked       [IN]        
  2306.  * RETURNS
  2307.  *  MMI_BOOL result
  2308.  *****************************************************************************/
  2309. MMI_BOOL mmi_jsr_insert_msg_info_to_list(jsr_msg_info **msg_list, U32 msgId, U8 ischecked)
  2310. {
  2311.     /*----------------------------------------------------------------*/
  2312.     /* Local Variables                                                */
  2313.     /*----------------------------------------------------------------*/
  2314.     jsr_msg_info *node = NULL;
  2315.     /*----------------------------------------------------------------*/
  2316.     /* Code Body                                                      */
  2317.     /*----------------------------------------------------------------*/
  2318.     if (msg_list == NULL)
  2319.     {
  2320.         return FALSE;
  2321.     }
  2322.     node = (jsr_msg_info*) jdd_MemAlloc(1, sizeof(jsr_msg_info));
  2323.     ASSERT(node);
  2324.     node->msgId = msgId;
  2325.     node->is_checked = ischecked;
  2326.     if (*msg_list == NULL)
  2327.     {
  2328.         node->prev = node;
  2329.         *msg_list = node;
  2330.         return TRUE;
  2331.     }
  2332.     else
  2333.     {
  2334.         jsr_msg_info *tempnode = *msg_list;
  2335.         while (tempnode->next)
  2336.         {
  2337.             tempnode = tempnode->next;
  2338.         }
  2339.         tempnode->next = node;
  2340.         node->prev = tempnode;
  2341.         return TRUE;
  2342.     }
  2343. }
  2344. /*****************************************************************************
  2345.  * FUNCTION
  2346.  *  mmi_jsr_remove_msg_info_from_list
  2347.  * DESCRIPTION
  2348.  *  Remove the message info from application object list.
  2349.  * PARAMETERS
  2350.  *  list        [IN]        
  2351.  *  msgId       [IN]        
  2352.  * RETURNS
  2353.  *  MMI_BOOL result
  2354.  *****************************************************************************/
  2355. MMI_BOOL mmi_jsr_remove_msg_info_from_list(jsr_msg_info **list, U32 msgId)
  2356. {
  2357.     /*----------------------------------------------------------------*/
  2358.     /* Local Variables                                                */
  2359.     /*----------------------------------------------------------------*/
  2360.     jsr_msg_info *msg_list;
  2361.     /*----------------------------------------------------------------*/
  2362.     /* Code Body                                                      */
  2363.     /*----------------------------------------------------------------*/
  2364.     if ((list == NULL) || (*(list) == NULL))
  2365.     {
  2366.         return FALSE;
  2367.     }
  2368.     msg_list = *list;
  2369.     while (msg_list)
  2370.     {
  2371.         if (msg_list->msgId == msgId)
  2372.         {
  2373.             if (msg_list == *list)
  2374.             {
  2375.                 *list = msg_list->next;
  2376.                 if (msg_list->next)
  2377.                 {
  2378.                     msg_list->next->prev = msg_list->next;
  2379.                 }
  2380.             }
  2381.             else
  2382.             {
  2383.                 msg_list->prev->next = msg_list->next;
  2384.                 if (msg_list->next)
  2385.                 {
  2386.                     msg_list->next->prev = msg_list->prev;
  2387.                 }
  2388.             }
  2389.             jdd_MemFree(msg_list);
  2390.             return TRUE;
  2391.         }
  2392.         msg_list = msg_list->next;
  2393.     }
  2394.     return FALSE;
  2395. }
  2396. /*****************************************************************************
  2397.  * FUNCTION
  2398.  *  mmi_jsr_remove_msg_info_from_list_recursive
  2399.  * DESCRIPTION
  2400.  *  Remove the message info of all the messages in the message list.
  2401.  * PARAMETERS
  2402.  *  list        [IN]        
  2403.  * RETURNS
  2404.  *  MMI_BOOL result
  2405.  *****************************************************************************/
  2406. MMI_BOOL mmi_jsr_remove_msg_info_from_list_recursive(jsr_msg_info **list)
  2407. {
  2408.     /*----------------------------------------------------------------*/
  2409.     /* Local Variables                                                */
  2410.     /*----------------------------------------------------------------*/
  2411.     jsr_msg_info *msg_list;
  2412.     jsr_msg_info *msg_list_temp = NULL;
  2413.     /*----------------------------------------------------------------*/
  2414.     /* Code Body                                                      */
  2415.     /*----------------------------------------------------------------*/
  2416.     if ((list == NULL) || (*(list) == NULL))
  2417.     {
  2418.         return FALSE;
  2419.     }
  2420.     msg_list = *list;
  2421.     while (msg_list)
  2422.     {
  2423.         msg_list_temp = msg_list->next;
  2424.         jdd_MemFree(msg_list);
  2425.         msg_list = msg_list_temp;
  2426.     }
  2427.     *list = NULL;
  2428.     return TRUE;
  2429. }
  2430. /*****************************************************************************
  2431.  * FUNCTION
  2432.  *  mmi_jsr_get_digit_of_integer
  2433.  * DESCRIPTION
  2434.  *  Calculates the number of digits in an integer.
  2435.  * PARAMETERS
  2436.  *  msgId       [IN]        
  2437.  * RETURNS
  2438.  *  U32 length
  2439.  *****************************************************************************/
  2440. U32 mmi_jsr_get_digit_of_integer(U32 msgId)
  2441. {
  2442.     /*----------------------------------------------------------------*/
  2443.     /* Local Variables                                                */
  2444.     /*----------------------------------------------------------------*/
  2445.     S8 buff[11];
  2446.     /*----------------------------------------------------------------*/
  2447.     /* Code Body                                                      */
  2448.     /*----------------------------------------------------------------*/
  2449.     sprintf((S8*) buff, "%d", msgId);
  2450.     return strlen((S8*) buff);
  2451. }
  2452. /*****************************************************************************
  2453.  * FUNCTION
  2454.  *  mmi_jsr_get_current_size_of_object_list
  2455.  * DESCRIPTION
  2456.  *  Calculates the current size of application object list.
  2457.  * PARAMETERS
  2458.  *  appid_object_list       [?]     
  2459.  *  max_chrs_in_line        [?]     
  2460.  * RETURNS
  2461.  *  U32 size
  2462.  *****************************************************************************/
  2463. U32 mmi_jsr_get_current_size_of_object_list(jsr_appid_msgid_list *appid_object_list, U32 *max_chrs_in_line)
  2464. {
  2465.     /*----------------------------------------------------------------*/
  2466.     /* Local Variables                                                */
  2467.     /*----------------------------------------------------------------*/
  2468.     U32 sum = 0;
  2469.     U32 chrs = 0;
  2470.     U32 max_chrs = 0;
  2471.     jsr_appid_msgid_list *appid_list;
  2472.     /*----------------------------------------------------------------*/
  2473.     /* Code Body                                                      */
  2474.     /*----------------------------------------------------------------*/
  2475.     *(max_chrs_in_line) = 0;
  2476.     if (appid_object_list == NULL)
  2477.     {
  2478.         return 0;
  2479.     }
  2480.     appid_list = appid_object_list;
  2481.     while (appid_list)
  2482.     {
  2483.         if (appid_list->appId)
  2484.         {
  2485.             chrs = strlen((S8*) appid_list->appId) + 2; /* appid string+rn */
  2486.             sum += chrs;
  2487.             if (chrs > max_chrs)
  2488.             {
  2489.                 max_chrs = chrs;
  2490.             }
  2491.         }
  2492.         chrs = 0;
  2493.         if (appid_list->msgs)
  2494.         {
  2495.             jsr_msg_info *msg_list = appid_list->msgs;
  2496.             while (msg_list)
  2497.             {
  2498.                 /* msgid:isChecked */
  2499.                 chrs += (mmi_jsr_get_digit_of_integer(msg_list->msgId) + 2);
  2500.                 if (msg_list->next)
  2501.                 {
  2502.                     chrs += 1;
  2503.                 }
  2504.                 msg_list = msg_list->next;
  2505.             }
  2506.             chrs += 5;  /* rn*rn */
  2507.             sum += chrs;
  2508.             if (chrs > max_chrs)
  2509.             {
  2510.                 max_chrs = chrs;
  2511.             }
  2512.         }
  2513.         appid_list = appid_list->next;
  2514.     }
  2515.     *max_chrs_in_line = max_chrs;
  2516.     return sum;
  2517. }
  2518. /*****************************************************************************
  2519.  * FUNCTION
  2520.  *  mmi_jsr_read_line_from_file
  2521.  * DESCRIPTION
  2522.  *  Reads a line from a file and store it in buffer.
  2523.  * PARAMETERS
  2524.  *  filehandle      [IN]        
  2525.  *  buffer          [?]         
  2526.  *  buf_length      [IN]        
  2527.  *  line_length     [?]         
  2528.  *  ret             [?]         
  2529.  * RETURNS
  2530.  *  void
  2531.  *****************************************************************************/
  2532. void mmi_jsr_read_line_from_file(U32 filehandle, S8 *buffer, U32 buf_length, U32 *line_length, S32 *ret)
  2533. {
  2534.     /*----------------------------------------------------------------*/
  2535.     /* Local Variables                                                */
  2536.     /*----------------------------------------------------------------*/
  2537.     S8 *pos = buffer;
  2538.     U32 rd_no = 0;
  2539.     U32 count = 0;
  2540.     MMI_BOOL CR = FALSE;
  2541.     /*----------------------------------------------------------------*/
  2542.     /* Code Body                                                      */
  2543.     /*----------------------------------------------------------------*/
  2544.     memset(buffer, 0, buf_length);
  2545.     *line_length = 0;
  2546.     while (buf_length)
  2547.     {
  2548.         *ret = FS_Read(filehandle, pos, 1, &rd_no);
  2549.         if (*ret < 0)
  2550.         {
  2551.             *line_length = count;
  2552.             return;
  2553.         }
  2554.         else if (rd_no != 1)
  2555.         {
  2556.             *line_length = count;
  2557.             return;
  2558.         }
  2559.         else
  2560.         {
  2561.             count++;
  2562.             if (*pos == 'r')
  2563.             {
  2564.                 CR = TRUE;
  2565.             }
  2566.             else if (*pos == 'n')
  2567.             {
  2568.                 if (CR == TRUE)
  2569.                 {
  2570.                     *line_length = count;
  2571.                     return;
  2572.                 }
  2573.                 else
  2574.                 {
  2575.                     CR = FALSE;
  2576.                 }
  2577.             }
  2578.             else
  2579.             {
  2580.                 CR = FALSE;
  2581.             }
  2582.         }
  2583.         buf_length--;
  2584.         pos++;
  2585.     }
  2586.     *ret = -1;
  2587.     *line_length = rd_no;
  2588.     return;
  2589. }
  2590. /*****************************************************************************
  2591.  * FUNCTION
  2592.  *  mmi_jsr_check_appId
  2593.  * DESCRIPTION
  2594.  *  Checks whether the application is registered or not.
  2595.  * PARAMETERS
  2596.  *  appId       [?]     
  2597.  * RETURNS
  2598.  *  MMI_BOOL result
  2599.  *****************************************************************************/
  2600. MMI_BOOL mmi_jsr_check_appId(S8 *appId)
  2601. {
  2602.     /*----------------------------------------------------------------*/
  2603.     /* Local Variables                                                */
  2604.     /*----------------------------------------------------------------*/
  2605.     U32 i;
  2606.     /*----------------------------------------------------------------*/
  2607.     /* Code Body                                                      */
  2608.     /*----------------------------------------------------------------*/
  2609.     for (i = 0; i < JSR_MAX_APP_ID_NUM; i++)
  2610.     {
  2611.         if (jsr_appid_db[i] && jsr_appid_db[i]->appId && (strcmp((S8*) jsr_appid_db[i]->appId, (S8*) appId) == 0))
  2612.         {
  2613.             return TRUE;
  2614.         }
  2615.     }
  2616.     return FALSE;
  2617. }
  2618. /*****************************************************************************
  2619.  * FUNCTION
  2620.  *  mmi_jsr_is_java_msg
  2621.  * DESCRIPTION
  2622.  *  Checks whether the message is a Java message or not.
  2623.  * PARAMETERS
  2624.  *  msgId       [IN]        
  2625.  * RETURNS
  2626.  *  MMI_BOOL result
  2627.  *****************************************************************************/
  2628. MMI_BOOL mmi_jsr_is_java_msg(U32 msgId)
  2629. {
  2630.     /*----------------------------------------------------------------*/
  2631.     /* Local Variables                                                */
  2632.     /*----------------------------------------------------------------*/
  2633.     /*----------------------------------------------------------------*/
  2634.     /* Code Body                                                      */
  2635.     /*----------------------------------------------------------------*/
  2636.     if (g_jsr_appid_object_list == NULL)
  2637.     {
  2638.         mmi_jsr_read_object_list_from_file();
  2639.     }
  2640.     if (g_jsr_appid_object_list)
  2641.     {
  2642.         jsr_appid_msgid_list *appid_list = g_jsr_appid_object_list;
  2643.         while (appid_list)
  2644.         {
  2645.             if (appid_list->msgs)
  2646.             {
  2647.                 jsr_msg_info *msg_list = appid_list->msgs;
  2648.                 while (msg_list)
  2649.                 {
  2650.                     if (msg_list->msgId == msgId)
  2651.                     {
  2652.                         return TRUE;
  2653.                     }
  2654.                     msg_list = msg_list->next;
  2655.                 }
  2656.             }
  2657.             appid_list = appid_list->next;
  2658.         }
  2659.     }
  2660.     return FALSE;
  2661. }
  2662. #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */ // #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
  2663. #endif /* _MMI_JSR_C */