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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * EmailAppMiscell.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements miscell utilities for Email application.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  *------------------------------------------------------------------------------
  136.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  137.  *============================================================================
  138.  ****************************************************************************/
  139.  /**
  140.  * Copyright Notice
  141.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  142.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  143.  *  (It is illegal to remove this copyright notice from this software or any
  144.  *  portion of it)
  145.  */
  146. /**************************************************************
  147.    FILENAME : EmailAppMiscell.c
  148.    PURPOSE     : nil
  149.    REMARKS     : nil
  150.    AUTHOR      : Magesh k
  151.    DATE     : 30-01-2004
  152. **************************************************************/
  153. #ifndef _MMI_EMAILAPPMISCELL_C
  154. #define _MMI_EMAILAPPMISCELL_C
  155. #include "MMI_features.h"
  156. #ifdef __MMI_EMAIL__
  157. #include "stdC.h"
  158. #include "L4Dr1.h"
  159. #include "FileSystemDef.h"
  160. #include "FileMgr.h"
  161. #include "Fmt_struct.h"
  162. #include "FileSystemGProt.h"
  163. #include "mdi_datatype.h"
  164. #include "mdi_audio.h"
  165. /* micha1230 */
  166. #include "custom_nvram_editor_data_item.h"
  167. #include "custom_data_account.h"
  168. #include "EmailAppProt.h"
  169. #include "EmailAppGProt.h"
  170. #include "Conversions.h"
  171. #include "app_mine.h"
  172. #include "DebugInitDef.h"
  173. #include "FrameworkStruct.h"
  174. #include "EventsGprot.h"
  175. #include "HistoryGprot.h"
  176. #include "CommonScreens.h"
  177. #include "GlobalDefs.h"
  178. #include "SettingProfile.h"
  179. #include "IdleAppProt.h"
  180. #include "IdleAppDef.h"
  181. #include "wgui_status_icons.h"
  182. #include "CallManagementStruct.h"
  183. #include "CallManagementGprot.h"
  184. #include "CallStructureManagementProt.h"
  185. #include "SimDetectionGprot.h"
  186. const mmi_email_err_string_struct g_email_err_tbl[] = 
  187. {
  188.     {MMI_EMAIL_ACCT_NOT_CONFIG, STR_EMAIL_ERROR_CODE_ACCT_NOT_CONFIG_ID},
  189.     {MMI_EMAIL_INVALID_ACCT_INDEX, STR_EMAIL_ERROR_CODE_INVALID_ACCT_INDEX_ID},
  190.     {MMI_EMAIL_FOLDER_NOT_EXISTING, STR_EMAIL_ERROR_CODE_FOLDER_NOT_EXISTING_ID},
  191.     {MMI_EMAIL_MSG_NOT_EXISTING, STR_EMAIL_ERROR_CODE_MSG_NOT_EXISTING_ID},
  192.     {MMI_EMAIL_CONN_FAIL, STR_EMAIL_ERROR_CODE_CONN_FAIL_ID},
  193.     {MMI_EMAIL_AUTH_FAIL, STR_EMAIL_ERROR_CODE_AUTH_FAIL_ID},
  194.     {MMI_EMAIL_BAD_PAGE_NUMBER, STR_EMAIL_ERROR_CODE_BAD_PAGE_NUMBER_ID},
  195.     {MMI_EMAIL_READ_ONLY_ACCESS, STR_EMAIL_READ_ONLY_ACCESS},
  196.     {MMI_EMAIL_DNS_ERR, STR_EMAIL_DNS_ERR},
  197.     {MMI_EMAIL_APP_SOC_TIMEOUT_ERR, STR_EMAIL_ERROR_CODE_APP_SOC_TIMEOUT_ERR_ID},
  198.     {MMI_EMAIL_GET_HOST_TIMEOUT_ERR, STR_EMAIL_ERROR_CODE_APP_SOC_TIMEOUT_ERR_ID},
  199.     {MMI_EMAIL_POP3_MSG_XACTION_ERR, STR_EMAIL_ERROR_CODE_POP_CMD},
  200.     {MMI_EMAIL_POP3_SESSION_QUIT_ERR, STR_EMAIL_ERROR_CODE_POP_CMD},
  201.     {MMI_EMAIL_POP3_FSM_ERR, STR_EMAIL_ERROR_CODE_POP_CMD},
  202.     {MMI_EMAIL_INVALID_FOLDER_ID, STR_EMAIL_ERROR_CODE_FOLDER_NOT_EXISTING_ID},
  203.     {MMI_EMAIL_MEMORY_ALLOC_FAIL, STR_EMAIL_MEMORY_FULL_ID},
  204.     {MMI_EMAIL_SMTP_RCPT_TO_FAIL, STR_EMAIL_SMTP_RCPT_TO_FAIL},
  205.     {MMI_EMAIL_INVALID_PORT_NUM, STR_EMAIL_ERROR_CODE_INVALID_PORT_NUM_ID},
  206.     {MMI_EMAIL_INVALID_IP_ADDR, STR_EMAIL_ERROR_CODE_INVALID_IP_ADDR_ID},
  207.     {MMI_EMAIL_INVALID_FILE_PATH, STR_EMAIL_WRONG_SETTINGS},
  208.     {MMI_EMAIL_INVALID_EMAIL_ADDR_LEN, STR_EMAIL_WRONG_SETTINGS},
  209.     {MMI_EMAIL_INVALID_DISP_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
  210.     {MMI_EMAIL_INVALID_USR_LEN, STR_EMAIL_WRONG_SETTINGS},
  211.     {MMI_EMAIL_INVALID_PASS_LEN, STR_EMAIL_WRONG_SETTINGS},
  212.     {MMI_EMAIL_INVALID_ACCT_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
  213.     {MMI_EMAIL_INVALID_SERVER_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
  214.     {MMI_EMAIL_INVALID_SERVICE_TYPE, STR_EMAIL_WRONG_SETTINGS},
  215.     {MMI_EMAIL_INVALID_IN_PROTOCOL, STR_EMAIL_WRONG_SETTINGS},
  216.     {MMI_EMAIL_INVALID_CHK_INT, STR_EMAIL_WRONG_SETTINGS},
  217.     {MMI_EMAIL_INVALID_SIGNATURE_LEN, STR_EMAIL_WRONG_SETTINGS},
  218.     {MMI_EMAIL_INVALID_DOWNLOAD_SIZE, STR_EMAIL_WRONG_SETTINGS},
  219.     {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
  220.     {MMI_EMAIL_SMTP_VERSION_STATE_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  221.     {MMI_EMAIL_SMTP_MAIL_FROM_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  222.     {MMI_EMAIL_SMTP_GREET_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  223.     {MMI_EMAIL_MAIL_DATA_END_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  224.     {MMI_EMAIL_SMTP_RCPT_TO_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  225.     {MMI_EMAIL_SMTP_DATA_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  226.     {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  227.     {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  228.     {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_ERROR_CODE_SMTP_CMD},
  229.     {MMI_EMAIL_EXCEEDED_MSG_CNT, STR_EMAIL_MEMORY_FULL_ID},
  230.     {MMI_EMAIL_ERROR_MSG_REQ, STR_EMAIL_ERROR_MSG_REQ}, /* shall add assertion */
  231.     {MMI_EMAIL_FILE_QUOTA_EXCEEDED, STR_EMAIL_FILE_QUOTA_EXCEEDED},
  232.     {MMI_EMAIL_IMAP_CLOSE_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  233.     {MMI_EMAIL_IMAP_SELECT_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  234.     {MMI_EMAIL_IMAP_FETCH_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  235.     {MMI_EMAIL_IMAP_STORE_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  236.     {MMI_EMAIL_IMAP_LOGOUT_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  237.     {MMI_EMAIL_SELECT_FOLDER_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  238.     {MMI_EMAIL_MSG_SELECT_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  239.     {MMI_EMAIL_NOOP_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
  240.     {MMI_EMAIL_FOLDER_SELECT_NOT_PERMITTED, STR_EMAIL_FOLDER_SELECT_NOT_PERMITTED},
  241.     {MMI_EMAIL_INVALID_BODY_TYPE, STR_EMAIL_INVALID_MAIL_MESSAGE},
  242.     {MMI_EMAIL_INVALID_BODY_ENCODING, STR_EMAIL_INVALID_MAIL_MESSAGE},
  243.     {MMI_EMAIL_INVALID_MAIL_MESSAGE, STR_EMAIL_INVALID_MAIL_MESSAGE},
  244.     {MMI_EMAIL_STREAM_BUFFER_NOT_ENOUGH, STR_EMAIL_MEMORY_FULL_ID},
  245.     {MMI_EMAIL_LIMITED_RESOURCE, STR_EMAIL_MEMORY_FULL_ID},
  246.     {MMI_EMAIL_SMTP_AUTH_FAIL, STR_EMAIL_ERROR_CODE_AUTH_FAIL_ID},
  247.     {MMI_EMAIL_SMTP_AUTH_NOT_SUPPORT, STR_EMAIL_AUTH_NOT_SUPPORT},
  248.     {0, STR_EMAIL_ERROR_CODE_UNKNOWN_ID}
  249. };
  250. #define CHSET_UTIL_EMAIL
  251. /*****************************************************************************
  252.  * FUNCTION
  253.  *  mmi_email_util_ucs2_to_chset
  254.  * DESCRIPTION
  255.  *  Convert string from UCS2 to a specific chasert
  256.  * PARAMETERS
  257.  *  data        [IN]            String to be converted in UCS2.
  258.  *  len         [IN]            Length of the string (in bytes)
  259.  *  chset       [IN]            Charset of result string
  260.  *  outLen      [IN/OUT]        Length of converted string(in bytes)
  261.  * RETURNS
  262.  *  pointer to the result string.
  263.  *****************************************************************************/
  264. U8 *mmi_email_util_ucs2_to_chset(U8 *data, U16 len, U8 chset, U16 *outLen)
  265. {
  266.     /*----------------------------------------------------------------*/
  267.     /* Local Variables                                                */
  268.     /*----------------------------------------------------------------*/
  269.     U8 encoding = 0;
  270.     U8 *convertedData = NULL;
  271.     /*----------------------------------------------------------------*/
  272.     /* Code Body                                                      */
  273.     /*----------------------------------------------------------------*/
  274.     *outLen = 0;
  275.     if (len > 0)
  276.     {
  277.         convertedData = OslMalloc(EMAIL_CHSET_BUFF_LEN);
  278.         switch (chset)
  279.         {
  280.             case EMAIL_ASCII:
  281.                 memset(convertedData, 0, (len + 1));
  282.                 UnicodeNToAnsii((S8*) convertedData, (S8*) data, len);
  283.                 *outLen = len / ENCODING_LENGTH + 1;
  284.                 break;
  285.             default:
  286.                 encoding = mmi_email_util_get_chset(chset);
  287.                 *outLen = mmi_chset_convert(
  288.                             MMI_CHSET_UCS2,
  289.                             (mmi_chset_enum) encoding,
  290.                             (char*)data,
  291.                             (char*)convertedData,
  292.                             EMAIL_CHSET_BUFF_LEN);
  293.                 break;
  294.         }
  295.     }
  296.     return convertedData;
  297. }
  298. /*****************************************************************************
  299.  * FUNCTION
  300.  *  mmi_email_util_chset_to_ucs2
  301.  * DESCRIPTION
  302.  *  Convert string from a specific chasert to UCS2.
  303.  * PARAMETERS
  304.  *  data        [IN]            String to be converted.
  305.  *  len         [IN]            Length of the string (in bytes)
  306.  *  chset       [IN]            Charset of source string
  307.  *  outLen      [IN/OUT]        Length of converted string(in bytes)
  308.  * RETURNS
  309.  *  pointer to the result string.
  310.  *****************************************************************************/
  311. U8 *mmi_email_util_chset_to_ucs2(U8 *data, U16 len, U8 chset, U16 *outLen)
  312. {
  313.     /*----------------------------------------------------------------*/
  314.     /* Local Variables                                                */
  315.     /*----------------------------------------------------------------*/
  316.     U8 mmiEncoding = 0;
  317.     U8 *convertedData = NULL;
  318.     /*----------------------------------------------------------------*/
  319.     /* Code Body                                                      */
  320.     /*----------------------------------------------------------------*/
  321.     *outLen = 0;
  322.     if (len > 0)
  323.     {
  324.         convertedData = OslMalloc(EMAIL_CHSET_BUFF_LEN);
  325.         /* because of buffer size constrained, ASCII charset shall be reduced within boundary */
  326.         if (len > (EMAIL_CHSET_BUFF_LEN - 2) / 2)
  327.         {
  328.             len = (EMAIL_CHSET_BUFF_LEN - 2) / 2;
  329.         }
  330.         switch (chset)
  331.         {
  332.             case EMAIL_ASCII:
  333.                 AnsiiNToUnicodeString((S8*) convertedData, (S8*) data, len);
  334.                 convertedData[len * ENCODING_LENGTH] = 0;
  335.                 convertedData[len * ENCODING_LENGTH + 1] = 0;
  336.                 *outLen = (len + 1) * ENCODING_LENGTH;
  337.                 break;
  338.             default:
  339.                 mmiEncoding = mmi_email_util_get_chset(chset);
  340.                 *outLen = mmi_chset_convert(
  341.                             (mmi_chset_enum) mmiEncoding,
  342.                             MMI_CHSET_UCS2,
  343.                             (char*)data,
  344.                             (char*)convertedData,
  345.                             EMAIL_CHSET_BUFF_LEN);
  346.                 break;
  347.         }
  348.     }
  349.     return convertedData;
  350. }
  351. #define MSG_UTIL_EMAIL
  352. /*****************************************************************************
  353.  * FUNCTION
  354.  *  mmi_email_util_get_chset
  355.  * DESCRIPTION
  356.  *  Convert charset from Email application to the enum value used in conversion function
  357.  * PARAMETERS
  358.  *  src_chset       [IN]        Charset of source.
  359.  * RETURNS
  360.  *  charset enum value for conversion function
  361.  *****************************************************************************/
  362. U8 mmi_email_util_get_chset(U8 src_chset)
  363. {
  364.     /*----------------------------------------------------------------*/
  365.     /* Local Variables                                                */
  366.     /*----------------------------------------------------------------*/
  367.     /*----------------------------------------------------------------*/
  368.     /* Code Body                                                      */
  369.     /*----------------------------------------------------------------*/
  370.     switch (src_chset)
  371.     {
  372.     #ifdef __MMI_CHSET_BIG5__
  373.         case EMAIL_BIG5:
  374.             return MMI_CHSET_BIG5;
  375.     #endif /* __MMI_CHSET_BIG5__ */ 
  376.     #ifdef __MMI_CHSET_GB2312__
  377.         case EMAIL_GB2312:
  378.             return MMI_CHSET_GB2312;
  379.     #endif /* __MMI_CHSET_GB2312__ */ 
  380.         case EMAIL_UTF8:
  381.             return MMI_CHSET_UTF8;
  382.     #ifdef __MMI_CHSET_ARABIC_ISO__
  383.         case EMAIL_ARABIC_ISO:
  384.             return MMI_CHSET_ARABIC_ISO;
  385.     #endif /* __MMI_CHSET_ARABIC_ISO__ */ 
  386.     #ifdef __MMI_CHSET_ARABIC_WIN__
  387.         case EMAIL_ARABIC_WINDOWS:
  388.             return MMI_CHSET_ARABIC_WIN;
  389.     #endif /* __MMI_CHSET_ARABIC_WIN__ */ 
  390.             /* PMT START PERSIAN */
  391.     #ifdef __MMI_CHSET_PERSIAN_CP1097__
  392.         case EMAIL_PERSIAN_CP1097:
  393.             return MMI_CHSET_PERSIAN_CP1097;
  394.     #endif /* __MMI_CHSET_PERSIAN_CP1097__ */ 
  395.     #ifdef __MMI_CHSET_PERSIAN_CP1098__
  396.         case EMAIL_PERSIAN_CP1098:
  397.             return MMI_CHSET_PERSIAN_CP1098;
  398.     #endif /* __MMI_CHSET_PERSIAN_CP1098__ */ 
  399.             /* PMT END PERSIAN */
  400.     #ifdef __MMI_CHSET_BALTIC_ISO__
  401.         case EMAIL_BALTIC_ISO:
  402.             return MMI_CHSET_BALTIC_ISO;
  403.     #endif /* __MMI_CHSET_BALTIC_ISO__ */ 
  404.     #ifdef __MMI_CHSET_BALTIC_WIN__
  405.         case EMAIL_BALTIC_WINDOWS:
  406.             return MMI_CHSET_BALTIC_WIN;
  407.     #endif /* __MMI_CHSET_BALTIC_WIN__ */ 
  408.     #ifdef __MMI_CHSET_CEURO_ISO__
  409.         case EMAIL_CENTRAL_EUROPEAN_ISO:
  410.             return MMI_CHSET_CEURO_ISO;
  411.     #endif /* __MMI_CHSET_CEURO_ISO__ */ 
  412.     #ifdef __MMI_CHSET_CEURO_WIN__
  413.         case EMAIL_CENTRAL_EUROPEAN_WINDOWS:
  414.             return MMI_CHSET_CEURO_WIN;
  415.     #endif /* __MMI_CHSET_CEURO_WIN__ */ 
  416.     #ifdef __MMI_CHSET_GREEK_ISO__
  417.         case EMAIL_GREEK_ISO:
  418.             return MMI_CHSET_GREEK_ISO;
  419.     #endif /* __MMI_CHSET_GREEK_ISO__ */ 
  420.     #ifdef __MMI_CHSET_GREEK_WIN__
  421.         case EMAIL_GREEK_WINDOWS:
  422.             return MMI_CHSET_GREEK_WIN;
  423.     #endif /* __MMI_CHSET_GREEK_WIN__ */ 
  424.     #ifdef __MMI_CHSET_HEBREW_ISO__
  425.         case EMAIL_HEBREW_ISO:
  426.             return MMI_CHSET_HEBREW_ISO;
  427.     #endif /* __MMI_CHSET_HEBREW_ISO__ */ 
  428.     #ifdef __MMI_CHSET_HEBREW_WIN__
  429.         case EMAIL_HEBREW_WINDOWS:
  430.             return MMI_CHSET_HEBREW_WIN;
  431.     #endif /* __MMI_CHSET_HEBREW_WIN__ */ 
  432.     #ifdef __MMI_CHSET_LATIN_ISO__
  433.         case EMAIL_LATIN_ISO:
  434.             return MMI_CHSET_LATIN_ISO;
  435.     #endif /* __MMI_CHSET_LATIN_ISO__ */ 
  436.     #ifdef __MMI_CHSET_NORDIC_ISO__
  437.         case EMAIL_NORDIC_ISO:
  438.             return MMI_CHSET_NORDIC_ISO;
  439.     #endif /* __MMI_CHSET_NORDIC_ISO__ */ 
  440.     #ifdef __MMI_CHSET_SEURO_ISO__
  441.         case EMAIL_SOURTH_EUROPEAN_ISO:
  442.             return MMI_CHSET_SEURO_ISO;
  443.     #endif /* __MMI_CHSET_SEURO_ISO__ */ 
  444.     #ifdef __MMI_CHSET_TURKISH_ISO__
  445.         case EMAIL_TURKISH_ISO:
  446.             return MMI_CHSET_TURKISH_ISO;
  447.     #endif /* __MMI_CHSET_TURKISH_ISO__ */ 
  448.     #ifdef __MMI_CHSET_TURKISH_WIN__
  449.         case EMAIL_TURKISH_WINDOWS:
  450.             return MMI_CHSET_TURKISH_WIN;
  451.     #endif /* __MMI_CHSET_TURKISH_WIN__ */ 
  452.     #ifdef __MMI_CHSET_WESTERN_ISO__
  453.         case EMAIL_WESTERN_ISO:
  454.             return MMI_CHSET_WESTERN_ISO;
  455.     #endif /* __MMI_CHSET_WESTERN_ISO__ */ 
  456.     #ifdef __MMI_CHSET_WESTERN_WIN__
  457.         case EMAIL_WESTERN_WINDOWS:
  458.             return MMI_CHSET_WESTERN_WIN;
  459.     #endif /* __MMI_CHSET_WESTERN_WIN__ */ 
  460.     #ifdef __MMI_CHSET_GB18030__
  461.         case EMAIL_GB:
  462.             return MMI_CHSET_GB18030;
  463.     #endif /* __MMI_CHSET_GB18030__ */ 
  464.     #ifdef __MMI_CHSET_UTF7__
  465.         case EMAIL_UTF7:
  466.             return MMI_CHSET_UTF7;
  467.     #endif /* __MMI_CHSET_UTF7__ */ 
  468.     #ifdef __MMI_CHSET_EUCKR_WIN__
  469.         case EMAIL_KOREAN_EUC:
  470.             return MMI_CHSET_EUCKR;
  471.     #endif /* __MMI_CHSET_EUCKR_WIN__ */ 
  472.     #ifdef __MMI_CHSET_THAI_WINDOWS__
  473.         case EMAIL_THAI_WINDOWS:
  474.             return MMI_CHSET_THAI_WIN;
  475.     #endif /* __MMI_CHSET_THAI_WINDOWS__ */ 
  476.     #ifdef __MMI_CHSET_VIETNAMESE_WINDOWS__
  477.         case EMAIL_VIETNAMESE_WINDOWS:
  478.             return MMI_CHSET_VIETNAMESE_WIN;
  479.     #endif /* __MMI_CHSET_VIETNAMESE_WINDOWS__ */ 
  480.         default:
  481.             return MMI_CHSET_TOTAL; /* unsupported charset */
  482.     }
  483. }
  484. /*****************************************************************************
  485.  * FUNCTION
  486.  *  mmi_email_fldr_get_start_scr
  487.  * DESCRIPTION
  488.  *  Get start screen id to be deleted after send/save operations.
  489.  *  This function is used in Write Email and each folder, which constains send/save operation
  490.  * PARAMETERS
  491.  *  void
  492.  * RETURNS
  493.  *  The start screen id to be deleted after send/save.
  494.  *****************************************************************************/
  495. U16 mmi_email_fldr_get_start_scr(void)
  496. {
  497.     /*----------------------------------------------------------------*/
  498.     /* Local Variables                                                */
  499.     /*----------------------------------------------------------------*/
  500.     /*----------------------------------------------------------------*/
  501.     /* Code Body                                                      */
  502.     /*----------------------------------------------------------------*/
  503.     if (email_p->main_info.curr_menu == MMI_EMAIL_COMP)
  504.     {
  505.         return SCR_ID_EMAIL_COMP;
  506.     }
  507.     else
  508.     {
  509.         U16 startScrnId;
  510.         U16 folderListSrcnId = mmi_email_util_get_fldr_scr_id();
  511.         if (GetNextScrnIdOf(folderListSrcnId, &startScrnId) == FALSE)
  512.         {
  513.             startScrnId = 0;
  514.         }
  515.         return startScrnId;
  516.     }
  517. }
  518. #define STRING_UTIL_EMAIL
  519. /*****************************************************************************
  520.  * FUNCTION
  521.  *  mmi_email_util_is_username_vaild
  522.  * DESCRIPTION
  523.  *  Check if the user name is all ASCII
  524.  * PARAMETERS
  525.  *  username        [IN]        String to be check
  526.  * RETURNS
  527.  *  TRUE if username is valid; otherwise, FALSE
  528.  *****************************************************************************/
  529. BOOL mmi_email_util_is_username_vaild(S8 *username)
  530. {
  531.     /*----------------------------------------------------------------*/
  532.     /* Local Variables                                                */
  533.     /*----------------------------------------------------------------*/
  534.     /*----------------------------------------------------------------*/
  535.     /* Code Body                                                      */
  536.     /*----------------------------------------------------------------*/
  537.     while (!((*username == 0) && (*(username + 1) == 0)))
  538.     {
  539.         if (username[0] != 0 && username[1] != 0)
  540.         {
  541.             return FALSE;
  542.         }
  543.         if (username[0] > 0x7E || username[1] > 0x7E)
  544.         {
  545.             return FALSE;
  546.         }
  547.         username += 2;
  548.     }
  549.     return TRUE;
  550. }
  551. /*****************************************************************************
  552.  * FUNCTION
  553.  *  mmi_email_util_get_err_code
  554.  * DESCRIPTION
  555.  *  Compute string id to be displayed accoding to error cause
  556.  * PARAMETERS
  557.  *  minor       [IN]        Minor cause
  558.  *  major       [IN]        Major cause
  559.  * RETURNS
  560.  *  void
  561.  *****************************************************************************/
  562. U16 mmi_email_util_get_err_code(S32 minor, signed char major)
  563. {
  564.     /*----------------------------------------------------------------*/
  565.     /* Local Variables                                                */
  566.     /*----------------------------------------------------------------*/
  567.     /*----------------------------------------------------------------*/
  568.     /* Code Body                                                      */
  569.     /*----------------------------------------------------------------*/
  570.     switch (major)
  571.     {
  572.         case MMI_EMAIL_MAIL_ERR:
  573.             return mmi_email_util_get_err_string(minor);
  574.         case MMI_EMAIL_SOCKET_ERR:
  575.             return STR_EMAIL_ERROR_CODE_NETWORK_ID;
  576.         case MMI_EMAIL_FS_ERR:
  577.             return GetFileSystemErrorString(minor);
  578.         default:
  579.             return STR_EMAIL_ERROR_CODE_UNKNOWN_ID;
  580.     }
  581. }
  582. /*****************************************************************************
  583.  * FUNCTION
  584.  *  mmi_email_util_ascii_2_ucs2_str
  585.  * DESCRIPTION
  586.  *  Convert from ASCII to UCS2
  587.  * PARAMETERS
  588.  *  str     [IN]        String to be converted
  589.  * RETURNS
  590.  *  address of result string
  591.  *****************************************************************************/
  592. S8 *mmi_email_util_ascii_2_ucs2_str(S8 *str)
  593. {
  594.     /*----------------------------------------------------------------*/
  595.     /* Local Variables                                                */
  596.     /*----------------------------------------------------------------*/
  597.     /*----------------------------------------------------------------*/
  598.     /* Code Body                                                      */
  599.     /*----------------------------------------------------------------*/
  600.     AnsiiToUnicodeString((S8*) email_p->comm_buff, str);
  601.     return (S8*) email_p->comm_buff;
  602. }
  603. /*****************************************************************************
  604.  * FUNCTION
  605.  *  mmi_email_util_num_2_ucs2_str
  606.  * DESCRIPTION
  607.  *  Convert from ASCII to UCS2
  608.  * PARAMETERS
  609.  *  num     [IN]        Number to be converted
  610.  * RETURNS
  611.  *  address of result string
  612.  *****************************************************************************/
  613. S8 *mmi_email_util_num_2_ucs2_str(S8 num)
  614. {
  615.     /*----------------------------------------------------------------*/
  616.     /* Local Variables                                                */
  617.     /*----------------------------------------------------------------*/
  618.     S8 fileNumberAnsii[ENCODING_LENGTH];
  619.     /*----------------------------------------------------------------*/
  620.     /* Code Body                                                      */
  621.     /*----------------------------------------------------------------*/
  622.     sprintf(fileNumberAnsii, "%d", num);
  623.     AnsiiToUnicodeString((S8*) email_p->comm_buff, fileNumberAnsii);
  624.     return (S8*) email_p->comm_buff;
  625. }
  626. /*****************************************************************************
  627.  * FUNCTION
  628.  *  mmi_email_util_get_num_len
  629.  * DESCRIPTION
  630.  *  Compute the length of an integer.
  631.  * PARAMETERS
  632.  *  number          [IN]        
  633.  *  nunmber(?)      [IN]        Number to be computed.
  634.  * RETURNS
  635.  *  the length of the number.
  636.  *****************************************************************************/
  637. S32 mmi_email_util_get_num_len(U32 number)
  638. {
  639.     /*----------------------------------------------------------------*/
  640.     /* Local Variables                                                */
  641.     /*----------------------------------------------------------------*/
  642.     S32 len;
  643.     S8 *asciiMaxString = OslMalloc(EMAIL_MAX_DWNL_LEN);
  644.     /*----------------------------------------------------------------*/
  645.     /* Code Body                                                      */
  646.     /*----------------------------------------------------------------*/
  647.     sprintf((S8*) asciiMaxString, "%d", number);
  648.     len = strlen((S8*) asciiMaxString);
  649.     OslMfree(asciiMaxString);
  650.     return len;
  651. }
  652. /*****************************************************************************
  653.  * FUNCTION
  654.  *  mmi_email_util_get_err_string
  655.  * DESCRIPTION
  656.  *  Get string id to represent an error codes of Email
  657.  * PARAMETERS
  658.  *  error       [IN]        Error codes of Email
  659.  * RETURNS
  660.  *  void
  661.  *****************************************************************************/
  662. U16 mmi_email_util_get_err_string(S32 error)
  663. {
  664.     /*----------------------------------------------------------------*/
  665.     /* Local Variables                                                */
  666.     /*----------------------------------------------------------------*/
  667.     S16 i;
  668.     S16 entry;
  669.     /*----------------------------------------------------------------*/
  670.     /* Code Body                                                      */
  671.     /*----------------------------------------------------------------*/
  672.     entry = sizeof(g_email_err_tbl) / sizeof(mmi_email_err_string_struct);
  673.     for (i = 0; i < entry; i++)
  674.         if (g_email_err_tbl[i].err_no == error)
  675.         {
  676.             return g_email_err_tbl[i].str_id;
  677.         }
  678.     return STR_EMAIL_ERROR_CODE_UNKNOWN_ID;
  679. }
  680. /*****************************************************************************
  681.  * FUNCTION
  682.  *  mmi_email_util_chk_addr
  683.  * DESCRIPTION
  684.  *  To check if an email address is valid (contains '@' charcater *).
  685.  * PARAMETERS
  686.  *  mailAddr        [IN]        Address to be checked (in UCS).
  687.  * RETURNS
  688.  *  TRUE if valid; otherwise FALSE.
  689.  *****************************************************************************/
  690. BOOL mmi_email_util_chk_addr(U8 *mailAddr)
  691. {
  692.     /*----------------------------------------------------------------*/
  693.     /* Local Variables                                                */
  694.     /*----------------------------------------------------------------*/
  695.     S8 foundAt = 0;
  696.     S32 count = 0;
  697.     U8 char_unit;
  698.     /*----------------------------------------------------------------*/
  699.     /* Code Body                                                      */
  700.     /*----------------------------------------------------------------*/
  701.     while (mailAddr[count] != 0 || mailAddr[count + 1] != 0)
  702.     {
  703.         if (mailAddr[count] > 0x7e || mailAddr[count + 1] > 0x7e)
  704.         {
  705.             return FALSE;
  706.         }
  707.         char_unit = mailAddr[count];
  708.         switch (char_unit)
  709.         {
  710.             case '@':
  711.             {
  712.                 foundAt++;
  713.                 if (count == 0) /* @xxxxx */
  714.                 {
  715.                     return FALSE;
  716.                 }
  717.                 else if (foundAt > 1)
  718.                 {
  719.                     return FALSE;
  720.                 }
  721.                 else if (mailAddr[count + 2] == 0 && mailAddr[count + 3] == 0)
  722.                 {
  723.                     return FALSE;   /* xxxx@ */
  724.                 }
  725.                 else
  726.                 {
  727.                     break;
  728.                 }
  729.             }
  730.             case ',':
  731.             case ';':
  732.             case ':':
  733.             case '<':
  734.             case '>':
  735.             case '[':
  736.             case ']':
  737.             case '"':
  738.             case ')':
  739.             case '(':
  740.                 return FALSE;
  741.             default:
  742.                 break;
  743.         }
  744.         count += 2;
  745.     }
  746.     if (foundAt == 1)
  747.     {
  748.         return TRUE;
  749.     }
  750.     return FALSE;
  751. }
  752. #define FILE_UTIL_EMAIL
  753. /*****************************************************************************
  754.  * FUNCTION
  755.  *  mmi_email_util_get_cont_name
  756.  * DESCRIPTION
  757.  *  Get file name of content.
  758.  * PARAMETERS
  759.  *  fileNo          [IN]            Index of content
  760.  *  path_buff       [IN/OUT]        Buffer to store the file path+name
  761.  * RETURNS
  762.  *  void
  763.  *****************************************************************************/
  764. void mmi_email_util_get_cont_name(S8 fileNo, S8 *path_buff)
  765. {
  766.     /*----------------------------------------------------------------*/
  767.     /* Local Variables                                                */
  768.     /*----------------------------------------------------------------*/
  769.     /*----------------------------------------------------------------*/
  770.     /* Code Body                                                      */
  771.     /*----------------------------------------------------------------*/
  772.     pfnUnicodeStrcpy((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  773.     pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_TEXT_FILE_NAME));
  774.     pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_num_2_ucs2_str(fileNo));
  775. }
  776. /*****************************************************************************
  777.  * FUNCTION
  778.  *  mmi_email_util_get_attch_name
  779.  * DESCRIPTION
  780.  *  Get file name of attachment.
  781.  * PARAMETERS
  782.  *  fileNo          [IN]            Index of attachment
  783.  *  path_buff       [IN/OUT]        Buffer to store the file path+name
  784.  * RETURNS
  785.  *  void
  786.  *****************************************************************************/
  787. void mmi_email_util_get_attch_name(S8 fileNo, S8 *path_buff)
  788. {
  789.     /*----------------------------------------------------------------*/
  790.     /* Local Variables                                                */
  791.     /*----------------------------------------------------------------*/
  792.     /*----------------------------------------------------------------*/
  793.     /* Code Body                                                      */
  794.     /*----------------------------------------------------------------*/
  795.     pfnUnicodeStrcpy((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  796.     pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_ATTACH_FILE_NAME));
  797.     pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_num_2_ucs2_str(fileNo));
  798. }
  799. /*****************************************************************************
  800.  * FUNCTION
  801.  *  mmi_email_util_get_sig_name
  802.  * DESCRIPTION
  803.  *  Get file name of signature.
  804.  * PARAMETERS
  805.  *  fileNo          [IN]            Index of profile
  806.  *  path_buff       [IN/OUT]        Buffer to store the file path+name
  807.  * RETURNS
  808.  *  void
  809.  *****************************************************************************/
  810. void mmi_email_util_get_sig_name(S8 fileNo, S8 *path_buff)
  811. {
  812.     /*----------------------------------------------------------------*/
  813.     /* Local Variables                                                */
  814.     /*----------------------------------------------------------------*/
  815.     /*----------------------------------------------------------------*/
  816.     /* Code Body                                                      */
  817.     /*----------------------------------------------------------------*/
  818.     pfnUnicodeStrcpy((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  819.     pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_SIG_FILE_NAME));
  820.     pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_num_2_ucs2_str(fileNo));
  821. }
  822. /*****************************************************************************
  823.  * FUNCTION
  824.  *  mmi_email_fldr_read_cont
  825.  * DESCRIPTION
  826.  *  Read content from file system and convert to UCS2.
  827.  * PARAMETERS
  828.  *  fileNo          [IN]            Index of attachment
  829.  *  in_len          [IN]            Length of data to be read (in bytes)
  830.  *  ch_set          [IN]            Charset of file content
  831.  *  out_buff        [IN/OUT]        Pointer to the address whitch stores the output data
  832.  *  out_len         [IN]            Stores the size of output data (in bytes)
  833.  * RETURNS
  834.  *  void
  835.  *****************************************************************************/
  836. S8 mmi_email_fldr_read_cont(S8 fileNo, S32 in_len, email_charset_enum ch_set, U8 **out_buff, U16 *out_len)
  837. {
  838.     /*----------------------------------------------------------------*/
  839.     /* Local Variables                                                */
  840.     /*----------------------------------------------------------------*/
  841.     FILE_HANDLE file_h;
  842.     U32 errorCode = 0;
  843.     S8 *filepath;
  844.     S8 result = FALSE;
  845.     /*----------------------------------------------------------------*/
  846.     /* Code Body                                                      */
  847.     /*----------------------------------------------------------------*/
  848.     if (in_len == 0)
  849.     {
  850.         return FALSE;
  851.     }
  852.     else if (in_len > EMAIL_MAX_CONT_LEN * EMAIL_UTF8_ENCODING_LENGTH)
  853.     {
  854.         in_len = EMAIL_MAX_CONT_LEN * EMAIL_UTF8_ENCODING_LENGTH;
  855.     }
  856.     filepath = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  857.     mmi_email_util_get_cont_name(fileNo, (S8*) filepath);
  858.     file_h = pfopen(filepath, PFS_READ);
  859.     if (file_h > 0)
  860.     {
  861.         FS_Read(file_h, &email_p->misc_info.cont_inline_buff, in_len, &errorCode);
  862.         /* pfread (&email_p->misc_info.cont_inline_buff, 1, in_len, file_h, &errorCode); */
  863.         email_p->misc_info.cont_inline_buff[in_len] = 0;
  864.         email_p->misc_info.cont_inline_buff[in_len + 1] = 0;
  865.         pfclose(file_h);
  866.         if (errorCode > 0)
  867.         {
  868.             *out_buff = mmi_email_util_chset_to_ucs2(
  869.                             (U8*) email_p->misc_info.cont_inline_buff,
  870.                             (U16) in_len,
  871.                             (U8) ch_set,
  872.                             out_len);
  873.             result = TRUE;
  874.         }
  875.         else
  876.         {
  877.             *out_buff = NULL;
  878.             *out_len = 0;
  879.         }
  880.     }
  881.     /* result cont_inline_buff buffer because it's temporary usage */
  882.     email_p->misc_info.cont_inline_buff[0] = 0;
  883.     email_p->misc_info.cont_inline_buff[1] = 0;
  884.     OslMfree(filepath);
  885.     return result;
  886. }
  887. /*****************************************************************************
  888.  * FUNCTION
  889.  *  mmi_email_util_get_cont_size
  890.  * DESCRIPTION
  891.  *  Get file size of each content file
  892.  * PARAMETERS
  893.  *  totalTextMsg            [IN]        Total number of content file.
  894.  *  outContentDataSize      [IN]        Buffer to store size of each content file
  895.  * RETURNS
  896.  *  void
  897.  *****************************************************************************/
  898. void mmi_email_util_get_cont_size(U8 totalTextMsg, S32 *outContentDataSize)
  899. {
  900.     /*----------------------------------------------------------------*/
  901.     /* Local Variables                                                */
  902.     /*----------------------------------------------------------------*/
  903.     S32 i;
  904.     FILE_HANDLE emailContentFilePtr;
  905.     S8 *emailContentFileNameBuf = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  906.     /*----------------------------------------------------------------*/
  907.     /* Code Body                                                      */
  908.     /*----------------------------------------------------------------*/
  909.     for (i = 0; i < totalTextMsg; i++)
  910.     {
  911.         pfnUnicodeStrcpy(
  912.             (S8*) emailContentFileNameBuf,
  913.             (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  914.         pfnUnicodeStrcat(
  915.             (S8*) emailContentFileNameBuf,
  916.             (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_TEXT_FILE_NAME));
  917.         pfnUnicodeStrcat((S8*) emailContentFileNameBuf, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
  918.         emailContentFilePtr = pfopen(emailContentFileNameBuf, PFS_READ);
  919.         if (emailContentFilePtr < 0)
  920.         {
  921.             /* file open failed */
  922.             outContentDataSize[i] = 0;
  923.         }
  924.         else
  925.         {
  926.             outContentDataSize[i] = GetFSFileSize(emailContentFilePtr);
  927.             pfclose(emailContentFilePtr);
  928.         }
  929.     }
  930.     OslMfree(emailContentFileNameBuf);
  931. }
  932. /*****************************************************************************
  933.  * FUNCTION
  934.  *  mmi_email_util_rename_after_abort
  935.  * DESCRIPTION
  936.  *  Rollback file name from convention name to composed name, when abort sending
  937.  * PARAMETERS
  938.  *  fileNo              [IN]            Index of file
  939.  *  DestFilePathPtr     [IN/OUT]        Buffer to store file path+name after rename.
  940.  * RETURNS
  941.  *  void
  942.  *****************************************************************************/
  943. void mmi_email_util_rename_after_abort(S8 fileNo, S8 *DestFilePathPtr)
  944. {
  945.     /*----------------------------------------------------------------*/
  946.     /* Local Variables                                                */
  947.     /*----------------------------------------------------------------*/
  948.     S8 *attachDefaultFileNameBuf = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  949.     /*----------------------------------------------------------------*/
  950.     /* Code Body                                                      */
  951.     /*----------------------------------------------------------------*/
  952.     mmi_email_util_get_attch_name(fileNo, (S8*) attachDefaultFileNameBuf);
  953.     pfdelete(DestFilePathPtr);
  954.     pfrename(attachDefaultFileNameBuf, DestFilePathPtr);
  955.     OslMfree(attachDefaultFileNameBuf);
  956. }
  957. /*****************************************************************************
  958.  * FUNCTION
  959.  *  mmi_email_util_rename_attch
  960.  * DESCRIPTION
  961.  *  Rename attachment to convention name
  962.  * PARAMETERS
  963.  *  fileNo              [IN]        Index of attachment
  964.  *  srcFilePathPtr      [IN]        Source file
  965.  * RETURNS
  966.  *  Error cause from file system.
  967.  *****************************************************************************/
  968. S32 mmi_email_util_rename_attch(S8 fileNo, S8 *srcFilePathPtr)
  969. {
  970.     /*----------------------------------------------------------------*/
  971.     /* Local Variables                                                */
  972.     /*----------------------------------------------------------------*/
  973.     S32 result;
  974.     S8 *attachDefaultFileNameBuf = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  975.     S8 *fileExt;
  976.     /*----------------------------------------------------------------*/
  977.     /* Code Body                                                      */
  978.     /*----------------------------------------------------------------*/
  979.     mmi_email_util_get_attch_name(fileNo, (S8*) attachDefaultFileNameBuf);
  980.     /* rename attachX.EXT to attachX. delete the destination file 
  981.        only if source file extension exists in case delete the same file. */
  982.     fileExt = mmi_email_get_file_ext(srcFilePathPtr);
  983.     if (fileExt != NULL)
  984.     {
  985.         pfdelete(attachDefaultFileNameBuf);
  986.     }
  987.     result = pfrename(srcFilePathPtr, attachDefaultFileNameBuf);
  988.     OslMfree(attachDefaultFileNameBuf);
  989.     return result;
  990. }
  991. /*****************************************************************************
  992.  * FUNCTION
  993.  *  mmi_email_util_rename_default_to_read
  994.  * DESCRIPTION
  995.  *  Rename default attachment name to the name use in Read Email screen
  996.  * PARAMETERS
  997.  *  void
  998.  * RETURNS
  999.  *  void
  1000.  *****************************************************************************/
  1001. void mmi_email_util_rename_default_to_read(void)
  1002. {
  1003.     /*----------------------------------------------------------------*/
  1004.     /* Local Variables                                                */
  1005.     /*----------------------------------------------------------------*/
  1006.     S32 i, j;
  1007.     S8 *fileExt;
  1008.     S8 *orig_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1009.     S8 *new_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1010.     /*----------------------------------------------------------------*/
  1011.     /* Code Body                                                      */
  1012.     /*----------------------------------------------------------------*/
  1013.     for (i = 0, j = 0; i < email_p->inbox_info.read_info.total_attch; i++)
  1014.     {
  1015.         /* Original name */
  1016.         mmi_email_util_get_attch_name((U8) (i + 1), orig_name);
  1017.         /* Read name */
  1018.         pfnUnicodeStrcpy((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  1019.         pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
  1020.         pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_READ_TMP_FILE_NAME));
  1021.         pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
  1022.         fileExt = mmi_email_get_file_ext((S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
  1023.         pfnUnicodeStrcat((S8*) new_name, (S8*) fileExt);
  1024.         /* delete if the same file name is existing */
  1025.         pfdelete(new_name);
  1026.         if (pfrename(orig_name, new_name) == FS_NO_ERROR)
  1027.         {
  1028.             pfnUnicodeStrcpy((S8*) email_p->inbox_info.read_info.attch_list[i].file_path, (S8*) new_name);
  1029.             email_p->inbox_info.read_info.attch_list[i].attch_present = TRUE;
  1030.             j++;
  1031.         }
  1032.     }
  1033.     email_p->inbox_info.read_info.total_attch = j;
  1034.     OslMfree(orig_name);
  1035.     OslMfree(new_name);
  1036. }
  1037. /*****************************************************************************
  1038.  * FUNCTION
  1039.  *  mmi_email_util_rename_default_to_comp
  1040.  * DESCRIPTION
  1041.  *  Rename default attachment name to the name use in Write Email screen
  1042.  * PARAMETERS
  1043.  *  void
  1044.  * RETURNS
  1045.  *  void
  1046.  *****************************************************************************/
  1047. void mmi_email_util_rename_default_to_comp(void)
  1048. {
  1049.     /*----------------------------------------------------------------*/
  1050.     /* Local Variables                                                */
  1051.     /*----------------------------------------------------------------*/
  1052.     S32 i, j;
  1053.     S32 fileSize;
  1054.     S8 *fileExt;
  1055.     S8 *orig_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1056.     S8 *new_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1057.     /*----------------------------------------------------------------*/
  1058.     /* Code Body                                                      */
  1059.     /*----------------------------------------------------------------*/
  1060.     email_p->comp_info.total_attch_size = 0;
  1061.     
  1062.     for (i = 0, j = 0; i < email_p->inbox_info.read_info.total_attch; i++)
  1063.     {
  1064.         /* Original name */
  1065.         mmi_email_util_get_attch_name((U8) (i + 1), orig_name);
  1066.         /* new name */
  1067.         pfnUnicodeStrcpy((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  1068.         pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
  1069.         pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_COMP_TMP_FILE_NAME));
  1070.         pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
  1071.         fileExt = mmi_email_get_file_ext((S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
  1072.         pfnUnicodeStrcat((S8*) new_name, (S8*) fileExt);
  1073.         /* delete if the same file name is existing */
  1074.         pfdelete(new_name);
  1075.         if (pfrename(orig_name, new_name) == FS_NO_ERROR)
  1076.         {
  1077.             pfnUnicodeStrcpy(
  1078.                 (S8*) email_p->comp_info.attch_list[j].file_name,
  1079.                 (S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
  1080.             pfnUnicodeStrcpy((S8*) email_p->comp_info.attch_list[i].file_path, (S8*) new_name);
  1081.             email_p->comp_info.attch_list[j].attch_type = email_p->inbox_info.read_info.attch_list[i].attch_type;
  1082.             email_p->comp_info.attch_list[j].attch_subtype = email_p->inbox_info.read_info.attch_list[i].attch_subtype;
  1083.             email_p->comp_info.attch_list[j].ch_set = email_p->inbox_info.read_info.attch_list[i].ch_set;
  1084.             email_p->comp_info.attch_list[j].attch_present = TRUE;
  1085.             /* calculate file size */
  1086.             mmi_email_util_get_file_size((S8*) email_p->comp_info.attch_list[j].file_path, &fileSize);
  1087.             /* update total attachment size */
  1088.             email_p->comp_info.total_attch_size += fileSize;
  1089.             j++;            
  1090.         }        
  1091.         PRINT_INFORMATION(("n[mmi_email_util_rename_default_to_comp] Updated Total comp_info Size: %dn", email_p->comp_info.total_attch_size));
  1092.     }
  1093.     email_p->comp_info.total_attch = j;
  1094.     
  1095.     OslMfree(orig_name);
  1096.     OslMfree(new_name);
  1097. }
  1098. /*****************************************************************************
  1099.  * FUNCTION
  1100.  *  mmi_email_util_rename_read_to_comp
  1101.  * DESCRIPTION
  1102.  *  Rename Read attachment name to Compose attachment.
  1103.  *  If any error happens for an attachment, set the attachment to empty.
  1104.  * PARAMETERS
  1105.  *  void
  1106.  * RETURNS
  1107.  *  void
  1108.  *****************************************************************************/
  1109. void mmi_email_util_rename_read_to_comp(void)
  1110. {
  1111.     /*----------------------------------------------------------------*/
  1112.     /* Local Variables                                                */
  1113.     /*----------------------------------------------------------------*/
  1114.     S32 i, j;
  1115.     S32 fileSize;
  1116.     S8 *fileExt;
  1117.     S8 *comp_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1118.     /*----------------------------------------------------------------*/
  1119.     /* Code Body                                                      */
  1120.     /*----------------------------------------------------------------*/
  1121.     email_p->comp_info.total_attch_size = 0;
  1122.     
  1123.     for (i = 0, j = 0; i < email_p->inbox_info.read_info.total_attch; i++)
  1124.     {
  1125.         /* chcek file size */
  1126.         if (mmi_email_util_get_file_size((S8*) email_p->inbox_info.read_info.attch_list[i].file_path, &fileSize) ==
  1127.             FS_NO_ERROR)
  1128.         {
  1129.             /* ensure previous total attachment size + current attachment size no greater than 90K */
  1130.             // if (fileSize <= MMI_EMAIL_MAX_ATTACH_SIZE)
  1131.             if (email_p->inbox_info.read_info.total_attch_size + fileSize <= MMI_EMAIL_TOTAL_MAX_ATTACH_SIZE)
  1132.             {
  1133.                 /* delete if the same file name is existing */
  1134.                 pfnUnicodeStrcpy((S8*) comp_name, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  1135.                 pfnUnicodeStrcat((S8*) comp_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
  1136.                 pfnUnicodeStrcat((S8*) comp_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_COMP_TMP_FILE_NAME));
  1137.                 pfnUnicodeStrcat((S8*) comp_name, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
  1138.                 fileExt = mmi_email_get_file_ext((S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
  1139.                 pfnUnicodeStrcat((S8*) comp_name, (S8*) fileExt);
  1140.                 pfdelete(comp_name);
  1141.                 /* rename */
  1142.                 if (pfrename((S8*) email_p->inbox_info.read_info.attch_list[i].file_path, comp_name) == FS_NO_ERROR)
  1143.                 {
  1144.                     pfnUnicodeStrcpy(
  1145.                         (S8*) email_p->comp_info.attch_list[j].file_name,
  1146.                         (S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
  1147.                     pfnUnicodeStrcpy((S8*) email_p->comp_info.attch_list[j].file_path, (S8*) comp_name);
  1148.                     email_p->comp_info.attch_list[j].attch_type =
  1149.                         email_p->inbox_info.read_info.attch_list[i].attch_type;
  1150.                     email_p->comp_info.attch_list[j].attch_subtype =
  1151.                         email_p->inbox_info.read_info.attch_list[i].attch_subtype;
  1152.                     email_p->comp_info.attch_list[j].ch_set = email_p->inbox_info.read_info.attch_list[i].ch_set;
  1153.                     email_p->comp_info.attch_list[j].attch_present = TRUE;                    
  1154.                     /* update total attachment size */
  1155.                     email_p->comp_info.total_attch_size += fileSize;
  1156.                     /* rename successfully, continue next file */
  1157.                     j++;
  1158.                 }
  1159.                 PRINT_INFORMATION(("n[mmi_email_util_rename_read_to_comp] Updated Total comp_info Size: %dn", email_p->comp_info.total_attch_size));
  1160.             }
  1161.             else
  1162.             {
  1163.                 /* file size exceeded */
  1164.                 email_p->comp_info.attch_exceed = TRUE;
  1165.             }
  1166.         }
  1167.     }
  1168.     email_p->comp_info.total_attch = j;
  1169.     
  1170.     OslMfree(comp_name);
  1171. }
  1172. /*****************************************************************************
  1173.  * FUNCTION
  1174.  *  mmi_email_util_create_working_dir
  1175.  * DESCRIPTION
  1176.  *  Create working directory
  1177.  * PARAMETERS
  1178.  *  void
  1179.  * RETURNS
  1180.  *  void
  1181.  *****************************************************************************/
  1182. void mmi_email_util_create_working_dir(void)
  1183. {
  1184.     /*----------------------------------------------------------------*/
  1185.     /* Local Variables                                                */
  1186.     /*----------------------------------------------------------------*/
  1187.     U8 *createFolder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1188.     /*----------------------------------------------------------------*/
  1189.     /* Code Body                                                      */
  1190.     /*----------------------------------------------------------------*/
  1191.     pfnUnicodeStrcpy((S8*) createFolder, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  1192.     pfnUnicodeStrcat((S8*) createFolder, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
  1193.     pcreateDir(createFolder);
  1194.     OslMfree(createFolder);
  1195. }
  1196. /*****************************************************************************
  1197.  * FUNCTION
  1198.  *  mmi_email_read_copy_attch
  1199.  * DESCRIPTION
  1200.  *  Copy attachment from file buffer to user selected path
  1201.  * PARAMETERS
  1202.  *  fileNo          [IN]        Index of file buffer.
  1203.  *  attchName       [IN]        File name to be saved
  1204.  * RETURNS
  1205.  *  void
  1206.  *****************************************************************************/
  1207. S8 mmi_email_read_copy_attch(S8 fileNo, S8 *attchName)
  1208. {
  1209.     /*----------------------------------------------------------------*/
  1210.     /* Local Variables                                                */
  1211.     /*----------------------------------------------------------------*/
  1212.     FILE_HANDLE fh;
  1213.     /*----------------------------------------------------------------*/
  1214.     /* Code Body                                                      */
  1215.     /*----------------------------------------------------------------*/
  1216.     /* path too long */
  1217.     if ((pfnUnicodeStrlen((S8*) email_p->comm_buff) + pfnUnicodeStrlen((S8*) attchName) +
  1218.          pfnUnicodeStrlen((S8*) email_p->fileext_buff)) > FMGR_MAX_PATH_LEN)
  1219.     {
  1220.         return EMAIL_SAVE_ATTACH_NAME_TOO_LONG;
  1221.     }
  1222.     /* file name empty */
  1223.     if (pfnUnicodeStrlen((S8*) attchName) == 0)
  1224.     {
  1225.         return EMAIL_SAVE_ATTACH_EMPTY_NAME;
  1226.     }
  1227.     if (email_p->inbox_info.attch_dest_path == NULL)
  1228.     {
  1229.         email_p->inbox_info.attch_dest_path = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1230.     }
  1231.     /* duplicated file name */
  1232.     pfnUnicodeStrcpy((S8*) email_p->inbox_info.attch_dest_path, (S8*) email_p->comm_buff);
  1233.     pfnUnicodeStrcat(email_p->inbox_info.attch_dest_path, (S8*) attchName);
  1234.     pfnUnicodeStrcat(email_p->inbox_info.attch_dest_path, (S8*) email_p->fileext_buff);
  1235.     fh = pfopen(email_p->inbox_info.attch_dest_path, PFS_READ);
  1236.     if (fh > 0)
  1237.     {
  1238.         OslMfree(email_p->inbox_info.attch_dest_path);
  1239.         email_p->inbox_info.attch_dest_path = NULL;
  1240.         pfclose(fh);
  1241.         return EMAIL_SAVE_ATTACH_DUP_NAME;
  1242.     }
  1243.     /* send copy request to fmt ask */
  1244.     FS_Delete((U16*) email_p->inbox_info.attch_dest_path);
  1245.     mmi_fmgr_send_copy_req(
  1246.         FMGR_ACTION_COPY,
  1247.         (U8*) email_p->inbox_info.read_info.attch_list[email_p->misc_info.curr_hilite_attch]. file_path,
  1248.         (U8*) email_p->inbox_info.attch_dest_path,
  1249.         mmi_email_read_attch_copy_callback);
  1250.     return EMAIL_SAVE_ATTACH_NO_ERR;
  1251. }
  1252. /*****************************************************************************
  1253.  * FUNCTION
  1254.  *  mmi_email_read_attch_copy_callback
  1255.  * DESCRIPTION
  1256.  *  Callback function for saving attachment to file manager
  1257.  * PARAMETERS
  1258.  *  info        [IN]        Result of savng attachment
  1259.  * RETURNS
  1260.  *  void
  1261.  *****************************************************************************/
  1262. void mmi_email_read_attch_copy_callback(void *info)
  1263. {
  1264.     /*----------------------------------------------------------------*/
  1265.     /* Local Variables                                                */
  1266.     /*----------------------------------------------------------------*/
  1267.     /* display done and go back to option screen */
  1268.     mmi_fmt_copy_rsp_strcut *msgPtr;
  1269.     /*----------------------------------------------------------------*/
  1270.     /* Code Body                                                      */
  1271.     /*----------------------------------------------------------------*/
  1272.     msgPtr = (mmi_fmt_copy_rsp_strcut*) info;
  1273.     OslMfree(email_p->inbox_info.attch_dest_path);
  1274.     email_p->inbox_info.attch_dest_path = NULL;
  1275.     if (mmi_email_util_is_call_interrupt_allow() && GetExitScrnID() != SCR_ID_EMAIL_PROGRESS)
  1276.     {
  1277.         /* delete progressing screen */
  1278.         DeleteScreenIfPresent(SCR_ID_EMAIL_PROGRESS);
  1279.         return;
  1280.     }
  1281.     if (msgPtr->result >= 0)
  1282.     {
  1283.         DisplayPopup(
  1284.             (U8*) GetString(STR_GLOBAL_DONE),
  1285.             IMG_GLOBAL_ACTIVATED,
  1286.             0,
  1287.             UI_POPUP_NOTIFYDURATION_TIME,
  1288.             SUCCESS_TONE);
  1289.     }
  1290.     else
  1291.     {
  1292.         DisplayPopup((U8*) GetString(GetFileSystemErrorString(msgPtr->result)), IMG_GLOBAL_ERROR, 0, 1000, ERROR_TONE);
  1293.     }
  1294.     DeleteScreenIfPresent(SCR_ID_EMAIL_PROGRESS);
  1295. }
  1296. /*****************************************************************************
  1297.  * FUNCTION
  1298.  *  mmi_email_get_file_ext
  1299.  * DESCRIPTION
  1300.  *  Get file extension of a file name
  1301.  * PARAMETERS
  1302.  *  pFileName       [?]         
  1303.  *  info(?)         [IN]        Result of savng attachment
  1304.  * RETURNS
  1305.  *  void
  1306.  *****************************************************************************/
  1307. S8 *mmi_email_get_file_ext(S8 *pFileName)
  1308. {
  1309.     /*----------------------------------------------------------------*/
  1310.     /* Local Variables                                                */
  1311.     /*----------------------------------------------------------------*/
  1312.     S32 nLength;
  1313.     S8 *pFilePtr = NULL;
  1314.     /*----------------------------------------------------------------*/
  1315.     /* Code Body                                                      */
  1316.     /*----------------------------------------------------------------*/
  1317.     nLength = pfnUnicodeStrlen(pFileName);
  1318.     --nLength;
  1319.     nLength *= ENCODING_LENGTH;
  1320.     while (nLength && (pFileName[nLength] != '.') && (pFileName[nLength - 1] == ''))
  1321.     {
  1322.         nLength -= 2;
  1323.     }
  1324.     if (nLength)
  1325.     {
  1326.         pFilePtr = pFileName + nLength;
  1327.     }
  1328.     return pFilePtr;
  1329. }
  1330. /*****************************************************************************
  1331.  * FUNCTION
  1332.  *  mmi_email_fs_del_all_tmp_file_rsp
  1333.  * DESCRIPTION
  1334.  *  Response handle for folder_delete_rsp
  1335.  * PARAMETERS
  1336.  *  info        [IN]        Struct variable for response message
  1337.  * RETURNS
  1338.  *  void
  1339.  *****************************************************************************/
  1340. void mmi_email_fs_del_all_tmp_file_rsp(void *info)
  1341. {
  1342.     /*----------------------------------------------------------------*/
  1343.     /* Local Variables                                                */
  1344.     /*----------------------------------------------------------------*/
  1345.     mmi_fmt_delete_rsp_strcut *msgPtr;
  1346.     /*----------------------------------------------------------------*/
  1347.     /* Code Body                                                      */
  1348.     /*----------------------------------------------------------------*/
  1349.     msgPtr = (mmi_fmt_delete_rsp_strcut*) info;
  1350.     email_p->main_info.ready_state |= EMAIL_CLEAR_BUFF_DONE;
  1351.     /* create dir again */
  1352.     mmi_email_util_create_working_dir();
  1353.     if (msgPtr->result >= FS_NO_ERROR)
  1354.     {
  1355.         return;
  1356.     }
  1357. }
  1358. /*****************************************************************************
  1359.  * FUNCTION
  1360.  *  mmi_email_fs_del_all_tmp_file_req
  1361.  * DESCRIPTION
  1362.  *  Delete temporary file folder.
  1363.  * PARAMETERS
  1364.  *  void
  1365.  * RETURNS
  1366.  *  void
  1367.  *****************************************************************************/
  1368. void mmi_email_fs_del_all_tmp_file_req(void)
  1369. {
  1370.     /*----------------------------------------------------------------*/
  1371.     /* Local Variables                                                */
  1372.     /*----------------------------------------------------------------*/
  1373.     S8 *fldr_path = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  1374.     /*----------------------------------------------------------------*/
  1375.     /* Code Body                                                      */
  1376.     /*----------------------------------------------------------------*/
  1377.     pfnUnicodeStrcpy((S8*) fldr_path, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
  1378.     pfnUnicodeStrcat((S8*) fldr_path, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
  1379.     pfnUnicodeStrcpy((S8*) email_p->comm_buff, fldr_path);
  1380.     mmi_fmgr_send_delete_req((U8*) email_p->comm_buff, FS_DIR_TYPE, mmi_email_fs_del_all_tmp_file_rsp);
  1381.     OslMfree(fldr_path);
  1382. }
  1383. /*****************************************************************************
  1384.  * FUNCTION
  1385.  *  mmi_email_util_get_file_size
  1386.  * DESCRIPTION
  1387.  *  Get size of a file
  1388.  * PARAMETERS
  1389.  *  filePathPtr         [?]             
  1390.  *  fileSizePtr         [?]             
  1391.  *  filePathPrt(?)      [IN]            File path and name
  1392.  *  fileSizePrt(?)      [IN/OUT]        Address to store the size of file
  1393.  * RETURNS
  1394.  *  Error cause of file open
  1395.  *****************************************************************************/
  1396. S32 mmi_email_util_get_file_size(S8 *filePathPtr, S32 *fileSizePtr)
  1397. {
  1398.     /*----------------------------------------------------------------*/
  1399.     /* Local Variables                                                */
  1400.     /*----------------------------------------------------------------*/
  1401.     FILE_HANDLE fileHandle = pfopen(filePathPtr, PFS_READ);
  1402.     /*----------------------------------------------------------------*/
  1403.     /* Code Body                                                      */
  1404.     /*----------------------------------------------------------------*/
  1405.     if (fileHandle > 0)
  1406.     {
  1407.         *fileSizePtr = GetFSFileSize(fileHandle);
  1408.         pfclose(fileHandle);
  1409.         return FS_NO_ERROR;
  1410.     }
  1411.     return fileHandle;
  1412. }
  1413. /*****************************************************************************
  1414.  * FUNCTION
  1415.  *  mmi_email_util_check_file_exist
  1416.  * DESCRIPTION
  1417.  *  To check whether file exist or not
  1418.  * PARAMETERS
  1419.  *  filePathPtr     [IN]        File path
  1420.  * RETURNS
  1421.  *  TURE of file exists; otherwise FALSE.
  1422.  *****************************************************************************/
  1423. S32 mmi_email_util_check_file_exist(S8 *filePathPtr)
  1424. {
  1425.     /*----------------------------------------------------------------*/
  1426.     /* Local Variables                                                */
  1427.     /*----------------------------------------------------------------*/
  1428.     FILE_HANDLE fileHandle;
  1429.     /*----------------------------------------------------------------*/
  1430.     /* Code Body                                                      */
  1431.     /*----------------------------------------------------------------*/
  1432.     /* if file already exist */
  1433.     fileHandle = pfopen((U16*) filePathPtr, PFS_READ);
  1434.     if (fileHandle > 0)
  1435.     {
  1436.         pfclose(fileHandle);
  1437.         return FS_NO_ERROR;
  1438.     }
  1439.     return fileHandle;
  1440. }
  1441. #define SCR_UTIL_EMAIL
  1442. /*****************************************************************************
  1443.  * FUNCTION
  1444.  *  mmi_email_util_add_history
  1445.  * DESCRIPTION
  1446.  *  Common function to add history node when exiting a screen.
  1447.  *  The logic of this function depends on the flag "insert_hist".
  1448.  *  This flag determines if the screen shall be added to history or inserted before CM screen
  1449.  * PARAMETERS
  1450.  *  scrnId              [IN]        Screen index
  1451.  *  entryFuncPtr        [IN]        Pointer of the screen entry function
  1452.  * RETURNS
  1453.  *  void
  1454.  *****************************************************************************/
  1455. void mmi_email_util_add_history(U16 scrnId, FuncPtr entryFuncPtr)
  1456. {
  1457.     /*----------------------------------------------------------------*/
  1458.     /* Local Variables                                                */
  1459.     /*----------------------------------------------------------------*/
  1460.     history currHistory;
  1461.     S16 ucs2InputBuffer = 0;
  1462.     /*----------------------------------------------------------------*/
  1463.     /* Code Body                                                      */
  1464.     /*----------------------------------------------------------------*/
  1465.     currHistory.scrnID = scrnId;
  1466.     currHistory.entryFuncPtr = entryFuncPtr;
  1467.     pfnUnicodeStrcpy((S8*) currHistory.inputBuffer, (S8*) & ucs2InputBuffer);
  1468.     if (!email_p->misc_info.insert_hist)
  1469.     {
  1470.         GetCategoryHistory(currHistory.guiBuffer);
  1471.         AddHistory(currHistory);
  1472.     }
  1473.     else
  1474.     {
  1475.         U16 cmScrnId = GetCmMarkerScrnID();
  1476.         if (IsScreenPresent(cmScrnId))
  1477.         {
  1478.             InsertHistoryBeforeThisScrn(cmScrnId, currHistory);
  1479.         }
  1480.         else
  1481.         {
  1482.             AddHistory(currHistory);
  1483.         }
  1484.     }
  1485.     email_p->misc_info.insert_hist = FALSE;
  1486. }
  1487. /*****************************************************************************
  1488.  * FUNCTION
  1489.  *  mmi_email_util_add_n_history
  1490.  * DESCRIPTION
  1491.  *  Common function to add a category 57 history node when exiting a screen.
  1492.  *  The logic of this function depends on the flag "insert_hist".
  1493.  *  This flag determines if the screen shall be added to history or inserted before CM screen
  1494.  * PARAMETERS
  1495.  *  scrnId              [IN]        Screen index
  1496.  *  entryFuncPtr        [IN]        Pointer of the screen entry function
  1497.  * RETURNS
  1498.  *  void
  1499.  *****************************************************************************/
  1500. void mmi_email_util_add_n_history(U16 scrnId, FuncPtr entryFuncPtr)
  1501. {
  1502.     /*----------------------------------------------------------------*/
  1503.     /* Local Variables                                                */
  1504.     /*----------------------------------------------------------------*/
  1505.     history currHistory;
  1506.     /*----------------------------------------------------------------*/
  1507.     /* Code Body                                                      */
  1508.     /*----------------------------------------------------------------*/
  1509.     currHistory.scrnID = scrnId;
  1510.     currHistory.entryFuncPtr = entryFuncPtr;
  1511.     if (!email_p->misc_info.insert_hist)
  1512.     {
  1513.         U16 inputBufferSize = 0;
  1514.         CloseCategory57Screen();
  1515.         GetCategoryHistory(currHistory.guiBuffer);
  1516.         inputBufferSize = (U16) GetCategory57DataSize();
  1517.         GetCategory57Data((U8*) currHistory.inputBuffer);
  1518.         AddNHistory(currHistory, inputBufferSize);
  1519.     }
  1520.     else
  1521.     {
  1522.         U16 cmScrnId = GetCmMarkerScrnID();
  1523.         if (IsScreenPresent(cmScrnId))
  1524.         {
  1525.             InsertHistoryBeforeThisScrn(cmScrnId, currHistory);
  1526.         }
  1527.         else
  1528.         {
  1529.             AddHistory(currHistory);
  1530.         }
  1531.     }
  1532.     email_p->misc_info.insert_hist = FALSE;
  1533. }
  1534. /*****************************************************************************
  1535.  * FUNCTION
  1536.  *  mmi_email_util_go_back_2_hist
  1537.  * DESCRIPTION
  1538.  *  Go back to previosu 2 screen.
  1539.  * PARAMETERS
  1540.  *  void
  1541.  * RETURNS
  1542.  *  void
  1543.  *****************************************************************************/
  1544. void mmi_email_util_go_back_2_hist(void)
  1545. {
  1546.     /*----------------------------------------------------------------*/
  1547.     /* Local Variables                                                */
  1548.     /*----------------------------------------------------------------*/
  1549.     /*----------------------------------------------------------------*/
  1550.     /* Code Body                                                      */
  1551.     /*----------------------------------------------------------------*/
  1552.     GoBacknHistory(1);
  1553. }
  1554. /*****************************************************************************
  1555.  * FUNCTION
  1556.  *  mmi_email_util_folder_select_cap_str
  1557.  * DESCRIPTION
  1558.  *  Construct caption string of folder according to current protocol.
  1559.  * PARAMETERS
  1560.  *  strCaptionId        [IN]        
  1561.  * RETURNS
  1562.  *  void
  1563.  *****************************************************************************/
  1564. U8 *mmi_email_util_folder_select_cap_str(U16 strCaptionId)
  1565. {
  1566. #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
  1567.     /*----------------------------------------------------------------*/
  1568.     /* Local Variables                                                */
  1569.     /*----------------------------------------------------------------*/
  1570.     /*----------------------------------------------------------------*/
  1571.     /* Code Body                                                      */
  1572.     /*----------------------------------------------------------------*/
  1573.     /* Unsent folder is not related to IMAP4 protocol */
  1574.     if (email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4 && strCaptionId != STR_EMAIL_COMMON_UNSENT_ID)
  1575.     {
  1576.         S8 *asciiPageNumberInfoBuff = OslMalloc(EMAIL_MAX_FLDR_CAP_LEN);
  1577.         S8 *ucs2PageNumberInfoBuff = OslMalloc(EMAIL_MAX_FLDR_CAP_LEN * ENCODING_LENGTH);
  1578.         sprintf(
  1579.             (S8*) asciiPageNumberInfoBuff,
  1580.             " [%d/%d]",
  1581.             email_p->fldr_info.curr_page,
  1582.             email_p->fldr_info.total_page);
  1583.         AnsiiToUnicodeString((S8*) ucs2PageNumberInfoBuff, (S8*) asciiPageNumberInfoBuff);
  1584.         pfnUnicodeStrcpy((S8*) email_p->misc_info.folder_cap_buff, (S8*) GetString(strCaptionId));
  1585.         pfnUnicodeStrcat((S8*) email_p->misc_info.folder_cap_buff, (S8*) ucs2PageNumberInfoBuff);
  1586.         OslMfree(asciiPageNumberInfoBuff);
  1587.         OslMfree(ucs2PageNumberInfoBuff);
  1588.         return (U8*) email_p->misc_info.folder_cap_buff;
  1589.     }
  1590. #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */ 
  1591.     return (U8*) GetString(strCaptionId);
  1592. }
  1593. /*****************************************************************************
  1594.  * FUNCTION
  1595.  *  mmi_email_util_del_between_scr
  1596.  * DESCRIPTION
  1597.  *  Delete Email screen between two screens
  1598.  * PARAMETERS
  1599.  *  start_scr       [IN]        Start screen id to be deleted
  1600.  *  end_scr         [IN]        End screen id to be deleted
  1601.  * RETURNS
  1602.  *  void
  1603.  *****************************************************************************/
  1604. void mmi_email_util_del_between_scr(U16 start_scr, U16 end_scr)
  1605. {
  1606.     /*----------------------------------------------------------------*/
  1607.     /* Local Variables                                                */
  1608.     /*----------------------------------------------------------------*/
  1609.     U16 next_scr;
  1610.     /*----------------------------------------------------------------*/
  1611.     /* Code Body                                                      */
  1612.     /*----------------------------------------------------------------*/
  1613.     while (GetNextScrnIdOf(start_scr, &next_scr))
  1614.     {
  1615.         if (next_scr == end_scr)
  1616.         {
  1617.             break;
  1618.         }
  1619.         else if (next_scr > SCR_ID_EMAIL_START && next_scr < SCR_ID_EMAIL_END)
  1620.         {
  1621.             DeleteScreenIfPresent(next_scr);
  1622.         }
  1623.         else
  1624.         {
  1625.             break;
  1626.         }
  1627.     }
  1628.     DeleteScreenIfPresent(end_scr);
  1629.     DeleteScreenIfPresent(start_scr);
  1630. }
  1631. /*****************************************************************************
  1632.  * FUNCTION
  1633.  *  mmi_email_util_del_upto_scr
  1634.  * DESCRIPTION
  1635.  *  Delete Email screen update to some screen
  1636.  * PARAMETERS
  1637.  *  end_scr     [IN]        End screen id to be deleted
  1638.  * RETURNS
  1639.  *  void
  1640.  *****************************************************************************/
  1641. void mmi_email_util_del_upto_scr(U16 end_scr)
  1642. {
  1643.     /*----------------------------------------------------------------*/
  1644.     /* Local Variables                                                */
  1645.     /*----------------------------------------------------------------*/
  1646.     U16 next_scr;
  1647.     /*----------------------------------------------------------------*/
  1648.     /* Code Body                                                      */
  1649.     /*----------------------------------------------------------------*/
  1650.     while (GetNextScrnIdOf(end_scr, &next_scr))
  1651.     {
  1652.         if (next_scr > SCR_ID_EMAIL_START && next_scr < SCR_ID_EMAIL_END)
  1653.         {
  1654.             DeleteScreenIfPresent(next_scr);
  1655.         }
  1656.         else
  1657.         {
  1658.             break;
  1659.         }
  1660.     }
  1661.     DeleteScreenIfPresent(end_scr);
  1662. }
  1663. /*****************************************************************************
  1664.  * FUNCTION
  1665.  *  mmi_email_util_display_err_popup
  1666.  * DESCRIPTION
  1667.  *  Common function to display popup screen
  1668.  * PARAMETERS
  1669.  *  minor               [IN]        Minor cause
  1670.  *  major               [IN]        Major cause
  1671.  *  startDelScrnId      [IN]        Starting index of screen to be deleted
  1672.  *  endDelScrnId        [IN]        End index of screen to be deleted
  1673.  * RETURNS
  1674.  *  void
  1675.  *****************************************************************************/
  1676. void mmi_email_util_display_err_popup(S32 minor, signed char major, U16 startDelScrnId, U16 endDelScrnId)
  1677. {
  1678.     /*----------------------------------------------------------------*/
  1679.     /* Local Variables                                                */
  1680.     /*----------------------------------------------------------------*/
  1681.     U16 errMsgId;
  1682.     /*----------------------------------------------------------------*/
  1683.     /* Code Body                                                      */
  1684.     /*----------------------------------------------------------------*/
  1685.     errMsgId = mmi_email_util_get_err_code(minor, major);
  1686.     DisplayPopup((U8*) GetString(errMsgId), IMG_GLOBAL_UNFINISHED, 1, UI_POPUP_NOTIFYDURATION_TIME, (U8) WARNING_TONE);
  1687.     if (startDelScrnId)
  1688.     {
  1689.         mmi_email_util_del_between_scr(startDelScrnId, endDelScrnId);
  1690.     }
  1691.     else
  1692.     {
  1693.         mmi_email_util_del_upto_scr(endDelScrnId);
  1694.     }
  1695. }
  1696. /*****************************************************************************
  1697.  * FUNCTION
  1698.  *  mmi_email_util_clear_end_key_hdlr
  1699.  * DESCRIPTION
  1700.  *  Clear all handlers of END key
  1701.  * PARAMETERS
  1702.  *  void
  1703.  * RETURNS
  1704.  *  void
  1705.  *****************************************************************************/
  1706. void mmi_email_util_clear_end_key_hdlr(void)
  1707. {
  1708.     /*----------------------------------------------------------------*/
  1709.     /* Local Variables                                                */
  1710.     /*----------------------------------------------------------------*/
  1711.     /*----------------------------------------------------------------*/
  1712.     /* Code Body                                                      */
  1713.     /*----------------------------------------------------------------*/
  1714.     ClearKeyHandler(KEY_END, KEY_EVENT_UP);
  1715.     ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1716.     ClearKeyHandler(KEY_END, KEY_LONG_PRESS);
  1717.     ClearKeyHandler(KEY_END, KEY_REPEAT);
  1718. }
  1719. #if !defined(__MMI_SLIM_EMAIL_NO_AUTO_CHECK__)
  1720. /*****************************************************************************
  1721.  * FUNCTION
  1722.  *  mmi_email_util_is_idle
  1723.  * DESCRIPTION
  1724.  *  To check if MMI is in IDLE screen.
  1725.  * PARAMETERS
  1726.  *  void
  1727.  * RETURNS
  1728.  *  TURE if MMI is in idle/screen saver mode; otherwise, FALSE.
  1729.  *****************************************************************************/
  1730. U8 mmi_email_util_is_idle(void) // #ifdef __MMI_SLIM_EMAIL_NO_AUTO_CHECK__
  1731. {
  1732.     /*----------------------------------------------------------------*/
  1733.     /* Local Variables                                                */
  1734.     /*----------------------------------------------------------------*/
  1735.     /*----------------------------------------------------------------*/
  1736.     /* Code Body                                                      */
  1737.     /*----------------------------------------------------------------*/
  1738.     if (g_idle_context.IsOnIdleScreen || g_idle_context.ScreenSaverRunFlag)
  1739.     {
  1740.         return TRUE;
  1741.     }
  1742.     else
  1743.     {
  1744.         return FALSE;
  1745.     }
  1746. }
  1747. /*****************************************************************************
  1748.  * FUNCTION
  1749.  *  mmi_email_util_is_key_locked
  1750.  * DESCRIPTION
  1751.  *  To check if MMI is in keypad lock screen.
  1752.  * PARAMETERS
  1753.  *  void
  1754.  * RETURNS
  1755.  *  TURE if MMI is in keypad-locked mode; otherwise, FALSE.
  1756.  *****************************************************************************/
  1757. U8 mmi_email_util_is_key_locked(void)   // #ifdef __MMI_SLIM_EMAIL_NO_AUTO_CHECK__
  1758. {
  1759.     /*----------------------------------------------------------------*/
  1760.     /* Local Variables                                                */
  1761.     /*----------------------------------------------------------------*/
  1762.     /*----------------------------------------------------------------*/
  1763.     /* Code Body                                                      */
  1764.     /*----------------------------------------------------------------*/
  1765.     return g_keylock_context.gKeyPadLockFlag;
  1766. }
  1767. #endif /* !defined(__MMI_SLIM_EMAIL_NO_AUTO_CHECK__) */ 
  1768. /*****************************************************************************
  1769.  * FUNCTION
  1770.  *  mmi_email_util_update_status_icon
  1771.  * DESCRIPTION
  1772.  *  Update status icon in IDLE screen.
  1773.  * PARAMETERS
  1774.  *  void
  1775.  * RETURNS
  1776.  *  void
  1777.  *****************************************************************************/
  1778. void mmi_email_util_update_status_icon(void)
  1779. {
  1780.     /*----------------------------------------------------------------*/
  1781.     /* Local Variables                                                */
  1782.     /*----------------------------------------------------------------*/
  1783.     /*----------------------------------------------------------------*/
  1784.     /* Code Body                                                      */
  1785.     /*----------------------------------------------------------------*/
  1786.     /* do not display status icon when flight mode is on */
  1787.     if (!mmi_bootup_get_active_flight_mode())
  1788.     {
  1789.         if (email_p->main_info.is_mem_full == FALSE)
  1790.         {
  1791.             HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
  1792.             if (email_p->main_info.unread_mails != 0)
  1793.             {
  1794.                 ShowStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
  1795.             }
  1796.             UpdateStatusIcons();
  1797.         }
  1798.         else
  1799.         {
  1800.             HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
  1801.             BlinkStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
  1802.             UpdateStatusIcons();
  1803.         }
  1804.     }
  1805. }
  1806. /*****************************************************************************
  1807.  * FUNCTION
  1808.  *  mmi_email_util_change_title
  1809.  * DESCRIPTION
  1810.  *  Change title string
  1811.  * PARAMETERS
  1812.  *  strId       [IN]        
  1813.  * RETURNS
  1814.  *  void
  1815.  *****************************************************************************/
  1816. void mmi_email_util_change_title(U16 strId)
  1817. {
  1818.     /*----------------------------------------------------------------*/
  1819.     /* Local Variables                                                */
  1820.     /*----------------------------------------------------------------*/
  1821.     /*----------------------------------------------------------------*/
  1822.     /* Code Body                                                      */
  1823.     /*----------------------------------------------------------------*/
  1824.     ChangeTitleString((U8*) GetString(strId));
  1825.     draw_title();
  1826. }
  1827. /*****************************************************************************
  1828.  * FUNCTION
  1829.  *  mmi_email_util_get_fldr_scr_id
  1830.  * DESCRIPTION
  1831.  *  Get screen id of current folder
  1832.  * PARAMETERS
  1833.  *  void
  1834.  * RETURNS
  1835.  *  Screen index
  1836.  *****************************************************************************/
  1837. U16 mmi_email_util_get_fldr_scr_id(void)
  1838. {
  1839.     /*----------------------------------------------------------------*/
  1840.     /* Local Variables                                                */
  1841.     /*----------------------------------------------------------------*/
  1842.     /*----------------------------------------------------------------*/
  1843.     /* Code Body                                                      */
  1844.     /*----------------------------------------------------------------*/
  1845.     switch (email_p->main_info.curr_menu)
  1846.     {
  1847.         case MMI_EMAIL_INBOX:
  1848.             return SCR_ID_EMAIL_INBOX;
  1849.         case MMI_EMAIL_UNSENT:
  1850.             return SCR_ID_EMAIL_UNSENT;
  1851.         case MMI_EMAIL_SENT:
  1852.             return SCR_ID_EMAIL_SENT;
  1853.         case MMI_EMAIL_DRAFT:
  1854.             return SCR_ID_EMAIL_DRAFT;
  1855.         default:
  1856.             return SCR_ID_EMAIL_MAIN;
  1857.     }
  1858. }
  1859. /*****************************************************************************
  1860.  * FUNCTION
  1861.  *  mmi_email_util_get_abort_func
  1862.  * DESCRIPTION
  1863.  *  Get function pointer of abort in progressing screen.
  1864.  * PARAMETERS
  1865.  *  void
  1866.  * RETURNS
  1867.  *  function pointer of abort function if required.
  1868.  *****************************************************************************/
  1869. FuncPtr mmi_email_util_get_abort_func(void)
  1870. {
  1871. #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
  1872.     /*----------------------------------------------------------------*/
  1873.     /* Local Variables                                                */
  1874.     /*----------------------------------------------------------------*/
  1875.     /*----------------------------------------------------------------*/
  1876.     /* Code Body                                                      */
  1877.     /*----------------------------------------------------------------*/
  1878.     if ((email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4) && (email_p->main_info.curr_menu != MMI_EMAIL_UNSENT))
  1879.     {
  1880.         return (FuncPtr) mmi_email_ps_abort_req;
  1881.     }
  1882. #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */ 
  1883.     return NULL;
  1884. }
  1885. /*****************************************************************************
  1886.  * FUNCTION
  1887.  *  mmi_email_util_is_call_interrupt_allow
  1888.  * DESCRIPTION
  1889.  *  To determine if interrupt from call is allowed
  1890.  * PARAMETERS
  1891.  *  void
  1892.  * RETURNS
  1893.  *  TURE if screen can be displayed; otherwise, FALSE.
  1894.  *****************************************************************************/
  1895. U8 mmi_email_util_is_call_interrupt_allow(void)
  1896. {
  1897.     /*----------------------------------------------------------------*/
  1898.     /* Local Variables                                                */
  1899.     /*----------------------------------------------------------------*/
  1900.     /*----------------------------------------------------------------*/
  1901.     /* Code Body                                                      */
  1902.     /*----------------------------------------------------------------*/
  1903.     if ((isInCall() == FALSE) || (isInCall() && GetWapCallPresent()))
  1904.     {
  1905.         return TRUE;
  1906.     }
  1907.     return FALSE;
  1908. }
  1909. /*****************************************************************************
  1910.  * FUNCTION
  1911.  *  mmi_email_util_abort_str
  1912.  * DESCRIPTION
  1913.  *  Get string id of abort key.
  1914.  *  If current protocol is POP3 or folder is Unsent, no abrot key reqired.
  1915.  * PARAMETERS
  1916.  *  void
  1917.  * RETURNS
  1918.  *  string index of abort key.
  1919.  *****************************************************************************/
  1920. U16 mmi_email_util_abort_str(void)
  1921. {
  1922. #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
  1923.     /*----------------------------------------------------------------*/
  1924.     /* Local Variables                                                */
  1925.     /*----------------------------------------------------------------*/
  1926.     /*----------------------------------------------------------------*/
  1927.     /* Code Body                                                      */
  1928.     /*----------------------------------------------------------------*/
  1929.     if ((email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4) && (email_p->main_info.curr_menu != MMI_EMAIL_UNSENT))
  1930.     {
  1931.         return STR_GLOBAL_ABORT;
  1932.     }
  1933. #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */ 
  1934.     return 0;
  1935. }
  1936. /*****************************************************************************
  1937.  * FUNCTION
  1938.  *  mmi_email_util_abort_img
  1939.  * DESCRIPTION
  1940.  *  Get image id of abort key.
  1941.  *  If current protocol is POP3 or folder is Unsent, no abrot key reqired.
  1942.  * PARAMETERS
  1943.  *  void
  1944.  * RETURNS
  1945.  *  image index of abort key.
  1946.  *****************************************************************************/
  1947. U16 mmi_email_util_abort_img(void)
  1948. {
  1949. #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
  1950.     /*----------------------------------------------------------------*/
  1951.     /* Local Variables                                                */
  1952.     /*----------------------------------------------------------------*/
  1953.     /*----------------------------------------------------------------*/
  1954.     /* Code Body                                                      */
  1955.     /*----------------------------------------------------------------*/
  1956.     if ((email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4) && (email_p->main_info.curr_menu != MMI_EMAIL_UNSENT))
  1957.     {
  1958.         return IMG_GLOBAL_BACK;
  1959.     }
  1960. #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */ 
  1961.     return 0;
  1962. }
  1963. #define MIME_UTIL_EMAIL
  1964. /*****************************************************************************
  1965.  * FUNCTION
  1966.  *  mmi_email_uti_tolower
  1967.  * DESCRIPTION
  1968.  *  Convert a character from upper case to lower case
  1969.  * PARAMETERS
  1970.  *  ch      [IN]        Character to be converted.
  1971.  * RETURNS
  1972.  *  result of the converting.
  1973.  *****************************************************************************/
  1974. U8 mmi_email_uti_tolower(U8 ch)
  1975. {
  1976.     /*----------------------------------------------------------------*/
  1977.     /* Local Variables                                                */
  1978.     /*----------------------------------------------------------------*/
  1979.     /*----------------------------------------------------------------*/
  1980.     /* Code Body                                                      */
  1981.     /*----------------------------------------------------------------*/
  1982.     if (ch >= 'A' && ch <= 'Z')
  1983.     {
  1984.         return (U8) (ch + ('a' - 'A'));
  1985.     }
  1986.     return ch;
  1987. }
  1988. /*****************************************************************************
  1989.  * FUNCTION
  1990.  *  mmi_email_uti_strnicmp
  1991.  * DESCRIPTION
  1992.  *  Compare two string without regarding upper/lower case
  1993.  * PARAMETERS
  1994.  *  src         [IN]        Source string
  1995.  *  dest        [IN]        Destination string
  1996.  *  maxlen      [IN]        Length of the string to be compared
  1997.  * RETURNS
  1998.  *  TRUE if two string is different; otherwise, FALSE.
  1999.  *****************************************************************************/
  2000. S8 mmi_email_uti_strnicmp(S8 *src, S8 *dest, S32 maxlen)
  2001. {
  2002.     /*----------------------------------------------------------------*/
  2003.     /* Local Variables                                                */
  2004.     /*----------------------------------------------------------------*/
  2005.     U8 ch1, ch2;
  2006.     S8 *s1, *s2;
  2007.     /*----------------------------------------------------------------*/
  2008.     /* Code Body                                                      */
  2009.     /*----------------------------------------------------------------*/
  2010.     s1 = src;
  2011.     s2 = dest;
  2012.     while (maxlen-- > 0)
  2013.     {
  2014.         ch1 = mmi_email_uti_tolower(*s1++);
  2015.         ch2 = mmi_email_uti_tolower(*s2++);
  2016.         if (ch1 != ch2)
  2017.         {
  2018.             return TRUE;
  2019.         }
  2020.     }
  2021.     return FALSE;
  2022. }
  2023. /*****************************************************************************
  2024.  * FUNCTION
  2025.  *  mmi_email_util_get_mine_type
  2026.  * DESCRIPTION
  2027.  *  Get mine type and mine subtype of a give file according to filename
  2028.  * PARAMETERS
  2029.  *  filename            [IN]        File name
  2030.  *  mine_type           [OUT]       Mine type of a file
  2031.  *  mine_subtype        [OUT]       Mine subtype of a file
  2032.  * RETURNS
  2033.  *  void
  2034.  *****************************************************************************/
  2035. void mmi_email_util_get_mine_type(S8 *filename, U8 *mime_type, U8 *mime_subtype)
  2036. {
  2037.     /*----------------------------------------------------------------*/
  2038.     /* Local Variables                                                */
  2039.     /*----------------------------------------------------------------*/
  2040.     S8 *fileExtPtr = mmi_email_get_file_ext((S8*) filename);
  2041.     S8 *fileExt = OslMalloc((FMGR_MAX_EXT_LEN + 1) * ENCODING_LENGTH);
  2042.     applib_mime_type_struct *mimeTypePtr = NULL;
  2043.     /*----------------------------------------------------------------*/
  2044.     /* Code Body                                                      */
  2045.     /*----------------------------------------------------------------*/
  2046.     if (fileExtPtr)
  2047.     {
  2048.         /* neglect "." */
  2049.         fileExtPtr = fileExtPtr + 2;
  2050.         UnicodeToAnsii(fileExt, fileExtPtr);
  2051.     }
  2052.     if (strlen(fileExt))
  2053.     {
  2054.         mimeTypePtr = mime_type_look_up(NULL, fileExt, 0, 0);
  2055.     }
  2056.     if (mimeTypePtr != NULL)
  2057.     {
  2058.         *mime_type = mimeTypePtr->mime_type;
  2059.         *mime_subtype = mimeTypePtr->mime_subtype;
  2060.     }
  2061.     else
  2062.     {
  2063.         *mime_type = MIME_TYPE_UNKNOWN;
  2064.         *mime_subtype = MIME_SUBTYPE_UNRECOGNIZED;
  2065.     }
  2066.     OslMfree(fileExt);
  2067. }
  2068. /*****************************************************************************
  2069.  * FUNCTION
  2070.  *  mmi_email_util_get_attch_icon
  2071.  * DESCRIPTION
  2072.  *  Get displayed icon of a file according to its file path.
  2073.  *  The supported type is sync with file manager.
  2074.  * PARAMETERS
  2075.  *  filepath        [IN]        File path
  2076.  * RETURNS
  2077.  *  image index of the given file type
  2078.  *****************************************************************************/
  2079. U16 mmi_email_util_get_attch_icon(S8 *filepath)
  2080. {
  2081.     /*----------------------------------------------------------------*/
  2082.     /* Local Variables                                                */
  2083.     /*----------------------------------------------------------------*/
  2084.     U8 fileType;
  2085.     /*----------------------------------------------------------------*/
  2086.     /* Code Body                                                      */
  2087.     /*----------------------------------------------------------------*/
  2088.     fileType = mmi_fmgr_get_file_group((S8*) filepath);
  2089.     if (fileType == FMGR_GROUP_IMAGE)
  2090.     {
  2091.         return IMG_EMAIL_ATTACH_IMAGE_15x15_ID;
  2092.     }
  2093.     else if (fileType == FMGR_GROUP_AUDIO)
  2094.     {
  2095.         return IMG_EMAIL_ATTACH_AUDIO_15x15_ID;
  2096.     }
  2097.     else if (fileType == FMGR_GROUP_VIDEO)
  2098.     {
  2099.         return IMG_EMAIL_ATTACH_VIDEO_15x15_ID;
  2100.     }
  2101.     else
  2102.     {
  2103.         return IMG_EMAIL_ATTACH_UNKNOWN_15x15_ID;
  2104.     }
  2105. }
  2106. #define MEM_UTIL_EMAIL
  2107. /*****************************************************************************
  2108.  * FUNCTION
  2109.  *  mmi_email_util_free_container_pool
  2110.  * DESCRIPTION
  2111.  *  Free memory pool container and reset folder info.
  2112.  * PARAMETERS
  2113.  *  void
  2114.  * RETURNS
  2115.  *  void
  2116.  *****************************************************************************/
  2117. void mmi_email_util_free_container_pool(void)
  2118. {
  2119.     /*----------------------------------------------------------------*/
  2120.     /* Local Variables                                                */
  2121.     /*----------------------------------------------------------------*/
  2122.     /*----------------------------------------------------------------*/
  2123.     /* Code Body                                                      */
  2124.     /*----------------------------------------------------------------*/
  2125.     if (email_p->mem_pool_info.mem_container.num_pool != -1)
  2126.     {
  2127.         mmi_mem_destroy_container(&email_p->mem_pool_info.mem_container);
  2128.         memset(&email_p->fldr_info.fldr_list, 0, sizeof(mmi_email_fldr_list_info_struct));
  2129.         /* -1 to indicate no container now */
  2130.         email_p->mem_pool_info.mem_container.num_pool = -1;
  2131.     }
  2132. }
  2133. #endif /* __MMI_EMAIL__ */ // #ifdef __MMI_EMAIL__
  2134. #endif /* _MMI_EMAILAPPMISCELL_C */ // #ifndef _MMI_EMAILAPPMISCELL_C