mmimms_main.c
上传用户:tqh2500
上传日期:2014-05-09
资源大小:163k
文件大小:313k
开发平台:

Visual C++

  1. MMI_MEMCPY(
  2. ucs2_ptr,
  3. out_len,
  4. utf8_str_ptr->buf_ptr,
  5. utf8_str_ptr->len,
  6. utf8_str_ptr->len
  7. );
  8. str_out.str_ptr = ucs2_ptr;
  9. }
  10. else
  11. {
  12. str_out.is_ucs2 = TRUE;
  13. str_out.length = j;
  14. str_out.str_ptr = ucs2_ptr;
  15. }
  16. return str_out;
  17. }
  18. /*****************************************************************************/
  19. //  Description : adapter for FILE SYSTEM
  20. // Global resource dependence : 
  21. //  Author: Bruce.Chi
  22. // Note: it's FFS now
  23. ///*****************************************************************************/
  24. LOCAL FFS_ERROR_E FILE_CdRootPath(void)
  25. {
  26. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  27. int ucs2_name_len = 0;
  28. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)PATH_ROOT, strlen(PATH_ROOT));
  29.     return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
  30. }
  31. /*****************************************************************************/
  32. //  Description : adapter for FILE SYSTEM
  33. // Global resource dependence : 
  34. //  Author: Bruce.Chi
  35. // Note: it's FFS now
  36. ///*****************************************************************************/
  37. LOCAL FFS_ERROR_E FILE_CD(const char *path)
  38. {
  39. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  40. int ucs2_name_len = 0;
  41. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)path, strlen(path));
  42. // return FFS_CD(g_filetype, (const wchar*)path);
  43. return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
  44. }
  45. /*****************************************************************************/
  46. //  Description : adapter for FILE SYSTEM
  47. // Global resource dependence : 
  48. //  Author: Bruce.Chi
  49. // Note: it's FFS now
  50. ///*****************************************************************************/
  51. LOCAL FFS_ERROR_E FILE_CdMMSPath(void)
  52. {
  53. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  54. int ucs2_name_len = 0;
  55. FILE_CdRootPath();
  56. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MMIMMS_MMS_DIR, strlen(MMIMMS_MMS_DIR));
  57.     return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
  58. }
  59. /*****************************************************************************/
  60. //  Description : adapter for FILE SYSTEM
  61. // Global resource dependence : 
  62. //  Author: Bruce.Chi
  63. // Note: it's FFS now
  64. ///*****************************************************************************/
  65. LOCAL FFS_ERROR_E FILE_CdMP3Path(void)
  66. {
  67. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  68. int ucs2_name_len = 0;
  69. FILE_CdRootPath();
  70. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MMIMMS_MP3_DIR, strlen(MMIMMS_MP3_DIR));
  71.     return FFS_CD(g_filetype, (const wchar*)ucs2_name_arr);
  72. }
  73. /*****************************************************************************/
  74. //  Description : adapter for FILE SYSTEM
  75. // Global resource dependence : 
  76. //  Author: Bruce.Chi
  77. // Note: it's FFS now
  78. ///*****************************************************************************/
  79. LOCAL FFS_ERROR_E FILE_CreateDir (const char *path)
  80. {
  81. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  82. int ucs2_name_len = 0;
  83. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)path, strlen(path));
  84. return FFS_CreateDir(g_filetype, (wchar *)ucs2_name_arr);
  85. }
  86. /*****************************************************************************/
  87. //  Description : adapter for FILE SYSTEM
  88. // Global resource dependence : 
  89. //  Author: Bruce.Chi
  90. // Note: it's FFS now
  91. ///*****************************************************************************/
  92. LOCAL HFS FILE_Create ( const char *name, uint16 mode)
  93. {
  94. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  95. int ucs2_name_len = 0;
  96. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)name, strlen(name));
  97. return FFS_Create(g_filetype, (wchar *)ucs2_name_arr, mode);
  98. }
  99. /*****************************************************************************/
  100. //  Description : adapter for FILE SYSTEM
  101. // Global resource dependence : 
  102. //  Author: Bruce.Chi
  103. // Note: it's FFS now
  104. ///*****************************************************************************/
  105. LOCAL void FILE_Close (HFS handle)
  106. {
  107. FFS_Close(g_filetype, handle);
  108. }
  109. /*****************************************************************************/
  110. //  Description : adapter for FILE SYSTEM
  111. // Global resource dependence : 
  112. //  Author: Bruce.Chi
  113. // Note: it's FFS now
  114. ///*****************************************************************************/
  115. LOCAL FFS_ERROR_E FILE_Write ( HFS handle, uint8 *buf,  uint32 len, uint32 *transmitted, FFS_OVERLAPPED_T *overlapped_ptr)
  116. {
  117. return FFS_Write(g_filetype, handle, buf, len, transmitted, overlapped_ptr);
  118. }
  119. /*****************************************************************************/
  120. //  Description : set the flag after UDisk is formatted
  121. // Global resource dependence : 
  122. //  Author: Bruce.Chi
  123. // Note:
  124. /*****************************************************************************/
  125. PUBLIC void MMIMMS_ResetAfterUDiskFormat(void)
  126. {
  127.     uint8               gb_path_name[MMIMMS_DEFAULT_DIR_LEN] = {0};
  128.     uint16              ucs2_path_name[MMIMMS_DEFAULT_DIR_LEN] = {0};
  129. SCI_TRACE_LOW("MMIMMS : MMIMMS_ResetAfterUDiskFormat");
  130. //tell sms
  131. MMISMS_DelAllMMSByFormatFFS();
  132.     
  133. /*fnh add 0327 begin*/
  134. MMIMMS_UdiskFormat();
  135. /*fnh add 0327 end*/
  136.     //creat mp3 dir
  137.     sprintf((char*)gb_path_name,"%s",MMIMMS_MMS_DIR);
  138.     GUI_GB2UCS(ucs2_path_name, gb_path_name, (uint16)(sizeof(gb_path_name)));
  139.     MMI_CdRootPath(FS_UDISK);
  140.     FFS_CreateDir(FS_UDISK,(const wchar*)ucs2_path_name);
  141. }
  142. #endif
  143. /*****************************************************************************/
  144. //  Description : adapter for FILE SYSTEM
  145. // Global resource dependence : 
  146. //  Author: Bruce.Chi
  147. // Note: it's FFS now
  148. ///*****************************************************************************/
  149. LOCAL BOOLEAN FILE_CheckExist (const char *file)
  150. {
  151. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  152. int ucs2_name_len = 0;
  153. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)file, strlen(file));
  154. return FFS_CheckExist(g_filetype, (wchar *)ucs2_name_arr);//modify 2006-2-10 liangliu
  155. }
  156. /* ----------------------------------------------------------------------------
  157. * Function Name: MMIMMS_IsMMSFull
  158. * Purpose:初始化时判断当前彩信是否已满
  159. * Input:  void
  160. * Returns: BOOLEAN
  161. * Author:nihongf@mobilesoft.com.cn
  162. * ----------------------------------------------------------------------------*/ 
  163. PUBLIC BOOLEAN MMIMMS_IsMMSFull(void)
  164. {
  165. if (MMIMMS_GetManagerTotalNum() >= MMS_MAX_NUM)
  166. {
  167. return TRUE;
  168. }
  169. else
  170. {
  171. return FALSE;
  172. }
  173. }
  174. /* ----------------------------------------------------------------------------
  175. * Function Name: MMIMMS_GetInboxUnreadMsgNum
  176. * Purpose:得到当前收件箱的PUSH数目
  177. * Input:  void
  178. * Returns: uint16
  179. * Author:nihongf@mobilesoft.com.cn
  180. * ----------------------------------------------------------------------------*/ 
  181. PUBLIC uint16 MMIMMS_GetInboxUnreadMsgNum(void)
  182. {
  183. uint16 unread_msg_num = 0;
  184. if(g_pManager != NULL)
  185. {
  186. SCI_TRACE_LOW("MMIMMS_GetInboxUnreadMsgNum  g_pManager != PNULL COME IN -- ");
  187.        unread_msg_num = g_pManager->inboxfolder->unsettlednumber;
  188. }//xuelianb modify [2006-02-07]
  189. else
  190.             SCI_TRACE_LOW("MMIMMS_GetInboxUnreadMsgNum  g_pManager == PNULL");
  191. }
  192. SCI_TRACE_LOW("fnh unread_msg_num = %d",unread_msg_num);
  193. return unread_msg_num;
  194. }
  195. /*****************************************************************************/
  196. //  Description : TRACE DATA
  197. // Global resource dependence : 
  198. //  Author:
  199. // Note
  200. ///*****************************************************************************/
  201. void cms_trace_data(unsigned char *data,int datalen)
  202. {
  203. int i=0, n=0;
  204. SCI_TRACE_LOW("FNH UI access cms_trace_data: in datalen = %d n", datalen );
  205. while(i < datalen)
  206. {
  207. n = datalen - i;// + 8;
  208. if(n>8)
  209. {
  210. SCI_TRACE_LOW("0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, rn", 
  211. data[i], data[i+1],data[i+2], data[i+3],data[i+4], data[i+5],data[i+6], data[i+7]);
  212. i += 8;
  213. //rvf_delay(2);
  214. }
  215. else
  216. {
  217. while(n > 0)
  218. {
  219. SCI_TRACE_LOW("0x%02x, rn", data[i] );
  220. i++;n--;
  221. }
  222. //rvf_delay(2);
  223. break;
  224. }
  225. }
  226. SCI_TRACE_LOW("FNH UI access cms_trace_data: out datalen = %d n", datalen );
  227. }
  228. /*****************************************************************************/
  229. //  Description : receive push over sms
  230. // Global resource dependence : 
  231. //  Author:
  232. // Note
  233. ///*****************************************************************************/
  234. PUBLIC uint8 MMIMMS_PushRecvSms(APP_MMS_USER_DATA_T *sms_ptr)
  235. {
  236. //wanqiangzh Modify for STK
  237. return MMICMS_PUSH_recv_data(sms_ptr->user_valid_data_t.user_valid_data_arr,
  238. sms_ptr->user_valid_data_t.length);
  239. }
  240. /*****************************************************************************/
  241. //  Description : cat two string
  242. // Global resource dependence : 
  243. //  Author: Bruce.Chi
  244. // Note: should free the dst_ptr->str_ptr
  245. ///*****************************************************************************/
  246. BOOLEAN CatString( MMI_STRING_T *dst_ptr, //out.
  247. MMI_STRING_T *src1_ptr, //in.
  248. MMI_STRING_T *src2_ptr //in.
  249. )
  250. {
  251. #if 1
  252. uint32 str1_len = 0;
  253. uint8 *str1_text_ptr = PNULL;
  254. BOOLEAN str1_need_free = FALSE;
  255. uint32 str2_len = 0;
  256. uint8 *str2_text_ptr = PNULL;
  257. BOOLEAN str2_need_free = FALSE;
  258. SCI_ASSERT(dst_ptr != PNULL);
  259. SCI_ASSERT(src1_ptr != PNULL);
  260. SCI_ASSERT(src2_ptr != PNULL);
  261. //check
  262. if (src1_ptr->length == 0 && src2_ptr->length == 0)
  263. {
  264. return FALSE;
  265. }
  266. //need to convert?
  267. if (src1_ptr->is_ucs2 && !src2_ptr->is_ucs2)
  268. {
  269. //src1 is UCS2, src2 is ASCII
  270. str1_text_ptr = src1_ptr->str_ptr;
  271. str1_len = src1_ptr->length;
  272. str2_text_ptr = ASCtoUCS2(
  273. src2_ptr->str_ptr, 
  274. src2_ptr->length, 
  275. &str2_len
  276. );
  277. str2_need_free = TRUE;
  278. }
  279. else if (!src1_ptr->is_ucs2 && src2_ptr->is_ucs2)
  280. {
  281. //src1 is ASCII
  282. str1_text_ptr = ASCtoUCS2(
  283. src1_ptr->str_ptr,
  284. src1_ptr->length,
  285. &str1_len
  286. );
  287. str2_text_ptr = src2_ptr->str_ptr;
  288. str2_len = src2_ptr->length;
  289. str1_need_free = TRUE;
  290. }
  291. else
  292. {
  293. //need not convert
  294. str1_text_ptr = src1_ptr->str_ptr;
  295. str1_len = src1_ptr->length;
  296. str2_text_ptr = src2_ptr->str_ptr;
  297. str2_len = src2_ptr->length;
  298. }
  299. if (src1_ptr->is_ucs2 || src2_ptr->is_ucs2)
  300. {
  301. dst_ptr->is_ucs2 = TRUE;
  302. }
  303. else
  304. {
  305. dst_ptr->is_ucs2 = FALSE;
  306. }
  307. //merge
  308. dst_ptr->length = str1_len + str2_len;
  309. SCI_TRACE_LOW("dst_ptr->length = %d",dst_ptr->length);
  310. dst_ptr->str_ptr = cms_malloc(dst_ptr->length);
  311. SCI_ASSERT(dst_ptr->str_ptr != PNULL);
  312. SCI_MEMSET(dst_ptr->str_ptr, 0, dst_ptr->length);
  313. if (str1_text_ptr != PNULL)
  314. {
  315. //  SCI_MEMCPY(dst_ptr->str_ptr, str1_text_ptr, str1_len);
  316. MMI_MEMCPY(dst_ptr->str_ptr, dst_ptr->length, str1_text_ptr, str1_len, str1_len);
  317. if (str1_need_free)
  318. {
  319. cms_free(str1_text_ptr);
  320. str1_text_ptr = PNULL;
  321. }
  322. }
  323. if (str2_text_ptr != PNULL)
  324. {
  325. // SCI_MEMCPY(dst_ptr->str_ptr + str1_len, str2_text_ptr, str2_len);
  326. MMI_MEMCPY(dst_ptr->str_ptr + str1_len, dst_ptr->length, str2_text_ptr, str2_len, str2_len);
  327. if (str2_need_free)
  328. {
  329. cms_free(str2_text_ptr);
  330. str2_text_ptr = PNULL;
  331. }
  332. }
  333. #endif
  334. return TRUE;
  335. }
  336. /* ----------------------------------------------------------------------------
  337. * Function Name: MMIMMS_Receive_MMS
  338. * Purpose:回调函数,主要用于push消息处理
  339. * Input:  status:消息状态
  340.   prompt:消息值
  341.   status_value:状态值
  342. * Returns: void
  343. * Author:nihongf@mobilesoft.com.cn
  344. * ----------------------------------------------------------------------------*/ 
  345. int sms_handle_callback(int status,void *prompt,int status_value)
  346. {
  347. NOTIFICATION_IND_SMS_MSG *msg = NULL;
  348.        SCI_TRACE_LOW("sms_handle_callback come in --here!");
  349. switch(status)
  350. {
  351. case SMS_TYPE_DELIVERY_IND:
  352. //可在此处向用户弹出对话框,"用户已收到你的彩信"
  353. //参数prompt就是告诉用户接收成功的字符串,
  354. //VC 下可表达为
  355. //MessageBox(NULL,prompt,"a message",MB_OK);
  356. msg = (NOTIFICATION_IND_SMS_MSG *)prompt;
  357. SCI_TRACE_LOW("sms_handle_callback THE MSG->de_status is%d",msg->de_status);
  358. MMIMMS_DeliveryRpt_Arrive((void *)msg);
  359. MMIMMS_PlayMMSSound();
  360. break;
  361. case SMS_TYPE_NOTIFICATION_IND:
  362. {
  363. //此时参数prompt为MMS url,status_value为url的长度。
  364. //可在此处向用户弹出对话框,"某用户向您发了一封彩信,是否现在接收!"
  365. //将这个值取得,赋到状态机中,就可以使用MMS_RecvMms去接收MMS了。或者将此URL存在文件中
  366. //且放入到未接收邮箱中去。
  367. msg = (NOTIFICATION_IND_SMS_MSG *)prompt;
  368. if (g_nv_setting_mirror.advertisingallowable == MMS_MSG_SETTINGS_OFF) //判断当前彩信是否是广告
  369. {
  370. SCI_TRACE_LOW("SMS_TYPE_NOTIFICATION_IND msg->message_class_vlaue = %d",msg->message_class_value);
  371. if (msg->message_class_value == 0x81)
  372. break;
  373. }
  374. g_filetype = MMICMS_GetCurrentFFS(); //判断当前是否有存储空间。
  375. if (g_filetype != FS_INVALID)
  376. {
  377. MMIMMS_Notification_Arrive((void *)msg);
  378. MMIMMS_PlayMMSSound();
  379. }
  380. }
  381. break;
  382. case SMS_TYPE_UNKNOW:
  383. //可以扔了。
  384. break;
  385. }
  386. return 1;
  387. }
  388. /* ----------------------------------------------------------------------------
  389. * Function Name: MMIMMS_DeliveryRpt_Arrive
  390. * Purpose: 送达报告处理函数
  391. * Input:  void * ptr:push内容
  392. * Returns: void
  393. * Author:nihongf@mobilesoft.com.cn
  394. * ----------------------------------------------------------------------------*/ 
  395. void MMIMMS_DeliveryRpt_Arrive(void * ptr)
  396. {
  397. NOTIFICATION_IND_SMS_MSG *msg = NULL;
  398. msg = (NOTIFICATION_IND_SMS_MSG *)ptr;
  399. SCI_TRACE_LOW("MMIMMS_DeliveryRpt_Arrive IN ");
  400. switch(msg->de_status)
  401. {
  402. SCI_TRACE_LOW("THE MSG STETUS IS %d",msg->de_status);
  403. case MMS_STATUS_VALUE_RETRIVED:
  404. if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
  405. {
  406. PUBWIN_OpenPromptAlertWin(
  407. PUBWIN_SOFTKEY_ONE, 
  408. TXT_DELIVERYRPT_RETRIVED,
  409. IMAGE_PROMPT_ICON_SUCCESS,//IMAGE_PROMPT_ICON_OK, 
  410. PNULL, 
  411. PNULL
  412. );
  413. MMIDEFAULT_SetBackLight(TRUE);
  414. }else
  415. {
  416. g_delivery_value= MMS_DELIVERY_REPORT_VALUE_RETRIVED;
  417. MMIDEFAULT_SetBackLight(TRUE);
  418. }
  419. break;
  420. case MMS_STATUS_VALUE_REJECTED:
  421. if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
  422. {
  423. PUBWIN_OpenPromptAlertWin(
  424. PUBWIN_SOFTKEY_ONE, 
  425. TXT_DELIVERYRPT_REJECTED,
  426. IMAGE_PROMPT_ICON_ALERT, 
  427. PNULL, 
  428. PNULL
  429. );
  430. MMIDEFAULT_SetBackLight(TRUE);
  431. }  
  432. else
  433. {
  434. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_REJECTED;
  435. MMIDEFAULT_SetBackLight(TRUE);
  436. }
  437. break; 
  438. case  MMS_STATUS_VALUE_DEFERRED:
  439. if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
  440. {
  441. PUBWIN_OpenPromptAlertWin(
  442. PUBWIN_SOFTKEY_ONE, 
  443. TXT_DELIVERYRPT_DEFERRED,
  444. IMAGE_PROMPT_ICON_ALERT, 
  445. PNULL, 
  446. PNULL
  447. );
  448. MMIDEFAULT_SetBackLight(TRUE);
  449. }
  450. else
  451. {
  452. g_delivery_value= MMS_DELIVERY_REPORT_VALUE_DEFERRED;
  453. MMIDEFAULT_SetBackLight(TRUE);
  454. }
  455. break; 
  456. case MMS_STATUS_VALUE_EXPIRED:
  457. if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
  458. {
  459. PUBWIN_OpenPromptAlertWin(
  460. PUBWIN_SOFTKEY_ONE, 
  461. TXT_DELIVERYRPT_EXPIRED,
  462. IMAGE_PROMPT_ICON_ALERT, 
  463. PNULL, 
  464. PNULL
  465. );
  466. MMIDEFAULT_SetBackLight(TRUE);
  467. }
  468. else
  469. {
  470. g_delivery_value= MMS_DELIVERY_REPORT_VALUE_EXPIRED;
  471. MMIDEFAULT_SetBackLight(TRUE);
  472. }
  473. break; 
  474. case MMS_STATUS_VALUE_UNRECOGNISED:
  475. if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID))
  476. {
  477. PUBWIN_OpenPromptAlertWin(
  478. PUBWIN_SOFTKEY_ONE, 
  479. TXT_DELIVERYRPT_UNRECOGNISED,
  480. IMAGE_PROMPT_ICON_ALERT, 
  481. PNULL, 
  482. PNULL
  483. );
  484. MMIDEFAULT_SetBackLight(TRUE);
  485. }
  486. else
  487. {
  488. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_UNRECOGNESED;
  489. MMIDEFAULT_SetBackLight(TRUE);
  490. }
  491. break;
  492. default:
  493. break;
  494. }
  495. }
  496. /* ----------------------------------------------------------------------------
  497. * Function Name: MMIMMS_Notification_Arrive
  498. * Purpose: 彩信通知push处理函数
  499. * Input:  void * ptr:push内容
  500. * Returns: void
  501. * Author:nihongf@mobilesoft.com.cn
  502. * ----------------------------------------------------------------------------*/ 
  503. LOCAL void MMIMMS_Notification_Arrive(void * ptr)
  504. {
  505. pMessageList tlist = NULL;
  506. NOTIFICATION_IND_SMS_MSG *msg = NULL;
  507. uint32 value ;
  508. uint32 timevalue = 0 ;
  509. MMI_TM_T tm;
  510. msg = (NOTIFICATION_IND_SMS_MSG *)ptr;
  511. tlist= (pMessageList)cms_malloc(sizeof(MESSAGELIST));
  512. if (!tlist)
  513. {
  514. return ;
  515. }
  516. SCI_MEMSET(tlist, 0, sizeof(MESSAGELIST));
  517. /* FILENAME */
  518. tlist->filename= (uint8*)cms_malloc(MMS_MAX_FILE_NAME_LENGTH);
  519. if (!tlist->filename)
  520. {
  521. MMIMMS_FreeMessage(tlist);
  522. tlist = NULL;
  523. return ;
  524. }
  525. SCI_MEMSET(tlist->filename, 0, MMS_MAX_FILE_NAME_LENGTH);
  526. value = MMI_GetFfsTime();
  527. SCI_TRACE_LOW("the MMIMMS_Notification_Arrive here the MMI_GetFfsTime value is %u",value);
  528. sprintf((char *)tlist->filename,"%lu",value);
  529. strcat((char *)tlist->filename, ".mms");
  530. /* SUBJECT */
  531. if (msg->subject)
  532. {
  533. SCI_TRACE_LOW("fnh msg->subject len = %d",sizeof((char *)msg->subject));
  534. if (!(msg->subject[0] == 0 && msg->subject[1] == 0))
  535. {//有主题
  536. int outlen = 0;
  537. tlist->subject = (uint8*)cms_malloc(MMS_MAX_UTF_SUBJECT_SIZE);
  538. if (!tlist->subject)
  539. {
  540. MMIMMS_FreeMessage(tlist);
  541.               tlist = NULL;
  542.   return ;
  543. }
  544. SCI_MEMSET(tlist->subject, 0, MMS_MAX_UTF_SUBJECT_SIZE);
  545. outlen = Cms_UTF16toUTF8Len(msg->subject);
  546. Cms_UTF16toUTF8(msg->subject, outlen, outlen+1, tlist->subject);
  547. SCI_TRACE_LOW("fnh tlist->subject len is %d",sizeof((char *)tlist->subject));
  548. //temp = Cms_mms_uni16_8(msg->subject + 2);//here the unicode changed to the asc
  549. // SCI_MEMCPY(tlist->subject,(char*) temp);
  550. //cms_free(temp);
  551. //temp = NULL;
  552. }
  553. }
  554. else
  555. {
  556. SCI_TRACE_LOW("FNH msg->subject is null");
  557. }
  558. /* ADDRESS */
  559. if (msg->phone_number)
  560. {
  561. if (msg->phone_number[0] != 0) 
  562. {
  563. tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
  564. if (!tlist->sender)
  565. {
  566. MMIMMS_FreeMessage(tlist);
  567.               tlist = NULL;
  568.   return ;
  569. }
  570. SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
  571. SCI_STRCPY((char*)tlist->sender,(char*) msg->phone_number);
  572. }
  573. else
  574. {
  575. tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
  576. SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
  577. SCI_STRCPY((char*)tlist->sender,(char*)"MMS");
  578. }
  579.   }
  580. else
  581. {
  582. tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
  583. SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
  584. SCI_STRCPY((char*)tlist->sender,(char*)"MMS");
  585. }
  586. /* URL */
  587. tlist->url = (uint8*)cms_malloc(MAX_URL_LENGTH);
  588. if (!tlist->url)
  589. {
  590. MMIMMS_FreeMessage(tlist);
  591. tlist = NULL;
  592. return ;
  593. }
  594. SCI_MEMSET(tlist->url, 0, MAX_URL_LENGTH);
  595. if (msg->mms_url) 
  596. {
  597. SCI_STRCPY((char*)tlist->url, (char*)msg->mms_url);
  598. }
  599. tlist->msg_id= (uint8*)cms_malloc(MMS_MAX_MSGID_LENGTH);
  600. if (!tlist->msg_id)
  601. {
  602. MMIMMS_FreeMessage(tlist);
  603. tlist = NULL;
  604. return ;
  605. }
  606. SCI_MEMSET(tlist->msg_id, 0, MMS_MAX_MSGID_LENGTH);
  607. if (msg->de_msgid) 
  608. {
  609. SCI_STRCPY((char*)tlist->msg_id, (char*)msg->de_msgid);
  610. }
  611. /* DATE */
  612. tlist->date = (uint8*)cms_malloc(MMS_MAX_DATE_LEN);
  613. if (!tlist->date)
  614. {
  615. MMIMMS_FreeMessage(tlist);
  616. tlist = NULL;
  617. return ;
  618. }
  619. SCI_MEMSET(tlist->date, 0, MMS_MAX_DATE_LEN);
  620. /*
  621. TM_GetSysDate(&sys_date);
  622. TM_GetSysTime(&sys_time);
  623. */
  624. timevalue =MMI_GetFfsTime();
  625. tm  = MMI_FatData2Tm(timevalue);
  626. SCI_STRCPY((char*)tlist->date, (char*)CmsTimeToString(tm));
  627. /*fnh add 0509*/
  628. if(msg->expiry_time<=168)
  629. {
  630. tlist->expiry =(uint32)msg->expiry_time;
  631. }
  632. else
  633. {
  634. if((msg->expiry_time%3600)>1800)
  635. {
  636. tlist->expiry=(uint32)(msg->expiry_time/3600)+1;
  637. }
  638. else
  639. {
  640. tlist->expiry=(uint32)(msg->expiry_time/3600);
  641. }
  642. }
  643. /*fnh add 0509*/
  644. tlist->state = 0;
  645. if (g_nv_setting_mirror.retrieve_mode == 1) //当前设置为自动下载
  646. {
  647. tlist->needautodw = 1;
  648. }
  649. tlist->size = msg->msgsize;//modify 2005-12-15 liangliu
  650. MMIMMS_AddManagerList(g_pManager->inboxfolder, tlist);
  651. g_pManager->inboxfolder->unsettlednumber++;
  652. SCI_TRACE_LOW("fnh g_pManager->inboxfolder->unsettlednumber = %d",g_pManager->inboxfolder->unsettlednumber);
  653. SCI_TRACE_LOW("FNH inboxfile_openstatus = %d",inboxfile_openstatus);
  654. SCI_TRACE_LOW("g_nv_setting_mirror.retrieve_mode  IS%d",g_nv_setting_mirror.retrieve_mode);
  655. if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID)&&g_nv_setting_mirror.retrieve_mode == 1)
  656. {
  657. //judge whether it's making a call
  658. if (CC_IsInCall())
  659. {
  660. //alert : TXT_MMS_CANNOT_DOWNLOAD_IN_CALL
  661. PUBWIN_OpenPromptAlertWin(
  662. PUBWIN_SOFTKEY_ONE, 
  663. TXT_MMS_CANNOT_DOWNLOAD_IN_CALL, 
  664. IMAGE_PROMPT_ICON_ALERT, 
  665. ALERT_TIMEOUT, 
  666. PNULL
  667. );
  668. }
  669. else
  670. {
  671. if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
  672. {
  673. PUBWIN_OpenPromptAlertWin(
  674. PUBWIN_SOFTKEY_ONE, 
  675. TXT_MMS_NEWANDFULL, 
  676. IMAGE_PROMPT_ICON_ALERT, 
  677. ALERT_TIMEOUT, PNULL);
  678. }else
  679. {
  680. g_backautodownload = TRUE;
  681. g_inboxneedsave = TRUE;
  682. MMIMMS_Download_CreateDownloadingWin();
  683. MMIDEFAULT_SetBackLight(TRUE);
  684. g_netusing = MMS_MSG_NETUSING_STEP1 ;
  685. //MMK_CreateWin((uint32 *)MMIMMS_SEND_WIN_TAB,PNULL);
  686. g_pCurrentList = g_pManager->inboxfolder->currentmessage;
  687. g_progressneedsize = g_pCurrentList->size;
  688. MMIMMS_Receive_MMS(g_pCurrentList);
  689. }
  690. }
  691. }
  692. else if(MMK_IsFocusWin(MAIN_IDLE_WIN_ID)&&g_nv_setting_mirror.retrieve_mode == 0)
  693. {
  694. MMIMMS_StoreFolder(g_pManager->inboxfolder);
  695. g_savestate = MMS_MSG_SAVEFILE_FOR_NOTIFY;
  696. MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX);
  697. if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
  698. {
  699.   PUBWIN_OpenPromptAlertWin(
  700.   PUBWIN_SOFTKEY_ONE, 
  701.   TXT_MMS_NEWANDFULL, 
  702.   IMAGE_PROMPT_ICON_ALERT, 
  703.   ALERT_TIMEOUT, 
  704.   PNULL);
  705.   MMIDEFAULT_SetBackLight(TRUE);
  706. }else
  707. {
  708.   PUBWIN_OpenPromptAlertWin(
  709.   PUBWIN_SOFTKEY_ONE, 
  710.   TXT_CL_NEW_MMS,
  711.   IMAGE_PROMPT_ICON_ALERT, 
  712.   PNULL, 
  713.   PNULL
  714.   );
  715.   MMIDEFAULT_SetBackLight(TRUE);
  716. }
  717. }else
  718. {
  719. if (inboxfile_openstatus == FFS_INVALID_HANDLE) //FNH add 20060914
  720. {
  721. MMIMMS_StoreFolder(g_pManager->inboxfolder);
  722. MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX);//liangliu@mobilesoft.com.cn  modify for inboxfile of mms  save.
  723. }
  724. else //说明收件箱的索引文件是打开的,这时候需要启动定时器,定期判断文件是否关闭,如果文件关闭了,则进行写文件操作
  725. SCI_TRACE_LOW("fnh inbox file is open");
  726. }
  727. g_inboxneedsave = TRUE;
  728. g_donewmms = TRUE;
  729. if(g_nv_setting_mirror.retrieve_mode == 1)
  730. {
  731. if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
  732. {
  733. PUBWIN_OpenPromptAlertWin(
  734. PUBWIN_SOFTKEY_ONE, 
  735. TXT_MMS_NEWANDFULL, 
  736. IMAGE_PROMPT_ICON_ALERT, 
  737. ALERT_TIMEOUT, PNULL);
  738. MMIMMS_FreeAutodownList();
  739. }else
  740. {
  741. if (g_num_autodw < (MMS_MAX_NUM -  MMIMMS_GetManagerTotalNum()))
  742. {
  743. pAutoDownloadMMSList  autommslist =PNULL;
  744. autommslist =(pAutoDownloadMMSList)mms_Malloc(sizeof(autoDownloadMMSList));
  745. autommslist->autolist = tlist;
  746. SCI_TRACE_LOW("FNH before MMIMMS_AddAutodownList = %d",autommslist);
  747. MMIMMS_AddAutodownList(autommslist);
  748. }
  749. }
  750. }
  751. }
  752. }
  753. /* ----------------------------------------------------------------------------
  754. * Function Name: MMIMMS_Receive_MMS
  755. * Purpose:接受彩信
  756. * Input:  接受彩信,从list列表中获取filename和url
  757. * Returns: void
  758. * Author:nihongf@mobilesoft.com.cn
  759. * ----------------------------------------------------------------------------*/ 
  760. void MMIMMS_Receive_MMS(pMessageList tlist)
  761. {
  762. MMS_RECV_SETTING recvset;
  763. MMS_CONFIG_SETTING cfgset;
  764. //暂时不从设置中读出,只是这儿设定
  765. SCI_TRACE_LOW("here the MMIMMS_Receive_MMS in-------- ");
  766. if (!tlist->url) // [qiangent 2005-03-22]
  767. {
  768. //error handle
  769. SCI_TRACE_LOW("FNH here the tlist->url is null!");
  770. g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
  771. MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
  772. return ;
  773. }
  774. if (!tlist->url[0])
  775. {
  776. //error handle
  777. SCI_TRACE_LOW("FNH here the tlist->url  is EMPTY!");
  778. g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
  779. MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
  780. return ;
  781. }
  782. if(MMS_Init() == 0)
  783. {
  784. SCI_TRACE_LOW("FNH here MMS_Init() == 0");
  785. g_netusing = MMS_MSG_NETUSING_STEP2;//modify 2006-1-3
  786. MMK_PostMsg(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID, MSG_MMS_RECV_FAILED, PNULL, 0);
  787. return;
  788. }
  789. SCI_MEMSET(&cfgset,0,sizeof(MMS_CONFIG_SETTING));
  790. SCI_MEMSET(&recvset,0,sizeof(MMS_RECV_SETTING));
  791. cfgset.wap_gateway = (unsigned char *)g_nv_setting_mirror.gateway;
  792. SCI_TRACE_LOW("FNH cfgset.wap_gateway = %s",cfgset.wap_gateway);
  793. cfgset.mms_centery = (char *)g_nv_setting_mirror.centre_addr;
  794. SCI_TRACE_LOW("FNH cfgset.mms_centery = %s",cfgset.mms_centery);
  795. cfgset.wap_port = atoi((char *)g_nv_setting_mirror.port);
  796. SCI_TRACE_LOW("FNH cfgset.wap_port = %d",cfgset.wap_port);
  797. MMS_Machine_Config(&cfgset);
  798. recvset.immediate_recv = 1;//## 置为0测一下
  799. recvset.get_url = (char*)tlist->url;
  800. SCI_TRACE_LOW("HERE THE URL IS %s",tlist->url);
  801. recvset.recv_vfilename = (char*)tlist->filename;
  802. recvset.recv_msgsize = tlist->size;
  803.     SCI_TRACE_LOW("here will MMS_ReceiveMms--- ");
  804. if(!MMS_ReceiveMms(&recvset,mms_lib_callback))
  805. {
  806. //can not receive the mms
  807. return;
  808. }
  809. }
  810. /* ----------------------------------------------------------------------------
  811. * Function Name: MMIMMS_Receive_MMS
  812. * Purpose:保存彩信
  813. * Input:  pMessageList: 当前彩信LIST
  814. * Returns: void
  815. * Author:nihongf@mobilesoft.com.cn
  816. * ----------------------------------------------------------------------------*/ 
  817. void MMIMMS_SaveMMS(pMessageList tlist)
  818. {
  819. //FILE_HANDLE   cmshandle = 0;
  820. uint8* tempbuf;
  821. //int curroffset;
  822. uint32 filelen = 0;
  823. //static HFS s_hefs = FFS_INVALID_HANDLE;
  824. HFS cur_hefs = FFS_INVALID_HANDLE;
  825. uint32 file_size = 0;
  826. //uint16 *  file_name =NULL;
  827. //uint16 * dir_name =PNULL;
  828. //uint16  unicodelong  = 0 ;
  829. //MMI_STRING_T                     prompt_str;
  830. FFS_ERROR_E efs_error;
  831. FFS_OVERLAPPED_T overlapped;
  832. uint32 transmit;
  833. //uint8 *efs_buf_ptr = PNULL;
  834. FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
  835. if(MMIMMS_IsMoreSpace())
  836. {
  837. SCI_TRACE_LOW("MMIMMS_SaveMMS IN ");
  838. if(tlist->filename == NULL)
  839. {
  840. SCI_TRACE_LOW("FNH tlist->filename is null!");
  841. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  842. return ;
  843. }else
  844. {
  845. mmsf_GetConstFileData((char *)tlist->filename,(char **)&tempbuf,(int *)&filelen);
  846. SCI_TRACE_LOW("fnh filelen = %d",filelen);
  847. SCI_TRACE_LOW("fnh read tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
  848. if (filelen > 0)
  849. {
  850. if(0!=FILE_CdMMSPath())
  851. {
  852.    FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
  853.    FILE_CdMMSPath();
  854. }
  855. cur_hefs = FILE_Create((char*)tlist->filename, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
  856. SCI_TRACE_LOW("fnh cur_hefs = %d",cur_hefs);
  857. if (cur_hefs == FFS_INVALID_HANDLE)
  858. {
  859. //the reason may be that I have not closed the former opened file with the same name
  860. SCI_TRACE_LOW("ERROR THE cur_hefs is invalid");
  861. FILE_Close(cur_hefs); //close former file
  862. cur_hefs = FILE_Create((char*)tlist->filename, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
  863. if (cur_hefs == FFS_INVALID_HANDLE)
  864. {
  865. mmsf_Remove((char *)tlist->filename);
  866. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  867. return ;
  868. }
  869. }
  870. SCI_TRACE_LOW("here creat the mms fike in flash is ok----------");
  871. param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
  872. if (param_save_ptr == NULL)
  873. {
  874. mmsf_Remove((char *)tlist->filename);
  875. FILE_Close(cur_hefs);
  876. cur_hefs = FFS_INVALID_HANDLE;
  877. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  878. return ;
  879. }
  880. SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  881. SCI_TRACE_LOW("fnh tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
  882. // SCI_TRACE_LOW("fnh tempbuf strln is %s",tempbuf);
  883. param_save_ptr->buf_ptr = tempbuf;
  884. param_save_ptr->hefs = cur_hefs;//传递的参数
  885. param_save_ptr->buf_size = filelen;
  886. g_filename = NULL;
  887. g_filename= (char *)cms_malloc(SCI_STRLEN((char*)tlist->filename)+1);
  888. if (g_filename == NULL)
  889. {
  890. if (param_save_ptr != NULL)
  891. {
  892. cms_free(param_save_ptr);
  893. param_save_ptr = NULL;
  894. }
  895. mmsf_Remove((char *)tlist->filename);
  896. FILE_Close(cur_hefs);
  897. cur_hefs = FFS_INVALID_HANDLE;
  898. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  899. return ;
  900. }
  901. SCI_MEMSET(g_filename,0,SCI_STRLEN((char *)tlist->filename)+1);
  902. SCI_STRCPY((char*)g_filename, (char*)tlist->filename);
  903. overlapped.offset = 0;
  904. overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
  905. overlapped.complete_route = SaveFS_SaveMMS_CallBack; 
  906. efs_error = FILE_Write(
  907. cur_hefs,
  908. tempbuf,
  909. filelen,
  910. &transmit,
  911. &overlapped
  912. );
  913. if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
  914. {
  915. if (g_filename != NULL)
  916. {
  917. cms_free(g_filename);
  918. g_filename = NULL;
  919. }
  920. if (param_save_ptr != NULL)
  921. {
  922. cms_free(param_save_ptr);
  923. param_save_ptr = NULL;
  924. }
  925. mmsf_Remove((char *)tlist->filename);
  926. FILE_Close(cur_hefs);
  927. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  928. cur_hefs = FFS_INVALID_HANDLE;
  929. return ;
  930. }
  931. }
  932. else
  933. {
  934. SCI_TRACE_LOW("fnh read mms file len is zero");
  935. mmsf_Remove((char *)tlist->filename);
  936. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  937. return ;
  938. }
  939. }
  940. }
  941. else
  942. {  
  943. SCI_TRACE_LOW("FNH save mms no more space!");
  944. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID, MSG_MMS_SAVE_FAILED, PNULL,PNULL); 
  945. return ;
  946. }
  947. }
  948. /* ----------------------------------------------------------------------------
  949. * Function Name: SaveFS_SaveAutoSign_CallBack
  950. * Purpose: 保存自动签名页回调函数
  951. * Input:  FFS_ERROR_E efs_error, 
  952.   FFS_RESULT result, 
  953.   FFS_PARAM param
  954. * Returns: void
  955. * Author:nihongf@mobilesoft.com.cn
  956. * ----------------------------------------------------------------------------*/ 
  957. LOCAL void SaveFS_SaveAutoSign_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  958. {
  959. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  960. FFS_SAVEFILE_RESULT_T efs_result;
  961. SCI_TRACE_LOW("mmimms:SaveFS_SaveAutoSign_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  962. //init
  963. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  964. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  965. //judge write status
  966.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  967.     {    
  968.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  969.     }
  970.     else
  971.     {
  972. efs_result.write_result = SAVEFS_WRITE_FAIL;
  973.     }
  974. //post message
  975. efs_result.hefs = efs_param_ptr->hefs;
  976. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  977. efs_result.buf_size = efs_param_ptr->buf_size;
  978. SCI_TRACE_LOW("IN autosign before postmsg!");
  979. SCI_TRACE_LOW("size is %d,buffer ptr is %d",efs_result.buf_size,efs_result.buf_ptr);
  980. MMK_PostMsg(
  981. MMIMMS_SAVE_MMS_WAITING_WIN_ID, 
  982. MSG_MMS_SAVE_AUTO_SIGN_OK, 
  983. &efs_result, 
  984. sizeof(FFS_SAVEFILE_RESULT_T)
  985. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  986. if(efs_param_ptr != PNULL)
  987. {
  988. cms_free(efs_param_ptr);
  989. efs_param_ptr = PNULL;
  990. }
  991. }
  992. /* ----------------------------------------------------------------------------
  993. * Function Name: MMIMMS_SaveAutoSign
  994. * Purpose:保存自动签名页到文件系统
  995. * Input:  filename:自动签名页的文件名
  996. * Returns: void
  997. * Author:nihongf@mobilesoft.com.cn
  998. * ----------------------------------------------------------------------------*/ 
  999. void MMIMMS_SaveAutoSign(uint8 * filename)
  1000. {
  1001. FILE_HANDLE   cmshandle = 0;
  1002. uint32 filelen = 0;
  1003. HFS cur_hefs = FFS_INVALID_HANDLE;
  1004. uint8* tempbuf = PNULL;
  1005. FFS_ERROR_E efs_error;
  1006. FFS_OVERLAPPED_T overlapped;
  1007. uint32 transmit;
  1008. FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
  1009. SCI_TRACE_LOW("in MMIMMS_SaveAutoSign");
  1010. cmshandle = mmsf_Open((char*)filename, "rb");
  1011. if (cmshandle > 0)
  1012. {
  1013. filelen=Cms_GetFileLength(cmshandle);
  1014. if (filelen > 0)
  1015. {
  1016. tempbuf = (unsigned char *)cms_malloc(filelen+1);
  1017. if (tempbuf == NULL)
  1018. {
  1019. SCI_TRACE_LOW("fnh tempbuf malloc failed");
  1020. mmsf_Close(cmshandle);
  1021. mmsf_Remove((char*)filename);
  1022. if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
  1023. {
  1024. MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
  1025. }
  1026. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  1027. return;
  1028. }
  1029. SCI_MEMSET(tempbuf, 0, filelen+1);
  1030. mmsf_Read((char*)tempbuf, filelen, 1, cmshandle);
  1031. mmsf_Close(cmshandle);
  1032. mmsf_Remove((char*)filename);
  1033. if(0!=FILE_CdMMSPath())
  1034. {
  1035. FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
  1036. FILE_CdMMSPath();
  1037. }
  1038. cur_hefs = FILE_Create((char*)MMSAUTOSIGNFILE, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
  1039. if (cur_hefs == FFS_INVALID_HANDLE)
  1040. {
  1041. //the reason may be that I have not closed the former opened file with the same name
  1042. FILE_Close(cur_hefs); //close former file
  1043. cur_hefs = FILE_Create((char*)MMSAUTOSIGNFILE, FFS_MODE_OPEN_ALWAYS | FFS_MODE_WRITE);
  1044. if (cur_hefs == FFS_INVALID_HANDLE)
  1045. {
  1046. SCI_TRACE_LOW("fnh save auto sign cretae autosign file is error");
  1047. if (tempbuf != NULL)
  1048. {
  1049. cms_free(tempbuf);
  1050. tempbuf = NULL;
  1051. }
  1052. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  1053. return ;
  1054. }
  1055. }
  1056. SCI_TRACE_LOW("here creat auto sign the mms fike in flash is ok----------");
  1057. param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
  1058. if (param_save_ptr == NULL)
  1059. {
  1060. SCI_TRACE_LOW("fnh save autosign param_save_ptr malloc fail!");
  1061. FILE_Close(cur_hefs);
  1062. cur_hefs = FFS_INVALID_HANDLE;
  1063. if (tempbuf != NULL)
  1064. {
  1065. cms_free(tempbuf);
  1066. tempbuf = NULL;
  1067. }
  1068. if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
  1069. {
  1070. MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
  1071. }
  1072. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  1073. return ;
  1074. }
  1075. SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  1076. param_save_ptr->buf_ptr = tempbuf;
  1077. param_save_ptr->hefs = cur_hefs;//传递的参数
  1078. param_save_ptr->buf_size = filelen;
  1079. overlapped.offset = 0;
  1080. overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
  1081. overlapped.complete_route = SaveFS_SaveAutoSign_CallBack; 
  1082. efs_error = FILE_Write(
  1083. cur_hefs,
  1084. tempbuf,
  1085. filelen,
  1086. &transmit,
  1087. &overlapped
  1088. );
  1089. if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
  1090. {
  1091. if (tempbuf != NULL)
  1092. {
  1093. cms_free(tempbuf);
  1094. tempbuf = NULL;
  1095. }
  1096. if (param_save_ptr != NULL)
  1097. {
  1098. cms_free(param_save_ptr);
  1099. param_save_ptr = NULL;
  1100. }
  1101. FILE_Close(cur_hefs);
  1102. cur_hefs = FFS_INVALID_HANDLE;
  1103. if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
  1104. {
  1105. MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
  1106. }
  1107. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  1108. return ;
  1109. }
  1110. }
  1111. else
  1112. {
  1113. SCI_TRACE_LOW("FNH save auto sign file len is zero!");
  1114. mmsf_Close(cmshandle);
  1115. mmsf_Remove((char*)filename);
  1116. if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
  1117. {
  1118. MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
  1119. }
  1120. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  1121. return;
  1122. }
  1123. }
  1124. else
  1125. {
  1126. SCI_TRACE_LOW("FNH save auto sign open file is error!");
  1127. if (MMK_IsOpenWin(MAIN_PROMPTALERT_WIN_ID)) //46351
  1128. {
  1129. MMK_CloseWin(MAIN_PROMPTALERT_WIN_ID);
  1130. }
  1131. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  1132. return;
  1133. }
  1134. }
  1135. /* ----------------------------------------------------------------------------
  1136. * Function Name: MMIMMS_SaveVideo
  1137. * Purpose: 保存视频文件
  1138. * Input:  videoname:视频文件名
  1139.       vidoBuf:视频内容指针
  1140.   videoBufLen:视频内容大小
  1141. * Returns: DOWN_ERROR_TYPE
  1142. * Author:nihongf@mobilesoft.com.cn
  1143. * ----------------------------------------------------------------------------*/ 
  1144. DOWN_ERROR_TYPE MMIMMS_SaveVideo(uint8 * videoname, uint8 *vidoBuf, uint32 vidoBufLen)
  1145. {
  1146. //FILE_HANDLE   cmshandle = 0;
  1147.    // int curroffset = 0;
  1148. //uint32 filelen = 0;
  1149. //static HFS s_hefs = FFS_INVALID_HANDLE;
  1150. HFS cur_hefs = FFS_INVALID_HANDLE;
  1151. //uint16 * dir_name =PNULL;
  1152. //uint16  unicodelong  = 0 ;
  1153. //MMI_STRING_T                     prompt_str = {0};
  1154. FFS_ERROR_E efs_error = FFS_NO_ERROR;
  1155. FFS_OVERLAPPED_T overlapped = {0};
  1156. uint32 transmit = 0;
  1157. //uint8 *efs_buf_ptr = PNULL;
  1158. FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
  1159. FILE_DEV_E_T          vedio_device_type =FS_UDISK;
  1160. FILE_DEV_E_T          default_device_type = FS_UDISK;
  1161.     DOWN_ERROR_TYPE       result = DOWN_ERROR_NONE;
  1162. uint16 ucs2_vedio_name_arr[UCS2_NAME_MAX_LEN] = {0};
  1163. int ucs2_vedio_name_len = 0;
  1164. if((PNULL == videoname) || (PNULL == vidoBuf) || (0 == vidoBufLen))
  1165. {
  1166. SCI_TRACE_LOW("vedio name is null");
  1167. return DOWN_ERROR_DEFAULT;
  1168. }
  1169. ucs2_vedio_name_len = GUI_GB2UCS(ucs2_vedio_name_arr, (uint8 *)videoname, strlen((char*)videoname));
  1170. //得到当前的ring, pic文件保存设置
  1171. if (g_mmi_exist_sd)
  1172. {
  1173. default_device_type   = MMIMultim_GetVideoSavePath();
  1174. }
  1175. else
  1176.     {
  1177. default_device_type   = FS_UDISK;
  1178.     }
  1179. //如果SD卡不存在,就保存到U盘
  1180. if (!g_mmi_exist_sd)
  1181. {
  1182. vedio_device_type = FS_UDISK;
  1183. }
  1184. //SDcard and Udisk 都存在,一个空间满,就选择保存到另一个。
  1185. else
  1186.     {
  1187. if (vidoBufLen >= MMI_GetFreeSpace(default_device_type))
  1188. {
  1189. if (FS_UDISK == default_device_type)
  1190. {
  1191. vedio_device_type = FS_MMC;
  1192. }
  1193. else
  1194. {
  1195. vedio_device_type = FS_UDISK;
  1196. }
  1197. }
  1198. else
  1199. {
  1200. vedio_device_type = default_device_type;
  1201. }
  1202.     }
  1203.  
  1204.     SCI_TRACE_LOW("MMIMMS_SaveVideo:video len = %d",vidoBufLen);
  1205.     SCI_TRACE_LOW("MMIMMS_SaveVideo:free space = %d",FFS_GetFreeSpace(vedio_device_type));
  1206. //两个盘都满,退出保存
  1207. if (vidoBufLen >= MMI_GetFreeSpace(vedio_device_type))
  1208. {
  1209. return DOWN_ERROR_FULL;
  1210. }
  1211. SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(), come in!");
  1212. if (FFS_ERROR_NONE ==  MMIMEPG4_CdMpeg4Path(vedio_device_type))
  1213. {
  1214. //判断是否有重名文件
  1215. if (FFS_CheckExist(vedio_device_type,(const wchar*)ucs2_vedio_name_arr))
  1216. {   
  1217. return DOWN_ERROR_REPEAT;
  1218. }
  1219. cur_hefs = FFS_Create(vedio_device_type,(const wchar*)ucs2_vedio_name_arr, FFS_MODE_CREATE_NEW|FFS_MODE_WRITE);
  1220. SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo():FFS_Create g_handle_result is %d",cur_hefs);
  1221. if(FFS_INVALID_HANDLE != cur_hefs)
  1222. {
  1223. //异步写文件数据
  1224. param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
  1225. SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  1226. param_save_ptr->buf_ptr = vidoBuf;
  1227. param_save_ptr->hefs = cur_hefs;//传递的参数
  1228. param_save_ptr->buf_size = vidoBufLen;
  1229. param_save_ptr->dev_type = vedio_device_type;
  1230. overlapped.offset = 0;
  1231. overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
  1232. overlapped.complete_route = SaveFS_SaveVideo_CallBack; 
  1233. efs_error = FFS_Write(
  1234. vedio_device_type,
  1235. cur_hefs,
  1236. vidoBuf,
  1237. vidoBufLen,
  1238. &transmit,
  1239. &overlapped
  1240. );
  1241. result = DOWN_ERROR_NONE;
  1242. switch (efs_error)
  1243. {
  1244. case FFS_ERROR_IO_PENDING:
  1245.     SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(): FFS_Write start");
  1246. break;
  1247. case FFS_ERROR_NONE:
  1248. SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(): FFS_Write success");
  1249. break;
  1250. default:
  1251.     SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveVideo(): FFS_Write failed. ffs_error=%d", efs_error);
  1252.           result = DOWN_ERROR_DEFAULT;
  1253. }
  1254. }
  1255. }
  1256. else
  1257. {
  1258. result = DOWN_ERROR_DEFAULT; //cd mp4 path fail
  1259. }
  1260. return result;
  1261. }
  1262. /* ----------------------------------------------------------------------------
  1263. * Function Name: MMIMMS_SaveMp3
  1264. * Purpose: 保存MP3文件
  1265. * Input:  mp3name:MP3文件名
  1266.       mp3Buf:MP3内容指针
  1267.   mp3BufLen:MP3内容大小
  1268. * Returns: DOWN_ERROR_TYPE
  1269. * Author:nihongf@mobilesoft.com.cn
  1270. * ----------------------------------------------------------------------------*/ 
  1271. DOWN_ERROR_TYPE MMIMMS_SaveMp3(uint8 * mp3name, uint8* mp3Buf, uint32 mp3BufLen)
  1272. {
  1273. HFS cur_hefs = FFS_INVALID_HANDLE;
  1274. FFS_ERROR_E efs_error = FFS_NO_ERROR;
  1275. FFS_OVERLAPPED_T overlapped = {0};
  1276. uint32 transmit = 0;
  1277. //uint8 *efs_buf_ptr = PNULL;
  1278. FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
  1279. FILE_DEV_E_T     mp3_device_type      = FS_UDISK;
  1280. FILE_DEV_E_T     default_device_type  = FS_UDISK;
  1281.     DOWN_ERROR_TYPE             result = DOWN_ERROR_NONE;
  1282. uint16 ucs2_mp3_name_arr[UCS2_NAME_MAX_LEN] = {0};
  1283. int ucs2_mp3_name_len = 0;
  1284. if((PNULL == mp3name) || (PNULL == mp3Buf) || (0 == mp3BufLen))
  1285. {
  1286. SCI_TRACE_LOW("mp3 name is null");
  1287. return DOWN_ERROR_DEFAULT;
  1288. }
  1289. ucs2_mp3_name_len = GUI_GB2UCS(ucs2_mp3_name_arr, (uint8 *)mp3name, strlen((char*)mp3name));
  1290. SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(), come in!");
  1291. if (g_mmi_exist_sd)
  1292. {
  1293. // default_device_type   = MMIMultim_GetRingSavePath();
  1294. default_device_type = MMIMultim_GetMP3SavePath();
  1295. }
  1296. else
  1297.     {
  1298. default_device_type   = FS_UDISK;
  1299.     }
  1300.  
  1301. //如果SD卡不存在,就保存到U盘
  1302. if (!g_mmi_exist_sd)
  1303. {
  1304. mp3_device_type = FS_UDISK;
  1305. }
  1306. //SDcard and Udisk 都存在,一个空间满,就选择保存到另一个。
  1307. else
  1308.     {
  1309. if (mp3BufLen >= MMI_GetFreeSpace(default_device_type))
  1310. {
  1311. if (FS_UDISK == default_device_type)
  1312. {
  1313. mp3_device_type = FS_MMC;
  1314. }
  1315. else
  1316. {
  1317. mp3_device_type = FS_UDISK;
  1318. }
  1319. }
  1320. else
  1321. {
  1322. mp3_device_type = default_device_type;
  1323. }
  1324.     }
  1325.     SCI_TRACE_LOW("MMIMMS_SaveMp3:MP3 len = %d",mp3BufLen);
  1326.     SCI_TRACE_LOW("MMIMMS_SaveMp3:free space = %d",FFS_GetFreeSpace(mp3_device_type));
  1327.     SCI_TRACE_LOW("MMIMMS_SaveMp3:mp3_device_type = %d", mp3_device_type);
  1328. //两个盘都满,退出保存
  1329. if (mp3BufLen >= MMI_GetFreeSpace(mp3_device_type))
  1330. {
  1331. return DOWN_ERROR_FULL;
  1332. }
  1333. SCI_TRACE_LOW((char *)ucs2_mp3_name_arr);
  1334. if ( MMIMP3_CdMp3Path(mp3_device_type) )
  1335. {
  1336. //判断是否有重名文件
  1337. if (FFS_CheckExist(mp3_device_type,(const wchar*)ucs2_mp3_name_arr))
  1338. {   
  1339. return DOWN_ERROR_REPEAT;
  1340. }
  1341. cur_hefs = FFS_Create(
  1342. mp3_device_type,
  1343. (const wchar*)ucs2_mp3_name_arr, 
  1344. FFS_MODE_CREATE_NEW|FFS_MODE_WRITE
  1345. );
  1346. SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3():FFS_Create cur_hefs is %d",cur_hefs);
  1347. if(FFS_INVALID_HANDLE != cur_hefs)
  1348. {
  1349. //异步写文件数据
  1350. param_save_ptr = (FFS_SAVEFILE_RESULT_T *)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
  1351. SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  1352. param_save_ptr->buf_ptr = mp3Buf;
  1353. param_save_ptr->hefs = cur_hefs;//传递的参数
  1354. param_save_ptr->buf_size = mp3BufLen;
  1355. param_save_ptr->dev_type = mp3_device_type;
  1356. overlapped.offset = 0;
  1357. overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
  1358. overlapped.complete_route = SaveFS_SaveMp3_CallBack; 
  1359. efs_error = FFS_Write(
  1360. mp3_device_type,
  1361. cur_hefs,
  1362. mp3Buf,
  1363. mp3BufLen,
  1364. &transmit,
  1365. &overlapped
  1366. );
  1367. result = DOWN_ERROR_NONE;
  1368. switch (efs_error)
  1369. {
  1370. case FFS_ERROR_IO_PENDING:
  1371.     SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(): FFS_Write start");
  1372. break;
  1373. case FFS_ERROR_NONE:
  1374. SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(): FFS_Write success");
  1375. break;
  1376. default:
  1377.     SCI_TRACE_LOW("mmimms_main.c, MMIMMS_SaveMp3(): FFS_Write failed. ffs_error=%d", efs_error);
  1378.           result = DOWN_ERROR_DEFAULT;
  1379. }
  1380. }
  1381. }
  1382. else
  1383. {
  1384. result = DOWN_ERROR_DEFAULT;  //cd mp3 path fail
  1385. }
  1386. //      PUBWIN_CloseWaitingMessageWin(MMICMSBRW_WAITINGMESSAGE_WIN_ID);
  1387. return result;
  1388. }
  1389. /* ----------------------------------------------------------------------------
  1390. * Function Name: MMIMMS_ReadMMS
  1391. * Purpose:从flash资源中读取彩信
  1392. * Input:  pMessageList:彩信LIST
  1393. * Returns: void
  1394. * Author:nihongf@mobilesoft.com.cn
  1395. * ----------------------------------------------------------------------------*/ 
  1396. void MMIMMS_ReadMMS(pMessageList tlist)
  1397. {
  1398.     FFS_OVERLAPPED_T                 overlapped;
  1399.     HFS cur_hefs = FFS_INVALID_HANDLE;
  1400.     uint32                           size = 0;
  1401.     uint32                      transmitted;
  1402.     FFS_READFILE_RESULT_T   * param_read_ptr =PNULL;
  1403. SCI_TRACE_LOW("MMIMMS_ReadMMS IN -------");
  1404. FILE_CdMMSPath();
  1405. if (tlist->filename == NULL)
  1406. {
  1407. SCI_TRACE_LOW("fnh the tlist->filename is NULL");
  1408. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1409. return;
  1410. }
  1411. //tlist->state = 2;//added 2005-12-8 for readed mms. delete 12-28 for readrpt state change after read end 
  1412. SCI_TRACE_LOW("THE FILE NAME IS %s",tlist->filename);
  1413. if(FILE_CheckExist((const char*)tlist->filename) == TRUE)
  1414. {
  1415. cur_hefs = FILE_Create((const char*)tlist->filename, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
  1416.         //SCI_TRACE_BUF("VC: ReadVideo file_name = ", file_name, video_info_ptr->name_len);
  1417.         if(FFS_INVALID_HANDLE != cur_hefs)
  1418.         {
  1419. FFS_ERROR_E ffs_error = 0;
  1420. size = FFS_GetLength(g_filetype,cur_hefs);
  1421. if (size == 0)
  1422. {
  1423. SCI_TRACE_LOW("fnh read file size is zero!");
  1424. FFS_Close(g_filetype,cur_hefs);
  1425. cur_hefs = FFS_INVALID_HANDLE;
  1426.   MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1427. return;
  1428. }
  1429. param_read_ptr = (FFS_READFILE_RESULT_T*)cms_malloc(sizeof(FFS_READFILE_RESULT_T));
  1430. if (param_read_ptr == NULL)
  1431. {
  1432. SCI_TRACE_LOW("fnh param_read_ptr malloc fail");
  1433. FFS_Close(g_filetype,cur_hefs);
  1434. cur_hefs = FFS_INVALID_HANDLE;
  1435.   MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1436. return;
  1437. }
  1438. SCI_MEMSET(param_read_ptr, 0, sizeof(FFS_READFILE_RESULT_T))
  1439. param_read_ptr->hefs = cur_hefs;//传递的参数
  1440. param_read_ptr->buf_size = size;
  1441. param_read_ptr->buf_ptr = (uint8*)cms_malloc(param_read_ptr->buf_size);
  1442. if (param_read_ptr->buf_ptr == NULL)
  1443. {
  1444. SCI_TRACE_LOW("fnh param_read_ptr->buf_ptr malloc fail");
  1445. FFS_Close(g_filetype,cur_hefs);
  1446. cur_hefs = FFS_INVALID_HANDLE;
  1447. if (param_read_ptr != NULL)
  1448. {
  1449. cms_free(param_read_ptr);
  1450. param_read_ptr = NULL;
  1451. }
  1452.   MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1453. return;
  1454. }
  1455. overlapped.offset = 0;
  1456. overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
  1457. overlapped.complete_route = MMIVC_ReadMMS_CallBack;
  1458. ffs_error = FFS_Read(g_filetype,cur_hefs, 
  1459. param_read_ptr->buf_ptr,
  1460. param_read_ptr->buf_size, 
  1461. &transmitted, 
  1462. &overlapped);
  1463.             
  1464.             if( ( FFS_ERROR_IO_PENDING != ffs_error )&&(FFS_NO_ERROR != ffs_error))
  1465.             {
  1466. SCI_TRACE_LOW("FNH read mms file error!");
  1467. FFS_Close(g_filetype,cur_hefs);
  1468. cur_hefs = FFS_INVALID_HANDLE;
  1469. if (param_read_ptr->buf_ptr != NULL)
  1470. {
  1471. cms_free(param_read_ptr->buf_ptr);
  1472. param_read_ptr->buf_ptr= NULL;
  1473. }
  1474. if (param_read_ptr != NULL)
  1475. {
  1476. cms_free(param_read_ptr);
  1477. param_read_ptr = NULL;
  1478. }
  1479.   MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1480. return ;
  1481.            }
  1482.         }
  1483.         else//打开文件失败
  1484.         {
  1485. SCI_TRACE_LOW("fnh the mms file is open fail");
  1486. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1487. return ;
  1488. }
  1489. }
  1490. else
  1491. {
  1492. SCI_TRACE_LOW("fnh the mms file is not exist");
  1493. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_FAILED, PNULL, PNULL);
  1494. return;
  1495. }
  1496. }
  1497. /* ----------------------------------------------------------------------------
  1498. * Function Name: SaveFS_SaveMMS_CallBack
  1499. * Purpose: 保存彩信回调函数
  1500. * Input:  FFS_ERROR_E efs_error, 
  1501.   FFS_RESULT result, 
  1502.   FFS_PARAM param
  1503. * Returns: void
  1504. * Author:nihongf@mobilesoft.com.cn
  1505. * ----------------------------------------------------------------------------*/ 
  1506. void SaveFS_SaveMMS_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  1507. {
  1508. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  1509. FFS_SAVEFILE_RESULT_T efs_result;
  1510. SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  1511. //init
  1512. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  1513. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  1514. //judge write status
  1515.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  1516.     {    
  1517.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  1518.     }
  1519.     else
  1520.     {
  1521. efs_result.write_result = SAVEFS_WRITE_FAIL;
  1522.     }
  1523. //post message
  1524. efs_result.hefs = efs_param_ptr->hefs;
  1525. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  1526. efs_result.buf_size = efs_param_ptr->buf_size;
  1527. SCI_TRACE_LOW("fnh efs_result.buf_ptr len = %d",SCI_STRLEN((char *)efs_result.buf_ptr));
  1528. MMK_PostMsg(
  1529. MMIMMS_SAVE_MMS_WAITING_WIN_ID, 
  1530. MSG_MMS_SAVE_OK, 
  1531. &efs_result, 
  1532. sizeof(FFS_SAVEFILE_RESULT_T)
  1533. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  1534. //free in param
  1535. if(efs_param_ptr != PNULL)
  1536. {
  1537. cms_free(efs_param_ptr);
  1538. efs_param_ptr = PNULL;
  1539. }
  1540. }
  1541. /* ----------------------------------------------------------------------------
  1542. * Function Name: SaveFS_SaveVideo_CallBack
  1543. * Purpose: 保存视频回调函数
  1544. * Input:  FFS_ERROR_E efs_error, 
  1545.   FFS_RESULT result, 
  1546.   FFS_PARAM param
  1547. * Returns: void
  1548. * Author:nihongf@mobilesoft.com.cn
  1549. * ----------------------------------------------------------------------------*/ 
  1550. LOCAL void SaveFS_SaveVideo_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  1551. {
  1552. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  1553. FFS_SAVEFILE_RESULT_T efs_result;
  1554. SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  1555. //init
  1556. SCI_MEMSET(&efs_result, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  1557. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  1558. if ( PNULL == efs_param_ptr )
  1559. {
  1560. return;
  1561. }
  1562. efs_result    = *efs_param_ptr;
  1563. //judge write status
  1564.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  1565.     {    
  1566.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  1567. SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, SAVEFS_WRITE_SUCCEED");
  1568.     }
  1569.     else
  1570.     {
  1571. efs_result.write_result = SAVEFS_WRITE_FAIL;
  1572. SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, SAVEFS_WRITE_FAIL");
  1573.     }
  1574. MMK_PostMsg(
  1575. VIRTUAL_WIN_ID, 
  1576. MSG_MMS_VIDEO_SAVE_OK, 
  1577. &efs_result, 
  1578. sizeof(FFS_SAVEFILE_RESULT_T)
  1579. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  1580. //free in param
  1581. if(efs_param_ptr != PNULL)
  1582. {
  1583. cms_free(efs_param_ptr);
  1584. efs_param_ptr = PNULL;
  1585. }
  1586. }
  1587. /* ----------------------------------------------------------------------------
  1588. * Function Name: SaveFS_SaveMp3_CallBack
  1589. * Purpose: 保存MP3回调函数
  1590. * Input:  FFS_ERROR_E efs_error, 
  1591.   FFS_RESULT result, 
  1592.   FFS_PARAM param
  1593. * Returns: void
  1594. * Author:nihongf@mobilesoft.com.cn
  1595. * ----------------------------------------------------------------------------*/ 
  1596. LOCAL void SaveFS_SaveMp3_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  1597. {
  1598. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  1599. FFS_SAVEFILE_RESULT_T efs_result;
  1600. SCI_TRACE_LOW("mmimms:SaveFS_SaveMMS_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  1601. //init
  1602. SCI_MEMSET(&efs_result, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  1603. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  1604. //judge write status
  1605.   if ( PNULL == efs_param_ptr )
  1606. {
  1607. return;
  1608. }
  1609. efs_result = *efs_param_ptr;
  1610. //judge write status
  1611.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  1612.     {    
  1613.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  1614.     }
  1615.     else
  1616.     {
  1617. efs_result.write_result = SAVEFS_WRITE_FAIL;
  1618.     }
  1619. MMK_PostMsg(
  1620. VIRTUAL_WIN_ID, 
  1621. MSG_MMS_MP3_SAVE_OK, 
  1622. &efs_result, 
  1623. sizeof(FFS_SAVEFILE_RESULT_T)
  1624. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  1625. //free in param
  1626. if(efs_param_ptr != PNULL)
  1627. {
  1628. cms_free(efs_param_ptr);
  1629. efs_param_ptr = PNULL;
  1630. }
  1631. }
  1632. /* ----------------------------------------------------------------------------
  1633. * Function Name: MMIVC_ReadMMS_CallBack
  1634. * Purpose: 读取彩信的回调函数
  1635. * Input:  FFS_ERROR_E a, 
  1636.   FFS_RESULT result, 
  1637.   FFS_PARAM param
  1638. * Returns: void
  1639. * Author:nihongf@mobilesoft.com.cn
  1640. * ----------------------------------------------------------------------------*/ 
  1641. LOCAL void MMIVC_ReadMMS_CallBack(
  1642. FFS_ERROR_E a, 
  1643. FFS_RESULT result, 
  1644. FFS_PARAM param
  1645. )
  1646. {
  1647. FFS_READFILE_RESULT_T *efs_param_ptr = PNULL;
  1648. FFS_READFILE_RESULT_T         efs_result;
  1649. //init
  1650. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  1651. efs_param_ptr = (FFS_READFILE_RESULT_T *)param;
  1652. //post message
  1653. efs_result.hefs = efs_param_ptr->hefs;
  1654. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  1655. efs_result.buf_size = efs_param_ptr->buf_size;
  1656. if(efs_param_ptr != PNULL)
  1657. {
  1658. cms_free(efs_param_ptr);
  1659. efs_param_ptr = PNULL;
  1660. }
  1661. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
  1662. MMI_TriggerMMITask();
  1663. }
  1664. /* ----------------------------------------------------------------------------
  1665. * Function Name: MMIMMS_GetMMSMessage
  1666. * Purpose:从对应的 彩信文档中获取对应的管理信息条目
  1667. * Input:  彩信文档
  1668. * Returns: 对应的列表信息
  1669. * Author:nihongf@mobilesoft.com.cn
  1670. * ----------------------------------------------------------------------------*/ 
  1671. pMessageList MMIMMS_GetMMSMessage(MMSHANDLE mmsdoc,int state)
  1672. {
  1673.     pMessageList tlist = PNULL;
  1674. char  buffer[512];
  1675. uint32            ldate;
  1676. uint32            priority;
  1677. uint32            readpt;
  1678. char * receiver_str = NULL;
  1679. MMI_TM_T tm;
  1680. tlist = (pMessageList)cms_malloc(sizeof(MESSAGELIST));
  1681. if(!tlist)
  1682. {
  1683. SCI_TRACE_LOW("HERE MALLOC THE SPACE IS ERROR------");
  1684. return 0;
  1685. }
  1686.    SCI_TRACE_LOW("MMIMMS_GetMMSMessage come in ------");
  1687.    SCI_MEMSET(tlist, 0, sizeof(MESSAGELIST));
  1688. /* set value to it */
  1689. SCI_MEMSET(buffer, 0, sizeof(buffer));
  1690. MMS_GetMmsFile(mmsdoc, buffer);
  1691. tlist->filename = (uint8 *)cms_malloc(SCI_STRLEN(buffer)+1);
  1692. if(tlist->filename)
  1693. {
  1694. SCI_STRCPY((char*)tlist->filename, buffer);
  1695. }
  1696. SCI_MEMSET(buffer, 0, sizeof(buffer));
  1697. MMS_GetMmsHeadField(mmsdoc, MMS_SUBJECT, 0, buffer);
  1698.  SCI_TRACE_BUF("the subject is not empty,is %x",buffer,10);
  1699. if(buffer[0]||buffer[1])
  1700. {
  1701. int outlen = 0;
  1702. SCI_TRACE_LOW("FNH buffer len is %d",SCI_STRLEN((char *)buffer));
  1703. outlen = Cms_UTF16toUTF8Len(buffer+2);
  1704. tlist->subject =(uint8*)cms_malloc(outlen);
  1705. SCI_MEMSET(tlist->subject, 0, outlen);
  1706. Cms_UTF16toUTF8(buffer+2, sizeof(buffer)-2, outlen, tlist->subject);
  1707. tlist->subject[outlen] = 0;
  1708. }
  1709. else 
  1710. SCI_TRACE_LOW("fnh buffer is null");
  1711. receiver_str = NULL;
  1712. MMS_GetMmsHeadField(mmsdoc, MMS_TO, 0, (char *)&receiver_str);
  1713. // SCI_TRACE_LOW("the to str is %s",receiver_str);
  1714. if(receiver_str)
  1715. {
  1716. tlist->to_address = (uint8 *)cms_malloc(SCI_STRLEN(receiver_str)+1);
  1717. if(tlist->to_address)
  1718. {
  1719. SCI_STRCPY((char*)tlist->to_address, receiver_str);
  1720. // SCI_TRACE_LOW("fnh get to = %s",tlist->to_address);
  1721. }
  1722. cms_free(receiver_str);
  1723. receiver_str = NULL;
  1724. }
  1725. else
  1726. {
  1727. tlist->to_address =  (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
  1728. SCI_MEMSET(tlist->to_address, 0, MMS_MAX_ADDRESS_LENGTH);
  1729. SCI_STRCPY((char*)tlist->to_address,(char*)MMIMMS_UNKNOWN_SENDER);
  1730. }
  1731. SCI_MEMSET(buffer, 0, sizeof(buffer));
  1732. MMS_GetMmsHeadField(mmsdoc, MMS_FROM, 0, buffer);
  1733. if(buffer[0])
  1734. {
  1735. tlist->sender = (uint8*)cms_malloc(SCI_STRLEN(buffer)+1);
  1736. if(tlist->sender)
  1737. {
  1738. SCI_STRCPY((char*)tlist->sender, buffer);
  1739. }
  1740.  SCI_TRACE_LOW("the sender is not empty,is %s",tlist->sender);
  1741. }
  1742. else
  1743. {
  1744. tlist->sender= (uint8 *)cms_malloc(MMS_MAX_ADDRESS_LENGTH);
  1745. SCI_MEMSET(tlist->sender, 0, MMS_MAX_ADDRESS_LENGTH);
  1746. SCI_STRCPY((char*)tlist->sender,(char*)"MMS");
  1747. }
  1748. receiver_str = NULL;
  1749. MMS_GetMmsHeadField(mmsdoc, MMS_CC, 0, (char *)&receiver_str);
  1750. if(receiver_str)
  1751. {
  1752. tlist->cc_address= (uint8 *)cms_malloc(SCI_STRLEN(receiver_str)+1);
  1753. if(tlist->cc_address)
  1754. {
  1755. SCI_STRCPY((char*)tlist->cc_address, receiver_str);
  1756. }
  1757. cms_free(receiver_str);
  1758. receiver_str = NULL;
  1759. }
  1760. receiver_str = NULL;
  1761.     MMS_GetMmsHeadField(mmsdoc, MMS_BCC, 0, (char *)&receiver_str);
  1762. if(receiver_str)
  1763. {
  1764. tlist->bcc_address=  (uint8*)cms_malloc(SCI_STRLEN(receiver_str)+1);
  1765. if(tlist->bcc_address)
  1766. {
  1767. SCI_STRCPY((char*)tlist->bcc_address, receiver_str);
  1768. }
  1769. cms_free(receiver_str);
  1770. receiver_str = NULL;
  1771. }
  1772. SCI_MEMSET(buffer, 0, MMS_MAX_MSGID_LENGTH);//added liangliu 2006-2-20 for msg_id used in  readrpt.
  1773. MMS_GetMmsHeadField(mmsdoc, MMS_TRANSACTION_ID, 0, buffer);
  1774. if(buffer[0])
  1775. {
  1776. tlist->msg_id=  (uint8 *)cms_malloc(SCI_STRLEN(buffer)+1);
  1777. if(tlist->msg_id)
  1778. {
  1779. SCI_STRCPY((char*)tlist->msg_id, buffer);
  1780. }
  1781. }
  1782. MMS_GetMmsHeadField(mmsdoc, MMS_PRIORITY, (long *)&priority, (char *)0);
  1783. SCI_TRACE_LOW("FNH priority = %d",priority);
  1784. tlist->pritority = priority ;
  1785. MMS_GetMmsHeadField(mmsdoc, MMS_READ_REPORT, (long *)&readpt, (char *)0);
  1786. tlist->needreadrpt = readpt;
  1787. SCI_TRACE_LOW("HERE MMIMMS_GetMMSMessage THE READRPT IS %d",tlist->needreadrpt);
  1788. if(state == 2) //是一条彩信,彩信中的时间是根据传过来的数据得到的
  1789. {
  1790.      MMS_GetMmsHeadField(mmsdoc, MMS_DATE, (long *)&ldate, NULL);
  1791.  SCI_TRACE_LOW("FNH ldate = %ld",ldate);
  1792.      tm = CMS_MMSSecond2Tm(ldate+8*3600);
  1793. }
  1794. else if(state == 1) //是一条PUSH,PUSH中的时间是根据当地时间得到的
  1795. {
  1796. ldate = (uint32)CmsGetCurrentTime();
  1797. SCI_TRACE_LOW("FNH ldate = %ld",ldate);
  1798. tm = CMS_MMSSecond2Tm(ldate);       
  1799. }
  1800.  tlist->date =(uint8*)cms_malloc(32);
  1801. SCI_MEMSET(tlist->date, 0, 32);
  1802. SCI_STRCPY((char*)tlist->date, (char*)CmsTimeToString(tm));
  1803. SCI_TRACE_LOW("FNH tlist->date = %s",tlist->date);
  1804. tlist->state = 1;
  1805. return tlist;
  1806. }
  1807. /* ----------------------------------------------------------------------------
  1808. * Function Name: MMIMMS_GetListSubject
  1809. * Purpose:得到实际的标题内容
  1810. * Input:  pMessageList:彩信LIST
  1811. * Returns: 
  1812. * Author:nihongf@mobilesoft.com.cn
  1813. * ----------------------------------------------------------------------------*/ 
  1814. //注意这儿内存没有释放
  1815. uint8* MMIMMS_GetListSubject(pMessageList   tlist)
  1816. {
  1817. unsigned int outlen = 0;
  1818. uint8 * uni_16 = PNULL;
  1819. if(!tlist)
  1820. return NULL;
  1821. if(tlist->subject == 0)
  1822. {
  1823. return NULL;
  1824. }
  1825. outlen =  Cms_UTF8toUTF16Len(tlist->subject);
  1826. uni_16 = (uint8 *)cms_malloc(outlen+2);
  1827. SCI_MEMSET(uni_16,0, outlen+2);
  1828. Cms_UTF8toUTF16((char*)tlist->subject,SCI_STRLEN((char*)tlist->subject),outlen,(char*)uni_16);
  1829. uni_16[outlen +1] = 0;
  1830. uni_16[outlen +2] = 0;
  1831. return uni_16;
  1832. }
  1833. /* ----------------------------------------------------------------------------
  1834. * Function Name: MMIMMS_UpdateRecvMMSMessage
  1835. * Purpose:接受完彩信后更新对应的管理条目
  1836. * Input:  一条管理list
  1837. * Returns: void
  1838. * Author:nihongf@mobilesoft.com.cn
  1839. * ----------------------------------------------------------------------------*/ 
  1840. void  MMIMMS_UpdateRecvMMSMessage(pMessageList tlist)
  1841. {
  1842. MMSHANDLE mmsdoc=0;
  1843. pMessageList  mlist =PNULL;
  1844. /* first: get new mms document */
  1845. mmsdoc = (MMSHANDLE)MMS_NewMms();
  1846. if(mmsdoc==0)
  1847. return ;
  1848. MMS_SetMmsFile(mmsdoc, (CMS_MMS_S8 *)tlist->filename);
  1849. /* next: parse the source file */
  1850. MMS_DecodeMms(mmsdoc);
  1851. mlist = MMIMMS_GetMMSMessage(mmsdoc,2);
  1852. SCI_TRACE_LOW("FNH mlist->date = %s",mlist->date);
  1853. if ((mlist->date!=NULL)&&(mlist->date[0]))
  1854. {
  1855. SCI_TRACE_LOW("FNH tlist->date = %s",tlist->date);
  1856. if(tlist->date!=NULL)
  1857. {
  1858. cms_free(tlist->date);
  1859. tlist->date = NULL;
  1860. }
  1861. tlist->date = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->date));
  1862. SCI_STRCPY((char*)tlist->date,(char*)mlist->date);
  1863. SCI_TRACE_LOW("FNH tlist->date = %s",tlist->date);
  1864. }
  1865. if(mlist->to_address!=NULL)
  1866. {
  1867. if(tlist->to_address!=NULL)
  1868. {
  1869. cms_free(tlist->to_address);
  1870. tlist->to_address = NULL;
  1871. }
  1872. tlist->to_address = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->to_address));
  1873. SCI_STRCPY((char*)tlist->to_address,(char*)mlist->to_address);
  1874. }
  1875. if(mlist->cc_address!=NULL)
  1876. {
  1877. if(tlist->cc_address!=NULL)
  1878. {
  1879. cms_free(tlist->cc_address);
  1880. tlist->cc_address = NULL;
  1881. }
  1882. tlist->cc_address = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->cc_address));//modify 2005-12-9
  1883. SCI_STRCPY((char*)tlist->cc_address,(char*)mlist->cc_address);
  1884. }
  1885. if(mlist->bcc_address!=NULL)
  1886. {
  1887. if(tlist->bcc_address!=NULL)
  1888. {
  1889. cms_free(tlist->bcc_address);
  1890. tlist->bcc_address = NULL;
  1891. }
  1892. tlist->bcc_address = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->bcc_address));
  1893. SCI_STRCPY((char*)tlist->bcc_address,(char*)mlist->bcc_address);
  1894. }
  1895. if(mlist->sender!=NULL)
  1896. {
  1897. if(tlist->sender!=NULL)
  1898. {
  1899. cms_free(tlist->sender);
  1900. tlist->sender = NULL;
  1901. }
  1902. tlist->sender = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->sender));
  1903. SCI_STRCPY((char*)tlist->sender,(char*)mlist->sender);
  1904. }
  1905. if(mlist->msg_id!=NULL)//added liangliu 2006-2-20 for msg_id used in readprt
  1906. {
  1907. if(tlist->msg_id!=NULL)
  1908. {
  1909. cms_free(tlist->msg_id);
  1910. tlist->msg_id= NULL;
  1911. }
  1912. tlist->msg_id= (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->msg_id));
  1913. SCI_STRCPY((char*)tlist->msg_id,(char*)mlist->msg_id);
  1914. }
  1915. if(mlist->subject!=NULL)
  1916. {
  1917. SCI_TRACE_LOW("FNH mlist->subject len = %d",SCI_STRLEN((char *)mlist->subject));
  1918. if(tlist->subject!=NULL)
  1919. {
  1920. cms_free(tlist->subject);
  1921. tlist->subject = NULL;
  1922. }
  1923. tlist->subject = (uint8*)cms_malloc(SCI_STRLEN((char*)mlist->subject)+1);
  1924. SCI_MEMSET(tlist->subject, 0, SCI_STRLEN((char*)mlist->subject)+1);
  1925. SCI_STRCPY((char*)tlist->subject,(char*)mlist->subject);
  1926. }
  1927. else
  1928. SCI_TRACE_LOW("FNH mlist->subject is null");
  1929. //tlist->size = mlist->size;
  1930. tlist->pritority = mlist->pritority;
  1931. tlist->needreadrpt = mlist->needreadrpt;
  1932. tlist->state = mlist->state;
  1933. SCI_TRACE_LOW("fnh tlist->state = %d",tlist->state);
  1934. MMIMMS_FreeMessage(mlist);
  1935. MMS_DeleteMms(mmsdoc);
  1936. SCI_TRACE_LOW("MMIMMS_UpdateRecvMMSMessage OUT-------");
  1937. }
  1938. /* ----------------------------------------------------------------------------
  1939. * Function Name: CMS_MMSSecond2Tm
  1940. * Purpose:获得当前的时间
  1941. * Input:  1970年标准时间
  1942. * Returns: 当地时间结构
  1943. * Author:nihongf@mobilesoft.com.cn
  1944. * ----------------------------------------------------------------------------*/ 
  1945. MMI_TM_T CMS_MMSSecond2Tm(uint32 second)
  1946. {
  1947.     uint32 second2000 = 0;
  1948.     second2000 = second - (365*23 +366*7)*24*3600;
  1949. return MMI_Second2Tm(second2000);
  1950.     
  1951. }
  1952. /* ----------------------------------------------------------------------------
  1953. * Function Name: CmsTimeToString
  1954. * Purpose: 获得当前时间对应的字符串 指针
  1955. * Input:  MMI_TM_T:时间结构
  1956. * Returns: 对应的字符串指针
  1957. * Author:nihongf@mobilesoft.com.cn
  1958. * ----------------------------------------------------------------------------*/ 
  1959. uint8 * CmsTimeToString(MMI_TM_T tm)
  1960. {
  1961. char str[32];
  1962.     sprintf((char*)str,"%04d%s%02d%s%02d%s%02d:%02d:%02d",
  1963.         tm.tm_year,
  1964.         "-",
  1965.         tm.tm_mon,
  1966.         "-",
  1967.         tm.tm_mday,
  1968.         "  ", //fnh modify 0327 for add one space  (43526)
  1969.         tm.tm_hour,
  1970.         tm.tm_min,  
  1971.         tm.tm_sec
  1972. );
  1973. SCI_TRACE_LOW("FNH time string is %s",str);
  1974. return (uint8*)str;
  1975. }
  1976. /* ----------------------------------------------------------------------------
  1977. * Function Name: MMIMMS_DeleteFLASHMMS
  1978. * Purpose:删除对应的falsh上彩信文件
  1979. * Input:  当前消息list列表
  1980. * Returns: 当地时间结构
  1981. * Author:nihongf@mobilesoft.com.cn
  1982. * ----------------------------------------------------------------------------*/ 
  1983. void MMIMMS_DeleteFLASHMMS(pMessageList tlist)
  1984. {
  1985.     HFS cur_hefs = FFS_INVALID_HANDLE;
  1986.     FFS_OVERLAPPED_T                 overlapped;
  1987. SCI_TRACE_LOW("MMIMMS_DeleteFLASHMMS IN -------");
  1988. FILE_CdMMSPath();
  1989. if (tlist->filename == NULL)
  1990. {
  1991. MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEMMS_OK, PNULL, PNULL);
  1992. SCI_TRACE_LOW("fnh tlist->filename is NULL");
  1993. MMI_TriggerMMITask();
  1994. return;
  1995. }
  1996. if(FILE_CheckExist((const char*)tlist->filename) == TRUE)
  1997. {
  1998. FFS_ERROR_E ffs_error = 0;
  1999. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  2000. int ucs2_name_len = 0;
  2001. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)tlist->filename, SCI_STRLEN((char*)tlist->filename));
  2002. overlapped.offset         = 0;
  2003. overlapped.complete_route = MMIVC_CallBackDeleteMMSFile;
  2004. overlapped.param          = PNULL;
  2005. ffs_error  =  FFS_AYS_Delete(g_filetype, (const wchar*)ucs2_name_arr, &overlapped);
  2006. SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
  2007. if(  FFS_ERROR_IO_PENDING != ffs_error )
  2008. {
  2009. FFS_Close(g_filetype,cur_hefs);
  2010. }
  2011. }
  2012. else
  2013. {
  2014. MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEMMS_OK, PNULL, PNULL);
  2015. SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
  2016. MMI_TriggerMMITask();
  2017. }
  2018. }
  2019. /* ----------------------------------------------------------------------------
  2020. * Function Name: MMIVC_CallBackDeleteMMSFile
  2021. * Purpose: 删除彩信的回调函数
  2022. * Input:  FFS_ERROR_E a, 
  2023.   FFS_RESULT result, 
  2024.   FFS_PARAM param
  2025. * Returns: void
  2026. * Author:nihongf@mobilesoft.com.cn
  2027. * ----------------------------------------------------------------------------*/ 
  2028. LOCAL void MMIVC_CallBackDeleteMMSFile(
  2029.  FFS_ERROR_E a, 
  2030.  FFS_RESULT result, 
  2031.  FFS_PARAM param
  2032.  )
  2033. {
  2034. MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEMMS_OK, PNULL, PNULL);
  2035. SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
  2036. MMI_TriggerMMITask();
  2037. }
  2038. /* ----------------------------------------------------------------------------
  2039. * Function Name: MMIVC_CallBackDeleteManagerFile
  2040. * Purpose: 删除彩信管理目录的回调函数
  2041. * Input:  FFS_ERROR_E a, 
  2042.   FFS_RESULT result, 
  2043.   FFS_PARAM param
  2044. * Returns: void
  2045. * Author:nihongf@mobilesoft.com.cn
  2046. * ----------------------------------------------------------------------------*/ 
  2047. LOCAL void MMIVC_CallBackDeleteManagerFile(
  2048.  FFS_ERROR_E a, 
  2049.  FFS_RESULT result, 
  2050.  FFS_PARAM param
  2051.  )
  2052. {
  2053. if (g_mailbox_status != SEND_OUTBOX_MMS)
  2054. {
  2055. MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERFILE_OK, PNULL, PNULL);
  2056. SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
  2057. MMI_TriggerMMITask();
  2058. }else
  2059. MMK_PostMsg(
  2060. MMIMMS_SAVE_MMS_WAITING_WIN_ID, 
  2061. MSG_MMS_DELETEMANAGERFILE_OK, 
  2062. PNULL, 
  2063. PNULL
  2064. );
  2065. }
  2066. }
  2067. /* ----------------------------------------------------------------------------
  2068. * Function Name: MMIVC_CallBackDeleteManagerInboxFile
  2069. * Purpose: 删除彩信收件箱管理目录的回调函数
  2070. * Input:  FFS_ERROR_E a, 
  2071.   FFS_RESULT result, 
  2072.   FFS_PARAM param
  2073. * Returns: void
  2074. * Author:nihongf@mobilesoft.com.cn
  2075. * ----------------------------------------------------------------------------*/ 
  2076. LOCAL void MMIVC_CallBackDeleteManagerInboxFile(
  2077.  FFS_ERROR_E a, 
  2078.  FFS_RESULT result, 
  2079.  FFS_PARAM param
  2080.  )
  2081. {
  2082. MMK_PostMsg(VIRTUAL_WIN_ID, MSG_MMS_DELETEMANAGERINBOXOK, PNULL, PNULL);
  2083. SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
  2084. MMI_TriggerMMITask();
  2085. }
  2086. /* ----------------------------------------------------------------------------
  2087. * Function Name: MMIMMS_ManagerListCopy
  2088. * Purpose:拷贝生成另外一条彩信信息,另外申请了内存
  2089. * Input:  当前消息list列表
  2090. * Returns: void
  2091. * Author:nihongf@mobilesoft.com.cn
  2092. * ----------------------------------------------------------------------------*/ 
  2093. pMessageList MMIMMS_ManagerListCopy(pMessageList   tlist)
  2094. {
  2095. pMessageList  mlist = PNULL;
  2096. if(tlist == NULL)
  2097. {
  2098. return PNULL;
  2099. }
  2100. mlist  = (pMessageList)cms_malloc(sizeof(MESSAGELIST));
  2101. SCI_MEMSET(mlist, 0, sizeof(MESSAGELIST));
  2102. if(mlist== NULL)
  2103. {
  2104. return NULL;
  2105. }
  2106. /* copy message heads */
  2107. mlist->size = tlist->size;
  2108. mlist->pritority= tlist->pritority;
  2109. if(tlist->bcc_address)
  2110. {
  2111. mlist->bcc_address= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->bcc_address)+1);
  2112. if(mlist->bcc_address)
  2113. {
  2114. SCI_STRCPY((char*)mlist->bcc_address, (char*)tlist->bcc_address);
  2115. }
  2116. }
  2117. if(tlist->cc_address)
  2118. {
  2119. mlist->cc_address= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->cc_address)+1);
  2120. if(mlist->cc_address)
  2121. {
  2122. SCI_STRCPY((char*)mlist->cc_address, (char*)tlist->cc_address);
  2123. }
  2124. }
  2125. if(tlist->to_address)
  2126. {
  2127. mlist->to_address= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->to_address)+1);
  2128. if(mlist->to_address)
  2129. {
  2130. SCI_STRCPY((char*)mlist->to_address, (char*)tlist->to_address);
  2131. }
  2132. }
  2133. if(tlist->sender)
  2134. {
  2135.    mlist->sender= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->sender)+1); 
  2136. if(mlist->sender)
  2137. {
  2138. SCI_STRCPY((char*)mlist->sender, (char*)tlist->sender);
  2139. }
  2140. }
  2141. if(tlist->subject)
  2142. {
  2143. mlist->subject= (uint8 *)cms_malloc(SCI_STRLEN((char *)tlist->subject)+1); 
  2144. if(mlist->subject)
  2145. {
  2146. SCI_STRCPY((char *)mlist->subject, (char *)tlist->subject);
  2147. }
  2148. }
  2149. if(tlist->filename)
  2150. {
  2151. mlist->filename= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->filename)+1);
  2152. if(mlist->filename)
  2153. {
  2154. SCI_STRCPY((char*)mlist->filename, (char*)tlist->filename);
  2155. }
  2156. }
  2157. if(tlist->date)
  2158. {
  2159. mlist->date= (uint8 *)cms_malloc(SCI_STRLEN((char*)tlist->date)+1);
  2160. if(mlist->filename)
  2161. {
  2162. SCI_STRCPY((char*)mlist->date, (char*)tlist->date);
  2163. }
  2164. }
  2165. return mlist;
  2166. }
  2167. /* ----------------------------------------------------------------------------
  2168. * Function Name: MMIMMS_SortManagerFolder
  2169. * Purpose: 对于传入的文件列表进行排序,为了更好的节省时间,采取对与传入的LIST先
  2170.                                          进行删除,,再进行插入排序
  2171. * Input:  pMessageFolder:当前folder
  2172.   pMessageList tlist:当前list
  2173. * Returns: void
  2174. * Author:nihongf@mobilesoft.com.cn
  2175. * ----------------------------------------------------------------------------*/ 
  2176. void MMIMMS_SortManagerFolder(pMessageFolder folder,pMessageList tlist)
  2177. {
  2178. pMessageList  mlist = PNULL;
  2179. g_inboxneedsave = TRUE;
  2180. SCI_TRACE_LOW("MMIMMS_SortManagerFolder in --------");
  2181. if(!folder )
  2182. return ;
  2183. if(folder->messagenumber == 1 )//when there is only one list.no need to sort.
  2184. {
  2185. return ;
  2186. }
  2187. if(folder->root  == tlist)
  2188.     {
  2189.         folder->root = folder->root->next;
  2190.     }
  2191.     else{
  2192. for(mlist = folder->root; mlist; mlist = mlist->next)
  2193. {
  2194. if(mlist->next == tlist)
  2195. {
  2196. if(tlist->next)
  2197. {
  2198. mlist->next = tlist->next;
  2199. }else
  2200. {
  2201. mlist->next = PNULL;
  2202. }
  2203. break;
  2204. }
  2205. }
  2206.     }
  2207. MMIMMS_AddManagerListBySort(folder,tlist);
  2208. }
  2209. /* ----------------------------------------------------------------------------
  2210. * Function Name: MMIMMS_AddManagerListBySort
  2211. * Purpose: 将list内容插入管理目录中
  2212. * Input:  pMessageFolder:当前folder
  2213.   pMessageList tlist:当前list
  2214. * Returns: void
  2215. * Author:nihongf@mobilesoft.com.cn
  2216. * ----------------------------------------------------------------------------*/ 
  2217. void MMIMMS_AddManagerListBySort(pMessageFolder folder, pMessageList tlist)
  2218. {
  2219. pMessageList  mlist = PNULL,alist = PNULL,blist = PNULL;
  2220. SCI_TRACE_LOW("MMIMMS_AddManagerListBySort  IN ");
  2221. if(folder == NULL)
  2222. {
  2223. SCI_TRACE_LOW("MMIMMS_AddManagerListBySort error:folder is NULL");
  2224. return;
  2225. }
  2226. /* temp code start */
  2227. mlist = folder->root ;
  2228. if(tlist->state < mlist->state||(tlist->state == mlist->state&&strcmp((char*)tlist->date,(char*)mlist->date)>0))
  2229. {
  2230. tlist->next = folder->root;
  2231. folder->root = tlist;
  2232. SCI_TRACE_LOW("COME HEHE IS NOT NORMAL");
  2233. return;
  2234. }
  2235. else 
  2236. {
  2237. alist = folder->root;
  2238. blist = alist->next;
  2239. while(blist)
  2240. {
  2241. if(tlist->state < blist->state)
  2242. {
  2243. alist->next = tlist;
  2244. tlist->next = blist;
  2245. SCI_TRACE_LOW("here come to the case 2");
  2246. return;
  2247. }else if(tlist->state == blist->state)
  2248. {
  2249. if(strcmp((char*)tlist->date,(char*)blist->date)>0)
  2250. {
  2251. alist->next = tlist;
  2252. tlist->next = blist;
  2253. SCI_TRACE_LOW("here come to the case 3");
  2254. return;
  2255. }
  2256. }
  2257. alist = blist;
  2258. blist = blist->next;
  2259. }
  2260. {    
  2261. alist->next = tlist;//最后一种情况,加在最后
  2262. tlist->next = NULL;
  2263. SCI_TRACE_LOW("come to the last case----");
  2264. SCI_TRACE_LOW("come to the last case----");
  2265. return;
  2266. }
  2267. }
  2268. }
  2269. /* ----------------------------------------------------------------------------
  2270. * Function Name: MMIMMS_IsMoreSpace
  2271. * Purpose: 判断是否还有足够空间用以保存彩信
  2272. * Input:  void
  2273. * Returns: BOOLEAN
  2274. * Author:nihongf@mobilesoft.com.cn
  2275. * ----------------------------------------------------------------------------*/ 
  2276. BOOLEAN MMIMMS_IsMoreSpace(void)
  2277. {
  2278. BOOLEAN result     = FALSE;
  2279. uint32 space_size = 0;
  2280. #ifndef WIN32
  2281. space_size = FFS_GetFreeSpace(g_filetype);
  2282. #else
  2283. space_size = 0x0FFF;
  2284. #endif
  2285. if(  space_size > LEAVE_SPACE)//剩余200K空间确保系统能够正常运行. 
  2286. {
  2287. result =TRUE;
  2288. }
  2289. SCI_TRACE_LOW("MMIVC_IsMoreSpace result = %d", result);
  2290.     return(result);
  2291. }
  2292. /* ----------------------------------------------------------------------------
  2293. * Function Name: MMIMMS_SendMMSReadRpt
  2294. * Purpose: 发送阅读报告
  2295. * Input:  pMessageList:list
  2296. * Returns: void
  2297. * Author:nihongf@mobilesoft.com.cn
  2298. * ----------------------------------------------------------------------------*/ 
  2299. void MMIMMS_SendMMSReadRpt(pMessageList tlist)
  2300. {
  2301. MMS_CONFIG_SETTING  cfgset;
  2302. MMS_SEND_SETTING    sendset;
  2303. P_MMS_DOCUMENT pMms_Doc = NULL;
  2304. pMMS_EDocument p_temp_editdoc;
  2305. char fname[MMS_FILE_NAME_LEN];
  2306. char * readrpt_text_str = NULL;
  2307. int readrpt_text_len = 0 ;
  2308. uint32 ldate = 0;
  2309. char  cur_date[40] ;
  2310. char  cur_time[40];
  2311. MMI_TM_T tm;
  2312. uint32 curvalue = 0;
  2313. p_temp_editdoc = MMS_New();
  2314. SCI_ASSERT(p_temp_editdoc != NULL);
  2315. SCI_TRACE_LOW("FNH new mms!");
  2316.     SCI_TRACE_LOW("FNH before cms_parse_mms");
  2317. MMS_New_Slide(p_temp_editdoc);
  2318. SCI_MEMSET(cur_date,0,sizeof(cur_date));
  2319. SCI_MEMSET(cur_time,0,sizeof(cur_time));
  2320. ldate = (uint32)CmsGetCurrentTime();
  2321. tm = CMS_MMSSecond2Tm(ldate);       
  2322. sprintf((char *)cur_date,"%04d%s%02d%s%02d",tm.tm_year,"-",tm.tm_mon,"-",tm.tm_mday);
  2323. sprintf((char *)cur_time,"%02d%s%02d%s%02d",tm.tm_hour,":",tm.tm_min,":",tm.tm_sec);
  2324. // SCI_STRCPY((char *)cur_date,(char *)CmsTimeToString(tm)-;
  2325. SCI_TRACE_LOW("FNH read report cur_date = %s",cur_date);
  2326. SCI_TRACE_LOW("FNH read report cur_len = %d",SCI_STRLEN(cur_date));
  2327. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"to: ") + SCI_STRLEN((char *)tlist->to_address)+ SCI_STRLEN((char *)"r");
  2328. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"subject: ") + SCI_STRLEN((char *)tlist->subject)+ SCI_STRLEN((char *)"r");
  2329. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"message-id: ") + SCI_STRLEN((char *)tlist->msg_id) + SCI_STRLEN((char *)"r");
  2330. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"sent: ") + SCI_STRLEN((char *)tlist->date) + SCI_STRLEN((char *)"r");
  2331. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"r");
  2332. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)"was read on: ") + SCI_STRLEN((char *)"r");
  2333. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)cur_date) + SCI_STRLEN((char *)"r");
  2334. readrpt_text_len = readrpt_text_len + SCI_STRLEN((char *)cur_time);
  2335. readrpt_text_str = (char *)cms_malloc(readrpt_text_len + 1);
  2336. SCI_MEMSET(readrpt_text_str,0,readrpt_text_len + 1);
  2337. SCI_STRCPY(readrpt_text_str,(char *)"To: ");
  2338. strcat((char *)readrpt_text_str,(char *)tlist->to_address);
  2339. strcat((char *)readrpt_text_str,(char *)"r");
  2340. SCI_TRACE_LOW("FNH tlist->subject = %s",tlist->subject);
  2341. SCI_TRACE_LOW("FNH subject len = %d",SCI_STRLEN((char *)tlist->subject));
  2342. strcat((char *)readrpt_text_str,(char *)"Subject: ");
  2343. if (!tlist->subject)
  2344. {
  2345. strcat((char *)readrpt_text_str,"");
  2346. }
  2347. else
  2348. {
  2349. strcat((char *)readrpt_text_str,(char *)tlist->subject);
  2350. }
  2351. strcat((char *)readrpt_text_str,(char *)"r");
  2352. strcat((char *)readrpt_text_str,(char *)"Message-id: ");
  2353. strcat((char *)readrpt_text_str,(char *)tlist->msg_id);
  2354. strcat((char *)readrpt_text_str,(char *)"r");
  2355. strcat((char *)readrpt_text_str,(char *)"Sent: ");
  2356. strcat((char *)readrpt_text_str,(char *)tlist->date);
  2357. strcat((char *)readrpt_text_str,(char *)"r");
  2358. strcat((char *)readrpt_text_str,(char *)"r");
  2359. strcat((char *)readrpt_text_str,(char *)"was read on: ");
  2360. strcat((char *)readrpt_text_str,(char *)"r");
  2361. strcat((char *)readrpt_text_str,(char *)cur_date );
  2362. strcat((char *)readrpt_text_str,(char *)"r");
  2363. strcat((char *)readrpt_text_str,(char *)cur_time );
  2364. {
  2365. int16 type = 0;
  2366. char text_fname[MMS_MAX_FILE_NAME_LENGTH] = {0};
  2367. SCI_FILE* fd = 0;
  2368. uint32 value = 0;
  2369. unsigned short buff_size = 0;
  2370. int16 uni_len = 0;
  2371. char* str_utf16 = NULL;
  2372. uni_len = Cms_UTF8toUTF16Len(readrpt_text_str);
  2373. SCI_TRACE_LOW("FNH uni_len = %d",uni_len);
  2374. value = MMI_GetFfsTime();
  2375. sprintf(text_fname,"%lu",value);
  2376. type = MMS_TYPE_TEXT;
  2377. fd =(SCI_FILE*)mmsf_Open((char*)text_fname,"w");
  2378. if ( !fd )
  2379. {
  2380. SCI_TRACE_LOW("open the file error");
  2381. return ;
  2382. }
  2383. str_utf16 = (char*)cms_malloc(uni_len+1);
  2384. SCI_MEMSET(str_utf16,0,uni_len+1);
  2385. Cms_UTF8toUTF16(readrpt_text_str,readrpt_text_len,uni_len,str_utf16);
  2386. buff_size = uni_len;
  2387. mmsf_Write((char *)(&buff_size),1,sizeof(unsigned short),(FILE_HANDLE)fd);
  2388. SCI_TRACE_LOW("FNH buff_size = %d",buff_size);
  2389. mmsf_Write((char *)str_utf16,1,uni_len,(FILE_HANDLE)fd);
  2390. SCI_TRACE_LOW("FNH after write str_utr16 = %s,uni_len = %d",str_utf16,uni_len);
  2391. mmsf_Close((FILE_HANDLE)fd);
  2392. if (str_utf16)
  2393. {
  2394. cms_free(str_utf16);
  2395. str_utf16 = NULL;
  2396. }
  2397. if (MMS_New_Content((unsigned char *)text_fname,type,p_temp_editdoc->slide_cur,p_temp_editdoc))
  2398. {
  2399. SCI_TRACE_LOW("insert text is ok!");
  2400. }
  2401. else 
  2402. {
  2403. SCI_TRACE_LOW("insert text is failed!");
  2404. }
  2405. }
  2406. if (tlist->subject)
  2407. {
  2408. unsigned int outlen = 0;
  2409. uint8 * uni_16 =PNULL;
  2410. SCI_TRACE_LOW("FNH current subject is not null!");
  2411. g_p_mms_subject = (char *)cms_malloc(MMIMMS_MAX_SUBJECTS_LEN+1);
  2412. SCI_ASSERT(g_p_mms_subject != NULL);
  2413. SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN+1);
  2414. outlen =  Cms_UTF8toUTF16Len(tlist->subject);
  2415. SCI_TRACE_LOW("FNH currentsubject len = %d",outlen);
  2416. uni_16 =(uint8 *)cms_malloc(outlen);
  2417. SCI_MEMSET(uni_16,0,outlen);
  2418. Cms_UTF8toUTF16(tlist->subject,SCI_STRLEN((char *)tlist->subject),outlen,uni_16);
  2419. SCI_TRACE_BUF("FNH currentsubject uni_16 = %x",uni_16,10);
  2420. if ((outlen+2) > MMIMMS_MAX_SUBJECTS_LEN)
  2421. {
  2422. outlen = MMIMMS_MAX_SUBJECTS_LEN-2;
  2423. }
  2424. SCI_MEMCPY((int8 *)(g_p_mms_subject),uni_16,outlen); 
  2425. SCI_TRACE_BUF("FNH before enter MMIMMS_OptionSubject g_p_mms_subject = %x",g_p_mms_subject,10);
  2426. if (uni_16)
  2427. {
  2428. cms_free(uni_16);
  2429. uni_16 = NULL;
  2430. }
  2431. MMIMMS_OptionSubject(MMSREAD);
  2432. }
  2433. {
  2434. curvalue = MMI_GetFfsTime();
  2435. SCI_TRACE_LOW("FNH value = %u",curvalue);
  2436. sprintf(fname,"%lu",curvalue);
  2437. strcat(fname, ".mms");
  2438. SCI_TRACE_LOW("FNH fname = %s",fname);
  2439. SCI_TRACE_LOW("FNH start of send message");
  2440. pMms_Doc = (P_MMS_DOCUMENT)cms_integrate_mms(p_temp_editdoc);
  2441. SCI_TRACE_LOW("FNH after cms_integrate_mms");
  2442. if(!MMS_SetMmsFile(pMms_Doc,fname))
  2443. {
  2444. SCI_TRACE_LOW("FNH error:MMS_SetMmsFile failed");
  2445. if (pMms_Doc)
  2446. {
  2447. MMS_DeleteMms(pMms_Doc);
  2448. pMms_Doc = NULL;
  2449. }
  2450. return;
  2451. }
  2452. SCI_TRACE_LOW("FNH before insert to");
  2453. MMS_SetMmsHeadField(pMms_Doc, MMS_TO, (long)0, (char *)tlist->sender);
  2454. MMS_SetMmsHeadField(pMms_Doc, MMS_MESSAGE_CLASS, (long)MMS_MESSAGE_CLASS_TYPE_PERSONAL, (char *)0);
  2455. SCI_TRACE_BUF("FNH before sendmmshead g_p_mms_subject = %x",g_p_mms_subject,10);
  2456. MMS_SetMmsHeadField(pMms_Doc, MMS_SUBJECT, (long)0, (char*)g_p_mms_subject);//设置主题
  2457. if (g_nv_setting_mirror.delivery_rpt == MMS_MSG_SETTINGS_ON)
  2458. {
  2459. MMS_SetMmsHeadField(pMms_Doc, MMS_DELIVERY_REPORT, (long)MMS_DELIVERY_REPORT_YES, (char *)0);
  2460. }
  2461. else
  2462. {
  2463. MMS_SetMmsHeadField(pMms_Doc, MMS_DELIVERY_REPORT, (long)MMS_DELIVERY_REPORT_NO, (char *)0);
  2464. }
  2465. SCI_TRACE_LOW("FNH start of MMS_EncodeMms");
  2466. if(!MMS_EncodeMms(pMms_Doc))
  2467. {
  2468. SCI_TRACE_LOW("FNH error:MMS_EncodeMms failed");
  2469. if (pMms_Doc)
  2470. {
  2471. MMS_DeleteMms(pMms_Doc);
  2472. pMms_Doc = NULL;
  2473. }
  2474. mmsf_Remove(fname);
  2475. return ;
  2476. }
  2477. MMS_DeleteMms(pMms_Doc);
  2478. pMms_Doc = NULL; // xuelianb modify[2005-11-09]
  2479. }
  2480. MMS_Init();
  2481. cfgset.wap_gateway = (unsigned char *)g_nv_setting_mirror.gateway;
  2482. cfgset.mms_centery = (char *)g_nv_setting_mirror.centre_addr;
  2483. cfgset.wap_port = atoi((char *)g_nv_setting_mirror.port);
  2484. if(!MMS_Machine_Config(&cfgset))
  2485.     {
  2486. SCI_TRACE_LOW("error:MMS_Machine_Config(&cfgset) failed");
  2487. return;
  2488.     }
  2489.     sendset.send_vfilename = fname;  
  2490.     sendset.conf_vfilename = (char*)"confirm.mms";
  2491.     if(!MMS_SendMms(&sendset,mms_lib_callback))
  2492.     {
  2493. SCI_TRACE_LOW("FNH error:mms send failed");
  2494. return;
  2495.     }
  2496.     SCI_TRACE_LOW("FNH udpinput end");
  2497.     SCI_TRACE_LOW("FNH end of send mms");
  2498. return ;
  2499. }
  2500. /* ----------------------------------------------------------------------------
  2501. * Function Name: MMIMMS_DisplaySendRecvProgress
  2502. * Purpose: 显示进度条
  2503. * Input:  uint32   pos:当前进度
  2504.   uint32 totalsize:总的大小
  2505. * Returns: void
  2506. * Author:nihongf@mobilesoft.com.cn
  2507. * ----------------------------------------------------------------------------*/ 
  2508. void MMIMMS_DisplaySendRecvProgress(uint32    pos, uint32 totalsize)
  2509. {
  2510.     GUI_RECT_T  rect;
  2511. if( !MMK_IsFocusWin(MMIMMS_SEND_MMS_WAITING_WIN_ID)
  2512. && !MMK_IsFocusWin(MMIMMS_DOWNLOAD_DOWNLOADING_WIN_ID)
  2513.   )
  2514. {
  2515. return;
  2516. }
  2517. if (pos > 0 && totalsize != 0)
  2518.   {
  2519.         //display scroll bar
  2520.         rect.left = MMIMMS_SCROLL_BAR_LEFT;
  2521.         rect.top = MMIMMS_SCROLL_BAR_TOP;
  2522.         rect.right = MMIMMS_SCROLL_BAR_LEFT +((MMIMMS_SCROLL_BAR_RIGHT -MMIMMS_SCROLL_BAR_LEFT) * pos)/totalsize;
  2523.         rect.bottom = MMIMMS_SCROLL_BAR_BOTTOM;
  2524.         //防止滚动条长度超过进度条
  2525.         if (MMIMMS_SCROLL_BAR_RIGHT < rect.right)
  2526.         {
  2527.             rect.right = MMIMMS_SCROLL_BAR_RIGHT;
  2528.         }
  2529.         //display progress bar
  2530.  //       GUI_DisplayStaticBmp(MAINLCD_ID,MMIMMS_PROGRESS_BAR_LEFT,MMIMMS_PROGRESS_BAR_TOP,IMAGE_MMS_PROGRESS_BAR_ICON);
  2531.         LCD_FillRect(MAINLCD_ID, rect, MMIMMS_SCROLL_BAR_COLOR);
  2532.         
  2533.     }
  2534. }
  2535. /* ----------------------------------------------------------------------------
  2536. * Function Name: RingCallBack
  2537. * Purpose: call back function
  2538. * Input:  void
  2539. * Returns: void
  2540. * Author:nihongf@mobilesoft.com.cn
  2541. * ----------------------------------------------------------------------------*/ 
  2542. LOCAL void RingCallBack( void )
  2543. {
  2544. if (0 != s_play_mms_vibrator_timer_id)
  2545.     {
  2546.         MMK_StopTimer(s_play_mms_vibrator_timer_id);
  2547.         s_play_mms_vibrator_timer_id = 0;
  2548.     }
  2549. MMIPROFILE_SetVibrator(FALSE, RING_STA_MSG);
  2550.     //Callback函数里不能做太多操作,否则占用audio任务时间。
  2551. MMK_PostMsg(VIRTUAL_WIN_ID,MSG_MP3_CONTINUE,PNULL,0);
  2552.     MMI_TriggerMMITask();
  2553. }
  2554. /*****************************************************************************/
  2555. //  Description : get "to address" totol number
  2556. // Global resource dependence : g_mms_save_in_mem
  2557. //  Author: Bruce.Chi
  2558. // Note: used in edit and save moduel
  2559. ///*****************************************************************************/
  2560. uint32 Edit_GetToAddTotalNumber(void)
  2561. {
  2562. 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 );
  2563. }
  2564. /* ----------------------------------------------------------------------------
  2565. * Function Name: MMIMMS_PlayMMSSound
  2566. * Purpose: 播放声音(这里的声音是信息提示音)
  2567. * Input:  void
  2568. * Returns: void
  2569. * Author:nihongf@mobilesoft.com.cn
  2570. * ----------------------------------------------------------------------------*/ 
  2571. void MMIMMS_PlayMMSSound()
  2572. {
  2573. // MMISET_MSG_RING_TYPE_E   ring_type;
  2574. MMIPROFILE_ACT_TYPE_E ring_type;
  2575. MMIPROFILE_PARA_T cur_profile_para = {0,};
  2576.   
  2577. MMIDEFAULT_SetBackLight(TRUE);
  2578. MMIPROFILE_SetVibrator(FALSE, RING_STA_MSG);
  2579. MMIPROFILE_StopRing(RING_STA_MSG);
  2580. if (0 != s_play_mms_vibrator_timer_id)
  2581.     {
  2582.         MMK_StopTimer(s_play_mms_vibrator_timer_id);
  2583.         s_play_mms_vibrator_timer_id = 0;
  2584.     }
  2585.       //有新的需要播放铃声,把原来的播放铃声先停掉。
  2586. // MMISET_GetMsgRingType( &ring_type );
  2587. MMIPROFILE_GetCurrentProfileModeInfo(&cur_profile_para);
  2588. ring_type = cur_profile_para.msg_type;
  2589.     if (CC_IsInCallConnected() || PCcam_is_open())
  2590. {
  2591. // MMISET_PlayRing(FALSE,0,1,MMISET_RING_TYPE_MSG_IN_CALL,PNULL);
  2592. MMIPROFILE_PlayRing(FALSE,1,RING_STA_MSG_IN_CALL,PNULL);
  2593. }
  2594.         else if (MMK_IsOpenWin(MMIMPEG4_MAIN_PLAY_WIN_ID)
  2595. #ifdef MMI_APP_6800_PRJ
  2596. #else
  2597.             || DC_IsOpened()
  2598. #endif
  2599.             || MMK_IsOpenWin(MMIRECORD_PLAY_WIN_ID))
  2600.         {
  2601.             //不发声
  2602. SCI_TRACE_LOW("mmismsapp_wintab.c MMISMS_HandleNewMsgWin() MSG_SMS_PLAY_RING no sound");
  2603.         }
  2604. else
  2605. {
  2606. switch( ring_type )
  2607. {
  2608. case ACT_RING:
  2609. MMIPROFILE_PlayRing(FALSE,1,RING_STA_MSG,RingCallBack);
  2610. if (GPIO_CheckHeadsetStatus())     //耳机插入时启动振动
  2611. {
  2612.                 if ( 0 == s_play_mms_vibrator_timer_id)
  2613.                 {
  2614. MMIPROFILE_SetVibrator(TRUE,RING_STA_MSG);
  2615.                     s_play_mms_vibrator_timer_id = MMK_CreateWinTimer(VIRTUAL_WIN_ID, MMIMMS_VIBRA_TIMEROUT, FALSE);
  2616.                 }
  2617. }
  2618. break;
  2619. case ACT_VIBRATE:
  2620. if (MMIPROFILE_IsPermitPlayRingOrVib(RING_STA_MSG))
  2621.             {
  2622.                 if ( 0 == s_play_mms_vibrator_timer_id)
  2623.                 {
  2624.                     MMIPROFILE_SetVibrator(TRUE,RING_STA_MSG);
  2625.                     s_play_mms_vibrator_timer_id = MMK_CreateWinTimer(VIRTUAL_WIN_ID, MMIMMS_VIBRA_TIMEROUT, FALSE);
  2626.                 }
  2627.             }
  2628. break;
  2629.         
  2630. case ACT_SILENCE:
  2631. MMIPROFILE_IsPermitPlayRingOrVib(RING_STA_MSG);
  2632. break;
  2633. case ACT_RINGVIBRATE:
  2634.         if (MMIPROFILE_IsPermitPlayRingOrVib(RING_STA_MSG))
  2635.         {
  2636. MMIPROFILE_PlayRing(FALSE,1,RING_STA_MSG,RingCallBack);
  2637.                 if ( 0 == s_play_mms_vibrator_timer_id)
  2638.                 {
  2639. MMIPROFILE_SetVibrator(TRUE,RING_STA_MSG);
  2640.                     s_play_mms_vibrator_timer_id = MMK_CreateWinTimer(VIRTUAL_WIN_ID, MMIMMS_VIBRA_TIMEROUT, FALSE);
  2641.                 }
  2642.         }
  2643. break;
  2644. default:
  2645. break;
  2646. }
  2647. }
  2648. }
  2649. /*****************************************************************************/
  2650. //  Description : is play mms ring vibrator timer
  2651. // Global resource dependence : 
  2652. //  Author:wancan.you
  2653. // Note: 
  2654. /*****************************************************************************/
  2655. PUBLIC BOOLEAN MMIMMS_IsHandleMMSVibratorTimer(uint8 timerid)
  2656. {
  2657.     if (timerid == s_play_mms_vibrator_timer_id)
  2658.     {
  2659.         MMK_StopTimer(s_play_mms_vibrator_timer_id);
  2660.         s_play_mms_vibrator_timer_id = 0;
  2661.         MMIPROFILE_SetVibrator(FALSE, RING_STA_MSG);
  2662.         return TRUE;
  2663.     }
  2664.     return FALSE;
  2665. }
  2666. /* ----------------------------------------------------------------------------
  2667. * Function Name: MMIMMS_IdleWinShowNewMMS
  2668. * Purpose: IDLE界面显示新彩信
  2669. * Input:  void
  2670. * Returns: void
  2671. * Author:nihongf@mobilesoft.com.cn
  2672. * ----------------------------------------------------------------------------*/ 
  2673. PUBLIC void MMIMMS_IdleWinShowNewMMS()
  2674. {
  2675. if(g_nv_setting_mirror.retrieve_mode == 1)
  2676. {
  2677. if(g_pautoDownloadMMSRoot)
  2678. {
  2679. SCI_TRACE_LOW("fnh needautodw = %d",g_pautoDownloadMMSRoot->autolist->needautodw);
  2680. if (g_pautoDownloadMMSRoot->autolist->needautodw != 0)
  2681. {
  2682. if (CC_IsInCall())
  2683. {
  2684. //alert : TXT_MMS_CANNOT_DOWNLOAD_IN_CALL
  2685. PUBWIN_OpenPromptAlertWin(
  2686. PUBWIN_SOFTKEY_ONE, 
  2687. TXT_MMS_CANNOT_DOWNLOAD_IN_CALL, 
  2688. IMAGE_PROMPT_ICON_ALERT, 
  2689. ALERT_TIMEOUT, 
  2690. PNULL
  2691. );
  2692. }else
  2693. {
  2694. g_filetype = MMICMS_GetCurrentFFS();
  2695. if((g_filetype == FS_INVALID)||MMIMMS_GetManagerTotalNum() > (MMS_MAX_NUM-1)||!MMIMMS_IsMoreSpace())//modify liangliu 2005-12-14
  2696. {
  2697. PUBWIN_OpenPromptAlertWin(
  2698. PUBWIN_SOFTKEY_ONE, 
  2699. TXT_MMS_NEWANDFULL, 
  2700. IMAGE_PROMPT_ICON_ALERT, 
  2701. ALERT_TIMEOUT, PNULL);
  2702. MMIMMS_FreeAutodownList();
  2703. return ;
  2704. }else
  2705. {   
  2706. MMICMSBRW_InitCache(); //fnh add 
  2707. MMIMMS_Download_CreateDownloadingWin();
  2708. MMIDEFAULT_SetBackLight(TRUE);
  2709. g_backautodownload = TRUE;
  2710. g_netusing = MMS_MSG_NETUSING_STEP1 ;
  2711. //MMK_CreateWin((uint32 *)MMIMMS_SEND_WIN_TAB,PNULL);
  2712. SCI_TRACE_LOW("FNH g_pautoDownloadMMSRoot = %d,g_pautoDownloadMMSRoot->autolist = %d",g_pautoDownloadMMSRoot,g_pautoDownloadMMSRoot->autolist);
  2713. SCI_TRACE_LOW("FNH g_pCurrentList = %d",g_pCurrentList);
  2714. g_pCurrentList = g_pautoDownloadMMSRoot->autolist;
  2715. g_progressneedsize = g_pCurrentList->size;
  2716. MMIMMS_Receive_MMS(g_pCurrentList);
  2717. }
  2718. }
  2719. }
  2720. }
  2721. }
  2722.     else
  2723. {
  2724. if(g_donewmms == TRUE)
  2725. {
  2726. MMIMMS_StoreFolder(g_pManager->inboxfolder);
  2727. g_donewmms = FALSE;
  2728. MMIMMS_SaveManagerInboxFile(MMS_SAVE_INBOX);
  2729. PUBWIN_OpenPromptAlertWin(
  2730. PUBWIN_SOFTKEY_ONE, 
  2731. TXT_CL_NEW_MMS,
  2732. IMAGE_PROMPT_ICON_ALERT, 
  2733. PNULL, 
  2734. PNULL
  2735. );
  2736. }
  2737. else
  2738. {
  2739. switch(g_delivery_value)
  2740. {
  2741. case MMS_DELIVERY_REPORT_VALUE_RETRIVED:
  2742. SCI_TRACE_LOW("FNH delivery value RETRIVED");
  2743. PUBWIN_OpenPromptAlertWin(
  2744. PUBWIN_SOFTKEY_ONE, 
  2745. TXT_DELIVERYRPT_RETRIVED, //对方已经收到彩信
  2746. IMAGE_PROMPT_ICON_SUCCESS,//IMAGE_PROMPT_ICON_OK, 
  2747. PNULL, 
  2748. PNULL
  2749. );
  2750. MMIDEFAULT_SetBackLight(TRUE);
  2751. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
  2752. break;
  2753. case MMS_DELIVERY_REPORT_VALUE_REJECTED:
  2754. SCI_TRACE_LOW("FNH delivery value REJECTED");
  2755. PUBWIN_OpenPromptAlertWin(
  2756. PUBWIN_SOFTKEY_ONE, 
  2757. TXT_DELIVERYRPT_REJECTED, //发送彩信被拒绝
  2758. IMAGE_PROMPT_ICON_ALERT, 
  2759. PNULL, 
  2760. PNULL
  2761. );
  2762. MMIDEFAULT_SetBackLight(TRUE);
  2763. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
  2764. break;
  2765. case MMS_DELIVERY_REPORT_VALUE_DEFERRED:
  2766. SCI_TRACE_LOW("FNH delivery value DEFERRED");
  2767. PUBWIN_OpenPromptAlertWin(
  2768. PUBWIN_SOFTKEY_ONE, 
  2769. TXT_DELIVERYRPT_DEFERRED, //发彩信被延期
  2770. IMAGE_PROMPT_ICON_ALERT, 
  2771. PNULL, 
  2772. PNULL
  2773. );
  2774. MMIDEFAULT_SetBackLight(TRUE);
  2775. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
  2776. break;
  2777. case MMS_DELIVERY_REPORT_VALUE_EXPIRED:
  2778. SCI_TRACE_LOW("FNH delivery value EXPIRED");
  2779. PUBWIN_OpenPromptAlertWin(
  2780. PUBWIN_SOFTKEY_ONE, 
  2781. TXT_DELIVERYRPT_EXPIRED, //发送彩信过期
  2782. IMAGE_PROMPT_ICON_ALERT, 
  2783. PNULL, 
  2784. PNULL
  2785. );
  2786. MMIDEFAULT_SetBackLight(TRUE);
  2787. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
  2788. break;
  2789. case MMS_DELIVERY_REPORT_VALUE_UNRECOGNESED:
  2790. SCI_TRACE_LOW("FNH delivery value UNRECOGNESED");
  2791. PUBWIN_OpenPromptAlertWin(
  2792. PUBWIN_SOFTKEY_ONE, 
  2793. TXT_DELIVERYRPT_UNRECOGNISED, //发送彩信未被承认
  2794. IMAGE_PROMPT_ICON_ALERT, 
  2795. PNULL, 
  2796. PNULL
  2797. );
  2798. MMIDEFAULT_SetBackLight(TRUE);
  2799. g_delivery_value = MMS_DELIVERY_REPORT_VALUE_NONE;
  2800. break;
  2801. case MMS_DELIVERY_REPORT_VALUE_NONE:
  2802. SCI_TRACE_LOW("FNH delivery value none");
  2803. break;
  2804. default:
  2805. break;
  2806. }
  2807. }
  2808. }
  2809. }
  2810. /* ----------------------------------------------------------------------------
  2811. * Function Name: MMIMMS_IsInit
  2812. * Purpose: MMS是否初始化完毕
  2813. * Input:  void
  2814. * Returns: BOOLEAN
  2815. * Author:nihongf@mobilesoft.com.cn
  2816. * ----------------------------------------------------------------------------*/ 
  2817. BOOLEAN MMIMMS_IsInit(void)
  2818. {
  2819.       SCI_TRACE_LOW("MMIMMS_IsInit IS COME IN,and the ismmsinit is %d",g_ismmsinit);
  2820.       return g_ismmsinit;
  2821. }
  2822. /* ----------------------------------------------------------------------------
  2823. * Function Name: MMIMMS_UdiskFormat
  2824. * Purpose: U盘格式化时删除指定信箱里的MMS
  2825. * Input:  void
  2826. * Returns: void
  2827. * Author:nihongf@mobilesoft.com.cn
  2828. * ----------------------------------------------------------------------------*/ 
  2829. void MMIMMS_UdiskFormat(void)
  2830. {
  2831. if (g_pManager != NULL)
  2832. {
  2833. if(g_pManager->inboxfolder != NULL)
  2834. {
  2835. MMIMMS_FreeFolderForInit(g_pManager->inboxfolder);
  2836. g_pManager->inboxfolder->messagenumber = 0;
  2837. g_pManager->inboxfolder->unsettlednumber = 0 ;
  2838. }
  2839. if(g_pManager->outboxfolder != NULL)
  2840. {
  2841. MMIMMS_FreeFolderForInit(g_pManager->outboxfolder);
  2842. g_pManager->outboxfolder->messagenumber = 0;
  2843. g_pManager->outboxfolder->unsettlednumber = 0 ;
  2844. }
  2845. if(g_pManager->sentfolder != NULL)
  2846. {
  2847. MMIMMS_FreeFolderForInit(g_pManager->sentfolder);
  2848. g_pManager->sentfolder->messagenumber = 0;
  2849. g_pManager->sentfolder->unsettlednumber = 0 ;
  2850. }
  2851. if(g_pManager->draftfolder != NULL)
  2852. {
  2853. MMIMMS_FreeFolderForInit(g_pManager->draftfolder);
  2854. g_pManager->draftfolder->messagenumber = 0;
  2855. g_pManager->draftfolder->unsettlednumber = 0 ;
  2856. }
  2857. }
  2858. MMIMMS_FreeAutodownList();
  2859.       
  2860. }
  2861. /* ----------------------------------------------------------------------------
  2862. * Function Name: MMIMMS_SaveAutoSignMessage
  2863. * Purpose:将自动签名页的编辑文档保存到文件中
  2864. * Input:  pMMS_EDocument:自动签名页的编辑文档
  2865. * Returns: void
  2866. * Author:nihongf@mobilesoft.com.cn
  2867. * ----------------------------------------------------------------------------*/ 
  2868. void MMIMMS_SaveAutoSignMessage(pMMS_EDocument p_cur_edit)
  2869. {
  2870. P_MMS_DOCUMENT  pMms_Doc = NULL;
  2871. char fname[MMS_FILE_NAME_LEN];
  2872. unsigned long   value ;
  2873. value = TM_GetTotalSeconds();
  2874. SCI_TRACE_LOW("FNH value = %ld",value);
  2875. sprintf(fname,"%ld",value);
  2876. strcat(fname, ".mms");
  2877. SCI_TRACE_LOW("FNH fname = %s",fname);
  2878. pMms_Doc = (P_MMS_DOCUMENT)cms_integrate_mms(p_cur_edit);
  2879. SCI_TRACE_LOW("FNH after cms_integrate_mms");
  2880. if(!MMS_SetMmsFile(pMms_Doc,fname))
  2881. {
  2882. SCI_TRACE_LOW("FNH error:MMS_SetMmsFile failed");
  2883. if (pMms_Doc)
  2884. {
  2885. MMS_DeleteMms(pMms_Doc);
  2886. pMms_Doc = NULL;
  2887. }
  2888. if (p_cur_edit != NULL)
  2889. {
  2890. SCI_TRACE_LOW("FNH before free p_cur_edit");
  2891. MMSDelDocument(p_cur_edit);
  2892. p_cur_edit = NULL;
  2893. g_pcur_signdoc = NULL;
  2894. }
  2895. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  2896. return;
  2897. }
  2898. if(!MMS_EncodeMms(pMms_Doc))
  2899. {
  2900. SCI_TRACE_LOW("FNH error:MMS_EncodeMms failed");
  2901. if (pMms_Doc)
  2902. {
  2903. MMS_DeleteMms(pMms_Doc);
  2904. pMms_Doc = NULL;
  2905. }
  2906. if (p_cur_edit != NULL)
  2907. {
  2908. SCI_TRACE_LOW("FNH before free p_cur_edit");
  2909. MMSDelDocument(p_cur_edit);
  2910. p_cur_edit = NULL;
  2911. g_pcur_signdoc = NULL;
  2912. }
  2913. mmsf_Remove(fname);
  2914. MMK_PostMsg(MMIMMS_SAVE_MMS_WAITING_WIN_ID,MSG_MMS_SAVE_AUTO_SIGN_FAILED,PNULL,PNULL);
  2915. return ;
  2916. }
  2917. SCI_TRACE_LOW("FNH before save auto sign file name %s",fname);
  2918. MMIMMS_SaveAutoSign((uint8 *)fname);
  2919. if (p_cur_edit != NULL)
  2920. {
  2921. SCI_TRACE_LOW("FNH before free p_cur_edit");
  2922. MMSDelDocument(p_cur_edit);
  2923. p_cur_edit = NULL;
  2924. g_pcur_signdoc = NULL;
  2925. }
  2926. MMS_DeleteMms(pMms_Doc);
  2927. pMms_Doc = NULL; // xuelianb modify[2005-11-09]
  2928. }
  2929. /* ----------------------------------------------------------------------------
  2930. * Function Name: MMIMMS_ReadAutosign
  2931. * Purpose:从flash资源中读取自动签名页
  2932. * Input:  void
  2933. * Returns: void
  2934. * Author:nihongf@mobilesoft.com.cn
  2935. * ----------------------------------------------------------------------------*/ 
  2936. void   MMIMMS_ReadAutosign(void)
  2937. {
  2938.     FFS_OVERLAPPED_T                 overlapped;
  2939.     HFS  cur_hefs = FFS_INVALID_HANDLE;
  2940.     uint32                           size = 0;
  2941.     uint32  transmitted;
  2942.     FFS_READFILE_RESULT_T  *param_read_ptr =PNULL;
  2943. SCI_TRACE_LOW("MMIMMS_ReadAutosign IN -------");
  2944. FILE_CdMMSPath();
  2945. if(FILE_CheckExist((const char*)MMSAUTOSIGNFILE) == TRUE)
  2946. {
  2947. SCI_TRACE_LOW("FNH file exist !");
  2948. cur_hefs = FILE_Create((const char*)MMSAUTOSIGNFILE, FFS_MODE_READ|FFS_MODE_OPEN_EXISTING);
  2949.         //SCI_TRACE_BUF("VC: ReadVideo file_name = ", file_name, video_info_ptr->name_len);
  2950.         if(FFS_INVALID_HANDLE != cur_hefs)
  2951.         {
  2952. FFS_ERROR_E ffs_error = 0;
  2953. SCI_TRACE_LOW("FNH not invalid handle!");
  2954. size = FFS_GetLength(g_filetype,cur_hefs);
  2955. if (size == 0)
  2956. {
  2957. SCI_TRACE_LOW("fnh read autosign file size is zero!");
  2958. FFS_Close(g_filetype,cur_hefs);
  2959. cur_hefs = FFS_INVALID_HANDLE;
  2960. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
  2961. return ;
  2962. }
  2963. param_read_ptr = (FFS_READFILE_RESULT_T *)cms_malloc(sizeof(FFS_READFILE_RESULT_T));
  2964. if (param_read_ptr == NULL)
  2965. {
  2966. SCI_TRACE_LOW("fnh param_read_ptr malloc fail");
  2967. FFS_Close(g_filetype,cur_hefs);
  2968. cur_hefs = FFS_INVALID_HANDLE;
  2969. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
  2970. return ;
  2971. }
  2972. SCI_MEMSET(param_read_ptr, 0, sizeof(FFS_READFILE_RESULT_T));
  2973. param_read_ptr->hefs = cur_hefs;//传递的参数
  2974. param_read_ptr->buf_size = size;
  2975. param_read_ptr->buf_ptr = (uint8*)cms_malloc(param_read_ptr->buf_size);
  2976. if (param_read_ptr->buf_ptr == NULL)
  2977. {
  2978. SCI_TRACE_LOW("fnh param_read_ptr->buf_ptr malloc fail");
  2979. if (param_read_ptr != NULL)
  2980. {
  2981. cms_free(param_read_ptr);
  2982. param_read_ptr = NULL;
  2983. }
  2984. FFS_Close(g_filetype,cur_hefs);
  2985. cur_hefs = FFS_INVALID_HANDLE;
  2986. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
  2987. return ;
  2988. }
  2989. overlapped.offset = 0;
  2990. overlapped.param = (FFS_PARAM)param_read_ptr; //free it in call back function
  2991.             overlapped.complete_route = MMICMSMMS_CallBackReadAutoSignFile;
  2992. ffs_error = FFS_Read(g_filetype,cur_hefs, 
  2993. param_read_ptr->buf_ptr,
  2994. param_read_ptr->buf_size, 
  2995. &transmitted, 
  2996. &overlapped);
  2997.             if( ( FFS_ERROR_IO_PENDING != ffs_error )&&(FFS_NO_ERROR != ffs_error))
  2998.             {
  2999. SCI_TRACE_LOW("fnh read error!");
  3000. FFS_Close(g_filetype,cur_hefs);
  3001. cur_hefs = FFS_INVALID_HANDLE;
  3002. if (param_read_ptr->buf_ptr!= NULL)
  3003. {
  3004. cms_free(param_read_ptr->buf_ptr);
  3005. param_read_ptr->buf_ptr = NULL;
  3006. }
  3007. if (param_read_ptr != NULL)
  3008. {
  3009. cms_free(param_read_ptr);
  3010. param_read_ptr = NULL;
  3011. }
  3012. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
  3013.   return ;
  3014.            }
  3015.         }
  3016. else
  3017. {
  3018. SCI_TRACE_LOW("FNH OPEN FILE IS FAIL!");
  3019. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED, PNULL,0);
  3020. return ;
  3021. }
  3022. }
  3023. else
  3024. {
  3025. SCI_TRACE_LOW("FNH THE FILE IS NOT EXIST!");
  3026. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_FAILED,PNULL,0);
  3027. return ;
  3028. }
  3029. }
  3030. /* ----------------------------------------------------------------------------
  3031. * Function Name: MMICMSMMS_CallBackReadAutoSignFile
  3032. * Purpose: 读取自动签名页的回调函数
  3033. * Input:  FFS_ERROR_E a, 
  3034.   FFS_RESULT result, 
  3035.   FFS_PARAM param
  3036. * Returns: void
  3037. * Author:nihongf@mobilesoft.com.cn
  3038. * ----------------------------------------------------------------------------*/ 
  3039. LOCAL void MMICMSMMS_CallBackReadAutoSignFile(
  3040. FFS_ERROR_E a, 
  3041. FFS_RESULT result, 
  3042. FFS_PARAM param
  3043. )
  3044. {
  3045. FFS_READFILE_RESULT_T *efs_param_ptr = PNULL;
  3046. FFS_READFILE_RESULT_T         efs_result;
  3047. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  3048. efs_param_ptr = (FFS_READFILE_RESULT_T *)param;
  3049. efs_result.hefs = efs_param_ptr->hefs;
  3050. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  3051. efs_result.buf_size     = efs_param_ptr->buf_size;
  3052. if(efs_param_ptr != NULL)
  3053. {
  3054. cms_free(efs_param_ptr);
  3055. efs_param_ptr = NULL;
  3056. }
  3057. SCI_TRACE_LOW("FNH before postmsg read ok!");
  3058. MMK_PostMsg(MMIMMS_READ_MMS_WAITING_WIN_ID, MSG_MMS_READ_SIGN_OK, &efs_result, sizeof(FFS_READFILE_RESULT_T));
  3059. MMI_TriggerMMITask();
  3060. }
  3061. /*****************************************************************************/
  3062. //  Description : EditStringToGlobal
  3063. void MMIMMS_CheckMMSDownloadStatus(void)
  3064. {
  3065. return;
  3066. }
  3067. // Global resource dependence : none
  3068. //  Author: Bruce.Chi
  3069. // Input: memory pointer.
  3070. // Output:
  3071. // Note:
  3072. /*****************************************************************************/
  3073. void EditStringToGlobal(MMI_CTRL_ID_T contrl_id,To_Addr* addr_list)
  3074. {
  3075. TEXTEDIT_STRING_INFO_T  edit_string;
  3076. TEXTEDIT_STRING_INFO_T addr_edit_string;
  3077. MMI_STRING_T saved_string;
  3078. uint8 *temp_subject = NULL;
  3079. uint8 tele_num[MMIMMS_MAX_ADDRESS_LEN + 2] = {0};
  3080. uint16 index = 0;
  3081. p_MMS_RECEPIENT p_mms_x = g_p_mms_to;
  3082. p_MMS_RECEPIENT p_temp;
  3083. p_MMS_RECEPIENT p_temp_add;
  3084. SCI_ASSERT(addr_list != PNULL);
  3085. //----------get sendnumber
  3086. SCI_MEMSET( &addr_edit_string, 0, sizeof( TEXTEDIT_STRING_INFO_T ) );
  3087.     GUIEDITBOX_GetTextEditBoxInfo( contrl_id, &addr_edit_string);
  3088.     SCI_ASSERT(FALSE == addr_edit_string.is_ucs2);
  3089. MMIMMS_ParseDestAddr(&addr_edit_string,addr_list);
  3090. p_mms_x = NULL;
  3091. for(index=0;index<addr_list->total_num;index++)
  3092. {
  3093. p_temp_add= (p_MMS_RECEPIENT)cms_malloc(sizeof(MMS_RECEPIENT));
  3094. SCI_ASSERT(p_temp_add != NULL);
  3095. SCI_MEMSET(tele_num, 0, sizeof(tele_num));
  3096. 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);
  3097. SCI_MEMSET(p_temp_add,0,sizeof(MMS_RECEPIENT));
  3098. SCI_MEMSET(p_temp_add->m_address,0,MAX_NAME_LENGTH); 
  3099. SCI_STRCPY(p_temp_add->m_address,(char *)tele_num);
  3100. p_temp_add->p_next = NULL;
  3101. if (p_mms_x == NULL)
  3102. {
  3103. p_mms_x = p_temp_add;
  3104. // p_mms_x->p_next = NULL;
  3105. }
  3106. else
  3107. {
  3108. p_temp = p_mms_x;
  3109. while(p_temp->p_next)
  3110. {
  3111. p_temp = p_temp->p_next;
  3112. }
  3113. p_temp->p_next = p_temp_add;
  3114. }
  3115. }
  3116. switch(contrl_id)
  3117. {
  3118. case MMIMMS_ADDR_EDITBOX_CTRL_ID:
  3119. g_p_mms_to = p_mms_x;
  3120. break;
  3121. case MMIMMS_ADDR_EDITBOX_MMSCC_CTRL_ID:
  3122. g_p_mms_cc = p_mms_x;
  3123. break;
  3124. case MMIMMS_ADDR_EDITBOX_MMSBCC_CTRL_ID:
  3125. g_p_mms_bcc = p_mms_x;
  3126. break;
  3127. default:
  3128. break;
  3129. }
  3130. }
  3131. /*****************************************************************************/
  3132. //  Description : is allow audio alert window
  3133. //  Global resource dependence : none
  3134. //  Author: wancan.you
  3135. //  Note: 
  3136. /*****************************************************************************/
  3137. PUBLIC BOOLEAN MMIMMS_IsAllowAudioAlertWin(void)
  3138. {
  3139.     if (MMK_IsFocusWin(MMIMMS_EDIT_PREVIEW_WIN_ID))
  3140.     {
  3141.         return FALSE;
  3142.     }
  3143.     return TRUE;
  3144. }