EmailAppMiscell.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:89k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * EmailAppMiscell.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file implements miscell utilities for Email application.
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /**************************************************************
- FILENAME : EmailAppMiscell.c
- PURPOSE : nil
- REMARKS : nil
- AUTHOR : Magesh k
- DATE : 30-01-2004
- **************************************************************/
- #ifndef _MMI_EMAILAPPMISCELL_C
- #define _MMI_EMAILAPPMISCELL_C
- #include "MMI_features.h"
- #ifdef __MMI_EMAIL__
- #include "stdC.h"
- #include "L4Dr1.h"
- #include "FileSystemDef.h"
- #include "FileMgr.h"
- #include "Fmt_struct.h"
- #include "FileSystemGProt.h"
- #include "mdi_datatype.h"
- #include "mdi_audio.h"
- /* micha1230 */
- #include "custom_nvram_editor_data_item.h"
- #include "custom_data_account.h"
- #include "EmailAppProt.h"
- #include "EmailAppGProt.h"
- #include "Conversions.h"
- #include "app_mine.h"
- #include "DebugInitDef.h"
- #include "FrameworkStruct.h"
- #include "EventsGprot.h"
- #include "HistoryGprot.h"
- #include "CommonScreens.h"
- #include "GlobalDefs.h"
- #include "SettingProfile.h"
- #include "IdleAppProt.h"
- #include "IdleAppDef.h"
- #include "wgui_status_icons.h"
- #include "CallManagementStruct.h"
- #include "CallManagementGprot.h"
- #include "CallStructureManagementProt.h"
- #include "SimDetectionGprot.h"
- const mmi_email_err_string_struct g_email_err_tbl[] =
- {
- {MMI_EMAIL_ACCT_NOT_CONFIG, STR_EMAIL_ERROR_CODE_ACCT_NOT_CONFIG_ID},
- {MMI_EMAIL_INVALID_ACCT_INDEX, STR_EMAIL_ERROR_CODE_INVALID_ACCT_INDEX_ID},
- {MMI_EMAIL_FOLDER_NOT_EXISTING, STR_EMAIL_ERROR_CODE_FOLDER_NOT_EXISTING_ID},
- {MMI_EMAIL_MSG_NOT_EXISTING, STR_EMAIL_ERROR_CODE_MSG_NOT_EXISTING_ID},
- {MMI_EMAIL_CONN_FAIL, STR_EMAIL_ERROR_CODE_CONN_FAIL_ID},
- {MMI_EMAIL_AUTH_FAIL, STR_EMAIL_ERROR_CODE_AUTH_FAIL_ID},
- {MMI_EMAIL_BAD_PAGE_NUMBER, STR_EMAIL_ERROR_CODE_BAD_PAGE_NUMBER_ID},
- {MMI_EMAIL_READ_ONLY_ACCESS, STR_EMAIL_READ_ONLY_ACCESS},
- {MMI_EMAIL_DNS_ERR, STR_EMAIL_DNS_ERR},
- {MMI_EMAIL_APP_SOC_TIMEOUT_ERR, STR_EMAIL_ERROR_CODE_APP_SOC_TIMEOUT_ERR_ID},
- {MMI_EMAIL_GET_HOST_TIMEOUT_ERR, STR_EMAIL_ERROR_CODE_APP_SOC_TIMEOUT_ERR_ID},
- {MMI_EMAIL_POP3_MSG_XACTION_ERR, STR_EMAIL_ERROR_CODE_POP_CMD},
- {MMI_EMAIL_POP3_SESSION_QUIT_ERR, STR_EMAIL_ERROR_CODE_POP_CMD},
- {MMI_EMAIL_POP3_FSM_ERR, STR_EMAIL_ERROR_CODE_POP_CMD},
- {MMI_EMAIL_INVALID_FOLDER_ID, STR_EMAIL_ERROR_CODE_FOLDER_NOT_EXISTING_ID},
- {MMI_EMAIL_MEMORY_ALLOC_FAIL, STR_EMAIL_MEMORY_FULL_ID},
- {MMI_EMAIL_SMTP_RCPT_TO_FAIL, STR_EMAIL_SMTP_RCPT_TO_FAIL},
- {MMI_EMAIL_INVALID_PORT_NUM, STR_EMAIL_ERROR_CODE_INVALID_PORT_NUM_ID},
- {MMI_EMAIL_INVALID_IP_ADDR, STR_EMAIL_ERROR_CODE_INVALID_IP_ADDR_ID},
- {MMI_EMAIL_INVALID_FILE_PATH, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_EMAIL_ADDR_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_DISP_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_USR_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_PASS_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_ACCT_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_SERVER_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_SERVICE_TYPE, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_IN_PROTOCOL, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_CHK_INT, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_SIGNATURE_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_DOWNLOAD_SIZE, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_WRONG_SETTINGS},
- {MMI_EMAIL_SMTP_VERSION_STATE_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_SMTP_MAIL_FROM_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_SMTP_GREET_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_MAIL_DATA_END_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_SMTP_RCPT_TO_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_SMTP_DATA_FAIL, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_INVALID_FOLDER_NAME_LEN, STR_EMAIL_ERROR_CODE_SMTP_CMD},
- {MMI_EMAIL_EXCEEDED_MSG_CNT, STR_EMAIL_MEMORY_FULL_ID},
- {MMI_EMAIL_ERROR_MSG_REQ, STR_EMAIL_ERROR_MSG_REQ}, /* shall add assertion */
- {MMI_EMAIL_FILE_QUOTA_EXCEEDED, STR_EMAIL_FILE_QUOTA_EXCEEDED},
- {MMI_EMAIL_IMAP_CLOSE_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_IMAP_SELECT_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_IMAP_FETCH_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_IMAP_STORE_ERROR, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_IMAP_LOGOUT_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_SELECT_FOLDER_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_MSG_SELECT_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_NOOP_FAIL, STR_EMAIL_ERROR_CODE_IMAP_CMD},
- {MMI_EMAIL_FOLDER_SELECT_NOT_PERMITTED, STR_EMAIL_FOLDER_SELECT_NOT_PERMITTED},
- {MMI_EMAIL_INVALID_BODY_TYPE, STR_EMAIL_INVALID_MAIL_MESSAGE},
- {MMI_EMAIL_INVALID_BODY_ENCODING, STR_EMAIL_INVALID_MAIL_MESSAGE},
- {MMI_EMAIL_INVALID_MAIL_MESSAGE, STR_EMAIL_INVALID_MAIL_MESSAGE},
- {MMI_EMAIL_STREAM_BUFFER_NOT_ENOUGH, STR_EMAIL_MEMORY_FULL_ID},
- {MMI_EMAIL_LIMITED_RESOURCE, STR_EMAIL_MEMORY_FULL_ID},
- {MMI_EMAIL_SMTP_AUTH_FAIL, STR_EMAIL_ERROR_CODE_AUTH_FAIL_ID},
- {MMI_EMAIL_SMTP_AUTH_NOT_SUPPORT, STR_EMAIL_AUTH_NOT_SUPPORT},
- {0, STR_EMAIL_ERROR_CODE_UNKNOWN_ID}
- };
- #define CHSET_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_ucs2_to_chset
- * DESCRIPTION
- * Convert string from UCS2 to a specific chasert
- * PARAMETERS
- * data [IN] String to be converted in UCS2.
- * len [IN] Length of the string (in bytes)
- * chset [IN] Charset of result string
- * outLen [IN/OUT] Length of converted string(in bytes)
- * RETURNS
- * pointer to the result string.
- *****************************************************************************/
- U8 *mmi_email_util_ucs2_to_chset(U8 *data, U16 len, U8 chset, U16 *outLen)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 encoding = 0;
- U8 *convertedData = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *outLen = 0;
- if (len > 0)
- {
- convertedData = OslMalloc(EMAIL_CHSET_BUFF_LEN);
- switch (chset)
- {
- case EMAIL_ASCII:
- memset(convertedData, 0, (len + 1));
- UnicodeNToAnsii((S8*) convertedData, (S8*) data, len);
- *outLen = len / ENCODING_LENGTH + 1;
- break;
- default:
- encoding = mmi_email_util_get_chset(chset);
- *outLen = mmi_chset_convert(
- MMI_CHSET_UCS2,
- (mmi_chset_enum) encoding,
- (char*)data,
- (char*)convertedData,
- EMAIL_CHSET_BUFF_LEN);
- break;
- }
- }
- return convertedData;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_chset_to_ucs2
- * DESCRIPTION
- * Convert string from a specific chasert to UCS2.
- * PARAMETERS
- * data [IN] String to be converted.
- * len [IN] Length of the string (in bytes)
- * chset [IN] Charset of source string
- * outLen [IN/OUT] Length of converted string(in bytes)
- * RETURNS
- * pointer to the result string.
- *****************************************************************************/
- U8 *mmi_email_util_chset_to_ucs2(U8 *data, U16 len, U8 chset, U16 *outLen)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 mmiEncoding = 0;
- U8 *convertedData = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *outLen = 0;
- if (len > 0)
- {
- convertedData = OslMalloc(EMAIL_CHSET_BUFF_LEN);
- /* because of buffer size constrained, ASCII charset shall be reduced within boundary */
- if (len > (EMAIL_CHSET_BUFF_LEN - 2) / 2)
- {
- len = (EMAIL_CHSET_BUFF_LEN - 2) / 2;
- }
- switch (chset)
- {
- case EMAIL_ASCII:
- AnsiiNToUnicodeString((S8*) convertedData, (S8*) data, len);
- convertedData[len * ENCODING_LENGTH] = 0;
- convertedData[len * ENCODING_LENGTH + 1] = 0;
- *outLen = (len + 1) * ENCODING_LENGTH;
- break;
- default:
- mmiEncoding = mmi_email_util_get_chset(chset);
- *outLen = mmi_chset_convert(
- (mmi_chset_enum) mmiEncoding,
- MMI_CHSET_UCS2,
- (char*)data,
- (char*)convertedData,
- EMAIL_CHSET_BUFF_LEN);
- break;
- }
- }
- return convertedData;
- }
- #define MSG_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_chset
- * DESCRIPTION
- * Convert charset from Email application to the enum value used in conversion function
- * PARAMETERS
- * src_chset [IN] Charset of source.
- * RETURNS
- * charset enum value for conversion function
- *****************************************************************************/
- U8 mmi_email_util_get_chset(U8 src_chset)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (src_chset)
- {
- #ifdef __MMI_CHSET_BIG5__
- case EMAIL_BIG5:
- return MMI_CHSET_BIG5;
- #endif /* __MMI_CHSET_BIG5__ */
- #ifdef __MMI_CHSET_GB2312__
- case EMAIL_GB2312:
- return MMI_CHSET_GB2312;
- #endif /* __MMI_CHSET_GB2312__ */
- case EMAIL_UTF8:
- return MMI_CHSET_UTF8;
- #ifdef __MMI_CHSET_ARABIC_ISO__
- case EMAIL_ARABIC_ISO:
- return MMI_CHSET_ARABIC_ISO;
- #endif /* __MMI_CHSET_ARABIC_ISO__ */
- #ifdef __MMI_CHSET_ARABIC_WIN__
- case EMAIL_ARABIC_WINDOWS:
- return MMI_CHSET_ARABIC_WIN;
- #endif /* __MMI_CHSET_ARABIC_WIN__ */
- /* PMT START PERSIAN */
- #ifdef __MMI_CHSET_PERSIAN_CP1097__
- case EMAIL_PERSIAN_CP1097:
- return MMI_CHSET_PERSIAN_CP1097;
- #endif /* __MMI_CHSET_PERSIAN_CP1097__ */
- #ifdef __MMI_CHSET_PERSIAN_CP1098__
- case EMAIL_PERSIAN_CP1098:
- return MMI_CHSET_PERSIAN_CP1098;
- #endif /* __MMI_CHSET_PERSIAN_CP1098__ */
- /* PMT END PERSIAN */
- #ifdef __MMI_CHSET_BALTIC_ISO__
- case EMAIL_BALTIC_ISO:
- return MMI_CHSET_BALTIC_ISO;
- #endif /* __MMI_CHSET_BALTIC_ISO__ */
- #ifdef __MMI_CHSET_BALTIC_WIN__
- case EMAIL_BALTIC_WINDOWS:
- return MMI_CHSET_BALTIC_WIN;
- #endif /* __MMI_CHSET_BALTIC_WIN__ */
- #ifdef __MMI_CHSET_CEURO_ISO__
- case EMAIL_CENTRAL_EUROPEAN_ISO:
- return MMI_CHSET_CEURO_ISO;
- #endif /* __MMI_CHSET_CEURO_ISO__ */
- #ifdef __MMI_CHSET_CEURO_WIN__
- case EMAIL_CENTRAL_EUROPEAN_WINDOWS:
- return MMI_CHSET_CEURO_WIN;
- #endif /* __MMI_CHSET_CEURO_WIN__ */
- #ifdef __MMI_CHSET_GREEK_ISO__
- case EMAIL_GREEK_ISO:
- return MMI_CHSET_GREEK_ISO;
- #endif /* __MMI_CHSET_GREEK_ISO__ */
- #ifdef __MMI_CHSET_GREEK_WIN__
- case EMAIL_GREEK_WINDOWS:
- return MMI_CHSET_GREEK_WIN;
- #endif /* __MMI_CHSET_GREEK_WIN__ */
- #ifdef __MMI_CHSET_HEBREW_ISO__
- case EMAIL_HEBREW_ISO:
- return MMI_CHSET_HEBREW_ISO;
- #endif /* __MMI_CHSET_HEBREW_ISO__ */
- #ifdef __MMI_CHSET_HEBREW_WIN__
- case EMAIL_HEBREW_WINDOWS:
- return MMI_CHSET_HEBREW_WIN;
- #endif /* __MMI_CHSET_HEBREW_WIN__ */
- #ifdef __MMI_CHSET_LATIN_ISO__
- case EMAIL_LATIN_ISO:
- return MMI_CHSET_LATIN_ISO;
- #endif /* __MMI_CHSET_LATIN_ISO__ */
- #ifdef __MMI_CHSET_NORDIC_ISO__
- case EMAIL_NORDIC_ISO:
- return MMI_CHSET_NORDIC_ISO;
- #endif /* __MMI_CHSET_NORDIC_ISO__ */
- #ifdef __MMI_CHSET_SEURO_ISO__
- case EMAIL_SOURTH_EUROPEAN_ISO:
- return MMI_CHSET_SEURO_ISO;
- #endif /* __MMI_CHSET_SEURO_ISO__ */
- #ifdef __MMI_CHSET_TURKISH_ISO__
- case EMAIL_TURKISH_ISO:
- return MMI_CHSET_TURKISH_ISO;
- #endif /* __MMI_CHSET_TURKISH_ISO__ */
- #ifdef __MMI_CHSET_TURKISH_WIN__
- case EMAIL_TURKISH_WINDOWS:
- return MMI_CHSET_TURKISH_WIN;
- #endif /* __MMI_CHSET_TURKISH_WIN__ */
- #ifdef __MMI_CHSET_WESTERN_ISO__
- case EMAIL_WESTERN_ISO:
- return MMI_CHSET_WESTERN_ISO;
- #endif /* __MMI_CHSET_WESTERN_ISO__ */
- #ifdef __MMI_CHSET_WESTERN_WIN__
- case EMAIL_WESTERN_WINDOWS:
- return MMI_CHSET_WESTERN_WIN;
- #endif /* __MMI_CHSET_WESTERN_WIN__ */
- #ifdef __MMI_CHSET_GB18030__
- case EMAIL_GB:
- return MMI_CHSET_GB18030;
- #endif /* __MMI_CHSET_GB18030__ */
- #ifdef __MMI_CHSET_UTF7__
- case EMAIL_UTF7:
- return MMI_CHSET_UTF7;
- #endif /* __MMI_CHSET_UTF7__ */
- #ifdef __MMI_CHSET_EUCKR_WIN__
- case EMAIL_KOREAN_EUC:
- return MMI_CHSET_EUCKR;
- #endif /* __MMI_CHSET_EUCKR_WIN__ */
- #ifdef __MMI_CHSET_THAI_WINDOWS__
- case EMAIL_THAI_WINDOWS:
- return MMI_CHSET_THAI_WIN;
- #endif /* __MMI_CHSET_THAI_WINDOWS__ */
- #ifdef __MMI_CHSET_VIETNAMESE_WINDOWS__
- case EMAIL_VIETNAMESE_WINDOWS:
- return MMI_CHSET_VIETNAMESE_WIN;
- #endif /* __MMI_CHSET_VIETNAMESE_WINDOWS__ */
- default:
- return MMI_CHSET_TOTAL; /* unsupported charset */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_fldr_get_start_scr
- * DESCRIPTION
- * Get start screen id to be deleted after send/save operations.
- * This function is used in Write Email and each folder, which constains send/save operation
- * PARAMETERS
- * void
- * RETURNS
- * The start screen id to be deleted after send/save.
- *****************************************************************************/
- U16 mmi_email_fldr_get_start_scr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (email_p->main_info.curr_menu == MMI_EMAIL_COMP)
- {
- return SCR_ID_EMAIL_COMP;
- }
- else
- {
- U16 startScrnId;
- U16 folderListSrcnId = mmi_email_util_get_fldr_scr_id();
- if (GetNextScrnIdOf(folderListSrcnId, &startScrnId) == FALSE)
- {
- startScrnId = 0;
- }
- return startScrnId;
- }
- }
- #define STRING_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_is_username_vaild
- * DESCRIPTION
- * Check if the user name is all ASCII
- * PARAMETERS
- * username [IN] String to be check
- * RETURNS
- * TRUE if username is valid; otherwise, FALSE
- *****************************************************************************/
- BOOL mmi_email_util_is_username_vaild(S8 *username)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (!((*username == 0) && (*(username + 1) == 0)))
- {
- if (username[0] != 0 && username[1] != 0)
- {
- return FALSE;
- }
- if (username[0] > 0x7E || username[1] > 0x7E)
- {
- return FALSE;
- }
- username += 2;
- }
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_err_code
- * DESCRIPTION
- * Compute string id to be displayed accoding to error cause
- * PARAMETERS
- * minor [IN] Minor cause
- * major [IN] Major cause
- * RETURNS
- * void
- *****************************************************************************/
- U16 mmi_email_util_get_err_code(S32 minor, signed char major)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (major)
- {
- case MMI_EMAIL_MAIL_ERR:
- return mmi_email_util_get_err_string(minor);
- case MMI_EMAIL_SOCKET_ERR:
- return STR_EMAIL_ERROR_CODE_NETWORK_ID;
- case MMI_EMAIL_FS_ERR:
- return GetFileSystemErrorString(minor);
- default:
- return STR_EMAIL_ERROR_CODE_UNKNOWN_ID;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_ascii_2_ucs2_str
- * DESCRIPTION
- * Convert from ASCII to UCS2
- * PARAMETERS
- * str [IN] String to be converted
- * RETURNS
- * address of result string
- *****************************************************************************/
- S8 *mmi_email_util_ascii_2_ucs2_str(S8 *str)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- AnsiiToUnicodeString((S8*) email_p->comm_buff, str);
- return (S8*) email_p->comm_buff;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_num_2_ucs2_str
- * DESCRIPTION
- * Convert from ASCII to UCS2
- * PARAMETERS
- * num [IN] Number to be converted
- * RETURNS
- * address of result string
- *****************************************************************************/
- S8 *mmi_email_util_num_2_ucs2_str(S8 num)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 fileNumberAnsii[ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf(fileNumberAnsii, "%d", num);
- AnsiiToUnicodeString((S8*) email_p->comm_buff, fileNumberAnsii);
- return (S8*) email_p->comm_buff;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_num_len
- * DESCRIPTION
- * Compute the length of an integer.
- * PARAMETERS
- * number [IN]
- * nunmber(?) [IN] Number to be computed.
- * RETURNS
- * the length of the number.
- *****************************************************************************/
- S32 mmi_email_util_get_num_len(U32 number)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 len;
- S8 *asciiMaxString = OslMalloc(EMAIL_MAX_DWNL_LEN);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- sprintf((S8*) asciiMaxString, "%d", number);
- len = strlen((S8*) asciiMaxString);
- OslMfree(asciiMaxString);
- return len;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_err_string
- * DESCRIPTION
- * Get string id to represent an error codes of Email
- * PARAMETERS
- * error [IN] Error codes of Email
- * RETURNS
- * void
- *****************************************************************************/
- U16 mmi_email_util_get_err_string(S32 error)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 i;
- S16 entry;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- entry = sizeof(g_email_err_tbl) / sizeof(mmi_email_err_string_struct);
- for (i = 0; i < entry; i++)
- if (g_email_err_tbl[i].err_no == error)
- {
- return g_email_err_tbl[i].str_id;
- }
- return STR_EMAIL_ERROR_CODE_UNKNOWN_ID;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_chk_addr
- * DESCRIPTION
- * To check if an email address is valid (contains '@' charcater *).
- * PARAMETERS
- * mailAddr [IN] Address to be checked (in UCS).
- * RETURNS
- * TRUE if valid; otherwise FALSE.
- *****************************************************************************/
- BOOL mmi_email_util_chk_addr(U8 *mailAddr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 foundAt = 0;
- S32 count = 0;
- U8 char_unit;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (mailAddr[count] != 0 || mailAddr[count + 1] != 0)
- {
- if (mailAddr[count] > 0x7e || mailAddr[count + 1] > 0x7e)
- {
- return FALSE;
- }
- char_unit = mailAddr[count];
- switch (char_unit)
- {
- case '@':
- {
- foundAt++;
- if (count == 0) /* @xxxxx */
- {
- return FALSE;
- }
- else if (foundAt > 1)
- {
- return FALSE;
- }
- else if (mailAddr[count + 2] == 0 && mailAddr[count + 3] == 0)
- {
- return FALSE; /* xxxx@ */
- }
- else
- {
- break;
- }
- }
- case ',':
- case ';':
- case ':':
- case '<':
- case '>':
- case '[':
- case ']':
- case '"':
- case ')':
- case '(':
- return FALSE;
- default:
- break;
- }
- count += 2;
- }
- if (foundAt == 1)
- {
- return TRUE;
- }
- return FALSE;
- }
- #define FILE_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_cont_name
- * DESCRIPTION
- * Get file name of content.
- * PARAMETERS
- * fileNo [IN] Index of content
- * path_buff [IN/OUT] Buffer to store the file path+name
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_get_cont_name(S8 fileNo, S8 *path_buff)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_TEXT_FILE_NAME));
- pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_num_2_ucs2_str(fileNo));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_attch_name
- * DESCRIPTION
- * Get file name of attachment.
- * PARAMETERS
- * fileNo [IN] Index of attachment
- * path_buff [IN/OUT] Buffer to store the file path+name
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_get_attch_name(S8 fileNo, S8 *path_buff)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_ATTACH_FILE_NAME));
- pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_num_2_ucs2_str(fileNo));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_sig_name
- * DESCRIPTION
- * Get file name of signature.
- * PARAMETERS
- * fileNo [IN] Index of profile
- * path_buff [IN/OUT] Buffer to store the file path+name
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_get_sig_name(S8 fileNo, S8 *path_buff)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_SIG_FILE_NAME));
- pfnUnicodeStrcat((S8*) path_buff, (S8*) mmi_email_util_num_2_ucs2_str(fileNo));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_fldr_read_cont
- * DESCRIPTION
- * Read content from file system and convert to UCS2.
- * PARAMETERS
- * fileNo [IN] Index of attachment
- * in_len [IN] Length of data to be read (in bytes)
- * ch_set [IN] Charset of file content
- * out_buff [IN/OUT] Pointer to the address whitch stores the output data
- * out_len [IN] Stores the size of output data (in bytes)
- * RETURNS
- * void
- *****************************************************************************/
- S8 mmi_email_fldr_read_cont(S8 fileNo, S32 in_len, email_charset_enum ch_set, U8 **out_buff, U16 *out_len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE file_h;
- U32 errorCode = 0;
- S8 *filepath;
- S8 result = FALSE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (in_len == 0)
- {
- return FALSE;
- }
- else if (in_len > EMAIL_MAX_CONT_LEN * EMAIL_UTF8_ENCODING_LENGTH)
- {
- in_len = EMAIL_MAX_CONT_LEN * EMAIL_UTF8_ENCODING_LENGTH;
- }
- filepath = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- mmi_email_util_get_cont_name(fileNo, (S8*) filepath);
- file_h = pfopen(filepath, PFS_READ);
- if (file_h > 0)
- {
- FS_Read(file_h, &email_p->misc_info.cont_inline_buff, in_len, &errorCode);
- /* pfread (&email_p->misc_info.cont_inline_buff, 1, in_len, file_h, &errorCode); */
- email_p->misc_info.cont_inline_buff[in_len] = 0;
- email_p->misc_info.cont_inline_buff[in_len + 1] = 0;
- pfclose(file_h);
- if (errorCode > 0)
- {
- *out_buff = mmi_email_util_chset_to_ucs2(
- (U8*) email_p->misc_info.cont_inline_buff,
- (U16) in_len,
- (U8) ch_set,
- out_len);
- result = TRUE;
- }
- else
- {
- *out_buff = NULL;
- *out_len = 0;
- }
- }
- /* result cont_inline_buff buffer because it's temporary usage */
- email_p->misc_info.cont_inline_buff[0] = 0;
- email_p->misc_info.cont_inline_buff[1] = 0;
- OslMfree(filepath);
- return result;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_cont_size
- * DESCRIPTION
- * Get file size of each content file
- * PARAMETERS
- * totalTextMsg [IN] Total number of content file.
- * outContentDataSize [IN] Buffer to store size of each content file
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_get_cont_size(U8 totalTextMsg, S32 *outContentDataSize)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i;
- FILE_HANDLE emailContentFilePtr;
- S8 *emailContentFileNameBuf = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < totalTextMsg; i++)
- {
- pfnUnicodeStrcpy(
- (S8*) emailContentFileNameBuf,
- (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat(
- (S8*) emailContentFileNameBuf,
- (S8*) mmi_email_util_ascii_2_ucs2_str(MMI_EMAIL_TEXT_FILE_NAME));
- pfnUnicodeStrcat((S8*) emailContentFileNameBuf, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
- emailContentFilePtr = pfopen(emailContentFileNameBuf, PFS_READ);
- if (emailContentFilePtr < 0)
- {
- /* file open failed */
- outContentDataSize[i] = 0;
- }
- else
- {
- outContentDataSize[i] = GetFSFileSize(emailContentFilePtr);
- pfclose(emailContentFilePtr);
- }
- }
- OslMfree(emailContentFileNameBuf);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_rename_after_abort
- * DESCRIPTION
- * Rollback file name from convention name to composed name, when abort sending
- * PARAMETERS
- * fileNo [IN] Index of file
- * DestFilePathPtr [IN/OUT] Buffer to store file path+name after rename.
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_rename_after_abort(S8 fileNo, S8 *DestFilePathPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *attachDefaultFileNameBuf = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_email_util_get_attch_name(fileNo, (S8*) attachDefaultFileNameBuf);
- pfdelete(DestFilePathPtr);
- pfrename(attachDefaultFileNameBuf, DestFilePathPtr);
- OslMfree(attachDefaultFileNameBuf);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_rename_attch
- * DESCRIPTION
- * Rename attachment to convention name
- * PARAMETERS
- * fileNo [IN] Index of attachment
- * srcFilePathPtr [IN] Source file
- * RETURNS
- * Error cause from file system.
- *****************************************************************************/
- S32 mmi_email_util_rename_attch(S8 fileNo, S8 *srcFilePathPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 result;
- S8 *attachDefaultFileNameBuf = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- S8 *fileExt;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_email_util_get_attch_name(fileNo, (S8*) attachDefaultFileNameBuf);
- /* rename attachX.EXT to attachX. delete the destination file
- only if source file extension exists in case delete the same file. */
- fileExt = mmi_email_get_file_ext(srcFilePathPtr);
- if (fileExt != NULL)
- {
- pfdelete(attachDefaultFileNameBuf);
- }
- result = pfrename(srcFilePathPtr, attachDefaultFileNameBuf);
- OslMfree(attachDefaultFileNameBuf);
- return result;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_rename_default_to_read
- * DESCRIPTION
- * Rename default attachment name to the name use in Read Email screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_rename_default_to_read(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j;
- S8 *fileExt;
- S8 *orig_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- S8 *new_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0, j = 0; i < email_p->inbox_info.read_info.total_attch; i++)
- {
- /* Original name */
- mmi_email_util_get_attch_name((U8) (i + 1), orig_name);
- /* Read name */
- pfnUnicodeStrcpy((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
- pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_READ_TMP_FILE_NAME));
- pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
- fileExt = mmi_email_get_file_ext((S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
- pfnUnicodeStrcat((S8*) new_name, (S8*) fileExt);
- /* delete if the same file name is existing */
- pfdelete(new_name);
- if (pfrename(orig_name, new_name) == FS_NO_ERROR)
- {
- pfnUnicodeStrcpy((S8*) email_p->inbox_info.read_info.attch_list[i].file_path, (S8*) new_name);
- email_p->inbox_info.read_info.attch_list[i].attch_present = TRUE;
- j++;
- }
- }
- email_p->inbox_info.read_info.total_attch = j;
- OslMfree(orig_name);
- OslMfree(new_name);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_rename_default_to_comp
- * DESCRIPTION
- * Rename default attachment name to the name use in Write Email screen
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_rename_default_to_comp(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j;
- S32 fileSize;
- S8 *fileExt;
- S8 *orig_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- S8 *new_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- email_p->comp_info.total_attch_size = 0;
- for (i = 0, j = 0; i < email_p->inbox_info.read_info.total_attch; i++)
- {
- /* Original name */
- mmi_email_util_get_attch_name((U8) (i + 1), orig_name);
- /* new name */
- pfnUnicodeStrcpy((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
- pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_COMP_TMP_FILE_NAME));
- pfnUnicodeStrcat((S8*) new_name, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
- fileExt = mmi_email_get_file_ext((S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
- pfnUnicodeStrcat((S8*) new_name, (S8*) fileExt);
- /* delete if the same file name is existing */
- pfdelete(new_name);
- if (pfrename(orig_name, new_name) == FS_NO_ERROR)
- {
- pfnUnicodeStrcpy(
- (S8*) email_p->comp_info.attch_list[j].file_name,
- (S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
- pfnUnicodeStrcpy((S8*) email_p->comp_info.attch_list[i].file_path, (S8*) new_name);
- email_p->comp_info.attch_list[j].attch_type = email_p->inbox_info.read_info.attch_list[i].attch_type;
- email_p->comp_info.attch_list[j].attch_subtype = email_p->inbox_info.read_info.attch_list[i].attch_subtype;
- email_p->comp_info.attch_list[j].ch_set = email_p->inbox_info.read_info.attch_list[i].ch_set;
- email_p->comp_info.attch_list[j].attch_present = TRUE;
- /* calculate file size */
- mmi_email_util_get_file_size((S8*) email_p->comp_info.attch_list[j].file_path, &fileSize);
- /* update total attachment size */
- email_p->comp_info.total_attch_size += fileSize;
- j++;
- }
- PRINT_INFORMATION(("n[mmi_email_util_rename_default_to_comp] Updated Total comp_info Size: %dn", email_p->comp_info.total_attch_size));
- }
- email_p->comp_info.total_attch = j;
- OslMfree(orig_name);
- OslMfree(new_name);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_rename_read_to_comp
- * DESCRIPTION
- * Rename Read attachment name to Compose attachment.
- * If any error happens for an attachment, set the attachment to empty.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_rename_read_to_comp(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 i, j;
- S32 fileSize;
- S8 *fileExt;
- S8 *comp_name = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- email_p->comp_info.total_attch_size = 0;
- for (i = 0, j = 0; i < email_p->inbox_info.read_info.total_attch; i++)
- {
- /* chcek file size */
- if (mmi_email_util_get_file_size((S8*) email_p->inbox_info.read_info.attch_list[i].file_path, &fileSize) ==
- FS_NO_ERROR)
- {
- /* ensure previous total attachment size + current attachment size no greater than 90K */
- // if (fileSize <= MMI_EMAIL_MAX_ATTACH_SIZE)
- if (email_p->inbox_info.read_info.total_attch_size + fileSize <= MMI_EMAIL_TOTAL_MAX_ATTACH_SIZE)
- {
- /* delete if the same file name is existing */
- pfnUnicodeStrcpy((S8*) comp_name, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) comp_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
- pfnUnicodeStrcat((S8*) comp_name, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_COMP_TMP_FILE_NAME));
- pfnUnicodeStrcat((S8*) comp_name, (S8*) mmi_email_util_num_2_ucs2_str((U8) (i + 1)));
- fileExt = mmi_email_get_file_ext((S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
- pfnUnicodeStrcat((S8*) comp_name, (S8*) fileExt);
- pfdelete(comp_name);
- /* rename */
- if (pfrename((S8*) email_p->inbox_info.read_info.attch_list[i].file_path, comp_name) == FS_NO_ERROR)
- {
- pfnUnicodeStrcpy(
- (S8*) email_p->comp_info.attch_list[j].file_name,
- (S8*) email_p->inbox_info.read_info.attch_list[i].file_name);
- pfnUnicodeStrcpy((S8*) email_p->comp_info.attch_list[j].file_path, (S8*) comp_name);
- email_p->comp_info.attch_list[j].attch_type =
- email_p->inbox_info.read_info.attch_list[i].attch_type;
- email_p->comp_info.attch_list[j].attch_subtype =
- email_p->inbox_info.read_info.attch_list[i].attch_subtype;
- email_p->comp_info.attch_list[j].ch_set = email_p->inbox_info.read_info.attch_list[i].ch_set;
- email_p->comp_info.attch_list[j].attch_present = TRUE;
- /* update total attachment size */
- email_p->comp_info.total_attch_size += fileSize;
- /* rename successfully, continue next file */
- j++;
- }
- PRINT_INFORMATION(("n[mmi_email_util_rename_read_to_comp] Updated Total comp_info Size: %dn", email_p->comp_info.total_attch_size));
- }
- else
- {
- /* file size exceeded */
- email_p->comp_info.attch_exceed = TRUE;
- }
- }
- }
- email_p->comp_info.total_attch = j;
- OslMfree(comp_name);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_create_working_dir
- * DESCRIPTION
- * Create working directory
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_create_working_dir(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *createFolder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) createFolder, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) createFolder, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
- pcreateDir(createFolder);
- OslMfree(createFolder);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_read_copy_attch
- * DESCRIPTION
- * Copy attachment from file buffer to user selected path
- * PARAMETERS
- * fileNo [IN] Index of file buffer.
- * attchName [IN] File name to be saved
- * RETURNS
- * void
- *****************************************************************************/
- S8 mmi_email_read_copy_attch(S8 fileNo, S8 *attchName)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE fh;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* path too long */
- if ((pfnUnicodeStrlen((S8*) email_p->comm_buff) + pfnUnicodeStrlen((S8*) attchName) +
- pfnUnicodeStrlen((S8*) email_p->fileext_buff)) > FMGR_MAX_PATH_LEN)
- {
- return EMAIL_SAVE_ATTACH_NAME_TOO_LONG;
- }
- /* file name empty */
- if (pfnUnicodeStrlen((S8*) attchName) == 0)
- {
- return EMAIL_SAVE_ATTACH_EMPTY_NAME;
- }
- if (email_p->inbox_info.attch_dest_path == NULL)
- {
- email_p->inbox_info.attch_dest_path = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- }
- /* duplicated file name */
- pfnUnicodeStrcpy((S8*) email_p->inbox_info.attch_dest_path, (S8*) email_p->comm_buff);
- pfnUnicodeStrcat(email_p->inbox_info.attch_dest_path, (S8*) attchName);
- pfnUnicodeStrcat(email_p->inbox_info.attch_dest_path, (S8*) email_p->fileext_buff);
- fh = pfopen(email_p->inbox_info.attch_dest_path, PFS_READ);
- if (fh > 0)
- {
- OslMfree(email_p->inbox_info.attch_dest_path);
- email_p->inbox_info.attch_dest_path = NULL;
- pfclose(fh);
- return EMAIL_SAVE_ATTACH_DUP_NAME;
- }
- /* send copy request to fmt ask */
- FS_Delete((U16*) email_p->inbox_info.attch_dest_path);
- mmi_fmgr_send_copy_req(
- FMGR_ACTION_COPY,
- (U8*) email_p->inbox_info.read_info.attch_list[email_p->misc_info.curr_hilite_attch]. file_path,
- (U8*) email_p->inbox_info.attch_dest_path,
- mmi_email_read_attch_copy_callback);
- return EMAIL_SAVE_ATTACH_NO_ERR;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_read_attch_copy_callback
- * DESCRIPTION
- * Callback function for saving attachment to file manager
- * PARAMETERS
- * info [IN] Result of savng attachment
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_read_attch_copy_callback(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* display done and go back to option screen */
- mmi_fmt_copy_rsp_strcut *msgPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgPtr = (mmi_fmt_copy_rsp_strcut*) info;
- OslMfree(email_p->inbox_info.attch_dest_path);
- email_p->inbox_info.attch_dest_path = NULL;
- if (mmi_email_util_is_call_interrupt_allow() && GetExitScrnID() != SCR_ID_EMAIL_PROGRESS)
- {
- /* delete progressing screen */
- DeleteScreenIfPresent(SCR_ID_EMAIL_PROGRESS);
- return;
- }
- if (msgPtr->result >= 0)
- {
- DisplayPopup(
- (U8*) GetString(STR_GLOBAL_DONE),
- IMG_GLOBAL_ACTIVATED,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- SUCCESS_TONE);
- }
- else
- {
- DisplayPopup((U8*) GetString(GetFileSystemErrorString(msgPtr->result)), IMG_GLOBAL_ERROR, 0, 1000, ERROR_TONE);
- }
- DeleteScreenIfPresent(SCR_ID_EMAIL_PROGRESS);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_get_file_ext
- * DESCRIPTION
- * Get file extension of a file name
- * PARAMETERS
- * pFileName [?]
- * info(?) [IN] Result of savng attachment
- * RETURNS
- * void
- *****************************************************************************/
- S8 *mmi_email_get_file_ext(S8 *pFileName)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 nLength;
- S8 *pFilePtr = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nLength = pfnUnicodeStrlen(pFileName);
- --nLength;
- nLength *= ENCODING_LENGTH;
- while (nLength && (pFileName[nLength] != '.') && (pFileName[nLength - 1] == ' '))
- {
- nLength -= 2;
- }
- if (nLength)
- {
- pFilePtr = pFileName + nLength;
- }
- return pFilePtr;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_fs_del_all_tmp_file_rsp
- * DESCRIPTION
- * Response handle for folder_delete_rsp
- * PARAMETERS
- * info [IN] Struct variable for response message
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_fs_del_all_tmp_file_rsp(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_fmt_delete_rsp_strcut *msgPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgPtr = (mmi_fmt_delete_rsp_strcut*) info;
- email_p->main_info.ready_state |= EMAIL_CLEAR_BUFF_DONE;
- /* create dir again */
- mmi_email_util_create_working_dir();
- if (msgPtr->result >= FS_NO_ERROR)
- {
- return;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_fs_del_all_tmp_file_req
- * DESCRIPTION
- * Delete temporary file folder.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_fs_del_all_tmp_file_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *fldr_path = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) fldr_path, (S8*) mmi_email_util_ascii_2_ucs2_str((S8*) EMAIL_WORKING_PATH));
- pfnUnicodeStrcat((S8*) fldr_path, (S8*) mmi_email_util_ascii_2_ucs2_str(EMAIL_TEMP_FOLDER_NAME));
- pfnUnicodeStrcpy((S8*) email_p->comm_buff, fldr_path);
- mmi_fmgr_send_delete_req((U8*) email_p->comm_buff, FS_DIR_TYPE, mmi_email_fs_del_all_tmp_file_rsp);
- OslMfree(fldr_path);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_file_size
- * DESCRIPTION
- * Get size of a file
- * PARAMETERS
- * filePathPtr [?]
- * fileSizePtr [?]
- * filePathPrt(?) [IN] File path and name
- * fileSizePrt(?) [IN/OUT] Address to store the size of file
- * RETURNS
- * Error cause of file open
- *****************************************************************************/
- S32 mmi_email_util_get_file_size(S8 *filePathPtr, S32 *fileSizePtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE fileHandle = pfopen(filePathPtr, PFS_READ);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (fileHandle > 0)
- {
- *fileSizePtr = GetFSFileSize(fileHandle);
- pfclose(fileHandle);
- return FS_NO_ERROR;
- }
- return fileHandle;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_check_file_exist
- * DESCRIPTION
- * To check whether file exist or not
- * PARAMETERS
- * filePathPtr [IN] File path
- * RETURNS
- * TURE of file exists; otherwise FALSE.
- *****************************************************************************/
- S32 mmi_email_util_check_file_exist(S8 *filePathPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FILE_HANDLE fileHandle;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* if file already exist */
- fileHandle = pfopen((U16*) filePathPtr, PFS_READ);
- if (fileHandle > 0)
- {
- pfclose(fileHandle);
- return FS_NO_ERROR;
- }
- return fileHandle;
- }
- #define SCR_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_add_history
- * DESCRIPTION
- * Common function to add history node when exiting a screen.
- * The logic of this function depends on the flag "insert_hist".
- * This flag determines if the screen shall be added to history or inserted before CM screen
- * PARAMETERS
- * scrnId [IN] Screen index
- * entryFuncPtr [IN] Pointer of the screen entry function
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_add_history(U16 scrnId, FuncPtr entryFuncPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history currHistory;
- S16 ucs2InputBuffer = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- currHistory.scrnID = scrnId;
- currHistory.entryFuncPtr = entryFuncPtr;
- pfnUnicodeStrcpy((S8*) currHistory.inputBuffer, (S8*) & ucs2InputBuffer);
- if (!email_p->misc_info.insert_hist)
- {
- GetCategoryHistory(currHistory.guiBuffer);
- AddHistory(currHistory);
- }
- else
- {
- U16 cmScrnId = GetCmMarkerScrnID();
- if (IsScreenPresent(cmScrnId))
- {
- InsertHistoryBeforeThisScrn(cmScrnId, currHistory);
- }
- else
- {
- AddHistory(currHistory);
- }
- }
- email_p->misc_info.insert_hist = FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_add_n_history
- * DESCRIPTION
- * Common function to add a category 57 history node when exiting a screen.
- * The logic of this function depends on the flag "insert_hist".
- * This flag determines if the screen shall be added to history or inserted before CM screen
- * PARAMETERS
- * scrnId [IN] Screen index
- * entryFuncPtr [IN] Pointer of the screen entry function
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_add_n_history(U16 scrnId, FuncPtr entryFuncPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history currHistory;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- currHistory.scrnID = scrnId;
- currHistory.entryFuncPtr = entryFuncPtr;
- if (!email_p->misc_info.insert_hist)
- {
- U16 inputBufferSize = 0;
- CloseCategory57Screen();
- GetCategoryHistory(currHistory.guiBuffer);
- inputBufferSize = (U16) GetCategory57DataSize();
- GetCategory57Data((U8*) currHistory.inputBuffer);
- AddNHistory(currHistory, inputBufferSize);
- }
- else
- {
- U16 cmScrnId = GetCmMarkerScrnID();
- if (IsScreenPresent(cmScrnId))
- {
- InsertHistoryBeforeThisScrn(cmScrnId, currHistory);
- }
- else
- {
- AddHistory(currHistory);
- }
- }
- email_p->misc_info.insert_hist = FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_go_back_2_hist
- * DESCRIPTION
- * Go back to previosu 2 screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_go_back_2_hist(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GoBacknHistory(1);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_folder_select_cap_str
- * DESCRIPTION
- * Construct caption string of folder according to current protocol.
- * PARAMETERS
- * strCaptionId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- U8 *mmi_email_util_folder_select_cap_str(U16 strCaptionId)
- {
- #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Unsent folder is not related to IMAP4 protocol */
- if (email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4 && strCaptionId != STR_EMAIL_COMMON_UNSENT_ID)
- {
- S8 *asciiPageNumberInfoBuff = OslMalloc(EMAIL_MAX_FLDR_CAP_LEN);
- S8 *ucs2PageNumberInfoBuff = OslMalloc(EMAIL_MAX_FLDR_CAP_LEN * ENCODING_LENGTH);
- sprintf(
- (S8*) asciiPageNumberInfoBuff,
- " [%d/%d]",
- email_p->fldr_info.curr_page,
- email_p->fldr_info.total_page);
- AnsiiToUnicodeString((S8*) ucs2PageNumberInfoBuff, (S8*) asciiPageNumberInfoBuff);
- pfnUnicodeStrcpy((S8*) email_p->misc_info.folder_cap_buff, (S8*) GetString(strCaptionId));
- pfnUnicodeStrcat((S8*) email_p->misc_info.folder_cap_buff, (S8*) ucs2PageNumberInfoBuff);
- OslMfree(asciiPageNumberInfoBuff);
- OslMfree(ucs2PageNumberInfoBuff);
- return (U8*) email_p->misc_info.folder_cap_buff;
- }
- #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */
- return (U8*) GetString(strCaptionId);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_del_between_scr
- * DESCRIPTION
- * Delete Email screen between two screens
- * PARAMETERS
- * start_scr [IN] Start screen id to be deleted
- * end_scr [IN] End screen id to be deleted
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_del_between_scr(U16 start_scr, U16 end_scr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 next_scr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (GetNextScrnIdOf(start_scr, &next_scr))
- {
- if (next_scr == end_scr)
- {
- break;
- }
- else if (next_scr > SCR_ID_EMAIL_START && next_scr < SCR_ID_EMAIL_END)
- {
- DeleteScreenIfPresent(next_scr);
- }
- else
- {
- break;
- }
- }
- DeleteScreenIfPresent(end_scr);
- DeleteScreenIfPresent(start_scr);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_del_upto_scr
- * DESCRIPTION
- * Delete Email screen update to some screen
- * PARAMETERS
- * end_scr [IN] End screen id to be deleted
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_del_upto_scr(U16 end_scr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 next_scr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (GetNextScrnIdOf(end_scr, &next_scr))
- {
- if (next_scr > SCR_ID_EMAIL_START && next_scr < SCR_ID_EMAIL_END)
- {
- DeleteScreenIfPresent(next_scr);
- }
- else
- {
- break;
- }
- }
- DeleteScreenIfPresent(end_scr);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_display_err_popup
- * DESCRIPTION
- * Common function to display popup screen
- * PARAMETERS
- * minor [IN] Minor cause
- * major [IN] Major cause
- * startDelScrnId [IN] Starting index of screen to be deleted
- * endDelScrnId [IN] End index of screen to be deleted
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_display_err_popup(S32 minor, signed char major, U16 startDelScrnId, U16 endDelScrnId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 errMsgId;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- errMsgId = mmi_email_util_get_err_code(minor, major);
- DisplayPopup((U8*) GetString(errMsgId), IMG_GLOBAL_UNFINISHED, 1, UI_POPUP_NOTIFYDURATION_TIME, (U8) WARNING_TONE);
- if (startDelScrnId)
- {
- mmi_email_util_del_between_scr(startDelScrnId, endDelScrnId);
- }
- else
- {
- mmi_email_util_del_upto_scr(endDelScrnId);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_clear_end_key_hdlr
- * DESCRIPTION
- * Clear all handlers of END key
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_clear_end_key_hdlr(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ClearKeyHandler(KEY_END, KEY_EVENT_UP);
- ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
- ClearKeyHandler(KEY_END, KEY_LONG_PRESS);
- ClearKeyHandler(KEY_END, KEY_REPEAT);
- }
- #if !defined(__MMI_SLIM_EMAIL_NO_AUTO_CHECK__)
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_is_idle
- * DESCRIPTION
- * To check if MMI is in IDLE screen.
- * PARAMETERS
- * void
- * RETURNS
- * TURE if MMI is in idle/screen saver mode; otherwise, FALSE.
- *****************************************************************************/
- U8 mmi_email_util_is_idle(void) // #ifdef __MMI_SLIM_EMAIL_NO_AUTO_CHECK__
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_idle_context.IsOnIdleScreen || g_idle_context.ScreenSaverRunFlag)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_is_key_locked
- * DESCRIPTION
- * To check if MMI is in keypad lock screen.
- * PARAMETERS
- * void
- * RETURNS
- * TURE if MMI is in keypad-locked mode; otherwise, FALSE.
- *****************************************************************************/
- U8 mmi_email_util_is_key_locked(void) // #ifdef __MMI_SLIM_EMAIL_NO_AUTO_CHECK__
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return g_keylock_context.gKeyPadLockFlag;
- }
- #endif /* !defined(__MMI_SLIM_EMAIL_NO_AUTO_CHECK__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_update_status_icon
- * DESCRIPTION
- * Update status icon in IDLE screen.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_update_status_icon(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* do not display status icon when flight mode is on */
- if (!mmi_bootup_get_active_flight_mode())
- {
- if (email_p->main_info.is_mem_full == FALSE)
- {
- HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
- if (email_p->main_info.unread_mails != 0)
- {
- ShowStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
- }
- UpdateStatusIcons();
- }
- else
- {
- HideStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
- BlinkStatusIcon(STATUS_ICON_UNREAD_EMAIL_L1);
- UpdateStatusIcons();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_change_title
- * DESCRIPTION
- * Change title string
- * PARAMETERS
- * strId [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_change_title(U16 strId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeTitleString((U8*) GetString(strId));
- draw_title();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_fldr_scr_id
- * DESCRIPTION
- * Get screen id of current folder
- * PARAMETERS
- * void
- * RETURNS
- * Screen index
- *****************************************************************************/
- U16 mmi_email_util_get_fldr_scr_id(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (email_p->main_info.curr_menu)
- {
- case MMI_EMAIL_INBOX:
- return SCR_ID_EMAIL_INBOX;
- case MMI_EMAIL_UNSENT:
- return SCR_ID_EMAIL_UNSENT;
- case MMI_EMAIL_SENT:
- return SCR_ID_EMAIL_SENT;
- case MMI_EMAIL_DRAFT:
- return SCR_ID_EMAIL_DRAFT;
- default:
- return SCR_ID_EMAIL_MAIN;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_abort_func
- * DESCRIPTION
- * Get function pointer of abort in progressing screen.
- * PARAMETERS
- * void
- * RETURNS
- * function pointer of abort function if required.
- *****************************************************************************/
- FuncPtr mmi_email_util_get_abort_func(void)
- {
- #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4) && (email_p->main_info.curr_menu != MMI_EMAIL_UNSENT))
- {
- return (FuncPtr) mmi_email_ps_abort_req;
- }
- #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */
- return NULL;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_is_call_interrupt_allow
- * DESCRIPTION
- * To determine if interrupt from call is allowed
- * PARAMETERS
- * void
- * RETURNS
- * TURE if screen can be displayed; otherwise, FALSE.
- *****************************************************************************/
- U8 mmi_email_util_is_call_interrupt_allow(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((isInCall() == FALSE) || (isInCall() && GetWapCallPresent()))
- {
- return TRUE;
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_abort_str
- * DESCRIPTION
- * Get string id of abort key.
- * If current protocol is POP3 or folder is Unsent, no abrot key reqired.
- * PARAMETERS
- * void
- * RETURNS
- * string index of abort key.
- *****************************************************************************/
- U16 mmi_email_util_abort_str(void)
- {
- #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4) && (email_p->main_info.curr_menu != MMI_EMAIL_UNSENT))
- {
- return STR_GLOBAL_ABORT;
- }
- #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */
- return 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_abort_img
- * DESCRIPTION
- * Get image id of abort key.
- * If current protocol is POP3 or folder is Unsent, no abrot key reqired.
- * PARAMETERS
- * void
- * RETURNS
- * image index of abort key.
- *****************************************************************************/
- U16 mmi_email_util_abort_img(void)
- {
- #if !defined(__MMI_SLIM_EMAIL_NO_IMAP4__)
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((email_p->prof_info.act_prof.in_prot == EMAIL_PROT_IMAP4) && (email_p->main_info.curr_menu != MMI_EMAIL_UNSENT))
- {
- return IMG_GLOBAL_BACK;
- }
- #endif /* !defined(__MMI_SLIM_EMAIL_NO_IMAP4__) */
- return 0;
- }
- #define MIME_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_uti_tolower
- * DESCRIPTION
- * Convert a character from upper case to lower case
- * PARAMETERS
- * ch [IN] Character to be converted.
- * RETURNS
- * result of the converting.
- *****************************************************************************/
- U8 mmi_email_uti_tolower(U8 ch)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (ch >= 'A' && ch <= 'Z')
- {
- return (U8) (ch + ('a' - 'A'));
- }
- return ch;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_uti_strnicmp
- * DESCRIPTION
- * Compare two string without regarding upper/lower case
- * PARAMETERS
- * src [IN] Source string
- * dest [IN] Destination string
- * maxlen [IN] Length of the string to be compared
- * RETURNS
- * TRUE if two string is different; otherwise, FALSE.
- *****************************************************************************/
- S8 mmi_email_uti_strnicmp(S8 *src, S8 *dest, S32 maxlen)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 ch1, ch2;
- S8 *s1, *s2;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- s1 = src;
- s2 = dest;
- while (maxlen-- > 0)
- {
- ch1 = mmi_email_uti_tolower(*s1++);
- ch2 = mmi_email_uti_tolower(*s2++);
- if (ch1 != ch2)
- {
- return TRUE;
- }
- }
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_mine_type
- * DESCRIPTION
- * Get mine type and mine subtype of a give file according to filename
- * PARAMETERS
- * filename [IN] File name
- * mine_type [OUT] Mine type of a file
- * mine_subtype [OUT] Mine subtype of a file
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_get_mine_type(S8 *filename, U8 *mime_type, U8 *mime_subtype)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *fileExtPtr = mmi_email_get_file_ext((S8*) filename);
- S8 *fileExt = OslMalloc((FMGR_MAX_EXT_LEN + 1) * ENCODING_LENGTH);
- applib_mime_type_struct *mimeTypePtr = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (fileExtPtr)
- {
- /* neglect "." */
- fileExtPtr = fileExtPtr + 2;
- UnicodeToAnsii(fileExt, fileExtPtr);
- }
- if (strlen(fileExt))
- {
- mimeTypePtr = mime_type_look_up(NULL, fileExt, 0, 0);
- }
- if (mimeTypePtr != NULL)
- {
- *mime_type = mimeTypePtr->mime_type;
- *mime_subtype = mimeTypePtr->mime_subtype;
- }
- else
- {
- *mime_type = MIME_TYPE_UNKNOWN;
- *mime_subtype = MIME_SUBTYPE_UNRECOGNIZED;
- }
- OslMfree(fileExt);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_get_attch_icon
- * DESCRIPTION
- * Get displayed icon of a file according to its file path.
- * The supported type is sync with file manager.
- * PARAMETERS
- * filepath [IN] File path
- * RETURNS
- * image index of the given file type
- *****************************************************************************/
- U16 mmi_email_util_get_attch_icon(S8 *filepath)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 fileType;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- fileType = mmi_fmgr_get_file_group((S8*) filepath);
- if (fileType == FMGR_GROUP_IMAGE)
- {
- return IMG_EMAIL_ATTACH_IMAGE_15x15_ID;
- }
- else if (fileType == FMGR_GROUP_AUDIO)
- {
- return IMG_EMAIL_ATTACH_AUDIO_15x15_ID;
- }
- else if (fileType == FMGR_GROUP_VIDEO)
- {
- return IMG_EMAIL_ATTACH_VIDEO_15x15_ID;
- }
- else
- {
- return IMG_EMAIL_ATTACH_UNKNOWN_15x15_ID;
- }
- }
- #define MEM_UTIL_EMAIL
- /*****************************************************************************
- * FUNCTION
- * mmi_email_util_free_container_pool
- * DESCRIPTION
- * Free memory pool container and reset folder info.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_email_util_free_container_pool(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (email_p->mem_pool_info.mem_container.num_pool != -1)
- {
- mmi_mem_destroy_container(&email_p->mem_pool_info.mem_container);
- memset(&email_p->fldr_info.fldr_list, 0, sizeof(mmi_email_fldr_list_info_struct));
- /* -1 to indicate no container now */
- email_p->mem_pool_info.mem_container.num_pool = -1;
- }
- }
- #endif /* __MMI_EMAIL__ */ // #ifdef __MMI_EMAIL__
- #endif /* _MMI_EMAILAPPMISCELL_C */ // #ifndef _MMI_EMAILAPPMISCELL_C