mmimms_main.c
资源名称:MMSCodes.rar [点击查看]
上传用户:fuyouda
上传日期:2021-12-23
资源大小:164k
文件大小:313k
源码类别:
手机彩信(MMS)编程
开发平台:
C/C++
- MMI_MEMCPY(
- ucs2_ptr,
- out_len,
- utf8_str_ptr->buf_ptr,
- utf8_str_ptr->len,
- utf8_str_ptr->len
- );
- str_out.str_ptr = ucs2_ptr;
- }
- else
- {
- str_out.is_ucs2 = TRUE;
- str_out.length = j;
- str_out.str_ptr = ucs2_ptr;
- }
- return str_out;
- }
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CdRootPath(void)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)PATH_ROOT, strlen(PATH_ROOT));
- return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
- }
- /*****************************************************************************/
- // 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)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)path, strlen(path));
- // return FFS_CD(g_filetype, (const wchar*)path);
- return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
- }
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CdMMSPath(void)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- FILE_CdRootPath();
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MMIMMS_MMS_DIR, strlen(MMIMMS_MMS_DIR));
- return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
- }
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL FFS_ERROR_E FILE_CdMP3Path(void)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- FILE_CdRootPath();
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MMIMMS_MP3_DIR, strlen(MMIMMS_MP3_DIR));
- return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
- }
- /*****************************************************************************/
- // 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)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)path, strlen(path));
- return FFS_CreateDir(g_filetype, (wchar *)ucs2_name_arr);
- }
- /*****************************************************************************/
- // 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)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)name, strlen(name));
- return FFS_Create(g_filetype, (wchar *)ucs2_name_arr, mode);
- }
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL void FILE_Close (HFS handle)
- {
- FFS_Close(g_filetype, 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)
- {
- return FFS_Write(g_filetype, handle, buf, len, transmitted, overlapped_ptr);
- }
- /*****************************************************************************/
- // Description : set the flag after UDisk is formatted
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note:
- /*****************************************************************************/
- PUBLIC void MMIMMS_ResetAfterUDiskFormat(void)
- {
- uint8 gb_path_name[MMIMMS_DEFAULT_DIR_LEN] = {0};
- uint16 ucs2_path_name[MMIMMS_DEFAULT_DIR_LEN] = {0};
- SCI_TRACE_LOW("MMIMMS : MMIMMS_ResetAfterUDiskFormat");
- //tell sms
- MMISMS_DelAllMMSByFormatFFS();
- /*fnh add 0327 begin*/
- MMIMMS_UdiskFormat();
- /*fnh add 0327 end*/
- //creat mp3 dir
- sprintf((char*)gb_path_name,"%s",MMIMMS_MMS_DIR);
- GUI_GB2UCS(ucs2_path_name, gb_path_name, (uint16)(sizeof(gb_path_name)));
- MMI_CdRootPath(FS_UDISK);
- FFS_CreateDir(FS_UDISK,(const wchar*)ucs2_path_name);
- }
- #endif
- /*****************************************************************************/
- // Description : adapter for FILE SYSTEM
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: it's FFS now
- ///*****************************************************************************/
- LOCAL BOOLEAN FILE_CheckExist (const char *file)
- {
- uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_name_len = 0;
- ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)file, strlen(file));
- return FFS_CheckExist(g_filetype, (wchar *)ucs2_name_arr);//modify 2006-2-10 liangliu
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_IsMMSFull
- * Purpose:初始化时判断当前彩信是否已满
- * Input: void
- * Returns: BOOLEAN
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- PUBLIC BOOLEAN MMIMMS_IsMMSFull(void)
- {
- if (MMIMMS_GetManagerTotalNum() >= MMS_MAX_NUM)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetInboxUnreadMsgNum
- * Purpose:得到当前收件箱的PUSH数目
- * Input: void
- * Returns: uint16
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- PUBLIC uint16 MMIMMS_GetInboxUnreadMsgNum(void)
- {
- uint16 unread_msg_num = 0;
- if(g_pManager != NULL)
- {
- SCI_TRACE_LOW("MMIMMS_GetInboxUnreadMsgNum g_pManager != PNULL COME IN -- ");
- unread_msg_num = g_pManager->inboxfolder->unsettlednumber;
- }//xuelianb modify [2006-02-07]
- else
- {
- SCI_TRACE_LOW("MMIMMS_GetInboxUnreadMsgNum g_pManager == PNULL");
- }
- SCI_TRACE_LOW("fnh unread_msg_num = %d",unread_msg_num);
- return unread_msg_num;
- }
- /*****************************************************************************/
- // Description : TRACE DATA
- // Global resource dependence :
- // Author:
- // Note
- ///*****************************************************************************/
- void cms_trace_data(unsigned char *data,int datalen)
- {
- int i=0, n=0;
- SCI_TRACE_LOW("FNH UI access cms_trace_data: in datalen = %d n", datalen );
- while(i < datalen)
- {
- n = datalen - i;// + 8;
- if(n>8)
- {
- SCI_TRACE_LOW("0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, rn",
- data[i], data[i+1],data[i+2], data[i+3],data[i+4], data[i+5],data[i+6], data[i+7]);
- i += 8;
- //rvf_delay(2);
- }
- else
- {
- while(n > 0)
- {
- SCI_TRACE_LOW("0x%02x, rn", data[i] );
- i++;n--;
- }
- //rvf_delay(2);
- break;
- }
- }
- SCI_TRACE_LOW("FNH UI access cms_trace_data: out datalen = %d n", datalen );
- }
- /*****************************************************************************/
- // Description : receive push over sms
- // Global resource dependence :
- // Author:
- // Note
- ///*****************************************************************************/
- PUBLIC uint8 MMIMMS_PushRecvSms(APP_MMS_USER_DATA_T *sms_ptr)
- {
- //wanqiangzh Modify for STK
- return MMICMS_PUSH_recv_data(sms_ptr->user_valid_data_t.user_valid_data_arr,
- sms_ptr->user_valid_data_t.length);
- }
- /*****************************************************************************/
- // Description : cat two string
- // Global resource dependence :
- // Author: Bruce.Chi
- // Note: should free the dst_ptr->str_ptr
- ///*****************************************************************************/
- BOOLEAN CatString( MMI_STRING_T *dst_ptr, //out.
- MMI_STRING_T *src1_ptr, //in.
- MMI_STRING_T *src2_ptr //in.
- )
- {
- #if 1
- uint32 str1_len = 0;
- uint8 *str1_text_ptr = PNULL;
- BOOLEAN str1_need_free = FALSE;
- uint32 str2_len = 0;
- uint8 *str2_text_ptr = PNULL;
- BOOLEAN str2_need_free = FALSE;
- SCI_ASSERT(dst_ptr != PNULL);
- SCI_ASSERT(src1_ptr != PNULL);
- SCI_ASSERT(src2_ptr != PNULL);
- //check
- if (src1_ptr->length == 0 && src2_ptr->length == 0)
- {
- return FALSE;
- }
- //need to convert?
- if (src1_ptr->is_ucs2 && !src2_ptr->is_ucs2)
- {
- //src1 is UCS2, src2 is ASCII
- str1_text_ptr = src1_ptr->str_ptr;
- str1_len = src1_ptr->length;
- str2_text_ptr = ASCtoUCS2(
- src2_ptr->str_ptr,
- src2_ptr->length,
- &str2_len
- );
- str2_need_free = TRUE;
- }
- else if (!src1_ptr->is_ucs2 && src2_ptr->is_ucs2)
- {
- //src1 is ASCII
- str1_text_ptr = ASCtoUCS2(
- src1_ptr->str_ptr,
- src1_ptr->length,
- &str1_len
- );
- str2_text_ptr = src2_ptr->str_ptr;
- str2_len = src2_ptr->length;
- str1_need_free = TRUE;
- }
- else
- {
- //need not convert
- str1_text_ptr = src1_ptr->str_ptr;
- str1_len = src1_ptr->length;
- str2_text_ptr = src2_ptr->str_ptr;
- str2_len = src2_ptr->length;
- }
- if (src1_ptr->is_ucs2 || src2_ptr->is_ucs2)
- {
- dst_ptr->is_ucs2 = TRUE;
- }
- else
- {
- dst_ptr->is_ucs2 = FALSE;
- }
- //merge
- dst_ptr->length = str1_len + str2_len;
- SCI_TRACE_LOW("dst_ptr->length = %d",dst_ptr->length);
- dst_ptr->str_ptr = cms_malloc(dst_ptr->length);
- SCI_ASSERT(dst_ptr->str_ptr != PNULL);
- SCI_MEMSET(dst_ptr->str_ptr, 0, dst_ptr->length);
- if (str1_text_ptr != PNULL)
- {
- // SCI_MEMCPY(dst_ptr->str_ptr, str1_text_ptr, str1_len);
- MMI_MEMCPY(dst_ptr->str_ptr, dst_ptr->length, str1_text_ptr, str1_len, str1_len);
- if (str1_need_free)
- {
- cms_free(str1_text_ptr);
- str1_text_ptr = PNULL;
- }
- }
- if (str2_text_ptr != PNULL)
- {
- // SCI_MEMCPY(dst_ptr->str_ptr + str1_len, str2_text_ptr, str2_len);
- MMI_MEMCPY(dst_ptr->str_ptr + str1_len, dst_ptr->length, str2_text_ptr, str2_len, str2_len);
- if (str2_need_free)
- {
- cms_free(str2_text_ptr);
- str2_text_ptr = PNULL;
- }
- }
- #endif
- return TRUE;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Receive_MMS
- * Purpose:回调函数,主要用于push消息处理
- * Input: status:消息状态
- prompt:消息值
- status_value:状态值
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- int sms_handle_callback(int status,void *prompt,int status_value)
- {
- NOTIFICATION_IND_SMS_MSG *msg = NULL;
- SCI_TRACE_LOW("sms_handle_callback come in --here!");
- switch(status)
- {
- case SMS_TYPE_DELIVERY_IND:
- //可在此处向用户弹出对话框,"用户已收到你的彩信"
- //参数prompt就是告诉用户接收成功的字符串,
- //VC 下可表达为
- //MessageBox(NULL,prompt,"a message",MB_OK);
- msg = (NOTIFICATION_IND_SMS_MSG *)prompt;
- SCI_TRACE_LOW("sms_handle_callback THE MSG->de_status is%d",msg->de_status);
- MMIMMS_DeliveryRpt_Arrive((void *)msg);
- MMIMMS_PlayMMSSound();
- break;
- case SMS_TYPE_NOTIFICATION_IND:
- {
- //此时参数prompt为MMS url,status_value为url的长度。
- //可在此处向用户弹出对话框,"某用户向您发了一封彩信,是否现在接收!"
- //将这个值取得,赋到状态机中,就可以使用MMS_RecvMms去接收MMS了。或者将此URL存在文件中
- //且放入到未接收邮箱中去。
- msg = (NOTIFICATION_IND_SMS_MSG *)prompt;
- if (g_nv_setting_mirror.advertisingallowable == MMS_MSG_SETTINGS_OFF) //判断当前彩信是否是广告
- {
- SCI_TRACE_LOW("SMS_TYPE_NOTIFICATION_IND msg->message_class_vlaue = %d",msg->message_class_value);
- if (msg->message_class_value == 0x81)
- break;
- }
- g_filetype = MMICMS_GetCurrentFFS(); //判断当前是否有存储空间。
- if (g_filetype != FS_INVALID)
- {
- MMIMMS_Notification_Arrive((void *)msg);
- MMIMMS_PlayMMSSound();
- }
- }
- break;
- case SMS_TYPE_UNKNOW:
- //可以扔了。
- break;
- }
- return 1;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeliveryRpt_Arrive
- * Purpose: 送达报告处理函数
- * Input: void * ptr:push内容
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeliveryRpt_Arrive(void * ptr)
- {
- NOTIFICATION_IND_SMS_MSG *msg = NULL;
- msg = (NOTIFICATION_IND_SMS_MSG *)ptr;
- SCI_TRACE_LOW("MMIMMS_DeliveryRpt_Arrive IN ");
- switch(msg->de_status)
- {
- SCI_TRACE_LOW("THE MSG STETUS IS %d",msg->de_status);
- case MMS_STATUS_VALUE_RETRIVED:
- if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_RETRIVED,
- IMAGE_PROMPT_ICON_SUCCESS,//IMAGE_PROMPT_ICON_OK,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- }else
- {
- g_delivery_value= MMS_DELIVERY_REPORT_VALUE_RETRIVED;
- MMIDEFAULT_SetBackLight(TRUE);
- }
- break;
- case MMS_STATUS_VALUE_REJECTED:
- if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_REJECTED,
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- }
- else
- {
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_REJECTED;
- MMIDEFAULT_SetBackLight(TRUE);
- }
- break;
- case MMS_STATUS_VALUE_DEFERRED:
- if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_DEFERRED,
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- }
- else
- {
- g_delivery_value= MMS_DELIVERY_REPORT_VALUE_DEFERRED;
- MMIDEFAULT_SetBackLight(TRUE);
- }
- break;
- case MMS_STATUS_VALUE_EXPIRED:
- if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_EXPIRED,
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- }
- else
- {
- g_delivery_value= MMS_DELIVERY_REPORT_VALUE_EXPIRED;
- MMIDEFAULT_SetBackLight(TRUE);
- }
- break;
- case MMS_STATUS_VALUE_UNRECOGNISED:
- if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_UNRECOGNISED,
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- }
- else
- {
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_UNRECOGNESED;
- MMIDEFAULT_SetBackLight(TRUE);
- }
- break;
- default:
- break;
- }
- }
- /* ----------------------------------------------------------------------------
- * 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)
- {
- pMessageList tlist = NULL;
- NOTIFICATION_IND_SMS_MSG *msg = NULL;
- uint32 value ;
- uint32 timevalue = 0 ;
- MMI_TM_T tm;
- msg = (NOTIFICATION_IND_SMS_MSG *)ptr;
- tlist= (pMessageList)cms_malloc(sizeof(MESSAGELIST));
- if (!tlist)
- {
- return ;
- }
- SCI_MEMSET(tlist, 0, sizeof(MESSAGELIST));
- /* FILENAME */
- tlist->filename= (uint8*)cms_malloc(MMS_MAX_FILE_NAME_LENGTH);
- if (!tlist->filename)
- {
- MMIMMS_FreeMessage(tlist);
- tlist = NULL;
- return ;
- }
- SCI_MEMSET(tlist->filename, 0, MMS_MAX_FILE_NAME_LENGTH);
- value = MMI_GetFfsTime();
- SCI_TRACE_LOW("the MMIMMS_Notification_Arrive here the MMI_GetFfsTime value is %u",value);
- sprintf((char *)tlist->filename,"%lu",value);
- strcat((char *)tlist->filename, ".mms");
- /* SUBJECT */
- if (msg->subject)
- {
- SCI_TRACE_LOW("fnh msg->subject len = %d",sizeof((char *)msg->subject));
- if (!(msg->subject[0] == 0 && msg->subject[1] == 0))
- {//有主题
- int outlen = 0;
- tlist->subject = (uint8*)cms_malloc(MMS_MAX_UTF_SUBJECT_SIZE);
- if (!tlist->subject)
- {
- MMIMMS_FreeMessage(tlist);
- tlist = NULL;
- return ;
- }
- SCI_MEMSET(tlist->subject, 0, MMS_MAX_UTF_SUBJECT_SIZE);
- outlen = Cms_UTF16toUTF8Len(msg->subject);
- Cms_UTF16toUTF8(msg->subject, outlen, outlen+1, tlist->subject);
- SCI_TRACE_LOW("fnh tlist->subject len is %d",sizeof((char *)tlist->subject));
- //temp = Cms_mms_uni16_8(msg->subject + 2);//here the unicode changed to the asc
- // SCI_MEMCPY(tlist->subject,(char*) temp);
- //cms_free(temp);
- //temp = NULL;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH msg->subject is null");
- }
- /* ADDRESS */
- if (msg->phone_number)
- {
- if (msg->phone_number[0] != 0)
- {
- tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
- if (!tlist->sender)
- {
- MMIMMS_FreeMessage(tlist);
- tlist = NULL;
- return ;
- }
- SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
- SCI_STRCPY((char*)tlist->sender,(char*) msg->phone_number);
- }
- else
- {
- tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
- SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
- SCI_STRCPY((char*)tlist->sender,(char*)"MMS");
- }
- }
- else
- {
- tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
- SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
- SCI_STRCPY((char*)tlist->sender,(char*)"MMS");
- }
- /* URL */
- tlist->url = (uint8*)cms_malloc(MAX_URL_LENGTH);
- if (!tlist->url)
- {
- MMIMMS_FreeMessage(tlist);
- tlist = NULL;
- return ;
- }
- SCI_MEMSET(tlist->url, 0, MAX_URL_LENGTH);
- if (msg->mms_url)
- {
- SCI_STRCPY((char*)tlist->url, (char*)msg->mms_url);
- }
- tlist->msg_id= (uint8*)cms_malloc(MMS_MAX_MSGID_LENGTH);
- if (!tlist->msg_id)
- {
- MMIMMS_FreeMessage(tlist);
- tlist = NULL;
- return ;
- }
- SCI_MEMSET(tlist->msg_id, 0, MMS_MAX_MSGID_LENGTH);
- if (msg->de_msgid)
- {
- SCI_STRCPY((char*)tlist->msg_id, (char*)msg->de_msgid);
- }
- /* DATE */
- tlist->date = (uint8*)cms_malloc(MMS_MAX_DATE_LEN);
- if (!tlist->date)
- {
- MMIMMS_FreeMessage(tlist);
- tlist = NULL;
- return ;
- }
- SCI_MEMSET(tlist->date, 0, MMS_MAX_DATE_LEN);
- /*
- TM_GetSysDate(&sys_date);
- TM_GetSysTime(&sys_time);
- */
- timevalue =MMI_GetFfsTime();
- tm = MMI_FatData2Tm(timevalue);
- SCI_STRCPY((char*)tlist->date, (char*)CmsTimeToString(tm));
- /*fnh add 0509*/
- if(msg->expiry_time<=168)
- {
- tlist->expiry =(uint32)msg->expiry_time;
- }
- else
- {
- if((msg->expiry_time%3600)>1800)
- {
- tlist->expiry=(uint32)(msg->expiry_time/3600)+1;
- }
- else
- {
- tlist->expiry=(uint32)(msg->expiry_time/3600);
- }
- }
- /*fnh add 0509*/
- tlist->state = 0;
- if (g_nv_setting_mirror.retrieve_mode == 1) //当前设置为自动下载
- {
- tlist->needautodw = 1;
- }
- tlist->size = msg->msgsize;//modify 2005-12-15 liangliu
- MMIMMS_AddManagerList(g_pManager->inboxfolder, tlist);
- g_pManager->inboxfolder->unsettlednumber++;
- SCI_TRACE_LOW("fnh g_pManager->inboxfolder->unsettlednumber = %d",g_pManager->inboxfolder->unsettlednumber);
- SCI_TRACE_LOW("FNH inboxfile_openstatus = %d",inboxfile_openstatus);
- SCI_TRACE_LOW("g_nv_setting_mirror.retrieve_mode IS%d",g_nv_setting_mirror.retrieve_mode);
- if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID)&&g_nv_setting_mirror.retrieve_mode == 1)
- {
- //judge whether it's making a call
- if (CC_IsInCall())
- {
- //alert : TXT_MMS_CANNOT_DOWNLOAD_IN_CALL
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_CANNOT_DOWNLOAD_IN_CALL,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT,
- PNULL
- );
- }
- else
- {
- if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_NEWANDFULL,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT, PNULL);
- }else
- {
- g_backautodownload = TRUE;
- g_inboxneedsave = TRUE;
- MMIMMS_Download_CreateDownloadingWin();
- MMIDEFAULT_SetBackLight(TRUE);
- g_netusing = MMS_MSG_NETUSING_STEP1 ;
- //MMK_CreateWin((uint32 *)MMIMMS_SEND_WIN_TAB,PNULL);
- g_pCurrentList = g_pManager->inboxfolder->currentmessage;
- g_progressneedsize = g_pCurrentList->size;
- MMIMMS_Receive_MMS(g_pCurrentList);
- }
- }
- }
- else if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID)&&g_nv_setting_mirror.retrieve_mode == 0)
- {
- MMIMMS_StoreFolder(g_pManager->inboxfolder);
- g_savestate = MMS_MSG_SAVEFILE_FOR_NOTIFY;
- MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX);
- if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_NEWANDFULL,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT,
- PNULL);
- MMIDEFAULT_SetBackLight(TRUE);
- }else
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_CL_NEW_MMS,
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- }
- }else
- {
- if (inboxfile_openstatus == FFS_INVALID_HANDLE) //FNH add 20060914
- {
- MMIMMS_StoreFolder(g_pManager->inboxfolder);
- MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX);//liangliu@mobilesoft.com.cn modify for inboxfile of mms save.
- }
- else //说明收件箱的索引文件是打开的,这时候需要启动定时器,定期判断文件是否关闭,如果文件关闭了,则进行写文件操作
- {
- SCI_TRACE_LOW("fnh inbox file is open");
- }
- g_inboxneedsave = TRUE;
- g_donewmms = TRUE;
- if(g_nv_setting_mirror.retrieve_mode == 1)
- {
- if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_NEWANDFULL,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT, PNULL);
- MMIMMS_FreeAutodownList();
- }else
- {
- if (g_num_autodw < (MMS_MAX_NUM - MMIMMS_GetManagerTotalNum()))
- {
- pAutoDownloadMMSList autommslist =PNULL;
- autommslist =(pAutoDownloadMMSList)mms_Malloc(sizeof(autoDownloadMMSList));
- autommslist->autolist = tlist;
- SCI_TRACE_LOW("FNH before MMIMMS_AddAutodownList = %d",autommslist);
- MMIMMS_AddAutodownList(autommslist);
- }
- }
- }
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Receive_MMS
- * Purpose:接受彩信
- * Input: 接受彩信,从list列表中获取filename和url
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_Receive_MMS(pMessageList tlist)
- {
- MMS_RECV_SETTING recvset;
- MMS_CONFIG_SETTING cfgset;
- //暂时不从设置中读出,只是这儿设定
- SCI_TRACE_LOW("here the MMIMMS_Receive_MMS in-------- ");
- if (!tlist->url) // [qiangent 2005-03-22]
- {
- //error handle
- SCI_TRACE_LOW("FNH here the tlist->url is null!");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
- return ;
- }
- if (!tlist->url[0])
- {
- //error handle
- SCI_TRACE_LOW("FNH here the tlist->url is EMPTY!");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
- return ;
- }
- if(MMS_Init() == 0)
- {
- SCI_TRACE_LOW("FNH here MMS_Init() == 0");
- g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
- MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
- return;
- }
- SCI_MEMSET(&cfgset,0,sizeof(MMS_CONFIG_SETTING));
- SCI_MEMSET(&recvset,0,sizeof(MMS_RECV_SETTING));
- 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);
- MMS_Machine_Config(&cfgset);
- recvset.immediate_recv = 1;//## 置为0测一下
- recvset.get_url = (char*)tlist->url;
- SCI_TRACE_LOW("HERE THE URL IS %s",tlist->url);
- recvset.recv_vfilename = (char*)tlist->filename;
- recvset.recv_msgsize = tlist->size;
- SCI_TRACE_LOW("here will MMS_ReceiveMms--- ");
- if(!MMS_ReceiveMms(&recvset,mms_lib_callback))
- {
- //can not receive the mms
- return;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_Receive_MMS
- * Purpose:保存彩信
- * Input: pMessageList: 当前彩信LIST
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_SaveMMS(pMessageList tlist)
- {
- //FILE_HANDLE cmshandle = 0;
- uint8* tempbuf;
- //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;
- if(MMIMMS_IsMoreSpace())
- {
- SCI_TRACE_LOW("MMIMMS_SaveMMS IN ");
- if(tlist->filename == NULL)
- {
- SCI_TRACE_LOW("FNH tlist->filename is null!");
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- return ;
- }else
- {
- mmsf_GetConstFileData((char *)tlist->filename,(char **)&tempbuf,(int *)&filelen);
- SCI_TRACE_LOW("fnh filelen = %d",filelen);
- SCI_TRACE_LOW("fnh read tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
- if (filelen > 0)
- {
- if(0!=FILE_CdMMSPath())
- {
- FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
- FILE_CdMMSPath();
- }
- cur_hefs = FILE_Create((char*)tlist->filename, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
- SCI_TRACE_LOW("fnh cur_hefs = %d",cur_hefs);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- //the reason may be that I have not closed the former opened file with the same name
- SCI_TRACE_LOW("ERROR THE cur_hefs is invalid");
- FILE_Close(cur_hefs); //close former file
- cur_hefs = FILE_Create((char*)tlist->filename, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- mmsf_Remove((char *)tlist->filename);
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- return ;
- }
- }
- SCI_TRACE_LOW("here creat the mms fike in flash is ok----------");
- param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
- if (param_save_ptr == NULL)
- {
- mmsf_Remove((char *)tlist->filename);
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- return ;
- }
- SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- SCI_TRACE_LOW("fnh tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
- // SCI_TRACE_LOW("fnh tempbuf strln is %s",tempbuf);
- param_save_ptr->buf_ptr = tempbuf;
- param_save_ptr->hefs = cur_hefs;//传递的参数
- param_save_ptr->buf_size = filelen;
- g_filename = NULL;
- g_filename= (char *)cms_malloc(SCI_STRLEN((char*)tlist->filename)+1);
- if (g_filename == NULL)
- {
- if (param_save_ptr != NULL)
- {
- cms_free(param_save_ptr);
- param_save_ptr = NULL;
- }
- mmsf_Remove((char *)tlist->filename);
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- return ;
- }
- SCI_MEMSET(g_filename,0,SCI_STRLEN((char *)tlist->filename)+1);
- SCI_STRCPY((char*)g_filename, (char*)tlist->filename);
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
- overlapped.complete_route = SaveFS_SaveMMS_CallBack;
- efs_error = FILE_Write(
- cur_hefs,
- tempbuf,
- filelen,
- &transmit,
- &overlapped
- );
- if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
- {
- if (g_filename != NULL)
- {
- cms_free(g_filename);
- g_filename = NULL;
- }
- if (param_save_ptr != NULL)
- {
- cms_free(param_save_ptr);
- param_save_ptr = NULL;
- }
- mmsf_Remove((char *)tlist->filename);
- FILE_Close(cur_hefs);
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- cur_hefs = FFS_INVALID_HANDLE;
- return ;
- }
- }
- else
- {
- SCI_TRACE_LOW("fnh read mms file len is zero");
- mmsf_Remove((char *)tlist->filename);
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- return ;
- }
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH save mms no more space!");
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL);
- return ;
- }
- }
- /* ----------------------------------------------------------------------------
- * 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)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveAutoSign_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- SCI_TRACE_LOW("IN autosign before postmsg!");
- SCI_TRACE_LOW("size is %d,buffer ptr is %d",efs_result.buf_size,efs_result.buf_ptr);
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MMS_SAVE_AUTO_SIGN_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SaveAutoSign
- * Purpose:保存自动签名页到文件系统
- * Input: filename:自动签名页的文件名
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_SaveAutoSign(uint8 * filename)
- {
- FILE_HANDLE cmshandle = 0;
- uint32 filelen = 0;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- uint8* tempbuf = PNULL;
- FFS_ERROR_E efs_error;
- FFS_OVERLAPPED_T overlapped;
- uint32 transmit;
- FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
- SCI_TRACE_LOW("in MMIMMS_SaveAutoSign");
- cmshandle = mmsf_Open((char*)filename, "rb");
- if (cmshandle > 0)
- {
- filelen=Cms_GetFileLength(cmshandle);
- if (filelen > 0)
- {
- tempbuf = (unsigned char *)cms_malloc(filelen+1);
- if (tempbuf == NULL)
- {
- SCI_TRACE_LOW("fnh tempbuf malloc failed");
- mmsf_Close(cmshandle);
- mmsf_Remove((char*)filename);
- if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
- {
- MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return;
- }
- SCI_MEMSET(tempbuf, 0, filelen+1);
- mmsf_Read((char*)tempbuf, filelen, 1, cmshandle);
- mmsf_Close(cmshandle);
- mmsf_Remove((char*)filename);
- if(0!=FILE_CdMMSPath())
- {
- FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
- FILE_CdMMSPath();
- }
- cur_hefs = FILE_Create((char*)MMSAUTOSIGNFILE, FFS_MODE_OPEN_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*)MMSAUTOSIGNFILE, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
- if (cur_hefs == FFS_INVALID_HANDLE)
- {
- SCI_TRACE_LOW("fnh save auto sign cretae autosign file is error");
- if (tempbuf != NULL)
- {
- cms_free(tempbuf);
- tempbuf = NULL;
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return ;
- }
- }
- SCI_TRACE_LOW("here creat auto sign the mms fike in flash 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 save autosign param_save_ptr malloc fail!");
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- if (tempbuf != NULL)
- {
- cms_free(tempbuf);
- tempbuf = NULL;
- }
- if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
- {
- MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_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_SaveAutoSign_CallBack;
- efs_error = FILE_Write(
- cur_hefs,
- tempbuf,
- filelen,
- &transmit,
- &overlapped
- );
- if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
- {
- if (tempbuf != NULL)
- {
- cms_free(tempbuf);
- tempbuf = NULL;
- }
- if (param_save_ptr != NULL)
- {
- cms_free(param_save_ptr);
- param_save_ptr = NULL;
- }
- FILE_Close(cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
- {
- MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return ;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH save auto sign file len is zero!");
- mmsf_Close(cmshandle);
- mmsf_Remove((char*)filename);
- if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
- {
- MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH save auto sign open file is error!");
- if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
- {
- MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SaveVideo
- * Purpose: 保存视频文件
- * Input: videoname:视频文件名
- vidoBuf:视频内容指针
- videoBufLen:视频内容大小
- * Returns: DOWN_ERROR_TYPE
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- DOWN_ERROR_TYPE MMIMMS_SaveVideo(uint8 * videoname, uint8 *vidoBuf, uint32 vidoBufLen)
- {
- //FILE_HANDLE cmshandle = 0;
- // int curroffset = 0;
- //uint32 filelen = 0;
- //static HFS s_hefs = FFS_INVALID_HANDLE;
- HFS cur_hefs = FFS_INVALID_HANDLE;
- //uint16 * dir_name =PNULL;
- //uint16 unicodelong = 0 ;
- //MMI_STRING_T prompt_str = {0};
- FFS_ERROR_E efs_error = FFS_NO_ERROR;
- FFS_OVERLAPPED_T overlapped = {0};
- uint32 transmit = 0;
- //uint8 *efs_buf_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
- FILE_DEV_E_T vedio_device_type =FS_UDISK;
- FILE_DEV_E_T default_device_type = FS_UDISK;
- DOWN_ERROR_TYPE result = DOWN_ERROR_NONE;
- uint16 ucs2_vedio_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_vedio_name_len = 0;
- if((PNULL == videoname) || (PNULL == vidoBuf) || (0 == vidoBufLen))
- {
- SCI_TRACE_LOW("vedio name is null");
- return DOWN_ERROR_DEFAULT;
- }
- ucs2_vedio_name_len = GUI_GB2UCS(ucs2_vedio_name_arr, (uint8 *)videoname, strlen((char*)videoname));
- //得到当前的ring, pic文件保存设置
- if (g_mmi_exist_sd)
- {
- default_device_type = MMIMultim_GetVideoSavePath();
- }
- else
- {
- default_device_type = FS_UDISK;
- }
- //如果SD卡不存在,就保存到U盘
- if (!g_mmi_exist_sd)
- {
- vedio_device_type = FS_UDISK;
- }
- //SDcard and Udisk 都存在,一个空间满,就选择保存到另一个。
- else
- {
- if (vidoBufLen >= MMI_GetFreeSpace(default_device_type))
- {
- if (FS_UDISK == default_device_type)
- {
- vedio_device_type = FS_MMC;
- }
- else
- {
- vedio_device_type = FS_UDISK;
- }
- }
- else
- {
- vedio_device_type = default_device_type;
- }
- }
- SCI_TRACE_LOW("MMIMMS_SaveVideo:video len = %d",vidoBufLen);
- SCI_TRACE_LOW("MMIMMS_SaveVideo:free space = %d",FFS_GetFreeSpace(vedio_device_type));
- //两个盘都满,退出保存
- if (vidoBufLen >= MMI_GetFreeSpace(vedio_device_type))
- {
- return DOWN_ERROR_FULL;
- }
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(), come in!");
- if (FFS_ERROR_NONE == MMIMEPG4_CdMpeg4Path(vedio_device_type))
- {
- //判断是否有重名文件
- if (FFS_CheckExist(vedio_device_type,(const wchar*)ucs2_vedio_name_arr))
- {
- return DOWN_ERROR_REPEAT;
- }
- cur_hefs = FFS_Create(vedio_device_type,(const wchar*)ucs2_vedio_name_arr, FFS_MODE_CREATE_NEW|FFS_MODE_WRITE);
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo():FFS_Create g_handle_result is %d",cur_hefs);
- if(FFS_INVALID_HANDLE != cur_hefs)
- {
- //异步写文件数据
- param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
- SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- param_save_ptr->buf_ptr = vidoBuf;
- param_save_ptr->hefs = cur_hefs;//传递的参数
- param_save_ptr->buf_size = vidoBufLen;
- param_save_ptr->dev_type = vedio_device_type;
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
- overlapped.complete_route = SaveFS_SaveVideo_CallBack;
- efs_error = FFS_Write(
- vedio_device_type,
- cur_hefs,
- vidoBuf,
- vidoBufLen,
- &transmit,
- &overlapped
- );
- result = DOWN_ERROR_NONE;
- switch (efs_error)
- {
- case FFS_ERROR_IO_PENDING:
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(): FFS_Write start");
- break;
- case FFS_ERROR_NONE:
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(): FFS_Write success");
- break;
- default:
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(): FFS_Write failed. ffs_error=%d", efs_error);
- result = DOWN_ERROR_DEFAULT;
- }
- }
- }
- else
- {
- result = DOWN_ERROR_DEFAULT; //cd mp4 path fail
- }
- return result;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SaveMp3
- * Purpose: 保存MP3文件
- * Input: mp3name:MP3文件名
- mp3Buf:MP3内容指针
- mp3BufLen:MP3内容大小
- * Returns: DOWN_ERROR_TYPE
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- DOWN_ERROR_TYPE MMIMMS_SaveMp3(uint8 * mp3name, uint8* mp3Buf, uint32 mp3BufLen)
- {
- HFS cur_hefs = FFS_INVALID_HANDLE;
- FFS_ERROR_E efs_error = FFS_NO_ERROR;
- FFS_OVERLAPPED_T overlapped = {0};
- uint32 transmit = 0;
- //uint8 *efs_buf_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
- FILE_DEV_E_T mp3_device_type = FS_UDISK;
- FILE_DEV_E_T default_device_type = FS_UDISK;
- DOWN_ERROR_TYPE result = DOWN_ERROR_NONE;
- uint16 ucs2_mp3_name_arr[UCS2_NAME_MAX_LEN] = {0};
- int ucs2_mp3_name_len = 0;
- if((PNULL == mp3name) || (PNULL == mp3Buf) || (0 == mp3BufLen))
- {
- SCI_TRACE_LOW("mp3 name is null");
- return DOWN_ERROR_DEFAULT;
- }
- ucs2_mp3_name_len = GUI_GB2UCS(ucs2_mp3_name_arr, (uint8 *)mp3name, strlen((char*)mp3name));
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(), come in!");
- if (g_mmi_exist_sd)
- {
- // default_device_type = MMIMultim_GetRingSavePath();
- default_device_type = MMIMultim_GetMP3SavePath();
- }
- else
- {
- default_device_type = FS_UDISK;
- }
- //如果SD卡不存在,就保存到U盘
- if (!g_mmi_exist_sd)
- {
- mp3_device_type = FS_UDISK;
- }
- //SDcard and Udisk 都存在,一个空间满,就选择保存到另一个。
- else
- {
- if (mp3BufLen >= MMI_GetFreeSpace(default_device_type))
- {
- if (FS_UDISK == default_device_type)
- {
- mp3_device_type = FS_MMC;
- }
- else
- {
- mp3_device_type = FS_UDISK;
- }
- }
- else
- {
- mp3_device_type = default_device_type;
- }
- }
- SCI_TRACE_LOW("MMIMMS_SaveMp3:MP3 len = %d",mp3BufLen);
- SCI_TRACE_LOW("MMIMMS_SaveMp3:free space = %d",FFS_GetFreeSpace(mp3_device_type));
- SCI_TRACE_LOW("MMIMMS_SaveMp3:mp3_device_type = %d", mp3_device_type);
- //两个盘都满,退出保存
- if (mp3BufLen >= MMI_GetFreeSpace(mp3_device_type))
- {
- return DOWN_ERROR_FULL;
- }
- SCI_TRACE_LOW((char *)ucs2_mp3_name_arr);
- if ( MMIMP3_CdMp3Path(mp3_device_type) )
- {
- //判断是否有重名文件
- if (FFS_CheckExist(mp3_device_type,(const wchar*)ucs2_mp3_name_arr))
- {
- return DOWN_ERROR_REPEAT;
- }
- cur_hefs = FFS_Create(
- mp3_device_type,
- (const wchar*)ucs2_mp3_name_arr,
- FFS_MODE_CREATE_NEW|FFS_MODE_WRITE
- );
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3():FFS_Create cur_hefs is %d",cur_hefs);
- if(FFS_INVALID_HANDLE != cur_hefs)
- {
- //异步写文件数据
- param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
- SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- param_save_ptr->buf_ptr = mp3Buf;
- param_save_ptr->hefs = cur_hefs;//传递的参数
- param_save_ptr->buf_size = mp3BufLen;
- param_save_ptr->dev_type = mp3_device_type;
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
- overlapped.complete_route = SaveFS_SaveMp3_CallBack;
- efs_error = FFS_Write(
- mp3_device_type,
- cur_hefs,
- mp3Buf,
- mp3BufLen,
- &transmit,
- &overlapped
- );
- result = DOWN_ERROR_NONE;
- switch (efs_error)
- {
- case FFS_ERROR_IO_PENDING:
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(): FFS_Write start");
- break;
- case FFS_ERROR_NONE:
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(): FFS_Write success");
- break;
- default:
- SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(): FFS_Write failed. ffs_error=%d", efs_error);
- result = DOWN_ERROR_DEFAULT;
- }
- }
- }
- else
- {
- result = DOWN_ERROR_DEFAULT; //cd mp3 path fail
- }
- // PUBWIN_CloseWaitingMessageWin(MMICMSBRW_WAITINGMESSAGE_WIN_ID);
- return result;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ReadMMS
- * Purpose:从flash资源中读取彩信
- * Input: pMessageList:彩信LIST
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_ReadMMS(pMessageList tlist)
- {
- 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_ReadMMS IN -------");
- FILE_CdMMSPath();
- if (tlist->filename == NULL)
- {
- SCI_TRACE_LOW("fnh the tlist->filename is NULL");
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
- return;
- }
- //tlist->state = 2;//added 2005-12-8 for readed mms. delete 12-28 for readrpt state change after read end
- SCI_TRACE_LOW("THE FILE NAME IS %s",tlist->filename);
- if(FILE_CheckExist((const char*)tlist->filename) == TRUE)
- {
- cur_hefs = FILE_Create((const char*)tlist->filename, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
- //SCI_TRACE_BUF("VC: ReadVideo file_name = ", file_name, video_info_ptr->name_len);
- 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 file size is zero!");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, 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(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, 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_ptr 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(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
- return;
- }
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
- overlapped.complete_route = MMIVC_ReadMMS_CallBack;
- 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 mms file 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;
- }
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
- return ;
- }
- }
- else//打开文件失败
- {
- SCI_TRACE_LOW("fnh the mms file is open fail");
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
- return ;
- }
- }
- else
- {
- SCI_TRACE_LOW("fnh the mms file is not exist");
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
- return;
- }
- }
- /* ----------------------------------------------------------------------------
- * 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
- * ----------------------------------------------------------------------------*/
- void SaveFS_SaveMMS_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- //post message
- efs_result.hefs = efs_param_ptr->hefs;
- efs_result.buf_ptr = efs_param_ptr->buf_ptr;
- efs_result.buf_size = efs_param_ptr->buf_size;
- SCI_TRACE_LOW("fnh efs_result.buf_ptr len = %d",SCI_STRLEN((char *)efs_result.buf_ptr));
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MMS_SAVE_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_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)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- if ( PNULL == efs_param_ptr )
- {
- return;
- }
- efs_result = *efs_param_ptr;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, SAVEFS_WRITE_SUCCEED");
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, SAVEFS_WRITE_FAIL");
- }
- MMK_PostMsg(
- VIRTUAL_WIN_ID,
- MSG_MMS_VIDEO_SAVE_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: SaveFS_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)
- {
- FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
- FFS_SAVEFILE_RESULT_T efs_result;
- SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
- //init
- SCI_MEMSET(&efs_result, 0, sizeof(FFS_SAVEFILE_RESULT_T));
- efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
- //judge write status
- if ( PNULL == efs_param_ptr )
- {
- return;
- }
- efs_result = *efs_param_ptr;
- //judge write status
- if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
- {
- efs_result.write_result = SAVEFS_WRITE_SUCCEED;
- }
- else
- {
- efs_result.write_result = SAVEFS_WRITE_FAIL;
- }
- MMK_PostMsg(
- VIRTUAL_WIN_ID,
- MSG_MMS_MP3_SAVE_OK,
- &efs_result,
- sizeof(FFS_SAVEFILE_RESULT_T)
- ); //note: MMK_PostMsg will save one copy of this message, and it will free it
- //free in param
- if(efs_param_ptr != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: 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
- )
- {
- 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 != PNULL)
- {
- cms_free(efs_param_ptr);
- efs_param_ptr = PNULL;
- }
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetMMSMessage
- * Purpose:从对应的 彩信文档中获取对应的管理信息条目
- * Input: 彩信文档
- * Returns: 对应的列表信息
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- pMessageList MMIMMS_GetMMSMessage(MMSHANDLE mmsdoc,int state)
- {
- pMessageList tlist = PNULL;
- char buffer[512];
- uint32 ldate;
- uint32 priority;
- uint32 readpt;
- char * receiver_str = NULL;
- MMI_TM_T tm;
- tlist = (pMessageList)cms_malloc(sizeof(MESSAGELIST));
- if(!tlist)
- {
- SCI_TRACE_LOW("HERE MALLOC THE SPACE IS ERROR------");
- return 0;
- }
- SCI_TRACE_LOW("MMIMMS_GetMMSMessage come in ------");
- SCI_MEMSET(tlist, 0, sizeof(MESSAGELIST));
- /* set value to it */
- SCI_MEMSET(buffer, 0, sizeof(buffer));
- MMS_GetMmsFile(mmsdoc, buffer);
- tlist->filename = (uint8 *)cms_malloc(SCI_STRLEN(buffer)+1);
- if(tlist->filename)
- {
- SCI_STRCPY((char*)tlist->filename, buffer);
- }
- SCI_MEMSET(buffer, 0, sizeof(buffer));
- MMS_GetMmsHeadField(mmsdoc, MMS_SUBJECT, 0, buffer);
- SCI_TRACE_BUF("the subject is not empty,is %x",buffer,10);
- if(buffer[0]||buffer[1])
- {
- int outlen = 0;
- SCI_TRACE_LOW("FNH buffer len is %d",SCI_STRLEN((char *)buffer));
- outlen = Cms_UTF16toUTF8Len(buffer+2);
- tlist->subject =(uint8*)cms_malloc(outlen);
- SCI_MEMSET(tlist->subject, 0, outlen);
- Cms_UTF16toUTF8(buffer+2, sizeof(buffer)-2, outlen, tlist->subject);
- tlist->subject[outlen] = 0;
- }
- else
- SCI_TRACE_LOW("fnh buffer is null");
- receiver_str = NULL;
- MMS_GetMmsHeadField(mmsdoc, MMS_TO, 0, (char *)&receiver_str);
- // SCI_TRACE_LOW("the to str is %s",receiver_str);
- if(receiver_str)
- {
- tlist->to_address = (uint8 *)cms_malloc(SCI_STRLEN(receiver_str)+1);
- if(tlist->to_address)
- {
- SCI_STRCPY((char*)tlist->to_address, receiver_str);
- // SCI_TRACE_LOW("fnh get to = %s",tlist->to_address);
- }
- cms_free(receiver_str);
- receiver_str = NULL;
- }
- else
- {
- tlist->to_address = (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
- SCI_MEMSET(tlist->to_address, 0, MMS_MAX_ADDRESS_LENGTH);
- SCI_STRCPY((char*)tlist->to_address,(char*)MMIMMS_UNKNOWN_SENDER);
- }
- SCI_MEMSET(buffer, 0, sizeof(buffer));
- MMS_GetMmsHeadField(mmsdoc, MMS_FROM, 0, buffer);
- if(buffer[0])
- {
- tlist->sender = (uint8*)cms_malloc(SCI_STRLEN(buffer)+1);
- if(tlist->sender)
- {
- SCI_STRCPY((char*)tlist->sender, buffer);
- }
- SCI_TRACE_LOW("the sender is not empty,is %s",tlist->sender);
- }
- else
- {
- tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
- SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
- SCI_STRCPY((char*)tlist->sender,(char*)"MMS");
- }
- receiver_str = NULL;
- MMS_GetMmsHeadField(mmsdoc, MMS_CC, 0, (char *)&receiver_str);
- if(receiver_str)
- {
- tlist->cc_address= (uint8 *)cms_malloc(SCI_STRLEN(receiver_str)+1);
- if(tlist->cc_address)
- {
- SCI_STRCPY((char*)tlist->cc_address, receiver_str);
- }
- cms_free(receiver_str);
- receiver_str = NULL;
- }
- receiver_str = NULL;
- MMS_GetMmsHeadField(mmsdoc, MMS_BCC, 0, (char *)&receiver_str);
- if(receiver_str)
- {
- tlist->bcc_address= (uint8*)cms_malloc(SCI_STRLEN(receiver_str)+1);
- if(tlist->bcc_address)
- {
- SCI_STRCPY((char*)tlist->bcc_address, receiver_str);
- }
- cms_free(receiver_str);
- receiver_str = NULL;
- }
- SCI_MEMSET(buffer, 0, MMS_MAX_MSGID_LENGTH);//added liangliu 2006-2-20 for msg_id used in readrpt.
- MMS_GetMmsHeadField(mmsdoc, MMS_TRANSACTION_ID, 0, buffer);
- if(buffer[0])
- {
- tlist->msg_id= (uint8 *)cms_malloc(SCI_STRLEN(buffer)+1);
- if(tlist->msg_id)
- {
- SCI_STRCPY((char*)tlist->msg_id, buffer);
- }
- }
- MMS_GetMmsHeadField(mmsdoc, MMS_PRIORITY, (long *)&priority, (char *)0);
- SCI_TRACE_LOW("FNH priority = %d",priority);
- tlist->pritority = priority ;
- MMS_GetMmsHeadField(mmsdoc, MMS_READ_REPORT, (long *)&readpt, (char *)0);
- tlist->needreadrpt = readpt;
- SCI_TRACE_LOW("HERE MMIMMS_GetMMSMessage THE READRPT IS %d",tlist->needreadrpt);
- if(state == 2) //是一条彩信,彩信中的时间是根据传过来的数据得到的
- {
- MMS_GetMmsHeadField(mmsdoc, MMS_DATE, (long *)&ldate, NULL);
- SCI_TRACE_LOW("FNH ldate = %ld",ldate);
- tm = CMS_MMSSecond2Tm(ldate+8*3600);
- }
- else if(state == 1) //是一条PUSH,PUSH中的时间是根据当地时间得到的
- {
- ldate = (uint32)CmsGetCurrentTime();
- SCI_TRACE_LOW("FNH ldate = %ld",ldate);
- tm = CMS_MMSSecond2Tm(ldate);
- }
- tlist->date =(uint8*)cms_malloc(32);
- SCI_MEMSET(tlist->date, 0, 32);
- SCI_STRCPY((char*)tlist->date, (char*)CmsTimeToString(tm));
- SCI_TRACE_LOW("FNH tlist->date = %s",tlist->date);
- tlist->state = 1;
- return tlist;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_GetListSubject
- * Purpose:得到实际的标题内容
- * Input: pMessageList:彩信LIST
- * Returns:
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- //注意这儿内存没有释放
- uint8* MMIMMS_GetListSubject(pMessageList tlist)
- {
- unsigned int outlen = 0;
- uint8 * uni_16 = PNULL;
- if(!tlist)
- return NULL;
- if(tlist->subject == 0)
- {
- return NULL;
- }
- outlen = Cms_UTF8toUTF16Len(tlist->subject);
- uni_16 = (uint8 *)cms_malloc(outlen+2);
- SCI_MEMSET(uni_16,0, outlen+2);
- Cms_UTF8toUTF16((char*)tlist->subject,SCI_STRLEN((char*)tlist->subject),outlen,(char*)uni_16);
- uni_16[outlen +1] = 0;
- uni_16[outlen +2] = 0;
- return uni_16;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_UpdateRecvMMSMessage
- * Purpose:接受完彩信后更新对应的管理条目
- * Input: 一条管理list
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_UpdateRecvMMSMessage(pMessageList tlist)
- {
- MMSHANDLE mmsdoc=0;
- pMessageList mlist =PNULL;
- /* first: get new mms document */
- mmsdoc = (MMSHANDLE)MMS_NewMms();
- if(mmsdoc==0)
- return ;
- MMS_SetMmsFile(mmsdoc, (CMS_MMS_S8 *)tlist->filename);
- /* next: parse the source file */
- MMS_DecodeMms(mmsdoc);
- mlist = MMIMMS_GetMMSMessage(mmsdoc,2);
- SCI_TRACE_LOW("FNH mlist->date = %s",mlist->date);
- if ((mlist->date!=NULL)&&(mlist->date[0]))
- {
- SCI_TRACE_LOW("FNH tlist->date = %s",tlist->date);
- if(tlist->date!=NULL)
- {
- cms_free(tlist->date);
- tlist->date = NULL;
- }
- tlist->date = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->date));
- SCI_STRCPY((char*)tlist->date,(char*)mlist->date);
- SCI_TRACE_LOW("FNH tlist->date = %s",tlist->date);
- }
- if(mlist->to_address!=NULL)
- {
- if(tlist->to_address!=NULL)
- {
- cms_free(tlist->to_address);
- tlist->to_address = NULL;
- }
- tlist->to_address = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->to_address));
- SCI_STRCPY((char*)tlist->to_address,(char*)mlist->to_address);
- }
- if(mlist->cc_address!=NULL)
- {
- if(tlist->cc_address!=NULL)
- {
- cms_free(tlist->cc_address);
- tlist->cc_address = NULL;
- }
- tlist->cc_address = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->cc_address));//modify 2005-12-9
- SCI_STRCPY((char*)tlist->cc_address,(char*)mlist->cc_address);
- }
- if(mlist->bcc_address!=NULL)
- {
- if(tlist->bcc_address!=NULL)
- {
- cms_free(tlist->bcc_address);
- tlist->bcc_address = NULL;
- }
- tlist->bcc_address = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->bcc_address));
- SCI_STRCPY((char*)tlist->bcc_address,(char*)mlist->bcc_address);
- }
- if(mlist->sender!=NULL)
- {
- if(tlist->sender!=NULL)
- {
- cms_free(tlist->sender);
- tlist->sender = NULL;
- }
- tlist->sender = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->sender));
- SCI_STRCPY((char*)tlist->sender,(char*)mlist->sender);
- }
- if(mlist->msg_id!=NULL)//added liangliu 2006-2-20 for msg_id used in readprt
- {
- if(tlist->msg_id!=NULL)
- {
- cms_free(tlist->msg_id);
- tlist->msg_id= NULL;
- }
- tlist->msg_id= (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->msg_id));
- SCI_STRCPY((char*)tlist->msg_id,(char*)mlist->msg_id);
- }
- if(mlist->subject!=NULL)
- {
- SCI_TRACE_LOW("FNH mlist->subject len = %d",SCI_STRLEN((char *)mlist->subject));
- if(tlist->subject!=NULL)
- {
- cms_free(tlist->subject);
- tlist->subject = NULL;
- }
- tlist->subject = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->subject)+1);
- SCI_MEMSET(tlist->subject, 0, SCI_STRLEN((char*)mlist->subject)+1);
- SCI_STRCPY((char*)tlist->subject,(char*)mlist->subject);
- }
- else
- SCI_TRACE_LOW("FNH mlist->subject is null");
- //tlist->size = mlist->size;
- tlist->pritority = mlist->pritority;
- tlist->needreadrpt = mlist->needreadrpt;
- tlist->state = mlist->state;
- SCI_TRACE_LOW("fnh tlist->state = %d",tlist->state);
- MMIMMS_FreeMessage(mlist);
- MMS_DeleteMms(mmsdoc);
- SCI_TRACE_LOW("MMIMMS_UpdateRecvMMSMessage OUT-------");
- }
- /* ----------------------------------------------------------------------------
- * Function Name: CMS_MMSSecond2Tm
- * Purpose:获得当前的时间
- * Input: 1970年标准时间
- * Returns: 当地时间结构
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- MMI_TM_T CMS_MMSSecond2Tm(uint32 second)
- {
- uint32 second2000 = 0;
- second2000 = second - (365*23 +366*7)*24*3600;
- return MMI_Second2Tm(second2000);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: CmsTimeToString
- * Purpose: 获得当前时间对应的字符串 指针
- * Input: MMI_TM_T:时间结构
- * Returns: 对应的字符串指针
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- uint8 * CmsTimeToString(MMI_TM_T tm)
- {
- char str[32];
- sprintf((char*)str,"%04d%s%02d%s%02d%s%02d:%02d:%02d",
- tm.tm_year,
- "-",
- tm.tm_mon,
- "-",
- tm.tm_mday,
- " ", //fnh modify 0327 for add one space (43526)
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec
- );
- SCI_TRACE_LOW("FNH time string is %s",str);
- return (uint8*)str;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DeleteFLASHMMS
- * Purpose:删除对应的falsh上彩信文件
- * Input: 当前消息list列表
- * Returns: 当地时间结构
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DeleteFLASHMMS(pMessageList tlist)
- {
- HFS cur_hefs = FFS_INVALID_HANDLE;
- FFS_OVERLAPPED_T overlapped;
- SCI_TRACE_LOW("MMIMMS_DeleteFLASHMMS IN -------");
- FILE_CdMMSPath();
- if (tlist->filename == NULL)
- {
- MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEMMS_OK, PNULL, PNULL);
- SCI_TRACE_LOW("fnh tlist->filename is NULL");
- MMI_TriggerMMITask();
- return;
- }
- if(FILE_CheckExist((const char*)tlist->filename) == 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 *)tlist->filename, SCI_STRLEN((char*)tlist->filename));
- overlapped.offset = 0;
- overlapped.complete_route = MMIVC_CallBackDeleteMMSFile;
- overlapped.param = PNULL;
- ffs_error = FFS_AYS_Delete(g_filetype, (const wchar*)ucs2_name_arr, &overlapped);
- SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
- if( FFS_ERROR_IO_PENDING != ffs_error )
- {
- FFS_Close(g_filetype,cur_hefs);
- }
- }
- else
- {
- MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEMMS_OK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }
- }
- /* ----------------------------------------------------------------------------
- * 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
- )
- {
- MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEMMS_OK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * 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
- )
- {
- if (g_mailbox_status != SEND_OUTBOX_MMS)
- {
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERFILE_OK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }else
- {
- MMK_PostMsg(
- MMIMMS_SAVE_MMS_WAITING_WIN_ID,
- MSG_MMS_DELETEMANAGERFILE_OK,
- PNULL,
- PNULL
- );
- }
- }
- /* ----------------------------------------------------------------------------
- * 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
- )
- {
- MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERINBOXOK, PNULL, PNULL);
- SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
- MMI_TriggerMMITask();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ManagerListCopy
- * Purpose:拷贝生成另外一条彩信信息,另外申请了内存
- * Input: 当前消息list列表
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- pMessageList MMIMMS_ManagerListCopy(pMessageList tlist)
- {
- pMessageList mlist = PNULL;
- if(tlist == NULL)
- {
- return PNULL;
- }
- mlist = (pMessageList)cms_malloc(sizeof(MESSAGELIST));
- SCI_MEMSET(mlist, 0, sizeof(MESSAGELIST));
- if(mlist== NULL)
- {
- return NULL;
- }
- /* copy message heads */
- mlist->size = tlist->size;
- mlist->pritority= tlist->pritority;
- if(tlist->bcc_address)
- {
- mlist->bcc_address= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->bcc_address)+1);
- if(mlist->bcc_address)
- {
- SCI_STRCPY((char*)mlist->bcc_address, (char*)tlist->bcc_address);
- }
- }
- if(tlist->cc_address)
- {
- mlist->cc_address= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->cc_address)+1);
- if(mlist->cc_address)
- {
- SCI_STRCPY((char*)mlist->cc_address, (char*)tlist->cc_address);
- }
- }
- if(tlist->to_address)
- {
- mlist->to_address= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->to_address)+1);
- if(mlist->to_address)
- {
- SCI_STRCPY((char*)mlist->to_address, (char*)tlist->to_address);
- }
- }
- if(tlist->sender)
- {
- mlist->sender= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->sender)+1);
- if(mlist->sender)
- {
- SCI_STRCPY((char*)mlist->sender, (char*)tlist->sender);
- }
- }
- if(tlist->subject)
- {
- mlist->subject= (uint8 *)cms_malloc(SCI_STRLEN((char *)tlist->subject)+1);
- if(mlist->subject)
- {
- SCI_STRCPY((char *)mlist->subject, (char *)tlist->subject);
- }
- }
- if(tlist->filename)
- {
- mlist->filename= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->filename)+1);
- if(mlist->filename)
- {
- SCI_STRCPY((char*)mlist->filename, (char*)tlist->filename);
- }
- }
- if(tlist->date)
- {
- mlist->date= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->date)+1);
- if(mlist->filename)
- {
- SCI_STRCPY((char*)mlist->date, (char*)tlist->date);
- }
- }
- return mlist;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SortManagerFolder
- * Purpose: 对于传入的文件列表进行排序,为了更好的节省时间,采取对与传入的LIST先
- 进行删除,,再进行插入排序
- * Input: pMessageFolder:当前folder
- pMessageList tlist:当前list
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_SortManagerFolder(pMessageFolder folder,pMessageList tlist)
- {
- pMessageList mlist = PNULL;
- g_inboxneedsave = TRUE;
- SCI_TRACE_LOW("MMIMMS_SortManagerFolder in --------");
- if(!folder )
- return ;
- if(folder->messagenumber == 1 )//when there is only one list.no need to sort.
- {
- return ;
- }
- if(folder->root == tlist)
- {
- folder->root = folder->root->next;
- }
- else{
- for(mlist = folder->root; mlist; mlist = mlist->next)
- {
- if(mlist->next == tlist)
- {
- if(tlist->next)
- {
- mlist->next = tlist->next;
- }else
- {
- mlist->next = PNULL;
- }
- break;
- }
- }
- }
- MMIMMS_AddManagerListBySort(folder,tlist);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_AddManagerListBySort
- * Purpose: 将list内容插入管理目录中
- * Input: pMessageFolder:当前folder
- pMessageList tlist:当前list
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_AddManagerListBySort(pMessageFolder folder, pMessageList tlist)
- {
- pMessageList mlist = PNULL,alist = PNULL,blist = PNULL;
- SCI_TRACE_LOW("MMIMMS_AddManagerListBySort IN ");
- if(folder == NULL)
- {
- SCI_TRACE_LOW("MMIMMS_AddManagerListBySort error:folder is NULL");
- return;
- }
- /* temp code start */
- mlist = folder->root ;
- if(tlist->state < mlist->state||(tlist->state == mlist->state&&strcmp((char*)tlist->date,(char*)mlist->date)>0))
- {
- tlist->next = folder->root;
- folder->root = tlist;
- SCI_TRACE_LOW("COME HEHE IS NOT NORMAL");
- return;
- }
- else
- {
- alist = folder->root;
- blist = alist->next;
- while(blist)
- {
- if(tlist->state < blist->state)
- {
- alist->next = tlist;
- tlist->next = blist;
- SCI_TRACE_LOW("here come to the case 2");
- return;
- }else if(tlist->state == blist->state)
- {
- if(strcmp((char*)tlist->date,(char*)blist->date)>0)
- {
- alist->next = tlist;
- tlist->next = blist;
- SCI_TRACE_LOW("here come to the case 3");
- return;
- }
- }
- alist = blist;
- blist = blist->next;
- }
- {
- alist->next = tlist;//最后一种情况,加在最后
- tlist->next = NULL;
- SCI_TRACE_LOW("come to the last case----");
- SCI_TRACE_LOW("come to the last case----");
- return;
- }
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_IsMoreSpace
- * Purpose: 判断是否还有足够空间用以保存彩信
- * Input: void
- * Returns: BOOLEAN
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN MMIMMS_IsMoreSpace(void)
- {
- BOOLEAN result = FALSE;
- uint32 space_size = 0;
- #ifndef WIN32
- space_size = FFS_GetFreeSpace(g_filetype);
- #else
- space_size = 0x0FFF;
- #endif
- if( space_size > LEAVE_SPACE)//剩余200K空间确保系统能够正常运行.
- {
- result =TRUE;
- }
- SCI_TRACE_LOW("MMIVC_IsMoreSpace result = %d", result);
- return(result);
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SendMMSReadRpt
- * Purpose: 发送阅读报告
- * Input: pMessageList:list
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_SendMMSReadRpt(pMessageList tlist)
- {
- MMS_CONFIG_SETTING cfgset;
- MMS_SEND_SETTING sendset;
- P_MMS_DOCUMENT pMms_Doc = NULL;
- pMMS_EDocument p_temp_editdoc;
- char fname[MMS_FILE_NAME_LEN];
- char * readrpt_text_str = NULL;
- int readrpt_text_len = 0 ;
- uint32 ldate = 0;
- char cur_date[40] ;
- char cur_time[40];
- MMI_TM_T tm;
- uint32 curvalue = 0;
- p_temp_editdoc = MMS_New();
- SCI_ASSERT(p_temp_editdoc != NULL);
- SCI_TRACE_LOW("FNH new mms!");
- SCI_TRACE_LOW("FNH before cms_parse_mms");
- MMS_New_Slide(p_temp_editdoc);
- SCI_MEMSET(cur_date,0,sizeof(cur_date));
- SCI_MEMSET(cur_time,0,sizeof(cur_time));
- ldate = (uint32)CmsGetCurrentTime();
- tm = CMS_MMSSecond2Tm(ldate);
- sprintf((char *)cur_date,"%04d%s%02d%s%02d",tm.tm_year,"-",tm.tm_mon,"-",tm.tm_mday);
- sprintf((char *)cur_time,"%02d%s%02d%s%02d",tm.tm_hour,":",tm.tm_min,":",tm.tm_sec);
- // SCI_STRCPY((char *)cur_date,(char *)CmsTimeToString(tm)-;
- SCI_TRACE_LOW("FNH read report cur_date = %s",cur_date);
- SCI_TRACE_LOW("FNH read report cur_len = %d",SCI_STRLEN(cur_date));
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"to: ") + SCI_STRLEN((char *)tlist->to_address)+ SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"subject: ") + SCI_STRLEN((char *)tlist->subject)+ SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"message-id: ") + SCI_STRLEN((char *)tlist->msg_id) + SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"sent: ") + SCI_STRLEN((char *)tlist->date) + SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"was read on: ") + SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)cur_date) + SCI_STRLEN((char *)"r");
- readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)cur_time);
- readrpt_text_str = (char *)cms_malloc(readrpt_text_len + 1);
- SCI_MEMSET(readrpt_text_str,0,readrpt_text_len + 1);
- SCI_STRCPY(readrpt_text_str,(char *)"To: ");
- strcat((char *)readrpt_text_str,(char *)tlist->to_address);
- strcat((char *)readrpt_text_str,(char *)"r");
- SCI_TRACE_LOW("FNH tlist->subject = %s",tlist->subject);
- SCI_TRACE_LOW("FNH subject len = %d",SCI_STRLEN((char *)tlist->subject));
- strcat((char *)readrpt_text_str,(char *)"Subject: ");
- if (!tlist->subject)
- {
- strcat((char *)readrpt_text_str,"");
- }
- else
- {
- strcat((char *)readrpt_text_str,(char *)tlist->subject);
- }
- strcat((char *)readrpt_text_str,(char *)"r");
- strcat((char *)readrpt_text_str,(char *)"Message-id: ");
- strcat((char *)readrpt_text_str,(char *)tlist->msg_id);
- strcat((char *)readrpt_text_str,(char *)"r");
- strcat((char *)readrpt_text_str,(char *)"Sent: ");
- strcat((char *)readrpt_text_str,(char *)tlist->date);
- strcat((char *)readrpt_text_str,(char *)"r");
- strcat((char *)readrpt_text_str,(char *)"r");
- strcat((char *)readrpt_text_str,(char *)"was read on: ");
- strcat((char *)readrpt_text_str,(char *)"r");
- strcat((char *)readrpt_text_str,(char *)cur_date );
- strcat((char *)readrpt_text_str,(char *)"r");
- strcat((char *)readrpt_text_str,(char *)cur_time );
- {
- int16 type = 0;
- char text_fname[MMS_MAX_FILE_NAME_LENGTH] = {0};
- SCI_FILE* fd = 0;
- uint32 value = 0;
- unsigned short buff_size = 0;
- int16 uni_len = 0;
- char* str_utf16 = NULL;
- uni_len = Cms_UTF8toUTF16Len(readrpt_text_str);
- SCI_TRACE_LOW("FNH uni_len = %d",uni_len);
- value = MMI_GetFfsTime();
- sprintf(text_fname,"%lu",value);
- type = MMS_TYPE_TEXT;
- fd =(SCI_FILE*)mmsf_Open((char*)text_fname,"w");
- if ( !fd )
- {
- SCI_TRACE_LOW("open the file error");
- return ;
- }
- str_utf16 = (char*)cms_malloc(uni_len+1);
- SCI_MEMSET(str_utf16,0,uni_len+1);
- Cms_UTF8toUTF16(readrpt_text_str,readrpt_text_len,uni_len,str_utf16);
- buff_size = uni_len;
- mmsf_Write((char *)(&buff_size),1,sizeof(unsigned short),(FILE_HANDLE)fd);
- SCI_TRACE_LOW("FNH buff_size = %d",buff_size);
- mmsf_Write((char *)str_utf16,1,uni_len,(FILE_HANDLE)fd);
- SCI_TRACE_LOW("FNH after write str_utr16 = %s,uni_len = %d",str_utf16,uni_len);
- mmsf_Close((FILE_HANDLE)fd);
- if (str_utf16)
- {
- cms_free(str_utf16);
- str_utf16 = NULL;
- }
- if (MMS_New_Content((unsigned char *)text_fname,type,p_temp_editdoc->slide_cur,p_temp_editdoc))
- {
- SCI_TRACE_LOW("insert text is ok!");
- }
- else
- {
- SCI_TRACE_LOW("insert text is failed!");
- }
- }
- if (tlist->subject)
- {
- unsigned int outlen = 0;
- uint8 * uni_16 =PNULL;
- SCI_TRACE_LOW("FNH current subject is not null!");
- g_p_mms_subject = (char *)cms_malloc(MMIMMS_MAX_SUBJECTS_LEN+1);
- SCI_ASSERT(g_p_mms_subject != NULL);
- SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN+1);
- outlen = Cms_UTF8toUTF16Len(tlist->subject);
- SCI_TRACE_LOW("FNH currentsubject len = %d",outlen);
- uni_16 =(uint8 *)cms_malloc(outlen);
- SCI_MEMSET(uni_16,0,outlen);
- Cms_UTF8toUTF16(tlist->subject,SCI_STRLEN((char *)tlist->subject),outlen,uni_16);
- SCI_TRACE_BUF("FNH currentsubject uni_16 = %x",uni_16,10);
- if ((outlen+2) > MMIMMS_MAX_SUBJECTS_LEN)
- {
- outlen = MMIMMS_MAX_SUBJECTS_LEN-2;
- }
- SCI_MEMCPY((int8 *)(g_p_mms_subject),uni_16,outlen);
- SCI_TRACE_BUF("FNH before enter MMIMMS_OptionSubject g_p_mms_subject = %x",g_p_mms_subject,10);
- if (uni_16)
- {
- cms_free(uni_16);
- uni_16 = NULL;
- }
- MMIMMS_OptionSubject(MMSREAD);
- }
- {
- curvalue = MMI_GetFfsTime();
- SCI_TRACE_LOW("FNH value = %u",curvalue);
- sprintf(fname,"%lu",curvalue);
- strcat(fname, ".mms");
- SCI_TRACE_LOW("FNH fname = %s",fname);
- SCI_TRACE_LOW("FNH start of send message");
- pMms_Doc = (P_MMS_DOCUMENT)cms_integrate_mms(p_temp_editdoc);
- 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");
- MMS_SetMmsHeadField(pMms_Doc, MMS_TO, (long)0, (char *)tlist->sender);
- 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.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("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;
- }
- mmsf_Remove(fname);
- return ;
- }
- MMS_DeleteMms(pMms_Doc);
- pMms_Doc = NULL; // xuelianb modify[2005-11-09]
- }
- MMS_Init();
- cfgset.wap_gateway = (unsigned char *)g_nv_setting_mirror.gateway;
- cfgset.mms_centery = (char *)g_nv_setting_mirror.centre_addr;
- cfgset.wap_port = atoi((char *)g_nv_setting_mirror.port);
- 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;
- }
- SCI_TRACE_LOW("FNH udpinput end");
- SCI_TRACE_LOW("FNH end of send mms");
- return ;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_DisplaySendRecvProgress
- * Purpose: 显示进度条
- * Input: uint32 pos:当前进度
- uint32 totalsize:总的大小
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_DisplaySendRecvProgress(uint32 pos, uint32 totalsize)
- {
- GUI_RECT_T rect;
- if( !MMK_IsFocusWin(MMIMMS_SEND_MMS_WAITING_WIN_ID)
- && !MMK_IsFocusWin(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID)
- )
- {
- return;
- }
- if (pos > 0 && totalsize != 0)
- {
- //display scroll bar
- rect.left = MMIMMS_SCROLL_BAR_LEFT;
- rect.top = MMIMMS_SCROLL_BAR_TOP;
- rect.right = MMIMMS_SCROLL_BAR_LEFT +((MMIMMS_SCROLL_BAR_RIGHT -MMIMMS_SCROLL_BAR_LEFT) * pos)/totalsize;
- rect.bottom = MMIMMS_SCROLL_BAR_BOTTOM;
- //防止滚动条长度超过进度条
- if (MMIMMS_SCROLL_BAR_RIGHT < rect.right)
- {
- rect.right = MMIMMS_SCROLL_BAR_RIGHT;
- }
- //display progress bar
- // GUI_DisplayStaticBmp(MAINLCD_ID,MMIMMS_PROGRESS_BAR_LEFT,MMIMMS_PROGRESS_BAR_TOP,IMAGE_MMS_PROGRESS_BAR_ICON);
- LCD_FillRect(MAINLCD_ID, rect, MMIMMS_SCROLL_BAR_COLOR);
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: RingCallBack
- * Purpose: call back function
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- LOCAL void RingCallBack( void )
- {
- if (0 != s_play_mms_vibrator_timer_id)
- {
- MMK_StopTimer(s_play_mms_vibrator_timer_id);
- s_play_mms_vibrator_timer_id = 0;
- }
- MMIPROFILE_SetVibrator(FALSE, RING_STA_MSG);
- //Callback函数里不能做太多操作,否则占用audio任务时间。
- MMK_PostMsg(VIRTUAL_WIN_ID,MSG_MP3_CONTINUE,PNULL,0);
- MMI_TriggerMMITask();
- }
- /*****************************************************************************/
- // Description : get "to address" totol number
- // Global resource dependence : g_mms_save_in_mem
- // Author: Bruce.Chi
- // Note: used in edit and save moduel
- ///*****************************************************************************/
- uint32 Edit_GetToAddTotalNumber(void)
- {
- return (g_mms_save_in_mem.to.total_num + g_mms_save_in_mem.cc.total_num + g_mms_save_in_mem.bcc.total_num );
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_PlayMMSSound
- * Purpose: 播放声音(这里的声音是信息提示音)
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_PlayMMSSound()
- {
- // MMISET_MSG_RING_TYPE_E ring_type;
- MMIPROFILE_ACT_TYPE_E ring_type;
- MMIPROFILE_PARA_T cur_profile_para = {0,};
- MMIDEFAULT_SetBackLight(TRUE);
- MMIPROFILE_SetVibrator(FALSE, RING_STA_MSG);
- MMIPROFILE_StopRing(RING_STA_MSG);
- if (0 != s_play_mms_vibrator_timer_id)
- {
- MMK_StopTimer(s_play_mms_vibrator_timer_id);
- s_play_mms_vibrator_timer_id = 0;
- }
- //有新的需要播放铃声,把原来的播放铃声先停掉。
- // MMISET_GetMsgRingType( &ring_type );
- MMIPROFILE_GetCurrentProfileModeInfo(&cur_profile_para);
- ring_type = cur_profile_para.msg_type;
- if (CC_IsInCallConnected() || PCcam_is_open())
- {
- // MMISET_PlayRing(FALSE,0,1,MMISET_RING_TYPE_MSG_IN_CALL,PNULL);
- MMIPROFILE_PlayRing(FALSE,1,RING_STA_MSG_IN_CALL,PNULL);
- }
- else if (MMK_IsOpenWin(MMIMPEG4_MAIN_PLAY_WIN_ID)
- #ifdef MMI_APP_6800_PRJ
- #else
- || DC_IsOpened()
- #endif
- || MMK_IsOpenWin(MMIRECORD_PLAY_WIN_ID))
- {
- //不发声
- SCI_TRACE_LOW("mmismsapp_wintab.c MMISMS_HandleNewMsgWin() MSG_SMS_PLAY_RING no sound");
- }
- else
- {
- switch( ring_type )
- {
- case ACT_RING:
- MMIPROFILE_PlayRing(FALSE,1,RING_STA_MSG,RingCallBack);
- if (GPIO_CheckHeadsetStatus()) //耳机插入时启动振动
- {
- if ( 0 == s_play_mms_vibrator_timer_id)
- {
- MMIPROFILE_SetVibrator(TRUE,RING_STA_MSG);
- s_play_mms_vibrator_timer_id = MMK_CreateWinTimer(VIRTUAL_WIN_ID, MMIMMS_VIBRA_TIMEROUT, FALSE);
- }
- }
- break;
- case ACT_VIBRATE:
- if (MMIPROFILE_IsPermitPlayRingOrVib(RING_STA_MSG))
- {
- if ( 0 == s_play_mms_vibrator_timer_id)
- {
- MMIPROFILE_SetVibrator(TRUE,RING_STA_MSG);
- s_play_mms_vibrator_timer_id = MMK_CreateWinTimer(VIRTUAL_WIN_ID, MMIMMS_VIBRA_TIMEROUT, FALSE);
- }
- }
- break;
- case ACT_SILENCE:
- MMIPROFILE_IsPermitPlayRingOrVib(RING_STA_MSG);
- break;
- case ACT_RINGVIBRATE:
- if (MMIPROFILE_IsPermitPlayRingOrVib(RING_STA_MSG))
- {
- MMIPROFILE_PlayRing(FALSE,1,RING_STA_MSG,RingCallBack);
- if ( 0 == s_play_mms_vibrator_timer_id)
- {
- MMIPROFILE_SetVibrator(TRUE,RING_STA_MSG);
- s_play_mms_vibrator_timer_id = MMK_CreateWinTimer(VIRTUAL_WIN_ID, MMIMMS_VIBRA_TIMEROUT, FALSE);
- }
- }
- break;
- default:
- break;
- }
- }
- }
- /*****************************************************************************/
- // Description : is play mms ring vibrator timer
- // Global resource dependence :
- // Author:wancan.you
- // Note:
- /*****************************************************************************/
- PUBLIC BOOLEAN MMIMMS_IsHandleMMSVibratorTimer(uint8 timerid)
- {
- if (timerid == s_play_mms_vibrator_timer_id)
- {
- MMK_StopTimer(s_play_mms_vibrator_timer_id);
- s_play_mms_vibrator_timer_id = 0;
- MMIPROFILE_SetVibrator(FALSE, RING_STA_MSG);
- return TRUE;
- }
- return FALSE;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_IdleWinShowNewMMS
- * Purpose: IDLE界面显示新彩信
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- PUBLIC void MMIMMS_IdleWinShowNewMMS()
- {
- if(g_nv_setting_mirror.retrieve_mode == 1)
- {
- if(g_pautoDownloadMMSRoot)
- {
- SCI_TRACE_LOW("fnh needautodw = %d",g_pautoDownloadMMSRoot->autolist->needautodw);
- if (g_pautoDownloadMMSRoot->autolist->needautodw != 0)
- {
- if (CC_IsInCall())
- {
- //alert : TXT_MMS_CANNOT_DOWNLOAD_IN_CALL
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_CANNOT_DOWNLOAD_IN_CALL,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT,
- PNULL
- );
- }else
- {
- g_filetype = MMICMS_GetCurrentFFS();
- if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
- {
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_MMS_NEWANDFULL,
- IMAGE_PROMPT_ICON_ALERT,
- ALERT_TIMEOUT, PNULL);
- MMIMMS_FreeAutodownList();
- return ;
- }else
- {
- MMICMSBRW_InitCache(); //fnh add
- MMIMMS_Download_CreateDownloadingWin();
- MMIDEFAULT_SetBackLight(TRUE);
- g_backautodownload = TRUE;
- g_netusing = MMS_MSG_NETUSING_STEP1 ;
- //MMK_CreateWin((uint32 *)MMIMMS_SEND_WIN_TAB,PNULL);
- SCI_TRACE_LOW("FNH g_pautoDownloadMMSRoot = %d,g_pautoDownloadMMSRoot->autolist = %d",g_pautoDownloadMMSRoot,g_pautoDownloadMMSRoot->autolist);
- SCI_TRACE_LOW("FNH g_pCurrentList = %d",g_pCurrentList);
- g_pCurrentList = g_pautoDownloadMMSRoot->autolist;
- g_progressneedsize = g_pCurrentList->size;
- MMIMMS_Receive_MMS(g_pCurrentList);
- }
- }
- }
- }
- }
- else
- {
- if(g_donewmms == TRUE)
- {
- MMIMMS_StoreFolder(g_pManager->inboxfolder);
- g_donewmms = FALSE;
- MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX);
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_CL_NEW_MMS,
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- }
- else
- {
- switch(g_delivery_value)
- {
- case MMS_DELIVERY_REPORT_VALUE_RETRIVED:
- SCI_TRACE_LOW("FNH delivery value RETRIVED");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_RETRIVED, //对方已经收到彩信
- IMAGE_PROMPT_ICON_SUCCESS,//IMAGE_PROMPT_ICON_OK,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
- break;
- case MMS_DELIVERY_REPORT_VALUE_REJECTED:
- SCI_TRACE_LOW("FNH delivery value REJECTED");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_REJECTED, //发送彩信被拒绝
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
- break;
- case MMS_DELIVERY_REPORT_VALUE_DEFERRED:
- SCI_TRACE_LOW("FNH delivery value DEFERRED");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_DEFERRED, //发彩信被延期
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
- break;
- case MMS_DELIVERY_REPORT_VALUE_EXPIRED:
- SCI_TRACE_LOW("FNH delivery value EXPIRED");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_EXPIRED, //发送彩信过期
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
- break;
- case MMS_DELIVERY_REPORT_VALUE_UNRECOGNESED:
- SCI_TRACE_LOW("FNH delivery value UNRECOGNESED");
- PUBWIN_OpenPromptAlertWin(
- PUBWIN_SOFTKEY_ONE,
- TXT_DELIVERYRPT_UNRECOGNISED, //发送彩信未被承认
- IMAGE_PROMPT_ICON_ALERT,
- PNULL,
- PNULL
- );
- MMIDEFAULT_SetBackLight(TRUE);
- g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
- break;
- case MMS_DELIVERY_REPORT_VALUE_NONE:
- SCI_TRACE_LOW("FNH delivery value none");
- break;
- default:
- break;
- }
- }
- }
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_IsInit
- * Purpose: MMS是否初始化完毕
- * Input: void
- * Returns: BOOLEAN
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- BOOLEAN MMIMMS_IsInit(void)
- {
- SCI_TRACE_LOW("MMIMMS_IsInit IS COME IN,and the ismmsinit is %d",g_ismmsinit);
- return g_ismmsinit;
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_UdiskFormat
- * Purpose: U盘格式化时删除指定信箱里的MMS
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_UdiskFormat(void)
- {
- if (g_pManager != NULL)
- {
- if(g_pManager->inboxfolder != NULL)
- {
- MMIMMS_FreeFolderForInit(g_pManager->inboxfolder);
- g_pManager->inboxfolder->messagenumber = 0;
- g_pManager->inboxfolder->unsettlednumber = 0 ;
- }
- if(g_pManager->outboxfolder != NULL)
- {
- MMIMMS_FreeFolderForInit(g_pManager->outboxfolder);
- g_pManager->outboxfolder->messagenumber = 0;
- g_pManager->outboxfolder->unsettlednumber = 0 ;
- }
- if(g_pManager->sentfolder != NULL)
- {
- MMIMMS_FreeFolderForInit(g_pManager->sentfolder);
- g_pManager->sentfolder->messagenumber = 0;
- g_pManager->sentfolder->unsettlednumber = 0 ;
- }
- if(g_pManager->draftfolder != NULL)
- {
- MMIMMS_FreeFolderForInit(g_pManager->draftfolder);
- g_pManager->draftfolder->messagenumber = 0;
- g_pManager->draftfolder->unsettlednumber = 0 ;
- }
- }
- MMIMMS_FreeAutodownList();
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_SaveAutoSignMessage
- * Purpose:将自动签名页的编辑文档保存到文件中
- * Input: pMMS_EDocument:自动签名页的编辑文档
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_SaveAutoSignMessage(pMMS_EDocument p_cur_edit)
- {
- P_MMS_DOCUMENT pMms_Doc = NULL;
- char fname[MMS_FILE_NAME_LEN];
- unsigned long value ;
- value = TM_GetTotalSeconds();
- SCI_TRACE_LOW("FNH value = %ld",value);
- sprintf(fname,"%ld",value);
- strcat(fname, ".mms");
- SCI_TRACE_LOW("FNH fname = %s",fname);
- pMms_Doc = (P_MMS_DOCUMENT)cms_integrate_mms(p_cur_edit);
- 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;
- }
- if (p_cur_edit != NULL)
- {
- SCI_TRACE_LOW("FNH before free p_cur_edit");
- MMSDelDocument(p_cur_edit);
- p_cur_edit = NULL;
- g_pcur_signdoc = NULL;
- }
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return;
- }
- if(!MMS_EncodeMms(pMms_Doc))
- {
- SCI_TRACE_LOW("FNH error:MMS_EncodeMms failed");
- if (pMms_Doc)
- {
- MMS_DeleteMms(pMms_Doc);
- pMms_Doc = NULL;
- }
- if (p_cur_edit != NULL)
- {
- SCI_TRACE_LOW("FNH before free p_cur_edit");
- MMSDelDocument(p_cur_edit);
- p_cur_edit = NULL;
- g_pcur_signdoc = NULL;
- }
- mmsf_Remove(fname);
- MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
- return ;
- }
- SCI_TRACE_LOW("FNH before save auto sign file name %s",fname);
- MMIMMS_SaveAutoSign((uint8 *)fname);
- if (p_cur_edit != NULL)
- {
- SCI_TRACE_LOW("FNH before free p_cur_edit");
- MMSDelDocument(p_cur_edit);
- p_cur_edit = NULL;
- g_pcur_signdoc = NULL;
- }
- MMS_DeleteMms(pMms_Doc);
- pMms_Doc = NULL; // xuelianb modify[2005-11-09]
- }
- /* ----------------------------------------------------------------------------
- * Function Name: MMIMMS_ReadAutosign
- * Purpose:从flash资源中读取自动签名页
- * Input: void
- * Returns: void
- * Author:nihongf@mobilesoft.com.cn
- * ----------------------------------------------------------------------------*/
- void MMIMMS_ReadAutosign(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_ReadAutosign IN -------");
- FILE_CdMMSPath();
- if(FILE_CheckExist((const char*)MMSAUTOSIGNFILE) == TRUE)
- {
- SCI_TRACE_LOW("FNH file exist !");
- cur_hefs = FILE_Create((const char*)MMSAUTOSIGNFILE, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
- //SCI_TRACE_BUF("VC: ReadVideo file_name = ", file_name, video_info_ptr->name_len);
- if(FFS_INVALID_HANDLE != cur_hefs)
- {
- FFS_ERROR_E ffs_error = 0;
- SCI_TRACE_LOW("FNH not invalid handle!");
- size = FFS_GetLength(g_filetype,cur_hefs);
- if (size == 0)
- {
- SCI_TRACE_LOW("fnh read autosign file size is zero!");
- FFS_Close(g_filetype,cur_hefs);
- cur_hefs = FFS_INVALID_HANDLE;
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
- 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(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
- 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;
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
- return ;
- }
- overlapped.offset = 0;
- overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
- overlapped.complete_route = MMICMSMMS_CallBackReadAutoSignFile;
- 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 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;
- }
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
- return ;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH OPEN FILE IS FAIL!");
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
- return ;
- }
- }
- else
- {
- SCI_TRACE_LOW("FNH THE FILE IS NOT EXIST!");
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED,PNULL,0);
- return ;
- }
- }
- /* ----------------------------------------------------------------------------
- * 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
- )
- {
- 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;
- }
- SCI_TRACE_LOW("FNH before postmsg read ok!");
- MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
- MMI_TriggerMMITask();
- }
- /*****************************************************************************/
- // Description : EditStringToGlobal
- void MMIMMS_CheckMMSDownloadStatus(void)
- {
- return;
- }
- // Global resource dependence : none
- // Author: Bruce.Chi
- // Input: memory pointer.
- // Output:
- // Note:
- /*****************************************************************************/
- void EditStringToGlobal(MMI_CTRL_ID_T contrl_id,To_Addr* addr_list)
- {
- TEXTEDIT_STRING_INFO_T edit_string;
- TEXTEDIT_STRING_INFO_T addr_edit_string;
- MMI_STRING_T saved_string;
- uint8 *temp_subject = NULL;
- uint8 tele_num[MMIMMS_MAX_ADDRESS_LEN + 2] = {0};
- uint16 index = 0;
- p_MMS_RECEPIENT p_mms_x = g_p_mms_to;
- p_MMS_RECEPIENT p_temp;
- p_MMS_RECEPIENT p_temp_add;
- SCI_ASSERT(addr_list != PNULL);
- //----------get sendnumber
- SCI_MEMSET( &addr_edit_string, 0, sizeof( TEXTEDIT_STRING_INFO_T ) );
- GUIEDITBOX_GetTextEditBoxInfo( contrl_id, &addr_edit_string);
- SCI_ASSERT(FALSE == addr_edit_string.is_ucs2);
- MMIMMS_ParseDestAddr(&addr_edit_string,addr_list);
- p_mms_x = NULL;
- for(index=0;index<addr_list->total_num;index++)
- {
- p_temp_add= (p_MMS_RECEPIENT)cms_malloc(sizeof(MMS_RECEPIENT));
- SCI_ASSERT(p_temp_add != NULL);
- SCI_MEMSET(tele_num, 0, sizeof(tele_num));
- MMI_MEMCPY(tele_num, (MMIMMS_MAX_ADDRESS_LEN + 1), addr_list->addr[index].str_arr, addr_list->addr[index].length, addr_list->addr[index].length);
- SCI_MEMSET(p_temp_add,0,sizeof(MMS_RECEPIENT));
- SCI_MEMSET(p_temp_add->m_address,0,MAX_NAME_LENGTH);
- SCI_STRCPY(p_temp_add->m_address,(char *)tele_num);
- p_temp_add->p_next = NULL;
- if (p_mms_x == NULL)
- {
- p_mms_x = p_temp_add;
- // p_mms_x->p_next = NULL;
- }
- else
- {
- p_temp = p_mms_x;
- while(p_temp->p_next)
- {
- p_temp = p_temp->p_next;
- }
- p_temp->p_next = p_temp_add;
- }
- }
- switch(contrl_id)
- {
- case MMIMMS_ADDR_EDITBOX_CTRL_ID:
- g_p_mms_to = p_mms_x;
- break;
- case MMIMMS_ADDR_EDITBOX_MMSCC_CTRL_ID:
- g_p_mms_cc = p_mms_x;
- break;
- case MMIMMS_ADDR_EDITBOX_MMSBCC_CTRL_ID:
- g_p_mms_bcc = p_mms_x;
- break;
- default:
- break;
- }
- }
- /*****************************************************************************/
- // Description : is allow audio alert window
- // Global resource dependence : none
- // Author: wancan.you
- // Note:
- /*****************************************************************************/
- PUBLIC BOOLEAN MMIMMS_IsAllowAudioAlertWin(void)
- {
- if (MMK_IsFocusWin(MMIMMS_EDIT_PREVIEW_WIN_ID))
- {
- return FALSE;
- }
- return TRUE;
- }