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

MTK

开发平台:

C/C++

  1.     }
  2.     while (g_uc_p->msg.object_head)
  3.     {
  4.         mmi_uc_delete_object_from_list(g_uc_p->msg.object_head);
  5.     }
  6.     memset(&(g_uc_p->msg), 0, sizeof(mmi_uc_msg_struct));
  7.     if (g_uc_p->main.file_handle)
  8.     {
  9.         FS_Close(g_uc_p->main.file_handle);
  10.         g_uc_p->main.file_handle = 0;
  11.     }
  12.     mmi_uc_init_uc_folder();
  13.     if (g_uc_p->send_info.fail_cause)
  14.     {
  15.         kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->send_info.fail_cause);
  16.         g_uc_p->send_info.fail_cause = NULL;
  17.     }   
  18.     memset(&(g_uc_p->send_info),0,sizeof(g_uc_p->send_info));
  19.     mmi_uc_reset_mms_signature();
  20.     g_uc_p->main.image_no = 0;
  21.     if (g_uc_p->main.callback != NULL)
  22.     {
  23.         g_uc_p->main.callback((void*)g_uc_p->main.callback_para);
  24.         
  25.         g_uc_p->main.callback = NULL;        
  26.     }
  27.     
  28.     g_uc_p->main.callback_para = NULL;
  29.     
  30.     kal_adm_delete(g_uc_p->main.mem_pool_id);
  31.     mmi_uc_create_adm_mem();
  32.     
  33. }
  34. /*****************************************************************************
  35.  * FUNCTION
  36.  *  mmi_uc_init_setting
  37.  * DESCRIPTION
  38.  *  Init msg setting
  39.  * PARAMETERS
  40.  *  void
  41.  * RETURNS
  42.  *  void
  43.  *****************************************************************************/
  44. void mmi_uc_init_setting(void)
  45. {
  46.     /*----------------------------------------------------------------*/
  47.     /* Local Variables                                                */
  48.     /*----------------------------------------------------------------*/
  49.     U8 index = 0;
  50.     S16 errorCode = 0;
  51.     
  52.     /*----------------------------------------------------------------*/
  53.     /* Code Body                                                      */
  54.     /*----------------------------------------------------------------*/
  55.     ReadValue(NVRAM_UC_PREFERRED_MSG_TYPE, &index, DS_BYTE, &errorCode);
  56.     
  57.     if (index >= 2)
  58.     {
  59.         index = 0;
  60.         WriteValue(NVRAM_UC_PREFERRED_MSG_TYPE, &index, DS_BYTE, &errorCode);
  61.     }
  62. }
  63. /*****************************************************************************
  64.  * FUNCTION
  65.  *  mmi_uc_get_setting_msg_type
  66.  * DESCRIPTION
  67.  *  Get msg type
  68.  * PARAMETERS
  69.  *  void
  70.  * RETURNS
  71.  *  void
  72.  *****************************************************************************/
  73. mmi_uc_msg_type_enum mmi_uc_get_setting_msg_type(void)
  74. {
  75.     /*----------------------------------------------------------------*/
  76.     /* Local Variables                                                */
  77.     /*----------------------------------------------------------------*/
  78.     S8 index = 0;
  79.     S16 errorCode = 0;
  80.     
  81.     /*----------------------------------------------------------------*/
  82.     /* Code Body                                                      */
  83.     /*----------------------------------------------------------------*/    
  84.     ReadValue(NVRAM_UC_PREFERRED_MSG_TYPE, &index, DS_BYTE, &errorCode);
  85.     if (index == 0)
  86.     {
  87.         return MMI_UC_MSG_TYPE_SMS_PREFER;
  88.     }
  89.     else if (index == 1)
  90.     {
  91.         return MMI_UC_MSG_TYPE_MMS_PREFER;
  92.     }
  93.     else
  94.     {
  95.         MMI_ASSERT(0);
  96.         return MMI_UC_MSG_TYPE_SMS_PREFER;        
  97.     }
  98. }
  99. /*****************************************************************************
  100.  * FUNCTION
  101.  *  mmi_uc_get_setting_msg_type
  102.  * DESCRIPTION
  103.  *  Get msg type
  104.  * PARAMETERS
  105.  *  void
  106.  * RETURNS
  107.  *  void
  108.  *****************************************************************************/
  109. void mmi_uc_clear_msg_bearer(mmi_uc_msg_type_enum msg_type)
  110. {
  111.     /*----------------------------------------------------------------*/
  112.     /* Local Variables                                                */
  113.     /*----------------------------------------------------------------*/
  114.     
  115.     /*----------------------------------------------------------------*/
  116.     /* Code Body                                                      */
  117.     /*----------------------------------------------------------------*/
  118.     if (msg_type == MMI_UC_MSG_TYPE_DEFAULT || msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  119.     {        
  120.         ReleaseEMSEditBuffer();
  121.     }
  122.     if (msg_type == MMI_UC_MSG_TYPE_DEFAULT || msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  123.     {
  124.         /* Delete MMS temp msg ID*/
  125.         mmi_uc_delete_mms_req(g_uc_p->send_info.new_msg_id);
  126.         g_uc_p->send_info.new_msg_id = 0; /* tricky! */
  127.         
  128.     }
  129. }
  130. /*****************************************************************************
  131.  * FUNCTION
  132.  *  mmi_uc_delete_sms_frm_screen
  133.  * DESCRIPTION
  134.  *  Delete SMS framework screen
  135.  * PARAMETERS
  136.  *  void
  137.  * RETURNS
  138.  *  void
  139.  *****************************************************************************/
  140. void mmi_uc_delete_sms_frm_screen(void)
  141. {
  142.     /*----------------------------------------------------------------*/
  143.     /* Local Variables                                                */
  144.     /*----------------------------------------------------------------*/
  145.     
  146.     /*----------------------------------------------------------------*/
  147.     /* Code Body                                                      */
  148.     /*----------------------------------------------------------------*/
  149.     mmi_frm_sms_delete_screen_history();
  150. }
  151. /*****************************************************************************
  152.  * FUNCTION
  153.  *  mmi_uc_get_addr
  154.  * DESCRIPTION
  155.  *  Get addr by type and index
  156.  * PARAMETERS
  157.  *  void
  158.  * RETURNS
  159.  *  void
  160.  *****************************************************************************/
  161. mmi_uc_addr_struct* mmi_uc_get_addr(mmi_uc_address_group_type_enum addr_type, U16 index)
  162. {
  163.     /*----------------------------------------------------------------*/
  164.     /* Local Variables                                                */
  165.     /*----------------------------------------------------------------*/
  166.     U16 i = 0;
  167.     mmi_uc_addr_struct* addr = NULL;
  168.     
  169.     /*----------------------------------------------------------------*/
  170.     /* Code Body                                                      */
  171.     /*----------------------------------------------------------------*/
  172.     switch (addr_type)
  173.     {
  174.         case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  175.         {
  176.             addr = g_uc_p->msg.to_head;
  177.         }
  178.         break;
  179.         case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  180.         {
  181.             addr = g_uc_p->msg.cc_head;
  182.         }
  183.         break;
  184.         case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  185.         {
  186.             addr = g_uc_p->msg.bcc_head;
  187.         }
  188.         break;
  189.         default:
  190.         {
  191.             MMI_ASSERT(0);
  192.             return NULL;
  193.         }
  194.     }
  195.     
  196.     for ( ; i < index ; i++)
  197.     {
  198.         MMI_ASSERT(addr->next);
  199.         addr = addr->next;
  200.     }
  201.     return addr;
  202. }
  203. /*****************************************************************************
  204.  * FUNCTION
  205.  *  mmi_uc_save_sms_after_send
  206.  * DESCRIPTION
  207.  *  Save sms after send
  208.  * PARAMETERS
  209.  *  void
  210.  * RETURNS
  211.  *  void
  212.  *****************************************************************************/
  213. void mmi_uc_save_sms_after_send(U8 status, void *number)
  214. {
  215.     /*----------------------------------------------------------------*/
  216.     /* Local Variables                                                */
  217.     /*----------------------------------------------------------------*/
  218.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  219.     EMSData *data = GetEMSDataForEdit(0, 0);
  220.     
  221.     /*----------------------------------------------------------------*/
  222.     /* Code Body                                                      */
  223.     /*----------------------------------------------------------------*/
  224.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  225.     sendData->dcs = data->dcs;
  226.     sendData->status = status;
  227.     strncpy((S8*) sendData->number, (S8*) number,MAX_DIGITS_SMS - 1);
  228.         
  229.     mmi_frm_sms_save_sms(mmi_uc_save_sms_rsp, MOD_MMI, sendData);
  230.     OslMfree(sendData);
  231. }
  232. /*****************************************************************************
  233.  * FUNCTION
  234.  *  mmi_uc_create_mms_xml_description_file
  235.  * DESCRIPTION
  236.  *  Create the mms xml description file
  237.  * PARAMETERS
  238.  *  void
  239.  * RETURNS
  240.  *  void
  241.  *****************************************************************************/
  242. S32 mmi_uc_create_mms_xml_description_file(void)
  243. {
  244.     /*----------------------------------------------------------------*/
  245.     /* Local Variables                                                */
  246.     /*----------------------------------------------------------------*/
  247.     U8 file_path[MMI_UC_MAX_TEMP_FILE_LEN];
  248.     FS_HANDLE fh;
  249.     S32 result = FS_NO_ERROR;
  250.     /*----------------------------------------------------------------*/
  251.     /* Code Body                                                      */
  252.     /*----------------------------------------------------------------*/
  253.     mmi_uc_update_object_id();
  254.     /* Make sure every object name is unique. */
  255.     mmi_uc_replace_duplicate_object_file_name();
  256.     
  257.     memset(file_path, 0, MMI_UC_MAX_TEMP_FILE_LEN);
  258.     MMI_UC_MAKE_MMS_XML_FILE_PATH(file_path, 0);
  259.     
  260.     /* Open the file to write, overwrite if already exists. */
  261.     fh = FS_Open((U16*) file_path, FS_CREATE_ALWAYS | FS_READ_WRITE);
  262.     if (fh > 0)
  263.     {
  264.         /* <mms> */
  265.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_MMS, NULL)) != FS_NO_ERROR)
  266.         {
  267.             FS_Close(fh);
  268.             return result;
  269.         }
  270.         if ((result = mmi_uc_create_xml_new_line(fh))!= FS_NO_ERROR)
  271.         {
  272.             FS_Close(fh);
  273.             return result;
  274.         }
  275.         /* <header> */
  276.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_HEADER, NULL)) != FS_NO_ERROR)
  277.         {
  278.             FS_Close(fh);
  279.             return result;
  280.         }
  281.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  282.         {
  283.             FS_Close(fh);
  284.             return result;
  285.         }
  286.         /* To address */
  287.         if (g_uc_p->msg.to_num)
  288.         {
  289.             if ((result = mmi_uc_create_xml_addr(fh, MMI_UC_ADDRESS_GROUP_TYPE_TO))
  290.                 != FS_NO_ERROR)
  291.             {
  292.                 FS_Close(fh);
  293.                 return result;
  294.             }
  295.         }
  296.         
  297.         /* Cc address */
  298.         if (g_uc_p->msg.cc_num)
  299.         {
  300.             if ((result = mmi_uc_create_xml_addr(fh, MMI_UC_ADDRESS_GROUP_TYPE_CC))
  301.                 != FS_NO_ERROR)
  302.             {
  303.                 FS_Close(fh);
  304.                 return result;
  305.             }
  306.         }
  307.         
  308.         /* Bcc address */
  309.         if (g_uc_p->msg.bcc_num)
  310.         {
  311.             if ((result = mmi_uc_create_xml_addr(fh, MMI_UC_ADDRESS_GROUP_TYPE_BCC))
  312.                 != FS_NO_ERROR)
  313.             {
  314.                 FS_Close(fh);
  315.                 return result;
  316.             }
  317.         }
  318.         /* subject */
  319.         if (pfnUnicodeStrlen((S8*)g_uc_p->msg.subject))
  320.         {
  321.             if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_SUBJECT, NULL)) != FS_NO_ERROR)
  322.             {
  323.                 FS_Close(fh);
  324.                 return result;
  325.             }
  326.             if ((result = mmi_uc_create_xml_data_usc2_to_utf8(fh, (U8*)g_uc_p->msg.subject)) != FS_NO_ERROR)
  327.             {
  328.                 FS_Close(fh);
  329.                 return result;
  330.             }        
  331.             if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_SUBJECT)) != FS_NO_ERROR)
  332.             {
  333.                 FS_Close(fh);
  334.                 return result;
  335.             }
  336.             if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  337.             {
  338.                 FS_Close(fh);
  339.                 return result;
  340.             }
  341.         }
  342.         /* Read Report */
  343.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_READ_REPORT, NULL)) != FS_NO_ERROR)
  344.         {
  345.             FS_Close(fh);
  346.             return result;
  347.         }
  348.         if ((result = mmi_uc_create_xml_data_numeric_to_char(fh, g_uc_p->msg.read_report)) != FS_NO_ERROR)
  349.         {
  350.             FS_Close(fh);
  351.             return result;
  352.         }        
  353.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_READ_REPORT)) != FS_NO_ERROR)
  354.         {
  355.             FS_Close(fh);
  356.             return result;
  357.         }
  358.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  359.         {
  360.             FS_Close(fh);
  361.             return result;
  362.         }
  363.         /* Delivery Report */
  364.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_DELIVERY_REPORT, NULL)) != FS_NO_ERROR)
  365.         {
  366.             FS_Close(fh);
  367.             return result;
  368.         }
  369.         if ((result = mmi_uc_create_xml_data_numeric_to_char(fh, g_uc_p->msg.delivery_report)) != FS_NO_ERROR)
  370.         {
  371.             FS_Close(fh);
  372.             return result;
  373.         }        
  374.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_DELIVERY_REPORT)) != FS_NO_ERROR)
  375.         {
  376.             FS_Close(fh);
  377.             return result;
  378.         }
  379.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  380.         {
  381.             FS_Close(fh);
  382.             return result;
  383.         }
  384.         /* Priority */
  385.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_PRIORITY, NULL)) != FS_NO_ERROR)
  386.         {
  387.             FS_Close(fh);
  388.             return result;
  389.         }
  390.         if ((result = mmi_uc_create_xml_data_numeric_to_char(fh, g_uc_p->msg.priority)) != FS_NO_ERROR)
  391.         {
  392.             FS_Close(fh);
  393.             return result;
  394.         }        
  395.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_PRIORITY)) != FS_NO_ERROR)
  396.         {
  397.             FS_Close(fh);
  398.             return result;
  399.         }
  400.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  401.         {
  402.             FS_Close(fh);
  403.             return result;
  404.         }
  405.         /* Expiry time */
  406.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_EXPIRY, NULL)) != FS_NO_ERROR)
  407.         {
  408.             FS_Close(fh);
  409.             return result;
  410.         }
  411.         if ((result = mmi_uc_create_xml_data_numeric_to_char(fh, g_uc_p->msg.expiry_time)) != FS_NO_ERROR)
  412.         {
  413.             FS_Close(fh);
  414.             return result;
  415.         }        
  416.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_EXPIRY)) != FS_NO_ERROR)
  417.         {
  418.             FS_Close(fh);
  419.             return result;
  420.         }
  421.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  422.         {
  423.             FS_Close(fh);
  424.             return result;
  425.         }
  426.         /* Delivery time */
  427.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_DELIVERY_TIME, NULL)) != FS_NO_ERROR)
  428.         {
  429.             FS_Close(fh);
  430.             return result;
  431.         }
  432.         if ((result = mmi_uc_create_xml_data_numeric_to_char(fh, g_uc_p->msg.delivery_time)) != FS_NO_ERROR)
  433.         {
  434.             FS_Close(fh);
  435.             return result;
  436.         }        
  437.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_DELIVERY_TIME)) != FS_NO_ERROR)
  438.         {
  439.             FS_Close(fh);
  440.             return result;
  441.         }
  442.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  443.         {
  444.             FS_Close(fh);
  445.             return result;
  446.         }
  447.         /* Sender visibility */
  448.         if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_VISIBLE, NULL)) != FS_NO_ERROR)
  449.         {
  450.             FS_Close(fh);
  451.             return result;
  452.         }
  453.         if ((result = mmi_uc_create_xml_data_numeric_to_char(fh, g_uc_p->msg.sender_visibility)) != FS_NO_ERROR)
  454.         {
  455.             FS_Close(fh);
  456.             return result;
  457.         }        
  458.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_VISIBLE)) != FS_NO_ERROR)
  459.         {
  460.             FS_Close(fh);
  461.             return result;
  462.         }
  463.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  464.         {
  465.             FS_Close(fh);
  466.             return result;
  467.         }
  468.         /* </header> */
  469.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_HEADER)) != FS_NO_ERROR)
  470.         {
  471.             FS_Close(fh);
  472.             return result;
  473.         }
  474.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  475.         {
  476.             FS_Close(fh);
  477.             return result;
  478.         }
  479.         if ((g_uc_p->main.state != MMI_UC_STATE_FORWARD && g_uc_p->main.state != MMI_UC_STATE_SEND) ||
  480.             ((g_uc_p->main.state == MMI_UC_STATE_FORWARD || g_uc_p->main.state == MMI_UC_STATE_SEND) && 
  481.                 (g_uc_p->send_info.existed_msg_type != MMI_UC_MSG_TYPE_MMS_PREFER)))
  482.         {
  483.             /* <body> */
  484.             {
  485.                 U16 color_str_len = 10; /* size of bg_color and fg_color */
  486.                 U16 str_len = 5; /* size of slide_num, obj_num, and layout */
  487.                 U16 attr_num = 5; /* size of arrt_list would be attr_num * 2 + 1 */
  488.                 U8 bg_color[10];
  489.                 U8 fg_color[10];
  490.                 U8 slide_num[5];
  491.                 U8 obj_num[5];
  492.                 U8 layout[5];
  493.                 U8* attr_list[5 * 2 + 1];
  494.                 U8 i = 0;
  495.                 memset(bg_color, 0, color_str_len);
  496.                 sprintf((char*)bg_color, "0x%06x", g_uc_p->msg.background_color);
  497.                 attr_list[i++] = (U8*)MMI_UC_XML_ATTR_BGCOLOR;
  498.                 attr_list[i++] = bg_color;
  499.                 
  500.                 memset(fg_color, 0, color_str_len);
  501.                 sprintf((char*)fg_color, "0x%06x", g_uc_p->msg.foreground_color);
  502.                 attr_list[i++] = (U8*)MMI_UC_XML_ATTR_FGCOLOR;
  503.                 attr_list[i++] = fg_color;
  504.                 /* If only attachments and one slide without any content, do not send slide info.*/
  505.                 /* reference phone behavior */
  506.                 memset(slide_num, 0, str_len);            
  507.                 if (mmi_uc_check_only_attachment() && g_uc_p->send_info.action != MMI_UC_ACTION_PREVIEW)
  508.                 {
  509.                     sprintf((char*)slide_num, "%d", 0);
  510.                 }
  511.                 else
  512.                 {
  513.                     sprintf((char*)slide_num, "%d", g_uc_p->msg.total_slide_num);
  514.                 }
  515.                 attr_list[i++] = (U8*)MMI_UC_XML_ATTR_SLIDE_NUM;
  516.                 attr_list[i++] = slide_num;
  517.                 memset(obj_num, 0, str_len);
  518.                 sprintf((char*)obj_num, "%d", g_uc_p->msg.total_object_num);
  519.                 attr_list[i++] = (U8*)MMI_UC_XML_ATTR_OBJ_NUM;
  520.                 attr_list[i++] = obj_num;            
  521.                 memset(layout, 0, str_len);
  522.                 sprintf((char*)layout, "%d", mmi_uc_convert_to_mms_layout_type(g_uc_p->msg.layout));
  523.                 attr_list[i++] = (U8*)MMI_UC_XML_ATTR_LAYOUT;
  524.                 attr_list[i++] = layout;
  525.                 attr_list[i++] = NULL;
  526.                 MMI_ASSERT(i == (attr_num * 2 + 1));
  527.                 if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_BODY, attr_list)) != FS_NO_ERROR)
  528.                 {
  529.                     FS_Close(fh);
  530.                     return result;
  531.                 }
  532.                 if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  533.                 {
  534.                     FS_Close(fh);
  535.                     return result;
  536.                 }            
  537.             }
  538.             /* Slide */
  539.             if (mmi_uc_check_only_attachment() && g_uc_p->send_info.action != MMI_UC_ACTION_PREVIEW)
  540.             {
  541.                 /* If only attachments and one slide without any content, do not send slide info.*/
  542.                 /* reference phone behavior */
  543.             }
  544.             else
  545.             {
  546.                 if (g_uc_p->msg.total_slide_num)
  547.                 {
  548.                     mmi_uc_slide_struct* slide = g_uc_p->msg.slide_head;
  549.                     U16 i = 0;
  550.                     while (i < g_uc_p->msg.total_slide_num)
  551.                     {
  552.                         MMI_ASSERT(slide);
  553.                         if ((result = mmi_uc_create_xml_slide(fh, slide)) != FS_NO_ERROR)
  554.                         {
  555.                             FS_Close(fh);
  556.                             return result;
  557.                         }
  558.                         slide = slide->next;
  559.                         i++;
  560.                     }            
  561.                 }
  562.             }
  563.             /* Object */
  564.             if (g_uc_p->msg.total_object_num)
  565.             {
  566.                 mmi_uc_object_struct* object = g_uc_p->msg.object_head;
  567.                 U16 i = 0;
  568.                 while (i < g_uc_p->msg.total_object_num)
  569.                 {
  570.                     MMI_ASSERT(object);
  571.                     if ((result = mmi_uc_create_xml_object(fh, object)) != FS_NO_ERROR)
  572.                     {
  573.                         FS_Close(fh);
  574.                         return result;
  575.                     }
  576.                     object = object->next;
  577.                     i++;
  578.                 }            
  579.             }
  580.             /* </body> */
  581.             if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_BODY)) != FS_NO_ERROR)
  582.             {
  583.                 FS_Close(fh);
  584.                 return result;
  585.             }
  586.             if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  587.             {
  588.                 FS_Close(fh);
  589.                 return result;
  590.             }
  591.         }
  592.         /* </mms> */
  593.         if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_MMS)) != FS_NO_ERROR)
  594.         {
  595.             FS_Close(fh);
  596.             return result;
  597.         }
  598.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  599.         {
  600.             FS_Close(fh);
  601.             return result;
  602.         }            
  603.         
  604.         FS_Close(fh);
  605.     }
  606.     else
  607.     {
  608.         result = (S32)fh;
  609.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  610.                              "*[UnifiedComposerMiscell.c] mmi_uc_create_mms_xml_description_file Create xml file FAIL! res=%d *n", result));
  611.     }
  612.     return result;
  613. }
  614. /*****************************************************************************
  615.  * FUNCTION
  616.  *  mmi_uc_create_xml_element_start
  617.  * DESCRIPTION
  618.  *  Create the xml start element
  619.  * PARAMETERS
  620.  *  void
  621.  * RETURNS
  622.  *  void
  623.  *****************************************************************************/
  624. S32 mmi_uc_create_xml_element_start(FS_HANDLE fh, U8* element_name, U8** attr_list)
  625. {
  626.     /*----------------------------------------------------------------*/
  627.     /* Local Variables                                                */
  628.     /*----------------------------------------------------------------*/
  629.     U8* temp_str = OslMalloc(MMI_UC_XML_TEMP_STR_LEN);
  630.     S32 result = FS_NO_ERROR;
  631.     U32 write_len = 0;
  632.     U32 i = 0;
  633.     U32 offset = 0;
  634.     /*----------------------------------------------------------------*/
  635.     /* Code Body                                                      */
  636.     /*----------------------------------------------------------------*/
  637.     memset(temp_str,0,MMI_UC_XML_TEMP_STR_LEN);
  638.     offset += sprintf((char*)temp_str, "%s%s", XML_TAG_ELEMENT_START, element_name);
  639.     if (attr_list)
  640.     {
  641.         while (attr_list[i])
  642.         {
  643.             offset += sprintf((char*)temp_str + offset, " %s="%s"", attr_list[i], attr_list[i + 1]);
  644.             i = i + 2;
  645.         }
  646.     }
  647.     offset += sprintf((char*)(temp_str + offset), "%s", XML_TAG_GENERAL_END);
  648.     MMI_ASSERT(offset < MMI_UC_XML_TEMP_STR_LEN);
  649.     result = FS_Write(fh, temp_str, offset, &write_len);
  650.     OslMfree(temp_str);
  651.     return result;
  652. }
  653. /*****************************************************************************
  654.  * FUNCTION
  655.  *  mmi_uc_create_xml_element_end
  656.  * DESCRIPTION
  657.  *  Create the xml end element
  658.  * PARAMETERS
  659.  *  void
  660.  * RETURNS
  661.  *  void
  662.  *****************************************************************************/
  663. S32 mmi_uc_create_xml_element_end(FS_HANDLE fh, U8* element_name)
  664. {
  665.     /*----------------------------------------------------------------*/
  666.     /* Local Variables                                                */
  667.     /*----------------------------------------------------------------*/
  668.     U8* temp_str = OslMalloc(MMI_UC_XML_TEMP_STR_LEN);
  669.     S32 result = FS_NO_ERROR;
  670.     U32 write_len = 0;
  671.     U32 offset = 0;
  672.     /*----------------------------------------------------------------*/
  673.     /* Code Body                                                      */
  674.     /*----------------------------------------------------------------*/
  675.     memset(temp_str,0,MMI_UC_XML_TEMP_STR_LEN);
  676.     offset += sprintf((char*)temp_str, "%s%s%s", XML_TAG_ELEMENT_END, element_name,XML_TAG_GENERAL_END);
  677.     MMI_ASSERT(offset < MMI_UC_XML_TEMP_STR_LEN);
  678.     result = FS_Write(fh, temp_str, offset, &write_len);
  679.     OslMfree(temp_str);
  680.     return result;
  681. }
  682. /*****************************************************************************
  683.  * FUNCTION
  684.  *  mmi_uc_create_xml_new_line
  685.  * DESCRIPTION
  686.  *  Insert new line
  687.  * PARAMETERS
  688.  *  void
  689.  * RETURNS
  690.  *  void
  691.  *****************************************************************************/
  692. S32 mmi_uc_create_xml_new_line(FS_HANDLE fh)
  693. {
  694.     /*----------------------------------------------------------------*/
  695.     /* Local Variables                                                */
  696.     /*----------------------------------------------------------------*/
  697.     U8* temp_str = OslMalloc(MMI_UC_XML_TEMP_STR_LEN);
  698.     S32 result = FS_NO_ERROR;
  699.     U32 write_len = 0;
  700.     U32 offset = 0;
  701.     /*----------------------------------------------------------------*/
  702.     /* Code Body                                                      */
  703.     /*----------------------------------------------------------------*/
  704.     memset(temp_str,0,MMI_UC_XML_TEMP_STR_LEN);
  705.     offset += sprintf((char*)temp_str, "n");
  706.     result = FS_Write(fh, temp_str, offset, &write_len);
  707.     OslMfree(temp_str);
  708.     return result;
  709. }
  710. /*****************************************************************************
  711.  * FUNCTION
  712.  *  mmi_uc_create_xml_data
  713.  * DESCRIPTION
  714.  *  Add data
  715.  * PARAMETERS
  716.  *  void
  717.  * RETURNS
  718.  *  void
  719.  *****************************************************************************/
  720. S32 mmi_uc_create_xml_data(FS_HANDLE fh, U8* data)
  721. {
  722.     /*----------------------------------------------------------------*/
  723.     /* Local Variables                                                */
  724.     /*----------------------------------------------------------------*/
  725.     S32 result = FS_NO_ERROR;
  726.     U32 write_len = 0;
  727.     U32 offset = 0;
  728.     /*----------------------------------------------------------------*/
  729.     /* Code Body                                                      */
  730.     /*----------------------------------------------------------------*/
  731.     offset = strlen((char*)data);
  732.     result = FS_Write(fh, data, offset, &write_len);
  733.     return result;
  734. }
  735. /*****************************************************************************
  736.  * FUNCTION
  737.  *  mmi_uc_create_xml_data
  738.  * DESCRIPTION
  739.  *  Add data
  740.  * PARAMETERS
  741.  *  void
  742.  * RETURNS
  743.  *  void
  744.  *****************************************************************************/
  745. S32 mmi_uc_create_xml_data_usc2_to_utf8(FS_HANDLE fh, U8* data)
  746. {
  747.     /*----------------------------------------------------------------*/
  748.     /* Local Variables                                                */
  749.     /*----------------------------------------------------------------*/
  750.     U8* utf8_data;
  751.     U32 utf8_data_len = pfnUnicodeStrlen((S8*)data) * 3 + 1;
  752.     S32 result;
  753.     /*----------------------------------------------------------------*/
  754.     /* Code Body                                                      */
  755.     /*----------------------------------------------------------------*/    
  756.     utf8_data = OslMalloc(utf8_data_len);
  757.     memset(utf8_data,0,utf8_data_len);
  758.     
  759.     mmi_chset_ucs2_to_utf8_string(
  760.         (kal_uint8*) utf8_data,
  761.         utf8_data_len,
  762.         (kal_uint8*) data);
  763.     result = mmi_uc_create_xml_data(fh, utf8_data);
  764.     OslMfree(utf8_data);
  765.     return result;
  766. }
  767. /*****************************************************************************
  768.  * FUNCTION
  769.  *  mmi_uc_create_xml_data_numeric_to_char
  770.  * DESCRIPTION
  771.  *  Add numeric data
  772.  * PARAMETERS
  773.  *  void
  774.  * RETURNS
  775.  *  void
  776.  *****************************************************************************/
  777. S32 mmi_uc_create_xml_data_numeric_to_char(FS_HANDLE fh, U32 value)
  778. {
  779.     /*----------------------------------------------------------------*/
  780.     /* Local Variables                                                */
  781.     /*----------------------------------------------------------------*/
  782.     U8* data;
  783.     U32 data_len = 10;
  784.     S32 result;
  785.     U32 offset = 0;
  786.     /*----------------------------------------------------------------*/
  787.     /* Code Body                                                      */
  788.     /*----------------------------------------------------------------*/    
  789.     data = OslMalloc(data_len);
  790.     memset(data,0,data_len);
  791.     
  792.     offset += sprintf((char*)data, "%d", value);
  793.     result = mmi_uc_create_xml_data(fh, data);
  794.     OslMfree(data);
  795.     return result;
  796. }
  797. /*****************************************************************************
  798.  * FUNCTION
  799.  *  mmi_uc_create_xml_addr
  800.  * DESCRIPTION
  801.  *  Add data
  802.  * PARAMETERS
  803.  *  void
  804.  * RETURNS
  805.  *  void
  806.  *****************************************************************************/
  807. S32 mmi_uc_create_xml_addr(FS_HANDLE fh, mmi_uc_address_group_type_enum type)
  808. {
  809.     /*----------------------------------------------------------------*/
  810.     /* Local Variables                                                */
  811.     /*----------------------------------------------------------------*/
  812.     S32 result;
  813.     U32 i = 0;
  814.     mmi_uc_addr_struct* addr = NULL;
  815.     U8* attr_list[3];
  816.     U8* xml_addr_type = NULL;
  817.     U32 total = 0;
  818.     /*----------------------------------------------------------------*/
  819.     /* Code Body                                                      */
  820.     /*----------------------------------------------------------------*/
  821.     switch (type)
  822.     {
  823.         case MMI_UC_ADDRESS_GROUP_TYPE_TO:
  824.         {
  825.             addr = g_uc_p->msg.to_head;
  826.             total = g_uc_p->msg.to_num;
  827.             xml_addr_type = (U8*)MMI_UC_XML_ELEMENT_TO;
  828.         }
  829.         break;
  830.             
  831.         case MMI_UC_ADDRESS_GROUP_TYPE_CC:
  832.         {
  833.             addr = g_uc_p->msg.cc_head;
  834.             total = g_uc_p->msg.cc_num;
  835.             xml_addr_type = (U8*)MMI_UC_XML_ELEMENT_CC;
  836.         }
  837.         break;
  838.         case MMI_UC_ADDRESS_GROUP_TYPE_BCC:
  839.         {
  840.             addr = g_uc_p->msg.bcc_head;
  841.             total = g_uc_p->msg.bcc_num;
  842.             xml_addr_type = (U8*)MMI_UC_XML_ELEMENT_BCC;
  843.         }
  844.         break;
  845.         default:
  846.         {
  847.             MMI_ASSERT(0);
  848.         }
  849.         break;
  850.     }
  851.     attr_list[0] = (U8*)MMI_UC_XML_ATTR_TYPE;
  852.     attr_list[2] = NULL;
  853.     while (i < total)
  854.     {
  855.         MMI_ASSERT(addr);
  856.         
  857.         if (addr->type == MMI_UC_ADDRESS_TYPE_PHONE_NUMBER)
  858.         {
  859.             attr_list[1] = (U8*)MMI_UC_XML_ATTR_POHNE_NUMBER;
  860.             if ((result = mmi_uc_create_xml_element_start(fh,xml_addr_type,attr_list)) 
  861.                 != FS_NO_ERROR)
  862.             {
  863.                 return result;
  864.             }
  865.             if ((result = mmi_uc_create_xml_data(fh, addr->addr)) != FS_NO_ERROR)
  866.             {
  867.                 return result;
  868.             }                    
  869.         }
  870.         else if (addr->type == MMI_UC_ADDRESS_TYPE_EMAIL)
  871.         {        
  872.             attr_list[1] = (U8*)MMI_UC_XML_ATTR_EMAIL_ADDR;
  873.             
  874.             if ((result = mmi_uc_create_xml_element_start(fh,xml_addr_type,attr_list)) 
  875.                 != FS_NO_ERROR)
  876.             {
  877.                 return result;
  878.             }            
  879.             if ((result = mmi_uc_create_xml_data_usc2_to_utf8(fh, addr->addr)) != FS_NO_ERROR)
  880.             {
  881.                 return result;
  882.             }                    
  883.         }
  884.         else
  885.         {
  886.             MMI_ASSERT(0);
  887.         }
  888.         if ((result = mmi_uc_create_xml_element_end(fh, xml_addr_type)) 
  889.                 != FS_NO_ERROR)
  890.         {
  891.             return result;
  892.         }
  893.         if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  894.         {
  895.             return result;
  896.         }
  897.         addr = addr->next;
  898.         i++;
  899.     }
  900.     return FS_NO_ERROR;
  901. }
  902. /*****************************************************************************
  903.  * FUNCTION
  904.  *  mmi_uc_create_xml_slide
  905.  * DESCRIPTION
  906.  *  Add data
  907.  * PARAMETERS
  908.  *  void
  909.  * RETURNS
  910.  *  void
  911.  *****************************************************************************/
  912. S32 mmi_uc_create_xml_slide(FS_HANDLE fh, mmi_uc_slide_struct* slide)
  913. {
  914.     /*----------------------------------------------------------------*/
  915.     /* Local Variables                                                */
  916.     /*----------------------------------------------------------------*/
  917.     S32 result;    
  918.     U16 str_len = 5;  /* size of index and duration */
  919.     U16 attr_num = 2; /* size of attr_list would be attr_num * 2 + 1 */
  920.     U8 index[5];
  921.     U8 duration[5];
  922.     U8* attr_list[2 * 2 + 1];
  923.     U8 j = 0;
  924.     
  925.     /*----------------------------------------------------------------*/
  926.     /* Code Body                                                      */
  927.     /*----------------------------------------------------------------*/
  928.     MMI_ASSERT(slide);
  929.     memset(index, 0, str_len);
  930.     sprintf((char*)index, "%d", (slide->slide_num));
  931.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_INDEX;
  932.     attr_list[j++] = index;
  933.     memset(duration, 0, str_len);
  934.     sprintf((char*)duration, "%d", g_uc_p->msg.slide_timing);
  935.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_DURATION;
  936.     attr_list[j++] = duration;
  937.     attr_list[j++] = NULL;
  938.     MMI_ASSERT(j == (attr_num * 2 + 1));
  939.     if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_SLIDE, attr_list)) != FS_NO_ERROR)
  940.     {
  941.         return result;
  942.     }
  943.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  944.     {
  945.         return result;
  946.     }
  947.     /* text */
  948.     if (slide->text.object)
  949.     {
  950.         if ((result = mmi_uc_create_xml_slide_object(fh, slide, MMI_UC_OBJECT_TYPE_TEXT)) != FS_NO_ERROR)
  951.         {
  952.             return result;
  953.         }
  954.     }
  955.     /* image */
  956.     if (slide->image.object)
  957.     {
  958.         if ((result = mmi_uc_create_xml_slide_object(fh, slide, MMI_UC_OBJECT_TYPE_IMAGE)) != FS_NO_ERROR)
  959.         {
  960.             return result;
  961.         }
  962.     }
  963.     /* audio */
  964.     if (slide->audio.object)
  965.     {
  966.         if ((result = mmi_uc_create_xml_slide_object(fh, slide, MMI_UC_OBJECT_TYPE_AUDIO)) != FS_NO_ERROR)
  967.         {
  968.             return result;
  969.         }
  970.     }
  971.     /* video */
  972.     if (slide->video.object)
  973.     {
  974.         if ((result = mmi_uc_create_xml_slide_object(fh, slide, MMI_UC_OBJECT_TYPE_VIDEO)) != FS_NO_ERROR)
  975.         {
  976.             return result;
  977.         }
  978.     }
  979.     if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_SLIDE)) != FS_NO_ERROR)
  980.     {
  981.         return result;
  982.     }
  983.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  984.     {
  985.         return result;
  986.     }
  987.     return FS_NO_ERROR;
  988. }
  989. /*****************************************************************************
  990.  * FUNCTION
  991.  *  mmi_uc_create_xml_slide_object
  992.  * DESCRIPTION
  993.  *  Add data
  994.  * PARAMETERS
  995.  *  void
  996.  * RETURNS
  997.  *  void
  998.  *****************************************************************************/
  999. S32 mmi_uc_create_xml_slide_object(FS_HANDLE fh, mmi_uc_slide_struct* slide, mmi_uc_object_type obj_type)
  1000. {
  1001.     /*----------------------------------------------------------------*/
  1002.     /* Local Variables                                                */
  1003.     /*----------------------------------------------------------------*/
  1004.     S32 result;
  1005.     U32 bg_color = 0;
  1006.     U32 fg_color = 0;
  1007.     U16 color_str_len = 10; /* size of bg_color_str and fg_color_str */
  1008.     U16 str_len = 5; /* size of id_str , start_str, and end_str */
  1009.     U16 attr_num = 5; /* size of attr_list would be attr_num * 2 + 1 */
  1010.     U32 id = 0;    
  1011.     U8 bg_color_str[10];
  1012.     U8 fg_color_str[10];
  1013.     U8 id_str[5];
  1014.     U8 start_str[5];
  1015.     U8 end_str[5];
  1016.     U8* attr_list[5 * 2 + 1];
  1017.     U8 i = 0;
  1018.     U8 begin = 0;
  1019.     U8 end = 0;
  1020.     U8* obj_xml_type = NULL;
  1021.     /*----------------------------------------------------------------*/
  1022.     /* Code Body                                                      */
  1023.     /*----------------------------------------------------------------*/
  1024.     MMI_ASSERT(slide);
  1025.     
  1026.     switch (obj_type)
  1027.     {
  1028.         case MMI_UC_OBJECT_TYPE_TEXT:
  1029.         {
  1030.             MMI_ASSERT(slide->text.object);
  1031.             fg_color = slide->text.foreground_color;
  1032.             bg_color = slide->text.background_color;
  1033.             id = slide->text.object->id;
  1034.             begin = slide->text.begin;            
  1035.             end = slide->text.end;
  1036.             obj_xml_type = (U8*)MMI_UC_XML_ELEMENT_TEXT;
  1037.         }
  1038.         break;
  1039.         case MMI_UC_OBJECT_TYPE_IMAGE:
  1040.         {
  1041.             MMI_ASSERT(slide->image.object);
  1042.             id = slide->image.object->id;
  1043.             begin = slide->image.begin;            
  1044.             end = slide->image.end;
  1045.             obj_xml_type = (U8*)MMI_UC_XML_ELEMENT_IMAGE;
  1046.         }
  1047.         break;
  1048.         
  1049.         case MMI_UC_OBJECT_TYPE_AUDIO:
  1050.         {
  1051.             MMI_ASSERT(slide->audio.object);
  1052.             id = slide->audio.object->id;
  1053.             begin = slide->audio.begin;            
  1054.             end = slide->audio.end;
  1055.             obj_xml_type = (U8*)MMI_UC_XML_ELEMENT_AUDIO;
  1056.         }
  1057.         break;
  1058.         
  1059.         case MMI_UC_OBJECT_TYPE_VIDEO:
  1060.         {
  1061.             MMI_ASSERT(slide->video.object);
  1062.             id = slide->video.object->id;
  1063.             begin = slide->video.begin;            
  1064.             end = slide->video.end;
  1065.             obj_xml_type = (U8*)MMI_UC_XML_ELEMENT_VIDEO;
  1066.         }
  1067.         break;        
  1068.         default:
  1069.         {
  1070.             MMI_ASSERT(0);
  1071.         }
  1072.         break;
  1073.     }
  1074.     if (obj_type == MMI_UC_OBJECT_TYPE_TEXT)
  1075.     {
  1076.         memset(bg_color_str, 0, color_str_len);
  1077.         sprintf((char*)bg_color_str, "0x%06x", bg_color);
  1078.         attr_list[i++] = (U8*)MMI_UC_XML_ATTR_BGCOLOR;
  1079.         attr_list[i++] = bg_color_str;
  1080.         
  1081.         memset(fg_color_str, 0, color_str_len);
  1082.         sprintf((char*)fg_color_str, "0x%06x", fg_color);
  1083.         attr_list[i++] = (U8*)MMI_UC_XML_ATTR_FGCOLOR;
  1084.         attr_list[i++] = fg_color_str;
  1085.     }
  1086.     memset(id_str, 0, str_len);
  1087.     sprintf((char*)id_str, "%d", id);
  1088.     attr_list[i++] = (U8*)MMI_UC_XML_ATTR_ID;
  1089.     attr_list[i++] = id_str;
  1090.     if (begin != MMI_UC_INVALID_VALUE &&
  1091.         end != MMI_UC_INVALID_VALUE)
  1092.     {
  1093.         memset(start_str, 0, str_len);
  1094.         sprintf((char*)start_str, "%d", slide->text.begin);
  1095.         attr_list[i++] = (U8*)MMI_UC_XML_ATTR_BEGIN;
  1096.         attr_list[i++] = start_str;            
  1097.         memset(end_str, 0, str_len);
  1098.         sprintf((char*)end_str, "%d", slide->text.end);
  1099.         attr_list[i++] = (U8*)MMI_UC_XML_ATTR_END;
  1100.         attr_list[i++] = end_str;
  1101.     }
  1102.     
  1103.     attr_list[i] = NULL;
  1104.     MMI_ASSERT(i <= (attr_num * 2 + 1));
  1105.     if ((result = mmi_uc_create_xml_element_single(fh, obj_xml_type, attr_list)) != FS_NO_ERROR)
  1106.     {
  1107.         return result;
  1108.     }
  1109.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  1110.     {
  1111.         return result;
  1112.     }
  1113.     return FS_NO_ERROR;
  1114. }
  1115. /*****************************************************************************
  1116.  * FUNCTION
  1117.  *  mmi_uc_create_xml_element_single
  1118.  * DESCRIPTION
  1119.  *  Create the xml single element
  1120.  * PARAMETERS
  1121.  *  void
  1122.  * RETURNS
  1123.  *  void
  1124.  *****************************************************************************/
  1125. S32 mmi_uc_create_xml_element_single(FS_HANDLE fh, U8* element_name, U8** attr_list)
  1126. {
  1127.     /*----------------------------------------------------------------*/
  1128.     /* Local Variables                                                */
  1129.     /*----------------------------------------------------------------*/
  1130.     U8* temp_str = OslMalloc(MMI_UC_XML_TEMP_STR_LEN);
  1131.     S32 result = FS_NO_ERROR;
  1132.     U32 write_len = 0;
  1133.     U32 i = 0;
  1134.     U32 offset = 0;
  1135.     /*----------------------------------------------------------------*/
  1136.     /* Code Body                                                      */
  1137.     /*----------------------------------------------------------------*/
  1138.     memset(temp_str,0,MMI_UC_XML_TEMP_STR_LEN);
  1139.     offset += sprintf((char*)temp_str, "%s%s", XML_TAG_ELEMENT_START, element_name);
  1140.     if (attr_list)
  1141.     {
  1142.         while (attr_list[i])
  1143.         {
  1144.             offset += sprintf((char*)(temp_str + offset), " %s="%s"", attr_list[i], attr_list[i + 1]);
  1145.             i = i + 2;
  1146.         }
  1147.     }
  1148.     offset += sprintf((char*)(temp_str + offset), "%s", XML_TAG_SINGLE_END);
  1149.     MMI_ASSERT(offset < MMI_UC_XML_TEMP_STR_LEN);
  1150.     result = FS_Write(fh, temp_str, offset, &write_len);
  1151.     OslMfree(temp_str);
  1152.     return result;
  1153. }
  1154.     
  1155. /*****************************************************************************
  1156.  * FUNCTION
  1157.  *  mmi_uc_create_xml_object
  1158.  * DESCRIPTION
  1159.  *  Add data
  1160.  * PARAMETERS
  1161.  *  void
  1162.  * RETURNS
  1163.  *  void
  1164.  *****************************************************************************/
  1165. S32 mmi_uc_create_xml_object(FS_HANDLE fh, mmi_uc_object_struct* obj)
  1166. {
  1167.     /*----------------------------------------------------------------*/
  1168.     /* Local Variables                                                */
  1169.     /*----------------------------------------------------------------*/
  1170.     S32 result;    
  1171.     U16 str_len = 5; /* size of id, attach, vf, and drm */
  1172.     U16 byte_len = 10; /* size of size and offset */
  1173.     U16 attr_num = 6; /* size of attr_list would be attr_num * 2 + 1 */
  1174.     U8 id[5];
  1175.     U8 attach[5];
  1176.     U8 vf[5];
  1177.     U8 drm[5];
  1178.     U8 size[10];
  1179.     U8 offset[10];
  1180.     U8* attr_list[6 * 2 + 1];
  1181.     U8 j = 0;
  1182.     
  1183.     /*----------------------------------------------------------------*/
  1184.     /* Code Body                                                      */
  1185.     /*----------------------------------------------------------------*/
  1186.     MMI_ASSERT(obj);
  1187.     memset(id, 0, str_len);
  1188.     sprintf((char*)id, "%d", obj->id);
  1189.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_ID;
  1190.     attr_list[j++] = id;
  1191.     memset(attach, 0, str_len);
  1192.     if (obj->type == MMI_UC_OBJECT_TYPE_ATTACHMENT)
  1193.     {
  1194.         sprintf((char*)attach, "%d", 1);
  1195.     }
  1196.     else
  1197.     {
  1198.         sprintf((char*)attach, "%d", 0);
  1199.     }    
  1200.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_ATTACH;
  1201.     attr_list[j++] = attach;
  1202.     memset(vf, 0, str_len);
  1203.     sprintf((char*)vf, "%d", obj->is_virtual_file);
  1204.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_VIRTUAL_FILE;
  1205.     attr_list[j++] = vf;
  1206.     memset(drm, 0, str_len);
  1207.     sprintf((char*)drm, "%d", obj->drm_type);
  1208.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_DRM;
  1209.     attr_list[j++] = drm;
  1210.     memset(size, 0, byte_len);
  1211.     sprintf((char*)size, "%d", obj->size);
  1212.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_SIZE;
  1213.     attr_list[j++] = size;
  1214.     memset(offset, 0, byte_len);
  1215.     sprintf((char*)offset, "%d", obj->offset);
  1216.     attr_list[j++] = (U8*)MMI_UC_XML_ATTR_OFFSET;
  1217.     attr_list[j++] = offset;
  1218.     attr_list[j++] = NULL;
  1219.     MMI_ASSERT(j == (attr_num * 2 + 1));
  1220.     /* <obj> */
  1221.     if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_OBJECT, attr_list)) != FS_NO_ERROR)
  1222.     {
  1223.         return result;
  1224.     }
  1225.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  1226.     {
  1227.         return result;
  1228.     }
  1229.     
  1230.     /* name */
  1231.     if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_NAME, NULL)) != FS_NO_ERROR)
  1232.     {
  1233.         return result;
  1234.     }
  1235.     if ((result = mmi_uc_create_xml_data_usc2_to_utf8(fh, (U8*)obj->file_name)) != FS_NO_ERROR)
  1236.     {
  1237.         return result;
  1238.     }                    
  1239.     if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_NAME)) != FS_NO_ERROR)
  1240.     {
  1241.         return result;
  1242.     }
  1243.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  1244.     {
  1245.         return result;
  1246.     }
  1247.     
  1248.     /* file path */
  1249.     if ((result = mmi_uc_create_xml_element_start(fh, (U8*)MMI_UC_XML_ELEMENT_FILE_PATH, NULL)) != FS_NO_ERROR)
  1250.     {
  1251.         return result;
  1252.     }
  1253.     if ((result = mmi_uc_create_xml_data_usc2_to_utf8(fh, (U8*)obj->file_path)) != FS_NO_ERROR)
  1254.     {
  1255.         return result;
  1256.     }                    
  1257.     if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_FILE_PATH)) != FS_NO_ERROR)
  1258.     {
  1259.         return result;
  1260.     }
  1261.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  1262.     {
  1263.         return result;
  1264.     }
  1265.    
  1266.     /* </obj> */
  1267.     if ((result = mmi_uc_create_xml_element_end(fh, (U8*)MMI_UC_XML_ELEMENT_OBJECT)) != FS_NO_ERROR)
  1268.     {
  1269.         return result;
  1270.     }
  1271.     if ((result = mmi_uc_create_xml_new_line(fh)) != FS_NO_ERROR)
  1272.     {
  1273.         return result;
  1274.     }
  1275.     return FS_NO_ERROR;
  1276. }
  1277. /*****************************************************************************
  1278.  * FUNCTION
  1279.  *  mmi_uc_update_object_id
  1280.  * DESCRIPTION
  1281.  *  Update object ID
  1282.  * PARAMETERS
  1283.  *  void
  1284.  * RETURNS
  1285.  *  void
  1286.  *****************************************************************************/
  1287. void mmi_uc_update_object_id(void)
  1288. {
  1289.     /*----------------------------------------------------------------*/
  1290.     /* Local Variables                                                */
  1291.     /*----------------------------------------------------------------*/
  1292.     U32 i = 1;
  1293.     mmi_uc_object_struct* object = g_uc_p->msg.object_head;
  1294.     /*----------------------------------------------------------------*/
  1295.     /* Code Body                                                      */
  1296.     /*----------------------------------------------------------------*/
  1297.     for(;i <= g_uc_p->msg.total_object_num; i++)
  1298.     {
  1299.         MMI_ASSERT(object);
  1300.         object->id = i;
  1301.         object = object->next;
  1302.     }
  1303.     
  1304.     return;
  1305. }
  1306. /*****************************************************************************
  1307.  * FUNCTION
  1308.  *  mmi_uc_parse_mms_xml_description_file
  1309.  * DESCRIPTION
  1310.  *  Pare mms xml description file
  1311.  * PARAMETERS
  1312.  *  void
  1313.  * RETURNS
  1314.  *  void
  1315.  *****************************************************************************/
  1316. S32 mmi_uc_parse_mms_xml_description_file(U16* file_path)
  1317. {
  1318.     /*----------------------------------------------------------------*/
  1319.     /* Local Variables                                                */
  1320.     /*----------------------------------------------------------------*/
  1321.     S32 result = 0;
  1322.     /*----------------------------------------------------------------*/
  1323.     /* Code Body                                                      */
  1324.     /*----------------------------------------------------------------*/
  1325.     g_uc_p->xml.xml_parser = OslMalloc(sizeof(XML_PARSER_STRUCT));
  1326.     memset(g_uc_p->xml.xml_parser, 0, sizeof(XML_PARSER_STRUCT));
  1327.     result = xml_new_parser(g_uc_p->xml.xml_parser);
  1328.     if (result)
  1329.     {
  1330.         xml_close_parser(g_uc_p->xml.xml_parser);
  1331.         OslMfree(g_uc_p->xml.xml_parser);
  1332.         g_uc_p->xml.xml_parser = NULL;
  1333.         return MMI_UC_XML_ERROR;
  1334.     }
  1335.     xml_register_element_handler(g_uc_p->xml.xml_parser, mmi_uc_xml_start_element_hdlr, mmi_uc_xml_end_element_hdlr);
  1336.     xml_register_data_handler(g_uc_p->xml.xml_parser, mmi_uc_xml_data_hdlr);
  1337.     result = xml_parse(g_uc_p->xml.xml_parser, file_path);
  1338.     xml_close_parser(g_uc_p->xml.xml_parser);
  1339.     OslMfree(g_uc_p->xml.xml_parser);
  1340.     g_uc_p->xml.xml_parser = NULL;
  1341.     if (result)
  1342.     {
  1343.         return MMI_UC_XML_ERROR;
  1344.     }
  1345.     else
  1346.     {
  1347.         if (mmi_uc_match_object_id() == FS_NO_ERROR)
  1348.         {
  1349.             return MMI_UC_OK;
  1350.         }
  1351.         else
  1352.         {
  1353.             return MMI_UC_STORAGE_FULL;
  1354.         }
  1355.     }
  1356. }
  1357. /*****************************************************************************
  1358.  * FUNCTION
  1359.  *  mmi_uc_convert_mms_app_mode_to_uc_state
  1360.  * DESCRIPTION
  1361.  *  Convert mma_app_mode_enum to mmi_uc_state_enum
  1362.  * PARAMETERS
  1363.  *  void
  1364.  * RETURNS
  1365.  *  void
  1366.  *****************************************************************************/
  1367. U16 mmi_uc_convert_mms_app_mode_to_uc_state(U16 app_mode)
  1368. {
  1369.     /*----------------------------------------------------------------*/
  1370.     /* Local Variables                                                */
  1371.     /*----------------------------------------------------------------*/
  1372.     U16 uc_state = 0;
  1373.     /*----------------------------------------------------------------*/
  1374.     /* Code Body                                                      */
  1375.     /*----------------------------------------------------------------*/
  1376.     switch (app_mode)
  1377.     {
  1378.         case MMA_MODE_SEND:
  1379.         {
  1380.             uc_state = MMI_UC_STATE_SEND;
  1381.         }
  1382.         break;
  1383.         case MMA_MODE_FORWARD:
  1384.         {
  1385.             uc_state = MMI_UC_STATE_FORWARD;
  1386.         }
  1387.         break;
  1388.         case MMA_MODE_REPLY:
  1389.         {
  1390.             uc_state = MMI_UC_STATE_REPLY;
  1391.         }
  1392.         break;
  1393.         case MMA_MODE_REPLY_ALL:
  1394.         {
  1395.             uc_state = MMI_UC_STATE_REPLY_ALL;
  1396.         }
  1397.         break;
  1398.         case MMA_MODE_EDIT:
  1399.         {
  1400.             uc_state = MMI_UC_STATE_EDIT_EXISTED_MSG;
  1401.         }
  1402.         break;
  1403.         default:
  1404.         {
  1405.             MMI_ASSERT(0);
  1406.         }
  1407.         break;
  1408.     }
  1409.     
  1410.     return uc_state;
  1411. }
  1412. /*****************************************************************************
  1413.  * FUNCTION
  1414.  *  mmi_uc_convert_uc_state_to_mms_app_mode
  1415.  * DESCRIPTION
  1416.  *  Convert mmi_uc_state_enum to mma_app_mode_enum
  1417.  * PARAMETERS
  1418.  *  void
  1419.  * RETURNS
  1420.  *  void
  1421.  *****************************************************************************/
  1422. U16 mmi_uc_convert_uc_state_to_mms_app_mode(U16 uc_state)
  1423. {
  1424.     /*----------------------------------------------------------------*/
  1425.     /* Local Variables                                                */
  1426.     /*----------------------------------------------------------------*/
  1427.     U16 app_mode = 0;
  1428.     /*----------------------------------------------------------------*/
  1429.     /* Code Body                                                      */
  1430.     /*----------------------------------------------------------------*/
  1431.     switch (uc_state)
  1432.     {
  1433.         case MMI_UC_STATE_SEND:
  1434.         {
  1435.             app_mode =  MMA_MODE_SEND;
  1436.         }
  1437.         break;
  1438.         case MMI_UC_STATE_FORWARD:
  1439.         {
  1440.             app_mode =  MMA_MODE_FORWARD;
  1441.         }
  1442.         break;
  1443.         case MMI_UC_STATE_REPLY:
  1444.         {
  1445.             app_mode =  MMA_MODE_REPLY;
  1446.         }
  1447.         break;
  1448.         case MMI_UC_STATE_REPLY_ALL:
  1449.         {
  1450.             app_mode =  MMA_MODE_REPLY_ALL;
  1451.         }
  1452.         break;
  1453.         case MMI_UC_STATE_EDIT_EXISTED_MSG:
  1454.         {
  1455.             app_mode =  MMA_MODE_EDIT;
  1456.         }
  1457.         break;
  1458.         default:
  1459.         {
  1460.             MMI_ASSERT(0);
  1461.         }
  1462.         break;
  1463.     }
  1464.     
  1465.     return app_mode;
  1466. }
  1467. /*****************************************************************************
  1468.  * FUNCTION
  1469.  *  mmi_uc_xml_start_element_hdlr
  1470.  * DESCRIPTION
  1471.  *  Start element handler
  1472.  * PARAMETERS
  1473.  *  void
  1474.  * RETURNS
  1475.  *  void
  1476.  *****************************************************************************/
  1477. void mmi_uc_xml_start_element_hdlr(void *data, const char *el, const char **attr)
  1478. {
  1479.     /*----------------------------------------------------------------*/
  1480.     /* Local Variables                                                */
  1481.     /*----------------------------------------------------------------*/
  1482.     U32 i = 0;
  1483.     /*----------------------------------------------------------------*/
  1484.     /* Code Body                                                      */
  1485.     /*----------------------------------------------------------------*/
  1486.     if ((!strcmp(MMI_UC_XML_ELEMENT_TO, el)) || 
  1487.         (!strcmp(MMI_UC_XML_ELEMENT_CC, el)) ||
  1488.         (!strcmp(MMI_UC_XML_ELEMENT_BCC, el))||
  1489.         (!strcmp(MMI_UC_XML_ELEMENT_FROM, el)))
  1490.     {
  1491.         if (!strcmp(MMI_UC_XML_ATTR_TYPE, attr[0]))
  1492.         {
  1493.             if (!strcmp(MMI_UC_XML_ATTR_POHNE_NUMBER, attr[1]))
  1494.             {
  1495.                 g_uc_p->xml.addr_type = MMI_UC_ADDRESS_TYPE_PHONE_NUMBER;
  1496.             }
  1497.             else if (!strcmp(MMI_UC_XML_ATTR_EMAIL_ADDR, attr[1]))
  1498.             {
  1499.                 g_uc_p->xml.addr_type = MMI_UC_ADDRESS_TYPE_EMAIL;
  1500.             }
  1501.             else
  1502.             {                
  1503.                 MMI_ASSERT(0);
  1504.                 
  1505.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1506.                          "*[UnifiedComposerMain.c] mmi_uc_xml_start_element_hdlr addr type error*n"));
  1507.                 
  1508.                 g_uc_p->xml.addr_type = MMI_UC_ADDRESS_TYPE_PHONE_NUMBER;
  1509.             }
  1510.         }        
  1511.     }
  1512.     else if (!strcmp(MMI_UC_XML_ELEMENT_BODY , el))
  1513.     {
  1514.         for (i = 0; attr[i]; i = i + 2)
  1515.         {
  1516.             if (!strcmp(MMI_UC_XML_ATTR_BGCOLOR , attr[i]))
  1517.             {
  1518.                 g_uc_p->msg.background_color = mmi_uc_convert_ascii_hex_to_dec((U8*) attr[i + 1]);
  1519.             }
  1520.             else if (!strcmp(MMI_UC_XML_ATTR_FGCOLOR , attr[i]))
  1521.             {
  1522.                 g_uc_p->msg.foreground_color = mmi_uc_convert_ascii_hex_to_dec((U8*) attr[i + 1]);
  1523.             }
  1524.             else if (!strcmp(MMI_UC_XML_ATTR_SLIDE_NUM , attr[i]))
  1525.             {
  1526.                 /* updated in mmi_uc_insert_slide_by_number*/
  1527.                 //g_uc_p->msg.total_slide_num = atoi((S8*) attr[i + 1]);
  1528.             }
  1529.             else if (!strcmp(MMI_UC_XML_ATTR_OBJ_NUM , attr[i]))
  1530.             {
  1531.                 /* updated in mmi_uc_insert_object_to_list_tail() */
  1532.                 //g_uc_p->msg.total_object_num = atoi((S8*) attr[i + 1]);
  1533.             }
  1534.             else if (!strcmp(MMI_UC_XML_ATTR_LAYOUT , attr[i]))
  1535.             {
  1536.                 g_uc_p->msg.layout = mmi_uc_convert_mms_layout_type_to_uc((U8)atoi((S8*) attr[i + 1]));
  1537.             }                
  1538.         }        
  1539.     }
  1540.     else if (!strcmp(MMI_UC_XML_ELEMENT_SLIDE  , el))
  1541.     {
  1542.         U8 slide_number = 0;
  1543.         U8 duration = 0;
  1544.         for (i = 0; attr[i]; i = i + 2)
  1545.         {
  1546.             if (!strcmp(MMI_UC_XML_ATTR_INDEX, attr[i]))
  1547.             {
  1548.                 slide_number = atoi((S8*) attr[i + 1]);
  1549.             }
  1550.             else if (!strcmp(MMI_UC_XML_ATTR_DURATION , attr[i]))
  1551.             {
  1552.                 duration = atoi((S8*) attr[i + 1]);
  1553.             }
  1554.         }        
  1555.         if (slide_number)
  1556.         {
  1557.             g_uc_p->xml.slide = mmi_uc_insert_slide_by_number(slide_number);
  1558.             if (g_uc_p->xml.slide)
  1559.             {
  1560.                 MMI_ASSERT(g_uc_p->xml.slide->slide_num == slide_number);
  1561.                 if (duration)
  1562.                 {
  1563.                     g_uc_p->xml.slide->duration = duration;
  1564.                 }                
  1565.             }
  1566.             else
  1567.             {
  1568.                 MMI_ASSERT(0);
  1569.                 PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1570.                          "*[UnifiedComposerMain.c] mmi_uc_xml_start_element_hdlr slide error*n"));      
  1571.             }
  1572.         }
  1573.         else
  1574.         {
  1575.             MMI_ASSERT(0);
  1576.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1577.                      "*[UnifiedComposerMain.c] mmi_uc_xml_start_element_hdlr slide number error*n"));      
  1578.         }        
  1579.     }
  1580.     else if (!strcmp(MMI_UC_XML_ELEMENT_TEXT , el))
  1581.     {
  1582.         for (i = 0; attr[i]; i = i + 2)
  1583.         {
  1584.             if (!strcmp(MMI_UC_XML_ATTR_ID , attr[i]))
  1585.             {
  1586.                 g_uc_p->xml.slide->text.id = (atoi((S8*) attr[i + 1]));
  1587.             }
  1588.             else if (!strcmp(MMI_UC_XML_ATTR_BEGIN , attr[i]))
  1589.             {
  1590.                 g_uc_p->xml.slide->text.begin = atoi((S8*) attr[i + 1]);
  1591.             }
  1592.             else if (!strcmp(MMI_UC_XML_ATTR_END , attr[i]))
  1593.             {
  1594.                 g_uc_p->xml.slide->text.end = atoi((S8*) attr[i + 1]);
  1595.             }            
  1596.             else if (!strcmp(MMI_UC_XML_ATTR_BGCOLOR , attr[i]))
  1597.             {
  1598.                 g_uc_p->xml.slide->text.background_color = mmi_uc_convert_ascii_hex_to_dec((U8*) attr[i + 1]);
  1599.             }
  1600.             else if (!strcmp(MMI_UC_XML_ATTR_FGCOLOR , attr[i]))
  1601.             {
  1602.                 g_uc_p->xml.slide->text.foreground_color = mmi_uc_convert_ascii_hex_to_dec((U8*) attr[i + 1]);
  1603.             }
  1604.         }        
  1605.     }    
  1606.     else if (!strcmp(MMI_UC_XML_ELEMENT_IMAGE, el))
  1607.     {
  1608.         for (i = 0; attr[i]; i = i + 2)
  1609.         {
  1610.             if (!strcmp(MMI_UC_XML_ATTR_ID , attr[i]))
  1611.             {
  1612.                 g_uc_p->xml.slide->image.id = (atoi((S8*) attr[i + 1]));
  1613.             }
  1614.             else if (!strcmp(MMI_UC_XML_ATTR_BEGIN , attr[i]))
  1615.             {
  1616.                 g_uc_p->xml.slide->image.begin = atoi((S8*) attr[i + 1]);
  1617.             }
  1618.             else if (!strcmp(MMI_UC_XML_ATTR_END , attr[i]))
  1619.             {
  1620.                 g_uc_p->xml.slide->image.end = atoi((S8*) attr[i + 1]);
  1621.             }            
  1622.         }        
  1623.     }    
  1624.     else if (!strcmp(MMI_UC_XML_ELEMENT_AUDIO, el))
  1625.     {
  1626.         for (i = 0; attr[i]; i = i + 2)
  1627.         {
  1628.             if (!strcmp(MMI_UC_XML_ATTR_ID , attr[i]))
  1629.             {
  1630.                 g_uc_p->xml.slide->audio.id = (atoi((S8*) attr[i + 1]));
  1631.             }
  1632.             else if (!strcmp(MMI_UC_XML_ATTR_BEGIN , attr[i]))
  1633.             {
  1634.                 g_uc_p->xml.slide->audio.begin = atoi((S8*) attr[i + 1]);
  1635.             }
  1636.             else if (!strcmp(MMI_UC_XML_ATTR_END , attr[i]))
  1637.             {
  1638.                 g_uc_p->xml.slide->audio.end = atoi((S8*) attr[i + 1]);
  1639.             }            
  1640.         }        
  1641.     }    
  1642.     else if (!strcmp(MMI_UC_XML_ELEMENT_VIDEO, el))
  1643.     {
  1644.         for (i = 0; attr[i]; i = i + 2)
  1645.         {
  1646.             if (!strcmp(MMI_UC_XML_ATTR_ID , attr[i]))
  1647.             {
  1648.                 g_uc_p->xml.slide->video.id = (atoi((S8*) attr[i + 1]));
  1649.             }
  1650.             else if (!strcmp(MMI_UC_XML_ATTR_BEGIN , attr[i]))
  1651.             {
  1652.                 g_uc_p->xml.slide->video.begin = atoi((S8*) attr[i + 1]);
  1653.             }
  1654.             else if (!strcmp(MMI_UC_XML_ATTR_END , attr[i]))
  1655.             {
  1656.                 g_uc_p->xml.slide->video.end = atoi((S8*) attr[i + 1]);
  1657.             }            
  1658.         }        
  1659.     }
  1660.     else if (!strcmp(MMI_UC_XML_ELEMENT_OBJECT, el))
  1661.     {
  1662.         g_uc_p->xml.object = mmi_uc_insert_object_to_list_tail();
  1663.         
  1664.         for (i = 0; attr[i]; i = i + 2)
  1665.         {
  1666.             if (!strcmp(MMI_UC_XML_ATTR_ID , attr[i]))
  1667.             {
  1668.                 g_uc_p->xml.object->id = (atoi((S8*) attr[i + 1]));
  1669.             }
  1670.             else if (!strcmp(MMI_UC_XML_ATTR_ATTACH , attr[i]))
  1671.             {
  1672.                 if (atoi((S8*) attr[i + 1]))
  1673.                 {
  1674.                     g_uc_p->xml.object->type = MMI_UC_OBJECT_TYPE_ATTACHMENT;
  1675.                 }
  1676.             }
  1677.             else if (!strcmp(MMI_UC_XML_ATTR_VIRTUAL_FILE , attr[i]))
  1678.             {
  1679.                 if (atoi((S8*) attr[i + 1]))
  1680.                 {
  1681.                     g_uc_p->xml.object->is_virtual_file = MMI_TRUE;
  1682.                 }
  1683.                 else
  1684.                 {
  1685.                     g_uc_p->xml.object->is_virtual_file = MMI_FALSE;
  1686.                 }
  1687.             }            
  1688.             else if (!strcmp(MMI_UC_XML_ATTR_DRM, attr[i]))
  1689.             {
  1690.                 if (atoi((S8*) attr[i + 1]))
  1691.                 {
  1692.                     g_uc_p->xml.object->drm_type = (atoi((S8*) attr[i + 1]));
  1693.                 }
  1694.             }
  1695.             else if (!strcmp(MMI_UC_XML_ATTR_SIZE , attr[i]))
  1696.             {
  1697.                 if (atoi((S8*) attr[i + 1]))
  1698.                 {
  1699.                     g_uc_p->xml.object->size = (atoi((S8*) attr[i + 1]));
  1700.                 }
  1701.             }
  1702.             else if (!strcmp(MMI_UC_XML_ATTR_OFFSET  , attr[i]))
  1703.             {
  1704.                 if (atoi((S8*) attr[i + 1]))
  1705.                 {
  1706.                     g_uc_p->xml.object->offset = (atoi((S8*) attr[i + 1]));
  1707.                 }
  1708.             }            
  1709.         }        
  1710.     }
  1711. }
  1712. /*****************************************************************************
  1713.  * FUNCTION
  1714.  *  mmi_uc_xml_end_element_hdlr
  1715.  * DESCRIPTION
  1716.  *  end element handler
  1717.  * PARAMETERS
  1718.  *  void
  1719.  * RETURNS
  1720.  *  void
  1721.  *****************************************************************************/
  1722. void mmi_uc_xml_end_element_hdlr(void *data, const char *el)
  1723. {
  1724.     /*----------------------------------------------------------------*/
  1725.     /* Local Variables                                                */
  1726.     /*----------------------------------------------------------------*/
  1727.     /*----------------------------------------------------------------*/
  1728.     /* Code Body                                                      */
  1729.     /*----------------------------------------------------------------*/
  1730.     if (!strcmp(MMI_UC_XML_ELEMENT_OBJECT, el))
  1731.     {   
  1732.         if (g_uc_p->xml.object->type == MMI_UC_OBJECT_TYPE_ATTACHMENT)
  1733.         {
  1734.             mmi_uc_attachment_info_struct* att;
  1735.             
  1736.             att = mmi_uc_insert_attachment();
  1737.             mmi_uc_insert_object_to_attachment(g_uc_p->xml.object, att);
  1738.         }
  1739.     }
  1740.     return;
  1741. }
  1742. /*****************************************************************************
  1743.  * FUNCTION
  1744.  *  mmi_uc_xml_start_element_hdlr
  1745.  * DESCRIPTION
  1746.  *  Start element handler
  1747.  * PARAMETERS
  1748.  *  void
  1749.  * RETURNS
  1750.  *  void
  1751.  *****************************************************************************/
  1752. void mmi_uc_xml_data_hdlr(void *data, const char *el, const char *value, int len)
  1753. {
  1754.     /*----------------------------------------------------------------*/
  1755.     /* Local Variables                                                */
  1756.     /*----------------------------------------------------------------*/
  1757.     /*----------------------------------------------------------------*/
  1758.     /* Code Body                                                      */
  1759.     /*----------------------------------------------------------------*/
  1760.     if (!strcmp(MMI_UC_XML_ELEMENT_TO, el))
  1761.     {   
  1762.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1763.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1764.         {
  1765.             /* Do nothing */
  1766.         }
  1767.         else
  1768.         {
  1769.             mmi_uc_xml_data_address_hdlr(
  1770.                     (U8*)value,
  1771.                     len,
  1772.                     g_uc_p->xml.addr_type, 
  1773.                     MMI_UC_ADDRESS_GROUP_TYPE_TO);
  1774.         }
  1775.     }
  1776.     else if (!strcmp(MMI_UC_XML_ELEMENT_CC, el))
  1777.     {
  1778.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY||
  1779.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1780.         {
  1781.             /* Do nothing */
  1782.         }
  1783.         else
  1784.         {
  1785.             mmi_uc_xml_data_address_hdlr(
  1786.                     (U8*)value,
  1787.                     len,
  1788.                     g_uc_p->xml.addr_type, 
  1789.                     MMI_UC_ADDRESS_GROUP_TYPE_CC);
  1790.         }
  1791.         
  1792.     }    
  1793.     else if (!strcmp(MMI_UC_XML_ELEMENT_BCC, el))
  1794.     {
  1795.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY||
  1796.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1797.         {
  1798.             /* Do nothing */
  1799.         }
  1800.         else
  1801.         {
  1802.             mmi_uc_xml_data_address_hdlr(
  1803.                     (U8*)value,
  1804.                     len,
  1805.                     g_uc_p->xml.addr_type, 
  1806.                     MMI_UC_ADDRESS_GROUP_TYPE_BCC);
  1807.         }
  1808.     }    
  1809.     else if (!strcmp(MMI_UC_XML_ELEMENT_FROM, el))
  1810.     {
  1811.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1812.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL )
  1813.         {
  1814.             mmi_uc_xml_data_address_hdlr(
  1815.                     (U8*)value,
  1816.                     len,
  1817.                     g_uc_p->xml.addr_type, 
  1818.                     MMI_UC_ADDRESS_GROUP_TYPE_TO);
  1819.         }
  1820.     }
  1821.     else if (!strcmp(MMI_UC_XML_ELEMENT_SUBJECT, el))
  1822.     {
  1823.         memset(g_uc_p->msg.subject, 0 ,MMI_UC_MAX_SUBJECT_LEN * ENCODING_LENGTH);        
  1824.         mmi_chset_utf8_to_ucs2_string((kal_uint8*)g_uc_p->msg.subject, MMI_UC_MAX_SUBJECT_LEN * ENCODING_LENGTH, (kal_uint8*)value);
  1825.     }
  1826.     else if (!strcmp(MMI_UC_XML_ELEMENT_READ_REPORT, el))
  1827.     {
  1828.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1829.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL ||
  1830.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1831.         {
  1832.             /* Do nothing */
  1833.         }
  1834.         else
  1835.         {
  1836.             if (atoi((S8*) value))
  1837.             {
  1838.                 g_uc_p->msg.read_report = MMI_TRUE;
  1839.             }
  1840.             else
  1841.             {
  1842.                 g_uc_p->msg.read_report = MMI_FALSE;
  1843.             }
  1844.         }
  1845.     }
  1846.     else if (!strcmp(MMI_UC_XML_ELEMENT_DELIVERY_REPORT, el))
  1847.     {
  1848.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1849.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL ||
  1850.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1851.         {
  1852.             /* Do nothing */
  1853.         }
  1854.         else
  1855.         {
  1856.             if (atoi((S8*) value))
  1857.             {
  1858.                 g_uc_p->msg.delivery_report = MMI_TRUE;
  1859.             }
  1860.             else
  1861.             {
  1862.                 g_uc_p->msg.delivery_report = MMI_FALSE;
  1863.             }
  1864.         }
  1865.     }    
  1866.     else if (!strcmp(MMI_UC_XML_ELEMENT_PRIORITY , el))
  1867.     {
  1868.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1869.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL ||
  1870.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1871.         {
  1872.             /* Do nothing */
  1873.         }
  1874.         else
  1875.         {
  1876.             g_uc_p->msg.priority = atoi((S8*) value);        
  1877.         }
  1878.     }
  1879.     else if (!strcmp(MMI_UC_XML_ELEMENT_EXPIRY , el))
  1880.     {
  1881.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1882.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL ||
  1883.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1884.         {
  1885.             /* Do nothing */
  1886.         }
  1887.         else
  1888.         {
  1889.             g_uc_p->msg.expiry_time = atoi((S8*) value);        
  1890.         }
  1891.     }    
  1892.     else if (!strcmp(MMI_UC_XML_ELEMENT_DELIVERY_TIME , el))
  1893.     {
  1894.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1895.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL ||
  1896.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1897.         {
  1898.             /* Do nothing */
  1899.         }
  1900.         else
  1901.         {
  1902.             g_uc_p->msg.delivery_time = atoi((S8*) value);        
  1903.         }
  1904.     }    
  1905.     else if (!strcmp(MMI_UC_XML_ELEMENT_VISIBLE , el))
  1906.     {
  1907.         if (g_uc_p->main.state == MMI_UC_STATE_REPLY ||
  1908.             g_uc_p->main.state == MMI_UC_STATE_REPLY_ALL ||
  1909.             g_uc_p->main.state == MMI_UC_STATE_FORWARD)
  1910.         {
  1911.             /* Do nothing */
  1912.         }
  1913.         else
  1914.         {
  1915.             if (atoi((S8*) value))
  1916.             {
  1917.                 g_uc_p->msg.sender_visibility = MMI_TRUE;
  1918.             }
  1919.             else
  1920.             {
  1921.                 g_uc_p->msg.sender_visibility = MMI_FALSE;
  1922.             }
  1923.         }
  1924.     }    
  1925.     else if (!strcmp(MMI_UC_XML_ELEMENT_NAME , el))
  1926.     {
  1927.         U32 ucs2_len = (len + 1) * ENCODING_LENGTH;
  1928.         
  1929.         MMI_ASSERT(g_uc_p->xml.object);
  1930.         MMI_ASSERT(g_uc_p->xml.object->file_name == NULL);
  1931.         g_uc_p->xml.object->file_name = kal_adm_alloc(g_uc_p->main.mem_pool_id, ucs2_len);
  1932.         MMI_ASSERT(g_uc_p->xml.object->file_name);
  1933.         memset(g_uc_p->xml.object->file_name, 0, ucs2_len);
  1934.         mmi_chset_utf8_to_ucs2_string((kal_uint8*)g_uc_p->xml.object->file_name, ucs2_len, (kal_uint8*)value);
  1935.     }    
  1936.     else if (!strcmp(MMI_UC_XML_ELEMENT_FILE_PATH  , el))
  1937.     {
  1938.         U32 ucs2_len = (len + 1) * ENCODING_LENGTH;
  1939.         
  1940.         MMI_ASSERT(g_uc_p->xml.object);
  1941.         MMI_ASSERT(g_uc_p->xml.object->file_path == NULL);
  1942.         g_uc_p->xml.object->file_path = kal_adm_alloc(g_uc_p->main.mem_pool_id, ucs2_len);
  1943.         MMI_ASSERT(g_uc_p->xml.object->file_path);
  1944.         memset(g_uc_p->xml.object->file_path, 0, ucs2_len);
  1945.         mmi_chset_utf8_to_ucs2_string((kal_uint8*)g_uc_p->xml.object->file_path, ucs2_len, (kal_uint8*)value);
  1946.     }
  1947.         
  1948. }
  1949. /*****************************************************************************
  1950.  * FUNCTION
  1951.  *  mmi_uc_xml_data_address_hdlr
  1952.  * DESCRIPTION
  1953.  *  Add address 
  1954.  * PARAMETERS
  1955.  *  void
  1956.  * RETURNS
  1957.  *  void
  1958.  *****************************************************************************/
  1959. void mmi_uc_xml_data_address_hdlr(U8* utf8_addr,
  1960.                                   S32 addr_len,
  1961.                                   mmi_uc_address_type_enum addr_type, 
  1962.                                   mmi_uc_address_group_type_enum addr_group_type)
  1963. {
  1964.     /*----------------------------------------------------------------*/
  1965.     /* Local Variables                                                */
  1966.     /*----------------------------------------------------------------*/
  1967.     U8 *ucs2;
  1968.     U32 ucs2_len;
  1969.     /*----------------------------------------------------------------*/
  1970.     /* Code Body                                                      */
  1971.     /*----------------------------------------------------------------*/        
  1972.     ucs2_len = (addr_len + 1) * ENCODING_LENGTH;        
  1973.     ucs2 = OslMalloc(ucs2_len);
  1974.     memset(ucs2, 0, ucs2_len);
  1975.         
  1976.     mmi_chset_utf8_to_ucs2_string(ucs2, ucs2_len, utf8_addr);
  1977.     if (mmi_uc_check_duplicate_address(ucs2, addr_type, addr_group_type) != NULL)
  1978.     {
  1979.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[UnifiedComposerMiscell.c] mmi_uc_xml_data_address_hdlr duplicate addr *n"));
  1980.     }
  1981.     else
  1982.     {    
  1983.         if (addr_type == MMI_UC_ADDRESS_TYPE_PHONE_NUMBER || 
  1984.             addr_type == MMI_UC_ADDRESS_TYPE_EMAIL )
  1985.         {
  1986.             mmi_uc_add_address(ucs2, addr_type, addr_group_type);
  1987.         }
  1988.         else
  1989.         {
  1990.             MMI_ASSERT(0);
  1991.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  1992.                      "*[UnifiedComposerMiscell.c] mmi_uc_xml_data_address_hdlr addr type error*n"));            
  1993.         }
  1994.     }
  1995.     
  1996.     OslMfree(ucs2);
  1997. }
  1998. /*****************************************************************************
  1999.  * FUNCTION
  2000.  *  mmi_uc_convert_ascii_hex_to_dec
  2001.  * DESCRIPTION
  2002.  *  Converts Ascii value to Decimal value
  2003.  * PARAMETERS
  2004.  *  character       [IN]        
  2005.  *  S8 ascii values(?)
  2006.  * RETURNS
  2007.  *  U8 Decimal value.
  2008.  *****************************************************************************/
  2009. U32 mmi_uc_convert_ascii_hex_to_dec(U8* character)
  2010. {
  2011.     /*----------------------------------------------------------------*/
  2012.     /* Local Variables                                                */
  2013.     /*----------------------------------------------------------------*/
  2014.     U32 i = 0;
  2015.     U32 value = 0;
  2016.     U8 c = 0;
  2017.     /*----------------------------------------------------------------*/
  2018.     /* Code Body                                                      */
  2019.     /*----------------------------------------------------------------*/
  2020.     /* Skip prefix "0x" or "0X" */
  2021.     if (character[0] == '0' && (character[1] == 'x' || character[1] == 'X'))
  2022.     {
  2023.         i = 2;
  2024.     }
  2025.     
  2026.     while ((c = character[i]) != 0)
  2027.     {
  2028.         value = value * 16;
  2029.         
  2030.         if (c > 47 && c < 58)   /* Digits 0..9 */
  2031.         {
  2032.             value += (c - 48);
  2033.         }
  2034.         else if (c > 64 && c < 71)  /* Characters A..F */
  2035.         {
  2036.             value += (c - 55);
  2037.         }
  2038.         else if (c > 96 && c < 103) /* Characters a..f */
  2039.         {
  2040.             value += (c - 87);
  2041.         }
  2042.         i++;
  2043.     }
  2044.     return value;
  2045. }
  2046. /*****************************************************************************
  2047.  * FUNCTION
  2048.  *  mmi_uc_insert_slide_by_number
  2049.  * DESCRIPTION
  2050.  *  Insert slide by slide number
  2051.  * PARAMETERS
  2052.  *  character       [IN]        
  2053.  *  S8 ascii values(?)
  2054.  * RETURNS
  2055.  *  U8 Decimal value.
  2056.  *****************************************************************************/
  2057. mmi_uc_slide_struct* mmi_uc_insert_slide_by_number(U8 slide_number)
  2058. {
  2059.     /*----------------------------------------------------------------*/
  2060.     /* Local Variables                                                */
  2061.     /*----------------------------------------------------------------*/
  2062.     mmi_uc_slide_struct* cur_slide = g_uc_p->msg.slide_head;
  2063.     mmi_uc_slide_struct* pre_slide = cur_slide;
  2064.     /*----------------------------------------------------------------*/
  2065.     /* Code Body                                                      */
  2066.     /*----------------------------------------------------------------*/
  2067.     if (slide_number == 1)
  2068.     {
  2069.         return mmi_uc_insert_slide(NULL);        
  2070.     }
  2071.     else
  2072.     {
  2073.         while (cur_slide && (cur_slide->slide_num < slide_number))
  2074.         {
  2075.             pre_slide = cur_slide;
  2076.             cur_slide = cur_slide->next;
  2077.         }
  2078.         return mmi_uc_insert_slide(pre_slide);
  2079.     }
  2080. }
  2081. /*****************************************************************************
  2082.  * FUNCTION
  2083.  *  mmi_uc_insert_object_to_list_tail
  2084.  * DESCRIPTION
  2085.  *  Insert object to object list tail
  2086.  * PARAMETERS
  2087.  *  character       [IN]        
  2088.  *  S8 ascii values(?)
  2089.  * RETURNS
  2090.  *  U8 Decimal value.
  2091.  *****************************************************************************/
  2092. mmi_uc_object_struct* mmi_uc_insert_object_to_list_tail(void)
  2093. {
  2094.     /*----------------------------------------------------------------*/
  2095.     /* Local Variables                                                */
  2096.     /*----------------------------------------------------------------*/
  2097.     mmi_uc_object_struct* new_object;
  2098.     U32 object_size;     
  2099.     U32 i = 1;
  2100.     /*----------------------------------------------------------------*/
  2101.     /* Code Body                                                      */
  2102.     /*----------------------------------------------------------------*/
  2103.     object_size = sizeof(mmi_uc_object_struct);
  2104.     new_object = kal_adm_alloc(g_uc_p->main.mem_pool_id, object_size);
  2105.     MMI_ASSERT(new_object);
  2106.     memset(new_object, 0, object_size);
  2107.     /* First object */
  2108.     if (g_uc_p->msg.object_head == NULL)
  2109.     {
  2110.         g_uc_p->msg.object_head = new_object;
  2111.         new_object->next = NULL;
  2112.         new_object->previous = NULL;
  2113.     }
  2114.     else
  2115.     {
  2116.         mmi_uc_object_struct* cur_object = g_uc_p->msg.object_head;
  2117.         while (cur_object->next)
  2118.         {
  2119.             MMI_ASSERT( i < g_uc_p->msg.total_object_num);
  2120.             cur_object = cur_object->next;
  2121.             i++;
  2122.         }        
  2123.         cur_object->next = new_object;
  2124.         
  2125.         new_object->next = NULL;
  2126.         new_object->previous = cur_object;
  2127.     }
  2128.     g_uc_p->msg.total_object_num++;
  2129.     return new_object;
  2130. }
  2131. /*****************************************************************************
  2132.  * FUNCTION
  2133.  *  mmi_uc_match_object_id
  2134.  * DESCRIPTION
  2135.  *  Match object id after parsing xml file
  2136.  * PARAMETERS
  2137.  *  character       [IN]        
  2138.  *  S8 ascii values(?)
  2139.  * RETURNS
  2140.  *  U8 Decimal value.
  2141.  *****************************************************************************/
  2142. S32 mmi_uc_match_object_id(void)
  2143. {
  2144.     /*----------------------------------------------------------------*/
  2145.     /* Local Variables                                                */
  2146.     /*----------------------------------------------------------------*/
  2147.     mmi_uc_slide_struct* cur_slide = g_uc_p->msg.slide_head;
  2148.     U32 slide_num = 0;
  2149.     mmi_uc_object_struct* cur_object = NULL;
  2150.     /*----------------------------------------------------------------*/
  2151.     /* Code Body                                                      */
  2152.     /*----------------------------------------------------------------*/
  2153.     for (; cur_slide != NULL; cur_slide = cur_slide->next, slide_num++)
  2154.     {
  2155.     
  2156.         if (cur_slide->text.id)
  2157.         {
  2158.             wgui_uce_text_info_struct text_info;
  2159.             U8 mmi_uc_text_path[MMI_UC_MAX_TEMP_FILE_LEN];
  2160.             U8 virtual_file_name[FS_GenVFN_SIZE];
  2161.             S32 ori_file_handle;
  2162.             S32 result;
  2163.             U8* file_name;
  2164.             U16 file_path_len = 0;
  2165.             U16 file_name_len = 0;
  2166.            
  2167.             memset(mmi_uc_text_path, 0, MMI_UC_MAX_TEMP_FILE_LEN);
  2168.             MMI_UC_MAKE_TEXT_FILE_PATH(mmi_uc_text_path, cur_slide->slide_num);
  2169.         
  2170.             MMI_ASSERT((cur_object = mmi_uc_get_object_by_id(cur_slide->text.id)) != NULL);                        
  2171.             mmi_uc_insert_object_to_slide(cur_object, cur_slide, MMI_UC_OBJECT_TYPE_TEXT);
  2172.             cur_slide->text.object->type = MMI_UC_OBJECT_TYPE_TEXT;            
  2173.             MMI_ASSERT(cur_slide->text.object->file_path);
  2174.             if (cur_slide->text.object->is_virtual_file)
  2175.             {
  2176.                 ori_file_handle = FS_Open(cur_slide->text.object->file_path, FS_READ_ONLY | FS_OPEN_SHARED);
  2177.                 if (ori_file_handle <= 0)
  2178.                 {
  2179.                     MMI_ASSERT(0);
  2180.                     return ori_file_handle;
  2181.                 }
  2182.              result = FS_GenVirtualFileName( 
  2183.                                     ori_file_handle, 
  2184.                                     (U16*)virtual_file_name, 
  2185.                              (unsigned int)FS_GenVFN_SIZE, 
  2186.                              cur_slide->text.object->offset, 
  2187.                              cur_slide->text.object->size);
  2188.                 
  2189.                 if (result < 0)
  2190.                 {
  2191.                     MMI_ASSERT(0);
  2192.                     return result;
  2193.                 }
  2194.                 mmi_uc_read_file_to_text_buffer(virtual_file_name);
  2195.                 FS_Close(ori_file_handle);
  2196.                 
  2197.             }
  2198.             else
  2199.             {
  2200.                 mmi_uc_read_file_to_text_buffer((U8*)cur_slide->text.object->file_path);
  2201.             }
  2202.             
  2203.             memset(&text_info, 0, sizeof(wgui_uce_text_info_struct));
  2204.             wgui_uce_get_text_info_for_buffer(&text_info, g_uc_p->main.text_buffer);                        
  2205.             mmi_uc_set_text_info_to_slide(cur_slide, &text_info);
  2206.             
  2207.             if ((result = mmi_uc_save_buffer_to_file(mmi_uc_text_path, g_uc_p->main.text_buffer, text_info.char_count)) != FS_NO_ERROR)
  2208.             {
  2209.                 return result;
  2210.             }
  2211.             if (cur_slide->text.object->is_virtual_file)
  2212.             {
  2213.                 /* file path */
  2214.                 kal_adm_free(g_uc_p->main.mem_pool_id, cur_slide->text.object->file_path);
  2215.                 file_path_len = pfnUnicodeStrlen((S8*)mmi_uc_text_path);
  2216.                 cur_slide->text.object->file_path = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_path_len + 1 ) * 2);
  2217.                 MMI_ASSERT(cur_slide->text.object->file_path);
  2218.                 memset(cur_slide->text.object->file_path, 0, (file_path_len + 1) * 2);
  2219.                 pfnUnicodeStrncpy((S8*)cur_slide->text.object->file_path, (S8*)mmi_uc_text_path, file_path_len);
  2220.                 /* file name */
  2221.                 if (cur_slide->text.object->file_name)
  2222.                 {
  2223.                     kal_adm_free(g_uc_p->main.mem_pool_id, cur_slide->text.object->file_name);
  2224.                 }
  2225.                 file_name = (U8*)mmi_uc_get_file_name((U16*)mmi_uc_text_path);
  2226.                 file_name_len = pfnUnicodeStrlen((S8*)file_name);
  2227.                 cur_slide->text.object->file_name = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_name_len + 1 ) * 2);
  2228.                 MMI_ASSERT(cur_slide->text.object->file_name);
  2229.                 memset(cur_slide->text.object->file_name, 0, (file_name_len + 1) * 2);
  2230.                 pfnUnicodeStrncpy((S8*)cur_slide->text.object->file_name, (S8*)file_name, file_name_len);
  2231.                 cur_slide->text.object->offset = 0;
  2232.                 cur_slide->text.object->size = applib_get_file_size((kal_wchar*)cur_slide->text.object->file_path);    
  2233.                 cur_slide->text.object->drm_type = MMA_DRM_NONE;
  2234.                 cur_slide->text.object->is_virtual_file = MMI_FALSE;
  2235.             }            
  2236.         }        
  2237.         if (cur_slide->image.id)
  2238.         {
  2239.             MMI_ASSERT((cur_object = mmi_uc_get_object_by_id(cur_slide->image.id)) != NULL);                    
  2240.             mmi_uc_insert_object_to_slide(cur_object, cur_slide, MMI_UC_OBJECT_TYPE_IMAGE);
  2241.             cur_slide->image.object->type = MMI_UC_OBJECT_TYPE_IMAGE;    
  2242.         }
  2243.         if (cur_slide->audio.id)
  2244.         {
  2245.             MMI_ASSERT((cur_object = mmi_uc_get_object_by_id(cur_slide->audio.id)) != NULL);
  2246.             mmi_uc_insert_object_to_slide(cur_object, cur_slide, MMI_UC_OBJECT_TYPE_AUDIO);
  2247.             cur_slide->audio.object->type = MMI_UC_OBJECT_TYPE_AUDIO;            
  2248.         }
  2249.         if (cur_slide->video.id)
  2250.         {
  2251.             MMI_ASSERT((cur_object = mmi_uc_get_object_by_id(cur_slide->video.id)) != NULL);
  2252.             mmi_uc_insert_object_to_slide(cur_object, cur_slide, MMI_UC_OBJECT_TYPE_VIDEO);
  2253.             cur_slide->video.object->type = MMI_UC_OBJECT_TYPE_VIDEO;            
  2254.         }        
  2255.     }
  2256.     MMI_ASSERT( slide_num == g_uc_p->msg.total_slide_num);
  2257.     return FS_NO_ERROR;
  2258.     
  2259. }
  2260. /*****************************************************************************
  2261.  * FUNCTION
  2262.  *  mmi_uc_get_object_by_id
  2263.  * DESCRIPTION
  2264.  *  Get object pointer by object id
  2265.  * PARAMETERS
  2266.  *  void
  2267.  * RETURNS
  2268.  *  void
  2269.  *****************************************************************************/
  2270. mmi_uc_object_struct* mmi_uc_get_object_by_id(U32 object_id)
  2271. {
  2272.     /*----------------------------------------------------------------*/
  2273.     /* Local Variables                                                */
  2274.     /*----------------------------------------------------------------*/
  2275.     mmi_uc_object_struct* cur_object = g_uc_p->msg.object_head;
  2276.     U32 object_num = 1;
  2277.     /*----------------------------------------------------------------*/
  2278.     /* Code Body                                                      */
  2279.     /*----------------------------------------------------------------*/
  2280.     for (; cur_object != NULL; cur_object = cur_object->next, object_num++)
  2281.     {
  2282.         MMI_ASSERT( object_num <= g_uc_p->msg.total_object_num);
  2283.         
  2284.         if (cur_object->id == object_id)
  2285.         {
  2286.             return cur_object;
  2287.         }
  2288.     }
  2289.     return NULL;
  2290. }
  2291. /*****************************************************************************
  2292.  * FUNCTION
  2293.  *  mmi_uc_check_only_attachment
  2294.  * DESCRIPTION
  2295.  *  Only attachments and one empty slide.
  2296.  * PARAMETERS
  2297.  *  void
  2298.  * RETURNS
  2299.  *  void
  2300.  *****************************************************************************/
  2301. BOOL mmi_uc_check_only_attachment (void)
  2302. {
  2303. #if (0)  
  2304. /* under construction !*/
  2305. /* under construction !*/
  2306. /* under construction !*/
  2307. /* under construction !*/
  2308. /* under construction !*/
  2309. /* under construction !*/
  2310. /* under construction !*/
  2311. /* under construction !*/
  2312. /* under construction !*/
  2313. /* under construction !*/
  2314. /* under construction !*/
  2315. /* under construction !*/
  2316. /* under construction !*/
  2317. /* under construction !*/
  2318. /* under construction !*/
  2319. /* under construction !*/
  2320. /* under construction !*/
  2321. /* under construction !*/
  2322. /* under construction !*/
  2323. /* under construction !*/
  2324. /* under construction !*/
  2325. /* under construction !*/
  2326. /* under construction !*/
  2327. /* under construction !*/
  2328. /* under construction !*/
  2329. /* under construction !*/
  2330. /* under construction !*/
  2331. /* under construction !*/
  2332. /* under construction !*/
  2333. /* under construction !*/
  2334. /* under construction !*/
  2335. /* under construction !*/
  2336. /* under construction !*/
  2337. /* under construction !*/
  2338. /* under construction !*/
  2339. /* under construction !*/
  2340. /* under construction !*/
  2341. /* under construction !*/
  2342. /* under construction !*/
  2343. /* under construction !*/
  2344. /* under construction !*/
  2345. /* under construction !*/
  2346. /* under construction !*/
  2347. /* under construction !*/
  2348. /* under construction !*/
  2349. /* under construction !*/
  2350. /* under construction !*/
  2351. /* under construction !*/
  2352. /* under construction !*/
  2353. /* under construction !*/
  2354. /* under construction !*/
  2355. /* under construction !*/
  2356. #endif /* (0) */
  2357.     return MMI_FALSE;
  2358. }
  2359. /*****************************************************************************
  2360.  * FUNCTION
  2361.  *  mmi_uc_resize_image
  2362.  * DESCRIPTION
  2363.  *  Resize image
  2364.  * PARAMETERS
  2365.  *  void
  2366.  * RETURNS
  2367.  *  1: resized. 0: no need to resize. negative: error!
  2368.  *****************************************************************************/
  2369. S32 mmi_uc_resize_image(U8 *file, U8 *dest_file, U32 resize_w, U32 resize_h)
  2370. {
  2371.     /*----------------------------------------------------------------*/
  2372.     /* Local Variables                                                */
  2373.     /*----------------------------------------------------------------*/
  2374.     S32 img_width = 0, img_height = 0;
  2375.     GDI_RESULT gdi_ret = GDI_FAILED;
  2376.     S32 ret = 0; 
  2377.     /*----------------------------------------------------------------*/
  2378.     /* Code Body                                                      */
  2379.     /*----------------------------------------------------------------*/
  2380.     MMI_ASSERT(file != NULL);
  2381.     MMI_ASSERT(dest_file != NULL);
  2382.     /* Get the image dimension */
  2383.     gdi_image_get_dimension_file((PS8) file, &img_width, &img_height);
  2384.     if ((img_width != 0) && (img_height != 0))
  2385.     {
  2386.         /* calculate the dimension of the resize JPEG */
  2387.         if ((img_width > resize_w) || (img_height > resize_h))
  2388.         {
  2389.             S32 w = 0, h = 0, buf_size = 0;
  2390.             U8 *buf_ptr = NULL;
  2391.             /* need to resize */
  2392.             if ((img_width * resize_h) > (img_height * resize_w))
  2393.             {
  2394.                 w = resize_w;
  2395.                 h = img_height * resize_w / img_width;
  2396.                 if (h == 0)
  2397.                 {
  2398.                     h = 1;
  2399.                 }
  2400.             }
  2401.             else
  2402.             {
  2403.                 w = img_width * resize_h / img_height;
  2404.                 h = resize_h;
  2405.                 if (w == 0)
  2406.                 {
  2407.                     w = 1;
  2408.                 }
  2409.             }
  2410.             /* resize the image and encode to jpeg file */
  2411.             buf_size = (w * h * GDI_MAINLCD_BIT_PER_PIXEL) >> 3;
  2412.             buf_size = ((buf_size + 3) / 4) * 4;
  2413.             if (buf_size > 0)
  2414.             {
  2415.                 media_get_ext_buffer(MOD_MMI, (void **)&buf_ptr, buf_size);
  2416.                 if (buf_ptr != NULL)
  2417.                 {
  2418.                     gdi_ret = gdi_image_encode_file_to_jpeg((PS8) file, (S8*)dest_file, w, h, buf_ptr, buf_size);
  2419.                     media_free_ext_buffer(MOD_MMI, (void **)&buf_ptr);
  2420.                 }
  2421.                 switch (gdi_ret)
  2422.                 {
  2423.                     case GDI_SUCCEED:
  2424.                         ret = MMI_UC_RESIZING_SUCCEED;
  2425.                         break;
  2426.                     case GDI_IMAGE_ENCODER_ERR_DISK_FULL:
  2427.                         ret = MMI_UC_RESIZING_FAILED_IN_GDI_ENCODER_ERR_DISK_FULL;
  2428.                         break;
  2429.                     case GDI_IMAGE_ENCODER_ERR_WRITE_PROTECTION:
  2430.                         ret = MMI_UC_RESIZING_FAILED_IN_GDI_ENCODER_ERR_WRITE_PROTECTION;
  2431.                         break;
  2432.                     case GDI_IMAGE_ENCODER_ERR_NO_DISK:
  2433.                         ret = MMI_UC_RESIZING_FAILED_IN_GDI_ENCODER_ERR_NO_DISK;
  2434.                         break;
  2435.                     default:
  2436.                         ret = MMI_UC_RESIZING_FAILED_IN_GDI_FAILED;
  2437.                 }
  2438.             }
  2439.             else
  2440.             {
  2441.                 /* -12: can't allocate gdi_layer for drawing image */
  2442.                 ret = MMI_UC_RESIZING_FAILED_IN_INSUFFICIENT_DRAWING_BUF;
  2443.             }
  2444.         }
  2445.         else
  2446.         {
  2447.             /* the dimension of the original image is smaller */
  2448.             ret = MMI_UC_RESIZING_SUCCEED_WITH_UNCHANGED; 
  2449.         }
  2450.     }
  2451.     else
  2452.     {
  2453.      /* -11: can't get the image dimension */
  2454.          ret = MMI_UC_RESIZING_FAILED_IN_UNKNOWN_DIMENSION;   
  2455.     }
  2456.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  2457.                                      "*[UnifiedComposerMiscell.c] mmi_uc_resize_image(), ret=%d",
  2458.                                      ret));
  2459.     return ret;
  2460. }
  2461. /*****************************************************************************
  2462.  * FUNCTION
  2463.  *  mmi_uc_entry_write_msg_with_content
  2464.  * DESCRIPTION
  2465.  *  Entry unified composer with content
  2466.  * PARAMETERS
  2467.  *  void
  2468.  * RETURNS
  2469.  *  void
  2470.  *****************************************************************************/
  2471. void mmi_uc_entry_write_msg_with_content(mmi_uc_done_type_enum type, mmi_uc_entry_write_struct* data)
  2472. {
  2473.     /*----------------------------------------------------------------*/
  2474.     /* Local Variables                                                */
  2475.     /*----------------------------------------------------------------*/
  2476.     U32 addr_num = 0;
  2477.     mmi_uc_addr_struct* addr = data->addr;
  2478.     mmi_uc_object_struct* object;
  2479.     wgui_uce_text_info_struct text_info;
  2480.     U8 mmi_uc_text_path[MMI_UC_MAX_TEMP_FILE_LEN];
  2481.     S32 result;
  2482.     /*----------------------------------------------------------------*/
  2483.     /* Code Body                                                      */
  2484.     /*----------------------------------------------------------------*/    
  2485.     if (!mmi_um_check_ready())
  2486.     {
  2487.         DisplayPopup(
  2488.             (PU8) GetString(STR_GLOBAL_NOT_AVAILABLE),
  2489.             IMG_GLOBAL_ERROR,
  2490.             1,
  2491.             MMI_UC_POPUP_TIME_OUT,
  2492.             (U8) ERROR_TONE);            
  2493.         
  2494.         return;
  2495.     }
  2496.     
  2497. #ifdef __USB_IN_NORMAL_MODE__
  2498.     if (mmi_usb_is_in_mass_storage_mode())
  2499.     {
  2500.         /* in mass storage mode */
  2501.         if (mmi_usb_check_path_exported((PS8) MMI_UC_FOLDER_DRV))
  2502.         {
  2503.             /* MMI public drive is exported, cannot use this app */
  2504.             mmi_usb_app_unavailable_popup(0);   /* pass 0 will show default string */
  2505.             return;
  2506.         }
  2507.     }
  2508. #endif /* __USB_IN_NORMAL_MODE__ */
  2509.     
  2510.     if (g_uc_p->send_info.action != MMI_UC_ACTION_IDLE ||
  2511.         IsScreenPresent(SCR_ID_UC_EDITOR))
  2512.     {
  2513.         DisplayPopup(
  2514.             (PU8) GetString(STR_GLOBAL_NOT_AVAILABLE),
  2515.             IMG_GLOBAL_ERROR,
  2516.             1,
  2517.             MMI_UC_POPUP_TIME_OUT,
  2518.             (U8) ERROR_TONE);            
  2519.         
  2520.         return;
  2521.     }
  2522.     
  2523.     mmi_uc_reset_msg();
  2524.     
  2525.     g_uc_p->main.state = type;
  2526.     if (type != MMI_UC_STATE_WRITE_NEW_MSG)
  2527.     {
  2528.         if (data->info_type == MMI_UC_INFO_TYPE_SMS)
  2529.         {
  2530.             U16* msg_id = data->info;
  2531.             
  2532.             g_uc_p->send_info.existed_msg_type = MMI_UC_MSG_TYPE_SMS_PREFER;
  2533.             g_uc_p->send_info.existed_msg_id = *msg_id;
  2534.         }
  2535.         else
  2536.         {
  2537.             MMI_ASSERT(0);
  2538.         }
  2539.     }
  2540.     
  2541.     for (; addr_num < data->addr_num; addr_num++)
  2542.     {
  2543.         MMI_ASSERT(addr);
  2544.         if (mmi_uc_check_duplicate_address(addr->addr, addr->type, addr->group) != NULL)
  2545.         {
  2546.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[UnifiedComposerMiscell.c] mmi_uc_entry_write_msg_with_content duplicate addr *n"));
  2547.         }
  2548.         else
  2549.         {
  2550.             mmi_uc_add_address(addr->addr, addr->type, addr->group);        
  2551.         }
  2552.         addr = addr->next;
  2553.     }
  2554.     
  2555.     g_uc_p->msg.current_slide = mmi_uc_insert_slide(NULL);
  2556.     g_uc_p->msg.current_slide_num = g_uc_p->msg.current_slide->slide_num;     
  2557.     if (pfnUnicodeStrlen((S8*)data->subject))
  2558.     {
  2559.         pfnUnicodeStrncpy((S8*)g_uc_p->msg.subject, (S8*)data->subject, MMI_UC_MAX_SUBJECT_LEN);
  2560.     }
  2561.     /* text file */
  2562.     if (data->text_num)
  2563.     {
  2564.         U32 buffer_size = (data->text_num + 1) * ENCODING_LENGTH;        
  2565.         U8* buffer = applib_mem_screen_alloc(buffer_size);
  2566.         U32 buffer_len = 0;
  2567.         
  2568.         MMI_ASSERT(buffer_size <= MMI_UC_UTF8_TEXT_BUFFER_SIZE);
  2569.         
  2570.         memset(buffer , 0, buffer_size);
  2571.         mmi_frm_sms_remove_escape_symbol_for_extension_char((U16*)buffer, (U16*)data->text_buffer,(U16)data->text_num);
  2572.         buffer_len = pfnUnicodeStrlen((S8*)buffer);
  2573.                     
  2574.         memset(mmi_uc_text_path, 0, MMI_UC_MAX_TEMP_FILE_LEN);
  2575.         MMI_UC_MAKE_TEXT_FILE_PATH(mmi_uc_text_path, g_uc_p->msg.current_slide->slide_num);
  2576.         mmi_uc_reset_text_buffer();               
  2577.         if (buffer_len <= (MMI_UC_TEXT_BUFFER_SIZE / ENCODING_LENGTH) - 1)
  2578.         {
  2579.             pfnUnicodeStrncpy((S8*)g_uc_p->main.text_buffer, (S8*)buffer, buffer_len);
  2580.         }
  2581.         else
  2582.         {
  2583.             pfnUnicodeStrncpy(
  2584.                 (S8*)g_uc_p->main.text_buffer, 
  2585.                 (S8*)buffer, 
  2586.                 (MMI_UC_TEXT_BUFFER_SIZE / ENCODING_LENGTH) - 1);
  2587.         }        
  2588.         applib_mem_screen_free(buffer);
  2589.         mmi_uc_editor_initialize();
  2590.         memset(&text_info, 0, sizeof(wgui_uce_text_info_struct));
  2591.         wgui_uce_get_text_info_for_buffer(&text_info, g_uc_p->main.text_buffer);                        
  2592.         result = mmi_uc_save_buffer_to_file(mmi_uc_text_path, g_uc_p->main.text_buffer, text_info.char_count);
  2593.         
  2594.         if (result == FS_NO_ERROR)
  2595.         {                        
  2596.             mmi_uc_set_text_info_to_slide(g_uc_p->msg.current_slide, &text_info);
  2597.             
  2598.             object = mmi_uc_insert_object((S8*)mmi_uc_text_path, MMI_UC_OBJECT_TYPE_TEXT);                
  2599.             mmi_uc_insert_object_to_slide(object, g_uc_p->msg.current_slide, MMI_UC_OBJECT_TYPE_TEXT);
  2600.         }
  2601.         else
  2602.         {
  2603.             mmi_uc_display_popup(MMI_UC_STORAGE_FULL);
  2604.             return;
  2605.         }            
  2606.     }
  2607.     mmi_uc_update_msg_size();
  2608.     if (data->info_type == MMI_UC_INFO_TYPE_SMS)
  2609.     {
  2610.         MMI_ASSERT(data->file_path == NULL);
  2611.     }
  2612.     if (data->file_path)
  2613.     {
  2614.         U32 flie_path_len = pfnUnicodeStrlen((S8*)data->file_path);
  2615.             
  2616.         if (g_uc_p->main.file_path)
  2617.         {
  2618.             kal_adm_free(g_uc_p->main.mem_pool_id, g_uc_p->main.file_path);
  2619.         }
  2620.         g_uc_p->main.file_path = kal_adm_alloc(
  2621.                                     g_uc_p->main.mem_pool_id, 
  2622.                                     (flie_path_len + 1) * ENCODING_LENGTH);
  2623.         MMI_ASSERT(g_uc_p->main.file_path);
  2624.         pfnUnicodeStrncpy((S8*)g_uc_p->main.file_path, (S8*)data->file_path, flie_path_len);
  2625.     }
  2626.     if (data->callback != NULL)
  2627.     {
  2628.         g_uc_p->main.callback = data->callback;
  2629.         g_uc_p->main.callback_para = data->callback_para;
  2630.     }
  2631.         
  2632.     g_uc_p->msg_type.setting_msg_type = mmi_uc_get_setting_msg_type();
  2633.     g_uc_p->msg_type.curr_msg_type = g_uc_p->msg_type.setting_msg_type;
  2634.     if (data->msg_type == MMI_UC_MSG_TYPE_SMS_ONLY)
  2635.     {
  2636.         g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_SMS_PREFER;
  2637.     }
  2638.     else if (data->msg_type == MMI_UC_MSG_TYPE_MMS_ONLY)
  2639.     {
  2640.         g_uc_p->msg_type.curr_msg_type = MMI_UC_MSG_TYPE_MMS_PREFER;
  2641.     }
  2642.     
  2643.     g_uc_p->msg_type.caller_specific_msg_type = data->msg_type;
  2644.     g_uc_p->msg_type.backup_msg_type = MMI_UC_MSG_TYPE_DEFAULT;
  2645.     mmi_uc_process_entry_write_msg();
  2646.             
  2647. }
  2648. /*****************************************************************************
  2649.  * FUNCTION
  2650.  *  mmi_uc_entry_done_option_with_content
  2651.  * DESCRIPTION
  2652.  *  Entry unified composer with content
  2653.  * PARAMETERS
  2654.  *  void
  2655.  * RETURNS
  2656.  *  void
  2657.  *****************************************************************************/
  2658. void mmi_uc_entry_done_option_with_content(mmi_uc_done_type_enum type, mmi_uc_entry_write_struct* data)
  2659. {
  2660.     /*----------------------------------------------------------------*/
  2661.     /* Local Variables                                                */
  2662.     /*----------------------------------------------------------------*/
  2663.     /*----------------------------------------------------------------*/
  2664.     /* Code Body                                                      */
  2665.     /*----------------------------------------------------------------*/
  2666.     mmi_uc_entry_write_msg_with_content(type, data);            
  2667. }
  2668. /*****************************************************************************
  2669.  * FUNCTION
  2670.  *  mmi_uc_calc_file_size_in_utf8
  2671.  * DESCRIPTION
  2672.  *  Read the file to text buffer
  2673.  * PARAMETERS
  2674.  *  void
  2675.  * RETURNS
  2676.  *  void
  2677.  *****************************************************************************/
  2678. U32 mmi_uc_calc_file_size_in_utf8 (U8* file_path)
  2679. {
  2680.     /*----------------------------------------------------------------*/
  2681.     /* Local Variables                                                */
  2682.     /*----------------------------------------------------------------*/
  2683.     FS_HANDLE file_handle;
  2684.     U32 result;
  2685.     U32 read_len = 0;
  2686.     U32 length = 0;
  2687.     /*----------------------------------------------------------------*/
  2688.     /* Code Body                                                      */
  2689.     /*----------------------------------------------------------------*/
  2690.     
  2691.     /* Open the file to read*/
  2692.     file_handle = FS_Open((U16*) file_path, FS_READ_ONLY | FS_OPEN_SHARED );
  2693.     if (file_handle > 0)
  2694.     {            
  2695.         U8* temp_buffer = applib_mem_screen_alloc(MMI_UC_UTF8_TEXT_BUFFER_SIZE);        
  2696.         memset(temp_buffer, 0, MMI_UC_UTF8_TEXT_BUFFER_SIZE);
  2697.         
  2698.         result = FS_Read(file_handle, 
  2699.                          temp_buffer, 
  2700.                          MMI_UC_UTF8_TEXT_BUFFER_SIZE - ENCODING_LENGTH,
  2701.                          &read_len);
  2702.         FS_Close(file_handle);
  2703.         if (result == FS_NO_ERROR)
  2704.         {
  2705.             length = mmi_charset_ucs2_to_utf8_length_in_bytes(temp_buffer);
  2706.         }
  2707.         applib_mem_screen_free(temp_buffer);
  2708.     }                                
  2709.     
  2710.    return length;
  2711. }
  2712. /*****************************************************************************
  2713.  * FUNCTION
  2714.  *  mmi_uc_text_change_callback
  2715.  * DESCRIPTION
  2716.  *  Check if the text is allowed to be inserted
  2717.  * PARAMETERS
  2718.  *  void
  2719.  * RETURNS
  2720.  *  void
  2721.  *****************************************************************************/
  2722. wgui_uce_text_change_result_enum mmi_uc_text_change_callback(wgui_uce_text_info_struct *new_text_info)
  2723. {
  2724.     /*----------------------------------------------------------------*/
  2725.     /* Local Variables                                                */
  2726.     /*----------------------------------------------------------------*/
  2727.     /*----------------------------------------------------------------*/
  2728.     /* Code Body                                                      */
  2729.     /*----------------------------------------------------------------*/
  2730.     if (new_text_info->char_count > MMI_UC_MAX_CHAR_NUM_IN_ONE_SLIDE)
  2731.     {
  2732.         return WGUI_UCE_TEXT_CHANGE_NOT_ALLOWED;
  2733.     }
  2734.     else
  2735.     {        
  2736.         g_uc_p->msg.current_slide->text.char_count = new_text_info->char_count; 
  2737.         g_uc_p->msg.current_slide->text.utf8_msg_len = new_text_info->utf8_msg_len; 
  2738.         g_uc_p->msg.current_slide->text.extension_char_count = new_text_info->extension_char_count;
  2739.         g_uc_p->msg.current_slide->text.UCS2_count = new_text_info->UCS2_count;
  2740.         
  2741.         /* For better performance, only update text buffer to text object when char count is one or zero */
  2742.         /* That is, text object is existed or not. */
  2743.         if (new_text_info->char_count == 1 || new_text_info->char_count == 0)
  2744.         {
  2745.             mmi_uc_exit_write_msg();
  2746.             mmi_uc_update_msg_size();
  2747.         }        
  2748.         
  2749.         return WGUI_UCE_TEXT_CHANGE_ALLOWED;
  2750.     }
  2751. }
  2752. /*****************************************************************************
  2753.  * FUNCTION
  2754.  *  mmi_uc_get_message_size_callback
  2755.  * DESCRIPTION
  2756.  *  Return msg size
  2757.  * PARAMETERS
  2758.  *  void
  2759.  * RETURNS
  2760.  *  void
  2761.  *****************************************************************************/
  2762. U32 mmi_uc_get_message_size_callback (wgui_uce_text_info_struct *current_text_info)
  2763. {
  2764.     /*----------------------------------------------------------------*/
  2765.     /* Local Variables                                                */
  2766.     /*----------------------------------------------------------------*/
  2767.     U32 msg_size = 0;
  2768.     /*----------------------------------------------------------------*/
  2769.     /* Code Body                                                      */
  2770.     /*----------------------------------------------------------------*/
  2771.     if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  2772.     {   
  2773.         msg_size = current_text_info->char_count;
  2774.     }
  2775.     else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  2776.     {
  2777.         msg_size = current_text_info->utf8_msg_len + g_uc_p->msg.msg_size_without_text_buffer;
  2778.     }
  2779.     else
  2780.     {
  2781.         MMI_ASSERT(0);
  2782.     }
  2783.     
  2784.     if (mmi_uc_change_msg_type_if_needed())
  2785.     {
  2786.         StartTimer(UC_MSG_TYPE_CHECK_TIMER_ID, MMI_UC_MSG_TYPE_CHECK_TIME, mmi_uc_disply_msg_type_change);
  2787.     }
  2788.     return msg_size;
  2789. }
  2790. /*****************************************************************************
  2791.  * FUNCTION
  2792.  *  mmi_uc_get_message_size_callback
  2793.  * DESCRIPTION
  2794.  *  Return msg size
  2795.  * PARAMETERS
  2796.  *  void
  2797.  * RETURNS
  2798.  *  void
  2799.  *****************************************************************************/
  2800. BOOL mmi_uc_is_pending_content(void)
  2801. {
  2802.     /*----------------------------------------------------------------*/
  2803.     /* Local Variables                                                */
  2804.     /*----------------------------------------------------------------*/
  2805.     /*----------------------------------------------------------------*/
  2806.     /* Code Body                                                      */
  2807.     /*----------------------------------------------------------------*/
  2808.     if (g_uc_p->msg.total_slide_num > 0)
  2809.     {
  2810.         if (g_uc_p->msg.current_slide->text.char_count ||        
  2811.             g_uc_p->msg.total_slide_num > 1 ||
  2812.             g_uc_p->msg.object_head ||
  2813.             g_uc_p->msg.to_num + g_uc_p->msg.cc_num + g_uc_p->msg.bcc_num > 0 ||
  2814.             pfnUnicodeStrlen((S8*)g_uc_p->msg.subject))
  2815.         {
  2816.             return TRUE;
  2817.         }
  2818.         else
  2819.         {
  2820.             return FALSE;
  2821.         }
  2822.     }
  2823.     else
  2824.     {
  2825.         return FALSE;
  2826.     }
  2827. }
  2828. /*****************************************************************************
  2829.  * FUNCTION
  2830.  *  mmi_uc_get_sms_setting
  2831.  * DESCRIPTION
  2832.  *  Get SMS setting
  2833.  * PARAMETERS
  2834.  *  void
  2835.  * RETURNS
  2836.  *  void
  2837.  *****************************************************************************/
  2838. void mmi_uc_get_sms_setting(void)
  2839. {
  2840.     /*----------------------------------------------------------------*/
  2841.     /* Local Variables                                                */
  2842.     /*----------------------------------------------------------------*/
  2843.     /*----------------------------------------------------------------*/
  2844.     /* Code Body                                                      */
  2845.     /*----------------------------------------------------------------*/
  2846.     g_uc_p->sms_info.max_gsm7bit_char_num = EMSUsableTextLen(SMSAL_DEFAULT_DCS) / 2;
  2847.     g_uc_p->sms_info.max_ucs2_char_num = EMSUsableTextLen(SMSAL_UCS2_DCS) / 2;
  2848. }
  2849. /*****************************************************************************
  2850.  * FUNCTION
  2851.  *  mmi_uc_get_sms_segment_number
  2852.  * DESCRIPTION
  2853.  *  Get SMS segment
  2854.  * PARAMETERS
  2855.  *  void
  2856.  * RETURNS
  2857.  *  void
  2858.  *****************************************************************************/
  2859. U8 mmi_uc_get_sms_segment_number(void)
  2860. {
  2861.     /*----------------------------------------------------------------*/
  2862.     /* Local Variables                                                */
  2863.     /*----------------------------------------------------------------*/
  2864.     U8 segment = 0;
  2865.     mmi_uc_slide_struct* slide = g_uc_p->msg.current_slide;
  2866.     /*----------------------------------------------------------------*/
  2867.     /* Code Body                                                      */
  2868.     /*----------------------------------------------------------------*/
  2869.     if (slide)
  2870.     {
  2871.         if (slide->text.UCS2_count)
  2872.         {
  2873.             if (EMSCalculateSeg(SMSAL_UCS2_DCS, (U16)(slide->text.char_count * 2), &segment) == EMS_OK)
  2874.             {
  2875.                 return segment;
  2876.             }
  2877.             else
  2878.             {
  2879.                 return 0;
  2880.             }
  2881.         }
  2882.         else
  2883.         {
  2884.             if (EMSCalculateSeg(SMSAL_DEFAULT_DCS, (U16)((slide->text.char_count + slide->text.extension_char_count) * 2), &segment) == EMS_OK)
  2885.             {
  2886.                 return segment;
  2887.             }
  2888.             else
  2889.             {
  2890.                 return 0;
  2891.             }
  2892.         }
  2893.     }
  2894.     return 0;
  2895. }
  2896. /*****************************************************************************
  2897.  * FUNCTION
  2898.  *  mmi_uc_sd_plug_out_hdlr
  2899.  * DESCRIPTION
  2900.  *  Handler when memory card is removed
  2901.  * PARAMETERS
  2902.  *  void
  2903.  * RETURNS
  2904.  *  void
  2905.  *****************************************************************************/
  2906. void mmi_uc_sd_plug_out_hdlr(void)
  2907. {
  2908.     /*----------------------------------------------------------------*/
  2909.     /* Local Variables                                                */
  2910.     /*----------------------------------------------------------------*/
  2911.     mmi_uc_slide_struct* slide = NULL;
  2912.     mmi_uc_object_struct* object = NULL;
  2913.     mmi_uc_attachment_info_struct* attachment = g_uc_p->msg.attachment_head;
  2914.     U16 shift_attachment_num = 0;    
  2915.     U8 cur_slide_num = 0;
  2916.     U8 cur_attachment_num = 0;
  2917.     /*----------------------------------------------------------------*/
  2918.     /* Code Body                                                      */
  2919.     /*----------------------------------------------------------------*/
  2920.     /* There is a popup when memory card is removed! */
  2921.     if (IsScreenPresent(SCR_ID_UC_EDITOR) && 
  2922.         (g_uc_p->send_info.action == MMI_UC_ACTION_IDLE || g_uc_p->send_info.action == MMI_UC_ACTION_PREVIEW))
  2923.     {
  2924.         for (slide = g_uc_p->msg.slide_head; cur_slide_num < g_uc_p->msg.total_slide_num; cur_slide_num++)
  2925.         {
  2926.             MMI_ASSERT(slide);
  2927.             if (slide->image.object)
  2928.             {
  2929.                 object = slide->image.object;
  2930.                 if (!(object->is_virtual_file))
  2931.                 {
  2932.                     if (FS_GetAttributes(object->file_path) < 0)
  2933.                     {
  2934.                         if (object->reference_count > 1)
  2935.                         {
  2936.                             object->reference_count--;
  2937.                         }
  2938.                         else
  2939.                         {
  2940.                             mmi_uc_delete_object_from_list(object);
  2941.                         }
  2942.                         memset(&slide->image, 0, sizeof(mmi_uc_object_info_struct));
  2943.                     }
  2944.                 }
  2945.             }
  2946.             if (slide->audio.object)
  2947.             {
  2948.                 object = slide->audio.object;
  2949.                 if (!(object->is_virtual_file))
  2950.                 {
  2951.                     if (FS_GetAttributes(object->file_path) < 0)
  2952.                     {
  2953.                         if (object->reference_count > 1)
  2954.                         {
  2955.                             object->reference_count--;
  2956.                         }
  2957.                         else
  2958.                         {
  2959.                             mmi_uc_delete_object_from_list(object);
  2960.                         }
  2961.                         memset(&slide->audio, 0, sizeof(mmi_uc_object_info_struct));
  2962.                     }
  2963.                 }
  2964.             }
  2965.             if (slide->video.object)
  2966.             {
  2967.                 object = slide->video.object;
  2968.                 if (!(object->is_virtual_file))
  2969.                 {
  2970.                     if (FS_GetAttributes(object->file_path) < 0)
  2971.                     {
  2972.                         if (object->reference_count > 1)
  2973.                         {
  2974.                             object->reference_count--;
  2975.                         }
  2976.                         else
  2977.                         {
  2978.                             mmi_uc_delete_object_from_list(object);
  2979.                         }
  2980.                         memset(&slide->video, 0, sizeof(mmi_uc_object_info_struct));
  2981.                     }
  2982.                 }
  2983.             }
  2984.             
  2985.             slide = slide->next;
  2986.             
  2987.         }
  2988.         while (attachment != NULL)
  2989.         {
  2990.             object = attachment->object;
  2991.             if (!(object->is_virtual_file))
  2992.             {
  2993.                 if (FS_GetAttributes(object->file_path) < 0)
  2994.                 {
  2995.                     mmi_uc_attachment_info_struct* att_temp = attachment->next;
  2996.                     
  2997.                     MMI_ASSERT(object->reference_count == 1);
  2998.                     mmi_uc_delete_object_from_list(object);
  2999.                     /* Replace attachment handling */
  3000.                     if (IsScreenPresent(SCR_ID_UC_OPT_REPLACE) &&
  3001.                         IsScreenPresent(SCR_ID_UC_OPT_ATTACHMENT_LIST))
  3002.                     {
  3003.                         if (g_uc_p->main.object_index == cur_attachment_num)
  3004.                         {
  3005.                             shift_attachment_num = MMI_UC_INVALID_INDEX;
  3006.                         }
  3007.                         if (shift_attachment_num != MMI_UC_INVALID_INDEX &&
  3008.                             g_uc_p->main.object_index > cur_attachment_num )
  3009.                         {
  3010.                             shift_attachment_num++;
  3011.                         }
  3012.                     }
  3013.                     
  3014.                     mmi_uc_delete_attachment_from_list(attachment);
  3015.                     attachment = att_temp;
  3016.                     cur_attachment_num++;
  3017.                     continue;
  3018.                 }                            
  3019.             }            
  3020.             
  3021.             cur_attachment_num++;
  3022.             attachment = attachment->next;            
  3023.         }
  3024.         /* Replace attachment handling */
  3025.         if (shift_attachment_num > 0)
  3026.         {
  3027.             if (shift_attachment_num == MMI_UC_INVALID_INDEX)
  3028.             {
  3029.                 g_uc_p->main.object_index = MMI_UC_INVALID_INDEX;
  3030.             }
  3031.             else
  3032.             {
  3033.                 MMI_ASSERT(g_uc_p->main.object_index >= shift_attachment_num);
  3034.                 g_uc_p->main.object_index -= shift_attachment_num;
  3035.             }
  3036.         }
  3037.         mmi_uc_reset_layout_if_needed();                
  3038.         
  3039.         if (mmi_uc_change_msg_type_if_needed())
  3040.         {
  3041.             mmi_uc_insert_signature_check();
  3042.         }
  3043.         mmi_uc_update_msg_size();                            
  3044.         //mmi_uc_switch_slide(g_uc_p->msg.current_slide);
  3045.         mmi_uc_editor_initialize();
  3046.         mmi_uc_set_editor_info(g_uc_p->msg.current_slide);
  3047.     }
  3048. }
  3049. /*****************************************************************************
  3050.  * FUNCTION
  3051.  *  mmi_uc_sd_plug_out_hdlr
  3052.  * DESCRIPTION
  3053.  *  Handler when memory card is removed
  3054.  * PARAMETERS
  3055.  *  void
  3056.  * RETURNS
  3057.  *  void
  3058.  *****************************************************************************/
  3059. void mmi_uc_reset_layout_if_needed(void)
  3060. {
  3061.     /*----------------------------------------------------------------*/
  3062.     /* Local Variables                                                */
  3063.     /*----------------------------------------------------------------*/
  3064.     mmi_uc_object_struct* object = NULL;
  3065.     /*----------------------------------------------------------------*/
  3066.     /* Code Body                                                      */
  3067.     /*----------------------------------------------------------------*/
  3068.     for (object = g_uc_p->msg.object_head ; object != NULL ; object = object->next)
  3069.     {
  3070.         if (object->type == MMI_UC_OBJECT_TYPE_IMAGE ||
  3071.             object->type == MMI_UC_OBJECT_TYPE_VIDEO )
  3072.         {
  3073.             break;
  3074.         }
  3075.     }
  3076.     
  3077.     if (object == NULL)
  3078.     {
  3079.         g_uc_p->msg.layout = MMI_UC_LAYOUT_DEFAULT;
  3080.     }
  3081. }
  3082. /*****************************************************************************
  3083.  * FUNCTION
  3084.  *  mmi_uc_reset_editor_history_guibuffer
  3085.  * DESCRIPTION
  3086.  *  reset editor history gui buffer
  3087.  * PARAMETERS
  3088.  *  screen_id           [IN]        
  3089.  * RETURNS
  3090.  *  kal_bool 
  3091.  *****************************************************************************/
  3092. BOOL mmi_uc_reset_history_guibuffer(U16 screen_id)
  3093. {
  3094.     /*----------------------------------------------------------------*/
  3095.     /* Local Variables                                                */
  3096.     /*----------------------------------------------------------------*/
  3097.     historyNode* history = NULL;
  3098.     /*----------------------------------------------------------------*/
  3099.     /* Code Body                                                      */
  3100.     /*----------------------------------------------------------------*/
  3101.     GetHistoryPointer(screen_id, &history);
  3102.     if (history != NULL)
  3103.     {    
  3104.         if (history->guiBuffer != NULL)
  3105.         {
  3106.             PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  3107.                                  "*[UnifiedComposerMiscell.c] mmi_uc_reset_history_guibuffer(), screen_id=%d",
  3108.                                  screen_id));
  3109.             OslMfree(history->guiBuffer);
  3110.             history->guiBuffer = NULL;
  3111.         }
  3112.         return KAL_TRUE;
  3113.     }
  3114.     else
  3115.     {
  3116.         return KAL_FALSE;
  3117.     }        
  3118. }
  3119. /*****************************************************************************
  3120.  * FUNCTION
  3121.  *  mmi_uc_is_uc_screen_in_history
  3122.  * DESCRIPTION
  3123.  *  Return if unified composer screen is in the history
  3124.  * PARAMETERS
  3125.  *  screen_id           [IN]        
  3126.  * RETURNS
  3127.  *  kal_bool 
  3128.  *****************************************************************************/
  3129. kal_bool mmi_uc_is_uc_screen_in_history(void)
  3130. {
  3131.     /*----------------------------------------------------------------*/
  3132.     /* Local Variables                                                */
  3133.     /*----------------------------------------------------------------*/
  3134.     /*----------------------------------------------------------------*/
  3135.     /* Code Body                                                      */
  3136.     /*----------------------------------------------------------------*/    
  3137.     return (kal_bool)IsScreenPresent(SCR_ID_UC_EDITOR);
  3138. }
  3139. /*****************************************************************************
  3140.  * FUNCTION
  3141.  *  mmi_uc_is_email_addr_valid
  3142.  * DESCRIPTION
  3143.  *  Return if email address valid
  3144.  * PARAMETERS
  3145.  *  screen_id           [IN]        
  3146.  * RETURNS
  3147.  *  kal_bool 
  3148.  *****************************************************************************/
  3149. BOOL mmi_uc_is_email_addr_valid(U8* addr)
  3150. {
  3151.     /*----------------------------------------------------------------*/
  3152.     /* Local Variables                                                */
  3153.     /*----------------------------------------------------------------*/
  3154.     U16 email_addr_len = pfnUnicodeStrlen((S8*)addr);
  3155.     U16 i = 0;
  3156.     U16* email_addr = (U16*)addr;
  3157.     /*----------------------------------------------------------------*/
  3158.     /* Code Body                                                      */
  3159.     /*----------------------------------------------------------------*/    
  3160.     for ( ; i< email_addr_len ; i++ )
  3161.     {
  3162.         if (pfnUnicodeStrncmp((S8*)&email_addr[i], (S8*)L"@", 1) == 0)
  3163.         {
  3164.             if (i == 0 || i == (email_addr_len - 1))
  3165.             {
  3166.                 return FALSE;
  3167.             }
  3168.             else
  3169.             {
  3170.                 return TRUE;
  3171.             }
  3172.         }
  3173.     }
  3174.     return FALSE;
  3175.         
  3176. }
  3177. /*****************************************************************************
  3178. * FUNCTION
  3179. *  mmi_uc_handle_msg_type_check
  3180. * DESCRIPTION
  3181. *  Handler for checking if msg type changes
  3182. * PARAMETERS
  3183. *  screen_id           [IN]        
  3184. * RETURNS
  3185. *  kal_bool 
  3186. *****************************************************************************/
  3187. void mmi_uc_handle_msg_type_check(void)
  3188. {
  3189.     /*----------------------------------------------------------------*/
  3190.     /* Local Variables                                                */
  3191.     /*----------------------------------------------------------------*/
  3192.     /*----------------------------------------------------------------*/
  3193.     /* Code Body                                                      */
  3194.     /*----------------------------------------------------------------*/
  3195.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[UnifiedComposerMiscell.c] mmi_uc_handle_msg_type_check *n"));
  3196.     
  3197.     if (mmi_uc_change_msg_type_if_needed())
  3198.     {
  3199.         mmi_uc_insert_signature_check();
  3200.     }
  3201.     if (GetExitScrnID() == SCR_ID_UC_OPT_DONE)
  3202.     {
  3203.         if (g_uc_p->done.pre_msg_type != g_uc_p->msg_type.curr_msg_type)
  3204.         {
  3205.             g_uc_p->done.pre_msg_type = g_uc_p->msg_type.curr_msg_type;
  3206.             if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  3207.             {
  3208.                 DisplayPopup(
  3209.                     (PU8) GetString(STR_UC_CHANGED_TO_TEXT_MSG_ID),
  3210.                     0,
  3211.                     1,
  3212.                     MMI_UC_POPUP_TIME_OUT,
  3213.                     (U8) WARNING_TONE);
  3214.             }
  3215.             else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  3216.             {
  3217.                 DisplayPopup(
  3218.                     (PU8) GetString(STR_UC_CHANGED_TO_MULTIMEDIA_MSG_ID),
  3219.                     0,
  3220.                     1,
  3221.                     MMI_UC_POPUP_TIME_OUT,
  3222.                     (U8) WARNING_TONE);
  3223.             }
  3224.             else
  3225.             {
  3226.                 MMI_ASSERT(0);
  3227.             }
  3228.         }
  3229.     }
  3230.     else
  3231.     {
  3232.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[UnifiedComposerMiscell.c] mmi_uc_handle_msg_type_check IGNORE! *n"));
  3233.     }
  3234. }
  3235. /*****************************************************************************
  3236. * FUNCTION
  3237. *  mmi_uc_disply_msg_type_change
  3238. * DESCRIPTION
  3239. *  display msg type is changed
  3240. * PARAMETERS
  3241. *  screen_id           [IN]        
  3242. * RETURNS
  3243. *  kal_bool 
  3244. *****************************************************************************/
  3245. void mmi_uc_disply_msg_type_change(void)
  3246. {
  3247.     /*----------------------------------------------------------------*/
  3248.     /* Local Variables                                                */
  3249.     /*----------------------------------------------------------------*/
  3250.     /*----------------------------------------------------------------*/
  3251.     /* Code Body                                                      */
  3252.     /*----------------------------------------------------------------*/
  3253.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[UnifiedComposerMiscell.c] mmi_uc_disply_msg_type_change *n"));
  3254.     
  3255.     if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_SMS_PREFER)
  3256.     {
  3257.         DisplayPopup(
  3258.             (PU8) GetString(STR_UC_CHANGED_TO_TEXT_MSG_ID),
  3259.             0,
  3260.             1,
  3261.             MMI_UC_POPUP_TIME_OUT,
  3262.             (U8) WARNING_TONE);
  3263.     }
  3264.     else if (g_uc_p->msg_type.curr_msg_type == MMI_UC_MSG_TYPE_MMS_PREFER)
  3265.     {
  3266.         DisplayPopup(
  3267.             (PU8) GetString(STR_UC_CHANGED_TO_MULTIMEDIA_MSG_ID),
  3268.             0,
  3269.             1,
  3270.             MMI_UC_POPUP_TIME_OUT,
  3271.             (U8) WARNING_TONE);
  3272.     }
  3273.     else
  3274.     {
  3275.         MMI_ASSERT(0);
  3276.     }
  3277.     mmi_uc_insert_signature_check();
  3278. }
  3279. /*****************************************************************************
  3280.  * FUNCTION
  3281.  *  mmi_uc_replace_duplicate_object_file_name
  3282.  * DESCRIPTION
  3283.  *  Replace duplicate object file name
  3284.  * PARAMETERS
  3285.  *  void
  3286.  * RETURNS
  3287.  *  void
  3288.  *****************************************************************************/
  3289. void mmi_uc_replace_duplicate_object_file_name(void)
  3290. {
  3291.     /*----------------------------------------------------------------*/
  3292.     /* Local Variables                                                */
  3293.     /*----------------------------------------------------------------*/
  3294.     mmi_uc_object_struct* obj = g_uc_p->msg.object_head;
  3295.     /*----------------------------------------------------------------*/
  3296.     /* Code Body                                                      */
  3297.     /*----------------------------------------------------------------*/
  3298.     while (obj != NULL)
  3299.     {
  3300.         mmi_uc_object_struct* handle_obj = obj->next;
  3301.         U8 i = 1;
  3302.         while (handle_obj != NULL)
  3303.         {
  3304.             handle_obj = mmi_uc_check_duplicate_object_by_filename(obj->file_name, handle_obj);
  3305.             if (handle_obj != NULL)
  3306.             {
  3307.                 if (handle_obj->is_virtual_file != MMI_TRUE)
  3308.                 {
  3309.                     /* replace file name */
  3310.                     U16 file_name_len = pfnUnicodeStrlen((S8*)handle_obj->file_name);
  3311.                     U16* new_file_name = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_name_len + 3 ) * ENCODING_LENGTH);
  3312.                     U16 file_suffix[5];
  3313.                     U16* file_extension = mmi_uc_get_file_extension(handle_obj->file_name);
  3314.                     U16 file_extension_len = 0;
  3315.                     if (file_extension != NULL)
  3316.                     {
  3317.                         file_extension_len = pfnUnicodeStrlen((S8*)file_extension);
  3318.                         pfnUnicodeStrncpy((S8*)new_file_name, (S8*)handle_obj->file_name, (file_name_len - file_extension_len - 1));
  3319.                     }
  3320.                     else
  3321.                     {
  3322.                         pfnUnicodeStrncpy((S8*)new_file_name, (S8*)handle_obj->file_name, file_name_len);
  3323.                     }
  3324.                     
  3325.                     memset(file_suffix, 0x00, sizeof(file_suffix));
  3326.                     kal_wsprintf( (kal_uint16 *)file_suffix, "%02d", i);                                 
  3327.                     pfnUnicodeStrcat((PS8) new_file_name, (PS8) file_suffix);
  3328.                     if (file_extension != NULL)
  3329.                     {
  3330.                         pfnUnicodeStrcat((PS8) new_file_name, (PS8) L".");
  3331.                         pfnUnicodeStrcat((PS8) new_file_name, (PS8) file_extension);
  3332.                     }
  3333.                     kal_adm_free(g_uc_p->main.mem_pool_id, handle_obj->file_name);
  3334.                     handle_obj->file_name = new_file_name;
  3335.                     i++;
  3336.                 }
  3337.                 
  3338.                 handle_obj = handle_obj->next;                
  3339.             }
  3340.         }
  3341.         obj = obj->next;
  3342.     }    
  3343.     return;
  3344. }
  3345. /*****************************************************************************
  3346.  * FUNCTION
  3347.  *  mmi_uc_compare_string_ignore_case
  3348.  * DESCRIPTION
  3349.  *  Compare string by ignoring case.
  3350.  * PARAMETERS
  3351.  *  void
  3352.  * RETURNS
  3353.  *  void
  3354.  *****************************************************************************/
  3355. BOOL mmi_uc_compare_string_ignore_case(U16* addr_1, U16* addr_2)
  3356. {
  3357.     /*----------------------------------------------------------------*/
  3358.     /* Local Variables                                                */
  3359.     /*----------------------------------------------------------------*/
  3360.     U16 addr_index = 0;
  3361.     U16 char_A = 0x0041;
  3362.     U16 char_Z = 0x005A;
  3363.     U16 char_a = 0x0061;
  3364.     U16 addr_1_len = pfnUnicodeStrlen((S8*)addr_1);
  3365.     U16 addr_2_len = pfnUnicodeStrlen((S8*)addr_2);
  3366.     U16 addr_1_char = 0;
  3367.     U16 addr_2_char = 0;
  3368.     
  3369.     /*----------------------------------------------------------------*/
  3370.     /* Code Body                                                      */
  3371.     /*----------------------------------------------------------------*/
  3372.     if (addr_1_len != addr_2_len)
  3373.     {
  3374.         return MMI_FALSE;
  3375.     }
  3376.     
  3377.     while (addr_index < addr_1_len)
  3378.     {
  3379.         if (addr_1[addr_index] >= char_A && addr_1[addr_index] <= char_Z)
  3380.         {
  3381.             addr_1_char = char_a + addr_1[addr_index] - char_A;
  3382.         }
  3383.         else
  3384.         {
  3385.             addr_1_char = addr_1[addr_index];            
  3386.         }
  3387.         
  3388.         if (addr_2[addr_index] >= char_A && addr_2[addr_index] <= char_Z)
  3389.         {
  3390.             addr_2_char = char_a + addr_2[addr_index] - char_A;
  3391.         }
  3392.         else
  3393.         {
  3394.             addr_2_char = addr_2[addr_index];
  3395.         }
  3396.         if (addr_1_char != addr_2_char)
  3397.         {
  3398.             return MMI_FALSE;
  3399.         }
  3400.         addr_index++;
  3401.     }
  3402.     
  3403.     return MMI_TRUE;
  3404. }
  3405. /*****************************************************************************
  3406.  * FUNCTION
  3407.  *  mmi_uc_delete_existed_mms
  3408.  * DESCRIPTION
  3409.  *  Delete existed MMS msg
  3410.  * PARAMETERS
  3411.  *  void
  3412.  * RETURNS
  3413.  *  void
  3414.  *****************************************************************************/
  3415. void mmi_uc_delete_existed_mms(void)
  3416. {
  3417.     /*----------------------------------------------------------------*/
  3418.     /* Local Variables                                                */
  3419.     /*----------------------------------------------------------------*/
  3420.     
  3421.     /*----------------------------------------------------------------*/
  3422.     /* Code Body                                                      */
  3423.     /*----------------------------------------------------------------*/
  3424.     if (g_uc_p->main.file_handle > 0)
  3425.     {
  3426.         FS_Close(g_uc_p->main.file_handle);
  3427.         g_uc_p->main.file_handle = 0;
  3428.     }
  3429.     
  3430.     mmi_uc_delete_mms_req(g_uc_p->send_info.existed_msg_id);
  3431. }
  3432. /*****************************************************************************
  3433.  * FUNCTION
  3434.  *  mmi_uc_update_text_object_path
  3435.  * DESCRIPTION
  3436.  *  Update text object file path
  3437.  * PARAMETERS
  3438.  *  void
  3439.  * RETURNS
  3440.  *  void
  3441.  *****************************************************************************/
  3442. void mmi_uc_update_text_object_path(mmi_uc_slide_struct* slide)
  3443. {
  3444.     /*----------------------------------------------------------------*/
  3445.     /* Local Variables                                                */
  3446.     /*----------------------------------------------------------------*/
  3447.     U8 mmi_uc_text_path[MMI_UC_MAX_TEMP_FILE_LEN];
  3448.     mmi_uc_object_struct* object = NULL;
  3449.     U16* file_name;
  3450.     U16 file_path_len = 0;
  3451.     U16 file_name_len = 0;
  3452.     
  3453.     
  3454.     /*----------------------------------------------------------------*/
  3455.     /* Code Body                                                      */
  3456.     /*----------------------------------------------------------------*/
  3457.     MMI_ASSERT(slide != NULL);
  3458.     memset(mmi_uc_text_path, 0, MMI_UC_MAX_TEMP_FILE_LEN);
  3459.     MMI_UC_MAKE_TEXT_FILE_PATH(mmi_uc_text_path, slide->slide_num);
  3460.     file_path_len = pfnUnicodeStrlen((S8*)mmi_uc_text_path);
  3461.     
  3462.     if ((object = slide->text.object) != NULL)
  3463.     {
  3464.         MMI_ASSERT(FS_Rename((U16*)object->file_path, (U16*)mmi_uc_text_path) == FS_NO_ERROR);
  3465.     
  3466.         /* file path */
  3467.         if (object->file_path != NULL)
  3468.         {
  3469.             kal_adm_free(g_uc_p->main.mem_pool_id, object->file_path);
  3470.             object->file_path = NULL;
  3471.         }
  3472.         object->file_path = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_path_len + 1 ) * 2);
  3473.         MMI_ASSERT(object->file_path);
  3474.         memset(object->file_path, 0, (file_path_len + 1) * 2);
  3475.         pfnUnicodeStrncpy((S8*)object->file_path, (S8*)mmi_uc_text_path, file_path_len);
  3476.         /* file name */
  3477.         if (object->file_name != NULL)
  3478.         {
  3479.             kal_adm_free(g_uc_p->main.mem_pool_id, object->file_name);
  3480.             object->file_name = NULL;
  3481.         }
  3482.         file_name = mmi_uc_get_file_name((U16*)mmi_uc_text_path);
  3483.         file_name_len = pfnUnicodeStrlen((S8*)file_name);
  3484.         object->file_name = kal_adm_alloc(g_uc_p->main.mem_pool_id, (file_name_len + 1 ) * 2);
  3485.         MMI_ASSERT(object->file_name);
  3486.         memset(object->file_name, 0, (file_name_len + 1) * 2);
  3487.         pfnUnicodeStrncpy((S8*)object->file_name, (S8*)file_name, file_name_len);
  3488.     }
  3489.     return;
  3490. }
  3491. /*****************************************************************************
  3492.  * FUNCTION
  3493.  *  mmi_uc_get_end_slide
  3494.  * DESCRIPTION
  3495.  *  get the last slide
  3496.  * PARAMETERS
  3497.  *  void
  3498.  * RETURNS
  3499.  *  void
  3500.  *****************************************************************************/
  3501. mmi_uc_slide_struct* mmi_uc_get_end_slide(void)
  3502. {
  3503.     /*----------------------------------------------------------------*/
  3504.     /* Local Variables                                                */
  3505.     /*----------------------------------------------------------------*/
  3506.     mmi_uc_slide_struct* slide = g_uc_p->msg.slide_head;
  3507.     
  3508.     /*----------------------------------------------------------------*/
  3509.     /* Code Body                                                      */
  3510.     /*----------------------------------------------------------------*/
  3511.     if(slide == NULL)
  3512.     {
  3513.         return NULL;
  3514.     }
  3515.     
  3516.     while (slide->next != NULL)
  3517.     {
  3518.         slide = slide->next;
  3519.     }
  3520.     return slide;
  3521.     
  3522. }
  3523. /*****************************************************************************
  3524.  * FUNCTION
  3525.  *  mmi_uc_delete_between_screens
  3526.  * DESCRIPTION
  3527.  *  Delete screens including start_sreen and end_screen
  3528.  * PARAMETERS
  3529.  *  void
  3530.  * RETURNS
  3531.  *  void
  3532.  *****************************************************************************/
  3533. BOOL mmi_uc_delete_between_screens(U16 start_screen_id, U16 end_screen_id)
  3534. {
  3535.     /*----------------------------------------------------------------*/
  3536.     /* Local Variables                                                */
  3537.     /*----------------------------------------------------------------*/
  3538.     
  3539.     /*----------------------------------------------------------------*/
  3540.     /* Code Body                                                      */
  3541.     /*----------------------------------------------------------------*/
  3542.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  3543.                                  "*[UnifiedComposerMiscell.c] mmi_uc_delete_between_screens(), start_scr=%d, end_scr=%d",
  3544.                                  start_screen_id, end_screen_id));
  3545.         
  3546.     if (!IsScreenPresent(start_screen_id))
  3547.     {        
  3548.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  3549.                                      "*[UnifiedComposerMiscell.c] mmi_uc_delete_between_screens(), start_scr=%d NOT present",
  3550.                                      start_screen_id));
  3551.         return MMI_FALSE;        
  3552.     }
  3553.     if (!IsScreenPresent(end_screen_id))
  3554.     {
  3555.         
  3556.         PRINT_INFORMATION_2((MMI_TRACE_G6_SMS,
  3557.                                      "*[UnifiedComposerMiscell.c] mmi_uc_delete_between_screens(), end_scr=%d NOT present",
  3558.                                      end_screen_id));
  3559.         return MMI_FALSE;        
  3560.     }
  3561.     
  3562.     return DeleteBetweenScreen(start_screen_id, end_screen_id);
  3563. }
  3564. #endif /* __MMI_UNIFIED_COMPOSER__ */ 
  3565. #endif /* _MMI_UNIFIED_COMPOSER_MISCELL_C */