JMMSStoreHandling.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:56k
源码类别:
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) 2002
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * jmms_store_handling.C
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file conains the store APIs for interacting with Jatayu Store module
- *
- * 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!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _MMI_JMMSSTOREHANDLING_C
- #define _MMI_JMMSSTOREHANDLING_C
- /*****************************************************************************
- * Include
- *****************************************************************************/
- #include "MMI_features.h"
- #if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
- #include "PixtelDataTypes.h"
- #include "Unicodexdcl.h"
- #include "HistoryGprot.h"
- #include "GlobalDefs.h"
- #include "SettingProfile.h"
- #include "DebugInitDef.h"
- #include "CommonScreens.h"
- #include "EventsGprot.h"
- #include "wgui_inputs.h"
- #include "wgui_categories.h"
- #include "wgui_categories_inputs.h"
- #include "MainMenuDef.h"
- #include <ddl.h>
- #include <jcal.h>
- #include <ddlbase.h>
- #include <MessagingDataTypes.h>
- #include <MessagingAPI.h>
- #include "JMMSConfig.h"
- #include "JMMSMessageSettings.h"
- #include "JMMSCoreAPI.h"
- #include "JMMSDrafts.h"
- #include "JMMSExdcl.h"
- #include "JMMSCompose.h"
- #include "JMMSGprot.h"
- #include "JMMSInbox.h"
- #include "JMMSJSRHandler.h"
- #include "JMMSMainMMS.h"
- #include "JMMSMessageSettingsUtils.h"
- #include "JMMSOutbox.h"
- #include "JMMSProtocols.h"
- #include "JMMSPushHandling.h"
- #include "JMMSResEnum.h"
- #include "JMMSSent.h"
- #include "JMMSStoreHandling.h"
- #include "JMMSStructs.h"
- #include "JMMSTemplates.h"
- #include "JMMSUseDetails.h"
- #include "JMMSView.h"
- #include "JMMSWriteMMS.h"
- #include "NVRAMType.h"
- #include "NVRAMProt.h"
- #include "NVRAMEnum.h"
- #include "PrvStoreDataTypes.h"
- #include "PrvStoreHandleInterfaces.h"
- #include "JSRProts.h"
- //PMT VIKAS START 20060325
- //For size calculation.
- #include "FileMgr.h"
- /* PMT VIKAS END 20060325 */
- /*****************************************************************************
- * Define
- *****************************************************************************/
- /*****************************************************************************
- * Typedef
- *****************************************************************************/
- /*****************************************************************************
- * Local Variable
- *****************************************************************************/
- /*****************************************************************************
- * Local Function
- *****************************************************************************/
- /*****************************************************************************
- * Global Variable
- *****************************************************************************/
- U64 g_jmms_normal_msgid = MMI_JMMS_MAX_JAVA_MSG_ID;
- U64 g_jmms_java_msgid = 0;
- /*****************************************************************************
- * Global Function
- *****************************************************************************/
- extern void mmi_jmms_create_template_messages(void);
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_normal_msgid_value_from_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_get_normal_msgid_value_from_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_JMMS_NORMAL_MESSAGE_ID, &g_jmms_normal_msgid, DS_DOUBLE, &error);
- if (g_jmms_normal_msgid > (0xFFFFFFFF)) // COMPILER WARNING REMOVAL
- {
- g_jmms_normal_msgid = MMI_JMMS_MAX_JAVA_MSG_ID;
- WriteValue(NVRAM_JMMS_NORMAL_MESSAGE_ID, &g_jmms_normal_msgid, DS_DOUBLE, &error);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_java_msgid_value_from_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_get_java_msgid_value_from_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ReadValue(NVRAM_JMMS_JAVA_MESSAGE_ID, &g_jmms_java_msgid, DS_DOUBLE, &error);
- if (g_jmms_java_msgid > (0xFFFFFFFF)) // COMPILER WARNING REMOVAL
- {
- g_jmms_java_msgid = 0;
- WriteValue(NVRAM_JMMS_JAVA_MESSAGE_ID, &g_jmms_java_msgid, DS_DOUBLE, &error);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_set_normal_msgid_value_to_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_set_normal_msgid_value_to_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- WriteValue(NVRAM_JMMS_NORMAL_MESSAGE_ID, &g_jmms_normal_msgid, DS_DOUBLE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_set_java_msgid_value_to_nvram
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_set_java_msgid_value_to_nvram(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- WriteValue(NVRAM_JMMS_JAVA_MESSAGE_ID, &g_jmms_java_msgid, DS_DOUBLE, &error);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_folder_list
- * DESCRIPTION
- * This function is to get the folder list from store
- * PARAMETERS
- * folder_list [IN] - list of folders
- * RETURNS
- * void
- *****************************************************************************/
- JC_RETCODE mmi_jmms_get_folder_list(FOLDER_INFO **folder_list)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FOLDER_INFO *pFolderList = NULL;
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_jdi_get_folders(g_jmms_context->hStoreHandle, &pFolderList);
- if (JC_OK == eRet)
- {
- *folder_list = pFolderList;
- }
- else
- {
- folder_list = NULL;
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_messages_list
- * DESCRIPTION
- * This function is to get the msg list from a folder
- * PARAMETERS
- * pFolderName [?] [?]
- * msg_list [IN] - list of mesages
- * retrieve_filters [?] [?]
- * folder_name - name of folder from which messages are to fetch out(?)(?)
- * RETURNS
- * void
- *****************************************************************************/
- JC_RETCODE mmi_jmms_get_messages_list(S8 *pFolderName, MESSAGE_LIST **msg_list, RETRIEVE_FILTERS *retrieve_filters)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, msg_list, retrieve_filters);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, msg_list, retrieve_filters);
- }
- }
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_mms_get_number_of_messages
- * DESCRIPTION
- * This function is to get the total number of messages present in a folder
- * PARAMETERS
- * pFolderName [?] [?]
- * total_num_messages [?] [?] - list of mesages
- * folder_name - name of folder from which messages are to fetch out(?)(?)
- * RETURNS
- * void
- *****************************************************************************/
- JC_RETCODE mmi_mms_get_number_of_messages(S8 *pFolderName, U8 *total_num_messages)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 len = 0;
- S8 *folder_name = NULL;
- JC_RETCODE eRet = JC_OK;
- FOLDER_INFO *folder_info = NULL;
- FOLDER_LIST *pFolderList = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *total_num_messages = 0;
- len = (strlen((PS8) pFolderName) + 1) * ENCODING_LENGTH;
- folder_name = (PS8) jdd_MemAlloc(sizeof(S8), len);
- if (NULL == folder_name)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- AnsiiToUnicodeString((PS8) folder_name, (PS8) pFolderName);
- /* manish changing */
- eRet = mmi_jmms_jdi_get_folders(g_jmms_context->hStoreHandle, &folder_info);
- if (JC_OK != eRet)
- {
- goto END;
- }
- pFolderList = folder_info->pFolderList;
- while (pFolderList != NULL)
- {
- if (pfnUnicodeStrcmp((S8*) pFolderList->pFolderName, (S8*) folder_name) == NULL)
- {
- *total_num_messages = pFolderList->uiTotalMessages;
- break;
- }
- pFolderList = pFolderList->pNext;
- }
- END:
- if (folder_name != NULL)
- {
- jdd_MemFree(folder_name);
- folder_name = NULL;
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_total_number_of_messages
- * DESCRIPTION
- *
- * PARAMETERS
- * total_num_messages [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_get_total_number_of_messages(U8 *total_num_messages)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 i = 0;
- U8 msgs = 0;
- S8 *folder_list[MMI_JMMS_NO_OF_SYSTEM_FOLDERS] = {MMI_JMMS_INBOX,
- MMI_JMMS_OUTBOX,
- MMI_JMMS_SENT,
- MMI_JMMS_DRAFTS,
- MMI_JMMS_TEMPLATES
- };
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *total_num_messages = 0;
- for (i = 0; i < MMI_JMMS_NO_OF_SYSTEM_FOLDERS; i++)
- {
- msgs = 0;
- eRet = mmi_mms_get_number_of_messages(folder_list[i], &msgs);
- if (eRet != JC_OK)
- {
- return eRet;
- }
- *total_num_messages += msgs;
- }
- return eRet;
- }
- /* PMT VIKAS START 20060325 */
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_free_size_for_mms
- * DESCRIPTION
- * This function is to get the total free space for mms
- * PARAMETERS
- * disk_free_space [?] [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_get_free_size_for_mms(U64 *disk_free_space)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 buf[6];
- FS_HANDLE file_handle;
- FS_DiskInfo disk_info;
- S32 fs_RetDrv = FS_GetDrive(FS_DRIVE_I_SYSTEM, 1, FS_NO_ALT_DRIVE);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *disk_free_space = 0;
- #ifdef MMS_IN_LARGE_STORAGE
- /* Order: 1. Invisible NAND 2. Visible NAND 3. visible NOR 4. Invisible NOR */
- fs_RetDrv = FS_GetDrive(FS_DRIVE_V_NORMAL, 2, FS_DRIVE_V_NORMAL | FS_DRIVE_I_SYSTEM);
- #endif /* MMS_IN_LARGE_STORAGE */
- sprintf(buf, "%c:\", (U8) fs_RetDrv);
- memset(subMenuData, 0, (FMGR_MAX_PATH_LEN + FMGR_MAX_FILE_LEN) * ENCODING_LENGTH);
- AnsiiToUnicodeString((S8*) subMenuData, (S8*) buf);
- file_handle = FS_Open((kal_uint16*) subMenuData, FS_OPEN_DIR | FS_READ_ONLY);
- if(file_handle)
- {
- FS_GetDiskInfo((PU16) subMenuData, &disk_info, FS_DI_BASIC_INFO | FS_DI_FREE_SPACE);
- *disk_free_space = disk_info.FreeClusters * disk_info.SectorsPerCluster * disk_info.BytesPerSector;
- FS_Close(file_handle);
- }
- }
- /* PMT VIKAS END 20060325 */
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_sys_folders_exist
- * DESCRIPTION
- * This function is check whether MMS Sys folders have been created or not
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- S32 mmi_jmms_sys_folders_exist(void)
- {
- JDD_FSHANDLE fs_handle = NULL;
- JC_INT32 drive_letter = FS_GetDrive(FS_DRIVE_I_SYSTEM, 1, FS_NO_ALT_DRIVE);
- JC_INT8 mms_folder_path_ascii[FMGR_MAX_PATH_LEN + 1];
- JC_CHAR mms_folder_path_ucs2[(FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH];
- JC_CHAR *mms_sys_filepath_ucs2 = NULL;
- JC_RETCODE eRet = JC_OK;
- #ifdef MMS_IN_LARGE_STORAGE
- /* Order: 1. Invisible NAND 2. Visible NAND 3. visible NOR 4. Invisible NOR */
- drive_letter = FS_GetDrive(FS_DRIVE_I_SYSTEM, 2, FS_DRIVE_V_NORMAL | FS_DRIVE_I_SYSTEM);
- #endif /* MMS_IN_LARGE_STORAGE */
- if (fs_handle == NULL)
- {
- if (jdd_FSInitialize(&fs_handle) != JC_OK)
- {
- return -1;
- }
- }
- jdi_UtilsCharToTchar(&mms_sys_filepath_ucs2, JDD_FS_MMS_SYS_FOLDER);
- if (jdd_FSIsDirExist(fs_handle, mms_sys_filepath_ucs2) == E_FALSE)
- {
- eRet=-1;
- goto error;
- }
- sprintf(mms_folder_path_ascii, "%c:\@mms", drive_letter);
- app_ansii_to_unicodestring((kal_int8*) mms_folder_path_ucs2, (kal_int8*) mms_folder_path_ascii);
- if (jdd_FSIsDirExist(fs_handle, mms_folder_path_ucs2) == E_FALSE)
- {
- eRet=-1;
- goto error;
- }
- error:
- jdd_MemFree(mms_sys_filepath_ucs2);
- if (fs_handle != NULL)
- {
- jdd_FSDeinitialize(fs_handle);
- fs_handle = NULL;
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_init_store
- * DESCRIPTION
- * This function is to initialize the store.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_init_store(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- /* FOLDER_INFO *folder_info=NULL; */
- JC_CHAR *folder_name = NULL;
- U32 len = 0;
- U32 i = 0;
- S8 *folder_list[MMI_JMMS_NO_OF_SYSTEM_FOLDERS] = {MMI_JMMS_INBOX,
- MMI_JMMS_OUTBOX,
- MMI_JMMS_SENT,
- MMI_JMMS_DRAFTS,
- MMI_JMMS_TEMPLATES
- };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_jdi_store_init(&g_jmms_context->hStoreHandle);
- if(mmi_jmms_sys_folders_exist()!=JC_OK)
- {
- g_jmms_context->init_done = JMMS_NOT_INITIALIZED;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_init_store: %d",g_jmms_context->init_done ));
- return;
- }
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet != JC_OK)
- {
- ASSERT(0);
- }
- }
- else
- {
- ASSERT(0);
- }
- }
- for (i = 0; i < MMI_JMMS_NO_OF_SYSTEM_FOLDERS; i++)
- {
- len = (strlen((S8*) folder_list[i]) + 1) * ENCODING_LENGTH;
- folder_name = (JC_CHAR*) jdd_MemAlloc(sizeof(S8), len);
- if (NULL == folder_name)
- {
- ASSERT(0);
- }
- AnsiiToUnicodeString((PS8) folder_name, (PS8) folder_list[i]);
- eRet = mmi_jmms_jdi_create_folder(g_jmms_context->hStoreHandle, (JC_CHAR*) folder_name, NULL);
- /* don't free memory on success. It will be used in Store. */
- if (eRet != JC_OK)
- {
- jdd_MemFree(folder_name);
- if(eRet!=JC_ERR_STORE_FOLDER_ALREADY_EXIST)
- {
- g_jmms_context->init_done = JMMS_NOT_INITIALIZED;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_init_store at bottom: %d",g_jmms_context->init_done ));
- return;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_create_templates_in_store
- * DESCRIPTION
- * This function is to initialize the templates. Should always be called after Initializing ans syncing store
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_create_templates_in_store(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- U8 num_mms = 0;
- eRet = mmi_mms_get_number_of_messages("Templates", &num_mms);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_mms_get_number_of_messages returns eRet = %d, No MMS =%d", eRet,num_mms ));
- if (eRet != JC_OK)
- {
- mmi_jmms_update_status_icon_indicator();
- g_jmms_context->init_done = JMMS_TEMPLATES_INITIALIZED;/*we won't be creating templates so let's READY JMMS anyway*/
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_create_templates_in_store: %d",g_jmms_context->init_done ));
- return;
- }
- if (num_mms < __MMI_MMS_TEMPLATES_NUM__)
- {
- eRet = mmi_jmms_delete_all_message("Templates");
- ASSERT(!(eRet != JC_OK && num_mms > 0));
- mmi_jmms_create_template_messages();
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_create_templates_in_store returns from second: %d ",num_mms));
- }
- else
- {
- g_jmms_context->init_done = JMMS_TEMPLATES_INITIALIZED;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_create_templates_in_store at bottom: %d",g_jmms_context->init_done ));
- }
- mmi_jmms_update_status_icon_indicator();
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_de_init_store
- * DESCRIPTION
- * This function is to deinitialize the store.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_de_init_store(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_jmms_context != NULL)
- {
- eRet = mmi_jmms_jdi_store_dinit(g_jmms_context->hStoreHandle);
- if (eRet == JC_OK)
- {
- g_jmms_context->hStoreHandle = NULL;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_restore_folder_info
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_restore_folder_info(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- JC_CHAR *folder_name = NULL;
- U32 len = 0;
- U32 i = 0;
- S8 *folder_list[MMI_JMMS_NO_OF_SYSTEM_FOLDERS] = {MMI_JMMS_INBOX,
- MMI_JMMS_OUTBOX,
- MMI_JMMS_SENT,
- MMI_JMMS_DRAFTS,
- MMI_JMMS_TEMPLATES
- };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_jdi_store_restore(g_jmms_context->hStoreHandle);
- if (eRet != JC_OK)
- {
- ASSERT(0);
- }
- eRet = mmi_jmms_jdi_store_dinit(g_jmms_context->hStoreHandle);
- if (eRet != JC_OK)
- {
- ASSERT(0);
- }
- g_jmms_context->hStoreHandle = NULL;
- eRet = mmi_jmms_jdi_store_init(&g_jmms_context->hStoreHandle);
- if (eRet != JC_OK)
- {
- ASSERT(0);
- }
- for (i = 0; i < MMI_JMMS_NO_OF_SYSTEM_FOLDERS; i++)
- {
- JC_RETCODE eRet_temp = JC_OK;
- len = (strlen((S8*) folder_list[i]) + 1) * ENCODING_LENGTH;
- folder_name = (JC_CHAR*) jdd_MemAlloc(sizeof(S8), len);
- if (NULL == folder_name)
- {
- ASSERT(0);
- }
- AnsiiToUnicodeString((PS8) folder_name, (PS8) folder_list[i]);
- eRet_temp = mmi_jmms_jdi_create_folder(g_jmms_context->hStoreHandle, (JC_CHAR*) folder_name, NULL);
- /* don't free memory on success. It will be used in Store. */
- if (eRet_temp != JC_OK)
- {
- jdd_MemFree(folder_name);
- }
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_delete_message_as_per_id
- * DESCRIPTION
- * This function is to delete the message from the store.
- * PARAMETERS
- * msgId [IN] Message Id
- * RETURNS
- * JC_RETCODE
- *****************************************************************************/
- void mmi_jmms_delete_message_as_per_id(U32 msgId)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MESSAGE_LIST *pMessageList = NULL;
- MESSAGE_LIST *pTempMessageList = NULL;
- S8 fname[100];
- U32 msgIndex = 0;
- JC_RETCODE eRet = JC_OK;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(fname, 0, 100);
- mmi_jmms_get_folder_name_from_folderId(JSR_INBOX, fname);
- /* /manish chnging here 0n 2 Feb */
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- mmi_jmms_get_messages_list((S8*) fname, &pMessageList, &StoreRetFilter);
- pTempMessageList = pMessageList;
- while (pTempMessageList)
- {
- msgIndex++;
- #ifdef __MMI_UNIFIED_MESSAGE__
- if ((pTempMessageList->uiExtraBytes & 0x00FFFFFF) == msgId) /* msgId is stored in the extra bytes of message list. */
- #else
- if (pTempMessageList->uiExtraBytes == msgId) /* msgId is stored in the extra bytes of message list. */
- #endif
- {
- eRet = mmi_jmms_delete_message(fname, msgIndex);
- if(eRet == JC_OK)
- mmi_jmms_delete_msg_status(msgIndex);
- break;
- }
- pTempMessageList = pTempMessageList->pNext;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_delete_message
- * DESCRIPTION
- * This function is to delete the message from the store.
- * PARAMETERS
- * pFolderName [?] [?]
- * uiMsgIndex [IN] - index of the message
- * folder_name - name of folder from where the message to be deleted(?)(?)
- * RETURNS
- * JC_RETCODE
- *****************************************************************************/
- JC_RETCODE mmi_jmms_delete_message(S8 *pFolderName, JC_UINT32 uiMsgIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MESSAGE_LIST *pMessageList = NULL;
- JC_RETCODE eRet = JC_OK;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- U8 number_mms = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- StoreRetFilter.uiStartIndex = uiMsgIndex;
- StoreRetFilter.uiNumMessage = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- }
- }
- if (eRet != JC_OK)
- {
- return eRet;
- }
- eRet = mmi_jmms_jdi_delete_msg(g_jmms_context->hStoreHandle, uiMsgIndex);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (g_jmms_context->msg_handle != NULL)
- {
- eRet = mmi_jmms_jdi_msg_deinit(g_jmms_context->msg_handle);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- g_jmms_context->msg_handle = NULL;
- }
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- eRet = mmi_jmms_jdi_update_msg_list(g_jmms_context->hStoreHandle, E_FALSE);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- }
- }
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_get_total_number_of_messages(&number_mms);
- if (eRet != JC_OK)
- {
- return eRet;
- }
- if (number_mms < MAX_POSSIBLE_MESSAGES)
- {
- mmi_jmms_remove_memory_full_node_if_present();
- }
- }
- /* PMT VIKAS START 20060405 */
- mmi_jmms_update_status_icon_indicator();
- /* PMT VIKAS END 20060405 */
- g_jmms_context->is_unread_msg_deleted = 0;
- if (strcmp(pFolderName, MMI_JMMS_INBOX) == 0)
- {
- if (g_jmms_context->is_unread_msg_deleted == 1)
- {
- mmi_jmms_handle_read_report(g_jmms_context->MsgHeader_type_p);
- }
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_save_message_buffer_in_Store
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * uiMsgIndex [?] [?]
- * MsgHeaders [?] [?]
- * Content [?] [?]
- * extraBytes [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_save_message_buffer_in_Store(
- S8 *pFolderName,
- JC_UINT32 *uiMsgIndex,
- MESSAGE_HEADERS *MsgHeaders,
- CONTENT_DATA *Content,
- JC_UINT32 *extraBytes)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 len = 0;
- S8 *folder_name = NULL;
- JC_RETCODE eRet = JC_OK;
- U32 msgId = 0;
- U8 number_mms = 0;
- // MMI_BOOL isJavaMsg = MMI_FALSE;
- // JC_INT8 *content_type = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* /check whether Total msgs count have been reached to max limit */
- eRet = mmi_jmms_get_total_number_of_messages(&number_mms);
- if (eRet != JC_OK)
- {
- return eRet;
- }
- if (number_mms >= MAX_POSSIBLE_MESSAGES)
- {
- mmi_jmms_add_memory_full_node_if_not_already();
- return E_MEMORY_FULL_ERROR;
- }
- len = (strlen((PS8) pFolderName) + 1) * ENCODING_LENGTH;
- folder_name = (PS8) jdd_MemAlloc(sizeof(S8), len);
- if (NULL == folder_name)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- AnsiiToUnicodeString((PS8) folder_name, (PS8) pFolderName);
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- jdd_MemFree(folder_name);
- return eRet;
- }
- mmi_jmms_get_normal_msgid_value_from_nvram();
- msgId = (U32) (g_jmms_normal_msgid) + 1;
- if (msgId >= MMI_JMMS_MAX_NORMAL_MSG_ID)
- {
- msgId = MMI_JMMS_MAX_JAVA_MSG_ID + 1;
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- if (extraBytes != NULL)
- {
- *extraBytes = msgId | *extraBytes;
- eRet = mmi_jmms_jdi_save_msg(
- g_jmms_context->hStoreHandle,
- (JC_CHAR*) folder_name,
- 0,
- MsgHeaders,
- Content,
- uiMsgIndex,
- *extraBytes);
- }
- else
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- eRet = mmi_jmms_jdi_save_msg(
- g_jmms_context->hStoreHandle,
- (JC_CHAR*) folder_name,
- 0,
- MsgHeaders,
- Content,
- uiMsgIndex,
- msgId);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- }
- }
- else
- {
- g_jmms_normal_msgid = msgId;
- mmi_jmms_set_normal_msgid_value_to_nvram();
- }
- jdd_MemFree(folder_name);
- /* sandeep there is no need to update for saving notification
- if (eRet == JC_OK)
- {
- mmi_jmms_update_status_icon_indicator();
- }
- */
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_message
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * Content [?] [?]
- * index [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_get_message(S8 *pFolderName, CONTENT_DATA *Content, JC_INT32 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- MESSAGE_LIST *pMessageList = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- ///TODO:: need to check this step whether require and check if require get only for
- //index
- ///manish chnging here 0n 2 Feb
- StoreRetFilter.uiStartIndex = index;
- StoreRetFilter.uiNumMessage = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- }
- }
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg(g_jmms_context->hStoreHandle, index, Content);
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_store_move_message
- * DESCRIPTION
- *
- * PARAMETERS
- * pSrcFolderName [?] [?]
- * pDestFolderName [?] [?]
- * uiMsgIndex [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_store_move_message(S8 *pSrcFolderName, S8 *pDestFolderName, JC_UINT32 *uiMsgIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 len = 0;
- S8 *folder_name = NULL;
- JC_RETCODE eRet = JC_OK;
- MESSAGE_LIST *pMessageList = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pSrcFolderName);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- StoreRetFilter.uiStartIndex = *uiMsgIndex;
- StoreRetFilter.uiNumMessage = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (eRet != JC_OK)
- {
- goto END;
- }
- }
- else
- {
- goto END;
- }
- }
- else
- {
- goto END;
- }
- }
- len = (strlen((S8*) pDestFolderName) + 1) * ENCODING_LENGTH;
- folder_name = (S8*) jdd_MemAlloc(sizeof(S8), len);
- if (NULL == folder_name)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- AnsiiToUnicodeString((S8*) folder_name, (PS8) pDestFolderName);
- eRet = mmi_jmms_jdi_move_msg(g_jmms_context->hStoreHandle, (JC_UINT32) (*uiMsgIndex), (JC_CHAR*) folder_name);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet != JC_OK)
- {
- goto END;
- }
- }
- else
- {
- goto END;
- }
- }
- eRet = mmi_jmms_jdi_update_msg_list(g_jmms_context->hStoreHandle, E_FALSE);
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- }
- END:
- jdd_MemFree(folder_name);
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_store_update_message
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * uiMsgIndex [?] [?]
- * MsgHeaders [?] [?]
- * Content [?] [?]
- * extraBytes [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_store_update_message(
- S8 *pFolderName,
- JC_UINT32 *uiMsgIndex,
- MESSAGE_HEADERS *MsgHeaders,
- CONTENT_DATA *Content,
- JC_UINT32 extraBytes)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- MESSAGE_LIST *pMessageList = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- U32 msgId = 0;
- MMI_BOOL isJavaMsg = MMI_FALSE;
- JC_INT8 *content_type = NULL;
- JC_UINT32 new_extraBytes = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- StoreRetFilter.uiStartIndex = *uiMsgIndex;
- StoreRetFilter.uiNumMessage = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- }
- }
- if (eRet != JC_OK)
- {
- return eRet;
- }
- }
- if( pMessageList == NULL)
- {
- return -1;
- }
- mmi_jmms_get_content_type(Content, &content_type);
- if (content_type != NULL)
- {
- isJavaMsg = mmi_jsr_check_recv_mms_for_java(content_type);
- }
- if (isJavaMsg == MMI_TRUE)
- {
- mmi_jmms_get_java_msgid_value_from_nvram();
- msgId = (U32) (g_jmms_java_msgid) + 1;
- if (msgId >= MMI_JMMS_MAX_JAVA_MSG_ID)
- {
- msgId = 0;
- }
- }
- else
- {
- msgId = (U32) (pMessageList->uiExtraBytes & 0x00FFFFFF);
- }
- if (extraBytes != 0)
- {
- new_extraBytes = (extraBytes & 0xFF000000);
- }
- else
- {
- new_extraBytes = (pMessageList->uiExtraBytes & 0xFF000000);
- }
- new_extraBytes |= msgId;
- eRet = mmi_jmms_jdi_update_msg(g_jmms_context->hStoreHandle, *uiMsgIndex, MsgHeaders, Content, new_extraBytes);
- if (eRet == JC_OK)
- {
- if (isJavaMsg == E_TRUE)
- {
- g_jmms_java_msgid = msgId;
- mmi_jmms_set_java_msgid_value_to_nvram();
- mmi_jsr_add_recv_java_mms_content(msgId, content_type);
- }
- }
- if (content_type != NULL)
- {
- jdd_MemFree(content_type);
- content_type = NULL;
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_store_update_message_extrabyte
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * uiMsgIndex [IN] [?]
- * uiExtraBytes [IN]
- * extraBytes(?) [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_store_update_message_extrabyte(S8 *pFolderName, JC_UINT32 uiMsgIndex, JC_UINT32 uiExtraBytes)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MESSAGE_LIST *pMessageList = NULL;
- JC_RETCODE eRet = JC_OK;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- StoreRetFilter.uiStartIndex = uiMsgIndex;
- StoreRetFilter.uiNumMessage = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- }
- else
- {
- return eRet;
- }
- }
- else
- {
- return eRet;
- }
- }
- if (eRet != JC_OK)
- {
- return eRet;
- }
- eRet = mmi_jmms_jdi_update_extrabytes(g_jmms_context->hStoreHandle, uiMsgIndex, uiExtraBytes);
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_delete_all_message
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_delete_all_message(S8 *pFolderName)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- U8 number_mms = 0;
- // TODO::manish changing here.Ned to test
- MESSAGE_LIST *pMessageList = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_delete_all_message: %s", pFolderName));
- if (JC_OK != eRet)
- {
- return eRet;
- }
- StoreRetFilter.uiStartIndex = 1;
- StoreRetFilter.uiNumMessage = 0;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- }
- }
- if (eRet != JC_OK)
- {
- return eRet;
- }
- }
- eRet = mmi_jmms_store_jdi_delete_all_msg(g_jmms_context->hStoreHandle);
- if (JC_OK != eRet)
- {
- return eRet;
- }
- eRet = mmi_jmms_jdi_update_msg_list(g_jmms_context->hStoreHandle, E_FALSE);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet != JC_OK)
- {
- return eRet;
- }
- }
- }
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_get_total_number_of_messages(&number_mms);
- if (eRet != JC_OK)
- {
- return eRet;
- }
- if (number_mms < MAX_POSSIBLE_MESSAGES)
- {
- mmi_jmms_remove_memory_full_node_if_present();
- }
- /* PMT VIKAS START 20060405 */
- mmi_jmms_update_status_icon_indicator();
- /* PMT VIKAS END 20060405 */
- }
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_message_id
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * uiMsgIndex [IN]
- * RETURNS
- *
- *****************************************************************************/
- JC_UINT32 mmi_jmms_get_message_id(S8 *pFolderName, JC_UINT32 uiMsgIndex)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- JC_UINT32 msgId = 0;
- MESSAGE_LIST *pMessageList = NULL;
- RETRIEVE_FILTERS StoreRetFilter = {0, };
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- eRet = mmi_jmms_set_active_folder(pFolderName);
- if (JC_OK != eRet)
- {
- return 0;
- }
- StoreRetFilter.uiStartIndex = uiMsgIndex;
- StoreRetFilter.uiNumMessage = 1;
- StoreRetFilter.eRetrieve = E_RETRIEVE_BY_INDEX;
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- if (JC_OK != eRet)
- {
- if (JC_ERR_STORE_FILE_CORRUPTED == eRet)
- {
- eRet = mmi_jmms_restore_folder_info();
- if (eRet == JC_OK)
- {
- eRet = mmi_jmms_jdi_get_msg_list(g_jmms_context->hStoreHandle, &pMessageList, &StoreRetFilter);
- }
- }
- if (eRet != JC_OK)
- {
- return 0;
- }
- }
- #ifdef __MMI_UNIFIED_MESSAGE__
- msgId = pMessageList->uiExtraBytes & 0x00FFFFFF;
- #else
- msgId = pMessageList->uiExtraBytes;
- #endif
- return msgId;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_free_messages_list
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_jmms_free_messages_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- STORAGE_CTX *pStorageHandle = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pStorageHandle = (STORAGE_CTX*) (g_jmms_context->hStoreHandle);
- if (pStorageHandle->pMessageList != NULL)
- {
- StoreFreeMessageList(pStorageHandle->pMessageList);
- pStorageHandle->pMessageList = NULL;
- }
- }
- /* PMT VIKAS START 20060401 */
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_get_number_of_unread_messages_in_inbox
- * DESCRIPTION
- *
- * PARAMETERS
- * total_num_unread_messages [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_get_number_of_unread_messages_in_inbox(U8 *total_num_unread_messages)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE eRet = JC_OK;
- U8 msgs = 0;
- U8 i = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- *total_num_unread_messages = 0;
- eRet = mmi_mms_get_number_of_messages(MMI_JMMS_INBOX, &msgs);
- if (eRet != JC_OK)
- {
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "mmi_jmms_get_number_of_unread_messages_in_inbox returns = ",eRet));
- return eRet;
- }
- for (i = 0; i < msgs; i++)
- {
- U8 msg_index = 0;
- msg_index = msgs - i;
- msg_index = msg_index - 1;
- if (mmi_jmms_is_msg_read(msg_index) == MMI_FALSE)
- {
- *total_num_unread_messages = *total_num_unread_messages + 1;
- }
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s%d", "unread_messages_in_inbox = ",*total_num_unread_messages));
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_set_active_folder
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- JC_RETCODE mmi_jmms_set_active_folder(S8 *pFolderName)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 len = 0;
- JC_CHAR *folder_name = NULL;
- JC_RETCODE eRet = JC_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- len = strlen((PS8) pFolderName);
- folder_name = (JC_CHAR*) jdd_MemAlloc(sizeof(JC_CHAR), len + 1);
- if (NULL == folder_name)
- {
- return JC_ERR_MEMORY_ALLOCATION;
- }
- AnsiiToUnicodeString((PS8) folder_name, (PS8) pFolderName);
- eRet = mmi_jmms_jdi_set_active_folder(g_jmms_context->hStoreHandle, (JC_CHAR*) folder_name);
- jdd_MemFree(folder_name);
- return eRet;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_delete_progresing_screen
- * DESCRIPTION
- *
- * PARAMETERS
- * pFolderName [?] [?]
- * RETURNS
- *
- *****************************************************************************/
- void mmi_jmms_delete_progresing_screen(U16 title_str_id, U16 image_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EntryNewScreen(SCR_ID_JMMS_DELETING_PROGRESS, NULL, NULL, NULL);
- ShowCategory8Screen(
- title_str_id,
- GetRootTitleIcon(MAIN_MENU_MESSAGES_MENUID),
- 0,
- 0,
- 0,
- 0,
- STR_ID_JMMS_DELETING_MMS,
- image_id,
- NULL);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_jmms_recreate_sys_folders
- * DESCRIPTION
- *
- * PARAMETERS
- * void [?] [?]
- * RETURNS
- * JC_RETCODE
- *****************************************************************************/
- JC_RETCODE mmi_jmms_recreate_sys_folders(void)
- {
- JDD_FSHANDLE fs_handle = NULL;
- JC_INT32 drive_letter = FS_GetDrive(FS_DRIVE_I_SYSTEM, 1, FS_NO_ALT_DRIVE);
- JC_INT8 mms_folder_path_ascii[30];
- JC_CHAR mms_folder_path_ucs2[30 * ENCODING_LENGTH];
- JC_CHAR *mms_sys_filepath_ucs2 = NULL;
- JC_RETCODE eRet = JC_OK;
- #ifdef MMS_IN_LARGE_STORAGE
- /* Order: 1. Invisible NAND 2. Visible NAND 3. visible NOR 4. Invisible NOR */
- drive_letter = FS_GetDrive(FS_DRIVE_I_SYSTEM, 2, FS_DRIVE_V_NORMAL | FS_DRIVE_I_SYSTEM);
- #endif /* MMS_IN_LARGE_STORAGE */
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "Enters mmi_jmms_recreate_sys_folders"));
- if (fs_handle == NULL)
- {
- if (jdd_FSInitialize(&fs_handle) != JC_OK)
- {
- return -1;
- }
- }
- jdi_UtilsCharToTchar(&mms_sys_filepath_ucs2, JDD_FS_MMS_SYS_FOLDER);
- if (jdd_FSIsDirExist(fs_handle, mms_sys_filepath_ucs2) == E_TRUE)
- {
- eRet=jdd_FSDelDir(fs_handle, mms_sys_filepath_ucs2);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_delete_sys_folders: %d",eRet));
- eRet=jdd_FSMakeDir(fs_handle, mms_sys_filepath_ucs2);
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "mmi_jmms_create_sys_folders: %d",eRet));
- }
- error:
- jdd_MemFree(mms_sys_filepath_ucs2);
- if (fs_handle != NULL)
- {
- jdd_FSDeinitialize(fs_handle);
- fs_handle = NULL;
- }
- return eRet;
- }
- /* PMT VIKAS END 20060401 */
- #endif /* (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT)) */
- #endif /* _MMI_JMMSSTOREHANDLING_C */ /* _MMI_STOREHANDLING_C */