mmimms_main.c
上传用户:fuyouda
上传日期:2021-12-23
资源大小:164k
文件大小:313k
开发平台:

C/C++

  1. &overlapped
  2. );
  3. if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
  4. {
  5. if (param_save_ptr != NULL)
  6. {
  7. cms_free(param_save_ptr );
  8. param_save_ptr = NULL;
  9. }
  10. FILE_Close(cur_hefs);
  11. cur_hefs = FFS_INVALID_HANDLE;
  12. mmsf_Remove((char *)"\cmsoutbox.cnf");
  13. if (g_mailbox_status == SEND_OUTBOX_MMS)
  14. {
  15.   MMK_PostMsg(
  16. MMIMMS_SAVE_MMS_WAITING_WIN_ID, 
  17. MSG_MANAGERFILEWRITE_OUTBOX_FAILED, 
  18. PNULL, 
  19. PNULL
  20. );
  21. }
  22. return ;
  23. }
  24. }
  25. else
  26. {
  27. mmsf_Remove((char*)"\cmsoutbox.cnf" );
  28. FILE_CdMMSPath();
  29. if(FILE_CheckExist((const char*)MANAGER_FLASH_OUTBOXNAME) == TRUE)
  30. {      
  31. FFS_ERROR_E ffs_error = 0;
  32. uint16  ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  33. int ucs2_name_len = 0;
  34. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MANAGER_FLASH_OUTBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_OUTBOXNAME));
  35. overlapped.offset         = 0;
  36. overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
  37. overlapped.param          = PNULL;
  38. ffs_error  =  FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
  39. SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
  40. }
  41. if (g_mailbox_status == SEND_OUTBOX_MMS)
  42. {
  43.   MMK_PostMsg(
  44. MMIMMS_SAVE_MMS_WAITING_WIN_ID, 
  45. MSG_MANAGERFILEWRITE_OUTBOX_FAILED, 
  46. PNULL, 
  47. PNULL
  48. );
  49. }
  50. return;
  51. }
  52. }
  53. /*==============================================================
  54. *   函数名: MMIMMS_SaveManagerSentboxFile
  55. *   输入: 空
  56. *   输出: void
  57. *   功能描述: 存储相应涉及已发件箱的虚拟文件到flash资源。
  58.                                    因为为异步文件系统,目前顺序是:收件箱;发件箱;
  59.                                    已发邮件;草稿箱。
  60. *   代码编写者: liangliu
  61. *   代码编写日期: 10/28/2005
  62. *   修改原因:
  63. *   修改人员:
  64. *   修改日期:
  65.  ==============================================================*/
  66. void MMIMMS_SaveManagerSentboxFile()
  67. {
  68. //FILE_HANDLE   cmshandle = 0;
  69. uint8* tempbuf= NULL;
  70. //int curroffset;
  71. uint32 filelen = 0;
  72. //static HFS s_hefs = FFS_INVALID_HANDLE;
  73. HFS cur_hefs = FFS_INVALID_HANDLE;
  74. //uint32 file_size = 0;
  75. //uint16 *file_name =NULL;
  76. //uint16 * dir_name =PNULL;
  77. //uint16  unicodelong  = 0 ;
  78. //MMI_STRING_T      prompt_str;
  79. FFS_ERROR_E efs_error;
  80. FFS_OVERLAPPED_T overlapped;
  81. uint32 transmit;
  82. //uint8 *efs_buf_ptr = PNULL;
  83. FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
  84. SCI_TRACE_LOW("MMIMMS_SaveManagerSentboxFile IN ---------");
  85. mmsf_GetConstFileData((char *)"\cmssentbox.cnf",(char **)&tempbuf,(int *)&filelen);
  86. SCI_TRACE_LOW("fnh filelen = %d",filelen);
  87. SCI_TRACE_LOW("fnh tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
  88. if (filelen > 0)
  89. {
  90. SCI_TRACE_LOW("HERE MMIMMS_SaveManagerSentboxFile THE filehandle >0");
  91. if(0!=FILE_CdMMSPath())
  92. {
  93.    FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
  94.    FILE_CdMMSPath();
  95. }
  96. cur_hefs = FILE_Create((char*)MANAGER_FLASH_SENTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
  97. if (cur_hefs == FFS_INVALID_HANDLE)
  98. {
  99. //the reason may be that I have not closed the former opened file with the same name
  100. FILE_Close(cur_hefs); //close former file
  101. cur_hefs = FILE_Create((char*)MANAGER_FLASH_SENTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
  102. if (cur_hefs == FFS_INVALID_HANDLE)
  103. {
  104. SCI_TRACE_LOW("FNH here create sentbox is fail");
  105. mmsf_Remove((char *)"\cmssentbox.cnf");
  106. return;
  107. }
  108. }
  109. param_save_ptr = (FFS_SAVEFILE_RESULT_T*)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
  110. if (param_save_ptr == NULL)
  111. {
  112. SCI_TRACE_LOW("FNH param_save_ptr malloc fail");
  113. mmsf_Remove((char *)"\cmssentbox.cnf");
  114. FILE_Close(cur_hefs);
  115. cur_hefs = FFS_INVALID_HANDLE;
  116. return ;
  117. }
  118. SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  119. param_save_ptr->buf_ptr = tempbuf;
  120. param_save_ptr->hefs = cur_hefs;//传递的参数
  121. param_save_ptr->buf_size = filelen;
  122. overlapped.offset = 0;
  123. overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
  124. overlapped.complete_route = SaveFS_SaveSentboxFile_CallBack; 
  125. efs_error = FILE_Write(
  126. cur_hefs,
  127. tempbuf,
  128. filelen,
  129. &transmit,
  130. &overlapped
  131. );
  132. if((FFS_ERROR_IO_PENDING != efs_error) && (FFS_NO_ERROR != efs_error))
  133. {
  134. if (param_save_ptr != NULL)
  135. {
  136. cms_free(param_save_ptr);
  137. param_save_ptr = NULL;
  138. }
  139. mmsf_Remove((char *)"cmssentbox.cnf");
  140. FILE_Close(cur_hefs);
  141. cur_hefs = FFS_INVALID_HANDLE;
  142. return ;
  143. }
  144. }
  145. else
  146. {
  147. mmsf_Remove((char*)"\cmssentbox.cnf" );
  148. FILE_CdMMSPath();
  149. if(FILE_CheckExist((const char*)MANAGER_FLASH_SENTBOXNAME) == TRUE)
  150. {      
  151. FFS_ERROR_E ffs_error = 0;
  152. uint16  ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  153. int ucs2_name_len = 0;
  154. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MANAGER_FLASH_SENTBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_SENTBOXNAME));
  155. overlapped.offset         = 0;
  156. overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
  157. overlapped.param          = PNULL;
  158. ffs_error  =  FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
  159. SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
  160.    }
  161. }
  162. }
  163. /*==============================================================
  164. *   函数名: MMIMMS_SaveManagerDraftboxFile
  165. *   输入: 空
  166. *   输出: void
  167. *   功能描述: 存储相应涉及草稿箱的虚拟文件到flash资源。
  168.                                    因为为异步文件系统,目前顺序是:收件箱;发件箱;
  169.                                    已发邮件;草稿箱。
  170. *   代码编写者: liangliu
  171. *   代码编写日期: 10/28/2005
  172. *   修改原因:
  173. *   修改人员:
  174. *   修改日期:
  175.  ==============================================================*/
  176. void MMIMMS_SaveManagerDraftboxFile(void)
  177. {
  178. //FILE_HANDLE   cmshandle = 0;
  179. uint8* tempbuf = NULL;
  180. //int curroffset;
  181. uint32  filelen = 0;
  182. //static HFS s_hefs = FFS_INVALID_HANDLE;
  183. HFS cur_hefs = FFS_INVALID_HANDLE;
  184. //uint32 file_size = 0;
  185. //uint16 *file_name =NULL;
  186. //uint16 * dir_name =PNULL;
  187. //uint16  unicodelong  = 0 ;
  188. //MMI_STRING_T                     prompt_str;
  189. FFS_ERROR_E efs_error;
  190. FFS_OVERLAPPED_T overlapped;
  191. uint32 transmit;
  192. //uint8 *efs_buf_ptr = PNULL;
  193. FFS_SAVEFILE_RESULT_T *param_save_ptr = PNULL;
  194. mmsf_GetConstFileData((char *)"\cmsdraftbox.cnf",(char **)&tempbuf,(int *)&filelen);
  195. SCI_TRACE_LOW("fnh filelen = %d",filelen);
  196. SCI_TRACE_LOW("fnh tempbuf len = %d",SCI_STRLEN((char *)tempbuf));
  197. if (filelen > 0)
  198. {
  199. SCI_TRACE_LOW("MMIMMS_SaveManagerDraftboxFile THE cmshandle > 0");
  200. if(0!=FILE_CdMMSPath())
  201. {
  202.    FILE_CreateDir( (char *)MMIMMS_MMS_DIR);
  203.    FILE_CdMMSPath();
  204. }
  205. cur_hefs = FILE_Create((char*)MANAGER_FLASH_DRAFTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
  206. if (cur_hefs == FFS_INVALID_HANDLE)
  207. {
  208.        SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile CREATE FILE FAILED1");
  209. //the reason may be that I have not closed the former opened file with the same name
  210. FILE_Close(cur_hefs); //close former file
  211. cur_hefs = FILE_Create((char*)MANAGER_FLASH_DRAFTBOXNAME, FFS_MODE_CREATE_ALWAYS | FFS_MODE_WRITE);
  212. if (cur_hefs == FFS_INVALID_HANDLE)
  213. {
  214.     SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile CREATE FILE IS FAILED2");
  215. mmsf_Remove((char *)"\cmsdraftbox.cnf");
  216. return ;
  217. }
  218. }
  219. SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile CREATE FILE IS OK");
  220. param_save_ptr = (FFS_SAVEFILE_RESULT_T*)cms_malloc(sizeof(FFS_SAVEFILE_RESULT_T));
  221. if (param_save_ptr == NULL)
  222. {
  223. SCI_TRACE_LOW("fnh param_save_ptr malloc fail");
  224. mmsf_Remove((char *)"\cmsdraftbox.cnf");
  225. FILE_Close(cur_hefs );
  226. cur_hefs = FFS_INVALID_HANDLE;
  227. return;
  228. }
  229. SCI_MEMSET(param_save_ptr, 0, sizeof(FFS_SAVEFILE_RESULT_T));
  230. param_save_ptr->buf_ptr = tempbuf;
  231. param_save_ptr->hefs = cur_hefs;//传递的参数
  232. param_save_ptr->buf_size = filelen;
  233. overlapped.offset = 0;
  234. overlapped.param = (FFS_PARAM)param_save_ptr; //free it in call back function
  235. overlapped.complete_route = SaveFS_SaveDraftboxFile_CallBack; 
  236. efs_error = FILE_Write(
  237. cur_hefs,
  238. tempbuf,
  239. filelen,
  240. &transmit,
  241. &overlapped
  242. );
  243. if((FFS_ERROR_IO_PENDING != efs_error) &&(FFS_NO_ERROR != efs_error))
  244. {
  245.      SCI_TRACE_LOW("HERE MMIMMS_SaveManagerDraftboxFile 1");
  246.  if (param_save_ptr != NULL)
  247.  {
  248.  cms_free(param_save_ptr );
  249.  param_save_ptr = NULL;
  250.  }
  251.  mmsf_Remove((char *)"\cmsdraftbox.cnf");
  252.  FILE_Close(cur_hefs);
  253.  cur_hefs = FFS_INVALID_HANDLE;
  254. return ;
  255. }
  256. }
  257. else
  258. {
  259. mmsf_Remove((char*)"\cmsdraftbox.cnf" );
  260. FILE_CdMMSPath();
  261. if(FILE_CheckExist((const char*)MANAGER_FLASH_DRAFTBOXNAME) == TRUE)
  262. {      
  263. FFS_ERROR_E ffs_error = 0;
  264. uint16  ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  265. int ucs2_name_len = 0;
  266. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MANAGER_FLASH_DRAFTBOXNAME, SCI_STRLEN((char*)MANAGER_FLASH_DRAFTBOXNAME));
  267. overlapped.offset         = 0;
  268. overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
  269. overlapped.param          = PNULL;
  270. ffs_error  =  FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
  271. SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
  272.    }
  273. }
  274. }
  275. /* ----------------------------------------------------------------------------
  276. * Function Name: CmsTimeToString
  277. * Purpose: 取得文件的长度
  278. * Input:  虚拟文件句柄
  279. * Returns: 虚拟文件的长度
  280. * Author:nihongf@mobilesoft.com.cn
  281. * ----------------------------------------------------------------------------*/ 
  282. uint32 Cms_GetFileLength( FILE_HANDLE file)
  283. {
  284. uint32 curroffset = 0;
  285. uint32 filelength = - 1;
  286. curroffset = mmsf_Tell(file);
  287. if(curroffset!=-1 && mmsf_Seek(file, 0, SEEK_END)==0)
  288. {
  289. filelength = mmsf_Tell(file);
  290. mmsf_Seek(file, curroffset, SEEK_SET);
  291. }
  292. return filelength;
  293. }
  294. /* ----------------------------------------------------------------------------
  295. * Function Name: SaveFS_SaveInboxFile_CallBack
  296. * Purpose: 处理保存收件箱文件的回调函数
  297. * Input:  FFS_ERROR_E efs_error, 
  298.   FFS_RESULT result, 
  299.   FFS_PARAM param
  300. * Returns: void
  301. * Author:nihongf@mobilesoft.com.cn
  302. * ----------------------------------------------------------------------------*/ 
  303. LOCAL void SaveFS_SaveInboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  304. {
  305. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  306. FFS_SAVEFILE_RESULT_T efs_result;
  307. SCI_TRACE_LOW("mmimms:SaveFS_SaveInboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  308. //init
  309. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  310. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  311. //judge write status
  312.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  313.     {    
  314.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  315.     }
  316.     else
  317.     {
  318. efs_result.write_result = SAVEFS_WRITE_FAIL;
  319.     }
  320. //post message
  321. efs_result.hefs = efs_param_ptr->hefs;
  322. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  323. efs_result.buf_size = efs_param_ptr->buf_size;
  324. MMK_PostMsg(
  325. VIRTUAL_WIN_ID, 
  326. MSG_MANAGERFILEWRITE_INBOX_OK, 
  327. &efs_result, 
  328. sizeof(FFS_SAVEFILE_RESULT_T)
  329. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  330. //free in param
  331. g_savestate = MMS_MSG_SAVEFILE_FOR_NULL;
  332. if(efs_param_ptr != PNULL)
  333. {
  334. cms_free(efs_param_ptr);
  335. efs_param_ptr = PNULL;
  336. }
  337. }
  338. /* ----------------------------------------------------------------------------
  339. * Function Name: SaveFS_SaveInboxPUSHFile_CallBack
  340. * Purpose: 处理保存收件箱中PUSH文件的回调函数
  341. * Input:  FFS_ERROR_E efs_error, 
  342.   FFS_RESULT result, 
  343.   FFS_PARAM param
  344. * Returns: void
  345. * Author:nihongf@mobilesoft.com.cn
  346. * ----------------------------------------------------------------------------*/ 
  347. LOCAL void SaveFS_SaveInboxPUSHFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  348. {
  349. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  350. FFS_SAVEFILE_RESULT_T efs_result;
  351. SCI_TRACE_LOW("mmimms:SaveFS_SaveInboxPUSHFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  352. //init
  353. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  354. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  355. //judge write status
  356.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  357.     {    
  358.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  359.     }
  360.     else
  361.     {
  362. efs_result.write_result = SAVEFS_WRITE_FAIL;
  363.     }
  364. //post message
  365. efs_result.hefs = efs_param_ptr->hefs;
  366. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  367. efs_result.buf_size = efs_param_ptr->buf_size;
  368. MMK_PostMsg(
  369. MMIMMS_READ_MMS_WAITING_WIN_ID, 
  370. MSG_MANAGERFILEWRITE_INBOX_OK, 
  371. &efs_result, 
  372. sizeof(FFS_SAVEFILE_RESULT_T)
  373. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  374. //free in param
  375. g_savestate = MMS_MSG_SAVEFILE_FOR_NULL;
  376. if(efs_param_ptr != PNULL)
  377. {
  378. cms_free(efs_param_ptr);
  379. efs_param_ptr = PNULL;
  380. }
  381. }
  382. /* ----------------------------------------------------------------------------
  383. * Function Name: SaveFS_SaveOutboxFile_CallBack
  384. * Purpose: 处理保存彩信到发件箱回调函数
  385. * Input:  FFS_ERROR_E efs_error, 
  386.   FFS_RESULT result, 
  387.   FFS_PARAM param
  388. * Returns: void
  389. * Author:nihongf@mobilesoft.com.cn
  390. * ----------------------------------------------------------------------------*/ 
  391. LOCAL void SaveFS_SaveOutboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  392. {
  393. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  394. FFS_SAVEFILE_RESULT_T efs_result;
  395. SCI_TRACE_LOW("mmimms:SaveFS_SaveOutboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  396. //init
  397. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  398. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  399. //judge write status
  400.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  401.     {    
  402.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  403.     }
  404.     else
  405.     {
  406. efs_result.write_result = SAVEFS_WRITE_FAIL;
  407.     }
  408. //post message
  409. efs_result.hefs = efs_param_ptr->hefs;
  410. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  411. efs_result.buf_size = efs_param_ptr->buf_size;
  412. if (g_mailbox_status != SEND_OUTBOX_MMS)
  413. {
  414.       MMK_PostMsg(
  415. VIRTUAL_WIN_ID, 
  416. MSG_MANAGERFILEWRITE_OUTBOX_OK, 
  417. &efs_result, 
  418. sizeof(FFS_SAVEFILE_RESULT_T)
  419. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  420. }else
  421.       MMK_PostMsg(
  422. MMIMMS_SAVE_MMS_WAITING_WIN_ID, 
  423. MSG_MANAGERFILEWRITE_OUTBOX_OK, 
  424. &efs_result, 
  425. sizeof(FFS_SAVEFILE_RESULT_T)
  426. );
  427. }
  428. //free in param
  429. if(efs_param_ptr != PNULL)
  430. {
  431. cms_free(efs_param_ptr);
  432. efs_param_ptr = PNULL;
  433. }
  434. }
  435. /* ----------------------------------------------------------------------------
  436. * Function Name: SaveFS_SaveSentboxFile_CallBack
  437. * Purpose: 处理保存彩信到已发箱回调函数
  438. * Input:  FFS_ERROR_E efs_error, 
  439.   FFS_RESULT result, 
  440.   FFS_PARAM param
  441. * Returns: void
  442. * Author:nihongf@mobilesoft.com.cn
  443. * ----------------------------------------------------------------------------*/ 
  444. LOCAL void SaveFS_SaveSentboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  445. {
  446. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  447. FFS_SAVEFILE_RESULT_T efs_result;
  448. SCI_TRACE_LOW("mmimms:SaveFS_SaveSentboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  449. //init
  450. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  451. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  452. //judge write status
  453.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  454.     {    
  455.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  456.     }
  457.     else
  458.     {
  459. efs_result.write_result = SAVEFS_WRITE_FAIL;
  460.     }
  461. //post message
  462. efs_result.hefs = efs_param_ptr->hefs;
  463. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  464. efs_result.buf_size = efs_param_ptr->buf_size;
  465. MMK_PostMsg(
  466. VIRTUAL_WIN_ID, 
  467. MSG_MANAGERFILEWRITE_SENTBOX_OK, 
  468. &efs_result, 
  469. sizeof(FFS_SAVEFILE_RESULT_T)
  470. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  471. //free in param
  472. if(efs_param_ptr != PNULL)
  473. {
  474. cms_free(efs_param_ptr);
  475. efs_param_ptr = PNULL;
  476. }
  477. }
  478. /* ----------------------------------------------------------------------------
  479. * Function Name: SaveFS_SaveDraftboxFile_CallBack
  480. * Purpose: 处理保存彩信到草稿箱回调函数
  481. * Input:  FFS_ERROR_E efs_error, 
  482.   FFS_RESULT result, 
  483.   FFS_PARAM param
  484. * Returns: void
  485. * Author:nihongf@mobilesoft.com.cn
  486. * ----------------------------------------------------------------------------*/ 
  487. LOCAL void SaveFS_SaveDraftboxFile_CallBack(FFS_ERROR_E efs_error, FFS_RESULT result, FFS_PARAM param)
  488. {
  489. FFS_SAVEFILE_RESULT_T *efs_param_ptr = PNULL;
  490. FFS_SAVEFILE_RESULT_T efs_result;
  491. SCI_TRACE_LOW("mmimms:SaveFS_SaveDraftboxFile_CallBack, efs_error=%d, result=%d, param=%d, %d", efs_error, result, param, __LINE__);
  492. //init
  493. SCI_MEMSET(&efs_result, 0, sizeof(efs_result));
  494. efs_param_ptr = (FFS_SAVEFILE_RESULT_T *)param;
  495. //judge write status
  496.     if(FFS_ERROR_NONE == efs_error && result == efs_param_ptr->buf_size)
  497.     {    
  498.         efs_result.write_result = SAVEFS_WRITE_SUCCEED;
  499.     }
  500.     else
  501.     {
  502. efs_result.write_result = SAVEFS_WRITE_FAIL;
  503.     }
  504. //post message
  505. efs_result.hefs = efs_param_ptr->hefs;
  506. efs_result.buf_ptr = efs_param_ptr->buf_ptr;
  507. efs_result.buf_size = efs_param_ptr->buf_size;
  508. MMK_PostMsg(
  509. VIRTUAL_WIN_ID, 
  510. MSG_MANAGERFILEWRITE_DRAFTBOX_OK, 
  511. &efs_result, 
  512. sizeof(FFS_SAVEFILE_RESULT_T)
  513. ); //note: MMK_PostMsg will save one copy of this message, and it will free it
  514. //free in param
  515. if(efs_param_ptr != PNULL)
  516. {
  517. cms_free(efs_param_ptr);
  518. efs_param_ptr = PNULL;
  519. }
  520. }
  521. /* ----------------------------------------------------------------------------
  522. * Function Name: MMIMMS_GetManagerDocument
  523. * Purpose:获得当前的彩信管理结构
  524. * Input:  void
  525. * Returns: void
  526. * Author:nihongf@mobilesoft.com.cn
  527. * ----------------------------------------------------------------------------*/ 
  528. void   MMIMMS_GetManagerDocument(MMIMMS_OPTION_BOX option_box)
  529. {
  530. pMessageFolder folder =NULL;
  531. SCI_TRACE_LOW("MMIMMS_GetManagerDocument in ----");
  532. if (g_pManager == NULL)
  533. {
  534. g_pManager = (P_ManagerDocument)cms_malloc(sizeof(ManagerDocument));
  535. if(!g_pManager)
  536. {
  537.   SCI_TRACE_LOW("malloc failed,g_pManager = NULL");
  538.   return ;
  539. }
  540. SCI_MEMSET(g_pManager,0,sizeof(ManagerDocument));
  541. }
  542. if (g_pManager->inboxfolder == NULL)
  543. {
  544. SCI_TRACE_LOW("FNH IS INBOX!");
  545. folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
  546. if(!folder)
  547. {
  548.   SCI_TRACE_LOW("malloc failed,infolder = NULL");
  549.   return ;
  550. }
  551. SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
  552. folder->type = MMS_FOLDER_TYPE_INBOX;
  553. g_pManager->inboxfolder = folder;
  554. folder = NULL;
  555. }
  556. if (g_pManager->outboxfolder == NULL)
  557. {
  558. SCI_TRACE_LOW("FNH IS OUTBOX");
  559. folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
  560. if(!folder)
  561. {
  562.   SCI_TRACE_LOW("malloc failed,outfolder = NULL");
  563.   return ;
  564. }
  565. SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
  566. folder->type = MMS_FOLDER_TYPE_OUTBOX;
  567. g_pManager->outboxfolder = folder;
  568. }
  569. if (g_pManager->sentfolder == NULL)
  570. {
  571. SCI_TRACE_LOW("FNH IS SENTBOX");
  572. folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
  573. if(!folder)
  574. {
  575.   SCI_TRACE_LOW("malloc failed,sentfolder = NULL");
  576.   return ;
  577. }
  578. SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
  579. folder->type = MMS_FOLDER_TYPE_SENTBOX;
  580. g_pManager->sentfolder=folder;
  581. }
  582. if (g_pManager->draftfolder == NULL)
  583. {
  584. SCI_TRACE_LOW("FNH IS DRAFTBOX");
  585. folder =(pMessageFolder)cms_malloc(sizeof(MESSAGEFOLDER));
  586. if(!folder)
  587. {
  588.   SCI_TRACE_LOW("malloc failed,draftfolder = NULL");
  589.   return ;
  590. }
  591. SCI_MEMSET(folder, 0, sizeof(MESSAGEFOLDER));
  592. folder->type = MMS_FOLDER_TYPE_DRAFTBOX;
  593. g_pManager->draftfolder=folder;
  594. }
  595. switch(option_box)
  596. {
  597. case ALL_BOX:
  598. SCI_TRACE_LOW("fnh all_box");
  599. break;
  600. case INBOX:
  601. {
  602. SCI_TRACE_LOW("fnh read inboxfolder!");
  603. MMIMMS_ReadFolder(g_pManager->inboxfolder);
  604. }
  605. break;
  606. case OUTBOX:
  607. {
  608. SCI_TRACE_LOW("fnh read outboxfolder");
  609. MMIMMS_ReadFolder(g_pManager->outboxfolder);
  610. }
  611. break;
  612. case SENTBOX:
  613. {
  614. SCI_TRACE_LOW("fnh read sentfolder");
  615. MMIMMS_ReadFolder(g_pManager->sentfolder);
  616. }
  617. break;
  618. case DRAFTBOX:
  619. {
  620. SCI_TRACE_LOW("fnh read draftfolder");
  621. MMIMMS_ReadFolder(g_pManager->draftfolder);
  622. }
  623. break;
  624. default:
  625. SCI_TRACE_LOW("FNH IS default");
  626. break;
  627. }
  628. SCI_TRACE_LOW("MMIMMS_GetManagerDocument OUT ----");
  629. }
  630. /* ----------------------------------------------------------------------------
  631. * Function Name: MMIMMS_ResetConfig
  632. * Purpose: 重新设置成初始值
  633. * Input:  void
  634. * Returns: void
  635. * Author:nihongf@mobilesoft.com.cn
  636. * ----------------------------------------------------------------------------*/ 
  637. void   MMIMMS_ResetConfig(void)
  638. {
  639. SCI_MEMSET(&g_nv_setting_mirror, 0, sizeof(g_nv_setting_mirror));
  640. SCI_STRCPY((char *)g_nv_setting_mirror.centre_addr,"http://mmsc.monternet.com/");
  641. SCI_STRCPY((char *)g_nv_setting_mirror.gateway,"10.0.0.172");
  642. SCI_STRCPY((char *)g_nv_setting_mirror.port,"9201");
  643. SCI_STRCPY((char *)g_nv_setting_mirror.username,"");
  644. SCI_STRCPY((char *)g_nv_setting_mirror.password,"");
  645. SCI_STRCPY((char *)g_nv_setting_mirror.apn,"cmwap");
  646. g_nv_setting_mirror.anonymous = MMS_MSG_SETTINGS_OFF;
  647. g_nv_setting_mirror.prior = MMS_MSG_SETTINGS_PRIORITY_NORMAL;
  648. g_nv_setting_mirror.retrieve_mode = MMS_MSG_SETTINGS_RETRIEVE_AUTO;
  649. g_nv_setting_mirror.delivery_rpt = MMS_MSG_SETTINGS_OFF;
  650. g_nv_setting_mirror.read_rpt = MMS_MSG_SETTINGS_OFF;
  651. g_nv_setting_mirror.play_sound = MMS_MSG_SETTINGS_ON;
  652. g_nv_setting_mirror.advertisingallowable = MMS_MSG_SETTINGS_OFF;
  653. g_nv_setting_mirror.valid_period = MMS_MSG_VALID_PERIOD_LONGEST;  //fnh modify 20060510 MMS_MSG_VALID_PERIOD_12_HOUR;
  654. g_nv_setting_mirror.auto_sign = MMS_MSG_SETTINGS_OFF; // fnh add 20060516
  655. MMINV_WRITE(MMINV_MMS_SETTING, &g_nv_setting_mirror);
  656. if(FILE_CheckExist((const char*)MMSAUTOSIGNFILE) == TRUE)
  657. {      
  658. FFS_ERROR_E ffs_error = 0;
  659. uint16  ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  660. int ucs2_name_len = 0;
  661. FFS_OVERLAPPED_T overlapped;
  662. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)MMSAUTOSIGNFILE, SCI_STRLEN((char*)MMSAUTOSIGNFILE));
  663. SCI_TRACE_LOW("FNH BEFORE DELETE autosignfile!");
  664. overlapped.offset         = 0;
  665. overlapped.complete_route = MMIVC_CallBackDeleteManagerFile;
  666. overlapped.param          = PNULL;
  667. ffs_error  =  FFS_AYS_Delete(FS_UDISK, (const wchar*)ucs2_name_arr, &overlapped);
  668. SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
  669. }
  670. /*
  671. g_pcur_signdoc = MMS_New();
  672. SCI_ASSERT(g_pcur_signdoc != NULL);
  673. SCI_TRACE_LOW("FNH new mms!");
  674. MMS_New_Slide(g_pcur_signdoc);
  675. MMIMMS_SaveAutoSignMessage(g_pcur_signdoc);
  676. */
  677. }
  678. /* ----------------------------------------------------------------------------
  679. * Function Name: MMIMMS_StoreMangerDocument
  680. * Purpose:存储当前的管理结构到虚拟文件中
  681. * Input:  void
  682. * Returns: void
  683. * Author:nihongf@mobilesoft.com.cn
  684. * ----------------------------------------------------------------------------*/ 
  685. void MMIMMS_StoreMangerDocument(void)
  686. {
  687. if(!g_pManager)
  688.   return ;
  689. MMIMMS_StoreFolder(g_pManager->inboxfolder);
  690. MMIMMS_StoreFolder(g_pManager->outboxfolder);
  691. MMIMMS_StoreFolder(g_pManager->sentfolder);
  692. MMIMMS_StoreFolder(g_pManager->draftfolder);
  693. }
  694.   
  695. /* ----------------------------------------------------------------------------
  696. * Function Name: MMIMMS_FreeManagerDocument
  697. * Purpose:释放当前的管理结构
  698. * Input:  void
  699. * Returns: void
  700. * Author:nihongf@mobilesoft.com.cn
  701. * ----------------------------------------------------------------------------*/ 
  702. void MMIMMS_FreeManagerDocument()
  703. {
  704. if(g_pManager->inboxfolder != NULL)
  705.   MMIMMS_FreeFolder(g_pManager->inboxfolder);
  706. g_pManager->inboxfolder =NULL;
  707. if(g_pManager->outboxfolder != NULL)
  708.   MMIMMS_FreeFolder(g_pManager->outboxfolder);
  709. g_pManager->outboxfolder =NULL;
  710. if(g_pManager->sentfolder != NULL)
  711.   MMIMMS_FreeFolder(g_pManager->sentfolder);
  712. g_pManager->sentfolder =NULL;
  713. if(g_pManager->draftfolder != NULL)
  714.   MMIMMS_FreeFolder(g_pManager->draftfolder);
  715. g_pManager->draftfolder =NULL;
  716. g_pManager->currentfolder = NULL;
  717. g_pManager  = NULL;
  718. }
  719. /* ----------------------------------------------------------------------------
  720. * Function Name: MMIMMS_ReadFolder
  721. * Purpose:读取相应文件配置需要操作的文件夹
  722. * Input:  pMessageFolder:当前需要操作的folder
  723. * Returns: void
  724. * Author:nihongf@mobilesoft.com.cn
  725. * ----------------------------------------------------------------------------*/ 
  726. void MMIMMS_ReadFolder(pMessageFolder folder)
  727. {
  728. FILE_HANDLE fp;
  729. MESSAGELIST     mlist;
  730. pMessageList messagelist, tlist;
  731. uint8                     pathname[256];
  732. //    MMS_DEBUG(" enter readmessagefolder");
  733. SCI_TRACE_LOW("MMIMMS_ReadFolder IN ----");
  734. if(folder == NULL)
  735. {
  736. SCI_TRACE_LOW("MMIMMS_ReadFolder error: folder is NULL");
  737. return ;
  738. }
  739. SCI_STRCPY((char*)pathname, (char*)CURR_DIRECTORY);
  740. SCI_TRACE_LOW("fnh folder->type = %d",folder->type);
  741. switch (folder->type)
  742. {
  743. case MMS_FOLDER_TYPE_INBOX:
  744. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERINBOXFILE);
  745. break;
  746. case MMS_FOLDER_TYPE_OUTBOX:
  747. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGEROUTBOXFILE);
  748. break;
  749. case MMS_FOLDER_TYPE_SENTBOX:
  750. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERSENTBOXFILE);//文件名暂时这么命名,全局变量代替.
  751. break;
  752. case MMS_FOLDER_TYPE_DRAFTBOX:
  753. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERDRAFTBOXFILE);//文件名暂时这么命名,全局变量代替.
  754. break;
  755. default:
  756. return ;
  757. }
  758. SCI_TRACE_LOW("fnh pathname = %s",pathname);
  759. fp=mmsf_Open((char*)pathname, "rb");
  760. if(fp==0)
  761. {
  762. SCI_TRACE_LOW("cannot open the file %s",pathname);
  763. return ;
  764. SCI_MEMSET(&mlist, 0, sizeof(MESSAGELIST));
  765. while(mmsf_Read((char*)&mlist, sizeof(MESSAGELIST), 1, fp) != 0)
  766. {
  767. //MMS_DEBUG("read a message list");
  768. SCI_TRACE_LOW("fnh read a message list");
  769. messagelist=(pMessageList)cms_malloc(sizeof(MESSAGELIST));
  770. if(messagelist==NULL)
  771. {
  772. SCI_TRACE_LOW("MMIMMS_ReadFolder error: messagelist is NULL");
  773. return ;
  774. }
  775. SCI_MEMSET(messagelist, 0, sizeof(MESSAGELIST));
  776. SCI_MEMCPY(messagelist, &mlist, sizeof(MESSAGELIST));
  777. messagelist->next = PNULL;
  778. MMIMMS_ReadMessageHeads(messagelist, fp);
  779. // MMS_DEBUG(" message title: %s", mlist.title);
  780. if(folder->root==NULL)
  781. {
  782. folder->root=messagelist;
  783. }
  784. else
  785. {
  786. for(tlist=folder->root; tlist->next; tlist=tlist->next);
  787. tlist->next=messagelist;
  788. }
  789. // folder->size += messagelist->size;
  790. SCI_TRACE_LOW("fnh messagelist->state = %d",messagelist->state);
  791. if (folder->type == MMS_FOLDER_TYPE_INBOX)
  792. {
  793. if(messagelist->state == 0)
  794. {
  795. folder->unsettlednumber++;//modify liangliu 2006-4-12
  796. SCI_TRACE_LOW("fnh folder->unsettlednumber = %d",folder->unsettlednumber);
  797. }
  798. }
  799. folder->messagenumber++;
  800. SCI_TRACE_LOW("fnh folder->messagenumber = %d",folder->messagenumber);
  801. SCI_MEMSET(&mlist, 0, sizeof(MESSAGELIST));
  802. }
  803. mmsf_Close(fp);
  804. mmsf_RemoveByHandle(fp);//modify by liangliu 2006-3-6
  805. folder->currentmessage = folder->root;
  806. }
  807.   
  808. /* ----------------------------------------------------------------------------
  809. * Function Name: MMIMMS_ReadMessageHeads
  810. * Purpose:从fp中读取彩信列表的头数据,主要是指列表中指针所指向的域
  811. * Input:  pMessageList:需要操作的msg指针
  812.           fp:文件句柄
  813. * Returns: void
  814. * Author:nihongf@mobilesoft.com.cn
  815. * ----------------------------------------------------------------------------*/ 
  816. void  MMIMMS_ReadMessageHeads(pMessageList messagelist, FILE_HANDLE fp)
  817. {
  818. MMIMMS_ReadTextField((char **)&(messagelist->filename), fp);
  819. MMIMMS_ReadTextField((char **)&(messagelist->subject), fp);
  820. MMIMMS_ReadTextField((char **)&(messagelist->date), fp);
  821. SCI_TRACE_LOW("FNH read to_address!");
  822. MMIMMS_ReadTextField((char **)&(messagelist->to_address), fp);
  823. MMIMMS_ReadTextField((char **)&(messagelist->cc_address), fp);
  824. MMIMMS_ReadTextField((char **)&(messagelist->bcc_address), fp);
  825. MMIMMS_ReadTextField((char **)&(messagelist->sender), fp);
  826. MMIMMS_ReadTextField((char **)&(messagelist->url), fp);
  827. MMIMMS_ReadTextField((char **)&(messagelist->msg_id), fp);
  828. }
  829.   
  830. /* ----------------------------------------------------------------------------
  831. * Function Name: MMIMMS_ReadTextField
  832. * Purpose:从fp中读取数据并使field指向该数据.
  833. * Input:  char **需要操作的指针的地址指针所指向的内容(空间)
  834.           fp:文件句柄
  835. * Returns: void
  836. * Author:nihongf@mobilesoft.com.cn
  837. * ----------------------------------------------------------------------------*/ 
  838. void  MMIMMS_ReadTextField(char**field,FILE_HANDLE fp)
  839. {
  840. uint32 i=0;
  841. uint8 buffer[MMIMMS_MAX_ADDRESS_NUM * MAX_NAME_LENGTH + MMIMMS_MAX_ADDRESS_NUM];
  842. uint16  address_max_len = MMIMMS_MAX_ADDRESS_NUM * MAX_NAME_LENGTH + MMIMMS_MAX_ADDRESS_NUM;
  843. SCI_MEMSET(buffer,0,address_max_len);
  844. while(mmsf_Read((char*)(buffer+i), 1, 1, fp)==1)
  845. {
  846. if(buffer[i++] == 0)
  847. {
  848. break;
  849. }
  850. if(i>address_max_len)
  851. {
  852. buffer[i]=0;
  853. break;
  854. }
  855. }
  856. SCI_TRACE_LOW("fnh read i = %ld",i);
  857. if(i>1)
  858. {
  859. *field = (char *)cms_malloc(i+1);
  860. if(*field)
  861. {
  862. SCI_STRCPY((char*)*field,(char*) buffer);
  863. // MMS_DEBUG(" message head: %s", *field);
  864. }
  865. }
  866. else
  867. {
  868. *field = 0;
  869. }
  870. }
  871.   
  872. /* ----------------------------------------------------------------------------
  873. * Function Name: MMIMMS_ReadTextField
  874. * Purpose:存储相应文件配置需要操作的文件夹存储方案为原来MANAGER中
  875. * Input:  pMessageFolder:当前需要操作的folder
  876. * Returns: void
  877. * Author:nihongf@mobilesoft.com.cn
  878. * ----------------------------------------------------------------------------*/ 
  879. void MMIMMS_StoreFolder(pMessageFolder folder)
  880. {
  881. FILE_HANDLE fp=0;
  882. pMessageList  tlist;
  883. CMS_MMS_S8 pathname[256];
  884. if(folder == NULL)
  885. {
  886. return;
  887. }
  888. SCI_TRACE_LOW("MMIMMS_StoreFolder IN -----------");
  889. SCI_STRCPY((char *)pathname, (char *)CURR_DIRECTORY);
  890. switch (folder->type)
  891. {
  892. case MMS_FOLDER_TYPE_INBOX:
  893. /* initialize receive message folder */
  894. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERINBOXFILE);
  895. break;
  896. case MMS_FOLDER_TYPE_OUTBOX:
  897. /* initialize send message folder */
  898. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGEROUTBOXFILE);
  899. break;
  900. case MMS_FOLDER_TYPE_SENTBOX:
  901. /* initialize draft message folder */
  902. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERSENTBOXFILE);
  903. break;
  904. case MMS_FOLDER_TYPE_DRAFTBOX:
  905. /* initialize draft message folder */
  906. MMS_strcat((P_CMS_MMS_U8)pathname, (P_CMS_MMS_U8)MANAGERDRAFTBOXFILE);
  907. break;
  908. default:
  909. break;
  910. }
  911. /* store message list */
  912. fp=mmsf_Open(pathname, "wb");
  913. if(fp)
  914. {
  915. for(tlist=folder->root; tlist; tlist=tlist->next)
  916. {
  917. mmsf_Write((char*)tlist, sizeof(MESSAGELIST), 1, fp);
  918. /* store message head field */
  919. MMIMMS_StoreMessageHeads(tlist, fp);
  920. }
  921. mmsf_Close(fp);
  922. }
  923. }
  924.   
  925. /* ----------------------------------------------------------------------------
  926. * Function Name: MMIMMS_StoreMessageHeads
  927. * Purpose:存储其中的指针所指向的数据
  928. * Input:  pMessageList:  需要操作的msg指针
  929. * Returns: void
  930. * Author:nihongf@mobilesoft.com.cn
  931. * ----------------------------------------------------------------------------*/ 
  932. void  MMIMMS_StoreMessageHeads(pMessageList mlist, FILE_HANDLE fp)
  933. {
  934. CMS_MMS_S8 ch[2];
  935. ch[0]=0;
  936. ch[1]=0;
  937. // //MMS_DEBUG("store message head fields");
  938. SCI_TRACE_LOW("MMIMMS_StoreMessageHeads IN -----------");
  939. if(mlist->filename)
  940. {
  941. mmsf_Write((char*)mlist->filename, 1, SCI_STRLEN((char *)mlist->filename)+1, fp);
  942. }
  943. else
  944. {
  945. mmsf_Write((char*)ch, 1, 1, fp);
  946. }
  947. if(mlist->subject)
  948. {
  949. mmsf_Write((char*)mlist->subject, 1, SCI_STRLEN((char *)mlist->subject)+1, fp);
  950. }
  951. else
  952. {
  953. mmsf_Write((char*)ch, 1, 1, fp);
  954. }
  955. if(mlist->date)
  956. {
  957. mmsf_Write((char*)mlist->date, 1, SCI_STRLEN((char *)mlist->date)+1, fp);
  958. }
  959. else
  960. {
  961. mmsf_Write((char*)ch, 1, 1, fp);
  962. }
  963. if(mlist->to_address)
  964. {
  965. mmsf_Write((char*)mlist->to_address, 1, SCI_STRLEN((char *)mlist->to_address)+1, fp);
  966. }
  967. else
  968. {
  969. mmsf_Write((char*)ch, 1, 1, fp);
  970. }
  971. if(mlist->cc_address)
  972. {
  973. mmsf_Write((char*)mlist->cc_address, 1, SCI_STRLEN((char *)mlist->cc_address)+1, fp);
  974. }
  975. else
  976. {
  977. mmsf_Write((char*)ch, 1, 1, fp);
  978. }
  979. if(mlist->bcc_address)
  980. {
  981. mmsf_Write((char*)mlist->bcc_address, 1, SCI_STRLEN((char *)mlist->bcc_address)+1, fp);
  982. }
  983. else
  984. {
  985. mmsf_Write((char*)ch, 1, 1, fp);
  986. }
  987. if(mlist->sender)
  988. {
  989. mmsf_Write((char*)mlist->sender, 1, SCI_STRLEN((char *)mlist->sender)+1, fp);
  990. }
  991. else
  992. {
  993. mmsf_Write((char*)ch, 1, 1, fp);
  994. }
  995. if(mlist->url)
  996. {
  997. mmsf_Write((char*)mlist->url, 1, SCI_STRLEN((char *)mlist->url)+1, fp);
  998. }
  999. else
  1000. {
  1001. mmsf_Write((char*)ch, 1, 1, fp);
  1002. }
  1003. if(mlist->msg_id)
  1004. {
  1005. mmsf_Write((char*)mlist->msg_id, 1, SCI_STRLEN((char *)mlist->msg_id)+1, fp);
  1006. }
  1007. else
  1008. {
  1009. mmsf_Write((char*)ch, 1, 1, fp);
  1010. }
  1011.   
  1012. }
  1013.   
  1014. /* ----------------------------------------------------------------------------
  1015. * Function Name: MMIMMS_FreeFolder
  1016. * Purpose:释放当前的文件夹的内存空间
  1017. * Input:  pMessageFolder:当前需要操作的folder
  1018. * Returns: void
  1019. * Author:nihongf@mobilesoft.com.cn
  1020. * ----------------------------------------------------------------------------*/ 
  1021. void MMIMMS_FreeFolder(pMessageFolder folder)
  1022. {
  1023. pMessageList  tlist;
  1024. if(folder)
  1025. {
  1026. for(tlist=folder->root; folder->root; )
  1027. {
  1028. /* free message list */
  1029. folder->root=tlist->next;
  1030. MMIMMS_FreeMessage(tlist);
  1031. tlist=folder->root;
  1032. }
  1033. cms_free(folder);
  1034. folder = PNULL;
  1035. }
  1036. }
  1037. /* ----------------------------------------------------------------------------
  1038. * Function Name: MMIMMS_FreeFolderForInit
  1039. * Purpose:初始化释放管理目录
  1040. * Input:  pMessageFolder:当前需要操作的folder
  1041. * Returns: void
  1042. * Author:nihongf@mobilesoft.com.cn
  1043. * ----------------------------------------------------------------------------*/ 
  1044. void MMIMMS_FreeFolderForInit(pMessageFolder folder)
  1045. {
  1046. pMessageList  tlist;
  1047. if(folder)
  1048. {
  1049. for(tlist=folder->root; folder->root; )
  1050. {
  1051. /* free message list */
  1052. folder->root=tlist->next;
  1053. MMIMMS_FreeMessage(tlist);
  1054. tlist=folder->root;
  1055. }
  1056. }
  1057. }
  1058. /* ----------------------------------------------------------------------------
  1059. * Function Name: MMIMMS_FreeMessage
  1060. * Purpose:释放当前的LIST
  1061. * Input:  pMessageList:需要释放空间的消息list指针
  1062. * Returns: void
  1063. * Author:nihongf@mobilesoft.com.cn
  1064. * ----------------------------------------------------------------------------*/ 
  1065. void MMIMMS_FreeMessage(pMessageList mlist)
  1066. {
  1067. if(mlist->filename)
  1068. {
  1069. cms_free(mlist->filename);
  1070. mlist->filename = PNULL;
  1071. }
  1072. if(mlist->subject)
  1073. {
  1074. cms_free(mlist->subject);
  1075. mlist->subject = PNULL;
  1076. }
  1077. if(mlist->date)
  1078. {
  1079. cms_free(mlist->date);
  1080. mlist->date =PNULL;
  1081. }
  1082. if(mlist->to_address)
  1083. {
  1084. cms_free(mlist->to_address);
  1085. mlist->to_address =PNULL;
  1086. }
  1087. if(mlist->cc_address)
  1088. {
  1089. cms_free(mlist->cc_address);
  1090. mlist->cc_address =NULL;
  1091. }
  1092. if(mlist->bcc_address)
  1093. {
  1094. cms_free(mlist->bcc_address);
  1095. mlist->bcc_address =NULL;
  1096. }
  1097. if(mlist->sender)
  1098. {
  1099. cms_free(mlist->sender);
  1100. mlist->sender =NULL;
  1101. }
  1102. if(mlist->url)
  1103. {
  1104. cms_free(mlist->url);
  1105. mlist->url =NULL;
  1106. }
  1107. if(mlist->msg_id)
  1108. {
  1109. cms_free(mlist->msg_id);
  1110. mlist->msg_id=NULL;
  1111. }
  1112. cms_free(mlist);
  1113. mlist = NULL ;
  1114. }
  1115. /* ----------------------------------------------------------------------------
  1116. * Function Name: MMIMMS_GetListState
  1117. * Purpose:得到传入list的状态
  1118. * Input:  当前list
  1119. * Returns: list所处状态
  1120. * Author:nihongf@mobilesoft.com.cn
  1121. * ----------------------------------------------------------------------------*/ 
  1122. uint32 MMIMMS_GetListState(pMessageList mlist)
  1123. {
  1124.   return mlist->state;
  1125. }
  1126. /* ----------------------------------------------------------------------------
  1127. * Function Name: MMIMMS_GetManagerTotalNum
  1128. * Purpose:得到总共现在所有彩信数目
  1129. * Input:  void
  1130. * Returns: 所有彩信数目
  1131. * Author:nihongf@mobilesoft.com.cn
  1132. * ----------------------------------------------------------------------------*/ 
  1133. uint32 MMIMMS_GetManagerTotalNum(void)
  1134. {
  1135. uint32 totalnum = 0;
  1136. #ifndef WIN32
  1137. if(g_pManager != NULL)
  1138. {
  1139. totalnum = (g_pManager->inboxfolder->messagenumber-g_pManager->inboxfolder->unsettlednumber) + g_pManager->outboxfolder->messagenumber +g_pManager->sentfolder->messagenumber + g_pManager->draftfolder->messagenumber;
  1140. }
  1141. #endif
  1142. SCI_TRACE_LOW("MMIMMS_GetManagerTotalNum is %d",totalnum);
  1143. return totalnum;
  1144. }
  1145. /* ----------------------------------------------------------------------------
  1146. * Function Name: MMIMMS_DeleteMMS
  1147. * Purpose:删除当前floder的当前管理条目以及对应的彩信
  1148. * Input:  当前操作的文件夹,currentFloder
  1149. * Returns: void
  1150. * Author:nihongf@mobilesoft.com.cn
  1151. * ----------------------------------------------------------------------------*/ 
  1152. void MMIMMS_DeleteMMS(pMessageFolder folder)
  1153. {
  1154. SCI_TRACE_LOW("MMIMMS_DeleteMMS in----------");
  1155. if(!folder)
  1156. {
  1157. return ;
  1158. }
  1159. if(!folder->currentmessage || !folder->root)
  1160. {
  1161. return;
  1162. }
  1163. //下面要根据模拟还是实际情况选择
  1164. if(folder->type == MMS_FOLDER_TYPE_INBOX)//modify 2005-12-3
  1165.     {
  1166.         mmsf_Remove((char*)g_pCurrentList->filename);//在虚拟文件中删除
  1167. SCI_TRACE_LOW("mmsf_Remove the filename is normal-----");
  1168. MMIMMS_DeleteFLASHMMS(g_pCurrentList);//must delete the flash mms first or the list will be empty!
  1169.     }
  1170. else
  1171. {
  1172. mmsf_Remove((char*)folder->currentmessage->filename);//在虚拟文件中删除
  1173. SCI_TRACE_LOW("mmsf_Remove the filename is normal-----");
  1174. MMIMMS_DeleteFLASHMMS(folder->currentmessage);//must delete the flash mms first or the list will be empty!
  1175. }
  1176. }
  1177. /* ----------------------------------------------------------------------------
  1178. * Function Name: MMIMMS_DeleteAllMMS
  1179. * Purpose:删除当前floder的所有管理条目以及对应的彩信
  1180. * Input:  当前操作的文件夹,currentFloder
  1181. * Returns: 
  1182. * Author:nihongf@mobilesoft.com.cn
  1183. * ----------------------------------------------------------------------------*/ 
  1184. void MMIMMS_DeleteAllMMS(pMessageFolder folder)
  1185. {
  1186. if(!folder)
  1187. {
  1188. return;
  1189. }
  1190. folder->currentmessage = folder->root;
  1191. MMIMMS_DeleteMMSOneOfAll(folder);
  1192. }
  1193. /* ----------------------------------------------------------------------------
  1194. * Function Name: MMIMMS_DeleteMMSOneOfAll
  1195. * Purpose:删除当前floder的一条管理条目以及对应的彩信
  1196. * Input:  当前操作的文件夹,currentFloder
  1197. * Returns: 
  1198. * Author:nihongf@mobilesoft.com.cn
  1199. * ----------------------------------------------------------------------------*/ 
  1200. void MMIMMS_DeleteMMSOneOfAll(pMessageFolder folder)
  1201. {
  1202. HFS cur_hefs = FFS_INVALID_HANDLE;
  1203. FFS_OVERLAPPED_T                 overlapped;
  1204. if(!folder)
  1205. {
  1206. return ;
  1207. }
  1208. if(!folder->currentmessage || !folder->root)
  1209. {
  1210. return;
  1211. }
  1212. //下面要根据模拟还是实际情况选择
  1213.     
  1214. mmsf_Remove((char*)folder->currentmessage->filename);//在虚拟文件中删除
  1215. SCI_TRACE_LOW("MMIMMS_DeleteMMSOneOfAll IN -------");
  1216. FILE_CdMMSPath();
  1217. if (folder->currentmessage->filename == NULL)
  1218. {
  1219. MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEONEMMS_OK, PNULL, PNULL);
  1220. SCI_TRACE_LOW("fnh folder->currentmessage->filename is NULL");
  1221. MMI_TriggerMMITask();
  1222. return;
  1223. }
  1224. if(FILE_CheckExist((const char*)folder->currentmessage->filename) == TRUE)
  1225. {
  1226.         //SCI_TRACE_BUF("VC: ReadVideo file_name = ", file_name, video_info_ptr->name_len);
  1227. FFS_ERROR_E ffs_error = 0;
  1228. uint16 ucs2_name_arr[UCS2_NAME_MAX_LEN] = {0};
  1229. int ucs2_name_len = 0;
  1230. ucs2_name_len = GUI_GB2UCS(ucs2_name_arr, (uint8 *)folder->currentmessage->filename, SCI_STRLEN((char*)folder->currentmessage->filename));
  1231. overlapped.offset         = 0;
  1232. overlapped.complete_route = MMIVC_CallBackDeleteOneMMSFile;
  1233. overlapped.param          = PNULL;
  1234. ffs_error  =  FFS_AYS_Delete(g_filetype, (const wchar*)ucs2_name_arr, &overlapped);
  1235. SCI_TRACE_LOW("VC:DeleteVideoFile FFS_AYS_Delete = %d", ffs_error);
  1236. if(  FFS_ERROR_IO_PENDING != ffs_error )
  1237. {
  1238. FFS_Close(g_filetype,cur_hefs);
  1239. }
  1240. }
  1241. else{
  1242. MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEONEMMS_OK, PNULL, PNULL);
  1243. SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
  1244. MMI_TriggerMMITask();
  1245. }
  1246. }
  1247. /* ----------------------------------------------------------------------------
  1248. * Function Name: MMIVC_CallBackDeleteOneMMSFile
  1249. * Purpose: 删除某一彩信的回调函数
  1250. * Input:  FFS_ERROR_E a, 
  1251.   FFS_RESULT result, 
  1252.   FFS_PARAM param
  1253. * Returns: void
  1254. * Author:nihongf@mobilesoft.com.cn
  1255. * ----------------------------------------------------------------------------*/ 
  1256. LOCAL void MMIVC_CallBackDeleteOneMMSFile(
  1257.  FFS_ERROR_E a, 
  1258.  FFS_RESULT result, 
  1259.  FFS_PARAM param
  1260.  )
  1261. {
  1262. MMK_PostMsg(MMIMMS_NORMAL_WAITING_WIN_ID, MSG_MMS_DELETEONEMMS_OK, PNULL, PNULL);
  1263. SCI_TRACE_LOW("VC: MMIVC_CallBackDeleteMMSFile run");
  1264. MMI_TriggerMMITask();
  1265. }
  1266. /* ----------------------------------------------------------------------------
  1267. * Function Name: MMIMMS_DeleteManagerList
  1268. * Purpose:删除当前floder的所有管理条目但不涉及其对应的虚拟文件和flash
  1269.                                           上资源,主要用于发件箱-->已发信箱
  1270. * Input:  当前操作的文件夹,currentFloder
  1271. * Returns: void
  1272. * Author:nihongf@mobilesoft.com.cn
  1273. * ----------------------------------------------------------------------------*/ 
  1274. void MMIMMS_DeleteManagerList(pMessageFolder folder)
  1275. {
  1276. pMessageList tlist = PNULL;
  1277. if(!folder)
  1278. {
  1279. return ;
  1280. }
  1281. if(!folder->currentmessage || !folder->root)
  1282. {
  1283. return;
  1284. }
  1285. if(folder->type == MMS_FOLDER_TYPE_INBOX)
  1286. {
  1287. if(g_pCurrentList->state == 0)
  1288. {
  1289. folder->unsettlednumber--;
  1290. }
  1291. if(folder->root == g_pCurrentList)
  1292. {
  1293. folder->root = folder->root->next;
  1294. MMIMMS_FreeMessage(g_pCurrentList);
  1295. folder->currentmessage=folder->root;
  1296. }
  1297. else
  1298. {
  1299. for(tlist = folder->root; tlist; tlist=tlist->next)
  1300. {
  1301. if(tlist->next == g_pCurrentList)
  1302. {
  1303. tlist->next = g_pCurrentList->next;
  1304. MMIMMS_FreeMessage(g_pCurrentList);
  1305. if(tlist->next)
  1306. folder->currentmessage=tlist->next;
  1307. else
  1308. folder->currentmessage=tlist;
  1309. break;
  1310. }
  1311. }
  1312. }
  1313. }
  1314. else
  1315. {
  1316. if(folder->root == folder->currentmessage)
  1317. {
  1318. folder->root = folder->root->next;
  1319. MMIMMS_FreeMessage(folder->currentmessage);
  1320. folder->currentmessage=folder->root;
  1321. }
  1322. else
  1323. {
  1324. for(tlist = folder->root; tlist; tlist=tlist->next)
  1325. {
  1326. if(tlist->next == folder->currentmessage)
  1327. {
  1328. tlist->next = folder->currentmessage->next;
  1329. MMIMMS_FreeMessage(folder->currentmessage);
  1330. if(tlist->next)
  1331. folder->currentmessage=tlist->next;
  1332. else
  1333. folder->currentmessage=tlist;
  1334. break;
  1335. }
  1336. }
  1337. }
  1338. }
  1339. folder->messagenumber--;
  1340. }
  1341. /* ----------------------------------------------------------------------------
  1342. * Function Name: MMIMMS_DeleteManagerListOneOfAll
  1343. * Purpose: 删除管理目录
  1344. * Input:  pMessageFolder:当前folder
  1345. * Returns: void
  1346. * Author:nihongf@mobilesoft.com.cn
  1347. * ----------------------------------------------------------------------------*/ 
  1348. void MMIMMS_DeleteManagerListOneOfAll(pMessageFolder folder)
  1349. {
  1350. pMessageList tlist = PNULL;
  1351. if(!folder)
  1352. {
  1353. return ;
  1354. }
  1355. if(!folder->currentmessage || !folder->root)
  1356. {
  1357. return;
  1358. }
  1359. if(folder->root == folder->currentmessage)
  1360. {
  1361. folder->root = folder->root->next;
  1362. MMIMMS_FreeMessage(folder->currentmessage);
  1363. SCI_TRACE_LOW("FNH deleteoneofall free 7308");
  1364. folder->currentmessage=folder->root;
  1365. }
  1366. else
  1367. {
  1368. for(tlist = folder->root; tlist; tlist=tlist->next)
  1369. {
  1370. if(tlist->next == folder->currentmessage)
  1371. {
  1372. tlist->next = folder->currentmessage->next;
  1373. MMIMMS_FreeMessage(folder->currentmessage);
  1374. SCI_TRACE_LOW("FNH deleteoneofall free 7319");
  1375. if(tlist->next)
  1376. folder->currentmessage=tlist->next;
  1377. else
  1378. folder->currentmessage=tlist;
  1379. break;
  1380. }
  1381. }
  1382. }
  1383. folder->messagenumber--;
  1384. }
  1385. /******************************************************************************
  1386. *   函数定义: MMIMMS_GetMessageNum(pMessageFolder)
  1387. *   参数说明: 当前folder
  1388. *   返回值: 总共的消息个数
  1389. *   函数说明: 获得当前文件夹总共消息个数
  1390. *   代码编写者: liangliu
  1391. *   代码编写日期: 10/10/2005
  1392. *   修改原因:
  1393. *   修改人员:
  1394. *   修改日期:
  1395.  ********************************************************************************/
  1396. uint32 MMIMMS_GetMessageNum(pMessageFolder folder)
  1397. {
  1398. if(!folder)
  1399. {
  1400.   return 0 ;
  1401. }
  1402. return folder->messagenumber;
  1403. }
  1404. /* ----------------------------------------------------------------------------
  1405. * Function Name: MMIMMS_AppInit
  1406. * Purpose: MMS初始化
  1407. * Input:  void
  1408. * Returns: void
  1409. * Author:nihongf@mobilesoft.com.cn
  1410. * ----------------------------------------------------------------------------*/ 
  1411. PUBLIC void MMIMMS_AppInit(void)
  1412. {
  1413. MN_RETURN_RESULT_E nv_result;
  1414. MMINV_READ(MMINV_MMS_SETTING, &g_nv_setting_mirror, nv_result);
  1415. SCI_TRACE_LOW("FNH after appinit cente_addr = %s",g_nv_setting_mirror.centre_addr);
  1416. SCI_TRACE_LOW("FNH after appinit gateway = %s",g_nv_setting_mirror.gateway);
  1417. SCI_TRACE_LOW("FNH after appinit port = %s",g_nv_setting_mirror.port);
  1418. SCI_TRACE_LOW("FNH after appinit anonymous = %d",g_nv_setting_mirror.anonymous);
  1419. if (MN_RETURN_SUCCESS != nv_result)
  1420. {
  1421. SCI_MEMSET(&g_nv_setting_mirror, 0, sizeof(g_nv_setting_mirror));
  1422. SCI_STRCPY((char *)g_nv_setting_mirror.centre_addr,"http://mmsc.monternet.com/");
  1423. SCI_STRCPY((char *)g_nv_setting_mirror.gateway,"10.0.0.172");
  1424. SCI_STRCPY((char *)g_nv_setting_mirror.port,"9201");
  1425. SCI_STRCPY((char *)g_nv_setting_mirror.username,"");
  1426. SCI_STRCPY((char *)g_nv_setting_mirror.password,"");
  1427. SCI_STRCPY((char *)g_nv_setting_mirror.apn,"cmwap");
  1428. g_nv_setting_mirror.anonymous = MMS_MSG_SETTINGS_OFF;
  1429. g_nv_setting_mirror.prior = MMS_MSG_SETTINGS_PRIORITY_NORMAL;
  1430. g_nv_setting_mirror.retrieve_mode = MMS_MSG_SETTINGS_RETRIEVE_AUTO;
  1431. g_nv_setting_mirror.delivery_rpt = MMS_MSG_SETTINGS_OFF;
  1432. g_nv_setting_mirror.read_rpt = MMS_MSG_SETTINGS_OFF;
  1433. g_nv_setting_mirror.play_sound = MMS_MSG_SETTINGS_ON;
  1434. g_nv_setting_mirror.advertisingallowable = MMS_MSG_SETTINGS_OFF;
  1435. g_nv_setting_mirror.valid_period = MMS_MSG_VALID_PERIOD_LONGEST;  //fnh modify 20060510 MMS_MSG_VALID_PERIOD_12_HOUR;
  1436. g_nv_setting_mirror.auto_sign = MMS_MSG_SETTINGS_OFF; // fnh add 20060516
  1437. MMINV_WRITE(MMINV_MMS_SETTING, &g_nv_setting_mirror);
  1438. }
  1439. MMS_RegMenuGroup();
  1440. g_ismmsinit = FALSE;
  1441. //create MMS folder
  1442.     FILE_CdRootPath();
  1443.     if (FFS_NO_ERROR != FILE_CD(MMIMMS_MMS_DIR))
  1444.     {
  1445. SCI_TRACE_LOW("fnh in appinit mms dir is not find!");
  1446.         FILE_CreateDir(MMIMMS_MMS_DIR);
  1447.     }
  1448.     FILE_CdRootPath();
  1449.     if (FFS_NO_ERROR != FILE_CD(MMICMSBRW_WAP_DEFAULT_DIR))
  1450.     {
  1451.         FILE_CreateDir(MMICMSBRW_WAP_DEFAULT_DIR);
  1452.     }
  1453. if(g_pManager != NULL) //信箱链表
  1454. {
  1455.   MMIMMS_FreeManagerDocument();
  1456. }
  1457. if (g_pautoDownloadMMSRoot) // 如果有自动下载,初始化时删除链表
  1458. {
  1459. MMIMMS_FreeAutodownList();
  1460. }
  1461. g_filetype = MMICMS_GetCurrentFFS();
  1462. if (g_filetype != FS_INVALID)
  1463. {
  1464. MMIMMS_ReadManagerInboxFile();
  1465. }
  1466. else
  1467. {
  1468. g_ismmsinit = TRUE;
  1469. }
  1470. }
  1471. /* ----------------------------------------------------------------------------
  1472. * Function Name: MMIMMS_WriteNewMMS
  1473. * Purpose: 编辑新彩信
  1474. * Input:  void
  1475. * Returns: void
  1476. * Author:nihongf@mobilesoft.com.cn
  1477. * ----------------------------------------------------------------------------*/ 
  1478. BOOLEAN MMIMMS_WriteNewMMS(void)
  1479. {
  1480. /* 初始化主题 */
  1481. g_p_mms_subject = (char *)cms_malloc(MMIMMS_MAX_SUBJECTS_LEN+1);
  1482. SCI_ASSERT(g_p_mms_subject != NULL);
  1483. SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN+1);
  1484. /* 创建空白编辑器 */
  1485. g_peditdoc = MMS_New();
  1486. SCI_ASSERT(g_peditdoc != NULL);
  1487. g_p_mms_to = NULL;
  1488. g_p_mms_cc = NULL;
  1489. g_p_mms_bcc = NULL;
  1490. g_p_mms_to_group = NULL;
  1491. g_p_mms_cc_group = NULL;
  1492. g_p_mms_bcc_group = NULL;
  1493. //init MMIMMS global
  1494. //    MMIMMS_Construction(); 
  1495.     //create edit window
  1496.     MMK_CreateWin( (uint32*)MMIMMS_EDIT_WIN_TAB, (ADD_DATA)MMIMMS_NV_ID_INVALID);//2nd param is used to distiguish PNULL and index_0
  1497.     return 1;
  1498. }
  1499. /*****************************************************************************/
  1500. //  Description : give sms module to answer mms
  1501. // Global resource dependence : none
  1502. //  Author: Bruce.Chi
  1503. // Input : Send to name string
  1504. // Note:
  1505. /*****************************************************************************/
  1506. PUBLIC BOOLEAN MMIMMS_AnswerMMS(
  1507. uint8 send_to_name_len,
  1508. uint8 *sen_to_name_ptr
  1509. )
  1510. {
  1511. SCI_ASSERT(sen_to_name_ptr != PNULL);
  1512. mmicms_replymmsforsms((char *)sen_to_name_ptr); //电话本和短信回复彩信
  1513. return TRUE;
  1514. }
  1515. /*****************************************************************************/
  1516. //  Description : MMIMMS construction fuction
  1517. // Global resource dependence : ??????
  1518. //  Author: Bruce.Chi
  1519. // Note:
  1520. /*****************************************************************************/
  1521. #if 1
  1522. MMIMMS_RESULT_E MMIMMS_Construction(void)
  1523. {
  1524. uint32 str_number = 0;
  1525. TO_STRING_T *str_ptr = PNULL;
  1526. str_number = MMIMMS_MAX_ADDRESS_NUM * sizeof(TO_STRING_T);
  1527. //to
  1528. str_ptr =(TO_STRING_T *)cms_malloc(str_number );
  1529. SCI_ASSERT(str_ptr != PNULL);
  1530. SCI_MEMSET(str_ptr, 0, str_number);
  1531. g_mms_save_in_mem.to.addr = str_ptr;
  1532. //cc
  1533. str_ptr = PNULL;
  1534. str_ptr =(TO_STRING_T *)cms_malloc(str_number );
  1535. SCI_ASSERT(str_ptr != PNULL);
  1536. SCI_MEMSET(str_ptr, 0, str_number);
  1537. g_mms_save_in_mem.cc.addr = str_ptr;
  1538. //bcc
  1539. str_ptr = PNULL;
  1540. str_ptr =(TO_STRING_T *)cms_malloc(str_number );
  1541. SCI_ASSERT(str_ptr != PNULL);
  1542. SCI_MEMSET(str_ptr, 0, str_number);
  1543. g_mms_save_in_mem.bcc.addr = str_ptr;
  1544. //init the static var
  1545. // SCI_MEMSET(&g_mms_save_in_mem, 0, sizeof(g_mms_save_in_mem));
  1546. return MMIMMS_RESULT_SUCCESS;
  1547. }
  1548. #endif
  1549. /*****************************************************************************/
  1550. //  Description : MMIMMS destruction fuction
  1551. // Global resource dependence : ??????
  1552. //  Author: Bruce.Chi
  1553. // Note:
  1554. /*****************************************************************************/
  1555. #if 1
  1556. MMIMMS_RESULT_E MMIMMS_Destruction(void)
  1557. {
  1558. //free subject
  1559. if (g_mms_save_in_mem.subject.str_ptr != PNULL)
  1560. {
  1561. cms_free(g_mms_save_in_mem.subject.str_ptr);
  1562. g_mms_save_in_mem.subject.str_ptr = PNULL;
  1563. }
  1564. //free To address
  1565. if (g_mms_save_in_mem.to.addr != PNULL)
  1566. {
  1567. cms_free(g_mms_save_in_mem.to.addr);
  1568. g_mms_save_in_mem.to.addr =PNULL;
  1569. }
  1570. if (g_mms_save_in_mem.cc.addr != PNULL)
  1571. {
  1572. cms_free(g_mms_save_in_mem.cc.addr);
  1573. g_mms_save_in_mem.cc.addr =PNULL;
  1574. }
  1575. if (g_mms_save_in_mem.bcc.addr != PNULL)
  1576. {
  1577. cms_free(g_mms_save_in_mem.bcc.addr);
  1578. g_mms_save_in_mem.bcc.addr =PNULL;
  1579. }
  1580. if (g_mms_save_in_mem.content_text.str_ptr != PNULL)
  1581. {
  1582. cms_free(g_mms_save_in_mem.content_text.str_ptr);
  1583. g_mms_save_in_mem.content_text.str_ptr = PNULL;
  1584. }
  1585. //set whole g_mms_save_in_mem to zero
  1586. SCI_MEMSET(&g_mms_save_in_mem, 0, sizeof(g_mms_save_in_mem));
  1587. return MMIMMS_RESULT_SUCCESS;
  1588. }
  1589. #endif
  1590. /*****************************************************************************/
  1591. //  Description : judge whether subject exist
  1592. // Global resource dependence : g_mms_save_in_mem
  1593. //  Author: Bruce.Chi
  1594. // Note: used in edit and save moduel
  1595. ///*****************************************************************************/
  1596. BOOLEAN Edit_CurSubjectExist(void)
  1597. {
  1598. SCI_TRACE_BUF("FNH cursubjectexist = %x",g_p_mms_subject,10);
  1599. if (g_p_mms_subject == PNULL)//g_mms_save_in_mem.subject.str_ptr == PNULL)
  1600. {
  1601. return FALSE;
  1602. }
  1603. else
  1604. {
  1605. return TRUE;
  1606. }
  1607. }
  1608. /* ----------------------------------------------------------------------------
  1609. * Function Name: Edit_CurContentTextExist
  1610. * Purpose: 判断当前内容是否有文本
  1611. * Input:  pMMS_EDocument,当前编辑文档
  1612. * Returns: 布尔型
  1613. * Author:nihongf@mobilesoft.com.cn
  1614. * ----------------------------------------------------------------------------*/ 
  1615. BOOLEAN Edit_CurContentTextExist(pMMS_EDocument p_cur_doc)
  1616. {
  1617. if (p_cur_doc->slide_cur->text_flag == 1)
  1618. {
  1619. return TRUE;
  1620. }
  1621. else
  1622. {
  1623. return FALSE;
  1624. }
  1625. }
  1626. /* ----------------------------------------------------------------------------
  1627. /* Function Name: CmsGetUnicodeLen
  1628. *  Purpose:取得unicode字符串的长度
  1629. *  Input:  输入的字符串
  1630. *  Output: 长度
  1631. *  Returns:
  1632. *  Author:nihongf@mobilesoft.com.cn
  1633. * ----------------------------------------------------------------------------*/ 
  1634. uint16 CmsGetUnicodeLen(const unsigned char *data)
  1635. {
  1636. unsigned short len = 0;
  1637. unsigned short *s_data = ( unsigned short*)data;
  1638. if(!data)
  1639. return 0;
  1640. len = *s_data;
  1641. return len;
  1642. }
  1643. /* ----------------------------------------------------------------------------
  1644. * Function Name: GetSubjectStringLen
  1645. * Purpose:得到字符串的具体内容
  1646. * Input:  输入的字符串
  1647. * Output: 输出的字符传及字符串长度,输出的字符串是从第二个字符开始的
  1648. * Returns:
  1649. * Author:nihongf@mobilesoft.com.cn
  1650. * ----------------------------------------------------------------------------*/ 
  1651. uint16 GetSubjectStringLen(char* srcstr,char** decstr)
  1652. {
  1653. char utf_buff[128];
  1654. uint16 length = 0;
  1655. SCI_MEMSET(utf_buff, 0, sizeof(utf_buff));
  1656. length = CmsGetUnicodeLen((unsigned char *)srcstr);
  1657. *decstr = (char *)&srcstr[2];
  1658. return length;
  1659. }
  1660. /* ----------------------------------------------------------------------------
  1661. * Function Name: MMIMMS_OptionSubject
  1662. * Purpose:在subject前添加RE或FW
  1663. * Input:  mms状态(转发或回复)
  1664. * Output: 空,输出的字符串是从第二个字符开始的
  1665. * Returns:
  1666. * Author:nihongf@mobilesoft.com.cn
  1667. * ----------------------------------------------------------------------------*/ 
  1668. void MMIMMS_OptionSubject(MMSSTATE mmsstate)
  1669. {
  1670. char *subjecttemp;
  1671. uint16 len = 0;
  1672. uint16 sublen=0;
  1673. char *addstring;
  1674. uint16 addlen = 0;
  1675. char* subjectstring = NULL;
  1676. char *tempsubjectstring = NULL;
  1677. subjecttemp = g_p_mms_subject;
  1678. len = CmsGetUnicodeLen((unsigned char *)subjecttemp);
  1679. SCI_TRACE_LOW("FNH len = %d",len);
  1680. subjectstring = (char*)cms_malloc(len +1);
  1681. SCI_MEMSET(subjectstring,0,len+1);
  1682. len = GetSubjectStringLen((char *)subjecttemp,(char **)&tempsubjectstring);
  1683. SCI_MEMCPY(subjectstring,tempsubjectstring,len);
  1684. SCI_TRACE_BUF("FNH subjectsring = %x",subjectstring,len);
  1685. switch(mmsstate)
  1686. {
  1687. case MMSRE:
  1688. addlen = Cms_UTF8toUTF16Len("RE:");
  1689. SCI_TRACE_LOW("FNH addlen = %d",addlen);
  1690. addstring = (char *)cms_malloc(addlen);
  1691. SCI_MEMSET(addstring,0,addlen);
  1692. Cms_UTF8toUTF16("RE:",3,addlen,addstring);
  1693. SCI_TRACE_BUF("FNH addstring is %x",addstring,10);
  1694. SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
  1695. if (len > (MMIMMS_MAX_SUBJECTS_LEN-addlen-2))
  1696. {
  1697. len = MMIMMS_MAX_SUBJECTS_LEN-addlen-2;
  1698. }
  1699. sublen = addlen+len;
  1700. SCI_TRACE_LOW("FNH sublen = %d",sublen);
  1701. SCI_MEMCPY(g_p_mms_subject,&sublen,2);
  1702. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1703. SCI_MEMCPY(g_p_mms_subject+2,addstring,addlen);
  1704. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,addlen+2);
  1705. SCI_MEMCPY(g_p_mms_subject+addlen+2,subjectstring,len);
  1706. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,MMIMMS_MAX_SUBJECTS_LEN);
  1707. if (addstring )
  1708. {
  1709. cms_free(addstring);
  1710. addstring = NULL;
  1711. SCI_TRACE_LOW("fnh AFTER free addstring");
  1712. }
  1713. if (subjectstring )
  1714. {
  1715. cms_free(subjectstring);
  1716. subjectstring = NULL;
  1717. SCI_TRACE_LOW("fnh AFTER free subjectstring");
  1718. }
  1719. break;
  1720. case MMSFW:
  1721. addlen = Cms_UTF8toUTF16Len("FW:");
  1722. SCI_TRACE_LOW("FNH addlen = %d",addlen);
  1723. addstring = (char *)cms_malloc(addlen);
  1724. SCI_MEMSET(addstring,0,addlen);
  1725. Cms_UTF8toUTF16("FW:",3,addlen,addstring);
  1726. SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
  1727. if (len > (MMIMMS_MAX_SUBJECTS_LEN-addlen-2))
  1728. {
  1729. len = MMIMMS_MAX_SUBJECTS_LEN-addlen-2;
  1730. }
  1731. sublen = addlen+len;
  1732. SCI_MEMCPY(g_p_mms_subject,&sublen,2);
  1733. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1734. SCI_MEMCPY(g_p_mms_subject+2,addstring,addlen);
  1735. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1736. SCI_MEMCPY(g_p_mms_subject+addlen+2,subjectstring,len);
  1737. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1738. if (addstring )
  1739. {
  1740. cms_free(addstring);
  1741. addstring = NULL;
  1742. SCI_TRACE_LOW("fnh AFTER free addstring");
  1743. }
  1744. if (subjectstring )
  1745. {
  1746. cms_free(subjectstring);
  1747. subjectstring = NULL;
  1748. SCI_TRACE_LOW("fnh AFTER free subjectstring");
  1749. }
  1750. break;
  1751. case MMSEDIT:
  1752. SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
  1753. if (len > (MMIMMS_MAX_SUBJECTS_LEN-2))
  1754. {
  1755. len = MMIMMS_MAX_SUBJECTS_LEN-2;
  1756. }
  1757. sublen = len;
  1758. SCI_MEMCPY(g_p_mms_subject,&sublen,2);
  1759. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,sublen);
  1760. SCI_MEMCPY(g_p_mms_subject+2,subjectstring,len);
  1761. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,len+2);
  1762. if (subjectstring )
  1763. {
  1764. cms_free(subjectstring);
  1765. subjectstring = NULL;
  1766. SCI_TRACE_LOW("fnh AFTER free subjectstring");
  1767. }
  1768. break;
  1769. case MMSREAD:
  1770. addlen = Cms_UTF8toUTF16Len("read:");
  1771. SCI_TRACE_LOW("FNH addlen = %d",addlen);
  1772. addstring = (char *)cms_malloc(addlen);
  1773. SCI_MEMSET(addstring,0,addlen);
  1774. Cms_UTF8toUTF16("read:",5,addlen,addstring);
  1775. SCI_MEMSET(g_p_mms_subject,0,MMIMMS_MAX_SUBJECTS_LEN);
  1776. if (len > (MMIMMS_MAX_SUBJECTS_LEN-addlen-2))
  1777. {
  1778. len = MMIMMS_MAX_SUBJECTS_LEN-addlen-2;
  1779. }
  1780. sublen = addlen+len;
  1781. SCI_MEMCPY(g_p_mms_subject,&sublen,2);
  1782. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1783. SCI_MEMCPY(g_p_mms_subject+2,addstring,addlen);
  1784. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1785. SCI_MEMCPY(g_p_mms_subject+addlen+2,subjectstring,len);
  1786. SCI_TRACE_BUF("FNH p_mms_subect = %x",g_p_mms_subject,10);
  1787. if (addstring )
  1788. {
  1789. cms_free(addstring);
  1790. addstring = NULL;
  1791. SCI_TRACE_LOW("fnh AFTER free addstring");
  1792. }
  1793. if (subjectstring )
  1794. {
  1795. cms_free(subjectstring);
  1796. subjectstring = NULL;
  1797. SCI_TRACE_LOW("fnh AFTER free subjectstring");
  1798. }
  1799. break;
  1800. default:
  1801. break;
  1802. }
  1803. return ;
  1804. }
  1805. //  Description : get subject string
  1806. // Global resource dependence : g_mms_save_in_mem
  1807. //  Author: Bruce.Chi
  1808. // Note: used in edit and save moduel, return pointer pointing to internal memory
  1809. ///*****************************************************************************/
  1810. MMI_STRING_T Edit_GetSubject(void)
  1811. {
  1812. MMI_STRING_T string_ret;
  1813. SCI_MEMSET(&string_ret, 0 , sizeof(string_ret));
  1814. if (g_p_mms_subject != PNULL)
  1815. {
  1816. //return inner pointer.
  1817. SCI_TRACE_BUF("FNH Edit_GetSubject g_p_mms_subject = %x",g_p_mms_subject,10);
  1818. string_ret.length = GetSubjectStringLen((char *)g_p_mms_subject,(char **)&string_ret.str_ptr);
  1819. string_ret.is_ucs2 = TRUE;
  1820. SCI_TRACE_LOW("FNH Edit_GetSubject string_ret.length = %d",string_ret.length);
  1821. SCI_TRACE_BUF("FNH Edit_GetSubject string_ret.str_ptr = %x",string_ret.str_ptr,10);
  1822. }
  1823. return string_ret;
  1824. }
  1825. /* ----------------------------------------------------------------------------
  1826. * Function Name: Edit_GetContentText
  1827. * Purpose:取得当前文本内容
  1828. * Input:  pMMS_EDocument
  1829. * Output: 字符串结构.
  1830. * Returns:
  1831. * Author:nihongf@mobilesoft.com.cn
  1832. * ----------------------------------------------------------------------------*/
  1833. MMI_STRING_T Edit_GetContentText(pMMS_EDocument p_cur_doc)
  1834. {
  1835. MMI_STRING_T string_ret;
  1836. T_Composer_Text composer_text;
  1837. SCI_MEMSET(&string_ret, 0 , sizeof(string_ret));
  1838. SCI_MEMSET(&composer_text,0,sizeof(T_Composer_Text));
  1839. MMIMMS_GetCurText(&composer_text,p_cur_doc);
  1840. string_ret.is_ucs2 = TRUE;
  1841. string_ret.str_ptr = composer_text.TxtBuf;
  1842. string_ret.length = composer_text.size ;
  1843. return string_ret;
  1844. }
  1845. /*****************************************************************************/
  1846. //  Description : delete subject string
  1847. // Global resource dependence : g_mms_save_in_mem
  1848. //  Author: Bruce.Chi
  1849. // Note: used in edit and save moduel
  1850. ///*****************************************************************************/
  1851. MMIMMS_RESULT_E Edit_DeleteSubject(void)
  1852. {
  1853. if (g_mms_save_in_mem.subject.str_ptr != PNULL)
  1854. {
  1855. cms_free(g_mms_save_in_mem.subject.str_ptr);
  1856. g_mms_save_in_mem.subject.str_ptr = PNULL;
  1857. g_mms_save_in_mem.subject.length = 0;
  1858. }
  1859. return MMIMMS_RESULT_SUCCESS;
  1860. }
  1861. /*****************************************************************************/
  1862. //  Description : "add to address"
  1863. // Global resource dependence : g_mms_save_in_mem
  1864. //  Author: Bruce.Chi
  1865. // Note: used in edit and save moduel. refer to Vector<> in c++
  1866. ///*****************************************************************************/
  1867. // Array
  1868. // |--|
  1869. // | 0|-->content0(heap)
  1870. // |--|
  1871. // | 1|-->content1(heap)
  1872. // |--|
  1873. // total_num = 2|  |
  1874. // |..|
  1875. BOOLEAN Edit_AddToAddr(uint8 *to_ptr, To_Addr* addr_list)
  1876. {
  1877. int len = 0;
  1878. uint32 total_num = 0;
  1879. TO_STRING_T *str_ptr = PNULL;
  1880. uint32 str_number = 0;
  1881. SCI_ASSERT(to_ptr != PNULL);
  1882. SCI_ASSERT(addr_list != PNULL);
  1883. SCI_TRACE_LOW("mmimms_main:Edit_AddToAddr(), %s,L%d", to_ptr, __LINE__);
  1884. len = strlen((char *)to_ptr);
  1885. if (len == 0)
  1886. {
  1887. return FALSE;
  1888. }
  1889. //cut
  1890. len = MIN(len ,MMIMMS_MAX_ADDRESS_LEN);
  1891. total_num = addr_list->total_num;
  1892. /*
  1893. //judge total number, and the array.
  1894. if ((total_num % MMIMMS_MAX_ADDRESS_NUM) == 0)
  1895. {
  1896. //need to alloc new
  1897. str_number= sizeof(TO_STRING_T) * (((total_num / MMIMMS_MAX_ADDRESS_NUM) + 1) * MMIMMS_MAX_ADDRESS_NUM);
  1898. str_ptr =(TO_STRING_T *)cms_malloc(str_number );
  1899. SCI_ASSERT(str_ptr != PNULL);
  1900. SCI_MEMSET(str_ptr, 0, str_number);
  1901. //copy old to new
  1902. if (g_mms_save_in_mem.to.addr != PNULL)
  1903. {
  1904. // SCI_MEMCPY(str_ptr, g_mms_save_in_mem.to.addr, (total_num * sizeof(MMI_STRING_T)));
  1905. MMI_MEMCPY(str_ptr, str_number, g_mms_save_in_mem.to.addr, (total_num * sizeof(TO_STRING_T)), (total_num * sizeof(TO_STRING_T)));
  1906. }
  1907. //FREE old
  1908. if (g_mms_save_in_mem.to.addr != PNULL)
  1909. {
  1910. cms_free(g_mms_save_in_mem.to.addr);
  1911. g_mms_save_in_mem.to.addr = PNULL;
  1912. }
  1913. //g_mms_save_in_mem point to new
  1914. g_mms_save_in_mem.to.addr = str_ptr;
  1915. }
  1916. */
  1917. //save one copy
  1918. SCI_MEMSET(addr_list->addr[total_num].str_arr, 0, sizeof(addr_list->addr[total_num].str_arr));
  1919. MMI_MEMCPY(
  1920. addr_list->addr[total_num].str_arr,
  1921. MMIMMS_MAX_ADDRESS_LEN,
  1922. to_ptr,
  1923. len,
  1924. len
  1925. );
  1926. addr_list->addr[total_num].length = len;
  1927. addr_list->addr[total_num].is_ucs2 = FALSE;
  1928. //total number ++
  1929. addr_list->total_num++;
  1930. return TRUE;
  1931. }
  1932. /*****************************************************************************/
  1933. //  Description : delete  "to address"
  1934. // Global resource dependence : g_mms_save_in_mem
  1935. //  Author: Bruce.Chi
  1936. // Note: used in edit and save moduel
  1937. ///*****************************************************************************/
  1938. BOOLEAN Edit_DeleteToAddr(uint32 index,To_Addr* addr_list )
  1939. {
  1940. uint32 i;
  1941. SCI_ASSERT(addr_list != PNULL);
  1942. SCI_ASSERT(index < addr_list->total_num);
  1943. SCI_ASSERT(addr_list->total_num > 0);
  1944. //move the later to former, only pointer change
  1945. for(i = index; i < addr_list->total_num - 1; i++)
  1946. {
  1947. //  g_mms_save_in_mem.to.addr[i].str_ptr = g_mms_save_in_mem.to.addr[i + 1].str_ptr;
  1948. MMI_MEMCPY(
  1949. addr_list->addr[i].str_arr,
  1950. MMIMMS_MAX_ADDRESS_LEN,
  1951. addr_list->addr[i + 1].str_arr,
  1952. MMIMMS_MAX_ADDRESS_LEN,
  1953. MMIMMS_MAX_ADDRESS_LEN
  1954. );
  1955. addr_list->addr[i].is_ucs2 = addr_list->addr[i + 1].is_ucs2;
  1956. addr_list->addr[i].length = addr_list->addr[i + 1].length;
  1957. }
  1958. //total number --
  1959. addr_list->total_num--;
  1960. return TRUE;
  1961. }
  1962. /*****************************************************************************/
  1963. //  Description : delete  all "to address"
  1964. // Global resource dependence : g_mms_save_in_mem
  1965. //  Author: Bruce.Chi
  1966. // Note: used in edit and save moduel
  1967. ///*****************************************************************************/
  1968. BOOLEAN Edit_DeleteToAddrAll(To_Addr* addr_list)
  1969. {
  1970. int i = 0;
  1971. BOOLEAN is_success = FALSE;
  1972. SCI_ASSERT(addr_list != PNULL);
  1973. for (i = addr_list->total_num - 1; i >=0; i--)
  1974. {
  1975. is_success = Edit_DeleteToAddr((uint32)i,addr_list);
  1976. SCI_ASSERT(is_success);
  1977. }
  1978. /*
  1979. if(addr_list->addr != PNULL)
  1980. {
  1981. cms_free(addr_list->addr);
  1982. addr_list->addr = PNULL;
  1983. }
  1984. */
  1985. return TRUE;
  1986. }
  1987. #if 1
  1988. /* ----------------------------------------------------------------------------
  1989. * Function Name: MMIMMS_GetPBNameByNumber
  1990. * Purpose:通过电话得到电话所属姓名
  1991. * Input:  uint8 *number_ptr:电话号码指针
  1992.   MMI_STRING_T *name_pt:姓名结构
  1993. * Output: BOOLEAN.
  1994. * Returns:
  1995. * Author:nihongf@mobilesoft.com.cn
  1996. * ----------------------------------------------------------------------------*/
  1997. BOOLEAN MMIMMS_GetPBNameByNumber(uint8 *number_ptr, MMI_STRING_T *name_ptr)
  1998. {
  1999. MMIPB_BCD_NUMBER_T bcd_num;
  2000. MMI_PARTY_NUMBER_T party_num;
  2001. int num_len = 0;
  2002. uint8                 real_phonenum[MMIPB_NAME_MAX_LEN];
  2003. BOOLEAN is_found = FALSE;
  2004. SCI_ASSERT(name_ptr != PNULL);
  2005. SCI_ASSERT(number_ptr != PNULL);
  2006. SCI_TRACE_LOW("GetPBNameByNumber number is %s",number_ptr);
  2007. SCI_MEMSET(&party_num, 0, sizeof(party_num));
  2008. SCI_MEMSET(real_phonenum, 0, sizeof(real_phonenum));
  2009. num_len = (SCI_STRLEN((char *)(number_ptr)) > (MMIPB_NAME_MAX_LEN-1))? (MMIPB_NAME_MAX_LEN-1) : SCI_STRLEN((char *)(number_ptr));
  2010. SCI_MEMCPY(real_phonenum,number_ptr,num_len);
  2011. SCI_TRACE_LOW("num_len = %d",num_len);
  2012. MMI_GenPartyNumber(real_phonenum, strlen((char *)real_phonenum), &party_num);
  2013. SCI_MEMSET(&bcd_num, 0, sizeof(bcd_num));
  2014. bcd_num.npi_ton = MMI_ChangeTypePlanToUint8(party_num.number_type, 0 );
  2015. bcd_num.number_len = MIN(MMIPB_BCD_NUMBER_MAX_LEN, party_num.num_len);
  2016. MMI_MEMCPY(bcd_num.number, MMIPB_BCD_NUMBER_MAX_LEN, party_num.bcd_num, MN_MAX_ADDR_BCD_LEN, bcd_num.number_len);
  2017. is_found = MMIPB_FindAlphaAndGroupByNumber(name_ptr, PNULL, PNULL, &bcd_num);
  2018. SCI_TRACE_LOW("FNH is_found = %d",is_found);
  2019. //special, the name is zero
  2020. if (is_found && (name_ptr->length == 0))
  2021. {
  2022. is_found = FALSE;
  2023. }
  2024. return is_found;
  2025. }
  2026. /*****************************************************************************/
  2027. //  Description : get mms amout in different mailbox
  2028. // Global resource dependence : s_nv_index_mirror
  2029. //  Author: Bruce.Chi
  2030. // Note:
  2031. ///*****************************************************************************/
  2032. int MMIMMS_GetMailboxMsgSize(MMIMMS_MAILBOX_TYPE mailbox_type)
  2033. {
  2034. uint32 i = 0;
  2035. int sum = 0;
  2036. pMessageList pMlist_temp = PNULL;
  2037. uint32 msg_num = 0;
  2038. switch(mailbox_type)
  2039. {
  2040. case MMIMMS_INBOX: // 收件箱
  2041. pMlist_temp = g_pManager->inboxfolder->root;
  2042. msg_num = g_pManager->inboxfolder->messagenumber;
  2043. SCI_TRACE_LOW("fnh msg_num = %d",msg_num);
  2044. for (i = 0;i < msg_num;i++)
  2045. {
  2046. SCI_TRACE_LOW("FNH sum is %d,pMlist_temp->size = %d",sum,pMlist_temp->size);
  2047. sum = sum + pMlist_temp->size;
  2048. pMlist_temp = pMlist_temp->next;
  2049. SCI_TRACE_LOW("FNH sum is %d",sum);
  2050. }
  2051. break;
  2052. case MMIMMS_SENTBOX: //  已发信箱
  2053. pMlist_temp = g_pManager->sentfolder->root;
  2054. msg_num = g_pManager->sentfolder->messagenumber;
  2055. for (i = 0;i < msg_num;i++)
  2056. {
  2057. sum = sum + pMlist_temp->size;
  2058. pMlist_temp = pMlist_temp->next;
  2059. }
  2060. break;
  2061. case MMIMMS_OUTBOX: //  发件箱
  2062. pMlist_temp = g_pManager->outboxfolder->root;
  2063. msg_num = g_pManager->outboxfolder->messagenumber;
  2064. for (i = 0;i < msg_num;i++)
  2065. {
  2066. sum = sum + pMlist_temp->size;
  2067. pMlist_temp = pMlist_temp->next;
  2068. }
  2069. break;
  2070. case MMIMMS_DRAFTBOX: //  草稿箱
  2071. pMlist_temp = g_pManager->draftfolder->root;
  2072. msg_num = g_pManager->draftfolder->messagenumber;
  2073. for (i = 0;i < msg_num;i++)
  2074. {
  2075. sum = sum + pMlist_temp->size;
  2076. pMlist_temp = pMlist_temp->next;
  2077. }
  2078. break;
  2079. default:
  2080. break;
  2081. }
  2082. return sum;
  2083. }
  2084. /* ----------------------------------------------------------------------------
  2085. * Function Name: MMIMMS_Setting_GetPriority
  2086. * Purpose:得到优先级的设定值
  2087. * Input:  void
  2088. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2089. * Author:nihongf@mobilesoft.com.cn
  2090. * ----------------------------------------------------------------------------*/ 
  2091. MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetPriority(void)
  2092. {
  2093. return g_nv_setting_mirror.prior;
  2094. }
  2095. /* ----------------------------------------------------------------------------
  2096. * Function Name: MMIMMS_Setting_GetValidPeriod
  2097. * Purpose:得到有效期的设定值
  2098. * Input:  void
  2099. * Returns: MESSAGES_MMS_SETTING_VALID_PERIOD
  2100. * Author:nihongf@mobilesoft.com.cn
  2101. * ----------------------------------------------------------------------------*/ 
  2102. MESSAGES_MMS_SETTING_VALID_PERIOD MMIMMS_Setting_GetValidPeriod(void)
  2103. {
  2104. return g_nv_setting_mirror.valid_period;
  2105. }
  2106. /*****************************************************************************/
  2107. //  Description : get mms setting is_auto_download
  2108. // Global resource dependence : g_nv_setting_mirror
  2109. //  Author:liangliu
  2110. // Note:
  2111. /*****************************************************************************/
  2112. MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetAutoDownload(void)
  2113. {
  2114. return g_nv_setting_mirror.retrieve_mode;
  2115. }
  2116. /* ----------------------------------------------------------------------------
  2117. * Function Name: MMIMMS_Setting_GetDeliveryReport
  2118. * Purpose:得到送达报告的设定值
  2119. * Input:  void
  2120. * Output: MESSAGES_MMS_MSG_SETTINGS_ONOFF.
  2121. * Returns:
  2122. * Author:nihongf@mobilesoft.com.cn
  2123. * ----------------------------------------------------------------------------*/
  2124. MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetDeliveryReport(void)
  2125. {
  2126. return g_nv_setting_mirror.delivery_rpt;
  2127. }
  2128. /* ----------------------------------------------------------------------------
  2129. * Function Name: MMIMMS_Setting_GetAutoSign
  2130. * Purpose:得到自动签名的设定值
  2131. * Input:  void
  2132. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2133. * Author:nihongf@mobilesoft.com.cn
  2134. * ----------------------------------------------------------------------------*/ 
  2135. MESSAGES_MMS_MSG_SETTINGS_ONOFF MMIMMS_Setting_GetAutoSign(void)
  2136. {
  2137. return g_nv_setting_mirror.auto_sign;
  2138. }
  2139. /* ----------------------------------------------------------------------------
  2140. * Function Name: MMIMMS_Setting_GetReadReport
  2141. * Purpose:得到阅读报告的设定值
  2142. * Input:  void
  2143. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2144. * Author:nihongf@mobilesoft.com.cn
  2145. * ----------------------------------------------------------------------------*/ 
  2146. MESSAGES_MMS_MSG_SETTINGS_ONOFF  MMIMMS_Setting_GetReadReport(void)
  2147. {
  2148. return g_nv_setting_mirror.read_rpt;
  2149. }
  2150. /* ----------------------------------------------------------------------------
  2151. * Function Name: MMIMMS_Setting_GetAnonymous
  2152. * Purpose:得到匿名发送的设定值
  2153. * Input:  void
  2154. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2155. * Author:nihongf@mobilesoft.com.cn
  2156. * ----------------------------------------------------------------------------*/ 
  2157. MESSAGES_MMS_MSG_SETTINGS_ONOFF  MMIMMS_Setting_GetAnonymous(void)
  2158. {
  2159. return g_nv_setting_mirror.anonymous;
  2160. }
  2161. /* ----------------------------------------------------------------------------
  2162. * Function Name: MMIMMS_Setting_GetPlaySoundAble
  2163. * Purpose:得到是否播放声音的设定值
  2164. * Input:  void
  2165. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2166. * Author:nihongf@mobilesoft.com.cn
  2167. * ----------------------------------------------------------------------------*/ 
  2168. MESSAGES_MMS_MSG_SETTINGS_ONOFF  MMIMMS_Setting_GetPlaySoundAble(void)
  2169. {
  2170. return g_nv_setting_mirror.play_sound;
  2171. }
  2172. /* ----------------------------------------------------------------------------
  2173. * Function Name: MMIMMS_Setting_GetAdvertisingallowable
  2174. * Purpose:得到是否允许广告的设定值
  2175. * Input:  void
  2176. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2177. * Author:nihongf@mobilesoft.com.cn
  2178. * ----------------------------------------------------------------------------*/ 
  2179. MESSAGES_MMS_MSG_SETTINGS_ONOFF  MMIMMS_Setting_GetAdvertisingallowable(void)
  2180. {
  2181. return g_nv_setting_mirror.advertisingallowable;
  2182. }
  2183. /* ----------------------------------------------------------------------------
  2184. * Function Name: MMIMMS_Setting_SetDeliveryReport
  2185. * Purpose:设定送达报告的值
  2186. * Input:  uint16 list_index
  2187. * Returns: void
  2188. * Author:nihongf@mobilesoft.com.cn
  2189. * ----------------------------------------------------------------------------*/ 
  2190. void MMIMMS_Setting_SetDeliveryReport(uint16 list_index)
  2191. {
  2192. if (list_index!= g_nv_setting_mirror.delivery_rpt)
  2193. {
  2194. g_nv_setting_mirror.delivery_rpt= list_index;
  2195. Setting_WriteBack();
  2196. }
  2197. }
  2198. /* ----------------------------------------------------------------------------
  2199. * Function Name: MMIMMS_Setting_SetAutoDownload
  2200. * Purpose:设定自动下载的值
  2201. * Input:  uint16 list_index
  2202. * Returns: void
  2203. * Author:nihongf@mobilesoft.com.cn
  2204. * ----------------------------------------------------------------------------*/ 
  2205. void MMIMMS_Setting_SetAutoDownload(uint16 list_index)
  2206. {
  2207. if (list_index!= g_nv_setting_mirror.retrieve_mode)
  2208. {
  2209. g_nv_setting_mirror.retrieve_mode= list_index;
  2210. if(g_nv_setting_mirror.retrieve_mode == 0)
  2211. {
  2212. MMIMMS_FreeAutodownList();//add liangliu 2006-4-28 for back to idle autodownload.
  2213. }
  2214. Setting_WriteBack();
  2215. }
  2216. }
  2217. /* ----------------------------------------------------------------------------
  2218. * Function Name: MMIMMS_Setting_SetReadReport
  2219. * Purpose:设定阅读报告的值
  2220. * Input:  uint16 list_index
  2221. * Returns: void
  2222. * Author:nihongf@mobilesoft.com.cn
  2223. * ----------------------------------------------------------------------------*/ 
  2224. void MMIMMS_Setting_SetReadReport(uint16 list_index)
  2225. {
  2226. if (list_index!= g_nv_setting_mirror.read_rpt)
  2227. {
  2228. g_nv_setting_mirror.read_rpt= list_index;
  2229. Setting_WriteBack();
  2230. }
  2231. }
  2232. /* ----------------------------------------------------------------------------
  2233. * Function Name: MMIMMS_Setting_SetAutoSign
  2234. * Purpose:设置自动签名
  2235. * Input:  uint16:
  2236. * Returns: void
  2237. * Author:nihongf@mobilesoft.com.cn
  2238. * ----------------------------------------------------------------------------*/ 
  2239. void MMIMMS_Setting_SetAutoSign(uint16 list_index)
  2240. {
  2241. if (list_index!= g_nv_setting_mirror.auto_sign)
  2242. {
  2243. g_nv_setting_mirror.auto_sign= list_index;
  2244. Setting_WriteBack();
  2245. }
  2246. }
  2247. /* ----------------------------------------------------------------------------
  2248. * Function Name: MMIMMS_Setting_SetAnonymous
  2249. * Purpose:设定匿名发送的值
  2250. * Input:  uint16 list_index
  2251. * Returns: void
  2252. * Author:nihongf@mobilesoft.com.cn
  2253. * ----------------------------------------------------------------------------*/ 
  2254. void MMIMMS_Setting_SetAnonymous(uint16 list_index)
  2255. {
  2256. if (list_index!= g_nv_setting_mirror.anonymous)
  2257. {
  2258. g_nv_setting_mirror.anonymous = list_index;
  2259. Setting_WriteBack();
  2260. }
  2261. }
  2262. /* ----------------------------------------------------------------------------
  2263. * Function Name: MMIMMS_Setting_SetPlaySound
  2264. * Purpose:uint16 list_index
  2265. * Input:  void
  2266. * Returns: MESSAGES_MMS_MSG_SETTINGS_ONOFF
  2267. * Author:nihongf@mobilesoft.com.cn
  2268. * ----------------------------------------------------------------------------*/ 
  2269. void MMIMMS_Setting_SetPlaySound(uint16 list_index)
  2270. {
  2271. if ((1-list_index)!= g_nv_setting_mirror.play_sound)
  2272. {
  2273. g_nv_setting_mirror.play_sound=1- list_index;
  2274. Setting_WriteBack();
  2275. }
  2276. }
  2277. /* ----------------------------------------------------------------------------
  2278. * Function Name: MMIMMS_Setting_SetAdvertising
  2279. * Purpose:设定是否允许广告的值
  2280. * Input:  uint16 list_index
  2281. * Returns: void
  2282. * Author:nihongf@mobilesoft.com.cn
  2283. * ----------------------------------------------------------------------------*/ 
  2284. void MMIMMS_Setting_SetAdvertising(uint16 list_index)
  2285. {
  2286. if (list_index!= g_nv_setting_mirror.advertisingallowable)
  2287. {
  2288. g_nv_setting_mirror.advertisingallowable = list_index;
  2289. Setting_WriteBack();
  2290. }
  2291. }
  2292. /* ----------------------------------------------------------------------------
  2293. * Function Name: MMIMMS_Setting_SetPriority
  2294. * Purpose:设定优先级的值
  2295. * Input:  uint16 list_index
  2296. * Returns: void
  2297. * Author:nihongf@mobilesoft.com.cn
  2298. * ----------------------------------------------------------------------------*/ 
  2299. void MMIMMS_Setting_SetPriority(uint16 list_index)
  2300. {
  2301. if (list_index!= g_nv_setting_mirror.prior)
  2302. {
  2303. g_nv_setting_mirror.prior= list_index;
  2304. Setting_WriteBack();
  2305. }
  2306. }
  2307. /* ----------------------------------------------------------------------------
  2308. * Function Name: MMIMMS_Setting_GetValidPeriod
  2309. * Purpose:设定有效期的值
  2310. * Input:  uint16 list_index
  2311. * Returns: void
  2312. * Author:nihongf@mobilesoft.com.cn
  2313. * ----------------------------------------------------------------------------*/ 
  2314. void MMIMMS_Setting_SetValidPeriod(uint16 list_index)
  2315. {
  2316. if (list_index!= g_nv_setting_mirror.valid_period)
  2317. {
  2318. g_nv_setting_mirror.valid_period= list_index;
  2319. Setting_WriteBack();
  2320. }
  2321. }
  2322. /* ----------------------------------------------------------------------------
  2323. * Function Name: MMIMMS_Setting_SetMMSC
  2324. * Purpose:设置彩信中心号码
  2325. * Input:  uint8 *:字符串
  2326.   uint16: 字符串长度
  2327. * Returns: void
  2328. * Author:nihongf@mobilesoft.com.cn
  2329. * ----------------------------------------------------------------------------*/ 
  2330. void MMIMMS_Setting_SetMMSC(uint8 *mmsc_ptr, uint16 mmsc_len)
  2331. {
  2332. int16 mmsc_str_len = 0;
  2333. SCI_TRACE_LOW("FNH set mmsc mmsc_ptr = %s",mmsc_ptr);
  2334. if (mmsc_ptr == NULL)
  2335. {
  2336. g_nv_setting_mirror.centre_addr[0]= 0;
  2337. return ;
  2338. }
  2339. mmsc_str_len = MIN(mmsc_len, MMIMMS_MMSC_MAX_LEN);
  2340. SCI_MEMSET(g_nv_setting_mirror.centre_addr, 0, MMS_MAX_CENTRE_ADDR_LENGTH);
  2341. SCI_TRACE_LOW("FNH set mmsc mmsc_str_len = %d",mmsc_str_len);
  2342. SCI_TRACE_LOW("FNH set mmsc g_nv_setting_mirror.centre_addr = %s",g_nv_setting_mirror.centre_addr);
  2343. SCI_MEMCPY(g_nv_setting_mirror.centre_addr, mmsc_ptr, mmsc_str_len);
  2344. SCI_TRACE_LOW("FNH set mmsc g_nv_setting_mirror.centre_addr = %s",g_nv_setting_mirror.centre_addr);
  2345. Setting_WriteBack();
  2346. return ;
  2347. }
  2348. /* ----------------------------------------------------------------------------
  2349. * Function Name: MMIMMS_Setting_GetMMSC
  2350. * Purpose:得到彩信中心的设定值
  2351. * Input:  void
  2352. * Returns: uint8*:彩信中心号码
  2353. * Author:nihongf@mobilesoft.com.cn
  2354. * ----------------------------------------------------------------------------*/ 
  2355. uint8 *MMIMMS_Setting_GetMMSC(void)
  2356. {
  2357. SCI_TRACE_LOW("FNH get mmsc g_nv_setting_mirror.centre_addr = %s",g_nv_setting_mirror.centre_addr);
  2358. return g_nv_setting_mirror.centre_addr;
  2359. }
  2360. /* ----------------------------------------------------------------------------
  2361. * Function Name: MMIMMS_Setting_SetGATEWAY
  2362. * Purpose:设置网关地址
  2363. * Input:  uint8 *:网关地址字符串
  2364.   uint16: 字符串长度
  2365. * Returns: void
  2366. * Author:nihongf@mobilesoft.com.cn
  2367. * ----------------------------------------------------------------------------*/ 
  2368. void MMIMMS_Setting_SetGATEWAY(uint8 *gateway_ptr, uint16 gateway_len)
  2369. {
  2370. int16 gateway_str_len = 0;
  2371. SCI_TRACE_LOW("FNH IN setgateway gateway_ptr = %s",gateway_ptr);
  2372. if (gateway_ptr == NULL)
  2373. {
  2374. g_nv_setting_mirror.gateway[0] = 0;
  2375. return ;
  2376. }
  2377. gateway_str_len = MIN(gateway_len, MMIMMS_GATEWAY_MAX_LEN);
  2378. SCI_MEMSET(g_nv_setting_mirror.gateway, 0, MMS_MAX_GATEWAY_LENGTH);
  2379. SCI_MEMCPY(g_nv_setting_mirror.gateway, gateway_ptr, gateway_str_len);
  2380. SCI_TRACE_LOW("FNH g_nv_setting_mirror.gateway = %s",g_nv_setting_mirror.gateway);
  2381. Setting_WriteBack();
  2382. }
  2383. /* ----------------------------------------------------------------------------
  2384. * Function Name: MMIMMS_Setting_GetGATEWAY
  2385. * Purpose:得到网关的设定值
  2386. * Input:  void
  2387. * Returns: uint8*:网关号码
  2388. * Author:nihongf@mobilesoft.com.cn
  2389. * ----------------------------------------------------------------------------*/ 
  2390. uint8 *MMIMMS_Setting_GetGATEWAY(void)
  2391. {
  2392. SCI_TRACE_LOW("FNH gateway = %s",g_nv_setting_mirror.gateway);
  2393. return g_nv_setting_mirror.gateway;
  2394. }
  2395. /* ----------------------------------------------------------------------------
  2396. * Function Name: MMIMMS_Setting_SetPORT
  2397. * Purpose:设置端口号
  2398. * Input:  uint8 *:端口号字符串
  2399.   uint16: 字符串长度
  2400. * Returns: void
  2401. * Author:nihongf@mobilesoft.com.cn
  2402. * ----------------------------------------------------------------------------*/ 
  2403. void MMIMMS_Setting_SetPORT(uint8 *port_ptr, uint16 port_len)
  2404. {
  2405. int16 port_str_len = 0;
  2406. SCI_TRACE_LOW("FNH IN setport port_ptr = %s",port_ptr);
  2407. SCI_TRACE_LOW("FNH IN setport port_len = %d",port_len);
  2408. if (port_ptr == NULL)
  2409. {
  2410. g_nv_setting_mirror.port[0] = 0;
  2411. return ;
  2412. }
  2413. port_str_len = MIN(port_len, MMIMMS_PORT_MAX_LEN);
  2414. SCI_TRACE_LOW("FNH before strcpy port_str_Len = %d",port_str_len);
  2415. SCI_MEMSET(g_nv_setting_mirror.port, 0, MMS_MAX_PORT_LENGTH);
  2416. SCI_TRACE_LOW("FNH before strcpy g_nv_setting_mirror.port = %s",g_nv_setting_mirror.port);
  2417. SCI_MEMCPY(g_nv_setting_mirror.port, port_ptr, port_str_len);
  2418. SCI_TRACE_LOW("FNH after strcpy g_nv_setting_mirror.port = %s",g_nv_setting_mirror.port);
  2419. Setting_WriteBack();
  2420. }
  2421. /* ----------------------------------------------------------------------------
  2422. * Function Name: MMIMMS_Setting_GetPORT
  2423. * Purpose:得到端口号的设定值
  2424. * Input:  void
  2425. * Returns: uint8*:端口号值
  2426. * Author:nihongf@mobilesoft.com.cn
  2427. * ----------------------------------------------------------------------------*/ 
  2428. uint8 *MMIMMS_Setting_GetPORT(void)
  2429. {
  2430. SCI_TRACE_LOW("FNH get port g_nv_setting_mirror.port = %s",g_nv_setting_mirror.port);
  2431. return g_nv_setting_mirror.port;
  2432. }
  2433. /* ----------------------------------------------------------------------------
  2434. * Function Name: MMIMMS_Setting_SetUserName
  2435. * Purpose:设置用户名
  2436. * Input:  uint8 *:字符串
  2437.   uint16: 字符串长度
  2438. * Returns: void
  2439. * Author:nihongf@mobilesoft.com.cn
  2440. * ----------------------------------------------------------------------------*/ 
  2441. void MMIMMS_Setting_SetUserName(uint8 *username_ptr, uint16 username_len)
  2442. {
  2443. int16 unsername_str_len = 0;
  2444. SCI_TRACE_LOW("FNH set username_ptr username_ptr = %s",username_ptr);
  2445. if (username_ptr == NULL)
  2446. {
  2447. g_nv_setting_mirror.username[0]= 0;
  2448. return ;
  2449. }
  2450. unsername_str_len = MIN(username_len, MMIMMS_USERNAME_MAX_LEN);
  2451. SCI_MEMSET(g_nv_setting_mirror.username, 0, MMS_MAX_USERNAME_LENGTH);
  2452. SCI_TRACE_LOW("FNH set username unsername_str_len = %d",username_len);
  2453. SCI_TRACE_LOW("FNH set unsername g_nv_setting_mirror.unsername = %s",g_nv_setting_mirror.username);
  2454. SCI_MEMCPY(g_nv_setting_mirror.username, username_ptr, username_len);
  2455. g_nv_setting_mirror.username[username_len] = '';
  2456. SCI_TRACE_LOW("FNH set unsername g_nv_setting_mirror.unsername = %s",g_nv_setting_mirror.username);
  2457. Setting_WriteBack();
  2458. return ;
  2459. }
  2460. /* ----------------------------------------------------------------------------
  2461. * Function Name: MMIMMS_Setting_GetMMSC
  2462. * Purpose:得到用户名的设定值
  2463. * Input:  void
  2464. * Returns: uint8*:用户名
  2465. * Author:nihongf@mobilesoft.com.cn
  2466. * ----------------------------------------------------------------------------*/ 
  2467. uint8 *MMIMMS_Setting_GetUserName(void)
  2468. {
  2469. SCI_TRACE_LOW("FNH get username g_nv_setting_mirror.username = %s",g_nv_setting_mirror.username);
  2470. return g_nv_setting_mirror.username;
  2471. }
  2472. /* ----------------------------------------------------------------------------
  2473. * Function Name: MMIMMS_Setting_SetPassword
  2474. * Purpose:设置密码
  2475. * Input:  uint8 *:字符串
  2476.   uint16: 字符串长度
  2477. * Returns: void
  2478. * Author:nihongf@mobilesoft.com.cn
  2479. * ----------------------------------------------------------------------------*/ 
  2480. void MMIMMS_Setting_SetPassword(uint8 *password_ptr, uint16 password_len)
  2481. {
  2482. int16 password_str_len = 0;
  2483. SCI_TRACE_LOW("FNH set password_ptr password_ptr = %s",password_ptr);
  2484. if (password_ptr == NULL)
  2485. {
  2486. g_nv_setting_mirror.password[0]= 0;
  2487. return ;
  2488. }
  2489. password_str_len = MIN(password_len, MMIMMS_PASSWORD_MAX_LEN);
  2490. SCI_MEMSET(g_nv_setting_mirror.password, 0, MMS_MAX_PASSWORD_LENGTH);
  2491. SCI_TRACE_LOW("FNH set password password_str_len = %d",password_len);
  2492. SCI_TRACE_LOW("FNH set password g_nv_setting_mirror.password = %s",g_nv_setting_mirror.password);
  2493. SCI_MEMCPY(g_nv_setting_mirror.password, password_ptr, password_len);
  2494. g_nv_setting_mirror.password[password_len] = '';
  2495. SCI_TRACE_LOW("FNH set password g_nv_setting_mirror.password = %s",g_nv_setting_mirror.password);
  2496. Setting_WriteBack();
  2497. return ;
  2498. }
  2499. /* ----------------------------------------------------------------------------
  2500. * Function Name: MMIMMS_Setting_Getpassword
  2501. * Purpose:得到密码的设定值
  2502. * Input:  void
  2503. * Returns: uint8*:密码的值
  2504. * Author:nihongf@mobilesoft.com.cn
  2505. * ----------------------------------------------------------------------------*/ 
  2506. uint8 *MMIMMS_Setting_GetPassword(void)
  2507. {
  2508. SCI_TRACE_LOW("FNH get password g_nv_setting_mirror.password = %s",g_nv_setting_mirror.password);
  2509. return g_nv_setting_mirror.password;
  2510. }
  2511. /* ----------------------------------------------------------------------------
  2512. * Function Name: MMIMMS_Setting_SetAPN
  2513. * Purpose:设置APN
  2514. * Input:  uint8 *:字符串
  2515.   uint16: 字符串长度
  2516. * Returns: void
  2517. * Author:nihongf@mobilesoft.com.cn
  2518. * ----------------------------------------------------------------------------*/ 
  2519. void MMIMMS_Setting_SetAPN(uint8 *apn_ptr, uint16 apn_len)
  2520. {
  2521. int16 apn_str_len = 0;
  2522. SCI_TRACE_LOW("FNH set apn_ptr apn_ptr = %s",apn_ptr);
  2523. if (apn_ptr == NULL)
  2524. {
  2525. g_nv_setting_mirror.apn[0]= 0;
  2526. return ;
  2527. }
  2528. apn_str_len = MIN(apn_len, MMIMMS_APN_MAX_LEN);
  2529. SCI_MEMSET(g_nv_setting_mirror.apn, 0, MMS_MAX_APN_LENGTH);
  2530. SCI_TRACE_LOW("FNH set apn apn_str_len = %d",apn_len);
  2531. SCI_TRACE_LOW("FNH set apn g_nv_setting_mirror.apn = %s",g_nv_setting_mirror.apn);
  2532. SCI_MEMCPY(g_nv_setting_mirror.apn, apn_ptr, apn_len);
  2533. SCI_TRACE_LOW("FNH set apn g_nv_setting_mirror.apn = %s",g_nv_setting_mirror.apn);
  2534. Setting_WriteBack();
  2535. return ;
  2536. }
  2537. /* ----------------------------------------------------------------------------
  2538. * Function Name: MMIMMS_Setting_GetAPN
  2539. * Purpose:得到APN的设定值
  2540. * Input:  void
  2541. * Returns: uint8*:APN的设定值
  2542. * Author:nihongf@mobilesoft.com.cn
  2543. * ----------------------------------------------------------------------------*/ 
  2544. uint8 *MMIMMS_Setting_GetAPN(void)
  2545. {
  2546. SCI_TRACE_LOW("FNH get apn g_nv_setting_mirror.apn = %s",g_nv_setting_mirror.apn);
  2547. return g_nv_setting_mirror.apn;
  2548. }
  2549. /*****************************************************************************/
  2550. //  Description : write mms setting to nv
  2551. // Global resource dependence : g_nv_setting_mirror
  2552. //  Author: Bruce.Chi
  2553. // Note:
  2554. /*****************************************************************************/
  2555. void Setting_WriteBack(void)
  2556. {
  2557. MMINV_WRITE(MMINV_MMS_SETTING, &g_nv_setting_mirror); //no returned value
  2558. }
  2559. /* ----------------------------------------------------------------------------
  2560. * Function Name: MMSMMS_SetCurSlideDuration
  2561. * Purpose:设定每祯播放的时间的值
  2562. * Input:  uint32 duaration
  2563. * Returns: void
  2564. * Author:nihongf@mobilesoft.com.cn
  2565. * ----------------------------------------------------------------------------*/ 
  2566. void MMSMMS_SetCurSlideDuration(uint32 duaration)
  2567. {
  2568. SCI_TRACE_LOW("mmimms : MMSMMS_SetCurSlideDuration, duaration=%d", duaration);
  2569. MMIMMS_SetCurSlideDuration(duaration * ONE_KILO);
  2570. }
  2571. /* ----------------------------------------------------------------------------
  2572. * Function Name: MMIMMS_GetCurSlideDuration
  2573. * Purpose:得到当前祯播放的时间的值
  2574. * Input:  pMMS_EDocument p_cur_doc
  2575. * Returns: uint32
  2576. * Author:nihongf@mobilesoft.com.cn
  2577. * ----------------------------------------------------------------------------*/ 
  2578. uint32 MMIMMS_GetCurSlideDuration(pMMS_EDocument p_cur_doc)
  2579. {
  2580. T_WORD slide_time = 0;
  2581. slide_time = p_cur_doc->slide_cur->times;
  2582. SCI_TRACE_LOW("mmimms : MMIMMS_GetCurSlideDuration, slide_time=%d", slide_time);
  2583. slide_time /= ONE_KILO;
  2584. /* if (slide_time < MMIMMS_SLIDE_DUARATION_MIN || slide_time > MMIMMS_SLIDE_DUARATION_MAX)
  2585. {
  2586. slide_time = MMIMMS_SLIDE_DUARATION_DEFAULT;
  2587. }
  2588. */
  2589. return slide_time;
  2590. }
  2591. /*****************************************************************************/
  2592. //  Description : convert ASC to UCS2
  2593. // Global resource dependence : 
  2594. //  Author: Bruce.Chi
  2595. // Note: should free the outer pointer
  2596. ///*****************************************************************************/
  2597. uint8 *ASCtoUCS2(uint8  *src_ptr, //in
  2598. uint32  src_len, //in
  2599. uint32  *ucs2_len_ptr //out
  2600.   )
  2601. {
  2602. uint8 *ucs2_text_ptr = PNULL;
  2603. int i = 0;
  2604. if (src_len == 0)
  2605. {
  2606. return PNULL;
  2607. }
  2608. SCI_ASSERT(src_ptr != PNULL);
  2609. SCI_ASSERT(ucs2_len_ptr != PNULL);
  2610. ucs2_text_ptr = cms_malloc(src_len * 2);
  2611. SCI_ASSERT(ucs2_text_ptr != PNULL);
  2612. SCI_MEMSET(ucs2_text_ptr, 0, src_len * 2);
  2613.     for( i = 0; i < src_len; i++ )
  2614.     {
  2615.         ucs2_text_ptr[2 *i] = 0x00;
  2616.         ucs2_text_ptr[2 * i + 1] = src_ptr[i];
  2617.     }
  2618. *ucs2_len_ptr = src_len * 2;
  2619. return ucs2_text_ptr;
  2620. }
  2621. /*****************************************************************************/
  2622. //  Description : cat two string
  2623. // Global resource dependence : 
  2624. //  Author: Bruce.Chi
  2625. // Note: should free the dst_ptr->str_ptr
  2626. ///*****************************************************************************/
  2627. BOOLEAN CatStringByTextID(
  2628. MMI_STRING_T *dst_ptr, //out.
  2629. uint32 text_id, //in.
  2630. MMI_STRING_T *src2_ptr //in.
  2631. )
  2632. {
  2633. MMI_STRING_T string_prefix;
  2634. SCI_ASSERT(dst_ptr != PNULL);
  2635. SCI_ASSERT(src2_ptr != PNULL);
  2636. MMI_GetLabelTextByLang(text_id, &string_prefix); //don't need to free string_prefix.str_ptr
  2637. return CatString(dst_ptr, &string_prefix, src2_ptr);
  2638. }
  2639. /*****************************************************************************/
  2640. //  Description : cat two string
  2641. // Global resource dependence : 
  2642. //  Author: Bruce.Chi
  2643. // Note: should free the dst_ptr->str_ptr
  2644. ///*****************************************************************************/
  2645. BOOLEAN CatStringByTextID2(
  2646. MMI_STRING_T *dst_ptr, //out.
  2647. uint32 text_id1, //in.
  2648. uint32 text_id2 //in.
  2649. )
  2650. {
  2651. MMI_STRING_T string_prefix;
  2652. MMI_STRING_T string_subfix;
  2653. SCI_ASSERT(dst_ptr != PNULL);
  2654. MMI_GetLabelTextByLang(text_id1, &string_prefix); //don't need to free string_prefix.str_ptr
  2655. MMI_GetLabelTextByLang(text_id2, &string_subfix);
  2656. return CatString(dst_ptr, &string_prefix, &string_subfix);
  2657. }
  2658. /*****************************************************************************/
  2659. //  Description : get delta mms image type string through multim image type
  2660. // Global resource dependence : 
  2661. //  Author: Bruce.Chi
  2662. // Note:
  2663. ///*****************************************************************************/
  2664. T_BYTE *Edit_GetDeltaMMSImageType2(ANIMATE_IMAGE_TYPE_E multim_img_type)
  2665. {
  2666. T_BYTE *img_type_ptr = PNULL;
  2667. SCI_ASSERT(multim_img_type >= ANIM_NONE && multim_img_type <= ANIM_GIF);
  2668. switch(multim_img_type)
  2669. {
  2670. case ANIM_WBMP:
  2671. img_type_ptr = COMPOSER_IMAGE_WBMP;
  2672. break;
  2673. case ANIM_BMP:
  2674. img_type_ptr = COMPOSER_IMAGE_BMP;
  2675. break;
  2676. case ANIM_JPG:
  2677. img_type_ptr = COMPOSER_IMAGE_JPEG;
  2678. break;
  2679. case ANIM_GIF:
  2680. img_type_ptr = COMPOSER_IMAGE_GIF;
  2681. break;
  2682. case ANIM_PNG:
  2683. img_type_ptr = COMPOSER_IMAGE_PNG;
  2684. break;
  2685. default:
  2686. img_type_ptr = PNULL;
  2687. break;
  2688. }
  2689. return img_type_ptr;
  2690. }
  2691. /*****************************************************************************/
  2692. //  Description : get mms audio type string through multim audio type
  2693. // Global resource dependence : 
  2694. //  Author: Bruce.Chi
  2695. // Note:
  2696. ///*****************************************************************************/
  2697. T_BYTE *Edit_GetDeltaMMSAudioType(MMIMULTIM_MUSIC_TYPE_E multim_audio_type)
  2698. {
  2699. T_BYTE *audio_type_ptr = PNULL;
  2700. // MMIMULTIM_MUSIC_NO_TYPE,
  2701. // MMIMULTIM_TYPE_MIDI, //MIDI类型
  2702. // MMIMULTIM_TYPE_MMF, //MMF类型
  2703. // MMIMULTIM_TYPE_WAV, //WAV类型
  2704. //  MMIMULTIM_TYPE_MP3, //MP3类型
  2705. // MMIMULTIM_MAX_MUSIC_TYPE_NUM //音乐的类型总数
  2706. //#define COMPOSER_AUDIO_WAV "audio/wav"
  2707. //#define COMPOSER_AUDIO_IMELODY "audio/imelody"
  2708. //#define COMPOSER_AUDIO_MIDI "audio/midi"
  2709. //#define COMPOSER_AUDIO_AMR "audio/amr"
  2710. //#define COMPOSER_AUDIO_MP3 "audio/mp3"
  2711. SCI_ASSERT(multim_audio_type >= MMIMULTIM_MUSIC_NO_TYPE && multim_audio_type < MMIMULTIM_MAX_MUSIC_TYPE_NUM);
  2712. SCI_TRACE_LOW("mmimms_main:Edit_GetDeltaMMSAudioType(), multim_audio_type=%d, L%d", multim_audio_type, __LINE__);
  2713. switch(multim_audio_type)
  2714. {
  2715. case MMIMULTIM_TYPE_MIDI:
  2716. case MMIMULTIM_TYPE_MID:
  2717. audio_type_ptr = COMPOSER_AUDIO_MIDI;
  2718. break;
  2719. case MMIMULTIM_TYPE_MMF:
  2720. audio_type_ptr = PNULL;
  2721. break;
  2722. #ifdef HAVE_AMR
  2723. case MMIMULTIM_TYPE_AMR:
  2724. audio_type_ptr = COMPOSER_AUDIO_AMR;
  2725. break;
  2726. #endif
  2727. case MMIMULTIM_TYPE_WAV:
  2728. audio_type_ptr = COMPOSER_AUDIO_WAV;
  2729. break;
  2730. #ifdef HAVE_MP3
  2731. case MMIMULTIM_TYPE_MP3:
  2732. audio_type_ptr = COMPOSER_AUDIO_MP3;
  2733. break;
  2734. #endif
  2735. default:
  2736. audio_type_ptr = PNULL;
  2737. break;
  2738. }
  2739. return audio_type_ptr;
  2740. }
  2741. /*****************************************************************************/
  2742. //  Description : get audio type through delta mms audio type string
  2743. // Global resource dependence : 
  2744. //  Author: Bruce.Chi
  2745. // Note:
  2746. ///*****************************************************************************/
  2747. MMIMULTIM_MUSIC_TYPE_E Edit_GetMultimAudioType(char *delta_mms_audio_type_ptr)
  2748. {
  2749. MMIMULTIM_MUSIC_TYPE_E music_type = MMIMULTIM_MUSIC_NO_TYPE;
  2750. // MMIMULTIM_MUSIC_NO_TYPE,
  2751. // MMIMULTIM_TYPE_MIDI, //MIDI类型
  2752. // MMIMULTIM_TYPE_MMF, //MMF类型
  2753. // MMIMULTIM_TYPE_WAV, //WAV类型
  2754. //  MMIMULTIM_TYPE_MP3, //MP3类型
  2755. // MMIMULTIM_MAX_MUSIC_TYPE_NUM //音乐的类型总数
  2756. //#define COMPOSER_AUDIO_WAV "audio/wav"
  2757. //#define COMPOSER_AUDIO_IMELODY "audio/imelody"
  2758. //#define COMPOSER_AUDIO_MIDI "audio/midi"
  2759. //#define COMPOSER_AUDIO_AMR "audio/amr"
  2760. //#define COMPOSER_AUDIO_MP3 "audio/mp3"
  2761. if (delta_mms_audio_type_ptr != PNULL)
  2762. {
  2763. SCI_TRACE_LOW("mmimms_main:Edit_GetMultimAudioType(), delta_mms_audio_type_ptr=%s, L%d", delta_mms_audio_type_ptr, __LINE__);
  2764. }
  2765. if (delta_mms_audio_type_ptr == PNULL)
  2766. {
  2767. music_type = MMIMULTIM_MUSIC_NO_TYPE;
  2768. }
  2769. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_WAV))
  2770. {
  2771. music_type = MMIMULTIM_TYPE_WAV;   //wave
  2772. }
  2773. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_IMELODY))
  2774. {
  2775. music_type = MMIMULTIM_MUSIC_NO_TYPE; //not supported
  2776. }
  2777. else if(0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MIDI))
  2778. {
  2779. music_type = MMIMULTIM_TYPE_MIDI;
  2780. }
  2781. else if (0 == stricmp(delta_mms_audio_type_ptr, "audio/mid")) //there are many kinds of composer
  2782. {
  2783. music_type = MMIMULTIM_TYPE_MIDI;
  2784. }
  2785. #ifdef HAVE_AMR
  2786. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_AMR))
  2787. {
  2788. music_type = MMIMULTIM_TYPE_AMR; //amr
  2789. }
  2790. #endif
  2791. #ifdef HAVE_MP3
  2792. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MP3))
  2793. {
  2794. music_type = MMIMULTIM_TYPE_MP3; //mp3
  2795. }
  2796. #endif
  2797. //SCI_TRACE_LOW("mmimms_main:Edit_GetMultimAudioType(), music_type = %d, L%d", music_type, __LINE__);
  2798. return music_type;
  2799. }
  2800. /*****************************************************************************/
  2801. //  Description : get low layer audio type through delta mms audio type string
  2802. // Global resource dependence : 
  2803. //  Author: Bruce.Chi
  2804. // Note:
  2805. ///*****************************************************************************/
  2806. MMIAUDIO_TYPE_E Edit_GetLowLayerAudioType(char *delta_mms_audio_type_ptr)
  2807. {
  2808. MMIAUDIO_TYPE_E audio_type = MMIAUDIO_TYPE_MAX;
  2809. if (delta_mms_audio_type_ptr != PNULL)
  2810. {
  2811. SCI_TRACE_LOW("mmimms_main:Edit_GetLowLayerAudioType(), delta_mms_audio_type_ptr=%s, L%d", delta_mms_audio_type_ptr, __LINE__);
  2812. }
  2813. if (delta_mms_audio_type_ptr == PNULL)
  2814. {
  2815. audio_type = MMIAUDIO_TYPE_MAX;
  2816. }
  2817. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_WAV))
  2818. {
  2819. audio_type = MMIAUDIO_ADPCM;
  2820. }
  2821. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_IMELODY))
  2822. {
  2823. audio_type = MMIAUDIO_TYPE_MAX; //not supported
  2824. }
  2825. else if(0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MIDI))
  2826. {
  2827. audio_type = MMIAUDIO_MIDI;
  2828. }
  2829. else if (0 == stricmp(delta_mms_audio_type_ptr, "audio/mid")) //there are many composer
  2830. {
  2831. audio_type = MMIAUDIO_MIDI;
  2832. }
  2833. #ifdef HAVE_AMR
  2834. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_AMR))
  2835. {
  2836. audio_type = MMIAUDIO_AMR;
  2837. }
  2838. #endif
  2839. #ifdef HAVE_MP3
  2840. else if (0 == stricmp(delta_mms_audio_type_ptr, COMPOSER_AUDIO_MP3))
  2841. {
  2842. audio_type = MMIAUDIO_MP3; //not supported
  2843. }
  2844. #endif
  2845. return audio_type;
  2846. }
  2847. /*****************************************************************************/
  2848. //  Description : get ani type through delta mms type string
  2849. // Global resource dependence : 
  2850. //  Author: Bruce.Chi
  2851. // Note:
  2852. ///*****************************************************************************/
  2853. ANIMATE_IMAGE_TYPE_E Edit_GetAniType(char *delta_mms_img_type_ptr)
  2854. {
  2855. ANIMATE_IMAGE_TYPE_E anim_type = ANIM_NONE;
  2856.     if (delta_mms_img_type_ptr != PNULL)
  2857. {
  2858. SCI_TRACE_LOW("mmimms_main:Edit_GetAniType(), delta_mms_img_type_ptr=%s, L%d", delta_mms_img_type_ptr, __LINE__);
  2859. }
  2860. if (delta_mms_img_type_ptr == PNULL)
  2861. {
  2862. anim_type = ANIM_NONE;
  2863. }
  2864. else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_JPEG))
  2865. {
  2866. anim_type = ANIM_JPG;
  2867. }
  2868. else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_GIF))
  2869. {
  2870. anim_type = ANIM_GIF;
  2871. }
  2872. else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_BMP))
  2873. {
  2874. anim_type = ANIM_BMP;
  2875. }
  2876. else if(0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_WBMP))
  2877. {
  2878. anim_type = ANIM_WBMP;
  2879. }
  2880. else if (0 == stricmp(delta_mms_img_type_ptr, COMPOSER_IMAGE_PNG))
  2881. {
  2882. anim_type = ANIM_NONE;
  2883. }
  2884. return anim_type;
  2885. }
  2886. #define MMIMMS_RECEIVE_MMS_DELIVERY 0x86
  2887. #define MMIMMS_RECEIVE_MMS_NOTIFICATION 0x82
  2888. /*****************************************************************************/
  2889. //  Description : get MMI_TM_T through seconds since 1970
  2890. // Global resource dependence : 
  2891. //  Author: Bruce.Chi
  2892. // Note:
  2893. ///*****************************************************************************/
  2894. MMI_TM_T Edit_GetTimeFrom1970(uint32 seconds) 
  2895. {
  2896. MMI_TM_T date_time;
  2897. int year,month,day,hour,minute,second,i;
  2898. int total_day,current_year_days, current_month_day,leap_year;
  2899. int total_second;
  2900. uint16 day_of_month[2][12] =
  2901.     {
  2902.         {31,  28,  31,  30,  31,  30,  31,  31,  30,  31,  30,  31  },
  2903.         {31,  29,  31,  30,  31,  30,  31,  31,  30,  31,  30,  31  }
  2904.     };
  2905. SCI_MEMSET(&date_time, 0, sizeof(date_time));
  2906. total_day = seconds / (24 * 60 * 60);
  2907. total_second = seconds % (24 * 60 * 60);
  2908.      
  2909. year =  1970;
  2910. month = 1;
  2911. day = 1;
  2912. hour    =  MMS_LOCAL_TIME_ZONE;
  2913. minute = 0;
  2914. second = 0;
  2915. for (i = 0; i < MMS_100_YEARS; i++) 
  2916. {
  2917. current_year_days = Edit_IsLeapYear(year) ? 366:365;
  2918. if ((total_day -current_year_days) >= 0) 
  2919. {
  2920. total_day -=current_year_days;
  2921. year++;
  2922. }
  2923. else
  2924. {
  2925. break;
  2926. }
  2927. }
  2928. if (i == MMS_100_YEARS)
  2929. {
  2930. return date_time;
  2931. }
  2932. leap_year  = Edit_IsLeapYear(year) ? 1:0;
  2933. for (i = 0; i < 12;i++) 
  2934. {
  2935. current_month_day = day_of_month[ leap_year][i];
  2936. if ((total_day -current_month_day) >= 0) 
  2937. {
  2938. total_day -=current_month_day;
  2939. month++;
  2940. }
  2941. else
  2942. break;
  2943. }
  2944. }
  2945. day += total_day;
  2946. hour += total_second / (60 * 60);
  2947. minute =  (total_second % (60 * 60)) / 60;
  2948. second =  (total_second % (60 * 60)) % 60;
  2949. date_time.tm_year = year;
  2950. date_time.tm_mon = month;
  2951. date_time.tm_mday = day;
  2952. date_time.tm_hour = hour;
  2953. date_time.tm_min = minute;
  2954. date_time.tm_sec = second;
  2955.     
  2956. return date_time;
  2957. }
  2958. /*****************************************************************************/
  2959. //  Description : judge whether this year is leap year
  2960. // Global resource dependence : 
  2961. //  Author: Bruce.Chi
  2962. // Note:
  2963. ///*****************************************************************************/
  2964. LOCAL BOOLEAN Edit_IsLeapYear(uint16  year)
  2965. {
  2966.     if (year % 400 == 0)
  2967.     {
  2968.         return TRUE;
  2969.     }
  2970.     else if (year % 100 == 0)
  2971.     {
  2972.         return FALSE;
  2973.     }
  2974.     else if (year % 4 == 0)
  2975.     {
  2976.         return TRUE;
  2977.     }
  2978.     else
  2979.     {
  2980.         return FALSE;
  2981.     }
  2982. }
  2983. /*****************************************************************************/
  2984. //  Description : ucs2 -> utf8
  2985. // Global resource dependence : 
  2986. //  Author: Bruce.Chi
  2987. // Note: should free the return pointer UTF8_T.buf_ptr
  2988. ///*****************************************************************************/
  2989. UTF8_T Edit_UNICODE2UTF(MMI_STRING_T *str_src_ptr)
  2990. {
  2991. UTF8_T utf8_str = {0};
  2992. uint16 ucs2_char = 0; //here, we only consider UCS2. UCS4 is not considered.
  2993. int i = 0;
  2994. int j = 0;
  2995. uint8 *out_ptr = PNULL;
  2996. uint32 out_len = 0;
  2997. uint32 src_len = 0;
  2998. if (str_src_ptr == PNULL || str_src_ptr->str_ptr == PNULL || str_src_ptr->length == 0)
  2999. {
  3000. utf8_str.buf_ptr = 0;
  3001. utf8_str.len = 0;
  3002. return utf8_str;
  3003. }
  3004. //alloc
  3005. out_len = str_src_ptr->length / 2 * 3 + 3;
  3006. out_ptr = cms_malloc(out_len);
  3007. SCI_ASSERT(out_ptr != PNULL);
  3008. SCI_MEMSET(out_ptr, 0, out_len);
  3009. if (!str_src_ptr->is_ucs2)
  3010. {
  3011. //this is ACSII
  3012. MMI_MEMCPY(
  3013. out_ptr,
  3014. out_len,
  3015. str_src_ptr->str_ptr,
  3016. str_src_ptr->length,
  3017. str_src_ptr->length
  3018. );
  3019. utf8_str.buf_ptr = out_ptr;
  3020. utf8_str.len = str_src_ptr->length;
  3021. }
  3022. else
  3023. {
  3024. src_len = str_src_ptr->length;
  3025. if ((src_len % 2) != 0) //half of ucs2, ignore it
  3026. {
  3027. src_len--;
  3028. }
  3029. for (i = 0, j = 0; i < str_src_ptr->length / 2; i++)
  3030. {
  3031. //get unicode character
  3032. ucs2_char = ((str_src_ptr->str_ptr[2 * i]) << 8) | str_src_ptr->str_ptr[2 * i + 1];
  3033. if (ucs2_char <= 0x7F)
  3034. {
  3035. //0xxx xxxx 
  3036. //0111 1111 == 0x7F
  3037. out_ptr[j] = ucs2_char & 0x7F;
  3038. j++;
  3039. }
  3040. else if (ucs2_char <= 0x7FF)
  3041. {
  3042. //110x xxxx 10xx xxxx
  3043. //11位拆成5,6位
  3044. //0000 0111 1100 0000 == 0x7C0 110 == 0x6 //取出高5位+(110 << 5)
  3045. out_ptr[j] = (uint8)(((ucs2_char & 0x7C0) >> 5) | (0x6 << 5));
  3046. j++;
  3047. //0000 0000 0011 1111 = 0x3F 10 == 0x2 //取出低6位+(10 << 6)
  3048. out_ptr[j] = (uint8)((ucs2_char & 0x3F) | (0x2 << 6));
  3049. j++;
  3050. }
  3051. else if (ucs2_char <= 0xFFFF)
  3052. {
  3053. //1110 xxxx 10xx xxxxxx 10xx xxxxxx
  3054. //16位拆成4, 6, 6
  3055. //1111 0000 0000 0000 == 0xF000 1110 == 0xE //取出高4位 + (1110 << 4)
  3056. out_ptr[j] = (uint8)((ucs2_char & 0xF000) >> 12) | (0xE << 4);
  3057. j++;
  3058. //0000 1111 1100 0000 == 0xFC0 10 = 0x2 //中间6位 + (10 << 6)
  3059. out_ptr[j] = (uint8)(((ucs2_char & 0xFC0 ) >> 6) | (0x2 << 6));
  3060. j++;
  3061. //0000 0000 0011 1111 == 0x3F 10 = 0x2 //最后6位 + (10 << 6)
  3062. out_ptr[j] = (uint8)((ucs2_char & 0x3F) | (0x2 << 6));
  3063. j++;
  3064. }
  3065. }
  3066. utf8_str.buf_ptr = out_ptr;
  3067. utf8_str.len = j;
  3068. SCI_ASSERT(j <= out_len);
  3069. }
  3070. return utf8_str;
  3071. }
  3072. /*****************************************************************************/
  3073. //  Description : utf8 -> ucs2
  3074. // Global resource dependence : 
  3075. //  Author: Bruce.Chi
  3076. // Note: should free the return pointer MMI_STRING_T.str_ptr
  3077. ///*****************************************************************************/
  3078. MMI_STRING_T Edit_UTF2UNICODE(UTF8_T *utf8_str_ptr)
  3079. {
  3080. int i = 0;
  3081. int j = 0;
  3082. uint8 *ucs2_ptr = PNULL;
  3083. uint32 out_len = 0;
  3084. uint8 head_char = 0;
  3085. uint16 ucs2_char = 0;
  3086. BOOLEAN is_asc = TRUE;
  3087. MMI_STRING_T str_out = {0};
  3088. SCI_ASSERT(utf8_str_ptr != PNULL);
  3089. out_len = utf8_str_ptr->len * 2 + 2;
  3090. ucs2_ptr = cms_malloc(out_len);
  3091. SCI_ASSERT(ucs2_ptr != PNULL);
  3092. SCI_MEMSET(ucs2_ptr, 0, out_len);
  3093. is_asc = TRUE;
  3094. while(i < utf8_str_ptr->len)
  3095. {
  3096. head_char = utf8_str_ptr->buf_ptr[i];
  3097. if (head_char <= 0x7F)
  3098. {
  3099. //0xxx xxxx
  3100. //0111 1111 = 0X7F
  3101. ucs2_ptr[j] = 0;
  3102. ucs2_ptr[j + 1] = head_char;
  3103. j += 2;
  3104. i += 1;
  3105. }
  3106. else if (head_char <= 0xDF)
  3107. {
  3108. if (i + 1 <= utf8_str_ptr->len - 1)
  3109. {
  3110. //110x xxxx 10xx xxxx
  3111. //1101 1111 == 0xDF
  3112. //0001 1111 == 0x1F 0011 1111 == 0x3F
  3113. ucs2_char = ((utf8_str_ptr->buf_ptr[i] & 0x1F) << 6) | ((utf8_str_ptr->buf_ptr[i+1] & 0x3F));
  3114. ucs2_ptr[j] = (uint8)((ucs2_char & 0xFF00) >> 8);
  3115. ucs2_ptr[j + 1] = (uint8)(ucs2_char & 0xFF);
  3116. j += 2;
  3117. }
  3118. i += 2;
  3119. is_asc = FALSE;
  3120. }
  3121. else if (head_char <= 0xEF)
  3122. {
  3123. if (i + 2 <= utf8_str_ptr->len - 1)
  3124. {
  3125. //1110 xxxx 10xx xxxx 10xx xxxx
  3126. //1110 1111 == 0xEF
  3127. //0000 1111 == 0xF 0011 1111 == 0x3F
  3128. ucs2_char = ((utf8_str_ptr->buf_ptr[i] & 0xF) << 12) | ((utf8_str_ptr->buf_ptr[i + 1] & 0x3F) << 6) | (utf8_str_ptr->buf_ptr[i + 2] & 0x3F);
  3129. ucs2_ptr[j] = (uint8)((ucs2_char & 0xFF00) >> 8);
  3130. ucs2_ptr[j + 1] = (uint8)(ucs2_char & 0xFF);
  3131. j += 2;
  3132. }
  3133. i += 3;
  3134. is_asc = FALSE;
  3135. }
  3136. else
  3137. {
  3138. i++;
  3139. break;
  3140. }
  3141. }
  3142. if (is_asc)
  3143. {
  3144. str_out.is_ucs2 = FALSE;
  3145. str_out.length = utf8_str_ptr->len;