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

MTK

开发平台:

C/C++

  1.  *  set mms bg color in message handle.
  2.  * PARAMETERS
  3.  *  bg_color        [IN]        
  4.  * RETURNS
  5.  *  void
  6.  *****************************************************************************/
  7. JMMS_COMP_ERRCODE mmi_jmms_set_bg_color(U32 bg_color)
  8. {
  9.     /*----------------------------------------------------------------*/
  10.     /* Local Variables                                                */
  11.     /*----------------------------------------------------------------*/
  12.     JC_INT8 bg_color_str[10];
  13.     U32 height, width;
  14.     JC_RETCODE ret_code;
  15.     JMMS_COMP_ERRCODE err_code;
  16.     DeviceCharacteristics dev_ch = {0};
  17.     /*----------------------------------------------------------------*/
  18.     /* Code Body                                                      */
  19.     /*----------------------------------------------------------------*/
  20.     jdd_MMIGetDeviceCharacteristics(&dev_ch);
  21.     height = dev_ch.uiRenderingWidth;
  22.     width = dev_ch.uiRenderingHeight;
  23.     mmi_jmms_convert_u32To_hash_col_string(bg_color, bg_color_str);
  24.     ret_code = mmi_jmms_jdi_set_smil_root_layout(g_jmms_context->msg_handle, height, width, bg_color_str);
  25.     err_code = mmi_jmms_compose_handle_error(ret_code, 0);
  26.     return err_code;
  27. }
  28. /*****************************************************************************
  29.  * FUNCTION
  30.  *  mmi_jmms_get_bg_color
  31.  * DESCRIPTION
  32.  *  set mms bg color in message handle.
  33.  * PARAMETERS
  34.  *  bg_color        [?]     [?]
  35.  * RETURNS
  36.  *  void
  37.  *****************************************************************************/
  38. JMMS_COMP_ERRCODE mmi_jmms_get_bg_color(JC_INT32 *bg_color)
  39. {
  40.     /*----------------------------------------------------------------*/
  41.     /* Local Variables                                                */
  42.     /*----------------------------------------------------------------*/
  43.     JC_INT8 *bg_color_str;
  44.     U32 height, width;
  45.     JC_RETCODE ret_code;
  46.     JMMS_COMP_ERRCODE err_code;
  47.     /*----------------------------------------------------------------*/
  48.     /* Code Body                                                      */
  49.     /*----------------------------------------------------------------*/
  50.     ret_code = mmi_jmms_jdi_get_smil_root_layout(g_jmms_context->msg_handle, &height, &width, &bg_color_str);
  51.     err_code = mmi_jmms_compose_handle_error(ret_code, 0);
  52.     if (err_code == JMMS_COMP_OK && bg_color_str != NULL)
  53.     {
  54.         *bg_color = GetColorValue(bg_color_str);
  55.         if (*bg_color > 0)
  56.         {
  57.             *bg_color <<= 8;
  58.             *bg_color |= 0x00000064;
  59.         }
  60.     }
  61.     else
  62.     {
  63.         *bg_color = g_jmms_color_RGB_list[COLOR_WHITE];
  64.     }
  65.     return JMMS_COMP_OK;
  66. }
  67. /*****************************************************************************
  68.  * FUNCTION
  69.  *  mmi_jmms_set_region_list
  70.  * DESCRIPTION
  71.  *  set mms bg color in message handle.
  72.  * PARAMETERS
  73.  *  void
  74.  * RETURNS
  75.  *  void
  76.  *****************************************************************************/
  77. JMMS_COMP_ERRCODE mmi_jmms_set_region_list(void)
  78. {
  79.     /*----------------------------------------------------------------*/
  80.     /* Local Variables                                                */
  81.     /*----------------------------------------------------------------*/
  82.     JC_RETCODE ret_code = JC_OK;
  83.     JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK;
  84.     REGION_LAYOUT region_layout1, region_layout2;
  85.     DeviceCharacteristics dev_ch = {0};
  86.     U8 size;
  87.     JC_RECT display_rect;
  88.     media_type_enum first_region_media = MEDIA_AUDIO;
  89.     MEDIA_INFO *media_info_p;
  90.     U8 media_count = 0, page_count = 0, temp_page_count;
  91.     /*----------------------------------------------------------------*/
  92.     /* Code Body                                                      */
  93.     /*----------------------------------------------------------------*/
  94.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_set_region_list"));
  95.     region_layout1.pRegionName = NULL;
  96.     region_layout2.pRegionName = NULL;
  97.      /* Check that any media exists on slide other then audio */
  98.     mmi_jmms_jdi_get_total_pages(g_jmms_context->msg_handle, &page_count);
  99.     for(temp_page_count=1;(media_count==0 && temp_page_count <= page_count);temp_page_count++)
  100.     {
  101.         mmi_jmms_compose_get_media_list(temp_page_count, &media_info_p, &media_count, MMI_FALSE);
  102.         if(media_count !=0 )
  103.         {
  104.             if (media_info_p != NULL)
  105.             {
  106.                 first_region_media = media_info_p->eMediaType;
  107.                 if ( media_info_p->eMediaType == MEDIA_AUDIO && media_count > 1)
  108.                 {
  109.                     first_region_media = media_info_p->pNext->eMediaType;                    
  110.                 }
  111.             }
  112.             break;
  113.         }
  114.     }
  115.     if ((media_count != 0 && first_region_media != MEDIA_AUDIO ) && temp_page_count >= g_jmms_context->compose_context->curr_page_index)
  116.     {
  117.         jdd_MMIGetDeviceCharacteristics(&dev_ch);
  118.         display_rect.iLeft = dev_ch.uiLeftMargin;
  119.         display_rect.iTop = dev_ch.uiTopMargin;
  120.         /* Deepali: Here they want regions as rendering area, excluding scroll bar. */
  121.         display_rect.uiHeight = dev_ch.uiRenderingHeight;
  122.         display_rect.uiWidth = dev_ch.uiRenderingWidth;
  123. /* Now Template will always be Viewed in PORTRAIT mode */
  124. if (IsScreenPresent(SCR_ID_JMMS_TEMPLATES) ||(g_jmms_context->layout==CUSTOM_LAYOUT)|| (U8) mmi_jmms_compose_settings_layout() == (U8) E_MMS_LAYOUT_POTRAIT)
  125.         {
  126.             region_layout1.uiTop = display_rect.iTop;
  127.             region_layout1.uiLeft = display_rect.iLeft;
  128.             region_layout1.uiWidth = (JC_UINT32) (display_rect.uiWidth) - (2 * display_rect.iLeft);
  129.             region_layout1.uiHeight =
  130.                 (JC_UINT32) ((display_rect.uiHeight - (2 * display_rect.iTop) -
  131.                               JMMS_VIEW_DEFAULT_MEDIA_SPACING) * 0.5);
  132.             region_layout1.eFit = E_CONFIG_REGION_MEET;
  133.             region_layout2.uiTop = region_layout1.uiHeight + JMMS_VIEW_DEFAULT_MEDIA_SPACING;
  134.             region_layout2.uiLeft = display_rect.iLeft;
  135.             region_layout2.uiWidth = (JC_UINT32) (display_rect.uiWidth) - (2 * display_rect.iLeft);
  136.             region_layout2.uiHeight =
  137.                 (JC_UINT32) (display_rect.uiHeight - region_layout2.uiTop - display_rect.iTop);
  138.             region_layout2.eFit = E_CONFIG_REGION_MEET;
  139.         }
  140.         else
  141.         {
  142.             region_layout1.uiTop = display_rect.iTop;
  143.             region_layout1.uiLeft = display_rect.iLeft;
  144.             region_layout1.uiWidth =
  145.                 (JC_UINT32) ((display_rect.uiWidth - (2 * display_rect.iLeft) -
  146.                               JMMS_VIEW_DEFAULT_MEDIA_SPACING) * 0.5);
  147.             region_layout1.uiHeight = (JC_UINT32) ((display_rect.uiHeight - (2 * display_rect.iTop)) * 10);
  148.             region_layout1.eFit = E_CONFIG_REGION_MEET;
  149.             region_layout2.uiTop = display_rect.iTop;
  150.             region_layout2.uiLeft =
  151.                 region_layout1.uiLeft + region_layout1.uiWidth + JMMS_VIEW_DEFAULT_MEDIA_SPACING;
  152.             region_layout2.uiWidth =
  153.                 (JC_UINT32) (display_rect.uiWidth - region_layout2.uiLeft - display_rect.iLeft);
  154.             region_layout2.uiHeight = (JC_UINT32) ((display_rect.uiHeight - (2 * display_rect.iTop)) * 10);
  155.             region_layout2.eFit = E_CONFIG_REGION_MEET;
  156.         }
  157.         if ((g_jmms_context->compose_context->
  158.              is_image_first[temp_page_count - 1] == 0) && first_region_media == MEDIA_TEXT)
  159.         {
  160.             /* Text is first */
  161.             size = strlen(STRING_TEXT);
  162.             region_layout1.pRegionName = (JC_CHAR*) jdd_MemAlloc(sizeof(JC_CHAR), size + 1);
  163.             if (region_layout1.pRegionName == NULL)
  164.             {
  165.                 ret_code = JC_ERR_MEMORY_ALLOCATION;
  166.                 goto ERROR_HANDLE;
  167.             }
  168.             AnsiiToUnicodeString((PS8)(region_layout1.pRegionName), (PS8) (STRING_TEXT));
  169.             size = strlen(STRING_IMAGE);
  170.             region_layout2.pRegionName = (JC_CHAR*) jdd_MemAlloc(sizeof(JC_CHAR), size + 1);
  171.             if (region_layout2.pRegionName == NULL)
  172.             {
  173.                 ret_code = JC_ERR_MEMORY_ALLOCATION;
  174.                 goto ERROR_HANDLE;
  175.             }
  176.             AnsiiToUnicodeString((PS8)(region_layout2.pRegionName), (PS8) (STRING_IMAGE));
  177.         }
  178.         else
  179.         {
  180.             /* Image/Video is first */
  181.            size = strlen(STRING_IMAGE);
  182.             region_layout1.pRegionName = (JC_CHAR*) jdd_MemAlloc(sizeof(JC_CHAR), size + 1);
  183.             if (region_layout1.pRegionName == NULL)
  184.             {
  185.                 ret_code = JC_ERR_MEMORY_ALLOCATION;
  186.                 goto ERROR_HANDLE;
  187.             }
  188.             AnsiiToUnicodeString((PS8)(region_layout1.pRegionName), (PS8) (STRING_IMAGE));
  189.             size = strlen(STRING_TEXT);
  190.             region_layout2.pRegionName = (JC_CHAR*) jdd_MemAlloc(sizeof(JC_CHAR), size + 1);
  191.             if (region_layout2.pRegionName == NULL)
  192.             {
  193.                 ret_code = JC_ERR_MEMORY_ALLOCATION;
  194.                 goto ERROR_HANDLE;
  195.             }
  196.             AnsiiToUnicodeString((PS8)(region_layout2.pRegionName), (PS8) (STRING_TEXT));
  197.         }
  198.         ret_code = mmi_jmms_jdi_add_smil_region_layout(g_jmms_context->msg_handle, &region_layout1);
  199.         if (ret_code == JC_OK)
  200.         {
  201.             ret_code = mmi_jmms_jdi_add_smil_region_layout(g_jmms_context->msg_handle, &region_layout2);
  202.         }
  203.     }
  204.   ERROR_HANDLE:
  205.     err_code = mmi_jmms_compose_handle_error(ret_code, 0);
  206.     if (region_layout1.pRegionName != NULL)
  207.     {
  208.         jdd_MemFree(region_layout1.pRegionName);
  209.         region_layout1.pRegionName = NULL;
  210.     }
  211.     if (region_layout2.pRegionName != NULL)
  212.     {
  213.         jdd_MemFree(region_layout2.pRegionName);
  214.         region_layout2.pRegionName = NULL;
  215.     }
  216.     return err_code;
  217. }
  218. /*****************************************************************************
  219.  * FUNCTION
  220.  *  mmi_jmms_get_region_list
  221.  * DESCRIPTION
  222.  *  get smil region list.
  223.  * PARAMETERS
  224.  *  page_index          [IN]        
  225.  *  isImageFirst        [?]         [?]
  226.  * RETURNS
  227.  *  void
  228.  *****************************************************************************/
  229. JMMS_COMP_ERRCODE mmi_jmms_get_region_list(U8 page_index, U8 *isImageFirst)
  230. {
  231.     /*----------------------------------------------------------------*/
  232.     /* Local Variables                                                */
  233.     /*----------------------------------------------------------------*/
  234.     JC_RETCODE ret_code = JC_OK;
  235.     S8 temp_string[25] = {0, };
  236.     /* JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK; */
  237.     REGION_LAYOUT *region_layout1;
  238.     /*----------------------------------------------------------------*/
  239.     /* Code Body                                                      */
  240.     /*----------------------------------------------------------------*/
  241.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_get_region_list"));
  242.     ret_code = mmi_jmms_jdi_get_smil_region_layout(g_jmms_context->msg_handle, &region_layout1);
  243.     //      if(ret_code == JC_OK)
  244.     //              ret_code = mmi_jmms_jdi_get_smil_region_layout(g_jmms_context->msg_handle,&region_layout2);
  245.     if (ret_code == JC_OK)
  246.     {
  247.         AnsiiToUnicodeString((PS8)(temp_string), (PS8) (STRING_IMAGE));
  248.         if (pfnUnicodeStrcmp((S8*) region_layout1->pRegionName, (S8*) temp_string) == 0)
  249.         {
  250.             *isImageFirst = 1;
  251.         }
  252.         else
  253.         {
  254.             *isImageFirst = 0;
  255.         }
  256.     }
  257.     else
  258.     {
  259.         *isImageFirst = 0;
  260.     }
  261.     /* err_code = mmi_jmms_compose_handle_error(ret_code, 0); */
  262.     return JMMS_COMP_OK;
  263. }
  264. /* PMT VIKAS START 20060405 */
  265. //#ifdef __MMI_MMS_SIGNATURE__
  266. /*****************************************************************************
  267.  * FUNCTION
  268.  *  mmi_jmms_insert_auto_signature
  269.  * DESCRIPTION
  270.  *  insert the auto signature slide
  271.  * PARAMETERS
  272.  *  void
  273.  *  a(?)        [IN/OUT]        Nil(?)
  274.  *  b(?)        [IN]            Nil(?)
  275.  * RETURNS
  276.  *  JMMS_COMP_ERRCODE.(?)(?)
  277.  *****************************************************************************/
  278. void mmi_jmms_insert_auto_signature(void)
  279. {
  280.     /*----------------------------------------------------------------*/
  281.     /* Local Variables                                                */
  282.     /*----------------------------------------------------------------*/
  283.     U8 page_count;
  284.     /*----------------------------------------------------------------*/
  285.     /* Code Body                                                      */
  286.     /*----------------------------------------------------------------*/
  287.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_insert_auto_signature"));
  288.     if (mmi_jmms_compose_settings_auto_sign_status() == E_ON &&
  289.         ((g_jmms_context->store_context->current_folder_name == E_JMMS_INBOX &&
  290.           mmi_jmms_is_fw_from_inbox() == MMI_FALSE) ||
  291.          g_jmms_context->store_context->current_folder_name == E_JMMS_SENT ||
  292.          g_jmms_context->store_context->current_folder_name == E_JMMS_WRITE_MMS ||
  293.          g_jmms_context->store_context->current_folder_name == E_JMMS_TEMPLATES ||
  294.          g_jmms_context->store_context->current_folder_name == E_JMMS_DRAFTS))
  295.     {
  296.         mmi_jmms_jdi_get_total_pages(g_jmms_context->msg_handle, &page_count);
  297.         if (page_count < mmi_jmms_compose_settings_max_no_pages())
  298.         {
  299.             mmi_jmms_insert_auto_signature_slide(page_count);
  300.         }
  301.         else
  302.         {
  303.             DisplayPopup(
  304.                 (U8*) GetString(STR_ID_AUTO_SIGNATURE_ERROR_TOO_MANY_SLIDES),
  305.                 IMG_GLOBAL_WARNING,
  306.                 1,
  307.                 JMMS_POPUP_TIME,
  308.                 (U8) WARNING_TONE);
  309.         }
  310.     }
  311. }
  312. /*****************************************************************************
  313.  * FUNCTION
  314.  *  mmi_jmms_compose_auto_signature_mms
  315.  * DESCRIPTION
  316.  *  function of writing a new signature MMS
  317.  * PARAMETERS
  318.  *  void
  319.  *  a(?)        [IN/OUT]        Nil(?)
  320.  *  b(?)        [IN]            Nil(?)
  321.  * RETURNS
  322.  *  void
  323.  *****************************************************************************/
  324. JMMS_COMP_ERRCODE mmi_jmms_compose_auto_signature_mms(void)
  325. {
  326.     /*----------------------------------------------------------------*/
  327.     /* Local Variables                                                */
  328.     /*----------------------------------------------------------------*/
  329.     /* Deepali: use setting API's */
  330.     JC_RETCODE ret_code = JC_OK;
  331.     JMMS_COMP_ERRCODE err_code;
  332.     /*----------------------------------------------------------------*/
  333.     /* Code Body                                                      */
  334.     /*----------------------------------------------------------------*/
  335.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_compose_auto_signature_mms"));
  336.     ret_code = mmi_jmms_jdi_set_content_class(g_jmms_context->msg_handle, MMS_SUPPORTED_CONTENT_CLASS);
  337.     if (ret_code == JC_OK)
  338.     {
  339.         ret_code = mmi_jmms_jdi_set_creation_mode(g_jmms_context->msg_handle, mmi_jmms_compose_settings_creation_mode());
  340.     }
  341.     if (ret_code == JC_OK)
  342.     {
  343.         ret_code = mmi_jmms_jdi_set_msg_type(g_jmms_context->msg_handle, E_TYPE_MMS);
  344.     }
  345.     if (ret_code == JC_OK)
  346.     {
  347.         ret_code = mmi_jmms_jdi_set_presentation_type(g_jmms_context->msg_handle, E_PRESENTATION_SMIL);
  348.     }
  349.     if (ret_code == JC_OK)
  350.     {
  351.         ret_code = mmi_jmms_jdi_set_max_pages(g_jmms_context->msg_handle, (U8) mmi_jmms_compose_settings_max_no_pages());
  352.     }
  353.     if (ret_code == JC_OK)
  354.     {
  355.         ret_code = mmi_jmms_jdi_msg_register_callback(
  356.                     g_jmms_context->msg_handle,
  357.                     E_CB_ERROR_IND,
  358.                     (void*)mmi_jmms_error_ind_cb);
  359.     }
  360.     err_code = mmi_jmms_compose_handle_error(ret_code, 0);
  361.     return err_code;
  362. }
  363. /*****************************************************************************
  364.  * FUNCTION
  365.  *  mmi_jmms_insert_auto_signature_slide
  366.  * DESCRIPTION
  367.  *  insert the auto signature slide
  368.  * PARAMETERS
  369.  *  page_count      [IN]        
  370.  *  a(?)        [IN/OUT]        Nil(?)
  371.  *  b(?)        [IN]            Nil(?)
  372.  * RETURNS
  373.  *  JMMS_COMP_ERRCODE.
  374.  *****************************************************************************/
  375. JMMS_COMP_ERRCODE mmi_jmms_insert_auto_signature_slide(U8 page_count)
  376. {
  377.     /*----------------------------------------------------------------*/
  378.     /* Local Variables                                                */
  379.     /*----------------------------------------------------------------*/
  380.     JC_RETCODE ret_code = JC_OK;
  381. U8 *orig_edit_content_buffer;
  382.     JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK;
  383.     stFontAttribute text_font;
  384.     MMI_BOOL context_to_free = MMI_FALSE;
  385.     /*----------------------------------------------------------------*/
  386.     /* Code Body                                                      */
  387.     /*----------------------------------------------------------------*/
  388.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_insert_auto_signature_slide"));
  389.     text_font.italic = 0;
  390.     text_font.bold = 0;
  391.     text_font.size = MEDIUM_FONT;
  392.     if (g_jmms_context->compose_context == NULL)
  393.     {
  394.         context_to_free = MMI_TRUE;
  395.         g_jmms_context->compose_context =
  396.             (jmms_compose_context_struct*) jdd_MemAlloc(sizeof(jmms_compose_context_struct), 1);
  397.         if (g_jmms_context->compose_context == NULL)
  398.         {
  399.             DisplayPopup((PU8) GetString(STR_ID_JMMS_OUT_OF_MEMORY), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);
  400.             return err_code;
  401.         }
  402.     }
  403. orig_edit_content_buffer = 
  404. (U8 *) jdd_MemAlloc(sizeof(U8), (JMMS_COMPOSE_TEXT_LENGTH + 1) * ENCODING_LENGTH);
  405. memcpy(
  406. orig_edit_content_buffer,
  407.         g_jmms_context->compose_context->curr_slide_info.edit_content_buffer,
  408.         (JMMS_COMPOSE_TEXT_LENGTH + 1) * ENCODING_LENGTH);
  409.     if (page_count == 0)
  410.     {
  411.         if (JMMS_COMP_OK == mmi_jmms_compose_auto_signature_mms())
  412.         {
  413.             g_jmms_context->compose_context->mms_bg_color = g_jmms_color_RGB_list[COLOR_WHITE];
  414.             /* PMT HIMANSHU START 20060425 */
  415.             /* Added by Deepali for root layout. */
  416.             err_code = mmi_jmms_set_bg_color(g_jmms_context->compose_context->mms_bg_color);
  417.             if ((err_code == JMMS_COMP_OUT_MEMORY) || (err_code == JMMS_COMP_FAIL))
  418.             {
  419.                 mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
  420.                 return JMMS_COMP_OUT_MEMORY;
  421.             }
  422.             /* PMT HIMANSHU END 20060425 */
  423.             ret_code = mmi_jmms_jdi_add_page(g_jmms_context->msg_handle, (U8) (page_count + 1));        /* mmi_jmms_compose_insert_slide(); */
  424.             err_code = mmi_jmms_compose_handle_error(ret_code, 1);
  425.             if ((err_code == JMMS_COMP_OUT_MEMORY) || (err_code == JMMS_COMP_FAIL))
  426.             {
  427.                 mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
  428.                 return JMMS_COMP_OUT_MEMORY;
  429.             }
  430.             else
  431.             {
  432.                 /* Added By RAJ KUMAR GUPTA on Augest 26, 2006 */
  433.                 /* Changes are made to add the default slide time with Signature slide */
  434.                 U32 slide_time = 0;
  435.                 g_jmms_context->compose_context->curr_page_index = page_count + 1;
  436.                 mmi_jmms_compose_fill_default_values_slide_settings();
  437.                 slide_time = mmi_jmms_compose_settings_default_slide_time();
  438.                 err_code = mmi_jmms_save_page_time(slide_time);
  439.                 if (err_code == JMMS_COMP_OK)
  440.                 {
  441.                     g_jmms_context->compose_context->curr_slide_info.slide_prop.slide_time = slide_time;
  442.                 }
  443.                 g_jmms_context->auto_signature_added = MMI_TRUE;
  444.                 pfnUnicodeStrcpy(
  445.                     (S8*) g_jmms_context->compose_context->curr_slide_info.edit_content_buffer,
  446.                     (S8*) g_jmms_context->nvram_compose_settings.auto_signature_content);
  447.                 g_jmms_context->disable_warning_popup = 1;
  448.                 mmi_jmms_compose_add_text((U8) (page_count + 1), &(text_font), g_jmms_color_RGB_list[COLOR_BLACK],0);
  449.                 g_jmms_context->disable_warning_popup = 0;
  450.             }
  451.         }
  452.     }
  453.     else
  454.     {
  455.         ret_code = mmi_jmms_jdi_add_page(g_jmms_context->msg_handle, (U8) (page_count + 1));
  456.         err_code = mmi_jmms_compose_handle_error(ret_code, 1);
  457.         if ((err_code == JMMS_COMP_OUT_MEMORY) || (err_code == JMMS_COMP_FAIL))
  458.         {
  459.             mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
  460.             return JMMS_COMP_OUT_MEMORY;
  461.         }
  462.         else
  463.         {
  464.             /* Added By RAJ KUMAR GUPTA on Augest 26, 2006 */
  465.             /* Changes are made to add the default slide time with Signature slide */
  466.             U32 slide_time = 0;
  467.             g_jmms_context->compose_context->curr_page_index = page_count + 1;
  468.             mmi_jmms_compose_fill_default_values_slide_settings();
  469.             slide_time = mmi_jmms_compose_settings_default_slide_time();
  470.             err_code = mmi_jmms_save_page_time(slide_time);
  471.             if (err_code == JMMS_COMP_OK)
  472.             {
  473.                 g_jmms_context->compose_context->curr_slide_info.slide_prop.slide_time = slide_time;
  474.             }
  475.             g_jmms_context->auto_signature_added = MMI_TRUE;
  476.             pfnUnicodeStrcpy(
  477.                 (S8*) g_jmms_context->compose_context->curr_slide_info.edit_content_buffer,
  478.                 (S8*) g_jmms_context->nvram_compose_settings.auto_signature_content);
  479.             g_jmms_context->disable_warning_popup = 1;
  480.             mmi_jmms_compose_add_text((U8) (page_count + 1), &(text_font), g_jmms_color_RGB_list[COLOR_BLACK],0);
  481.             g_jmms_context->disable_warning_popup = 0;
  482.         }
  483.     }
  484. memcpy(
  485.     g_jmms_context->compose_context->curr_slide_info.edit_content_buffer,
  486. orig_edit_content_buffer,
  487.             (JMMS_COMPOSE_TEXT_LENGTH + 1) * ENCODING_LENGTH);
  488. jdd_MemFree(orig_edit_content_buffer);
  489.     if (context_to_free == MMI_TRUE)
  490.     {
  491.         context_to_free = MMI_FALSE;
  492.         if (g_jmms_context->compose_context != NULL)
  493.         {
  494.             jdd_MemFree(g_jmms_context->compose_context);
  495.             g_jmms_context->compose_context = NULL;
  496.         }
  497.     }
  498.     return err_code;
  499. }
  500. /*****************************************************************************
  501.  * FUNCTION
  502.  *  mmi_jmms_del_inserted_auto_signature_slide
  503.  * DESCRIPTION
  504.  *  delete the auto signature slide
  505.  * PARAMETERS
  506.  *  void
  507.  *  a(?)        [IN/OUT]        Nil(?)
  508.  *  b(?)        [IN]            Nil(?)
  509.  * RETURNS
  510.  *  JMMS_COMP_ERRCODE.
  511.  *****************************************************************************/
  512. JMMS_COMP_ERRCODE mmi_jmms_del_inserted_auto_signature_slide(void)
  513. {
  514.     /*----------------------------------------------------------------*/
  515.     /* Local Variables                                                */
  516.     /*----------------------------------------------------------------*/
  517.     MEDIA_INFO *media_info_p;
  518.     U8 media_count, page_count = 0;
  519.     JMMS_COMP_ERRCODE err_code = JC_OK;
  520.     MMI_BOOL is_sig_existed = E_FALSE;
  521.     /*----------------------------------------------------------------*/
  522.     /* Code Body                                                      */
  523.     /*----------------------------------------------------------------*/
  524.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_del_inserted_auto_signature_slide"));
  525.     if (mmi_jmms_compose_settings_auto_sign_status() == E_ON && g_jmms_context->auto_signature_added == MMI_TRUE &&
  526.         ((g_jmms_context->store_context->current_folder_name == E_JMMS_INBOX &&
  527.           mmi_jmms_is_fw_from_inbox() == MMI_FALSE) ||
  528.          g_jmms_context->store_context->current_folder_name == E_JMMS_WRITE_MMS ||
  529.          g_jmms_context->store_context->current_folder_name == E_JMMS_TEMPLATES ||
  530.          g_jmms_context->store_context->current_folder_name == E_JMMS_DRAFTS))
  531.     {
  532.         /* Check that any slide exists */
  533.         mmi_jmms_jdi_get_total_pages(g_jmms_context->msg_handle, &page_count);
  534.         if (page_count != 0)
  535.         {
  536.             /* Check if the last slide is signature */
  537.             err_code = mmi_jmms_compose_get_media_list(page_count, &media_info_p, &media_count, MMI_FALSE);
  538.             if (media_count == 1 && media_info_p->eMediaType == E_MEDIA_TEXT)
  539.             {
  540.                 if (pfnUnicodeStrcmp
  541.                     ((S8*) (UI_character_type*) media_info_p->pMimeInfo->ContentData.pBuffer,
  542.                      (S8*) g_jmms_context->nvram_compose_settings.auto_signature_content) == 0)
  543.                 {
  544.                     is_sig_existed = TRUE;
  545.                 }
  546.             }
  547.             /* Delete signature slide */
  548.             if (is_sig_existed)
  549.             {
  550.                 /* Free all data in the slide */
  551.                 mmi_jmms_compose_delete_page(page_count);
  552. /* g_jmms_context->compose_context will be NULL in case of Drafts->Option->Send */
  553. if(g_jmms_context->compose_context)
  554. {
  555.                 g_jmms_context->compose_context->curr_page_index--;
  556.             }
  557.         }
  558.         }
  559.         g_jmms_context->auto_signature_added = MMI_FALSE;
  560.     }
  561.     return err_code;
  562. }
  563. //#endif /* __MMI_MMS_SIGNATURE__ */ 
  564. //PMT VIKAS END 20060405
  565. //PMT VIKAS START 20060403
  566. /*****************************************************************************
  567.  * FUNCTION
  568.  *  mmi_jmms_get_mms_media_type_from_file
  569.  * DESCRIPTION
  570.  *  returns the content type of media file.
  571.  * PARAMETERS
  572.  *  file_name_p     [?]     [?]
  573.  *  a(?)            [IN/OUT]        Nil(?)
  574.  *  b(?)            [IN]            Nil(?)
  575.  * RETURNS
  576.  *  media_type_enum.
  577.  *****************************************************************************/
  578. media_type_enum mmi_jmms_get_mms_media_type_from_file(JC_CHAR *file_name_p)
  579. {
  580.     /*----------------------------------------------------------------*/
  581.     /* Local Variables                                                */
  582.     /*----------------------------------------------------------------*/
  583.     media_type_enum media_type_p = MEDIA_OTHER;
  584.     U8 i;
  585.     JC_CHAR *temp_file_name = NULL;
  586.     S8 media_string_ansi[5][10] = { "text", "image", "audio", "video", 0};
  587.     applib_mime_type_struct *mime_info = NULL;
  588.     /*----------------------------------------------------------------*/
  589.     /* Code Body                                                      */
  590.     /*----------------------------------------------------------------*/
  591.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_get_mms_media_type_from_file"));
  592.     if (file_name_p)
  593.     {
  594.         U32 iIndex = 0;
  595.         iIndex = jdi_UtilsLastIndexOfTchar('.', file_name_p, jc_tcslen(file_name_p) - 1);
  596.         if (iIndex > 0 && jc_tcslen(file_name_p) != (U32) iIndex)
  597.         {
  598.             U16 uhCounter = 0;
  599.             iIndex++;
  600.             temp_file_name =
  601.                 (JC_CHAR*) jdd_MemAlloc(pfnUnicodeStrlen((S8*) file_name_p) * ENCODING_LENGTH + ENCODING_LENGTH, 1);
  602.             if (temp_file_name == NULL)
  603.             {
  604.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "OUT OF MEMORY in file name generation"));
  605.                 DisplayPopup(
  606.                     (PU8) GetString(STR_ID_JMMS_OUT_OF_MEMORY),
  607.                     IMG_GLOBAL_ERROR,
  608.                     1,
  609.                     JMMS_POPUP_TIME,
  610.                     ERROR_TONE);
  611.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "media Type = %d", media_type_p));
  612.                 return media_type_p;
  613.             }
  614.             pfnUnicodeStrcpy((S8*) temp_file_name, (S8*) file_name_p);
  615.             temp_file_name = jdi_UtilsTcsUpperToLower((JC_CHAR*) temp_file_name);
  616.             while (*(g_content_type_list[uhCounter][0]) != 0)
  617.             {
  618.                 if (jdi_UtilsTcsStrCmp(temp_file_name + iIndex, g_content_type_list[uhCounter][1]) == 0)
  619.                 {
  620.                     for (i = 0; i < MEDIA_OTHER; i++)
  621.                     {
  622.                         if (strncmp
  623.                             (media_string_ansi[i], g_content_type_list[uhCounter][0],
  624.                              strlen((PS8) media_string_ansi[i])) == 0)
  625.                         {
  626.                             media_type_p = i;
  627.                             if (temp_file_name != NULL)
  628.                             {
  629.                                 jdd_MemFree(temp_file_name);
  630.                                 temp_file_name = NULL;
  631.                             }
  632.                             PRINT_INFORMATION_2((MMI_TRACE_INFO, "media Type = %d", media_type_p));
  633.                             return media_type_p;
  634.                         }
  635.                     }
  636.                 }
  637.                 uhCounter++;
  638.             }
  639.         }
  640.     }
  641.     if (temp_file_name != NULL)
  642.     {
  643.         jdd_MemFree(temp_file_name);
  644.         temp_file_name = NULL;
  645.     }
  646.     if (mime_get_extension(file_name_p) != NULL)
  647.     {
  648.         mime_info = mime_get_file_type(file_name_p);
  649.     }
  650.     if (mime_info != NULL)
  651.     {
  652.         switch (mime_info->mime_type)
  653.         {
  654.         case MIME_TYPE_IMAGE:
  655. #if defined(SVG_SUPPORT)
  656. if(mime_info->mime_subtype == MIME_SUBTYPE_SVG)
  657. {
  658. media_type_p = MEDIA_OTHER;
  659. }
  660. else
  661. #endif
  662.             media_type_p = MEDIA_IMAGE;
  663.             break;
  664.         case MIME_TYPE_AUDIO:
  665.             media_type_p = MEDIA_AUDIO;
  666.             break;
  667.         case MIME_TYPE_VIDEO:
  668.             media_type_p = MEDIA_VIDEO;
  669.             break;
  670.         case MIME_TYPE_TEXT:
  671.             media_type_p = MEDIA_TEXT;
  672.             break;
  673.         }
  674.     }
  675.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "media Type = %d", media_type_p));
  676.     return media_type_p;
  677. }
  678. /*Dilip Start 14th sept for slide time issue*/
  679. /*****************************************************************************
  680.  * FUNCTION
  681.  *  mmi_jmms_save_post_entry_edit_content_slide_timing
  682.  * DESCRIPTION
  683.  *  fn check the slide timings after user return from Media timing setting and try to reduce slide time.
  684.  *  We are setting as custom if media start time is made greater than equal to slide time and maximum is set for that media
  685.  * PARAMETERS
  686.  *  void
  687.  *  a(?)        [IN/OUT]        Nil(?)
  688.  *  b(?)        [IN]            Nil(?)
  689.  * RETURNS
  690.  *  void
  691.  *****************************************************************************/
  692. JMMS_COMP_ERRCODE mmi_jmms_save_post_entry_edit_content_slide_timing(U32 slide_time)
  693. {
  694.     /*----------------------------------------------------------------*/
  695.     /* Local Variables                                                */
  696.     /*----------------------------------------------------------------*/
  697.     JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK;
  698.     
  699.     U32 start_time_text,start_time_image,start_time_audio,start_time_video;
  700.     U32 text_duration,image_duration,audio_duration,video_duration;
  701.     
  702.     /*----------------------------------------------------------------*/
  703.     /* Code Body                                                      */
  704.     /*----------------------------------------------------------------*/
  705. if(slide_time==0)
  706. return err_code;
  707.     
  708.     if(g_jmms_context->compose_context->curr_slide_info.text_ID > 0)
  709.     {
  710.         err_code = mmi_jmms_get_media_time(
  711.                 &start_time_text,
  712.                 &text_duration,
  713.                 g_jmms_context->compose_context->curr_slide_info.text_ID,
  714.                 g_jmms_context->compose_context->curr_page_index);
  715.         if(err_code == JMMS_COMP_OK)
  716.         {
  717.             if(start_time_text >= slide_time)
  718.             {
  719.                 return -1;
  720.             }
  721.         }
  722.           
  723.     }
  724.     
  725.     if(g_jmms_context->compose_context->curr_slide_info.image_ID > 0)
  726.     {
  727.         err_code = mmi_jmms_get_media_time(
  728.                 &start_time_image,
  729.                 &image_duration,
  730.                 g_jmms_context->compose_context->curr_slide_info.image_ID,
  731.                 g_jmms_context->compose_context->curr_page_index);
  732.         if(err_code == JMMS_COMP_OK)
  733.         {
  734.             if(start_time_image >= slide_time)
  735.             {
  736.                 return -1;
  737.             }
  738.         }
  739.     }
  740.     
  741.     if(g_jmms_context->compose_context->curr_slide_info.audio_ID > 0)
  742.     {
  743.         err_code = mmi_jmms_get_media_time(
  744.                 &start_time_audio,
  745.                 &audio_duration,
  746.                 g_jmms_context->compose_context->curr_slide_info.audio_ID,
  747.                 g_jmms_context->compose_context->curr_page_index);
  748.         if(err_code == JMMS_COMP_OK)
  749.         {
  750.             if(start_time_audio >= slide_time)
  751.             {
  752.                 return -1;
  753.             }
  754.             
  755.         }
  756.     }
  757.     
  758.     if(g_jmms_context->compose_context->curr_slide_info.video_ID > 0)
  759.     {
  760.         err_code = mmi_jmms_get_media_time(
  761.                 &start_time_video,
  762.                 &video_duration,
  763.                 g_jmms_context->compose_context->curr_slide_info.video_ID,
  764.                 g_jmms_context->compose_context->curr_page_index);
  765.         if(err_code == JMMS_COMP_OK)
  766.         {
  767.             if(start_time_video >= slide_time)
  768.             {
  769.                 return -1;
  770.             }
  771.         }
  772.     }
  773.     return err_code;
  774. }
  775. /*****************************************************************************
  776.  * FUNCTION
  777.  *  mmi_jmms_create_mms_for_file
  778.  * DESCRIPTION
  779.  *  Checks whether file need to be added as DRM fwd-lock
  780.  * PARAMETERS
  781.  *  content_source      [?]     [?]
  782.  *  a(?)                [IN/OUT]        Nil(?)
  783.  *  b(?)                [IN]            JC_CHAR*(?)
  784.  * RETURNS
  785.  *  void
  786.  *****************************************************************************/ 
  787. static U8 g_media_type;
  788. static JC_CHAR *g_content_file_name;
  789. void mmi_jmms_create_mms_for_file(JC_CHAR *content_source)
  790. {
  791.     /*----------------------------------------------------------------*/
  792.     /* Local Variables                                                */
  793.     /*----------------------------------------------------------------*/
  794.     U8 media_type = 0;
  795.     JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK;
  796. #ifdef __MMI_VIDEO_PLAYER__
  797.     MDI_RESULT result_video = 0;
  798. #endif 
  799.     MMI_BOOL result_media = MMI_TRUE;
  800.     GDI_RESULT image_result;
  801.     S32 audio_result = 0;
  802.     S32 img_widthv = 0, img_heightv = 0, audio_du;
  803.     /* HIMANSHU 05122006 START */
  804.     JC_CHAR *content_file_name = content_source;
  805. #ifdef __MMI_MMS_MEGA_PIXEL_SUPPORT__
  806.     JC_CHAR *dest_fname = NULL;
  807.     U32 resize_result = 0;
  808. #endif /* __MMI_MMS_MEGA_PIXEL_SUPPORT__ */ 
  809.     /* HIMANSHU 05122006 END */
  810. #ifdef __DRM_SUPPORT__
  811.     JC_BOOLEAN is_separate_DRM = E_FALSE;
  812. #endif
  813.     U32 media_size = 0;
  814.     /*----------------------------------------------------------------*/
  815.     /* Code Body                                                      */
  816.     /*----------------------------------------------------------------*/
  817.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_create_mms_for_file"));
  818.     mmi_jmms_reset_fw_flag_of_message();
  819.         is_add_media_as_drm = MMI_FALSE;
  820. if(g_jmms_context->init_done == JMMS_READY_WITHOUT_STORE)
  821. {
  822.         DisplayPopup((U8*) GetString(STR_ID_JMMS_MEMORY_FULL), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, (U8) ERROR_TONE);
  823. PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Store is not ready"));
  824.         return;
  825. }
  826.     mmi_jmms_init_msg_context_struct(); /* this will different for different ways */
  827.     if (g_jmms_context->compose_context == NULL)
  828.     {
  829.         g_jmms_context->compose_context =
  830.             (jmms_compose_context_struct*) jdd_MemAlloc(sizeof(jmms_compose_context_struct), 1);
  831.         if (g_jmms_context->compose_context == NULL)
  832.         {
  833.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "OUT OF MEMORY: Fail to create compose Context"));
  834.             DisplayPopup((PU8) GetString(STR_ID_JMMS_OUT_OF_MEMORY), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);
  835.             goto error;
  836.         }
  837.     }
  838.     media_type = mmi_jmms_get_mms_media_type_from_file(content_file_name);
  839. #ifdef __DRM_SUPPORT__
  840.     if ((is_separate_DRM = jMMS_is_sep_delivery_content((JC_CHAR*) content_file_name)) == E_FALSE)
  841. #endif 
  842.     {
  843. #ifdef __MMI_VIDEO_PLAYER__
  844.         if(media_type == MEDIA_VIDEO)
  845.         {
  846.             result_video = mmi_jdd_videoapp_get_video_file_size_info((S8*) content_file_name, (JC_UINT32*)&img_widthv, (JC_UINT32*)&img_heightv);
  847.             if(result_video == MDI_RES_VDOPLY_ERR_OPEN_FILE_FAILED)
  848.             {
  849.     result_media = MMI_FALSE;
  850.             }
  851.         }
  852. #endif
  853.     if(media_type == MEDIA_IMAGE)
  854.     {
  855.     image_result = gdi_image_get_dimension_file((S8*) content_file_name, &img_widthv, &img_heightv);
  856.     if(image_result != GDI_SUCCEED || (img_widthv * img_heightv) == 0)
  857.     {
  858.     result_media = MMI_FALSE;
  859.     }
  860.     }
  861.         if (media_type == MEDIA_AUDIO)
  862.         {
  863.     audio_result = mdi_audio_get_duration((S8*) content_source,(U32*) &audio_du);  // compiler warning removal
  864.             if (audio_result != GDI_SUCCEED)
  865.             {
  866.                 result_media = MMI_FALSE;
  867.             }
  868.         }
  869.         if (result_media == MMI_FALSE)
  870.         {
  871.             DisplayPopup((PU8) GetString(STR_ID_JMMS_CORRUPTED_MEDIA_FILE), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);
  872.             goto error;
  873.         }
  874.     }
  875.     if ((media_type == MEDIA_VIDEO || media_type == MEDIA_AUDIO) && mmi_jmms_selected_media_valid_size_check_for_mms((S8*) content_file_name, MMI_FALSE, &media_size, E_FALSE) != E_TRUE)
  876.     {
  877.         goto error;
  878.     }
  879.     else if ((media_type == MEDIA_IMAGE) && mmi_jmms_selected_media_valid_size_check_for_mms((S8*) content_file_name, MMI_FALSE, &media_size, E_TRUE) != E_TRUE)
  880.     {
  881.         goto error;
  882.     }
  883.     /* Himanshu Fix PMTSW00006527 START */
  884.     if ((media_type == MEDIA_IMAGE) && (mmi_jmms_check_for_image_size_and_resolution((S8*)content_file_name, img_widthv, img_heightv, media_size) != E_TRUE))
  885.     {
  886.         goto error;
  887.     }
  888.     /* Himanshu Fix PMTSW00006527 END */
  889.     /* HIMANSHU 05122006 START */
  890. #ifdef __MMI_MMS_MEGA_PIXEL_SUPPORT__
  891. #ifdef __DRM_SUPPORT__
  892.     if ((is_separate_DRM == E_FALSE) && (media_type == MEDIA_IMAGE))
  893. #else
  894.     if (media_type == MEDIA_IMAGE)
  895. #endif
  896.     {
  897.         /* Check if image resizing needs to be done. */
  898.         resize_result = check_for_image_resize(content_file_name, &dest_fname);
  899.         if (resize_result == JMMS_IMAGE_RESIZE_SUCCEED)
  900.         {
  901.             content_file_name = dest_fname;
  902.         }
  903.         else if (resize_result == JMMS_IMAGE_RESIZE_UNCHANGED)
  904.         {
  905.             /* content_file_name = content_source; */
  906.         }
  907.         else
  908.         {
  909.             goto error;
  910.         }
  911.     }
  912. #endif /* __MMI_MMS_MEGA_PIXEL_SUPPORT__ */ 
  913.     /* HIMANSHU 05122006 END */
  914.     g_media_type = media_type;
  915.     g_content_file_name = jdi_UtilsTcsDup(content_file_name);
  916.     if (g_content_file_name == NULL)
  917.     {
  918.         PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "OUT OF MEMORY: Fail to create compose Context"));
  919.         DisplayPopup((PU8) GetString(STR_ID_JMMS_OUT_OF_MEMORY), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);
  920.         goto error;
  921.     }
  922. #ifdef __DRM_SUPPORT__
  923.     if (mmi_jmms_is_compose_add_as_drm(content_source) && !jMMS_is_sep_delivery_content(content_source))
  924.     {
  925.         mmi_jmms_confirm_add_drm_media(mmi_jmms_fm_fwd_file_to_mms);
  926.         goto error;
  927.     }
  928.     else
  929. #endif
  930.     {
  931.         mmi_jmms_fm_fwd_file_to_mms();
  932.     }
  933.   error:
  934.     /* HIMANSHU 05122006 START */
  935. #ifdef __MMI_MMS_MEGA_PIXEL_SUPPORT__
  936.     if (dest_fname != NULL)
  937.     {
  938.         jdd_MemFree(dest_fname);
  939.         dest_fname = NULL;
  940.     }
  941.     DeleteScreenIfPresent(SCR_ID_JMMS_IMAGE_RESIZE_TRANSITION);
  942. #endif /* __MMI_MMS_MEGA_PIXEL_SUPPORT__ */ 
  943.     /* HIMANSHU 05122006 END */
  944. return;
  945. }
  946. /*****************************************************************************
  947.  * FUNCTION
  948.  *  mmi_jmms_fm_fwd_file_to_mms
  949.  * DESCRIPTION
  950.  *  Add the file content to MMS according to their Media type.
  951.  * PARAMETERS
  952.  *  void
  953.  * RETURNS
  954.  *  void
  955.  *****************************************************************************/
  956. void mmi_jmms_fm_fwd_file_to_mms(void)
  957. {
  958.     JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK;
  959.     ClearAllKeyHandler();
  960.     g_jmms_context->g_use_local_send_setings = 0;
  961. mmi_jmms_fill_mms_sending_settings();
  962.     g_jmms_context->store_context->current_folder_name = E_JMMS_WRITE_MMS;
  963.     g_jmms_context->compose_context->curr_page_index = 0;
  964.     if (JMMS_COMP_OK == mmi_jmms_compose_new_mms())
  965.     {
  966.         g_jmms_context->compose_context->mms_bg_color = g_jmms_color_RGB_list[COLOR_WHITE];
  967.         err_code = mmi_jmms_set_bg_color(g_jmms_context->compose_context->mms_bg_color);
  968.         err_code = mmi_jmms_compose_insert_slide();
  969.         if ((err_code == JMMS_COMP_OUT_MEMORY) || (err_code == JMMS_COMP_FAIL))
  970.         {
  971.             mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
  972.             jdd_MemFree(g_content_file_name);
  973.             g_content_file_name = NULL;
  974.             return;
  975.         }
  976.         else
  977.         {
  978.             switch (g_media_type)
  979.             {
  980.                 case MEDIA_IMAGE:
  981.                     err_code = mmi_jmms_compose_add_media(
  982.                                 g_content_file_name,
  983.                                 E_MEDIA_IMAGE,
  984.                                 0,
  985.                                 g_jmms_context->compose_context->curr_page_index);
  986.                     break;
  987.                 case MEDIA_AUDIO:
  988.                     err_code = mmi_jmms_compose_add_media(
  989.                                 g_content_file_name,
  990.                                 E_MEDIA_AUDIO,
  991.                                 0,
  992.                                 g_jmms_context->compose_context->curr_page_index);
  993.                     break;
  994.                 case MEDIA_VIDEO:
  995.                     err_code = mmi_jmms_compose_add_media(
  996.                                 g_content_file_name,
  997.                                 E_MEDIA_VIDEO,
  998.                                 0,
  999.                                 g_jmms_context->compose_context->curr_page_index);
  1000.                     break;
  1001.                 case MEDIA_OTHER:
  1002.                 default:
  1003.                     err_code = mmi_jmms_compose_add_media(g_content_file_name, E_MEDIA_OTHERS, E_TRUE, 0);
  1004.                     mmi_jmms_compose_delete_page(g_jmms_context->compose_context->curr_page_index);
  1005.                     g_jmms_context->compose_context->curr_page_index--;
  1006.                     break;
  1007.             }
  1008.         }
  1009.     }
  1010.     if (err_code == JMMS_COMP_OK || err_code == JMMS_COMP_POPUP_OK)
  1011.     {
  1012.         /*Dilip start  26 aug 06 to overcome 200KB size file acting restricted mode media instead of warning mode*/
  1013.         if (g_media_type == E_MEDIA_IMAGE || g_media_type == E_MEDIA_VIDEO)
  1014.         {
  1015.             /*Dilip end 26 aug 06 to overcome 200KB size file acting restricted mode media instead of warning mode*/
  1016.             g_jmms_context->compose_context->curr_slide_info.img_info.custom_img_display = 1;
  1017.             if (pfnUnicodeStrlen((S8*) g_jmms_context->compose_context->curr_slide_info.edit_content_buffer) == 0)
  1018.             {
  1019.                 g_jmms_context->compose_context->is_image_first[g_jmms_context->compose_context->curr_page_index - 1] =
  1020.                     1;
  1021.             }
  1022.             else
  1023.             {
  1024.                 g_jmms_context->compose_context->is_image_first[g_jmms_context->compose_context->curr_page_index - 1] =
  1025.                     0;
  1026.             }
  1027.         }
  1028.         g_jmms_context->g_write_mms_right_soft_key = STR_GLOBAL_DONE;
  1029.         if (err_code == JMMS_COMP_POPUP_OK)
  1030.         {
  1031.             mmi_jmms_entry_write_message_screen_in_history();
  1032.         }
  1033.         else
  1034.         {
  1035.             mmi_jmms_entry_write_message_screen();
  1036.         }
  1037.     }
  1038.     else
  1039.     {
  1040.         mmi_jmms_deinit_mms_context(g_jmms_context);
  1041.     }
  1042.     if(g_content_file_name)
  1043.     {
  1044.         jdd_MemFree(g_content_file_name);
  1045.         g_content_file_name = NULL;
  1046.     }
  1047. }
  1048. /* HIMANSHU 05122006 START */
  1049. #ifdef __MMI_MMS_MEGA_PIXEL_SUPPORT__
  1050. /*****************************************************************************
  1051.  * FUNCTION
  1052.  *  check_for_image_resize
  1053.  * DESCRIPTION
  1054.  *  If the image resizing is being set to TRUE then it calls function to resize the
  1055.  *  image.
  1056.  *  tries to resize the image.
  1057.  * PARAMETERS
  1058.  *  content_source      [IN]        
  1059.  *  dest_fname          [OUT]       
  1060.  * RETURNS
  1061.  *  JMMS_IMAGE_RESIZE_FAILED if image can't be resized
  1062.  *  JMMS_IMAGE_RESIZE_UNCHANGED if iamge original size is less than the image resize settings
  1063.  *  JMMS_IMAGE_RESIZE_SUCCEED otherwise.
  1064.  *****************************************************************************/
  1065. S16 check_for_image_resize(JC_CHAR *content_source, JC_CHAR **dest_fname)
  1066. {
  1067.     /*----------------------------------------------------------------*/
  1068.     /* Local Variables                                                */
  1069.     /*----------------------------------------------------------------*/
  1070.     U8 image_resize_option = E_IMAGE_RESIZE_OFF;
  1071.     S32 resize_width = 0;
  1072.     S32 resize_height = 0;
  1073.     JC_RETCODE ret_code = JC_OK;
  1074.     JC_CHAR *temp_file = NULL;
  1075.     S16 resize_result = JMMS_IMAGE_RESIZE_UNCHANGED;
  1076.     JDD_FSHANDLE fs_handle = NULL;
  1077.     JDD_FILE fh = NULL;
  1078.     GDI_RESULT gdi_ret = GDI_FAILED;
  1079.     S32 img_width = 0, img_height = 0;
  1080.     S8 name[40] = {0, };
  1081.     kal_uint32 unique_value = 0;
  1082.     /*----------------------------------------------------------------*/
  1083.     /* Code Body                                                      */
  1084.     /*----------------------------------------------------------------*/
  1085.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside check_for_image_resize"));
  1086.     image_resize_option = g_jmms_context->nvram_compose_settings.image_resize_option;
  1087.     if (image_resize_option != E_IMAGE_RESIZE_OFF)
  1088.     {
  1089.         switch (image_resize_option)
  1090.         {
  1091.             case E_IMAGE_RESIZE_160x120:
  1092.                 resize_width = 160;
  1093.                 resize_height = 120;
  1094.                 break;
  1095.             case E_IMAGE_RESIZE_320x240:
  1096.                 resize_width = 320;
  1097.                 resize_height = 240;
  1098.                 break;
  1099.             case E_IMAGE_RESIZE_640x480:
  1100.                 resize_width = 640;
  1101.                 resize_height = 480;
  1102.                 break;
  1103.             default:
  1104.                 ASSERT(0);
  1105.         }
  1106.         gdi_ret = gdi_image_get_dimension_file((PS8) content_source, &img_width, &img_height);
  1107.         if (img_width > resize_width || img_height > resize_height)
  1108.         {
  1109.             ret_code = jdd_FSInitialize(&fs_handle);
  1110.             if (ret_code != JC_OK)
  1111.             {
  1112.                 /* return JMMS_IMAGE_RESIZE_FAILED; */
  1113.                 resize_result = JMMS_IMAGE_RESIZE_FAILED;
  1114.                 goto END;
  1115.             }
  1116.             /* Himanshu Fix PMTSW00006574 START */
  1117.             /* Creation of @mms\temp\resize folder */
  1118.             AnsiiToUnicodeString(name, "@mms\temp\resize\");
  1119.             fh = jdd_FSOpen(fs_handle, (U16*) name, E_OPEN_READ_MODE);
  1120.             if (fh == NULL) /* Folder Does Not Exist */
  1121.             {
  1122.                 jdd_FSMakeDir(fs_handle, (U16*) name);
  1123.             }
  1124.             else
  1125.             {
  1126.                 jdd_FSClose(fh);
  1127.             }
  1128.             kal_get_time(&unique_value);
  1129.             sprintf(name, "@mms\temp\resize\img%d.%s", unique_value, "jpg");
  1130.             jdi_UtilsCharToTchar((JC_CHAR **) & (temp_file), name);
  1131.             /* Himanshu Fix PMTSW00006574 END */
  1132.             *dest_fname = (JC_CHAR*) jdd_FSFileNameTranslate(fs_handle, temp_file);
  1133.             if (*dest_fname == NULL)
  1134.             {
  1135.                 /* return JMMS_IMAGE_RESIZE_FAILED; */
  1136.                 resize_result = JMMS_IMAGE_RESIZE_FAILED;
  1137.                 goto END;
  1138.             }
  1139.             mmi_jmms_ext_display_image_animation();
  1140.             resize_result = mmi_jmms_ext_image_resizing(content_source, *dest_fname, resize_width, resize_height);
  1141.             //jdd_MemFree(temp_file);
  1142.             //jdd_FSDeinitialize(fs_handle);
  1143.             switch (resize_result)
  1144.             {
  1145.                 case JMMS_IMAGE_RESIZE_UNCHANGED:
  1146.                 case JMMS_IMAGE_RESIZE_SUCCEED:
  1147.                     ClearKeyEvents();   /* Flush all the Key Events */
  1148.                     break;
  1149.                 case JMMS_IMAGE_RESIZING_FAILED_IN_GDI_ENCODER_ERR_DISK_FULL:
  1150.                     DisplayPopup(
  1151.                         (PU8) GetString(STR_ID_JMMS_STORAGE_FULL),
  1152.                         IMG_GLOBAL_ERROR,
  1153.                         1,
  1154.                         JMMS_POPUP_TIME,
  1155.                         ERROR_TONE);
  1156.                     /* GoBackHistory(); */
  1157.                     break;
  1158.                 case JMMS_IMAGE_RESIZING_FAILED_IN_INSUFFICIENT_DRAWING_BUF:
  1159.                 case JMMS_IMAGE_RESIZING_FAILED_IN_NO_QUOTA:
  1160.                     DisplayPopup(
  1161.                         (PU8) GetString(STR_ID_JMMS_FAILED_RESOURCES_EXHAUSTED),
  1162.                         IMG_GLOBAL_ERROR,
  1163.                         1,
  1164.                         JMMS_POPUP_TIME,
  1165.                         ERROR_TONE);
  1166.                     /* GoBackHistory(); */
  1167.                     break;
  1168.                 case JMMS_IMAGE_RESIZING_FAILED_IN_UNKNOWN_DIMENSION:
  1169.                     DisplayPopup(
  1170.                         (PU8) GetString(STR_ID_JMMS_CORRUPTED_MEDIA_FILE),
  1171.                         IMG_GLOBAL_ERROR,
  1172.                         1,
  1173.                         JMMS_POPUP_TIME,
  1174.                         ERROR_TONE);
  1175.                     /* GoBackHistory(); */
  1176.                     break;
  1177.                 case JMMS_IMAGE_RESIZING_FAILED_IN_GDI_FAILED:
  1178.                 case JMMS_IMAGE_RESIZING_FAILED_IN_GDI_ENCODER_ERR_NO_DISK:
  1179.                 case JMMS_IMAGE_RESIZING_FAILED_IN_GDI_ENCODER_ERR_WRITE_PROTECTION:
  1180.                 default:
  1181.                     DisplayPopup(
  1182.                         (PU8) GetString(STR_ID_JMMS_IMAGE_RESIZE_FAILED),
  1183.                         IMG_GLOBAL_ERROR,
  1184.                         1,
  1185.                         JMMS_POPUP_TIME,
  1186.                         ERROR_TONE);
  1187.                     /* GoBackHistory(); */
  1188.                     break;
  1189.             }
  1190.         }
  1191.     }
  1192.   END:
  1193.     if (temp_file != NULL)
  1194.     {
  1195.         jdd_MemFree(temp_file);
  1196.     }
  1197.     if (fs_handle != NULL)
  1198.     {
  1199.         jdd_FSDeinitialize(fs_handle);
  1200.     }
  1201.     return resize_result;
  1202. }
  1203. /*****************************************************************************
  1204.  * FUNCTION
  1205.  *  mmi_jmms_ext_display_image_animation
  1206.  * DESCRIPTION
  1207.  *  
  1208.  * PARAMETERS
  1209.  *  void
  1210.  * RETURNS
  1211.  *  void
  1212.  *****************************************************************************/
  1213. void mmi_jmms_ext_display_image_animation(void)
  1214. {
  1215.     /*----------------------------------------------------------------*/
  1216.     /* Local Variables                                                */
  1217.     /*----------------------------------------------------------------*/
  1218.     /*----------------------------------------------------------------*/
  1219.     /* Code Body                                                      */
  1220.     /*----------------------------------------------------------------*/
  1221.     resize_animation_disable_status = RESIZE_ANIMATION_DISABLE_ON;
  1222.     mmi_jmms_display_resize_image_animation();
  1223.     resize_animation_disable_status = RESIZE_ANIMATION_DISABLE_OFF;
  1224. }
  1225. /*****************************************************************************
  1226.  * FUNCTION
  1227.  *  mmi_jmms_display_resize_image_animation
  1228.  * DESCRIPTION
  1229.  *  
  1230.  * PARAMETERS
  1231.  *  void
  1232.  * RETURNS
  1233.  *  void
  1234.  *****************************************************************************/
  1235. void mmi_jmms_display_resize_image_animation(void)
  1236. {
  1237.     /*----------------------------------------------------------------*/
  1238.     /* Local Variables                                                */
  1239.     /*----------------------------------------------------------------*/
  1240.     /*----------------------------------------------------------------*/
  1241.     /* Code Body                                                      */
  1242.     /*----------------------------------------------------------------*/
  1243.     if (IsScreenPresent(SCR_ID_JMMS_IMAGE_RESIZE_TRANSITION))
  1244.     {
  1245.         PRINT_INFORMATION_2((MMI_TRACE_INFO, " %s(%d) DisplayImageTransitionAnimation() - already existn", __FILE__, __LINE__));
  1246.         return;
  1247.     }
  1248.     PRINT_INFORMATION_2((MMI_TRACE_INFO, " %s(%d) DisplayImageTransitionAnimation()n", __FILE__, __LINE__));
  1249.     mmi_jmms_entry_resize_image_animation();
  1250. }
  1251. /*****************************************************************************
  1252.  * FUNCTION
  1253.  *  mmi_jmms_entry_resize_image_animation
  1254.  * DESCRIPTION
  1255.  *  
  1256.  * PARAMETERS
  1257.  *  void
  1258.  * RETURNS
  1259.  *  void
  1260.  *****************************************************************************/
  1261. void mmi_jmms_entry_resize_image_animation(void)
  1262. {
  1263.     /*----------------------------------------------------------------*/
  1264.     /* Local Variables                                                */
  1265.     /*----------------------------------------------------------------*/
  1266.     /*----------------------------------------------------------------*/
  1267.     /* Code Body                                                      */
  1268.     /*----------------------------------------------------------------*/
  1269.     EntryNewScreen(SCR_ID_JMMS_IMAGE_RESIZE_TRANSITION, NULL, mmi_jmms_entry_resize_image_animation, NULL);
  1270.     /* draw the blank softkey if no softkey button */
  1271.     show_softkey_background();
  1272.     ShowCategory66Screen(
  1273.         STR_MMS_MENUENTRY,
  1274.         GetRootTitleIcon(MAIN_MENU_MESSAGES_MENUID),
  1275.         0,
  1276.         0,
  1277.         0,
  1278.         0,
  1279.         (PU8) GetString(STR_ID_SETTINGS_IMAGE_RESIZE),
  1280.         SAT_WAIT_IMAGE_ID,
  1281.         0);
  1282.     ClearAllKeyHandler();   /* End key is still valid */
  1283.     if (resize_animation_disable_status == RESIZE_ANIMATION_DISABLE_ON)
  1284.     {
  1285.         ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1286.     }
  1287. }
  1288. /*****************************************************************************
  1289.  * FUNCTION
  1290.  *  mmi_jmms_ext_image_resizing
  1291.  * DESCRIPTION
  1292.  *  This function does the resizing of image.
  1293.  * PARAMETERS
  1294.  *  source_file         [IN]        
  1295.  *  dest_file           [IN]        
  1296.  *  resize_width        [IN]        
  1297.  *  resize_height       [IN]        
  1298.  * RETURNS
  1299.  *  JMMS_IMAGE_RESIZE_FAILED if image can't be resized
  1300.  *  JMMS_IMAGE_RESIZE_UNCHANGED if iamge original size is less than the image resize settings
  1301.  *  JMMS_IMAGE_RESIZE_SUCCEED otherwise.
  1302.  *****************************************************************************/
  1303. S16 mmi_jmms_ext_image_resizing(JC_CHAR *source_file, JC_CHAR *dest_file, S32 resize_width, S32 resize_height)
  1304. {
  1305.     /*----------------------------------------------------------------*/
  1306.     /* Local Variables                                                */
  1307.     /*----------------------------------------------------------------*/
  1308.     S32 img_width = 0, img_height = 0;
  1309.     S32 temp_width = 0, temp_height = 0;
  1310.     GDI_RESULT gdi_ret = GDI_FAILED;
  1311.     S32 buf_size = 0;
  1312.     U8 *buf_ptr;
  1313.     S16 ret;
  1314.     /*----------------------------------------------------------------*/
  1315.     /* Code Body                                                      */
  1316.     /*----------------------------------------------------------------*/
  1317.     ASSERT(source_file != NULL);
  1318.     ASSERT(dest_file != NULL);
  1319.     PRINT_INFORMATION_2((MMI_TRACE_INFO, " %s(%d) Image Resizing Starts n", __FILE__, __LINE__));
  1320.     /* Get the image dimension */
  1321.     gdi_ret = gdi_image_get_dimension_file((PS8) source_file, &img_width, &img_height);
  1322.     if ((img_width >= 0) && (img_height >= 0))
  1323.     {
  1324.         /* calculate the dimension of the resize JPEG */
  1325.         if ((img_width > resize_width) || (img_height > resize_height))
  1326.         {
  1327.             /* need to resize */
  1328.             if ((img_width * resize_height) > (img_height * resize_width))
  1329.             {
  1330.                 temp_width = resize_width;
  1331.                 temp_height = img_height * resize_width / img_width;
  1332.                 if (temp_height == 0)
  1333.                 {
  1334.                     temp_height = 1;
  1335.                 }
  1336.             }
  1337.             else
  1338.             {
  1339.                 temp_width = img_width * resize_height / img_height;
  1340.                 temp_height = resize_height;
  1341.                 if (temp_width == 0)
  1342.                 {
  1343.                     temp_width = 1;
  1344.                 }
  1345.             }
  1346.             /* resize the image and encode to jpef file */
  1347.             buf_size = (temp_width * temp_height * 16) >> 3;
  1348.             buf_size = ((buf_size + 3) / 4) * 4;
  1349.             if (buf_size > 0)
  1350.             {
  1351.                 media_get_ext_buffer(MOD_MMI, (void **)&buf_ptr, buf_size);
  1352.                 if (buf_ptr != NULL)
  1353.                 {
  1354.                     gdi_ret = gdi_image_encode_file_to_jpeg(
  1355.                                 (PS8) source_file,
  1356.                                 (PS8) dest_file,
  1357.                                 temp_width,
  1358.                                 temp_height,
  1359.                                 buf_ptr,
  1360.                                 buf_size);
  1361.                     media_free_ext_buffer(MOD_MMI, (void **)&buf_ptr);
  1362.                 }
  1363.                 switch (gdi_ret)
  1364.                 {
  1365.                     case GDI_SUCCEED:
  1366.                         ret = JMMS_IMAGE_RESIZE_SUCCEED;
  1367.                         break;
  1368.                     case GDI_IMAGE_ENCODER_ERR_DISK_FULL:
  1369.                         ret = JMMS_IMAGE_RESIZING_FAILED_IN_GDI_ENCODER_ERR_DISK_FULL;
  1370.                         break;
  1371.                     case GDI_IMAGE_ENCODER_ERR_WRITE_PROTECTION:
  1372.                         ret = JMMS_IMAGE_RESIZING_FAILED_IN_GDI_ENCODER_ERR_WRITE_PROTECTION;
  1373.                         break;
  1374.                     case GDI_IMAGE_ENCODER_ERR_NO_DISK:
  1375.                         ret = JMMS_IMAGE_RESIZING_FAILED_IN_GDI_ENCODER_ERR_NO_DISK;
  1376.                         break;
  1377.                     default:
  1378.                         ret = JMMS_IMAGE_RESIZE_FAILED;
  1379.                 }
  1380.             }
  1381.             else
  1382.             {
  1383.                 ret = JMMS_IMAGE_RESIZING_FAILED_IN_INSUFFICIENT_DRAWING_BUF;
  1384.             }
  1385.         }
  1386.         else
  1387.         {
  1388.             /* the dimension of the original image is smaller */
  1389.             ret = JMMS_IMAGE_RESIZE_UNCHANGED;
  1390.         }
  1391.     }
  1392.     else
  1393.     {
  1394.         ret = JMMS_IMAGE_RESIZING_FAILED_IN_UNKNOWN_DIMENSION;
  1395.     }
  1396.     PRINT_INFORMATION_2((MMI_TRACE_INFO, " (%d) Image Resizing returns with code(%d) n", __LINE__, ret));
  1397.     return ret;
  1398. }
  1399. /*****************************************************************************
  1400.  * FUNCTION
  1401.  *  mmi_jmms_delete_resized_temp_file
  1402.  * DESCRIPTION
  1403.  *  
  1404.  * PARAMETERS
  1405.  *  file_name       [IN]     
  1406.  * RETURNS
  1407.  *  void
  1408.  *****************************************************************************/
  1409. void mmi_jmms_delete_resized_temp_file(S8 *file_name)
  1410. {
  1411.     /*----------------------------------------------------------------*/
  1412.     /* Local Variables                                                */
  1413.     /*----------------------------------------------------------------*/
  1414.     JDD_FSHANDLE fs_handle = NULL;
  1415.     S8 *temp_file = NULL;
  1416.     JC_RETCODE ret_code = JC_OK;
  1417.     /*----------------------------------------------------------------*/
  1418.     /* Code Body                                                      */
  1419.     /*----------------------------------------------------------------*/
  1420.     temp_file = (S8*) jdd_MemAlloc(pfnUnicodeStrlen((PS8) file_name) + 1, 1);
  1421.     if (temp_file != NULL)
  1422.     {
  1423.         UnicodeToAnsii((PS8) temp_file, (PS8) file_name);
  1424.         if ((strstr((PS8) temp_file, (PS8) "@mms\temp\resize")) != NULL)
  1425.         {
  1426.             ret_code = jdd_FSInitialize(&fs_handle);
  1427.             if (ret_code == JC_OK)
  1428.             {
  1429.                 jdd_FSDelete(fs_handle, (JC_CHAR*) file_name);
  1430.                 jdd_FSDeinitialize(fs_handle);
  1431.             }
  1432.         }
  1433.         jdd_MemFree(temp_file);
  1434.     }
  1435. }
  1436. #endif /* __MMI_MMS_MEGA_PIXEL_SUPPORT__ */ 
  1437. /* HIMANSHU 05122006 END */
  1438. /*****************************************************************************
  1439.  * FUNCTION
  1440.  *  mmi_jmms_create_mms_to_address
  1441.  * DESCRIPTION
  1442.  *  Add the file content to MMS according to their Media type.
  1443.  * PARAMETERS
  1444.  *  address     [IN]        
  1445.  * RETURNS
  1446.  *  void
  1447.  *****************************************************************************/
  1448. void mmi_jmms_create_mms_to_address(JC_CHAR *address)
  1449. {
  1450.     /*----------------------------------------------------------------*/
  1451.     /* Local Variables                                                */
  1452.     /*----------------------------------------------------------------*/
  1453.     U8 ret = 0;
  1454.     /*----------------------------------------------------------------*/
  1455.     /* Code Body                                                      */
  1456.     /*----------------------------------------------------------------*/
  1457.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_create_mms_to_address"));
  1458.     ClearAllKeyHandler();
  1459.     mmi_jmms_init_msg_context_struct(); /* this will different for different ways */
  1460.     if (g_jmms_context->compose_context == NULL)
  1461.     {
  1462.         g_jmms_context->compose_context =
  1463.             (jmms_compose_context_struct*) jdd_MemAlloc(sizeof(jmms_compose_context_struct), 1);
  1464.         if (g_jmms_context->compose_context == NULL)
  1465.         {
  1466.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "OUT OF MEMORY: Fail to create compose Context"));
  1467.             DisplayPopup((PU8) GetString(STR_ID_JMMS_OUT_OF_MEMORY), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);
  1468.             return;
  1469.         }
  1470.     }
  1471.     g_jmms_context->g_use_local_send_setings = 0;
  1472.     g_jmms_context->store_context->current_folder_name = E_JMMS_WRITE_MMS;
  1473.     g_jmms_context->compose_context->curr_page_index = 0;
  1474.  //   mmi_jmms_init_msg_context_struct(); /* this will different for different ways */
  1475.     if (JMMS_COMP_OK == mmi_jmms_compose_new_mms())
  1476.     {
  1477.         g_jmms_context->address_list_flag = E_TO_ADDRESSES;
  1478.         ret = mmi_jmms_add_address_in_addresse_list((S8*) address);
  1479.         if (ret != 0)
  1480.         {
  1481.             DisplayPopup(
  1482.                 (U8*) GetString(STR_ID_JMMS_MEMORY_FULL),
  1483.                 IMG_GLOBAL_ERROR,
  1484.                 1,
  1485.                 JMMS_POPUP_TIME,
  1486.                 (U8) ERROR_TONE);
  1487.             mmi_jmms_deinit_mms_context(g_jmms_context);
  1488.             return;
  1489.         }
  1490.         /* /back to address list scren with newly added adress highlighted and rsk as DONE */
  1491.         g_jmms_context->g_write_mms_right_soft_key = STR_GLOBAL_DONE;
  1492.         mmi_jmms_entry_write_message_screen();
  1493.     }
  1494.     else
  1495.     {
  1496.         mmi_jmms_deinit_mms_context(g_jmms_context);
  1497.     }
  1498. }
  1499. /*****************************************************************************
  1500.  * FUNCTION
  1501.  *  mmi_jmms_create_mms_for_barcode
  1502.  * DESCRIPTION
  1503.  *  This function is written to add the subject and text of 2D Barcode into
  1504.  *  the new MMS.
  1505.  * PARAMETERS
  1506.  *  subject         [IN]        JC_CHAR*
  1507.  *  subject_len     [IN]        U8
  1508.  *  text            [IN]        JC_CHAR*
  1509.  *  text_len        [OUT]       U16
  1510.  * RETURNS
  1511.  *  void
  1512.  *****************************************************************************/
  1513. #ifdef __MMI_BARCODEREADER__
  1514. void mmi_jmms_create_mms_for_barcode(JC_CHAR *subject, U8 subject_len, JC_CHAR *text, U16 text_len)
  1515. {
  1516.     /*----------------------------------------------------------------*/
  1517.     /* Local Variables                                                */
  1518.     /*----------------------------------------------------------------*/
  1519.     U32 slide_time = 0;
  1520.     JMMS_COMP_ERRCODE err_code = JMMS_COMP_OK;
  1521.     /*----------------------------------------------------------------*/
  1522.     /* Code Body                                                      */
  1523.     /*----------------------------------------------------------------*/
  1524.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_create_mms_for_barcode"));
  1525.     mmi_jmms_reset_fw_flag_of_message();
  1526. if(g_jmms_context->init_done == JMMS_READY_WITHOUT_STORE)
  1527. {
  1528.         DisplayPopup((U8*) GetString(STR_ID_JMMS_MEMORY_FULL), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, (U8) ERROR_TONE);
  1529. PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "JMMS: Store is not ready"));
  1530.         return;
  1531. }
  1532.     ClearAllKeyHandler();
  1533.     mmi_jmms_init_msg_context_struct(); /* this will different for different ways */
  1534.     if (g_jmms_context->compose_context == NULL)
  1535.     {
  1536.         g_jmms_context->compose_context =
  1537.             (jmms_compose_context_struct*) jdd_MemAlloc(sizeof(jmms_compose_context_struct), 1);
  1538.         if (g_jmms_context->compose_context == NULL)
  1539.         {
  1540.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "OUT OF MEMORY: Fail to create compose Context"));
  1541.             DisplayPopup((PU8) GetString(STR_ID_JMMS_OUT_OF_MEMORY), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);
  1542.             return;
  1543.         }
  1544.     }
  1545.     g_jmms_context->g_use_local_send_setings = 0;
  1546. mmi_jmms_fill_mms_sending_settings();
  1547.     g_jmms_context->store_context->current_folder_name = E_JMMS_WRITE_MMS;
  1548.     g_jmms_context->compose_context->curr_page_index = 0;
  1549.    // mmi_jmms_init_msg_context_struct(); /* this will different for different ways */
  1550.     if (JMMS_COMP_OK == mmi_jmms_compose_new_mms())
  1551.     {
  1552.         g_jmms_context->compose_context->mms_bg_color = g_jmms_color_RGB_list[COLOR_WHITE];
  1553.         /* PMT HIMANSHU START 20060425 */
  1554.         /* Added by Deepali for root layout. */
  1555.         err_code = mmi_jmms_set_bg_color(g_jmms_context->compose_context->mms_bg_color);
  1556.         if ((err_code == JMMS_COMP_OUT_MEMORY) || (err_code == JMMS_COMP_FAIL))
  1557.         {
  1558.             mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
  1559.             return;
  1560.         }
  1561.         err_code = mmi_jmms_compose_handle_error(mmi_jmms_jdi_add_page(g_jmms_context->msg_handle, 1), 1);
  1562.         if ((err_code == JMMS_COMP_OUT_MEMORY) || (err_code == JMMS_COMP_FAIL))
  1563.         {
  1564.             mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
  1565.             return;
  1566.         }
  1567.         g_jmms_context->compose_context->curr_page_index++;
  1568.         mmi_jmms_compose_fill_default_values_slide_settings();
  1569.         slide_time = mmi_jmms_compose_settings_default_slide_time();
  1570.         err_code = mmi_jmms_save_page_time(slide_time);
  1571.         if (err_code == JMMS_COMP_OK)
  1572.         {
  1573.             g_jmms_context->compose_context->curr_slide_info.slide_prop.slide_time = slide_time;
  1574.         }
  1575.     subject_len *=ENCODING_LENGTH;
  1576.         /* To copy the subject content into the buffer */
  1577.         if (subject_len > (MAX_SUBJECT_LENGTH * ENCODING_LENGTH))
  1578.         {
  1579.             memcpy(g_jmms_context->subject_input_buffer, (S8*) subject, (MAX_SUBJECT_LENGTH * ENCODING_LENGTH));
  1580.         }
  1581.         else
  1582.         {
  1583.             memcpy(g_jmms_context->subject_input_buffer, (S8*) subject, subject_len);
  1584.         }
  1585.         /* To copy the MMS content into the buffer. */
  1586.     text_len *=ENCODING_LENGTH;
  1587.         if (text_len > (JMMS_COMPOSE_TEXT_LENGTH * ENCODING_LENGTH))
  1588.         {
  1589.             memcpy(
  1590.                 g_jmms_context->compose_context->curr_slide_info.edit_content_buffer,
  1591.                 (S8*) text,
  1592.                 (JMMS_COMPOSE_TEXT_LENGTH * ENCODING_LENGTH));
  1593.         }
  1594.         else
  1595.         {
  1596.             memcpy(g_jmms_context->compose_context->curr_slide_info.edit_content_buffer, (S8*) text, text_len);
  1597.         }
  1598.         /* To add the text with the MMS */
  1599.         err_code = mmi_jmms_compose_add_text(
  1600.             g_jmms_context->compose_context->curr_page_index,
  1601.             &(g_jmms_context->compose_context->curr_slide_info.slide_prop.text_font),
  1602.             g_jmms_context->compose_context->curr_slide_info.slide_prop.text_color,1);
  1603.         g_jmms_context->g_write_mms_right_soft_key = STR_GLOBAL_DONE;
  1604.         if (err_code == JMMS_COMP_OK || err_code == JMMS_COMP_POPUP_OK)
  1605.         {
  1606.             g_jmms_context->g_write_mms_right_soft_key = STR_GLOBAL_DONE;
  1607.             if (err_code == JMMS_COMP_POPUP_OK)
  1608.             {
  1609.                 mmi_jmms_entry_write_message_screen_in_history();
  1610.             }
  1611.             else
  1612.             {
  1613.                 mmi_jmms_entry_write_message_screen();
  1614.             }
  1615.             return;
  1616.         }
  1617.     }
  1618.     mmi_jmms_deinit_mms_context(g_jmms_context);
  1619.     return;
  1620. }
  1621. #endif /* __MMI_BARCODEREADER__ */ 
  1622. /*****************************************************************************
  1623.  * FUNCTION
  1624.  *  mmi_jmms_convert_chinese_english_filename
  1625.  * DESCRIPTION
  1626.  *  
  1627.  * PARAMETERS
  1628.  *  dst_filename        [IN]        
  1629.  *  src_filename        [IN]         
  1630.  * RETURNS
  1631.  *  
  1632.  *****************************************************************************/
  1633. JC_RETCODE mmi_jmms_convert_chinese_english_filename(JC_CHAR **dst_filename, JC_CHAR *src_filename)
  1634. {
  1635.     /*----------------------------------------------------------------*/
  1636.     /* Local Variables                                                */
  1637.     /*----------------------------------------------------------------*/
  1638.     JC_CHAR *tmp_file_ext = NULL;
  1639.     JC_RETCODE ret_code = JC_OK;
  1640.     MESSAGING_HANDLER *msg_handle = g_jmms_context->msg_handle;
  1641.     MEDIA_MIME_LIST *pMimeList;
  1642.     MEDIA_MIME_INFO *pTargetMime = NULL;
  1643.     U8 isDuplicate = 1;
  1644.     U32 ch_transaction_id = mmi_jmms_get_chinese_file_name_id_from_nvram();
  1645.     /*----------------------------------------------------------------*/
  1646.     /* Code Body                                                      */
  1647.     /*----------------------------------------------------------------*/
  1648.     while (src_filename != NULL && isDuplicate == 1)
  1649.     {
  1650.         U32 index = 0;
  1651.         S8 temp_str[50];
  1652.         JC_CHAR *dst_temp_file_name = NULL;
  1653.         index = jdi_UtilsLastIndexOfTchar('.', src_filename, jc_tcslen(src_filename) - 1);
  1654.         tmp_file_ext = &src_filename[index];
  1655.         sprintf(temp_str, "%s%d", JMMS_CHINESE_FILE_NAME_PRE_STRING, ++ch_transaction_id);
  1656.         ret_code = jdi_UtilsCharToTchar(&dst_temp_file_name, temp_str);
  1657.         if (ret_code != JC_OK)
  1658.         {
  1659.             return ret_code;
  1660.         }
  1661.         *dst_filename =
  1662.             (JC_CHAR*) jdd_MemAlloc((jc_tcslen(dst_temp_file_name) + jc_tcslen(tmp_file_ext) + 1), sizeof(JC_CHAR));
  1663.         if (*dst_filename == NULL)
  1664.         {
  1665.             jdd_MemFree(dst_temp_file_name);
  1666.             return JC_ERR_MEMORY_ALLOCATION;
  1667.         }
  1668.         jc_tcscpy((JC_CHAR*) * dst_filename, (JC_CHAR*) dst_temp_file_name);
  1669.         jc_tcscat(*dst_filename, tmp_file_ext);
  1670.         jdd_MemFree(dst_temp_file_name);
  1671.         /* Check for duplicate filename */
  1672.         isDuplicate = 0;
  1673.         pMimeList = msg_handle->pMimeList;
  1674.         while (pMimeList != NULL)
  1675.         {
  1676.             pTargetMime = pMimeList->pMimeInfo;
  1677.             if (jc_tcscmp(pTargetMime->MimeHeaders.pObjectName, *dst_filename) == 0)
  1678.             {
  1679.                 isDuplicate = 1;
  1680.                 jdd_MemFree(*dst_filename);
  1681.                 break;
  1682.             }
  1683.             pMimeList = pMimeList->pNext;
  1684.         }
  1685.     }
  1686.     mmi_jmms_set_chinese_file_name_id_to_nvram(ch_transaction_id);
  1687.     return ret_code;
  1688. }
  1689. /*****************************************************************************
  1690.  * FUNCTION
  1691.  *  mmi_jmms_get_chinese_file_name_id_from_nvram
  1692.  * DESCRIPTION
  1693.  *  
  1694.  * PARAMETERS
  1695.  *  void
  1696.  * RETURNS
  1697.  *  void
  1698.  *****************************************************************************/
  1699. U32 mmi_jmms_get_chinese_file_name_id_from_nvram(void)
  1700. {
  1701.     /*----------------------------------------------------------------*/
  1702.     /* Local Variables                                                */
  1703.     /*----------------------------------------------------------------*/
  1704.     S16 error;
  1705.     U64 ch_file_num = 0;
  1706.     /*----------------------------------------------------------------*/
  1707.     /* Code Body                                                      */
  1708.     /*----------------------------------------------------------------*/
  1709.     ReadValue(NVRAM_JMMS_CHINESE_TRANSACTION_ID, &ch_file_num, DS_DOUBLE, &error);
  1710.     if (ch_file_num > (0xFFFFFFFF))   // compiler warning removal
  1711.     {
  1712.         ch_file_num = 0;
  1713.         WriteValue(NVRAM_JMMS_CHINESE_TRANSACTION_ID, &ch_file_num, DS_DOUBLE, &error);
  1714.     }
  1715.     return (U32) ch_file_num;
  1716. }
  1717. /*****************************************************************************
  1718.  * FUNCTION
  1719.  *  mmi_jmms_set_chinese_file_name_id_to_nvram
  1720.  * DESCRIPTION
  1721.  *  
  1722.  * PARAMETERS
  1723.  *  tr_id       [IN]        
  1724.  * RETURNS
  1725.  *  void
  1726.  *****************************************************************************/
  1727. void mmi_jmms_set_chinese_file_name_id_to_nvram(U32 tr_id)
  1728. {
  1729.     /*----------------------------------------------------------------*/
  1730.     /* Local Variables                                                */
  1731.     /*----------------------------------------------------------------*/
  1732.     S16 error;
  1733.     U64 ch_file_num = 0;
  1734.     /*----------------------------------------------------------------*/
  1735.     /* Code Body                                                      */
  1736.     /*----------------------------------------------------------------*/
  1737.     ch_file_num = tr_id;
  1738.     if (ch_file_num == 0x00000000FFFFFFFF)
  1739.     {
  1740.         ch_file_num = 0;
  1741.     }
  1742.     WriteValue(NVRAM_JMMS_CHINESE_TRANSACTION_ID, &ch_file_num, DS_DOUBLE, &error);
  1743. }
  1744. /*****************************************************************************
  1745.  * FUNCTION
  1746.  *  IsExtendedCharPresent
  1747.  * DESCRIPTION
  1748.  *  
  1749.  * PARAMETERS
  1750.  *  tr_id       [IN]        
  1751.  * RETURNS
  1752.  *  void
  1753.  *****************************************************************************/
  1754. pBOOL IsExtendedCharPresent(S8* buffer)
  1755. {
  1756.     /*----------------------------------------------------------------*/
  1757.     /* Local Variables                                                */
  1758.     /*----------------------------------------------------------------*/
  1759. pBOOL isExtended = FALSE;
  1760.         U8 i=0, bufferLen=0;
  1761. UI_character_type ch;
  1762.    /*----------------------------------------------------------------*/
  1763.     /* Code Body                                                      */
  1764.     /*----------------------------------------------------------------*/
  1765. ch = 0x00FF & (UI_character_type)buffer[i];
  1766.     bufferLen = pfnUnicodeStrlen(buffer) * ENCODING_LENGTH;
  1767.     for (i = 0; i < bufferLen; i += 2)
  1768.     {
  1769. if ((0x00FF & (UI_character_type)buffer[i]) >= 0x80 && (0x00FF & (UI_character_type)buffer[i+1]==0x00))
  1770.         {
  1771. isExtended = TRUE;
  1772.              break;
  1773.         }
  1774. }
  1775. return isExtended;
  1776. }
  1777. #ifdef __DRM_SUPPORT__
  1778. /*****************************************************************************
  1779.  * FUNCTION
  1780.  *  mmi_jmms_is_drm_fwd_lock_media_in_mms
  1781.  * DESCRIPTION
  1782.  *  
  1783.  * PARAMETERS
  1784.  *  MESSAGING_HANDLER        [IN]
  1785.  *  JC_BOOLEAN               [IN]
  1786.  * RETURNS
  1787.  *  JC_BOOLEAN
  1788.  *****************************************************************************/
  1789. JC_BOOLEAN mmi_jmms_is_drm_fwd_lock_media_in_mms(MESSAGING_HANDLER *pMessagingHandle, JC_BOOLEAN check_for_edit)
  1790. {
  1791.     /*----------------------------------------------------------------*/
  1792.     /* Local Variables                                                */
  1793.     /*----------------------------------------------------------------*/
  1794.     MEDIA_MIME_LIST *pTempMimeList = NULL;
  1795.     /*----------------------------------------------------------------*/
  1796.     /* Code Body                                                      */
  1797.     /*----------------------------------------------------------------*/
  1798.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "mmi_jmms_is_drm_fwd_lock_media_in_mms"));
  1799.     if (pMessagingHandle->pMimeList != NULL)
  1800.     {
  1801.         pTempMimeList = pMessagingHandle->pMimeList;
  1802.     }
  1803. while(pTempMimeList != NULL)
  1804. {
  1805.         if(jdi_CUtilsStrStartsWith(pTempMimeList->pMimeInfo->MimeHeaders.pContentType, "application/vnd.oma.drm.message") == E_TRUE)
  1806.         {
  1807.             if(check_for_edit)
  1808.             {
  1809.                 DisplayPopup((PU8) GetString(STR_ID_JMMS_FORWARD_LOCK_DRM_CANT_EDIT), IMG_GLOBAL_WARNING, 1, JMMS_POPUP_TIME, WARNING_TONE);          
  1810.             }
  1811.             else
  1812.             {
  1813.                 DisplayPopup((PU8) GetString(STR_ID_JMMS_FORWARD_LOCK_DRM), IMG_GLOBAL_WARNING, 1, JMMS_POPUP_TIME, WARNING_TONE);          
  1814.             }
  1815.             return E_TRUE;
  1816.         }
  1817. pTempMimeList = pTempMimeList->pNext ;
  1818. }
  1819.     return E_FALSE;
  1820. }
  1821. #endif
  1822. /*****************************************************************************
  1823.  * FUNCTION
  1824.  *  mmi_jmms_is_corrupted_video_media_in_mms
  1825.  * DESCRIPTION
  1826.  *  
  1827.  * PARAMETERS
  1828.  *  MESSAGING_HANDLER        [IN]        
  1829.  * RETURNS
  1830.  *  JC_BOOLEAN
  1831.  *****************************************************************************/
  1832. JC_BOOLEAN mmi_jmms_is_corrupted_video_media_in_mms(MESSAGING_HANDLER *pMessagingHandle)
  1833. {
  1834.     /*----------------------------------------------------------------*/
  1835.     /* Local Variables                                                */
  1836.     /*----------------------------------------------------------------*/
  1837.     MSG_PAGE *pTempPageList = NULL;
  1838.     JC_UINT32 audio_du = 0;
  1839.     S32 img_widthv, img_heightv;
  1840. #ifdef __MMI_VIDEO_PLAYER__
  1841.     MDI_RESULT result_video = 0;
  1842. #endif 
  1843.     JC_BOOLEAN result_media = E_FALSE;
  1844.     GDI_RESULT image_result;
  1845.     S32 audio_result = 0;
  1846.     /*----------------------------------------------------------------*/
  1847.     /* Code Body                                                      */
  1848.     /*----------------------------------------------------------------*/
  1849.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_is_corrupted_video_media_in_mms"));
  1850.     if (pMessagingHandle->pPageList != NULL)
  1851.     {
  1852.         pTempPageList = pMessagingHandle->pPageList;
  1853.     }
  1854. while(pTempPageList != NULL)
  1855. {
  1856. if(pTempPageList->pMediaList != NULL)
  1857. {
  1858. switch(pTempPageList->pMediaList->eMediaType)
  1859. {
  1860. case E_MEDIA_IMAGE:
  1861. #ifdef __DRM_SUPPORT__
  1862.                     if(jdi_CUtilsStrStartsWith(pTempPageList->pMediaList->pMimeInfo->MimeHeaders.pContentType, APPLICATION_DRM_VALUE) != E_TRUE)
  1863. #endif
  1864.                     {
  1865.     image_result = gdi_image_get_dimension_file((S8*) pTempPageList->pMediaList->pMimeInfo->ContentData.pFileName, &img_widthv, &img_heightv);
  1866.     if(image_result != GDI_SUCCEED || (img_widthv * img_heightv) == 0)
  1867.     {
  1868.     result_media = E_TRUE;
  1869.     }
  1870.                     }
  1871. break;
  1872. case E_MEDIA_AUDIO:
  1873. #ifdef __DRM_SUPPORT__
  1874.                     if(jdi_CUtilsStrStartsWith(pTempPageList->pMediaList->pMimeInfo->MimeHeaders.pContentType, APPLICATION_DRM_VALUE) != E_TRUE)
  1875. #endif
  1876.                     {
  1877.     audio_result = mdi_audio_get_duration((S8*) pTempPageList->pMediaList->pMimeInfo->ContentData.pFileName, &audio_du);
  1878.     if(audio_result != GDI_SUCCEED )
  1879.     {
  1880.     result_media = E_TRUE;
  1881.     }
  1882.                     }
  1883. break;
  1884. #ifdef __MMI_VIDEO_PLAYER__
  1885. case E_MEDIA_VIDEO:
  1886. #ifdef __DRM_SUPPORT__
  1887.                     if(jdi_CUtilsStrStartsWith(pTempPageList->pMediaList->pMimeInfo->MimeHeaders.pContentType, APPLICATION_DRM_VALUE) != E_TRUE)
  1888. #endif
  1889.                     {
  1890.     result_video = mmi_jdd_videoapp_get_video_file_size_info((S8*) pTempPageList->pMediaList->pMimeInfo->ContentData.pFileName, (JC_UINT32*)&img_widthv, (JC_UINT32*)&img_heightv);
  1891.     if(result_video == MDI_RES_VDOPLY_ERR_OPEN_FILE_FAILED)
  1892.     {
  1893.     result_media = E_TRUE;
  1894.     }
  1895.                     }
  1896. break;
  1897. #endif
  1898. }
  1899. if(result_media == E_TRUE)
  1900. {
  1901.                 #ifdef __MMI_UNIFIED_MESSAGE__
  1902. g_jmms_context->edit_error_code=-1;
  1903.         #endif
  1904.                 DisplayPopup((PU8) GetString(STR_ID_JMMS_CORRUPTED_MEDIA_FILE), IMG_GLOBAL_ERROR, 1, JMMS_POPUP_TIME, ERROR_TONE);          
  1905.                 return E_TRUE;
  1906.             }
  1907. }
  1908. pTempPageList = pTempPageList->pNext ;
  1909. }
  1910.     return E_FALSE;
  1911. }
  1912. /* PMT VIKAS END 20060403 */
  1913. JMMS_COMP_ERRCODE mmi_jmms_compose_replace_media(void *path_p, U8 type, U8 is_attachment, U8 page_index, JC_UINT32 uiOldMediaID)
  1914. {
  1915.     /*----------------------------------------------------------------*/
  1916.     /* Local Variables                                                */
  1917.     /*----------------------------------------------------------------*/
  1918.     MEDIA_INFO *media_info_p;
  1919.     S8 *file_name_p;
  1920.     U32 file_size = 0;
  1921.     /* FS_HANDLE  file_handle; */
  1922.     JC_RETCODE ret_code = JC_OK;
  1923.     JMMS_COMP_ERRCODE err_code;
  1924.     U32 media_id;
  1925.     JDD_FILE file_handle;
  1926.     /*----------------------------------------------------------------*/
  1927.     /* Code Body                                                      */
  1928.     /*----------------------------------------------------------------*/
  1929.     PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s", "Inside mmi_jmms_compose_replace_media"));
  1930.     media_info_p = (MEDIA_INFO*) jdd_MemAlloc(sizeof(MEDIA_INFO), sizeof(U8));
  1931.     if (media_info_p == NULL)
  1932.     {
  1933.         ret_code = JC_ERR_MEMORY_ALLOCATION;
  1934.         goto ERROR_HANDLE;
  1935.     }
  1936.     if (g_jmms_context->jmms_fs_handle == NULL)
  1937.     {
  1938.         if (jdd_FSInitialize(&g_jmms_context->jmms_fs_handle) != JC_OK)
  1939.         {
  1940.             ret_code = JC_ERR_FILE_SYS_INIT;
  1941.             goto ERROR_HANDLE;
  1942.         }
  1943.     }
  1944.     file_name_p = mmi_fmgr_extract_file_name((S8*) path_p);
  1945.     file_handle = jdd_FSOpen(g_jmms_context->jmms_fs_handle, (U16*) path_p, E_OPEN_READ_MODE);
  1946.     if (file_handle == NULL)
  1947.     {
  1948.         ret_code = JC_ERR_FILE_OPEN;
  1949.         goto ERROR_HANDLE;
  1950.     }
  1951.     jdd_FSGetSize(file_handle, &file_size);
  1952.     jdd_FSClose(file_handle);
  1953.     media_info_p->pMimeInfo = (MEDIA_MIME_INFO*) jdd_MemAlloc(sizeof(MEDIA_MIME_INFO), sizeof(U8));
  1954.     if (media_info_p->pMimeInfo == NULL)
  1955.     {
  1956.         ret_code = JC_ERR_MEMORY_ALLOCATION;
  1957.         goto ERROR_HANDLE;
  1958.     }
  1959.     media_info_p->eMediaType = type;
  1960.     if (is_attachment == E_FALSE && (type == E_MEDIA_IMAGE || type == E_MEDIA_VIDEO))
  1961.     {
  1962.         U8 size;
  1963.         size = strlen(STRING_IMAGE);
  1964.         media_info_p->PresentationInfo.pRegionName = (JC_CHAR*) jdd_MemAlloc(sizeof(JC_CHAR), size + 1);
  1965.         if (media_info_p->PresentationInfo.pRegionName == NULL)
  1966.         {
  1967.             ret_code = JC_ERR_MEMORY_ALLOCATION;
  1968.             goto ERROR_HANDLE;
  1969.         }
  1970.         AnsiiToUnicodeString((PS8)(media_info_p->PresentationInfo.pRegionName), (PS8) (STRING_IMAGE) );
  1971.     }
  1972.     media_info_p->pMimeInfo->ContentData.bIsStream = E_TRUE;
  1973.     media_info_p->pMimeInfo->ContentData.eCopyMemory = E_FALSE;
  1974.     media_info_p->pMimeInfo->ContentData.pBuffer = NULL;
  1975.     media_info_p->pMimeInfo->ContentData.uiCurSize = 0;
  1976.     media_info_p->pMimeInfo->ContentData.uiTotalSize = file_size;
  1977.     media_info_p->pMimeInfo->ContentData.cbReadCallback = mmi_jmms_read_callback;
  1978.     media_info_p->pMimeInfo->ContentData.cbWriteCallback = NULL;
  1979.     media_info_p->pMimeInfo->ContentData.uiStartOffset = 0;
  1980.     media_info_p->pMimeInfo->ContentData.pFileName =
  1981.         (JC_CHAR*) jdd_MemAlloc((jc_tcslen((JC_CHAR*) path_p) + 1), sizeof(JC_CHAR));
  1982.     if (media_info_p->pMimeInfo->ContentData.pFileName == NULL)
  1983.     {
  1984.         ret_code = JC_ERR_MEMORY_ALLOCATION;
  1985.         goto ERROR_HANDLE;
  1986.     }
  1987.     jc_tcscpy((UI_character_type*) media_info_p->pMimeInfo->ContentData.pFileName, (UI_character_type*) path_p);
  1988.     media_info_p->pMimeInfo->ContentData.pStream = media_info_p->pMimeInfo->ContentData.pFileName;
  1989.     media_info_p->pMimeInfo->MimeHeaders.bIsAttachment = is_attachment;
  1990.     if ((GetUCS2Flag((S8*) file_name_p) == FALSE )&& (IsExtendedCharPresent((S8*) file_name_p)== FALSE))
  1991.     {
  1992.         media_info_p->pMimeInfo->MimeHeaders.pObjectName =
  1993.             (JC_CHAR*) jdd_MemAlloc((jc_tcslen((JC_CHAR*) file_name_p) + 1), sizeof(JC_CHAR));
  1994.         if (media_info_p->pMimeInfo->MimeHeaders.pObjectName == NULL)
  1995.         {
  1996.             ret_code = JC_ERR_MEMORY_ALLOCATION;
  1997.             goto ERROR_HANDLE;
  1998.         }
  1999.         jc_tcscpy((JC_CHAR*) media_info_p->pMimeInfo->MimeHeaders.pObjectName, (JC_CHAR*) file_name_p);
  2000.     }
  2001.     else
  2002.     {
  2003.         ret_code = mmi_jmms_convert_chinese_english_filename(
  2004.                     (JC_CHAR **) & (media_info_p->pMimeInfo->MimeHeaders.pObjectName),
  2005.                     (JC_CHAR*) file_name_p);
  2006.         if (ret_code != JC_OK)
  2007.         {
  2008.             goto ERROR_HANDLE;
  2009.         }
  2010.     }
  2011. #ifdef __DRM_SUPPORT__
  2012.     if(jMMS_is_sep_delivery_content(path_p))/* && (mmi_jmms_compose_settings_creation_mode() == E_CREATION_MODE_RESTRICTED))*/
  2013.     {
  2014.         media_info_p->pMimeInfo->MimeHeaders.pContentType = jdi_UtilsStrdup("application/vnd.oma.drm.content");
  2015.     }
  2016.     else
  2017.     {
  2018. #endif /* __DRM_SUPPORT__ */ 
  2019.         media_info_p->pMimeInfo->MimeHeaders.pContentType =
  2020.         (JC_INT8*) mmi_mms_get_mms_content_type_file((UI_character_type*) file_name_p);
  2021. #ifdef __DRM_SUPPORT__
  2022.     }
  2023. #endif 
  2024.     if (media_info_p->pMimeInfo->MimeHeaders.pContentType == NULL)
  2025.     {
  2026.         ret_code = JC_ERR_MEMORY_ALLOCATION;
  2027.         goto ERROR_HANDLE;
  2028.     }
  2029.     /* add media */
  2030.     ret_code = mmi_jmms_jdi_replace_media(g_jmms_context->msg_handle, media_info_p, uiOldMediaID, page_index, &media_id);
  2031.     if(ret_code != JC_OK)
  2032.     {
  2033.         goto ERROR_HANDLE;
  2034.     }
  2035. #ifdef __DRM_SUPPORT__
  2036.     if(is_add_media_as_drm)
  2037.     {
  2038.         ret_code = jdi_MsgSetMediaDRMType (g_jmms_context->msg_handle, page_index, 
  2039. media_id, E_DRM_FWD_LOCK, 
  2040. media_info_p->pMimeInfo->MimeHeaders.bIsAttachment);
  2041.         mmi_jmms_jdi_msg_register_callback(g_jmms_context->msg_handle,
  2042.                                     E_CB_DRM_COMPOSE,
  2043.                                     (void*)jMMS_drm_compose_handler);
  2044.         is_add_media_as_drm = MMI_FALSE;
  2045.     }
  2046.     else
  2047.     {
  2048.         ret_code = jdi_MsgSetMediaDRMType (g_jmms_context->msg_handle, page_index, 
  2049. media_id, E_DRM_NONE, 
  2050. media_info_p->pMimeInfo->MimeHeaders.bIsAttachment);
  2051.     }
  2052. #endif
  2053.   ERROR_HANDLE:
  2054.     err_code = mmi_jmms_compose_handle_error(ret_code, 0);
  2055.     switch (err_code)
  2056.     {
  2057.         case JMMS_COMP_OK:
  2058.         case JMMS_COMP_POPUP_OK:
  2059.         {
  2060.             if (is_attachment == E_FALSE)
  2061.             {
  2062.                 U32 start_time = 0;
  2063.                 U32 duration = 0, audio_duration = 0;
  2064.                 U32 max = 999;
  2065.             #ifdef __MMI_VIDEO_PLAYER__
  2066.                 U64 video_duration = 0;
  2067.             #endif 
  2068.                 switch (type)
  2069.                 {
  2070.                     case E_MEDIA_IMAGE:
  2071.                     {
  2072.                         g_jmms_context->compose_context->curr_slide_info.image_ID = media_id;
  2073.                         g_jmms_context->compose_context->curr_slide_info.img_info.pFileName =
  2074.                             (U8*) media_info_p->pMimeInfo->ContentData.pFileName;
  2075.                         break;
  2076.                     }
  2077.                     case E_MEDIA_AUDIO:
  2078.                         g_jmms_context->compose_context->curr_slide_info.audio_ID = media_id;
  2079. mdi_audio_get_duration((S8*) path_p, &audio_duration);
  2080. duration = audio_duration / 1000;
  2081. duration = (duration >= max)? max : ((audio_duration % 1000) > 0)?(duration + 1) : duration;
  2082. err_code = mmi_jmms_set_media_time(
  2083. start_time,
  2084. duration,
  2085. g_jmms_context->compose_context->curr_slide_info.audio_ID,
  2086. g_jmms_context->compose_context->curr_page_index);
  2087.                         break;
  2088.                     case E_MEDIA_VIDEO:
  2089.                         g_jmms_context->compose_context->curr_slide_info.video_ID = media_id;
  2090.                         g_jmms_context->compose_context->curr_slide_info.img_info.pFileName =
  2091.                             (U8*) media_info_p->pMimeInfo->ContentData.pFileName;
  2092. #ifdef __MMI_VIDEO_PLAYER__
  2093. video_duration = mmi_jdd_videoapp_get_video_file_duration_info((S8*) path_p);
  2094. duration = (U32)( video_duration / 1000);
  2095. duration = (duration >= max)? max : ((video_duration % 1000) > 0)?(duration + 1) : duration;
  2096. err_code = mmi_jmms_set_media_time(
  2097. start_time,
  2098. duration,
  2099. g_jmms_context->compose_context->curr_slide_info.video_ID,
  2100. g_jmms_context->compose_context->curr_page_index);
  2101. #endif
  2102.                         break;
  2103.                 }
  2104.             }
  2105.             else
  2106.             {
  2107.                 g_jmms_context->num_attachments++;
  2108.             }
  2109.         }
  2110.             break;
  2111.         case JMMS_COMP_FAIL:
  2112.         case JMMS_COMP_OUT_MEMORY:  /* deallocate memory for new slide and out of mmeory case. */
  2113.         {
  2114.             if (media_info_p != NULL)
  2115.             {
  2116.                 if (media_info_p->pMimeInfo != NULL)
  2117.                 {
  2118.                     if (media_info_p->pMimeInfo->ContentData.pFileName != NULL)
  2119.                     {
  2120.                         jdd_MemFree(media_info_p->pMimeInfo->ContentData.pFileName);
  2121.                     }
  2122.                     if (media_info_p->pMimeInfo->MimeHeaders.pContentType != NULL)
  2123.                     {
  2124.                         jdd_MemFree(media_info_p->pMimeInfo->MimeHeaders.pContentType);
  2125.                     }
  2126.                     if (media_info_p->pMimeInfo->MimeHeaders.pObjectName != NULL)
  2127.                     {
  2128.                         jdd_MemFree(media_info_p->pMimeInfo->MimeHeaders.pObjectName);
  2129.                     }
  2130.                     jdd_MemFree(media_info_p->pMimeInfo);
  2131.                 }
  2132.                 if (media_info_p->PresentationInfo.pRegionName != NULL)
  2133.                 {
  2134.                     jdd_MemFree(media_info_p->PresentationInfo.pRegionName);
  2135.                 }
  2136.                 jdd_MemFree(media_info_p);
  2137.                 media_info_p = NULL;
  2138.             }
  2139.         }
  2140.             err_code = JMMS_COMP_FAIL;
  2141.             break;
  2142.     }
  2143.     mmi_jmms_set_region_list();
  2144.     if (g_jmms_context->jmms_fs_handle != NULL)
  2145.     {
  2146.         jdd_FSDeinitialize(g_jmms_context->jmms_fs_handle);
  2147.         g_jmms_context->jmms_fs_handle = NULL;
  2148.     }
  2149.     if (media_info_p != NULL)
  2150.     {
  2151.         jdd_MemFree(media_info_p);
  2152.         media_info_p = NULL;
  2153.     }
  2154.     return err_code;
  2155. }
  2156. #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */