mmimms_main.c
资源名称:MMSCodes.rar [点击查看]
上传用户:fuyouda
上传日期:2021-12-23
资源大小:164k
文件大小:313k
源码类别:
手机彩信(MMS)编程
开发平台:
C/C++
- &overlapped
- );
- if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
- {
- if (param_save_ptr != NULL)
- {
- cms_free(param_save_ptr );
- param_save_ptr = NULL;
- }
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- mmsf_Remove((char *)"\cmsoutbox.cnf");
- if (g_mailbox_status == SEND_OUTBOX_MMS)
- {
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MANAGERFILEWRITE_OUTBOX_FAILED,
- PNULL,
- PNULL
- );
- }
- return ;
- }
- }
- else
- {
- mmsf_Remove((char*)"\cmsoutbox.cnf" );
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_OUTBOXNAME) == TRUE)
- {
- FFS_ERROR_E ffs_error = 0;
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MANAGER_FLASH_OUTBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_OUTBOXNAME));
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
- overlapped.param = PNULL;
- ffs_error = FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
- SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
- }
- if (g_mailbox_status == SEND_OUTBOX_MMS)
- {
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MANAGERFILEWRITE_OUTBOX_FAILED,
- PNULL,
- PNULL
- );
- }
- return;
- }
- }
- /*==============================================================
- * 函数名: MMIMMS_SaveManagerSentboxFile
- * 输入: 空
- * 输出: void
- * 功能描述: 存储相应涉及已发件箱的虚拟文件到flash资源。
- 因为为异步文件系统,目前顺序是:收件箱;发件箱;
- 已发邮件;草稿箱。
- * 代码编写者: liangliu
- * 代码编写日期: 10/28/2005
- * 修改原因:
- * 修改人员:
- * 修改日期:
- ==============================================================*/
- void MMIMMS_SaveManagerSentboxFile()
- {
- //FILE_HANDLE cmshandle = 0;
- uint8* tempbuf= NULL;
- //int curroffset;
- uint32 filelen = 0;
- //static HFS s_hefs = FFS_INVALID_HANDLE;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- //uint32 file_size = 0;
- //uint16 *file_name =NULL;
- //uint16 * dir_name =PNULL;
- //uint16 unicodelong = 0 ;
- //MMI_STRING_T prompt_str;
- FFS_ERROR_E efs_error;
- FFS_OVERLAPPED_T overlapped;
- uint32 transmit;
- //uint8 *efs_buf_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
- SCI_TRACE_LOW("MMIMMS_SaveManagerSentboxFile IN ---------");
- mmsf_GetConstFileData((char *)"\cmssentbox.cnf",(char **)&tempbuf,(int *)&filelen);
- SCI_TRACE_LOW("fnh filelen = %d",filelen);
- SCI_TRACE_LOW("fnh tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
- if (filelen > 0)
- {
- SCI_TRACE_LOW("HERE MMIMMS_SaveManagerSentboxFile THE filehandle >0");
- if(0!=FILE_CdMMSPath())
- {
- FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
- FILE_CdMMSPath();
- }
- cur_hefs = FILE_Create((char*)MANAGER_FLASH_SENTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- //the reason may be that I have not closed the former opened file with the same name
- FILE_Close(cur_hefs); //close former file
- cur_hefs = FILE_Create((char*)MANAGER_FLASH_SENTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- SCI_TRACE_LOW("FNH here create sentbox is fail");
- mmsf_Remove((char *)"\cmssentbox.cnf");
- return;
- }
- }
- param_save_ptr = (FFS_SAVEFILE_RESULT_T*)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
- if (param_save_ptr == NULL)
- {
- SCI_TRACE_LOW("FNH param_save_ptr malloc fail");
- mmsf_Remove((char *)"\cmssentbox.cnf");
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- return ;
- }
- SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- param_save_ptr->buf_ptr = tempbuf;
- param_save_ptr->hefs = cur_hefs;//传递的参数
- param_save_ptr->buf_size = filelen;
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
- overlapped.complete_route = SaveFS_SaveSentboxFile_CallBack;
- efs_error = FILE_Write(
- cur_hefs,
- tempbuf,
- filelen,
- &transmit,
- &overlapped
- );
- if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
- {
- if (param_save_ptr != NULL)
- {
- cms_free(param_save_ptr);
- param_save_ptr = NULL;
- }
- mmsf_Remove((char *)"cmssentbox.cnf");
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- return ;
- }
- }
- else
- {
- mmsf_Remove((char*)"\cmssentbox.cnf" );
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_SENTBOXNAME) == TRUE)
- {
- FFS_ERROR_E ffs_error = 0;
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MANAGER_FLASH_SENTBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_SENTBOXNAME));
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
- overlapped.param = PNULL;
- ffs_error = FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
- SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
- }
- }
- }
- /*==============================================================
- * 函数名: MMIMMS_SaveManagerDraftboxFile
- * 输入: 空
- * 输出: void
- * 功能描述: 存储相应涉及草稿箱的虚拟文件到flash资源。
- 因为为异步文件系统,目前顺序是:收件箱;发件箱;
- 已发邮件;草稿箱。
- * 代码编写者: liangliu
- * 代码编写日期: 10/28/2005
- * 修改原因:
- * 修改人员:
- * 修改日期:
- ==============================================================*/
- void MMIMMS_SaveManagerDraftboxFile(void)
- {
- //FILE_HANDLE cmshandle = 0;
- uint8* tempbuf = NULL;
- //int curroffset;
- uint32 filelen = 0;
- //static HFS s_hefs = FFS_INVALID_HANDLE;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- //uint32 file_size = 0;
- //uint16 *file_name =NULL;
- //uint16 * dir_name =PNULL;
- //uint16 unicodelong = 0 ;
- //MMI_STRING_T prompt_str;
- FFS_ERROR_E efs_error;
- FFS_OVERLAPPED_T overlapped;
- uint32 transmit;
- //uint8 *efs_buf_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
- mmsf_GetConstFileData((char *)"\cmsdraftbox.cnf",(char **)&tempbuf,(int *)&filelen);
- SCI_TRACE_LOW("fnh filelen = %d",filelen);
- SCI_TRACE_LOW("fnh tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
- if (filelen > 0)
- {
- SCI_TRACE_LOW("MMIMMS_SaveManagerDraftboxFile THE cmshandle > 0");
- if(0!=FILE_CdMMSPath())
- {
- FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
- FILE_CdMMSPath();
- }
- cur_hefs = FILE_Create((char*)MANAGER_FLASH_DRAFTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile CREATE FILE FAILED1");
- //the reason may be that I have not closed the former opened file with the same name
- FILE_Close(cur_hefs); //close former file
- cur_hefs = FILE_Create((char*)MANAGER_FLASH_DRAFTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile CREATE FILE IS FAILED2");
- mmsf_Remove((char *)"\cmsdraftbox.cnf");
- return ;
- }
- }
- SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile CREATE FILE IS OK");
- param_save_ptr = (FFS_SAVEFILE_RESULT_T*)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
- if (param_save_ptr == NULL)
- {
- SCI_TRACE_LOW("fnh param_save_ptr malloc fail");
- mmsf_Remove((char *)"\cmsdraftbox.cnf");
- FILE_Close(cur_hefs );
- cur_hefs = FFS_INVALID_HANDLE;
- return;
- }
- SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- param_save_ptr->buf_ptr = tempbuf;
- param_save_ptr->hefs = cur_hefs;//传递的参数
- param_save_ptr->buf_size = filelen;
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
- overlapped.complete_route = SaveFS_SaveDraftboxFile_CallBack;
- efs_error = FILE_Write(
- cur_hefs,
- tempbuf,
- filelen,
- &transmit,
- &overlapped
- );
- if((FFS_ERROR_IO_PENDING != efs_error) &&(FFS_NO_ERROR != efs_error))
- {
- SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile 1");
- if (param_save_ptr != NULL)
- {
- cms_free(param_save_ptr );
- param_save_ptr = NULL;
- }
- mmsf_Remove((char *)"\cmsdraftbox.cnf");
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- return ;
- }
- }
- else
- {
- mmsf_Remove((char*)"\cmsdraftbox.cnf" );
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_DRAFTBOXNAME) == TRUE)
- {
- FFS_ERROR_E ffs_error = 0;
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MANAGER_FLASH_DRAFTBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_DRAFTBOXNAME));
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
- overlapped.param = PNULL;
- ffs_error = FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
- SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
- }
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: CmsTimeToString
- * Purpose: 取得文件的长度
- * Input: 虚拟文件句柄
- * Returns: 虚拟文件的长度
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint32 Cms_GetFileLength( FILE_HANDLE file)
- {
- uint32 curroffset = 0;
- uint32 filelength = - 1;
- curroffset = mmsf_Tell(file);
- if(curroffset!=-1 && mmsf_Seek(file, 0, SEEK_END)==0)
- {
- filelength = mmsf_Tell(file);
- mmsf_Seek(file, curroffset, SEEK_SET);
- }
- return filelength;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveInboxFile_CallBack
- * Purpose: 处理保存收件箱文件的回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveInboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveInboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- MMK_PostMsg(
- VIRTUAL_WIN_ID,
- MSG_MANAGERFILEWRITE_INBOX_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- g_savestate = MMS_MSG_SAVEFILE_FOR_NULL;
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveInboxPUSHFile_CallBack
- * Purpose: 处理保存收件箱中PUSH文件的回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveInboxPUSHFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveInboxPUSHFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- MMK_PostMsg(
- MMIMMS_READ_MMS_WAITING_WIN_ID,
- MSG_MANAGERFILEWRITE_INBOX_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- g_savestate = MMS_MSG_SAVEFILE_FOR_NULL;
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveOutboxFile_CallBack
- * Purpose: 处理保存彩信到发件箱回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveOutboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveOutboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- if (g_mailbox_status != SEND_OUTBOX_MMS)
- {
- MMK_PostMsg(
- VIRTUAL_WIN_ID,
- MSG_MANAGERFILEWRITE_OUTBOX_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- }else
- {
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MANAGERFILEWRITE_OUTBOX_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- );
- }
- //free in param
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveSentboxFile_CallBack
- * Purpose: 处理保存彩信到已发箱回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveSentboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveSentboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- MMK_PostMsg(
- VIRTUAL_WIN_ID,
- MSG_MANAGERFILEWRITE_SENTBOX_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveDraftboxFile_CallBack
- * Purpose: 处理保存彩信到草稿箱回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveDraftboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveDraftboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- MMK_PostMsg(
- VIRTUAL_WIN_ID,
- MSG_MANAGERFILEWRITE_DRAFTBOX_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetManagerDocument
- * Purpose:获得当前的彩信管理结构
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_GetManagerDocument(MMIMMS_OPTION_BOX option_box)
- {
- pMessageFolder folder =NULL;
- SCI_TRACE_LOW("MMIMMS_GetManagerDocument in ----");
- if (g_pManager == NULL)
- {
- g_pManager = (P_ManagerDocument)cms_malloc(sizeof(ManagerDocument));
- if(!g_pManager)
- {
- SCI_TRACE_LOW("malloc failed,g_pManager = NULL");
- return ;
- }
- SCI_MEMSET(g_pManager,0,sizeof(ManagerDocument));
- }
- if (g_pManager->inboxfolder == NULL)
- {
- SCI_TRACE_LOW("FNH IS INBOX!");
- folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
- if(!folder)
- {
- SCI_TRACE_LOW("malloc failed,infolder = NULL");
- return ;
- }
- SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
- folder->type = MMS_FOLDER_TYPE_INBOX;
- g_pManager->inboxfolder = folder;
- folder = NULL;
- }
- if (g_pManager->outboxfolder == NULL)
- {
- SCI_TRACE_LOW("FNH IS OUTBOX");
- folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
- if(!folder)
- {
- SCI_TRACE_LOW("malloc failed,outfolder = NULL");
- return ;
- }
- SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
- folder->type = MMS_FOLDER_TYPE_OUTBOX;
- g_pManager->outboxfolder = folder;
- }
- if (g_pManager->sentfolder == NULL)
- {
- SCI_TRACE_LOW("FNH IS SENTBOX");
- folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
- if(!folder)
- {
- SCI_TRACE_LOW("malloc failed,sentfolder = NULL");
- return ;
- }
- SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
- folder->type = MMS_FOLDER_TYPE_SENTBOX;
- g_pManager->sentfolder=folder;
- }
- if (g_pManager->draftfolder == NULL)
- {
- SCI_TRACE_LOW("FNH IS DRAFTBOX");
- folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
- if(!folder)
- {
- SCI_TRACE_LOW("malloc failed,draftfolder = NULL");
- return ;
- }
- SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
- folder->type = MMS_FOLDER_TYPE_DRAFTBOX;
- g_pManager->draftfolder=folder;
- }
- switch(option_box)
- {
- case ALL_BOX:
- SCI_TRACE_LOW("fnh all_box");
- break;
- case INBOX:
- {
- SCI_TRACE_LOW("fnh read inboxfolder!");
- MMIMMS_ReadFolder(g_pManager->inboxfolder);
- }
- break;
- case OUTBOX:
- {
- SCI_TRACE_LOW("fnh read outboxfolder");
- MMIMMS_ReadFolder(g_pManager->outboxfolder);
- }
- break;
- case SENTBOX:
- {
- SCI_TRACE_LOW("fnh read sentfolder");
- MMIMMS_ReadFolder(g_pManager->sentfolder);
- }
- break;
- case DRAFTBOX:
- {
- SCI_TRACE_LOW("fnh read draftfolder");
- MMIMMS_ReadFolder(g_pManager->draftfolder);
- }
- break;
- default:
- SCI_TRACE_LOW("FNH IS default");
- break;
- }
- SCI_TRACE_LOW("MMIMMS_GetManagerDocument OUT ----");
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ResetConfig
- * Purpose: 重新设置成初始值
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_ResetConfig(void)
- {
- SCI_MEMSET(&g_nv_setting_mirror, 0, sizeof(g_nv_setting_mirror));
- SCI_STRCPY((char *)g_nv_setting_mirror.centre_addr,"http://mmsc.monternet.com/");
- SCI_STRCPY((char *)g_nv_setting_mirror.gateway,"10.0.0.172");
- SCI_STRCPY((char *)g_nv_setting_mirror.port,"9201");
- SCI_STRCPY((char *)g_nv_setting_mirror.username,"");
- SCI_STRCPY((char *)g_nv_setting_mirror.password,"");
- SCI_STRCPY((char *)g_nv_setting_mirror.apn,"cmwap");
- g_nv_setting_mirror.anonymous = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.prior = MMS_MSG_SETTINGS_PRIORITY_NORMAL;
- g_nv_setting_mirror.retrieve_mode = MMS_MSG_SETTINGS_RETRIEVE_AUTO;
- g_nv_setting_mirror.delivery_rpt = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.read_rpt = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.play_sound = MMS_MSG_SETTINGS_ON;
- g_nv_setting_mirror.advertisingallowable = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.valid_period = MMS_MSG_VALID_PERIOD_LONGEST; //fnh modify 20060510 MMS_MSG_VALID_PERIOD_12_HOUR;
- g_nv_setting_mirror.auto_sign = MMS_MSG_SETTINGS_OFF; // fnh add 20060516
- MMINV_WRITE(MMINV_MMS_SETTING, &g_nv_setting_mirror);
- if(FILE_CheckExist((const char*)MMSAUTOSIGNFILE) == TRUE)
- {
- FFS_ERROR_E ffs_error = 0;
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- FFS_OVERLAPPED_T overlapped;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MMSAUTOSIGNFILE, SCI_STRLEN((char*)MMSAUTOSIGNFILE));
- SCI_TRACE_LOW("FNH BEFORE DELETE autosignfile!");
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
- overlapped.param = PNULL;
- ffs_error = FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
- SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
- }
- /*
- g_pcur_signdoc = MMS_New();
- SCI_ASSERT(g_pcur_signdoc != NULL);
- SCI_TRACE_LOW("FNH new mms!");
- MMS_New_Slide(g_pcur_signdoc);
- MMIMMS_SaveAutoSignMessage(g_pcur_signdoc);
- */
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_StoreMangerDocument
- * Purpose:存储当前的管理结构到虚拟文件中
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_StoreMangerDocument(void)
- {
- if(!g_pManager)
- return ;
- MMIMMS_StoreFolder(g_pManager->inboxfolder);
- MMIMMS_StoreFolder(g_pManager->outboxfolder);
- MMIMMS_StoreFolder(g_pManager->sentfolder);
- MMIMMS_StoreFolder(g_pManager->draftfolder);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_FreeManagerDocument
- * Purpose:释放当前的管理结构
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_FreeManagerDocument()
- {
- if(g_pManager->inboxfolder != NULL)
- MMIMMS_FreeFolder(g_pManager->inboxfolder);
- g_pManager->inboxfolder =NULL;
- if(g_pManager->outboxfolder != NULL)
- MMIMMS_FreeFolder(g_pManager->outboxfolder);
- g_pManager->outboxfolder =NULL;
- if(g_pManager->sentfolder != NULL)
- MMIMMS_FreeFolder(g_pManager->sentfolder);
- g_pManager->sentfolder =NULL;
- if(g_pManager->draftfolder != NULL)
- MMIMMS_FreeFolder(g_pManager->draftfolder);
- g_pManager->draftfolder =NULL;
- g_pManager->currentfolder = NULL;
- g_pManager = NULL;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ReadFolder
- * Purpose:读取相应文件配置需要操作的文件夹
- * Input: pMessageFolder:当前需要操作的folder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_ReadFolder(pMessageFolder folder)
- {
- FILE_HANDLE fp;
- MESSAGELIST mlist;
- pMessageList messagelist, tlist;
- uint8 pathname[256];
- // MMS_DEBUG(" enter readmessagefolder");
- SCI_TRACE_LOW("MMIMMS_ReadFolder IN ----");
- if(folder == NULL)
- {
- SCI_TRACE_LOW("MMIMMS_ReadFolder error: folder is NULL");
- return ;
- }
- SCI_STRCPY((char*)pathname, (char*)CURR_DIRECTORY);
- SCI_TRACE_LOW("fnh folder->type = %d",folder->type);
- switch (folder->type)
- {
- case MMS_FOLDER_TYPE_INBOX:
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERINBOXFILE);
- break;
- case MMS_FOLDER_TYPE_OUTBOX:
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGEROUTBOXFILE);
- break;
- case MMS_FOLDER_TYPE_SENTBOX:
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERSENTBOXFILE);//文件名暂时这么命名,全局变量代替.
- break;
- case MMS_FOLDER_TYPE_DRAFTBOX:
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERDRAFTBOXFILE);//文件名暂时这么命名,全局变量代替.
- break;
- default:
- return ;
- }
- SCI_TRACE_LOW("fnh pathname = %s",pathname);
- fp=mmsf_Open((char*)pathname, "rb");
- if(fp==0)
- {
- SCI_TRACE_LOW("cannot open the file %s",pathname);
- return ;
- }
- SCI_MEMSET(&mlist, 0, sizeof(MESSAGELIST));
- while(mmsf_Read((char*)&mlist, sizeof(MESSAGELIST), 1, fp) != 0)
- {
- //MMS_DEBUG("read a message list");
- SCI_TRACE_LOW("fnh read a message list");
- messagelist=(pMessageList)cms_malloc(sizeof(MESSAGELIST));
- if(messagelist==NULL)
- {
- SCI_TRACE_LOW("MMIMMS_ReadFolder error: messagelist is NULL");
- return ;
- }
- SCI_MEMSET(messagelist, 0, sizeof(MESSAGELIST));
- SCI_MEMCPY(messagelist, &mlist, sizeof(MESSAGELIST));
- messagelist->next = PNULL;
- MMIMMS_ReadMessageHeads(messagelist, fp);
- // MMS_DEBUG(" message title: %s", mlist.title);
- if(folder->root==NULL)
- {
- folder->root=messagelist;
- }
- else
- {
- for(tlist=folder->root; tlist->next; tlist=tlist->next);
- tlist->next=messagelist;
- }
- // folder->size += messagelist->size;
- SCI_TRACE_LOW("fnh messagelist->state = %d",messagelist->state);
- if (folder->type == MMS_FOLDER_TYPE_INBOX)
- {
- if(messagelist->state == 0)
- {
- folder->unsettlednumber++;//modify liangliu 2006-4-12
- SCI_TRACE_LOW("fnh folder->unsettlednumber = %d",folder->unsettlednumber);
- }
- }
- folder->messagenumber++;
- SCI_TRACE_LOW("fnh folder->messagenumber = %d",folder->messagenumber);
- SCI_MEMSET(&mlist, 0, sizeof(MESSAGELIST));
- }
- mmsf_Close(fp);
- mmsf_RemoveByHandle(fp);//modify by liangliu 2006-3-6
- folder->currentmessage = folder->root;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ReadMessageHeads
- * Purpose:从fp中读取彩信列表的头数据,主要是指列表中指针所指向的域
- * Input: pMessageList:需要操作的msg指针
- fp:文件句柄
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_ReadMessageHeads(pMessageList messagelist, FILE_HANDLE fp)
- {
- MMIMMS_ReadTextField((char **)&(messagelist->filename), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->subject), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->date), fp);
- SCI_TRACE_LOW("FNH read to_address!");
- MMIMMS_ReadTextField((char **)&(messagelist->to_address), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->cc_address), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->bcc_address), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->sender), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->url), fp);
- MMIMMS_ReadTextField((char **)&(messagelist->msg_id), fp);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ReadTextField
- * Purpose:从fp中读取数据并使field指向该数据.
- * Input: char **需要操作的指针的地址指针所指向的内容(空间)
- fp:文件句柄
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_ReadTextField(char**field,FILE_HANDLE fp)
- {
- uint32 i=0;
- uint8 buffer[MMIMMS_MAX_ADDRESS_NUM * MAX_NAME_LENGTH + MMIMMS_MAX_ADDRESS_NUM];
- uint16 address_max_len = MMIMMS_MAX_ADDRESS_NUM * MAX_NAME_LENGTH + MMIMMS_MAX_ADDRESS_NUM;
- SCI_MEMSET(buffer,0,address_max_len);
- while(mmsf_Read((char*)(buffer+i), 1, 1, fp)==1)
- {
- if(buffer[i++] == 0)
- {
- break;
- }
- if(i>address_max_len)
- {
- buffer[i]=0;
- break;
- }
- }
- SCI_TRACE_LOW("fnh read i = %ld",i);
- if(i>1)
- {
- *field = (char *)cms_malloc(i+1);
- if(*field)
- {
- SCI_STRCPY((char*)*field,(char*) buffer);
- // MMS_DEBUG(" message head: %s", *field);
- }
- }
- else
- {
- *field = 0;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ReadTextField
- * Purpose:存储相应文件配置需要操作的文件夹存储方案为原来MANAGER中
- * Input: pMessageFolder:当前需要操作的folder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_StoreFolder(pMessageFolder folder)
- {
- FILE_HANDLE fp=0;
- pMessageList tlist;
- CMS_MMS_S8 pathname[256];
- if(folder == NULL)
- {
- return;
- }
- SCI_TRACE_LOW("MMIMMS_StoreFolder IN -----------");
- SCI_STRCPY((char *)pathname, (char *)CURR_DIRECTORY);
- switch (folder->type)
- {
- case MMS_FOLDER_TYPE_INBOX:
- /* initialize receive message folder */
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERINBOXFILE);
- break;
- case MMS_FOLDER_TYPE_OUTBOX:
- /* initialize send message folder */
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGEROUTBOXFILE);
- break;
- case MMS_FOLDER_TYPE_SENTBOX:
- /* initialize draft message folder */
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERSENTBOXFILE);
- break;
- case MMS_FOLDER_TYPE_DRAFTBOX:
- /* initialize draft message folder */
- MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERDRAFTBOXFILE);
- break;
- default:
- break;
- }
- /* store message list */
- fp=mmsf_Open(pathname, "wb");
- if(fp)
- {
- for(tlist=folder->root; tlist; tlist=tlist->next)
- {
- mmsf_Write((char*)tlist, sizeof(MESSAGELIST), 1, fp);
- /* store message head field */
- MMIMMS_StoreMessageHeads(tlist, fp);
- }
- mmsf_Close(fp);
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_StoreMessageHeads
- * Purpose:存储其中的指针所指向的数据
- * Input: pMessageList: 需要操作的msg指针
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_StoreMessageHeads(pMessageList mlist, FILE_HANDLE fp)
- {
- CMS_MMS_S8 ch[2];
- ch[0]=0;
- ch[1]=0;
- // //MMS_DEBUG("store message head fields");
- SCI_TRACE_LOW("MMIMMS_StoreMessageHeads IN -----------");
- if(mlist->filename)
- {
- mmsf_Write((char*)mlist->filename, 1, SCI_STRLEN((char *)mlist->filename)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->subject)
- {
- mmsf_Write((char*)mlist->subject, 1, SCI_STRLEN((char *)mlist->subject)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->date)
- {
- mmsf_Write((char*)mlist->date, 1, SCI_STRLEN((char *)mlist->date)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->to_address)
- {
- mmsf_Write((char*)mlist->to_address, 1, SCI_STRLEN((char *)mlist->to_address)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->cc_address)
- {
- mmsf_Write((char*)mlist->cc_address, 1, SCI_STRLEN((char *)mlist->cc_address)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->bcc_address)
- {
- mmsf_Write((char*)mlist->bcc_address, 1, SCI_STRLEN((char *)mlist->bcc_address)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->sender)
- {
- mmsf_Write((char*)mlist->sender, 1, SCI_STRLEN((char *)mlist->sender)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->url)
- {
- mmsf_Write((char*)mlist->url, 1, SCI_STRLEN((char *)mlist->url)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- if(mlist->msg_id)
- {
- mmsf_Write((char*)mlist->msg_id, 1, SCI_STRLEN((char *)mlist->msg_id)+1, fp);
- }
- else
- {
- mmsf_Write((char*)ch, 1, 1, fp);
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_FreeFolder
- * Purpose:释放当前的文件夹的内存空间
- * Input: pMessageFolder:当前需要操作的folder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_FreeFolder(pMessageFolder folder)
- {
- pMessageList tlist;
- if(folder)
- {
- for(tlist=folder->root; folder->root; )
- {
- /* free message list */
- folder->root=tlist->next;
- MMIMMS_FreeMessage(tlist);
- tlist=folder->root;
- }
- cms_free(folder);
- folder = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_FreeFolderForInit
- * Purpose:初始化释放管理目录
- * Input: pMessageFolder:当前需要操作的folder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_FreeFolderForInit(pMessageFolder folder)
- {
- pMessageList tlist;
- if(folder)
- {
- for(tlist=folder->root; folder->root; )
- {
- /* free message list */
- folder->root=tlist->next;
- MMIMMS_FreeMessage(tlist);
- tlist=folder->root;
- }
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_FreeMessage
- * Purpose:释放当前的LIST
- * Input: pMessageList:需要释放空间的消息list指针
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_FreeMessage(pMessageList mlist)
- {
- if(mlist->filename)
- {
- cms_free(mlist->filename);
- mlist->filename = PNULL;
- }
- if(mlist->subject)
- {
- cms_free(mlist->subject);
- mlist->subject = PNULL;
- }
- if(mlist->date)
- {
- cms_free(mlist->date);
- mlist->date =PNULL;
- }
- if(mlist->to_address)
- {
- cms_free(mlist->to_address);
- mlist->to_address =PNULL;
- }
- if(mlist->cc_address)
- {
- cms_free(mlist->cc_address);
- mlist->cc_address =NULL;
- }
- if(mlist->bcc_address)
- {
- cms_free(mlist->bcc_address);
- mlist->bcc_address =NULL;
- }
- if(mlist->sender)
- {
- cms_free(mlist->sender);
- mlist->sender =NULL;
- }
- if(mlist->url)
- {
- cms_free(mlist->url);
- mlist->url =NULL;
- }
- if(mlist->msg_id)
- {
- cms_free(mlist->msg_id);
- mlist->msg_id=NULL;
- }
- cms_free(mlist);
- mlist = NULL ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetListState
- * Purpose:得到传入list的状态
- * Input: 当前list
- * Returns: list所处状态
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint32 MMIMMS_GetListState(pMessageList mlist)
- {
- return mlist->state;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetManagerTotalNum
- * Purpose:得到总共现在所有彩信数目
- * Input: void
- * Returns: 所有彩信数目
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint32 MMIMMS_GetManagerTotalNum(void)
- {
- uint32 totalnum = 0;
- #ifndef WIN32
- if(g_pManager != NULL)
- {
- totalnum = (g_pManager->inboxfolder->messagenumber-g_pManager->inboxfolder->unsettlednumber) + g_pManager->outboxfolder->messagenumber +g_pManager->sentfolder->messagenumber + g_pManager->draftfolder->messagenumber;
- }
- #endif
- SCI_TRACE_LOW("MMIMMS_GetManagerTotalNum is %d",totalnum);
- return totalnum;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteMMS
- * Purpose:删除当前floder的当前管理条目以及对应的彩信
- * Input: 当前操作的文件夹,currentFloder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteMMS(pMessageFolder folder)
- {
- SCI_TRACE_LOW("MMIMMS_DeleteMMS in----------");
- if(!folder)
- {
- return ;
- }
- if(!folder->currentmessage || !folder->root)
- {
- return;
- }
- //下面要根据模拟还是实际情况选择
- if(folder->type == MMS_FOLDER_TYPE_INBOX)//modify 2005-12-3
- {
- mmsf_Remove((char*)g_pCurrentList->filename);//在虚拟文件中删除
- SCI_TRACE_LOW("mmsf_Remove the filename is normal-----");
- MMIMMS_DeleteFLASHMMS(g_pCurrentList);//must delete the flash mms first or the list will be empty!
- }
- else
- {
- mmsf_Remove((char*)folder->currentmessage->filename);//在虚拟文件中删除
- SCI_TRACE_LOW("mmsf_Remove the filename is normal-----");
- MMIMMS_DeleteFLASHMMS(folder->currentmessage);//must delete the flash mms first or the list will be empty!
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteAllMMS
- * Purpose:删除当前floder的所有管理条目以及对应的彩信
- * Input: 当前操作的文件夹,currentFloder
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteAllMMS(pMessageFolder folder)
- {
- if(!folder)
- {
- return;
- }
- folder->currentmessage = folder->root;
- MMIMMS_DeleteMMSOneOfAll(folder);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteMMSOneOfAll
- * Purpose:删除当前floder的一条管理条目以及对应的彩信
- * Input: 当前操作的文件夹,currentFloder
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteMMSOneOfAll(pMessageFolder folder)
- {
- HFS cur_hefs = FFS_INVALID_HANDLE;
- FFS_OVERLAPPED_T overlapped;
- if(!folder)
- {
- return ;
- }
- if(!folder->currentmessage || !folder->root)
- {
- return;
- }
- //下面要根据模拟还是实际情况选择
- mmsf_Remove((char*)folder->currentmessage->filename);//在虚拟文件中删除
- SCI_TRACE_LOW("MMIMMS_DeleteMMSOneOfAll IN -------");
- FILE_CdMMSPath();
- if (folder->currentmessage->filename == NULL)
- {
- MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEONEMMS_OK, PNULL, PNULL);
- SCI_TRACE_LOW("fnh folder->currentmessage->filename is NULL");
- MMI_TriggerMMITask();
- return;
- }
- if(FILE_CheckExist((const char*)folder->currentmessage->filename) == TRUE)
- {
- //SCI_TRACE_BUF("VC: ReadVideo file_name = ", file_name, video_info_ptr->name_len);
- FFS_ERROR_E ffs_error = 0;
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)folder->currentmessage->filename, SCI_STRLEN((char*)folder->currentmessage->filename));
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteOneMMSFile;
- overlapped.param = PNULL;
- ffs_error = FFS_AYS_Delete(g_filetype, (const wchar*)ucs2_name_arr, &overlapped);
- SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
- if( FFS_ERROR_IO_PENDING != ffs_error )
- {
- FFS_Close(g_filetype,cur_hefs);
- }
- }
- else{
- MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEONEMMS_OK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackDeleteOneMMSFile
- * Purpose: 删除某一彩信的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackDeleteOneMMSFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- )
- {
- MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEONEMMS_OK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteManagerList
- * Purpose:删除当前floder的所有管理条目但不涉及其对应的虚拟文件和flash
- 上资源,主要用于发件箱-->已发信箱
- * Input: 当前操作的文件夹,currentFloder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteManagerList(pMessageFolder folder)
- {
- pMessageList tlist = PNULL;
- if(!folder)
- {
- return ;
- }
- if(!folder->currentmessage || !folder->root)
- {
- return;
- }
- if(folder->type == MMS_FOLDER_TYPE_INBOX)
- {
- if(g_pCurrentList->state == 0)
- {
- folder->unsettlednumber--;
- }
- if(folder->root == g_pCurrentList)
- {
- folder->root = folder->root->next;
- MMIMMS_FreeMessage(g_pCurrentList);
- folder->currentmessage=folder->root;
- }
- else
- {
- for(tlist = folder->root; tlist; tlist=tlist->next)
- {
- if(tlist->next == g_pCurrentList)
- {
- tlist->next = g_pCurrentList->next;
- MMIMMS_FreeMessage(g_pCurrentList);
- if(tlist->next)
- folder->currentmessage=tlist->next;
- else
- folder->currentmessage=tlist;
- break;
- }
- }
- }
- }
- else
- {
- if(folder->root == folder->currentmessage)
- {
- folder->root = folder->root->next;
- MMIMMS_FreeMessage(folder->currentmessage);
- folder->currentmessage=folder->root;
- }
- else
- {
- for(tlist = folder->root; tlist; tlist=tlist->next)
- {
- if(tlist->next == folder->currentmessage)
- {
- tlist->next = folder->currentmessage->next;
- MMIMMS_FreeMessage(folder->currentmessage);
- if(tlist->next)
- folder->currentmessage=tlist->next;
- else
- folder->currentmessage=tlist;
- break;
- }
- }
- }
- }
- folder->messagenumber--;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteManagerListOneOfAll
- * Purpose: 删除管理目录
- * Input: pMessageFolder:当前folder
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteManagerListOneOfAll(pMessageFolder folder)
- {
- pMessageList tlist = PNULL;
- if(!folder)
- {
- return ;
- }
- if(!folder->currentmessage || !folder->root)
- {
- return;
- }
- if(folder->root == folder->currentmessage)
- {
- folder->root = folder->root->next;
- MMIMMS_FreeMessage(folder->currentmessage);
- SCI_TRACE_LOW("FNH deleteoneofall free 7308");
- folder->currentmessage=folder->root;
- }
- else
- {
- for(tlist = folder->root; tlist; tlist=tlist->next)
- {
- if(tlist->next == folder->currentmessage)
- {
- tlist->next = folder->currentmessage->next;
- MMIMMS_FreeMessage(folder->currentmessage);
- SCI_TRACE_LOW("FNH deleteoneofall free 7319");
- if(tlist->next)
- folder->currentmessage=tlist->next;
- else
- folder->currentmessage=tlist;
- break;
- }
- }
- }
- folder->messagenumber--;
- }
- /******************************************************************************
- * 函数定义: MMIMMS_GetMessageNum(pMessageFolder)
- * 参数说明: 当前folder
- * 返回值: 总共的消息个数
- * 函数说明: 获得当前文件夹总共消息个数
- * 代码编写者: liangliu
- * 代码编写日期: 10/10/2005
- * 修改原因:
- * 修改人员:
- * 修改日期:
- ********************************************************************************/
- uint32 MMIMMS_GetMessageNum(pMessageFolder folder)
- {
- if(!folder)
- {
- return 0 ;
- }
- return folder->messagenumber;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_AppInit
- * Purpose: MMS初始化
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- PUBLIC void MMIMMS_AppInit(void)
- {
- MN_RETURN_RESULT_E nv_result;
- MMINV_READ(MMINV_MMS_SETTING, &g_nv_setting_mirror, nv_result);
- SCI_TRACE_LOW("FNH after appinit cente_addr = %s",g_nv_setting_mirror.centre_addr);
- SCI_TRACE_LOW("FNH after appinit gateway = %s",g_nv_setting_mirror.gateway);
- SCI_TRACE_LOW("FNH after appinit port = %s",g_nv_setting_mirror.port);
- SCI_TRACE_LOW("FNH after appinit anonymous = %d",g_nv_setting_mirror.anonymous);
- if (MN_RETURN_SUCCESS != nv_result)
- {
- SCI_MEMSET(&g_nv_setting_mirror, 0, sizeof(g_nv_setting_mirror));
- SCI_STRCPY((char *)g_nv_setting_mirror.centre_addr,"http://mmsc.monternet.com/");
- SCI_STRCPY((char *)g_nv_setting_mirror.gateway,"10.0.0.172");
- SCI_STRCPY((char *)g_nv_setting_mirror.port,"9201");
- SCI_STRCPY((char *)g_nv_setting_mirror.username,"");
- SCI_STRCPY((char *)g_nv_setting_mirror.password,"");
- SCI_STRCPY((char *)g_nv_setting_mirror.apn,"cmwap");
- g_nv_setting_mirror.anonymous = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.prior = MMS_MSG_SETTINGS_PRIORITY_NORMAL;
- g_nv_setting_mirror.retrieve_mode = MMS_MSG_SETTINGS_RETRIEVE_AUTO;
- g_nv_setting_mirror.delivery_rpt = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.read_rpt = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.play_sound = MMS_MSG_SETTINGS_ON;
- g_nv_setting_mirror.advertisingallowable = MMS_MSG_SETTINGS_OFF;
- g_nv_setting_mirror.valid_period = MMS_MSG_VALID_PERIOD_LONGEST; //fnh modify 20060510 MMS_MSG_VALID_PERIOD_12_HOUR;
- g_nv_setting_mirror.auto_sign = MMS_MSG_SETTINGS_OFF; // fnh add 20060516
- MMINV_WRITE(MMINV_MMS_SETTING, &g_nv_setting_mirror);
- }
- MMS_RegMenuGroup();
- g_ismmsinit = FALSE;
- //create MMS folder
- FILE_CdRootPath();
- if (FFS_NO_ERROR != FILE_CD(MMIMMS_MMS_DIR))
- {
- SCI_TRACE_LOW("fnh in appinit mms dir is not find!");
- FILE_CreateDir(MMIMMS_MMS_DIR);
- }
- FILE_CdRootPath();
- if (FFS_NO_ERROR != FILE_CD(MMICMSBRW_WAP_DEFAULT_DIR))
- {
- FILE_CreateDir(MMICMSBRW_WAP_DEFAULT_DIR);
- }
- if(g_pManager != NULL) //信箱链表
- {
- MMIMMS_FreeManagerDocument();
- }
- if (g_pautoDownloadMMSRoot) // 如果有自动下载,初始化时删除链表
- {
- MMIMMS_FreeAutodownList();
- }
- g_filetype = MMICMS_GetCurrentFFS();
- if (g_filetype != FS_INVALID)
- {
- MMIMMS_ReadManagerInboxFile();
- }
- else
- {
- g_ismmsinit = TRUE;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_WriteNewMMS
- * Purpose: 编辑新彩信
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN MMIMMS_WriteNewMMS(void)
- {
- /* 初始化主题 */
- g_p_mms_subject = (char *)cms_malloc(MMIMMS_MAX_SUBJECTS_LEN+1);
- SCI_ASSERT(g_p_mms_subject != NULL);
- SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN+1);
- /* 创建空白编辑器 */
- g_peditdoc = MMS_New();
- SCI_ASSERT(g_peditdoc != NULL);
- g_p_mms_to = NULL;
- g_p_mms_cc = NULL;
- g_p_mms_bcc = NULL;
- g_p_mms_to_group = NULL;
- g_p_mms_cc_group = NULL;
- g_p_mms_bcc_group = NULL;
- //init MMIMMS global
- // MMIMMS_Construction();
- //create edit window
- MMK_CreateWin( (uint32*)MMIMMS_EDIT_WIN_TAB, (ADD_DATA)MMIMMS_NV_ID_INVALID);//2nd param is used to distiguish PNULL and index_0
- return 1;
- }
- /*****************************************************************************/
- // Description : give sms module to answer mms
- // Global resource dependence : none
- // Author: Bruce.Chi
- // Input : Send to name string
- // Note:
- /*****************************************************************************/
- PUBLIC BOOLEAN MMIMMS_AnswerMMS(
- uint8 send_to_name_len,
- uint8 *sen_to_name_ptr
- )
- {
- SCI_ASSERT(sen_to_name_ptr != PNULL);
- mmicms_replymmsforsms((char *)sen_to_name_ptr); //电话本和短信回复彩信
- return TRUE;
- }
- /*****************************************************************************/
- // Description : MMIMMS construction fuction
- // Global resource dependence : ??????
- // Author: Bruce.Chi
- // Note:
- /*****************************************************************************/
- #if 1
- MMIMMS_RESULT_E MMIMMS_Construction(void)
- {
- uint32 str_number = 0;
- TO_STRING_T *str_ptr = PNULL;
- str_number = MMIMMS_MAX_ADDRESS_NUM * sizeof(TO_STRING_T);
- //to
- str_ptr =(TO_STRING_T *)cms_malloc(str_number );
- SCI_ASSERT(str_ptr != PNULL);
- SCI_MEMSET(str_ptr, 0, str_number);
- g_mms_save_in_mem.to.addr = str_ptr;
- //cc
- str_ptr = PNULL;
- str_ptr =(TO_STRING_T *)cms_malloc(str_number );
- SCI_ASSERT(str_ptr != PNULL);
- SCI_MEMSET(str_ptr, 0, str_number);
- g_mms_save_in_mem.cc.addr = str_ptr;
- //bcc
- str_ptr = PNULL;
- str_ptr =(TO_STRING_T *)cms_malloc(str_number );
- SCI_ASSERT(str_ptr != PNULL);
- SCI_MEMSET(str_ptr, 0, str_number);
- g_mms_save_in_mem.bcc.addr = str_ptr;
- //init the static var
- // SCI_MEMSET(&g_mms_save_in_mem, 0, sizeof(g_mms_save_in_mem));
- return MMIMMS_RESULT_SUCCESS;
- }
- #endif
- /*****************************************************************************/
- // Description : MMIMMS destruction fuction
- // Global resource dependence : ??????
- // Author: Bruce.Chi
- // Note:
- /*****************************************************************************/
- #if 1
- MMIMMS_RESULT_E MMIMMS_Destruction(void)
- {
- //free subject
- if (g_mms_save_in_mem.subject.str_ptr != PNULL)
- {
- cms_free(g_mms_save_in_mem.subject.str_ptr);
- g_mms_save_in_mem.subject.str_ptr = PNULL;
- }
- //free To address
- if (g_mms_save_in_mem.to.addr != PNULL)
- {
- cms_free(g_mms_save_in_mem.to.addr);
- g_mms_save_in_mem.to.addr =PNULL;
- }
- if (g_mms_save_in_mem.cc.addr != PNULL)
- {
- cms_free(g_mms_save_in_mem.cc.addr);
- g_mms_save_in_mem.cc.addr =PNULL;
- }
- if (g_mms_save_in_mem.bcc.addr != PNULL)
- {
- cms_free(g_mms_save_in_mem.bcc.addr);
- g_mms_save_in_mem.bcc.addr =PNULL;
- }
- if (g_mms_save_in_mem.content_text.str_ptr != PNULL)
- {
- cms_free(g_mms_save_in_mem.content_text.str_ptr);
- g_mms_save_in_mem.content_text.str_ptr = PNULL;
- }
- //set whole g_mms_save_in_mem to zero
- SCI_MEMSET(&g_mms_save_in_mem, 0, sizeof(g_mms_save_in_mem));
- return MMIMMS_RESULT_SUCCESS;
- }
- #endif
- /*****************************************************************************/
- // Description : judge whether subject exist
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel
- ///*****************************************************************************/
- BOOLEAN Edit_CurSubjectExist(void)
- {
- SCI_TRACE_BUF("FNH cursubjectexist = %x",g_p_mms_subject,10);
- if (g_p_mms_subject == PNULL)//g_mms_save_in_mem.subject.str_ptr == PNULL)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: Edit_CurContentTextExist
- * Purpose: 判断当前内容是否有文本
- * Input: pMMS_EDocument,当前编辑文档
- * Returns: 布尔型
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN Edit_CurContentTextExist(pMMS_EDocument p_cur_doc)
- {
- if (p_cur_doc->slide_cur->text_flag == 1)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /* ----------------------------------------------------------------------------
- /* Function Name: CmsGetUnicodeLen
- * Purpose:取得unicode字符串的长度
- * Input: 输入的字符串
- * Output: 长度
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint16 CmsGetUnicodeLen(const unsigned char *data)
- {
- unsigned short len = 0;
- unsigned short *s_data = ( unsigned short*)data;
- if(!data)
- return 0;
- len = *s_data;
- return len;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: GetSubjectStringLen
- * Purpose:得到字符串的具体内容
- * Input: 输入的字符串
- * Output: 输出的字符传及字符串长度,输出的字符串是从第二个字符开始的
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint16 GetSubjectStringLen(char* srcstr,char** decstr)
- {
- char utf_buff[128];
- uint16 length = 0;
- SCI_MEMSET(utf_buff, 0, sizeof(utf_buff));
- length = CmsGetUnicodeLen((unsigned char *)srcstr);
- *decstr = (char *)&srcstr[2];
- return length;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_OptionSubject
- * Purpose:在subject前添加RE或FW
- * Input: mms状态(转发或回复)
- * Output: 空,输出的字符串是从第二个字符开始的
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_OptionSubject(MMSSTATE mmsstate)
- {
- char *subjecttemp;
- uint16 len = 0;
- uint16 sublen=0;
- char *addstring;
- uint16 addlen = 0;
- char* subjectstring = NULL;
- char *tempsubjectstring = NULL;
- subjecttemp = g_p_mms_subject;
- len = CmsGetUnicodeLen((unsigned char *)subjecttemp);
- SCI_TRACE_LOW("FNH len = %d",len);
- subjectstring = (char*)cms_malloc(len +1);
- SCI_MEMSET(subjectstring,0,len+1);
- len = GetSubjectStringLen((char *)subjecttemp,(char **)&tempsubjectstring);
- SCI_MEMCPY(subjectstring,tempsubjectstring,len);
- SCI_TRACE_BUF("FNH subjectsring = %x",subjectstring,len);
- switch(mmsstate)
- {
- case MMSRE:
- addlen = Cms_UTF8toUTF16Len("RE:");
- SCI_TRACE_LOW("FNH addlen = %d",addlen);
- addstring = (char *)cms_malloc(addlen);
- SCI_MEMSET(addstring,0,addlen);
- Cms_UTF8toUTF16("RE:",3,addlen,addstring);
- SCI_TRACE_BUF("FNH addstring is %x",addstring,10);
- SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
- if (len > (MMIMMS_MAX_SUBJECTS_LEN-addlen-2))
- {
- len = MMIMMS_MAX_SUBJECTS_LEN-addlen-2;
- }
- sublen = addlen+len;
- SCI_TRACE_LOW("FNH sublen = %d",sublen);
- SCI_MEMCPY(g_p_mms_subject,&sublen,2);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- SCI_MEMCPY(g_p_mms_subject+2,addstring,addlen);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,addlen+2);
- SCI_MEMCPY(g_p_mms_subject+addlen+2,subjectstring,len);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,MMIMMS_MAX_SUBJECTS_LEN);
- if (addstring )
- {
- cms_free(addstring);
- addstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free addstring");
- }
- if (subjectstring )
- {
- cms_free(subjectstring);
- subjectstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free subjectstring");
- }
- break;
- case MMSFW:
- addlen = Cms_UTF8toUTF16Len("FW:");
- SCI_TRACE_LOW("FNH addlen = %d",addlen);
- addstring = (char *)cms_malloc(addlen);
- SCI_MEMSET(addstring,0,addlen);
- Cms_UTF8toUTF16("FW:",3,addlen,addstring);
- SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
- if (len > (MMIMMS_MAX_SUBJECTS_LEN-addlen-2))
- {
- len = MMIMMS_MAX_SUBJECTS_LEN-addlen-2;
- }
- sublen = addlen+len;
- SCI_MEMCPY(g_p_mms_subject,&sublen,2);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- SCI_MEMCPY(g_p_mms_subject+2,addstring,addlen);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- SCI_MEMCPY(g_p_mms_subject+addlen+2,subjectstring,len);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- if (addstring )
- {
- cms_free(addstring);
- addstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free addstring");
- }
- if (subjectstring )
- {
- cms_free(subjectstring);
- subjectstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free subjectstring");
- }
- break;
- case MMSEDIT:
- SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
- if (len > (MMIMMS_MAX_SUBJECTS_LEN-2))
- {
- len = MMIMMS_MAX_SUBJECTS_LEN-2;
- }
- sublen = len;
- SCI_MEMCPY(g_p_mms_subject,&sublen,2);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,sublen);
- SCI_MEMCPY(g_p_mms_subject+2,subjectstring,len);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,len+2);
- if (subjectstring )
- {
- cms_free(subjectstring);
- subjectstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free subjectstring");
- }
- break;
- case MMSREAD:
- addlen = Cms_UTF8toUTF16Len("read:");
- SCI_TRACE_LOW("FNH addlen = %d",addlen);
- addstring = (char *)cms_malloc(addlen);
- SCI_MEMSET(addstring,0,addlen);
- Cms_UTF8toUTF16("read:",5,addlen,addstring);
- SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
- if (len > (MMIMMS_MAX_SUBJECTS_LEN-addlen-2))
- {
- len = MMIMMS_MAX_SUBJECTS_LEN-addlen-2;
- }
- sublen = addlen+len;
- SCI_MEMCPY(g_p_mms_subject,&sublen,2);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- SCI_MEMCPY(g_p_mms_subject+2,addstring,addlen);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- SCI_MEMCPY(g_p_mms_subject+addlen+2,subjectstring,len);
- SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
- if (addstring )
- {
- cms_free(addstring);
- addstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free addstring");
- }
- if (subjectstring )
- {
- cms_free(subjectstring);
- subjectstring = NULL;
- SCI_TRACE_LOW("fnh AFTER free subjectstring");
- }
- break;
- default:
- break;
- }
- return ;
- }
- // Description : get subject string
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel, return pointer pointing to internal memory
- ///*****************************************************************************/
- MMI_STRING_T Edit_GetSubject(void)
- {
- MMI_STRING_T string_ret;
- SCI_MEMSET(&string_ret, 0 , sizeof(string_ret));
- if (g_p_mms_subject != PNULL)
- {
- //return inner pointer.
- SCI_TRACE_BUF("FNH Edit_GetSubject g_p_mms_subject = %x",g_p_mms_subject,10);
- string_ret.length = GetSubjectStringLen((char *)g_p_mms_subject,(char **)&string_ret.str_ptr);
- string_ret.is_ucs2 = TRUE;
- SCI_TRACE_LOW("FNH Edit_GetSubject string_ret.length = %d",string_ret.length);
- SCI_TRACE_BUF("FNH Edit_GetSubject string_ret.str_ptr = %x",string_ret.str_ptr,10);
- }
- return string_ret;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: Edit_GetContentText
- * Purpose:取得当前文本内容
- * Input: pMMS_EDocument
- * Output: 字符串结构.
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MMI_STRING_T Edit_GetContentText(pMMS_EDocument p_cur_doc)
- {
- MMI_STRING_T string_ret;
- T_Composer_Text composer_text;
- SCI_MEMSET(&string_ret, 0 , sizeof(string_ret));
- SCI_MEMSET(&composer_text,0,sizeof(T_Composer_Text));
- MMIMMS_GetCurText(&composer_text,p_cur_doc);
- string_ret.is_ucs2 = TRUE;
- string_ret.str_ptr = composer_text.TxtBuf;
- string_ret.length = composer_text.size ;
- return string_ret;
- }
- /*****************************************************************************/
- // Description : delete subject string
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel
- ///*****************************************************************************/
- MMIMMS_RESULT_E Edit_DeleteSubject(void)
- {
- if (g_mms_save_in_mem.subject.str_ptr != PNULL)
- {
- cms_free(g_mms_save_in_mem.subject.str_ptr);
- g_mms_save_in_mem.subject.str_ptr = PNULL;
- g_mms_save_in_mem.subject.length = 0;
- }
- return MMIMMS_RESULT_SUCCESS;
- }
- /*****************************************************************************/
- // Description : "add to address"
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel. refer to Vector<> in c++
- ///*****************************************************************************/
- // Array
- // |--|
- // | 0|-->content0(heap)
- // |--|
- // | 1|-->content1(heap)
- // |--|
- // total_num = 2| |
- // |..|
- BOOLEAN Edit_AddToAddr(uint8 *to_ptr, To_Addr* addr_list)
- {
- int len = 0;
- uint32 total_num = 0;
- TO_STRING_T *str_ptr = PNULL;
- uint32 str_number = 0;
- SCI_ASSERT(to_ptr != PNULL);
- SCI_ASSERT(addr_list != PNULL);
- SCI_TRACE_LOW("mmimms_main:Edit_AddToAddr(), %s,L%d", to_ptr, __LINE__);
- len = strlen((char *)to_ptr);
- if (len == 0)
- {
- return FALSE;
- }
- //cut
- len = MIN(len ,MMIMMS_MAX_ADDRESS_LEN);
- total_num = addr_list->total_num;
- /*
- //judge total number, and the array.
- if ((total_num % MMIMMS_MAX_ADDRESS_NUM) == 0)
- {
- //need to alloc new
- str_number= sizeof(TO_STRING_T) * (((total_num / MMIMMS_MAX_ADDRESS_NUM) + 1) * MMIMMS_MAX_ADDRESS_NUM);
- str_ptr =(TO_STRING_T *)cms_malloc(str_number );
- SCI_ASSERT(str_ptr != PNULL);
- SCI_MEMSET(str_ptr, 0, str_number);
- //copy old to new
- if (g_mms_save_in_mem.to.addr != PNULL)
- {
- // SCI_MEMCPY(str_ptr, g_mms_save_in_mem.to.addr, (total_num * sizeof(MMI_STRING_T)));
- MMI_MEMCPY(str_ptr, str_number, g_mms_save_in_mem.to.addr, (total_num * sizeof(TO_STRING_T)), (total_num * sizeof(TO_STRING_T)));
- }
- //FREE old
- if (g_mms_save_in_mem.to.addr != PNULL)
- {
- cms_free(g_mms_save_in_mem.to.addr);
- g_mms_save_in_mem.to.addr = PNULL;
- }
- //g_mms_save_in_mem point to new
- g_mms_save_in_mem.to.addr = str_ptr;
- }
- */
- //save one copy
- SCI_MEMSET(addr_list->addr[total_num].str_arr, 0, sizeof(addr_list->addr[total_num].str_arr));
- MMI_MEMCPY(
- addr_list->addr[total_num].str_arr,
- MMIMMS_MAX_ADDRESS_LEN,
- to_ptr,
- len,
- len
- );
- addr_list->addr[total_num].length = len;
- addr_list->addr[total_num].is_ucs2 = FALSE;
- //total number ++
- addr_list->total_num++;
- return TRUE;
- }
- /*****************************************************************************/
- // Description : delete "to address"
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel
- ///*****************************************************************************/
- BOOLEAN Edit_DeleteToAddr(uint32 index,To_Addr* addr_list )
- {
- uint32 i;
- SCI_ASSERT(addr_list != PNULL);
- SCI_ASSERT(index < addr_list->total_num);
- SCI_ASSERT(addr_list->total_num > 0);
- //move the later to former, only pointer change
- for(i = index; i < addr_list->total_num - 1; i++)
- {
- // g_mms_save_in_mem.to.addr[i].str_ptr = g_mms_save_in_mem.to.addr[i + 1].str_ptr;
- MMI_MEMCPY(
- addr_list->addr[i].str_arr,
- MMIMMS_MAX_ADDRESS_LEN,
- addr_list->addr[i + 1].str_arr,
- MMIMMS_MAX_ADDRESS_LEN,
- MMIMMS_MAX_ADDRESS_LEN
- );
- addr_list->addr[i].is_ucs2 = addr_list->addr[i + 1].is_ucs2;
- addr_list->addr[i].length = addr_list->addr[i + 1].length;
- }
- //total number --
- addr_list->total_num--;
- return TRUE;
- }
- /*****************************************************************************/
- // Description : delete all "to address"
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel
- ///*****************************************************************************/
- BOOLEAN Edit_DeleteToAddrAll(To_Addr* addr_list)
- {
- int i = 0;
- BOOLEAN is_success = FALSE;
- SCI_ASSERT(addr_list != PNULL);
- for (i = addr_list->total_num - 1; i >=0; i--)
- {
- is_success = Edit_DeleteToAddr((uint32)i,addr_list);
- SCI_ASSERT(is_success);
- }
- /*
- if(addr_list->addr != PNULL)
- {
- cms_free(addr_list->addr);
- addr_list->addr = PNULL;
- }
- */
- return TRUE;
- }
- #if 1
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetPBNameByNumber
- * Purpose:通过电话得到电话所属姓名
- * Input: uint8 *number_ptr:电话号码指针
- MMI_STRING_T *name_pt:姓名结构
- * Output: BOOLEAN.
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN MMIMMS_GetPBNameByNumber(uint8 *number_ptr, MMI_STRING_T *name_ptr)
- {
- MMIPB_BCD_NUMBER_T bcd_num;
- MMI_PARTY_NUMBER_T party_num;
- int num_len = 0;
- uint8 real_phonenum[MMIPB_NAME_MAX_LEN];
- BOOLEAN is_found = FALSE;
- SCI_ASSERT(name_ptr != PNULL);
- SCI_ASSERT(number_ptr != PNULL);
- SCI_TRACE_LOW("GetPBNameByNumber number is %s",number_ptr);
- SCI_MEMSET(&party_num, 0, sizeof(party_num));
- SCI_MEMSET(real_phonenum, 0, sizeof(real_phonenum));
- num_len = (SCI_STRLEN((char *)(number_ptr)) > (MMIPB_NAME_MAX_LEN-1))? (MMIPB_NAME_MAX_LEN-1) : SCI_STRLEN((char *)(number_ptr));
- SCI_MEMCPY(real_phonenum,number_ptr,num_len);
- SCI_TRACE_LOW("num_len = %d",num_len);
- MMI_GenPartyNumber(real_phonenum, strlen((char *)real_phonenum), &party_num);
- SCI_MEMSET(&bcd_num, 0, sizeof(bcd_num));
- bcd_num.npi_ton = MMI_ChangeTypePlanToUint8(party_num.number_type, 0 );
- bcd_num.number_len = MIN(MMIPB_BCD_NUMBER_MAX_LEN, party_num.num_len);
- MMI_MEMCPY(bcd_num.number, MMIPB_BCD_NUMBER_MAX_LEN, party_num.bcd_num, MN_MAX_ADDR_BCD_LEN, bcd_num.number_len);
- is_found = MMIPB_FindAlphaAndGroupByNumber(name_ptr, PNULL, PNULL, &bcd_num);
- SCI_TRACE_LOW("FNH is_found = %d",is_found);
- //special, the name is zero
- if (is_found && (name_ptr->length == 0))
- {
- is_found = FALSE;
- }
- return is_found;
- }
- /*****************************************************************************/
- // Description : get mms amout in different mailbox
- // Global resource dependence : s_nv_index_mirror
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- int MMIMMS_GetMailboxMsgSize(MMIMMS_MAILBOX_TYPE mailbox_type)
- {
- uint32 i = 0;
- int sum = 0;
- pMessageList pMlist_temp = PNULL;
- uint32 msg_num = 0;
- switch(mailbox_type)
- {
- case MMIMMS_INBOX: // 收件箱
- pMlist_temp = g_pManager->inboxfolder->root;
- msg_num = g_pManager->inboxfolder->messagenumber;
- SCI_TRACE_LOW("fnh msg_num = %d",msg_num);
- for (i = 0;i < msg_num;i++)
- {
- SCI_TRACE_LOW("FNH sum is %d,pMlist_temp->size = %d",sum,pMlist_temp->size);
- sum = sum + pMlist_temp->size;
- pMlist_temp = pMlist_temp->next;
- SCI_TRACE_LOW("FNH sum is %d",sum);
- }
- break;
- case MMIMMS_SENTBOX: // 已发信箱
- pMlist_temp = g_pManager->sentfolder->root;
- msg_num = g_pManager->sentfolder->messagenumber;
- for (i = 0;i < msg_num;i++)
- {
- sum = sum + pMlist_temp->size;
- pMlist_temp = pMlist_temp->next;
- }
- break;
- case MMIMMS_OUTBOX: // 发件箱
- pMlist_temp = g_pManager->outboxfolder->root;
- msg_num = g_pManager->outboxfolder->messagenumber;
- for (i = 0;i < msg_num;i++)
- {
- sum = sum + pMlist_temp->size;
- pMlist_temp = pMlist_temp->next;
- }
- break;
- case MMIMMS_DRAFTBOX: // 草稿箱
- pMlist_temp = g_pManager->draftfolder->root;
- msg_num = g_pManager->draftfolder->messagenumber;
- for (i = 0;i < msg_num;i++)
- {
- sum = sum + pMlist_temp->size;
- pMlist_temp = pMlist_temp->next;
- }
- break;
- default:
- break;
- }
- return sum;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetPriority
- * Purpose:得到优先级的设定值
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetPriority(void)
- {
- return g_nv_setting_mirror.prior;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetValidPeriod
- * Purpose:得到有效期的设定值
- * Input: void
- * Returns: MESSAGES_MMS_SETTING_VALID_PERIOD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_SETTING_VALID_PERIOD MMIMMS_Setting_GetValidPeriod(void)
- {
- return g_nv_setting_mirror.valid_period;
- }
- /*****************************************************************************/
- // Description : get mms setting is_auto_download
- // Global resource dependence : g_nv_setting_mirror
- // Author:liangliu
- // Note:
- /*****************************************************************************/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetAutoDownload(void)
- {
- return g_nv_setting_mirror.retrieve_mode;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetDeliveryReport
- * Purpose:得到送达报告的设定值
- * Input: void
- * Output: MESSAGES_MMS_MSG_SETTINGS_ONOFF.
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetDeliveryReport(void)
- {
- return g_nv_setting_mirror.delivery_rpt;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetAutoSign
- * Purpose:得到自动签名的设定值
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetAutoSign(void)
- {
- return g_nv_setting_mirror.auto_sign;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetReadReport
- * Purpose:得到阅读报告的设定值
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetReadReport(void)
- {
- return g_nv_setting_mirror.read_rpt;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetAnonymous
- * Purpose:得到匿名发送的设定值
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetAnonymous(void)
- {
- return g_nv_setting_mirror.anonymous;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetPlaySoundAble
- * Purpose:得到是否播放声音的设定值
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetPlaySoundAble(void)
- {
- return g_nv_setting_mirror.play_sound;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetAdvertisingallowable
- * Purpose:得到是否允许广告的设定值
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetAdvertisingallowable(void)
- {
- return g_nv_setting_mirror.advertisingallowable;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetDeliveryReport
- * Purpose:设定送达报告的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetDeliveryReport(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.delivery_rpt)
- {
- g_nv_setting_mirror.delivery_rpt= list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetAutoDownload
- * Purpose:设定自动下载的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetAutoDownload(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.retrieve_mode)
- {
- g_nv_setting_mirror.retrieve_mode= list_index;
- if(g_nv_setting_mirror.retrieve_mode == 0)
- {
- MMIMMS_FreeAutodownList();//add liangliu 2006-4-28 for back to idle autodownload.
- }
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetReadReport
- * Purpose:设定阅读报告的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetReadReport(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.read_rpt)
- {
- g_nv_setting_mirror.read_rpt= list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetAutoSign
- * Purpose:设置自动签名
- * Input: uint16:
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetAutoSign(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.auto_sign)
- {
- g_nv_setting_mirror.auto_sign= list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetAnonymous
- * Purpose:设定匿名发送的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetAnonymous(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.anonymous)
- {
- g_nv_setting_mirror.anonymous = list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetPlaySound
- * Purpose:uint16 list_index
- * Input: void
- * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetPlaySound(uint16 list_index)
- {
- if ((1-list_index)!= g_nv_setting_mirror.play_sound)
- {
- g_nv_setting_mirror.play_sound=1- list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetAdvertising
- * Purpose:设定是否允许广告的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetAdvertising(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.advertisingallowable)
- {
- g_nv_setting_mirror.advertisingallowable = list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetPriority
- * Purpose:设定优先级的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetPriority(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.prior)
- {
- g_nv_setting_mirror.prior= list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetValidPeriod
- * Purpose:设定有效期的值
- * Input: uint16 list_index
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetValidPeriod(uint16 list_index)
- {
- if (list_index!= g_nv_setting_mirror.valid_period)
- {
- g_nv_setting_mirror.valid_period= list_index;
- Setting_WriteBack();
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetMMSC
- * Purpose:设置彩信中心号码
- * Input: uint8 *:字符串
- uint16: 字符串长度
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetMMSC(uint8 *mmsc_ptr, uint16 mmsc_len)
- {
- int16 mmsc_str_len = 0;
- SCI_TRACE_LOW("FNH set mmsc mmsc_ptr = %s",mmsc_ptr);
- if (mmsc_ptr == NULL)
- {
- g_nv_setting_mirror.centre_addr[0]= 0;
- return ;
- }
- mmsc_str_len = MIN(mmsc_len, MMIMMS_MMSC_MAX_LEN);
- SCI_MEMSET(g_nv_setting_mirror.centre_addr, 0, MMS_MAX_CENTRE_ADDR_LENGTH);
- SCI_TRACE_LOW("FNH set mmsc mmsc_str_len = %d",mmsc_str_len);
- SCI_TRACE_LOW("FNH set mmsc g_nv_setting_mirror.centre_addr = %s",g_nv_setting_mirror.centre_addr);
- SCI_MEMCPY(g_nv_setting_mirror.centre_addr, mmsc_ptr, mmsc_str_len);
- SCI_TRACE_LOW("FNH set mmsc g_nv_setting_mirror.centre_addr = %s",g_nv_setting_mirror.centre_addr);
- Setting_WriteBack();
- return ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetMMSC
- * Purpose:得到彩信中心的设定值
- * Input: void
- * Returns: uint8*:彩信中心号码
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 *MMIMMS_Setting_GetMMSC(void)
- {
- SCI_TRACE_LOW("FNH get mmsc g_nv_setting_mirror.centre_addr = %s",g_nv_setting_mirror.centre_addr);
- return g_nv_setting_mirror.centre_addr;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetGATEWAY
- * Purpose:设置网关地址
- * Input: uint8 *:网关地址字符串
- uint16: 字符串长度
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetGATEWAY(uint8 *gateway_ptr, uint16 gateway_len)
- {
- int16 gateway_str_len = 0;
- SCI_TRACE_LOW("FNH IN setgateway gateway_ptr = %s",gateway_ptr);
- if (gateway_ptr == NULL)
- {
- g_nv_setting_mirror.gateway[0] = 0;
- return ;
- }
- gateway_str_len = MIN(gateway_len, MMIMMS_GATEWAY_MAX_LEN);
- SCI_MEMSET(g_nv_setting_mirror.gateway, 0, MMS_MAX_GATEWAY_LENGTH);
- SCI_MEMCPY(g_nv_setting_mirror.gateway, gateway_ptr, gateway_str_len);
- SCI_TRACE_LOW("FNH g_nv_setting_mirror.gateway = %s",g_nv_setting_mirror.gateway);
- Setting_WriteBack();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetGATEWAY
- * Purpose:得到网关的设定值
- * Input: void
- * Returns: uint8*:网关号码
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 *MMIMMS_Setting_GetGATEWAY(void)
- {
- SCI_TRACE_LOW("FNH gateway = %s",g_nv_setting_mirror.gateway);
- return g_nv_setting_mirror.gateway;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetPORT
- * Purpose:设置端口号
- * Input: uint8 *:端口号字符串
- uint16: 字符串长度
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetPORT(uint8 *port_ptr, uint16 port_len)
- {
- int16 port_str_len = 0;
- SCI_TRACE_LOW("FNH IN setport port_ptr = %s",port_ptr);
- SCI_TRACE_LOW("FNH IN setport port_len = %d",port_len);
- if (port_ptr == NULL)
- {
- g_nv_setting_mirror.port[0] = 0;
- return ;
- }
- port_str_len = MIN(port_len, MMIMMS_PORT_MAX_LEN);
- SCI_TRACE_LOW("FNH before strcpy port_str_Len = %d",port_str_len);
- SCI_MEMSET(g_nv_setting_mirror.port, 0, MMS_MAX_PORT_LENGTH);
- SCI_TRACE_LOW("FNH before strcpy g_nv_setting_mirror.port = %s",g_nv_setting_mirror.port);
- SCI_MEMCPY(g_nv_setting_mirror.port, port_ptr, port_str_len);
- SCI_TRACE_LOW("FNH after strcpy g_nv_setting_mirror.port = %s",g_nv_setting_mirror.port);
- Setting_WriteBack();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetPORT
- * Purpose:得到端口号的设定值
- * Input: void
- * Returns: uint8*:端口号值
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 *MMIMMS_Setting_GetPORT(void)
- {
- SCI_TRACE_LOW("FNH get port g_nv_setting_mirror.port = %s",g_nv_setting_mirror.port);
- return g_nv_setting_mirror.port;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetUserName
- * Purpose:设置用户名
- * Input: uint8 *:字符串
- uint16: 字符串长度
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetUserName(uint8 *username_ptr, uint16 username_len)
- {
- int16 unsername_str_len = 0;
- SCI_TRACE_LOW("FNH set username_ptr username_ptr = %s",username_ptr);
- if (username_ptr == NULL)
- {
- g_nv_setting_mirror.username[0]= 0;
- return ;
- }
- unsername_str_len = MIN(username_len, MMIMMS_USERNAME_MAX_LEN);
- SCI_MEMSET(g_nv_setting_mirror.username, 0, MMS_MAX_USERNAME_LENGTH);
- SCI_TRACE_LOW("FNH set username unsername_str_len = %d",username_len);
- SCI_TRACE_LOW("FNH set unsername g_nv_setting_mirror.unsername = %s",g_nv_setting_mirror.username);
- SCI_MEMCPY(g_nv_setting_mirror.username, username_ptr, username_len);
- g_nv_setting_mirror.username[username_len] = ' ';
- SCI_TRACE_LOW("FNH set unsername g_nv_setting_mirror.unsername = %s",g_nv_setting_mirror.username);
- Setting_WriteBack();
- return ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetMMSC
- * Purpose:得到用户名的设定值
- * Input: void
- * Returns: uint8*:用户名
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 *MMIMMS_Setting_GetUserName(void)
- {
- SCI_TRACE_LOW("FNH get username g_nv_setting_mirror.username = %s",g_nv_setting_mirror.username);
- return g_nv_setting_mirror.username;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetPassword
- * Purpose:设置密码
- * Input: uint8 *:字符串
- uint16: 字符串长度
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetPassword(uint8 *password_ptr, uint16 password_len)
- {
- int16 password_str_len = 0;
- SCI_TRACE_LOW("FNH set password_ptr password_ptr = %s",password_ptr);
- if (password_ptr == NULL)
- {
- g_nv_setting_mirror.password[0]= 0;
- return ;
- }
- password_str_len = MIN(password_len, MMIMMS_PASSWORD_MAX_LEN);
- SCI_MEMSET(g_nv_setting_mirror.password, 0, MMS_MAX_PASSWORD_LENGTH);
- SCI_TRACE_LOW("FNH set password password_str_len = %d",password_len);
- SCI_TRACE_LOW("FNH set password g_nv_setting_mirror.password = %s",g_nv_setting_mirror.password);
- SCI_MEMCPY(g_nv_setting_mirror.password, password_ptr, password_len);
- g_nv_setting_mirror.password[password_len] = ' ';
- SCI_TRACE_LOW("FNH set password g_nv_setting_mirror.password = %s",g_nv_setting_mirror.password);
- Setting_WriteBack();
- return ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_Getpassword
- * Purpose:得到密码的设定值
- * Input: void
- * Returns: uint8*:密码的值
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 *MMIMMS_Setting_GetPassword(void)
- {
- SCI_TRACE_LOW("FNH get password g_nv_setting_mirror.password = %s",g_nv_setting_mirror.password);
- return g_nv_setting_mirror.password;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_SetAPN
- * Purpose:设置APN
- * Input: uint8 *:字符串
- uint16: 字符串长度
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Setting_SetAPN(uint8 *apn_ptr, uint16 apn_len)
- {
- int16 apn_str_len = 0;
- SCI_TRACE_LOW("FNH set apn_ptr apn_ptr = %s",apn_ptr);
- if (apn_ptr == NULL)
- {
- g_nv_setting_mirror.apn[0]= 0;
- return ;
- }
- apn_str_len = MIN(apn_len, MMIMMS_APN_MAX_LEN);
- SCI_MEMSET(g_nv_setting_mirror.apn, 0, MMS_MAX_APN_LENGTH);
- SCI_TRACE_LOW("FNH set apn apn_str_len = %d",apn_len);
- SCI_TRACE_LOW("FNH set apn g_nv_setting_mirror.apn = %s",g_nv_setting_mirror.apn);
- SCI_MEMCPY(g_nv_setting_mirror.apn, apn_ptr, apn_len);
- SCI_TRACE_LOW("FNH set apn g_nv_setting_mirror.apn = %s",g_nv_setting_mirror.apn);
- Setting_WriteBack();
- return ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Setting_GetAPN
- * Purpose:得到APN的设定值
- * Input: void
- * Returns: uint8*:APN的设定值
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 *MMIMMS_Setting_GetAPN(void)
- {
- SCI_TRACE_LOW("FNH get apn g_nv_setting_mirror.apn = %s",g_nv_setting_mirror.apn);
- return g_nv_setting_mirror.apn;
- }
- /*****************************************************************************/
- // Description : write mms setting to nv
- // Global resource dependence : g_nv_setting_mirror
- // Author: Bruce.Chi
- // Note:
- /*****************************************************************************/
- void Setting_WriteBack(void)
- {
- MMINV_WRITE(MMINV_MMS_SETTING, &g_nv_setting_mirror); //no returned value
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMSMMS_SetCurSlideDuration
- * Purpose:设定每祯播放的时间的值
- * Input: uint32 duaration
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMSMMS_SetCurSlideDuration(uint32 duaration)
- {
- SCI_TRACE_LOW("mmimms : MMSMMS_SetCurSlideDuration, duaration=%d", duaration);
- MMIMMS_SetCurSlideDuration(duaration * ONE_KILO);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetCurSlideDuration
- * Purpose:得到当前祯播放的时间的值
- * Input: pMMS_EDocument p_cur_doc
- * Returns: uint32
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint32 MMIMMS_GetCurSlideDuration(pMMS_EDocument p_cur_doc)
- {
- T_WORD slide_time = 0;
- slide_time = p_cur_doc->slide_cur->times;
- SCI_TRACE_LOW("mmimms : MMIMMS_GetCurSlideDuration, slide_time=%d", slide_time);
- slide_time /= ONE_KILO;
- /* if (slide_time < MMIMMS_SLIDE_DUARATION_MIN || slide_time > MMIMMS_SLIDE_DUARATION_MAX)
- {
- slide_time = MMIMMS_SLIDE_DUARATION_DEFAULT;
- }
- */
- return slide_time;
- }
- /*****************************************************************************/
- // Description : convert ASC to UCS2
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: should free the outer pointer
- ///*****************************************************************************/
- uint8 *ASCtoUCS2(uint8 *src_ptr, //in
- uint32 src_len, //in
- uint32 *ucs2_len_ptr //out
- )
- {
- uint8 *ucs2_text_ptr = PNULL;
- int i = 0;
- if (src_len == 0)
- {
- return PNULL;
- }
- SCI_ASSERT(src_ptr != PNULL);
- SCI_ASSERT(ucs2_len_ptr != PNULL);
- ucs2_text_ptr = cms_malloc(src_len * 2);
- SCI_ASSERT(ucs2_text_ptr != PNULL);
- SCI_MEMSET(ucs2_text_ptr, 0, src_len * 2);
- for( i = 0; i < src_len; i++ )
- {
- ucs2_text_ptr[2 *i] = 0x00;
- ucs2_text_ptr[2 * i + 1] = src_ptr[i];
- }
- *ucs2_len_ptr = src_len * 2;
- return ucs2_text_ptr;
- }
- /*****************************************************************************/
- // Description : cat two string
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: should free the dst_ptr->str_ptr
- ///*****************************************************************************/
- BOOLEAN CatStringByTextID(
- MMI_STRING_T *dst_ptr, //out.
- uint32 text_id, //in.
- MMI_STRING_T *src2_ptr //in.
- )
- {
- MMI_STRING_T string_prefix;
- SCI_ASSERT(dst_ptr != PNULL);
- SCI_ASSERT(src2_ptr != PNULL);
- MMI_GetLabelTextByLang(text_id, &string_prefix); //don't need to free string_prefix.str_ptr
- return CatString(dst_ptr, &string_prefix, src2_ptr);
- }
- /*****************************************************************************/
- // Description : cat two string
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: should free the dst_ptr->str_ptr
- ///*****************************************************************************/
- BOOLEAN CatStringByTextID2(
- MMI_STRING_T *dst_ptr, //out.
- uint32 text_id1, //in.
- uint32 text_id2 //in.
- )
- {
- MMI_STRING_T string_prefix;
- MMI_STRING_T string_subfix;
- SCI_ASSERT(dst_ptr != PNULL);
- MMI_GetLabelTextByLang(text_id1, &string_prefix); //don't need to free string_prefix.str_ptr
- MMI_GetLabelTextByLang(text_id2, &string_subfix);
- return CatString(dst_ptr, &string_prefix, &string_subfix);
- }
- /*****************************************************************************/
- // Description : get delta mms image type string through multim image type
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- T_BYTE *Edit_GetDeltaMMSImageType2(ANIMATE_IMAGE_TYPE_E multim_img_type)
- {
- T_BYTE *img_type_ptr = PNULL;
- SCI_ASSERT(multim_img_type >= ANIM_NONE && multim_img_type <= ANIM_GIF);
- switch(multim_img_type)
- {
- case ANIM_WBMP:
- img_type_ptr = COMPOSER_IMAGE_WBMP;
- break;
- case ANIM_BMP:
- img_type_ptr = COMPOSER_IMAGE_BMP;
- break;
- case ANIM_JPG:
- img_type_ptr = COMPOSER_IMAGE_JPEG;
- break;
- case ANIM_GIF:
- img_type_ptr = COMPOSER_IMAGE_GIF;
- break;
- case ANIM_PNG:
- img_type_ptr = COMPOSER_IMAGE_PNG;
- break;
- default:
- img_type_ptr = PNULL;
- break;
- }
- return img_type_ptr;
- }
- /*****************************************************************************/
- // Description : get mms audio type string through multim audio type
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- T_BYTE *Edit_GetDeltaMMSAudioType(MMIMULTIM_MUSIC_TYPE_E multim_audio_type)
- {
- T_BYTE *audio_type_ptr = PNULL;
- // MMIMULTIM_MUSIC_NO_TYPE,
- // MMIMULTIM_TYPE_MIDI, //MIDI类型
- // MMIMULTIM_TYPE_MMF, //MMF类型
- // MMIMULTIM_TYPE_WAV, //WAV类型
- // MMIMULTIM_TYPE_MP3, //MP3类型
- // MMIMULTIM_MAX_MUSIC_TYPE_NUM //音乐的类型总数
- //#define COMPOSER_AUDIO_WAV "audio/wav"
- //#define COMPOSER_AUDIO_IMELODY "audio/imelody"
- //#define COMPOSER_AUDIO_MIDI "audio/midi"
- //#define COMPOSER_AUDIO_AMR "audio/amr"
- //#define COMPOSER_AUDIO_MP3 "audio/mp3"
- SCI_ASSERT(multim_audio_type >= MMIMULTIM_MUSIC_NO_TYPE && multim_audio_type < MMIMULTIM_MAX_MUSIC_TYPE_NUM);
- SCI_TRACE_LOW("mmimms_main:Edit_GetDeltaMMSAudioType(), multim_audio_type=%d, L%d", multim_audio_type, __LINE__);
- switch(multim_audio_type)
- {
- case MMIMULTIM_TYPE_MIDI:
- case MMIMULTIM_TYPE_MID:
- audio_type_ptr = COMPOSER_AUDIO_MIDI;
- break;
- case MMIMULTIM_TYPE_MMF:
- audio_type_ptr = PNULL;
- break;
- #ifdef HAVE_AMR
- case MMIMULTIM_TYPE_AMR:
- audio_type_ptr = COMPOSER_AUDIO_AMR;
- break;
- #endif
- case MMIMULTIM_TYPE_WAV:
- audio_type_ptr = COMPOSER_AUDIO_WAV;
- break;
- #ifdef HAVE_MP3
- case MMIMULTIM_TYPE_MP3:
- audio_type_ptr = COMPOSER_AUDIO_MP3;
- break;
- #endif
- default:
- audio_type_ptr = PNULL;
- break;
- }
- return audio_type_ptr;
- }
- /*****************************************************************************/
- // Description : get audio type through delta mms audio type string
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- MMIMULTIM_MUSIC_TYPE_E Edit_GetMultimAudioType(char *delta_mms_audio_type_ptr)
- {
- MMIMULTIM_MUSIC_TYPE_E music_type = MMIMULTIM_MUSIC_NO_TYPE;
- // MMIMULTIM_MUSIC_NO_TYPE,
- // MMIMULTIM_TYPE_MIDI, //MIDI类型
- // MMIMULTIM_TYPE_MMF, //MMF类型
- // MMIMULTIM_TYPE_WAV, //WAV类型
- // MMIMULTIM_TYPE_MP3, //MP3类型
- // MMIMULTIM_MAX_MUSIC_TYPE_NUM //音乐的类型总数
- //#define COMPOSER_AUDIO_WAV "audio/wav"
- //#define COMPOSER_AUDIO_IMELODY "audio/imelody"
- //#define COMPOSER_AUDIO_MIDI "audio/midi"
- //#define COMPOSER_AUDIO_AMR "audio/amr"
- //#define COMPOSER_AUDIO_MP3 "audio/mp3"
- if (delta_mms_audio_type_ptr != PNULL)
- {
- SCI_TRACE_LOW("mmimms_main:Edit_GetMultimAudioType(), delta_mms_audio_type_ptr=%s, L%d", delta_mms_audio_type_ptr, __LINE__);
- }
- if (delta_mms_audio_type_ptr == PNULL)
- {
- music_type = MMIMULTIM_MUSIC_NO_TYPE;
- }
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_WAV))
- {
- music_type = MMIMULTIM_TYPE_WAV; //wave
- }
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_IMELODY))
- {
- music_type = MMIMULTIM_MUSIC_NO_TYPE; //not supported
- }
- else if(0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MIDI))
- {
- music_type = MMIMULTIM_TYPE_MIDI;
- }
- else if (0 == stricmp(delta_mms_audio_type_ptr, "audio/mid")) //there are many kinds of composer
- {
- music_type = MMIMULTIM_TYPE_MIDI;
- }
- #ifdef HAVE_AMR
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_AMR))
- {
- music_type = MMIMULTIM_TYPE_AMR; //amr
- }
- #endif
- #ifdef HAVE_MP3
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MP3))
- {
- music_type = MMIMULTIM_TYPE_MP3; //mp3
- }
- #endif
- //SCI_TRACE_LOW("mmimms_main:Edit_GetMultimAudioType(), music_type = %d, L%d", music_type, __LINE__);
- return music_type;
- }
- /*****************************************************************************/
- // Description : get low layer audio type through delta mms audio type string
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- MMIAUDIO_TYPE_E Edit_GetLowLayerAudioType(char *delta_mms_audio_type_ptr)
- {
- MMIAUDIO_TYPE_E audio_type = MMIAUDIO_TYPE_MAX;
- if (delta_mms_audio_type_ptr != PNULL)
- {
- SCI_TRACE_LOW("mmimms_main:Edit_GetLowLayerAudioType(), delta_mms_audio_type_ptr=%s, L%d", delta_mms_audio_type_ptr, __LINE__);
- }
- if (delta_mms_audio_type_ptr == PNULL)
- {
- audio_type = MMIAUDIO_TYPE_MAX;
- }
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_WAV))
- {
- audio_type = MMIAUDIO_ADPCM;
- }
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_IMELODY))
- {
- audio_type = MMIAUDIO_TYPE_MAX; //not supported
- }
- else if(0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MIDI))
- {
- audio_type = MMIAUDIO_MIDI;
- }
- else if (0 == stricmp(delta_mms_audio_type_ptr, "audio/mid")) //there are many composer
- {
- audio_type = MMIAUDIO_MIDI;
- }
- #ifdef HAVE_AMR
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_AMR))
- {
- audio_type = MMIAUDIO_AMR;
- }
- #endif
- #ifdef HAVE_MP3
- else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MP3))
- {
- audio_type = MMIAUDIO_MP3; //not supported
- }
- #endif
- return audio_type;
- }
- /*****************************************************************************/
- // Description : get ani type through delta mms type string
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- ANIMATE_IMAGE_TYPE_E Edit_GetAniType(char *delta_mms_img_type_ptr)
- {
- ANIMATE_IMAGE_TYPE_E anim_type = ANIM_NONE;
- if (delta_mms_img_type_ptr != PNULL)
- {
- SCI_TRACE_LOW("mmimms_main:Edit_GetAniType(), delta_mms_img_type_ptr=%s, L%d", delta_mms_img_type_ptr, __LINE__);
- }
- if (delta_mms_img_type_ptr == PNULL)
- {
- anim_type = ANIM_NONE;
- }
- else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_JPEG))
- {
- anim_type = ANIM_JPG;
- }
- else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_GIF))
- {
- anim_type = ANIM_GIF;
- }
- else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_BMP))
- {
- anim_type = ANIM_BMP;
- }
- else if(0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_WBMP))
- {
- anim_type = ANIM_WBMP;
- }
- else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_PNG))
- {
- anim_type = ANIM_NONE;
- }
- return anim_type;
- }
- #define MMIMMS_RECEIVE_MMS_DELIVERY 0x86
- #define MMIMMS_RECEIVE_MMS_NOTIFICATION 0x82
- /*****************************************************************************/
- // Description : get MMI_TM_T through seconds since 1970
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- MMI_TM_T Edit_GetTimeFrom1970(uint32 seconds)
- {
- MMI_TM_T date_time;
- int year,month,day,hour,minute,second,i;
- int total_day,current_year_days, current_month_day,leap_year;
- int total_second;
- uint16 day_of_month[2][12] =
- {
- {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
- };
- SCI_MEMSET(&date_time, 0, sizeof(date_time));
- total_day = seconds / (24 * 60 * 60);
- total_second = seconds % (24 * 60 * 60);
- year = 1970;
- month = 1;
- day = 1;
- hour = MMS_LOCAL_TIME_ZONE;
- minute = 0;
- second = 0;
- for (i = 0; i < MMS_100_YEARS; i++)
- {
- current_year_days = Edit_IsLeapYear(year) ? 366:365;
- if ((total_day -current_year_days) >= 0)
- {
- total_day -=current_year_days;
- year++;
- }
- else
- {
- break;
- }
- }
- if (i == MMS_100_YEARS)
- {
- return date_time;
- }
- leap_year = Edit_IsLeapYear(year) ? 1:0;
- for (i = 0; i < 12;i++)
- {
- current_month_day = day_of_month[ leap_year][i];
- if ((total_day -current_month_day) >= 0)
- {
- total_day -=current_month_day;
- month++;
- }
- else
- {
- break;
- }
- }
- day += total_day;
- hour += total_second / (60 * 60);
- minute = (total_second % (60 * 60)) / 60;
- second = (total_second % (60 * 60)) % 60;
- date_time.tm_year = year;
- date_time.tm_mon = month;
- date_time.tm_mday = day;
- date_time.tm_hour = hour;
- date_time.tm_min = minute;
- date_time.tm_sec = second;
- return date_time;
- }
- /*****************************************************************************/
- // Description : judge whether this year is leap year
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- LOCAL BOOLEAN Edit_IsLeapYear(uint16 year)
- {
- if (year % 400 == 0)
- {
- return TRUE;
- }
- else if (year % 100 == 0)
- {
- return FALSE;
- }
- else if (year % 4 == 0)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /*****************************************************************************/
- // Description : ucs2 -> utf8
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: should free the return pointer UTF8_T.buf_ptr
- ///*****************************************************************************/
- UTF8_T Edit_UNICODE2UTF(MMI_STRING_T *str_src_ptr)
- {
- UTF8_T utf8_str = {0};
- uint16 ucs2_char = 0; //here, we only consider UCS2. UCS4 is not considered.
- int i = 0;
- int j = 0;
- uint8 *out_ptr = PNULL;
- uint32 out_len = 0;
- uint32 src_len = 0;
- if (str_src_ptr == PNULL || str_src_ptr->str_ptr == PNULL || str_src_ptr->length == 0)
- {
- utf8_str.buf_ptr = 0;
- utf8_str.len = 0;
- return utf8_str;
- }
- //alloc
- out_len = str_src_ptr->length / 2 * 3 + 3;
- out_ptr = cms_malloc(out_len);
- SCI_ASSERT(out_ptr != PNULL);
- SCI_MEMSET(out_ptr, 0, out_len);
- if (!str_src_ptr->is_ucs2)
- {
- //this is ACSII
- MMI_MEMCPY(
- out_ptr,
- out_len,
- str_src_ptr->str_ptr,
- str_src_ptr->length,
- str_src_ptr->length
- );
- utf8_str.buf_ptr = out_ptr;
- utf8_str.len = str_src_ptr->length;
- }
- else
- {
- src_len = str_src_ptr->length;
- if ((src_len % 2) != 0) //half of ucs2, ignore it
- {
- src_len--;
- }
- for (i = 0, j = 0; i < str_src_ptr->length / 2; i++)
- {
- //get unicode character
- ucs2_char = ((str_src_ptr->str_ptr[2 * i]) << 8) | str_src_ptr->str_ptr[2 * i + 1];
- if (ucs2_char <= 0x7F)
- {
- //0xxx xxxx
- //0111 1111 == 0x7F
- out_ptr[j] = ucs2_char & 0x7F;
- j++;
- }
- else if (ucs2_char <= 0x7FF)
- {
- //110x xxxx 10xx xxxx
- //11位拆成5,6位
- //0000 0111 1100 0000 == 0x7C0 110 == 0x6 //取出高5位+(110 << 5)
- out_ptr[j] = (uint8)(((ucs2_char & 0x7C0) >> 5) | (0x6 << 5));
- j++;
- //0000 0000 0011 1111 = 0x3F 10 == 0x2 //取出低6位+(10 << 6)
- out_ptr[j] = (uint8)((ucs2_char & 0x3F) | (0x2 << 6));
- j++;
- }
- else if (ucs2_char <= 0xFFFF)
- {
- //1110 xxxx 10xx xxxxxx 10xx xxxxxx
- //16位拆成4, 6, 6
- //1111 0000 0000 0000 == 0xF000 1110 == 0xE //取出高4位 + (1110 << 4)
- out_ptr[j] = (uint8)((ucs2_char & 0xF000) >> 12) | (0xE << 4);
- j++;
- //0000 1111 1100 0000 == 0xFC0 10 = 0x2 //中间6位 + (10 << 6)
- out_ptr[j] = (uint8)(((ucs2_char & 0xFC0 ) >> 6) | (0x2 << 6));
- j++;
- //0000 0000 0011 1111 == 0x3F 10 = 0x2 //最后6位 + (10 << 6)
- out_ptr[j] = (uint8)((ucs2_char & 0x3F) | (0x2 << 6));
- j++;
- }
- }
- utf8_str.buf_ptr = out_ptr;
- utf8_str.len = j;
- SCI_ASSERT(j <= out_len);
- }
- return utf8_str;
- }
- /*****************************************************************************/
- // Description : utf8 -> ucs2
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: should free the return pointer MMI_STRING_T.str_ptr
- ///*****************************************************************************/
- MMI_STRING_T Edit_UTF2UNICODE(UTF8_T *utf8_str_ptr)
- {
- int i = 0;
- int j = 0;
- uint8 *ucs2_ptr = PNULL;
- uint32 out_len = 0;
- uint8 head_char = 0;
- uint16 ucs2_char = 0;
- BOOLEAN is_asc = TRUE;
- MMI_STRING_T str_out = {0};
- SCI_ASSERT(utf8_str_ptr != PNULL);
- out_len = utf8_str_ptr->len * 2 + 2;
- ucs2_ptr = cms_malloc(out_len);
- SCI_ASSERT(ucs2_ptr != PNULL);
- SCI_MEMSET(ucs2_ptr, 0, out_len);
- is_asc = TRUE;
- while(i < utf8_str_ptr->len)
- {
- head_char = utf8_str_ptr->buf_ptr[i];
- if (head_char <= 0x7F)
- {
- //0xxx xxxx
- //0111 1111 = 0X7F
- ucs2_ptr[j] = 0;
- ucs2_ptr[j + 1] = head_char;
- j += 2;
- i += 1;
- }
- else if (head_char <= 0xDF)
- {
- if (i + 1 <= utf8_str_ptr->len - 1)
- {
- //110x xxxx 10xx xxxx
- //1101 1111 == 0xDF
- //0001 1111 == 0x1F 0011 1111 == 0x3F
- ucs2_char = ((utf8_str_ptr->buf_ptr[i] & 0x1F) << 6) | ((utf8_str_ptr->buf_ptr[i+1] & 0x3F));
- ucs2_ptr[j] = (uint8)((ucs2_char & 0xFF00) >> 8);
- ucs2_ptr[j + 1] = (uint8)(ucs2_char & 0xFF);
- j += 2;
- }
- i += 2;
- is_asc = FALSE;
- }
- else if (head_char <= 0xEF)
- {
- if (i + 2 <= utf8_str_ptr->len - 1)
- {
- //1110 xxxx 10xx xxxx 10xx xxxx
- //1110 1111 == 0xEF
- //0000 1111 == 0xF 0011 1111 == 0x3F
- ucs2_char = ((utf8_str_ptr->buf_ptr[i] & 0xF) << 12) | ((utf8_str_ptr->buf_ptr[i + 1] & 0x3F) << 6) | (utf8_str_ptr->buf_ptr[i + 2] & 0x3F);
- ucs2_ptr[j] = (uint8)((ucs2_char & 0xFF00) >> 8);
- ucs2_ptr[j + 1] = (uint8)(ucs2_char & 0xFF);
- j += 2;
- }
- i += 3;
- is_asc = FALSE;
- }
- else
- {
- i++;
- break;
- }
- }
- if (is_asc)
- {
- str_out.is_ucs2 = FALSE;
- str_out.length = utf8_str_ptr->len;