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

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.  * ChatAppGuiInterface.C
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for Chat 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.  *------------------------------------------------------------------------------
  128.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  129.  *============================================================================
  130.  ****************************************************************************/
  131. /**
  132.  * Copyright Notice
  133.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  134.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  135.  *  (It is illegal to remove this copyright notice from this software or any
  136.  *  portion of it)
  137.  */
  138. /**************************************************************
  139.    FILENAME : ChatAppGuiInterface.c
  140.    PURPOSE     : To Provide GUI Interface functions  
  141.    REMARKS     : nil
  142.    AUTHOR      : Alok Sharma     
  143.    DATE     : Feb 18,04
  144. **************************************************************/
  145. #include "MMI_features.h"
  146. #ifdef __MMI_MESSAGES_CHAT__
  147. #include "stdC.h"
  148. #include "L4Dr1.h"
  149. #include "PixtelDataTypes.h"
  150. #include "EventsGprot.h"
  151. #include "HistoryGprot.h"
  152. #include "GlobalMenuItems.h"
  153. #include "GlobalConstants.h"
  154. #include "Globaldefs.h"
  155. #include "wgui_categories.h"
  156. #include "wgui_categories_inputs.h"
  157. #include "wgui_categories_popup.h"
  158. #include "wgui_status_icons.h"
  159. #include "CustMenuRes.h"
  160. #include "CommonScreens.h"
  161. #include "Unicodexdcl.h"
  162. #include "TimerEvents.h"
  163. #include "DebugInitDef.h"
  164. #include "ProtocolEvents.h"
  165. #include "ChatAppDef.h"
  166. #include "ChatGtype.h"
  167. #include "ChatAppprot.h"
  168. #include "ChatAppGexdcl.h"
  169. #include "ChatAppGprot.h"
  170. #include "EmsMiscell.h"
  171. #include "SettingProfile.h"
  172. #include "MessagesL4Def.h"
  173. #include "MessagesExDcl.h"
  174. #include "SmsGuiInterfaceProt.h"
  175. #include "PhoneBookTypes.h"
  176. #include "PhoneBookGprot.h"
  177. #include "PhoneBookProt.h"
  178. #include "PhoneBookDef.h"
  179. #include "wgui_ems.h"
  180. #include "ProfileGprots.h"
  181. #include "NVRAMEnum.h"
  182. #include "NVRAMProt.h"
  183. #include "MessagesResourceData.h"
  184. #include "SMSAPI.h"
  185. #include "l4dr.h"
  186. #ifdef __MMI_UNIFIED_MESSAGE__
  187. #include "UnifiedMessageDef.h"
  188. #endif
  189. /****************Static Variable Start*********/
  190. static U8 gSetChatFlagNameNumber = 0;
  191. static S32 gHilightedChatRoomInfoItem;
  192. static U8 gNickname[(MAX_NICKNAME_LENGTH + 1) * ENCODING_LENGTH];
  193. static U8 gDestinationNo[(MAX_PHONE_NUMBER_LENGTH + 2) * ENCODING_LENGTH];
  194. static U16 gDetailChatRoomInfoImageList[4];
  195. static pBOOL gQuitFlag;
  196. static S16 currentMsgCount;
  197. static S8 gNumbersList[(MAX_PHONE_NUMBER_LENGTH + 2) * ENCODING_LENGTH];
  198. /****************Static Variable End*********/
  199. /****************Static Function Start*********/
  200. /****************Static Function End*********/
  201. /****************Global Variable Start*********/
  202. pBOOL gInputBoxUcs2Flag;
  203. pBOOL gOutBoxSaveFlag;
  204. /****************Global Variable End*********/
  205. /****************Function Start*********/
  206.  /****************Function End*********/
  207. /*********Extern Variable**********/
  208. /* Deepali */
  209. extern chat_context_struct g_chat_cntx;
  210. extern MMI_PHB_LIST_VIEW phbListView;
  211. extern U8 gIsItChatSmsArrivalInd;
  212. extern U8 gIsThereAnyNewChatSMSToInd;
  213. extern wgui_inline_item wgui_inline_items[];
  214. extern const U16 gChatSmsIcon[];
  215. /*********Extern Function**********/
  216. extern S32 GetInlineListMenuChanged(void);
  217. extern EMSData *GetEMSDataForEdit(EMSData **p, U8 force);
  218. extern void ReleaseEMSEditBuffer(void);
  219.  /**************************End****************************/
  220. /*****************************************************************************
  221.  * FUNCTION
  222.  *  SetChatHiliteHandlers
  223.  * DESCRIPTION
  224.  *  It Sets Hilite Handler of Chat Menu items
  225.  * PARAMETERS
  226.  *  void
  227.  * RETURNS
  228.  *  void
  229.  *****************************************************************************/
  230. void SetChatHiliteHandlers(void)
  231. {
  232.     /*----------------------------------------------------------------*/
  233.     /* Local Variables                                                */
  234.     /*----------------------------------------------------------------*/
  235.     /*----------------------------------------------------------------*/
  236.     /* Code Body                                                      */
  237.     /*----------------------------------------------------------------*/
  238.     SetHiliteHandler(MENU_CHAT_ROOM1, HighlightChatRooM1);
  239.     SetHiliteHandler(MENU_CHAT_ROOM2, HighlightChatRooM2);
  240.     SetHiliteHandler(MENU_CHATROOM_INFO, HighlightChatRoomInfo);
  241.     SetHiliteHandler(MENU_START_NEW, HighlightChatStartMenu);
  242.     SetHiliteHandler(MENU_RESUME_CHAT, HighlightChatResumeMenu);
  243.     SetHiliteHandler(MENU_END_CHAT, HighlightChatEndMenu);
  244.     SetHiliteHandler(MENU_CHATMSG_SEND, HighlightChatSend);
  245.     SetHiliteHandler(MENU_CHATAPP_TEMPLATE, HighlightChatTemplate);
  246.     SetHiliteHandler(MENU_CHAT_PHB_NUM, HighlightChatPhbNum);
  247.     SetHiliteHandler(MENU_CHAT_PHB_NAM, HighlightChatPhbNam);
  248.     SetHiliteHandler(MENU_CHAT_INPUT_METHOD, HighlightChatInputMethod);
  249.     SetHiliteHandler(MENU_CHAT_REPLY_SCRN, HighlightChatReply);
  250.     SetHiliteHandler(MENU_CHAT_USE_NUM_SCRN, HighlightChatUseNumMethod);
  251.     SetHiliteHandler(MENU_CHAT_CLEAR_SCRN, HighlightChatClearMethod);
  252.     SetHiliteHandler(MENU_CHAT_TEMP_SCRN, HighlightChatTempLeaveMethod);
  253.     SetHiliteHandler(MENU_CHAT_QUIT_SCRN, HighlightChatQuitMethod);
  254.     /* SetHiliteHandler (MENU_CHAT_SAVE,HighlititeChatSaveOutBox); */
  255. }
  256. /****************/
  257. /* Highlight Function */
  258. /****************/
  259. /*****************************************************************************
  260.  * FUNCTION
  261.  *  HighlightChatRooM1
  262.  * DESCRIPTION
  263.  *  Hilite function of Chat Room1
  264.  * PARAMETERS
  265.  *  void
  266.  * RETURNS
  267.  *  void
  268.  *****************************************************************************/
  269. void HighlightChatRooM1(void)
  270. {
  271.     /*----------------------------------------------------------------*/
  272.     /* Local Variables                                                */
  273.     /*----------------------------------------------------------------*/
  274.     /*----------------------------------------------------------------*/
  275.     /* Code Body                                                      */
  276.     /*----------------------------------------------------------------*/
  277.     SetCurrentChatRoomNo(CHAT_ROOM1);
  278.     gChatInvitation = FALSE;
  279.     gDestinationNo[0] = '';
  280.     gNickname[0] = '';
  281.     ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OK);
  282.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  283.     SetLeftSoftkeyFunction(EntryChatOption, KEY_EVENT_UP);
  284.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  285.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  286.     SetKeyHandler(EntryChatOption, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  287. }
  288. /*****************************************************************************
  289.  * FUNCTION
  290.  *  HighlightChatRooM2
  291.  * DESCRIPTION
  292.  *  Hilite function of Chat Room2
  293.  * PARAMETERS
  294.  *  void
  295.  * RETURNS
  296.  *  void
  297.  *****************************************************************************/
  298. void HighlightChatRooM2(void)
  299. {
  300.     /*----------------------------------------------------------------*/
  301.     /* Local Variables                                                */
  302.     /*----------------------------------------------------------------*/
  303.     /*----------------------------------------------------------------*/
  304.     /* Code Body                                                      */
  305.     /*----------------------------------------------------------------*/
  306.     SetCurrentChatRoomNo(CHAT_ROOM2);
  307.     gChatInvitation = FALSE;
  308.     gDestinationNo[0] = '';
  309.     gNickname[0] = '';
  310.     ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OK);
  311.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  312.     SetLeftSoftkeyFunction(EntryChatOption, KEY_EVENT_UP);
  313.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  314.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  315.     SetKeyHandler(EntryChatOption, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  316. }
  317. /*****************************************************************************
  318.  * FUNCTION
  319.  *  HighlightChatRoomInfo
  320.  * DESCRIPTION
  321.  *  Hilite function of Chat Room Info
  322.  * PARAMETERS
  323.  *  void
  324.  * RETURNS
  325.  *  void
  326.  *****************************************************************************/
  327. void HighlightChatRoomInfo(void)
  328. {
  329.     /*----------------------------------------------------------------*/
  330.     /* Local Variables                                                */
  331.     /*----------------------------------------------------------------*/
  332.     /*----------------------------------------------------------------*/
  333.     /* Code Body                                                      */
  334.     /*----------------------------------------------------------------*/
  335.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  336.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  337.     SetLeftSoftkeyFunction(EntryChatRoomInfo, KEY_EVENT_UP);
  338.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  339.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  340. }
  341. /*****************************************************************************
  342.  * FUNCTION
  343.  *  HighlightChatStartMenu
  344.  * DESCRIPTION
  345.  *  Hilite function of Chat Start Menu
  346.  * PARAMETERS
  347.  *  void
  348.  * RETURNS
  349.  *  void
  350.  *****************************************************************************/
  351. void HighlightChatStartMenu(void)
  352. {
  353.     /*----------------------------------------------------------------*/
  354.     /* Local Variables                                                */
  355.     /*----------------------------------------------------------------*/
  356.     /*----------------------------------------------------------------*/
  357.     /* Code Body                                                      */
  358.     /*----------------------------------------------------------------*/
  359.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  360.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  361.     /* reset message content in case the message in different chatroom using different encoding scheme */
  362.     memset(g_chat_cntx.writeChatBuffer, 0, (MAX_MSG_SIZE + 1) * ENCODING_LENGTH);
  363.     SetLeftSoftkeyFunction(EntryChatWrite, KEY_EVENT_UP);
  364.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  365.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  366. }
  367. /*****************************************************************************
  368.  * FUNCTION
  369.  *  HighlightChatResumeMenu
  370.  * DESCRIPTION
  371.  *  Hilite function of Chat Resume Menu
  372.  * PARAMETERS
  373.  *  void
  374.  * RETURNS
  375.  *  void
  376.  *****************************************************************************/
  377. void HighlightChatResumeMenu(void)
  378. {
  379.     /*----------------------------------------------------------------*/
  380.     /* Local Variables                                                */
  381.     /*----------------------------------------------------------------*/
  382.     /*----------------------------------------------------------------*/
  383.     /* Code Body                                                      */
  384.     /*----------------------------------------------------------------*/
  385.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  386.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  387.     SetLeftSoftkeyFunction(EntryChatRoom, KEY_EVENT_UP);
  388.     SetKeyHandler(EntryChatRoom, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  389.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  390.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  391. }
  392. /*****************************************************************************
  393.  * FUNCTION
  394.  *  HighlightChatEndMenu
  395.  * DESCRIPTION
  396.  *  Hilite function of Chat End Menu
  397.  * PARAMETERS
  398.  *  void
  399.  * RETURNS
  400.  *  void
  401.  *****************************************************************************/
  402. void HighlightChatEndMenu(void)
  403. {
  404.     /*----------------------------------------------------------------*/
  405.     /* Local Variables                                                */
  406.     /*----------------------------------------------------------------*/
  407.     /*----------------------------------------------------------------*/
  408.     /* Code Body                                                      */
  409.     /*----------------------------------------------------------------*/
  410.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  411.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  412.     SetLeftSoftkeyFunction(PreEntryChatQuitConfirm, KEY_EVENT_UP);
  413.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  414. }
  415. /*****************************************************************************
  416.  * FUNCTION
  417.  *  HighlightChatSend
  418.  * DESCRIPTION
  419.  *  Hilite Send function
  420.  * PARAMETERS
  421.  *  void
  422.  * RETURNS
  423.  *  void
  424.  *****************************************************************************/
  425. void HighlightChatSend(void)
  426. {
  427.     /*----------------------------------------------------------------*/
  428.     /* Local Variables                                                */
  429.     /*----------------------------------------------------------------*/
  430.     /*----------------------------------------------------------------*/
  431.     /* Code Body                                                      */
  432.     /*----------------------------------------------------------------*/
  433.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  434.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  435.     SetLeftSoftkeyFunction(PreSendChatMsg, KEY_EVENT_UP);
  436.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  437. }
  438. /*****************************************************************************
  439.  * FUNCTION
  440.  *  HighlightChatTemplate
  441.  * DESCRIPTION
  442.  *  Hilite ChatTemplate
  443.  * PARAMETERS
  444.  *  void
  445.  * RETURNS
  446.  *  void
  447.  *****************************************************************************/
  448. void HighlightChatTemplate(void)
  449. {
  450.     /*----------------------------------------------------------------*/
  451.     /* Local Variables                                                */
  452.     /*----------------------------------------------------------------*/
  453.     /*----------------------------------------------------------------*/
  454.     /* Code Body                                                      */
  455.     /*----------------------------------------------------------------*/
  456.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  457.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  458.     SetLeftSoftkeyFunction(mmi_msg_entry_template_list, KEY_EVENT_UP);
  459.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  460. }
  461. /*****************************************************************************
  462.  * FUNCTION
  463.  *  HighlightChatPhbNum
  464.  * DESCRIPTION
  465.  *  Hilite Function for Phone Book Number
  466.  * PARAMETERS
  467.  *  void
  468.  * RETURNS
  469.  *  void
  470.  *****************************************************************************/
  471. void HighlightChatPhbNum(void)
  472. {
  473.     /*----------------------------------------------------------------*/
  474.     /* Local Variables                                                */
  475.     /*----------------------------------------------------------------*/
  476.     /*----------------------------------------------------------------*/
  477.     /* Code Body                                                      */
  478.     /*----------------------------------------------------------------*/
  479.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  480.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  481.     SetLeftSoftkeyFunction(EnterPhoneBookForChatNumberApp, KEY_EVENT_UP);
  482.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  483. }
  484. /*****************************************************************************
  485.  * FUNCTION
  486.  *  HighlightChatPhbNam
  487.  * DESCRIPTION
  488.  *  Hilite Phone Book Name function
  489.  * PARAMETERS
  490.  *  void
  491.  * RETURNS
  492.  *  void
  493.  *****************************************************************************/
  494. void HighlightChatPhbNam(void)
  495. {
  496.     /*----------------------------------------------------------------*/
  497.     /* Local Variables                                                */
  498.     /*----------------------------------------------------------------*/
  499.     /*----------------------------------------------------------------*/
  500.     /* Code Body                                                      */
  501.     /*----------------------------------------------------------------*/
  502.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  503.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  504.     SetLeftSoftkeyFunction(EnterPhoneBookForChatNameApp, KEY_EVENT_UP);
  505.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  506. }
  507. /*****************************************************************************
  508.  * FUNCTION
  509.  *  HighlightChatInputMethod
  510.  * DESCRIPTION
  511.  *  Hilite Function for Chat Input Method
  512.  * PARAMETERS
  513.  *  void
  514.  * RETURNS
  515.  *  void
  516.  *****************************************************************************/
  517. void HighlightChatInputMethod(void)
  518. {
  519.     /*----------------------------------------------------------------*/
  520.     /* Local Variables                                                */
  521.     /*----------------------------------------------------------------*/
  522.     /*----------------------------------------------------------------*/
  523.     /* Code Body                                                      */
  524.     /*----------------------------------------------------------------*/
  525.     SetInputMethodAndDoneCaptionIcon(CHAT_IMAGE_APP_ID);
  526.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  527.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  528.     SetLeftSoftkeyFunction(EntryInputMethodScreen, KEY_EVENT_UP);
  529.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  530.     RegisterInputMethodScreenCloseFunction(GoBackHistoryFromChatInputMethod);
  531. }
  532. /*****************************************************************************
  533.  * FUNCTION
  534.  *  HighlightChatReply
  535.  * DESCRIPTION
  536.  *  Hilite function of Chat Reply Screen
  537.  * PARAMETERS
  538.  *  void
  539.  * RETURNS
  540.  *  void
  541.  *****************************************************************************/
  542. void HighlightChatReply(void)
  543. {
  544.     /*----------------------------------------------------------------*/
  545.     /* Local Variables                                                */
  546.     /*----------------------------------------------------------------*/
  547.     /*----------------------------------------------------------------*/
  548.     /* Code Body                                                      */
  549.     /*----------------------------------------------------------------*/
  550.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  551.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  552.     /* reset message content in case the message in different chatroom using different encoding scheme */
  553.     memset(g_chat_cntx.writeChatBuffer, 0, (MAX_MSG_SIZE + 1) * ENCODING_LENGTH);
  554.     SetLeftSoftkeyFunction(EntryChatWrite, KEY_EVENT_UP);
  555.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  556. }
  557. /*****************************************************************************
  558.  * FUNCTION
  559.  *  HighlightChatUseNumMethod
  560.  * DESCRIPTION
  561.  *  Hilite function of Chat Use Number method
  562.  * PARAMETERS
  563.  *  void
  564.  * RETURNS
  565.  *  void
  566.  *****************************************************************************/
  567. void HighlightChatUseNumMethod(void)
  568. {
  569.     /*----------------------------------------------------------------*/
  570.     /* Local Variables                                                */
  571.     /*----------------------------------------------------------------*/
  572.     /*----------------------------------------------------------------*/
  573.     /* Code Body                                                      */
  574.     /*----------------------------------------------------------------*/
  575.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  576.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  577.     SetLeftSoftkeyFunction(mmi_msg_entry_use_number, KEY_EVENT_UP);
  578.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  579. }
  580. /*****************************************************************************
  581.  * FUNCTION
  582.  *  HighlightChatClearMethod
  583.  * DESCRIPTION
  584.  *  Hilite Handler of Chat Clear Method
  585.  * PARAMETERS
  586.  *  void
  587.  * RETURNS
  588.  *  void
  589.  *****************************************************************************/
  590. void HighlightChatClearMethod(void)
  591. {
  592.     /*----------------------------------------------------------------*/
  593.     /* Local Variables                                                */
  594.     /*----------------------------------------------------------------*/
  595.     /*----------------------------------------------------------------*/
  596.     /* Code Body                                                      */
  597.     /*----------------------------------------------------------------*/
  598.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  599.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  600.     SetLeftSoftkeyFunction(EntryClearChatRoomConfirm, KEY_EVENT_UP);
  601.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  602. }
  603. /*****************************************************************************
  604.  * FUNCTION
  605.  *  HighlightChatTempLeaveMethod
  606.  * DESCRIPTION
  607.  *  Hilite Handler of Chat Temp Leave Method
  608.  * PARAMETERS
  609.  *  void
  610.  * RETURNS
  611.  *  void
  612.  *****************************************************************************/
  613. void HighlightChatTempLeaveMethod(void)
  614. {
  615.     /*----------------------------------------------------------------*/
  616.     /* Local Variables                                                */
  617.     /*----------------------------------------------------------------*/
  618.     /*----------------------------------------------------------------*/
  619.     /* Code Body                                                      */
  620.     /*----------------------------------------------------------------*/
  621.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  622.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  623.     SetLeftSoftkeyFunction(TempleaveChatApp, KEY_EVENT_UP);
  624.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  625. }
  626. /*****************************************************************************
  627.  * FUNCTION
  628.  *  HighlightChatQuitMethod
  629.  * DESCRIPTION
  630.  *  Hilite Handler of Chat Quit Method
  631.  * PARAMETERS
  632.  *  void
  633.  * RETURNS
  634.  *  void
  635.  *****************************************************************************/
  636. void HighlightChatQuitMethod(void)
  637. {
  638.     /*----------------------------------------------------------------*/
  639.     /* Local Variables                                                */
  640.     /*----------------------------------------------------------------*/
  641.     /*----------------------------------------------------------------*/
  642.     /* Code Body                                                      */
  643.     /*----------------------------------------------------------------*/
  644.     gQuitFlag = TRUE;
  645.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  646.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  647.     SetLeftSoftkeyFunction(EntryChatQuitConfirm, KEY_EVENT_UP);
  648.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  649. }
  650. /*****************************************************************************
  651.  * FUNCTION
  652.  *  HighlititeChatSaveOutBox
  653.  * DESCRIPTION
  654.  *  This is Hilight Function of Chat save
  655.  * PARAMETERS
  656.  *  void
  657.  * RETURNS
  658.  *  void
  659.  *****************************************************************************/
  660. void HighlititeChatSaveOutBox(void)
  661. {
  662.     /*----------------------------------------------------------------*/
  663.     /* Local Variables                                                */
  664.     /*----------------------------------------------------------------*/
  665.     /*----------------------------------------------------------------*/
  666.     /* Code Body                                                      */
  667.     /*----------------------------------------------------------------*/
  668.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  669.     ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  670.     SetLeftSoftkeyFunction(SaveChatMsgToOutBox, KEY_EVENT_UP);
  671.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  672. }
  673. /*****************************************************************************
  674.  * FUNCTION
  675.  *  EntryChatOption
  676.  * DESCRIPTION
  677.  *  Entry function of Chat Room Option (before enter chat room)
  678.  * PARAMETERS
  679.  *  void
  680.  * RETURNS
  681.  *  void
  682.  *****************************************************************************/
  683. void EntryChatOption(void)
  684. {
  685.     /*----------------------------------------------------------------*/
  686.     /* Local Variables                                                */
  687.     /*----------------------------------------------------------------*/
  688.     U8 *guiBuffer;
  689.     S32 numOfItems = 0;
  690.     U16 itemList[MAX_SUB_MENUS];
  691.     U16 itemIcon[MAX_SUB_MENUS];
  692.     U16 scrId = 0;
  693.     /*----------------------------------------------------------------*/
  694.     /* Code Body                                                      */
  695.     /*----------------------------------------------------------------*/
  696.     EntryNewScreen(CHAT_SCREEN_ROOM_ID, NULL, EntryChatOption, NULL);
  697.     if (g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].status == MMI_MSG_CHAT_ENABLE)
  698.     {
  699.         scrId = MENU_ACTIVE_CHAT_ROOM;
  700.     }
  701.     else
  702.     {
  703.         scrId = MENU_DEACTIVE_CHAT_ROOM;
  704.     }
  705.     guiBuffer = GetCurrGuiBuffer(CHAT_SCREEN_ROOM_ID);
  706.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  707.     SetParentHandler(scrId);
  708.     numOfItems = GetNumOfChild(scrId);
  709.     GetSequenceStringIds(scrId, itemList);
  710.     GetSequenceImageIds(scrId, itemIcon);
  711.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  712.     ShowCategory52Screen(
  713.         CHAT_ROOM_TEXT,
  714.         CHAT_IMAGE_APP_ID,
  715.         STR_GLOBAL_OPTIONS,
  716.         IMG_GLOBAL_OK,
  717.         STR_GLOBAL_BACK,
  718.         IMG_GLOBAL_BACK,
  719.         numOfItems,
  720.         itemList,
  721.         (U16*) gIndexIconsImageList,
  722.         NULL,
  723.         0,
  724.         0,
  725.         guiBuffer);
  726.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  727. }
  728. /*****************************************************************************
  729.  * FUNCTION
  730.  *  EntryChatRoomInfo
  731.  * DESCRIPTION
  732.  *  Entry function of Chat Room Info
  733.  * PARAMETERS
  734.  *  void
  735.  * RETURNS
  736.  *  void
  737.  *****************************************************************************/
  738. void EntryChatRoomInfo(void)
  739. {
  740.     /*----------------------------------------------------------------*/
  741.     /* Local Variables                                                */
  742.     /*----------------------------------------------------------------*/
  743.     U8 *guiBuffer;
  744.     U16 inputBufferSize;
  745.     U8 *inputBuffer;
  746.     /*----------------------------------------------------------------*/
  747.     /* Code Body                                                      */
  748.     /*----------------------------------------------------------------*/
  749.     EntryNewScreen(CHAT_ROOM_INFO_ID, ExitChatRoomInfo, NULL, NULL);
  750.     guiBuffer = GetCurrGuiBuffer(CHAT_ROOM_INFO_ID);
  751.     if (guiBuffer == NULL)
  752.     {
  753.         pfnUnicodeStrcpy((S8*) gNickname, (S8*) g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.nickName);
  754.         pfnUnicodeStrcpy(
  755.             (S8*) gDestinationNo,
  756.             (S8*) g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.destinationNo);
  757.         gHilightedChatRoomInfoItem = 1;
  758.     }
  759.     inputBuffer = GetCurrNInputBuffer(CHAT_ROOM_INFO_ID, &inputBufferSize);
  760.     RegisterHighlightHandler(ChatInlineHandler);
  761.     if (GetInlineDoneFlag(guiBuffer))
  762.     {
  763.         SetInlineDoneFlag(guiBuffer);
  764.     }
  765.     InitializeCategory57Screen();
  766.     FillChatRoomActivationStruct();
  767.     if (inputBuffer != NULL)
  768.     {
  769.         SetCategory57Data(wgui_inline_items, 4, inputBuffer);
  770.     }
  771.     ShowCategory57Screen(
  772.         CHAT_ROOM_INFO_STR,
  773.         CHAT_IMAGE_APP_ID,
  774.         STR_GLOBAL_OPTIONS,
  775.         IMG_GLOBAL_OK,
  776.         STR_GLOBAL_BACK,
  777.         IMG_GLOBAL_BACK,
  778.         4,
  779.         gDetailChatRoomInfoImageList,
  780.         wgui_inline_items,
  781.         gHilightedChatRoomInfoItem,
  782.         guiBuffer);
  783.     SetCategory57RightSoftkeyFunctions(PreSaveChatInfo, GoBackHistory);
  784. }
  785. /*****************************************************************************
  786.  * FUNCTION
  787.  *  ExitChatRoomInfo
  788.  * DESCRIPTION
  789.  *  Exit function of Chat Room Info
  790.  * PARAMETERS
  791.  *  void
  792.  * RETURNS
  793.  *  void
  794.  *****************************************************************************/
  795. void ExitChatRoomInfo(void)
  796. {
  797.     /*----------------------------------------------------------------*/
  798.     /* Local Variables                                                */
  799.     /*----------------------------------------------------------------*/
  800.     history h;
  801.     U16 inputBufferSize = 0;
  802.     /*----------------------------------------------------------------*/
  803.     /* Code Body                                                      */
  804.     /*----------------------------------------------------------------*/
  805.     CloseCategory57Screen();
  806.     h.scrnID = CHAT_ROOM_INFO_ID;
  807.     h.entryFuncPtr = EntryChatRoomInfo;
  808.     gHilightedChatRoomInfoItem = (U8) GetHighlightedItem();
  809.     GetCategoryHistory(h.guiBuffer);
  810.     inputBufferSize = (U16) GetCategory57DataSize();
  811.     GetCategory57Data((U8*) h.inputBuffer);
  812.     AddNHistory(h, inputBufferSize);
  813. }
  814. /*****************************************************************************
  815.  * FUNCTION
  816.  *  EntryChatWrite
  817.  * DESCRIPTION
  818.  *  It provides Edit screen for writing Chat Message
  819.  * PARAMETERS
  820.  *  void
  821.  * RETURNS
  822.  *  void
  823.  *****************************************************************************/
  824. void EntryChatWrite(void)
  825. {
  826.     /*----------------------------------------------------------------*/
  827.     /* Local Variables                                                */
  828.     /*----------------------------------------------------------------*/
  829.     U8 *guiBuffer;
  830.     /*----------------------------------------------------------------*/
  831.     /* Code Body                                                      */
  832.     /*----------------------------------------------------------------*/
  833.     if (!pfnUnicodeStrlen((PS8) g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.destinationNo))
  834.     {
  835.         DisplayPopup((PU8) GetString(CHATROOM_EMPTY_ERROR), IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  836.     }
  837.     else
  838.     {
  839.         EntryNewScreen(CHAT_SCREEN_START_NEW_ID, ExitChatWrite, EntryChatWrite, NULL);
  840.         guiBuffer = GetCurrGuiBuffer(CHAT_SCREEN_START_NEW_ID);
  841.     #if(0)
  842. if(GetUCS2Flag(g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.nickName))
  843. ShowCategory5Screen(STR_CHAT_WRITE_MESSAGE_TITLE, CHAT_IMAGE_APP_ID,
  844.   STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS,
  845.   STR_GLOBAL_BACK, IMG_GLOBAL_BACK,INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,g_chat_cntx.writeChatBuffer,MAX_MSG_SIZE_UCS2+1,guiBuffer);
  846. else
  847. ShowCategory5Screen(STR_CHAT_WRITE_MESSAGE_TITLE, CHAT_IMAGE_APP_ID,
  848.   STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS,
  849.   STR_GLOBAL_BACK, IMG_GLOBAL_BACK,(S16)(INPUT_TYPE_ALPHANUMERIC_SENTENCECASE|INPUT_TYPE_USE_ENCODING_BASED_LENGTH|INPUT_TYPE_FORTY_FOUR_LESS_CHARACTER|INPUT_TYPE_SMS_CHAT_MAX_LENGTH_HANDLING),g_chat_cntx.writeChatBuffer,MAX_MSG_SIZE+1,guiBuffer);
  850.     #endif /* (0) */ 
  851.         ShowCategory5Screen(
  852.             STR_CHAT_WRITE_MESSAGE_TITLE,
  853.             CHAT_IMAGE_APP_ID,
  854.             STR_GLOBAL_OPTIONS,
  855.             IMG_GLOBAL_OPTIONS,
  856.             STR_GLOBAL_BACK,
  857.             IMG_GLOBAL_BACK,
  858.             (S16) (INPUT_TYPE_ALPHANUMERIC_SENTENCECASE | INPUT_TYPE_FORTY_FOUR_LESS_CHARACTER),
  859.             g_chat_cntx.writeChatBuffer,
  860.             MAX_MSG_SIZE + 1,
  861.             guiBuffer);
  862.         SetLeftSoftkeyFunction(EntryChatWriteOption, KEY_EVENT_UP);
  863.         SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  864.         SetKeyHandler(PreSendChatMsg, KEY_SEND, KEY_EVENT_UP);
  865.     }
  866. }
  867. /*****************************************************************************
  868.  * FUNCTION
  869.  *  ExitChatWrite
  870.  * DESCRIPTION
  871.  *  Exit function of Chat Edit Screen
  872.  * PARAMETERS
  873.  *  void
  874.  * RETURNS
  875.  *  void
  876.  *****************************************************************************/
  877. void ExitChatWrite(void)
  878. {
  879.     /*----------------------------------------------------------------*/
  880.     /* Local Variables                                                */
  881.     /*----------------------------------------------------------------*/
  882.     /*----------------------------------------------------------------*/
  883.     /* Code Body                                                      */
  884.     /*----------------------------------------------------------------*/
  885.     if (GetInputBoxUCS2Count())
  886.     {
  887.         gInputBoxUcs2Flag = 1;
  888.     }
  889.     else
  890.     {
  891.         gInputBoxUcs2Flag = 0;
  892.     }
  893. }
  894. /*****************************************************************************
  895.  * FUNCTION
  896.  *  EntryChatWriteOption
  897.  * DESCRIPTION
  898.  *  Entry function of Chat Option Screen (write message)
  899.  * PARAMETERS
  900.  *  void
  901.  * RETURNS
  902.  *  void
  903.  *****************************************************************************/
  904. void EntryChatWriteOption(void)
  905. {
  906.     /*----------------------------------------------------------------*/
  907.     /* Local Variables                                                */
  908.     /*----------------------------------------------------------------*/
  909.     U8 *guiBuffer;
  910.     S32 numOfItems = 0;
  911.     U16 itemList[MAX_SUB_MENUS];
  912.     /*----------------------------------------------------------------*/
  913.     /* Code Body                                                      */
  914.     /*----------------------------------------------------------------*/
  915.     EntryNewScreen(CHAT_OPTION_SCREEN_ID, NULL, EntryChatWriteOption, NULL);
  916.     gHilightedChatRoomInfoItem = 0;
  917.     guiBuffer = GetCurrGuiBuffer(CHAT_OPTION_SCREEN_ID);
  918.     SetParentHandler(MENU_CHAT_OPTION);
  919.     numOfItems = GetNumOfChild(MENU_CHAT_OPTION);
  920.     GetSequenceStringIds(MENU_CHAT_OPTION, itemList);
  921.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  922.     ShowCategory52Screen(
  923.         CHAT_ROOM_TEXT,
  924.         CHAT_IMAGE_APP_ID,
  925.         STR_GLOBAL_OK,
  926.         IMG_GLOBAL_OK,
  927.         STR_GLOBAL_BACK,
  928.         IMG_GLOBAL_BACK,
  929.         numOfItems,
  930.         itemList,
  931.         (U16*) gIndexIconsImageList,
  932.         NULL,
  933.         0,
  934.         0,
  935.         guiBuffer);
  936.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  937.     GetCurrEndKeyDownHandler();
  938.     SetKeyHandler(ExecCurrEndKeyDownHandler, KEY_END, KEY_EVENT_UP);
  939. }
  940. /*****************************************************************************
  941.  * FUNCTION
  942.  *  EntryChatRoom
  943.  * DESCRIPTION
  944.  *  Entry Screen for Chat Room
  945.  * PARAMETERS
  946.  *  void
  947.  * RETURNS
  948.  *  void
  949.  *****************************************************************************/
  950. void EntryChatRoom()
  951. {
  952.     /*----------------------------------------------------------------*/
  953.     /* Local Variables                                                */
  954.     /*----------------------------------------------------------------*/
  955.     U8 *guiBuffer;
  956.     S32 numOfItems = 0;
  957.     char *phNumber;
  958.     S16 index = GetCurrentChatRoomNo();
  959.     /*----------------------------------------------------------------*/
  960.     /* Code Body                                                      */
  961.     /*----------------------------------------------------------------*/
  962.     if (GetMessagesCurrScrnID() != CHAT_ROOM_SCREEN_ID)
  963.     {
  964.         EntryNewScreen(CHAT_ROOM_SCREEN_ID, ExitChatRoom, EntryChatRoom, NULL);
  965.     }
  966.     if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  967.     {
  968.         if (!IsScreenPresent(CHAT_SCREEN_ROOM_ID))
  969.         {
  970.             HistoryReplace(SCR_ID_MSG_INBOX_MSG, CHAT_SCREEN_ROOM_ID, EntryChatOption);
  971.         }
  972.     #ifdef __MMI_UNIFIED_MESSAGE__
  973.         DeleteScreenIfPresent(SCR_ID_UM_INBOX);
  974.     #else /* __MMI_UNIFIED_MESSAGE__ */
  975.         DeleteScreenIfPresent(SCR_ID_MSG_INBOX_LIST);
  976.     #endif /* __MMI_UNIFIED_MESSAGE__ */
  977.     #ifdef __UNIFIED_MESSAGE_LIST_OPTION_SUPPORT__
  978.         DeleteScreenIfPresent(SCR_ID_MSG_INBOX_LIST_OPTION);
  979.     #endif
  980.     
  981.         DeleteScreenIfPresent(SCR_ID_MSG_INBOX_MSG);
  982.         DeleteScreenIfPresent(SCR_ID_MSG_INBOX_OPTION);
  983.     }
  984.     guiBuffer = GetCurrGuiBuffer(CHAT_ROOM_SCREEN_ID);
  985.     SetParentHandler(MENU_CHAT_ROOM_SCRN);
  986.     numOfItems = GetNumOfMessage(index);
  987.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  988.     phNumber = lookUpNumber((PS8) g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.destinationNo);
  989.     if (phNumber)
  990.     {
  991.         if (pfnUnicodeStrcmp(phNumber, ""))
  992.         {
  993.             pfnUnicodeStrncpy((PS8) gNumbersList, (PS8) phNumber, (U32) (sizeof(gNumbersList) / ENCODING_LENGTH) - 1);
  994.         }
  995.         else
  996.         {
  997.             pfnUnicodeStrncpy(
  998.                 (PS8) gNumbersList,
  999.                 (PS8) g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.destinationNo,
  1000.                 (U32) (sizeof(gNumbersList) / ENCODING_LENGTH) - 1);
  1001.         }
  1002.     }
  1003.     else
  1004.     {
  1005.         pfnUnicodeStrncpy(
  1006.             (PS8) gNumbersList,
  1007.             (PS8) g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo.destinationNo,
  1008.             (U32) (sizeof(gNumbersList) / ENCODING_LENGTH) - 1);
  1009.     }
  1010.     if (GetMessagechatRoomNo() == index)
  1011.     {
  1012.         gIsItChatSmsArrivalInd = FALSE;
  1013.         gIsThereAnyNewChatSMSToInd = FALSE;
  1014.     }
  1015.     /* !is_redrawing_old_screens() is temp solution for small screen issue */
  1016.     if (g_chat_cntx.blinkChatFlag[index] && !is_redrawing_old_screens())
  1017.     {
  1018.         /* do not update status icon before ShowCategoryScreen */
  1019.         HideStatusIcon(gChatSmsIcon[index]);
  1020.         ShowStatusIcon(gChatSmsIcon[index]);
  1021.         g_chat_cntx.blinkChatFlag[index] = FALSE;
  1022.     }
  1023.     SetMessagesCurrScrnID(CHAT_ROOM_SCREEN_ID);
  1024.     ShowCategory305Screen(
  1025.         0,
  1026.         CHAT_IMAGE_APP_ID,
  1027.         STR_GLOBAL_OPTIONS,
  1028.         IMG_GLOBAL_OK,
  1029.         STR_GLOBAL_BACK,
  1030.         IMG_GLOBAL_BACK,
  1031.         numOfItems,
  1032.         g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatStrings,
  1033.         guiBuffer,
  1034.         (PU8) gNumbersList,
  1035.         IMG_GLOBAL_OK);
  1036.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1037.     SetLeftSoftkeyFunction(EntryChatRoomOption, KEY_EVENT_UP);
  1038.     GetCurrEndKeyDownHandler();
  1039.     SetKeyHandler(ExecCurrEndKeyDownHandler, KEY_END, KEY_EVENT_UP);
  1040. }
  1041. /*****************************************************************************
  1042.  * FUNCTION
  1043.  *  ExitChatRoom
  1044.  * DESCRIPTION
  1045.  *  Exit Screen for Chat Room
  1046.  * PARAMETERS
  1047.  *  void
  1048.  * RETURNS
  1049.  *  void
  1050.  *****************************************************************************/
  1051. void ExitChatRoom(void)
  1052. {
  1053.     /*----------------------------------------------------------------*/
  1054.     /* Local Variables                                                */
  1055.     /*----------------------------------------------------------------*/
  1056.     /*----------------------------------------------------------------*/
  1057.     /* Code Body                                                      */
  1058.     /*----------------------------------------------------------------*/
  1059.     SetMessagesCurrScrnID(0);
  1060. }
  1061. /*****************************************************************************
  1062.  * FUNCTION
  1063.  *  EntrySmsMemoryFullIndInChatApp
  1064.  * DESCRIPTION
  1065.  *  Entry SMS memory full indication in chat room screen
  1066.  * PARAMETERS
  1067.  *  void
  1068.  * RETURNS
  1069.  *  void
  1070.  *****************************************************************************/
  1071. void EntrySmsMemoryFullIndInChatApp(void)   /* Magesh */
  1072. {
  1073.     /*----------------------------------------------------------------*/
  1074.     /* Local Variables                                                */
  1075.     /*----------------------------------------------------------------*/
  1076.     /*----------------------------------------------------------------*/
  1077.     /* Code Body                                                      */
  1078.     /*----------------------------------------------------------------*/
  1079.     if (GetMessagesCurrScrnID() == CHAT_ROOM_SCREEN_ID)
  1080.     {
  1081.         DisplayPopup((PU8) GetString(CHATROOM_STORAGE_FULL_ERROR), IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  1082.     }
  1083. }
  1084. /*****************************************************************************
  1085.  * FUNCTION
  1086.  *  EntryChatRoomOption
  1087.  * DESCRIPTION
  1088.  *  Entry function for Chat Room option (chat room)
  1089.  * PARAMETERS
  1090.  *  void
  1091.  * RETURNS
  1092.  *  void
  1093.  *****************************************************************************/
  1094. void EntryChatRoomOption(void)
  1095. {
  1096.     /*----------------------------------------------------------------*/
  1097.     /* Local Variables                                                */
  1098.     /*----------------------------------------------------------------*/
  1099.     U8 *guiBuffer = NULL;
  1100.     S32 numofitems = 0;
  1101.     U16 itemList[MAX_SUB_MENUS];
  1102.     /*----------------------------------------------------------------*/
  1103.     /* Code Body                                                      */
  1104.     /*----------------------------------------------------------------*/
  1105.     EntryNewScreen(CHAT_OPTION_SCREEN_ID_2, NULL, EntryChatRoomOption, NULL);
  1106.     guiBuffer = GetCurrGuiBuffer(CHAT_OPTION_SCREEN_ID_2);
  1107.     SetParentHandler(MENU_CHAT_OPTION_SCRN);
  1108.     numofitems = GetNumOfChild(MENU_CHAT_OPTION_SCRN);
  1109.     GetSequenceStringIds(MENU_CHAT_OPTION_SCRN, itemList);
  1110.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  1111.     ShowCategory52Screen(
  1112.         STR_GLOBAL_OPTIONS,
  1113.         CHAT_IMAGE_APP_ID,
  1114.         STR_GLOBAL_OK,
  1115.         IMG_GLOBAL_OK,
  1116.         STR_GLOBAL_BACK,
  1117.         IMG_GLOBAL_BACK,
  1118.         numofitems,
  1119.         itemList,
  1120.         (U16*) gIndexIconsImageList,
  1121.         NULL,
  1122.         0,
  1123.         0,
  1124.         guiBuffer);
  1125.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1126. }
  1127. /*****************************************************************************
  1128.  * FUNCTION
  1129.  *  PreEntryChatQuitConfirm
  1130.  * DESCRIPTION
  1131.  *  Wrapper function of GotoQuitChatScreen
  1132.  * PARAMETERS
  1133.  *  void
  1134.  * RETURNS
  1135.  *  void
  1136.  *****************************************************************************/
  1137. void PreEntryChatQuitConfirm(void)
  1138. {
  1139.     /*----------------------------------------------------------------*/
  1140.     /* Local Variables                                                */
  1141.     /*----------------------------------------------------------------*/
  1142.     /*----------------------------------------------------------------*/
  1143.     /* Code Body                                                      */
  1144.     /*----------------------------------------------------------------*/
  1145.     gQuitFlag = FALSE;
  1146.     EntryChatQuitConfirm();
  1147. }
  1148. /*****************************************************************************
  1149.  * FUNCTION
  1150.  *  EntryChatQuitConfirm
  1151.  * DESCRIPTION
  1152.  *  Ask from user before quitting from Chat Room
  1153.  * PARAMETERS
  1154.  *  void
  1155.  * RETURNS
  1156.  *  void
  1157.  *****************************************************************************/
  1158. void EntryChatQuitConfirm(void)
  1159. {
  1160.     /*----------------------------------------------------------------*/
  1161.     /* Local Variables                                                */
  1162.     /*----------------------------------------------------------------*/
  1163.     UI_string_type str;
  1164.     /*----------------------------------------------------------------*/
  1165.     /* Code Body                                                      */
  1166.     /*----------------------------------------------------------------*/
  1167.     if (gQuitFlag == TRUE)
  1168.     {
  1169.         str = get_string(STR_QUIT_CHAT_ROOM_QUERY);
  1170.     }
  1171.     else
  1172.     {
  1173.         str = get_string(STR_END_QUERY);
  1174.     }
  1175.     DisplayConfirm(
  1176.         STR_GLOBAL_YES,
  1177.         IMG_GLOBAL_YES,
  1178.         STR_GLOBAL_NO,
  1179.         IMG_GLOBAL_NO,
  1180.         str,
  1181.         IMG_GLOBAL_QUESTION,
  1182.         WARNING_TONE);
  1183.     SetLeftSoftkeyFunction(QuitChatRoom, KEY_EVENT_UP);
  1184.     if (gQuitFlag == TRUE)
  1185.     {
  1186.         SetRightSoftkeyFunction(GoBackChatHistory, KEY_EVENT_UP);
  1187.     }
  1188.     else
  1189.     {
  1190.         SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1191.     }
  1192. }
  1193. /*****************************************************************************
  1194.  * FUNCTION
  1195.  *  EntryClearChatRoomConfirm
  1196.  * DESCRIPTION
  1197.  *  It confirms from User before clearing Chat Room
  1198.  * PARAMETERS
  1199.  *  void
  1200.  * RETURNS
  1201.  *  void
  1202.  *****************************************************************************/
  1203. void EntryClearChatRoomConfirm(void)
  1204. {
  1205.     /*----------------------------------------------------------------*/
  1206.     /* Local Variables                                                */
  1207.     /*----------------------------------------------------------------*/
  1208.     /*----------------------------------------------------------------*/
  1209.     /* Code Body                                                      */
  1210.     /*----------------------------------------------------------------*/
  1211.     DisplayConfirm(
  1212.         STR_GLOBAL_YES,
  1213.         IMG_GLOBAL_YES,
  1214.         STR_GLOBAL_NO,
  1215.         IMG_GLOBAL_NO,
  1216.         get_string(STR_CLEAR_CHAT_ROOM_QUERY),
  1217.         IMG_GLOBAL_QUESTION,
  1218.         WARNING_TONE);
  1219.     SetLeftSoftkeyFunction(ClearChatRoom, KEY_EVENT_UP);
  1220.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1221. }
  1222. /*****************************************************************************
  1223.  * FUNCTION
  1224.  *  EntryChatReplaceConfirm
  1225.  * DESCRIPTION
  1226.  *  This function Displace Yes/No pop up before replacing Chat Room
  1227.  * PARAMETERS
  1228.  *  void
  1229.  * RETURNS
  1230.  *  void
  1231.  *****************************************************************************/
  1232. void EntryChatReplaceConfirm(void)
  1233. {
  1234.     /*----------------------------------------------------------------*/
  1235.     /* Local Variables                                                */
  1236.     /*----------------------------------------------------------------*/
  1237.     /*----------------------------------------------------------------*/
  1238.     /* Code Body                                                      */
  1239.     /*----------------------------------------------------------------*/
  1240.     DisplayConfirm(
  1241.         STR_GLOBAL_YES,
  1242.         IMG_GLOBAL_YES,
  1243.         STR_GLOBAL_NO,
  1244.         IMG_GLOBAL_NO,
  1245.         get_string(STR_REPLACE_CHAT_INFO_QUERY),
  1246.         IMG_GLOBAL_QUESTION,
  1247.         WARNING_TONE);
  1248.     SetLeftSoftkeyFunction(ReplaceChatRoom, KEY_EVENT_UP);
  1249.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1250. }
  1251. /*****************************************************************************
  1252.  * FUNCTION
  1253.  *  EnterPhoneBookForChatNumberApp
  1254.  * DESCRIPTION
  1255.  *  This function calls phone book function to get Phone book number
  1256.  * PARAMETERS
  1257.  *  void
  1258.  * RETURNS
  1259.  *  void
  1260.  *****************************************************************************/
  1261. void EnterPhoneBookForChatNumberApp(void)
  1262. {
  1263.     /*----------------------------------------------------------------*/
  1264.     /* Local Variables                                                */
  1265.     /*----------------------------------------------------------------*/
  1266.     /*----------------------------------------------------------------*/
  1267.     /* Code Body                                                      */
  1268.     /*----------------------------------------------------------------*/
  1269.     phbListView = MMI_PHB_LIST_FOR_CHAT;
  1270.     g_phb_cntx.highlight_entry = 0;
  1271.     gSetChatFlagNameNumber = CHAT_PHB_NUMBER;
  1272.     mmi_phb_list_pre_entry_second_level();
  1273. }
  1274. /*****************************************************************************
  1275.  * FUNCTION
  1276.  *  EnterPhoneBookForChatNameApp
  1277.  * DESCRIPTION
  1278.  *  This function calls phonebook function to get phone book name
  1279.  * PARAMETERS
  1280.  *  void
  1281.  * RETURNS
  1282.  *  void
  1283.  *****************************************************************************/
  1284. void EnterPhoneBookForChatNameApp(void)
  1285. {
  1286.     /*----------------------------------------------------------------*/
  1287.     /* Local Variables                                                */
  1288.     /*----------------------------------------------------------------*/
  1289.     /*----------------------------------------------------------------*/
  1290.     /* Code Body                                                      */
  1291.     /*----------------------------------------------------------------*/
  1292.     /* empty number entry could be selected without checking */
  1293.     phbListView = MMI_PHB_LIST_FOR_CHAT_NO_CHECK;
  1294.     g_phb_cntx.highlight_entry = 0;
  1295.     gSetChatFlagNameNumber = CHAT_PHB_NAME;
  1296.     mmi_phb_list_pre_entry_second_level();
  1297. }
  1298. /*****************************************************************************
  1299.  * FUNCTION
  1300.  *  InsertTemplateToChat
  1301.  * DESCRIPTION
  1302.  *  To Insert template in Chat message
  1303.  * PARAMETERS
  1304.  *  templ       [?]     
  1305.  *  template to be inserted(?)
  1306.  * RETURNS
  1307.  *  void
  1308.  *****************************************************************************/
  1309. void InsertTemplateToChat(S8 *templ)
  1310. {
  1311.     /*----------------------------------------------------------------*/
  1312.     /* Local Variables                                                */
  1313.     /*----------------------------------------------------------------*/
  1314.     history temphistory;
  1315.     historyNode *History;
  1316.     /*----------------------------------------------------------------*/
  1317.     /* Code Body                                                      */
  1318.     /*----------------------------------------------------------------*/
  1319.     PRINT_INFORMATION_2((MMI_TRACE_G6_SMS, "*[SmsMoMtGuiInterface.c] InsertTemplateToChat *n"));
  1320.     if (templ)
  1321.     {
  1322.         memset(&temphistory, 0, sizeof(temphistory));
  1323.         GetHistory(CHAT_SCREEN_START_NEW_ID, &temphistory);
  1324.         AppendCategory5String(
  1325.             INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  1326.             g_chat_cntx.writeChatBuffer,
  1327.             MAX_MSG_SIZE,
  1328.             (U8*) templ,
  1329.             temphistory.guiBuffer);
  1330.         if (GetHistoryScrID(CHAT_SCREEN_START_NEW_ID, &History) == ST_SUCCESS)
  1331.         {
  1332.             memcpy(History->guiBuffer, temphistory.guiBuffer, MAX_GUI_BUFFER);
  1333.         }
  1334.     }
  1335.     DeleteUptoScrID(CHAT_SCREEN_START_NEW_ID);
  1336.     GoBackHistory();
  1337.     DeInitTemplates();
  1338. }
  1339. /*****************************************************************************
  1340.  * FUNCTION
  1341.  *  SetNameNumberForChatScreen
  1342.  * DESCRIPTION
  1343.  *  This function Set Phone Book Name or Number to Edit screen
  1344.  * PARAMETERS
  1345.  *  name        [?]     Or number
  1346.  *  number      [?]     
  1347.  * RETURNS
  1348.  *  void
  1349.  *****************************************************************************/
  1350. void SetNameNumberForChatScreen(U8 name[], U8 number[])
  1351. {
  1352.     /*----------------------------------------------------------------*/
  1353.     /* Local Variables                                                */
  1354.     /*----------------------------------------------------------------*/
  1355.     history temphistory;
  1356.     historyNode *History;
  1357.     /*----------------------------------------------------------------*/
  1358.     /* Code Body                                                      */
  1359.     /*----------------------------------------------------------------*/
  1360.     if (gSetChatFlagNameNumber == CHAT_PHB_NAME)
  1361.     {
  1362.         if (pfnUnicodeStrlen((S8*) name))
  1363.         {
  1364.             memset(&temphistory, 0, sizeof(history));
  1365.             GetHistory(CHAT_SCREEN_START_NEW_ID, &temphistory);
  1366.             AppendCategory5String(
  1367.                 INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  1368.                 g_chat_cntx.writeChatBuffer,
  1369.                 MAX_MSG_SIZE,
  1370.                 name,
  1371.                 temphistory.guiBuffer);
  1372.             if (GetHistoryScrID(CHAT_SCREEN_START_NEW_ID, &History) == ST_SUCCESS)
  1373.             {
  1374.                 memcpy(History->guiBuffer, temphistory.guiBuffer, MAX_GUI_BUFFER);
  1375.             }
  1376.         }
  1377.         DeleteUptoScrID(CHAT_SCREEN_START_NEW_ID);
  1378.         GoBackHistory();
  1379.     }
  1380.     else if (gSetChatFlagNameNumber == CHAT_PHB_NUMBER)
  1381.     {
  1382.         if (pfnUnicodeStrlen((S8*) number))
  1383.         {
  1384.             memset(&temphistory, 0, sizeof(history));
  1385.             GetHistory(CHAT_SCREEN_START_NEW_ID, &temphistory);
  1386.             AppendCategory5String(
  1387.                 INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  1388.                 g_chat_cntx.writeChatBuffer,
  1389.                 MAX_MSG_SIZE,
  1390.                 number,
  1391.                 temphistory.guiBuffer);
  1392.             if (GetHistoryScrID(CHAT_SCREEN_START_NEW_ID, &History) == ST_SUCCESS)
  1393.             {
  1394.                 memcpy(History->guiBuffer, temphistory.guiBuffer, MAX_GUI_BUFFER);
  1395.             }
  1396.         }
  1397.         DeleteUptoScrID(CHAT_SCREEN_START_NEW_ID);
  1398.         GoBackHistory();
  1399.     }
  1400.     else if (gSetChatFlagNameNumber == CHAT_PHB_NUMBER_CHATROOMINFO)
  1401.     {
  1402.         S32 size;
  1403.         memset(&temphistory, 0, sizeof(history));
  1404.         GetHistory(CHAT_ROOM_INFO_ID, &temphistory);
  1405.         if (pfnUnicodeStrlen((PS8) number) > (MAX_DIGITS_SMS - 1))
  1406.         {
  1407.             DisplayPopup(
  1408.                 (PU8) GetString(STR_SMS_NUM_LEN_EXCEEDED),
  1409.                 IMG_GLOBAL_UNFINISHED,
  1410.                 1,
  1411.                 MESSAGES_POPUP_TIME_OUT,
  1412.                 (U8) ERROR_TONE);
  1413.             return;
  1414.         }
  1415.         pfnUnicodeStrncpy((S8*) gDestinationNo, (S8*) number, (MAX_DIGITS_SMS - 1));
  1416.         AppendInlineItemTextEditString(
  1417.             INPUT_TYPE_PHONE_NUMBER,
  1418.             gDestinationNo,
  1419.             wgui_inline_items,
  1420.             4,
  1421.             &size,
  1422.             &temphistory,
  1423.             1);
  1424.         /* ensure DeleteNHistory(1) to delete chat room info screen in case there are two phonebook screens presented */
  1425.         DeleteUptoScrID(CHAT_ROOM_INFO_ID);
  1426.         DeleteNHistory(1);
  1427.         AddNHistory(temphistory, (U16) size);
  1428.         GoBackHistory();
  1429.     }
  1430. }
  1431. /*****************************************************************************
  1432.  * FUNCTION
  1433.  *  GoBackHistoryFromChatInputMethod
  1434.  * DESCRIPTION
  1435.  *  Wrapper function to call GoBackHistory from Input Method function
  1436.  * PARAMETERS
  1437.  *  void
  1438.  * RETURNS
  1439.  *  void
  1440.  *****************************************************************************/
  1441. void GoBackHistoryFromChatInputMethod(void)
  1442. {
  1443.     /*----------------------------------------------------------------*/
  1444.     /* Local Variables                                                */
  1445.     /*----------------------------------------------------------------*/
  1446.     /*----------------------------------------------------------------*/
  1447.     /* Code Body                                                      */
  1448.     /*----------------------------------------------------------------*/
  1449.     DeleteUptoScrID(CHAT_SCREEN_START_NEW_ID);
  1450.     GoBackHistory();
  1451. }
  1452. /*****************************************************************************
  1453.  * FUNCTION
  1454.  *  ChatInlineHandler
  1455.  * DESCRIPTION
  1456.  *  Hilite Handler for Destination Number option of Chat Room Info
  1457.  * PARAMETERS
  1458.  *  index       [IN]        
  1459.  * RETURNS
  1460.  *  void
  1461.  *****************************************************************************/
  1462. void ChatInlineHandler(S32 index)
  1463. {
  1464.     /*----------------------------------------------------------------*/
  1465.     /* Local Variables                                                */
  1466.     /*----------------------------------------------------------------*/
  1467.     /*----------------------------------------------------------------*/
  1468.     /* Code Body                                                      */
  1469.     /*----------------------------------------------------------------*/
  1470.     switch (index)
  1471.     {
  1472.         case 1:
  1473.             gSetChatFlagNameNumber = 0;
  1474.             /* W05.48 Fix RSK Auto Back History Issue in touch Screen */
  1475.             EnableCategory57ScreenDone();
  1476.             if (GetInlineListMenuChanged())
  1477.             {
  1478.                 ChangeRightSoftkey(STR_GLOBAL_DONE, IMAGE_ID_NULL);
  1479.             }
  1480.             break;
  1481.         case 3: /* check!!!! */
  1482.             if ((gDestinationNo != NULL) && (pfnUnicodeStrlen((S8*) gDestinationNo)) == 0)
  1483.             {
  1484.                 gSetChatFlagNameNumber = CHAT_PHB_NUMBER_CHATROOMINFO;
  1485.                 phbListView = MMI_PHB_LIST_FOR_CHAT;
  1486.                 ChangeLeftSoftkey(STR_SMS_COMMON_SEARCH, IMG_SMS_COMMON_NOIMAGE);
  1487.                 SetLeftSoftkeyFunction(mmi_phb_list_pre_entry_second_level, KEY_EVENT_UP);
  1488.                 ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  1489.                 SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1490.             }
  1491.             /* W05.48 Fix RSK Auto Back History Issue in touch Screen */
  1492.             DisableCategory57ScreenDone();
  1493.             RegisterInputBoxEmptyFunction(ChatNumberScreenEmpty);
  1494.             RegisterInputBoxNotEmptyFunction(ChatNumberScreenNotEmpty);
  1495.             break;
  1496.         default:
  1497.             break;
  1498.     }
  1499. }
  1500. /*****************************************************************************
  1501.  * FUNCTION
  1502.  *  ChatNumberScreenEmpty
  1503.  * DESCRIPTION
  1504.  *  This function is called when there is no data on Edit Screen
  1505.  * PARAMETERS
  1506.  *  void
  1507.  * RETURNS
  1508.  *  void
  1509.  *****************************************************************************/
  1510. void ChatNumberScreenEmpty(void)
  1511. {
  1512.     /*----------------------------------------------------------------*/
  1513.     /* Local Variables                                                */
  1514.     /*----------------------------------------------------------------*/
  1515.     /*----------------------------------------------------------------*/
  1516.     /* Code Body                                                      */
  1517.     /*----------------------------------------------------------------*/
  1518.     gSetChatFlagNameNumber = CHAT_PHB_NUMBER_CHATROOMINFO;
  1519.     phbListView = MMI_PHB_LIST_FOR_CHAT;
  1520.     g_phb_cntx.highlight_entry = 0;
  1521.     ChangeLeftSoftkey(STR_SMS_COMMON_SEARCH, IMG_SMS_COMMON_NOIMAGE);
  1522.     SetLeftSoftkeyFunction(mmi_phb_list_pre_entry_second_level, KEY_EVENT_UP);
  1523.     //W05.48 Fix RSK Auto Back History Issue in touch Screen
  1524.     //ChangeRightSoftkey (STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
  1525.     //SetRightSoftkeyFunction (GoBackHistory, KEY_EVENT_UP);
  1526. }
  1527. /*****************************************************************************
  1528.  * FUNCTION
  1529.  *  ChatNumberScreenNotEmpty
  1530.  * DESCRIPTION
  1531.  *  This function is called when there is some data on Edit Screen
  1532.  * PARAMETERS
  1533.  *  void
  1534.  * RETURNS
  1535.  *  void
  1536.  *****************************************************************************/
  1537. void ChatNumberScreenNotEmpty(void)
  1538. {
  1539.     /*----------------------------------------------------------------*/
  1540.     /* Local Variables                                                */
  1541.     /*----------------------------------------------------------------*/
  1542.     /*----------------------------------------------------------------*/
  1543.     /* Code Body                                                      */
  1544.     /*----------------------------------------------------------------*/
  1545.     gSetChatFlagNameNumber = 0;
  1546.     ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  1547.     SetLeftSoftkeyFunction(PreSaveChatInfo, KEY_EVENT_UP);
  1548. }
  1549. /*****************************************************************************
  1550.  * FUNCTION
  1551.  *  ChatInlineCustomFunction
  1552.  * DESCRIPTION
  1553.  *  This function fills Chat Room Activation recods
  1554.  * PARAMETERS
  1555.  *  void
  1556.  * RETURNS
  1557.  *  void
  1558.  *****************************************************************************/
  1559. void ChatInlineCustomFunction(void)
  1560. {
  1561.     /*----------------------------------------------------------------*/
  1562.     /* Local Variables                                                */
  1563.     /*----------------------------------------------------------------*/
  1564.     /*----------------------------------------------------------------*/
  1565.     /* Code Body                                                      */
  1566.     /*----------------------------------------------------------------*/
  1567.     SetInputMethodAndDoneCaptionIcon(CHAT_IMAGE_APP_ID);
  1568.     ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  1569.     SetLeftSoftkeyFunction(EntryScrForInputMethodAndDone, KEY_EVENT_UP);
  1570. }
  1571. /*****************************************************************************
  1572.  * FUNCTION
  1573.  *  FillChatRoomActivationStruct
  1574.  * DESCRIPTION
  1575.  *  Fill chat room info for inline editor
  1576.  * PARAMETERS
  1577.  *  void
  1578.  * RETURNS
  1579.  *  void
  1580.  *****************************************************************************/
  1581. void FillChatRoomActivationStruct(void)
  1582. {
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Local Variables                                                */
  1585.     /*----------------------------------------------------------------*/
  1586.     /*----------------------------------------------------------------*/
  1587.     /* Code Body                                                      */
  1588.     /*----------------------------------------------------------------*/
  1589.     SetInlineItemCaption(&wgui_inline_items[0], (U8*) GetString(CHATROOM_NICKNAME));
  1590.     gDetailChatRoomInfoImageList[0] = IMG_CHAT_NICKNAME;
  1591.     SetInlineItemActivation(&wgui_inline_items[1], KEY_LSK, KEY_EVENT_UP);
  1592.     SetInlineItemFullScreenEdit(
  1593.         &wgui_inline_items[1],
  1594.         CHATROOM_NICKNAME,
  1595.         CHAT_IMAGE_APP_ID,
  1596.         (PU8) gNickname,
  1597.         MAX_NICKNAME_LENGTH + 1,
  1598.         (INPUT_TYPE_ALPHANUMERIC_UPPERCASE));
  1599.     SetInlineFullScreenEditCustomFunction(&wgui_inline_items[1], ChatInlineCustomFunction);
  1600.     gDetailChatRoomInfoImageList[1] = 0;
  1601.     SetInlineItemCaption(&wgui_inline_items[2], (U8*) GetString(CHATROOM_DESTINATION));
  1602.     gDetailChatRoomInfoImageList[2] = IMG_CHAT_DESTINATION;
  1603.     SetInlineItemActivation(&wgui_inline_items[3], INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT, 0);
  1604.     /* MMI SMS supports 20-digit number. */
  1605.     SetInlineItemTextEdit(
  1606.         &wgui_inline_items[3],
  1607.         (PU8) gDestinationNo,
  1608.         MAX_DIGITS_SMS,
  1609.         INPUT_TYPE_PHONE_NUMBER);
  1610.     DisableInlineItemHighlight(&wgui_inline_items[3]);
  1611.     gDetailChatRoomInfoImageList[3] = 0;
  1612. }
  1613. /*****************************************************************************
  1614.  * FUNCTION
  1615.  *  GoBackHistoryPreChatInfoSaveKey
  1616.  * DESCRIPTION
  1617.  *  This is wrapper function for calling GobackHistory from Saving Chat Room Info
  1618.  * PARAMETERS
  1619.  *  void
  1620.  * RETURNS
  1621.  *  void
  1622.  *****************************************************************************/
  1623. void GoBackHistoryPreChatInfoSaveKey(void)
  1624. {
  1625.     /*----------------------------------------------------------------*/
  1626.     /* Local Variables                                                */
  1627.     /*----------------------------------------------------------------*/
  1628.     /*----------------------------------------------------------------*/
  1629.     /* Code Body                                                      */
  1630.     /*----------------------------------------------------------------*/
  1631.     //      CloseCategory57Screen(); 
  1632.     //      DeleteUptoScrID(CHAT_ROOM_INFO_ID);
  1633.     GoBacknHistory(1);
  1634. }
  1635. /*****************************************************************************
  1636.  * FUNCTION
  1637.  *  PreSaveChatInfo
  1638.  * DESCRIPTION
  1639.  *  This function asks user Befor saving Chat Room info
  1640.  * PARAMETERS
  1641.  *  void
  1642.  * RETURNS
  1643.  *  void
  1644.  *****************************************************************************/
  1645. void PreSaveChatInfo(void)
  1646. {
  1647.     /*----------------------------------------------------------------*/
  1648.     /* Local Variables                                                */
  1649.     /*----------------------------------------------------------------*/
  1650.     /*----------------------------------------------------------------*/
  1651.     /* Code Body                                                      */
  1652.     /*----------------------------------------------------------------*/
  1653.     if (!GetInlineListMenuChanged())
  1654.     {
  1655.         GoBackHistory();
  1656.         return;
  1657.     }
  1658.     DisplayConfirm(
  1659.         STR_GLOBAL_YES,
  1660.         IMG_GLOBAL_YES,
  1661.         STR_GLOBAL_NO,
  1662.         IMG_GLOBAL_NO,
  1663.         get_string(STR_SAVE_CHAT_INFO),
  1664.         IMG_GLOBAL_QUESTION,
  1665.         WARNING_TONE);
  1666.     SetLeftSoftkeyFunction(SaveChatRoomInfo, KEY_EVENT_UP);
  1667.     SetRightSoftkeyFunction(GoBackHistoryPreChatInfoSaveKey, KEY_EVENT_UP);
  1668. }
  1669. /*****************************************************************************
  1670.  * FUNCTION
  1671.  *  SaveChatRoomInfo
  1672.  * DESCRIPTION
  1673.  *  This function Calls Number Check and number save functions
  1674.  * PARAMETERS
  1675.  *  void
  1676.  * RETURNS
  1677.  *  void
  1678.  *****************************************************************************/
  1679. void SaveChatRoomInfo(void)
  1680. {
  1681.     /*----------------------------------------------------------------*/
  1682.     /* Local Variables                                                */
  1683.     /*----------------------------------------------------------------*/
  1684.     S32 index = GetCurrentChatRoomNo();
  1685.     /*----------------------------------------------------------------*/
  1686.     /* Code Body                                                      */
  1687.     /*----------------------------------------------------------------*/
  1688.     if (CheckChatNumber(gDestinationNo, g_chat_cntx.chatRoomInfo[index].status, index))
  1689.     {
  1690.         FillChatRoomInfo(gNickname, gDestinationNo, index);
  1691.         DisplayPopup(
  1692.             (PU8) GetString(STR_GLOBAL_DONE),
  1693.             IMG_GLOBAL_ACTIVATED,
  1694.             FALSE,
  1695.             MESSAGES_POPUP_TIME_OUT,
  1696.             (U8) SUCCESS_TONE);
  1697.         DeleteScreenIfPresent(CHAT_ROOM_INFO_ID);
  1698.     }
  1699. }
  1700. /*****************************************************************************
  1701.  * FUNCTION
  1702.  *  FillChatRoomInfo
  1703.  * DESCRIPTION
  1704.  *  This function Writes Chat Room Info on NVRAM
  1705.  * PARAMETERS
  1706.  *  name        [IN]        
  1707.  *  destnum     [IN]        
  1708.  *  index       [IN]        
  1709.  *  Nickname,Destination Number and Chat Room Number(?)
  1710.  * RETURNS
  1711.  *  void
  1712.  *****************************************************************************/
  1713. void FillChatRoomInfo(PU8 name, PU8 destnum, S32 index)
  1714. {
  1715.     /*----------------------------------------------------------------*/
  1716.     /* Local Variables                                                */
  1717.     /*----------------------------------------------------------------*/
  1718.     S16 error;
  1719.     S16 roomCount;
  1720.     chat_info_nvram_struct infostruct[MAX_NO_OF_CHAT_ROOM];
  1721.     /*----------------------------------------------------------------*/
  1722.     /* Code Body                                                      */
  1723.     /*----------------------------------------------------------------*/
  1724.     pfnUnicodeStrcpy((S8*) (g_chat_cntx.chatRoomInfo[index].chatInfo.nickName), (S8*) name);
  1725.     pfnUnicodeStrcpy((S8*) (g_chat_cntx.chatRoomInfo[index].chatInfo.destinationNo), (S8*) destnum);
  1726.     /* memset(&gChatRoomInfo[index].chatInfo.destinationNo[len*ENCODING_LENGTH],0,ENCODING_LENGTH); */
  1727.     for (roomCount = 0; roomCount < MAX_NO_OF_CHAT_ROOM; roomCount++)
  1728.     {
  1729.         U16 index = (U16) roomCount + 1;
  1730.         pfnUnicodeStrcpy(
  1731.             (S8*) (infostruct[roomCount].nickName),
  1732.             (S8*) g_chat_cntx.chatRoomInfo[roomCount].chatInfo.nickName);
  1733.         UnicodeToAnsii(
  1734.             (S8*) (infostruct[roomCount].destinationNo),
  1735.             (S8*) (g_chat_cntx.chatRoomInfo[roomCount].chatInfo.destinationNo));
  1736.         WriteRecord(
  1737.             NVRAM_EF_CHAT_ROOM_INFO_LID,
  1738.             index,
  1739.             (void*)&infostruct[roomCount],
  1740.             NVRAM_CHAT_ROOM_INFO_RECORD_SIZE,
  1741.             &error);
  1742.     }
  1743. }
  1744. /*****************************************************************************
  1745.  * FUNCTION
  1746.  *  CheckDuplicateNumber
  1747.  * DESCRIPTION
  1748.  *  This function Writes Chat Room Info on NVRAM
  1749.  * PARAMETERS
  1750.  *  DestNo      [IN]        
  1751.  *  index       [IN]        
  1752.  *  Destination number and Chat Room Number(?)
  1753.  * RETURNS
  1754.  *  status
  1755.  *****************************************************************************/
  1756. pBOOL CheckDuplicateNumber(PU8 DestNo, S32 index)
  1757. {
  1758.     /*----------------------------------------------------------------*/
  1759.     /* Local Variables                                                */
  1760.     /*----------------------------------------------------------------*/
  1761.     U8 num1[(MAX_PHONE_NUMBER_LENGTH + 2) * ENCODING_LENGTH];
  1762.     U8 num2[(MAX_PHONE_NUMBER_LENGTH + 2) * ENCODING_LENGTH];
  1763.     /*----------------------------------------------------------------*/
  1764.     /* Code Body                                                      */
  1765.     /*----------------------------------------------------------------*/
  1766.     memset(num1, 0x00, (MAX_PHONE_NUMBER_LENGTH + 2) * ENCODING_LENGTH);
  1767.     memset(num2, 0x00, (MAX_PHONE_NUMBER_LENGTH + 2) * ENCODING_LENGTH);
  1768.     UnicodeToAnsii((PS8) num1, (PS8) g_chat_cntx.chatRoomInfo[index].chatInfo.destinationNo);
  1769.     UnicodeToAnsii((PS8) num2, (PS8) DestNo);
  1770.     if (mmi_phb_util_convert_number_to_int(num2) == INVALID_NUMBER)
  1771.     {
  1772.         return FALSE;
  1773.     }
  1774.     else
  1775.     {
  1776.         return ComparePhoneNum((PU8) num1, (PU8) num2);
  1777.     }
  1778. }
  1779. /*****************************************************************************
  1780.  * FUNCTION
  1781.  *  mmi_msg_chat_check_ussd_number
  1782.  * DESCRIPTION
  1783.  *  Check if the number is USSD string
  1784.  * PARAMETERS
  1785.  *  number          [?]         And Number length
  1786.  *  number_len      [IN]        
  1787.  * RETURNS
  1788.  *  TRUE means the number is USSD string, Otherwise FALSE
  1789.  *****************************************************************************/
  1790. U8 mmi_msg_chat_check_ussd_number(U16 *number, S32 number_len)
  1791. {
  1792.     /*----------------------------------------------------------------*/
  1793.     /* Local Variables                                                */
  1794.     /*----------------------------------------------------------------*/
  1795.     U16 ussd_pattern = (U16) '#';
  1796.     /*----------------------------------------------------------------*/
  1797.     /* Code Body                                                      */
  1798.     /*----------------------------------------------------------------*/
  1799.     if (pfnUnicodeStrncmp((S8*) (number + number_len - 1), (S8*) & ussd_pattern, 1) == 0)
  1800.     {
  1801.         return TRUE;
  1802.     }
  1803.     return FALSE;
  1804. }
  1805. /*****************************************************************************
  1806.  * FUNCTION
  1807.  *  CheckChatNumber
  1808.  * DESCRIPTION
  1809.  *  This function Checks for Duplicate Number
  1810.  * PARAMETERS
  1811.  *  DestNum     [IN]        
  1812.  *  status      [IN]        And Chat Room Number
  1813.  *  index       [IN]        
  1814.  * RETURNS
  1815.  *  status
  1816.  *****************************************************************************/
  1817. pBOOL CheckChatNumber(PU8 DestNum, S8 status, S32 index)
  1818. {
  1819.     /*----------------------------------------------------------------*/
  1820.     /* Local Variables                                                */
  1821.     /*----------------------------------------------------------------*/
  1822.     S32 len = pfnUnicodeStrlen((S8*) DestNum);
  1823.     S32 checkindex = (index == 0) ? 1 : 0;
  1824.     U8 ascii_num[MAX_PHONE_NUMBER_LENGTH];
  1825.     /*----------------------------------------------------------------*/
  1826.     /* Code Body                                                      */
  1827.     /*----------------------------------------------------------------*/
  1828.     memset(ascii_num, 0,MAX_PHONE_NUMBER_LENGTH);
  1829.     UnicodeNToAnsii((S8*) ascii_num, (S8*) DestNum, len * ENCODING_LENGTH);
  1830.     
  1831.     if (!len && (status == MMI_MSG_CHAT_ENABLE))
  1832.     {
  1833.         DisplayPopup((PU8) GetString(CHATROOM_EMPTY_ERROR), (U16) IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  1834.         return FALSE;
  1835.     }
  1836.     /* else if (CheckDuplicateNumber(DestNum,checkindex) && pfnUnicodeStrlen((PS8)DestNum)) */
  1837.     else if (CheckDuplicateNumber(DestNum, checkindex))
  1838.     {
  1839.         DisplayPopup((PU8) GetString(CHATROOM_DUPLICATE_ERROR), IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  1840.         return FALSE;
  1841.     }
  1842.     else if (mmi_msg_chat_check_ussd_number((U16*) DestNum, len))
  1843.     {
  1844.         DisplayPopup((PU8) GetString(STR_ID_PHB_NUM_INVALID), IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  1845.         return FALSE;
  1846.     }
  1847.     else if (!mmi_frm_sms_check_dst_number(ascii_num, (U8) len))
  1848.     {
  1849.         DisplayPopup((PU8) GetString(STR_ID_PHB_NUM_INVALID), IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  1850.         return FALSE;
  1851.     }
  1852.     return TRUE;
  1853. }
  1854. /*****************************************************************************
  1855.  * FUNCTION
  1856.  *  ChatUseNumberScreen
  1857.  * DESCRIPTION
  1858.  *  Wrapper function to call function which extracts number from chat message
  1859.  * PARAMETERS
  1860.  *  void
  1861.  * RETURNS
  1862.  *  total use number record
  1863.  *****************************************************************************/
  1864. U16 ChatUseNumberScreen(void)
  1865. {
  1866.     /*----------------------------------------------------------------*/
  1867.     /* Local Variables                                                */
  1868.     /*----------------------------------------------------------------*/
  1869.     U16 totalusenumber = ObtainChatNumbersFromMessageTextWrapper(
  1870.                             (char*)g_chat_cntx.chatRoomInfo[GetCurrentChatRoomNo()].chatInfo. destinationNo,
  1871.                             GetCurrentChatRoomNo());
  1872.     /*----------------------------------------------------------------*/
  1873.     /* Code Body                                                      */
  1874.     /*----------------------------------------------------------------*/
  1875.     return totalusenumber;
  1876. }
  1877. /*****************************************************************************
  1878.  * FUNCTION
  1879.  *  TempleaveChatApp
  1880.  * DESCRIPTION
  1881.  *  Temp leave function from Chat Room screen
  1882.  * PARAMETERS
  1883.  *  void
  1884.  * RETURNS
  1885.  *  void
  1886.  *****************************************************************************/
  1887. void TempleaveChatApp(void)
  1888. {
  1889.     /*----------------------------------------------------------------*/
  1890.     /* Local Variables                                                */
  1891.     /*----------------------------------------------------------------*/
  1892.     U16 screen_id;
  1893.     /*----------------------------------------------------------------*/
  1894.     /* Code Body                                                      */
  1895.     /*----------------------------------------------------------------*/
  1896.     if (IsScreenPresent(CHAT_SCREEN_ID))
  1897.     {
  1898.         GoBackToHistory(CHAT_SCREEN_ID);
  1899.     }
  1900.     else if (IsScreenPresent(CHAT_SCREEN_ROOM_ID) && 
  1901.              GetPreviousScrnIdOf(CHAT_SCREEN_ROOM_ID, &screen_id))
  1902.     {
  1903.         GoBackToHistory(screen_id);
  1904.     }
  1905.     else
  1906.     {
  1907.         GoBackHistory();
  1908.     }
  1909. }
  1910. /*****************************************************************************
  1911.  * FUNCTION
  1912.  *  GoBackChatHistory
  1913.  * DESCRIPTION
  1914.  *  Wrapper function of Gobackhistory
  1915.  * PARAMETERS
  1916.  *  void
  1917.  * RETURNS
  1918.  *  void
  1919.  *****************************************************************************/
  1920. void GoBackChatHistory(void)
  1921. {
  1922.     /*----------------------------------------------------------------*/
  1923.     /* Local Variables                                                */
  1924.     /*----------------------------------------------------------------*/
  1925.     /*----------------------------------------------------------------*/
  1926.     /* Code Body                                                      */
  1927.     /*----------------------------------------------------------------*/
  1928.     GoBacknHistory(1);
  1929. }
  1930. /*****************************************************************************
  1931.  * FUNCTION
  1932.  *  ExitChatConfirm
  1933.  * DESCRIPTION
  1934.  *  Exit Function of confirmation screen
  1935.  * PARAMETERS
  1936.  *  void
  1937.  * RETURNS
  1938.  *  void
  1939.  *****************************************************************************/
  1940. void ExitChatConfirm(void)
  1941. {
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Local Variables                                                */
  1944.     /*----------------------------------------------------------------*/
  1945.     /*----------------------------------------------------------------*/
  1946.     /* Code Body                                                      */
  1947.     /*----------------------------------------------------------------*/
  1948.     stopRequestedTone(WARNING_TONE);
  1949. }
  1950. /*****************************************************************************
  1951.  * FUNCTION
  1952.  *  GoBackQuitScreen
  1953.  * DESCRIPTION
  1954.  *  GoBack Quit Chat Room Screen
  1955.  * PARAMETERS
  1956.  *  void
  1957.  * RETURNS
  1958.  *  void
  1959.  *****************************************************************************/
  1960. void GoBackQuitScreen(void)
  1961. {
  1962.     /*----------------------------------------------------------------*/
  1963.     /* Local Variables                                                */
  1964.     /*----------------------------------------------------------------*/
  1965.     /*----------------------------------------------------------------*/
  1966.     /* Code Body                                                      */
  1967.     /*----------------------------------------------------------------*/
  1968.     DeleteScreenIfPresent(CHAT_OPTION_SCREEN_ID_2);
  1969.     DeleteScreenIfPresent(CHAT_ROOM_SCREEN_ID);
  1970.     DeleteScreenIfPresent(CHAT_SCREEN_ROOM_ID);
  1971. }
  1972. /*****************************************************************************
  1973.  * FUNCTION
  1974.  *  QuitChatRoom
  1975.  * DESCRIPTION
  1976.  *  This funtion quits from Chat room and goback to previous screen
  1977.  * PARAMETERS
  1978.  *  void
  1979.  * RETURNS
  1980.  *  void
  1981.  *****************************************************************************/
  1982. void QuitChatRoom(void)
  1983. {
  1984.     /*----------------------------------------------------------------*/
  1985.     /* Local Variables                                                */
  1986.     /*----------------------------------------------------------------*/
  1987.     /*----------------------------------------------------------------*/
  1988.     /* Code Body                                                      */
  1989.     /*----------------------------------------------------------------*/
  1990.     EndChatRoom();
  1991.     DisplayPopup(
  1992.         (PU8) GetString(STR_GLOBAL_DONE),
  1993.         IMG_GLOBAL_ACTIVATED,
  1994.         FALSE,
  1995.         MESSAGES_POPUP_TIME_OUT,
  1996.         (U8) SUCCESS_TONE);
  1997.     GoBackQuitScreen();
  1998. }
  1999. /*****************************************************************************
  2000.  * FUNCTION
  2001.  *  EndChatRoom
  2002.  * DESCRIPTION
  2003.  *  This funtion Reset all Chat room variables and make it disable
  2004.  * PARAMETERS
  2005.  *  void
  2006.  * RETURNS
  2007.  *  void
  2008.  *****************************************************************************/
  2009. void EndChatRoom(void)
  2010. {
  2011.     /*----------------------------------------------------------------*/
  2012.     /* Local Variables                                                */
  2013.     /*----------------------------------------------------------------*/
  2014.     S32 msgCount;
  2015.     S16 index = GetCurrentChatRoomNo();
  2016.     /*----------------------------------------------------------------*/
  2017.     /* Code Body                                                      */
  2018.     /*----------------------------------------------------------------*/
  2019.     if (GetMessagechatRoomNo() == index)
  2020.     {
  2021.         gIsItChatSmsArrivalInd = FALSE;
  2022.         gIsThereAnyNewChatSMSToInd = FALSE;
  2023.     }
  2024.     g_chat_cntx.chatRoomInfo[index].status = MMI_MSG_CHAT_DISABLE;
  2025.     ResetMemoryBuffer(index);
  2026.     for (msgCount = 0; msgCount < g_chat_cntx.chatRoomInfo[index].chatRoomCounter; msgCount++)
  2027.     {
  2028.         g_chat_cntx.chatRoomInfo[index].chatStrings[msgCount].chat_message_string = NULL;
  2029.     }
  2030.     gChatInvitation = FALSE;
  2031.     ResetCounter(index);
  2032.     HideChatStatusIcon(index);
  2033. }
  2034. /*****************************************************************************
  2035.  * FUNCTION
  2036.  *  ClearChatRoom
  2037.  * DESCRIPTION
  2038.  *  This function displays Done pop up and Calls Clear function for Chat Room
  2039.  * PARAMETERS
  2040.  *  void
  2041.  * RETURNS
  2042.  *  void
  2043.  *****************************************************************************/
  2044. void ClearChatRoom(void)
  2045. {
  2046.     /*----------------------------------------------------------------*/
  2047.     /* Local Variables                                                */
  2048.     /*----------------------------------------------------------------*/
  2049.     /*----------------------------------------------------------------*/
  2050.     /* Code Body                                                      */
  2051.     /*----------------------------------------------------------------*/
  2052.     DisplayPopup(
  2053.         (PU8) GetString(STR_GLOBAL_DONE),
  2054.         IMG_GLOBAL_ACTIVATED,
  2055.         FALSE,
  2056.         MESSAGES_POPUP_TIME_OUT,
  2057.         (U8) SUCCESS_TONE);
  2058.     ClearChat(GetCurrentChatRoomNo());
  2059.     DeleteScreenIfPresent(CHAT_OPTION_SCREEN_ID_2);
  2060. }
  2061. /*****************************************************************************
  2062.  * FUNCTION
  2063.  *  ClearChat
  2064.  * DESCRIPTION
  2065.  *  This function clears Chat room by resseting all varaibles
  2066.  * PARAMETERS
  2067.  *  index       [IN]        
  2068.  *  Chat Room Number(?)
  2069.  * RETURNS
  2070.  *  void
  2071.  *****************************************************************************/
  2072. void ClearChat(S16 index)
  2073. {
  2074.     /*----------------------------------------------------------------*/
  2075.     /* Local Variables                                                */
  2076.     /*----------------------------------------------------------------*/
  2077.     S32 msgCount;
  2078.     /*----------------------------------------------------------------*/
  2079.     /* Code Body                                                      */
  2080.     /*----------------------------------------------------------------*/
  2081.     ResetMemoryBuffer(index);
  2082.     for (msgCount = 0; msgCount < g_chat_cntx.chatRoomInfo[index].chatRoomCounter; msgCount++)
  2083.     {
  2084.         g_chat_cntx.chatRoomInfo[index].chatStrings[msgCount].chat_message_string = NULL;
  2085.     }
  2086.     ResetCounter(GetCurrentChatRoomNo());
  2087. }
  2088. /*****************************************************************************
  2089.  * FUNCTION
  2090.  *  ChatInboxInterface
  2091.  * DESCRIPTION
  2092.  *  This is an interface function when Chat is selected from Inbox
  2093.  * PARAMETERS
  2094.  *  destnum     [IN]        
  2095.  *  Destination number(?)
  2096.  * RETURNS
  2097.  *  void
  2098.  *****************************************************************************/
  2099. void ChatInboxInterface(PU8 destnum)
  2100. {
  2101.     /*----------------------------------------------------------------*/
  2102.     /* Local Variables                                                */
  2103.     /*----------------------------------------------------------------*/
  2104.     S16 duplicateNumberStatus = 0;
  2105.     S16 status = 0;
  2106.     /*----------------------------------------------------------------*/
  2107.     /* Code Body                                                      */
  2108.     /*----------------------------------------------------------------*/
  2109.     pfnUnicodeStrcpy((PS8) gDestinationNo, (PS8) destnum);
  2110.     while (status < MAX_NO_OF_CHAT_ROOM)
  2111.     {
  2112.         duplicateNumberStatus = CheckDuplicateNumber(destnum, status);
  2113.         if (duplicateNumberStatus)
  2114.         {
  2115.             SetCurrentChatRoomNo(status);
  2116.             if (g_chat_cntx.chatRoomInfo[status].status == MMI_MSG_CHAT_DISABLE)
  2117.             {
  2118.                 if (gChatInvitation)
  2119.                 {
  2120.                     ActivateChatRoom(status);
  2121.                     UpdateChatRoom(status, RECEIVING_CHAT);
  2122.                     EntryChatRoom();
  2123.                     DeleteInvitationMessage();
  2124.                 }
  2125.                 else
  2126.                 {
  2127.                     EntryChatOption();
  2128.                 }
  2129.             }
  2130.             else
  2131.             {
  2132.                 EntryChatRoom();
  2133.             }
  2134.             return;
  2135.         }
  2136.         status++;
  2137.     }
  2138.     status = CheckActiveChatRoom();
  2139.     if (status >= 0)
  2140.     {
  2141.         SetCurrentChatRoomNo(status);
  2142.         FillChatRoomInfo((PU8) g_chat_cntx.chatRoomInfo[status].chatInfo.nickName, destnum, status);
  2143.         if (gChatInvitation)
  2144.         {
  2145.             ActivateChatRoom(status);
  2146.             UpdateChatRoom(status, RECEIVING_CHAT);
  2147.             EntryChatRoom();
  2148.             DeleteInvitationMessage();
  2149.         }
  2150.         else
  2151.         {
  2152.             EntryChatOption();
  2153.         }
  2154.         return;
  2155.     }
  2156.     else
  2157.     {
  2158.         EntryChatReplaceConfirm();
  2159.     }
  2160. }
  2161. /*****************************************************************************
  2162.  * FUNCTION
  2163.  *  CheckActiveChatRoom
  2164.  * DESCRIPTION
  2165.  *  This function returns Chat room number if not active else -1
  2166.  * PARAMETERS
  2167.  *  void
  2168.  * RETURNS
  2169.  *  chat room count
  2170.  *****************************************************************************/
  2171. S16 CheckActiveChatRoom(void)
  2172. {
  2173.     /*----------------------------------------------------------------*/
  2174.     /* Local Variables                                                */
  2175.     /*----------------------------------------------------------------*/
  2176.     S16 chatRoomCount;
  2177.     /*----------------------------------------------------------------*/
  2178.     /* Code Body                                                      */
  2179.     /*----------------------------------------------------------------*/
  2180.     for (chatRoomCount = 0; chatRoomCount < MAX_NO_OF_CHAT_ROOM; chatRoomCount++)
  2181.     {
  2182.         if (g_chat_cntx.chatRoomInfo[chatRoomCount].status == MMI_MSG_CHAT_DISABLE)
  2183.         {
  2184.             return chatRoomCount;
  2185.         }
  2186.     }
  2187.     return -1;
  2188. }
  2189. /*****************************************************************************
  2190.  * FUNCTION
  2191.  *  ReplaceChatRoom
  2192.  * DESCRIPTION
  2193.  *  This function Replaces first Chat Room with currently selected Chat Room
  2194.  * PARAMETERS
  2195.  *  void
  2196.  * RETURNS
  2197.  *  void
  2198.  *****************************************************************************/
  2199. void ReplaceChatRoom(void)
  2200. {
  2201.     /*----------------------------------------------------------------*/
  2202.     /* Local Variables                                                */
  2203.     /*----------------------------------------------------------------*/
  2204.     S16 status = 0;
  2205.     S32 checkindex = (status == 0) ? 1 : 0;
  2206.     S16 duplicateNumberStatus = CheckDuplicateNumber(gDestinationNo, checkindex);
  2207.     /*----------------------------------------------------------------*/
  2208.     /* Code Body                                                      */
  2209.     /*----------------------------------------------------------------*/
  2210.     if (duplicateNumberStatus)
  2211.     {
  2212.         DisplayPopup((PU8) GetString(CHATROOM_DUPLICATE_ERROR), IMG_GLOBAL_ERROR, FALSE, 2000, ERROR_TONE);
  2213.         DeleteScreenIfPresent(SCR_CHAT_REPLACE_QUERY);
  2214.         return;
  2215.     }
  2216.     if (gChatInvitation)
  2217.     {
  2218.         SetCurrentChatRoomNo(status);
  2219.         EndChatRoom();
  2220.         FillChatRoomInfo((PU8) g_chat_cntx.chatRoomInfo[status].chatInfo.nickName, gDestinationNo, status);
  2221.         ActivateChatRoom(status);
  2222.         UpdateChatRoom(status, RECEIVING_CHAT);
  2223.         EntryChatRoom();
  2224.         DeleteInvitationMessage();
  2225.     }
  2226.     else
  2227.     {
  2228.         history currHistory;
  2229.         historyNode *History;
  2230.         SetCurrentChatRoomNo(status);
  2231.         EndChatRoom();
  2232.         FillChatRoomInfo((PU8) g_chat_cntx.chatRoomInfo[status].chatInfo.nickName, gDestinationNo, status);
  2233.         if ((GetHistoryScrID(CHAT_SCREEN_ROOM_ID, &History) == ST_FAILURE))
  2234.         {
  2235.             currHistory.scrnID = CHAT_SCREEN_ROOM_ID;
  2236.             currHistory.entryFuncPtr = EntryChatOption;
  2237.             memset((S8*) currHistory.inputBuffer, 0, ENCODING_LENGTH);
  2238.             memset((S8*) currHistory.guiBuffer, 0, ENCODING_LENGTH);
  2239.             AddHistory(currHistory);
  2240.         }
  2241.         EntryChatRoomInfo();
  2242.     }
  2243. }
  2244. /*****************************************************************************
  2245.  * FUNCTION
  2246.  *  GetChatMsgToOutBox
  2247.  * DESCRIPTION
  2248.  *  It get chat message to save to outbox
  2249.  * PARAMETERS
  2250.  *  void
  2251.  * RETURNS
  2252.  *  void
  2253.  *****************************************************************************/
  2254. void GetChatMsgToOutBox(void)
  2255. {
  2256.     /*----------------------------------------------------------------*/
  2257.     /* Local Variables                                                */
  2258.     /*----------------------------------------------------------------*/
  2259.     S16 nMessageCount;
  2260.     EMSData *pEms;
  2261.     S8 newLineChar[4], endOfChar[4];
  2262.     S16 totalMsgSize = 0, size = 0, totalMsgCount;
  2263.     S16 maxBufferSize = MAX_MSG_SIZE + MAX_SMS_CHAT_HEADER_SIZE;
  2264.     S16 maxUcsLength = MAX_MSG_SIZE_UCS2;
  2265.     S16 roomIndex = GetCurrentChatRoomNo();
  2266.     /*----------------------------------------------------------------*/
  2267.     /* Code Body                                                      */
  2268.     /*----------------------------------------------------------------*/
  2269.     totalMsgCount = GetNumOfMessage(roomIndex);
  2270.     if (totalMsgCount == 0)
  2271.     {
  2272.         return;
  2273.     }
  2274.     AnsiiToUnicodeString((PS8) newLineChar, "n");
  2275.     AnsiiToUnicodeString((PS8) endOfChar, "");
  2276.     ReleaseEMSEditBuffer();
  2277.     GetEMSDataForEdit(&pEms, 1);
  2278.     ResetCurrentPosition(pEms);
  2279. /**********************************UCS CHECK *******************************/
  2280.     for (nMessageCount = 0; nMessageCount < totalMsgCount; nMessageCount++)
  2281.     {
  2282.         size =
  2283.             (S16) (pfnUnicodeStrlen
  2284.                    ((S8*) g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string));
  2285.         if ((totalMsgSize + size + 1) <= maxBufferSize)
  2286.         {
  2287.             if (GetUCS2Flag((PS8) g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string))
  2288.             {
  2289.                 if ((totalMsgSize + size + 1) <= maxUcsLength)
  2290.                 {
  2291.                     maxBufferSize = maxUcsLength;
  2292.                     EMSSetDCS(pEms, SMSAL_UCS2_DCS);
  2293.                 }
  2294.                 else
  2295.                 {
  2296.                     S16 UcsLength = 0;
  2297.                     S16 indexUcs = GetUCS2CharIndex((PS8) g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].
  2298.                                          chat_message_string);
  2299.                     if (indexUcs == -1)
  2300.                     {
  2301.                         break;
  2302.                     }
  2303.                     UcsLength = totalMsgSize + indexUcs + 1;
  2304.                     if (UcsLength <= maxBufferSize)
  2305.                     {
  2306.                         if (UcsLength <= maxUcsLength)
  2307.                         {
  2308.                             maxBufferSize = maxUcsLength;
  2309.                             EMSSetDCS(pEms, SMSAL_UCS2_DCS);
  2310.                         }
  2311.                         else
  2312.                         {
  2313.                             maxBufferSize = UcsLength;
  2314.                         }
  2315.                     }
  2316.                 }
  2317.                 break;
  2318.             }
  2319.             totalMsgSize += size + 1;
  2320.         }
  2321.         else
  2322.         {
  2323.             size = maxBufferSize - totalMsgSize - 1;
  2324.             if (size > 0)
  2325.             {
  2326.                 if (GetUCS2Flag
  2327.                     ((PS8) g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string))
  2328.                 {
  2329.                     S16 UcsLength = 0;
  2330.                     S16 indexUcs = GetUCS2CharIndex((PS8) g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].
  2331.                                          chat_message_string);
  2332.                     if (indexUcs == -1)
  2333.                     {
  2334.                         break;
  2335.                     }
  2336.                     UcsLength = totalMsgSize + indexUcs + 1;
  2337.                     if (UcsLength <= maxBufferSize)
  2338.                     {
  2339.                         maxBufferSize = UcsLength;
  2340.                     }
  2341.                     else
  2342.                     {
  2343.                         maxBufferSize = totalMsgSize;
  2344.                     }
  2345.                 }
  2346.                 break;
  2347.             }
  2348.         }
  2349.     }
  2350. /****************************UCS END************************************/
  2351.     totalMsgSize = 0;
  2352.     for (nMessageCount = 0; nMessageCount < totalMsgCount; nMessageCount++)
  2353.     {
  2354.         size =
  2355.             (S16) (pfnUnicodeStrlen
  2356.                    ((S8*) g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string));
  2357.         if ((totalMsgSize + size + 1) <= maxBufferSize)
  2358.         {
  2359.             AddString(
  2360.                 pEms,
  2361.                 g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string,
  2362.                 size,
  2363.                 NULL);
  2364.             AddString(pEms, (PU8) newLineChar, 1, NULL);
  2365.             totalMsgSize += size + 1;
  2366.         }
  2367.         else
  2368.         {
  2369.             size = maxBufferSize - totalMsgSize - 1;
  2370.             if (size > 0)
  2371.             {
  2372.                 AddString(
  2373.                     pEms,
  2374.                     g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string,
  2375.                     size,
  2376.                     NULL);
  2377.                 AddString(pEms, (PU8) newLineChar, 1, NULL);
  2378.                 g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nMessageCount].chat_message_string +=
  2379.                     size * ENCODING_LENGTH;
  2380.             }
  2381.             break;
  2382.         }
  2383.     }
  2384.     currentMsgCount = nMessageCount;
  2385. }
  2386. /*****************************************************************************
  2387.  * FUNCTION
  2388.  *  SaveChatMsgToOutBox
  2389.  * DESCRIPTION
  2390.  *  This  saves Chat Message to OutBox
  2391.  * PARAMETERS
  2392.  *  void
  2393.  * RETURNS
  2394.  *  void
  2395.  *****************************************************************************/
  2396. void SaveChatMsgToOutBox(void)
  2397. {
  2398.     /*----------------------------------------------------------------*/
  2399.     /* Local Variables                                                */
  2400.     /*----------------------------------------------------------------*/
  2401.     S16 roomIndex = GetCurrentChatRoomNo();
  2402.     /*----------------------------------------------------------------*/
  2403.     /* Code Body                                                      */
  2404.     /*----------------------------------------------------------------*/
  2405.     GetChatMsgToOutBox();
  2406.     gOutBoxSaveFlag = TRUE;
  2407.     mmi_msg_set_phb_send_case(MMI_SAVE_CHAT);
  2408.     mmi_msg_get_number_from_phb(NULL, g_chat_cntx.chatRoomInfo[roomIndex].chatInfo.destinationNo);
  2409. }
  2410. /*****************************************************************************
  2411.  * FUNCTION
  2412.  *  AdjustMemoryPointers
  2413.  * DESCRIPTION
  2414.  *  This  Replaces Saved Pointers with renmaining chat data pointer
  2415.  * PARAMETERS
  2416.  *  void
  2417.  * RETURNS
  2418.  *  status
  2419.  *****************************************************************************/
  2420. extern void SaveChatMsg(void);
  2421. U8 AdjustMemoryPointers(void)
  2422. {
  2423.     /*----------------------------------------------------------------*/
  2424.     /* Local Variables                                                */
  2425.     /*----------------------------------------------------------------*/
  2426.     S16 iCount, jCount, nCount, roomIndex;
  2427.     S16 remainingMsgCount;
  2428.     /*----------------------------------------------------------------*/
  2429.     /* Code Body                                                      */
  2430.     /*----------------------------------------------------------------*/
  2431.     roomIndex = GetCurrentChatRoomNo();
  2432.     remainingMsgCount = g_chat_cntx.chatRoomInfo[roomIndex].chatRoomCounter - currentMsgCount;
  2433.     jCount = currentMsgCount;
  2434.     for (iCount = 0; iCount < remainingMsgCount; iCount++, jCount++)
  2435.     {
  2436.         g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[iCount].chat_message_string =
  2437.             g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[jCount].chat_message_string;
  2438.         g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[iCount].flag =
  2439.             g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[jCount].flag;
  2440.     }
  2441.     for (nCount = iCount; nCount < remainingMsgCount + currentMsgCount; nCount++)
  2442.     {
  2443.         g_chat_cntx.chatRoomInfo[roomIndex].chatStrings[nCount].chat_message_string = NULL;
  2444.     }
  2445.     if ((remainingMsgCount >= 0))
  2446.     {
  2447.         g_chat_cntx.chatRoomInfo[roomIndex].chatRoomCounter = remainingMsgCount;
  2448.         ResetRoundedFlag(roomIndex);
  2449.     }
  2450.     else
  2451.     {
  2452.         ClearChat(roomIndex);
  2453.     }
  2454.     if (GetNumOfMessage(roomIndex) > 0)
  2455.     {
  2456.         GetChatMsgToOutBox();
  2457.         gOutBoxSaveFlag = TRUE;
  2458.         SaveChatMsg();
  2459.         return TRUE;
  2460.     }
  2461.     else
  2462.     {
  2463.         return FALSE;
  2464.     }
  2465. }
  2466. /*****************************************************************************
  2467.  * FUNCTION
  2468.  *  GetUCS2CharIndex
  2469.  * DESCRIPTION
  2470.  *  It returns UCS char position
  2471.  * PARAMETERS
  2472.  *  buffer      [IN]        
  2473.  *  Data Buffer(?)
  2474.  * RETURNS
  2475.  *  Ucs char position
  2476.  *****************************************************************************/
  2477. S16 GetUCS2CharIndex(PS8 buffer)
  2478. {
  2479.     /*----------------------------------------------------------------*/
  2480.     /* Local Variables                                                */
  2481.     /*----------------------------------------------------------------*/
  2482.     U8 index, bufferLen;
  2483.     S16 jCount;
  2484.     /*----------------------------------------------------------------*/
  2485.     /* Code Body                                                      */
  2486.     /*----------------------------------------------------------------*/
  2487.     bufferLen = (U8) (pfnUnicodeStrlen(buffer) * ENCODING_LENGTH);
  2488.     jCount = -1;
  2489.     for (index = 1; index < bufferLen; index += 2)
  2490.     {
  2491.         jCount++;
  2492.         if (buffer[index] != 0x00)
  2493.         {
  2494.             return jCount;
  2495.         }
  2496.     }
  2497.     return -1;
  2498. }
  2499. #endif /* __MMI_MESSAGES_CHAT__ */