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

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. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * UnifiedComposerMsg.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements handlers to process primitives.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  *------------------------------------------------------------------------------
  92.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  93.  *============================================================================
  94.  ****************************************************************************/
  95. #ifndef _MMI_UNIFIED_COMPOSER_MSG_C
  96. #define _MMI_UNIFIED_COMPOSER_MSG_C
  97. #include "MMI_features.h"
  98. #ifdef __MMI_UNIFIED_COMPOSER__
  99. #include "stdC.h"
  100. #include "L4Dr1.h"
  101. #include "FileSystemDef.h"
  102. #include "FileMgr.h"
  103. #include "mdi_datatype.h"
  104. /* micha1230 */
  105. #include "custom_nvram_editor_data_item.h"
  106. #include "custom_data_account.h"
  107. #include "MessagesResourceData.h"
  108. /* other files */
  109. #include "GlobalDefs.h"
  110. #include "QueueGprot.h"
  111. #include "Unicodexdcl.h"
  112. #include "DebugInitDef.h"
  113. #include "ProtocolEvents.h"
  114. #include "PixtelDataTypes.h"
  115. #include "EventsGprot.h"
  116. #include "CustDataRes.h"
  117. #include "SettingProfile.h"
  118. #include "IdleAppProt.h"
  119. #include "wgui_categories_UCE.h"
  120. #include "FrameworkStruct.h"
  121. #include "AlarmFrameWorkProt.h"
  122. #include "HistoryGprot.h"
  123. #include "Conversions.h"
  124. #include "DataAccount.h"
  125. #include "PhoneBookGprot.h"
  126. #include "GpioInc.h"
  127. #include "ProfileGprots.h"
  128. #include "MemPoolContainerProt.h"
  129. #include "CommonScreens.h"
  130. #include "mmi_trc.h"
  131. #include "MessagesMiscell.h"
  132. #include "SmsPsHandler.h"
  133. #include "app_asyncfile.h"
  134. #include "wapadp.h"
  135. #include "mmsadp.h"
  136. #include "wap_ps_struct.h"
  137. #include "custom_wap_config.h"
  138. #include "xml_def.h"
  139. #include "custom_uc_config.h"
  140. #include "UnifiedComposerDef.h"
  141. #include "UnifiedComposerGProt.h"
  142. #include "UnifiedComposerProt.h"
  143. /*****************************************************************************
  144.  * FUNCTION
  145.  *  mmi_uc_set_protocol_event_handler
  146.  * DESCRIPTION
  147.  *  Set protocol event handler
  148.  * PARAMETERS
  149.  *  void
  150.  * RETURNS
  151.  *  void
  152.  *****************************************************************************/
  153. void mmi_uc_set_protocol_event_handler(void)
  154. {
  155.     /*----------------------------------------------------------------*/
  156.     /* Local Variables                                                */
  157.     /*----------------------------------------------------------------*/
  158.     /*----------------------------------------------------------------*/
  159.     /* Code Body                                                      */
  160.     /*----------------------------------------------------------------*/
  161.     SetProtocolEventHandler(mmi_uc_start_req, MSG_ID_WAP_MMA_UC_START_REQ);
  162.     SetProtocolEventHandler(mmi_uc_get_mms_setting_rsp, MSG_ID_WAP_MMA_GET_SETTING_RSP);
  163.     SetProtocolEventHandler(mmi_uc_get_mms_content_rsp, MSG_ID_WAP_MMA_GET_CONTENT_RSP);
  164.     SetProtocolEventHandler(mmi_uc_create_mms_rsp, MSG_ID_WAP_MMA_CREATE_RSP);
  165.     SetProtocolEventHandler(mmi_uc_send_mms_ind_hdlr, MSG_ID_WAP_MMA_SEND_IND);
  166.     SetProtocolEventHandler(mmi_uc_send_mms_rsp, MSG_ID_WAP_MMA_SEND_RSP);
  167.     SetProtocolEventHandler(mmi_uc_delete_mms_rsp, MSG_ID_WAP_MMA_DELETE_RSP);
  168.     SetProtocolEventHandler(mmi_uc_save_mms_rsp, MSG_ID_WAP_MMA_SAVE_RSP);
  169.     SetProtocolEventHandler(mmi_uc_abort_send_mms_rsp, MSG_ID_WAP_MMA_CANCEL_SEND_RSP);
  170.     SetProtocolEventHandler(mmi_uc_preview_mms_rsp, MSG_ID_WAP_MMA_PREVIEW_RSP);
  171. }
  172. /*****************************************************************************
  173.  * FUNCTION
  174.  *  mmi_uc_start_req
  175.  * DESCRIPTION
  176.  *  Handler for start UC request
  177.  * PARAMETERS
  178.  *  void
  179.  * RETURNS
  180.  *  void
  181.  *****************************************************************************/
  182. void mmi_uc_start_req(void *inMsg)
  183. {
  184.     /*----------------------------------------------------------------*/
  185.     /* Local Variables                                                */
  186.     /*----------------------------------------------------------------*/
  187.     wap_mma_uc_start_req_struct *msg_req = (wap_mma_uc_start_req_struct*) inMsg;
  188.     /*----------------------------------------------------------------*/
  189.     /* Code Body                                                      */
  190.     /*----------------------------------------------------------------*/
  191.     if (GetExitScrnID() == SCR_ID_UC_EDITOR || IsScreenPresent(SCR_ID_UC_EDITOR))
  192.     {
  193.         mmi_uc_start_rsp(MMA_RESULT_FAIL_BUSY, msg_req->msg_id, msg_req->mode);
  194.     } 
  195.     else
  196.     {
  197.         mmi_uc_reset_msg();
  198.         g_uc_p->main.state = mmi_uc_convert_mms_app_mode_to_uc_state(msg_req->mode);
  199.         g_uc_p->send_info.existed_msg_id = msg_req->msg_id;
  200.         g_uc_p->send_info.existed_msg_type = MMI_UC_MSG_TYPE_MMS_PREFER;
  201.         
  202.         mmi_uc_start_rsp(MMA_RESULT_OK, msg_req->msg_id, msg_req->mode);
  203.         
  204.         g_uc_p->msg_type.setting_msg_type = mmi_uc_get_setting_msg_type();        
  205.         g_uc_p->msg_type.curr_msg_type = g_uc_p->msg_type.setting_msg_type;
  206.         g_uc_p->msg_type.caller_specific_msg_type = MMI_UC_MSG_TYPE_DEFAULT;
  207.         g_uc_p->msg_type.backup_msg_type = MMI_UC_MSG_TYPE_DEFAULT;
  208.         
  209.         mmi_uc_process_entry_write_msg();        
  210.     }
  211.     return;
  212. }
  213. /*****************************************************************************
  214.  * FUNCTION
  215.  *  mmi_uc_start_rsp
  216.  * DESCRIPTION
  217.  *  Handler for start UC response
  218.  * PARAMETERS
  219.  *  void
  220.  * RETURNS
  221.  *  void
  222.  *****************************************************************************/
  223. void mmi_uc_start_rsp(U16 result, U32 msg_id, U16 app_mode)
  224. {
  225.     /*----------------------------------------------------------------*/
  226.     /* Local Variables                                                */
  227.     /*----------------------------------------------------------------*/
  228.     wap_mma_uc_start_rsp_struct *msg_rsp;
  229.     /*----------------------------------------------------------------*/
  230.     /* Code Body                                                      */
  231.     /*----------------------------------------------------------------*/    
  232.     msg_rsp = (wap_mma_uc_start_rsp_struct*) OslConstructDataPtr(sizeof(wap_mma_uc_start_rsp_struct));
  233.     
  234.     msg_rsp->result = result;
  235.     msg_rsp->mode = app_mode;
  236.     msg_rsp->msg_id = msg_id;
  237.     
  238.     mmi_uc_send_message(
  239.         MOD_MMI,
  240.         MOD_WAP,
  241.         0,
  242.         MSG_ID_WAP_MMA_UC_START_RSP,
  243.         (oslParaType*) msg_rsp,
  244.         NULL);
  245.     
  246.     return;
  247. }
  248. /*****************************************************************************
  249.  * FUNCTION
  250.  *  mmi_uc_get_mms_setting_req
  251.  * DESCRIPTION
  252.  *  Get MMS setting request
  253.  * PARAMETERS
  254.  *  void
  255.  * RETURNS
  256.  *  void
  257.  *****************************************************************************/
  258. void mmi_uc_get_mms_setting_req(void)
  259. {
  260.     /*----------------------------------------------------------------*/
  261.     /* Local Variables                                                */
  262.     /*----------------------------------------------------------------*/
  263.     wap_mma_get_setting_req_struct *msg_req;
  264.     /*----------------------------------------------------------------*/
  265.     /* Code Body                                                      */
  266.     /*----------------------------------------------------------------*/
  267.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  268.     
  269.     msg_req = (wap_mma_get_setting_req_struct*) OslConstructDataPtr(sizeof(wap_mma_get_setting_req_struct));
  270.     msg_req->req_id = g_uc_p->send_info.request_id;
  271.     
  272.     mmi_uc_send_message(
  273.         MOD_MMI,
  274.         MOD_WAP,
  275.         0,
  276.         MSG_ID_WAP_MMA_GET_SETTING_REQ,
  277.         (oslParaType*) msg_req,
  278.         NULL);
  279.     
  280.     return;
  281. }
  282. /*****************************************************************************
  283.  * FUNCTION
  284.  *  mmi_uc_get_mms_setting_rsp
  285.  * DESCRIPTION
  286.  *  Get MMS setting response
  287.  * PARAMETERS
  288.  *  void
  289.  * RETURNS
  290.  *  void
  291.  *****************************************************************************/
  292. void mmi_uc_get_mms_setting_rsp(void *inMsg)
  293. {
  294.     /*----------------------------------------------------------------*/
  295.     /* Local Variables                                                */
  296.     /*----------------------------------------------------------------*/
  297.     wap_mma_get_setting_rsp_struct *msg_rsp = (wap_mma_get_setting_rsp_struct*) inMsg;
  298.     /*----------------------------------------------------------------*/
  299.     /* Code Body                                                      */
  300.     /*----------------------------------------------------------------*/
  301.     MMI_ASSERT(g_uc_p->send_info.request_id == msg_rsp->req_id);
  302.     if (msg_rsp->result != MMA_RESULT_OK)
  303.     {
  304.         mmi_uc_display_mma_result_popup(msg_rsp->result);
  305.         DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);        
  306.         return;
  307.     }
  308.     else
  309.     {
  310.         g_uc_p->mms_info.creation_mode = msg_rsp->creation_mode;
  311.         g_uc_p->mms_info.priority = msg_rsp->priority;
  312.         g_uc_p->mms_info.validity_period = msg_rsp->validity_period;
  313.         g_uc_p->mms_info.delivery_time = msg_rsp->delivery_time;
  314.         g_uc_p->mms_info.delivery_report = msg_rsp->delivery_report;
  315.         g_uc_p->mms_info.read_report = msg_rsp->read_report;
  316.         g_uc_p->mms_info.max_mms_size = msg_rsp->max_mms_size;
  317.         memcpy(&g_uc_p->mms_info.image_resize, &msg_rsp->image_resize, sizeof(msg_rsp->image_resize));
  318.         memcpy(&g_uc_p->mms_info.sliding_time, &msg_rsp->sliding_time, sizeof(msg_rsp->sliding_time));
  319.         /*g_uc_p->mms_info.sender_visibility = msg_rsp->sender_visibility;*/ /*may add sender_visibility in get setting rsp*/
  320.         g_uc_p->mms_info.sender_visibility = MMI_TRUE;
  321.         
  322.         mmi_uc_reset_mms_signature();
  323.         if ((g_uc_p->mms_info.signature.enable = msg_rsp->signature.enable) == TRUE)
  324.         {
  325.             U32 file_path_len;
  326.         
  327.             if ((file_path_len = pfnUnicodeStrlen((S8*)msg_rsp->signature.text_file)) > 0)
  328.             {
  329.                 g_uc_p->mms_info.signature.text_file = kal_adm_alloc(g_uc_p->main.mem_pool_id, 
  330.                                                                      (file_path_len + 1) * ENCODING_LENGTH);
  331.                 pfnUnicodeStrncpy((S8*)g_uc_p->mms_info.signature.text_file, 
  332.                                   (S8*)msg_rsp->signature.text_file,
  333.                                   file_path_len);
  334.             }
  335.             if ((file_path_len = pfnUnicodeStrlen((S8*)msg_rsp->signature.img_file)) > 0)
  336.             {
  337.                 g_uc_p->mms_info.signature.img_file = kal_adm_alloc(g_uc_p->main.mem_pool_id, 
  338.                                                                      (file_path_len + 1) * ENCODING_LENGTH);
  339.             
  340.                 pfnUnicodeStrncpy((S8*)g_uc_p->mms_info.signature.img_file, 
  341.                                   (S8*)msg_rsp->signature.img_file,
  342.                                   file_path_len);
  343.             }
  344.             if ((file_path_len = pfnUnicodeStrlen((S8*)msg_rsp->signature.audio_file)) > 0)
  345.             {
  346.                 g_uc_p->mms_info.signature.audio_file = kal_adm_alloc(g_uc_p->main.mem_pool_id, 
  347.                                                                       (file_path_len + 1) * ENCODING_LENGTH);
  348.             
  349.                 pfnUnicodeStrncpy((S8*)g_uc_p->mms_info.signature.audio_file, 
  350.                                   (S8*)msg_rsp->signature.audio_file,
  351.                                   file_path_len);
  352.             }
  353.             if ((file_path_len = pfnUnicodeStrlen((S8*)msg_rsp->signature.video_file)) > 0)
  354.             {
  355.                 g_uc_p->mms_info.signature.video_file = kal_adm_alloc(g_uc_p->main.mem_pool_id, 
  356.                                                                       (file_path_len + 1) * ENCODING_LENGTH);
  357.              
  358.                 pfnUnicodeStrncpy((S8*)g_uc_p->mms_info.signature.video_file, 
  359.                                   (S8*)msg_rsp->signature.video_file,
  360.                                   file_path_len);
  361.             }
  362.         }        
  363.     }
  364.     
  365.     g_uc_p->msg.read_report = g_uc_p->mms_info.read_report;
  366.     g_uc_p->msg.delivery_report = g_uc_p->mms_info.delivery_report;
  367.     g_uc_p->msg.priority = g_uc_p->mms_info.priority;
  368.     g_uc_p->msg.expiry_time = g_uc_p->mms_info.validity_period;
  369.     g_uc_p->msg.delivery_time = g_uc_p->mms_info.delivery_time;
  370.     g_uc_p->msg.slide_timing = g_uc_p->mms_info.sliding_time.value;
  371.     g_uc_p->msg.sender_visibility = g_uc_p->mms_info.sender_visibility;
  372.     g_uc_p->msg.background_color = MMI_UC_DEFAULT_BG_COLOR;
  373.     g_uc_p->msg.foreground_color = MMI_UC_DEFAULT_FG_COLOR;
  374.                 
  375.     switch (g_uc_p->main.state)
  376.     {
  377.         case MMI_UC_STATE_WRITE_NEW_MSG:
  378.         {            
  379.             /* If enter from mmi_uc_entry_write_msg_with_content, the first slide is ready. */
  380.             if (g_uc_p->msg.total_slide_num == 0)
  381.             {
  382.                 g_uc_p->msg.current_slide = mmi_uc_insert_slide(NULL);
  383.                 g_uc_p->msg.current_slide_num = g_uc_p->msg.current_slide->slide_num;
  384.             }
  385.             else
  386.             {
  387.                 U8 mmi_uc_image_path[MMI_UC_MAX_TEMP_FILE_LEN];
  388.                 U16* filePath = (U16*)g_uc_p->main.file_path;
  389.                 memset(mmi_uc_image_path, 0x00, MMI_UC_MAX_TEMP_FILE_LEN);
  390.                     
  391.                 if (g_uc_p->main.file_path)
  392.                 {
  393.                     mma_insert_check_struct check_result;
  394.                     S32 result;
  395.                     mmi_uc_object_struct* object;
  396.                     mmi_uc_object_type object_type;
  397.                     memset(&check_result,0,sizeof(check_result));
  398.                     wap_mma_uc_insert_object_check(
  399.                                     (kal_wchar*)g_uc_p->main.file_path, 
  400.                                     MMA_INSERT_UNKNOWN, 
  401.                                     g_uc_p->msg.msg_size, 
  402.                                     g_uc_p->mms_info.max_mms_size,
  403.                                     &check_result);
  404.         
  405.                     if (!(check_result.result) && 
  406.                      !(check_result.insert_type == MMA_INSERT_IMAGE && g_uc_p->mms_info.image_resize.enable))
  407.                     {
  408.                         result = mmi_uc_convert_mms_check_result(&check_result);
  409.                         mmi_uc_display_popup(result);
  410.                         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->main.file_path);
  411.                         g_uc_p->main.file_path = NULL;
  412.                         mmi_uc_reset_msg();
  413.                         DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);                        
  414.                         return;
  415.                     }
  416.                     object_type = mmi_uc_convert_mms_insert_type_to_uc(check_result.insert_type);
  417.                     if (object_type == MMI_UC_OBJECT_TYPE_IMAGE)
  418.                     {
  419.                         if (g_uc_p->mms_info.image_resize.enable)
  420.                         {        
  421.                             S32 resize_result;
  422.                             mma_insert_check_struct check_image_result;
  423.                             
  424.                             memset(&check_image_result, 0 ,sizeof(check_image_result));
  425.                             MMI_UC_MAKE_IMAGE_FILE_PATH(mmi_uc_image_path, ++g_uc_p->main.image_no);
  426.                             resize_result = mmi_uc_resize_image(
  427.                                                     (U8*) filePath, 
  428.                                                     mmi_uc_image_path, 
  429.                                                     g_uc_p->mms_info.image_resize.width,
  430.                                                     g_uc_p->mms_info.image_resize.height);
  431.                     
  432.                             /* Error ! */
  433.                             if (resize_result < 0)
  434.                             {                                
  435.                                 /* Check if it is DRM file */                    
  436.                                 wap_mma_uc_insert_object_check(filePath, 
  437.                                                                check_result.insert_type, 
  438.                                                                g_uc_p->msg.msg_size, 
  439.                                                                g_uc_p->mms_info.max_mms_size,
  440.                                                                &check_image_result);
  441.                     
  442.                                 if (check_image_result.result == MMI_TRUE && check_image_result.drm_type == MMA_DRM_SD_NO_RIGHT)
  443.                                 {
  444.                                     /* allows inserted but display default image for thumbnail. */
  445.                                 }
  446.                                 else
  447.                                 {            
  448.                                     mmi_uc_display_resize_result_popup(resize_result);
  449.                                     kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->main.file_path);
  450.                                     g_uc_p->main.file_path = NULL;                                    
  451.                                     mmi_uc_reset_msg();                                    
  452.                                     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  453.                                     return;
  454.                                 }                    
  455.                             }
  456.                             /* resized */
  457.                             else if (resize_result)
  458.                             {
  459.                                 filePath = (PU16)mmi_uc_image_path;
  460.                             }
  461.                             /* resize_result == 0 means no need to resize */
  462.                             memset(&check_image_result, 0 ,sizeof(check_image_result));
  463.                             /* The img size may exceed limitation even if it is resized. */                    
  464.                             wap_mma_uc_insert_object_check(filePath, 
  465.                                                            check_result.insert_type, 
  466.                                                            g_uc_p->msg.msg_size, 
  467.                                                            g_uc_p->mms_info.max_mms_size,
  468.                                                            &check_image_result);
  469.                             if (!(check_image_result.result))
  470.                             {
  471.                                 result = mmi_uc_convert_mms_check_result(&check_image_result);
  472.                                 mmi_uc_display_popup(result);
  473.                                 kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->main.file_path);
  474.                                 g_uc_p->main.file_path = NULL;
  475.                                 mmi_uc_reset_msg();
  476.                                 DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);                        
  477.                                 return;
  478.                             }
  479.                             
  480.                         }
  481.                     }
  482.                     
  483.                     object = mmi_uc_insert_object((S8*) filePath, object_type);
  484.                     object->drm_type = check_result.drm_type;
  485.                     
  486.                     if (object_type == MMI_UC_OBJECT_TYPE_ATTACHMENT)
  487.                     {
  488.                         mmi_uc_attachment_info_struct* att;
  489.                         att = mmi_uc_insert_attachment();
  490.                         mmi_uc_insert_object_to_attachment(object, att);
  491.                     }
  492.                     else
  493.                     {
  494.                         mmi_uc_insert_object_to_slide(object, g_uc_p->msg.current_slide, object_type);
  495.                     }
  496.                     
  497.                     /* Determine layout */
  498.                     if (object_type == MMI_UC_OBJECT_TYPE_IMAGE || object_type == MMI_UC_OBJECT_TYPE_VIDEO)
  499.                     {
  500.                         if (g_uc_p->msg.layout == MMI_UC_LAYOUT_DEFAULT)
  501.                         {
  502.                             if (g_uc_p->msg.current_slide->text.char_count)
  503.                             {
  504.                                 g_uc_p->msg.layout = MMI_UC_LAYOUT_THUMBNAIL_AT_BOTTOM;
  505.                             }
  506.                             else
  507.                             {
  508.                                 g_uc_p->msg.layout = MMI_UC_LAYOUT_THUMBNAIL_AT_TOP;
  509.                             }
  510.                         }
  511.                     }   
  512.                     
  513.                     kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->main.file_path);
  514.                     g_uc_p->main.file_path = NULL;
  515.                 }
  516.                 mmi_uc_change_msg_type_if_needed();
  517.             }
  518.             
  519.             mmi_uc_insert_signature_check();
  520.             mmi_uc_switch_slide(g_uc_p->msg.current_slide);
  521.             mmi_uc_update_msg_size();            
  522.             mmi_uc_entry_write_msg();
  523.         }
  524.         break;
  525.         case MMI_UC_STATE_EDIT_EXISTED_MSG:
  526.         case MMI_UC_STATE_FORWARD:
  527.         case MMI_UC_STATE_SEND:
  528.         case MMI_UC_STATE_REPLY:
  529.         case MMI_UC_STATE_REPLY_ALL:
  530.         {
  531.             if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  532.             {
  533.                 mmi_uc_change_msg_type_if_needed();
  534.                 if (g_uc_p->main.state == MMI_UC_STATE_EDIT_EXISTED_MSG ||
  535.                     g_uc_p->main.state == MMI_UC_STATE_REPLY||
  536.                     g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL)
  537.                 {
  538.                     mmi_uc_insert_signature_check();
  539.                     
  540.                     mmi_uc_switch_slide(g_uc_p->msg.current_slide);
  541.                     mmi_uc_entry_write_msg();                    
  542.                 }
  543.                 else
  544.                 {
  545.                     g_uc_p->done.pre_msg_type = g_uc_p->msg_type.curr_msg_type;
  546.                     
  547.                     /* tricky! disallow to insert signature for forward and send case */
  548.                     g_uc_p->msg.signature_inserted = MMI_TRUE; 
  549.                     
  550.                     mmi_uc_entry_done();
  551.                     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  552.                 }                
  553.             }
  554.             else if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  555.             {
  556.                 mmi_uc_get_mms_content_req();
  557.             }
  558.             else
  559.             {
  560.                 MMI_ASSERT(0);
  561.             }            
  562.         }
  563.         break;
  564.         default:
  565.         {
  566.             MMI_ASSERT(0);
  567.         }
  568.         break;
  569.     }   
  570.     return;
  571. }
  572. /*****************************************************************************
  573.  * FUNCTION
  574.  *  mmi_uc_get_mms_content_req
  575.  * DESCRIPTION
  576.  *  Get MMS content request
  577.  * PARAMETERS
  578.  *  void
  579.  * RETURNS
  580.  *  void
  581.  *****************************************************************************/
  582. void mmi_uc_get_mms_content_req(void)
  583. {
  584.     /*----------------------------------------------------------------*/
  585.     /* Local Variables                                                */
  586.     /*----------------------------------------------------------------*/
  587.     wap_mma_get_content_req_struct *msg_req;
  588.     /*----------------------------------------------------------------*/
  589.     /* Code Body                                                      */
  590.     /*----------------------------------------------------------------*/
  591.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  592.     
  593.     msg_req = (wap_mma_get_content_req_struct*) OslConstructDataPtr(sizeof(wap_mma_get_content_req_struct));
  594.     
  595.     msg_req->req_id = g_uc_p->send_info.request_id;
  596.     msg_req->msg_id = g_uc_p->send_info.existed_msg_id;
  597.     msg_req->buffer_index = g_uc_p->send_info.buffer_index = 0;
  598.     /* For Forward and Re-send MMS cases, the MMS msg may become SMS message before send */
  599.     /* so the msg content should be gotten besides addresses */
  600.     //msg_req->mode = mmi_uc_convert_uc_state_to_mms_app_mode(g_uc_p->main.state);
  601.     if (g_uc_p->main.state == MMI_UC_STATE_REPLY)
  602.     {
  603.         msg_req->mode = MMA_MODE_REPLY;
  604.     }
  605.     else if (g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL)
  606.     {
  607.         msg_req->mode = MMA_MODE_REPLY_ALL;
  608.     }
  609.     else if (g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  610.     {
  611.         msg_req->mode = MMA_MODE_FORWARD;
  612.     }
  613.     else if (g_uc_p->main.state == MMI_UC_STATE_SEND)
  614.     {
  615.         msg_req->mode = MMA_MODE_SEND;
  616.     }
  617.     else
  618.     {
  619.         msg_req->mode = MMA_MODE_EDIT;
  620.     }
  621.     
  622.     msg_req->creation_mode = g_uc_p->mms_info.creation_mode;
  623.     mmi_uc_send_message(
  624.         MOD_MMI,
  625.         MOD_WAP,
  626.         0,
  627.         MSG_ID_WAP_MMA_GET_CONTENT_REQ,
  628.         (oslParaType*) msg_req,
  629.         NULL);
  630.     
  631.     return;
  632. }
  633. /*****************************************************************************
  634.  * FUNCTION
  635.  *  mmi_uc_get_mms_content_rsp
  636.  * DESCRIPTION
  637.  *  Get MMS content response
  638.  * PARAMETERS
  639.  *  void
  640.  * RETURNS
  641.  *  void
  642.  *****************************************************************************/
  643. void mmi_uc_get_mms_content_rsp(void *inMsg)
  644. {
  645.     /*----------------------------------------------------------------*/
  646.     /* Local Variables                                                */
  647.     /*----------------------------------------------------------------*/
  648.     wap_mma_get_content_rsp_struct *msg_rsp = (wap_mma_get_content_rsp_struct*) inMsg;
  649.     S32 result;
  650.     /*----------------------------------------------------------------*/
  651.     /* Code Body                                                      */
  652.     /*----------------------------------------------------------------*/
  653.     MMI_ASSERT(msg_rsp->req_id == g_uc_p->send_info.request_id);
  654.     MMI_ASSERT(msg_rsp->msg_id == g_uc_p->send_info.existed_msg_id);
  655.     MMI_ASSERT(msg_rsp->buffer_index == g_uc_p->send_info.buffer_index);    
  656.     if (msg_rsp->result != MMA_RESULT_OK)
  657.     {
  658.         mmi_uc_display_mma_result_popup(msg_rsp->result);
  659.         
  660.         DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);        
  661.     }
  662.     else
  663.     {
  664.         g_uc_p->msg.msg_body_size = msg_rsp->mms_body_size;
  665.         g_uc_p->msg.msg_size = msg_rsp->mms_header_size + msg_rsp->mms_body_size;
  666.         if (msg_rsp->more)
  667.         {
  668.             /*----------------------------------------------------------------*/
  669.             /* Local Variables                                                */
  670.             /*----------------------------------------------------------------*/
  671.             wap_mma_get_content_req_struct *msg_req;
  672.             /*----------------------------------------------------------------*/
  673.             /* Code Body                                                      */
  674.             /*----------------------------------------------------------------*/            
  675.             msg_req = (wap_mma_get_content_req_struct*) OslConstructDataPtr(sizeof(wap_mma_get_content_req_struct));
  676.  
  677.             g_uc_p->send_info.buffer_index++;
  678.             msg_req->req_id = g_uc_p->send_info.request_id;
  679.             msg_req->msg_id = g_uc_p->send_info.existed_msg_id;
  680.             msg_req->buffer_index = g_uc_p->send_info.buffer_index;
  681.             msg_req->mode = mmi_uc_convert_uc_state_to_mms_app_mode((U16)g_uc_p->main.state);
  682.             mmi_uc_send_message(
  683.                 MOD_MMI,
  684.                 MOD_WAP,
  685.                 0,
  686.                 MSG_ID_WAP_MMA_GET_CONTENT_REQ,
  687.                 (oslParaType*) msg_req,
  688.                 NULL);
  689.         }
  690.         else
  691.         {
  692.             g_uc_p->send_info.xml_file_size = msg_rsp->xml_size;
  693.             mmi_uc_editor_initialize();
  694.             /* parse the XML file*/
  695.             result = mmi_uc_parse_mms_xml_description_file(msg_rsp->xml_filepath);
  696.             if (result != MMI_UC_OK)
  697.             {
  698.                 mmi_uc_display_popup(result);
  699.                 DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  700.                 mmi_uc_reset_msg();
  701.             }
  702.             else
  703.             {
  704.                 switch (g_uc_p->main.state)
  705.                 {
  706.                     case MMI_UC_STATE_EDIT_EXISTED_MSG:
  707.                     case MMI_UC_STATE_REPLY:
  708.                     case MMI_UC_STATE_REPLY_ALL:
  709.                     {   
  710.                         /* In reply case, there is no content. */
  711.                         if (g_uc_p->msg.total_slide_num == 0)
  712.                         {
  713.                             g_uc_p->msg.current_slide = mmi_uc_insert_slide(NULL);
  714.                         }
  715.                         else
  716.                         {
  717.                             g_uc_p->msg.current_slide = g_uc_p->msg.slide_head;            
  718.                         }                        
  719.                         
  720.                         g_uc_p->msg.current_slide_num = g_uc_p->msg.current_slide->slide_num;
  721.                         mmi_uc_change_msg_type_if_needed();
  722.                         
  723.                         mmi_uc_insert_signature_check();
  724.                         /* (MMS template -> write msg) should be taken as write new msg case */
  725.                         if (g_uc_p->main.state == MMI_UC_STATE_EDIT_EXISTED_MSG &&
  726.                             wap_mma_get_box(g_uc_p->send_info.existed_msg_id) == MMA_FOLDER_TEMPLATE)
  727.                         {
  728.                             g_uc_p->main.state = MMI_UC_STATE_WRITE_NEW_MSG;
  729.                         }
  730.                         //mmi_uc_change_msg_type_if_needed();
  731.                         
  732.                         mmi_uc_switch_slide(g_uc_p->msg.current_slide);
  733.                         mmi_uc_update_msg_size();
  734.                         mmi_uc_entry_write_msg();
  735.                     }
  736.                     break;
  737.                     case MMI_UC_STATE_FORWARD:
  738.                     case MMI_UC_STATE_SEND:
  739.                     {
  740.                         g_uc_p->msg.current_slide = g_uc_p->msg.slide_head;            
  741.                         
  742.                         /* In forward case, there is no content. */
  743.                         if (g_uc_p->msg.current_slide)
  744.                         {
  745.                             g_uc_p->msg.current_slide_num = g_uc_p->msg.current_slide->slide_num;
  746.                         }
  747.                         
  748.                         //mmi_uc_change_msg_type_if_needed();
  749.                         g_uc_p->msg_type.caller_specific_msg_type = MMI_UC_MSG_TYPE_MMS_ONLY;                        
  750.                         g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_MMS_PREFER;
  751.                                                         
  752.                         g_uc_p->done.pre_msg_type = g_uc_p->msg_type.curr_msg_type;
  753.                         
  754.                         /* tricky! disallow to insert signature for forward and send case */
  755.                         g_uc_p->msg.signature_inserted = MMI_TRUE; 
  756.                         
  757.                         mmi_uc_switch_slide(g_uc_p->msg.current_slide);
  758.                         mmi_uc_update_msg_size();
  759.                         mmi_uc_entry_done();
  760.                         DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  761.                     }
  762.                     break;
  763.                     default:
  764.                     {
  765.                         MMI_ASSERT(0);
  766.                     }
  767.                     break;
  768.                 }   
  769.                 return;
  770.             }
  771.         }               
  772.     }
  773. }
  774. /*****************************************************************************
  775.  * FUNCTION
  776.  *  mmi_uc_create_mms_req
  777.  * DESCRIPTION
  778.  *  Create MMS msg request
  779.  * PARAMETERS
  780.  *  void
  781.  * RETURNS
  782.  *  void
  783.  *****************************************************************************/
  784. void mmi_uc_create_mms_req(void)
  785. {
  786.     /*----------------------------------------------------------------*/
  787.     /* Local Variables                                                */
  788.     /*----------------------------------------------------------------*/
  789.     wap_mma_create_req_struct *msg_req;
  790.     peer_buff_struct *peer_buff_ptr;
  791.     U32 read_size;
  792.     U16 peer_buff_len = 0;
  793.     /*----------------------------------------------------------------*/
  794.     /* Code Body                                                      */
  795.     /*----------------------------------------------------------------*/
  796.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  797.     
  798.     msg_req = (wap_mma_create_req_struct*) OslConstructDataPtr(sizeof(wap_mma_create_req_struct));
  799.     msg_req->req_id = g_uc_p->send_info.request_id;
  800.     /* reset */
  801.     msg_req->mode = MMA_MODE_EDIT;
  802.     msg_req->msg_id = 0;
  803.     if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER )
  804.     {
  805.         if (g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  806.         {
  807.             msg_req->msg_id = g_uc_p->send_info.existed_msg_id;
  808.             msg_req->mode = MMA_MODE_FORWARD;
  809.         }
  810.         else if (g_uc_p->main.state == MMI_UC_STATE_SEND)
  811.         {
  812.             msg_req->msg_id = g_uc_p->send_info.existed_msg_id;
  813.             msg_req->mode = MMA_MODE_SEND;
  814.         }
  815.     }
  816.     
  817.     MMI_UC_MAKE_MMS_XML_FILE_PATH(msg_req->xml_filepath, 0);
  818.     msg_req->xml_size = g_uc_p->send_info.xml_file_size = applib_get_file_size(msg_req->xml_filepath);
  819.     msg_req->buffer_index = g_uc_p->send_info.buffer_index = 0;
  820.     if (msg_req->xml_size <= MMI_UC_MAX_XML_SIZE_IN_PEER_BUFFER)
  821.     {
  822.         msg_req->buffer_size = msg_req->xml_size;
  823.         msg_req->more = KAL_FALSE;
  824.     }
  825.     else
  826.     {
  827.         msg_req->buffer_size = MMI_UC_MAX_XML_SIZE_IN_PEER_BUFFER;
  828.         msg_req->more = KAL_TRUE;
  829.     }
  830.     peer_buff_ptr = construct_peer_buff((kal_uint16) msg_req->buffer_size, 0, 0, TD_CTRL);
  831.     
  832.     g_uc_p->send_info.fs = FS_Open(msg_req->xml_filepath, FS_READ_ONLY );
  833.     
  834.     if( FS_Read( g_uc_p->send_info.fs, get_pdu_ptr(peer_buff_ptr, &peer_buff_len), msg_req->buffer_size, &read_size ) != FS_NO_ERROR ||
  835.         read_size != msg_req->buffer_size)
  836.     {
  837.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  838.                  "*[UnifiedComposerMsg.c] mmi_uc_create_mms_req read_size=%d buf_size=%d*n",
  839.                  read_size, msg_req->buffer_size));
  840.     }
  841.     
  842.     mmi_uc_send_message(
  843.         MOD_MMI,
  844.         MOD_WAP,
  845.         0,
  846.         MSG_ID_WAP_MMA_CREATE_REQ,
  847.         (oslParaType*) msg_req,
  848.         peer_buff_ptr);
  849.     
  850.     return;
  851. }
  852. /*****************************************************************************
  853.  * FUNCTION
  854.  *  mmi_uc_create_mms_rsp
  855.  * DESCRIPTION
  856.  *  Create MMS msg response
  857.  * PARAMETERS
  858.  *  void
  859.  * RETURNS
  860.  *  void
  861.  *****************************************************************************/
  862. void mmi_uc_create_mms_rsp(void *inMsg)
  863. {
  864.     /*----------------------------------------------------------------*/
  865.     /* Local Variables                                                */
  866.     /*----------------------------------------------------------------*/
  867.     wap_mma_create_rsp_struct *msg_rsp = (wap_mma_create_rsp_struct*) inMsg;
  868.     /*----------------------------------------------------------------*/
  869.     /* Code Body                                                      */
  870.     /*----------------------------------------------------------------*/
  871.     MMI_ASSERT(msg_rsp->req_id == g_uc_p->send_info.request_id);
  872.     if (msg_rsp->result != MMA_RESULT_OK)
  873.     {
  874.         if (g_uc_p->send_info.action != MMI_UC_ACTION_SAVE_IN_BACKGROUND)
  875.         {
  876.             mmi_uc_display_mma_result_popup(msg_rsp->result);
  877.         }
  878.         
  879.         FS_Close( g_uc_p->send_info.fs);
  880.         DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  881.         /* reset state */
  882.         g_uc_p->send_info.action = MMI_UC_ACTION_IDLE;
  883.     }
  884.     else
  885.     {
  886.         /* More XML content needs to send */
  887.         if (msg_rsp->msg_id == 0)
  888.         {
  889.             wap_mma_create_req_struct *msg_req;
  890.             peer_buff_struct *peer_buff_ptr;
  891.             U32 read_size;
  892.             S32 remaining_size;
  893.             U16 peer_buff_len = 0;
  894.             MMI_ASSERT(msg_rsp->buffer_index == g_uc_p->send_info.buffer_index + 1);
  895.             msg_req = (wap_mma_create_req_struct*) OslConstructDataPtr(sizeof(wap_mma_create_req_struct));
  896.             msg_req->req_id = g_uc_p->send_info.request_id;
  897.             /* reset */
  898.             msg_req->mode = MMA_MODE_EDIT;
  899.             msg_req->msg_id = 0;
  900.             if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER )
  901.             {
  902.                 if (g_uc_p->main.state == MMI_UC_STATE_FORWARD ||
  903.                     g_uc_p->main.state == MMI_UC_STATE_SEND)
  904.                 {
  905.                     msg_req->msg_id = g_uc_p->send_info.existed_msg_id;
  906.                 }
  907.                 if (g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  908.                 {        
  909.                     msg_req->mode = MMA_MODE_FORWARD;
  910.                 }
  911.                 else if (g_uc_p->main.state == MMI_UC_STATE_SEND)
  912.                 {        
  913.                     msg_req->mode = MMA_MODE_SEND;
  914.                 }
  915.             }            
  916.             MMI_UC_MAKE_MMS_XML_FILE_PATH(msg_req->xml_filepath, 0);
  917.             msg_req->xml_size = g_uc_p->send_info.xml_file_size;
  918.             g_uc_p->send_info.buffer_index++;
  919.             msg_req->buffer_index = g_uc_p->send_info.buffer_index;
  920.             remaining_size  = g_uc_p->send_info.xml_file_size - 
  921.                               (msg_req->buffer_index * MMI_UC_MAX_XML_SIZE_IN_PEER_BUFFER);
  922.             if (remaining_size <= MMI_UC_MAX_XML_SIZE_IN_PEER_BUFFER)
  923.             {
  924.                 msg_req->buffer_size = remaining_size;
  925.                 msg_req->more = KAL_FALSE;
  926.             }
  927.             else
  928.             {
  929.                 msg_req->buffer_size = MMI_UC_MAX_XML_SIZE_IN_PEER_BUFFER;
  930.                 msg_req->more = KAL_TRUE;
  931.             }
  932.             peer_buff_ptr = construct_peer_buff((kal_uint16) msg_req->buffer_size, 0, 0, TD_CTRL);
  933.             
  934.             if( FS_Read( g_uc_p->send_info.fs, get_pdu_ptr(peer_buff_ptr, &peer_buff_len), msg_req->buffer_size, &read_size ) != FS_NO_ERROR ||
  935.                 read_size != msg_req->buffer_size)
  936.             {
  937.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  938.                          "*[UnifiedComposerMsg.c] mmi_uc_create_mms_rsp read_size=%d buf_size=%d*n",
  939.                          read_size, msg_req->buffer_size));
  940.             }
  941.             
  942.             mmi_uc_send_message(
  943.                 MOD_MMI,
  944.                 MOD_WAP,
  945.                 0,
  946.                 MSG_ID_WAP_MMA_CREATE_REQ,
  947.                 (oslParaType*) msg_req,
  948.                 peer_buff_ptr);            
  949.         }   
  950.         /* sending XML content completes */
  951.         else
  952.         {
  953.             FS_Close(g_uc_p->send_info.fs);
  954.             g_uc_p->send_info.new_msg_id = msg_rsp->msg_id;
  955.             
  956.             switch (g_uc_p->send_info.action)
  957.             {
  958.                 case MMI_UC_ACTION_SEND:
  959.                 {
  960.                     mmi_uc_send_mms();
  961.                     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);                    
  962.                 }
  963.                 break;
  964.                 
  965.                 case MMI_UC_ACTION_SEND_AND_SAVE:
  966.                 {
  967.                     mmi_uc_send_and_save_mms();
  968.                     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);                    
  969.                 }
  970.                 break;
  971.                 case MMI_UC_ACTION_SAVE:
  972.                 {
  973.                     UmMsgBoxType msg_box = mmi_um_get_current_msg_box_type();
  974.                     
  975.                     if (g_uc_p->main.state == MMI_UC_STATE_EDIT_EXISTED_MSG &&
  976.                         msg_box == UM_MSG_BOX_TYPE_DRAFT)
  977.                     {
  978.                         mmi_uc_set_processing_screen(
  979.                                     STR_GLOBAL_SAVING, 
  980.                                     STR_UC_PLEASE_WAIT_ID, 
  981.                                     IMG_GLOBAL_PROGRESS, 
  982.                                     0);
  983.                         
  984.                         mmi_uc_entry_processing_generic();
  985.                         
  986.                         /* save msg from MMS to SMS. Save new one and then delete original one. */
  987.                         if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  988.                         {                                
  989.                             mmi_uc_save_mms_req(g_uc_p->send_info.new_msg_id, MMA_FOLDER_DRAFT);
  990.                         }
  991.                         /* save msg from MMS to MMS. Delete original one and then save new one. */
  992.                         else if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  993.                         {
  994.                             mmi_uc_delete_existed_mms();
  995.                         }
  996.                         else
  997.                         {
  998.                             MMI_ASSERT(0);
  999.                         }
  1000.                     }
  1001.                     else
  1002.                     {
  1003.                         mmi_uc_save_mms();
  1004.                     }
  1005.                     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);                    
  1006.                 }
  1007.                 break;
  1008.                 case MMI_UC_ACTION_SAVE_IN_BACKGROUND:
  1009.                 {
  1010.                     mmi_uc_save_mms_req(g_uc_p->send_info.new_msg_id, MMA_FOLDER_DRAFT);
  1011.                 }
  1012.                 break;
  1013.                 case MMI_UC_ACTION_PREVIEW:
  1014.                 {
  1015.                     mmi_uc_preview_mms();
  1016.                     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  1017.                 }
  1018.                 break;
  1019.                 default:
  1020.                 {
  1021.                     MMI_ASSERT(0);
  1022.                 }
  1023.             }                
  1024.         }
  1025.     }
  1026.     
  1027. }
  1028. /*****************************************************************************
  1029.  * FUNCTION
  1030.  *  mmi_uc_send_mms_req
  1031.  * DESCRIPTION
  1032.  *  Send MMS msg request
  1033.  * PARAMETERS
  1034.  *  void
  1035.  * RETURNS
  1036.  *  void
  1037.  *****************************************************************************/
  1038. void mmi_uc_send_mms_req(BOOL send_and_save, U16 msg_box_to_save)
  1039. {
  1040.     /*----------------------------------------------------------------*/
  1041.     /* Local Variables                                                */
  1042.     /*----------------------------------------------------------------*/
  1043.     wap_mma_send_req_struct *msg_req;
  1044.     /*----------------------------------------------------------------*/
  1045.     /* Code Body                                                      */
  1046.     /*----------------------------------------------------------------*/
  1047.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  1048.     
  1049.     msg_req = (wap_mma_send_req_struct*) OslConstructDataPtr(sizeof(wap_mma_send_req_struct));
  1050.     msg_req->req_id = g_uc_p->send_info.request_id;
  1051.     msg_req->msg_id = g_uc_p->send_info.new_msg_id;
  1052.     if (send_and_save)
  1053.     {
  1054.         msg_req->send_and_save = KAL_TRUE;
  1055.         msg_req->box = msg_box_to_save;
  1056.     }
  1057.     else
  1058.     {
  1059.         msg_req->send_and_save = KAL_FALSE;
  1060.         msg_req->box = 0;
  1061.     }
  1062.     
  1063.     mmi_uc_send_message(
  1064.         MOD_MMI,
  1065.         MOD_WAP,
  1066.         0,
  1067.         MSG_ID_WAP_MMA_SEND_REQ,
  1068.         (oslParaType*) msg_req,
  1069.         NULL);
  1070.     
  1071.     return;
  1072. }
  1073.     
  1074. /*****************************************************************************
  1075.  * FUNCTION
  1076.  *  mmi_uc_send_mms_ind_hdlr
  1077.  * DESCRIPTION
  1078.  *  Send MMS message indication handler
  1079.  * PARAMETERS
  1080.  *  void
  1081.  * RETURNS
  1082.  *  void
  1083.  *****************************************************************************/
  1084. void mmi_uc_send_mms_ind_hdlr(void *inMsg)
  1085. {
  1086.     /*----------------------------------------------------------------*/
  1087.     /* Local Variables                                                */
  1088.     /*----------------------------------------------------------------*/
  1089.     wap_mma_send_ind_struct *msg_ind = (wap_mma_send_ind_struct*) inMsg;;
  1090.     /*----------------------------------------------------------------*/
  1091.     /* Code Body                                                      */
  1092.     /*----------------------------------------------------------------*/
  1093.     if (g_uc_p->send_info.request_id != msg_ind->req_id ||
  1094.         g_uc_p->send_info.new_msg_id != msg_ind->msg_id )
  1095.     {
  1096.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[UnifiedComposerMsg.c] mmi_uc_send_mms_ind_hdlr IGNORE! *n"));
  1097.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1098.                      "*[UnifiedComposerMain.c] mmi_uc_send_mms_ind_hdlr IGNORE! req_id=%d new_msg_id=%d *n",
  1099.                      g_uc_p->send_info.request_id, g_uc_p->send_info.new_msg_id));
  1100.         return;
  1101.     }
  1102.     mmi_uc_update_sending_mms_percent(msg_ind->percent);
  1103.     
  1104. }
  1105. /*****************************************************************************
  1106.  * FUNCTION
  1107.  *  mmi_uc_send_mms_rsp
  1108.  * DESCRIPTION
  1109.  *  Send MMS msg response
  1110.  * PARAMETERS
  1111.  *  void
  1112.  * RETURNS
  1113.  *  void
  1114.  *****************************************************************************/
  1115. void mmi_uc_send_mms_rsp(void *inMsg)
  1116. {
  1117.     /*----------------------------------------------------------------*/
  1118.     /* Local Variables                                                */
  1119.     /*----------------------------------------------------------------*/
  1120.     wap_mma_send_rsp_struct *msg_rsp = (wap_mma_send_rsp_struct*) inMsg;
  1121.     /*----------------------------------------------------------------*/
  1122.     /* Code Body                                                      */
  1123.     /*----------------------------------------------------------------*/
  1124.     //MMI_ASSERT(g_uc_p->send_info.request_id == msg_rsp->req_id );
  1125.     MMI_ASSERT(g_uc_p->send_info.new_msg_id == msg_rsp->msg_id);
  1126.     g_uc_p->send_info.send_result = msg_rsp->result;
  1127.     if (g_uc_p->send_info.fail_cause)
  1128.     {
  1129.         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->send_info.fail_cause);
  1130.         g_uc_p->send_info.fail_cause = NULL;
  1131.     } 
  1132.     if (msg_rsp->result != MMA_RESULT_OK && pfnUnicodeStrlen((S8*)msg_rsp->response_text))
  1133.     {
  1134.         U32 str_len = pfnUnicodeStrlen((S8*)msg_rsp->response_text);
  1135.         g_uc_p->send_info.fail_cause = kal_adm_alloc(g_uc_p->main.mem_pool_id, (str_len + 1) * ENCODING_LENGTH);
  1136.         if (g_uc_p->send_info.fail_cause != NULL)
  1137.         {
  1138.             memset(g_uc_p->send_info.fail_cause , 0, (str_len + 1) * ENCODING_LENGTH);
  1139.             pfnUnicodeStrncpy((S8*)g_uc_p->send_info.fail_cause,  (S8*)msg_rsp->response_text, str_len);
  1140.         }
  1141.         else
  1142.         {
  1143.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1144.                              "*[UnifiedComposerMsg.c] mmi_uc_send_mms_rsp fail_cause memory not allocated! len=%d*n",
  1145.                              str_len));
  1146.         }
  1147.     }
  1148.     
  1149.     mmi_uc_action_fsm(MMI_UC_ACTION_SEND, msg_rsp->result);    
  1150. }
  1151. /*****************************************************************************
  1152.  * FUNCTION
  1153.  *  mmi_uc_delete_mms_req
  1154.  * DESCRIPTION
  1155.  *  Delete MMS msg request
  1156.  * PARAMETERS
  1157.  *  void
  1158.  * RETURNS
  1159.  *  void
  1160.  *****************************************************************************/
  1161. void mmi_uc_delete_mms_req(U16 msg_id)
  1162. {
  1163.     /*----------------------------------------------------------------*/
  1164.     /* Local Variables                                                */
  1165.     /*----------------------------------------------------------------*/
  1166.     wap_mma_delete_req_struct *msg_req;
  1167.     /*----------------------------------------------------------------*/
  1168.     /* Code Body                                                      */
  1169.     /*----------------------------------------------------------------*/
  1170.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  1171.     MMI_ASSERT(msg_id);
  1172.     
  1173.     msg_req = (wap_mma_delete_req_struct*) OslConstructDataPtr(sizeof(wap_mma_delete_req_struct));
  1174.     msg_req->req_id = g_uc_p->send_info.request_id;
  1175.     msg_req->msg_id = msg_id;
  1176.     
  1177.     mmi_uc_send_message(
  1178.         MOD_MMI,
  1179.         MOD_WAP,
  1180.         0,
  1181.         MSG_ID_WAP_MMA_DELETE_REQ,
  1182.         (oslParaType*) msg_req,
  1183.         NULL);
  1184.     
  1185.     return;
  1186. }
  1187. /*****************************************************************************
  1188.  * FUNCTION
  1189.  *  mmi_uc_delete_mms_rsp
  1190.  * DESCRIPTION
  1191.  *  Delete MMS msg response
  1192.  * PARAMETERS
  1193.  *  void
  1194.  * RETURNS
  1195.  *  void
  1196.  *****************************************************************************/
  1197. void mmi_uc_delete_mms_rsp(void *in_msg)
  1198. {
  1199.     /*----------------------------------------------------------------*/
  1200.     /* Local Variables                                                */
  1201.     /*----------------------------------------------------------------*/
  1202.     wap_mma_rsp_struct *msg_rsp = (wap_mma_rsp_struct*) in_msg;
  1203.     /*----------------------------------------------------------------*/
  1204.     /* Code Body                                                      */
  1205.     /*----------------------------------------------------------------*/
  1206.     //MMI_ASSERT(g_uc_p->send_info.request_id == msg_rsp->req_id );
  1207.     if (g_uc_p->send_info.request_id == msg_rsp->req_id)
  1208.     {
  1209.         mmi_uc_action_fsm(MMI_UC_ACTION_DELETE, msg_rsp->result);    
  1210.     }
  1211.     else
  1212.     {
  1213.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1214.                      "*[UnifiedComposerMain.c] mmi_uc_delete_mms_rsp IGNORE! req_id=%d *n",
  1215.                      g_uc_p->send_info.request_id));
  1216.     }
  1217. }
  1218. /*****************************************************************************
  1219.  * FUNCTION
  1220.  *  mmi_uc_save_mms_req
  1221.  * DESCRIPTION
  1222.  *  Save MMS msg request
  1223.  * PARAMETERS
  1224.  *  void
  1225.  * RETURNS
  1226.  *  void
  1227.  *****************************************************************************/
  1228. void mmi_uc_save_mms_req(U16 msg_id, U16 msg_box)
  1229. {
  1230.     /*----------------------------------------------------------------*/
  1231.     /* Local Variables                                                */
  1232.     /*----------------------------------------------------------------*/
  1233.     wap_mma_save_req_struct *msg_req;
  1234.     /*----------------------------------------------------------------*/
  1235.     /* Code Body                                                      */
  1236.     /*----------------------------------------------------------------*/
  1237.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  1238.     
  1239.     msg_req = (wap_mma_save_req_struct*) OslConstructDataPtr(sizeof(wap_mma_save_req_struct));
  1240.     msg_req->req_id = g_uc_p->send_info.request_id;
  1241.     msg_req->msg_id = msg_id;
  1242.     msg_req->box = msg_box;
  1243.     
  1244.     mmi_uc_send_message(
  1245.         MOD_MMI,
  1246.         MOD_WAP,
  1247.         0,
  1248.         MSG_ID_WAP_MMA_SAVE_REQ,
  1249.         (oslParaType*) msg_req,
  1250.         NULL);
  1251.     
  1252.     return;
  1253. }
  1254. /*****************************************************************************
  1255.  * FUNCTION
  1256.  *  mmi_uc_save_mms_rsp
  1257.  * DESCRIPTION
  1258.  *  Save MMS msg response
  1259.  * PARAMETERS
  1260.  *  void
  1261.  * RETURNS
  1262.  *  void
  1263.  *****************************************************************************/
  1264. void mmi_uc_save_mms_rsp(void *in_msg)
  1265. {
  1266.     /*----------------------------------------------------------------*/
  1267.     /* Local Variables                                                */
  1268.     /*----------------------------------------------------------------*/
  1269.     wap_mma_rsp_struct *msg_rsp = (wap_mma_rsp_struct*) in_msg;
  1270.     /*----------------------------------------------------------------*/
  1271.     /* Code Body                                                      */
  1272.     /*----------------------------------------------------------------*/
  1273.     MMI_ASSERT(g_uc_p->send_info.request_id == msg_rsp->req_id );
  1274.     
  1275.     mmi_uc_action_fsm(MMI_UC_ACTION_SAVE, msg_rsp->result);    
  1276. }
  1277. /*****************************************************************************
  1278.  * FUNCTION
  1279.  *  mmi_uc_abort_send_mms_req
  1280.  * DESCRIPTION
  1281.  *  Abort sending MMS msg request
  1282.  * PARAMETERS
  1283.  *  void
  1284.  * RETURNS
  1285.  *  void
  1286.  *****************************************************************************/
  1287. void mmi_uc_abort_send_mms_req(U16 msg_id)
  1288. {
  1289.     /*----------------------------------------------------------------*/
  1290.     /* Local Variables                                                */
  1291.     /*----------------------------------------------------------------*/
  1292.     wap_mma_cancel_send_req_struct *msg_req;
  1293.     /*----------------------------------------------------------------*/
  1294.     /* Code Body                                                      */
  1295.     /*----------------------------------------------------------------*/
  1296.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  1297.     
  1298.     msg_req = (wap_mma_cancel_send_req_struct*) OslConstructDataPtr(sizeof(wap_mma_cancel_send_req_struct));
  1299.     msg_req->req_id = g_uc_p->send_info.request_id;
  1300.     msg_req->msg_id = msg_id;
  1301.     
  1302.     mmi_uc_send_message(
  1303.         MOD_MMI,
  1304.         MOD_WAP,
  1305.         0,
  1306.         MSG_ID_WAP_MMA_CANCEL_SEND_REQ,
  1307.         (oslParaType*) msg_req,
  1308.         NULL);
  1309.     
  1310.     return;
  1311. }
  1312. /*****************************************************************************
  1313.  * FUNCTION
  1314.  *  mmi_uc_abort_send_mms_rsp
  1315.  * DESCRIPTION
  1316.  *  Abort MMS msg response
  1317.  * PARAMETERS
  1318.  *  void
  1319.  * RETURNS
  1320.  *  void
  1321.  *****************************************************************************/
  1322. void mmi_uc_abort_send_mms_rsp(void *in_msg)
  1323. {
  1324.     /*----------------------------------------------------------------*/
  1325.     /* Local Variables                                                */
  1326.     /*----------------------------------------------------------------*/
  1327.     wap_mma_rsp_struct *msg_rsp = (wap_mma_rsp_struct*) in_msg;
  1328.     /*----------------------------------------------------------------*/
  1329.     /* Code Body                                                      */
  1330.     /*----------------------------------------------------------------*/
  1331.     MMI_ASSERT(g_uc_p->send_info.request_id == msg_rsp->req_id );
  1332.     if (g_uc_p->send_info.abort == MMI_UC_ABORT_NORMAL)
  1333.     {
  1334.         /* Do nothing */
  1335.     }
  1336.     else if (g_uc_p->send_info.abort == MMI_UC_ABORT_BY_END_KEY)
  1337.     {
  1338.         /* Do nothing */
  1339.     }
  1340.     else if (g_uc_p->send_info.abort == MMI_UC_ABORT_NONE)
  1341.     {
  1342.         /* Do nothing */
  1343.     }
  1344.     else 
  1345.     {
  1346.         MMI_ASSERT(0);
  1347.     }        
  1348. }
  1349. /*****************************************************************************
  1350.  * FUNCTION
  1351.  *  mmi_uc_preview_mms_req
  1352.  * DESCRIPTION
  1353.  *  Preview MMS msg request
  1354.  * PARAMETERS
  1355.  *  void
  1356.  * RETURNS
  1357.  *  void
  1358.  *****************************************************************************/
  1359. void mmi_uc_preview_mms_req()
  1360. {
  1361.     /*----------------------------------------------------------------*/
  1362.     /* Local Variables                                                */
  1363.     /*----------------------------------------------------------------*/
  1364.     wap_mma_preview_req_struct *msg_req;
  1365.     /*----------------------------------------------------------------*/
  1366.     /* Code Body                                                      */
  1367.     /*----------------------------------------------------------------*/
  1368.     g_uc_p->send_info.request_id = wap_mma_get_request_id();
  1369.     MMI_ASSERT(g_uc_p->send_info.new_msg_id);
  1370.     
  1371.     msg_req = (wap_mma_preview_req_struct*) OslConstructDataPtr(sizeof(wap_mma_preview_req_struct));
  1372.      
  1373.     msg_req->req_id = g_uc_p->send_info.request_id;
  1374.     msg_req->msg_id = g_uc_p->send_info.new_msg_id;
  1375.     
  1376.     mmi_uc_send_message(
  1377.         MOD_MMI,
  1378.         MOD_WAP,
  1379.         0,
  1380.         MSG_ID_WAP_MMA_PREVIEW_REQ,
  1381.         (oslParaType*) msg_req,
  1382.         NULL);
  1383.     
  1384.     return;
  1385. }
  1386. /*****************************************************************************
  1387.  * FUNCTION
  1388.  *  mmi_uc_preview_mms_rsp
  1389.  * DESCRIPTION
  1390.  *  Preview MMS msg response
  1391.  * PARAMETERS
  1392.  *  void
  1393.  * RETURNS
  1394.  *  void
  1395.  *****************************************************************************/
  1396. void mmi_uc_preview_mms_rsp(void *in_msg)
  1397. {
  1398.     /*----------------------------------------------------------------*/
  1399.     /* Local Variables                                                */
  1400.     /*----------------------------------------------------------------*/
  1401.     wap_mma_rsp_struct *msg_rsp = (wap_mma_rsp_struct*) in_msg;
  1402.     /*----------------------------------------------------------------*/
  1403.     /* Code Body                                                      */
  1404.     /*----------------------------------------------------------------*/
  1405.     MMI_ASSERT(g_uc_p->send_info.request_id == msg_rsp->req_id );
  1406.     MMI_ASSERT(g_uc_p->send_info.new_msg_id == msg_rsp->msg_id);
  1407.     if (msg_rsp->result != MMA_RESULT_OK)
  1408.     {
  1409.         DisplayPopup(
  1410.                 (PU8) GetString(STR_GLOBAL_UNFINISHED),
  1411.                 IMG_GLOBAL_UNFINISHED,
  1412.                 1,
  1413.                 MMI_UC_POPUP_TIME_OUT,
  1414.                 (U8) ERROR_TONE);
  1415.         
  1416.     }
  1417.     
  1418.     DeleteScreenIfPresent(SCR_ID_UC_PROCESSING);
  1419.     
  1420. }
  1421. /*****************************************************************************
  1422.  * FUNCTION
  1423.  *  mmi_uc_send_message
  1424.  * DESCRIPTION
  1425.  *  Common function for sending message
  1426.  * PARAMETERS
  1427.  *  MOD_SRC         [IN]        Source module
  1428.  *  MOD_DEST        [IN]        Destination module
  1429.  *  MSG_SAP         [IN]        Message SAP
  1430.  *  MSG_ID          [IN]        Message ID
  1431.  *  LOCAL           [IN]        Local parameter
  1432.  *  PEER            [IN]        Peer buffer
  1433.  * RETURNS
  1434.  *  void
  1435.  *****************************************************************************/
  1436. void mmi_uc_send_message(
  1437.         module_type MOD_SRC,
  1438.         module_type MOD_DEST,
  1439.         U8 MSG_SAP,
  1440.         const U16 MSG_ID,
  1441.         void *LOCAL,
  1442.         void *PEER)
  1443. {
  1444.     /*----------------------------------------------------------------*/
  1445.     /* Local Variables                                                */
  1446.     /*----------------------------------------------------------------*/
  1447.     MYQUEUE Message;
  1448.     /*----------------------------------------------------------------*/
  1449.     /* Code Body                                                      */
  1450.     /*----------------------------------------------------------------*/
  1451.     Message.oslSrcId = MOD_SRC;
  1452.     Message.oslDestId = MOD_DEST;
  1453.     Message.oslSapId = MSG_SAP;
  1454.     Message.oslMsgId = MSG_ID;
  1455.     Message.oslDataPtr = LOCAL;
  1456.     Message.oslPeerBuffPtr = PEER;
  1457.     OslMsgSendExtQueue(&Message);
  1458. }
  1459. #endif /* __MMI_UNIFIED_COMPOSER__ */ 
  1460. #endif /* _MMI_UNIFIED_COMPOSER_MSG_C */