📄 jsr205.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
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* mmi_jsr.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* 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!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef _MMI_JSR_C
#define _MMI_JSR_C
/* Include: MMI header file */
#include "MMI_features.h"
#if (defined (JATAAYU_SUPPORT) && defined(MMS_SUPPORT))
#include "stdC.h"
#include "PixtelDataTypes.h"
#include "Fat_fs.h"
#include "QueueGProt.h"
#include "EventsGprot.h"
#include "ProtocolEvents.h"
#include "DebugInitDef.h" /* Debug Info */
#include "JsrTypes.h"
#include "JsrProts.h"
#include "JMMSJSRHandler.h"
#include "JMMSGprot.h"
#include "jdd_memapi.h" /* JDD memory allocation functions */
#include "JProfileHandlerTypes.h"
#include "JProfileHandlerProts.h"
#ifdef __MMI_UNIFIED_MESSAGE__
#include "JMMSUMHandling.h"
#endif
#include "Unicodexdcl.h" /* Unicode transform functions */
#include "UCS2Prot.h"
/*****************************************************************************
* Define
*****************************************************************************/
/*****************************************************************************
* Typedef
*****************************************************************************/
/*****************************************************************************
* Local Variable
*****************************************************************************/
/*****************************************************************************
* Local Function
*****************************************************************************/
static JsrResult mmi_jsr_write_folder_status_to_file(U32 no_of_message, JsrMessageInfo *list);
static void mmi_jsr_read_object_list_from_file(void);
static MMI_BOOL mmi_jsr_write_object_list_to_file(void);
static MMI_BOOL mmi_jsr_insert_appid_info_to_list(
jsr_appid_msgid_list **appid_object_list,
S8 *string,
jsr_msg_info *msg_list);
static MMI_BOOL mmi_jsr_remove_appid_info_from_list(jsr_appid_msgid_list **list, S8 *appId);
static MMI_BOOL mmi_jsr_remove_appid_info_from_list_recursive(jsr_appid_msgid_list **list);
static MMI_BOOL mmi_jsr_insert_msg_info_to_list(jsr_msg_info **msg_list, U32 msgId, U8 ischecked);
static MMI_BOOL mmi_jsr_remove_msg_info_from_list(jsr_msg_info **list, U32 msgId);
static MMI_BOOL mmi_jsr_remove_msg_info_from_list_recursive(jsr_msg_info **list);
static U32 mmi_jsr_get_digit_of_integer(U32 msgId);
static U32 mmi_jsr_get_current_size_of_object_list(jsr_appid_msgid_list *appid_object_list, U32 *max_chrs_in_line);
static void mmi_jsr_read_line_from_file(U32 filehandle, S8 *buffer, U32 buf_length, U32 *line_length, S32 *ret);
static MMI_BOOL mmi_jsr_check_appId(S8 *appId);
/*****************************************************************************
* Global Variable
*****************************************************************************/
jsr_context_struct jsr_cntx;
jsr_context_struct *jsr_cntx_p = &jsr_cntx;
jsr_appid_msgid_list *g_jsr_appid_object_list = NULL;
jsr_appid_info_struct *jsr_appid_db[JSR_MAX_APP_ID_NUM]; /* for registered apps */
/*****************************************************************************
* Global Function
*****************************************************************************/
extern int mmi_charset_ucs2_to_utf8_length_in_bytes(const kal_uint8 *raw);
extern kal_int32 mmi_chset_ucs2_to_utf8_string(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
extern void mmi_jmms_reset_mms_downloading_busy(void);
extern void mmi_jmms_update_status_icon_indicator(void);
/*****************************************************************************
* FUNCTION
* JsrCleanContext
* DESCRIPTION
* Clear the JSR context information.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void JsrCleanContext(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (JSR_CNTX)
{
JSR_CNTX->op = 0;
JSR_CNTX->state = 0;
JSR_CNTX->msgId = 0;
JSR_CNTX->curr_media_obj_no = 0;
JSR_CNTX->total_media_obj_no = 0;
JSR_CNTX->retrievalMode = 0;
}
}
/*****************************************************************************
* FUNCTION
* mmi_jsr_init_appid_msgid_list
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_jsr_init_appid_msgid_list(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (g_jsr_appid_object_list == NULL)
{
mmi_jsr_read_object_list_from_file();
}
}
//Testing Stubs start
//wap_mmc_read_folder_status_req_ind_struct folder_status;
//extern void mmi_jmms_get_msgid_value_from_nvram(void);
//void mmi_jmms_java_mms_set_content_type_params(wap_mmc_recv_appmms_rsp_struct* resp,JC_INT8 *content_type);
//wap_mmc_recv_appmms_rsp_struct recv_struct;
//wap_mmc_delete_msg_req_ind_struct delete_struct;
/* wap_mmc_upload_msg_req_ind_struct upload_struct; */
/*****************************************************************************
* FUNCTION
* mmi_jsr_testing
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_jsr_testing(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
// folder_status.folderId = JSR_DRAFTS;
// folder_status.folderId = JSR_TEMPLATES;
// folder_status.retrievalMode = JSR_FULL;
// mmi_jsr_read_folder_status_req_hldr(&folder_status);
// delete_struct.folderId = 0;
// delete_struct.msgId = 6;
// mmi_jsr_delete_msg_req_hldr(&delete_struct);
// pfnUnicodeStrcpy(upload_struct.filePath,"C\0:\0\\\0t\0e\0m\0p\0.\0m\0");
// mmi_jsr_upload_msg_req_hldr((void*)&upload_struct);
// mmi_jmms_get_msgid_value_from_nvram(); //tested
// mmi_jmms_java_mms_set_content_type_params(&recv_struct, "application/vnd.wap.multipart.related; Type=application/smil; Start=\"<smil-part>\"; Application-ID=com.siemens.Messenger; Reply-To-Application-ID=com.siemens.Messenger");//tested
}
/* Testing Stubs end. */
/* AT COMMANDS API */
/*****************************************************************************
* FUNCTION
* mmi_jsr_write_folder_status_to_file
* DESCRIPTION
* Write mms folder status to information file
* PARAMETERS
* no_of_msgs [IN] Number of messages
* list [?] List of messages
* RETURNS
* JsrResult
*****************************************************************************/
JsrResult mmi_jsr_write_folder_status_to_file(U32 no_of_msgs, JsrMessageInfo *list)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 msg_no = 0;
int info_file_size = 0;
int result = JSR_RESULT_ERROR;
U32 bytes_written = 0;
JsrMessageInfo *msgInfo_p = NULL;
/* for new phone suite */
JDD_FSHANDLE file_handle = NULL;
JC_CHAR *pInFilename = NULL;
S8 buff[20];
JDD_FILE fh = NULL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* for new phone suite */
if (file_handle == NULL)
{
jdd_FSInitialize(&file_handle);
}
memset(buff, 0, 20);
pInFilename = jdd_MemAlloc(sizeof(S8), 100);
if (NULL == pInFilename)
{
result = JSR_RESULT_INSUFFICIENT_MEMORY;
goto END;
}
AnsiiToUnicodeString((S8*) pInFilename, (S8*) (JDD_FS_MMS_SYS_FOLDER));
AnsiiToUnicodeString((S8*) buff, (S8*) "\\");
pfnUnicodeStrcat((S8*) pInFilename, (S8*) buff);
AnsiiToUnicodeString((S8*) buff, (S8*) (JSR_INFO));
pfnUnicodeStrcat((S8*) pInFilename, (S8*) buff);
jdd_FSDelete(file_handle, (JC_CHAR*) pInFilename);
if (no_of_msgs == 0)
{
result = JSR_RESULT_OK;
goto END;
}
fh = jdd_FSOpen(file_handle, (JC_CHAR*) pInFilename, E_CREATE_WRITE_MODE);
if (fh == NULL)
{
result = JSR_RESULT_FILE_OPERATION_ERROR;
goto END;
}
info_file_size = no_of_msgs * sizeof(JsrMessageInfo);
msgInfo_p = (JsrMessageInfo*) jdd_MemAlloc(no_of_msgs, sizeof(JsrMessageInfo));
if (NULL == msgInfo_p)
{
result = JSR_RESULT_INSUFFICIENT_MEMORY;
goto END;
}
memset(msgInfo_p, 0, (no_of_msgs * sizeof(JsrMessageInfo)));
for (msg_no = 0; msg_no < no_of_msgs; msg_no++)
{
msgInfo_p[msg_no].msgId = list[msg_no].msgId;
/* 180406 */
msgInfo_p[msg_no].offset = list[msg_no].offset;
msgInfo_p[msg_no].date = list[msg_no].date;
msgInfo_p[msg_no].size = list[msg_no].size;
/* msgInfo_p[msg_no].fileType = list[msg_no].fileType; */
strcpy((S8*) msgInfo_p[msg_no].filename, (S8*) list[msg_no].filename);
/* write address and subject only when retrieval mode is JSR_FULL */
if (JSR_CNTX->retrievalMode == JSR_FULL)
{
strcpy((S8*) msgInfo_p[msg_no].address, (S8*) list[msg_no].address);
strcpy((S8*) msgInfo_p[msg_no].subject, (S8*) list[msg_no].subject);
}
}
bytes_written = jdd_FSWrite(msgInfo_p, 1, info_file_size, fh);
if (bytes_written != info_file_size)
{
jdd_FSDelete(file_handle, (JC_CHAR*) pInFilename);
result = JSR_RESULT_INSUFFICIENT_MEMORY;
goto END;
}
PRINT_INFORMATION_2((MMI_TRACE_INFO, "%s(%d): JSR module write folder status to info.db file. \n", __FILE__,
__LINE__));
result = JSR_RESULT_OK;
END:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -