mmimms_main.c
资源名称:MMS.rar [点击查看]
上传用户:tqh2500
上传日期:2014-05-09
资源大小:163k
文件大小:313k
源码类别:
手机彩信(MMS)编程
开发平台:
Visual C++
- /****************************************************************************
- ** File Name: mmimms_main.c *
- ** Author: *
- ** Date: 2004.8.23 *
- ** Copyright: 2004 Spreatrum, Incoporated. All Rights Reserved. *
- ** Description: This file is used to describe the MMS *
- ****************************************************************************
- ** Important Edit History *
- ** ------------------------------------------------------------------------*
- ** DATE NAME DESCRIPTION *
- ** 2004.8 Bruce.Chi Create
- **
- ****************************************************************************/
- /**--------------------------------------------------------------------------*
- ** Include Files *
- **--------------------------------------------------------------------------*/
- #include "window_parse.h"
- #include "guitextbox.h"
- #include "mmi_pubwin.h"
- #include "mmi_text.h"
- #include "mms_text.h"
- #include "mmi_image.h"
- #include "mmk_timer.h"
- #include "mainapp.h"
- #include "mmipb.h"
- #include "ccapp.h"
- #include "mmimms_internal.h"
- #include "tb_dal.h"
- #include "mmi_menutable.h"
- #include "mmidisplay_data.h"
- #include "mmi_default.h"
- #include "mmiudisk.h"
- #include "mmiwap.h"
- #include "mmimms.h"
- #include "mmimultim.h"
- #ifdef MMI_APP_6800_PRJ
- #else
- #include "mmidv.h"
- #endif
- //#include "mmibrowser.h"
- #include "mmibrowser_internal.h"
- #include "Cms_MMSDoc.h"
- #include "Cms_MMSProvide.h"
- #include "Cms_WAPMain.h"
- #include "mmi_appmsg.h"
- #include "Cms_MMSFilefunc.h"
- #include "mmiset.h"//add liangliu@palmsource.com
- #include "mmimpeg4.h"
- #include "mmiaudio.h"
- #include "mn_type.h"
- /**--------------------------------------------------------------------------*
- ** MACRO DEFINITION *
- **--------------------------------------------------------------------------*/
- #define ONE_HOUR_IN_SECONDS (3600)
- #define UCS2_NAME_MAX_LEN 32
- #define FILE_DEVICE FS_UDISK
- #define PATH_ROOT "/"
- #define CURR_DIRECTORY "\"
- #define MANAGERINBOXFILE "cmsinbox.cnf"
- #define MANAGEROUTBOXFILE "cmsoutbox.cnf"
- #define MANAGERSENTBOXFILE "cmssentbox.cnf"
- #define MANAGERDRAFTBOXFILE "cmsdraftbox.cnf"
- #define MANAGER_FLASH_DIR "MANAGER"
- #define MMS_FLASH_CONFIGFILE "cmsmmsconfig.ini"
- #define MANAGER_FLASH_INBOXNAME "inbox.ini"
- #define MANAGER_FLASH_OUTBOXNAME "outbox.ini"
- #define MANAGER_FLASH_SENTBOXNAME "sentbox.ini"
- #define MANAGER_FLASH_DRAFTBOXNAME "draftbox.ini"
- #define MMSCONFIGFILE "mmsconfigfile.cnf"
- #define MMSAUTOSIGNFILE "mmsautosign.ini"
- #define MMS_FILE_NAME_LENGTH 128
- #define MMIMMS_VIBRA_TIMEROUT 3000
- #define LEAVE_SPACE (200*1024)
- #ifndef FILE_HANDLE
- #define FILE_HANDLE int
- #endif
- #ifndef ALERT_TIMEOUT
- #define ALERT_TIMEOUT 3000
- #endif
- /*---------------------------------------------------------------------------*/
- /* TYPE AND CONSTANT */
- /*---------------------------------------------------------------------------*/
- typedef enum
- {
- MMS_DELIVERY_REPORT_VALUE_NONE,
- MMS_DELIVERY_REPORT_VALUE_RETRIVED,
- MMS_DELIVERY_REPORT_VALUE_REJECTED,
- MMS_DELIVERY_REPORT_VALUE_DEFERRED,
- MMS_DELIVERY_REPORT_VALUE_EXPIRED,
- MMS_DELIVERY_REPORT_VALUE_UNRECOGNESED
- }MMS_DELIVERY_REPORT_VALUE;
- /**-------------------------------------------------------------------------*
- ** GLOBAL DEFINITION *
- **--------------------------------------------------------------------------*/
- MMIMMS_MEM_STORE_T g_mms_save_in_mem; //used between edit and save in ram modules
- MMIMMS_NV_SETTING g_nv_setting_mirror; //mirror of NV mms setting
- //liangl added 2005-10-8 for spread new managerdocument.
- P_ManagerDocument g_pManager = NULL;
- pAutoDownloadMMSList g_pautoDownloadMMSRoot = PNULL;//cr liangliu 2006-4-27
- uint16 g_num_autodw = 0;
- pMMS_EDocument g_pcur_signdoc = NULL;
- char *g_filename = PNULL;
- uint32 g_progressneedsize = 0;
- uint32 g_progresscurrentsize = 0;
- BOOLEAN g_backautodownload = FALSE;//add liangliu 2006-4-28 for back to idle autodownload.
- BOOLEAN g_inboxneedsave = FALSE;//全局变量增加判断是否退回到idle状态需要保存inboxfile
- BOOLEAN g_issendingreadrpt = FALSE;//modify 2005-12-28 for send readrpt
- BOOLEAN g_donewmms = FALSE; //modify 2006-2-15 for change saving.
- BOOLEAN g_ismmsinit = FALSE;
- uint8 g_videoname_arr[MMIMMS_MAX_FILE_NAME_LEN+1] = {0};
- uint8 g_mp3name_arr[MMIMMS_MAX_FILE_NAME_LEN+1]={0};
- static uint8 s_play_mms_vibrator_timer_id = 0; //play mms vibrator timer id
- HFS inboxfile_openstatus = FFS_INVALID_HANDLE;
- MMS_DELIVERY_REPORT_VALUE g_delivery_value;
- /**--------------------------------------------------------------------------*
- ** EXTERNAL DECLARE *
- **--------------------------------------------------------------------------*/
- extern BOOLEAN g_mmi_exist_sd;
- extern FILE_DEV_E_T g_filetype;
- /**--------------------------------------------------------------------------*
- ** Description : function in Delta MMS lib
- **--------------------------------------------------------------------------*/
- extern void *MYMalloc(uint32 size);
- extern pMMS_EDocument g_peditdoc ; // 编辑文档,编辑器内部使用,生存期为编辑器主窗口开关时间 */
- extern int PeekGetData (unsigned short tid,unsigned char * buf,int length);
- extern void fnDB_MYMemInit(void *starting_address, unsigned long size, unsigned long page_size);
- extern void ConvertHttp(unsigned char * href );
- extern uint8 g_mmimms_preview_timer_id;
- extern p_MMS_RECEPIENT g_p_mms_to;
- extern p_MMS_RECEPIENT g_p_mms_cc;
- extern p_MMS_RECEPIENT g_p_mms_bcc;
- extern p_MMS_GROUP g_p_mms_to_group;
- extern p_MMS_GROUP g_p_mms_cc_group;
- extern p_MMS_GROUP g_p_mms_bcc_group;
- extern MMS_SEND_ONTIME_TIME g_set_date;
- extern char* g_p_mms_subject; //主题字符串,生存期为编辑窗口开关时间
- extern MMIMMS_SAVEMANAGERFILE_STATE g_savestate;
- extern MMIMMS_SAVEMAMMS_STATE g_savemmsstate;
- extern MMIMMS_NETUSING_STATE g_netusing;
- extern pMessageList g_pCurrentList ;
- extern wap_mms_init;
- extern uint8 g_mailbox_status;
- extern uint16 iFClose;
- extern FILE_DEV_E_T MMICMS_GetCurrentFFS( void );
- extern BOOLEAN GPIO_CheckHeadsetStatus(void);
- /*---------------------------------------------------------------------------*/
- /* LOCAL FUNCTION DECLARE */
- /*---------------------------------------------------------------------------*/
- /* ----------------------------------------------------------------------------
- * Function Name: MMICMSMMS_CallBackReadAutoSignFile
- * Purpose: 读取自动签名页的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMICMSMMS_CallBackReadAutoSignFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CdRootPath(void);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CD(const char *path);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CdMMSPath(void);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CdMP3Path(void);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CreateDir (const char *path);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL BOOLEAN FILE_CheckExist (const char *file);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL HFS FILE_Create ( const char *name, uint16 mode);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL void FILE_Close (HFS handle);
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_Write ( HFS handle, uint8 *buf, uint32 len, uint32 *transmitted, FFS_OVERLAPPED_T *overlapped_ptr);
- /* ----------------------------------------------------------------------------
- * Function Name: CmsMmsAddNewAddr
- * Purpose: 将新地址加入到地址链表中
- * Input: head: 地址链表指针
- addr: 新地址指针
- bAddNode:增加的结点
- * Returns: 地址链表指针
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL p_MMS_RECEPIENT CmsMmsAddNewAddr( p_MMS_RECEPIENT head , char* addr , int bAddNode );
- /*****************************************************************************/
- // Description : judge whether this year is leap year
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- ///*****************************************************************************/
- LOCAL BOOLEAN Edit_IsLeapYear(uint16 year);
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerInboxFile
- * 函数说明: 读取收件箱文件的回调处理
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- LOCAL void MMIVC_CallBackReadManagerInboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerInboxFile
- * 函数说明: 读取发件箱文件的回调处理
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- LOCAL void MMIVC_CallBackReadManagerOutboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackReadManagerSentboxFile
- * Purpose: 读取已发信箱的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackReadManagerSentboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackReadManagerDraftboxFile
- * Purpose: 读取草稿信箱的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackReadManagerDraftboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * 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);
- /* ----------------------------------------------------------------------------
- * 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);
- /* ----------------------------------------------------------------------------
- * 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);
- /* ----------------------------------------------------------------------------
- * 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);
- /* ----------------------------------------------------------------------------
- * 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);
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveMMS_CallBack
- * Purpose: 保存彩信回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveMMS_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param);
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveVideo_CallBack
- * Purpose: 保存视频回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveVideo_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param);
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveMp3_CallBack
- * Purpose: 保存MP3回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveMp3_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param);
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_SaveAutoSign_CallBack
- * Purpose: 保存自动签名页回调函数
- * Input: FFS_ERROR_E efs_error,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void SaveFS_SaveAutoSign_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param);
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_ReadMMS_CallBack
- * Purpose: 读取彩信的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_ReadMMS_CallBack(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackDeleteMMSFile
- * Purpose: 删除彩信的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackDeleteMMSFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackDeleteManagerFile
- * Purpose: 删除彩信管理目录的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackDeleteManagerFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackDeleteManagerInboxFile
- * Purpose: 删除彩信收件箱管理目录的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackDeleteManagerInboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- );
- /* ----------------------------------------------------------------------------
- * 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
- );
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Notification_Arrive
- * Purpose: 彩信通知push处理函数
- * Input: void * ptr:push内容
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIMMS_Notification_Arrive(void * ptr);
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeliveryRpt_Arrive
- * Purpose: 送达报告处理函数
- * Input: void * ptr:push内容
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIMMS_DeliveryRpt_Arrive(void * ptr);
- /* ----------------------------------------------------------------------------
- * Function Name: CmsTimeToString
- * Purpose: 获得当前时间对应的字符串 指针
- * Input: MMI_TM_T:时间结构
- * Returns: 对应的字符串指针
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 * CmsTimeToString(MMI_TM_T tm);
- /* ----------------------------------------------------------------------------
- * Function Name: CmsTimeToString
- * Purpose: 取得文件的长度
- * Input: 虚拟文件句柄
- * Returns: 虚拟文件的长度
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint32 Cms_GetFileLength( FILE_HANDLE file);
- /**--------------------------------------------------------------------------*
- ** FUNCTION DEFINITION *
- **--------------------------------------------------------------------------*/
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_get_port
- * Purpose: 得到当前的网关和端口号
- * Input: curgatway: 当前的网关
- curport: 当前的端口号
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_get_port(char **curgatway,unsigned short *curport)
- {
- SCI_TRACE_LOW("FNH get_port g_nv_setting_mirror->gateway = %s",g_nv_setting_mirror.gateway);
- SCI_TRACE_LOW("FNH get_port g_nv_setting_mirror->port = %s",g_nv_setting_mirror.port);
- *curgatway =(char *)g_nv_setting_mirror.gateway;
- *curport = (unsigned short)atoi((char *)g_nv_setting_mirror.port);
- SCI_TRACE_LOW("FNH *curport = %d",*curport);
- return ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_IsIPAddress
- * Purpose:判断用户输入的网关地址是否是IP地址
- * Input: curipaddress: 当前的网关地址
- * Output: BOOLEAN
- TRUE: 是IP地址
- FALSE:不是IP地址
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN MMIMMS_IsIPAddress(char *curipaddress)
- {
- char *tempstr = NULL;
- char curipnum[34];
- short len = 0;
- short ipcount = 0;
- short curnum = 0;
- short curadd = 0;
- short index = 0;
- tempstr = curipaddress;
- len = (short)strlen(curipaddress);
- SCI_MEMSET(curipnum,0,sizeof(curipnum));
- for (index = 0;index <= len;index ++ )
- {
- if (((curipaddress[index] <0x30 || curipaddress[index] >0x39) && curipaddress[index] != 0x2E)&& (index != len))
- {
- return FALSE;
- }
- curnum ++;
- if ((curipaddress[index] == 0x2E) ||(index == len))
- {
- if ((curnum > 4) || (curnum == 1))
- {
- return FALSE;
- }
- else
- {
- short i = 0;
- if (curnum > 2)
- {
- BOOLEAN firstchar = FALSE;
- while(!firstchar)
- {
- i = 0;
- if (curipnum[i] !=0x30)
- {
- firstchar = TRUE;
- }
- else
- {
- if(curipnum[i] == 0x30 && i <curnum-2 && curipnum[i+1] != 0)
- {
- return FALSE;
- }
- }
- i++;
- if (i==curnum)
- {
- firstchar = TRUE;
- }
- }
- }
- curadd = (short)atoi(curipnum);
- if (curadd > 0xFF)
- {
- return FALSE;
- }
- ipcount ++;
- SCI_MEMSET(curipnum,0,sizeof(curipnum));
- curnum = 0;
- }
- }
- else
- curipnum[curnum-1] = curipaddress[index];
- }
- if (ipcount == 4)
- return TRUE;
- else
- return FALSE;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_AddVideo
- * Purpose:在当前页添加视频
- * Input: T_Composer_Video: 视频结构
- pMMS_EDocument: 编辑文档
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_AddVideo(T_Composer_Video*Video,pMMS_EDocument p_cur_doc)
- {
- #ifdef HAVE_MPEG4
- int16 type = 0;
- char video_fname[MMS_FILE_NAME_LENGTH] = {0};
- SCI_FILE* fd = 0;
- uint32 value = 0;
- SCI_TRACE_LOW("MMIMMS_AddVideo in");
- if ((p_cur_doc->totalsize + Video->size) > MMS_SIZE_OF_MESSAGE)
- {
- SCI_TRACE_LOW("open the file error");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_MMS_TOO_BIG,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- value = MMI_GetFfsTime();
- sprintf(video_fname,"%lu",value);
- SCI_TRACE_LOW("FNH video_fname = %s",video_fname);
- if (Video->Type == MPEG4_3GP_FILE)
- {
- type = MMS_TYPE_3GP;
- strcat(video_fname,".3gp");
- }
- else if (Video->Type == MPEG4_MP4_FILE)
- {
- type = MMS_TYPE_MP4;
- strcat(video_fname,".mp4");
- }
- SCI_TRACE_LOW("FNH type = %d",type);
- fd =(SCI_FILE*) mmsf_Open((char*)video_fname,"w");
- if (!fd )
- {
- SCI_TRACE_LOW("open the file error");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_ADD_FAIL,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- mmsf_Write((char *)Video->VidBuf, 1, Video->size,(FILE_HANDLE) fd);
- mmsf_Close((FILE_HANDLE)fd);
- if (MMS_New_Content((unsigned char*)video_fname,type,p_cur_doc->slide_cur,p_cur_doc))
- {
- SCI_TRACE_LOW("FNH NEW VIDEO IS SUCCESS");
- return 0;
- }
- else
- {
- SCI_TRACE_LOW("FNH NEW VIDEO IS FAIL");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_ADD_FAIL,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- #endif
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SetCurSlideDuration
- * Purpose:设置当前页面的延时
- * Input: T_WORD: 延时时间
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_SetCurSlideDuration(T_WORD delay)
- {
- g_peditdoc->slide_cur->times = delay* ONE_KILO;
- return 1;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: CmsIsSupportType
- * Purpose:判断是否是支持的数据类型
- * Input: uint16 type:图片文档
- * Returns:BOOLEAN
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN CmsIsSupportType(uint16 type)
- {
- BOOLEAN returnvalue = FALSE;
- if (type == MMS_TYPE_GIF ||
- type == MMS_TYPE_JPEG ||
- type == MMS_TYPE_WBMP ||
- type == MMS_TYPE_BMP1 ||
- type == MMS_TYPE_PNG )
- {
- returnvalue = TRUE;
- }
- return returnvalue;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteCurImage
- * Purpose:从当前页删除图像
- * Input: pMMS_EDocument:编辑文档
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_DeleteCurImage(pMMS_EDocument p_cur_doc)
- {
- uint16 type = 0;
- pMMS_Content content = NULL;
- pMMS_Slide slide = p_cur_doc->slide_cur;
- if(slide->image_flag)
- {
- content = slide->content_root;
- while (content)
- {
- if (CmsIsSupportType(content->type))
- {
- type = (uint16)content->type;
- break;
- }
- content = content->next;
- }
- slide->content_cur = content;
- MMS_DelContent(slide,p_cur_doc);
- slide->image_flag = 0;
- }
- return 1;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteCurVideo
- * Purpose:从当前页删除视频
- * Input: pMMS_EDocument:编辑文档
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_DeleteCurVideo(pMMS_EDocument p_cur_doc)
- {
- uint16 type = 0;
- pMMS_Content content = NULL;
- pMMS_Slide slide = p_cur_doc->slide_cur;
- if(slide->video_flag)
- {
- content = slide->content_root;
- while (content)
- {
- if (content->type == MMS_TYPE_MP4 ||
- content->type == MMS_TYPE_3GP )
- {
- type = (uint16)content->type;
- break;
- }
- content = content->next;
- }
- slide->content_cur = content;
- MMS_DelContent(slide,p_cur_doc);
- slide->video_flag = 0;
- }
- return 1;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: CmsMmsAddNewAddr
- * Purpose: 将新地址加入到地址链表中
- * Input: head: 地址链表指针
- addr: 新地址指针
- bAddNode:增加的结点
- * Returns: 地址链表指针
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL p_MMS_RECEPIENT CmsMmsAddNewAddr( p_MMS_RECEPIENT head , char* addr , int bAddNode )
- {
- if( !head ) return NULL;
- SCI_MEMCPY( head->m_address , addr , MAX_NAME_LENGTH );
- // SCI_TRACE_LOW( "addr list1 : %s.n" , head->m_address );
- if( bAddNode )
- {
- head->p_next = (p_MMS_RECEPIENT)cms_malloc( sizeof( MMS_RECEPIENT ) );
- if( head->p_next )
- {
- SCI_MEMSET( head->p_next , 0 , sizeof( MMS_RECEPIENT) );
- }
- }
- return head->p_next;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: CmsMmsParseRecepient
- * Purpose: 将得到的字符串解析生成地址链表
- * Input: __head: 地址链表指针
- str: 字符串
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void CmsMmsParseRecepient(p_MMS_RECEPIENT __head, char *str)
- {
- p_MMS_RECEPIENT head = __head;
- int nAddrCount = 0;
- const char* chToken = " ,;";
- char chAddr[ 64 ] , *ptrAddr = chAddr;
- while( str && *str )
- {
- if( !strchr( chToken , *str ) )
- {
- if( ptrAddr - chAddr <= MAX_NAME_LENGTH )
- {
- *ptrAddr++ = *str;
- }
- else
- {
- SCI_TRACE_LOW( "addr too long , cut ...... n" );
- }
- }
- else
- {
- if( ptrAddr != chAddr )
- {
- if( ++nAddrCount > MMIMMS_MAX_ADDRESS_NUM )
- {
- SCI_TRACE_LOW( "hehe , too many addr , ignore.....n" );
- break;
- }
- *ptrAddr = 0;
- head = CmsMmsAddNewAddr( head , chAddr , 1 );
- }
- ptrAddr = chAddr;
- }
- ++str;
- }
- *ptrAddr = 0;
- CmsMmsAddNewAddr( head , chAddr , 0 );
- }
- /******************************************************************************
- * 函数定义: MmsDelAllReceiver
- * 函数说明: 删除所有收件人
- * 参数说明: p_receiver: 收件人列表头指针
- * 返回值: 空
- ********************************************************************************/
- void MmsDelAllReceiver(p_MMS_RECEPIENT* p_receiver)
- {
- p_MMS_RECEPIENT p_temp = NULL;
- p_MMS_RECEPIENT p_temp2 = NULL;
- p_temp = *p_receiver;
- while(p_temp != NULL)
- {
- p_temp2 = p_temp->p_next;
- cms_free(p_temp);
- p_temp = p_temp2;
- }
- *p_receiver = NULL;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_AddImage
- * Purpose:在当前页添加图像
- * Input: T_Composer_Image: 图片结构
- pMMS_EDocument: 编辑文档
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_AddImage(T_Composer_Image* Image,pMMS_EDocument p_cur_doc)
- {
- int16 type = 0;
- char img_fname[MMS_FILE_NAME_LENGTH] = {0};
- SCI_FILE* fd = 0;
- uint32 value = 0;
- SCI_TRACE_LOW("MMIMMS_AddImage in");
- if ((p_cur_doc->totalsize + Image->size) > MMS_SIZE_OF_MESSAGE)
- {
- SCI_TRACE_LOW("p_cur_doc->totalsize = %d,Image->size = %d",p_cur_doc->totalsize,Image->size);
- SCI_TRACE_LOW("MMIMMS_AddImage:total size is too big");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_MMS_TOO_BIG,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;// xuelianb modify[2005-11-08]
- }
- value = MMI_GetFfsTime();
- sprintf(img_fname,"%lu",value);
- if( 0 == strcmp(Image->Type, COMPOSER_IMAGE_GIF) )
- {
- type = MMS_TYPE_GIF;
- strcat(img_fname,".gif");
- }
- else if( 0 == strcmp(Image->Type, COMPOSER_IMAGE_JPEG) )
- {
- type = MMS_TYPE_JPEG;
- strcat(img_fname,".jpg");
- }
- else if( 0 == strcmp(Image->Type, COMPOSER_IMAGE_PNG) )
- {
- type = MMS_TYPE_PNG;
- strcat(img_fname,".png");
- }
- else if( 0 == strcmp(Image->Type, COMPOSER_IMAGE_WBMP) )
- {
- type = MMS_TYPE_WBMP;
- strcat(img_fname,".wbmp");
- }
- else if (0 == strcmp(Image->Type, COMPOSER_IMAGE_BMP))
- {
- type = MMS_TYPE_BMP1;
- strcat(img_fname,".bmp");
- }
- else
- {
- SCI_TRACE_LOW("error:unknown type:type = %s",Image->Type) ;
- }
- fd =(SCI_FILE*) mmsf_Open((char*)img_fname,"w");
- if (!fd )
- {
- SCI_TRACE_LOW("open the file error");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_ADD_FAIL,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- mmsf_Write((char *)Image->ImgBuf, 1, Image->size,(FILE_HANDLE) fd);
- mmsf_Close((FILE_HANDLE)fd);
- if (MMS_New_Content((unsigned char*)img_fname,type,p_cur_doc->slide_cur,p_cur_doc))
- {
- return 0;
- }
- else
- {
- SCI_TRACE_LOW("error:add new content failed");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_ADD_FAIL,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_AddAudio
- * Purpose:在当前页添加音乐
- * Input: T_Composer_Audio: 音乐结构
- pMMS_EDocument: 编辑文档
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_AddAudio(T_Composer_Audio*Audio,pMMS_EDocument p_cur_doc)
- {
- int16 type = 0;
- char audio_fname[MMS_FILE_NAME_LENGTH] = {0};
- SCI_FILE* fd = 0;
- uint32 value = 0;
- SCI_TRACE_LOW("MMIMMS_AddAudio in");
- if ((p_cur_doc->totalsize + Audio->size) > MMS_SIZE_OF_MESSAGE)
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_MMS_TOO_BIG,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- value = MMI_GetFfsTime();
- sprintf(audio_fname,"%lu",value);
- SCI_TRACE_LOW("FNH audio_fname = %s",audio_fname);
- if( 0 == strcmp(Audio->Type, COMPOSER_AUDIO_WAV) )
- {
- type = MMS_TYPE_WAV;
- strcat(audio_fname,".wav");
- SCI_TRACE_LOW("FNH type = %d",type);
- }
- else if( 0 == strcmp(Audio->Type, COMPOSER_AUDIO_IMELODY) )
- {
- type = MMS_TYPE_IMY;
- strcat(audio_fname,".imy");
- SCI_TRACE_LOW("FNH type = %d",type);
- }
- else if( 0 == strcmp(Audio->Type, COMPOSER_AUDIO_MIDI) )
- {
- type = MMS_TYPE_MIDI;
- strcat(audio_fname,".midi");
- SCI_TRACE_LOW("FNH type = %d",type);
- }
- #ifdef HAVE_AMR
- else if( 0 == strcmp(Audio->Type, COMPOSER_AUDIO_AMR) )
- {
- type = MMS_TYPE_AMR;
- strcat(audio_fname,".amr");
- SCI_TRACE_LOW("FNH type = %d",type);
- }
- #endif
- #ifdef HAVE_MP3
- else if( 0 == strcmp(Audio->Type, COMPOSER_AUDIO_MP3) )
- {
- type = MMS_TYPE_MP3;
- strcat(audio_fname,".mp3");
- SCI_TRACE_LOW("FNH type = %d",type);
- }
- #endif
- else
- {
- SCI_TRACE_LOW("error:unknown type %d",type) ;
- }
- fd =(SCI_FILE*) mmsf_Open((char*)audio_fname,"w");
- SCI_TRACE_LOW("FNH open file is success!");
- if (!fd )
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_ADD_FAIL,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- SCI_TRACE_LOW("open the file error");
- return -1;
- }
- mmsf_Write((char *)Audio->AudBuf, 1, Audio->size,(FILE_HANDLE) fd);
- SCI_TRACE_LOW("FNH write file is success!");
- mmsf_Close((FILE_HANDLE)fd);
- SCI_TRACE_LOW("FNH close file is success!");
- SCI_TRACE_LOW("FNH editdoc = %d",p_cur_doc);
- SCI_TRACE_LOW("fnh slide = %d",p_cur_doc->slide_cur);
- if (MMS_New_Audio((unsigned char*)audio_fname,type,p_cur_doc->slide_cur,p_cur_doc) == 0)
- {
- SCI_TRACE_LOW("FNH NEW AUDIO IS SUCCESS,g_peditdoc->slide_cur->audio_type = %d",p_cur_doc->slide_cur->audio_type);
- return 0;
- }
- else
- {
- SCI_TRACE_LOW("FNH NEW AUDIO IS FAIL");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_ADD_FAIL,
- IMAGE_PROMPT_ICON_WRONG,
- ALERT_TIMEOUT,
- PNULL
- );
- return -1;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetCurSlideVideo
- * Purpose:得到当前页的视频信息
- * Input: T_Composer_Video: 视频结构
- pMMS_EDocument: 编辑文档
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_GetCurSlideVideo(T_Composer_Video*Video,pMMS_EDocument p_edoc)
- {
- #ifdef HAVE_MPEG4
- uint32 len = 0,size=0;
- pMMS_Content content = NULL;
- pMMS_EDocument p_curedoc;
- SCI_TRACE_LOW("MMIMMS_GetCurSlideVideo in");
- p_curedoc = p_edoc;
- content = p_curedoc->slide_cur->content_root;
- if(p_curedoc->slide_cur->video_flag != 1)
- {
- SCI_TRACE_LOW("there is not any image in the slide");
- return -1;
- }
- for(;content;content = content->next)
- {
- if(content->type == MMS_TYPE_MP4 || content->type == MMS_TYPE_3GP )
- break;
- }
- if(content == NULL)
- {
- SCI_TRACE_LOW("there is not any Video in the slide,Video flag error");
- return -1;
- }
- if(content->type == MMS_TYPE_MP4)
- {
- SCI_TRACE_LOW("FNH enter MP4");
- size=content->contentsize;
- len = content->contentsize;
- Video->Type=MPEG4_MP4_FILE;
- }
- else if(content->type == MMS_TYPE_3GP)
- {
- SCI_TRACE_LOW("FNH enter 3GP");
- Video->Type=MPEG4_3GP_FILE;
- size = content->contentsize;
- len = content->contentsize;
- }
- else
- {
- SCI_TRACE_LOW("unknown video type:%d",content->type);
- }
- mmsf_GetConstFileData(content->filename,(char **)&Video->VidBuf,(int *)&Video->size );
- if(Video->VidBuf == NULL)
- {
- SCI_TRACE_LOW("malloc failed:size = %d",len);
- return -1;
- }
- #endif
- SCI_TRACE_LOW("MMIMMS_GetCurSlideVideo out");
- return 0;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetCurSlideImage
- * Purpose:得到当前页的图像信息
- * Input: T_Composer_Image: 图片结构
- pMMS_EDocument: 编辑文档
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_GetCurSlideImage(T_Composer_Image*Image,pMMS_EDocument p_edoc)
- {
- uint32 len = 0,size=0;
- pMMS_Content content = NULL;
- pMMS_EDocument p_curedoc;
- SCI_TRACE_LOW("MMIMMS_GetCurSlideImage in");
- p_curedoc = p_edoc;
- content = p_curedoc->slide_cur->content_root;
- if(p_curedoc->slide_cur->image_flag != 1)
- {
- SCI_TRACE_LOW("there is not any image in the slide");
- return -1;
- }
- for(;content;content = content->next)
- {
- if(CmsIsSupportType(content->type))
- break;
- }
- if(content == NULL)
- {
- SCI_TRACE_LOW("there is not any image in the slide,image flag error");
- return -1;
- }
- if(content->type == MMS_TYPE_GIF)
- {
- size=content->contentsize;
- len = content->contentsize+8;
- Image->Type="image/gif";
- }
- else if(content->type == MMS_TYPE_WBMP)
- {
- Image->Type="image/vnd.wap.wbmp";
- size = content->contentsize;
- len = content->contentsize;
- }
- else if(content->type == MMS_TYPE_JPEG)
- {
- Image->Type="image/jpeg";
- size = content->contentsize;
- len = content->contentsize;
- }
- else if (content->type == MMS_TYPE_BMP1)
- {
- Image->Type = "image/bmp";
- size = content->contentsize;
- len = content->contentsize;
- }
- else if(content->type == MMS_TYPE_PNG)
- {
- Image->Type="image/png";
- size = content->contentsize;
- len = content->contentsize;
- }
- else
- {
- SCI_TRACE_LOW("unknown image type:%d",content->type);
- }
- mmsf_GetConstFileData(content->filename,(char **)&Image->ImgBuf,(int *)&Image->size);
- if(Image->ImgBuf == NULL)
- {
- SCI_TRACE_LOW("malloc failed:size = %d",len);
- return -1;
- }
- SCI_TRACE_LOW("MMIMMS_GetCurSlideImage out");
- return 0;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetCurText
- * Purpose:得到当前页的文本信息
- * Input: pMMS_EDocument:编辑文档
- T_Composer_Text:文本结构
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_GetCurText(T_Composer_Text*Text,pMMS_EDocument p_cur_doc)
- {
- uint32 len = 0;
- uint8* str = NULL;
- pMMS_Content content = NULL;
- SCI_TRACE_LOW("MMIMMS_GetCurText in");
- if(p_cur_doc->slide_cur->text_flag != 1)
- {
- SCI_TRACE_LOW("error:there is not any text in the slide");
- return -1;
- }
- content = p_cur_doc->slide_cur->content_root;
- for(;content;content = content->next)
- {
- if(content->type == MMS_TYPE_TEXT)
- break;
- }
- if(content == NULL)
- {
- SCI_TRACE_LOW("error:there is not any text in the slide,text flag error");
- return -1;
- }
- mmsf_GetConstFileData(content->filename,(char **)&str,(int *)&len);
- SCI_TRACE_BUF("FNH GET TEXT str = %x",str,10);
- Text->size = CmsGetUnicodeLen((unsigned char *)str);
- SCI_TRACE_LOW("FNH GET TEXT LEN= %d",Text->size);
- Text->TxtBuf = (T_UBYTE* )str+2;
- SCI_TRACE_LOW("MMIMMS_GetCurText out");
- return 0;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetCurSlideAudio
- * Purpose:得到当前页的音乐信息
- * Input: T_Composer_Audio: 音乐结构
- pMMS_EDocument: 编辑文档
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_GetCurSlideAudio(T_Composer_Audio *audio,pMMS_EDocument pedoc)
- {
- pMMS_EDocument pedoctemp;
- pedoctemp = pedoc;
- SCI_TRACE_LOW("FNH in GetCurAudio pedoctemp->slide_cur->audiofile = %s",pedoctemp->slide_cur->audiofile);
- mmsf_GetConstFileData(pedoctemp->slide_cur->audiofile,(char **)&audio->AudBuf,(int *)&audio->size);
- switch(pedoctemp->slide_cur->audio_type)
- {
- case MMS_TYPE_WAV:
- audio->Type = "audio/wav";
- SCI_TRACE_LOW("FNH type is audio/wav");
- break;
- #ifdef HAVE_AMR
- case MMS_TYPE_AMR:
- audio->Type = "audio/amr";
- SCI_TRACE_LOW("FNH type is audio/amr");
- break;
- #endif
- case MMS_TYPE_MIDI:
- audio->Type="audio/midi";
- SCI_TRACE_LOW("FNH type is audio/midi");
- break;
- #ifdef HAVE_MP3
- case MMS_TYPE_MP3:
- audio->Type = "audio/mp3";
- SCI_TRACE_LOW("FNH type is audio/mp3");
- break;
- #endif
- default:
- SCI_TRACE_LOW("unknown type:%d",pedoctemp->slide_cur->audio_type);
- break;
- }
- return 0;
- }
- /******************************************************************************
- * 函数定义: MMIMMS_Get_Cur_Second
- * 函数说明: 得到当前的秒数
- * 参数说明: 无
- * 返回值: 当前的秒数
- ********************************************************************************/
- long MMIMMS_Get_Cur_Second()
- {
- long cursecond = 0;
- SCI_DATE_T curdate;
- SCI_TIME_T curtime ;
- TM_GetSysDate(&curdate);
- SCI_TRACE_LOW("FNH %d,%d,%d",curdate.year,curdate.mon,curdate.mday);
- TM_GetSysTime(&curtime);
- SCI_TRACE_LOW("FNH %d,%d,%d",curtime.hour,curtime.min,curtime.sec);
- cursecond = MMI_Tm2Second(curtime.sec,curtime.min,curtime.hour,curdate.mday,curdate.mon,curdate.year );
- SCI_TRACE_LOW("FNH cursecond = %ld",cursecond);
- cursecond = cursecond + (365*23 +366*7)*24*3600;
- SCI_TRACE_LOW("FNH cursecond = %ld",cursecond);
- return cursecond;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Receive_MMS
- * Purpose:彩信网络回调函数
- * Input: status: 网络返回状态
- prompt: 返回参数
- status_value:当前网络状态
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- int mms_lib_callback(int status,void *prompt,int status_value)
- {
- SCI_TRACE_LOW("mms_lib_callback COME IN");
- SCI_TRACE_LOW("mms_lib_callback wap_mms_init is %d",wap_mms_init);
- if(wap_mms_init == MMICMSWAP_BROWSER)
- {
- SCI_TRACE_LOW("it is not my status");
- return 0;
- }//xuelianb add [2006-01-11]
- switch(status)
- {
- case LIB_STATUS_NORMAL_STATUS:
- //可以在此处在状态栏上显示当前状况,如正在连接网关,正在发送数据,正在接收数据等
- //是正常处理过程中的状态显示。
- {
- switch(status_value)
- {
- case MMSNETLINKING:
- //g_netusing = MMS_MSG_NETUSING_STEP2;
- SCI_TRACE_LOW("mms_lib_callback the g_netusing is %d",g_netusing);
- if(g_issendingreadrpt == FALSE)
- {
- //g_progresscurrentsize = 3*(g_progressneedsize/20);
- // MMIMMS_DisplaySendRecvProgress(g_progresscurrentsize,g_progressneedsize);
- }
- SCI_TRACE_LOW("mms_lib_callback:%sn","connecting");
- break;
- case MMSNETLINK_SUCCESS:
- if(g_issendingreadrpt == FALSE)
- {
- g_progresscurrentsize = 3*(g_progressneedsize/10);
- SCI_TRACE_LOW("fnh MMSNETLINK_SUCCESS iFClose = %d",iFClose);
- if (iFClose == 0) //fnh add 0324 for MS00041490
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progresscurrentsize,g_progressneedsize);
- }
- }
- SCI_TRACE_LOW("mms_lib_callback:%sn","mms connect success");
- break;
- case WAPCONNECT_SUCCESS:
- SCI_TRACE_LOW("mms_lib_callback:%sn","wap connect success");
- break;
- case MMS_RECEIVING:
- if(g_issendingreadrpt == FALSE)
- {
- g_progresscurrentsize = (g_progressneedsize/2);
- SCI_TRACE_LOW("fnh MSG_RECEIVING iFClose = %d",iFClose);
- if (iFClose == 0)
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progresscurrentsize,g_progressneedsize);
- }
- }
- SCI_TRACE_LOW("mms_lib_callback:%sn","recving mms");
- break;
- case MMS_SENDING:
- if(g_issendingreadrpt == FALSE)
- {
- g_progresscurrentsize = (g_progressneedsize/2);
- SCI_TRACE_LOW("fnh MMS_SENDING iFClose = %d",iFClose);
- if (iFClose == 0)
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progresscurrentsize,g_progressneedsize);
- }
- }
- SCI_TRACE_LOW("mms_lib_callback:%sn","sending mms");
- break;
- default:
- SCI_TRACE_LOW("mms_lib_callback:%sn","LIB_STATUS_NORMAL_STATUS default.");
- break;
- }
- }
- break;
- case LIB_STATUS_SENDRETURN:
- {
- switch(status_value)
- {
- case MMS_RESPONSE_STATUS_VALUE_OK:
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- SCI_TRACE_LOW("mms_lib_callback:send success!");//除此条外,下列各种情况均属发送失败
- if(g_issendingreadrpt == FALSE)
- {
- SCI_TRACE_LOW("fnh MMS_RESPONSE_STATUS_VALUE_OK iFClose = %d",iFClose);
- if (iFClose == 0)
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progressneedsize,g_progressneedsize);
- }
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SEND_OK, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SEND_OK, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_UNSPECIFIED:
- SCI_TRACE_LOW("mms_lib_callback:unknown error");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_SERVICE_DENIED:
- SCI_TRACE_LOW("mms_lib_callback:service denied");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_FORMAT_CORRUPT:
- SCI_TRACE_LOW("mms_lib_callback:message format corrupt!");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_ADDRESS_UNRESOLVED:
- SCI_TRACE_LOW("mms_lib_callback:address error");//这条比较管用,当用户输错了地址时,会收到这个消息
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_MESSAGE_NOT_FOUND:
- SCI_TRACE_LOW("mms_lib_callback:message not found");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_NETWORK_PROBLEM:
- SCI_TRACE_LOW("mms_lib_callback:server busy");//虽字面是网络问题,但这个是在服务器过忙的情况下的状态
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_NOT_ACCEPTED:
- SCI_TRACE_LOW("mms_lib_callback:message not accepted");//由于消息的大小,媒体类型,或考贝权等原因
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_UNSUPORTED_MESSAGE:
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- SCI_TRACE_LOW("mms_lib_callback:unsuported message");
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- case MMS_RESPONSE_STATUS_VALUE_E_UNKNOW_ERROR:
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- SCI_TRACE_LOW("mms_lib_callback:send failed,unknow error");
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- g_issendingreadrpt = FALSE;
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- //发送时gprs网络拨号失败同样返回发送失败
- case MMSNETLINK_FAILED:
- SCI_TRACE_LOW("mms_lib_callback:dial failed");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- if(g_issendingreadrpt== FALSE)
- {
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }else
- {
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID, MSG_MMS_SENDED_FAILED, PNULL, 0);
- }
- break;
- //发送时用户取消发送则返回发送取消
- case MMSOPR_CANCEL:
- SCI_TRACE_LOW("mms_lib_callback:user cancel");
- MMK_PostMsg(MMIMMS_SEND_MMS_WAITING_WIN_ID, MSG_MMS_SEND_CANCEL, PNULL, 0);
- break;
- default:
- SCI_TRACE_LOW("mms_lib_callback:%sn","LIB_STATUS_SENDRETURN default.");
- break;
- }
- }
- break;
- case LIB_STATUS_RECVRETURN:
- {
- SCI_TRACE_LOW("FNH LIB_STATUS_RECVRETURN status_value = %d",status_value);
- switch(status_value)
- {
- case MMSRECV_SUCCESS:
- SCI_TRACE_LOW("mms_lib_callback:recv success");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- SCI_TRACE_LOW("fnh MMSRECV_SUCCESS iFClose = %d",iFClose);
- if (iFClose == 0)
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progressneedsize,g_progressneedsize);
- }
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_OK, PNULL, 0);
- break;
- case MMSRECV_FAILED:
- SCI_TRACE_LOW("mms_lib_callback:recv failed");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
- break;
- case MMSOPR_CANCEL:
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_CANCEL, PNULL, 0);
- SCI_TRACE_LOW("mms_lib_callback:recv cancel");
- break;
- case MMSNETLINK_FAILED:
- SCI_TRACE_LOW("mms_lib_callback:gprs netlink failed");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
- break;
- case MMSRECV_FAILED_BY_NOT_FOUND:
- SCI_TRACE_LOW("mms_lib_callback:recv failed, message not found");//常是由于一条MMS已过期而接收失败
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_INVALIDPERIOD, PNULL, 0);
- break;
- default:
- {
- SCI_TRACE_LOW("mms_lib_callback:%sn","LIB_STATUS_RECVRETURN default.");
- }
- break;
- }
- }
- break;
- case LIB_STATUS_SENDED_BYTES:
- if(g_issendingreadrpt == FALSE)
- {
- g_progresscurrentsize = (status_value+g_progressneedsize)/2;
- SCI_TRACE_LOW("fnh LIB_STATUS_SENDED_BYTES iFClose = %d",iFClose);
- if (iFClose == 0)
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progresscurrentsize,g_progressneedsize);
- }
- }
- break;
- case LIB_STATUS_RECVED_BYTES:
- g_progresscurrentsize = (status_value+g_progressneedsize)/2;
- SCI_TRACE_LOW("fnh LIB_STATUS_RECVED_BYTES iFClose = %d",iFClose);
- if (iFClose == 0)
- {
- SCI_TRACE_LOW("fnh before display progress");
- MMIMMS_DisplaySendRecvProgress(g_progresscurrentsize,g_progressneedsize);
- }
- break;
- default:
- SCI_TRACE_LOW("mms_lib_callback:%sn","all default.");
- break;
- }
- return 1;
- }
- /******************************************************************************
- * 函数定义: GetReceiverListLen
- * 函数说明: 得到收件人列表中的所有条目长度总和,其中还包括每两个条目之间的
- 间隔符所占长度。
- * 参数说明: p_receiver: 收件人列表
- * 返回值: 计算出的收件人长度之和
- ********************************************************************************/
- int GetReceiverListLen(p_MMS_RECEPIENT p_receiver)
- {
- p_MMS_RECEPIENT plist = NULL;
- int len = 0;
- plist = p_receiver;
- while(plist)
- {
- len += SCI_STRLEN((char *)plist->m_address)+1;
- plist = plist->p_next;
- }
- return len;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveMmsMessage
- * Purpose: 保存彩信到当前的信箱
- * Input: folder_id:信箱ID号,从1到5分别为:收件箱、发件箱、已发信箱、草稿箱、
- 当前信箱(可能不需要,暂时加上)
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void SaveMmsMessage(SAVE_MMS_STATUS folder_id, char *filename)
- {
- P_MMS_DOCUMENT pMms_Doc = NULL;
- char fname[MMS_FILE_NAME_LEN];
- uint8 *phone_list = NULL;
- int phone_list_len = 0;
- uint32 value ;
- pMessageFolder folder = NULL;
- long expire = 0;
- if(folder_id == SAVE_MMS_TO_INBOX)
- {
- folder = g_pManager->inboxfolder;
- }
- else if(folder_id == SAVE_MMS_TO_OUTBOX)
- {
- folder = g_pManager->outboxfolder;
- }
- else if(folder_id == SAVE_MMS_TO_SENTBOX)
- {
- folder = g_pManager->sentfolder;
- }
- else if(folder_id == SAVE_MMS_TO_DRAFTBOX)
- {
- folder = g_pManager->draftfolder;
- }
- else if(folder_id == SAVE_MMS_TO_DEFAULT)
- {
- folder = g_pManager->currentfolder;
- }
- else
- {
- SCI_TRACE_LOW("error:wrong folder id");
- return;
- }
- value = MMI_GetFfsTime();
- SCI_TRACE_LOW("FNH MMI_GetFfsTime = %u",MMI_GetFfsTime());
- SCI_TRACE_LOW("FNH value = %u",value);
- sprintf(fname,"%lu",value);
- strcat(fname, ".mms");
- SCI_TRACE_LOW("FNH fname = %s",fname);
- if(filename != NULL)
- {
- SCI_MEMSET(filename,0,sizeof(filename));
- SCI_STRCPY(filename,fname);
- }
- SCI_TRACE_LOW("FNH start of send message");
- pMms_Doc = (P_MMS_DOCUMENT)cms_integrate_mms(g_peditdoc);
- SCI_TRACE_LOW("fnh pMMS_Doc = %d",pMms_Doc);
- SCI_TRACE_LOW("FNH after cms_integrate_mms");
- if(!MMS_SetMmsFile(pMms_Doc,fname))
- {
- SCI_TRACE_LOW("FNH error:MMS_SetMmsFile failed");
- if (pMms_Doc)
- {
- MMS_DeleteMms(pMms_Doc);
- pMms_Doc = NULL;
- }
- return;
- }
- SCI_TRACE_LOW("FNH before insert to");
- if ((g_p_mms_to) || (g_p_mms_to_group))//插入电话号码
- {
- p_MMS_RECEPIENT plist = NULL;
- char *phone_list = NULL;
- uint16 single_tele_len = 0;
- uint16 group_tele_len = 0;
- SCI_TRACE_LOW("FNH enter g_p_mms_to");
- if (g_p_mms_to)
- {
- single_tele_len = GetReceiverListLen(g_p_mms_to);
- SCI_TRACE_LOW("FNH g_p_mms_to len = %d",single_tele_len);
- }
- if (g_p_mms_to_group)
- {
- if (g_p_mms_to_group->cur_group)
- {
- group_tele_len = GetReceiverListLen(g_p_mms_to_group->cur_group);
- }
- }
- phone_list_len = single_tele_len+group_tele_len+1;
- phone_list = (char *)cms_malloc(phone_list_len);
- if(!phone_list)
- {
- SCI_TRACE_LOW("malloc failed:phone list len = %d",phone_list_len);
- return;
- }
- SCI_MEMSET(phone_list,0,phone_list_len);
- if (g_p_mms_to)
- {
- plist = g_p_mms_to;
- while(plist->p_next)
- {
- strcat((char *)phone_list,(const char *)(plist->m_address));
- strcat((char *)phone_list,",");
- plist = plist->p_next;
- }
- strcat((char *)phone_list,(const char *)(plist->m_address)); // xuelianb modify[2005-11-08]
- }
- plist = NULL;
- if (g_p_mms_to_group)
- {
- if (g_p_mms_to_group->cur_group)
- {
- plist = g_p_mms_to_group->cur_group;
- if (g_p_mms_to)
- {
- strcat((char *)phone_list,",");
- }
- while(plist->p_next)
- {
- strcat((char *)phone_list,(const char *)(plist->m_address));
- strcat((char *)phone_list,",");
- plist = plist->p_next;
- }
- strcat((char *)phone_list,(const char *)(plist->m_address)); // xuelianb modify[2005-11-08]
- }
- }
- // SCI_TRACE_LOW("FNH to phone_list = %s",phone_list);
- MMS_SetMmsHeadField(pMms_Doc, MMS_TO, (long)0, (char *)phone_list);
- if (phone_list)
- {
- cms_free(phone_list);
- phone_list = NULL;
- }
- SCI_TRACE_LOW("FNH set to ok");
- }
- if ((g_p_mms_cc) ||(g_p_mms_cc_group))
- {
- p_MMS_RECEPIENT plist = NULL;
- char *phone_list = NULL;
- uint16 single_tele_len = 0;
- uint16 group_tele_len = 0;
- SCI_TRACE_LOW("FNH enter g_p_mms_cc");
- if (g_p_mms_cc)
- {
- single_tele_len = GetReceiverListLen(g_p_mms_cc);
- SCI_TRACE_LOW("FNH g_p_mms_cc len = %d",single_tele_len);
- }
- if (g_p_mms_cc_group)
- {
- if (g_p_mms_cc_group->cur_group)
- {
- group_tele_len = GetReceiverListLen(g_p_mms_cc_group->cur_group);
- }
- }
- phone_list_len = single_tele_len+group_tele_len+1;
- phone_list = (char *)cms_malloc(phone_list_len);
- if(!phone_list)
- {
- SCI_TRACE_LOW("malloc failed:phone list len = %d",phone_list_len);
- return;
- }
- SCI_MEMSET(phone_list,0,phone_list_len);
- if (g_p_mms_cc)
- {
- plist = g_p_mms_cc;
- while(plist->p_next)
- {
- strcat((char *)phone_list,(const char *)(plist->m_address));
- strcat((char *)phone_list,",");
- plist = plist->p_next;
- }
- strcat((char *)phone_list,(const char *)(plist->m_address)); // xuelianb modify[2005-11-08]
- }
- plist = NULL;
- if (g_p_mms_cc_group)
- {
- if (g_p_mms_cc_group->cur_group)
- {
- plist = g_p_mms_cc_group->cur_group;
- if (g_p_mms_cc)
- {
- strcat((char *)phone_list,",");
- }
- while(plist->p_next)
- {
- strcat((char *)phone_list,(const char *)(plist->m_address));
- strcat((char *)phone_list,",");
- plist = plist->p_next;
- }
- strcat((char *)phone_list,(const char *)(plist->m_address)); // xuelianb modify[2005-11-08]
- }
- }
- // SCI_TRACE_LOW("FNH cc phone_list = %s",phone_list);
- MMS_SetMmsHeadField(pMms_Doc, MMS_CC, (long)0, (char *)phone_list);
- if (phone_list)
- {
- cms_free(phone_list);
- phone_list = NULL;
- }
- SCI_TRACE_LOW("FNH set cc ok");
- }
- if ((g_p_mms_bcc) ||(g_p_mms_bcc_group))
- {
- p_MMS_RECEPIENT plist = NULL;
- char *phone_list = NULL;
- uint16 single_tele_len = 0;
- uint16 group_tele_len = 0;
- SCI_TRACE_LOW("FNH enter g_p_mms_bcc");
- if (g_p_mms_bcc)
- {
- single_tele_len = GetReceiverListLen(g_p_mms_bcc);
- SCI_TRACE_LOW("FNH g_p_mms_b len = %d",single_tele_len);
- }
- if (g_p_mms_bcc_group)
- {
- if (g_p_mms_bcc_group->cur_group)
- {
- group_tele_len = GetReceiverListLen(g_p_mms_bcc_group->cur_group);
- }
- }
- phone_list_len = single_tele_len+group_tele_len+1;
- phone_list = (char *)cms_malloc(phone_list_len);
- if(!phone_list)
- {
- SCI_TRACE_LOW("malloc failed:phone list len = %d",phone_list_len);
- return;
- }
- SCI_MEMSET(phone_list,0,phone_list_len);
- if (g_p_mms_bcc)
- {
- plist = g_p_mms_bcc;
- while(plist->p_next)
- {
- strcat((char *)phone_list,(const char *)(plist->m_address));
- strcat((char *)phone_list,",");
- plist = plist->p_next;
- }
- strcat((char *)phone_list,(const char *)(plist->m_address)); // xuelianb modify[2005-11-08]
- }
- plist = NULL;
- if (g_p_mms_bcc_group)
- {
- if (g_p_mms_bcc_group->cur_group)
- {
- plist = g_p_mms_bcc_group->cur_group;
- if (g_p_mms_bcc)
- {
- strcat((char *)phone_list,",");
- }
- while(plist->p_next)
- {
- strcat((char *)phone_list,(const char *)(plist->m_address));
- strcat((char *)phone_list,",");
- plist = plist->p_next;
- }
- strcat((char *)phone_list,(const char *)(plist->m_address)); // xuelianb modify[2005-11-08]
- }
- }
- // SCI_TRACE_LOW("FNH bcc phone_list = %s",phone_list);
- MMS_SetMmsHeadField(pMms_Doc, MMS_BCC, (long)0, (char *)phone_list);
- if (phone_list)
- {
- cms_free(phone_list);
- phone_list = NULL;
- }
- SCI_TRACE_LOW("FNH set bcc ok");
- }
- MMS_SetMmsHeadField(pMms_Doc, MMS_MESSAGE_CLASS, (long)MMS_MESSAGE_CLASS_TYPE_PERSONAL, (char *)0);
- SCI_TRACE_BUF("FNH before sendmmshead g_p_mms_subject = %x",g_p_mms_subject,10);
- MMS_SetMmsHeadField(pMms_Doc, MMS_SUBJECT, (long)0, (char*)g_p_mms_subject);//设置主题
- if (g_nv_setting_mirror.anonymous == MMS_MSG_SETTINGS_ON)//匿名发送
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_SENDER_VISIBILITY,(long)MMS_SENDER_VISIBILITY_HIDE, (char *)0);
- }
- else
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_SENDER_VISIBILITY,(long)MMS_SENDER_VISIBILITY_SHOW, (char *)0);
- }
- if (g_nv_setting_mirror.prior == MMS_MSG_SETTINGS_PRIORITY_LOW)
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_PRIORITY, (long)MMS_PRIORITY_VALUE_LOW, (char *)0);
- }
- else if (g_nv_setting_mirror.prior == MMS_MSG_SETTINGS_PRIORITY_NORMAL)
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_PRIORITY, (long)MMS_PRIORITY_VALUE_NORMAL, (char *)0);
- }
- else
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_PRIORITY, (long)MMS_PRIORITY_VALUE_HIGH, (char *)0);
- }
- if (g_nv_setting_mirror.delivery_rpt == MMS_MSG_SETTINGS_ON)
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_DELIVERY_REPORT, (long)MMS_DELIVERY_REPORT_YES, (char *)0);
- }
- else
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_DELIVERY_REPORT, (long)MMS_DELIVERY_REPORT_NO, (char *)0);
- }
- SCI_TRACE_LOW("SEND MMS SET READRPT IS %d",g_nv_setting_mirror.read_rpt);
- if (g_nv_setting_mirror.read_rpt== MMS_MSG_SETTINGS_ON)
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_READ_REPORT, (long)MMS_READ_REPORT_YES, (char *)0);
- }
- else
- {
- MMS_SetMmsHeadField(pMms_Doc, MMS_READ_REPORT, (long)MMS_READ_REPORT_NO, (char *)0);
- }//modify liangliu 2005-12-28 for readrpt.
- if (g_nv_setting_mirror.valid_period == MMS_MSG_VALID_PERIOD_12_HOUR)
- {
- // expire = MMIMMS_Get_Cur_Second();
- // SCI_TRACE_LOW("FNH expire = %ld",expire);
- expire = 0;
- expire = expire + (3600 * 12);// - 8*3600;
- SCI_TRACE_LOW("FNH expire = %ld",expire);
- MMS_SetMmsHeadField(pMms_Doc, MMS_EXPIRY, (long)expire, (char *)0);
- }
- else if (g_nv_setting_mirror.valid_period == MMS_MSG_VALID_PERIOD_1_DAY)
- {
- // expire = MMIMMS_Get_Cur_Second();
- // SCI_TRACE_LOW("FNH expire = %ld",expire);
- expire = 0;
- expire = expire + (3600 * 24) ;//- 8*3600;
- SCI_TRACE_LOW("FNH expire = %ld",expire);
- MMS_SetMmsHeadField(pMms_Doc, MMS_EXPIRY, (long)expire, (char *)0);
- }
- else if (g_nv_setting_mirror.valid_period == MMS_MSG_VALID_PERIOD_1_WEEK)
- {
- // expire = MMIMMS_Get_Cur_Second();
- // SCI_TRACE_LOW("FNH expire = %ld",expire);
- expire = 0;
- expire = expire + (3600 * 24*7);// - 8*3600;
- SCI_TRACE_LOW("FNH expire = %ld",expire);
- MMS_SetMmsHeadField(pMms_Doc, MMS_EXPIRY, (long)expire, (char *)0);
- }
- if (g_set_date.year != 0)
- {
- long cursecond = 0;
- cursecond = MMI_Tm2Second(0,g_set_date.minute,g_set_date.hour,g_set_date.day,g_set_date.month,g_set_date.year);
- SCI_TRACE_LOW("FNH set date cursecond = %ld",cursecond); //这时得到的秒数是从2000年开始的
- cursecond = cursecond + (365*23 +366*7)*24*3600 - 8*3600; //标准时间应该是从1970年开始计算,并且要减去东八区的差额秒数
- SCI_TRACE_LOW("FNH set date cursecond = %ld",cursecond);
- MMS_SetMmsHeadField(pMms_Doc,MMS_DELIVERY_TIME,(long)cursecond,(char *)0);
- SCI_MEMSET(&g_set_date,0,sizeof(MMS_SEND_ONTIME_TIME));
- }
- //end of set head field
- SCI_TRACE_LOW("FNH start of MMS_EncodeMms");
- if(!MMS_EncodeMms(pMms_Doc))
- {
- SCI_TRACE_LOW("FNH error:MMS_EncodeMms failed");
- if (pMms_Doc)
- {
- MMS_DeleteMms(pMms_Doc);
- pMms_Doc = NULL;
- }
- if (phone_list)
- {
- mms_Free(phone_list);
- phone_list = NULL;
- }
- mmsf_Remove(fname);
- return ;
- }
- //added by liangliu 2005-11-5 for sendbox
- {
- MMSHANDLE mmsdoc=0;
- pMessageList mlist =PNULL;
- /* first: get new mms document */
- mmsdoc = (MMSHANDLE)pMms_Doc;
- if(mmsdoc==0)
- {
- SCI_TRACE_LOW("error:mmsdoc==0");
- return ;
- }
- mlist = MMIMMS_GetMMSMessage(mmsdoc,1);
- SCI_TRACE_LOW("FNH g_peditdoc->totalsize = %d",g_peditdoc->totalsize);
- mlist->size = g_peditdoc->totalsize;
- g_progressneedsize =g_peditdoc->totalsize;
- SCI_TRACE_LOW("FNH mlist->size = %d",mlist->size);
- MMIMMS_AddManagerList(folder,mlist);
- if(folder_id ==SAVE_MMS_TO_DRAFTBOX)
- {
- MMIMMS_CreateSaveMMSWaitingWin();
- g_savemmsstate = MMS_MSG_SAVEMMS_FOR_DRAFTSAVE;
- MMIMMS_SaveMMS(g_pManager->draftfolder->currentmessage);
- }
- }
- //added end
- MMS_DeleteMms(pMms_Doc);
- pMms_Doc = NULL; // xuelianb modify[2005-11-09]
- }
- /* ----------------------------------------------------------------------------
- * Function 发送彩信: CmsSendMessage
- * Purpose: 发送彩信
- * Input: 发送状态
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void CmsSendMessage(MMIMMS_SEND_MMS_STATUS sendstate)
- {
- MMS_CONFIG_SETTING cfgset;
- MMS_SEND_SETTING sendset;
- char fname[MMS_FILE_NAME_LEN];
- SCI_TRACE_LOW("FNH IN sendMessage Before GetCurrentTime");
- if (sendstate == SEND_NEW_MMS)
- {
- SaveMmsMessage(SAVE_MMS_TO_OUTBOX,fname);
- }
- else if (sendstate == SEND_OUTBOX_MMS)
- {
- SCI_STRCPY(fname,(char *)g_pManager->currentfolder->currentmessage->filename);
- }
- //开始发送
- MMS_Init();
- cfgset.wap_gateway = (unsigned char *)g_nv_setting_mirror.gateway;
- SCI_TRACE_LOW("FNH cfgset.wap_gateway = %s",cfgset.wap_gateway);
- cfgset.mms_centery = (char *)g_nv_setting_mirror.centre_addr;
- SCI_TRACE_LOW("FNH cfgset.mms_centery = %s",cfgset.mms_centery);
- cfgset.wap_port = atoi((char *)g_nv_setting_mirror.port);
- SCI_TRACE_LOW("FNH cfgset.wap_port = %d",cfgset.wap_port);
- SCI_TRACE_LOW(" FNH Sending..............................");
- if(!MMS_Machine_Config(&cfgset))
- {
- SCI_TRACE_LOW("error:MMS_Machine_Config(&cfgset) failed");
- return;
- }
- sendset.send_vfilename = fname;
- sendset.conf_vfilename = (char*)"confirm.mms";
- if(!MMS_SendMms(&sendset,mms_lib_callback))
- {
- SCI_TRACE_LOW("FNH error:mms send failed");
- return;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetTotalSize
- * Purpose:得到当前编辑彩信的资源大小
- * Input: T_VOID
- * Returns:T_WORD
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- T_WORD MMIMMS_GetTotalSize(T_VOID)
- {
- return g_peditdoc->totalsize;
- }
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerInboxFile
- * 函数说明: 读取当前存储结构的文件
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- void MMIMMS_ReadManagerInboxFile(void)
- {
- FFS_OVERLAPPED_T overlapped;
- // HFS cur_hefs = FFS_INVALID_HANDLE;
- uint32 size = 0;
- uint32 transmitted;
- FFS_READFILE_RESULT_T *param_read_ptr =PNULL;
- SCI_TRACE_LOW("MMIMMS_ReadManagerInboxFile IN -------");
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_INBOXNAME) == TRUE)
- {
- SCI_TRACE_LOW("fnh inbox.txt is exist!");
- inboxfile_openstatus = FILE_Create((const char*)MANAGER_FLASH_INBOXNAME, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
- SCI_TRACE_LOW("fnh inboxfile_openstatus = %d",inboxfile_openstatus);
- if(FFS_INVALID_HANDLE != inboxfile_openstatus)
- {
- FFS_ERROR_E ffs_error = 0;
- size = FFS_GetLength(g_filetype,inboxfile_openstatus);
- if (size == 0)
- {
- SCI_TRACE_LOW("fnh read inbox size is zero!");
- FFS_Close(g_filetype,inboxfile_openstatus);
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerOutboxFile();
- return ;
- }
- param_read_ptr =(FFS_READFILE_RESULT_T *)cms_malloc(sizeof(FFS_READFILE_RESULT_T));
- if (param_read_ptr == PNULL)
- {
- SCI_TRACE_LOW("fnh malloc param_read_ptr fail!");
- FFS_Close(g_filetype,inboxfile_openstatus);
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerOutboxFile();
- return ;
- }
- SCI_MEMSET(param_read_ptr, 0, sizeof(FFS_READFILE_RESULT_T));
- param_read_ptr->hefs = inboxfile_openstatus;//传递的参数
- param_read_ptr->buf_size = size;
- SCI_TRACE_LOW("fnh size is %d",size);
- param_read_ptr->buf_ptr = (uint8*)cms_malloc(param_read_ptr->buf_size);
- if (param_read_ptr->buf_ptr == PNULL)
- {
- SCI_TRACE_LOW("fnh malloc param_read_ptr->buf_ptr fail!");
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- FFS_Close(g_filetype,inboxfile_openstatus);
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerOutboxFile();
- return ;
- }
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
- overlapped.complete_route = MMIVC_CallBackReadManagerInboxFile;
- ffs_error = FFS_Read(g_filetype,inboxfile_openstatus,
- param_read_ptr->buf_ptr,
- param_read_ptr->buf_size,
- &transmitted,
- &overlapped);
- if( ( FFS_ERROR_IO_PENDING != ffs_error )&&(FFS_NO_ERROR != ffs_error))
- {
- SCI_TRACE_LOW("FNH THE inbox FILE READ FAIL!");
- FFS_Close(g_filetype,inboxfile_openstatus);
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- if (param_read_ptr->buf_ptr!= NULL)
- {
- cms_free(param_read_ptr->buf_ptr);
- param_read_ptr->buf_ptr = NULL;
- }
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- MMIMMS_ReadManagerOutboxFile();
- return ;
- }
- }
- else//打开文件失败
- {
- SCI_TRACE_LOW("FNH THE inbox FILE IS failed!");
- MMIMMS_ReadManagerOutboxFile();
- return;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH THE inbox FILE IS not exist!");
- MMIMMS_ReadManagerOutboxFile();
- return;
- }
- }
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerOutboxFile
- * 函数说明: 读取发件箱的文件
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- void MMIMMS_ReadManagerOutboxFile(void)
- {
- FFS_OVERLAPPED_T overlapped;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- uint32 size = 0;
- uint32 transmitted;
- FFS_READFILE_RESULT_T *param_read_ptr =PNULL;
- SCI_TRACE_LOW("MMIMMS_ReadManagerOutboxFile IN -------");
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_OUTBOXNAME) == TRUE)
- {
- cur_hefs = FILE_Create((const char*)MANAGER_FLASH_OUTBOXNAME, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
- if(FFS_INVALID_HANDLE != cur_hefs)
- {
- FFS_ERROR_E ffs_error = 0;
- size = FFS_GetLength(g_filetype,cur_hefs);
- if (size == 0)
- {
- SCI_TRACE_LOW("fnh read outbox size is zero!");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE ;
- MMIMMS_ReadManagerSentboxFile();
- return ;
- }
- param_read_ptr =(FFS_READFILE_RESULT_T *)cms_malloc(sizeof(FFS_READFILE_RESULT_T));
- if (param_read_ptr == NULL)
- {
- SCI_TRACE_LOW("fnh param_read_ptr malloc is fail !");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerSentboxFile();
- return;
- }
- SCI_MEMSET(param_read_ptr, 0, sizeof(FFS_READFILE_RESULT_T));
- param_read_ptr->hefs = cur_hefs;//传递的参数
- param_read_ptr->buf_size = size;
- param_read_ptr->buf_ptr = (uint8*)cms_malloc(param_read_ptr->buf_size);
- if (param_read_ptr->buf_ptr == NULL)
- {
- SCI_TRACE_LOW("FNH param_read_ptr->buf_ptr malloc is fail");
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerSentboxFile();
- return;
- }
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
- overlapped.complete_route = MMIVC_CallBackReadManagerOutboxFile;
- ffs_error = FFS_Read(g_filetype,cur_hefs,
- param_read_ptr->buf_ptr,
- param_read_ptr->buf_size,
- &transmitted,
- &overlapped);
- if( (FFS_ERROR_IO_PENDING != ffs_error ) &&(FFS_NO_ERROR != ffs_error))
- {
- SCI_TRACE_LOW("FNH read outbox file is read error");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- if (param_read_ptr->buf_ptr != NULL)
- {
- cms_free(param_read_ptr->buf_ptr);
- param_read_ptr->buf_ptr = NULL;
- }
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- MMIMMS_ReadManagerSentboxFile();
- return ;
- }
- }
- else//打开文件失败
- {
- SCI_TRACE_LOW("FNH read outbox file is failed");
- MMIMMS_ReadManagerSentboxFile();
- return ;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH read outbox file is not exist");
- MMIMMS_ReadManagerSentboxFile();
- return;
- }
- }
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerSentboxFile
- * 函数说明: 读取已发信箱的文件
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- void MMIMMS_ReadManagerSentboxFile(void)
- {
- FFS_OVERLAPPED_T overlapped;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- uint32 size = 0;
- uint32 transmitted;
- FFS_READFILE_RESULT_T *param_read_ptr =PNULL;
- SCI_TRACE_LOW("MMIMMS_ReadManagerSentboxFile IN -------");
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_SENTBOXNAME) == TRUE)
- {
- cur_hefs = FILE_Create((const char*)MANAGER_FLASH_SENTBOXNAME, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
- if(FFS_INVALID_HANDLE != cur_hefs)
- {
- FFS_ERROR_E ffs_error = 0;
- size = FFS_GetLength(g_filetype,cur_hefs);
- if (size == 0)
- {
- SCI_TRACE_LOW("FNH read sentboxfile size is zero!");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerDraftboxFile();
- return ;
- }
- param_read_ptr = (FFS_READFILE_RESULT_T *)cms_malloc(sizeof(FFS_READFILE_RESULT_T));
- if (param_read_ptr == NULL)
- {
- SCI_TRACE_LOW("fnh param_read_ptr malloc fail");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerDraftboxFile();
- return;
- }
- SCI_MEMSET(param_read_ptr, 0, sizeof(FFS_READFILE_RESULT_T));
- param_read_ptr->hefs = cur_hefs;//传递的参数
- param_read_ptr->buf_size = size;
- param_read_ptr->buf_ptr = (uint8*)cms_malloc(param_read_ptr->buf_size);
- if (param_read_ptr->buf_ptr == NULL)
- {
- SCI_TRACE_LOW("FNH param_read_ptr->buf_ptr malloc fail");
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMIMMS_ReadManagerDraftboxFile();
- return ;
- }
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
- overlapped.complete_route = MMIVC_CallBackReadManagerSentboxFile;
- ffs_error = FFS_Read(g_filetype,cur_hefs,
- param_read_ptr->buf_ptr,
- param_read_ptr->buf_size,
- &transmitted,
- &overlapped);
- if( (FFS_ERROR_IO_PENDING != ffs_error ) &&(FFS_NO_ERROR != ffs_error))
- {
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- if (param_read_ptr->buf_ptr != NULL)
- {
- cms_free(param_read_ptr->buf_ptr);
- param_read_ptr->buf_ptr = NULL;
- }
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- SCI_TRACE_LOW("fnh read sentbox file is empty");
- MMIMMS_ReadManagerDraftboxFile();
- return ;
- }
- }
- else//打开文件失败
- {
- SCI_TRACE_LOW("fnh read sentbox file is failed");
- MMIMMS_ReadManagerDraftboxFile();
- return;
- }
- }
- else
- {
- SCI_TRACE_LOW("fnh read sentbox file is not exist");
- MMIMMS_ReadManagerDraftboxFile();
- return;
- }
- }
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerDraftboxFile
- * 函数说明: 读取草稿箱的文件
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- void MMIMMS_ReadManagerDraftboxFile(void)
- {
- FFS_OVERLAPPED_T overlapped;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- uint32 size = 0;
- uint32 transmitted;
- FFS_READFILE_RESULT_T *param_read_ptr =PNULL;
- SCI_TRACE_LOW("MMIMMS_ReadManagerDraftboxFile IN -------");
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MANAGER_FLASH_DRAFTBOXNAME) == TRUE)
- {
- cur_hefs = FILE_Create((const char*)MANAGER_FLASH_DRAFTBOXNAME, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
- if(FFS_INVALID_HANDLE != cur_hefs)
- {
- FFS_ERROR_E ffs_error = 0;
- size = FFS_GetLength(g_filetype,cur_hefs);
- if (size == 0)
- {
- SCI_TRACE_LOW("fnh read draftboxfile is zero");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILE_READ_OK, PNULL, PNULL);
- return ;
- }
- param_read_ptr = (FFS_READFILE_RESULT_T *)cms_malloc(sizeof(FFS_READFILE_RESULT_T));
- if (param_read_ptr == NULL)
- {
- SCI_TRACE_LOW("fnh param_read_ptr malloc fail");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMK_PostMsg(VIRTUAL_WIN_ID,MSG_MANAGERFILE_READ_OK,PNULL,PNULL);
- return;
- }
- SCI_MEMSET(param_read_ptr, 0, sizeof(FFS_READFILE_RESULT_T));
- param_read_ptr->hefs = cur_hefs;//传递的参数
- param_read_ptr->buf_size = size;
- param_read_ptr->buf_ptr = (uint8*)cms_malloc(param_read_ptr->buf_size);
- if (param_read_ptr->buf_ptr == NULL)
- {
- SCI_TRACE_LOW("fnh param_read_ptr->buf_ptf malloc fail");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- if (param_read_ptr != NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- MMK_PostMsg(VIRTUAL_WIN_ID,MSG_MANAGERFILE_READ_OK,PNULL,PNULL);
- return;
- }
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
- overlapped.complete_route = MMIVC_CallBackReadManagerDraftboxFile;
- ffs_error = FFS_Read(g_filetype,cur_hefs,
- param_read_ptr->buf_ptr,
- param_read_ptr->buf_size,
- &transmitted,
- &overlapped);
- if( ( FFS_ERROR_IO_PENDING != ffs_error )&&(FFS_NO_ERROR != ffs_error))
- {
- SCI_TRACE_LOW("FNH read draftbox is empty");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = NULL;
- if (param_read_ptr->buf_ptr != NULL)
- {
- cms_free(param_read_ptr->buf_ptr);
- param_read_ptr->buf_ptr = NULL;
- }
- if (param_read_ptr!= NULL)
- {
- cms_free(param_read_ptr);
- param_read_ptr = NULL;
- }
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILE_READ_OK, PNULL, PNULL);
- return;
- }
- }
- else//打开文件失败
- {
- SCI_TRACE_LOW("FNH read draftbox is failed");
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILE_READ_OK, PNULL, PNULL);
- return;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH read draftbox is not exist");
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILE_READ_OK, PNULL, PNULL);
- return;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_AddManagerList
- * Purpose:在指定的目录上增加list信息
- * Input: folder 当前操作的文件夹,mlist 增加的信息
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_AddManagerList(pMessageFolder folder, pMessageList mlist)
- {
- if(folder == NULL)
- {
- SCI_TRACE_LOW("MMIMMS_AddManagerList error:folder is NULL");
- return;
- }
- /* temp code start */
- if(folder->messagenumber == 0)
- {
- if(folder->root)
- {
- folder->root = NULL;
- }
- }
- if(folder->root == mlist)
- {
- return;
- }
- mlist->next = folder->root;
- folder->root = mlist;
- /* reset current message in send folder */
- folder->currentmessage = mlist;
- SCI_TRACE_LOW("fnh before messagenumber add");
- folder->messagenumber++;
- }
- /******************************************************************************
- * 函数定义: MMIMMS_AddaautoMMSList
- * 函数说明: 在指定的目录上增加list信息
- * 参数说明:传递进来的结构已经分配了空间。
- * 返回值: 空
- * 代码编写者: liangliu@palmsource.com
- * 代码编写日期: 4/27/2006
- ********************************************************************************/
- void MMIMMS_AddAutodownList(pAutoDownloadMMSList mlist)
- {
- pAutoDownloadMMSList autolist = PNULL;
- if(g_pautoDownloadMMSRoot == PNULL)
- {
- g_pautoDownloadMMSRoot = mlist;
- }else
- {
- autolist = g_pautoDownloadMMSRoot;
- while(autolist->next != PNULL)
- {
- autolist = autolist->next;
- }
- autolist->next = mlist;
- }
- g_num_autodw ++;
- SCI_TRACE_LOW("FNH MMIMMS_AddAutodownList g_num_autodw = %d",g_num_autodw);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_FreeAutodownList
- * Purpose: 释放整个自动签名链表
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_FreeAutodownList(void)
- {
- pAutoDownloadMMSList autolist = PNULL;
- uint16 i =0;
- if(g_pautoDownloadMMSRoot)
- {
- for(autolist = g_pautoDownloadMMSRoot; g_pautoDownloadMMSRoot; )
- {
- g_pautoDownloadMMSRoot = g_pautoDownloadMMSRoot->next;
- cms_free(autolist);
- autolist = PNULL;
- i++;
- }
- g_pautoDownloadMMSRoot = PNULL;
- }
- g_num_autodw = 0;
- SCI_TRACE_LOW("FNH FreeAutodownList i = %d",i);
- SCI_TRACE_LOW("FNH FreeAutodownList g_num_autodw = %d",g_num_autodw);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteAutodownList
- * Purpose: 删除自动签名链表的某一接点
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteAutodownList(void)
- {
- pAutoDownloadMMSList curautolist = PNULL;
- pAutoDownloadMMSList templist = PNULL;
- SCI_TRACE_LOW("FNH IN MMIMMS_DeletAutodownList!");
- SCI_TRACE_LOW("FNH g_pautoDownloadMMSRoot = %d",g_pautoDownloadMMSRoot);
- SCI_TRACE_LOW("FNH g_num_autodw = %d",g_num_autodw);
- if (g_pautoDownloadMMSRoot)
- {
- if ((g_pautoDownloadMMSRoot->autolist->state == 1) || (g_pautoDownloadMMSRoot->autolist->needautodw == 0))
- {
- curautolist = g_pautoDownloadMMSRoot;
- g_pautoDownloadMMSRoot = g_pautoDownloadMMSRoot->next;
- cms_free(curautolist);
- curautolist = PNULL;
- g_num_autodw --;
- SCI_TRACE_LOW("FNH g_num_autodw = %d",g_num_autodw);
- }
- else
- {
- curautolist = g_pautoDownloadMMSRoot;
- templist = curautolist->next;
- while(templist)
- {
- if ((templist->autolist->state == 1) || (templist->autolist->needautodw == 0))
- {
- curautolist->next = templist->next;
- cms_free(templist);
- templist = PNULL;
- g_num_autodw --;
- SCI_TRACE_LOW("FNH g_num_autodw = %d",g_num_autodw);
- break;
- }
- curautolist = templist;
- templist = templist->next;
- }
- }
- }
- SCI_TRACE_LOW("FNH out MMIMMS_DeletAutodownList!");
- }
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerInboxFile
- * 函数说明: 读取收件箱文件的回调处理
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- LOCAL void MMIVC_CallBackReadManagerInboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- )
- {
- FFS_READFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_READFILE_RESULT_T efs_result;
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_READFILE_RESULT_T *)param;
- //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(efs_param_ptr != NULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = NULL;
- }
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILEREAD_INBOX_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
- MMI_TriggerMMITask();
- }
- /******************************************************************************
- * 函数定义: MMIMMS_ReadManagerInboxFile
- * 函数说明: 读取发件箱文件的回调处理
- * 参数说明: 空
- * 返回值: 空
- * 代码编写者: liangliu
- * 代码编写日期: 10/17/2005
- ********************************************************************************/
- LOCAL void MMIVC_CallBackReadManagerOutboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- )
- {
- FFS_READFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_READFILE_RESULT_T efs_result;
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_READFILE_RESULT_T *)param;
- 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(efs_param_ptr != NULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = NULL;
- }
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILEREAD_OUTBOX_OK,&efs_result, sizeof(FFS_READFILE_RESULT_T));
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackReadManagerSentboxFile
- * Purpose: 读取已发信箱的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackReadManagerSentboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- )
- {
- FFS_READFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_READFILE_RESULT_T efs_result;
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_READFILE_RESULT_T *)param;
- 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(efs_param_ptr != NULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = NULL;
- }
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILEREAD_SENTBOX_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIVC_CallBackReadManagerDraftboxFile
- * Purpose: 读取草稿信箱的回调函数
- * Input: FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void MMIVC_CallBackReadManagerDraftboxFile(
- FFS_ERROR_E a,
- FFS_RESULT result,
- FFS_PARAM param
- )
- {
- FFS_READFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_READFILE_RESULT_T efs_result;
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_READFILE_RESULT_T *)param;
- 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(efs_param_ptr != NULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = NULL;
- }
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MANAGERFILEREAD_DRAFTBOX_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_NetLinkFailed
- * Purpose: 网络连接失败的处理
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- PUBLIC void MMIMMS_NetLinkFailed(void)
- {
- if(g_issendingreadrpt == TRUE&&MMK_IsFocusWin(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID))
- {
- MMK_PostMsg(MMIMMS_SEND_MMSREADRPT_WAITING_WIN_ID,MSG_MMS_SENDED_FAILED,PNULL,PNULL);
- }
- else{
- if(MMK_IsFocusWin(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID)||MMK_IsFocusWin(MMIMMS_SEND_MMS_WAITING_WIN_ID))
- {
- if(MMK_IsFocusWin(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID))
- {
- // MMK_CloseWin(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID);
- SCI_TRACE_LOW("FNH NETLINKFAILED");
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID,MSG_MMS_RECV_FAILED,PNULL,PNULL); //fnh modify [2006-07-25]
- }else if(MMK_IsFocusWin(MMIMMS_SEND_MMS_WAITING_WIN_ID))
- {
- MMK_CloseWin(MMIMMS_SEND_MMS_WAITING_WIN_ID);
- }
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_NET_FAILED,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT,
- PNULL
- );
- }
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_HandleReadOK
- * Purpose: 在虚拟窗口的处理函数中调用,处理读文件操作
- * Input: MMI_MESSAGE_ID_E msg_id,
- DPARAM param
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- PUBLIC void MMIMMS_HandleReadOK(MMI_MESSAGE_ID_E msg_id, DPARAM param)
- {
- FILE_HANDLE cmshandle = 0 ;
- FFS_READFILE_RESULT_T * efs_result_ptr;
- FFS_SAVEFILE_RESULT_T * efs_writeresult_ptr;
- switch(msg_id)
- {
- case MSG_MANAGERFILE_READ_OK: //if read ffs file fail, then set it to default value
- SCI_TRACE_LOW("init:MSG_MANAGERFILE_READ_OK");
- MMIMMS_GetManagerDocument(ALL_BOX);
- g_ismmsinit = TRUE;
- break;
- case MSG_MMS_CONFIGFILE_READ_OK: //read first
- efs_result_ptr = (FFS_READFILE_RESULT_T*)param;
- FILE_Close(efs_result_ptr->hefs);
- cmshandle = mmsf_Open((char*)MMSCONFIGFILE, "wb");
- mmsf_Write((char*)efs_result_ptr->buf_ptr,efs_result_ptr->buf_size, 1, cmshandle);
- mmsf_Close(cmshandle);
- if(efs_result_ptr->buf_ptr != NULL)
- {
- cms_free(efs_result_ptr->buf_ptr);
- efs_result_ptr->buf_ptr = NULL;
- }
- MMIMMS_ReadManagerInboxFile();
- break;
- case MSG_MANAGERFILEREAD_INBOX_OK: //read second
- SCI_TRACE_LOW("init:MSG_MANAGERFILEREAD_INBOX_OK");
- efs_result_ptr = (FFS_READFILE_RESULT_T*)param;
- FILE_Close(efs_result_ptr->hefs);
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- cmshandle = mmsf_Open((char*)"\cmsinbox.cnf", "wb");
- SCI_TRACE_LOW("FNH cmshandle = %d",cmshandle);
- mmsf_Write((char*)efs_result_ptr->buf_ptr,efs_result_ptr->buf_size, 1, cmshandle);
- mmsf_Close(cmshandle);
- MMIMMS_GetManagerDocument(INBOX);
- if(efs_result_ptr->buf_ptr != NULL)
- {
- cms_free(efs_result_ptr->buf_ptr);
- efs_result_ptr->buf_ptr = NULL;
- }
- MMIMMS_ReadManagerOutboxFile();
- break;
- case MSG_MANAGERFILEREAD_OUTBOX_OK: //read third
- SCI_TRACE_LOW("init:MSG_MANAGERFILEREAD_OUTBOX_OK");
- efs_result_ptr = (FFS_READFILE_RESULT_T*)param;
- FILE_Close(efs_result_ptr->hefs);
- cmshandle = mmsf_Open((char*)"\cmsoutbox.cnf", "wb");
- mmsf_Write((char*)efs_result_ptr->buf_ptr,efs_result_ptr->buf_size, 1, cmshandle);
- mmsf_Close(cmshandle);
- MMIMMS_GetManagerDocument(OUTBOX);
- if(efs_result_ptr->buf_ptr != NULL)
- {
- cms_free(efs_result_ptr->buf_ptr);
- efs_result_ptr->buf_ptr = NULL;
- }
- MMIMMS_ReadManagerSentboxFile();
- break;
- case MSG_MANAGERFILEREAD_SENTBOX_OK: //read four
- SCI_TRACE_LOW("init:MSG_MANAGERFILEREAD_SENTBOX_OK");
- efs_result_ptr = (FFS_READFILE_RESULT_T*)param;
- FILE_Close(efs_result_ptr->hefs);
- cmshandle = mmsf_Open((char*)"\cmssentbox.cnf", "wb");
- mmsf_Write((char*)efs_result_ptr->buf_ptr,efs_result_ptr->buf_size, 1, cmshandle);
- mmsf_Close(cmshandle);
- MMIMMS_GetManagerDocument(SENTBOX);
- if(efs_result_ptr->buf_ptr != NULL)
- {
- cms_free(efs_result_ptr->buf_ptr);
- efs_result_ptr->buf_ptr = NULL;
- }
- MMIMMS_ReadManagerDraftboxFile();
- break;
- case MSG_MANAGERFILEREAD_DRAFTBOX_OK: // read five
- SCI_TRACE_LOW("init:MSG_MANAGERFILEREAD_DRAFTBOX_OK");
- efs_result_ptr = (FFS_READFILE_RESULT_T*)param;
- FILE_Close(efs_result_ptr->hefs);
- cmshandle = mmsf_Open((char*)"\cmsdraftbox.cnf", "wb");
- mmsf_Write((char*)efs_result_ptr->buf_ptr,efs_result_ptr->buf_size, 1, cmshandle);
- mmsf_Close(cmshandle);
- MMIMMS_GetManagerDocument(DRAFTBOX);
- if(efs_result_ptr->buf_ptr != NULL)
- {
- cms_free(efs_result_ptr->buf_ptr);
- efs_result_ptr->buf_ptr = NULL;
- }
- g_ismmsinit =TRUE;
- SCI_TRACE_LOW("INIT IS OK !!!");
- break;
- case MSG_MANAGERFILEWRITE_INBOX_OK:
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- FFS_Close(g_filetype, efs_writeresult_ptr->hefs);
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- mmsf_Remove((char*)"\cmsinbox.cnf");
- break;
- case MSG_MANAGERFILEWRITE_OUTBOX_OK:
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- FFS_Close(g_filetype, efs_writeresult_ptr->hefs);
- mmsf_Remove((char*)"\cmsoutbox.cnf" );
- break;
- case MSG_MANAGERFILEWRITE_SENTBOX_OK:
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- FFS_Close(g_filetype, efs_writeresult_ptr->hefs);
- mmsf_Remove((char*)"\cmssentbox.cnf" );
- break;
- case MSG_MANAGERFILEWRITE_DRAFTBOX_OK:
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- FFS_Close(g_filetype, efs_writeresult_ptr->hefs);
- mmsf_Remove((char*)"\cmsdraftbox.cnf" );
- break;
- case MSG_MMS_DELETEMANAGERINBOXOK:
- break;
- case MSG_MMS_DELETEMANAGERFILE_OK:
- break;
- case MSG_MMS_VIDEO_SAVE_OK:
- #ifdef HAVE_MPEG4
- if (MMK_IsOpenWin(MMIMULTIM_DOWANLOAD_WAIT_WIN_ID)) //46351
- {
- MMK_CloseWin(MMIMULTIM_DOWANLOAD_WAIT_WIN_ID);
- }
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- FFS_Close(efs_writeresult_ptr->dev_type, efs_writeresult_ptr->hefs);
- if(efs_writeresult_ptr->write_result == SAVEFS_WRITE_SUCCEED)
- {
- /* if(efs_writeresult_ptr->buf_ptr != PNULL)
- {
- cms_free(efs_writeresult_ptr->buf_ptr);
- efs_writeresult_ptr->buf_ptr = PNULL;
- }
- */ {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- uint32 timevalue = 0 ;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)g_videoname_arr, strlen((char*)g_videoname_arr));
- timevalue = MMI_GetFfsTime();
- #ifdef MMI_APP_6800_PRJ
- #else
- MMIMPEG4_AddOne(
- ucs2_name_arr,
- ucs2_name_len,
- efs_writeresult_ptr->dev_type,
- efs_writeresult_ptr->buf_size,
- 1,
- timevalue
- );
- #endif
- }
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_SUCCESS,
- IMAGE_PROMPT_ICON_SUCCESS,
- MMI_3SECONDS,
- PNULL);
- }else
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_ERROR,
- IMAGE_PROMPT_ICON_FAIL,
- MMI_3SECONDS,
- PNULL);
- }
- #endif
- break;
- /* case MSG_MMS_SAVE_AUTO_SIGN_OK:
- SCI_TRACE_LOW("in MSG_MMS_SAVE_AUTO_SIGN_OK");
- if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
- {
- MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
- }
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- SCI_TRACE_LOW("fnh write_result = %d",efs_writeresult_ptr->write_result);
- if(efs_writeresult_ptr->write_result == SAVEFS_WRITE_SUCCEED)
- {
- FFS_Close(g_filetype, efs_writeresult_ptr->hefs);
- if(efs_writeresult_ptr->buf_ptr != PNULL)
- {
- cms_free(efs_writeresult_ptr->buf_ptr);
- efs_writeresult_ptr->buf_ptr = PNULL;
- }
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_SUCCESS,
- IMAGE_PROMPT_ICON_SUCCESS,
- MMI_3SECONDS,
- PNULL);
- }else
- {
- FFS_Close(g_filetype, efs_writeresult_ptr->hefs);
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_ERROR,
- IMAGE_PROMPT_ICON_SUCCESS,
- MMI_3SECONDS,
- PNULL);
- }
- break;
- */ case MSG_MMS_MP3_SAVE_OK:
- #ifdef HAVE_MP3
- efs_writeresult_ptr = (FFS_SAVEFILE_RESULT_T*)param;
- FFS_Close(efs_writeresult_ptr->dev_type, efs_writeresult_ptr->hefs);
- if (MMK_IsOpenWin(MMIMULTIM_DOWANLOAD_WAIT_WIN_ID)) //46351
- {
- MMK_CloseWin(MMIMULTIM_DOWANLOAD_WAIT_WIN_ID);
- }
- if(efs_writeresult_ptr->write_result == SAVEFS_WRITE_SUCCEED)
- {
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- uint32 timevalue = 0 ;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)g_mp3name_arr, strlen((char*)g_mp3name_arr));
- timevalue = MMI_GetFfsTime();
- MMIMP3_AddOne(
- ucs2_name_arr,
- ucs2_name_len,
- efs_writeresult_ptr->dev_type,
- efs_writeresult_ptr->buf_size,
- 1,
- timevalue
- );
- }
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_SUCCESS,
- IMAGE_PROMPT_ICON_SUCCESS,
- MMI_3SECONDS,
- PNULL);
- }
- else
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_ERROR,
- IMAGE_PROMPT_ICON_FAIL,
- MMI_3SECONDS,
- PNULL);
- }
- MMK_CloseWin(MMIMMS_DOWNLOAD_MP3_NAME_WIN_ID);
- #endif
- break;
- default:
- break;
- }
- }
- /*==============================================================
- * 函数名: MMIMMS_SaveManagerInboxFile
- * 输入: 空
- * 输出: void
- * 功能描述: 存储相应涉及收件箱的虚拟文件到flash资源。
- 因为为异步文件系统,目前顺序是:收件箱;发件箱;
- 已发邮件;草稿箱。
- * 代码编写者: liangliu
- * 代码编写日期: 10/28/2005
- * 修改原因:
- * 修改人员:
- * 修改日期:
- ==============================================================*/
- void MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX_STATUS saveinboxfilestate)
- {
- //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;
- g_inboxneedsave = FALSE;
- SCI_TRACE_LOW("MMIMMS_SaveManagerInboxFile IN ------------");
- mmsf_GetConstFileData((char *)"\cmsinbox.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 the cmshandle is >0 -in ");
- if(0!=FILE_CdMMSPath())
- {
- FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
- FILE_CdMMSPath();
- }
- inboxfile_openstatus = FILE_Create((char*)MANAGER_FLASH_INBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (inboxfile_openstatus == FFS_INVALID_HANDLE)
- {
- //the reason may be that I have not closed the former opened file with the same name
- FILE_Close(inboxfile_openstatus); //close former file
- inboxfile_openstatus = FILE_Create((char*)MANAGER_FLASH_INBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (inboxfile_openstatus == FFS_INVALID_HANDLE)
- {
- SCI_TRACE_LOW("HERE Creat the file is failed------------ ");
- mmsf_Remove((char*)"\cmsinbox.cnf");
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERINBOXOK, PNULL, PNULL);
- return ;
- }
- }
- SCI_TRACE_LOW("here create the inboxmanagerfile 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");
- FILE_Close(inboxfile_openstatus );
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- mmsf_Remove((char *)"\cmsinbox.cnf");
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERINBOXOK, PNULL, PNULL);
- return;
- }
- SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- param_save_ptr->buf_ptr = tempbuf;
- param_save_ptr->hefs = inboxfile_openstatus;//传递的参数
- param_save_ptr->buf_size = filelen;
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
- if(saveinboxfilestate == MMS_SAVE_INBOX)
- {
- overlapped.complete_route = SaveFS_SaveInboxFile_CallBack;
- }else
- {
- overlapped.complete_route = SaveFS_SaveInboxPUSHFile_CallBack;
- }
- efs_error = FILE_Write(
- inboxfile_openstatus,
- 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;
- }
- FILE_Close(inboxfile_openstatus );
- inboxfile_openstatus = FFS_INVALID_HANDLE;
- mmsf_Remove((char*)"\cmsinbox.cnf");
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERINBOXOK, PNULL, PNULL);
- return ;
- }
- }
- else
- {
- FILE_CdMMSPath();
- SCI_TRACE_LOW("fnh saveinboxfile filelen is zero!");
- mmsf_Remove((char*)"\cmsinbox.cnf");
- if(FILE_CheckExist((const char*)MANAGER_FLASH_INBOXNAME) == 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_INBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_INBOXNAME));
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteManagerInboxFile;
- 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);
- }
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERINBOXOK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }
- }
- /*==============================================================
- * 函数名: MMIMMS_SaveManagerOutboxFile
- * 输入: 空
- * 输出: void
- * 功能描述: 存储相应涉及发件箱的虚拟文件到flash资源。
- 因为为异步文件系统,目前顺序是:收件箱;发件箱;
- 已发邮件;草稿箱。
- * 代码编写者: liangliu
- * 代码编写日期: 10/28/2005
- * 修改原因:
- * 修改人员:
- * 修改日期:
- ==============================================================*/
- void MMIMMS_SaveManagerOutboxFile()
- {
- //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_SaveManagerOutboxFile IN ---------");
- mmsf_GetConstFileData((char *)"\cmsoutbox.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("enter filelen > 0");
- if(0!=FILE_CdMMSPath())
- {
- FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
- FILE_CdMMSPath();
- }
- cur_hefs = FILE_Create((char*)MANAGER_FLASH_OUTBOXNAME, 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_OUTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- SCI_TRACE_LOW("HERE Creat outboxfile is failed------------ ");
- 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 ;
- }
- }
- SCI_TRACE_LOW("HERE Create Oouboxfile is success !");
- param_save_ptr = (FFS_SAVEFILE_RESULT_T*)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
- if (param_save_ptr == NULL)
- {
- SCI_TRACE_LOW("here create outboxfile is fail!");
- mmsf_Remove((char *)"\cmsoutbox.cnf");
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- if (g_mailbox_status == SEND_OUTBOX_MMS)
- {
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MANAGERFILEWRITE_OUTBOX_FAILED,
- PNULL,
- PNULL
- );
- }
- 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_SaveOutboxFile_CallBack;
- efs_error = FILE_Write(
- cur_hefs,
- tempbuf,
- filelen,
- &transmit,