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

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.  *
  37.  * Filename:
  38.  * ---------
  39.  * SmsPsHandler.C
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for MMI SMS APP.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  *
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  *
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  *
  243.  * removed!
  244.  * removed!
  245.  * removed!
  246.  *
  247.  * removed!
  248.  * removed!
  249.  * removed!
  250.  *
  251.  * removed!
  252.  * removed!
  253.  * removed!
  254.  *
  255.  * removed!
  256.  * removed!
  257.  * removed!
  258.  *
  259.  * removed!
  260.  * removed!
  261.  * removed!
  262.  *
  263.  * removed!
  264.  * removed!
  265.  * removed!
  266.  *
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  * removed!
  276.  * removed!
  277.  * removed!
  278.  *
  279.  * removed!
  280.  * removed!
  281.  * removed!
  282.  *
  283.  * removed!
  284.  * removed!
  285.  * removed!
  286.  *
  287.  * removed!
  288.  * removed!
  289.  * removed!
  290.  *
  291.  * removed!
  292.  * removed!
  293.  * removed!
  294.  *
  295.  * removed!
  296.  * removed!
  297.  * removed!
  298.  *
  299.  * removed!
  300.  * removed!
  301.  * removed!
  302.  *
  303.  * removed!
  304.  * removed!
  305.  * removed!
  306.  *
  307.  *------------------------------------------------------------------------------
  308.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  309.  *============================================================================
  310.  ****************************************************************************/
  311. /**
  312.  * Copyright Notice
  313.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  314.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  315.  *  (It is illegal to remove this copyright notice from this software or any
  316.  *  portion of it)
  317.  */
  318. /**************************************************************
  319.    FILENAME : SmsPsHandler.c
  320.    PURPOSE     : It handles protocol SMS messages. 
  321.    REMARKS     : nil
  322.    AUTHOR      : Magesh K, Hiran 
  323.    DATE     : 01-01-2003
  324. **************************************************************/
  325. #ifdef __MOD_SMSAL__
  326. //
  327. //MTK Joy added for FDN check, 1121, shall be removed
  328. //#define FDN_CHECK_TESTING
  329. //MTK end
  330. /*  */
  331. #include "MMI_features.h"
  332. #include "stdC.h"
  333. #include "L4Dr1.h"
  334. #include "PixtelDataTypes.h"
  335. /* ... Add More MMI header */
  336. #include "EventsGprot.h"
  337. #include "HistoryGprot.h"
  338. #include "GlobalMenuItems.h"
  339. #include "GlobalConstants.h"
  340. #include "Globaldefs.h"
  341. #include "wgui_categories.h"
  342. #include "CustMenuRes.h"
  343. #include "CommonScreens.h"
  344. #include "Unicodexdcl.h"
  345. #include "TimerEvents.h"
  346. #include "DebugInitDef.h"
  347. #include "ProtocolEvents.h"
  348. /* ...Add MSG header */
  349. #include "customer_ps_inc.h"
  350. #include "mmi_msg_context.h"
  351. #include "MessagesL4Def.h"
  352. #include "MessagesResourceData.h"
  353. #include "MessagesMiscell.h"
  354. #include "MessagesExDcl.h"
  355. #include "SmsGuiInterfaceProt.h"
  356. #include "SMsGuiInterfaceType.h"
  357. #include "SmsPsHandler.h"
  358. #include "CellBroadcastType.h"
  359. #ifdef __MMI_MESSAGES_CHAT__
  360. #include "ChatAppGprot.h"
  361. #include "ChatAppDef.h"
  362. #endif /* __MMI_MESSAGES_CHAT__ */ 
  363. /*  */
  364. #include "customer_ps_inc.h"
  365. #include "l4c2smsal_struct.h"
  366. #include "smsal_l4c_enum.h"
  367. #include "ems.h"
  368. /*  */
  369. #include "Gui_ems.h"
  370. #include "wgui_ems.h"
  371. #include "GSM7BitDefaultAlphabet.h"
  372. /*  */
  373. #include "gpioInc.h"
  374. #include "CallHistoryGProts.h"
  375. #include "CallManagementGprot.h"
  376. #include "CallStructureManagementProt.h"
  377. #include "IdleAppProt.h"
  378. #include "SettingProfile.h"
  379. #include "ProfileGprots.h"
  380. #include "AlarmFrameworkProt.h"
  381. #include "PhoneBookTypes.h"
  382. #include "PhoneBookDef.h"
  383. #include "SimDetectionGexdcl.h"
  384. #include "SettingDefs.h"
  385. #include "SettingsGdcl.h"
  386. /*  */
  387. #include "wgui_status_icons.h"
  388. #include "KeyBrd.h"
  389. #include "SMSApi.h"
  390. #include "SMSStruct.h"
  391. #include "SMSFunc.h"
  392. #ifdef __MMI_UNIFIED_MESSAGE__
  393. #include "UnifiedMessageDef.h"
  394. #include "UnifiedMessageGProt.h"
  395. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  396. #ifdef __MMI_UNIFIED_COMPOSER__
  397. #include "UnifiedComposerGProt.h"
  398. #endif /* __MMI_UNIFIED_COMPOSER__ */
  399. //KP Jerry add on 2007-4-26 start
  400. #if defined(__MMI_CM_BLACK_LIST__) && defined(__MMI_CM_WHITE_LIST__)
  401. #include "ManageCallMain.h"
  402. #endif
  403. //KP Jerry add on 2007-4-26 end
  404. //
  405. //
  406. #ifdef __MMI_OPERATOR_LOGO__
  407. extern void mmi_op_logo_parse_ota_data(void);
  408. #endif 
  409. #ifdef __MMI_CLI_ICON__
  410. extern void mmi_cli_icon_parse_ota_data(void);
  411. #endif 
  412. #ifdef __MMI_MESSAGES_CHAT__
  413. extern pBOOL gOutBoxSaveFlag;
  414. extern U16 gChatMsgFlag;    /* Added By Alok */
  415. #endif /* __MMI_MESSAGES_CHAT__ */ 
  416. extern msg_active_profile_struct activeProfile;
  417. extern U16 processRSKStrId;
  418. extern PS8 lookUpNumber(PS8 number);
  419. extern void MoveCursorToPosition(EMSData *data, EMSPosition *dst);
  420. extern void mmi_phb_sms_enter_send_by_group(void);
  421. extern U16 GetCmMarkerScrnID(void);
  422. extern MMI_PHB_LIST_VIEW phbListView;
  423. extern EMSData *GetEMSDataForView(EMSData **p, U8 force);
  424. extern EMSData *GetEMSDataForEdit(EMSData **p, U8 force);
  425. extern U8 DeInitMessagesEMSBuffer(msg_ems_data_struct *pE);
  426. #if defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  427. #include "PicMsgApiToOthers.h"
  428. extern U8 gNSMBuffer[];
  429. extern U8 gaddtext_buffer[];
  430. extern U8 gOTADataBuffer[];
  431. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  432. extern nsm_msg_struct g_nsm_msg_context;
  433. #endif 
  434. extern S8 g_pmsg_TextInMessage[];
  435. static U16 gMessageType = 0;    /*
  436.                                  * Flag to identify Message type
  437.                                  * * 0 - NORMAL MESSAGE
  438.                                  * * 1 - PICTURE MESSAGE
  439.                                  * * 2 - RINGTONE MESSAGE
  440.                                  */
  441. S32 mmi_nsm_send_pic_msg(U8 *bmpDataPtr, U8 *PicTextPtr, U8 **emsDataT);
  442. U8 mmi_nsm_prepare_msg(U8 *data, S32 data_len);
  443. U8 mmi_nsm_pack_and_send_msg(void);
  444. U16 StuffZerosInBetween(S8 *pOutBuffer, S8 *pInBuffer, U16 size);
  445. #define ASCIISEGMENTSIZE 252
  446. static void mmi_nsm_get_picmsg_sendData(mmi_frm_sms_send_struct *sendData);
  447. #endif /* defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  448. #if defined(__MMI_SMART_MESSAGE_MT__)
  449. static S32 ucs2_count = 0;  /* For Sending chinese character with pic msg */
  450. extern nsm_picmsg_text_struct picmsg_text_struct;
  451. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  452. /*******************************************************
  453.             protocol event handler           
  454. *******************************************************/
  455. extern msg_msgbox_info_struct msgbox_info;
  456. extern PendingSaveSendDataStruct PendingSaveSendData;
  457. extern void mmi_phb_sms_enter_send_entry(void);
  458. extern U8 mmi_phb_convert_to_digit(U8 *dest, U8 *source, U8 max_dest_len);
  459. #ifdef __MMI_MESSAGES_SEND_BY_GROUP__
  460. extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[];
  461. #endif /* ifdef __MMI_MESSAGES_SEND_BY_GROUP__ */
  462. extern U8 mmi_msg_get_seg_num(void);
  463. extern U16 mmi_msg_get_msgbox_size(void);
  464. /*****************************************************************************
  465.  * FUNCTION
  466.  *  mmi_msg_handle_ready_ind
  467.  * DESCRIPTION
  468.  *  
  469.  * PARAMETERS
  470.  *  dummy       [?]         
  471.  *  mod         [IN]        
  472.  *  result      [IN]        
  473.  * RETURNS
  474.  *  void
  475.  *****************************************************************************/
  476. void mmi_msg_handle_ready_ind(void *dummy, module_type mod, U16 result)
  477. {
  478.     /*----------------------------------------------------------------*/
  479.     /* Local Variables                                                */
  480.     /*----------------------------------------------------------------*/
  481.     U16 totalInbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
  482.     U16 totalOutbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_OUTBOX);
  483.     U16 totalDraftbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_DRAFTS);
  484.     /*----------------------------------------------------------------*/
  485.     /* Code Body                                                      */
  486.     /*----------------------------------------------------------------*/
  487.     g_msg_cntx.msg_init = TRUE;
  488.     mmi_msg_set_msg_num_hint(totalInbox, totalOutbox, totalDraftbox);
  489.     RefreshMessagesMenuList();
  490.     mmi_msg_set_msg_icon(FALSE, FALSE);
  491.     /* it is in the processing screen or the processing screen has been interrupted */
  492.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_PROCESSING || IsScreenPresent(SCR_ID_MSG_PROCESSING))
  493.     {
  494.         if (processRSKStrId == STR_LOADING_INBOX_BACK)
  495.         {
  496.             mmi_msg_entry_inbox_list();
  497.             /* if the processing screen is in the history after entry inbox list */
  498.             DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  499.         }
  500.         else if (processRSKStrId == STR_LOADING_OUTBOX_BACK)
  501.         {
  502.             mmi_msg_entry_outbox_list();
  503.             /* if the processing screen is in the history after entry outbox list */
  504.             DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  505.         }
  506.     #ifdef __MMI_MESSAGES_DRAFT_BOX__
  507.         else if (processRSKStrId == STR_LOADING_DRAFTBOX_BACK)
  508.         {
  509.             mmi_msg_entry_draftbox_list();
  510.             /* if the processing screen is in the history after entry draftbox list */
  511.             DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  512.         }
  513.     #endif /* __MMI_MESSAGES_DRAFT_BOX__ */ 
  514.     }
  515. #ifdef __MMI_UNIFIED_MESSAGE__
  516.     mmi_msg_send_ready_ind(KAL_TRUE);
  517. #endif 
  518. }
  519. /*****************************************************************************
  520.  * FUNCTION
  521.  *  mmi_msg_sync_msgbox_with_at
  522.  * DESCRIPTION
  523.  *  
  524.  * PARAMETERS
  525.  *  dummy       [?]         
  526.  *  mod         [IN]        
  527.  *  type        [IN]        
  528.  * RETURNS
  529.  *  void
  530.  *****************************************************************************/
  531. void mmi_msg_sync_msgbox_with_at(void *dummy, module_type mod, U16 type)
  532. {
  533.     /*----------------------------------------------------------------*/
  534.     /* Local Variables                                                */
  535.     /*----------------------------------------------------------------*/
  536.     U16 todelscrid = 0;
  537.     /*----------------------------------------------------------------*/
  538.     /* Code Body                                                      */
  539.     /*----------------------------------------------------------------*/
  540. #ifdef __MMI_UNIFIED_MESSAGE__
  541. #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  542.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_INBOX_LIST_OPTION || IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  543.     {
  544.         todelscrid = SCR_ID_MSG_INBOX_LIST_OPTION;
  545.     }
  546.     else if (GetMessagesCurrScrnID() == SCR_ID_MSG_OUTBOX_LIST_OPTION || IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  547.     {
  548.         todelscrid = SCR_ID_MSG_OUTBOX_LIST_OPTION;
  549.     }
  550.     else if (GetMessagesCurrScrnID() == SCR_ID_MSG_DEFAULT_LIST_OPTION || IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION))
  551.     {
  552.         todelscrid = SCR_ID_MSG_DEFAULT_LIST_OPTION;
  553.     }
  554.     else
  555. #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  556.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_INBOX_MSG || IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  557.     {
  558.         todelscrid = SCR_ID_MSG_INBOX_MSG;
  559.     }
  560.     else if (GetMessagesCurrScrnID() == SCR_ID_MSG_OUTBOX_MSG || IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  561.     {
  562.         todelscrid = SCR_ID_MSG_OUTBOX_MSG;
  563.     }
  564.     else if (GetMessagesCurrScrnID() == SCR_ID_MSG_DEFAULT_MSG || IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
  565.     {
  566.         todelscrid = SCR_ID_MSG_DEFAULT_MSG;
  567.     }
  568.     /* For L4C_AT_SMS_ADD, the refresh ind would be sent in mmi_frm_sms_get_sms_rsp() */
  569.     if (type != L4C_AT_SMS_ADD)
  570.     {
  571.         mmi_msg_send_refresh_ind(UM_MSG_BOX_TYPE_INBOX | UM_MSG_BOX_TYPE_UNSENT | UM_MSG_BOX_TYPE_SENT |
  572.                                  UM_MSG_BOX_TYPE_DRAFT);
  573.     }
  574. #else /* __MMI_UNIFIED_MESSAGE__ */ 
  575.     U16 totalInbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
  576.     U16 totalOutbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_OUTBOX);
  577.     U16 totalDraftbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_DRAFTS);
  578.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_INBOX_LIST || IsScreenPresent(SCR_ID_MSG_INBOX_LIST))
  579.     {
  580.         todelscrid = SCR_ID_MSG_INBOX_LIST;
  581.     }
  582.     else if (GetMessagesCurrScrnID() == SCR_ID_MSG_OUTBOX_LIST || IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST))
  583.     {
  584.         todelscrid = SCR_ID_MSG_OUTBOX_LIST;
  585.     }
  586. #ifdef __MMI_MESSAGES_DRAFT_BOX__
  587.     else if (GetMessagesCurrScrnID() == SCR_ID_MSG_DRAFTBOX_LIST || IsScreenPresent(SCR_ID_MSG_DRAFTBOX_LIST))
  588.     {
  589.         todelscrid = SCR_ID_MSG_DRAFTBOX_LIST;
  590.     }
  591. #endif /* __MMI_MESSAGES_DRAFT_BOX__ */ 
  592. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  593.     /* For the case of SIM Refresh, the msg screens should be deleted in mmi_frm_sms_sim_refresh_ind() */
  594.     /* If the SMS screens cannot be deleted, do not show the done pupup. */
  595.     if (todelscrid != 0 && g_msg_cntx.MessagesScrnIdDelUptoHistoryNodes != 0 && type != L4C_SMS_SIM_REFRESH)
  596.     {
  597.         /* Do not interrupt calling screen */
  598.         if (!isIncomingCall())
  599.         {
  600.             DisplayPopup(
  601.                 (PU8) GetString(STR_GLOBAL_DONE),
  602.                 IMG_GLOBAL_ACTIVATED,
  603.                 1,
  604.                 MESSAGES_POPUP_TIME_OUT,
  605.                 (U8) SUCCESS_TONE);
  606.         }
  607.         SetMessagesScrnIdToDelHistoryNodes(todelscrid);
  608.         DeleteMessagesHistoryNodes();
  609.     }
  610. #ifndef __MMI_UNIFIED_MESSAGE__
  611.     mmi_msg_set_msg_num_hint(totalInbox, totalOutbox, totalDraftbox);
  612.     RefreshMessagesMenuList();
  613.     /* If the new msg is deleted by AT, the new msg indication screen should not be displayed. */
  614.     if (GetExitScrnID() == SCR_ID_MSG_NEW_MSG_IND &&
  615.         type == L4C_AT_SMS_DELETE)
  616.     {
  617.         EntryIdleScreen();
  618.     }
  619. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  620.     mmi_msg_set_msg_icon(FALSE, FALSE);
  621. }
  622. /*****************************************************************************
  623.  * FUNCTION
  624.  *  mmi_msg_handle_msg_waiting_ind
  625.  * DESCRIPTION
  626.  *  
  627.  * PARAMETERS
  628.  *  inMsg       [?]         
  629.  *  mod         [IN]        
  630.  *  result      [IN]        
  631.  * RETURNS
  632.  *  void
  633.  *****************************************************************************/
  634. void mmi_msg_handle_msg_waiting_ind(void *inMsg, module_type mod, U16 result)
  635. {
  636.     /*----------------------------------------------------------------*/
  637.     /* Local Variables                                                */
  638.     /*----------------------------------------------------------------*/
  639.     MMI_FRM_SMS_MSG_WAITING_IND_STRUCT *msgInd = (MMI_FRM_SMS_MSG_WAITING_IND_STRUCT*) inMsg;
  640.     /*----------------------------------------------------------------*/
  641.     /* Code Body                                                      */
  642.     /*----------------------------------------------------------------*/
  643.     if (msgInd->is_clear)
  644.     {
  645.         g_msg_cntx.msg_waiting_info[(msgInd->line_no)].number[msgInd->ind_type] = 0;        
  646.         mmi_msg_set_msg_waiting_icon(msgInd->line_no, msgInd->ind_type, 0);
  647.     }        
  648.     else
  649.     {
  650.         mmi_msg_set_msg_waiting_icon(msgInd->line_no, msgInd->ind_type, 1);
  651.         /* Only display icon for message indication in storage, not from network. */
  652.         if (msgInd->is_from_storage)
  653.         {
  654.             return;
  655.         }
  656.         
  657.         g_msg_cntx.msg_waiting_line_number = msgInd->line_no;
  658.         
  659.         if (msgInd->is_show_num)
  660.         {
  661.             g_msg_cntx.msg_waiting_info[(msgInd->line_no)].number[msgInd->ind_type] = msgInd->waiting_num;
  662.         }
  663.         else
  664.         {
  665.             g_msg_cntx.msg_waiting_info[(msgInd->line_no)].number[msgInd->ind_type] = 0;
  666.         }
  667.         
  668.         mmi_msg_msg_waiting_ind(msgInd->ind_type);
  669.     }
  670. }
  671. /*****************************************************************************
  672.  * FUNCTION
  673.  *  mmi_msg_handle_deliver_report_ind
  674.  * DESCRIPTION
  675.  *  
  676.  * PARAMETERS
  677.  *  inMsg       [?]         
  678.  *  mod         [IN]        
  679.  *  result      [IN]        
  680.  * RETURNS
  681.  *  void
  682.  *****************************************************************************/
  683. void mmi_msg_handle_deliver_report_ind(void *inMsg, module_type mod, U16 result)
  684. {
  685.     /*----------------------------------------------------------------*/
  686.     /* Local Variables                                                */
  687.     /*----------------------------------------------------------------*/
  688.     U8 i = 0;
  689.     MMI_FRM_SMS_STATUS_REPORT_IND_STRUCT *msgInd = (MMI_FRM_SMS_STATUS_REPORT_IND_STRUCT*) inMsg;
  690.     /*----------------------------------------------------------------*/
  691.     /* Code Body                                                      */
  692.     /*----------------------------------------------------------------*/
  693.     for (i = 0; i < MAX_STATUS_REPORT_NUM; i++)
  694.     {
  695.         if (g_msg_cntx.msg_deliver_report[i] == NULL)
  696.         {
  697.             break;
  698.         }
  699.     }
  700.     if (i == MAX_STATUS_REPORT_NUM)
  701.     {
  702.         U8 j = 0;
  703.         OslMfree(g_msg_cntx.msg_deliver_report[0]);
  704.         g_msg_cntx.msg_deliver_ind--;
  705.         for (j = 0; j < (MAX_STATUS_REPORT_NUM - 1); j++)
  706.         {
  707.             g_msg_cntx.msg_deliver_report[j] = g_msg_cntx.msg_deliver_report[j + 1];
  708.         }
  709.         g_msg_cntx.msg_deliver_report[j] = NULL;
  710.         i = j;
  711.     }
  712.     g_msg_cntx.msg_deliver_report[i] = OslMalloc(sizeof(msg_deliver_report_struct));
  713.     g_msg_cntx.msg_deliver_report[i]->delivered = msgInd->st;
  714.     if (msgInd->ra_number.type == CSMCC_INTERNATIONAL_ADDR||
  715.         (msgInd->ra_number.type & 0xf0) == 0x90)
  716.     {
  717.         g_msg_cntx.msg_deliver_report[i]->type = 1;
  718.     }
  719.     else
  720.     {
  721.         g_msg_cntx.msg_deliver_report[i]->type = 0;
  722.     }
  723.     memset((S8*) g_msg_cntx.msg_deliver_report[i]->number, 0, MSG_NUM_LEN);
  724.     memcpy((S8*) g_msg_cntx.msg_deliver_report[i]->number, msgInd->ra_number.number, msgInd->ra_number.length);
  725.     memcpy((S8*) g_msg_cntx.msg_deliver_report[i]->timestamp, msgInd->dt, 6);
  726.     mmi_msg_deliver_report_ind();
  727. }
  728. /*****************************************************************************
  729.  * FUNCTION
  730.  *  mmi_msg_handle_mem_full_ind
  731.  * DESCRIPTION
  732.  *  
  733.  * PARAMETERS
  734.  *  inMsg       [?]         
  735.  *  mod         [IN]        
  736.  *  result      [IN]        
  737.  * RETURNS
  738.  *  void
  739.  *****************************************************************************/
  740. void mmi_msg_handle_mem_full_ind(void *inMsg, module_type mod, U16 result)
  741. {
  742.     /*----------------------------------------------------------------*/
  743.     /* Local Variables                                                */
  744.     /*----------------------------------------------------------------*/
  745.     MMI_FRM_SMS_MEM_FULL_IND_STRUCT *msgInd = (MMI_FRM_SMS_MEM_FULL_IND_STRUCT*) inMsg;
  746.     /*----------------------------------------------------------------*/
  747.     /* Code Body                                                      */
  748.     /*----------------------------------------------------------------*/
  749.     if (msgInd->type == SMSAL_MEM_FULL_NORMAL)
  750.     {
  751.         mmi_msg_set_msg_icon(TRUE, FALSE);
  752.         g_msg_cntx.msg_full_ind = TRUE;
  753.     }
  754. }
  755. /*****************************************************************************
  756.  * FUNCTION
  757.  *  mmi_msg_handle_mem_exceed_ind
  758.  * DESCRIPTION
  759.  *  
  760.  * PARAMETERS
  761.  *  inMsg       [?]         
  762.  *  mod         [IN]        
  763.  *  result      [IN]        
  764.  * RETURNS
  765.  *  void
  766.  *****************************************************************************/
  767. void mmi_msg_handle_mem_exceed_ind(void *inMsg, module_type mod, U16 result)
  768. {
  769.     /*----------------------------------------------------------------*/
  770.     /* Local Variables                                                */
  771.     /*----------------------------------------------------------------*/
  772.     MMI_FRM_SMS_MEM_EXCEED_IND_STRUCT *msgInd = (MMI_FRM_SMS_MEM_EXCEED_IND_STRUCT*) inMsg;
  773.     /*----------------------------------------------------------------*/
  774.     /* Code Body                                                      */
  775.     /*----------------------------------------------------------------*/
  776.     if (msgInd->type == SMSAL_MEM_EXCEED_NORMAL || msgInd->type == SMSAL_SM_EXCEED_WITH_CLASS2)
  777.     {
  778.         g_msg_cntx.msg_exceed_ind = TRUE;
  779.         g_msg_cntx.msg_exceed_type = msgInd->type;
  780.         TurnOnBacklight(1);
  781.         if (IsMMIInIdleState())
  782.         {
  783.             ClearKeyEvents();
  784.             if (IsKeyPadLockState())
  785.             {
  786.                 EntryIdleScreen();
  787.             }
  788.             else
  789.             {
  790.                 mmi_msg_entry_mem_exceed_ind();
  791.             }
  792.         }
  793.     }
  794. }
  795. /*****************************************************************************
  796.  * FUNCTION
  797.  *  mmi_msg_handle_mem_avail_ind
  798.  * DESCRIPTION
  799.  *  
  800.  * PARAMETERS
  801.  *  inMsg       [?]         
  802.  *  mod         [IN]        
  803.  *  result      [IN]        
  804.  * RETURNS
  805.  *  void
  806.  *****************************************************************************/
  807. void mmi_msg_handle_mem_avail_ind(void *inMsg, module_type mod, U16 result)
  808. {
  809.     /*----------------------------------------------------------------*/
  810.     /* Local Variables                                                */
  811.     /*----------------------------------------------------------------*/
  812.     MMI_FRM_SMS_MEM_AVAILABLE_IND_STRUCT *msgInd = (MMI_FRM_SMS_MEM_AVAILABLE_IND_STRUCT*) inMsg;
  813.     /*----------------------------------------------------------------*/
  814.     /* Code Body                                                      */
  815.     /*----------------------------------------------------------------*/
  816.     if (msgInd->type == SMSAL_MEM_AVAIL_NORMAL)
  817.     {
  818.         g_msg_cntx.msg_full_ind = FALSE;
  819.         g_msg_cntx.msg_exceed_ind = FALSE;
  820.         mmi_msg_set_msg_icon(FALSE, TRUE);
  821.     }
  822. }
  823. /*****************************************************************************
  824.  * FUNCTION
  825.  *  mmi_msg_handle_class0_msg_ind
  826.  * DESCRIPTION
  827.  *  
  828.  * PARAMETERS
  829.  *  inMsg       [?]     
  830.  *  content     [?]     
  831.  * RETURNS
  832.  *  
  833.  *****************************************************************************/
  834. U8 mmi_msg_handle_class0_msg_ind(void *inMsg, void *content)
  835. {
  836.     /*----------------------------------------------------------------*/
  837.     /* Local Variables                                                */
  838.     /*----------------------------------------------------------------*/
  839.     mmi_frm_sms_deliver_msg_struct *msgInd = (mmi_frm_sms_deliver_msg_struct*) inMsg;
  840.     mmi_frm_sms_concat_struct *concatinfo = (mmi_frm_sms_concat_struct*) & (msgInd->concat_info);
  841.     U8 type = 0;
  842.     S16 len = 0;
  843.     S8 *unicodecontent = NULL;
  844.     /*----------------------------------------------------------------*/
  845.     /* Code Body                                                      */
  846.     /*----------------------------------------------------------------*/
  847.     if (g_msg_cntx.msg_class0_p != NULL)
  848.     {
  849.         if (g_msg_cntx.msg_class0_p->data != NULL)
  850.         {
  851.             OslMfree(g_msg_cntx.msg_class0_p->data);
  852.             g_msg_cntx.msg_class0_p->data = NULL;
  853.         }
  854.         OslMfree(g_msg_cntx.msg_class0_p);
  855.         g_msg_cntx.msg_class0_p = NULL;
  856.     }
  857.     g_msg_cntx.msg_class0_p = OslMalloc(sizeof(msg_class0_msg_struct));
  858.     g_msg_cntx.msg_class0_p->length = msgInd->no_msg_data;
  859.     g_msg_cntx.msg_class0_p->fo = msgInd->fo;
  860.     g_msg_cntx.msg_class0_p->dcs = msgInd->dcs;
  861.     g_msg_cntx.msg_class0_p->totalseg = concatinfo->total_seg;
  862.     if (msgInd->addr_number.type == CSMCC_INTERNATIONAL_ADDR ||
  863.         (msgInd->addr_number.type & 0xf0) == 0x90)
  864.     {
  865.         AnsiiToUnicodeString((S8*) g_msg_cntx.msg_class0_p->number, "+");
  866.         type = 1;
  867.     }
  868.     AnsiiNToUnicodeString(
  869.         (S8*) g_msg_cntx.msg_class0_p->number + type * ENCODING_LENGTH,
  870.         (S8*) msgInd->addr_number.number,
  871.         MSG_NUM_LEN);
  872.     memcpy(g_msg_cntx.msg_class0_p->timestamp, msgInd->scts, 6);
  873.     /* content might be unicode or ascii, convert it to unicode and store it to unicodecontent */
  874.     if (g_msg_cntx.msg_class0_p->dcs == SMSAL_UCS2_DCS)
  875.     {
  876.         /* len = (S16)pfnUnicodeStrlen(content); */
  877.         len = g_msg_cntx.msg_class0_p->length;
  878.         unicodecontent = OslMalloc(len + 2);
  879.         memcpy(unicodecontent, content, len);
  880.         memset(unicodecontent + len, 0, 2);
  881.     }
  882.     else
  883.     {
  884.         /* len = strlen(content); */
  885.         len = g_msg_cntx.msg_class0_p->length / 2;
  886.         unicodecontent = OslMalloc((len + 1) * 2);
  887.         AnsiiNToUnicodeString(unicodecontent, content, len);
  888.         memset(unicodecontent + len * 2, 0, 2);
  889.     }
  890.     /* indicate a class0 message with missing segment with (.....) in the front of message content */
  891.     if (!mmi_frm_sms_check_awaited_complete_msg(msgInd->msg_data[0]))
  892.     {
  893.         S8 ascii_miss_str[] = EMS_MISS_SEG_DELIMIT_STR;
  894.         U16 ascii_miss_str_len = strlen((S8*) ascii_miss_str);
  895.         S8 *unicode_miss_str = NULL;
  896.         U16 unicode_miss_str_len = 0;   /* the byte number of unicode_miss_str */
  897.         unicode_miss_str = OslMalloc((ascii_miss_str_len + 1) * 2);
  898.         AnsiiNToUnicodeString(unicode_miss_str, ascii_miss_str, ascii_miss_str_len);
  899.         memset(unicode_miss_str + ascii_miss_str_len * 2, 0, 2);
  900.         unicode_miss_str_len = (U16) pfnUnicodeStrlen(unicode_miss_str) * 2;
  901.         /* g_msg_cntx.msg_class0_p->length contains (.....) and the length of unicodecontent */
  902.         g_msg_cntx.msg_class0_p->length = g_msg_cntx.msg_class0_p->length + unicode_miss_str_len;
  903.         g_msg_cntx.msg_class0_p->data = OslMalloc(g_msg_cntx.msg_class0_p->length + ENCODING_LENGTH);
  904.         memset((S8*) g_msg_cntx.msg_class0_p->data, 0, g_msg_cntx.msg_class0_p->length + ENCODING_LENGTH);
  905.         memcpy((S8*) g_msg_cntx.msg_class0_p->data, (S8*) unicode_miss_str, unicode_miss_str_len);
  906.         memcpy(
  907.             (S8*) (g_msg_cntx.msg_class0_p->data + unicode_miss_str_len),
  908.             (S8*) unicodecontent,
  909.             (g_msg_cntx.msg_class0_p->length - unicode_miss_str_len));
  910.         /* free unicode_miss_str buffer */
  911.         OslMfree(unicode_miss_str);
  912.         unicode_miss_str = NULL;
  913.     }
  914.     else
  915.     {
  916.         g_msg_cntx.msg_class0_p->data = OslMalloc(g_msg_cntx.msg_class0_p->length + ENCODING_LENGTH);
  917.         memset((S8*) g_msg_cntx.msg_class0_p->data, 0, g_msg_cntx.msg_class0_p->length + ENCODING_LENGTH);
  918.         memcpy((S8*) g_msg_cntx.msg_class0_p->data, (S8*) unicodecontent, g_msg_cntx.msg_class0_p->length);
  919.     }
  920.     mmi_msg_class0_msg_ind();
  921.     /* free unicodecontent buffer */
  922.     if (unicodecontent != NULL)
  923.     {
  924.         OslMfree(unicodecontent);
  925.         unicodecontent = NULL;
  926.     }
  927.     return FALSE;
  928. }
  929. /*****************************************************************************
  930.  * FUNCTION
  931.  *  mmi_msg_handle_new_msg_ind
  932.  * DESCRIPTION
  933.  *  
  934.  * PARAMETERS
  935.  *  data        [?]         
  936.  *  mod         [IN]        
  937.  *  result      [IN]        
  938.  * RETURNS
  939.  *  void
  940.  *****************************************************************************/
  941. void mmi_msg_handle_new_msg_ind(void *data, module_type mod, U16 result)
  942. {
  943.     /*----------------------------------------------------------------*/
  944.     /* Local Variables                                                */
  945.     /*----------------------------------------------------------------*/
  946.     U16 index = *(U16*) data;
  947.     /*----------------------------------------------------------------*/
  948.     /* Code Body                                                      */
  949.     /*----------------------------------------------------------------*/
  950.     /* copy the message to show, "before" read sms screen it shall be copied again */
  951.     mmi_msg_new_msg_ind(index);
  952. }
  953. /*****************************************************************************
  954.  * FUNCTION
  955.  *  mmi_msg_get_msg_new
  956.  * DESCRIPTION
  957.  *  
  958.  * PARAMETERS
  959.  *  void
  960.  * RETURNS
  961.  *  void
  962.  *****************************************************************************/
  963. void mmi_msg_get_msg_new(void)
  964. {
  965.     /*----------------------------------------------------------------*/
  966.     /* Local Variables                                                */
  967.     /*----------------------------------------------------------------*/
  968.     U8 type;
  969.     U16 list_index;
  970.     /*----------------------------------------------------------------*/
  971.     /* Code Body                                                      */
  972.     /*----------------------------------------------------------------*/
  973.     /* Go back to Idle screen if the new msg is deleted by AT or SIM refresh is ongoing. */
  974.     if (!mmi_msg_need_new_msg_ind() || mmi_frm_sms_is_in_sim_refresh())
  975.     {
  976.         DisplayPopup(
  977.             (PU8) GetString(STR_GLOBAL_UNFINISHED),
  978.             IMG_GLOBAL_UNFINISHED,
  979.             1,
  980.             MESSAGES_POPUP_TIME_OUT,
  981.             (U8) ERROR_TONE);
  982.         g_msg_cntx.msg_ind_in_idle = FALSE;
  983.         return;
  984.     }
  985.     /* disallow re-entering SMS application when there is a pending SMS job running in the background */
  986.     if (!mmi_frm_sms_check_action_pending())
  987.     {
  988.         mmi_msg_exit_inbox_list_dummy();
  989.     }
  990.     g_msg_cntx.msg_ind_in_idle = FALSE;
  991.     g_msg_cntx.toDisplayMessageList = TO_DISPLAY_MESSAGE_LIST_INBOX;
  992.     mmi_msg_get_msg_req(MMI_FRM_SMS_APP_NOBOX, g_msg_cntx.msg_ind_index);
  993.     mmi_frm_sms_get_list_index(&type, &list_index, g_msg_cntx.msg_ind_index);
  994.     /* map message box index to message list index to get the correct inbox header */
  995.     if (type == MMI_FRM_SMS_APP_INBOX)
  996.     {
  997.         g_msg_cntx.currBoxIndex = list_index;
  998.         if (mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_NOBOX) != MMI_FRM_SMS_INVALID_INDEX)
  999.         {
  1000.             msgbox_info.totalinbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
  1001.             msgbox_info.totaloutbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_OUTBOX);
  1002.             msgbox_info.totaldraftbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_DRAFTS);
  1003.             mmi_msg_set_msg_num_hint(msgbox_info.totalinbox, msgbox_info.totaloutbox, msgbox_info.totaldraftbox);
  1004.             RefreshMessagesMenuList();
  1005.         }
  1006.     }
  1007. }
  1008. #ifdef __MMI_UNIFIED_MESSAGE__
  1009. /*****************************************************************************
  1010.  * FUNCTION
  1011.  *  mmi_msg_delete_msg_after_send_rsp
  1012.  * DESCRIPTION
  1013.  *  
  1014.  * PARAMETERS
  1015.  *  dummy       [?]         
  1016.  *  mod         [IN]        
  1017.  *  result      [IN]        
  1018.  * RETURNS
  1019.  *  void
  1020.  *****************************************************************************/
  1021. void mmi_msg_delete_msg_after_send_rsp(void *dummy, module_type mod, U16 result)
  1022. {
  1023.     /*----------------------------------------------------------------*/
  1024.     /* Local Variables                                                */
  1025.     /*----------------------------------------------------------------*/
  1026.     UmMsgBoxType msg_box_type = mmi_um_get_current_msg_box_type();
  1027.     /*----------------------------------------------------------------*/
  1028.     /* Code Body                                                      */
  1029.     /*----------------------------------------------------------------*/
  1030.     switch (mmi_msg_get_post_send_action_type())
  1031.     {
  1032.         case MMI_SMS_PS_ACTION_SEND_SUCCESS_REMOVE_MSG:
  1033.         {
  1034.             DisplayPopup(
  1035.                 (PU8) GetString(STR_SMS_SEND_SUCCESS),
  1036.                 IMG_SEND_SUCCESS_PIC_MSG,
  1037.                 1,
  1038.                 MESSAGES_POPUP_TIME_OUT,
  1039.                 (U8) SUCCESS_TONE);
  1040.             break;
  1041.         }
  1042.         case MMI_SMS_PS_ACTION_MOVE_MSG:
  1043.         {
  1044.             /* Do nothing. */
  1045.             mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_DEFAULT);
  1046.             return;
  1047.         }
  1048.         default:
  1049.         {
  1050.             MMI_ASSERT(0);
  1051.             break;
  1052.         }
  1053.     }
  1054.     if (msg_box_type == UM_MSG_BOX_TYPE_UNSENT || msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  1055.     {
  1056.     #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1057.         if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1058.         {
  1059.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1060.         }
  1061.         else
  1062.     #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */    
  1063.         {    
  1064.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1065.         }
  1066.     }
  1067.     else
  1068.     {
  1069.         MMI_ASSERT(0);
  1070.     }
  1071. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) || defined(__MMI_SMART_MESSAGE_MT__)
  1072.     if (mmi_nsm_get_msg_type() != NORMAL_MESSAGE)   /* When msg count > 0 */
  1073.     {
  1074.         if ((IsScreenPresent(SCR_ID_MYPIC_DISPLAY)) && (totalInbox != 0))       /* For pic msg in Inbox list */
  1075.         {
  1076.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  1077.         }
  1078.         else if ((IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG)) && (totalOutbox != 0))        /* For pic msg in Outbox list */
  1079.         {
  1080.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1081.         }
  1082.         else if ((IsScreenPresent(SCR_ID_MSG_INBOX_MSG)) && (totalDraftbox != 0))       /* For ringtone in Inbox list */
  1083.         {
  1084.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  1085.         }
  1086.     #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  1087.         if (g_nsm_msg_context.is_picmsg == TRUE)
  1088.         {
  1089.             mmi_nsm2_init_nsm_msg_struct(&g_nsm_msg_context);
  1090.         }
  1091.     #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  1092.     }
  1093. #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) || defined(__MMI_SMART_MESSAGE_MT__) */ 
  1094.     DeleteMessagesHistoryNodes();
  1095.     g_msg_cntx.msg_full_ind = FALSE;
  1096.     mmi_msg_set_msg_icon(FALSE, FALSE);
  1097.     mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_DEFAULT);
  1098. }
  1099. /*****************************************************************************
  1100.  * FUNCTION
  1101.  *  mmi_msg_delete_msg_after_send_req
  1102.  * DESCRIPTION
  1103.  *  
  1104.  * PARAMETERS
  1105.  *  type        [IN]        
  1106.  *  index       [IN]        
  1107.  * RETURNS
  1108.  *  void
  1109.  *****************************************************************************/
  1110. void mmi_msg_delete_msg_after_send_req(U8 type, U16 index)
  1111. {
  1112.     /*----------------------------------------------------------------*/
  1113.     /* Local Variables                                                */
  1114.     /*----------------------------------------------------------------*/
  1115.     /*----------------------------------------------------------------*/
  1116.     /* Code Body                                                      */
  1117.     /*----------------------------------------------------------------*/
  1118.     mmi_frm_sms_delete_sms(mmi_msg_delete_msg_after_send_rsp, MOD_MMI, type, index);
  1119. }
  1120. /*****************************************************************************
  1121.  * FUNCTION
  1122.  *  mmi_msg_delete_msg_before_save_rsp
  1123.  * DESCRIPTION
  1124.  *  
  1125.  * PARAMETERS
  1126.  *  dummy       [?]         
  1127.  *  mod         [IN]        
  1128.  *  result      [IN]        
  1129.  * RETURNS
  1130.  *  void
  1131.  *****************************************************************************/
  1132. void mmi_msg_delete_msg_before_save_rsp(void *dummy, module_type mod, U16 result)
  1133. {
  1134.     /*----------------------------------------------------------------*/
  1135.     /* Local Variables                                                */
  1136.     /*----------------------------------------------------------------*/
  1137.     UmMsgBoxType msg_box_type = mmi_um_get_current_msg_box_type();
  1138.     /*----------------------------------------------------------------*/
  1139.     /* Code Body                                                      */
  1140.     /*----------------------------------------------------------------*/
  1141.     if (result == MMI_FRM_SMS_OK)
  1142.     {
  1143.         mmi_msg_save_msg_with_flag_req(MMI_FRM_SMS_SAVE_HIGHLIGHT_NEW_MSG_IND);
  1144.     }
  1145.     else
  1146.     {
  1147.         if (result == MMI_FRM_SMS_MEMINSUFFICIENT)
  1148.         {
  1149.             DisplayPopup(
  1150.                 (PU8) GetString(STR_SMS_FAILURE_MEM_CAP_EXCEEDED),
  1151.                 IMG_GLOBAL_UNFINISHED,
  1152.                 1,
  1153.                 MESSAGES_POPUP_TIME_OUT,
  1154.                 (U8) WARNING_TONE);
  1155.         }
  1156.         else
  1157.         {
  1158.             DisplayPopup(
  1159.                 (PU8) GetString(STR_GLOBAL_UNFINISHED),
  1160.                 IMG_GLOBAL_UNFINISHED,
  1161.                 1,
  1162.                 MESSAGES_POPUP_TIME_OUT,
  1163.                 (U8) WARNING_TONE);
  1164.         }
  1165.         if (msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  1166.         {
  1167.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1168.             {
  1169.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE_OPTION);
  1170.             }
  1171.             else
  1172.             {
  1173.             #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1174.                 if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1175.                 {
  1176.                     SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1177.                 }
  1178.                 else
  1179.             #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  1180.                 {                        
  1181.                     SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1182.                 }
  1183.             }
  1184.         }
  1185.         else
  1186.         {
  1187.             MMI_ASSERT(0);
  1188.         }
  1189.         DeleteMessagesHistoryNodes();
  1190.     }
  1191. }
  1192. /*****************************************************************************
  1193.  * FUNCTION
  1194.  *  mmi_msg_delete_msg_before_save_req
  1195.  * DESCRIPTION
  1196.  *  
  1197.  * PARAMETERS
  1198.  *  type        [IN]        
  1199.  *  index       [IN]        
  1200.  * RETURNS
  1201.  *  void
  1202.  *****************************************************************************/
  1203. void mmi_msg_delete_msg_before_save_req(U8 type, U16 index)
  1204. {
  1205.     /*----------------------------------------------------------------*/
  1206.     /* Local Variables                                                */
  1207.     /*----------------------------------------------------------------*/
  1208.     /*----------------------------------------------------------------*/
  1209.     /* Code Body                                                      */
  1210.     /*----------------------------------------------------------------*/
  1211.     mmi_frm_sms_delete_sms(mmi_msg_delete_msg_before_save_rsp, MOD_MMI, type, index);
  1212. }
  1213. /*****************************************************************************
  1214.  * FUNCTION
  1215.  *  mmi_msg_delete_msg_before_save_pre_check
  1216.  * DESCRIPTION
  1217.  *  
  1218.  * PARAMETERS
  1219.  *  data        [?]         
  1220.  *  mod         [IN]        
  1221.  *  result      [IN]        
  1222.  * RETURNS
  1223.  *  void
  1224.  *****************************************************************************/
  1225. void mmi_msg_delete_msg_before_save_pre_check(void *data, module_type mod, U16 result)
  1226. {
  1227.     /*----------------------------------------------------------------*/
  1228.     /* Local Variables                                                */
  1229.     /*----------------------------------------------------------------*/
  1230.     /*----------------------------------------------------------------*/
  1231.     /* Code Body                                                      */
  1232.     /*----------------------------------------------------------------*/
  1233.     if (result == MMI_FRM_SMS_OK)
  1234.     {
  1235.         msg_mem_status_struct *memorystatus = (msg_mem_status_struct*) data;
  1236.         U16 total_storage = memorystatus->simTotal + memorystatus->meTotal;
  1237.         U16 used_storage = memorystatus->simUsed + memorystatus->meUsed;
  1238.         EMSData *pEMS;
  1239.         U8 sms_segment_size = mmi_frm_sms_get_sms_received_size(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1240.         GetEMSDataForEdit(&pEMS, 0);
  1241.         if (pEMS->Reminder.requiredSegment > (total_storage - used_storage + sms_segment_size))
  1242.         {
  1243.             mmi_msg_delete_msg_before_save_rsp(NULL, MOD_MMI, MMI_FRM_SMS_MEMINSUFFICIENT);
  1244.         }
  1245.         else
  1246.         {
  1247.             mmi_msg_delete_msg_before_save_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1248.         }
  1249.     }
  1250.     else
  1251.     {
  1252.         DisplayPopup(
  1253.             (PU8) GetString(STR_GLOBAL_UNFINISHED),
  1254.             IMG_GLOBAL_UNFINISHED,
  1255.             1,
  1256.             MESSAGES_POPUP_TIME_OUT,
  1257.             (U8) WARNING_TONE);
  1258.     }
  1259. }
  1260. /*****************************************************************************
  1261.  * FUNCTION
  1262.  *  mmi_msg_delete_msg_before_save
  1263.  * DESCRIPTION
  1264.  *  
  1265.  * PARAMETERS
  1266.  *  void
  1267.  * RETURNS
  1268.  *  void
  1269.  *****************************************************************************/
  1270. void mmi_msg_delete_msg_before_save()
  1271. {
  1272.     /*----------------------------------------------------------------*/
  1273.     /* Local Variables                                                */
  1274.     /*----------------------------------------------------------------*/
  1275.     /*----------------------------------------------------------------*/
  1276.     /* Code Body                                                      */
  1277.     /*----------------------------------------------------------------*/
  1278.     mmi_frm_sms_get_memory_status(mmi_msg_delete_msg_before_save_pre_check, MOD_MMI);
  1279. }
  1280. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1281. /*****************************************************************************
  1282.  * FUNCTION
  1283.  *  mmi_msg_send_msg_rsp
  1284.  * DESCRIPTION
  1285.  *  
  1286.  * PARAMETERS
  1287.  *  number      [?]         
  1288.  *  mod         [IN]        
  1289.  *  result      [IN]        
  1290.  * RETURNS
  1291.  *  void
  1292.  *****************************************************************************/
  1293. void mmi_msg_send_msg_rsp(void *number, module_type mod, U16 result)
  1294. {
  1295.     /*----------------------------------------------------------------*/
  1296.     /* Local Variables                                                */
  1297.     /*----------------------------------------------------------------*/
  1298.     /*----------------------------------------------------------------*/
  1299.     /* Code Body                                                      */
  1300.     /*----------------------------------------------------------------*/
  1301.     switch (result)
  1302.     {
  1303.         case MMI_FRM_SMS_OK:
  1304.             g_msg_cntx.msg_send_info.CurrSendSmsNumbers++;
  1305.             while (g_msg_cntx.msg_send_info.CurrSendSmsNumbers < g_msg_cntx.msg_send_info.TotalSendSmsNumbers)
  1306.             {
  1307.             #ifdef __MMI_MESSAGES_SEND_TO_MANY__
  1308.                 if ((g_msg_cntx.sendMessageCase == SEND_CASE_SEND_TO_MANY)
  1309.                     &&
  1310.                     (pfnUnicodeStrlen
  1311.                      ((S8*) g_msg_cntx.msg_send_info.PhbNumber[g_msg_cntx.msg_send_info.CurrSendSmsNumbers])))
  1312.                 {
  1313.                     U8 length = pfnUnicodeStrlen(g_msg_cntx.msg_send_info.
  1314.                                          PhbNumber[g_msg_cntx.msg_send_info.CurrSendSmsNumbers]);
  1315.                     memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  1316.                     UnicodeNToAnsii(
  1317.                         (S8*) g_msg_cntx.smsPhoneNumber,
  1318.                         (S8*) g_msg_cntx.msg_send_info.PhbNumber[g_msg_cntx.msg_send_info. CurrSendSmsNumbers],
  1319.                         length * ENCODING_LENGTH);
  1320.                     mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 1);
  1321.                     return;
  1322.                 }
  1323.             #endif /* __MMI_MESSAGES_SEND_TO_MANY__ */ 
  1324.             #ifdef __MMI_MESSAGES_SEND_BY_GROUP__
  1325.                 else if ((g_msg_cntx.sendMessageCase == SEND_CASE_SEND_BY_GROUP)
  1326.                          && (g_msg_cntx.msg_send_info.PhbIndex != NULL))
  1327.                 {
  1328.                     U8 PhbNuminBCD[(MAX_DIGITS + 1) / 2];
  1329.                     U8 PhbNum[MAX_DIGITS + 1];
  1330.                     S8 PhbNumUCS2[(MAX_DIGITS + 2) * ENCODING_LENGTH];
  1331.                     U8 type = 0;
  1332.                     U8 length =
  1333.                         (PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[g_msg_cntx.msg_send_info.CurrSendSmsNumbers]].tel.length >
  1334.                          (MAX_DIGITS / 2)) ? 
  1335.                          (MAX_DIGITS / 2) : 
  1336.                          PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[g_msg_cntx.msg_send_info.CurrSendSmsNumbers]].tel.length;
  1337.                     memset(PhbNuminBCD, 0, (MAX_DIGITS + 1) / 2);
  1338.                     memcpy(
  1339.                         PhbNuminBCD,
  1340.                         PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[g_msg_cntx.msg_send_info.CurrSendSmsNumbers]]. tel.number,
  1341.                         length);
  1342.                     memset(PhbNum, 0, MAX_DIGITS + 1);
  1343.                     mmi_phb_convert_to_digit((U8*) PhbNum, (U8*) PhbNuminBCD, MAX_DIGITS + 1);
  1344.                     memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  1345.                     if (PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[g_msg_cntx.msg_send_info.CurrSendSmsNumbers]].tel.
  1346.                         type == CSMCC_INTERNATIONAL_ADDR)
  1347.                     {
  1348.                         type = 1;
  1349.                         AnsiiToUnicodeString((S8*) PhbNumUCS2, "+");
  1350.                     }
  1351.                     AnsiiNToUnicodeString((S8*) PhbNumUCS2 + type * ENCODING_LENGTH, (S8*) PhbNum, length);
  1352.                     UnicodeNToAnsii(
  1353.                         (S8*) g_msg_cntx.smsPhoneNumber,
  1354.                         (S8*) PhbNumUCS2,
  1355.                         (length + type) * ENCODING_LENGTH);
  1356.                     mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 1);
  1357.                     return;
  1358.                 }
  1359.             #endif /* __MMI_MESSAGES_SEND_BY_GROUP__ */ 
  1360.                 g_msg_cntx.msg_send_info.CurrSendSmsNumbers++;
  1361.             }
  1362.             ReleaseEMSEditBuffer();
  1363.         #ifdef __MMI_UNIFIED_MESSAGE__
  1364.             /* Skip UM write menu */
  1365.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1366.             {
  1367.                 mmi_um_skip_write_menu(KAL_TRUE);
  1368.             }
  1369.             if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  1370.             {
  1371.                 /* Remove the sent msg from drafts box */
  1372.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_SEND_SUCCESS_REMOVE_MSG);
  1373.                 mmi_msg_set_processing_screen(
  1374.                     STR_UNSENTBOX_MENUENTRY,
  1375.                     STR_DELETING_SMS_CAPTION,
  1376.                     IMG_GLOBAL_PROGRESS,
  1377.                     0);
  1378.                 mmi_msg_entry_processing_generic();
  1379.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1380.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1381.                 return;
  1382.             }
  1383.             else if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_DRAFT)
  1384.             {
  1385.                 /* Remove the sent msg from drafts box */
  1386.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_SEND_SUCCESS_REMOVE_MSG);
  1387.                 mmi_msg_set_processing_screen(STR_DRAFTBOX_MENUENTRY, STR_DELETING_SMS_CAPTION, IMG_GLOBAL_PROGRESS, 0);
  1388.                 mmi_msg_entry_processing_generic();
  1389.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1390.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1391.                 return;
  1392.             }
  1393.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1394.         
  1395.         #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1396.             if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  1397.             {
  1398.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  1399.             }
  1400.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1401.             {
  1402.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1403.             }
  1404.             else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION))
  1405.             {
  1406.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_LIST_OPTION);
  1407.             }
  1408.             else
  1409.         #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  1410.             if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  1411.             {
  1412.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  1413.             }
  1414.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  1415.             {
  1416.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1417.             }
  1418.             else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
  1419.             {
  1420.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_MSG);
  1421.             }
  1422.         #if defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1423.             else if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY))
  1424.             {
  1425.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  1426.             }
  1427.         #endif /* defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  1428. //KP Jerry add for third sevice on 2007-03-26 start
  1429. #ifdef __KONG_NET_SP__
  1430.                      else if(IsScreenPresent(SCR_ID_THUMB_WORLD_OK))
  1431.                       {
  1432. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_THUMB_WORLD_OK);
  1433.        //SetMessagesScrnIdDelUpToHistoryNodes(SCR_ID_THUMB_WORLD);
  1434.                       }  
  1435.                      else if(IsScreenPresent(SCR_ID_THUMB_WORLD_OK2))
  1436.                       {
  1437. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_THUMB_WORLD_OK2);
  1438. //SetMessagesScrnIdDelUpToHistoryNodes(SCR_ID_THUMB_WORLD);
  1439.                       }
  1440.                      else if(IsScreenPresent(SCR_ID_WONDERUL_OK))
  1441.                       {
  1442. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_WONDERUL_OK);
  1443. //SetMessagesScrnIdDelUpToHistoryNodes(SCR_ID_WONDERFUL);
  1444.                       }
  1445.                      else if(IsScreenPresent(SCR_ID_WONDERUL_OK2))
  1446.                       {
  1447. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_WONDERUL_OK2);
  1448. //SetMessagesScrnIdDelUpToHistoryNodes(SCR_ID_WONDERFUL);
  1449.                       }
  1450. #endif  
  1451. //KP Jerry add for third sevice on 2007-03-26 end
  1452.             else if (IsScreenPresent(SCR_ID_MSG_TEMPLATE_OPTION))
  1453.             {
  1454.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_TEMPLATE_OPTION);
  1455.             }
  1456.             else if (IsScreenPresent(SCR_ID_MSG_WRITE))
  1457.             {
  1458.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  1459.             }
  1460.             DisplayPopup(
  1461.                 (PU8) GetString(STR_SMS_SEND_SUCCESS),
  1462.                 IMG_SEND_SUCCESS_PIC_MSG,
  1463.                 1,
  1464.                 MESSAGES_POPUP_TIME_OUT,
  1465.                 (U8) SUCCESS_TONE);
  1466.             if (g_msg_cntx.msg_send_info.CurrSendSmsNumbers == g_msg_cntx.msg_send_info.TotalSendSmsNumbers)
  1467.             {
  1468.                 DeleteMessagesHistoryNodes();
  1469.                 mmi_frm_sms_delete_screen_history();
  1470.             }
  1471. //KP Jerry add for third sevice on 2007-03-26 start
  1472. #ifdef __KONG_NET_SP__
  1473.                    if((IsScreenPresent(SCR_ID_THUMB_WORLD_OK))||(IsScreenPresent(SCR_ID_THUMB_WORLD_OK2))||(IsScreenPresent(SCR_ID_WONDERUL_OK))||(IsScreenPresent(SCR_ID_WONDERUL_OK2)))
  1474.                    {
  1475. mmi_frm_sms_delete_screen_history();
  1476. DeleteMessagesHistoryNodes ();
  1477.                    }
  1478. #endif
  1479. //KP Jerry add for third sevice on 2007-03-26 end
  1480.         #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1481.             mmi_nsm2_init_nsm_msg_struct(&g_nsm_msg_context);   /* Reset after sending picture msg */
  1482.         #endif 
  1483.             AlmEnableSPOF();
  1484.             break;
  1485.         case MMI_FRM_SMS_ABORT:
  1486.         #if ( defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1487.             if (g_nsm_msg_context.is_picmsg == TRUE)
  1488.             {
  1489.                 EMSData *pEMS;
  1490.                 GetEMSDataForEdit(&pEMS, 1);
  1491.                 AddString(
  1492.                     pEMS,
  1493.                     (U8*) g_nsm_msg_context.textbuffer,
  1494.                     (U16) pfnUnicodeStrlen((S8*) g_nsm_msg_context.textbuffer),
  1495.                     NULL);
  1496.             }
  1497.         #endif /* ( defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  1498.         #ifdef __MMI_SMART_MESSAGE_MT__
  1499.             /* Replying message only contains texts and the content of the msg should be keeped in abort case */
  1500.             if ((mmi_nsm_get_msg_type() == PICTURE_MESSAGE) && (g_msg_cntx.sendMessageCase != SEND_CASE_REPLY))
  1501.             {
  1502.                 EMSData *pEMS;
  1503.                 GetEMSDataForEdit(&pEMS, 0);
  1504.                 memset(pEMS->textBuffer, 0x00, pEMS->textLength);
  1505.                 /* memset(&picmsg_text_struct, 0x00, sizeof(picmsg_text_struct)); *//* For issue 140 */
  1506.                 ReleaseEMSEditBuffer();
  1507.             }
  1508.         #endif /* __MMI_SMART_MESSAGE_MT__ */ 
  1509.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1510.             {
  1511.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE_OPTION);
  1512.             }
  1513.         #ifdef __MMI_SMART_MESSAGE_MT__
  1514.             else if (IsScreenPresent(SCR_ID_EDIT_OPTIONS))
  1515.             {
  1516.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_EDIT_OPTIONS);
  1517.             }
  1518.             else if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY)) /* JAI 06-12-2004 for My Pic */
  1519.             {
  1520.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  1521.             }
  1522.         #endif /* __MMI_SMART_MESSAGE_MT__ */ 
  1523.             else if (IsScreenPresent(SCR_ID_MSG_SEND_OPTION))
  1524.             {
  1525.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SEND_OPTION);
  1526.             }
  1527.         #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1528.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1529.             {
  1530.                 /* sent / forward / abort . This case shall go back to send option */
  1531.                 if (mmi_um_get_current_msg_box_type() != UM_MSG_BOX_TYPE_SENT)
  1532.                 {
  1533.                     SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1534.                 }                
  1535.             }
  1536.         #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */            
  1537.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  1538.             {
  1539.             #ifdef __MMI_UNIFIED_MESSAGE__
  1540.                 /* sent / forward / abort . This case shall go back to send option */
  1541.                 if (mmi_um_get_current_msg_box_type() != UM_MSG_BOX_TYPE_SENT)
  1542.             #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1543.                 {
  1544.                     SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1545.                 }
  1546.             }
  1547. //KP Jerry add for third sevice on 2007-03-26 start
  1548. #ifdef __KONG_NET_SP__
  1549.                      else if(IsScreenPresent(SCR_ID_THUMB_WORLD_OK))
  1550. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_THUMB_WORLD_OK);
  1551.                      else if(IsScreenPresent(SCR_ID_THUMB_WORLD_OK2))
  1552. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_THUMB_WORLD_OK2);
  1553.                      else if(IsScreenPresent(SCR_ID_WONDERUL_OK))
  1554. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_WONDERUL_OK);
  1555.                      else if(IsScreenPresent(SCR_ID_WONDERUL_OK2))
  1556. SetMessagesScrnIdToDelHistoryNodes(SCR_ID_WONDERUL_OK2);
  1557. #endif  
  1558. //KP Jerry add for third sevice on 2007-03-26 end
  1559.             DisplayPopup(
  1560.                 (PU8) GetString(STR_ABORT_SENDING_SMS),
  1561.                 IMG_GLOBAL_ACTIVATED,
  1562.                 1,
  1563.                 MESSAGES_POPUP_TIME_OUT,
  1564.                 (U8) SUCCESS_TONE);
  1565.             DeleteMessagesHistoryNodes();
  1566.             mmi_frm_sms_delete_screen_history();
  1567.             AlmEnableSPOF();
  1568.             break;
  1569.         case MMI_FRM_SMS_NOTREADY:
  1570.             DisplayPopup(
  1571.                 (PU8) GetString(STR_SMS_MSG_NOT_READY_YET),
  1572.                 IMG_SEND_FAIL_PIC_MSG,
  1573.                 1,
  1574.                 MESSAGES_POPUP_TIME_OUT,
  1575.                 (U8) ERROR_TONE);
  1576.             AlmEnableSPOF();
  1577.             break;
  1578.         case MMI_FRM_SMS_NUMINVALID:
  1579.             DisplayPopup(
  1580.                 (PU8) GetString(STR_ID_PHB_NUM_INVALID),
  1581.                 IMG_GLOBAL_UNFINISHED,
  1582.                 1,
  1583.                 MESSAGES_POPUP_TIME_OUT,
  1584.                 (U8) ERROR_TONE);
  1585.             
  1586.         #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1587.             if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  1588.             {
  1589.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  1590.             }
  1591.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1592.             {
  1593.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1594.             }
  1595.             else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION))
  1596.             {
  1597.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_LIST_OPTION);
  1598.             }
  1599.             else
  1600.         #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */           
  1601.         
  1602.             if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  1603.             {
  1604.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  1605.             }
  1606.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  1607.             {
  1608.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1609.             }
  1610.             else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
  1611.             {
  1612.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_MSG);
  1613.             }
  1614.         #if defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1615.             else if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY))
  1616.             {
  1617.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  1618.             }
  1619.         #endif /* defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  1620.             else if (IsScreenPresent(SCR_ID_MSG_WRITE))
  1621.             {
  1622.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  1623.             }
  1624.             DeleteMessagesHistoryNodes();
  1625.             mmi_frm_sms_delete_screen_history();
  1626.             AlmEnableSPOF();
  1627.             break;
  1628.         case MMI_FRM_SMS_RETURN:
  1629.         case MMI_FRM_SMS_END:
  1630.         #ifdef __MMI_SMART_MESSAGE_MT__
  1631.             if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  1632.             {
  1633.                 ReleaseEMSEditBuffer();
  1634.             }
  1635.         #endif /* __MMI_SMART_MESSAGE_MT__ */ 
  1636.             break;
  1637.         case MMI_FRM_SMS_END_FROM_SENDING:
  1638.         #ifdef __MMI_SMART_MESSAGE_MT__
  1639.             if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  1640.             {
  1641.                 ReleaseEMSEditBuffer();
  1642.             }
  1643.         #endif /* __MMI_SMART_MESSAGE_MT__ */ 
  1644.         #ifdef __MMI_UNIFIED_MESSAGE__
  1645.             {
  1646.                 U8 msg_box_type = mmi_um_get_current_msg_box_type();
  1647.                 if (msg_box_type == UM_MSG_BOX_TYPE_UNSENT)
  1648.                 {
  1649.                     /* unsent / edit / send/ end key, delete the old msg and save the new one   */
  1650.                     if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1651.                     {
  1652.                         /* delete the msg in draft and save the msg to unsent  */
  1653.                         mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  1654.                         mmi_msg_set_background_process(KAL_TRUE);
  1655.                         mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_UNSENT, (U16) g_msg_cntx.currBoxIndex);
  1656.                         mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1657.                     }
  1658.                     /* unsent / send / end key, the msg should be kept. */
  1659.                     else
  1660.                     {
  1661.                         ;   /* Do nothing  */
  1662.                     }
  1663.                 }
  1664.                 else if (msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  1665.                 {
  1666.                     /* draft / edit / send/ end key, or draft / send / end key , delete the old msg and save the new one   */
  1667.                     /* delete the msg in draft and save the msg to unsent  */
  1668.                     mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  1669.                     mmi_msg_set_background_process(KAL_TRUE);
  1670.                     mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1671.                     mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1672.                 }
  1673.                 else
  1674.                 {
  1675.                     mmi_msg_set_background_process(KAL_TRUE);
  1676.                     mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1677.                 }
  1678.             }
  1679.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1680.             break;
  1681.         default:
  1682.         #ifdef __MMI_UNIFIED_MESSAGE__
  1683.         {
  1684.             U8 msg_box_type = mmi_um_get_current_msg_box_type();
  1685.             /* Skip UM write menu */
  1686.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1687.             {
  1688.                 mmi_um_skip_write_menu(KAL_TRUE);
  1689.             }
  1690.             if (msg_box_type == UM_MSG_BOX_TYPE_INBOX)
  1691.             {
  1692.                 /* inbox / edit / send/ send fail , or inbox / forward / send/ send fail, the msg should be saved to unsent box */
  1693.                 mmi_msg_set_processing_screen(STR_INBOX_MENUENTRY, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  1694.                 mmi_msg_entry_processing_generic();
  1695.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1696.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1697.             }
  1698.             else if (msg_box_type == UM_MSG_BOX_TYPE_SENT)
  1699.             {
  1700.                 /* sent / edit / send/ send fail , or sent / forward / send/ send fail, the msg should be saved to unsent box */
  1701.                 mmi_msg_set_processing_screen(STR_UM_SENT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  1702.                 mmi_msg_entry_processing_generic();
  1703.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1704.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1705.             }
  1706.             else if (msg_box_type == UM_MSG_BOX_TYPE_UNSENT)
  1707.             {
  1708.                 /* unsent / edit / send / send fail, delete the old msg and save the new one */
  1709.                 if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1710.                 {
  1711.                     mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  1712.                     mmi_msg_set_processing_screen(STR_UM_UNSENT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  1713.                     mmi_msg_entry_processing_generic();
  1714.                     DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1715.                     mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1716.                     mmi_msg_save_msg_after_send_with_flag_req(
  1717.                         SMSAL_STO_UNSENT,
  1718.                         number,
  1719.                         MMI_FRM_SMS_SAVE_HIGHLIGHT_NEW_MSG_IND);
  1720.                 }
  1721.                 /* unsent / send/ send fail, the msg should be kept. */
  1722.                 else
  1723.                 {
  1724.                     /* Do nothing  */
  1725.                 #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1726.                     if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1727.                     {
  1728.                         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1729.                     }
  1730.                     else
  1731.                 #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  1732.                     {
  1733.                         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1734.                     }
  1735.                     DisplayPopup(
  1736.                         (PU8) GetString(STR_SMS_SEND_FAILED),
  1737.                         IMG_SEND_FAIL_PIC_MSG,
  1738.                         1,
  1739.                         MESSAGES_POPUP_TIME_OUT,
  1740.                         (U8) ERROR_TONE);
  1741.                     DeleteMessagesHistoryNodes();
  1742.                     mmi_frm_sms_delete_screen_history();
  1743.                     AlmEnableSPOF();
  1744.                 }
  1745.             }
  1746.             else if (msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  1747.             {
  1748.                 /* draft / edit / send / send fail, or draft / send / send fail, delete the old msg and save the new one to unsent */
  1749.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  1750.                 mmi_msg_set_processing_screen(STR_UM_DRAFT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  1751.                 mmi_msg_entry_processing_generic();
  1752.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1753.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1754.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1755.             }
  1756.             else
  1757.             {
  1758.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1759.             }
  1760.         }
  1761.         #else /* __MMI_UNIFIED_MESSAGE__ */ 
  1762.             /* when sending fail, only save the content to outbox if the message is not sent from outbox originally */
  1763.             if (IsScreenPresent(SCR_ID_MSG_OUTBOX_SEND_OPTION))
  1764.             {
  1765.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1766.                 DisplayPopup(
  1767.                     (PU8) GetString(STR_SMS_SEND_FAILED),
  1768.                     IMG_SEND_FAIL_PIC_MSG,
  1769.                     1,
  1770.                     MESSAGES_POPUP_TIME_OUT,
  1771.                     (U8) ERROR_TONE);
  1772.                 DeleteMessagesHistoryNodes();
  1773.                 mmi_frm_sms_delete_screen_history();
  1774.                 AlmEnableSPOF();
  1775.             }
  1776.             else
  1777.             {
  1778.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  1779.             }
  1780.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1781.             break;
  1782.     }
  1783. }
  1784. /*****************************************************************************
  1785.  * FUNCTION
  1786.  *  mmi_msg_send_msg_req
  1787.  * DESCRIPTION
  1788.  *  
  1789.  * PARAMETERS
  1790.  *  number              [?]         
  1791.  *  replyindex          [IN]        
  1792.  *  hidenumscreen       [IN]        
  1793.  * RETURNS
  1794.  *  void
  1795.  *****************************************************************************/
  1796. void mmi_msg_send_msg_req(U8 *number, U16 replyindex, U8 hidenumscreen)
  1797. {
  1798.     /*----------------------------------------------------------------*/
  1799.     /* Local Variables                                                */
  1800.     /*----------------------------------------------------------------*/
  1801.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  1802.     /*----------------------------------------------------------------*/
  1803.     /* Code Body                                                      */
  1804.     /*----------------------------------------------------------------*/
  1805.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  1806. #ifdef __MMI_UNIFIED_MESSAGE__
  1807.     if (!(mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT && GetExitScrnID() == SCR_ID_MSG_OUTBOX_OPTION))
  1808. #else 
  1809.     if (GetMessagesCurrScrnID() != SCR_ID_MSG_OUTBOX_SEND_OPTION)
  1810. #endif 
  1811.     {
  1812.         sendData->sendrequire |= MMI_FRM_SMS_SAVE_AFTER_FAIL;
  1813.     }
  1814.     memset(sendData->number, 0, MAX_DIGITS_SMS);
  1815.     if (strlen((S8*) number))
  1816.     {
  1817.         memcpy((S8*) sendData->number, (S8*) number, strlen((S8*) number));
  1818.     }
  1819.     else if (replyindex != MMI_FRM_SMS_INVALID_INDEX)
  1820.     {
  1821.         sendData->sendrequire |= MMI_FRM_SMS_REPLY;
  1822.         sendData->replyindex = replyindex;
  1823.     }
  1824.     /* for send to many or send to group, show only one sending screen for all numbers */
  1825.     if ((g_msg_cntx.msg_send_info.CurrSendSmsNumbers + 1) < g_msg_cntx.msg_send_info.TotalSendSmsNumbers)
  1826.     {
  1827.         sendData->sendrequire |= MMI_FRM_SMS_MORE;
  1828.     }
  1829.     /* if sendcheck has a bit of MMI_FRM_SMS_SCR, do not show sending screen */
  1830.     if (g_msg_cntx.msg_send_info.CurrSendSmsNumbers != 0)
  1831.     {
  1832.         sendData->sendcheck |= MMI_FRM_SMS_SCR;
  1833.     }
  1834.     if (!hidenumscreen)
  1835.     {
  1836.     #ifdef __MMI_UNIFIED_MESSAGE__
  1837.         if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  1838.         {
  1839.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1840.             {
  1841.                 sendData->sendrequire |= MMI_FRM_SMS_NUM_SCR;
  1842.             }
  1843.         }
  1844.     #else /* __MMI_UNIFIED_MESSAGE__ */ 
  1845.         if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  1846.         {
  1847.             /* If press Send key in send-to-many number editor screen, the number exists so that not to display the number screen . */
  1848.             if (!IsScreenPresent(SCR_ID_MSG_SEND_MANY_LIST_OPTION))
  1849.             {
  1850.                 sendData->sendrequire |= MMI_FRM_SMS_NUM_SCR;
  1851.             }
  1852.         }
  1853.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1854.         /* the case of forward inbox message */
  1855.         if ((IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION) || IsScreenPresent(SCR_ID_MSG_INBOX_MSG)) && 
  1856.             replyindex == MMI_FRM_SMS_INVALID_INDEX)
  1857.         {
  1858.             /* If press Send key in send-to-many number editor screen, the number exists. */
  1859.             if (!(strlen((S8*) number)))
  1860.             {
  1861.                 sendData->sendrequire |= MMI_FRM_SMS_NUM_SCR;
  1862.                 memset(sendData->number, 0, MAX_DIGITS_SMS);
  1863.             }
  1864.         }
  1865.     }
  1866. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1867.     if (g_nsm_msg_context.is_picmsg == TRUE)
  1868.     {
  1869.         mmi_nsm_get_picmsg_sendData(sendData);
  1870.     }
  1871. #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  1872. #if defined(__MMI_SMART_MESSAGE_MT__)
  1873.     if ((mmi_nsm_get_msg_type() == PICTURE_MESSAGE) && (g_msg_cntx.sendMessageCase != SEND_CASE_REPLY)) /* If not reply to a picture message then do this */
  1874.     {
  1875.         mmi_nsm_get_picmsg_sendData(sendData);
  1876.     }
  1877. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  1878.     mmi_frm_sms_send_sms(mmi_msg_send_msg_rsp, MOD_MMI, sendData);
  1879.     OslMfree(sendData);
  1880. }
  1881. /*****************************************************************************
  1882.  * FUNCTION
  1883.  *  mmi_msg_send_and_save_msg_rsp
  1884.  * DESCRIPTION
  1885.  *  
  1886.  * PARAMETERS
  1887.  *  number      [?]         
  1888.  *  mod         [IN]        
  1889.  *  result      [IN]        
  1890.  * RETURNS
  1891.  *  void
  1892.  *****************************************************************************/
  1893. void mmi_msg_send_and_save_msg_rsp(void *number, module_type mod, U16 result)
  1894. {
  1895.     /*----------------------------------------------------------------*/
  1896.     /* Local Variables                                                */
  1897.     /*----------------------------------------------------------------*/
  1898.     /*----------------------------------------------------------------*/
  1899.     /* Code Body                                                      */
  1900.     /*----------------------------------------------------------------*/
  1901.     switch (result)
  1902.     {
  1903.         case MMI_FRM_SMS_OK:
  1904.     #ifdef __MMI_UNIFIED_MESSAGE__
  1905.             /* Skip UM write menu */
  1906.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1907.             {
  1908.                 mmi_um_skip_write_menu(KAL_TRUE);
  1909.             }
  1910.             if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  1911.             {
  1912.                 /* delete the msg in draft and save the msg to sent  */
  1913.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  1914.                 mmi_msg_set_processing_screen(STR_UM_UNSENT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  1915.                 mmi_msg_entry_processing_generic();
  1916.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1917.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1918.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_SENT, number);
  1919.             }
  1920.             else if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_DRAFT)
  1921.             {
  1922.                 /* delete the msg in draft and save the msg to unsent  */
  1923.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  1924.                 mmi_msg_set_processing_screen(STR_UM_DRAFT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  1925.                 mmi_msg_entry_processing_generic();
  1926.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  1927.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  1928.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_SENT, number);
  1929.             }
  1930.             else if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_SENT)
  1931.             {
  1932.                 /* After back to sent list, the highlight should be on the old one. */
  1933.                 mmi_msg_save_msg_after_send_with_flag_req(
  1934.                     SMSAL_STO_SENT,
  1935.                     number,
  1936.                     MMI_FRM_SMS_SAVE_HIGHLIGHT_ORIGINAL_MSG_IND | MMI_FRM_SMS_SAVE_MODIFY_HIGHLIGHT);
  1937.             }
  1938.             else
  1939.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  1940.             {
  1941.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_SENT, number);
  1942.             }
  1943.             break;
  1944.         case MMI_FRM_SMS_ABORT:
  1945.         #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1946.             if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  1947.             {
  1948.                 ReleaseEMSEditBuffer();
  1949.             }
  1950.         #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  1951.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  1952.             {
  1953.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE_OPTION);
  1954.             }
  1955.         #if defined(__MMI_SMART_MESSAGE_MT__) || defined(__MMI_SMART_MESSAGE_MO__)
  1956.             else if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY))
  1957.             {
  1958.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  1959.             }
  1960.         #endif /* defined(__MMI_SMART_MESSAGE_MT__) || defined(__MMI_SMART_MESSAGE_MO__) */ 
  1961.             else if (IsScreenPresent(SCR_ID_MSG_SEND_OPTION))
  1962.             {
  1963.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SEND_OPTION);
  1964.             }
  1965.         #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  1966.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  1967.             {
  1968.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  1969.             }
  1970.         #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  1971.             else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  1972.             {
  1973.                 SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  1974.             }
  1975.             DisplayPopup(
  1976.                 (PU8) GetString(STR_ABORT_SENDING_SMS),
  1977.                 IMG_GLOBAL_ACTIVATED,
  1978.                 1,
  1979.                 MESSAGES_POPUP_TIME_OUT,
  1980.                 (U8) SUCCESS_TONE);
  1981.             DeleteMessagesHistoryNodes();
  1982.             mmi_frm_sms_delete_screen_history();
  1983.             AlmEnableSPOF();
  1984.             break;
  1985.         case MMI_FRM_SMS_NOTREADY:
  1986.             DisplayPopup(
  1987.                 (PU8) GetString(STR_SMS_MSG_NOT_READY_YET),
  1988.                 IMG_SEND_FAIL_PIC_MSG,
  1989.                 1,
  1990.                 MESSAGES_POPUP_TIME_OUT,
  1991.                 (U8) ERROR_TONE);
  1992.             AlmEnableSPOF();
  1993.             break;
  1994.         case MMI_FRM_SMS_RETURN:
  1995.         case MMI_FRM_SMS_END:
  1996.         #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  1997.             if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  1998.             {
  1999.                 ReleaseEMSEditBuffer();
  2000.             }
  2001.         #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2002.             break;
  2003.         case MMI_FRM_SMS_END_FROM_SENDING:
  2004.         #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2005.             if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  2006.             {
  2007.                 ReleaseEMSEditBuffer();
  2008.             }
  2009.         #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2010.         #ifdef __MMI_UNIFIED_MESSAGE__
  2011.             {
  2012.                 U8 msg_box_type = mmi_um_get_current_msg_box_type();
  2013.                 if (msg_box_type == UM_MSG_BOX_TYPE_UNSENT)
  2014.                 {
  2015.                     /* unsent / edit / send/ end key, delete the old msg and save the new one   */
  2016.                     /* delete the msg in draft and save the msg to unsent  */
  2017.                     mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  2018.                     mmi_msg_set_background_process(KAL_TRUE);
  2019.                     mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_UNSENT, (U16) g_msg_cntx.currBoxIndex);
  2020.                     mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  2021.                 }
  2022.                 else if (msg_box_type == UM_MSG_BOX_TYPE_DRAFT)
  2023.                 {
  2024.                     /* draft / edit / send/ end key, or draft / send / end key , delete the old msg and save the new one   */
  2025.                     /* delete the msg in draft and save the msg to unsent  */
  2026.                     mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  2027.                     mmi_msg_set_background_process(KAL_TRUE);
  2028.                     mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  2029.                     mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  2030.                 }
  2031.                 else
  2032.                 {
  2033.                     mmi_msg_set_background_process(KAL_TRUE);
  2034.                     mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  2035.                 }
  2036.             }
  2037.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2038.             break;
  2039.         default:
  2040.         #ifdef __MMI_UNIFIED_MESSAGE__
  2041.             /* Skip UM write menu */
  2042.             if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  2043.             {
  2044.                 mmi_um_skip_write_menu(KAL_TRUE);
  2045.             }
  2046.             if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  2047.             {
  2048.                 /* delete the msg in draft and save the msg to sent  */
  2049.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  2050.                 mmi_msg_set_processing_screen(STR_UM_UNSENT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  2051.                 mmi_msg_entry_processing_generic();
  2052.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  2053.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  2054.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  2055.             }
  2056.             else if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_DRAFT)
  2057.             {
  2058.                 /* delete the msg in draft and save the msg to unsent  */
  2059.                 mmi_msg_set_post_send_action_type(MMI_SMS_PS_ACTION_MOVE_MSG);
  2060.                 mmi_msg_set_processing_screen(STR_UM_DRAFT_ID, STR_GLOBAL_SAVING, IMG_GLOBAL_PROGRESS, 0);
  2061.                 mmi_msg_entry_processing_generic();
  2062.                 DeleteScreenIfPresent(SCR_ID_MSG_PROCESSING);
  2063.                 mmi_msg_delete_msg_after_send_req(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  2064.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  2065.             }
  2066.             else
  2067.         #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2068.             {
  2069.                 mmi_msg_save_msg_after_send_req(SMSAL_STO_UNSENT, number);
  2070.             }
  2071.             break;
  2072.     }
  2073. }
  2074. /*****************************************************************************
  2075.  * FUNCTION
  2076.  *  mmi_msg_send_and_save_msg_req
  2077.  * DESCRIPTION
  2078.  *  
  2079.  * PARAMETERS
  2080.  *  number          [?]         
  2081.  *  replyindex      [IN]        
  2082.  * RETURNS
  2083.  *  void
  2084.  *****************************************************************************/
  2085. void mmi_msg_send_and_save_msg_req(U8 *number, U16 replyindex)
  2086. {
  2087.     /*----------------------------------------------------------------*/
  2088.     /* Local Variables                                                */
  2089.     /*----------------------------------------------------------------*/
  2090.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  2091.     /*----------------------------------------------------------------*/
  2092.     /* Code Body                                                      */
  2093.     /*----------------------------------------------------------------*/
  2094.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  2095.     sendData->sendrequire |= MMI_FRM_SMS_SAVE;
  2096.     memset(sendData->number, 0, MAX_DIGITS_SMS);
  2097.     if (number != NULL)
  2098.     {
  2099.         memcpy((S8*) sendData->number, (S8*) number, strlen((S8*) number));
  2100.     }
  2101.     else if (replyindex != MMI_FRM_SMS_INVALID_INDEX)
  2102.     {
  2103.         sendData->sendrequire = MMI_FRM_SMS_REPLY;
  2104.         sendData->replyindex = replyindex;
  2105.     }
  2106. #ifdef __MMI_UNIFIED_MESSAGE__
  2107.     if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  2108.     {
  2109.         sendData->sendrequire |= MMI_FRM_SMS_NUM_SCR;
  2110.     }
  2111. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2112. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2113.     /* JP for tracker issue : 20050625 */
  2114.     if (g_nsm_msg_context.is_picmsg == TRUE)
  2115.     {
  2116.         mmi_nsm_get_picmsg_sendData(sendData);
  2117.     }
  2118. #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2119.     // #else
  2120. #if defined(__MMI_SMART_MESSAGE_MT__)
  2121.     if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  2122.     {
  2123.         mmi_nsm_get_picmsg_sendData(sendData);
  2124.     }
  2125. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  2126.     mmi_frm_sms_send_sms(mmi_msg_send_and_save_msg_rsp, MOD_MMI, sendData);
  2127.     OslMfree(sendData);
  2128. }
  2129. /*****************************************************************************
  2130.  * FUNCTION
  2131.  *  mmi_msg_save_msg_after_send_rsp
  2132.  * DESCRIPTION
  2133.  *  
  2134.  * PARAMETERS
  2135.  *  status      [?]         
  2136.  *  mod         [IN]        
  2137.  *  result      [IN]        
  2138.  * RETURNS
  2139.  *  void
  2140.  *****************************************************************************/
  2141. void mmi_msg_save_msg_after_send_rsp(void *status, module_type mod, U16 result)
  2142. {
  2143.     /*----------------------------------------------------------------*/
  2144.     /* Local Variables                                                */
  2145.     /*----------------------------------------------------------------*/
  2146.     U8 sendresult = *(U8*) status;
  2147.     /*----------------------------------------------------------------*/
  2148.     /* Code Body                                                      */
  2149.     /*----------------------------------------------------------------*/
  2150.     switch (result)
  2151.     {
  2152.         case MMI_FRM_SMS_OK:
  2153.     #ifdef __MMI_UNIFIED_MESSAGE__
  2154.             if (!mmi_msg_check_background_process())
  2155.             {
  2156.                 if (sendresult == SMSAL_STO_UNSENT)
  2157.                 {
  2158.                     DisplayPopup(
  2159.                         (PU8) GetString(STR_UM_SEND_FAILED_SAVE_SUCCESS_ID),
  2160.                         IMG_SEND_FAIL_PIC_MSG,
  2161.                         1,
  2162.                         MESSAGES_POPUP_TIME_OUT,
  2163.                         (U8) ERROR_TONE);
  2164.                 }
  2165.                 else
  2166.                 {
  2167.                     DisplayPopup(
  2168.                         (PU8) GetString(STR_UM_SEND_SAVE_SUCCESS_ID),
  2169.                         IMG_SEND_SUCCESS_PIC_MSG,
  2170.                         1,
  2171.                         MESSAGES_POPUP_TIME_OUT,
  2172.                         (U8) SUCCESS_TONE);
  2173.                 }
  2174.             }
  2175.     #else /* __MMI_UNIFIED_MESSAGE__ */ 
  2176.         {
  2177.             if (sendresult == SMSAL_STO_UNSENT)
  2178.             {
  2179.                 DisplayPopup(
  2180.                     (PU8) GetString(STR_SMS_SEND_FAILED_SAVE_SUCCESS),
  2181.                     IMG_SEND_FAIL_PIC_MSG,
  2182.                     1,
  2183.                     MESSAGES_POPUP_TIME_OUT,
  2184.                     (U8) ERROR_TONE);
  2185.             }
  2186.             else
  2187.             {
  2188.                 DisplayPopup(
  2189.                     (PU8) GetString(STR_SMS_SEND_SAVE_SUCESS),
  2190.                     IMG_SEND_SUCCESS_PIC_MSG,
  2191.                     1,
  2192.                     MESSAGES_POPUP_TIME_OUT,
  2193.                     (U8) SUCCESS_TONE);
  2194.             }
  2195.         }
  2196.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2197.     #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2198.             mmi_nsm2_init_nsm_msg_struct(&g_nsm_msg_context);   /* Reset after saving picture msg */
  2199.     #endif 
  2200.             break;
  2201.         case MMI_FRM_SMS_ERROR:
  2202.         case MMI_FRM_SMS_MEMFULL:
  2203.             if (sendresult == SMSAL_STO_UNSENT)
  2204.             {
  2205.             #ifdef __MMI_UNIFIED_MESSAGE__
  2206.                 if (!mmi_msg_check_background_process())
  2207.             #endif 
  2208.                 {
  2209.                     DisplayPopup(
  2210.                         (PU8) GetString(STR_SMS_SEND_SAVE_FAILED),
  2211.                         IMG_SEND_FAIL_PIC_MSG,
  2212.                         1,
  2213.                         MESSAGES_POPUP_TIME_OUT,
  2214.                         (U8) ERROR_TONE);
  2215.                 }
  2216.             #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2217.                 if (g_nsm_msg_context.is_picmsg == TRUE)
  2218.                 {
  2219.                     EMSData *pEMS;
  2220.                     GetEMSDataForEdit(&pEMS, 1);
  2221.                     AddString(
  2222.                         pEMS,
  2223.                         (U8*) g_nsm_msg_context.textbuffer,
  2224.                         (U16) pfnUnicodeStrlen((S8*) g_nsm_msg_context.textbuffer),
  2225.                         NULL);
  2226.                 }
  2227.             #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2228.             }
  2229.             else
  2230.             {
  2231.             #ifdef __MMI_UNIFIED_MESSAGE__
  2232.                 if (!mmi_msg_check_background_process())
  2233.             #endif 
  2234.                 {
  2235.                     DisplayPopup(
  2236.                         (PU8) GetString(STR_SMS_SEND_SUCESS_SAVE_FILED),
  2237.                         IMG_GLOBAL_UNFINISHED,
  2238.                         1,
  2239.                         MESSAGES_POPUP_TIME_OUT,
  2240.                         (U8) ERROR_TONE);
  2241.                 }
  2242.             }
  2243.             break;
  2244.         default:
  2245.         #ifdef __MMI_UNIFIED_MESSAGE__
  2246.             if (!mmi_msg_check_background_process())
  2247.         #endif 
  2248.             {
  2249.                 DisplayPopup(
  2250.                     (PU8) GetString(STR_SMS_SEND_SAVE_FAILED),
  2251.                     IMG_SEND_FAIL_PIC_MSG,
  2252.                     1,
  2253.                     MESSAGES_POPUP_TIME_OUT,
  2254.                     (U8) ERROR_TONE);
  2255.             }
  2256.         #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2257.             if (g_nsm_msg_context.is_picmsg == TRUE)
  2258.             {
  2259.                 EMSData *pEMS;
  2260.                 GetEMSDataForEdit(&pEMS, 1);
  2261.                 AddString(
  2262.                     pEMS,
  2263.                     (U8*) g_nsm_msg_context.textbuffer,
  2264.                     (U16) pfnUnicodeStrlen((S8*) g_nsm_msg_context.textbuffer),
  2265.                     NULL);
  2266.             }
  2267.         #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2268.             break;
  2269.     }
  2270. #ifdef __MMI_UNIFIED_MESSAGE__
  2271.     if (!mmi_msg_check_background_process())
  2272. #endif 
  2273.     {    
  2274.     #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  2275.         if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  2276.         {
  2277.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  2278.         }
  2279.         else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  2280.         {
  2281.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  2282.         }
  2283.         else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION))
  2284.         {
  2285.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_LIST_OPTION);
  2286.         }
  2287.         else
  2288.     #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  2289.     
  2290.         if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))            
  2291.         {
  2292.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  2293.         }
  2294.         else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  2295.         {
  2296.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  2297.         }
  2298.         else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
  2299.         {
  2300.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_MSG);
  2301.         }
  2302.     #ifdef __MMI_SMART_MESSAGE_MT__
  2303.         else if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY))
  2304.         {
  2305.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  2306.         }
  2307.     #endif /* __MMI_SMART_MESSAGE_MT__ */ 
  2308.         else if (IsScreenPresent(SCR_ID_MSG_TEMPLATE_OPTION))
  2309.         {
  2310.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_TEMPLATE_OPTION);
  2311.         }
  2312.         else if (IsScreenPresent(SCR_ID_MSG_WRITE))
  2313.         {
  2314.             SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  2315.         }
  2316.         DeleteMessagesHistoryNodes();
  2317.         mmi_frm_sms_delete_screen_history();
  2318.         AlmEnableSPOF();
  2319.     }
  2320. #ifdef __MMI_UNIFIED_MESSAGE__
  2321.     mmi_msg_set_background_process(KAL_FALSE);
  2322. #endif 
  2323. }
  2324. /*****************************************************************************
  2325.  * FUNCTION
  2326.  *  mmi_msg_save_msg_after_send_req
  2327.  * DESCRIPTION
  2328.  *  
  2329.  * PARAMETERS
  2330.  *  status      [IN]        
  2331.  *  number      [?]         
  2332.  * RETURNS
  2333.  *  void
  2334.  *****************************************************************************/
  2335. void mmi_msg_save_msg_after_send_req(U8 status, void *number)
  2336. {
  2337.     /*----------------------------------------------------------------*/
  2338.     /* Local Variables                                                */
  2339.     /*----------------------------------------------------------------*/
  2340.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  2341.     EMSData *data = GetEMSDataForEdit(0, 0);
  2342.     /*----------------------------------------------------------------*/
  2343.     /* Code Body                                                      */
  2344.     /*----------------------------------------------------------------*/
  2345.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  2346.     sendData->dcs = data->dcs;
  2347.     sendData->status = status;
  2348.     memcpy((S8*) sendData->number, (S8*) number, strlen((S8*) number));
  2349.     mmi_frm_sms_save_sms(mmi_msg_save_msg_after_send_rsp, MOD_MMI, sendData);
  2350.     OslMfree(sendData);
  2351. }
  2352. /*****************************************************************************
  2353.  * FUNCTION
  2354.  *  mmi_msg_save_msg_after_send_with_flag_req
  2355.  * DESCRIPTION
  2356.  *  
  2357.  * PARAMETERS
  2358.  *  status      [IN]        
  2359.  *  number      [?]         
  2360.  *  flag        [IN]        
  2361.  * RETURNS
  2362.  *  void
  2363.  *****************************************************************************/
  2364. void mmi_msg_save_msg_after_send_with_flag_req(U8 status, void *number, U16 flag)
  2365. {
  2366.     /*----------------------------------------------------------------*/
  2367.     /* Local Variables                                                */
  2368.     /*----------------------------------------------------------------*/
  2369.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  2370.     EMSData *data = GetEMSDataForEdit(0, 0);
  2371.     /*----------------------------------------------------------------*/
  2372.     /* Code Body                                                      */
  2373.     /*----------------------------------------------------------------*/
  2374.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  2375.     sendData->dcs = data->dcs;
  2376.     sendData->status = status;
  2377.     sendData->sendrequire = flag;
  2378.     memcpy((S8*) sendData->number, (S8*) number, strlen((S8*) number));
  2379.     mmi_frm_sms_save_sms(mmi_msg_save_msg_after_send_rsp, MOD_MMI, sendData);
  2380.     OslMfree(sendData);
  2381. }
  2382. /*****************************************************************************
  2383.  * FUNCTION
  2384.  *  mmi_msg_search_phb
  2385.  * DESCRIPTION
  2386.  *  
  2387.  * PARAMETERS
  2388.  *  void
  2389.  * RETURNS
  2390.  *  void
  2391.  *****************************************************************************/
  2392. void mmi_msg_search_phb(void)
  2393. {
  2394.     /*----------------------------------------------------------------*/
  2395.     /* Local Variables                                                */
  2396.     /*----------------------------------------------------------------*/
  2397.     /*----------------------------------------------------------------*/
  2398.     /* Code Body                                                      */
  2399.     /*----------------------------------------------------------------*/
  2400.     g_msg_cntx.PhbSmsInterfaceState = MMI_SEND_ONLY;
  2401.     mmi_phb_sms_enter_send_entry();
  2402. }
  2403. #ifdef __MMI_MESSAGES_SEND_TO_MANY__
  2404. /*****************************************************************************
  2405.  * FUNCTION
  2406.  *  mmi_msg_send_msg_to_many
  2407.  * DESCRIPTION
  2408.  *  
  2409.  * PARAMETERS
  2410.  *  void
  2411.  * RETURNS
  2412.  *  void
  2413.  *****************************************************************************/
  2414. void mmi_msg_send_msg_to_many(void)
  2415. {
  2416.     /*----------------------------------------------------------------*/
  2417.     /* Local Variables                                                */
  2418.     /*----------------------------------------------------------------*/
  2419.     U8 last = MAX_SEND_TO_MANY_ITEMS;
  2420.     S16 avail = -1;
  2421.     U8 total = 0;
  2422.     /*----------------------------------------------------------------*/
  2423.     /* Code Body                                                      */
  2424.     /*----------------------------------------------------------------*/
  2425.     while (last > 0)
  2426.     {
  2427.         last--;
  2428.         if (pfnUnicodeStrlen((S8*) g_msg_cntx.msg_send_info.PhbNumber[last]))
  2429.         {
  2430.             /* search for the first free entry to sort the list */
  2431.             while (avail < last)
  2432.             {
  2433.                 avail++;
  2434.                 if (!pfnUnicodeStrlen((S8*) g_msg_cntx.msg_send_info.PhbNumber[avail]))
  2435.                 {
  2436.                     memcpy(
  2437.                         g_msg_cntx.msg_send_info.PhbNumber[avail],
  2438.                         g_msg_cntx.msg_send_info.PhbNumber[last],
  2439.                         sizeof(g_msg_cntx.msg_send_info.PhbNumber[last]));
  2440.                     memset(g_msg_cntx.msg_send_info.PhbNumber[last], 0, ENCODING_LENGTH);
  2441.                     break;
  2442.                 }
  2443.             }
  2444.         }
  2445.     }
  2446.     /* calculate total valid entries */
  2447.     for (total = 0; total < MAX_SEND_TO_MANY_ITEMS; total++)
  2448.     {
  2449.         if (!pfnUnicodeStrlen((S8*) g_msg_cntx.msg_send_info.PhbNumber[total]))
  2450.         {
  2451.             break;
  2452.         }
  2453.     }
  2454.     if (avail == -1)
  2455.     {
  2456.         DisplayPopup(
  2457.             (PU8) GetString(STR_SMS_NUM_CANNOT_BE_EMPTY),
  2458.             IMG_GLOBAL_UNFINISHED,
  2459.             1,
  2460.             MESSAGES_POPUP_TIME_OUT,
  2461.             (U8) ERROR_TONE);
  2462.     }
  2463.     else
  2464.     {
  2465.         U8 length = pfnUnicodeStrlen(g_msg_cntx.msg_send_info.PhbNumber[0]);
  2466.         memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  2467.         g_msg_cntx.msg_send_info.TotalSendSmsNumbers = total;
  2468.         g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
  2469.         UnicodeNToAnsii(
  2470.             (S8*) g_msg_cntx.smsPhoneNumber,
  2471.             (S8*) g_msg_cntx.msg_send_info.PhbNumber[0],
  2472.             length * ENCODING_LENGTH);
  2473.         mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 1);
  2474.     }
  2475. }
  2476. #endif /* __MMI_MESSAGES_SEND_TO_MANY__ */ 
  2477. #ifdef __MMI_MESSAGES_SEND_BY_GROUP__
  2478. /*****************************************************************************
  2479.  * FUNCTION
  2480.  *  mmi_msg_send_msg_to_group
  2481.  * DESCRIPTION
  2482.  *  
  2483.  * PARAMETERS
  2484.  *  cnt             [IN]        
  2485.  *  PhbIndex        [?]         
  2486.  * RETURNS
  2487.  *  void
  2488.  *****************************************************************************/
  2489. void mmi_msg_send_msg_to_group(U16 cnt, U16 *PhbIndex)
  2490. {
  2491.     /*----------------------------------------------------------------*/
  2492.     /* Local Variables                                                */
  2493.     /*----------------------------------------------------------------*/
  2494.     U16 i;
  2495.     U16 actualCount;
  2496.     U8 length;
  2497.     U8 numbers[(MAX_DIGITS + 1) / 2];
  2498.     U8 tempNumber[MAX_DIGITS + 1];
  2499.     /*----------------------------------------------------------------*/
  2500.     /* Code Body                                                      */
  2501.     /*----------------------------------------------------------------*/
  2502.     if (cnt == 0)
  2503.     {
  2504.         DisplayPopup(
  2505.             (PU8) GetString(STR_MESSAGES_EMPTY_GROUP_ID),
  2506.             IMG_GLOBAL_EMPTY,
  2507.             1,
  2508.             MESSAGES_POPUP_TIME_OUT,
  2509.             (U8) EMPTY_LIST_TONE);
  2510.         return;
  2511.     }
  2512.     if (g_msg_cntx.msg_send_info.PhbIndex != NULL)
  2513.     {
  2514.         OslMfree(g_msg_cntx.msg_send_info.PhbIndex);
  2515.         g_msg_cntx.msg_send_info.PhbIndex = NULL;
  2516.     }
  2517.     g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 0;
  2518.     g_msg_cntx.msg_send_info.PhbIndex = OslMalloc(cnt * sizeof(U16));
  2519.     for (i = 0, actualCount = 0; i < cnt; i++)
  2520.     {
  2521.         length =
  2522.             (PhoneBook[PhbIndex[i]].tel.length >
  2523.              (MAX_DIGITS / 2)) ? (MAX_DIGITS / 2) : PhoneBook[PhbIndex[i]].tel.length;
  2524.         memset(numbers, 0, (MAX_DIGITS + 1) / 2);
  2525.         memcpy(numbers, PhoneBook[PhbIndex[i]].tel.number, length);
  2526.         if ((PhoneBook[PhbIndex[i]].tel.length == 0) ||
  2527.             (mmi_phb_convert_to_digit(tempNumber, (U8*) numbers, MAX_DIGITS + 1) == 0))
  2528.         {
  2529.             continue;
  2530.         }
  2531.         g_msg_cntx.msg_send_info.PhbIndex[actualCount] = PhbIndex[i];
  2532.         actualCount++;
  2533.     }
  2534.     g_msg_cntx.msg_send_info.TotalSendSmsNumbers = (U16) actualCount;
  2535.     if (g_msg_cntx.msg_send_info.TotalSendSmsNumbers > 0)
  2536.     {
  2537.         U8 PhbNuminBCD[(MAX_DIGITS + 1) / 2];
  2538.         U8 PhbNum[MAX_DIGITS + 1];
  2539.         S8 PhbNumUCS2[(MAX_DIGITS + 2) * ENCODING_LENGTH];
  2540.         U8 type = 0;
  2541.         length =
  2542.             (PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[0]].tel.length >
  2543.              (MAX_DIGITS / 2)) ? (MAX_DIGITS / 2) : PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[0]].tel.length;
  2544.         memset(PhbNuminBCD, 0, (MAX_DIGITS + 1) / 2);
  2545.         memcpy(PhbNuminBCD, PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[0]].tel.number, length);
  2546.         memset(PhbNum, 0, MAX_DIGITS + 1);
  2547.         mmi_phb_convert_to_digit((U8*) PhbNum, (U8*) PhbNuminBCD, MAX_DIGITS + 1);
  2548.         memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  2549.         if (PhoneBook[g_msg_cntx.msg_send_info.PhbIndex[0]].tel.type == CSMCC_INTERNATIONAL_ADDR)
  2550.         {
  2551.             type = 1;
  2552.             AnsiiToUnicodeString((S8*) PhbNumUCS2, "+");
  2553.         }
  2554.         AnsiiNToUnicodeString((S8*) PhbNumUCS2 + type * ENCODING_LENGTH, (S8*) PhbNum, length);
  2555.         g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
  2556.         UnicodeNToAnsii((S8*) g_msg_cntx.smsPhoneNumber, (S8*) PhbNumUCS2, (length + type) * ENCODING_LENGTH);
  2557.         mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 1);
  2558.     }
  2559.     else
  2560.     {
  2561.         if (g_msg_cntx.msg_send_info.PhbIndex != NULL)
  2562.         {
  2563.             OslMfree(g_msg_cntx.msg_send_info.PhbIndex);
  2564.             g_msg_cntx.msg_send_info.PhbIndex = NULL;
  2565.         }
  2566.         g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 0;
  2567.         DisplayPopup(
  2568.             (PU8) GetString(STR_MESSAGES_EMPTY_GROUP_ID),
  2569.             IMG_GLOBAL_EMPTY,
  2570.             1,
  2571.             MESSAGES_POPUP_TIME_OUT,
  2572.             (U8) EMPTY_LIST_TONE);
  2573.     }
  2574. }
  2575. /*****************************************************************************
  2576.  * FUNCTION
  2577.  *  mmi_msg_send_msg_by_group
  2578.  * DESCRIPTION
  2579.  *  
  2580.  * PARAMETERS
  2581.  *  void
  2582.  * RETURNS
  2583.  *  void
  2584.  *****************************************************************************/
  2585. void mmi_msg_send_msg_by_group(void)
  2586. {
  2587.     /*----------------------------------------------------------------*/
  2588.     /* Local Variables                                                */
  2589.     /*----------------------------------------------------------------*/
  2590.     /*----------------------------------------------------------------*/
  2591.     /* Code Body                                                      */
  2592.     /*----------------------------------------------------------------*/
  2593.     g_msg_cntx.sendMessageCase = SEND_CASE_SEND_BY_GROUP;
  2594.     mmi_phb_sms_enter_send_by_group();
  2595. }
  2596. #endif /* __MMI_MESSAGES_SEND_BY_GROUP__ */ 
  2597. /*****************************************************************************
  2598.  * FUNCTION
  2599.  *  mmi_msg_send_msg_to_only_entry
  2600.  * DESCRIPTION
  2601.  *  
  2602.  * PARAMETERS
  2603.  *  void
  2604.  * RETURNS
  2605.  *  void
  2606.  *****************************************************************************/
  2607. void mmi_msg_send_msg_to_only_entry(void)
  2608. {
  2609.     /*----------------------------------------------------------------*/
  2610.     /* Local Variables                                                */
  2611.     /*----------------------------------------------------------------*/
  2612.     /*----------------------------------------------------------------*/
  2613.     /* Code Body                                                      */
  2614.     /*----------------------------------------------------------------*/
  2615.     g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
  2616.     g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 1;
  2617.     /* pressing SEND key from send to many phone number editor  or send message from phonebook */
  2618.     if (g_msg_cntx.sendMessageCase == SEND_CASE_SEND_TO_MANY || g_msg_cntx.sendMessageCase == SEND_CASE_SEND_FROM_PHB)
  2619.     {
  2620.         S8 phonenumber[(MAX_DIGITS + 1) * ENCODING_LENGTH];
  2621.         U8 length = pfnUnicodeStrlen(g_msg_cntx.smsPhoneNumber);
  2622.         /* The length should be extracted by 1 for the sake of handling odd number of ascii phone number characters. */
  2623.         kal_bool isAsciiNumber = mmi_msg_check_ascii_number((U8*) g_msg_cntx.smsPhoneNumber, (U16) (length * ENCODING_LENGTH - 1));
  2624.         /* convert g_msg_cntx.smsPhoneNumber from unicode to ascii */
  2625.         if (!isAsciiNumber)
  2626.         {
  2627.             memset(phonenumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  2628.             pfnUnicodeStrncpy(phonenumber, g_msg_cntx.smsPhoneNumber, length * ENCODING_LENGTH);
  2629.             memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  2630.             UnicodeNToAnsii((S8*) g_msg_cntx.smsPhoneNumber, (S8*) phonenumber, length * ENCODING_LENGTH);
  2631.         }
  2632.     }
  2633.     else if (g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_PHB)
  2634.     {
  2635.         memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  2636.     #ifdef __MMI_UNIFIED_MESSAGE__
  2637.         if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  2638.         {
  2639.             memcpy(
  2640.                 g_msg_cntx.smsPhoneNumber,
  2641.                 (S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_UNSENT, (U16) g_msg_cntx.currBoxIndex),
  2642.                 MAX_DIGITS_SMS);
  2643.         }
  2644.     #else /* __MMI_UNIFIED_MESSAGE__ */ 
  2645.         if (GetMessagesCurrScrnID() == SCR_ID_MSG_OUTBOX_SEND_OPTION)
  2646.         {
  2647.         #ifdef __MMI_MESSAGES_DRAFT_BOX__
  2648.             if (IsScreenPresent(SCR_ID_MSG_DRAFTBOX_LIST))
  2649.             {
  2650.                 memcpy(
  2651.                     g_msg_cntx.smsPhoneNumber,
  2652.                     (S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex),
  2653.                     MAX_DIGITS_SMS);
  2654.             }
  2655.             else
  2656.         #endif /* __MMI_MESSAGES_DRAFT_BOX__ */ 
  2657.                 memcpy(
  2658.                     g_msg_cntx.smsPhoneNumber,
  2659.                     (S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_APP_OUTBOX, (U16) g_msg_cntx.currBoxIndex),
  2660.                     MAX_DIGITS_SMS);
  2661.         }
  2662.     #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2663.     }
  2664.     mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 0);
  2665. }
  2666. #ifdef __MMI_SEND_BY_SEARCH_NAME__
  2667. /*****************************************************************************
  2668.  * FUNCTION
  2669.  *  mmi_msg_send_msg_to_only_name_entry
  2670.  * DESCRIPTION
  2671.  *  
  2672.  * PARAMETERS
  2673.  *  void
  2674.  * RETURNS
  2675.  *  void
  2676.  *****************************************************************************/
  2677. void mmi_msg_send_msg_to_only_name_entry(void)
  2678. {
  2679.     /*----------------------------------------------------------------*/
  2680.     /* Local Variables                                                */
  2681.     /*----------------------------------------------------------------*/
  2682.     /*----------------------------------------------------------------*/
  2683.     /* Code Body                                                      */
  2684.     /*----------------------------------------------------------------*/
  2685.     g_msg_cntx.PhbSmsInterfaceState = MMI_SEND_BY_NAME;
  2686.     phbListView = MMI_PHB_LIST_FOR_SMS_SEARCH_NAME;
  2687.     memset(g_msg_cntx.smsPhoneNumber, 0, ENCODING_LENGTH);
  2688.     mmi_phb_search_name_pre_entry();
  2689. }
  2690. #endif /* __MMI_SEND_BY_SEARCH_NAME__ */ 
  2691. /*****************************************************************************
  2692.  * FUNCTION
  2693.  *  mmi_msg_save_msg_rsp
  2694.  * DESCRIPTION
  2695.  *  
  2696.  * PARAMETERS
  2697.  *  dummy       [?]         
  2698.  *  mod         [IN]        
  2699.  *  result      [IN]        
  2700.  * RETURNS
  2701.  *  void
  2702.  *****************************************************************************/
  2703. void mmi_msg_save_msg_rsp(void *dummy, module_type mod, U16 result)
  2704. {
  2705.     /*----------------------------------------------------------------*/
  2706.     /* Local Variables                                                */
  2707.     /*----------------------------------------------------------------*/
  2708.     U16 totalInbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_INBOX);
  2709.     U16 totalOutbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_OUTBOX);
  2710.     U16 totalDraftbox = mmi_frm_sms_get_sms_list_size(MMI_FRM_SMS_APP_DRAFTS);
  2711.     /*----------------------------------------------------------------*/
  2712.     /* Code Body                                                      */
  2713.     /*----------------------------------------------------------------*/
  2714. #ifdef __MMI_UNIFIED_MESSAGE__
  2715.     /* Skip UM write menu */
  2716.     if (IsScreenPresent(SCR_ID_MSG_WRITE_OPTION))
  2717.     {
  2718.         mmi_um_skip_write_menu(KAL_TRUE);
  2719.     }
  2720. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2721.     if (result == MMI_FRM_SMS_OK)
  2722.     {
  2723.         DisplayPopup(
  2724.             (PU8) GetString(STR_GLOBAL_DONE),
  2725.             IMG_GLOBAL_ACTIVATED,
  2726.             1,
  2727.             MESSAGES_POPUP_TIME_OUT,
  2728.             (U8) SUCCESS_TONE);
  2729.         ReleaseEMSEditBuffer();
  2730.     #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2731.         mmi_nsm2_init_nsm_msg_struct(&g_nsm_msg_context);   /* Reset after saving picture msg */
  2732.     #endif 
  2733.     }
  2734.     else
  2735.     {
  2736.         DisplayPopup(
  2737.             (PU8) GetString(STR_SMS_FAILURE_MEM_FULL),
  2738.             IMG_GLOBAL_UNFINISHED,
  2739.             1,
  2740.             MESSAGES_POPUP_TIME_OUT,
  2741.             (U8) WARNING_TONE);
  2742.     #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2743.         if (g_nsm_msg_context.is_picmsg == TRUE)
  2744.         {
  2745.             EMSData *pEMS;
  2746.             GetEMSDataForEdit(&pEMS, 1);
  2747.             AddString(
  2748.                 pEMS,
  2749.                 (U8*) g_nsm_msg_context.textbuffer,
  2750.                 (U16) pfnUnicodeStrlen((S8*) g_nsm_msg_context.textbuffer),
  2751.                 NULL);
  2752.         }
  2753.     #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2754.     }
  2755. #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  2756.     if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  2757.     {
  2758.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  2759.     }
  2760.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  2761.     {
  2762.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  2763.     }
  2764.     else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION))
  2765.     {
  2766.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_LIST_OPTION);
  2767.     }
  2768.     else
  2769. #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  2770.     
  2771.     if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  2772.     {
  2773.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  2774.     }
  2775.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  2776.     {
  2777.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  2778.     }
  2779.     else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_MSG))
  2780.     {
  2781.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_DEFAULT_MSG);
  2782.     }
  2783. #if defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2784.     else if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY))
  2785.     {
  2786.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  2787.     }
  2788. #endif /* defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2789.     else if (IsScreenPresent(SCR_ID_MSG_TEMPLATE_OPTION))
  2790.     {
  2791.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_TEMPLATE_OPTION);
  2792.     }
  2793.     else if (IsScreenPresent(SCR_ID_MSG_WRITE))
  2794.     {
  2795.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  2796.     }
  2797.     else
  2798.     {
  2799.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_PROCESSING);
  2800.     }
  2801.     DeleteMessagesHistoryNodes();
  2802.     mmi_msg_set_msg_num_hint(totalInbox, totalOutbox, totalDraftbox);
  2803. }
  2804. /*****************************************************************************
  2805.  * FUNCTION
  2806.  *  mmi_msg_save_msg_req
  2807.  * DESCRIPTION
  2808.  *  
  2809.  * PARAMETERS
  2810.  *  void
  2811.  * RETURNS
  2812.  *  void
  2813.  *****************************************************************************/
  2814. void mmi_msg_save_msg_req(void)
  2815. {
  2816.     /*----------------------------------------------------------------*/
  2817.     /* Local Variables                                                */
  2818.     /*----------------------------------------------------------------*/
  2819.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  2820.     /*----------------------------------------------------------------*/
  2821.     /* Code Body                                                      */
  2822.     /*----------------------------------------------------------------*/
  2823.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  2824.     sendData->status = SMSAL_STO_UNSENT;
  2825.     memset((S8*) sendData->number, 0, MAX_DIGITS_SMS);
  2826. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2827.     /* Jp for tracker issue 20050626 */
  2828.     if (g_nsm_msg_context.is_picmsg == TRUE)
  2829.     {
  2830.         mmi_nsm_get_picmsg_sendData(sendData);
  2831.     }
  2832. #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2833. #if defined(__MMI_SMART_MESSAGE_MT__)
  2834.     if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  2835.     {
  2836.         mmi_nsm_get_picmsg_sendData(sendData);
  2837.     }
  2838. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  2839.     mmi_frm_sms_save_sms(mmi_msg_save_msg_rsp, MOD_MMI, sendData);
  2840.     OslMfree(sendData);
  2841. }
  2842. /*****************************************************************************
  2843.  * FUNCTION
  2844.  *  mmi_msg_save_msg_with_flag_req
  2845.  * DESCRIPTION
  2846.  *  
  2847.  * PARAMETERS
  2848.  *  flag        [IN]        
  2849.  * RETURNS
  2850.  *  void
  2851.  *****************************************************************************/
  2852. void mmi_msg_save_msg_with_flag_req(U16 flag)
  2853. {
  2854.     /*----------------------------------------------------------------*/
  2855.     /* Local Variables                                                */
  2856.     /*----------------------------------------------------------------*/
  2857.     mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
  2858.     /*----------------------------------------------------------------*/
  2859.     /* Code Body                                                      */
  2860.     /*----------------------------------------------------------------*/
  2861.     memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
  2862.     sendData->status = SMSAL_STO_UNSENT;
  2863.     memset((S8*) sendData->number, 0, MAX_DIGITS_SMS);
  2864.     sendData->sendrequire = flag;
  2865. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  2866.     /* Jp for tracker issue 20050626 */
  2867.     if (g_nsm_msg_context.is_picmsg == TRUE)
  2868.     {
  2869.         mmi_nsm_get_picmsg_sendData(sendData);
  2870.     }
  2871. #endif /* (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  2872. #if defined(__MMI_SMART_MESSAGE_MT__)
  2873.     if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  2874.     {
  2875.         mmi_nsm_get_picmsg_sendData(sendData);
  2876.     }
  2877. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  2878.     mmi_frm_sms_save_sms(mmi_msg_save_msg_rsp, MOD_MMI, sendData);
  2879.     OslMfree(sendData);
  2880. }
  2881. /*****************************************************************************
  2882.  * FUNCTION
  2883.  *  mmi_msg_save_msg_to_entry
  2884.  * DESCRIPTION
  2885.  *  
  2886.  * PARAMETERS
  2887.  *  void
  2888.  * RETURNS
  2889.  *  void
  2890.  *****************************************************************************/
  2891. void mmi_msg_save_msg_to_entry(void)
  2892. {
  2893.     /*----------------------------------------------------------------*/
  2894.     /* Local Variables                                                */
  2895.     /*----------------------------------------------------------------*/
  2896.     /*----------------------------------------------------------------*/
  2897.     /* Code Body                                                      */
  2898.     /*----------------------------------------------------------------*/
  2899.     mmi_msg_set_processing_screen(STR_MESSAGE_MAIN_MENU_CAPTION, STR_GLOBAL_SAVING, IMG_GLOBAL_SAVE, 0);
  2900.     mmi_msg_entry_processing_generic();
  2901. #ifdef __MMI_UNIFIED_MESSAGE__
  2902.     if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_DRAFT)
  2903.     {
  2904.         /* mmi_msg_delete_msg_before_save_req(MMI_FRM_SMS_APP_DRAFTS, (U16)g_msg_cntx.currBoxIndex); */
  2905.         mmi_msg_delete_msg_before_save();
  2906.         return;
  2907.     }
  2908. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2909.     mmi_msg_save_msg_req();
  2910. }
  2911. /*****************************************************************************
  2912.  * FUNCTION
  2913.  *  mmi_msg_send_and_save_to_entry
  2914.  * DESCRIPTION
  2915.  *  
  2916.  * PARAMETERS
  2917.  *  void
  2918.  * RETURNS
  2919.  *  void
  2920.  *****************************************************************************/
  2921. void mmi_msg_send_and_save_to_entry(void)
  2922. {
  2923.     /*----------------------------------------------------------------*/
  2924.     /* Local Variables                                                */
  2925.     /*----------------------------------------------------------------*/
  2926.     /*----------------------------------------------------------------*/
  2927.     /* Code Body                                                      */
  2928.     /*----------------------------------------------------------------*/
  2929. #ifdef __MMI_UNIFIED_MESSAGE__
  2930.     if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
  2931.     {
  2932.         mmi_msg_send_and_save_msg_req(
  2933.             mmi_frm_sms_get_address(MMI_FRM_SMS_UNSENT, (U16) g_msg_cntx.currBoxIndex),
  2934.             MMI_FRM_SMS_INVALID_INDEX);
  2935.     }
  2936.     else
  2937. #endif /* __MMI_UNIFIED_MESSAGE__ */ 
  2938.     {
  2939.         mmi_msg_send_and_save_msg_req(NULL, MMI_FRM_SMS_INVALID_INDEX);
  2940.     }
  2941. }
  2942. /*****************************************************************************
  2943.  * FUNCTION
  2944.  *  mmi_msg_reply_msg
  2945.  * DESCRIPTION
  2946.  *  
  2947.  * PARAMETERS
  2948.  *  void
  2949.  * RETURNS
  2950.  *  void
  2951.  *****************************************************************************/
  2952. void mmi_msg_reply_msg(void)
  2953. {
  2954.     /*----------------------------------------------------------------*/
  2955.     /* Local Variables                                                */
  2956.     /*----------------------------------------------------------------*/
  2957.     /*----------------------------------------------------------------*/
  2958.     /* Code Body                                                      */
  2959.     /*----------------------------------------------------------------*/
  2960.     memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  2961.     g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
  2962.     g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 1;
  2963.     mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, (U16) g_msg_cntx.currBoxIndex, 1);
  2964. }
  2965. /*****************************************************************************
  2966.  * FUNCTION
  2967.  *  mmi_msg_reply_msg_to_entry
  2968.  * DESCRIPTION
  2969.  *  
  2970.  * PARAMETERS
  2971.  *  void
  2972.  * RETURNS
  2973.  *  void
  2974.  *****************************************************************************/
  2975. void mmi_msg_reply_msg_to_entry(void)
  2976. {
  2977.     /*----------------------------------------------------------------*/
  2978.     /* Local Variables                                                */
  2979.     /*----------------------------------------------------------------*/
  2980.     /*----------------------------------------------------------------*/
  2981.     /* Code Body                                                      */
  2982.     /*----------------------------------------------------------------*/
  2983. #ifdef __MMI_UNIFIED_COMPOSER__
  2984.     U8 *replyaddr = mmi_frm_sms_get_sms_address(MMI_FRM_SMS_INBOX, (U16)g_msg_cntx.currBoxIndex);
  2985.     ReleaseEMSEditBuffer();
  2986.     mmi_msg_entry_uc(replyaddr , (U16)MMI_UC_STATE_REPLY, (U16)g_msg_cntx.currBoxIndex, MMI_UC_MSG_TYPE_DEFAULT);
  2987. #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  2988.     if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  2989.     {
  2990.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  2991.     }
  2992.     else
  2993. #endif /* __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__ */
  2994.     if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  2995.     {
  2996.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  2997.     }
  2998.     else
  2999.     {
  3000.         MMI_ASSERT(0);
  3001.     }
  3002.     
  3003.     DeleteMessagesHistoryNodes();
  3004.     return;
  3005. #else /* __MMI_UNIFIED_COMPOSER__ */
  3006.     g_msg_cntx.sendMessageCase = SEND_CASE_REPLY;
  3007.     ReleaseEMSEditBuffer();
  3008. #if (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  3009.     mmi_nsm2_init_nsm_msg_struct(&g_nsm_msg_context);
  3010. #endif 
  3011.     mmi_msg_entry_write_msg();
  3012. #endif /* __MMI_UNIFIED_COMPOSER__ */
  3013. }
  3014. /*****************************************************************************
  3015.  * FUNCTION
  3016.  *  mmi_msg_get_number_from_phb
  3017.  * DESCRIPTION
  3018.  *  
  3019.  * PARAMETERS
  3020.  *  name        [?]     
  3021.  *  number      [?]     
  3022.  * RETURNS
  3023.  *  void
  3024.  *****************************************************************************/
  3025. void mmi_msg_get_number_from_phb(U8 name[], U8 number[])
  3026. {
  3027.     /*----------------------------------------------------------------*/
  3028.     /* Local Variables                                                */
  3029.     /*----------------------------------------------------------------*/
  3030. #ifdef __MMI_UNIFIED_COMPOSER__
  3031.     U8 ascii_num[MAX_DIGITS_SMS + 1];
  3032. #endif /* __MMI_UNIFIED_COMPOSER__ */     
  3033.     /*----------------------------------------------------------------*/
  3034.     /* Code Body                                                      */
  3035.     /*----------------------------------------------------------------*/
  3036.     if (pfnUnicodeStrlen((PS8) number) > (MAX_DIGITS_SMS - 1))
  3037.     {
  3038.         DisplayPopup(
  3039.             (PU8) GetString(STR_SMS_NUM_LEN_EXCEEDED),
  3040.             IMG_GLOBAL_UNFINISHED,
  3041.             1,
  3042.             PHB_NOTIFY_TIMEOUT,
  3043.             (U8) ERROR_TONE);
  3044.         return;
  3045.     }
  3046.     memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  3047.     if (number)
  3048.     {
  3049.         pfnUnicodeStrcpy(g_msg_cntx.smsPhoneNumber, (PS8) number);
  3050.     }
  3051.     if (g_msg_cntx.PhbSmsInterfaceState == MMI_SEND_SMS_FROM_PHB)
  3052.     {
  3053.     #ifdef __MMI_UNIFIED_COMPOSER__
  3054.         memset(ascii_num, 0, sizeof(ascii_num));            
  3055.         UnicodeToAnsii((S8*)ascii_num, (S8*)number);
  3056.         mmi_msg_entry_uc(ascii_num, MMI_UC_STATE_WRITE_NEW_MSG, 0, MMI_UC_MSG_TYPE_SMS_ONLY);    
  3057.     #else /* __MMI_UNIFIED_COMPOSER__ */
  3058.         g_msg_cntx.sendMessageCase = SEND_CASE_SEND_FROM_PHB;
  3059.         mmi_msg_entry_write_msg();
  3060.     #endif /* __MMI_UNIFIED_COMPOSER__ */ 
  3061.     }
  3062.     else if (IsScreenPresent(SCR_ID_MSG_NUMBER))
  3063.     {
  3064.         /* put the selected number to editor */
  3065.         HistoryReplace(SCR_ID_MSG_NUMBER, SCR_ID_MSG_NUMBER, mmi_msg_entry_phone_number);
  3066.         GoBackToHistory(SCR_ID_MSG_NUMBER);
  3067.     }
  3068.     else
  3069.     {
  3070.         mmi_msg_entry_phone_number();
  3071.     }
  3072. }
  3073. #ifdef __MMI_UNIFIED_COMPOSER__
  3074. /*****************************************************************************
  3075.  * FUNCTION
  3076.  *  mmi_msg_edit_msg_by_uc
  3077.  * DESCRIPTION
  3078.  *  Edit msg by unified composer
  3079.  * PARAMETERS
  3080.  *  void
  3081.  * RETURNS
  3082.  *  void
  3083.  *****************************************************************************/
  3084. void mmi_msg_edit_msg_by_uc(void)
  3085. {
  3086.     /*----------------------------------------------------------------*/
  3087.     /* Local Variables                                                */
  3088.     /*----------------------------------------------------------------*/
  3089.     UmMsgBoxType msgbox_type = mmi_um_get_current_msg_box_type();
  3090.     U8* addr = NULL;
  3091.     /*----------------------------------------------------------------*/
  3092.     /* Code Body                                                      */
  3093.     /*----------------------------------------------------------------*/
  3094.     if (msgbox_type == UM_MSG_BOX_TYPE_INBOX)
  3095.     {
  3096.         addr = mmi_frm_sms_get_address(MMI_FRM_SMS_INBOX, (U16) g_msg_cntx.currBoxIndex);
  3097.     }
  3098.     else if (msgbox_type == UM_MSG_BOX_TYPE_UNSENT)
  3099.     {
  3100.         addr = mmi_frm_sms_get_address(MMI_FRM_SMS_UNSENT, (U16) g_msg_cntx.currBoxIndex);
  3101.     }
  3102.     else if (msgbox_type == UM_MSG_BOX_TYPE_SENT)
  3103.     {
  3104.         addr = mmi_frm_sms_get_address(MMI_FRM_SMS_OUTBOX, (U16) g_msg_cntx.currBoxIndex);
  3105.     }
  3106.     else if (msgbox_type == UM_MSG_BOX_TYPE_DRAFT)
  3107.     {
  3108.         addr = mmi_frm_sms_get_address(MMI_FRM_SMS_DRAFTS, (U16) g_msg_cntx.currBoxIndex);
  3109.     }
  3110.     else
  3111.     {
  3112.         MMI_ASSERT(0);
  3113.     }
  3114.     
  3115.     mmi_msg_entry_uc(addr , MMI_UC_STATE_EDIT_EXISTED_MSG, (U16)g_msg_cntx.currBoxIndex, MMI_UC_MSG_TYPE_DEFAULT);
  3116. #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  3117.     if (IsScreenPresent(SCR_ID_MSG_INBOX_LIST_OPTION))
  3118.     {
  3119.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_LIST_OPTION);
  3120.     }
  3121.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST_OPTION))
  3122.     {
  3123.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_LIST_OPTION);
  3124.     }
  3125.     else if (IsScreenPresent(SCR_ID_MSG_DEFAULT_LIST_OPTION))