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

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.  * UnifiedComposerMiscell.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements miscell utilities for Unified Composer application.
  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.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  *------------------------------------------------------------------------------
  116.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  117.  *============================================================================
  118.  ****************************************************************************/
  119. #ifndef _MMI_UNIFIED_COMPOSER_MISCELL_C
  120. #define _MMI_UNIFIED_COMPOSER_MISCELL_C
  121. #include "MMI_features.h"
  122. #ifdef __MMI_UNIFIED_COMPOSER__
  123. #include "stdC.h"
  124. #include "L4Dr1.h"
  125. #include "FileSystemDef.h"
  126. #include "FileMgr.h"
  127. #include "Fmt_struct.h"
  128. #include "FileSystemGProt.h"
  129. #include "mdi_datatype.h"
  130. #include "mdi_audio.h"
  131. /* micha1230 */
  132. #include "custom_nvram_editor_data_item.h"
  133. #include "custom_data_account.h"
  134. #include "NVRAMEnum.h"
  135. #include "NVRAMProt.h"
  136. #include "NVRAMType.h"
  137. #include "Conversions.h"
  138. #include "DebugInitDef.h"
  139. #include "FrameworkStruct.h"
  140. #include "EventsGprot.h"
  141. #include "HistoryGprot.h"
  142. #include "CommonScreens.h"
  143. #include "GlobalDefs.h"
  144. #include "SettingProfile.h"
  145. #include "PhoneBookGprot.h"
  146. #include "TimerEvents.h"
  147. #include "wgui_status_icons.h"
  148. #include "keyBrd.h"
  149. #include "gpioInc.h"
  150. #include "MessagesresourceData.h"
  151. #include "MessagesMiscell.h"
  152. #include "SmsGuiInterfaceProt.h"
  153. #include "SmsGuiInterfaceType.h"
  154. #include "SmsPsHandler.h"
  155. #include "mmi_msg_context.h"
  156. #include "xml_def.h"
  157. #include "wgui_categories_UCE.h"
  158. /* ASM */
  159. #include "app_mem.h"
  160. #include "lcd_sw_rnd.h"
  161. #include "gdi_include.h"
  162. #include "USBDeviceGprot.h"
  163. #include "SMSApi.h"
  164. #include "SMSStruct.h"
  165. #include "wapadp.h"
  166. #include "mmsadp.h"
  167. #include "wap_ps_struct.h"
  168. #include "custom_wap_config.h"
  169. #include "med_api.h"
  170. #include "gdi_include.h"
  171. #include "app_asyncfile.h"
  172. #include "UnifiedMessageGProt.h"
  173. #include "custom_uc_config.h"
  174. #include "UnifiedComposerDef.h"
  175. #include "UnifiedComposerGProt.h"
  176. #include "UnifiedComposerProt.h"
  177. /***************************************************************************** 
  178. * Local Variable
  179. *****************************************************************************/
  180. const S8 g_uc_three_dot[] = { '.', '', '.', '', '.', '', '', '' };
  181. /***************************************************************************** 
  182. * Extern Function
  183. *****************************************************************************/
  184. extern EMSData *GetEMSDataForEdit(EMSData **p, U8 force);
  185. extern int mmi_charset_utf8_to_ucs2_length_in_bytes(const kal_uint8 *raw);
  186. extern int mmi_charset_ucs2_to_utf8_length_in_bytes(const kal_uint8 *raw);
  187. extern kal_uint16 EMSUsableTextLen(kal_uint8   dcs);
  188. extern EMSTATUS EMSCalculateSeg(kal_uint8   dcs,kal_uint16  num_byte, kal_uint8   *usedSegment);
  189. /*****************************************************************************
  190.  * FUNCTION
  191.  *  mmi_uc_init_context
  192.  * DESCRIPTION
  193.  *  Initialize Unified Composer context
  194.  * PARAMETERS
  195.  *  void
  196.  * RETURNS
  197.  *  void
  198.  *****************************************************************************/
  199. void mmi_uc_init_context(void)
  200. {
  201.     /*----------------------------------------------------------------*/
  202.     /* Local Variables                                                */
  203.     /*----------------------------------------------------------------*/
  204.     /*----------------------------------------------------------------*/
  205.     /* Code Body                                                      */
  206.     /*----------------------------------------------------------------*/
  207.     memset(g_uc_p, 0 , sizeof(mmi_uc_context_struct));
  208. }
  209. /*****************************************************************************
  210.  * FUNCTION
  211.  *  mmi_uc_create_adm_mem
  212.  * DESCRIPTION
  213.  *  Create adm memory for UC
  214.  * PARAMETERS
  215.  *  void
  216.  * RETURNS
  217.  *  void
  218.  *****************************************************************************/
  219. void mmi_uc_create_adm_mem(void)
  220. {
  221.     /*----------------------------------------------------------------*/
  222.     /* Local Variables                                                */
  223.     /*----------------------------------------------------------------*/    
  224.     /*----------------------------------------------------------------*/
  225.     /* Code Body                                                      */
  226.     /*----------------------------------------------------------------*/    
  227.     g_uc_p->main.mem_pool_id = kal_adm_create(mmi_uc_adm_mem,
  228.                                               MMI_UC_ADM_MEM_SIZE,
  229.                                               NULL,
  230.                                               KAL_FALSE);
  231.     MMI_ASSERT(g_uc_p->main.mem_pool_id);
  232. }
  233. /*****************************************************************************
  234.  * FUNCTION
  235.  *  mmi_uc_add_address
  236.  * DESCRIPTION
  237.  *  add address function
  238.  * PARAMETERS
  239.  *  void
  240.  * RETURNS
  241.  *  TRUE means add successfully. Otherwise FALSE.
  242.  *****************************************************************************/
  243. BOOL mmi_uc_add_address(U8* ucs2_addr, mmi_uc_address_type_enum type, mmi_uc_address_group_type_enum group)
  244. {
  245.     /*----------------------------------------------------------------*/
  246.     /* Local Variables                                                */
  247.     /*----------------------------------------------------------------*/
  248.     mmi_uc_addr_struct** addr_head = &(g_uc_p->msg.to_head);
  249.     mmi_uc_addr_struct* addr_tail = NULL;
  250.     mmi_uc_addr_struct* addr_new = NULL;
  251.     U8 ascii_addr[MMI_UC_MAX_ADDR_LEN + 1];
  252.     U8 addr_num_calculated = 0;
  253.     U8* addr_num = NULL;
  254.     /*----------------------------------------------------------------*/
  255.     /* Code Body                                                      */
  256.     /*----------------------------------------------------------------*/
  257.     switch (group)
  258.     {
  259.         case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  260.         {
  261.             addr_tail = g_uc_p->msg.to_head;
  262.             addr_head = &(g_uc_p->msg.to_head);
  263.             addr_num = &(g_uc_p->msg.to_num);
  264.         }
  265.         break;
  266.         
  267.         case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  268.         {
  269.             addr_tail = g_uc_p->msg.cc_head;
  270.             addr_head = &(g_uc_p->msg.cc_head);
  271.             addr_num = &(g_uc_p->msg.cc_num);
  272.         }
  273.         break;
  274.         case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  275.         {
  276.             addr_tail = g_uc_p->msg.bcc_head;
  277.             addr_head = &(g_uc_p->msg.bcc_head);
  278.             addr_num = &(g_uc_p->msg.bcc_num);
  279.         }
  280.         break;
  281.         case MMI_UC_ADDRESS_GROUP_TYPE_FROM:
  282.         {
  283.             addr_tail = g_uc_p->msg.from;
  284.             addr_head = &(g_uc_p->msg.from);
  285.         }
  286.         break;
  287.         default:
  288.         {
  289.             MMI_ASSERT(0);
  290.         }
  291.         break;        
  292.     }
  293.     
  294.     if (type == MMI_UC_ADDRESS_TYPE_PHONE_NUMBER)
  295.     {
  296.         memset(ascii_addr, 0, sizeof(ascii_addr));
  297.         UnicodeNToAnsii((S8*) ascii_addr, (S8*) ucs2_addr, MMI_UC_MAX_ADDR_LEN * ENCODING_LENGTH);
  298.     }
  299.     if (group != MMI_UC_ADDRESS_GROUP_TYPE_FROM)
  300.     {
  301.         if (addr_tail == NULL)
  302.         {
  303.             addr_num_calculated = 0;
  304.         }
  305.         else
  306.         {
  307.             addr_num_calculated = 1;
  308.             
  309.             for (; addr_tail->next != NULL ; addr_tail = addr_tail->next)
  310.             {
  311.                 addr_num_calculated++;
  312.             }
  313.         }
  314.         MMI_ASSERT((addr_num_calculated == (*addr_num)));
  315.     }
  316.     addr_new = kal_adm_alloc(g_uc_p->main.mem_pool_id, sizeof(mmi_uc_addr_struct));
  317.     MMI_ASSERT(addr_new);
  318.     addr_new->type = type;
  319.     addr_new->group = group;    
  320.     addr_new->next = NULL;
  321.     if (addr_new->type == MMI_UC_ADDRESS_TYPE_PHONE_NUMBER)
  322.     {
  323.         U8 len = strlen((char*)ascii_addr);
  324.         MMI_ASSERT(len <= MMI_UC_MAX_ADDR_LEN);
  325.         
  326.         addr_new->addr = kal_adm_alloc(g_uc_p->main.mem_pool_id, len + 1);
  327.         MMI_ASSERT(addr_new->addr);
  328.         
  329.         memset(addr_new->addr, 0, len + 1);
  330.         memcpy(addr_new->addr, ascii_addr, len);        
  331.     }
  332.     else if (addr_new->type == MMI_UC_ADDRESS_TYPE_EMAIL)
  333.     {    
  334.         U8 len = pfnUnicodeStrlen((S8*)ucs2_addr);
  335.         MMI_ASSERT(len <= MMI_UC_MAX_ADDR_LEN);
  336.         
  337.         addr_new->addr = kal_adm_alloc(g_uc_p->main.mem_pool_id, ((len + 1) * ENCODING_LENGTH));
  338.         MMI_ASSERT(addr_new->addr);
  339.         memset(addr_new->addr, 0, ((len + 1) * ENCODING_LENGTH));        
  340.         memcpy(addr_new->addr, ucs2_addr, (len * ENCODING_LENGTH));        
  341.     }
  342.     else
  343.     {
  344.         MMI_ASSERT(0);
  345.     }
  346.     /* First entry */
  347.     if (addr_tail == NULL)
  348.     {
  349.         addr_new->previous = NULL;
  350.         
  351.         *addr_head = addr_new;
  352.     }
  353.     else
  354.     {
  355.         addr_new->previous = addr_tail;
  356.         addr_tail->next = addr_new;
  357.     }
  358.     if (group != MMI_UC_ADDRESS_GROUP_TYPE_FROM)
  359.     {
  360.         (*addr_num) = (*addr_num) + 1;
  361.     }
  362.     return MMI_TRUE;
  363.     
  364. }
  365. /*****************************************************************************
  366.  * FUNCTION
  367.  *  mmi_uc_check_duplicate_address
  368.  * DESCRIPTION
  369.  *  Check duplicate address function
  370.  * PARAMETERS
  371.  *  void
  372.  * RETURNS
  373.  *  void
  374.  *****************************************************************************/
  375. mmi_uc_addr_struct* mmi_uc_check_duplicate_address(U8* ucs2_addr, mmi_uc_address_type_enum type, mmi_uc_address_group_type_enum group)
  376. {
  377.     /*----------------------------------------------------------------*/
  378.     /* Local Variables                                                */
  379.     /*----------------------------------------------------------------*/
  380.     mmi_uc_addr_struct* addr_tail = NULL;    
  381.     /*----------------------------------------------------------------*/
  382.     /* Code Body                                                      */
  383.     /*----------------------------------------------------------------*/
  384.     switch (group)
  385.     {
  386.         case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  387.         {
  388.             addr_tail = g_uc_p->msg.to_head;
  389.         }
  390.         break;
  391.         
  392.         case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  393.         {
  394.             addr_tail = g_uc_p->msg.cc_head;
  395.         }
  396.         break;
  397.         case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  398.         {
  399.             addr_tail = g_uc_p->msg.bcc_head;
  400.         }
  401.         break;
  402.         case MMI_UC_ADDRESS_GROUP_TYPE_FROM:
  403.         {
  404.             addr_tail = g_uc_p->msg.from;
  405.         }
  406.         break;
  407.         default:
  408.         {
  409.             MMI_ASSERT(0);
  410.         }
  411.         break;        
  412.     }
  413.     
  414.     if (type == MMI_UC_ADDRESS_TYPE_PHONE_NUMBER)
  415.     {
  416.         U8 addr[(MMI_UC_MAX_ADDR_LEN + 1) * ENCODING_LENGTH];
  417.         
  418.         memset(addr, 0, sizeof(addr));
  419.         UnicodeNToAnsii((S8*) addr, (S8*) ucs2_addr, MMI_UC_MAX_ADDR_LEN * ENCODING_LENGTH);
  420.         for (; addr_tail != NULL ; addr_tail = addr_tail->next)
  421.         {
  422.             if (addr_tail->type != MMI_UC_ADDRESS_TYPE_PHONE_NUMBER)
  423.             {
  424.                 continue;
  425.             }
  426.             
  427.             //if (strcmp((char*)addr, (char*)addr_tail->addr) == 0)
  428.             if (ComparePhoneNum(addr, addr_tail->addr) == MMI_TRUE )
  429.             {
  430.                 return addr_tail;
  431.             }
  432.         }
  433.     }
  434.     else if (type == MMI_UC_ADDRESS_TYPE_EMAIL)
  435.     {
  436.         for (; addr_tail != NULL ; addr_tail = addr_tail->next)
  437.         {
  438.             if (addr_tail->type != MMI_UC_ADDRESS_TYPE_EMAIL)
  439.             {
  440.                 continue;
  441.             }
  442.         
  443.             //if (pfnUnicodeStrcmp((S8*)ucs2_addr, (S8*)addr_tail->addr) == 0)
  444.             if (mmi_uc_compare_string_ignore_case((U16*)ucs2_addr, (U16*)addr_tail->addr) == MMI_TRUE)
  445.             {
  446.                 return addr_tail;
  447.             }
  448.         }        
  449.     }
  450.     else
  451.     {
  452.         MMI_ASSERT(0);
  453.     }
  454.     return NULL;
  455.     
  456. }
  457. /*****************************************************************************
  458.  * FUNCTION
  459.  *  mmi_uc_change_msg_type_if_needed
  460.  * DESCRIPTION
  461.  *  Change msg type if needed.
  462.  * PARAMETERS
  463.  *  void
  464.  * RETURNS
  465.  *  void
  466.  *****************************************************************************/
  467. BOOL mmi_uc_change_msg_type_if_needed(void)
  468. {
  469.     /*----------------------------------------------------------------*/
  470.     /* Local Variables                                                */
  471.     /*----------------------------------------------------------------*/
  472.     mmi_uc_msg_type_enum msg_type;
  473.             
  474.     /*----------------------------------------------------------------*/
  475.     /* Code Body                                                      */
  476.     /*----------------------------------------------------------------*/
  477.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  478.                          "*[UnifiedComposerMiscell.c] mmi_uc_change_msg_type_if_needed curr=%d spec=%d set=%d*n",
  479.                          g_uc_p->msg_type.curr_msg_type, 
  480.                          g_uc_p->msg_type.caller_specific_msg_type,
  481.                          g_uc_p->msg_type.setting_msg_type));
  482.     msg_type = mmi_uc_determine_msg_type_by_content();
  483.     switch (g_uc_p->msg_type.caller_specific_msg_type )
  484.     {
  485.         case MMI_UC_MSG_TYPE_SMS_ONLY:
  486.         {
  487.             MMI_ASSERT(g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER);
  488.         }
  489.         break;
  490.         
  491.         case MMI_UC_MSG_TYPE_MMS_ONLY:
  492.         {
  493.             MMI_ASSERT(g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER);
  494.         }
  495.         break;
  496.         case MMI_UC_MSG_TYPE_DEFAULT:
  497.         {                        
  498.             if (g_uc_p->msg_type.setting_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  499.             {                
  500.                 if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  501.                 {                    
  502.                     if (msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  503.                     {
  504.                         g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_SMS_PREFER;
  505.                         return TRUE;
  506.                     }
  507.                 }
  508.                 else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  509.                 {
  510.                     if (msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  511.                     {
  512.                         g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_MMS_PREFER;
  513.                         return TRUE;
  514.                     }
  515.                 }
  516.                 else
  517.                 {
  518.                     MMI_ASSERT(0);
  519.                 }
  520.             }
  521.             else if (g_uc_p->msg_type.setting_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  522.             {
  523.                 if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  524.                 {                    
  525.                     /* Do nothing. */
  526.                 }
  527.                 else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  528.                 {
  529.                     MMI_ASSERT(0);
  530.                 }
  531.                 else
  532.                 {
  533.                     MMI_ASSERT(0);
  534.                 }
  535.             }
  536.             else
  537.             {
  538.                 MMI_ASSERT(0);
  539.             }
  540.         }
  541.         break;
  542.         case MMI_UC_MSG_TYPE_SMS_PREFER:
  543.         {
  544.             if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  545.             {                    
  546.                 if (msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  547.                 {
  548.                     g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_SMS_PREFER;
  549.                     return TRUE;
  550.                 }
  551.             }
  552.             else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  553.             {
  554.                 if (msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  555.                 {
  556.                     g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_MMS_PREFER;
  557.                     return TRUE;
  558.                 }
  559.             }
  560.             else
  561.             {
  562.                 MMI_ASSERT(0);
  563.             }
  564.         }
  565.         break;
  566.         case MMI_UC_MSG_TYPE_MMS_PREFER:
  567.         {
  568.             if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  569.             {                    
  570.                 /* Do nothing. */
  571.             }
  572.             else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  573.             {
  574.                 MMI_ASSERT(0);
  575.             }
  576.             else
  577.             {
  578.                 MMI_ASSERT(0);
  579.             }
  580.         }
  581.         break;
  582.         default:
  583.         {
  584.             MMI_ASSERT(0);
  585.         }
  586.     }       
  587.     
  588.     return FALSE;
  589. }
  590. /*****************************************************************************
  591.  * FUNCTION
  592.  *  mmi_uc_determine_msg_type_by_content
  593.  * DESCRIPTION
  594.  *  Determine msg type according to current msg content
  595.  * PARAMETERS
  596.  *  void
  597.  * RETURNS
  598.  *  void
  599.  *****************************************************************************/
  600. mmi_uc_msg_type_enum mmi_uc_determine_msg_type_by_content(void)
  601. {
  602.     /*----------------------------------------------------------------*/
  603.     /* Local Variables                                                */
  604.     /*----------------------------------------------------------------*/
  605.     /*----------------------------------------------------------------*/
  606.     /* Code Body                                                      */
  607.     /*----------------------------------------------------------------*/
  608.     if (g_uc_p->msg.cc_num > 0)
  609.     {        
  610.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  611.                      "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content cc=%d *n",
  612.                      g_uc_p->msg.cc_num));
  613.         
  614.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  615.     } 
  616.     else if (g_uc_p->msg.bcc_num > 0)
  617.     {
  618.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  619.                      "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content bcc=%d *n",
  620.                      g_uc_p->msg.bcc_num));
  621.         
  622.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  623.     }    
  624.     else if (pfnUnicodeStrlen((S8*)g_uc_p->msg.subject))
  625.     {
  626.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,"*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content subject *n"));
  627.         
  628.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  629.     }    
  630.     else if (g_uc_p->msg.total_slide_num > 1)
  631.     {
  632.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  633.                      "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content slide=%d *n",
  634.                      g_uc_p->msg.total_slide_num));
  635.         
  636.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  637.     }
  638.     else if (g_uc_p->msg.total_object_num > 1)
  639.     {
  640.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  641.                      "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content object=%d *n",
  642.                      g_uc_p->msg.total_object_num));
  643.         
  644.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  645.     }    
  646.     else if ((g_uc_p->msg.total_object_num == 1) &&
  647.              (g_uc_p->msg.object_head->type != MMI_UC_OBJECT_TYPE_TEXT))
  648.     {    
  649.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, 
  650.                      "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content one object *n"));
  651.         
  652.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  653.     }    
  654.     else
  655.     {
  656.         mmi_uc_addr_struct* addr = g_uc_p->msg.to_head;
  657.         for (; addr != NULL; addr = addr->next)
  658.         {
  659.             if (addr->type == MMI_UC_ADDRESS_TYPE_EMAIL)
  660.             {            
  661.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, 
  662.                          "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content email addr *n"));
  663.                 
  664.                 return MMI_UC_MSG_TYPE_MMS_PREFER;
  665.             }
  666.         }
  667.         /* Add text object when the UC screen is exited */
  668.         //MMI_ASSERT(g_uc_p->msg.current_slide->text.object);
  669.         if (g_uc_p->msg.current_slide)
  670.         {
  671.             if (g_uc_p->msg.current_slide->text.UCS2_count)
  672.             {
  673.                 if (g_uc_p->msg.current_slide->text.char_count > g_uc_p->sms_info.max_ucs2_char_num)
  674.                 {
  675.                     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, 
  676.                              "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content ucs2 text size exceed *n"));
  677.                     
  678.                     return MMI_UC_MSG_TYPE_MMS_PREFER;
  679.                 }
  680.             }
  681.             else if (g_uc_p->msg.current_slide->text.char_count)
  682.             {
  683.                 if (g_uc_p->msg.current_slide->text.char_count + g_uc_p->msg.current_slide->text.extension_char_count > 
  684.                     g_uc_p->sms_info.max_gsm7bit_char_num)
  685.                 {
  686.                     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, 
  687.                              "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content ascii text size exceed *n"));
  688.                     
  689.                     return MMI_UC_MSG_TYPE_MMS_PREFER;
  690.                 }
  691.             }
  692.         }
  693.     }
  694.     
  695.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, 
  696.                              "*[UnifiedComposerMiscell.c] mmi_uc_determine_msg_type_by_content SMS *n"));
  697.     return  MMI_UC_MSG_TYPE_SMS_PREFER;    
  698. }
  699. /*****************************************************************************
  700.  * FUNCTION
  701.  *  mmi_uc_update_msg_size
  702.  * DESCRIPTION
  703.  *  Update msg size
  704.  * PARAMETERS
  705.  *  void
  706.  * RETURNS
  707.  *  void
  708.  *****************************************************************************/
  709. void mmi_uc_update_msg_size(void)
  710. {
  711.     /*----------------------------------------------------------------*/
  712.     /* Local Variables                                                */
  713.     /*----------------------------------------------------------------*/
  714.             
  715.     /*----------------------------------------------------------------*/
  716.     /* Code Body                                                      */
  717.     /*----------------------------------------------------------------*/    
  718.     if (g_uc_p->send_info.existed_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER &&
  719.         (g_uc_p->main.state == MMI_UC_STATE_FORWARD || g_uc_p->main.state == MMI_UC_STATE_SEND))
  720.     {
  721.         g_uc_p->msg.msg_size = wap_mma_uc_calc_header_size(&g_uc_p->msg) + g_uc_p->msg.msg_body_size;
  722.     }
  723.     else
  724.     {
  725.         g_uc_p->msg.msg_size = wap_mma_uc_calc_msg_size(&g_uc_p->msg);            
  726.     }
  727.     
  728.     if (g_uc_p->msg.current_slide)
  729.     {
  730.         g_uc_p->msg.msg_size_without_text_buffer = g_uc_p->msg.msg_size - g_uc_p->msg.current_slide->text.utf8_msg_len;
  731.     }
  732.     else
  733.     {
  734.         g_uc_p->msg.msg_size_without_text_buffer = g_uc_p->msg.msg_size;
  735.     }
  736.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  737.                  "*[UnifiedComposerMiscell.c] mmi_uc_update_msg_size msg_size=%d msg_size_wo_text=%d *n",
  738.                  g_uc_p->msg.msg_size,
  739.                  g_uc_p->msg.msg_size_without_text_buffer));
  740.     MMI_ASSERT(g_uc_p->msg.msg_size_without_text_buffer <= g_uc_p->msg.msg_size);
  741. }
  742. /*****************************************************************************
  743.  * FUNCTION
  744.  *  mmi_uc_addr_struct
  745.  * DESCRIPTION
  746.  *  get current highlighted address
  747.  * PARAMETERS
  748.  *  void
  749.  * RETURNS
  750.  *  current highlighted address
  751.  *****************************************************************************/
  752. mmi_uc_addr_struct* mmi_uc_get_highlighted_addr(void)
  753. {
  754.     /*----------------------------------------------------------------*/
  755.     /* Local Variables                                                */
  756.     /*----------------------------------------------------------------*/
  757.     mmi_uc_addr_struct* addr = NULL;
  758.     U32 addr_num = 0;
  759.     U32 i = 0;        
  760.     /*----------------------------------------------------------------*/
  761.     /* Code Body                                                      */
  762.     /*----------------------------------------------------------------*/    
  763.     switch(g_uc_p->done.current_addr_type)
  764.     {
  765.         case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  766.         {
  767.             addr = g_uc_p->msg.to_head;
  768.             addr_num = g_uc_p->msg.to_num;
  769.         }
  770.         break;
  771.         
  772.         case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  773.         {
  774.             addr = g_uc_p->msg.cc_head;
  775.             addr_num = g_uc_p->msg.cc_num;            
  776.         }
  777.         break;
  778.         case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  779.         {
  780.             addr = g_uc_p->msg.bcc_head;
  781.             addr_num = g_uc_p->msg.bcc_num;            
  782.         }
  783.         break;
  784.         default:
  785.         {
  786.             MMI_ASSERT(0);
  787.         }
  788.         break;
  789.     }
  790.     MMI_ASSERT(g_uc_p->done.current_addr_index < addr_num);
  791.     for( ; i < g_uc_p->done.current_addr_index; addr = addr->next)
  792.     {
  793.         i++;
  794.         MMI_ASSERT(addr->next);
  795.     }
  796.     return addr;    
  797. }
  798. /*****************************************************************************
  799.  * FUNCTION
  800.  *  mmi_uc_free_addr_memory
  801.  * DESCRIPTION
  802.  *  free address memory
  803.  * PARAMETERS
  804.  *  void
  805.  * RETURNS
  806.  *  void
  807.  *****************************************************************************/
  808. void mmi_uc_free_addr_memory(mmi_uc_addr_struct* addr)
  809. {
  810.     /*----------------------------------------------------------------*/
  811.     /* Local Variables                                                */
  812.     /*----------------------------------------------------------------*/
  813.     /*----------------------------------------------------------------*/
  814.     /* Code Body                                                      */
  815.     /*----------------------------------------------------------------*/  
  816.     MMI_ASSERT(addr);
  817.     if (addr->addr)
  818.     {
  819.         kal_adm_free(g_uc_p->main.mem_pool_id, addr->addr);
  820.     }
  821.     
  822.     kal_adm_free(g_uc_p->main.mem_pool_id, addr);
  823. }
  824. /*****************************************************************************
  825.  * FUNCTION
  826.  *  mmi_uc_delete_addr
  827.  * DESCRIPTION
  828.  *  Delete address
  829.  * PARAMETERS
  830.  *  void
  831.  * RETURNS
  832.  *  void
  833.  *****************************************************************************/
  834. void mmi_uc_delete_addr(mmi_uc_addr_struct* address)
  835. {
  836.     /*----------------------------------------------------------------*/
  837.     /* Local Variables                                                */
  838.     /*----------------------------------------------------------------*/
  839.     mmi_uc_addr_struct* addr = address;
  840.     /*----------------------------------------------------------------*/
  841.     /* Code Body                                                      */
  842.     /*----------------------------------------------------------------*/
  843.     switch (addr->group)
  844.     {
  845.         case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  846.         {
  847.             if (g_uc_p->msg.to_num == 1)
  848.             {
  849.                 g_uc_p->msg.to_num = 0;
  850.                 g_uc_p->msg.to_head = NULL;
  851.             }
  852.             else
  853.             {
  854.                 g_uc_p->msg.to_num--;
  855.                 /* The first entry */
  856.                 if (addr == g_uc_p->msg.to_head)
  857.                 {
  858.                     g_uc_p->msg.to_head = addr->next;
  859.                     addr->next->previous = NULL;                    
  860.                 }
  861.                 /* The last entry */
  862.                 else if (addr->next == NULL)
  863.                 {
  864.                     addr->previous->next = NULL;                    
  865.                 }
  866.                 else
  867.                 {
  868.                     addr->next->previous = addr->previous;
  869.                     addr->previous->next = addr->next;
  870.                 }
  871.             }
  872.         }
  873.         break;
  874.         case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  875.         {
  876.             if (g_uc_p->msg.cc_num == 1)
  877.             {
  878.                 g_uc_p->msg.cc_num = 0;
  879.                 g_uc_p->msg.cc_head = NULL;
  880.             }
  881.             else
  882.             {
  883.                 g_uc_p->msg.cc_num--;
  884.                 /* The first entry */
  885.                 if (addr == g_uc_p->msg.cc_head)
  886.                 {
  887.                     g_uc_p->msg.cc_head = addr->next;
  888.                     addr->next->previous = NULL;                    
  889.                 }
  890.                 /* The last entry */
  891.                 else if (addr->next == NULL)
  892.                 {
  893.                     addr->previous->next = NULL;                    
  894.                 }
  895.                 else
  896.                 {
  897.                     addr->next->previous = addr->previous;
  898.                     addr->previous->next = addr->next;
  899.                 }                
  900.             }
  901.         }
  902.         break;
  903.         
  904.         case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  905.         {
  906.             if (g_uc_p->msg.bcc_num == 1)
  907.             {
  908.                 g_uc_p->msg.bcc_num = 0;
  909.                 g_uc_p->msg.bcc_head = NULL;
  910.             }
  911.             else
  912.             {
  913.                 g_uc_p->msg.bcc_num--;
  914.                 /* The first entry */
  915.                 if (addr == g_uc_p->msg.bcc_head)
  916.                 {
  917.                     g_uc_p->msg.bcc_head = addr->next;
  918.                     addr->next->previous = NULL;                    
  919.                 }
  920.                 /* The last entry */
  921.                 else if (addr->next == NULL)
  922.                 {
  923.                     addr->previous->next = NULL;                    
  924.                 }
  925.                 else
  926.                 {
  927.                     addr->next->previous = addr->previous;
  928.                     addr->previous->next = addr->next;
  929.                 }               
  930.             }
  931.         }
  932.         break;
  933.         case MMI_UC_ADDRESS_GROUP_TYPE_FROM:
  934.         {
  935.             mmi_uc_free_addr_memory(addr);
  936.             g_uc_p->msg.from = NULL;
  937.             return;
  938.         }
  939.         break;
  940.         default:
  941.         {
  942.             MMI_ASSERT(0);
  943.         }
  944.         break;        
  945.     } 
  946.     mmi_uc_free_addr_memory(addr);
  947. }
  948. /*****************************************************************************
  949.  * FUNCTION
  950.  *  mmi_uc_delete_all_addr
  951.  * DESCRIPTION
  952.  *  Delete group address address
  953.  * PARAMETERS
  954.  *  void
  955.  * RETURNS
  956.  *  void
  957.  *****************************************************************************/
  958. void mmi_uc_delete_all_addr(mmi_uc_address_group_type_enum group)
  959. {
  960.     /*----------------------------------------------------------------*/
  961.     /* Local Variables                                                */
  962.     /*----------------------------------------------------------------*/
  963.     mmi_uc_addr_struct* addr = NULL;
  964.     
  965.     /*----------------------------------------------------------------*/
  966.     /* Code Body                                                      */
  967.     /*----------------------------------------------------------------*/
  968.     do
  969.     {
  970.         switch (group)
  971.         {
  972.             case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  973.             {
  974.                 addr = g_uc_p->msg.to_head;
  975.             }
  976.             break;
  977.             
  978.             case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  979.             {
  980.                 addr = g_uc_p->msg.cc_head;
  981.             }
  982.             break;
  983.             case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  984.             {
  985.                 addr = g_uc_p->msg.bcc_head;
  986.             }
  987.             break;
  988.             default:
  989.             {
  990.                 MMI_ASSERT(0);
  991.             }
  992.             break;        
  993.         }
  994.         if (addr != NULL)
  995.         {
  996.             mmi_uc_delete_addr(addr);
  997.         }
  998.         else
  999.         {
  1000.             break;
  1001.         }
  1002.     }while(TRUE);
  1003. }
  1004. /*****************************************************************************
  1005.  * FUNCTION
  1006.  *  mmi_uc_copy_with_dot
  1007.  * DESCRIPTION
  1008.  *  Append three dots to the end of string
  1009.  * PARAMETERS
  1010.  *  source      [IN]            Source buffer.
  1011.  *  dest        [IN/OUT]        Destination buffer.
  1012.  *  max_len     [IN]            Max characters can be put in destination buffer
  1013.  * RETURNS
  1014.  *  void
  1015.  *****************************************************************************/
  1016. void mmi_uc_copy_with_dot(S8 *dest, S8 *source, S32 max_len)
  1017. {
  1018.     /*----------------------------------------------------------------*/
  1019.     /* Local Variables                                                */
  1020.     /*----------------------------------------------------------------*/
  1021.     /*----------------------------------------------------------------*/
  1022.     /* Code Body                                                      */
  1023.     /*----------------------------------------------------------------*/
  1024.     if (pfnUnicodeStrlen(source) <= max_len)
  1025.     {
  1026.         pfnUnicodeStrcpy((S8*) dest, (S8*) source);
  1027.     }
  1028.     else
  1029.     {
  1030.         /* do not clear end of string because pfnUnicodeStrncpy will auto set NULL terminate */
  1031.         pfnUnicodeStrncpy((S8*) dest, (S8*) source, max_len - 3);
  1032.         pfnUnicodeStrcat((S8*) dest, (S8*) g_uc_three_dot);
  1033.     }
  1034. }
  1035. /*****************************************************************************
  1036.  * FUNCTION
  1037.  *  mmi_uc_set_file_mgr_filter
  1038.  * DESCRIPTION
  1039.  *  Set file manager filters
  1040.  * PARAMETERS
  1041.  *  void
  1042.  * RETURNS
  1043.  *  void
  1044.  *****************************************************************************/
  1045. void mmi_uc_set_file_mgr_filter(FMGR_FILTER* filter, const char *mime_types)
  1046. {
  1047.     /*----------------------------------------------------------------*/
  1048.     /* Local Variables                                                */
  1049.     /*----------------------------------------------------------------*/
  1050.     /*----------------------------------------------------------------*/
  1051.     /* Code Body                                                      */
  1052.     /*----------------------------------------------------------------*/    
  1053.     if (strstr(mime_types, "jpeg"))
  1054.     {
  1055.         FMGR_FILTER_SET(filter, FMGR_TYPE_JPG);
  1056.     }
  1057.     if (strstr(mime_types, "gif"))
  1058.     {
  1059.         FMGR_FILTER_SET(filter, FMGR_TYPE_GIF);
  1060.     }
  1061.     
  1062.     if (strstr(mime_types, "wbmp"))
  1063.     {
  1064.         FMGR_FILTER_SET(filter, FMGR_TYPE_WBMP);
  1065.         FMGR_FILTER_SET(filter, FMGR_TYPE_WBM);        
  1066.     }    
  1067.     if (strstr(mime_types, "mid")) /* Including "audio/mid" */
  1068.     {
  1069.         FMGR_FILTER_SET(filter, FMGR_TYPE_MID);       
  1070.     }
  1071.     if (strstr(mime_types, "amr")) /* Assume audio/amr is okay even the parameter is audio/amr-wb */
  1072.     {
  1073.         FMGR_FILTER_SET(filter, FMGR_TYPE_AMR);       
  1074.     }
  1075. #ifdef __MMI_VCARD__
  1076.     if (strstr(mime_types, "vcard"))
  1077.     {
  1078.         FMGR_FILTER_SET(filter, FMGR_TYPE_VCF);  
  1079.     }
  1080. #endif /* __MMI_VCARD__ */ 
  1081. #ifdef __MMI_VCALENDAR__
  1082.     if (strstr(mime_types, "vcalendar"))
  1083.     {
  1084.         FMGR_FILTER_SET(filter, FMGR_TYPE_VCS);  
  1085.     }
  1086. #endif /* __MMI_VCALENDAR__ */ 
  1087.     if (strstr(mime_types, "video/mp4"))
  1088.     {
  1089.         FMGR_FILTER_SET(filter, FMGR_TYPE_MP4);  
  1090.     }
  1091.     
  1092.     if (strstr(mime_types, "video/mpeg"))
  1093.     {
  1094.         FMGR_FILTER_SET(filter, FMGR_TYPE_MPG);  
  1095.     }
  1096.     if (strstr(mime_types, "3gp"))
  1097.     {
  1098.         FMGR_FILTER_SET(filter, FMGR_TYPE_3GP);  
  1099.     }
  1100.     if (strstr(mime_types, "3gpp2"))
  1101.     {
  1102.         FMGR_FILTER_SET(filter, FMGR_TYPE_3G2);  
  1103.     }    
  1104.     if (strstr(mime_types, "bmp"))
  1105.     {
  1106.         FMGR_FILTER_SET(filter, FMGR_TYPE_BMP);  
  1107.     }
  1108.     
  1109.     if (strstr(mime_types, "png"))
  1110.     {
  1111.         FMGR_FILTER_SET(filter, FMGR_TYPE_PNG);  
  1112.     }
  1113.     if (strstr(mime_types, "wav"))
  1114.     {
  1115.         FMGR_FILTER_SET(filter, FMGR_TYPE_WAV);  
  1116.     }
  1117.     if (strstr(mime_types, "imelody"))
  1118.     {
  1119.         FMGR_FILTER_SET(filter, FMGR_TYPE_IMY);  
  1120.     }
  1121.             
  1122.     if (strstr(mime_types, "smaf"))
  1123.     {
  1124.         FMGR_FILTER_SET(filter, FMGR_TYPE_MMF);  
  1125.     }
  1126.     if (strstr(mime_types, "mp3") || strstr(mime_types, "audio/mpeg"))      /* with disagreement */
  1127.     {
  1128.         FMGR_FILTER_SET(filter, FMGR_TYPE_DAF);  
  1129.     }
  1130.     
  1131.     if (strstr(mime_types, "video/x-msvideo"))  /* with disagreement */
  1132.     {
  1133.         FMGR_FILTER_SET(filter, FMGR_TYPE_AVI);  
  1134.     }
  1135.     if (strstr(mime_types, "amr-wb"))
  1136.     {
  1137.         FMGR_FILTER_SET(filter, FMGR_TYPE_AWB);  
  1138.     }
  1139.     if (strstr(mime_types, "wma"))  /* with disagreement */
  1140.     {
  1141.         FMGR_FILTER_SET(filter, FMGR_TYPE_WMA);  
  1142.     }
  1143.     if (strstr(mime_types, "audio/aac"))
  1144.     {
  1145.         FMGR_FILTER_SET(filter, FMGR_TYPE_AAC);  
  1146.     }
  1147.     if (strstr(mime_types, "m4a"))
  1148.     {
  1149.         FMGR_FILTER_SET(filter, FMGR_TYPE_M4A);  
  1150.     }
  1151.     
  1152.     if (strstr(mime_types, "aiff"))
  1153.     {
  1154.         FMGR_FILTER_SET(filter, FMGR_TYPE_AIF);  
  1155.         FMGR_FILTER_SET(filter, FMGR_TYPE_AIFF);  
  1156.         FMGR_FILTER_SET(filter, FMGR_TYPE_AIFC);  
  1157.     }
  1158.     
  1159.     if (strstr(mime_types, "audio/basic"))
  1160.     {
  1161.         FMGR_FILTER_SET(filter, FMGR_TYPE_AU);  
  1162.         FMGR_FILTER_SET(filter, FMGR_TYPE_SND);  
  1163.     }    
  1164.     if (strstr(mime_types, "text/vnd.sun.j2me.app-descriptor"))
  1165.     {
  1166.         FMGR_FILTER_SET(filter, FMGR_TYPE_JAD);  
  1167.     }
  1168.     if (strstr(mime_types, "application/java-archive"))
  1169.     {
  1170.         FMGR_FILTER_SET(filter, FMGR_TYPE_JAR);  
  1171.     }
  1172.     if (strstr(mime_types, "application/vnd.mtk.lrc"))
  1173.     {
  1174.         FMGR_FILTER_SET(filter, FMGR_TYPE_LRC);  
  1175.     }
  1176.     if (strstr(mime_types, "image/svg+xml"))
  1177.     {
  1178.         FMGR_FILTER_SET(filter, FMGR_TYPE_SVG);  
  1179.     }
  1180.     if (strstr(mime_types, "application/vnd.mtk.m3d"))
  1181.     {
  1182.         FMGR_FILTER_SET(filter, FMGR_TYPE_M3D);  
  1183.     }
  1184.     return;
  1185. }
  1186. /*****************************************************************************
  1187.  * FUNCTION
  1188.  *  mmi_uc_convert_to_mms_insert_type
  1189.  * DESCRIPTION
  1190.  *  Insert object
  1191.  * PARAMETERS
  1192.  *  void
  1193.  * RETURNS
  1194.  *  void
  1195.  *****************************************************************************/
  1196. U32 mmi_uc_convert_to_mms_insert_type(mmi_uc_object_type object_type)
  1197. {
  1198.     /*----------------------------------------------------------------*/
  1199.     /* Local Variables                                                */
  1200.     /*----------------------------------------------------------------*/
  1201.     /*----------------------------------------------------------------*/
  1202.     /* Code Body                                                      */
  1203.     /*----------------------------------------------------------------*/ 
  1204.     switch (object_type)
  1205.     {
  1206.         case MMI_UC_OBJECT_TYPE_IMAGE:
  1207.         {
  1208.             return MMA_INSERT_IMAGE;
  1209.         }
  1210.         break;
  1211.         case MMI_UC_OBJECT_TYPE_AUDIO:
  1212.         {
  1213.             return MMA_INSERT_AUDIO;
  1214.         }
  1215.         break;
  1216.         case MMI_UC_OBJECT_TYPE_VIDEO:
  1217.         {
  1218.             return MMA_INSERT_VIDEO;
  1219.         }
  1220.         break;
  1221.         case MMI_UC_OBJECT_TYPE_ATTACHMENT:
  1222.         {
  1223.             return MMA_INSERT_ATTACHMENT;
  1224.         }
  1225.         break;
  1226.         case MMI_UC_OBJECT_TYPE_TEXT:
  1227.         {
  1228.             return MMA_INSERT_TEXT;
  1229.         }
  1230.         break;
  1231.         default:
  1232.         {
  1233.             MMI_ASSERT(0);
  1234.         }
  1235.         break;
  1236.     }
  1237.     return MMA_INSERT_UNKNOWN;
  1238. }
  1239. /*****************************************************************************
  1240.  * FUNCTION
  1241.  *  mmi_uc_convert_mms_insert_type_to_uc
  1242.  * DESCRIPTION
  1243.  *  Insert object
  1244.  * PARAMETERS
  1245.  *  void
  1246.  * RETURNS
  1247.  *  void
  1248.  *****************************************************************************/
  1249. mmi_uc_object_type mmi_uc_convert_mms_insert_type_to_uc(U32 object_type)
  1250. {
  1251.     /*----------------------------------------------------------------*/
  1252.     /* Local Variables                                                */
  1253.     /*----------------------------------------------------------------*/
  1254.     /*----------------------------------------------------------------*/
  1255.     /* Code Body                                                      */
  1256.     /*----------------------------------------------------------------*/ 
  1257.     switch (object_type)
  1258.     {
  1259.         case MMA_INSERT_IMAGE:
  1260.         {
  1261.             return  MMI_UC_OBJECT_TYPE_IMAGE;
  1262.         }
  1263.         break;
  1264.         case MMA_INSERT_AUDIO:
  1265.         {
  1266.             return  MMI_UC_OBJECT_TYPE_AUDIO;
  1267.         }
  1268.         break;
  1269.         case MMA_INSERT_VIDEO:
  1270.         {
  1271.             return  MMI_UC_OBJECT_TYPE_VIDEO;
  1272.         }
  1273.         break;
  1274.         case MMA_INSERT_ATTACHMENT:
  1275.         {
  1276.             return  MMI_UC_OBJECT_TYPE_ATTACHMENT;
  1277.         }
  1278.         break;
  1279.         case MMA_INSERT_TEXT:
  1280.         {
  1281.             return  MMI_UC_OBJECT_TYPE_TEXT;
  1282.         }
  1283.         break;
  1284.         default:
  1285.         {
  1286.             MMI_ASSERT(0);
  1287.         }
  1288.         break;
  1289.     }
  1290.     return 0;
  1291. }
  1292. /*****************************************************************************
  1293.  * FUNCTION
  1294.  *  mmi_uc_convert_to_editor_object_type
  1295.  * DESCRIPTION
  1296.  *  Insert object
  1297.  * PARAMETERS
  1298.  *  void
  1299.  * RETURNS
  1300.  *  void
  1301.  *****************************************************************************/
  1302. U32 mmi_uc_convert_to_editor_object_type(mmi_uc_object_type object_type)
  1303. {
  1304.     /*----------------------------------------------------------------*/
  1305.     /* Local Variables                                                */
  1306.     /*----------------------------------------------------------------*/
  1307.     /*----------------------------------------------------------------*/
  1308.     /* Code Body                                                      */
  1309.     /*----------------------------------------------------------------*/ 
  1310.     switch (object_type)
  1311.     {
  1312.         case MMI_UC_OBJECT_TYPE_IMAGE:
  1313.         {
  1314.             return WGUI_UCE_OBJECT_TYPE_IMAGE;
  1315.         }
  1316.         break;
  1317.         case MMI_UC_OBJECT_TYPE_AUDIO:
  1318.         {
  1319.             return WGUI_UCE_OBJECT_TYPE_AUDIO;
  1320.         }
  1321.         break;
  1322.         case MMI_UC_OBJECT_TYPE_VIDEO:
  1323.         {
  1324.             return WGUI_UCE_OBJECT_TYPE_VIDEO;
  1325.         }
  1326.         break;
  1327.         case MMI_UC_OBJECT_TYPE_ATTACHMENT:
  1328.         {
  1329.             return WGUI_UCE_OBJECT_TYPE_ATTACHMENT;
  1330.         }
  1331.         break;
  1332.         default:
  1333.         {
  1334.             MMI_ASSERT(0);
  1335.         }
  1336.         break;
  1337.     }
  1338.     return 0;
  1339. }
  1340. /*****************************************************************************
  1341.  * FUNCTION
  1342.  *  mmi_uc_convert_to_editor_msg_type
  1343.  * DESCRIPTION
  1344.  *  Insert object
  1345.  * PARAMETERS
  1346.  *  void
  1347.  * RETURNS
  1348.  *  void
  1349.  *****************************************************************************/
  1350. U32 mmi_uc_convert_to_editor_msg_type(mmi_uc_msg_type_enum msg_type)
  1351. {
  1352.     /*----------------------------------------------------------------*/
  1353.     /* Local Variables                                                */
  1354.     /*----------------------------------------------------------------*/
  1355.     /*----------------------------------------------------------------*/
  1356.     /* Code Body                                                      */
  1357.     /*----------------------------------------------------------------*/ 
  1358.     switch (msg_type)
  1359.     {
  1360.         case MMI_UC_MSG_TYPE_SMS_PREFER:
  1361.         case MMI_UC_MSG_TYPE_SMS_ONLY:
  1362.         {
  1363.             return WGUI_UCE_MSG_TYPE_SMS;
  1364.         }
  1365.         break;
  1366.         case MMI_UC_MSG_TYPE_MMS_PREFER:
  1367.         case MMI_UC_MSG_TYPE_MMS_ONLY:
  1368.         {
  1369.             return WGUI_UCE_MSG_TYPE_MMS;
  1370.         }
  1371.         break;
  1372.         
  1373.         default:
  1374.         {
  1375.             MMI_ASSERT(0);
  1376.         }
  1377.         break;
  1378.     }
  1379.     return 0;
  1380. }
  1381. /*****************************************************************************
  1382.  * FUNCTION
  1383.  *  mmi_uc_display_popup
  1384.  * DESCRIPTION
  1385.  *  Display result popup
  1386.  * PARAMETERS
  1387.  *  void
  1388.  * RETURNS
  1389.  *  void
  1390.  *****************************************************************************/
  1391. void mmi_uc_display_popup(mmi_uc_result result)
  1392. {
  1393.     /*----------------------------------------------------------------*/
  1394.     /* Local Variables                                                */
  1395.     /*----------------------------------------------------------------*/
  1396.     /*----------------------------------------------------------------*/
  1397.     /* Code Body                                                      */
  1398.     /*----------------------------------------------------------------*/ 
  1399.     switch (result)
  1400.     {
  1401.         case MMI_UC_OK:
  1402.         {
  1403.             DisplayPopup(
  1404.                 (PU8) GetString(STR_GLOBAL_OK),
  1405.                 IMG_GLOBAL_OK,
  1406.                 1,
  1407.                 MMI_UC_POPUP_TIME_OUT,
  1408.                 (U8) SUCCESS_TONE);
  1409.         }
  1410.         break;
  1411.         case MMI_UC_SIZE_EXCEEDS:
  1412.         {
  1413.             
  1414.             DisplayPopup(
  1415.                     (PU8) GetString(STR_UC_MSG_SIZE_EXCEED_ID),
  1416.                     IMG_GLOBAL_UNFINISHED,
  1417.                     1,
  1418.                     MMI_UC_POPUP_TIME_OUT,
  1419.                     (U8) ERROR_TONE);
  1420.         }
  1421.         break;
  1422.         case MMI_UC_PROHIBIT_BY_CREATION_MODE:
  1423.         {
  1424.             DisplayPopup(
  1425.                     (PU8) GetString(STR_UC_PROHIBIT_BY_CREATION_MODE_ID),
  1426.                     IMG_GLOBAL_UNFINISHED,
  1427.                     1,
  1428.                     MMI_UC_POPUP_TIME_OUT,
  1429.                     (U8) ERROR_TONE);
  1430.         }
  1431.         break;
  1432.         case MMI_UC_PROHIBIT_BY_DRM:
  1433.         {
  1434.             DisplayPopup(
  1435.                     (PU8) GetString(STR_GLOBAL_DRM_PROHIBITED),
  1436.                     IMG_GLOBAL_UNFINISHED,
  1437.                     1,
  1438.                     MMI_UC_POPUP_TIME_OUT,
  1439.                     (U8) ERROR_TONE);
  1440.         }
  1441.         break;
  1442.         case MMI_UC_NO_SPACE:
  1443.         {
  1444.             DisplayPopup(
  1445.                     (PU8) GetString(STR_UC_NO_SPACE_ID),
  1446.                     IMG_GLOBAL_UNFINISHED,
  1447.                     1,
  1448.                     MMI_UC_POPUP_TIME_OUT,
  1449.                     (U8) ERROR_TONE);
  1450.         }
  1451.         break;
  1452.         case MMI_UC_STORAGE_FULL:
  1453.         {
  1454.             DisplayPopup(
  1455.                     (PU8) GetString(STR_UC_STORAGE_FULL_ID),
  1456.                     IMG_GLOBAL_UNFINISHED,
  1457.                     1,
  1458.                     MMI_UC_POPUP_TIME_OUT,
  1459.                     (U8) ERROR_TONE);
  1460.         }
  1461.         break;
  1462.         case MMI_UC_XML_ERROR:
  1463.         {
  1464.             DisplayPopup(
  1465.                     (PU8) GetString(STR_UC_CONTENT_ERROR_ID),
  1466.                     IMG_GLOBAL_UNFINISHED,
  1467.                     1,
  1468.                     MMI_UC_POPUP_TIME_OUT,
  1469.                     (U8) ERROR_TONE);
  1470.         }
  1471.         break;
  1472.         case MMI_UC_ERROR:
  1473.         {
  1474.             DisplayPopup(
  1475.                     (PU8) GetString(STR_GLOBAL_UNFINISHED),
  1476.                     IMG_GLOBAL_UNFINISHED,
  1477.                     1,
  1478.                     MMI_UC_POPUP_TIME_OUT,
  1479.                     (U8) ERROR_TONE);
  1480.         }
  1481.         break;
  1482.         case MMI_UC_NOT_SUPPORT:
  1483.         {
  1484.             DisplayPopup(
  1485.                     (PU8) GetString(STR_UC_NOT_SUPPORT_ID),
  1486.                     IMG_GLOBAL_UNFINISHED,
  1487.                     1,
  1488.                     MMI_UC_POPUP_TIME_OUT,
  1489.                     (U8) ERROR_TONE);
  1490.         }
  1491.         break;
  1492.         default:
  1493.         {
  1494.             MMI_ASSERT(0);
  1495.         }
  1496.         break;
  1497.     }
  1498. }
  1499. /*****************************************************************************
  1500.  * FUNCTION
  1501.  *  mmi_uc_display_mma_result_popup
  1502.  * DESCRIPTION
  1503.  *  Display result popup
  1504.  * PARAMETERS
  1505.  *  void
  1506.  * RETURNS
  1507.  *  void
  1508.  *****************************************************************************/
  1509. void mmi_uc_display_mma_result_popup(mma_result_enum result)
  1510. {
  1511.     /*----------------------------------------------------------------*/
  1512.     /* Local Variables                                                */
  1513.     /*----------------------------------------------------------------*/
  1514.     /*----------------------------------------------------------------*/
  1515.     /* Code Body                                                      */
  1516.     /*----------------------------------------------------------------*/ 
  1517.     switch (result)
  1518.     {
  1519.         case MMA_RESULT_OK:
  1520.         {
  1521.             DisplayPopup(
  1522.                 (PU8) GetString(STR_GLOBAL_OK),
  1523.                 IMG_GLOBAL_OK,
  1524.                 1,
  1525.                 MMI_UC_POPUP_TIME_OUT,
  1526.                 (U8) SUCCESS_TONE);
  1527.         }
  1528.         break;
  1529.         case MMA_RESULT_FAIL_UNSUPPORT_CONTENT:
  1530.         {
  1531.             
  1532.             DisplayPopup(
  1533.                     (PU8) GetString(STR_UC_UNSUPPORT_CONTENT_ID),
  1534.                     IMG_GLOBAL_UNFINISHED,
  1535.                     1,
  1536.                     MMI_UC_POPUP_TIME_OUT,
  1537.                     (U8) ERROR_TONE);
  1538.         }
  1539.         break;
  1540.         case MMA_RESULT_FAIL_CREATION_MODE_MAX_MSG_SIZE_REACHED:
  1541.         {
  1542.             DisplayPopup(
  1543.                     (PU8) GetString(STR_UC_CREATION_MODE_MAX_MSG_SIZE_REACHED_ID),
  1544.                     IMG_GLOBAL_UNFINISHED,
  1545.                     1,
  1546.                     MMI_UC_POPUP_TIME_OUT,
  1547.                     (U8) ERROR_TONE);
  1548.         }
  1549.         break;
  1550.         case MMA_RESULT_FAIL_MAX_SLIDE_NUM_REACHED:
  1551.         {
  1552.             DisplayPopup(
  1553.                     (PU8) GetString(STR_UC_MAX_SLIDE_NUM_REACHED_ID),
  1554.                     IMG_GLOBAL_UNFINISHED,
  1555.                     1,
  1556.                     MMI_UC_POPUP_TIME_OUT,
  1557.                     (U8) ERROR_TONE);
  1558.         }
  1559.         break;
  1560.         case MMA_RESULT_FAIL_MAX_MSG_NUM_REACHED:
  1561.         {
  1562.             DisplayPopup(
  1563.                     (PU8) GetString(STR_UC_TOO_MANY_MSG_ID),
  1564.                     0,
  1565.                     1,
  1566.                     MMI_UC_POPUP_TIME_OUT,
  1567.                     (U8) ERROR_TONE);
  1568.         }
  1569.         break;
  1570.         case MMA_RESULT_FAIL_INSUFFICIENT_STORAGE:
  1571.         {
  1572.             DisplayPopup(
  1573.                     (PU8) GetString(STR_UC_STORAGE_FULL_DELETE_FILE_ID),
  1574.                     IMG_GLOBAL_UNFINISHED,
  1575.                     1,
  1576.                     MMI_UC_POPUP_TIME_OUT,
  1577.                     (U8) ERROR_TONE);
  1578.         }
  1579.         break;
  1580.         case MMA_RESULT_FAIL_NOT_READY:
  1581.         case MMA_RESULT_FAIL_BUSY:
  1582.         {
  1583.             DisplayPopup(
  1584.                     (PU8) GetString(STR_GLOBAL_NOT_AVAILABLE),
  1585.                     IMG_GLOBAL_UNFINISHED,
  1586.                     1,
  1587.                     MMI_UC_POPUP_TIME_OUT,
  1588.                     (U8) ERROR_TONE);
  1589.         }
  1590.         break;
  1591.         default:
  1592.         {
  1593.             DisplayPopup(
  1594.                     (PU8) GetString(STR_GLOBAL_UNFINISHED),
  1595.                     IMG_GLOBAL_UNFINISHED,
  1596.                     1,
  1597.                     MMI_UC_POPUP_TIME_OUT,
  1598.                     (U8) ERROR_TONE);
  1599.         }
  1600.         break;
  1601.     }
  1602. }
  1603. /*****************************************************************************
  1604.  * FUNCTION
  1605.  *  mmi_uc_display_mma_send_result_popup
  1606.  * DESCRIPTION
  1607.  *  Display result popup
  1608.  * PARAMETERS
  1609.  *  void
  1610.  * RETURNS
  1611.  *  void
  1612.  *****************************************************************************/
  1613. void mmi_uc_display_mma_send_result_popup(mma_result_enum result)
  1614. {
  1615.     /*----------------------------------------------------------------*/
  1616.     /* Local Variables                                                */
  1617.     /*----------------------------------------------------------------*/
  1618.     /*----------------------------------------------------------------*/
  1619.     /* Code Body                                                      */
  1620.     /*----------------------------------------------------------------*/
  1621.     if (g_uc_p->send_info.fail_cause != NULL && pfnUnicodeStrlen((S8*)g_uc_p->send_info.fail_cause))
  1622.     {
  1623.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1624.                              "*[UnifiedComposerMiscell.c] mmi_uc_display_mma_send_result_popup fail_string result=%d*n",
  1625.                              result));                             
  1626.         DisplayPopup(
  1627.                 (PU8) g_uc_p->send_info.fail_cause,
  1628.                 0,
  1629.                 1,
  1630.                 MMI_UC_POPUP_TIME_OUT,
  1631.                 (U8) ERROR_TONE);
  1632.         return;
  1633.     }
  1634.     
  1635.     switch (result)
  1636.     {
  1637.         case MMA_RESULT_OK:
  1638.         {
  1639.             DisplayPopup(
  1640.                 (PU8) GetString(STR_UC_SENT_ID),
  1641.                 IMG_SEND_SUCCESS_PIC_MSG,
  1642.                 1,
  1643.                 MMI_UC_POPUP_TIME_OUT,
  1644.                 (U8) SUCCESS_TONE);
  1645.         }
  1646.         break;
  1647.         case MMA_RESULT_FAIL_USER_CANCEL:
  1648.         {
  1649.             DisplayPopup(
  1650.                 (PU8) GetString(STR_UC_ABORTED_ID),
  1651.                 IMG_GLOBAL_ACTIVATED,
  1652.                 1,
  1653.                 MMI_UC_POPUP_TIME_OUT,
  1654.                 (U8) SUCCESS_TONE);
  1655.         }
  1656.         break;
  1657.         case MMA_RESULT_FAIL_COMM_CONFIG_ERROR:
  1658.         {
  1659.             DisplayPopup(
  1660.                     (PU8) GetString(STR_UC_CONFIG_ERROR_ID),
  1661.                     IMG_GLOBAL_UNFINISHED,
  1662.                     1,
  1663.                     MMI_UC_POPUP_TIME_OUT,
  1664.                     (U8) ERROR_TONE);
  1665.         }
  1666.         break;
  1667.         case MMA_RESULT_FAIL_COMM_CONNECT_ERROR:
  1668.         {
  1669.             DisplayPopup(
  1670.                     (PU8) GetString(STR_UC_SEND_FAIL_ID),
  1671.                     IMG_GLOBAL_UNFINISHED,
  1672.                     1,
  1673.                     MMI_UC_POPUP_TIME_OUT,
  1674.                     (U8) ERROR_TONE);
  1675.         }
  1676.         break;
  1677.         case MMA_RESULT_FAIL_COMM_SERVER_TIMEOUT:
  1678.         {
  1679.             DisplayPopup(
  1680.                     (PU8) GetString(STR_UC_SERVER_TIMEOUT_ID),
  1681.                     IMG_GLOBAL_UNFINISHED,
  1682.                     1,
  1683.                     MMI_UC_POPUP_TIME_OUT,
  1684.                     (U8) ERROR_TONE);
  1685.         }
  1686.         break;
  1687.         case MMA_RESULT_FAIL_COMM_SERVER_ERROR:
  1688.         {
  1689.             DisplayPopup(
  1690.                     (PU8) GetString(STR_UC_SERVER_ERROR_ID),
  1691.                     IMG_GLOBAL_UNFINISHED,
  1692.                     1,
  1693.                     MMI_UC_POPUP_TIME_OUT,
  1694.                     (U8) ERROR_TONE);
  1695.         }
  1696.         break;
  1697.         case MMA_RESULT_FAIL_COMM_SERVICE_DENIED:
  1698.         {
  1699.             DisplayPopup(
  1700.                     (PU8) GetString(STR_UC_SERVICE_DENIED_ID),
  1701.                     IMG_GLOBAL_UNFINISHED,
  1702.                     1,
  1703.                     MMI_UC_POPUP_TIME_OUT,
  1704.                     (U8) ERROR_TONE);
  1705.         }
  1706.         break;
  1707.         case MMA_RESULT_FAIL_COMM_UNSUPPORT_CONTENT:
  1708.         {
  1709.             DisplayPopup(
  1710.                     (PU8) GetString(STR_UC_UNSUPPORT_CONTENT_BY_SERVER_ID),
  1711.                     IMG_GLOBAL_UNFINISHED,
  1712.                     1,
  1713.                     MMI_UC_POPUP_TIME_OUT,
  1714.                     (U8) ERROR_TONE);
  1715.         }
  1716.         break;
  1717.         case MMA_RESULT_FAIL_COMM_UNKNOWN_APN:
  1718.         {
  1719.             DisplayPopup(
  1720.                     (PU8) GetString(STR_UC_UNKNOWN_APN_ID),
  1721.                     IMG_GLOBAL_UNFINISHED,
  1722.                     1,
  1723.                     MMI_UC_POPUP_TIME_OUT,
  1724.                     (U8) ERROR_TONE);
  1725.         }
  1726.         break;
  1727.         case MMA_RESULT_FAIL_COMM_UNAUTHORIZED:
  1728.         {
  1729.             DisplayPopup(
  1730.                     (PU8) GetString(STR_UC_UNAUTHORIZED_ID),
  1731.                     IMG_GLOBAL_UNFINISHED,
  1732.                     1,
  1733.                     MMI_UC_POPUP_TIME_OUT,
  1734.                     (U8) ERROR_TONE);
  1735.         }
  1736.         break;
  1737.         case MMA_RESULT_FAIL_NOT_READY:
  1738.         case MMA_RESULT_FAIL_BUSY:
  1739.         {
  1740.             DisplayPopup(
  1741.                     (PU8) GetString(STR_GLOBAL_NOT_AVAILABLE),
  1742.                     IMG_GLOBAL_UNFINISHED,
  1743.                     1,
  1744.                     MMI_UC_POPUP_TIME_OUT,
  1745.                     (U8) ERROR_TONE);
  1746.         }
  1747.         break;
  1748.         default:
  1749.         {
  1750.             DisplayPopup(
  1751.                     (PU8) GetString(STR_UC_SEND_FAIL_ID),
  1752.                     IMG_SEND_FAIL_PIC_MSG,
  1753.                     1,
  1754.                     MMI_UC_POPUP_TIME_OUT,
  1755.                     (U8) ERROR_TONE);
  1756.         }
  1757.         break;
  1758.     }
  1759. }
  1760. /*****************************************************************************
  1761.  * FUNCTION
  1762.  *  mmi_uc_display_resize_result_popup
  1763.  * DESCRIPTION
  1764.  *  Display result popup
  1765.  * PARAMETERS
  1766.  *  void
  1767.  * RETURNS
  1768.  *  void
  1769.  *****************************************************************************/
  1770. void mmi_uc_display_resize_result_popup(U16 result)
  1771. {
  1772.     /*----------------------------------------------------------------*/
  1773.     /* Local Variables                                                */
  1774.     /*----------------------------------------------------------------*/
  1775.     /*----------------------------------------------------------------*/
  1776.     /* Code Body                                                      */
  1777.     /*----------------------------------------------------------------*/
  1778.     switch (result)
  1779.     {
  1780.         case MMI_UC_RESIZING_SUCCEED:
  1781.         case MMI_UC_RESIZING_SUCCEED_WITH_UNCHANGED:
  1782.         {
  1783.             MMI_ASSERT(0);
  1784.         }
  1785.         break;
  1786.         case MMI_UC_RESIZING_FAILED_IN_GDI_ENCODER_ERR_DISK_FULL:
  1787.         {
  1788.             DisplayPopup(
  1789.                     (PU8) GetString(STR_UC_STORAGE_FULL_ID),
  1790.                     IMG_GLOBAL_UNFINISHED,
  1791.                     1,
  1792.                     MMI_UC_POPUP_TIME_OUT,
  1793.                     (U8) ERROR_TONE);
  1794.         }
  1795.         break;
  1796.         case MMI_UC_RESIZING_FAILED_IN_INSUFFICIENT_DRAWING_BUF:
  1797.         case MMI_UC_RESIZING_FAILED_IN_NO_QUOTA:
  1798.         {
  1799.             DisplayPopup(
  1800.                     (PU8) GetString(STR_UC_SYSTEM_RESOURCES_EXHAUSTED_ID),
  1801.                     IMG_GLOBAL_UNFINISHED,
  1802.                     1,
  1803.                     MMI_UC_POPUP_TIME_OUT,
  1804.                     (U8) ERROR_TONE);
  1805.         }
  1806.         break;        
  1807.         
  1808.         case MMI_UC_RESIZING_FAILED_IN_UNKNOWN_DIMENSION:
  1809.         {
  1810.             DisplayPopup(
  1811.                     (PU8) GetString(STR_UC_FILE_CORRUPT_ID),
  1812.                     IMG_GLOBAL_UNFINISHED,
  1813.                     1,
  1814.                     MMI_UC_POPUP_TIME_OUT,
  1815.                     (U8) ERROR_TONE);
  1816.         }
  1817.         break;        
  1818.         case MMI_UC_RESIZING_FAILED_IN_GDI_FAILED:
  1819.         case MMI_UC_RESIZING_FAILED_IN_GDI_ENCODER_ERR_WRITE_PROTECTION:
  1820.         case MMI_UC_RESIZING_FAILED_IN_GDI_ENCODER_ERR_NO_DISK:
  1821.         default:
  1822.         {
  1823.             DisplayPopup(
  1824.                     (PU8) GetString(STR_UC_FAIL_TO_RESIZE_IMAGE_ID),
  1825.                     IMG_GLOBAL_UNFINISHED,
  1826.                     1,
  1827.                     MMI_UC_POPUP_TIME_OUT,
  1828.                     (U8) ERROR_TONE);
  1829.         }
  1830.         break;
  1831.     }
  1832. }
  1833. /*****************************************************************************
  1834.  * FUNCTION
  1835.  *  mmi_uc_convert_mms_check_result
  1836.  * DESCRIPTION
  1837.  *  Translate mms_uc_insert_check_struct to mmi_uc_result
  1838.  * PARAMETERS
  1839.  *  void
  1840.  * RETURNS
  1841.  *  void
  1842.  *****************************************************************************/
  1843. mmi_uc_result mmi_uc_convert_mms_check_result(mma_insert_check_struct* check_result)
  1844. {
  1845.     /*----------------------------------------------------------------*/
  1846.     /* Local Variables                                                */
  1847.     /*----------------------------------------------------------------*/
  1848.     /*----------------------------------------------------------------*/
  1849.     /* Code Body                                                      */
  1850.     /*----------------------------------------------------------------*/
  1851.     if (check_result->result)
  1852.     {
  1853.         return MMI_UC_OK;
  1854.     }
  1855.     else
  1856.     {
  1857.         if (check_result->oversize)
  1858.         {
  1859.             return MMI_UC_SIZE_EXCEEDS;
  1860.         }
  1861.         if (check_result->creation_mode_violate)
  1862.         {
  1863.             return MMI_UC_PROHIBIT_BY_CREATION_MODE;
  1864.         }
  1865.         if (check_result->drm_type == MMA_DRM_FL_CD ||
  1866.             check_result->drm_type == MMA_DRM_SD_NO_RIGHT)
  1867.         {
  1868.             return MMI_UC_PROHIBIT_BY_DRM;
  1869.         }
  1870.     }
  1871.     
  1872.     return MMI_UC_NOT_SUPPORT;
  1873. }
  1874. /*****************************************************************************
  1875.  * FUNCTION
  1876.  *  mmi_uc_insert_slide
  1877.  * DESCRIPTION
  1878.  *  Insert empty slide next to cur_slide
  1879.  * PARAMETERS
  1880.  *  void
  1881.  * RETURNS
  1882.  *  void
  1883.  *****************************************************************************/
  1884. mmi_uc_slide_struct* mmi_uc_insert_slide(mmi_uc_slide_struct* cur_slide)
  1885. {
  1886.     /*----------------------------------------------------------------*/
  1887.     /* Local Variables                                                */
  1888.     /*----------------------------------------------------------------*/
  1889.     mmi_uc_slide_struct* new_slide;
  1890.     U32 slide_size;
  1891.     /*----------------------------------------------------------------*/
  1892.     /* Code Body                                                      */
  1893.     /*----------------------------------------------------------------*/
  1894.     slide_size = sizeof(mmi_uc_slide_struct);
  1895.     new_slide = kal_adm_alloc(g_uc_p->main.mem_pool_id, slide_size);
  1896.     MMI_ASSERT(new_slide);
  1897.     memset(new_slide, 0, slide_size);
  1898.     g_uc_p->msg.total_slide_num++;
  1899.     new_slide->duration = g_uc_p->mms_info.sliding_time.value;
  1900.     MMI_ASSERT(g_uc_p->msg.total_slide_num <= MMI_UC_MAX_MMS_SLIDE_NUM);
  1901.     /* First slide */
  1902.     if (cur_slide == NULL)
  1903.     {
  1904.         //MMI_ASSERT( g_uc_p->msg.total_slide_num == 1 );
  1905.         new_slide->next = g_uc_p->msg.slide_head;
  1906.         new_slide->previous = NULL;
  1907.         if (g_uc_p->msg.slide_head)
  1908.         {
  1909.             g_uc_p->msg.slide_head->previous = new_slide;
  1910.         }
  1911.         
  1912.         g_uc_p->msg.slide_head = new_slide;        
  1913.         new_slide->slide_num = 1;
  1914.         if (new_slide->next)
  1915.         {
  1916.             mmi_uc_slide_struct* update_slide = mmi_uc_get_end_slide();            
  1917.             while (update_slide != new_slide)
  1918.             {
  1919.                 update_slide->slide_num++;
  1920.                 mmi_uc_update_text_object_path(update_slide);
  1921.                 update_slide = update_slide->previous;
  1922.             }
  1923.         }       
  1924.     }
  1925.     else
  1926.     {
  1927.         new_slide->slide_num = cur_slide->slide_num + 1;
  1928.         
  1929.         new_slide->next = cur_slide->next;
  1930.         new_slide->previous = cur_slide;
  1931.         
  1932.         if (cur_slide->next)
  1933.         {
  1934.             mmi_uc_slide_struct* update_slide = mmi_uc_get_end_slide(); 
  1935.             
  1936.             cur_slide->next->previous = new_slide;
  1937.             while (update_slide != new_slide)
  1938.             {
  1939.                 update_slide->slide_num++;
  1940.                 mmi_uc_update_text_object_path(update_slide);
  1941.                 update_slide = update_slide->previous;
  1942.             }
  1943.         }                
  1944.         cur_slide->next = new_slide;
  1945.     }
  1946.     return new_slide;
  1947. }
  1948. /*****************************************************************************
  1949.  * FUNCTION
  1950.  *  mmi_uc_check_duplicate_object
  1951.  * DESCRIPTION
  1952.  *  Check duplicate object
  1953.  * PARAMETERS
  1954.  *  void
  1955.  * RETURNS
  1956.  *  void
  1957.  *****************************************************************************/
  1958. mmi_uc_object_struct* mmi_uc_check_duplicate_object(U16* filePath)
  1959. {
  1960.     /*----------------------------------------------------------------*/
  1961.     /* Local Variables                                                */
  1962.     /*----------------------------------------------------------------*/
  1963.     mmi_uc_object_struct* obj = g_uc_p->msg.object_head;
  1964.     U32 i = 0;
  1965.     /*----------------------------------------------------------------*/
  1966.     /* Code Body                                                      */
  1967.     /*----------------------------------------------------------------*/
  1968.     if (g_uc_p->msg.total_object_num == 0)
  1969.     {
  1970.         MMI_ASSERT(obj == NULL);
  1971.         return obj;
  1972.     }
  1973.     else
  1974.     {
  1975.         for (; i < g_uc_p->msg.total_object_num ; i++)
  1976.         {
  1977.             MMI_ASSERT(obj);
  1978.             
  1979.             if (pfnUnicodeStrcmp((S8*)obj->file_path, (S8*)filePath) == 0)
  1980.             {
  1981.                 return obj;
  1982.             }
  1983.             else
  1984.             {
  1985.                 obj = obj->next;
  1986.             }
  1987.         }            
  1988.     }    
  1989.     return NULL;
  1990. }
  1991. /*****************************************************************************
  1992.  * FUNCTION
  1993.  *  mmi_uc_check_duplicate_object_by_filename
  1994.  * DESCRIPTION
  1995.  *  Check duplicate object by file name
  1996.  * PARAMETERS
  1997.  *  void
  1998.  * RETURNS
  1999.  *  void
  2000.  *****************************************************************************/
  2001. mmi_uc_object_struct* mmi_uc_check_duplicate_object_by_filename(U16* file_name, mmi_uc_object_struct* start_obj)
  2002. {
  2003.     /*----------------------------------------------------------------*/
  2004.     /* Local Variables                                                */
  2005.     /*----------------------------------------------------------------*/
  2006.     mmi_uc_object_struct* obj = NULL;
  2007.     /*----------------------------------------------------------------*/
  2008.     /* Code Body                                                      */
  2009.     /*----------------------------------------------------------------*/
  2010.     if (start_obj == NULL)
  2011.     {
  2012.         obj = g_uc_p->msg.object_head;
  2013.     }
  2014.     else
  2015.     {
  2016.         obj = start_obj;
  2017.     }
  2018.     for (; obj != NULL ; obj = obj->next)
  2019.     {
  2020.         MMI_ASSERT(obj);
  2021.         
  2022.         if (pfnUnicodeStrcmp((S8*)obj->file_name, (S8*)file_name) == 0)
  2023.         {
  2024.             return obj;
  2025.         }
  2026.     }            
  2027.     return NULL;
  2028. }
  2029. /*****************************************************************************
  2030.  * FUNCTION
  2031.  *  mmi_uc_check_if_exceed_MMS_size_limitation
  2032.  * DESCRIPTION
  2033.  *  Insert object
  2034.  * PARAMETERS
  2035.  *  void
  2036.  * RETURNS
  2037.  *  void
  2038.  *****************************************************************************/
  2039. BOOL mmi_uc_check_if_exceed_MMS_size_limitation(U32 size)
  2040. {
  2041.     /*----------------------------------------------------------------*/
  2042.     /* Local Variables                                                */
  2043.     /*----------------------------------------------------------------*/
  2044.     /*----------------------------------------------------------------*/
  2045.     /* Code Body                                                      */
  2046.     /*----------------------------------------------------------------*/    
  2047.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  2048.                      "*[UnifiedComposerMiscell.c] mmi_uc_check_if_exceed_MMS_size_limitation size=%d mms_max_size=%d *n",
  2049.                      size,
  2050.                      g_uc_p->mms_info.max_mms_size));
  2051.     if (size <= g_uc_p->mms_info.max_mms_size)
  2052.     {
  2053.         return MMI_FALSE;
  2054.     }
  2055.     else
  2056.     {
  2057.         return MMI_TRUE;
  2058.     }
  2059. }
  2060. /*****************************************************************************
  2061.  * FUNCTION
  2062.  *  mmi_uc_insert_object_to_slide
  2063.  * DESCRIPTION
  2064.  *  Insert object
  2065.  * PARAMETERS
  2066.  *  void
  2067.  * RETURNS
  2068.  *  void
  2069.  *****************************************************************************/
  2070. void mmi_uc_insert_object_to_slide(mmi_uc_object_struct* object, mmi_uc_slide_struct* slide, mmi_uc_object_type object_type)
  2071. {
  2072.     /*----------------------------------------------------------------*/
  2073.     /* Local Variables                                                */
  2074.     /*----------------------------------------------------------------*/
  2075.     /*----------------------------------------------------------------*/
  2076.     /* Code Body                                                      */
  2077.     /*----------------------------------------------------------------*/   
  2078.     switch (object_type)
  2079.     {
  2080.         case MMI_UC_OBJECT_TYPE_IMAGE:
  2081.         {
  2082.             slide->image.object = object;
  2083.             slide->image.begin = MMI_UC_INVALID_VALUE;
  2084.             slide->image.end = MMI_UC_INVALID_VALUE;
  2085.             object->reference_count++;
  2086.         }
  2087.         break;
  2088.         case MMI_UC_OBJECT_TYPE_AUDIO:
  2089.         {
  2090.             slide->audio.object = object;
  2091.             slide->audio.begin = MMI_UC_INVALID_VALUE;
  2092.             slide->audio.end = MMI_UC_INVALID_VALUE;
  2093.             object->reference_count++;
  2094.         }
  2095.         break;
  2096.         case MMI_UC_OBJECT_TYPE_VIDEO:
  2097.         {
  2098.             slide->video.object = object;
  2099.             slide->video.begin = MMI_UC_INVALID_VALUE;
  2100.             slide->video.end = MMI_UC_INVALID_VALUE;
  2101.             object->reference_count++;
  2102.         }
  2103.         break;
  2104.         case MMI_UC_OBJECT_TYPE_TEXT:
  2105.         {
  2106.             slide->text.object = object;
  2107.             slide->text.background_color = MMI_UC_DEFAULT_BG_COLOR;
  2108.             slide->text.foreground_color = MMI_UC_DEFAULT_FG_COLOR;
  2109.             slide->text.begin = MMI_UC_INVALID_VALUE;
  2110.             slide->text.end = MMI_UC_INVALID_VALUE;
  2111.             object->reference_count++;
  2112.         }
  2113.         break;
  2114.         default:
  2115.         {
  2116.             MMI_ASSERT(0);
  2117.         }
  2118.         break;
  2119.     }
  2120. }
  2121. /*****************************************************************************
  2122.  * FUNCTION
  2123.  *  mmi_uc_initialize_editor
  2124.  * DESCRIPTION
  2125.  *  Initialize editor
  2126.  * PARAMETERS
  2127.  *  void
  2128.  * RETURNS
  2129.  *  void
  2130.  *****************************************************************************/
  2131. void mmi_uc_editor_initialize()
  2132. {
  2133.     /*----------------------------------------------------------------*/
  2134.     /* Local Variables                                                */
  2135.     /*----------------------------------------------------------------*/
  2136.     /*----------------------------------------------------------------*/
  2137.     /* Code Body                                                      */
  2138.     /*----------------------------------------------------------------*/
  2139.     wgui_uce_initialize_editor(  g_uc_p->main.text_buffer,
  2140.                              MMI_UC_TEXT_BUFFER_SIZE / ENCODING_LENGTH, 
  2141.                              g_uc_p->msg.current_slide_num, 
  2142.                              g_uc_p->msg.total_slide_num, 
  2143.                              mmi_uc_get_message_size_callback, 
  2144.                              mmi_uc_text_change_callback);
  2145. }
  2146. /*****************************************************************************
  2147.  * FUNCTION
  2148.  *  mmi_uc_convert_to_editor_layout_type
  2149.  * DESCRIPTION
  2150.  *  Insert object
  2151.  * PARAMETERS
  2152.  *  void
  2153.  * RETURNS
  2154.  *  void
  2155.  *****************************************************************************/
  2156. U32 mmi_uc_convert_to_editor_layout_type(mmi_uc_layout_enum layout_type)
  2157. {
  2158.     /*----------------------------------------------------------------*/
  2159.     /* Local Variables                                                */
  2160.     /*----------------------------------------------------------------*/
  2161.     /*----------------------------------------------------------------*/
  2162.     /* Code Body                                                      */
  2163.     /*----------------------------------------------------------------*/   
  2164.     switch (layout_type)
  2165.     {
  2166.         case MMI_UC_LAYOUT_DEFAULT:
  2167.         {
  2168.             return WGUI_UCE_LAYOUT_TYPE_THUMBNAIL_AT_TOP;
  2169.         }
  2170.         break;
  2171.         
  2172.         case MMI_UC_LAYOUT_THUMBNAIL_AT_TOP:
  2173.         {
  2174.             return WGUI_UCE_LAYOUT_TYPE_THUMBNAIL_AT_TOP;
  2175.         }
  2176.         break;
  2177.         case MMI_UC_LAYOUT_THUMBNAIL_AT_BOTTOM:
  2178.         {
  2179.             return WGUI_UCE_LAYOUT_TYPE_THUMBNAIL_AT_BOTTOM;
  2180.         }
  2181.         break;
  2182.         default:
  2183.         {
  2184.             MMI_ASSERT(0);
  2185.         }
  2186.         break;
  2187.     }
  2188.     return WGUI_UCE_LAYOUT_TYPE_THUMBNAIL_AT_TOP;
  2189. }
  2190. /*****************************************************************************
  2191.  * FUNCTION
  2192.  *  mmi_uc_convert_to_mms_layout_type
  2193.  * DESCRIPTION
  2194.  *  Insert object
  2195.  * PARAMETERS
  2196.  *  void
  2197.  * RETURNS
  2198.  *  void
  2199.  *****************************************************************************/
  2200. U32 mmi_uc_convert_to_mms_layout_type(mmi_uc_layout_enum layout_type)
  2201. {
  2202.     /*----------------------------------------------------------------*/
  2203.     /* Local Variables                                                */
  2204.     /*----------------------------------------------------------------*/
  2205.     /*----------------------------------------------------------------*/
  2206.     /* Code Body                                                      */
  2207.     /*----------------------------------------------------------------*/   
  2208.     switch (layout_type)
  2209.     {
  2210.         case MMI_UC_LAYOUT_DEFAULT:
  2211.         {
  2212.             return MMA_LAYOUT_IMAGE_ON_TOP;
  2213.         }
  2214.         break;
  2215.         
  2216.         case MMI_UC_LAYOUT_THUMBNAIL_AT_TOP:
  2217.         {
  2218.             return MMA_LAYOUT_IMAGE_ON_TOP;
  2219.         }
  2220.         break;
  2221.         case MMI_UC_LAYOUT_THUMBNAIL_AT_BOTTOM:
  2222.         {
  2223.             return MMA_LAYOUT_TEXT_ON_TOP;
  2224.         }
  2225.         break;
  2226.         default:
  2227.         {
  2228.             MMI_ASSERT(0);
  2229.         }
  2230.         break;
  2231.     }
  2232.     return MMA_LAYOUT_IMAGE_ON_TOP;
  2233. }
  2234. /*****************************************************************************
  2235.  * FUNCTION
  2236.  *  mmi_uc_convert_mms_layout_type_to_uc
  2237.  * DESCRIPTION
  2238.  *  Insert object
  2239.  * PARAMETERS
  2240.  *  void
  2241.  * RETURNS
  2242.  *  void
  2243.  *****************************************************************************/
  2244. U32 mmi_uc_convert_mms_layout_type_to_uc(U8 layout_type)
  2245. {
  2246.     /*----------------------------------------------------------------*/
  2247.     /* Local Variables                                                */
  2248.     /*----------------------------------------------------------------*/
  2249.     /*----------------------------------------------------------------*/
  2250.     /* Code Body                                                      */
  2251.     /*----------------------------------------------------------------*/   
  2252.     switch (layout_type)
  2253.     {
  2254.         case MMA_LAYOUT_NONE:
  2255.         {
  2256.             return MMI_UC_LAYOUT_DEFAULT;
  2257.         }
  2258.         break;
  2259.         
  2260.         case MMA_LAYOUT_IMAGE_ON_TOP:
  2261.         {
  2262.             return MMI_UC_LAYOUT_THUMBNAIL_AT_TOP;
  2263.         }
  2264.         break;
  2265.         case MMA_LAYOUT_TEXT_ON_TOP:
  2266.         {
  2267.             return MMI_UC_LAYOUT_THUMBNAIL_AT_BOTTOM;
  2268.         }
  2269.         break;
  2270.         default:
  2271.         {
  2272.             MMI_ASSERT(0);
  2273.         }
  2274.         break;
  2275.     }
  2276.     return MMI_UC_LAYOUT_THUMBNAIL_AT_TOP;
  2277. }
  2278. /*****************************************************************************
  2279.  * FUNCTION
  2280.  *  mmi_uc_editor_add_object
  2281.  * DESCRIPTION
  2282.  *  Add object to editor
  2283.  * PARAMETERS
  2284.  *  void
  2285.  * RETURNS
  2286.  *  void
  2287.  *****************************************************************************/
  2288. void mmi_uc_editor_add_object(mmi_uc_object_struct* object, mmi_uc_object_type object_type)
  2289. {
  2290.     /*----------------------------------------------------------------*/
  2291.     /* Local Variables                                                */
  2292.     /*----------------------------------------------------------------*/
  2293.     wgui_uce_object_type_enum uce_object_type = mmi_uc_convert_to_editor_object_type(object_type);
  2294.     /*----------------------------------------------------------------*/
  2295.     /* Code Body                                                      */
  2296.     /*----------------------------------------------------------------*/
  2297.     if (object_type == MMI_UC_OBJECT_TYPE_IMAGE ||
  2298.         object_type == MMI_UC_OBJECT_TYPE_VIDEO)
  2299.     {
  2300.         if (object->drm_type == MMA_DRM_NONE ||
  2301.             object->drm_type == MMA_DRM_SD)
  2302.         {
  2303.             if (object->is_virtual_file)
  2304.             {
  2305.                 U8 virtual_file_name[FS_GenVFN_SIZE + FMGR_MAX_EXT_LEN * ENCODING_LENGTH];
  2306.                 S32 result;
  2307.                 memset(virtual_file_name, 0, FS_GenVFN_SIZE + FMGR_MAX_EXT_LEN * ENCODING_LENGTH);
  2308.                 if (g_uc_p->main.file_handle > 0)
  2309.                 {
  2310.                     FS_Close(g_uc_p->main.file_handle);
  2311.                     g_uc_p->main.file_handle = 0;
  2312.                 }
  2313.                             
  2314.                 g_uc_p->main.file_handle = FS_Open(object->file_path, FS_READ_ONLY | FS_OPEN_SHARED);
  2315.                 
  2316.                 if (g_uc_p->main.file_handle <= 0)
  2317.                 {
  2318.                     MMI_ASSERT(0);
  2319.                 }
  2320.              result = FS_GenVirtualFileName( 
  2321.                                 g_uc_p->main.file_handle, 
  2322.                                 (U16*)virtual_file_name, 
  2323.                          (unsigned int)FS_GenVFN_SIZE, 
  2324.                          object->offset, 
  2325.                          object->size);
  2326.                 
  2327.                 if (result < 0)
  2328.                 {
  2329.                     MMI_ASSERT(0);
  2330.                 }
  2331.                 
  2332.                 pfnUnicodeStrcat((PS8) virtual_file_name, (PS8) L".");
  2333.                 MMI_ASSERT(mmi_uc_get_file_extension(object->file_name));
  2334.                 pfnUnicodeStrcat((PS8) virtual_file_name, (PS8) mmi_uc_get_file_extension(object->file_name));                
  2335.                 wgui_uce_add_object( uce_object_type, 
  2336.                                     (U16*)virtual_file_name, 
  2337.                                     0,
  2338.                                     mmi_uc_convert_to_editor_layout_type(g_uc_p->msg.layout));
  2339.             }
  2340.             else 
  2341.             {
  2342.                 wgui_uce_add_object( uce_object_type, 
  2343.                                     object->file_path, 
  2344.                                     0,
  2345.                                     mmi_uc_convert_to_editor_layout_type(g_uc_p->msg.layout));
  2346.             }
  2347.             
  2348.         }
  2349.         else
  2350.         {
  2351.             wgui_uce_add_object( uce_object_type, 
  2352.                                 NULL,
  2353.                                 IMG_UC_DRM_THUMBNAIL_ID,
  2354.                                 mmi_uc_convert_to_editor_layout_type(g_uc_p->msg.layout));
  2355.         }            
  2356.     }
  2357.     else
  2358.     {
  2359.         wgui_uce_add_object(uce_object_type, NULL, 0, 0);
  2360.     }
  2361.     
  2362. }
  2363. /*****************************************************************************
  2364.  * FUNCTION
  2365.  *  mmi_uc_insert_object
  2366.  * DESCRIPTION
  2367.  *  Insert object
  2368.  * PARAMETERS
  2369.  *  void
  2370.  * RETURNS
  2371.  *  void
  2372.  *****************************************************************************/
  2373. mmi_uc_object_struct* mmi_uc_insert_object(S8* filePath, mmi_uc_object_type object_type)
  2374. {
  2375.     /*----------------------------------------------------------------*/
  2376.     /* Local Variables                                                */
  2377.     /*----------------------------------------------------------------*/
  2378.     mmi_uc_object_struct* new_object;
  2379.     U16* file_name;
  2380.     U32 object_size;
  2381.     U16 file_path_len = pfnUnicodeStrlen(filePath);
  2382.     U16 file_name_len = 0;
  2383.      
  2384.     /*----------------------------------------------------------------*/
  2385.     /* Code Body                                                      */
  2386.     /*----------------------------------------------------------------*/
  2387.     object_size = sizeof(mmi_uc_object_struct);
  2388.     new_object = kal_adm_alloc(g_uc_p->main.mem_pool_id, object_size);
  2389.     MMI_ASSERT(new_object);
  2390.     memset(new_object, 0, object_size);
  2391.     /* file path */
  2392.     new_object->file_path = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_path_len + 1 ) * 2);
  2393.     MMI_ASSERT(new_object->file_path);
  2394.     memset(new_object->file_path, 0, (file_path_len + 1) * 2);
  2395.     pfnUnicodeStrncpy((S8*)new_object->file_path, (S8*)filePath, file_path_len);
  2396.     /* file name */
  2397.     file_name = mmi_uc_get_file_name((U16*)filePath);
  2398.     file_name_len = pfnUnicodeStrlen((S8*)file_name);
  2399.     new_object->file_name = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_name_len + 1 ) * 2);
  2400.     MMI_ASSERT(new_object->file_name);
  2401.     memset(new_object->file_name, 0, (file_name_len + 1) * 2);
  2402.     pfnUnicodeStrncpy((S8*)new_object->file_name, (S8*)file_name, file_name_len);
  2403.     /* type */
  2404.     new_object->type = object_type;
  2405.     /* size */
  2406.     new_object->size = applib_get_file_size((kal_wchar*)filePath);       
  2407.     /* Default value! caller should update these value if necessary. */
  2408.     new_object->offset = 0;
  2409.     new_object->drm_type = MMA_DRM_NONE;
  2410.     new_object->is_virtual_file = MMI_FALSE;
  2411.     g_uc_p->msg.total_object_num++;
  2412.     /* First object */
  2413.     if (g_uc_p->msg.object_head == NULL)
  2414.     {
  2415.         g_uc_p->msg.object_head = new_object;
  2416.         new_object->next = NULL;
  2417.         new_object->previous = NULL;
  2418.     }
  2419.     else
  2420.     {
  2421.         /* Insert new object in the list head */    
  2422.         new_object->next = g_uc_p->msg.object_head;
  2423.         new_object->previous = NULL;
  2424.         g_uc_p->msg.object_head->previous = new_object;
  2425.         g_uc_p->msg.object_head = new_object;
  2426.     }
  2427.     return new_object; 
  2428.     
  2429.     
  2430. }
  2431. /*****************************************************************************
  2432.  * FUNCTION
  2433.  *  mmi_uc_insert_attachment
  2434.  * DESCRIPTION
  2435.  *  Insert attachment 
  2436.  * PARAMETERS
  2437.  *  void
  2438.  * RETURNS
  2439.  *  void
  2440.  *****************************************************************************/
  2441. mmi_uc_attachment_info_struct* mmi_uc_insert_attachment()
  2442. {
  2443.     /*----------------------------------------------------------------*/
  2444.     /* Local Variables                                                */
  2445.     /*----------------------------------------------------------------*/
  2446.     mmi_uc_attachment_info_struct* new_attach;
  2447.     U32 attach_size;
  2448.     U32 i = 1;
  2449.     /*----------------------------------------------------------------*/
  2450.     /* Code Body                                                      */
  2451.     /*----------------------------------------------------------------*/
  2452.     attach_size = sizeof(mmi_uc_attachment_info_struct);
  2453.     new_attach = kal_adm_alloc(g_uc_p->main.mem_pool_id, attach_size);
  2454.     MMI_ASSERT(new_attach);
  2455.     memset(new_attach, 0, attach_size);
  2456.     if (g_uc_p->msg.total_attachment_num == 0)
  2457.     {
  2458.         MMI_ASSERT(g_uc_p->msg.attachment_head == NULL);
  2459.         g_uc_p->msg.attachment_head = new_attach;
  2460.         new_attach->next = NULL;
  2461.         new_attach->previous = NULL;        
  2462.     }
  2463.     else
  2464.     {
  2465.         mmi_uc_attachment_info_struct* cur_attach = g_uc_p->msg.attachment_head;
  2466.         MMI_ASSERT(cur_attach);
  2467.         
  2468.         for ( ; cur_attach->next != NULL; cur_attach = cur_attach->next)
  2469.         {
  2470.             i++;
  2471.         }
  2472.         MMI_ASSERT(i == g_uc_p->msg.total_attachment_num);
  2473.         cur_attach->next = new_attach;
  2474.         new_attach->next = NULL;
  2475.         new_attach->previous = cur_attach;
  2476.     }
  2477.     
  2478.     g_uc_p->msg.total_attachment_num++;
  2479.     return new_attach;
  2480. }
  2481. /*****************************************************************************
  2482.  * FUNCTION
  2483.  *  mmi_uc_insert_object_to_attachment
  2484.  * DESCRIPTION
  2485.  *  Insert object
  2486.  * PARAMETERS
  2487.  *  void
  2488.  * RETURNS
  2489.  *  void
  2490.  *****************************************************************************/
  2491. void mmi_uc_insert_object_to_attachment(mmi_uc_object_struct*  object,mmi_uc_attachment_info_struct* attachment)
  2492. {
  2493.     /*----------------------------------------------------------------*/
  2494.     /* Local Variables                                                */
  2495.     /*----------------------------------------------------------------*/
  2496.     /*----------------------------------------------------------------*/
  2497.     /* Code Body                                                      */
  2498.     /*----------------------------------------------------------------*/
  2499.     attachment->object = object;
  2500.     object->reference_count++;
  2501.     return;
  2502. }
  2503. /*****************************************************************************
  2504.  * FUNCTION
  2505.  *  mmi_uc_get_file_name
  2506.  * DESCRIPTION
  2507.  *  Get file name
  2508.  * PARAMETERS
  2509.  *  void
  2510.  * RETURNS
  2511.  *  void
  2512.  *****************************************************************************/
  2513. U16* mmi_uc_get_file_name(U16* filePath)
  2514. {
  2515.     /*----------------------------------------------------------------*/
  2516.     /* Local Variables                                                */
  2517.     /*----------------------------------------------------------------*/
  2518.     U32 file_path_len = pfnUnicodeStrlen((S8*)filePath);
  2519.     U16* cur_position;
  2520.     U16* pre_position;
  2521.     S32 i = file_path_len - 1;
  2522.     U8 pattern[3 * ENCODING_LENGTH];
  2523.     /*----------------------------------------------------------------*/
  2524.     /* Code Body                                                      */
  2525.     /*----------------------------------------------------------------*/
  2526.     memset(pattern, 0, sizeof(pattern));
  2527.     AnsiiNToUnicodeString((S8*)pattern, "\", 1);
  2528.     
  2529.     for (; i >= 0 ; i--)
  2530.     {
  2531.         cur_position = &(filePath[i]);
  2532.         pre_position = cur_position - 1;
  2533.         if (pfnUnicodeStrncmp((S8*)pre_position, (S8*)pattern, 1) == 0)
  2534.         {
  2535.             return cur_position;
  2536.         }
  2537.     }
  2538.     return filePath;
  2539. }
  2540. /*****************************************************************************
  2541.  * FUNCTION
  2542.  *  mmi_uc_get_file_extension
  2543.  * DESCRIPTION
  2544.  *  Get file name
  2545.  * PARAMETERS
  2546.  *  void
  2547.  * RETURNS
  2548.  *  void
  2549.  *****************************************************************************/
  2550. U16* mmi_uc_get_file_extension(U16* filePath)
  2551. {
  2552.     /*----------------------------------------------------------------*/
  2553.     /* Local Variables                                                */
  2554.     /*----------------------------------------------------------------*/
  2555.     U32 file_path_len = pfnUnicodeStrlen((S8*)filePath);
  2556.     U16* cur_position;
  2557.     U16* pre_position;
  2558.     S32 i = file_path_len - 1;
  2559.     U8 pattern[3 * ENCODING_LENGTH];
  2560.     /*----------------------------------------------------------------*/
  2561.     /* Code Body                                                      */
  2562.     /*----------------------------------------------------------------*/
  2563.     memset(pattern, 0, sizeof(pattern));
  2564.     AnsiiNToUnicodeString((S8*)pattern, ".", 1);
  2565.     
  2566.     for (; i >= 0 ; i--)
  2567.     {
  2568.         cur_position = &(filePath[i]);
  2569.         pre_position = cur_position - 1;
  2570.         if (pfnUnicodeStrncmp((S8*)pre_position, (S8*)pattern, 1) == 0)
  2571.         {
  2572.             return cur_position;
  2573.         }
  2574.     }
  2575.     return NULL;
  2576. }
  2577. /*****************************************************************************
  2578.  * FUNCTION
  2579.  *  mmi_uc_set_index
  2580.  * DESCRIPTION
  2581.  *  Set highlighted idnex
  2582.  * PARAMETERS
  2583.  *  void
  2584.  * RETURNS
  2585.  *  void
  2586.  *****************************************************************************/
  2587. void mmi_uc_set_index(S32 hilited_index)
  2588. {
  2589.     /*----------------------------------------------------------------*/
  2590.     /* Local Variables                                                */
  2591.     /*----------------------------------------------------------------*/
  2592.     /*----------------------------------------------------------------*/
  2593.     /* Code Body                                                      */
  2594.     /*----------------------------------------------------------------*/
  2595.     g_uc_p->main.object_index = hilited_index;
  2596. }
  2597. /*****************************************************************************
  2598.  * FUNCTION
  2599.  *  mmi_uc_delete_object_from_list
  2600.  * DESCRIPTION
  2601.  *  delete object from list
  2602.  * PARAMETERS
  2603.  *  void
  2604.  * RETURNS
  2605.  *  void
  2606.  *****************************************************************************/
  2607. void mmi_uc_delete_object_from_list(mmi_uc_object_struct* object)
  2608. {
  2609.     /*----------------------------------------------------------------*/
  2610.     /* Local Variables                                                */
  2611.     /*----------------------------------------------------------------*/
  2612.     /*----------------------------------------------------------------*/
  2613.     /* Code Body                                                      */
  2614.     /*----------------------------------------------------------------*/
  2615.     if (object == g_uc_p->msg.object_head)
  2616.     {
  2617.         g_uc_p->msg.object_head = object->next;
  2618.         if (object->next)
  2619.         {
  2620.             object->next->previous = NULL;
  2621.         }        
  2622.     }
  2623.     else
  2624.     {
  2625.         object->previous->next = object->next;
  2626.         if (object->next)
  2627.         {
  2628.             object->next->previous = object->previous;
  2629.         }
  2630.     }    
  2631.     g_uc_p->msg.total_object_num--;
  2632.     if (object->file_name)
  2633.     {
  2634.         kal_adm_free(g_uc_p->main.mem_pool_id, object->file_name);
  2635.     }
  2636.     
  2637.     if (object->file_path)
  2638.     {
  2639.         kal_adm_free(g_uc_p->main.mem_pool_id, object->file_path);
  2640.     }    
  2641.     
  2642.     kal_adm_free(g_uc_p->main.mem_pool_id, object);
  2643.     
  2644. }
  2645. /*****************************************************************************
  2646.  * FUNCTION
  2647.  *  mmi_uc_attachment_info_struct
  2648.  * DESCRIPTION
  2649.  *  get attachment by index
  2650.  * PARAMETERS
  2651.  *  void
  2652.  * RETURNS
  2653.  *  void
  2654.  *****************************************************************************/
  2655. mmi_uc_attachment_info_struct* mmi_uc_get_attachment_by_index(U16 index)
  2656. {
  2657.     /*----------------------------------------------------------------*/
  2658.     /* Local Variables                                                */
  2659.     /*----------------------------------------------------------------*/
  2660.     mmi_uc_attachment_info_struct* att = g_uc_p->msg.attachment_head;
  2661.     U16 i = 0;
  2662.  
  2663.     /*----------------------------------------------------------------*/
  2664.     /* Code Body                                                      */
  2665.     /*----------------------------------------------------------------*/    
  2666.     MMI_ASSERT(g_uc_p->msg.attachment_head);
  2667.     
  2668.     for (; i < index ; i++)
  2669.     {
  2670.         MMI_ASSERT(att);
  2671.         att = att->next;
  2672.     }
  2673.     
  2674.     return att;
  2675. }
  2676. /*****************************************************************************
  2677.  * FUNCTION
  2678.  *  mmi_uc_delete_attachment_from_list
  2679.  * DESCRIPTION
  2680.  *  delete attachment info from list
  2681.  * PARAMETERS
  2682.  *  void
  2683.  * RETURNS
  2684.  *  void
  2685.  *****************************************************************************/
  2686. void mmi_uc_delete_attachment_from_list(mmi_uc_attachment_info_struct* att)
  2687. {
  2688.     /*----------------------------------------------------------------*/
  2689.     /* Local Variables                                                */
  2690.     /*----------------------------------------------------------------*/
  2691.     /*----------------------------------------------------------------*/
  2692.     /* Code Body                                                      */
  2693.     /*----------------------------------------------------------------*/
  2694.     if (att == g_uc_p->msg.attachment_head)
  2695.     {
  2696.         g_uc_p->msg.attachment_head = att->next;
  2697.         if (att->next)
  2698.         {
  2699.             att->next->previous = NULL;
  2700.         }        
  2701.     }
  2702.     else
  2703.     {
  2704.         att->previous->next = att->next;
  2705.         if (att->next)
  2706.         {
  2707.             att->next->previous = att->previous;
  2708.         }
  2709.     }    
  2710.     g_uc_p->msg.total_attachment_num--;
  2711.     kal_adm_free(g_uc_p->main.mem_pool_id, att);
  2712.     
  2713. }
  2714. /*****************************************************************************
  2715.  * FUNCTION
  2716.  *  mmi_uc_get_object_in_slide
  2717.  * DESCRIPTION
  2718.  *  Get object in slide
  2719.  * PARAMETERS
  2720.  *  void
  2721.  * RETURNS
  2722.  *  void
  2723.  *****************************************************************************/
  2724. mmi_uc_object_struct* mmi_uc_get_object_in_slide(mmi_uc_slide_struct* slide, mmi_uc_object_type object_type)
  2725. {
  2726.     /*----------------------------------------------------------------*/
  2727.     /* Local Variables                                                */
  2728.     /*----------------------------------------------------------------*/
  2729.     /*----------------------------------------------------------------*/
  2730.     /* Code Body                                                      */
  2731.     /*----------------------------------------------------------------*/   
  2732.     switch (object_type)
  2733.     {
  2734.         case MMI_UC_OBJECT_TYPE_IMAGE:
  2735.         {
  2736.             return slide->image.object;
  2737.         }
  2738.         break;
  2739.         case MMI_UC_OBJECT_TYPE_AUDIO:
  2740.         {
  2741.             return slide->audio.object;
  2742.         }
  2743.         break;
  2744.         case MMI_UC_OBJECT_TYPE_VIDEO:
  2745.         {
  2746.             return slide->video.object;
  2747.         }
  2748.         break;
  2749.         default:
  2750.         {
  2751.             MMI_ASSERT(0);
  2752.         }
  2753.         break;
  2754.     }
  2755.     return NULL;
  2756. }
  2757. /*****************************************************************************
  2758.  * FUNCTION
  2759.  *  mmi_uc_reset_text_buffer
  2760.  * DESCRIPTION
  2761.  *  Reset text buffer
  2762.  * PARAMETERS
  2763.  *  void
  2764.  * RETURNS
  2765.  *  void
  2766.  *****************************************************************************/
  2767. void mmi_uc_reset_text_buffer(void)
  2768. {
  2769.     /*----------------------------------------------------------------*/
  2770.     /* Local Variables                                                */
  2771.     /*----------------------------------------------------------------*/
  2772.     /*----------------------------------------------------------------*/
  2773.     /* Code Body                                                      */
  2774.     /*----------------------------------------------------------------*/
  2775.     memset(g_uc_p->main.text_buffer, 0, MMI_UC_TEXT_BUFFER_SIZE);
  2776. }
  2777. /*****************************************************************************
  2778.  * FUNCTION
  2779.  *  mmi_uc_init_uc_folder
  2780.  * DESCRIPTION
  2781.  *  Create uc folder
  2782.  * PARAMETERS
  2783.  *  void
  2784.  * RETURNS
  2785.  *  void
  2786.  *****************************************************************************/
  2787. void mmi_uc_init_uc_folder(void)
  2788. {
  2789.     /*----------------------------------------------------------------*/
  2790.     /* Local Variables                                                */
  2791.     /*----------------------------------------------------------------*/
  2792.     FS_HANDLE file_handle;
  2793.     S32 result;
  2794.     U8 mmi_uc_folder_path[MMI_UC_MAX_TEMP_FILE_LEN];
  2795.     /*----------------------------------------------------------------*/
  2796.     /* Code Body                                                      */
  2797.     /*----------------------------------------------------------------*/
  2798.     memset(mmi_uc_folder_path, 0, MMI_UC_MAX_TEMP_FILE_LEN);
  2799.     MMI_UC_MAKE_FOLDER_PATH(mmi_uc_folder_path);
  2800.     
  2801.     /* if the dir exists, delete it */
  2802.     file_handle = FS_Open((WCHAR*)mmi_uc_folder_path, FS_OPEN_DIR | FS_READ_ONLY);
  2803.     if (file_handle >= 0)
  2804.     {            
  2805.         FS_Close(file_handle);
  2806.         FS_XDelete((WCHAR*)mmi_uc_folder_path, 
  2807.            FS_FILE_TYPE | FS_DIR_TYPE | FS_RECURSIVE_TYPE, 
  2808.            NULL, 
  2809.            0);
  2810.     }
  2811.     
  2812.     result = FS_CreateDir((WCHAR*)mmi_uc_folder_path);
  2813.     
  2814.     if (result < 0)
  2815.     {
  2816.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  2817.                              "*[UnifiedComposerMiscell.c] mmi_uc_init_uc_folder Create DIR FAIL! *n"));
  2818.     }
  2819.     FS_SetAttributes((unsigned short*)mmi_uc_folder_path, FS_ATTR_DIR | FS_ATTR_HIDDEN);
  2820. }
  2821. /*****************************************************************************
  2822.  * FUNCTION
  2823.  *  mmi_uc_save_buffer_to_file
  2824.  * DESCRIPTION
  2825.  *  Save the content of text buffer to file
  2826.  * PARAMETERS
  2827.  *  void
  2828.  * RETURNS
  2829.  *  void
  2830.  *****************************************************************************/
  2831. S32 mmi_uc_save_buffer_to_file(U8* file_path, U8* buffer, U16 char_num)
  2832. {
  2833.     /*----------------------------------------------------------------*/
  2834.     /* Local Variables                                                */
  2835.     /*----------------------------------------------------------------*/
  2836.     FS_HANDLE file_handle;
  2837.     S32 result = FS_NO_ERROR;
  2838.     U32 write_len = 0;
  2839.     /*----------------------------------------------------------------*/
  2840.     /* Code Body                                                      */
  2841.     /*----------------------------------------------------------------*/
  2842.     
  2843.     /* Open the file to write, overwrite if already exists. */
  2844.     file_handle = FS_Open((U16*) file_path, FS_CREATE_ALWAYS | FS_READ_WRITE);
  2845.     if (file_handle > 0)
  2846.     {
  2847.         U32 utf8_buffer_size = (char_num * 3 + ENCODING_LENGTH);        
  2848.         U8* utf8_buffer = applib_mem_screen_alloc(utf8_buffer_size);
  2849.         U32 utf8_len = 0;
  2850.         
  2851.         MMI_ASSERT(utf8_buffer_size <= MMI_UC_UTF8_TEXT_BUFFER_SIZE);
  2852.         
  2853.         memset(utf8_buffer , 0, utf8_buffer_size);
  2854.         utf8_len = mmi_chset_ucs2_to_utf8_string(utf8_buffer, utf8_buffer_size, buffer);
  2855.         
  2856.         result = FS_Write(file_handle, 
  2857.                           utf8_buffer, 
  2858.                           utf8_len - 1, /* null terminator */
  2859.                           &write_len);
  2860.         
  2861.         applib_mem_screen_free(utf8_buffer);
  2862.         FS_Close(file_handle);
  2863.     }
  2864.     return result;
  2865. }
  2866. /*****************************************************************************
  2867.  * FUNCTION
  2868.  *  mmi_uc_switch_slide
  2869.  * DESCRIPTION
  2870.  *  Switch slide
  2871.  * PARAMETERS
  2872.  *  void
  2873.  * RETURNS
  2874.  *  void
  2875.  *****************************************************************************/
  2876. void mmi_uc_switch_slide(mmi_uc_slide_struct* slide)
  2877. {
  2878.     /*----------------------------------------------------------------*/
  2879.     /* Local Variables                                                */
  2880.     /*----------------------------------------------------------------*/
  2881.     //wgui_uce_text_info_struct text_info;
  2882.     
  2883.     /*----------------------------------------------------------------*/
  2884.     /* Code Body                                                      */
  2885.     /*----------------------------------------------------------------*/
  2886.     //memset(&text_info, 0, sizeof(wgui_uce_text_info_struct));
  2887.     mmi_uc_reset_text_buffer();    
  2888.     mmi_uc_editor_initialize();
  2889.     mmi_uc_reset_history_guibuffer(SCR_ID_UC_EDITOR);
  2890.     
  2891.     if (slide != NULL && slide->text.object)
  2892.     {
  2893.         mmi_uc_read_file_to_text_buffer((U8*)slide->text.object->file_path);
  2894.         //wgui_uce_get_text_info_for_buffer(&text_info, g_uc_p->main.text_buffer);
  2895.         //mmi_uc_set_text_info_to_slide(slide, &text_info);
  2896.     }    
  2897.     mmi_uc_set_editor_info(slide);
  2898.         
  2899. }
  2900. /*****************************************************************************
  2901.  * FUNCTION
  2902.  *  mmi_uc_set_editor_info
  2903.  * DESCRIPTION
  2904.  *  Set editor info
  2905.  * PARAMETERS
  2906.  *  void
  2907.  * RETURNS
  2908.  *  void
  2909.  *****************************************************************************/
  2910. void mmi_uc_set_editor_info(mmi_uc_slide_struct* slide)
  2911. {
  2912.     /*----------------------------------------------------------------*/
  2913.     /* Local Variables                                                */
  2914.     /*----------------------------------------------------------------*/
  2915.     wgui_uce_text_info_struct text_info;
  2916.     
  2917.     /*----------------------------------------------------------------*/
  2918.     /* Code Body                                                      */
  2919.     /*----------------------------------------------------------------*/
  2920.     memset(&text_info, 0, sizeof(wgui_uce_text_info_struct));
  2921.     if (slide != NULL)
  2922.     {    
  2923.         if (slide->text.object)
  2924.         {
  2925.             mmi_uc_set_text_info_from_slide(slide, &text_info);
  2926.             wgui_uce_insert_text(&text_info, g_uc_p->main.text_buffer);
  2927.         }
  2928.         if (slide->image.object)
  2929.         {
  2930.             mmi_uc_editor_add_object(slide->image.object, MMI_UC_OBJECT_TYPE_IMAGE);
  2931.         }
  2932.         if (slide->audio.object)
  2933.         {
  2934.             mmi_uc_editor_add_object(slide->audio.object, MMI_UC_OBJECT_TYPE_AUDIO);
  2935.         }
  2936.         
  2937.         if (slide->video.object)
  2938.         {
  2939.             mmi_uc_editor_add_object(slide->video.object, MMI_UC_OBJECT_TYPE_VIDEO);
  2940.         }
  2941.     }
  2942.     if (g_uc_p->msg.total_attachment_num)
  2943.     {
  2944.         mmi_uc_editor_add_object(NULL, MMI_UC_OBJECT_TYPE_ATTACHMENT);
  2945.     }
  2946.     
  2947. }
  2948. /*****************************************************************************
  2949.  * FUNCTION
  2950.  *  mmi_uc_set_text_info_to_slide
  2951.  * DESCRIPTION
  2952.  *  Set text info to slide
  2953.  * PARAMETERS
  2954.  *  void
  2955.  * RETURNS
  2956.  *  void
  2957.  *****************************************************************************/
  2958. void mmi_uc_set_text_info_to_slide(mmi_uc_slide_struct* slide, wgui_uce_text_info_struct* text_info)
  2959. {
  2960.     /*----------------------------------------------------------------*/
  2961.     /* Local Variables                                                */
  2962.     /*----------------------------------------------------------------*/
  2963.     
  2964.     /*----------------------------------------------------------------*/
  2965.     /* Code Body                                                      */
  2966.     /*----------------------------------------------------------------*/
  2967.     slide->text.char_count = text_info->char_count;
  2968.     slide->text.UCS2_count = text_info->UCS2_count;
  2969.     slide->text.utf8_msg_len = text_info->utf8_msg_len;
  2970.     slide->text.extension_char_count = text_info->extension_char_count;
  2971. }
  2972. /*****************************************************************************
  2973.  * FUNCTION
  2974.  *  mmi_uc_set_text_info_from_slide
  2975.  * DESCRIPTION
  2976.  *  Set text info from slide
  2977.  * PARAMETERS
  2978.  *  void
  2979.  * RETURNS
  2980.  *  void
  2981.  *****************************************************************************/
  2982. void mmi_uc_set_text_info_from_slide(mmi_uc_slide_struct* slide, wgui_uce_text_info_struct* text_info)
  2983. {
  2984.     /*----------------------------------------------------------------*/
  2985.     /* Local Variables                                                */
  2986.     /*----------------------------------------------------------------*/
  2987.     
  2988.     /*----------------------------------------------------------------*/
  2989.     /* Code Body                                                      */
  2990.     /*----------------------------------------------------------------*/
  2991.     text_info->char_count = slide->text.char_count;
  2992.     text_info->UCS2_count = slide->text.UCS2_count;
  2993.     text_info->utf8_msg_len = slide->text.utf8_msg_len;
  2994.     text_info->extension_char_count = slide->text.extension_char_count;
  2995. }
  2996. /*****************************************************************************
  2997.  * FUNCTION
  2998.  *  mmi_uc_read_file_to_text_buffer
  2999.  * DESCRIPTION
  3000.  *  Read the file to text buffer
  3001.  * PARAMETERS
  3002.  *  void
  3003.  * RETURNS
  3004.  *  void
  3005.  *****************************************************************************/
  3006. void mmi_uc_read_file_to_text_buffer(U8* file_path)
  3007. {
  3008.     /*----------------------------------------------------------------*/
  3009.     /* Local Variables                                                */
  3010.     /*----------------------------------------------------------------*/
  3011.     FS_HANDLE file_handle;
  3012.     U32 result;
  3013.     U32 read_len = 0;
  3014.     /*----------------------------------------------------------------*/
  3015.     /* Code Body                                                      */
  3016.     /*----------------------------------------------------------------*/
  3017.     
  3018.     /* Open the file to write, overwrite if already exists. */
  3019.     file_handle = FS_Open((U16*) file_path, FS_READ_ONLY | FS_OPEN_SHARED );
  3020.     if (file_handle > 0)
  3021.     {            
  3022.         U8* temp_utf8_buffer = applib_mem_screen_alloc(MMI_UC_UTF8_TEXT_BUFFER_SIZE);
  3023.         
  3024.         memset(temp_utf8_buffer, 0, MMI_UC_UTF8_TEXT_BUFFER_SIZE);
  3025.         
  3026.         result = FS_Read(file_handle, 
  3027.                          temp_utf8_buffer, 
  3028.                          MMI_UC_UTF8_TEXT_BUFFER_SIZE,
  3029.                          &read_len);
  3030.         FS_Close(file_handle);
  3031.         if (result == FS_NO_ERROR)
  3032.         {
  3033.             mmi_chset_utf8_to_ucs2_string(g_uc_p->main.text_buffer, MMI_UC_TEXT_BUFFER_SIZE, temp_utf8_buffer);
  3034.             applib_mem_screen_free(temp_utf8_buffer);
  3035.     
  3036.             return;
  3037.         }
  3038.         applib_mem_screen_free(temp_utf8_buffer);
  3039.     }                                
  3040.     
  3041.     MMI_ASSERT(0);
  3042. }
  3043. /*****************************************************************************
  3044.  * FUNCTION
  3045.  *  mmi_uc_delete_slide
  3046.  * DESCRIPTION
  3047.  *  delete slide
  3048.  * PARAMETERS
  3049.  *  void
  3050.  * RETURNS
  3051.  *  void
  3052.  *****************************************************************************/
  3053. void mmi_uc_delete_slide(mmi_uc_slide_struct* slide)
  3054. {
  3055.     /*----------------------------------------------------------------*/
  3056.     /* Local Variables                                                */
  3057.     /*----------------------------------------------------------------*/
  3058.     /*----------------------------------------------------------------*/
  3059.     /* Code Body                                                      */
  3060.     /*----------------------------------------------------------------*/
  3061.     if (slide == g_uc_p->msg.slide_head)
  3062.     {
  3063.         g_uc_p->msg.slide_head = slide->next;
  3064.         if (slide->next)
  3065.         {
  3066.             slide->next->previous = NULL;
  3067.         }        
  3068.     }
  3069.     else
  3070.     {
  3071.         slide->previous->next = slide->next;
  3072.         if (slide->next)
  3073.         {
  3074.             slide->next->previous = slide->previous;
  3075.         }
  3076.     }    
  3077.     g_uc_p->msg.total_slide_num--;
  3078.     if (slide->next)
  3079.     {
  3080.         mmi_uc_slide_struct* update_slide = slide->next;
  3081.         
  3082.         while (update_slide)
  3083.         {
  3084.             update_slide->slide_num--;
  3085.             mmi_uc_update_text_object_path(update_slide);
  3086.             update_slide = update_slide->next;
  3087.         }
  3088.     }      
  3089.     
  3090.     kal_adm_free(g_uc_p->main.mem_pool_id, slide);
  3091.     
  3092. }
  3093. /*****************************************************************************
  3094. * FUNCTION
  3095. *  mmi_uc_insert_signature_check
  3096. * DESCRIPTION
  3097. *  Check if it is needed to insert signature.
  3098. * PARAMETERS
  3099. *  void
  3100. * RETURNS
  3101. *  kal_bool 
  3102. *****************************************************************************/
  3103. void mmi_uc_insert_signature_check(void)
  3104. {
  3105.     /*----------------------------------------------------------------*/
  3106.     /* Local Variables                                                */
  3107.     /*----------------------------------------------------------------*/
  3108.     /*----------------------------------------------------------------*/
  3109.     /* Code Body                                                      */
  3110.     /*----------------------------------------------------------------*/
  3111.     if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER &&
  3112.         g_uc_p->mms_info.signature.enable)
  3113.     {
  3114.         if (mmi_uc_insert_signature())
  3115.         {        
  3116.             /* Add signature successfully. Initialize editor. */
  3117.             //mmi_uc_switch_slide(g_uc_p->msg.current_slide);
  3118.             mmi_uc_editor_initialize();
  3119.             mmi_uc_set_editor_info(g_uc_p->msg.current_slide);
  3120.         }
  3121.     }
  3122.     else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER &&
  3123.              g_uc_p->mms_info.signature.enable)
  3124.     {
  3125.         /* tricky! disallow to insert signature for forward and send case */
  3126.         if (g_uc_p->main.state != MMI_UC_STATE_FORWARD && 
  3127.             g_uc_p->main.state != MMI_UC_STATE_SEND)
  3128.         {
  3129.             g_uc_p->msg.signature_inserted = MMI_FALSE;
  3130.         }
  3131.     }
  3132. }
  3133. /*****************************************************************************
  3134.  * FUNCTION
  3135.  *  mmi_uc_insert_signature
  3136.  * DESCRIPTION
  3137.  *  insert signature
  3138.  * PARAMETERS
  3139.  *  void
  3140.  * RETURNS
  3141.  *  void
  3142.  *****************************************************************************/
  3143. BOOL mmi_uc_insert_signature()
  3144. {
  3145.     /*----------------------------------------------------------------*/
  3146.     /* Local Variables                                                */
  3147.     /*----------------------------------------------------------------*/
  3148.     mmi_uc_slide_struct* slide;
  3149.     mmi_uc_slide_struct* last_slide;
  3150.     U32 i = 1;
  3151.     U32 new_slide_size;
  3152.     /*----------------------------------------------------------------*/
  3153.     /* Code Body                                                      */
  3154.     /*----------------------------------------------------------------*/
  3155.     if (g_uc_p->msg.signature_inserted)
  3156.     {
  3157.         g_uc_p->msg.fail_to_insert_signature = MMI_FALSE;
  3158.         return MMI_TRUE;
  3159.     }
  3160.     
  3161.     if (g_uc_p->msg.total_slide_num == MMI_UC_MAX_MMS_SLIDE_NUM)
  3162.     {
  3163.         g_uc_p->msg.fail_to_insert_signature = MMI_TRUE;
  3164.         return MMI_FALSE;
  3165.     }
  3166.     new_slide_size = wap_mma_uc_calc_object_smil_size(MMA_INSERT_EMPTY_SLIDE, NULL);
  3167.     if (mmi_uc_check_if_exceed_MMS_size_limitation(new_slide_size + g_uc_p->msg.msg_size))
  3168.     {    
  3169.         g_uc_p->msg.fail_to_insert_signature = MMI_TRUE;
  3170.         return MMI_FALSE;
  3171.     }
  3172.                 
  3173.     for (last_slide = g_uc_p->msg.slide_head; last_slide->next != NULL ; last_slide = last_slide->next)
  3174.     {
  3175.         i++;
  3176.     }
  3177.     MMI_ASSERT( i == g_uc_p->msg.total_slide_num);
  3178.     
  3179.     slide = mmi_uc_insert_slide(last_slide);
  3180.     mmi_uc_update_msg_size();
  3181.     if (g_uc_p->mms_info.signature.img_file)
  3182.     {
  3183.     
  3184.         if (!mmi_uc_insert_signature_file(g_uc_p->mms_info.signature.img_file, 
  3185.                                           slide, 
  3186.                                           MMI_UC_OBJECT_TYPE_IMAGE))
  3187.         {
  3188.             mmi_uc_delete_slide_with_object(slide);
  3189.             g_uc_p->msg.fail_to_insert_signature = MMI_TRUE;
  3190.             return MMI_FALSE;
  3191.         }        
  3192.         mmi_uc_update_msg_size();
  3193.     }
  3194.     if (g_uc_p->mms_info.signature.audio_file)
  3195.     {
  3196.     
  3197.         if (!mmi_uc_insert_signature_file(g_uc_p->mms_info.signature.audio_file, 
  3198.                                           slide, 
  3199.                                           MMI_UC_OBJECT_TYPE_AUDIO))
  3200.         {
  3201.             mmi_uc_delete_slide_with_object(slide);
  3202.             g_uc_p->msg.fail_to_insert_signature = MMI_TRUE;
  3203.             return MMI_FALSE;
  3204.         }        
  3205.         mmi_uc_update_msg_size();
  3206.     }
  3207.     
  3208.     if (g_uc_p->mms_info.signature.video_file)
  3209.     {
  3210.     
  3211.         if (!mmi_uc_insert_signature_file(g_uc_p->mms_info.signature.video_file,
  3212.                                           slide, 
  3213.                                           MMI_UC_OBJECT_TYPE_VIDEO))
  3214.         {
  3215.             mmi_uc_delete_slide_with_object(slide);
  3216.             g_uc_p->msg.fail_to_insert_signature = MMI_TRUE;
  3217.             return MMI_FALSE;
  3218.         }        
  3219.         mmi_uc_update_msg_size();
  3220.     }    
  3221.     if (g_uc_p->mms_info.signature.text_file)
  3222.     {
  3223.         if (!mmi_uc_insert_signature_file(g_uc_p->mms_info.signature.text_file, 
  3224.                                           slide, 
  3225.                                           MMI_UC_OBJECT_TYPE_TEXT))
  3226.         {
  3227.             mmi_uc_delete_slide_with_object(slide);
  3228.             g_uc_p->msg.fail_to_insert_signature = MMI_TRUE;
  3229.             return MMI_FALSE;
  3230.         }        
  3231.         mmi_uc_update_msg_size();
  3232.     }        
  3233.     g_uc_p->msg.fail_to_insert_signature = MMI_FALSE;    
  3234.     g_uc_p->msg.signature_inserted = MMI_TRUE;
  3235.     return MMI_TRUE;
  3236. }
  3237. /*****************************************************************************
  3238.  * FUNCTION
  3239.  *  mmi_uc_delete_slide_with_object
  3240.  * DESCRIPTION
  3241.  *  delete slide
  3242.  * PARAMETERS
  3243.  *  void
  3244.  * RETURNS
  3245.  *  void
  3246.  *****************************************************************************/
  3247. void mmi_uc_delete_slide_with_object(mmi_uc_slide_struct* slide)
  3248. {
  3249.     /*----------------------------------------------------------------*/
  3250.     /* Local Variables                                                */
  3251.     /*----------------------------------------------------------------*/
  3252.     /*----------------------------------------------------------------*/
  3253.     /* Code Body                                                      */
  3254.     /*----------------------------------------------------------------*/
  3255.     if (slide->image.object)
  3256.      {
  3257.          slide->image.object->reference_count--;
  3258.     
  3259.          if (slide->image.object->reference_count == 0)
  3260.          {
  3261.              mmi_uc_delete_object_from_list(slide->image.object);
  3262.          }
  3263.      }
  3264.     
  3265.      if (slide->audio.object)
  3266.      {
  3267.          slide->audio.object->reference_count--;
  3268.     
  3269.          if (slide->audio.object->reference_count == 0)
  3270.          {
  3271.              mmi_uc_delete_object_from_list(slide->audio.object);
  3272.          }
  3273.      }
  3274.      
  3275.      if (slide->video.object)
  3276.      {
  3277.          slide->video.object->reference_count--;
  3278.     
  3279.          if (slide->video.object->reference_count == 0)
  3280.          {
  3281.              mmi_uc_delete_object_from_list(slide->video.object);
  3282.          }
  3283.      }
  3284.      
  3285.      if (slide->text.object)
  3286.      {        
  3287.         S32 result = FS_Delete((U16*)slide->text.object->file_path);
  3288.         
  3289.         if ( result != FS_NO_ERROR)
  3290.         {
  3291.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  3292.                                          "*[UnifiedComposerMiscell.c] mmi_uc_delete_slide_with_object Delete Text file FAIL! *n"));
  3293.         }
  3294.         
  3295.          mmi_uc_delete_object_from_list(slide->text.object);
  3296.      }
  3297.     
  3298.      mmi_uc_delete_slide(slide);
  3299.      mmi_uc_reset_layout_if_needed();
  3300.      
  3301. }
  3302. /*****************************************************************************
  3303.  * FUNCTION
  3304.  *  mmi_uc_delete_slide_with_object
  3305.  * DESCRIPTION
  3306.  *  delete slide
  3307.  * PARAMETERS
  3308.  *  void
  3309.  * RETURNS
  3310.  *  void
  3311.  *****************************************************************************/
  3312. BOOL mmi_uc_insert_signature_file(U16* file_path, mmi_uc_slide_struct* slide, mmi_uc_object_type type)
  3313. {
  3314.     /*----------------------------------------------------------------*/
  3315.     /* Local Variables                                                */
  3316.     /*----------------------------------------------------------------*/
  3317.     mmi_uc_object_struct* object;
  3318.     mma_insert_type_enum mms_type = mmi_uc_convert_to_mms_insert_type(type);
  3319.     mma_insert_check_struct check_result;
  3320.     BOOL result = MMI_FALSE;
  3321.     
  3322.     /*----------------------------------------------------------------*/
  3323.     /* Code Body                                                      */
  3324.     /*----------------------------------------------------------------*/
  3325.     object = mmi_uc_check_duplicate_object(file_path);
  3326.     memset(&check_result, 0, sizeof(mma_insert_check_struct));
  3327.         
  3328.     if (object && object->type != MMI_UC_OBJECT_TYPE_ATTACHMENT)
  3329.     {        
  3330.         U32 obj_smil_size = wap_mma_uc_calc_object_smil_size(mms_type, file_path);
  3331.         
  3332.         if (mmi_uc_check_if_exceed_MMS_size_limitation(obj_smil_size + g_uc_p->msg.msg_size))
  3333.         {                
  3334.             result = MMI_FALSE;
  3335.         }
  3336.         else
  3337.         {
  3338.             mmi_uc_insert_object_to_slide(object, slide, type);
  3339.             result = MMI_TRUE;
  3340.         }
  3341.     }
  3342.     else
  3343.     {
  3344.     
  3345.         wap_mma_uc_insert_object_check(file_path, 
  3346.                                        mms_type, 
  3347.                                        g_uc_p->msg.msg_size, 
  3348.                                        g_uc_p->mms_info.max_mms_size,
  3349.                                        &check_result);        
  3350.         if (!(check_result.result))
  3351.         {
  3352.             result = MMI_FALSE;
  3353.         }
  3354.         else
  3355.         {   
  3356.             if (type == MMI_UC_OBJECT_TYPE_TEXT)
  3357.             {            
  3358.                 U8 mmi_uc_text_path[MMI_UC_MAX_TEMP_FILE_LEN];
  3359.                 FS_HANDLE file_handle;
  3360.                 U32 file_result = 0;
  3361.                 U32 read_len = 0;
  3362.                 U8* buffer = NULL;
  3363.                 wgui_uce_text_info_struct text_info;
  3364.                 U32 file_size = applib_get_file_size((kal_wchar*)file_path);
  3365.                 U32 buffer_size = (file_size + 1);
  3366.                 U32 write_len = 0;
  3367.                 U32 ucs2_buffer_size = MMI_UC_UTF8_TEXT_BUFFER_SIZE;        
  3368.                 U8* ucs2_buffer = 0;
  3369.                 
  3370.                 file_handle = FS_Open((U16*) file_path, FS_READ_ONLY );
  3371.                 if (file_handle <= 0)
  3372.                 {
  3373.                     return MMI_FALSE;
  3374.                 }
  3375.                 else
  3376.                 {
  3377.                     buffer = kal_adm_alloc(g_uc_p->main.mem_pool_id, buffer_size);
  3378.                     if (buffer == NULL)
  3379.                     {
  3380.                         return MMI_FALSE;
  3381.                     }
  3382.                     memset(buffer, 0, buffer_size);
  3383.                     
  3384.                     file_result = FS_Read(
  3385.                                      file_handle, 
  3386.                                      buffer, 
  3387.                                      buffer_size - 1, /* file_size */
  3388.                                      &read_len);
  3389.                     FS_Close(file_handle);
  3390.                     if (file_result != FS_NO_ERROR)
  3391.                     {
  3392.                         kal_adm_free(g_uc_p->main.mem_pool_id, buffer);
  3393.                         return MMI_FALSE;                    
  3394.                     }
  3395.                 }
  3396.                 
  3397.                 memset(mmi_uc_text_path, 0, MMI_UC_MAX_TEMP_FILE_LEN);
  3398.                 MMI_UC_MAKE_TEXT_FILE_PATH(mmi_uc_text_path, slide->slide_num);
  3399.                 
  3400.                 file_handle = FS_Open((U16*) mmi_uc_text_path, FS_CREATE_ALWAYS | FS_READ_WRITE);
  3401.                 if (file_handle <= 0)
  3402.                 {
  3403.                     kal_adm_free(g_uc_p->main.mem_pool_id, buffer);
  3404.                     return MMI_FALSE;
  3405.                 }
  3406.                 result = FS_Write(file_handle, 
  3407.                                   buffer, 
  3408.                                   buffer_size - 1, /* null terminator */
  3409.                                   &write_len);
  3410.                 
  3411.                 FS_Close(file_handle);
  3412.                 if (result != FS_NO_ERROR)
  3413.                 {
  3414.                     kal_adm_free(g_uc_p->main.mem_pool_id, buffer);
  3415.                     return MMI_FALSE;
  3416.                 }
  3417.                 ucs2_buffer = applib_mem_screen_alloc(ucs2_buffer_size);
  3418.                 memset(ucs2_buffer,0,ucs2_buffer_size);
  3419.                 mmi_chset_utf8_to_ucs2_string(ucs2_buffer, ucs2_buffer_size - ENCODING_LENGTH, buffer);
  3420.                 mmi_uc_editor_initialize();
  3421.                 memset(&text_info, 0, sizeof(wgui_uce_text_info_struct));
  3422.                 wgui_uce_get_text_info_for_buffer(&text_info, ucs2_buffer);
  3423.                 
  3424.                 applib_mem_screen_free(ucs2_buffer);                                        
  3425.                  mmi_uc_set_text_info_to_slide(slide, &text_info);
  3426.                 
  3427.                 object = mmi_uc_insert_object((S8*)mmi_uc_text_path, MMI_UC_OBJECT_TYPE_TEXT);                
  3428.                 mmi_uc_insert_object_to_slide(object, slide, MMI_UC_OBJECT_TYPE_TEXT);
  3429.                 result = MMI_TRUE;
  3430.             }
  3431.             else
  3432.             {
  3433.                 object = mmi_uc_insert_object((S8*) file_path, type);
  3434.                 object->drm_type = check_result.drm_type;
  3435.             
  3436.                 mmi_uc_insert_object_to_slide(object, slide, type);
  3437.                 result = MMI_TRUE;
  3438.             }
  3439.         }
  3440.     }
  3441.     return result;
  3442. }
  3443. /*****************************************************************************
  3444.  * FUNCTION
  3445.  *  mmi_uc_reset_mms_signature
  3446.  * DESCRIPTION
  3447.  *  Reset mms signature info in context
  3448.  * PARAMETERS
  3449.  *  void
  3450.  * RETURNS
  3451.  *  void
  3452.  *****************************************************************************/
  3453. void mmi_uc_reset_mms_signature(void)
  3454. {
  3455.     /*----------------------------------------------------------------*/
  3456.     /* Local Variables                                                */
  3457.     /*----------------------------------------------------------------*/
  3458.     
  3459.     /*----------------------------------------------------------------*/
  3460.     /* Code Body                                                      */
  3461.     /*----------------------------------------------------------------*/
  3462.     if (g_uc_p->mms_info.signature.text_file)
  3463.     {
  3464.         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->mms_info.signature.text_file);
  3465.         g_uc_p->mms_info.signature.text_file = NULL;
  3466.     }
  3467.     if (g_uc_p->mms_info.signature.img_file)
  3468.     {
  3469.         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->mms_info.signature.img_file);
  3470.         g_uc_p->mms_info.signature.img_file = NULL;
  3471.     }
  3472.     if (g_uc_p->mms_info.signature.audio_file)
  3473.     {
  3474.         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->mms_info.signature.audio_file);
  3475.         g_uc_p->mms_info.signature.audio_file = NULL;
  3476.     }
  3477.     if (g_uc_p->mms_info.signature.video_file)
  3478.     {
  3479.         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->mms_info.signature.video_file);
  3480.         g_uc_p->mms_info.signature.video_file = NULL;
  3481.     }
  3482. }
  3483. /*****************************************************************************
  3484.  * FUNCTION
  3485.  *  mmi_uc_reset_msg
  3486.  * DESCRIPTION
  3487.  *  Reset msg info in context
  3488.  * PARAMETERS
  3489.  *  void
  3490.  * RETURNS
  3491.  *  void
  3492.  *****************************************************************************/
  3493. void mmi_uc_reset_msg(void)
  3494. {
  3495.     /*----------------------------------------------------------------*/
  3496.     /* Local Variables                                                */
  3497.     /*----------------------------------------------------------------*/
  3498.     
  3499.     /*----------------------------------------------------------------*/
  3500.     /* Code Body                                                      */
  3501.     /*----------------------------------------------------------------*/
  3502.     while (g_uc_p->msg.to_head)
  3503.     {
  3504.         mmi_uc_delete_addr(g_uc_p->msg.to_head);
  3505.     }
  3506.     
  3507.     while (g_uc_p->msg.cc_head)
  3508.     {
  3509.         mmi_uc_delete_addr(g_uc_p->msg.cc_head);
  3510.     }
  3511.     while (g_uc_p->msg.bcc_head)
  3512.     {
  3513.         mmi_uc_delete_addr(g_uc_p->msg.bcc_head);
  3514.     }    
  3515.     while (g_uc_p->msg.from)
  3516.     {
  3517.         mmi_uc_delete_addr(g_uc_p->msg.from);
  3518.     }    
  3519.     while (g_uc_p->msg.slide_head)
  3520.     {
  3521.         mmi_uc_delete_slide_with_object(g_uc_p->msg.slide_head);
  3522.     }
  3523.     while (g_uc_p->msg.attachment_head)
  3524.     {
  3525.         mmi_uc_delete_object_from_list(g_uc_p->msg.attachment_head->object);
  3526.         mmi_uc_delete_attachment_from_list(g_uc_p->msg.attachment_head);