SMSMsg.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:209k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  *  SMSMsg.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  
  47.  *
  48.  * Author:
  49.  * -------
  50.  *  
  51.  *
  52.  *==============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  * removed!
  155.  * removed!
  156.  * removed!
  157.  *
  158.  * removed!
  159.  * removed!
  160.  * removed!
  161.  *
  162.  * removed!
  163.  * removed!
  164.  * removed!
  165.  *
  166.  * removed!
  167.  * removed!
  168.  * removed!
  169.  *
  170.  * removed!
  171.  * removed!
  172.  * removed!
  173.  *
  174.  * removed!
  175.  * removed!
  176.  * removed!
  177.  *
  178.  * removed!
  179.  * removed!
  180.  * removed!
  181.  *
  182.  * removed!
  183.  * removed!
  184.  * removed!
  185.  *
  186.  * removed!
  187.  * removed!
  188.  * removed!
  189.  *
  190.  * removed!
  191.  * removed!
  192.  * removed!
  193.  *
  194.  * removed!
  195.  * removed!
  196.  * removed!
  197.  *
  198.  * removed!
  199.  * removed!
  200.  * removed!
  201.  *
  202.  * removed!
  203.  * removed!
  204.  * removed!
  205.  *
  206.  * removed!
  207.  * removed!
  208.  * removed!
  209.  *
  210.  * removed!
  211.  * removed!
  212.  * removed!
  213.  *
  214.  * removed!
  215.  * removed!
  216.  * removed!
  217.  *
  218.  * removed!
  219.  * removed!
  220.  * removed!
  221.  *
  222.  * removed!
  223.  * removed!
  224.  * removed!
  225.  *
  226.  * removed!
  227.  * removed!
  228.  * removed!
  229.  *
  230.  * removed!
  231.  * removed!
  232.  * removed!
  233.  *
  234.  * removed!
  235.  * removed!
  236.  * removed!
  237.  *
  238.  * removed!
  239.  * removed!
  240.  * removed!
  241.  *
  242.  * removed!
  243.  * removed!
  244.  * removed!
  245.  *
  246.  * removed!
  247.  * removed!
  248.  * removed!
  249.  *
  250.  * removed!
  251.  * removed!
  252.  * removed!
  253.  *
  254.  * removed!
  255.  * removed!
  256.  * removed!
  257.  *
  258.  * removed!
  259.  * removed!
  260.  * removed!
  261.  *
  262.  * removed!
  263.  * removed!
  264.  * removed!
  265.  *
  266.  * removed!
  267.  * removed!
  268.  * removed!
  269.  *
  270.  * removed!
  271.  * removed!
  272.  * removed!
  273.  *
  274.  * removed!
  275.  * removed!
  276.  * removed!
  277.  *
  278.  *------------------------------------------------------------------------------
  279.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  280.  *==============================================================================
  281.  *******************************************************************************/
  282. #ifdef __MOD_SMSAL__
  283. #include "MMI_features.h"
  284. #include "stdC.h"
  285. #include "L4Dr1.h"
  286. #include "PixtelDataTypes.h"
  287. /* ... Add More MMI header */
  288. #include "EventsGprot.h"
  289. #include "HistoryGprot.h"
  290. #include "GlobalMenuItems.h"
  291. #include "GlobalConstants.h"
  292. #include "Globaldefs.h"
  293. #include "wgui_categories.h"
  294. #include "CustMenuRes.h"
  295. #include "CommonScreens.h"
  296. #include "Unicodexdcl.h"
  297. #include "TimerEvents.h"
  298. #include "DebugInitDef.h"
  299. #include "ProtocolEvents.h"
  300. /* ...Add MSG header */
  301. #include "customer_ps_inc.h"
  302. #include "mmi_msg_context.h"
  303. #include "MessagesL4Def.h"
  304. #include "MessagesResourceData.h"
  305. #include "MessagesMiscell.h"
  306. #include "MessagesExDcl.h"
  307. #include "SmsGuiInterfaceProt.h"
  308. #include "SMsGuiInterfaceType.h"
  309. #include "SmsPsHandler.h"
  310. #include "CellBroadcastType.h"
  311. #ifdef __MMI_MESSAGES_CHAT__
  312. #include "ChatAppGprot.h"
  313. #include "ChatAppDef.h"
  314. #endif /* __MMI_MESSAGES_CHAT__ */ 
  315. /*  */
  316. #include "customer_ps_inc.h"
  317. #include "l4c2smsal_struct.h"
  318. #include "smsal_l4c_enum.h"
  319. #include "ems.h"
  320. /*  */
  321. #include "Gui_ems.h"
  322. #include "wgui_ems.h"
  323. #include "GSM7BitDefaultAlphabet.h"
  324. /*  */
  325. #include "CallHistoryGProts.h"
  326. #include "IdleAppProt.h"
  327. #include "SettingProfile.h"
  328. #include "ProfileGprots.h"
  329. #include "AlarmFrameworkProt.h"
  330. #include "PhoneBookTypes.h"
  331. #include "PhoneBookDef.h"
  332. #include "SimDetectionGexdcl.h"
  333. #include "SettingDefs.h"
  334. #include "SettingsGdcl.h"
  335. #include "CSP.h"
  336. #ifdef MMI_ON_HARDWARE_P
  337. #include "sim_common_enums.h"
  338. #endif 
  339. /*  */
  340. #include "wgui_categories_inputs.h"
  341. #include "wgui_status_icons.h"
  342. #include "KeyBrd.h"
  343. /*  */
  344. #include "FileSystemDef.h"
  345. #include "FileSystemGProt.h"
  346. /*  */
  347. #include "NVRAMEnum.h"
  348. #include "NVRAMProt.h"
  349. #include "NVRAMType.h"
  350. /*  */
  351. #include "DateTimeGprot.h"
  352. #include "SMSApi.h"
  353. #include "SMSStruct.h"
  354. #include "SMSFunc.h"
  355. #include "app_datetime.h"
  356. #ifdef __MMI_UNIFIED_MESSAGE__
  357. #include "UnifiedMessageGProt.h"
  358. #endif 
  359. #ifdef __MMI_UNIFIED_COMPOSER__
  360. #include "UnifiedComposerGProt.h"
  361. #endif
  362. #if defined(__MMI_MESSAGES_USE_URL__)
  363. #include "wap_ps_struct.h"
  364. #endif 
  365. //KP Jerry modify on 2007-4-26 start
  366. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  367. #include "ManageCallMain.h"
  368. #endif
  369. //KP Jerry modify on 2007-4-26 end
  370. #ifndef MMI_FRM_SMS_INVALID_INDEX
  371. #define MMI_FRM_SMS_INVALID_INDEX   0xffff
  372. #endif 
  373. #ifndef MMI_FRM_SMS_INVALID_NUM
  374. #define MMI_FRM_SMS_INVALID_NUM     0xff
  375. #endif 
  376. #ifndef MMI_FRM_SMS_MSG_LEN
  377. #define MMI_FRM_SMS_MSG_LEN      160
  378. #endif 
  379. #ifndef MMI_FRM_SMS_MSG_SEQ_NUM
  380. #define MMI_FRM_SMS_MSG_SEQ_NUM  5
  381. #endif 
  382. #ifndef MMI_FRM_SMS_ACTION_SIZE
  383. #define MMI_FRM_SMS_ACTION_SIZE     10
  384. #endif 
  385. #define MMI_FRM_SMS_SEND_SEG     1
  386. static msg_profile_list_struct *profileList;
  387. static msg_profile_edit_struct *profileDetail;
  388. static msg_mailbox_edit_struct *mailboxDetail;
  389. #ifdef __MMI_MESSAGES_COPY__
  390. static mmi_frm_sms_copy_result_struct *copyResult;
  391. #endif 
  392. static mmi_frm_sms_send_struct *sendSMS;
  393. static mmi_frm_sms_send_struct *saveSMS;
  394. static MYTIME sms_saved_time;
  395. static U16 sendResult = MMI_FRM_SMS_OK;
  396. static U16 readIndex;
  397. static mmi_frm_sms_register_struct mmi_frm_sms_interrupt_handler[MMI_FRM_SMS_ACTION_SIZE];
  398. static U8 mmi_frm_sms_interrupt_handler_size = 0;
  399. extern EMSData *GetEMSDataForView(EMSData **p, U8 force);
  400. extern EMSData *GetEMSDataForEdit(EMSData **p, U8 force);
  401. extern U8 DeInitMessagesEMSBuffer(msg_ems_data_struct *pE);
  402. #if ( defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  403. extern nsm_msg_struct g_nsm_msg_context;
  404. #endif 
  405. /* Call before EMSPack  */
  406. extern void EMS_ConvertAsciiEncodingToGSM7BitDefault(EMSData *data);
  407. extern void EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended(EMSData *data);
  408. /* Call after EMSUnpack */
  409. extern void EMS_ConvertGSM7BitDefaultEncodingToAscii(EMSData *data);
  410. extern void EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended(EMSData *data);
  411. extern MMI_BOOL g_mmi_frm_sms_change_status;
  412. /*****************************************************************************
  413.  * FUNCTION
  414.  *  mmi_frm_sms_free_sendsms_data
  415.  * DESCRIPTION
  416.  *  free control buffer of sendSMS and sendSMS->string
  417.  * PARAMETERS
  418.  *  void
  419.  * RETURNS
  420.  *  void
  421.  *****************************************************************************/
  422. static void mmi_frm_sms_free_sendsms_data(void)
  423. {
  424.     /*----------------------------------------------------------------*/
  425.     /* Local Variables                                                */
  426.     /*----------------------------------------------------------------*/
  427.     /*----------------------------------------------------------------*/
  428.     /* Code Body                                                      */
  429.     /*----------------------------------------------------------------*/
  430.     if (sendSMS != NULL)
  431.     {
  432.         if (sendSMS->string != NULL)
  433.         {
  434.             OslMfree(sendSMS->string);
  435.             sendSMS->string = NULL;
  436.         }
  437.         OslMfree(sendSMS);
  438.         sendSMS = NULL;
  439.     }
  440. }
  441. /*****************************************************************************
  442.  * FUNCTION
  443.  *  mmi_frm_sms_free_savesms_data
  444.  * DESCRIPTION
  445.  *  free control buffer of saveSMS and saveSMS->string
  446.  * PARAMETERS
  447.  *  void
  448.  * RETURNS
  449.  *  void
  450.  *****************************************************************************/
  451. static void mmi_frm_sms_free_savesms_data(void)
  452. {
  453.     /*----------------------------------------------------------------*/
  454.     /* Local Variables                                                */
  455.     /*----------------------------------------------------------------*/
  456.     /*----------------------------------------------------------------*/
  457.     /* Code Body                                                      */
  458.     /*----------------------------------------------------------------*/
  459.     if (saveSMS != NULL)
  460.     {
  461.         if (saveSMS->string != NULL)
  462.         {
  463.             OslMfree(saveSMS->string);
  464.             saveSMS->string = NULL;
  465.         }
  466.         OslMfree(saveSMS);
  467.         saveSMS = NULL;
  468.     }
  469. }
  470. /*****************************************************************************
  471.  * FUNCTION
  472.  *  mmi_frm_sms_send_message
  473.  * DESCRIPTION
  474.  *  Common function for sending message
  475.  * PARAMETERS
  476.  *  MOD_SRC         [IN]        Source module
  477.  *  MOD_DEST        [IN]        Destination module
  478.  *  MSG_SAP         [IN]        Message SAP
  479.  *  MSG_ID          [IN]        Message ID
  480.  *  LOCAL           [IN]        Local parameter
  481.  *  PEER            [IN]        Peer buffer
  482.  * RETURNS
  483.  *  void
  484.  *****************************************************************************/
  485. void mmi_frm_sms_send_message(
  486.         module_type MOD_SRC,
  487.         module_type MOD_DEST,
  488.         U8 MSG_SAP,
  489.         const U16 MSG_ID,
  490.         void *LOCAL,
  491.         void *PEER)
  492. {
  493.     /*----------------------------------------------------------------*/
  494.     /* Local Variables                                                */
  495.     /*----------------------------------------------------------------*/
  496.     MYQUEUE Message;
  497.     /*----------------------------------------------------------------*/
  498.     /* Code Body                                                      */
  499.     /*----------------------------------------------------------------*/
  500.     Message.oslSrcId = MOD_SRC;
  501.     Message.oslDestId = MOD_DEST;
  502.     Message.oslMsgId = MSG_ID;
  503.     Message.oslDataPtr = LOCAL;
  504.     Message.oslPeerBuffPtr = PEER;
  505.     OslMsgSendExtQueue(&Message);
  506. }
  507. /*****************************************************************************
  508.  * FUNCTION
  509.  *  mmi_frm_sms_reg_interrupt_handler
  510.  * DESCRIPTION
  511.  *  Register interrupt handle
  512.  * PARAMETERS
  513.  *  mod             [IN]        Module type
  514.  *  msgid           [IN]        Message id
  515.  *  callback        [IN]        Callback of interrupt
  516.  * RETURNS
  517.  *  void
  518.  *****************************************************************************/
  519. void mmi_frm_sms_reg_interrupt_handler(module_type mod, U16 msgid, PsFuncPtrU16 callback)
  520. {
  521.     /*----------------------------------------------------------------*/
  522.     /* Local Variables                                                */
  523.     /*----------------------------------------------------------------*/
  524.     /*----------------------------------------------------------------*/
  525.     /* Code Body                                                      */
  526.     /*----------------------------------------------------------------*/
  527.     mmi_frm_sms_interrupt_handler[mmi_frm_sms_interrupt_handler_size].molude = mod;
  528.     mmi_frm_sms_interrupt_handler[mmi_frm_sms_interrupt_handler_size].msgid = msgid;
  529.     mmi_frm_sms_interrupt_handler[mmi_frm_sms_interrupt_handler_size].callback = callback;
  530.     mmi_frm_sms_interrupt_handler_size++;
  531. }
  532. /*****************************************************************************
  533.  * FUNCTION
  534.  *  mmi_frm_sms_ready_ind
  535.  * DESCRIPTION
  536.  *  Handle ready indication
  537.  * PARAMETERS
  538.  *  dummy       [IN]        Input message
  539.  * RETURNS
  540.  *  void
  541.  *****************************************************************************/
  542. void mmi_frm_sms_ready_ind(void *dummy)
  543. {
  544.     /*----------------------------------------------------------------*/
  545.     /* Local Variables                                                */
  546.     /*----------------------------------------------------------------*/
  547.     U8 i = 0;
  548.     /*----------------------------------------------------------------*/
  549.     /* Code Body                                                      */
  550.     /*----------------------------------------------------------------*/
  551.     g_frm_sms_cntx.mmi_frm_sms_ready = TRUE;
  552.     mmi_frm_sms_get_profile_list(NULL, MOD_MMI);
  553. #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
  554.     mmi_frm_sms_get_common_settings(NULL, MOD_MMI);
  555. #endif 
  556.     mmi_msg_pre_entry_cb_channel_bootup();
  557.     while (i < mmi_frm_sms_interrupt_handler_size)
  558.     {
  559.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_READY_IND)
  560.         {
  561.             mmi_frm_sms_interrupt_handler[i].callback(NULL, MOD_MMI, MMI_FRM_SMS_OK);
  562.         }
  563.         i++;
  564.     }
  565. }
  566. /*****************************************************************************
  567.  * FUNCTION
  568.  *  mmi_frm_sms_startup_read_req
  569.  * DESCRIPTION
  570.  *  SMS startup read request
  571.  * PARAMETERS
  572.  *  dummy       [IN]        Input message
  573.  * RETURNS
  574.  *  void
  575.  *****************************************************************************/
  576. void mmi_frm_sms_startup_read_req(void *dummy)
  577. {
  578.     /*----------------------------------------------------------------*/
  579.     /* Local Variables                                                */
  580.     /*----------------------------------------------------------------*/
  581.     /*----------------------------------------------------------------*/
  582.     /* Code Body                                                      */
  583.     /*----------------------------------------------------------------*/
  584.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_STARTUP_READ_NEXT_REQ, NULL, NULL);
  585. }
  586. /*****************************************************************************
  587.  * FUNCTION
  588.  *  mmi_frm_sms_startup_read_ind
  589.  * DESCRIPTION
  590.  *  Handle SMS startup read indication
  591.  * PARAMETERS
  592.  *  inMsg       [IN]        Input message
  593.  * RETURNS
  594.  *  void
  595.  *****************************************************************************/
  596. void mmi_frm_sms_startup_read_ind(void *inMsg)
  597. {
  598.     /*----------------------------------------------------------------*/
  599.     /* Local Variables                                                */
  600.     /*----------------------------------------------------------------*/
  601.     MMI_FRM_SMS_STARTUP_READ_MSG_IND_STRUCT *msgInd = (MMI_FRM_SMS_STARTUP_READ_MSG_IND_STRUCT*) inMsg;
  602.     mmi_frm_sms_msgbox_struct *entry = OslMalloc(sizeof(mmi_frm_sms_msgbox_struct));
  603.     U8 sendreq = (msgInd->startup_seq_num == 0) ? 1 : 0;
  604.     U8 seg = (msgInd->concat_info & 0xff000000) >> 24;
  605.     U8 thisseg = ((seg % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size) == 0) ?
  606.         g_frm_sms_cntx.mmi_frm_sms_msg_seg_size : (seg % g_frm_sms_cntx.mmi_frm_sms_msg_seg_size);
  607.     /*----------------------------------------------------------------*/
  608.     /* Code Body                                                      */
  609.     /*----------------------------------------------------------------*/
  610.     memset((S8*) entry, 0, sizeof(mmi_frm_sms_msgbox_struct));
  611.     if (msgInd->startup_seq_num == 0)
  612.     {
  613.         sendreq = TRUE;
  614.     }
  615.     mmi_frm_sms_convert_startup_read_to_entry((MMI_FRM_SMS_STARTUP_READ_MSG_IND_STRUCT*) msgInd, entry);
  616.     mmi_frm_sms_add_sms_to_msgbox(entry, msgInd->index, thisseg);
  617.     OslMfree(entry);
  618.     if (sendreq)
  619.     {
  620.         mmi_frm_sms_startup_read_req(NULL);
  621.     }
  622. }
  623. /*****************************************************************************
  624.  * FUNCTION
  625.  *  mmi_frm_sms_startup_finish_ind
  626.  * DESCRIPTION
  627.  *  Handle SMS startup finish indication
  628.  * PARAMETERS
  629.  *  dummy       [IN]        Input message
  630.  * RETURNS
  631.  *  void
  632.  *****************************************************************************/
  633. void mmi_frm_sms_startup_finish_ind(void *dummy)
  634. {
  635.     /*----------------------------------------------------------------*/
  636.     /* Local Variables                                                */
  637.     /*----------------------------------------------------------------*/
  638.     /*----------------------------------------------------------------*/
  639.     /* Code Body                                                      */
  640.     /*----------------------------------------------------------------*/
  641.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_STARTUP_READ_MSG_IND);
  642.     mmi_frm_sms_create_sms_list();
  643. }
  644. /*****************************************************************************
  645.  * FUNCTION
  646.  *  mmi_frm_sms_startup_begin_ind
  647.  * DESCRIPTION
  648.  *  Handle SMS startup begin indication
  649.  * PARAMETERS
  650.  *  dummy       [IN]        Input message
  651.  * RETURNS
  652.  *  void
  653.  *****************************************************************************/
  654. void mmi_frm_sms_startup_begin_ind(void *dummy)
  655. {
  656.     /*----------------------------------------------------------------*/
  657.     /* Local Variables                                                */
  658.     /*----------------------------------------------------------------*/
  659.     /*----------------------------------------------------------------*/
  660.     /* Code Body                                                      */
  661.     /*----------------------------------------------------------------*/
  662.     /* init msgbox in case of sim refresh */
  663.     mmi_frm_sms_init_msgbox();
  664.     SetProtocolEventHandler(mmi_frm_sms_startup_read_ind, PRT_MSG_ID_MMI_SMS_STARTUP_READ_MSG_IND);
  665.     SetProtocolEventHandler(mmi_frm_sms_startup_finish_ind, PRT_MSG_ID_MMI_SMS_STARTUP_FINISH_IND);
  666. }
  667. /*****************************************************************************
  668.  * FUNCTION
  669.  *  mmi_frm_sms_status_report_ind
  670.  * DESCRIPTION
  671.  *  Handle status report
  672.  * PARAMETERS
  673.  *  inMsg       [IN]        Input message
  674.  * RETURNS
  675.  *  void
  676.  *****************************************************************************/
  677. void mmi_frm_sms_status_report_ind(void *inMsg)
  678. {
  679.     /*----------------------------------------------------------------*/
  680.     /* Local Variables                                                */
  681.     /*----------------------------------------------------------------*/
  682.     MMI_FRM_SMS_STATUS_REPORT_IND_STRUCT *msgInd = (MMI_FRM_SMS_STATUS_REPORT_IND_STRUCT*) inMsg;
  683.     U8 i = 0;
  684. #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
  685.     U8 msg_ref = msgInd->mr;
  686.     U16 delivery_report_awaited_index;
  687.     /*----------------------------------------------------------------*/
  688.     /* Code Body                                                      */
  689.     /*----------------------------------------------------------------*/
  690.     /* check if mr is in delivery report awaited list */
  691.     delivery_report_awaited_index = mmi_frm_sms_get_delivery_report_index_by_mr(msg_ref);
  692.     /* mr is in delivery report awaited list */
  693.     if (delivery_report_awaited_index != MMI_FRM_SMS_ACTION_SIZE)
  694.     {
  695.         mmi_frm_sms_set_delivery_report_awaited_check(delivery_report_awaited_index, msg_ref, msgInd->st);
  696.         if (mmi_frm_sms_check_delivery_report_awaited_complete(delivery_report_awaited_index))
  697.         {
  698.             msgInd->st = mmi_frm_sms_get_delivery_report_awaited_result(delivery_report_awaited_index);
  699.             mmi_frm_sms_remove_delivery_report_awaited(delivery_report_awaited_index);
  700.             mmi_frm_sms_convert_time_stamp(msgInd->dt, msgInd->dt);
  701.             while (i < mmi_frm_sms_interrupt_handler_size)
  702.             {
  703.                 if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND)
  704.                 {
  705.                     mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  706.                     break;
  707.                 }
  708.                 i++;
  709.             }
  710.         }
  711.     }
  712.     /* Also indicate user if the mr is not in delivery report awaited list */        
  713.     /* For the case that the sending maybe aborted but actually the SMS is sent */
  714.     else
  715.     {
  716.         mmi_frm_sms_convert_time_stamp(msgInd->dt, msgInd->dt);
  717.         while (i < mmi_frm_sms_interrupt_handler_size)
  718.         {
  719.             if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND)
  720.             {
  721.                 mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  722.                 break;
  723.             }
  724.             i++;
  725.         }        
  726.     }
  727. #else /* __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__ */ 
  728.     mmi_frm_sms_convert_time_stamp(msgInd->dt, msgInd->dt);
  729.     while (i < mmi_frm_sms_interrupt_handler_size)
  730.     {
  731.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_STATUS_REPORT_IND)
  732.         {
  733.             mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  734.             break;
  735.         }
  736.         i++;
  737.     }
  738. #endif /* __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__ */ 
  739. }
  740. /*****************************************************************************
  741.  * FUNCTION
  742.  *  mmi_frm_sms_msg_waiting_ind
  743.  * DESCRIPTION
  744.  *  Handle message waiting indication
  745.  * PARAMETERS
  746.  *  inMsg       [IN]        Input message
  747.  * RETURNS
  748.  *  void
  749.  *****************************************************************************/
  750. void mmi_frm_sms_msg_waiting_ind(void *inMsg)
  751. {
  752.     /*----------------------------------------------------------------*/
  753.     /* Local Variables                                                */
  754.     /*----------------------------------------------------------------*/
  755.     U8 i = 0;
  756.     /*----------------------------------------------------------------*/
  757.     /* Code Body                                                      */
  758.     /*----------------------------------------------------------------*/
  759.     while (i < mmi_frm_sms_interrupt_handler_size)
  760.     {
  761.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_MSG_WAITING_IND)
  762.         {
  763.             mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  764.             break;
  765.         }
  766.         i++;
  767.     }
  768. }
  769. /*****************************************************************************
  770.  * FUNCTION
  771.  *  mmi_frm_sms_mem_full_ind
  772.  * DESCRIPTION
  773.  *  Handle memory full indication
  774.  * PARAMETERS
  775.  *  inMsg           [?]         
  776.  *  dummy(?)        [IN]        Input message
  777.  * RETURNS
  778.  *  void
  779.  *****************************************************************************/
  780. void mmi_frm_sms_mem_full_ind(void *inMsg)
  781. {
  782.     /*----------------------------------------------------------------*/
  783.     /* Local Variables                                                */
  784.     /*----------------------------------------------------------------*/
  785.     U8 i = 0;
  786.     /*----------------------------------------------------------------*/
  787.     /* Code Body                                                      */
  788.     /*----------------------------------------------------------------*/
  789.     while (i < mmi_frm_sms_interrupt_handler_size)
  790.     {
  791.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_MEM_FULL_IND)
  792.         {
  793.             mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  794.             break;
  795.         }
  796.         i++;
  797.     }
  798. }
  799. /*****************************************************************************
  800.  * FUNCTION
  801.  *  mmi_frm_sms_mem_exceed_ind
  802.  * DESCRIPTION
  803.  *  Handle memory exceed indication
  804.  * PARAMETERS
  805.  *  inMsg           [?]         
  806.  *  dummy(?)        [IN]        Input message
  807.  * RETURNS
  808.  *  void
  809.  *****************************************************************************/
  810. void mmi_frm_sms_mem_exceed_ind(void *inMsg)
  811. {
  812.     /*----------------------------------------------------------------*/
  813.     /* Local Variables                                                */
  814.     /*----------------------------------------------------------------*/
  815.     U8 i = 0;
  816.     /*----------------------------------------------------------------*/
  817.     /* Code Body                                                      */
  818.     /*----------------------------------------------------------------*/
  819.     while (i < mmi_frm_sms_interrupt_handler_size)
  820.     {
  821.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_MEM_EXCEED_IND)
  822.         {
  823.             mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  824.             break;
  825.         }
  826.         i++;
  827.     }
  828. }
  829. /*****************************************************************************
  830.  * FUNCTION
  831.  *  mmi_frm_sms_mem_avai_ind
  832.  * DESCRIPTION
  833.  *  Handle memory available indication
  834.  * PARAMETERS
  835.  *  inMsg           [?]         
  836.  *  dummy(?)        [IN]        Input message
  837.  * RETURNS
  838.  *  void
  839.  *****************************************************************************/
  840. void mmi_frm_sms_mem_avai_ind(void *inMsg)
  841. {
  842.     /*----------------------------------------------------------------*/
  843.     /* Local Variables                                                */
  844.     /*----------------------------------------------------------------*/
  845.     U8 i = 0;
  846.     /*----------------------------------------------------------------*/
  847.     /* Code Body                                                      */
  848.     /*----------------------------------------------------------------*/
  849.     while (i < mmi_frm_sms_interrupt_handler_size)
  850.     {
  851.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_MEM_AVAILABLE_IND)
  852.         {
  853.             mmi_frm_sms_interrupt_handler[i].callback(inMsg, MOD_MMI, MMI_FRM_SMS_OK);
  854.             break;
  855.         }
  856.         i++;
  857.     }
  858. }
  859. /*****************************************************************************
  860.  * FUNCTION
  861.  *  mmi_frm_sms_new_msg_ind
  862.  * DESCRIPTION
  863.  *  Callback new message indication
  864.  * PARAMETERS
  865.  *  index       [IN]        New SMS index
  866.  * RETURNS
  867.  *  void
  868.  *****************************************************************************/
  869. void mmi_frm_sms_new_msg_ind(U16 index)
  870. {
  871.     /*----------------------------------------------------------------*/
  872.     /* Local Variables                                                */
  873.     /*----------------------------------------------------------------*/
  874.     U8 i = 0;
  875.     U16 *data = OslMalloc(sizeof(U16));
  876.     /*----------------------------------------------------------------*/
  877.     /* Code Body                                                      */
  878.     /*----------------------------------------------------------------*/
  879.     *data = index;
  880.     while (i < mmi_frm_sms_interrupt_handler_size)
  881.     {
  882.         if (mmi_frm_sms_interrupt_handler[i].msgid == PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND)
  883.         {
  884.             mmi_frm_sms_interrupt_handler[i].callback((void*)data, MOD_MMI, MMI_FRM_SMS_OK);
  885.             break;
  886.         }
  887.         i++;
  888.     }
  889.     OslMfree(data);
  890. }
  891. //KP Jerry add on 2007-4-26 start
  892. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  893. void mmi_frm_sms_remove_smsInBList_from_msgbox(U8 *data)
  894. {
  895.     /*----------------------------------------------------------------*/
  896.     /* Local Variables                                                */
  897.     /*----------------------------------------------------------------*/
  898.     U8 *index_bitmap = (U8*) data;
  899.     U16 index = mmi_frm_sms_get_index(0, index_bitmap);
  900. kal_prompt_trace( MOD_SMS, " index =%d***********n",index);
  901.     /*----------------------------------------------------------------*/
  902.     /* Code Body                                                      */
  903.     /*----------------------------------------------------------------*/
  904.     while (index != MMI_FRM_SMS_INVALID_INDEX)
  905.     {
  906.         mmi_frm_sms_remove_sms_entry(index);
  907.         index++;
  908.         index = mmi_frm_sms_get_index(index, index_bitmap);
  909.     }
  910.     return;
  911. }
  912. void mmi_frm_sms_delete_smsInBList_rsp(void *inMsg)
  913. {
  914.     /*----------------------------------------------------------------*/
  915.     /* Local Variables                                                */
  916.     /*----------------------------------------------------------------*/
  917.     MMI_FRM_SMS_DEL_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_DEL_MSG_RSP_STRUCT*) inMsg;
  918.     U16 result = MMI_FRM_SMS_ERROR;
  919.     /*----------------------------------------------------------------*/
  920.     /* Code Body                                                      */
  921.     /*----------------------------------------------------------------*/
  922. kal_prompt_trace( MOD_SMS, " FirewallList_InvailFlag ==TRUE 2222n");
  923.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  924.     if (msgRsp->result == TRUE)
  925.     {
  926.      kal_prompt_trace( MOD_SMS, " FirewallList_InvailFlag ==TRUE 3333n");
  927.         result = MMI_FRM_SMS_OK;
  928.         mmi_frm_sms_remove_smsInBList_from_msgbox(msgRsp->del_bitmap);
  929.     }
  930.     mmi_frm_sms_callback_action(NULL, result);
  931. }
  932. void mmi_frm_sms_delete_smsInBList_req(void *inMsg)
  933. {
  934.     /*----------------------------------------------------------------*/
  935.     /* Local Variables                                                */
  936.     /*----------------------------------------------------------------*/
  937.     MMI_FRM_SMS_DEL_MSG_REQ_STRUCT *msgReq;
  938.     MMI_FRM_SMS_DELIVER_MSG_IND_STRUCT *msgInd = (MMI_FRM_SMS_DELIVER_MSG_IND_STRUCT*) inMsg;
  939.     U8 *index = (U8*) inMsg;
  940.     
  941.     /*----------------------------------------------------------------*/
  942.     /* Code Body                                                      */
  943.     /*----------------------------------------------------------------*/
  944.     msgReq = (MMI_FRM_SMS_DEL_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  945.     msgReq->del_flag = SMSAL_DEL_INDEXED_MSG;
  946.     kal_prompt_trace( MOD_SMS, " msgReq->index1 =%dn",msgReq->index);
  947.     msgReq->index = msgInd->index;
  948.    // memcpy((S8*) msgReq->del_bitmap, (S8*) index, 480);
  949.   //  kal_prompt_trace( MOD_SMS, " msgReq->del_bitmap=%sn",msgReq->del_bitmap);
  950.     kal_prompt_trace( MOD_SMS, " msgReq->del_flag =%dn",msgReq->del_flag);
  951.     kal_prompt_trace( MOD_SMS, " msgReq->index2 =%dn",msgReq->index);
  952.     SetProtocolEventHandler(mmi_frm_sms_delete_smsInBList_rsp, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  953.    // SetProtocolEventHandler(NULL, PRT_MSG_ID_MMI_SMS_DEL_MSG_RSP);
  954.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_DEL_MSG_REQ, (oslParaType*) msgReq, NULL);
  955.     OslMfree(inMsg);
  956. }
  957. #endif
  958. //KP Jerry add on 2007-4-26 end
  959. /*****************************************************************************
  960.  * FUNCTION
  961.  *  mmi_frm_sms_new_sms_ind
  962.  * DESCRIPTION
  963.  *  Handle new SMS indication
  964.  * PARAMETERS
  965.  *  inMsg       [IN]        Input message
  966.  * RETURNS
  967.  *  void
  968.  *****************************************************************************/
  969. //KP Jerry add on 2007-4-26 start
  970. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  971. BOOL SMS_DeleteFlag = 0;
  972. U16 SMS_DeleteIndex = 0;
  973. #endif
  974. //KP Jerry add on 2007-4-26 end
  975. void mmi_frm_sms_new_sms_ind(void *inMsg)
  976. {
  977.     /*----------------------------------------------------------------*/
  978.     /* Local Variables                                                */
  979.     /*----------------------------------------------------------------*/
  980. //KP Jerry add on 2007-4-26 start
  981. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  982.     U32 newNumber ;
  983. #endif
  984. //KP Jerry add on 2007-4-26 end
  985.     MMI_FRM_SMS_DELIVER_MSG_IND_STRUCT *msgInd = (MMI_FRM_SMS_DELIVER_MSG_IND_STRUCT*) inMsg;
  986.     mmi_frm_sms_deliver_msg_struct *data = OslMalloc(sizeof(mmi_frm_sms_deliver_msg_struct));
  987.     /*----------------------------------------------------------------*/
  988.     /* Code Body                                                      */
  989.     /*----------------------------------------------------------------*/
  990. //KP Jerry add on 2007-4-26 start
  991. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  992. newNumber = mmi_phb_util_convert_number_to_int(msgInd->oa_number.number);
  993. if(Sms_GetNumFromFirewallList_InvailFlag(newNumber))
  994. {
  995.   Set_Firewall_SmsDeleteFlag(TRUE);
  996.   Set_Firewall_SmsDeleteIndex(msgInd->index);
  997.   CHISTIncRecvdSMS();
  998.   mmi_frm_sms_convert_new_sms(msgInd, data);
  999.   /* put to awaited list last entry, from now on only process new data as awaited list last entry */
  1000.   mmi_frm_sms_add_new_sms(data, msgInd->no_msg_data, msgInd->msg_data);
  1001.   //mmi_frm_sms_set_bitmap(msgInd->index,msgInd->oa_number.number);
  1002.   mmi_msg_delete_msg_req(MMI_FRM_SMS_APP_INBOX, msgInd->index);
  1003.    OslMfree(data);
  1004.    return;
  1005. }
  1006. else
  1007. Set_Firewall_SmsDeleteFlag(FALSE);
  1008. #endif
  1009. //KP Jerry add on 2007-4-26 end
  1010.     CHISTIncRecvdSMS();
  1011.     /* convert L4 data to MMI data */
  1012.     mmi_frm_sms_convert_new_sms(msgInd, data);
  1013.     /* put to awaited list last entry, from now on only process new data as awaited list last entry */
  1014.     mmi_frm_sms_add_new_sms(data, msgInd->no_msg_data, msgInd->msg_data);
  1015.     /* process new sms data */
  1016.     mmi_frm_sms_new_sms();
  1017.     OslMfree(data);
  1018. }
  1019. /*****************************************************************************
  1020.  * FUNCTION
  1021.  *  mmi_frm_sms_new_data_ind
  1022.  * DESCRIPTION
  1023.  *  Handle new SMS with port number indication
  1024.  * PARAMETERS
  1025.  *  inMsg       [IN]        Input message
  1026.  * RETURNS
  1027.  *  void
  1028.  *****************************************************************************/
  1029. void mmi_frm_sms_new_data_ind(void *inMsg)
  1030. {
  1031.     /*----------------------------------------------------------------*/
  1032.     /* Local Variables                                                */
  1033.     /*----------------------------------------------------------------*/
  1034.     MMI_FRM_SMS_APP_DATA_IND_STRUCT *msgInd = (MMI_FRM_SMS_APP_DATA_IND_STRUCT*) inMsg;
  1035.     mmi_frm_sms_deliver_data_struct *data = OslMalloc(sizeof(mmi_frm_sms_deliver_data_struct));
  1036.     /*----------------------------------------------------------------*/
  1037.     /* Code Body                                                      */
  1038.     /*----------------------------------------------------------------*/
  1039.     /* convert L4 data to MMI data */
  1040.     mmi_frm_sms_convert_new_data(msgInd, data);
  1041.     /* put to awaited list last entry, from now on only process new data as awaited list last entry */
  1042.     mmi_frm_sms_add_new_data(data, msgInd->message_len, msgInd->msg_data);
  1043.     /* process new sms data */
  1044.     mmi_frm_sms_new_data();
  1045.     OslMfree(data);
  1046. }
  1047. /*****************************************************************************
  1048.  * FUNCTION
  1049.  *  mmi_frm_sms_reg_port_rsp
  1050.  * DESCRIPTION
  1051.  *  Register port response
  1052.  * PARAMETERS
  1053.  *  inMsg       [IN]        Input message
  1054.  * RETURNS
  1055.  *  void
  1056.  *****************************************************************************/
  1057. void mmi_frm_sms_reg_port_rsp(void *inMsg)
  1058. {
  1059.     /*----------------------------------------------------------------*/
  1060.     /* Local Variables                                                */
  1061.     /*----------------------------------------------------------------*/
  1062.     MMI_FRM_SMS_REG_PORT_NUM_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_REG_PORT_NUM_RSP_STRUCT*) inMsg;
  1063.     U16 result = MMI_FRM_SMS_ERROR;
  1064.     U16 cause = msgRsp->cause;
  1065.     /*----------------------------------------------------------------*/
  1066.     /* Code Body                                                      */
  1067.     /*----------------------------------------------------------------*/
  1068.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_REG_PORT_NUM_RSP);
  1069.     if (msgRsp->result == TRUE)
  1070.     {
  1071.         result = MMI_FRM_SMS_OK;
  1072.     }
  1073.     mmi_frm_sms_callback_action((void*)&cause, result);
  1074. }
  1075. /*****************************************************************************
  1076.  * FUNCTION
  1077.  *  mmi_frm_sms_reg_port_req
  1078.  * DESCRIPTION
  1079.  *  Register port request
  1080.  * PARAMETERS
  1081.  *  inMsg       [IN]        Input message
  1082.  * RETURNS
  1083.  *  void
  1084.  *****************************************************************************/
  1085. void mmi_frm_sms_reg_port_req(void *inMsg)
  1086. {
  1087.     /*----------------------------------------------------------------*/
  1088.     /* Local Variables                                                */
  1089.     /*----------------------------------------------------------------*/
  1090.     MMI_FRM_SMS_REG_PORT_NUM_REQ_STRUCT *msgReq;
  1091.     mmi_sms_reg_port_num_req_struct *data = (mmi_sms_reg_port_num_req_struct*) inMsg;
  1092.     /*----------------------------------------------------------------*/
  1093.     /* Code Body                                                      */
  1094.     /*----------------------------------------------------------------*/
  1095.     msgReq = (MMI_FRM_SMS_REG_PORT_NUM_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1096.     msgReq->enable = data->enable;
  1097.     msgReq->mod_id = data->mod_id;
  1098.     msgReq->port_num = data->port_num;
  1099.     SetProtocolEventHandler(mmi_frm_sms_reg_port_rsp, PRT_MSG_ID_MMI_SMS_REG_PORT_NUM_RSP);
  1100.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_REG_PORT_NUM_REQ, (oslParaType*) msgReq, NULL);
  1101.     OslMfree(inMsg);
  1102. }
  1103. /*****************************************************************************
  1104.  * FUNCTION
  1105.  *  mmi_frm_sms_get_sc_addr_rsp
  1106.  * DESCRIPTION
  1107.  *  Get SC address response
  1108.  * PARAMETERS
  1109.  *  inMsg       [IN]        Input message
  1110.  * RETURNS
  1111.  *  void
  1112.  *****************************************************************************/
  1113. void mmi_frm_sms_get_sc_addr_rsp(void *inMsg)
  1114. {
  1115.     /*----------------------------------------------------------------*/
  1116.     /* Local Variables                                                */
  1117.     /*----------------------------------------------------------------*/
  1118.     MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_GET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
  1119.     U16 result = MMI_FRM_SMS_ERROR;
  1120.     /*----------------------------------------------------------------*/
  1121.     /* Code Body                                                      */
  1122.     /*----------------------------------------------------------------*/
  1123.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
  1124.     if (msgRsp->result == TRUE)
  1125.     {
  1126.         result = MMI_FRM_SMS_OK;
  1127.         if (msgRsp->sc_addr.length == 0)
  1128.         {
  1129.             if (sendSMS->sendcheck & MMI_FRM_SMS_NOT_ALLOW_EMPTY_SC)
  1130.             {
  1131.                 mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_SC_EMPTY);
  1132.                 mmi_frm_sms_free_sendsms_data();
  1133.             }
  1134.             else
  1135.             {
  1136.                 mmi_frm_sms_entry_sc();
  1137.             }
  1138.         }
  1139.         else
  1140.         {
  1141.             sendSMS->sendcheck |= MMI_FRM_SMS_SC;
  1142.             mmi_frm_sms_send_sms_req();
  1143.         }
  1144.     }
  1145.     else
  1146.     {
  1147.         mmi_frm_sms_callback_action(NULL, result);
  1148.     }
  1149. }
  1150. /*****************************************************************************
  1151.  * FUNCTION
  1152.  *  mmi_frm_sms_get_sc_addr_req
  1153.  * DESCRIPTION
  1154.  *  Get SC address request
  1155.  * PARAMETERS
  1156.  *  inMsg       [IN]        Input message
  1157.  * RETURNS
  1158.  *  void
  1159.  *****************************************************************************/
  1160. void mmi_frm_sms_get_sc_addr_req(void *inMsg)
  1161. {
  1162.     /*----------------------------------------------------------------*/
  1163.     /* Local Variables                                                */
  1164.     /*----------------------------------------------------------------*/
  1165.     MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
  1166.     U8 index = *(U8*) inMsg;
  1167.     /*----------------------------------------------------------------*/
  1168.     /* Code Body                                                      */
  1169.     /*----------------------------------------------------------------*/
  1170.     msgReq = (MMI_FRM_SMS_GET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1171.     msgReq->profile_no = index;
  1172.     SetProtocolEventHandler(mmi_frm_sms_get_sc_addr_rsp, PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_RSP);
  1173.     mmi_frm_sms_send_message(
  1174.         MOD_MMI,
  1175.         MOD_L4C,
  1176.         0,
  1177.         PRT_MSG_ID_MMI_SMS_GET_PROFILE_PARAMS_REQ,
  1178.         (oslParaType*) msgReq,
  1179.         NULL);
  1180. }
  1181. /*****************************************************************************
  1182.  * FUNCTION
  1183.  *  mmi_frm_sms_set_sc_addr_rsp
  1184.  * DESCRIPTION
  1185.  *  Set SC address response
  1186.  * PARAMETERS
  1187.  *  inMsg       [IN]        Input message
  1188.  * RETURNS
  1189.  *  void
  1190.  *****************************************************************************/
  1191. void mmi_frm_sms_set_sc_addr_rsp(void *inMsg)
  1192. {
  1193.     /*----------------------------------------------------------------*/
  1194.     /* Local Variables                                                */
  1195.     /*----------------------------------------------------------------*/
  1196.     MMI_FRM_SMS_SET_PROFILE_PARAMS_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_PROFILE_PARAMS_RSP_STRUCT*) inMsg;
  1197.     U16 result = MMI_FRM_SMS_ERROR;
  1198.     /*----------------------------------------------------------------*/
  1199.     /* Code Body                                                      */
  1200.     /*----------------------------------------------------------------*/
  1201.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_RSP);
  1202.     if (msgRsp->result == TRUE)
  1203.     {
  1204.         result = MMI_FRM_SMS_OK;
  1205.         /* sending screen is displayed by SMS framework */
  1206.         if ((sendSMS->sendcheck & MMI_FRM_SMS_SCR) != MMI_FRM_SMS_SCR)
  1207.         {
  1208.             DisplayPopupCallBack(
  1209.                 (PU8) GetString(STR_GLOBAL_SAVED),
  1210.                 IMG_GLOBAL_ACTIVATED,
  1211.                 1,
  1212.                 MESSAGES_POPUP_TIME_OUT,
  1213.                 (U8) SUCCESS_TONE,
  1214.                 mmi_frm_sms_send_sms_req);
  1215.         }
  1216.         else /* sending screen is displayed by applications */
  1217.         {
  1218.             DisplayPopup(
  1219.                 (PU8) GetString(STR_GLOBAL_SAVED),
  1220.                 IMG_GLOBAL_ACTIVATED,
  1221.                 1,
  1222.                 MESSAGES_POPUP_TIME_OUT,
  1223.                 (U8) SUCCESS_TONE);
  1224.             StartTimer(
  1225.                 MESSAGES_CONTINUE_SEND_SMS_PROCESS_TIMER_ID, 
  1226.                 MESSAGES_POPUP_TIME_OUT, 
  1227.                 mmi_frm_sms_send_sms_req);    
  1228.         }
  1229.         DeleteScreenIfPresent(SCR_ID_MSG_SC_NUMBER);
  1230.         sendSMS->sendcheck |= MMI_FRM_SMS_SC;
  1231.     }
  1232.     else
  1233.     {
  1234.         DisplayPopup(
  1235.             (PU8) GetString(STR_MESSAGES_UNKNOWN_ERROR),
  1236.             IMG_GLOBAL_UNFINISHED,
  1237.             1,
  1238.             MESSAGES_POPUP_TIME_OUT,
  1239.             (U8) ERROR_TONE);
  1240.         DeleteScreenIfPresent(SCR_ID_MSG_SC_NUMBER);
  1241.         mmi_frm_sms_callback_action(NULL, result);
  1242.     }
  1243. }
  1244. /*****************************************************************************
  1245.  * FUNCTION
  1246.  *  mmi_frm_sms_set_sc_addr_req
  1247.  * DESCRIPTION
  1248.  *  Set SC address request
  1249.  * PARAMETERS
  1250.  *  inMsg       [IN]        Input message
  1251.  * RETURNS
  1252.  *  void
  1253.  *****************************************************************************/
  1254. void mmi_frm_sms_set_sc_addr_req(void *inMsg)
  1255. {
  1256.     /*----------------------------------------------------------------*/
  1257.     /* Local Variables                                                */
  1258.     /*----------------------------------------------------------------*/
  1259.     MMI_FRM_SMS_SET_PROFILE_PARAMS_REQ_STRUCT *msgReq;
  1260.     msg_profile_edit_struct *profile = (msg_profile_edit_struct*) inMsg;
  1261.     S8 scAddress[MAX_DIGITS_SMS * ENCODING_LENGTH];
  1262.     /*----------------------------------------------------------------*/
  1263.     /* Code Body                                                      */
  1264.     /*----------------------------------------------------------------*/
  1265.     msgReq = (MMI_FRM_SMS_SET_PROFILE_PARAMS_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1266.     memset(scAddress, 0, MAX_DIGITS_SMS * ENCODING_LENGTH);
  1267.     UnicodeNToAnsii((PS8) scAddress, (PS8) profile->scAddress, MAX_DIGITS_SMS * ENCODING_LENGTH);
  1268.     msgReq->profile_no = profile->profileIndex;
  1269.     if (scAddress[0] == '+')
  1270.     {
  1271.         msgReq->sc_addr.type = CSMCC_INTERNATIONAL_ADDR;
  1272.         msgReq->sc_addr.length = (strlen(scAddress) > MAX_DIGITS_SMS) ? (MAX_DIGITS_SMS - 1) : (strlen(scAddress) - 1);
  1273.         memcpy(msgReq->sc_addr.number, scAddress + 1, msgReq->sc_addr.length);
  1274.     }
  1275.     else
  1276.     {
  1277.         msgReq->sc_addr.type = CSMCC_DEFAULT_ADDR_TYPE;
  1278.         msgReq->sc_addr.length =
  1279.             (strlen(scAddress) > (MAX_DIGITS_SMS - 1)) ? (MAX_DIGITS_SMS - 1) : (strlen(scAddress));
  1280.         memcpy(msgReq->sc_addr.number, scAddress, msgReq->sc_addr.length);
  1281.     }
  1282.     memset(&msgReq->sc_addr.number[msgReq->sc_addr.length], 0, 1);
  1283.     msgReq->para_ind = SMSAL_PARA_SCA;
  1284.     SetProtocolEventHandler(mmi_frm_sms_set_sc_addr_rsp, PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_RSP);
  1285.     mmi_frm_sms_send_message(
  1286.         MOD_MMI,
  1287.         MOD_L4C,
  1288.         0,
  1289.         PRT_MSG_ID_MMI_SMS_SET_PROFILE_PARAMS_REQ,
  1290.         (oslParaType*) msgReq,
  1291.         NULL);
  1292. }
  1293. #ifdef _CHECK_FDL_BY_MMI_
  1294. /*****************************************************************************
  1295.  * FUNCTION
  1296.  *  mmi_frm_sms_check_fdl_rsp
  1297.  * DESCRIPTION
  1298.  *  Check FDL response
  1299.  * PARAMETERS
  1300.  *  inMsg       [IN]        Input message
  1301.  * RETURNS
  1302.  *  void
  1303.  *****************************************************************************/
  1304. void mmi_frm_sms_check_fdl_rsp(void *inMsg)
  1305. {
  1306.     /*----------------------------------------------------------------*/
  1307.     /* Local Variables                                                */
  1308.     /*----------------------------------------------------------------*/
  1309.     MMI_FRM_SMS_FDN_CHECK_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_FDN_CHECK_RSP_STRUCT*) inMsg;
  1310.     U16 result = MMI_FRM_SMS_ERROR;
  1311.     /*----------------------------------------------------------------*/
  1312.     /* Code Body                                                      */
  1313.     /*----------------------------------------------------------------*/
  1314.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_FDN_CHECK_RSP);
  1315.     if ((msgRsp->result) == TRUE)
  1316.     {
  1317.         result = MMI_FRM_SMS_OK;
  1318.         sendSMS->sendcheck |= MMI_FRM_SMS_FDL;
  1319.         mmi_frm_sms_send_sms_req();
  1320.     }
  1321.     else
  1322.     {
  1323.         mmi_frm_sms_callback_action(NULL, result);
  1324.     }
  1325. }
  1326. /*****************************************************************************
  1327.  * FUNCTION
  1328.  *  mmi_frm_sms_check_fdl_req
  1329.  * DESCRIPTION
  1330.  *  Check FDL request
  1331.  * PARAMETERS
  1332.  *  inMsg       [IN]        Input message
  1333.  * RETURNS
  1334.  *  void
  1335.  *****************************************************************************/
  1336. void mmi_frm_sms_check_fdl_req(void *inMsg)
  1337. {
  1338.     /*----------------------------------------------------------------*/
  1339.     /* Local Variables                                                */
  1340.     /*----------------------------------------------------------------*/
  1341.     MMI_FRM_SMS_FDN_CHECK_REQ_STRUCT *msgReq;
  1342.     /*----------------------------------------------------------------*/
  1343.     /* Code Body                                                      */
  1344.     /*----------------------------------------------------------------*/
  1345.     msgReq = (MMI_FRM_SMS_FDN_CHECK_REQ_STRUCT*) OslConstructDataPtr(sizeof(*msgReq));
  1346.     SetProtocolEventHandler(mmi_frm_sms_check_fdl_rsp, PRT_MSG_ID_MMI_SMS_FDN_CHECK_RSP);
  1347.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_FDN_CHECK_REQ, (oslParaType*) msgReq, NULL);
  1348.     OslMfree(inMsg);
  1349. }
  1350. #endif /* _CHECK_FDL_BY_MMI_ */ 
  1351. /*****************************************************************************
  1352.  * FUNCTION
  1353.  *  mmi_frm_sms_abort_sms_rsp
  1354.  * DESCRIPTION
  1355.  *  Abort SMS response
  1356.  * PARAMETERS
  1357.  *  inMsg       [IN]        Input message
  1358.  * RETURNS
  1359.  *  void
  1360.  *****************************************************************************/
  1361. void mmi_frm_sms_abort_sms_rsp(void *inMsg)
  1362. {
  1363.     /*----------------------------------------------------------------*/
  1364.     /* Local Variables                                                */
  1365.     /*----------------------------------------------------------------*/
  1366.     MMI_FRM_SMS_SEND_ABORT_FINISH_IND_STRUCT *msgRsp = (MMI_FRM_SMS_SEND_ABORT_FINISH_IND_STRUCT*) inMsg;
  1367.     U16 result = MMI_FRM_SMS_ERROR;
  1368.     /*----------------------------------------------------------------*/
  1369.     /* Code Body                                                      */
  1370.     /*----------------------------------------------------------------*/
  1371.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND);
  1372.     g_frm_sms_cntx.is_aborting = MMI_FALSE;
  1373.     if (msgRsp->result == TRUE)
  1374.     {
  1375.         result = MMI_FRM_SMS_OK;
  1376.     }
  1377.     mmi_frm_sms_free_sendsms_data();
  1378.     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ABORT);
  1379. }
  1380. /*****************************************************************************
  1381.  * FUNCTION
  1382.  *  mmi_frm_sms_abort_sms_ind
  1383.  * DESCRIPTION
  1384.  *  Handle abort indication
  1385.  * PARAMETERS
  1386.  *  inMsg       [IN]        Input message
  1387.  * RETURNS
  1388.  *  void
  1389.  *****************************************************************************/
  1390. void mmi_frm_sms_abort_sms_ind(void *inMsg)
  1391. {
  1392.     /*----------------------------------------------------------------*/
  1393.     /* Local Variables                                                */
  1394.     /*----------------------------------------------------------------*/
  1395.     /*----------------------------------------------------------------*/
  1396.     /* Code Body                                                      */
  1397.     /*----------------------------------------------------------------*/
  1398.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_MSG_RSP);
  1399.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_START_IND);
  1400.     mmi_frm_sms_entry_abort();
  1401.     SetProtocolEventHandler(mmi_frm_sms_abort_sms_rsp, PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND);
  1402. }
  1403. /*****************************************************************************
  1404.  * FUNCTION
  1405.  *  mmi_frm_sms_abort_sms_req
  1406.  * DESCRIPTION
  1407.  *  Abort SMS request
  1408.  * PARAMETERS
  1409.  *  inMsg       [IN]        Input message
  1410.  * RETURNS
  1411.  *  void
  1412.  *****************************************************************************/
  1413. void mmi_frm_sms_abort_sms_req(void *inMsg)
  1414. {
  1415.     /*----------------------------------------------------------------*/
  1416.     /* Local Variables                                                */
  1417.     /*----------------------------------------------------------------*/
  1418.     /*----------------------------------------------------------------*/
  1419.     /* Code Body                                                      */
  1420.     /*----------------------------------------------------------------*/
  1421.     mmi_frm_sms_abort_sms_ind(NULL);
  1422.     g_frm_sms_cntx.is_aborting = MMI_TRUE;
  1423.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_ABORT_REQ, NULL, NULL);
  1424. }
  1425. #ifdef __MMI_UNIFIED_MESSAGE__
  1426. /*****************************************************************************
  1427.  * FUNCTION
  1428.  *  mmi_frm_sms_callback_abort_sms_by_end_key
  1429.  * DESCRIPTION
  1430.  *  Abort SMS by end key callback
  1431.  * PARAMETERS
  1432.  *  void
  1433.  * RETURNS
  1434.  *  void
  1435.  *****************************************************************************/
  1436. void mmi_frm_sms_callback_abort_sms_by_end_key(void)
  1437. {
  1438.     /*----------------------------------------------------------------*/
  1439.     /* Local Variables                                                */
  1440.     /*----------------------------------------------------------------*/
  1441.     U8 *number = OslMalloc(MAX_DIGITS_SMS);
  1442.     /*----------------------------------------------------------------*/
  1443.     /* Code Body                                                      */
  1444.     /*----------------------------------------------------------------*/
  1445.     memset((S8*) number, 0, MAX_DIGITS_SMS);
  1446.     memcpy((S8*) number, (S8*) sendSMS->number, MAX_DIGITS_SMS);
  1447.     mmi_frm_sms_callback_action(number, MMI_FRM_SMS_END_FROM_SENDING);
  1448.     OslMfree(number);
  1449. }
  1450. /*****************************************************************************
  1451.  * FUNCTION
  1452.  *  mmi_frm_sms_abort_sms_by_end_key_rsp
  1453.  * DESCRIPTION
  1454.  *  Abort SMS by end key response
  1455.  * PARAMETERS
  1456.  *  inMsg       [IN]        Input message
  1457.  * RETURNS
  1458.  *  void
  1459.  *****************************************************************************/
  1460. void mmi_frm_sms_abort_sms_by_end_key_rsp(void *inMsg)
  1461. {
  1462.     /*----------------------------------------------------------------*/
  1463.     /* Local Variables                                                */
  1464.     /*----------------------------------------------------------------*/
  1465.     /*----------------------------------------------------------------*/
  1466.     /* Code Body                                                      */
  1467.     /*----------------------------------------------------------------*/
  1468.     /* MMI_FRM_SMS_SEND_ABORT_FINISH_IND_STRUCT *msgRsp = (MMI_FRM_SMS_SEND_ABORT_FINISH_IND_STRUCT*)inMsg; */
  1469.     g_frm_sms_cntx.is_aborting = MMI_FALSE;
  1470.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND);
  1471.     mmi_frm_sms_free_sendsms_data();
  1472. }
  1473. /*****************************************************************************
  1474.  * FUNCTION
  1475.  *  mmi_frm_sms_abort_sms_req_by_end_key
  1476.  * DESCRIPTION
  1477.  *  Abort SMS request without processing screen
  1478.  * PARAMETERS
  1479.  *  inMsg       [IN]        Input message
  1480.  * RETURNS
  1481.  *  void
  1482.  *****************************************************************************/
  1483. void mmi_frm_sms_abort_sms_req_by_end_key(void *inMsg)
  1484. {
  1485.     /*----------------------------------------------------------------*/
  1486.     /* Local Variables                                                */
  1487.     /*----------------------------------------------------------------*/
  1488.     /*----------------------------------------------------------------*/
  1489.     /* Code Body                                                      */
  1490.     /*----------------------------------------------------------------*/
  1491.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_MSG_RSP);
  1492.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_START_IND);
  1493.     SetProtocolEventHandler(mmi_frm_sms_abort_sms_by_end_key_rsp, PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND);
  1494.     g_frm_sms_cntx.is_aborting = MMI_TRUE;
  1495.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_ABORT_REQ, NULL, NULL);
  1496. }
  1497. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1498. /*****************************************************************************
  1499.  * FUNCTION
  1500.  *  mmi_frm_sms_abort_sms_callback
  1501.  * DESCRIPTION
  1502.  *  Abort SMS callback
  1503.  * PARAMETERS
  1504.  *  void
  1505.  * RETURNS
  1506.  *  void
  1507.  *****************************************************************************/
  1508. void mmi_frm_sms_abort_sms_callback(void)
  1509. {
  1510.     /*----------------------------------------------------------------*/
  1511.     /* Local Variables                                                */
  1512.     /*----------------------------------------------------------------*/
  1513.     /*----------------------------------------------------------------*/
  1514.     /* Code Body                                                      */
  1515.     /*----------------------------------------------------------------*/
  1516.     g_frm_sms_cntx.is_aborting = MMI_FALSE;
  1517.     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ABORT);
  1518.     mmi_frm_sms_free_sendsms_data();
  1519. }
  1520. /*****************************************************************************
  1521.  * FUNCTION
  1522.  *  mmi_frm_sms_abort_sms_dummy_rsp
  1523.  * DESCRIPTION
  1524.  *  Abort SMS dummy response
  1525.  * PARAMETERS
  1526.  *  inMsg       [IN]        Input message
  1527.  * RETURNS
  1528.  *  void
  1529.  *****************************************************************************/
  1530. void mmi_frm_sms_abort_sms_dummy_rsp(void *inMsg)
  1531. {
  1532.     /*----------------------------------------------------------------*/
  1533.     /* Local Variables                                                */
  1534.     /*----------------------------------------------------------------*/
  1535.     /*----------------------------------------------------------------*/
  1536.     /* Code Body                                                      */
  1537.     /*----------------------------------------------------------------*/
  1538.     /* MMI_FRM_SMS_SEND_ABORT_FINISH_IND_STRUCT *msgRsp = (MMI_FRM_SMS_SEND_ABORT_FINISH_IND_STRUCT*)inMsg; */
  1539.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND);
  1540.     g_frm_sms_cntx.is_aborting = MMI_FALSE;
  1541. }
  1542. /*****************************************************************************
  1543.  * FUNCTION
  1544.  *  mmi_frm_sms_abort_sending_sms_req
  1545.  * DESCRIPTION
  1546.  *  Abort Sending SMS request
  1547.  * PARAMETERS
  1548.  *  void
  1549.  * RETURNS
  1550.  *  void
  1551.  *****************************************************************************/
  1552. void mmi_frm_sms_abort_sending_sms_req(mmi_frm_sms_abort_enum type)
  1553. {
  1554.     /*----------------------------------------------------------------*/
  1555.     /* Local Variables                                                */
  1556.     /*----------------------------------------------------------------*/
  1557.     /*----------------------------------------------------------------*/
  1558.     /* Code Body                                                      */
  1559.     /*----------------------------------------------------------------*/
  1560.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_MSG_RSP);
  1561.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_START_IND);
  1562.     
  1563.     g_frm_sms_cntx.is_aborting = MMI_TRUE;
  1564.     if (type == MMI_FRM_SMS_ABORT_WITH_FINISH_IND)
  1565.     {
  1566.         SetProtocolEventHandler(mmi_frm_sms_abort_sms_rsp, PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND);
  1567.         mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_ABORT_REQ, NULL, NULL);
  1568.     }
  1569.     else if (type == MMI_FRM_SMS_ABORT_WITHOUT_FINISH_IND)
  1570.     {
  1571.         SetProtocolEventHandler(mmi_frm_sms_abort_sms_dummy_rsp, PRT_MSG_ID_MMI_SMS_SEND_ABORT_FINISH_IND); 
  1572.         mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_ABORT_REQ, NULL, NULL);
  1573.         mmi_frm_sms_abort_sms_callback();
  1574.     }
  1575.     else
  1576.     {
  1577.         MMI_ASSERT(0);
  1578.     }        
  1579. }
  1580. /* loop handle */
  1581. /*****************************************************************************
  1582.  * FUNCTION
  1583.  *  mmi_frm_sms_send_sms_rsp
  1584.  * DESCRIPTION
  1585.  *  Send SMS response
  1586.  * PARAMETERS
  1587.  *  inMsg       [IN]        Input message
  1588.  * RETURNS
  1589.  *  void
  1590.  *****************************************************************************/
  1591. void mmi_frm_sms_send_sms_rsp(void *inMsg)
  1592. {
  1593.     /*----------------------------------------------------------------*/
  1594.     /* Local Variables                                                */
  1595.     /*----------------------------------------------------------------*/
  1596.     MMI_FRM_SMS_SEND_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SEND_MSG_RSP_STRUCT*) inMsg;
  1597.     /*----------------------------------------------------------------*/
  1598.     /* Code Body                                                      */
  1599.     /*----------------------------------------------------------------*/
  1600.     PendingSaveSendData.presentSegments--;
  1601.     if ((msgRsp->result) == TRUE)
  1602.     {
  1603.         CHISTIncSentSMS();
  1604.     }
  1605.     else
  1606.     {
  1607.         sendResult = MMI_FRM_SMS_ERROR;
  1608.     }
  1609. #ifdef __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__
  1610.     if (g_frm_sms_cntx.mmi_frm_sms_delivery_report_setting)
  1611.     {
  1612.         mmi_frm_sms_check_delivery_report_awaited(msgRsp);
  1613.     }
  1614. #endif /* __MMI_MESSAGES_SINGLE_DELIVERY_REPORT__ */ 
  1615.     /* send SMS: pack and send the following segment, inMsg keeps the sent index */
  1616.     if (PendingSaveSendData.nextSegment < PendingSaveSendData.totalSegments)
  1617.     {
  1618.         mmi_frm_sms_send_sms_seg();
  1619.     }
  1620.     if (PendingSaveSendData.presentSegments == 0)
  1621.     {
  1622.         /* not always; use a flag to check */
  1623.         U8 *number = OslMalloc(MAX_DIGITS_SMS);
  1624.         memset((S8*) number, 0, MAX_DIGITS_SMS);
  1625.         memcpy((S8*) number, (S8*) sendSMS->number, MAX_DIGITS_SMS);
  1626.         if (((sendSMS->sendrequire & MMI_FRM_SMS_SAVE) == 0) &&
  1627.             ((sendSMS->sendrequire & MMI_FRM_SMS_SAVE_AFTER_FAIL) == 0))
  1628.         {
  1629.             ReleaseEMSEditBuffer();
  1630.         }
  1631.         mmi_frm_sms_free_sendsms_data();
  1632.         ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_MSG_RSP);
  1633.         ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SEND_ABORT_START_IND);
  1634.         /* no more to send or send fail: returns the result */
  1635.         mmi_frm_sms_callback_action((void*)number, sendResult);
  1636.         OslMfree(number);
  1637.     }
  1638. }
  1639. extern void MoveCursorToPosition(EMSData *data, EMSPosition *dst);
  1640. /*****************************************************************************
  1641.  * FUNCTION
  1642.  *  mmi_frm_sms_pack_sms
  1643.  * DESCRIPTION
  1644.  *  Pack SMS before send/save
  1645.  * PARAMETERS
  1646.  *  void
  1647.  * RETURNS
  1648.  *  void
  1649.  *****************************************************************************/
  1650. U16 mmi_frm_sms_pack_sms(void)
  1651. {
  1652.     /*----------------------------------------------------------------*/
  1653.     /* Local Variables                                                */
  1654.     /*----------------------------------------------------------------*/
  1655.     EMSData *pEMS = GetEMSDataForEdit(0, 0);
  1656.     EMSPosition SavedPosition = pEMS->CurrentPosition;
  1657.     U16 i;
  1658.     U16 result;
  1659.     /*----------------------------------------------------------------*/
  1660.     /* Code Body                                                      */
  1661.     /*----------------------------------------------------------------*/
  1662.     memset(PendingSaveSendData.TPUD, 0, sizeof(PendingSaveSendData.TPUD));
  1663. #if defined(MMI_ON_WIN32) && ( defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1664.     g_frm_sms_cntx.mmi_frm_sms_msg_seg_size = 4;
  1665. #endif /* defined(MMI_ON_WIN32) && ( defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  1666.     for (i = 0; i < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size; i++)
  1667.     {
  1668.         PendingSaveSendData.TPUD_udhi[i] = 0;
  1669.         PendingSaveSendData.TPUDLen[i] = 0;
  1670.         PendingSaveSendData.TPUD_p[i] = &PendingSaveSendData.TPUD[i * MMI_FRM_SMS_MSG_LEN];
  1671.     }
  1672.     if (pEMS->dcs == SMSAL_DEFAULT_DCS || pEMS->dcs == SMSAL_UCS2_DCS)
  1673.     {
  1674.     #ifdef MMI_ON_HARDWARE_P
  1675.         if (check_sim_card_status() == TEST_SIM_PRESENCE)
  1676.         {
  1677.             EMS_ConvertAsciiEncodingToGSM7BitDefault(pEMS);
  1678.         }
  1679.         else
  1680.     #endif /* MMI_ON_HARDWARE_P */ 
  1681.             EMS_ConvertAsciiEncodingToGSM7BitDefaultWithExtended(pEMS);
  1682.     }
  1683.     result = EMSPack(
  1684.                 pEMS,
  1685.                 1,
  1686.                 &PendingSaveSendData.totalSegments,
  1687.                 PendingSaveSendData.TPUD_p,
  1688.                 PendingSaveSendData.TPUDLen);
  1689.     if (pEMS->dcs == SMSAL_DEFAULT_DCS || pEMS->dcs == SMSAL_UCS2_DCS)
  1690.     {
  1691.     #ifdef MMI_ON_HARDWARE_P
  1692.         if (check_sim_card_status() == TEST_SIM_PRESENCE)
  1693.         {
  1694.             EMS_ConvertGSM7BitDefaultEncodingToAscii(pEMS);
  1695.         }
  1696.         else
  1697.     #endif /* MMI_ON_HARDWARE_P */ 
  1698.             EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended(pEMS);
  1699.     }
  1700.     MoveCursorToPosition(pEMS, &SavedPosition);
  1701.     if (sendSMS != NULL)    /* in sending procedure */
  1702.     {
  1703.         PendingSaveSendData.phNumber = (S8*) sendSMS->number;
  1704.     }
  1705.     else if (saveSMS != NULL)   /* in saving procedure */
  1706.     {
  1707.         PendingSaveSendData.phNumber = (S8*) saveSMS->number;
  1708.     }
  1709.     else
  1710.     {
  1711.         MMI_ASSERT(sendSMS != NULL || saveSMS != NULL);
  1712.     }
  1713.     PendingSaveSendData.udhi = pEMS->udhi;
  1714.     PendingSaveSendData.dcs = pEMS->ps_dcs;
  1715.     return result;
  1716. }
  1717. /*****************************************************************************
  1718.  * FUNCTION
  1719.  *  mmi_frm_sms_unpack_sms
  1720.  * DESCRIPTION
  1721.  *  Unpack SMS after read/receive
  1722.  * PARAMETERS
  1723.  *  dcs     [IN]        Dcs
  1724.  *  fo      [IN]        Fo
  1725.  * RETURNS
  1726.  *  void
  1727.  *****************************************************************************/
  1728. void mmi_frm_sms_unpack_sms(U8 dcs, U8 fo, U8 ori_dcs)
  1729. {
  1730.     /*----------------------------------------------------------------*/
  1731.     /* Local Variables                                                */
  1732.     /*----------------------------------------------------------------*/
  1733.     U8 i = 0;
  1734.     EMSData *pEMSdata;
  1735.     U8 UDHI;
  1736.     /*----------------------------------------------------------------*/
  1737.     /* Code Body                                                      */
  1738.     /*----------------------------------------------------------------*/
  1739. #ifdef __MMI_MESSAGES_USE_URL__
  1740.     GetEMSDataForView(&pEMSdata, 0);
  1741.     memset(pEMSdata->textBuffer, 0x00, pEMSdata->textLength);   /* Remove previous message content */
  1742. #endif /* __MMI_MESSAGES_USE_URL__ */ 
  1743.     GetEMSDataForView(&pEMSdata, 1);
  1744.     if (PendingSaveSendData.totalSegments == 1)
  1745.     {
  1746.         UDHI = GetUDHIBit(fo);
  1747.     }
  1748.     else
  1749.     {
  1750.         UDHI = KAL_TRUE;
  1751.         for (i = 0; i < PendingSaveSendData.totalSegments; i++)
  1752.         {
  1753.             if (PendingSaveSendData.TPUD_udhi[i] == KAL_FALSE)
  1754.             {
  1755.                 PendingSaveSendData.TPUD_p[i] = NULL;
  1756.             }
  1757.         }
  1758.     }
  1759.     if ((EMSSetDCS(pEMSdata, dcs) == EMS_OK) &&        
  1760.         (EMSUnPack(pEMSdata, UDHI, PendingSaveSendData.totalSegments, PendingSaveSendData.TPUD_p,
  1761.           PendingSaveSendData.TPUDLen) == EMS_OK) &&
  1762.         (EMSSetOriDCS(pEMSdata, ori_dcs) == EMS_OK))
  1763.     {
  1764.     }
  1765.     else
  1766.     {
  1767.         GetEMSDataForView(&pEMSdata, 1);
  1768.         if (PendingSaveSendData.totalSegments == 1)
  1769.         {
  1770.             UDHI = KAL_FALSE;
  1771.         }
  1772.         else
  1773.         {
  1774.             UDHI = KAL_TRUE;
  1775.         }
  1776.         for (i = 0; i < PendingSaveSendData.totalSegments; i++)
  1777.         {
  1778.             PendingSaveSendData.TPUD_p[i] = NULL;
  1779.             PendingSaveSendData.TPUDLen[i] = 0;
  1780.         }
  1781.         EMSSetDCS(pEMSdata, SMSAL_DEFAULT_DCS);
  1782.         EMSUnPack(
  1783.             pEMSdata,
  1784.             UDHI,
  1785.             PendingSaveSendData.totalSegments,
  1786.             PendingSaveSendData.TPUD_p,
  1787.             PendingSaveSendData.TPUDLen);
  1788.     }
  1789.     if (pEMSdata->dcs == SMSAL_DEFAULT_DCS || pEMSdata->dcs == SMSAL_UCS2_DCS)
  1790.     {
  1791.     #ifdef MMI_ON_HARDWARE_P
  1792.         if (check_sim_card_status() == TEST_SIM_PRESENCE)
  1793.         {
  1794.             EMS_ConvertGSM7BitDefaultEncodingToAscii(pEMSdata);
  1795.         }
  1796.         else
  1797.     #endif /* MMI_ON_HARDWARE_P */ 
  1798.             EMS_ConvertGSM7BitDefaultEncodingToAsciiWithExtended(pEMSdata);
  1799.     }
  1800. }
  1801. /*****************************************************************************
  1802.  * FUNCTION
  1803.  *  mmi_frm_sms_send_sms_seg
  1804.  * DESCRIPTION
  1805.  *  Send SMS segment
  1806.  * PARAMETERS
  1807.  *  void
  1808.  * RETURNS
  1809.  *  void
  1810.  *****************************************************************************/
  1811. void mmi_frm_sms_send_sms_seg(void)
  1812. {
  1813.     /*----------------------------------------------------------------*/
  1814.     /* Local Variables                                                */
  1815.     /*----------------------------------------------------------------*/
  1816.     MMI_FRM_SMS_SEND_MSG_REQ_STRUCT *sendSms;
  1817.     S8 *addr = (S8*) sendSMS->number;
  1818.     /*----------------------------------------------------------------*/
  1819.     /* Code Body                                                      */
  1820.     /*----------------------------------------------------------------*/
  1821.     sendSms = (MMI_FRM_SMS_SEND_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*sendSms));
  1822.     sendSms->dcs = PendingSaveSendData.dcs;
  1823.     sendSms->udhi = PendingSaveSendData.udhi;
  1824.     sendSms->length = PendingSaveSendData.TPUDLen[PendingSaveSendData.nextSegment];
  1825.     memset(sendSms->msg, 0, SMSAL_MAX_MSG_LEN);
  1826. //KP Jerry add for third sevice on 2007-03-26 start
  1827. #ifdef __KONG_NET_SP__
  1828.        if(pfnUnicodeStrlen(g_msg_cntx.dfmsg)>0)
  1829. {
  1830. UnicodeToAnsii((S8*)sendSms->msg, (S8*)g_msg_cntx.dfmsg);
  1831.        sendSms->msg[(U8)pfnUnicodeStrlen(g_msg_cntx.dfmsg)] = '';
  1832. sendSms->length = pfnUnicodeStrlen(g_msg_cntx.dfmsg);
  1833. memset(g_msg_cntx.dfmsg,0,sizeof(g_msg_cntx.dfmsg)); 
  1834. }
  1835. else
  1836. #endif
  1837. //KP Jerry add for third sevice on 2007-03-26 end
  1838.     memcpy(
  1839.         sendSms->msg,
  1840.         PendingSaveSendData.TPUD_p[PendingSaveSendData.nextSegment],
  1841.         PendingSaveSendData.TPUDLen[PendingSaveSendData.nextSegment]);
  1842.     sendSms->profile = sendSMS->profile;
  1843.     sendSms->para = 0;
  1844.     sendSms->reply_index = MMI_FRM_SMS_INVALID_INDEX;
  1845.     if ((sendSMS->sendrequire & MMI_FRM_SMS_REPLY) == MMI_FRM_SMS_REPLY)
  1846.     {
  1847.         U8 *replyaddr = mmi_frm_sms_get_sms_address(MMI_FRM_SMS_INBOX, sendSMS->replyindex);
  1848.         U16 l4_index[MMI_SMS_MAX_MSG_SEG];
  1849.         U8 i = 0;
  1850.         memset((S8*) sendSMS->number, 0, MAX_DIGITS_SMS);
  1851.         memcpy((S8*) sendSMS->number, (S8*) replyaddr, strlen((S8*) replyaddr));
  1852.         mmi_frm_sms_get_sms_index(MMI_FRM_SMS_INBOX, sendSMS->replyindex, l4_index);
  1853.         while (i < g_frm_sms_cntx.mmi_frm_sms_msg_seg_size)
  1854.         {
  1855.             if (l4_index[i] != MMI_FRM_SMS_INVALID_INDEX)
  1856.             {
  1857.                 sendSms->reply_index = l4_index[i];
  1858.                 break;
  1859.             }
  1860.             i++;
  1861.         }
  1862.     }
  1863.     if (sendSMS->number[0] == '+')
  1864.     {
  1865.         sendSms->dest.type = CSMCC_INTERNATIONAL_ADDR;
  1866.         addr++;
  1867.     }
  1868.     else
  1869.     {
  1870.         sendSms->dest.type = CSMCC_DEFAULT_ADDR_TYPE;
  1871.     }
  1872.     memset((S8*) sendSms->dest.number, 0, MAX_CC_ADDR_LEN);
  1873.     memcpy((S8*) sendSms->dest.number, (S8*) addr, strlen((S8*) addr));
  1874.     sendSms->dest.length = strlen((S8*) addr);
  1875.     sendSms->seq_num = PendingSaveSendData.nextSegment;
  1876.     /* set  to 0 only in the last segment of the last message */
  1877.     if (((PendingSaveSendData.nextSegment + 1) < PendingSaveSendData.totalSegments) ||
  1878.         ((g_msg_cntx.msg_send_info.CurrSendSmsNumbers + 1) < g_msg_cntx.msg_send_info.TotalSendSmsNumbers))
  1879.     {
  1880.         sendSms->mms_mode = 1;
  1881.     }
  1882.     else
  1883.     {
  1884.         sendSms->mms_mode = 0;
  1885.     }
  1886.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_SEND_MSG_REQ, (oslParaType*) sendSms, NULL);
  1887.     PendingSaveSendData.nextSegment++;
  1888.     PendingSaveSendData.presentSegments++;
  1889. }
  1890. /*****************************************************************************
  1891.  * FUNCTION
  1892.  *  mmi_frm_sms_pre_send_sms
  1893.  * DESCRIPTION
  1894.  *  Pre-send SMS: copy useful data and set flags
  1895.  * PARAMETERS
  1896.  *  inMsg       [IN]        Input message
  1897.  * RETURNS
  1898.  *  void
  1899.  *****************************************************************************/
  1900. void mmi_frm_sms_pre_send_sms(void *inMsg)
  1901. {
  1902.     /*----------------------------------------------------------------*/
  1903.     /* Local Variables                                                */
  1904.     /*----------------------------------------------------------------*/
  1905.     mmi_frm_sms_send_struct *sendData = (mmi_frm_sms_send_struct*) inMsg;
  1906.     /*----------------------------------------------------------------*/
  1907.     /* Code Body                                                      */
  1908.     /*----------------------------------------------------------------*/
  1909. #if defined(MMI_ON_WIN32) && (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1910.     g_frm_sms_cntx.mmi_frm_sms_ready = 1;   /* Just for testing */
  1911. #endif 
  1912.     if (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) == MMI_FRM_SMS_INVALID_INDEX ||
  1913.         g_frm_sms_cntx.is_aborting )/* The response of the abort is not received. */
  1914.     {
  1915.         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_NOTREADY);
  1916.         if (sendData->string != NULL)
  1917.         {
  1918.             OslMfree(sendData->string);
  1919.             sendData->string = NULL;
  1920.         }
  1921.         OslMfree(sendData);
  1922.         return;
  1923.     }
  1924.     mmi_frm_sms_free_sendsms_data();
  1925.     sendSMS = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  1926.     memcpy((S8*) sendSMS, (S8*) sendData, sizeof(mmi_frm_sms_send_struct));
  1927.     OslMfree(sendData);
  1928.     mmi_frm_sms_send_sms_req();
  1929. }
  1930. /*****************************************************************************
  1931.  * FUNCTION
  1932.  *  mmi_frm_sms_entry_number_done
  1933.  * DESCRIPTION
  1934.  *  After input number, keep send process
  1935.  * PARAMETERS
  1936.  *  void
  1937.  * RETURNS
  1938.  *  void
  1939.  *****************************************************************************/
  1940. void mmi_frm_sms_entry_number_done(void)
  1941. {
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Local Variables                                                */
  1944.     /*----------------------------------------------------------------*/
  1945.     U8 len = 0;
  1946.     /*----------------------------------------------------------------*/
  1947.     /* Code Body                                                      */
  1948.     /*----------------------------------------------------------------*/
  1949.     UnicodeToAnsii((S8*) sendSMS->number, (S8*) g_frm_sms_cntx.mmi_frm_sms_number);
  1950.     len = strlen((S8*) sendSMS->number) <
  1951.         sizeof(sendSMS->number) ? strlen((S8*) sendSMS->number) : sizeof(sendSMS->number);
  1952.     if (len == 0)
  1953.     {
  1954.         DisplayPopup(
  1955.             (PU8) GetString(STR_SMS_NUM_CANNOT_BE_EMPTY),
  1956.             IMG_GLOBAL_UNFINISHED,
  1957.             1,
  1958.             MESSAGES_POPUP_TIME_OUT,
  1959.             (U8) ERROR_TONE);
  1960.     }
  1961.     else if (mmi_frm_sms_check_dst_number(sendSMS->number, len) == KAL_FALSE)
  1962.     {
  1963.         DisplayPopup(
  1964.             (PU8) GetString(STR_ID_PHB_NUM_INVALID),
  1965.             IMG_GLOBAL_UNFINISHED,
  1966.             1,
  1967.             MESSAGES_POPUP_TIME_OUT,
  1968.             (U8) ERROR_TONE);
  1969.     }
  1970.     else
  1971.     {
  1972.         mmi_frm_sms_send_sms_req();
  1973.     }
  1974. }
  1975. extern EMSTATUS EMSSetMsgClass(EMSData *emsData, kal_uint8 msg_class);
  1976. /*****************************************************************************
  1977.  * FUNCTION
  1978.  *  mmi_frm_sms_send_sms_req
  1979.  * DESCRIPTION
  1980.  *  Send SMS request: check sc, number and copy content for send
  1981.  * PARAMETERS
  1982.  *  void
  1983.  * RETURNS
  1984.  *  void
  1985.  *****************************************************************************/
  1986. void mmi_frm_sms_send_sms_req(void)
  1987. {
  1988.     /*----------------------------------------------------------------*/
  1989.     /* Local Variables                                                */
  1990.     /*----------------------------------------------------------------*/
  1991.     /* MOD_MMI only, other module skips */
  1992.     EMSData *pEMS;
  1993.     U8 i, j;
  1994.     /*----------------------------------------------------------------*/
  1995.     /* Code Body                                                      */
  1996.     /*----------------------------------------------------------------*/
  1997. #if defined(MMI_ON_WIN32) && (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1998.     sendSMS->sendcheck = 1;
  1999. #endif 
  2000.     /* check SC: get SC address, inMsg keeps the flag */
  2001.     if ((sendSMS->sendcheck & MMI_FRM_SMS_SC) != MMI_FRM_SMS_SC)
  2002.     {
  2003.         S16 errorCode = 0;
  2004.         S8 nvramActiveProfileIndex = 0;
  2005.         ReadValue(NVRAM_SMS_ACTIVE_PROFILE_INDEX, &nvramActiveProfileIndex, DS_BYTE, &errorCode);
  2006.         mmi_frm_sms_get_sc_addr_req(&nvramActiveProfileIndex);
  2007.         sendSMS->profile = nvramActiveProfileIndex;
  2008.         return;
  2009.     }
  2010.     /* check DA: show input screen, inMsg keeps the number */
  2011.     if ((sendSMS->sendcheck & MMI_FRM_SMS_DA) != MMI_FRM_SMS_DA)
  2012.     {
  2013.         memset((S8*) g_frm_sms_cntx.mmi_frm_sms_number, 0, MAX_DIGITS_SMS);
  2014.         if ((sendSMS->sendrequire & MMI_FRM_SMS_NUM_SCR) == MMI_FRM_SMS_NUM_SCR)
  2015.         {
  2016.             AnsiiToUnicodeString((S8*) g_frm_sms_cntx.mmi_frm_sms_number, (S8*) sendSMS->number);
  2017.             mmi_frm_sms_entry_number();
  2018.             sendSMS->sendrequire &= ~MMI_FRM_SMS_NUM_SCR;
  2019.             return;
  2020.         }
  2021.         else if ((strlen((S8*) sendSMS->number) == 0) && ((sendSMS->sendrequire & MMI_FRM_SMS_REPLY) == 0))
  2022.         {
  2023.             if (GetCurrScrnId() != SCR_ID_MSG_NUMBER)
  2024.             {
  2025.                 mmi_frm_sms_entry_number();
  2026.             }
  2027.             return;
  2028.         }
  2029.         sendSMS->sendcheck |= MMI_FRM_SMS_DA;
  2030.     }
  2031.     /* check validity of DA */
  2032.     {
  2033.         U8 len = strlen((S8*) sendSMS->number) <
  2034.             sizeof(sendSMS->number) ? strlen((S8*) sendSMS->number) : sizeof(sendSMS->number);
  2035.         /* some digit is not numeric */
  2036.         if (mmi_frm_sms_check_dst_number(sendSMS->number, len) == KAL_FALSE)
  2037.         {
  2038.             mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_NUMINVALID);
  2039.             mmi_frm_sms_free_sendsms_data();
  2040.             return;
  2041.         }
  2042.     }
  2043.     /* check FDL: when FDN on */
  2044. #ifdef _CHECK_FDL_BY_MMI_
  2045.     if ((sendSMS->sendcheck & MMI_FRM_SMS_FDL) != MMI_FRM_SMS_FDL)
  2046.     {
  2047.         if (gSecuritySetupContext.FdlStatus)
  2048.         {
  2049.             U8 *msg = OslMalloc(strlen((S8*) sendSMS->number));
  2050.             memcpy((S8*) msg, (S8*) sendSMS->number, strlen((S8*) sendSMS->number));
  2051.             mmi_frm_sms_check_fdl_req(msg);
  2052.             return;
  2053.         }
  2054.         sendSMS->sendcheck |= MMI_FRM_SMS_FDL;
  2055.     }
  2056. #endif /* _CHECK_FDL_BY_MMI_ */ 
  2057.     {
  2058.         S8 *textbuf = NULL;
  2059.         S8 *textbufucs2 = NULL;
  2060.         U16 textlen = 0;
  2061.         U16 result = 0;
  2062.         history temphistory;
  2063.         if (sendSMS->filename != NULL)
  2064.         {
  2065.             S32 errorCode = 0;
  2066.             FILE_HANDLE emsObjectFilePtr;
  2067.             emsObjectFilePtr = pfopen((U8*) sendSMS->filename, PFS_READ);
  2068.             /* the file exists without error */
  2069.             if (!pfOpenError(emsObjectFilePtr))
  2070.             {
  2071.                 textlen = (U16) GetFSFileSize(emsObjectFilePtr);
  2072.                 /* the file size is 0 */
  2073.                 if (textlen == 0)
  2074.                 {
  2075.                     pfclose(emsObjectFilePtr);
  2076.                     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEMPTY);
  2077.                     mmi_frm_sms_free_sendsms_data();
  2078.                     return;
  2079.                 }
  2080.                 if (sendSMS->dcs == SMSAL_8BIT_DCS)
  2081.                 {
  2082.                     /* the file is too large. */
  2083.                     if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG) ||
  2084.                         textlen > ((MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE / ENCODING_LENGTH) - 1))
  2085.                     {
  2086.                         pfclose(emsObjectFilePtr);
  2087.                         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
  2088.                         mmi_frm_sms_free_sendsms_data();
  2089.                         return;
  2090.                     }
  2091.                     /* the file size is allowed */
  2092.                     textbuf = OslMalloc(textlen + 1);
  2093.                     pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
  2094.                     pfclose(emsObjectFilePtr);
  2095.                     /* the file content is corrupted */
  2096.                     if (pfError(errorCode))
  2097.                     {
  2098.                         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  2099.                         OslMfree(textbuf);
  2100.                         mmi_frm_sms_free_sendsms_data();
  2101.                         return;
  2102.                     }
  2103.                     /* the file content is allowed */
  2104.                     textbufucs2 = OslMalloc((textlen + 1) * ENCODING_LENGTH);
  2105.                     AnsiiNToUnicodeString(textbufucs2, textbuf, textlen);
  2106.                     memset(textbufucs2 + textlen * ENCODING_LENGTH, 0, ENCODING_LENGTH);
  2107.                     OslMfree(textbuf);
  2108.                 }
  2109.                 /* UCS2 and  DEFAULT DCS */
  2110.                 else
  2111.                 {
  2112.                     /* the file is too large. */
  2113.                     if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG) ||
  2114.                         textlen > (MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE - ENCODING_LENGTH))
  2115.                     {
  2116.                         pfclose(emsObjectFilePtr);
  2117.                         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
  2118.                         mmi_frm_sms_free_sendsms_data();
  2119.                         return;
  2120.                     }
  2121.                     /* the file size is allowed */
  2122.                     textbuf = OslMalloc(textlen + ENCODING_LENGTH);
  2123.                     pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
  2124.                     pfclose(emsObjectFilePtr);
  2125.                     /* the file content is corrupted */
  2126.                     if (pfError(errorCode))
  2127.                     {
  2128.                         mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  2129.                         OslMfree(textbuf);
  2130.                         mmi_frm_sms_free_sendsms_data();
  2131.                         return;
  2132.                     }
  2133.                     /* the file content is allowed */
  2134.                     textbufucs2 = OslMalloc((textlen + ENCODING_LENGTH));
  2135.                     memset(textbufucs2, 0, (textlen + ENCODING_LENGTH));
  2136.                     memcpy(textbufucs2, textbuf, textlen);
  2137.                     OslMfree(textbuf);
  2138.                 }
  2139.             }
  2140.             else
  2141.             {
  2142.                 mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  2143.                 mmi_frm_sms_free_sendsms_data();
  2144.                 return;
  2145.             }
  2146.         }
  2147.         else if (sendSMS->string != NULL && sendSMS->stringlength > 0)
  2148.         {
  2149.             textbufucs2 = OslMalloc((sendSMS->stringlength) * ENCODING_LENGTH);
  2150.             memset((S8*) textbufucs2, 0, ((sendSMS->stringlength) * ENCODING_LENGTH));
  2151.             memcpy(textbufucs2, sendSMS->string, ((sendSMS->stringlength) * ENCODING_LENGTH));
  2152.         }
  2153.         if (textbufucs2)
  2154.         {
  2155.             EMSTATUS EMSSetPortResult = EMS_OK;
  2156.             EMSTATUS EMSSetClassResult = EMS_OK;
  2157.             ReleaseEMSEditBuffer();
  2158.             pEMS = GetEMSDataForEdit(0, 1);
  2159.         #ifdef MMI_ON_HARDWARE_P
  2160.             if ((sendSMS->sendrequire & MMI_FRM_SMS_PORT) == MMI_FRM_SMS_PORT)
  2161.             {
  2162.                 EMSSetPortResult = EMSSetPortNum(pEMS, sendSMS->srcport, sendSMS->desport);
  2163.             }
  2164.             if ((sendSMS->sendrequire & MMI_FRM_SMS_CLASS) == MMI_FRM_SMS_CLASS)
  2165.             {
  2166.                 EMSSetClassResult = EMSSetMsgClass(pEMS, sendSMS->dcs_class);
  2167.             }
  2168.             if ((EMSSetPortResult != EMS_OK) || (EMSSetClassResult != EMS_OK))
  2169.             {
  2170.                 mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_ERROR);
  2171.                 mmi_frm_sms_free_sendsms_data();
  2172.                 OslMfree(textbufucs2);
  2173.                 return;
  2174.             }
  2175.         #endif /* MMI_ON_HARDWARE_P */ 
  2176.             if (sendSMS->filename != NULL)
  2177.             {
  2178.                 result = AppendEMSString(
  2179.                             INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  2180.                             pEMS,
  2181.                             (U8*) textbufucs2,
  2182.                             sendSMS->dcs,
  2183.                             temphistory.guiBuffer);
  2184.             }
  2185.             else if (sendSMS->string != NULL)
  2186.             {
  2187.                 EMSSetDCS(pEMS, sendSMS->dcs);
  2188.                 result = AddString(pEMS, (U8*) textbufucs2, sendSMS->stringlength, NULL);
  2189.             }
  2190.             OslMfree(textbufucs2);
  2191.             if ((sendSMS->filename != NULL && result == 0) || (sendSMS->string != NULL && result != EMS_OK))
  2192.             {
  2193.                 mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
  2194.                 mmi_frm_sms_free_sendsms_data();
  2195.                 return;
  2196.             }
  2197.         }
  2198.         result = mmi_frm_sms_pack_sms();
  2199.         if (result != EMS_OK)
  2200.         {
  2201.             mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  2202.             mmi_frm_sms_free_sendsms_data();
  2203.             return;
  2204.         }
  2205.         SetProtocolEventHandler(mmi_frm_sms_send_sms_rsp, PRT_MSG_ID_MMI_SMS_SEND_MSG_RSP);
  2206.         SetProtocolEventHandler(mmi_frm_sms_abort_sms_ind, PRT_MSG_ID_MMI_SMS_SEND_ABORT_START_IND);
  2207.         if ((sendSMS->sendcheck & MMI_FRM_SMS_SCR) != MMI_FRM_SMS_SCR)
  2208.         {
  2209.             mmi_frm_sms_entry_send();
  2210.         }
  2211.         j = (PendingSaveSendData.totalSegments >= MMI_FRM_SMS_SEND_SEG) ? MMI_FRM_SMS_SEND_SEG : 1;
  2212.         PendingSaveSendData.nextSegment = 0;
  2213.         PendingSaveSendData.presentSegments = 0;
  2214.         sendResult = MMI_FRM_SMS_OK;
  2215.         for (i = 0; i < j; i++)
  2216.         {
  2217.             mmi_frm_sms_send_sms_seg();
  2218.         }
  2219.     }
  2220. }
  2221. extern U8 GetRefFromNVRAM(void);
  2222. /* loop handle */
  2223. /*****************************************************************************
  2224.  * FUNCTION
  2225.  *  mmi_frm_sms_save_sms_rsp
  2226.  * DESCRIPTION
  2227.  *  Save SMS response
  2228.  * PARAMETERS
  2229.  *  inMsg       [IN]        Input message
  2230.  * RETURNS
  2231.  *  void
  2232.  *****************************************************************************/
  2233. void mmi_frm_sms_save_sms_rsp(void *inMsg)
  2234. {
  2235.     /*----------------------------------------------------------------*/
  2236.     /* Local Variables                                                */
  2237.     /*----------------------------------------------------------------*/
  2238.     MMI_FRM_SMS_SET_MSG_RSP_STRUCT *msgRsp = (MMI_FRM_SMS_SET_MSG_RSP_STRUCT*) inMsg;
  2239.     U16 msgbox_index = 0;
  2240.     /*----------------------------------------------------------------*/
  2241.     /* Code Body                                                      */
  2242.     /*----------------------------------------------------------------*/
  2243.     ClearProtocolEventHandler(PRT_MSG_ID_MMI_SMS_SET_MSG_RSP);
  2244.     if (msgRsp->result == TRUE)
  2245.     {
  2246.         mmi_frm_sms_msgbox_struct *entry = OslMalloc(sizeof(mmi_frm_sms_msgbox_struct));
  2247.         U16 ref = (U16) GetRefFromNVRAM();
  2248.         memset((S8*) entry, 0, sizeof(mmi_frm_sms_msgbox_struct));
  2249.         ref = (ref > 0) ? (ref - 1) : MMI_FRM_SMS_INVALID_NUM;
  2250.         mmi_frm_sms_convert_mo_to_entry(
  2251.             saveSMS,
  2252.             entry,
  2253.             msgRsp->index,
  2254.             msgRsp->status,
  2255.             PendingSaveSendData.totalSegments,
  2256.             ref,
  2257.             msgRsp->storage_type,
  2258.             &sms_saved_time);
  2259.     #ifdef __MMI_UNIFIED_MESSAGE__
  2260.         /* Only save content for the first segment */
  2261.         if (PendingSaveSendData.nextSegment == 1)
  2262.         {
  2263.             U8 *content = OslMalloc(mmi_msg_get_max_content_size() * ENCODING_LENGTH);
  2264.             EMSData *pEMS = NULL;
  2265.             U32 content_size = 0;
  2266.             pEMS = GetEMSDataForEdit(0, 0);
  2267.             if (pEMS->dcs == SMSAL_UCS2_DCS)
  2268.             {
  2269.                 content_size =
  2270.                     ((mmi_msg_get_max_content_size() - 1) <
  2271.                      (pEMS->textLength / 2)) ? (mmi_msg_get_max_content_size() - 1) : (pEMS->textLength / 2);
  2272.                 memset(entry->content, 0, sizeof(entry->content));
  2273.                 memset(content, 0, mmi_msg_get_max_content_size() * ENCODING_LENGTH);
  2274.                 pfnUnicodeStrncpy((S8*) content, (S8*) pEMS->textBuffer, content_size);
  2275.             }
  2276.             else
  2277.             {
  2278.                 U32 handled_content_size = mmi_msg_get_max_content_size() * 2 * ENCODING_LENGTH;
  2279.                 U8 *handled_content = OslMalloc(handled_content_size);
  2280.                 U32 handled_content_len = 0;
  2281.                 U16 ori_content_size = 
  2282.                         ((mmi_msg_get_max_content_size() - 1) <
  2283.                          (pEMS->textLength / 2)) ? (mmi_msg_get_max_content_size() - 1) : (pEMS->textLength / 2);
  2284.                 memset(handled_content, 0, handled_content_size);
  2285.                 mmi_frm_sms_remove_escape_symbol_for_extension_char
  2286.                     ((U16*)handled_content, 
  2287.                      (U16*)pEMS->textBuffer, 
  2288.                      (U16) (ori_content_size));
  2289.                 handled_content_len = pfnUnicodeStrlen((S8*)handled_content);
  2290.                 content_size =
  2291.                     ((mmi_msg_get_max_content_size() - 1) <
  2292.                      (handled_content_len)) ? (mmi_msg_get_max_content_size() - 1) : (handled_content_len);
  2293.                 memset(entry->content, 0, sizeof(entry->content));
  2294.                 memset(content, 0, mmi_msg_get_max_content_size() * ENCODING_LENGTH);
  2295.                 pfnUnicodeStrncpy((S8*) content, (S8*) handled_content, content_size);                
  2296.             }
  2297.             if (pfnUnicodeStrlen((S8*) content))
  2298.             {
  2299.                 mmi_frm_sms_add_content_to_entry(entry, content);
  2300.             }
  2301.             OslMfree(content);
  2302.         }
  2303.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2304.         msgbox_index = mmi_frm_sms_add_sms_to_msgbox(entry, msgRsp->index, PendingSaveSendData.presentSegments);
  2305.         OslMfree(entry);
  2306.         if (PendingSaveSendData.nextSegment < PendingSaveSendData.totalSegments)
  2307.         {
  2308.             mmi_frm_sms_save_sms_seg();
  2309.         }
  2310.         else
  2311.         {
  2312.             ReleaseEMSEditBuffer();
  2313.         #ifdef __MMI_UNIFIED_MESSAGE__
  2314.             if (saveSMS->sendrequire & MMI_FRM_SMS_SAVE_MODIFY_HIGHLIGHT)
  2315.             {
  2316.                 U8 type;
  2317.                 U16 list_index;
  2318.                 BOOL msg_box_match = KAL_FALSE;
  2319.                 mmi_frm_sms_get_list_index(&type, &list_index, msgbox_index);
  2320.                 switch (type)
  2321.                 {
  2322.                     case MMI_FRM_SMS_INBOX:
  2323.                     {
  2324.                         if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_INBOX)
  2325.                         {
  2326.                             msg_box_match = KAL_TRUE;
  2327.                         }
  2328.                         break;
  2329.                     }
  2330.                     case MMI_FRM_SMS_OUTBOX:
  2331.                     {
  2332.                         if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_SENT)
  2333.                         {
  2334.                             msg_box_match = KAL_TRUE;
  2335.                         }
  2336.                         break;
  2337.                     }
  2338.                     case MMI_FRM_SMS_DRAFTS:
  2339.                     {
  2340.                         if (strlen((S8*) entry->number))
  2341.                         {
  2342.                             if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  2343.                             {
  2344.                                 msg_box_match = KAL_TRUE;
  2345.                             }
  2346.                         }
  2347.                         else
  2348.                         {
  2349.                             if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_DRAFT)
  2350.                             {
  2351.                                 msg_box_match = KAL_TRUE;
  2352.                             }
  2353.                         }
  2354.                         break;
  2355.                     }
  2356.                 }
  2357.                 if (msg_box_match)
  2358.                 {
  2359.                     if (list_index <= g_msg_cntx.currBoxIndex)
  2360.                     {
  2361.                         g_msg_cntx.currBoxIndex++;
  2362.                     }
  2363.                 }
  2364.             }
  2365.             if (saveSMS->sendrequire & MMI_FRM_SMS_SAVE_HIGHLIGHT_NEW_MSG_IND)
  2366.             {
  2367.                 mmi_frm_sms_highlight_ind(MMI_FRM_SMS_NOBOX, msgbox_index);
  2368.             }
  2369.             if (saveSMS->sendrequire & MMI_FRM_SMS_SAVE_HIGHLIGHT_ORIGINAL_MSG_IND)
  2370.             {
  2371.                 U8 type = mmi_um_get_current_msg_box_type();
  2372.                 switch (type)
  2373.                 {
  2374.                     case UM_MSG_BOX_TYPE_INBOX:
  2375.                     {
  2376.                         mmi_frm_sms_highlight_ind(MMI_FRM_SMS_INBOX, (U16)g_msg_cntx.currBoxIndex);
  2377.                         break;
  2378.                     }
  2379.                     case UM_MSG_BOX_TYPE_UNSENT:
  2380.                     {
  2381.                         mmi_frm_sms_highlight_ind(MMI_FRM_SMS_UNSENT, (U16)g_msg_cntx.currBoxIndex);
  2382.                         break;
  2383.                     }
  2384.                     case UM_MSG_BOX_TYPE_SENT:
  2385.                     {
  2386.                         mmi_frm_sms_highlight_ind(MMI_FRM_SMS_OUTBOX, (U16)g_msg_cntx.currBoxIndex);
  2387.                         break;
  2388.                     }
  2389.                     case UM_MSG_BOX_TYPE_DRAFT:
  2390.                     {
  2391.                         mmi_frm_sms_highlight_ind(MMI_FRM_SMS_DRAFTS, (U16)g_msg_cntx.currBoxIndex);
  2392.                         break;
  2393.                     }
  2394.                 }
  2395.             }
  2396.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2397.             /* no more to send or send fail: returns the result */
  2398.             mmi_frm_sms_callback_action(&(saveSMS->status), MMI_FRM_SMS_OK);
  2399.             mmi_frm_sms_free_savesms_data();
  2400.         }
  2401.     }
  2402.     else
  2403.     {
  2404.         mmi_frm_sms_callback_action(&(saveSMS->status), MMI_FRM_SMS_MEMFULL);
  2405.         mmi_frm_sms_free_savesms_data();
  2406.     }
  2407. }
  2408. /*****************************************************************************
  2409.  * FUNCTION
  2410.  *  mmi_frm_sms_save_sms_seg
  2411.  * DESCRIPTION
  2412.  *  Save SMS segment
  2413.  * PARAMETERS
  2414.  *  void
  2415.  * RETURNS
  2416.  *  void
  2417.  *****************************************************************************/
  2418. void mmi_frm_sms_save_sms_seg(void)
  2419. {
  2420.     /*----------------------------------------------------------------*/
  2421.     /* Local Variables                                                */
  2422.     /*----------------------------------------------------------------*/
  2423.     MMI_FRM_SMS_SET_MSG_REQ_STRUCT *saveSms;
  2424.     S8 *addr = (S8*) saveSMS->number;
  2425.     /*----------------------------------------------------------------*/
  2426.     /* Code Body                                                      */
  2427.     /*----------------------------------------------------------------*/
  2428.     saveSms = (MMI_FRM_SMS_SET_MSG_REQ_STRUCT*) OslConstructDataPtr(sizeof(*saveSms));
  2429.     /* memset((S8*)saveSms, 0, sizeof(MMI_FRM_SMS_SET_MSG_REQ_STRUCT)); */
  2430.     saveSms->status = saveSMS->status;
  2431.     if (addr[0] == '+')
  2432.     {
  2433.         saveSms->dest.type = CSMCC_INTERNATIONAL_ADDR;
  2434.         addr++;
  2435.     }
  2436.     else
  2437.     {
  2438.         saveSms->dest.type = CSMCC_DEFAULT_ADDR_TYPE;
  2439.     }
  2440.     memset((S8*) saveSms->dest.number, 0, MAX_CC_ADDR_LEN);
  2441.     memcpy((S8*) saveSms->dest.number, (S8*) addr, strlen((S8*) addr));
  2442.     saveSms->dest.length = strlen((S8*) addr);
  2443.     saveSms->profile = saveSMS->profile;    /* active profile number.. */
  2444.     saveSms->para = 0;
  2445.     saveSms->udhi = PendingSaveSendData.udhi;
  2446.     saveSms->dcs = PendingSaveSendData.dcs;
  2447.     saveSms->length = PendingSaveSendData.TPUDLen[PendingSaveSendData.nextSegment];
  2448.     saveSms->index = MMI_FRM_SMS_INVALID_INDEX;
  2449.     mmi_frm_sms_convert_mytime(saveSms->scts, &sms_saved_time);
  2450.     memset(saveSms->msg, 0, SMSAL_MAX_MSG_LEN);
  2451.     memcpy(
  2452.         saveSms->msg,
  2453.         PendingSaveSendData.TPUD_p[PendingSaveSendData.nextSegment],
  2454.         PendingSaveSendData.TPUDLen[PendingSaveSendData.nextSegment]);
  2455.     SetProtocolEventHandler(mmi_frm_sms_save_sms_rsp, PRT_MSG_ID_MMI_SMS_SET_MSG_RSP);
  2456.     mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_SET_MSG_REQ, (oslParaType*) saveSms, NULL);
  2457.     PendingSaveSendData.nextSegment++;
  2458.     PendingSaveSendData.presentSegments++;
  2459. }
  2460. /*****************************************************************************
  2461.  * FUNCTION
  2462.  *  mmi_frm_sms_save_sms_req
  2463.  * DESCRIPTION
  2464.  *  Save SMS request
  2465.  * PARAMETERS
  2466.  *  inMsg       [IN]        Input message
  2467.  * RETURNS
  2468.  *  void
  2469.  *****************************************************************************/
  2470. void mmi_frm_sms_save_sms_req(void *inMsg)
  2471. {
  2472.     /*----------------------------------------------------------------*/
  2473.     /* Local Variables                                                */
  2474.     /*----------------------------------------------------------------*/
  2475.     S8 *textbuf = NULL;
  2476.     S8 *textbufucs2 = NULL;
  2477.     U16 textlen = 0;
  2478.     U16 result = 0;
  2479.     history temphistory;
  2480.     EMSData *pEMS;
  2481.     /*----------------------------------------------------------------*/
  2482.     /* Code Body                                                      */
  2483.     /*----------------------------------------------------------------*/
  2484.     /* do not replace saveSMS by sendSMS because sendSMS structure may be cleared by abort rsp */
  2485.     mmi_frm_sms_free_savesms_data();
  2486.     saveSMS = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  2487.     memcpy((S8*) saveSMS, (S8*) inMsg, sizeof(mmi_frm_sms_send_struct));
  2488.     OslMfree(inMsg);
  2489.     if (saveSMS->filename != NULL)
  2490.     {
  2491.         S32 errorCode = 0;
  2492.         FILE_HANDLE emsObjectFilePtr;
  2493.         emsObjectFilePtr = pfopen((U8*) saveSMS->filename, PFS_READ);
  2494.         /* the file exists without error */
  2495.         if (!pfOpenError(emsObjectFilePtr))
  2496.         {
  2497.             textlen = (U16) GetFSFileSize(emsObjectFilePtr);
  2498.             /* the file size is 0 */
  2499.             if (textlen == 0)
  2500.             {
  2501.                 pfclose(emsObjectFilePtr);
  2502.                 mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEMPTY);
  2503.                 mmi_frm_sms_free_savesms_data();
  2504.                 return;
  2505.             }
  2506.             if (saveSMS->dcs == SMSAL_8BIT_DCS)
  2507.             {
  2508.                 /* the file is too large. */
  2509.                 if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG / ENCODING_LENGTH) ||
  2510.                     textlen > ((MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE / ENCODING_LENGTH) - 1))
  2511.                 {
  2512.                     pfclose(emsObjectFilePtr);
  2513.                     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
  2514.                     mmi_frm_sms_free_savesms_data();
  2515.                     return;
  2516.                 }
  2517.                 /* the file size is allowed */
  2518.                 textbuf = OslMalloc(textlen + 1);
  2519.                 pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
  2520.                 pfclose(emsObjectFilePtr);
  2521.                 /* the file content is corrupted */
  2522.                 if (pfError(errorCode))
  2523.                 {
  2524.                     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  2525.                     OslMfree(textbuf);
  2526.                     mmi_frm_sms_free_savesms_data();
  2527.                     return;
  2528.                 }
  2529.                 /* the file content is allowed */
  2530.                 textbufucs2 = OslMalloc((textlen + 1) * ENCODING_LENGTH);
  2531.                 AnsiiNToUnicodeString(textbufucs2, textbuf, textlen);
  2532.                 memset(textbufucs2 + textlen * ENCODING_LENGTH, 0, ENCODING_LENGTH);
  2533.                 OslMfree(textbuf);
  2534.             }
  2535.             /* UCS2 and  DEFAULT DCS */
  2536.             else
  2537.             {
  2538.                 /* the file is too large. */
  2539.                 if (textlen > (MMI_FRM_SMS_MSG_LEN * MMI_SMS_MAX_MSG_SEG) ||
  2540.                     textlen > (MMI_FRM_SMS_MAX_CONTROL_BUFFER_SIZE - ENCODING_LENGTH))
  2541.                 {
  2542.                     pfclose(emsObjectFilePtr);
  2543.                     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAEXCEED);
  2544.                     mmi_frm_sms_free_savesms_data();
  2545.                     return;
  2546.                 }
  2547.                 /* the file size is allowed */
  2548.                 textbuf = OslMalloc(textlen + ENCODING_LENGTH);
  2549.                 pfread(textbuf, 1, textlen, emsObjectFilePtr, &errorCode);
  2550.                 pfclose(emsObjectFilePtr);
  2551.                 /* the file content is corrupted */
  2552.                 if (pfError(errorCode))
  2553.                 {
  2554.                     mmi_frm_sms_callback_action(NULL, MMI_FRM_SMS_DATAINVALID);
  2555.                     OslMfree(textbuf);
  2556.                     mmi_frm_sms_free_savesms_data();
  2557.                     return;
  2558.                 }
  2559.                 /* the file content is allowed */
  2560.                 textbufucs2 = OslMalloc((textlen + ENCODING_LENGTH));
  2561.                 memset(textbufucs2, 0, (textlen + ENCODING_LENGTH));
  2562.                 memcpy(textbufucs2, textbuf, textlen);
  2563.                 OslMfree(textbuf);