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

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.  * mmi_imps_util.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements all common utilities for IMPS application.
  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.  *------------------------------------------------------------------------------
  88.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  89.  *============================================================================
  90.  ****************************************************************************/
  91. #ifndef _MMI_IMPS_UTIL_C
  92. #define _MMI_IMPS_UTIL_C
  93. #include "MMI_features.h"
  94. #ifdef __MMI_IMPS__
  95. /*  Include: MMI header file */
  96. #include "PixtelDataTypes.h"
  97. #include "stdC.h"
  98. #include "L4Dr1.h"
  99. #include "GlobalDefs.h"
  100. #include "CommonScreens.h"
  101. #include "DebugInitDef.h"
  102. #include "GlobalConstants.h"
  103. #include "FrameworkStruct.h"
  104. #include "EventsGprot.h"
  105. #include "HistoryGprot.h"
  106. #include "wgui_categories.h"
  107. #include "wgui_categories_inputs.h"
  108. #include "wgui_inline_edit.h"
  109. #include "mmi_imps_enum.h"
  110. #include "mmi_imps_prot.h"
  111. #include "nvram_user_defs.h"
  112. #include "NVRAMProt.h"
  113. #include "Fat_fs.h"
  114. #include "FileManagerGProt.h"
  115. #include "wgui_tab_bars.h"
  116. #include "wgui_categories_IMPS.h"
  117. #include "Wgui_status_icons.h"
  118. #include "QuickAccessMenuItemProt.h"
  119. #include "ProfileGprots.h"
  120. #include "mdi_datatype.h"
  121. #include "mdi_audio.h"
  122. #include "gpioInc.h"
  123. #include "CallManagementGprot.h"
  124. #include "IdleAppDef.h"
  125. #include "app_mine.h"
  126. /*  Include: PS header file */
  127. /* ... Add More PS header */
  128. /***************************************************************************** 
  129. * Define
  130. *****************************************************************************/
  131. /***************************************************************************** 
  132. * Typedef 
  133. *****************************************************************************/
  134. /***************************************************************************** 
  135. * Local Variable
  136. *****************************************************************************/
  137. const S8 g_imps_cont_filename[] = { 'c', '', 'o', '', 'n', '', 't', '', '', '' };
  138. const S8 g_imps_group_filename[] = { 'g', '', 'r', '', 'o', '', 'u', '', 'p', '', '', '' };
  139. const S8 g_imps_three_dot[] = { '.', '', '.', '', '.', '', '', '' };
  140. #ifdef __MTK_TARGET__
  141. __align(2)
  142. #endif 
  143.      const U8 g_imps_msg_tone[] = 
  144.      {
  145.          0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06,
  146.          0x00, 0x00, 0x00, 0x01, 0x03, 0xC0, 0x4D, 0x54,
  147.          0x72, 0x6B, 0x00, 0x00, 0x00, 0xA2, 0x00, 0xFF,
  148.          0x02, 0x16, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69,
  149.          0x67, 0x68, 0x74, 0x20, 0x63, 0x20, 0x32, 0x30,
  150.          0x30, 0x35, 0x20, 0x62, 0x79, 0x20, 0x43, 0x43,
  151.          0x00, 0xFF, 0x01, 0x02, 0x43, 0x43, 0x00, 0xFF,
  152.          0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xFF,
  153.          0x59, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x51, 0x03,
  154.          0x03, 0xD0, 0x90, 0x00, 0xC0, 0x60, 0x00, 0xB0,
  155.          0x07, 0x6E, 0x00, 0x90, 0x3E, 0x64, 0x00, 0xC1,
  156.          0x52, 0x00, 0xB1, 0x07, 0x5C, 0x00, 0x91, 0x3E,
  157.          0x64, 0x83, 0x60, 0x90, 0x43, 0x64, 0x00, 0x91,
  158.          0x43, 0x64, 0x83, 0x60, 0x90, 0x45, 0x64, 0x00,
  159.          0x91, 0x45, 0x64, 0x81, 0x70, 0x90, 0x35, 0x64,
  160.          0x00, 0x24, 0x64, 0x00, 0x91, 0x30, 0x64, 0x00,
  161.          0x2B, 0x64, 0x00, 0x26, 0x64, 0x81, 0x70, 0x35,
  162.          0x64, 0x81, 0x70, 0x26, 0x00, 0x00, 0x2B, 0x00,
  163.          0x00, 0x90, 0x24, 0x00, 0x00, 0x35, 0x00, 0x00,
  164.          0x91, 0x30, 0x00, 0x00, 0x90, 0x43, 0x00, 0x00,
  165.          0x3E, 0x00, 0x81, 0x70, 0x45, 0x00, 0x00, 0x91,
  166.          0x3E, 0x00, 0x00, 0x35, 0x00, 0x81, 0x70, 0x45,
  167.          0x00, 0x00, 0x43, 0x00, 0x00, 0xFF, 0x2F, 0x00,
  168.      };
  169.  #ifdef __MTK_TARGET__
  170. __align(2)
  171.  #endif 
  172.      const U8 g_imps_err_tone[] = 
  173.      {
  174.          0x4D, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06,
  175.          0x00, 0x00, 0x00, 0x01, 0x03, 0xC0, 0x4D, 0x54,
  176.          0x72, 0x6B, 0x00, 0x00, 0x00, 0x76, 0x00, 0xFF,
  177.          0x02, 0x16, 0x43, 0x6F, 0x70, 0x79, 0x72, 0x69,
  178.          0x67, 0x68, 0x74, 0x20, 0x63, 0x20, 0x32, 0x30,
  179.          0x30, 0x33, 0x20, 0x62, 0x79, 0x20, 0x43, 0x43,
  180.          0x00, 0xFF, 0x01, 0x02, 0x43, 0x43, 0x00, 0xFF,
  181.          0x58, 0x04, 0x04, 0x02, 0x18, 0x08, 0x00, 0xFF,
  182.          0x59, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x51, 0x03,
  183.          0x09, 0x27, 0xC0, 0x00, 0x99, 0x44, 0x64, 0x00,
  184.          0x4F, 0x64, 0x00, 0x52, 0x7D, 0x05, 0x38, 0x64,
  185.          0x23, 0x4B, 0x64, 0x2A, 0x4A, 0x64, 0x05, 0x3E,
  186.          0x64, 0x35, 0x41, 0x64, 0x53, 0x4D, 0x64, 0x05,
  187.          0x42, 0x64, 0x0C, 0x52, 0x00, 0x00, 0x44, 0x00,
  188.          0x00, 0x4F, 0x00, 0x05, 0x38, 0x00, 0x23, 0x4B,
  189.          0x00, 0x2A, 0x4A, 0x00, 0x05, 0x3E, 0x00, 0x35,
  190.          0x41, 0x00, 0x53, 0x4D, 0x00, 0x05, 0x42, 0x00,
  191.          0x00, 0xFF, 0x2F, 0x00,
  192.      };
  193. /***************************************************************************** 
  194. * Local Function
  195. *****************************************************************************/
  196. /***************************************************************************** 
  197. * Global Variable
  198. *****************************************************************************/
  199. const mmi_imps_err_mapping_struct g_imps_err_tbl[] = 
  200. {
  201.     {IMPS_OK, STR_GLOBAL_OK},
  202.     {IMPS_ERROR_GENERAL, STR_ID_IMPS_ERR_UNKNOWN_ERROR},
  203.     {IMPS_ERROR_INVALID_PARAMETER, STR_ID_IMPS_ERR_INVALID_INPUT},
  204.     {IMPS_ERROR_SERVICE_NOT_AGREED, STR_ID_IMPS_ERR_UNSUPPORT_SERVICE},
  205.     {IMPS_ERROR_NOT_LOGGED_IN, STR_ID_IMPS_ERR_NOT_LOGIN},
  206.     {IMPS_ERROR_ALREADY_LOGGED_IN, STR_ID_IMPS_ERR_ALREADY_LOGIN},
  207.     {IMPS_ERROR_LOGIN_INVALID_PASSWD, STR_ID_IMPS_ERR_INVALID_PASSWD},
  208.     {IMPS_ERROR_LOGIN_INVALID_USER, STR_ID_IMPS_ERR_INVALID_USERNAME},
  209.     {IMPS_ERROR_LOGIN_INVALID_SERVER, STR_ID_IMPS_ERR_INVALID_SERVER},
  210.     {IMPS_ERROR_BAD_CLIENT_REQUEST, STR_ID_IMPS_ERR_INVALID_REQUEST},
  211.     {IMPS_ERROR_SERVER_NOT_SUPPORT, STR_ID_IMPS_ERR_SERVER_NOT_SUPPORT},
  212.     {IMPS_ERROR_SESSION_PROBLEM, STR_ID_IMPS_ERR_SESSION_PROBLEM},      /* attar: imps sesssion related problem */
  213.     {IMPS_ERROR_PRESENCE_PROBLEM, STR_ID_IMPS_ERR_PRESENCE_PROBLEM},    /* attar: imps presence related problem */
  214.     {IMPS_ERROR_GROUP_ALREADY_EXIST, STR_ID_IMPS_ERR_ROOM_EXIST},
  215.     {IMPS_ERROR_GROUP_PROBLEM, STR_ID_IMPS_ERR_GROUP_PROBLEM},  /* attar: imps group related problem */
  216.     {IMPS_ERROR_GROUP_NOT_EXIST, STR_ID_IMPS_ERR_ROOM_NOT_EXIST},
  217.     {IMPS_ERROR_CREATE_XML_FILE_FAIL, STR_ID_IMPS_ERR_SEND_REQUEST_FAIL},       /* attar : request can not be fulfilled */
  218.     {IMPS_ERROR_PARSE_XML_FILE_FAIL, STR_ID_IMPS_ERR_RECV_RESPONSE_FAIL},       /* attar : invalid content format */
  219.     {IMPS_ERROR_HIT_MAX_GROUP, STR_ID_IMPS_ERR_CHAT_ROOM_FULL},
  220.     {IMPS_ERROR_HIT_MAX_TRANSACTION, STR_ID_IMPS_ERR_NETWORK_BUSY},
  221.     {IMPS_ERROR_HIT_MAX_INVITATION, STR_ID_IMPS_ERR_NETWORK_BUSY},
  222.     {IMPS_ERROR_WRONG_TRANSACTION_ID, STR_ID_IMPS_ERR_UNKNOWN_ERROR},
  223.     {IMPS_ERROR_HTTP_FAIL, STR_ID_IMPS_ERR_CONN_FAILED},
  224.     {IMPS_ERROR_ABORT_FAIL, STR_ID_IMPS_ERR_ABORT_FAIL},
  225.     {IMPS_ERROR_WRONG_MSG_TYPE, STR_ID_IMPS_ERR_CONN_FAILED},
  226.     {IMPS_ERROR_UNAUTHORIZED, STR_ID_IMPS_ERR_AUTH_FAIL},
  227.     {IMPS_ERROR_REQUEST_TIMEOUT, STR_ID_IMPS_ERR_REQUEST_TIMEOUT},
  228.     {IMPS_ERROR_SENDER_IS_BLOCKED, STR_ID_IMPS_ERR_MSG_SEND_FAIL},
  229.     {IMPS_ERROR_TOO_BROAD_SEARCH_CRITERIA, STR_ID_IMPS_ERR_TOO_BROAD_SEARCH_CRITERIA},
  230.     {IMPS_ERROR_MESSAGE_IS_REJECTED, STR_ID_IMPS_ERR_MSG_REJECT_BY_RECIPIENT},
  231.     {IMPS_ERROR_HIT_MAX_CONTACTS, STR_ID_IMPS_ERR_CONT_FULL},
  232.     {IMPS_ERROR_HIT_MAX_CONTACT_LISTS, STR_ID_IMPS_ERR_CONT_LIST_FULL},
  233.     {IMPS_ERROR_SCREEN_NAME_IN_USE, STR_ID_IMPS_ERR_SNAME_IN_USE},
  234.     {IMPS_ERROR_GROUP_ALREADY_JOINED, STR_ID_IMPS_ERR_ROOM_ALREADY_JOINED},
  235.     {IMPS_ERROR_GROUP_NOT_JOINED, STR_ID_IMPS_ERR_ROOM_NOT_JOINED},
  236.     {IMPS_ERROR_FORCED_LEAVE_GROUP, STR_GLOBAL_ERROR},  /* not required, because it's sent with MSG_ID_MMI_IMPS_LEAVE_GROUP_IND */
  237.     {IMPS_ERROR_HIT_MAX_JOINED_USER, STR_ID_IMPS_ERR_ROOM_FULL},
  238.     {IMPS_ERROR_SEARCH_NEED_NAME_OR_TOPIC, STR_ID_IMPS_ERR_NO_SEATCH_RESULT},
  239.     {IMPS_ERROR_FILE_ACCESS_ERROR, STR_ID_IMPS_ERR_FILE_ACCESS_ERROR}
  240. };
  241. /*****************************************************************************
  242. * Global Function
  243. *****************************************************************************/
  244. /*****************************************************************************
  245.  * FUNCTION
  246.  *  mmi_imps_util_get_err_str
  247.  * DESCRIPTION
  248.  *  Get error string for a error code.
  249.  * PARAMETERS
  250.  *  err     [IN]        
  251.  * RETURNS
  252.  *  void
  253.  *****************************************************************************/
  254. U16 mmi_imps_util_get_err_str(S32 err)
  255. {
  256.     /*----------------------------------------------------------------*/
  257.     /* Local Variables                                                */
  258.     /*----------------------------------------------------------------*/
  259.     S16 i;
  260.     S16 entry;
  261.     /*----------------------------------------------------------------*/
  262.     /* Code Body                                                      */
  263.     /*----------------------------------------------------------------*/
  264.     entry = sizeof(g_imps_err_tbl) / sizeof(mmi_imps_err_mapping_struct);
  265.     for (i = 0; i < entry; i++)
  266.         if (g_imps_err_tbl[i].err_cause == err)
  267.         {
  268.             return g_imps_err_tbl[i].str_id;
  269.         }
  270.     return STR_ID_IMPS_ERR_UNKNOWN_ERROR;
  271. }
  272. /*****************************************************************************
  273.  * FUNCTION
  274.  *  mmi_imps_util_init_list
  275.  * DESCRIPTION
  276.  *  Initialize contact list and group list from file system.
  277.  * PARAMETERS
  278.  *  void
  279.  * RETURNS
  280.  *  void
  281.  *****************************************************************************/
  282. void mmi_imps_util_init_list(void)
  283. {
  284.     /*----------------------------------------------------------------*/
  285.     /* Local Variables                                                */
  286.     /*----------------------------------------------------------------*/
  287.     /*----------------------------------------------------------------*/
  288.     /* Code Body                                                      */
  289.     /*----------------------------------------------------------------*/
  290.     mmi_imps_util_read_cont();
  291.     mmi_imps_util_read_group();
  292. }
  293. /*****************************************************************************
  294.  * FUNCTION
  295.  *  mmi_imps_util_read_nvram
  296.  * DESCRIPTION
  297.  *  Read profile info from NVRAM
  298.  * PARAMETERS
  299.  *  buff        [?]     
  300.  * RETURNS
  301.  *  void
  302.  *****************************************************************************/
  303. void mmi_imps_util_read_nvram(void *buff)
  304. {
  305.     /*----------------------------------------------------------------*/
  306.     /* Local Variables                                                */
  307.     /*----------------------------------------------------------------*/
  308.     S16 error;
  309.     /*----------------------------------------------------------------*/
  310.     /* Code Body                                                      */
  311.     /*----------------------------------------------------------------*/
  312.     ReadRecord(NVRAM_EF_IMPS_LID, 1, (void*)buff, NVRAM_EF_IMPS_SIZE, &error);
  313. }
  314. /*****************************************************************************
  315.  * FUNCTION
  316.  *  mmi_imps_util_write_nvram
  317.  * DESCRIPTION
  318.  *  Write profile info to NVRAM
  319.  * PARAMETERS
  320.  *  buff        [?]     
  321.  * RETURNS
  322.  *  void
  323.  *****************************************************************************/
  324. void mmi_imps_util_write_nvram(void *buff)
  325. {
  326.     /*----------------------------------------------------------------*/
  327.     /* Local Variables                                                */
  328.     /*----------------------------------------------------------------*/
  329.     S16 error;
  330.     /*----------------------------------------------------------------*/
  331.     /* Code Body                                                      */
  332.     /*----------------------------------------------------------------*/
  333.     WriteRecord(NVRAM_EF_IMPS_LID, 1, (void*)buff, NVRAM_EF_IMPS_SIZE, &error);
  334. }
  335. /*****************************************************************************
  336.  * FUNCTION
  337.  *  mmi_imps_util_get_file_size
  338.  * DESCRIPTION
  339.  *  Get size of a file
  340.  * PARAMETERS
  341.  *  filePathPtr         [?]             
  342.  *  fileSizePtr         [?]             
  343.  *  fileSizePrt(?)      [IN/OUT]        Address to store the size of file
  344.  *  filePathPrt(?)      [IN]            File path and name
  345.  * RETURNS
  346.  *  Error cause of file open
  347.  *****************************************************************************/
  348. S32 mmi_imps_util_get_file_size(S8 *filePathPtr, S32 *fileSizePtr)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     FS_HANDLE fileHandle;
  354.     /*----------------------------------------------------------------*/
  355.     /* Code Body                                                      */
  356.     /*----------------------------------------------------------------*/
  357.     fileHandle = FS_Open((U16*) filePathPtr, FS_READ_ONLY);
  358.     if (fileHandle > 0)
  359.     {
  360.         S32 result;
  361.         result = FS_GetFileSize(fileHandle, (U32*) fileSizePtr);
  362.         FS_Close(fileHandle);
  363.         return result;
  364.     }
  365.     return fileHandle;
  366. }
  367. /*****************************************************************************
  368.  * FUNCTION
  369.  *  mmi_imps_util_check_file_exist
  370.  * DESCRIPTION
  371.  *  Check if the file already exists.
  372.  * PARAMETERS
  373.  *  filePathName        [IN]        Full file path + name
  374.  * RETURNS
  375.  *  TRUE if exists, otherwise, FALSE.
  376.  *****************************************************************************/
  377. BOOL mmi_imps_util_check_file_exist(S8 *filePathName)
  378. {
  379.     /*----------------------------------------------------------------*/
  380.     /* Local Variables                                                */
  381.     /*----------------------------------------------------------------*/
  382.     FS_HANDLE fileHandle;
  383.     /*----------------------------------------------------------------*/
  384.     /* Code Body                                                      */
  385.     /*----------------------------------------------------------------*/
  386.     fileHandle = FS_Open((U16*) filePathName, FS_READ_ONLY);
  387.     if (fileHandle > 0)
  388.     {
  389.         FS_Close(fileHandle);
  390.         return TRUE;
  391.     }
  392.     return FALSE;
  393. }
  394. /*****************************************************************************
  395.  * FUNCTION
  396.  *  mmi_imps_util_update_cont
  397.  * DESCRIPTION
  398.  *  Remove dangling file and update contact list to file
  399.  * PARAMETERS
  400.  *  void
  401.  *  filePathName(?)     [IN]        Full file path + name
  402.  * RETURNS
  403.  *  TRUE if exists, otherwise, FALSE.(?)
  404.  *****************************************************************************/
  405. void mmi_imps_util_update_cont(void)
  406. {
  407.     /*----------------------------------------------------------------*/
  408.     /* Local Variables                                                */
  409.     /*----------------------------------------------------------------*/
  410.     S32 i;
  411.     S32 count = (S32) imps_p->cont_info.no_cont;
  412.     /*----------------------------------------------------------------*/
  413.     /* Code Body                                                      */
  414.     /*----------------------------------------------------------------*/
  415.     /* remove dangling contact list */
  416.     for (i = 0; i < count; i++)
  417.     {
  418.         if ((imps_p->cont_info.cont_list[i].comm_state & IMPS_CONT_PA_READY) == 0)
  419.         {
  420.             if (i < (count - 1))
  421.             {
  422.                 memcpy(&imps_p->cont_info.cont_list[i], &imps_p->cont_info.cont_list[i + 1], (count - i - 1));
  423.                 memset(&imps_p->cont_info.cont_list[count], 0, sizeof(mmi_imps_cont_struct));
  424.             }
  425.             else
  426.             {
  427.                 memset(&imps_p->cont_info.cont_list[i], 0, sizeof(mmi_imps_cont_struct));
  428.             }
  429.             count--;
  430.         }
  431.     }
  432.     imps_p->cont_info.no_cont = (U8) count;
  433.     mmi_imps_util_write_cont();
  434. }
  435. /*****************************************************************************
  436.  * FUNCTION
  437.  *  mmi_imps_util_write_cont
  438.  * DESCRIPTION
  439.  *  Write contact list data to file
  440.  * PARAMETERS
  441.  *  void
  442.  * RETURNS
  443.  *  result of file operation
  444.  *****************************************************************************/
  445. S32 mmi_imps_util_write_cont(void)
  446. {
  447.     /*----------------------------------------------------------------*/
  448.     /* Local Variables                                                */
  449.     /*----------------------------------------------------------------*/
  450.     FS_HANDLE fileHandle;
  451.     S16 *ucs2_folder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  452.     /*----------------------------------------------------------------*/
  453.     /* Code Body                                                      */
  454.     /*----------------------------------------------------------------*/
  455.     mmi_imps_util_get_work_path((S8*) ucs2_folder);
  456.     pfnUnicodeStrcat((S8*) ucs2_folder, (S8*) g_imps_cont_filename);
  457.     fileHandle = FS_Open((U16*) ucs2_folder, FS_CREATE_ALWAYS);
  458.     OslMfree(ucs2_folder);
  459.     if (fileHandle > 0)
  460.     {
  461.         S32 result;
  462.         U32 len;
  463.         result = FS_Write(
  464.                     fileHandle,
  465.                     (void*)&imps_p->cont_info.cont_list[0],
  466.                     sizeof(mmi_imps_cont_struct) * IMPS_MAX_NO_CONT,
  467.                     (U32*) & len);
  468.         FS_Close(fileHandle);
  469.         return result;
  470.     }
  471.     return fileHandle;
  472. }
  473. /*****************************************************************************
  474.  * FUNCTION
  475.  *  mmi_imps_util_read_cont
  476.  * DESCRIPTION
  477.  *  Read contact list data from file
  478.  * PARAMETERS
  479.  *  void
  480.  * RETURNS
  481.  *  result of file operation
  482.  *****************************************************************************/
  483. S32 mmi_imps_util_read_cont(void)
  484. {
  485.     /*----------------------------------------------------------------*/
  486.     /* Local Variables                                                */
  487.     /*----------------------------------------------------------------*/
  488.     FS_HANDLE fileHandle;
  489.     S16 *ucs2_folder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  490.     mmi_imps_cont_struct *cont;
  491.     /*----------------------------------------------------------------*/
  492.     /* Code Body                                                      */
  493.     /*----------------------------------------------------------------*/
  494.     mmi_imps_util_get_work_path((S8*) ucs2_folder);
  495.     pfnUnicodeStrcat((S8*) ucs2_folder, (S8*) g_imps_cont_filename);
  496.     fileHandle = FS_Open((U16*) ucs2_folder, FS_READ_ONLY);
  497.     if (fileHandle > 0)
  498.     {
  499.         U32 len;
  500.         S32 i;
  501.         FS_Read(
  502.             fileHandle,
  503.             (void*)&imps_p->cont_info.cont_list[0],
  504.             sizeof(mmi_imps_cont_struct) * IMPS_MAX_NO_CONT,
  505.             (U32*) & len);
  506.         for (i = 1; i < IMPS_MAX_NO_CONT; i++)
  507.         {
  508.             cont = &imps_p->cont_info.cont_list[i];
  509.             if (strlen((S8*) cont->id))
  510.             {
  511.                 cont->comm_state = 0;
  512.                 cont->availability = IMPS_PA_USER_UNKNOWN;
  513.             }
  514.             else
  515.             {
  516.                 break;
  517.             }
  518.         }
  519.         imps_p->cont_info.no_cont = (U8) i;
  520.         FS_Close(fileHandle);
  521.         OslMfree(ucs2_folder);
  522.     }
  523. #ifdef IMPS_TEST_CODE
  524.     else
  525.     {
  526.         S32 result;
  527.         U32 len;
  528.         S32 i;
  529.         fileHandle = FS_Open((U16*) ucs2_folder, FS_CREATE_ALWAYS);
  530.         if (strlen((S8*) imps_p->act_prof.username) == 0)
  531.         {
  532.             strcpy((S8*) imps_p->cont_info.cont_list[0].id, (S8*) "Max Chen");
  533.         }
  534.         else
  535.         {
  536.             strcpy((S8*) imps_p->cont_info.cont_list[0].id, (S8*) imps_p->act_prof.username);
  537.         }
  538.         strcpy((S8*) imps_p->cont_info.cont_list[0].group_id, (S8*) "MySelf");
  539.         pfnUnicodeStrcpy((S8*) imps_p->cont_info.cont_list[0].alias, (S8*) L"MAXMAX");
  540.         for (i = 1; i < IMPS_MAX_NO_CONT; i++)
  541.         {
  542.             sprintf((S8*) imps_p->cont_info.cont_list[i].id, (S8*) "Max %ld", i);
  543.             sprintf((S8*) imps_p->cont_info.cont_list[i].group_id, "WCP_SW_PS%ld", (IMPS_MAX_NO_CONT - i));
  544.             AnsiiToUnicodeString((S8*) imps_p->cont_info.cont_list[i].alias, (S8*) "IMPS");
  545.             imps_p->cont_info.cont_list[i].availability = (U8) (i % 3);
  546.         }
  547.         result = FS_Write(
  548.                     fileHandle,
  549.                     (void*)&imps_p->cont_info.cont_list[0],
  550.                     sizeof(mmi_imps_cont_struct) * IMPS_MAX_NO_CONT,
  551.                     (U32*) & len);
  552.         FS_Close(fileHandle);
  553.         OslMfree(ucs2_folder);
  554.         return result;
  555.     }
  556. #elif defined(IMPS_PROF_TEST_CODE)
  557.     else
  558.     {
  559.         S32 result;
  560.         U32 len;
  561.         fileHandle = FS_Open((U16*) ucs2_folder, FS_CREATE_ALWAYS);
  562.         if (strlen((S8*) imps_p->act_prof.username) == 0)
  563.         {
  564.             strcpy((S8*) imps_p->cont_info.cont_list[0].id, (S8*) "wv:max");
  565.         }
  566.         else
  567.         {
  568.             strcpy((S8*) imps_p->cont_info.cont_list[0].id, (S8*) imps_p->act_prof.username);
  569.         }
  570.         strcpy((S8*) imps_p->cont_info.cont_list[0].group_id, (S8*) "MySelf");
  571.         pfnUnicodeStrcpy((S8*) imps_p->cont_info.cont_list[0].nick_name, (S8*) L"max");
  572.     #if 0
  573. /* under construction !*/
  574. /* under construction !*/
  575. /* under construction !*/
  576. /* under construction !*/
  577. /* under construction !*/
  578. /* under construction !*/
  579. /* under construction !*/
  580. /* under construction !*/
  581. /* under construction !*/
  582. /* under construction !*/
  583. /* under construction !*/
  584. /* under construction !*/
  585. /* under construction !*/
  586. /* under construction !*/
  587. /* under construction !*/
  588.     #endif /* 0 */ 
  589.         result = FS_Write(
  590.                     fileHandle,
  591.                     (void*)&imps_p->cont_info.cont_list[0],
  592.                     sizeof(mmi_imps_cont_struct) * 1,
  593.                     (U32*) & len);
  594.         FS_Close(fileHandle);
  595.         imps_p->cont_info.no_cont = (U8) 1;
  596.         OslMfree(ucs2_folder);
  597.         return result;
  598.     }
  599. #endif 
  600.     return fileHandle;
  601. }
  602. /*****************************************************************************
  603.  * FUNCTION
  604.  *  mmi_imps_util_write_group
  605.  * DESCRIPTION
  606.  *  Write group data to file
  607.  * PARAMETERS
  608.  *  void
  609.  * RETURNS
  610.  *  result of file operation
  611.  *****************************************************************************/
  612. S32 mmi_imps_util_write_group(void)
  613. {
  614.     /*----------------------------------------------------------------*/
  615.     /* Local Variables                                                */
  616.     /*----------------------------------------------------------------*/
  617.     FS_HANDLE fileHandle;
  618.     S16 *ucs2_folder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  619.     /*----------------------------------------------------------------*/
  620.     /* Code Body                                                      */
  621.     /*----------------------------------------------------------------*/
  622.     mmi_imps_util_get_work_path((S8*) ucs2_folder);
  623.     pfnUnicodeStrcat((S8*) ucs2_folder, (S8*) g_imps_group_filename);
  624.     fileHandle = FS_Open((U16*) ucs2_folder, FS_CREATE_ALWAYS);
  625.     OslMfree(ucs2_folder);
  626.     if (fileHandle > 0)
  627.     {
  628.         S32 result;
  629.         U32 len;
  630.         result = FS_Write(
  631.                     fileHandle,
  632.                     (void*)&imps_p->group_info.group_list[0],
  633.                     sizeof(mmi_imps_group_struct) * IMPS_MAX_NO_GROUP,
  634.                     (U32*) & len);
  635.         FS_Close(fileHandle);
  636.         return result;
  637.     }
  638.     return fileHandle;
  639. }
  640. /*****************************************************************************
  641.  * FUNCTION
  642.  *  mmi_imps_util_read_group
  643.  * DESCRIPTION
  644.  *  Write group data to file
  645.  * PARAMETERS
  646.  *  void
  647.  * RETURNS
  648.  *  result of file operation
  649.  *****************************************************************************/
  650. S32 mmi_imps_util_read_group(void)
  651. {
  652.     /*----------------------------------------------------------------*/
  653.     /* Local Variables                                                */
  654.     /*----------------------------------------------------------------*/
  655.     FS_HANDLE fileHandle;
  656.     S16 *ucs2_folder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  657.     /*----------------------------------------------------------------*/
  658.     /* Code Body                                                      */
  659.     /*----------------------------------------------------------------*/
  660.     mmi_imps_util_get_work_path((S8*) ucs2_folder);
  661.     pfnUnicodeStrcat((S8*) ucs2_folder, (S8*) g_imps_group_filename);
  662.     fileHandle = FS_Open((U16*) ucs2_folder, FS_READ_ONLY);
  663.     if (fileHandle > 0)
  664.     {
  665.         U32 len;
  666.         S32 i;
  667.         FS_Read(
  668.             fileHandle,
  669.             (void*)&imps_p->group_info.group_list[0],
  670.             sizeof(mmi_imps_group_struct) * IMPS_MAX_NO_GROUP,
  671.             (U32*) & len);
  672.         for (i = 0; i < IMPS_MAX_NO_GROUP; i++)
  673.         {
  674.             if (strlen((S8*) imps_p->group_info.group_list[i].group_id))
  675.             {
  676.                 imps_p->group_info.group_list[i].is_sync = FALSE;
  677.             }
  678.             else
  679.             {
  680.                 break;
  681.             }
  682.         }
  683.         imps_p->group_info.no_group = (U8) i;
  684.         FS_Close(fileHandle);
  685.         OslMfree(ucs2_folder);
  686.         return 0;
  687.     }
  688. #ifdef IMPS_TEST_CODE
  689.     else
  690.     {
  691.         S32 result;
  692.         U32 len;
  693.         fileHandle = FS_Open((U16*) ucs2_folder, FS_CREATE_ALWAYS);
  694.         strcpy((S8*) imps_p->group_info.group_list[0].group_id, (S8*) "WCP_SW_PS1");
  695.         AnsiiToUnicodeString((S8*) imps_p->group_info.group_list[0].group_name, (S8*) "PS1");
  696.         imps_p->group_info.group_list[0].no_users = (IMPS_MAX_NO_CONT - 1);
  697.         imps_p->group_info.group_list[0].is_sync = TRUE;
  698.         strcpy((S8*) imps_p->group_info.group_list[1].group_id, (S8*) "WCP_SW_PS2");
  699.         AnsiiToUnicodeString((S8*) imps_p->group_info.group_list[1].group_name, (S8*) "PS2");
  700.         imps_p->group_info.group_list[1].no_users = 0;
  701.         imps_p->group_info.group_list[0].is_sync = FALSE;
  702.         imps_p->group_info.no_group = 2;
  703.         result = FS_Write(
  704.                     fileHandle,
  705.                     (void*)&imps_p->group_info.group_list[0],
  706.                     sizeof(mmi_imps_group_struct) * IMPS_MAX_NO_GROUP,
  707.                     (U32*) & len);
  708.         FS_Close(fileHandle);
  709.         OslMfree(ucs2_folder);
  710.         return result;
  711.     }
  712. #endif /* IMPS_TEST_CODE */ 
  713.     OslMfree(ucs2_folder);
  714.     return fileHandle;
  715. }
  716. /*****************************************************************************
  717.  * FUNCTION
  718.  *  mmi_imps_util_reset_cont_list
  719.  * DESCRIPTION
  720.  *  Reset contact list when data account changed.
  721.  * PARAMETERS
  722.  *  void
  723.  * RETURNS
  724.  *  void
  725.  *****************************************************************************/
  726. void mmi_imps_util_reset_cont_list(void)
  727. {
  728.     /*----------------------------------------------------------------*/
  729.     /* Local Variables                                                */
  730.     /*----------------------------------------------------------------*/
  731.     /*----------------------------------------------------------------*/
  732.     /* Code Body                                                      */
  733.     /*----------------------------------------------------------------*/
  734.     /* update contact list */
  735.     memset(&imps_p->cont_info.cont_list[0], 0, IMPS_MAX_NO_CONT * sizeof(mmi_imps_cont_struct));
  736.     strcpy((S8*) imps_p->cont_info.cont_list[0].id, (S8*) imps_p->act_prof.username);
  737.     imps_p->cont_info.no_cont = 1;
  738.     mmi_imps_util_write_cont();
  739.     /* reset group list */
  740.     memset(&imps_p->group_info.group_list[0], 0, IMPS_MAX_NO_GROUP * sizeof(mmi_imps_group_struct));
  741.     mmi_imps_util_write_group();
  742.     imps_p->group_info.no_group = 0;
  743. }
  744. /*****************************************************************************
  745.  * FUNCTION
  746.  *  mmi_imps_util_reset_about_me
  747.  * DESCRIPTION
  748.  *  Reset about me data when data account changed.
  749.  * PARAMETERS
  750.  *  buff        [OUT]       Buffer which stores whole NVRAM data.
  751.  * RETURNS
  752.  *  void
  753.  *****************************************************************************/
  754. void mmi_imps_util_reset_about_me(void *buff)
  755. {
  756.     /*----------------------------------------------------------------*/
  757.     /* Local Variables                                                */
  758.     /*----------------------------------------------------------------*/
  759.     mmi_imps_nvram_struct *nvram_data = (mmi_imps_nvram_struct*) buff;
  760.     /*----------------------------------------------------------------*/
  761.     /* Code Body                                                      */
  762.     /*----------------------------------------------------------------*/
  763.     memset(&nvram_data->about_me, 0, sizeof(mmi_imps_about_me_nvram_struct));
  764. }
  765. /*****************************************************************************
  766.  * FUNCTION
  767.  *  mmi_imps_util_is_id_same
  768.  * DESCRIPTION
  769.  *  Compare if two ids are identical (without wv:)
  770.  * PARAMETERS
  771.  *  id1     [IN]        Id to be compared
  772.  *  id2     [IN]        Id to be compared
  773.  * RETURNS
  774.  *  TRUE if identical; otherwise, FALSE
  775.  *****************************************************************************/
  776. BOOL mmi_imps_util_is_id_same(S8 *id1, S8 *id2)
  777. {
  778.     /*----------------------------------------------------------------*/
  779.     /* Local Variables                                                */
  780.     /*----------------------------------------------------------------*/
  781.     S8 *str1, *str2;
  782.     S8 *comp1, *comp2;
  783.     BOOL result = FALSE;
  784.     /*----------------------------------------------------------------*/
  785.     /* Code Body                                                      */
  786.     /*----------------------------------------------------------------*/
  787.     comp1 = OslMalloc(IMPS_MAX_ID_LEN);
  788.     comp2 = OslMalloc(IMPS_MAX_ID_LEN);
  789.     /* remove wv: */
  790.     str1 = id1;
  791.     if (str1[0] == 'w' && str1[1] == 'v' && str1[2] == ':')
  792.     {
  793.         str1 += 3;
  794.     }
  795.     str2 = id2;
  796.     if (str2[0] == 'w' && str2[1] == 'v' && str2[2] == ':')
  797.     {
  798.         str2 += 3;
  799.     }
  800.     strcpy(comp1, str1);
  801.     strcpy(comp2, str2);
  802.     /* check if @ exist */
  803.     str1 = strstr(comp1, "@");
  804.     str2 = strstr(comp2, "@");
  805.     if (str1 == NULL && str2 != NULL)   /* trancated @ after str_at2 */
  806.     {
  807.         str2[0] = '';
  808.     }
  809.     else if (str1 != NULL && str2 == NULL)
  810.     {
  811.         str1[0] = '';
  812.     }
  813.     if (mmi_imps_util_stricmp(comp1, comp2) == 0)
  814.     {
  815.         result = TRUE;
  816.     }
  817.     OslMfree(comp1);
  818.     OslMfree(comp2);
  819.     return result;
  820. }
  821. /*****************************************************************************
  822.  * FUNCTION
  823.  *  mmi_imps_util_is_cont_exist
  824.  * DESCRIPTION
  825.  *  Check if the contact already exists in contact list
  826.  * PARAMETERS
  827.  *  id      [IN]        Id of the contact
  828.  * RETURNS
  829.  *  TRUE if the contact exists; otherwise, FALSE
  830.  *****************************************************************************/
  831. BOOL mmi_imps_util_is_cont_exist(S8 *id)
  832. {
  833.     /*----------------------------------------------------------------*/
  834.     /* Local Variables                                                */
  835.     /*----------------------------------------------------------------*/
  836.     S32 i;
  837.     S32 count = (S32) imps_p->cont_info.no_cont;
  838.     /*----------------------------------------------------------------*/
  839.     /* Code Body                                                      */
  840.     /*----------------------------------------------------------------*/
  841.     /* check if contact exists */
  842.     for (i = 0; i < count; i++)
  843.         if (mmi_imps_util_is_id_same(id, (S8*) imps_p->cont_info.cont_list[i].id))
  844.         {
  845.             return TRUE;
  846.         }
  847.     return FALSE;
  848. }
  849. /*****************************************************************************
  850.  * FUNCTION
  851.  *  mmi_imps_util_is_room_joined
  852.  * DESCRIPTION
  853.  *  Check if the user has already joined the chat room
  854.  * PARAMETERS
  855.  *  id      [IN]        Id of the chat room
  856.  * RETURNS
  857.  *  TRUE if the user has already joined the chat room; otherwise, FALSE
  858.  *****************************************************************************/
  859. BOOL mmi_imps_util_is_room_joined(S8 *id)
  860. {
  861.     /*----------------------------------------------------------------*/
  862.     /* Local Variables                                                */
  863.     /*----------------------------------------------------------------*/
  864.     S32 i;
  865.     /*----------------------------------------------------------------*/
  866.     /* Code Body                                                      */
  867.     /*----------------------------------------------------------------*/
  868.     /* check if the room is already joined */
  869.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  870.         if (imps_p->room_info.room_list[i].is_used)
  871.             if (strcmp(id, (S8*) imps_p->room_info.room_list[i].room_id) == 0)
  872.             {
  873.                 return TRUE;
  874.             }
  875.     return FALSE;
  876. }
  877. /*****************************************************************************
  878.  * FUNCTION
  879.  *  mmi_imps_util_get_empty_room_slot
  880.  * DESCRIPTION
  881.  *  Get the index of empty slot of chat room
  882.  * PARAMETERS
  883.  *  void
  884.  * RETURNS
  885.  *  Index in the chat room array
  886.  *****************************************************************************/
  887. S32 mmi_imps_util_get_empty_room_slot(void)
  888. {
  889.     /*----------------------------------------------------------------*/
  890.     /* Local Variables                                                */
  891.     /*----------------------------------------------------------------*/
  892.     S32 i;
  893.     /*----------------------------------------------------------------*/
  894.     /* Code Body                                                      */
  895.     /*----------------------------------------------------------------*/
  896.     /* check if all check rooms are occupied */
  897.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  898.     {
  899.         if (imps_p->room_info.room_list[i].is_used == FALSE)
  900.         {
  901.             break;
  902.         }
  903.     }
  904.     return i;
  905. }
  906. #define NVRAM_FILE_IMPS
  907. /*****************************************************************************
  908.  * FUNCTION
  909.  *  mmi_imps_get_mine_type
  910.  * DESCRIPTION
  911.  *  Reset contact list when data account changed.
  912.  * PARAMETERS
  913.  *  file_ext        [IN]        Get the mine of a file from its file extension.
  914.  * RETURNS
  915.  *  mine type string.
  916.  *****************************************************************************/
  917. S8 *mmi_imps_get_mine_type(S8 *file_ext)
  918. {
  919.     /*----------------------------------------------------------------*/
  920.     /* Local Variables                                                */
  921.     /*----------------------------------------------------------------*/
  922.     applib_mime_type_struct *mime = mime_type_look_up(NULL, file_ext, 0, 0);
  923.     /*----------------------------------------------------------------*/
  924.     /* Code Body                                                      */
  925.     /*----------------------------------------------------------------*/
  926.     if (mime)
  927.     {
  928.         return mime->mime_string;
  929.     }
  930.     else
  931.     {
  932.         return NULL;
  933.     }
  934. }
  935. #ifdef IMPS_TEST_CODE
  936. /*****************************************************************************
  937.  * FUNCTION
  938.  *  mmi_imps_write_watch_list
  939.  * DESCRIPTION
  940.  *  
  941.  * PARAMETERS
  942.  *  void
  943.  * RETURNS
  944.  *  void
  945.  *****************************************************************************/
  946. void mmi_imps_write_watch_list(void)
  947. {
  948.     /*----------------------------------------------------------------*/
  949.     /* Local Variables                                                */
  950.     /*----------------------------------------------------------------*/
  951.     U32 len;
  952.     S32 i, count = 5;
  953.     FS_HANDLE fileHandle;
  954.     S16 *ucs2_folder = OslMalloc((FMGR_MAX_PATH_LEN + 1) * ENCODING_LENGTH);
  955.     imps_watcher_entity_struct *buff = OslMalloc(sizeof(imps_watcher_entity_struct));
  956.     /*----------------------------------------------------------------*/
  957.     /* Code Body                                                      */
  958.     /*----------------------------------------------------------------*/
  959.     mmi_imps_util_get_work_path((S8*) ucs2_folder);
  960.     pfnUnicodeStrcat((S8*) ucs2_folder, (S8*) L"watch");
  961.     fileHandle = FS_Open((U16*) ucs2_folder, FS_CREATE_ALWAYS);
  962.     for (i = 0; i < count; i++)
  963.     {
  964.         sprintf((S8*) buff->watcher_user_id, "Max Chen %ld", i);
  965.         AnsiiToUnicodeString((S8*) buff->watcher_status, "WCP_SW_PS1");
  966.         FS_Write(fileHandle, (void*)buff, sizeof(imps_watcher_entity_struct), &len);
  967.     }
  968.     imps_p->search_result.count = 5;
  969.     FS_Close(fileHandle);
  970.     OslMfree(ucs2_folder);
  971.     OslMfree(buff);
  972. }
  973. #endif /* IMPS_TEST_CODE */ 
  974. /*****************************************************************************
  975.  * FUNCTION
  976.  *  mmi_imps_util_get_work_path
  977.  * DESCRIPTION
  978.  *  Get path of working directory
  979.  * PARAMETERS
  980.  *  dest        [OUT]       Buffer to store result
  981.  * RETURNS
  982.  *  void
  983.  *****************************************************************************/
  984. void mmi_imps_util_get_work_path(S8 *dest)
  985. {
  986.     /*----------------------------------------------------------------*/
  987.     /* Local Variables                                                */
  988.     /*----------------------------------------------------------------*/
  989.     S8 *buff = OslMalloc(FMGR_MAX_PATH_LEN * ENCODING_LENGTH);
  990.     /*----------------------------------------------------------------*/
  991.     /* Code Body                                                      */
  992.     /*----------------------------------------------------------------*/
  993.     sprintf(buff, "%s\", IMPS_XML_FILE_DIRECTORY);
  994.     AnsiiToUnicodeString(dest, buff);
  995.     OslMfree(buff);
  996. }
  997. /*****************************************************************************
  998.  * FUNCTION
  999.  *  mmi_imps_util_get_img_path
  1000.  * DESCRIPTION
  1001.  *  Get the path to store image
  1002.  * PARAMETERS
  1003.  *  dest        [OUT]       Buffer to store result
  1004.  * RETURNS
  1005.  *  void
  1006.  *****************************************************************************/
  1007. void mmi_imps_util_get_img_path(S8 *dest)
  1008. {
  1009.     /*----------------------------------------------------------------*/
  1010.     /* Local Variables                                                */
  1011.     /*----------------------------------------------------------------*/
  1012.     S8 *buff = OslMalloc(FMGR_MAX_PATH_LEN * ENCODING_LENGTH);
  1013.     /*----------------------------------------------------------------*/
  1014.     /* Code Body                                                      */
  1015.     /*----------------------------------------------------------------*/
  1016.     sprintf(buff, "%s%s", IMPS_XML_FILE_DIRECTORY, IMPS_STATUS_CONTENT_FOLDER);
  1017.     AnsiiToUnicodeString(dest, buff);
  1018.     OslMfree(buff);
  1019. }
  1020. #define HISTORY_IMPS
  1021. /*****************************************************************************
  1022.  * FUNCTION
  1023.  *  mmi_imps_util_is_in_imps
  1024.  * DESCRIPTION
  1025.  *  Check if it's currently in IMPS application
  1026.  * PARAMETERS
  1027.  *  void
  1028.  * RETURNS
  1029.  *  TURE if it's in IMPS application; otherwise, FALSE.
  1030.  *****************************************************************************/
  1031. BOOL mmi_imps_util_is_in_imps(void)
  1032. {
  1033.     /*----------------------------------------------------------------*/
  1034.     /* Local Variables                                                */
  1035.     /*----------------------------------------------------------------*/
  1036.     U16 scr_id = GetActiveScreenId();
  1037.     /*----------------------------------------------------------------*/
  1038.     /* Code Body                                                      */
  1039.     /*----------------------------------------------------------------*/
  1040.     if (mmi_imps_util_is_imps_scr(scr_id))
  1041.     {
  1042.         return TRUE;
  1043.     }
  1044.     else
  1045.     {
  1046.         return FALSE;
  1047.     }
  1048. }
  1049. /*****************************************************************************
  1050.  * FUNCTION
  1051.  *  mmi_imps_util_is_imps_scr
  1052.  * DESCRIPTION
  1053.  *  Check if the screen in IMPS application.
  1054.  * PARAMETERS
  1055.  *  scr_id      [IN]        Screen index to be examined.
  1056.  * RETURNS
  1057.  *  TRUE if the screen is an IMPS screen; otherwise, FALSE.
  1058.  *****************************************************************************/
  1059. BOOL mmi_imps_util_is_imps_scr(U16 scr_id)
  1060. {
  1061.     /*----------------------------------------------------------------*/
  1062.     /* Local Variables                                                */
  1063.     /*----------------------------------------------------------------*/
  1064.     /*----------------------------------------------------------------*/
  1065.     /* Code Body                                                      */
  1066.     /*----------------------------------------------------------------*/
  1067.     if (scr_id > SCR_ID_IMPS_START && scr_id < SCR_ID_IMPS_END)
  1068.     {
  1069.         return TRUE;
  1070.     }
  1071.     else
  1072.     {
  1073.         return FALSE;
  1074.     }
  1075. }
  1076. /*****************************************************************************
  1077.  * FUNCTION
  1078.  *  mmi_imps_util_del_up_to_screen
  1079.  * DESCRIPTION
  1080.  *  Delete IMPS screens until scr_id
  1081.  * PARAMETERS
  1082.  *  scr_id      [IN]        Ending screen of deletion, this screen won't be deleted.
  1083.  * RETURNS
  1084.  *  void
  1085.  *****************************************************************************/
  1086. void mmi_imps_util_del_up_to_screen(U16 scr_id)
  1087. {
  1088.     /*----------------------------------------------------------------*/
  1089.     /* Local Variables                                                */
  1090.     /*----------------------------------------------------------------*/
  1091.     U16 next_scr;
  1092.     /*----------------------------------------------------------------*/
  1093.     /* Code Body                                                      */
  1094.     /*----------------------------------------------------------------*/
  1095.     while (GetNextScrnIdOf(scr_id, &next_scr))
  1096.     {
  1097.         if (mmi_imps_util_is_imps_scr(next_scr))
  1098.         {
  1099.             DeleteScreenIfPresent(next_scr);
  1100.         }
  1101.         else
  1102.         {
  1103.             return;
  1104.         }
  1105.     }
  1106. }
  1107. /*****************************************************************************
  1108.  * FUNCTION
  1109.  *  mmi_imps_util_go_back_2_hist
  1110.  * DESCRIPTION
  1111.  *  Go back to previosu 2 screen.
  1112.  * PARAMETERS
  1113.  *  void
  1114.  * RETURNS
  1115.  *  void
  1116.  *****************************************************************************/
  1117. void mmi_imps_util_go_back_2_hist(void)
  1118. {
  1119.     /*----------------------------------------------------------------*/
  1120.     /* Local Variables                                                */
  1121.     /*----------------------------------------------------------------*/
  1122.     /*----------------------------------------------------------------*/
  1123.     /* Code Body                                                      */
  1124.     /*----------------------------------------------------------------*/
  1125.     GoBacknHistory(1);
  1126. }
  1127. /*****************************************************************************
  1128.  * FUNCTION
  1129.  *  mmi_imps_util_del_scr_after_progress
  1130.  * DESCRIPTION
  1131.  *  Delete screen between progressing screen and result screen.
  1132.  *  Result screen is not included.
  1133.  * PARAMETERS
  1134.  *  result_scr      [IN]        
  1135.  * RETURNS
  1136.  *  void
  1137.  *****************************************************************************/
  1138. void mmi_imps_util_del_scr_after_progress(U16 result_scr)
  1139. {
  1140.     /*----------------------------------------------------------------*/
  1141.     /* Local Variables                                                */
  1142.     /*----------------------------------------------------------------*/
  1143.     U16 start_scr;
  1144.     /*----------------------------------------------------------------*/
  1145.     /* Code Body                                                      */
  1146.     /*----------------------------------------------------------------*/
  1147.     if(GetNextScrnIdOf(result_scr, &start_scr) == MMI_TRUE)
  1148.     {
  1149.         /* because the result screen might not be in histor, this will ensure the correctness */
  1150.         DeleteBetweenScreen(start_scr, SCR_ID_IMPS_PROGRESS);
  1151.     }
  1152.     else
  1153.     {
  1154.         DeleteScreenIfPresent(SCR_ID_IMPS_PROGRESS);
  1155.     }
  1156. }
  1157. #define BUFF_IMPS
  1158. /*****************************************************************************
  1159.  * FUNCTION
  1160.  *  mmi_imps_util_free_buff_when_logout
  1161.  * DESCRIPTION
  1162.  *  Free allocated buffers required after login
  1163.  * PARAMETERS
  1164.  *  void
  1165.  * RETURNS
  1166.  *  void
  1167.  *****************************************************************************/
  1168. void mmi_imps_util_free_buff_when_logout(void)
  1169. {
  1170.     /*----------------------------------------------------------------*/
  1171.     /* Local Variables                                                */
  1172.     /*----------------------------------------------------------------*/
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Code Body                                                      */
  1175.     /*----------------------------------------------------------------*/
  1176.     /* free allocated buffer when logout automatically or manually */
  1177.     /* about me */
  1178.     mmi_imps_free_about_me_buff();
  1179.     /* search data */
  1180.     mmi_imps_free_search_mem();
  1181.     /* invitation */
  1182.     mmi_imps_invite_ind_free_mem();
  1183.     mmi_imps_free_invite_list();
  1184.     /* edit room */
  1185.     mmi_imps_free_room_mem();
  1186. }
  1187. /*****************************************************************************
  1188.  * FUNCTION
  1189.  *  mmi_imps_util_get_seq_no
  1190.  * DESCRIPTION
  1191.  *  Get sequence number of session
  1192.  * PARAMETERS
  1193.  *  void
  1194.  * RETURNS
  1195.  *  void
  1196.  *****************************************************************************/
  1197. S32 mmi_imps_util_get_seq_no(void)
  1198. {
  1199.     /*----------------------------------------------------------------*/
  1200.     /* Local Variables                                                */
  1201.     /*----------------------------------------------------------------*/
  1202.     /*----------------------------------------------------------------*/
  1203.     /* Code Body                                                      */
  1204.     /*----------------------------------------------------------------*/
  1205.     ++imps_p->gen_info.seq_no;
  1206.     if (imps_p->gen_info.seq_no > IMPS_MAX_SEQ_NUM)
  1207.     {
  1208.         imps_p->gen_info.seq_no = 1;
  1209.     }
  1210.     return imps_p->gen_info.seq_no;
  1211. }
  1212. #define STRING_IMPS
  1213. /*****************************************************************************
  1214.  * FUNCTION
  1215.  *  mmi_imps_util_copy_with_dot
  1216.  * DESCRIPTION
  1217.  *  Append three dots to the end of string
  1218.  * PARAMETERS
  1219.  *  source      [IN]            Source buffer.
  1220.  *  dest        [IN/OUT]        Destination buffer.
  1221.  *  max_len     [IN]            Max characters can be put in destination buffer , including NULL terminate
  1222.  * RETURNS
  1223.  *  void
  1224.  *****************************************************************************/
  1225. void mmi_imps_util_copy_with_dot(S8 *source, S8 *dest, S32 max_len)
  1226. {
  1227.     /*----------------------------------------------------------------*/
  1228.     /* Local Variables                                                */
  1229.     /*----------------------------------------------------------------*/
  1230.     /*----------------------------------------------------------------*/
  1231.     /* Code Body                                                      */
  1232.     /*----------------------------------------------------------------*/
  1233.     if (pfnUnicodeStrlen(source) < max_len)
  1234.     {
  1235.         pfnUnicodeStrcpy((S8*) dest, (S8*) source);
  1236.     }
  1237.     else
  1238.     {
  1239.         /* do not clear end of string because pfnUnicodeStrncpy will auto set NULL terminate */
  1240.         pfnUnicodeStrncpy((S8*) dest, (S8*) source, max_len - 4);
  1241.         pfnUnicodeStrcat((S8*) dest, (S8*) g_imps_three_dot);
  1242.     }
  1243. }
  1244. /*****************************************************************************
  1245.  * FUNCTION
  1246.  *  mmi_imps_util_ansi_2_ucs2_menu
  1247.  * DESCRIPTION
  1248.  *  Generate menu item from ASCII string
  1249.  * PARAMETERS
  1250.  *  source      [IN]            Source buffer.
  1251.  *  dest        [IN/OUT]        Destination buffer.
  1252.  *  max_len     [IN]            Max characters can be put in destination buffer
  1253.  * RETURNS
  1254.  *  void
  1255.  *****************************************************************************/
  1256. void mmi_imps_util_ansi_2_ucs2_menu(S8 *source, S8 *dest, S32 max_len)
  1257. {
  1258.     /*----------------------------------------------------------------*/
  1259.     /* Local Variables                                                */
  1260.     /*----------------------------------------------------------------*/
  1261.     S8 *tmp_buff = OslMalloc((IMPS_MAX_ID_LEN + 1) * ENCODING_LENGTH);
  1262.     /*----------------------------------------------------------------*/
  1263.     /* Code Body                                                      */
  1264.     /*----------------------------------------------------------------*/
  1265.     AnsiiToUnicodeString((S8*) tmp_buff, (S8*) source);
  1266.     mmi_imps_util_copy_with_dot((S8*) tmp_buff, (S8*) dest, max_len);
  1267.     OslMfree(tmp_buff);
  1268. }
  1269. /*****************************************************************************
  1270.  * FUNCTION
  1271.  *  mmi_imps_util_generate_name_hint
  1272.  * DESCRIPTION
  1273.  *  Generate hint value of a menu item
  1274.  * PARAMETERS
  1275.  *  source      [IN]        Source buffer.
  1276.  *  hint_id     [IN]        Index of hint
  1277.  *  max_len     [IN]        Max characters can be put in destination buffer
  1278.  * RETURNS
  1279.  *  void
  1280.  *****************************************************************************/
  1281. void mmi_imps_util_generate_name_hint(S8 *source, S32 hint_id, S32 max_len)
  1282. {
  1283.     /*----------------------------------------------------------------*/
  1284.     /* Local Variables                                                */
  1285.     /*----------------------------------------------------------------*/
  1286.     /*----------------------------------------------------------------*/
  1287.     /* Code Body                                                      */
  1288.     /*----------------------------------------------------------------*/
  1289.     if (pfnUnicodeStrlen(source))
  1290.     {
  1291.         mmi_imps_util_copy_with_dot((S8*) source, (S8*) hintData[hint_id], max_len);
  1292.         hintDataPtrs[hint_id] = hintData[hint_id];
  1293.     }
  1294.     else
  1295.     {
  1296.         hintDataPtrs[hint_id] = NULL;
  1297.     }
  1298. }
  1299. /*****************************************************************************
  1300.  * FUNCTION
  1301.  *  mmi_imps_util_is_group_name_valid
  1302.  * DESCRIPTION
  1303.  *  Check if the input user name string is allowable.
  1304.  *  A user name can only contains string between ASCII 0x20 ~ 0x7E
  1305.  *  The plus (+) character can only be placed before numeric character
  1306.  * PARAMETERS
  1307.  *  name        [IN]        String of input
  1308.  * RETURNS
  1309.  *  TRUE if the username string follows spec; otherwise, FALSE.
  1310.  *****************************************************************************/
  1311. BOOL mmi_imps_util_is_group_name_valid(S8 *name)
  1312. {
  1313.     /*----------------------------------------------------------------*/
  1314.     /* Local Variables                                                */
  1315.     /*----------------------------------------------------------------*/
  1316.     S8 *buff = OslMalloc(IMPS_MAX_ID_LEN);
  1317.     S32 i, len;
  1318.     S32 at_count = 0;   /* count of @ symbol */
  1319.     /*----------------------------------------------------------------*/
  1320.     /* Code Body                                                      */
  1321.     /*----------------------------------------------------------------*/
  1322.     UnicodeToAnsii((S8*) buff, (S8*) name);
  1323.     len = strlen(buff);
  1324.     /* scan each byte */
  1325.     for (i = 0; i < len; i++)
  1326.     {
  1327.         if (buff[i] <= 0x20 || buff[i] > 0x7E)  /* 0x20 == linear white space */
  1328.         {
  1329.             break;
  1330.         }
  1331.         else if (buff[i] == '/')    /* 0x2F */
  1332.         {
  1333.             break;
  1334.         }
  1335.         else if (buff[i] == '@')    /* can contain only 1 @ */
  1336.         {
  1337.             if (!at_count)
  1338.             {
  1339.                 at_count++;
  1340.             }
  1341.             else
  1342.             {
  1343.                 break;
  1344.             }
  1345.         }
  1346.     }
  1347.     OslMfree(buff);
  1348.     if (i == len)   /* all characters scanned */
  1349.     {
  1350.         return TRUE;
  1351.     }
  1352.     else
  1353.     {
  1354.         return FALSE;
  1355.     }
  1356. }
  1357. /*****************************************************************************
  1358.  * FUNCTION
  1359.  *  mmi_imps_util_is_username_valid
  1360.  * DESCRIPTION
  1361.  *  Check if the input user name string is allowable.
  1362.  *  A user name can only contains string between ASCII 0x20 ~ 0x7E
  1363.  *  The plus (+) character can only be placed before numeric character
  1364.  * PARAMETERS
  1365.  *  name        [IN]        String of input
  1366.  * RETURNS
  1367.  *  TRUE if the username string follows spec; otherwise, FALSE.
  1368.  *****************************************************************************/
  1369. BOOL mmi_imps_util_is_username_valid(S8 *name)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     S8 *buff = OslMalloc(IMPS_MAX_ID_LEN);
  1375.     S32 i, len;
  1376.     S32 at_count = 0;   /* count of @ symbol */
  1377.     S32 plus_count = 0; /* if it's numeric plus */
  1378.     S32 num_count = 0;  /* count of numeric value */
  1379.     /*----------------------------------------------------------------*/
  1380.     /* Code Body                                                      */
  1381.     /*----------------------------------------------------------------*/
  1382.     UnicodeToAnsii((S8*) buff, (S8*) name);
  1383.     len = strlen(buff);
  1384.     if (len == 3 && mmi_imps_util_stricmp((S8*) "wv:", (S8*) buff) == 0)
  1385.     {
  1386.         return FALSE;
  1387.     }
  1388.     /* scan each byte */
  1389.     for (i = 0; i < len; i++)
  1390.     {
  1391.         if (buff[i] <= 0x20 || buff[i] > 0x7E)  /* 0x20 == linear white space */
  1392.         {
  1393.             break;
  1394.         }
  1395.         else if (buff[i] == '/')    /* 0x2F */
  1396.         {
  1397.             break;
  1398.         }
  1399.         else if (buff[i] == '+')
  1400.         {
  1401.             if (!plus_count)
  1402.             {
  1403.                 plus_count++;
  1404.             }
  1405.             else
  1406.             {
  1407.                 break;
  1408.             }
  1409.         }
  1410.         else if (buff[i] == '@')    /* can contain only 1 @ */
  1411.         {
  1412.             if (!at_count)
  1413.             {
  1414.                 at_count++;
  1415.             }
  1416.             else
  1417.             {
  1418.                 break;
  1419.             }
  1420.         }
  1421.         else if (buff[i] >= 0x30 && buff[i] <= 0x39)
  1422.         {
  1423.             num_count++;
  1424.         }
  1425.     }
  1426.     OslMfree(buff);
  1427.     /* check if the user name is wv:+12324454545 */
  1428.     if (plus_count)
  1429.     {
  1430.         if ((plus_count > 1) || (strncmp((S8*) buff, (S8*) "wv:+", 4) != 0))
  1431.         {
  1432.             return FALSE;
  1433.         }
  1434.         else if (num_count != (len - 4))    /* it's not a username like wv:+009099090 (all numberic characters) */
  1435.         {
  1436.             return FALSE;
  1437.         }
  1438.     }
  1439.     if (i == len)   /* all characters scanned */
  1440.     {
  1441.         return TRUE;
  1442.     }
  1443.     else
  1444.     {
  1445.         return FALSE;
  1446.     }
  1447. }
  1448. /*****************************************************************************
  1449.  * FUNCTION
  1450.  *  mmi_imps_util_append_wv
  1451.  * DESCRIPTION
  1452.  *  Check if "wv:" string contains in the string.
  1453.  *  If not, append it.
  1454.  * PARAMETERS
  1455.  *  dest        [OUT]       Buffer to be checked andappended.
  1456.  *  max_len     [IN]        Max length of buffer
  1457.  * RETURNS
  1458.  *  TRUE if the username string follows spec; otherwise, FALSE.(?)
  1459.  *****************************************************************************/
  1460. void mmi_imps_util_append_wv(S8 *dest, S32 max_len)
  1461. {
  1462.     /*----------------------------------------------------------------*/
  1463.     /* Local Variables                                                */
  1464.     /*----------------------------------------------------------------*/
  1465.     S8 *buff = OslMalloc(IMPS_MAX_ID_LEN * ENCODING_LENGTH);
  1466.     /*----------------------------------------------------------------*/
  1467.     /* Code Body                                                      */
  1468.     /*----------------------------------------------------------------*/
  1469.     if (pfnUnicodeStrlen(dest) < (max_len - 3)) /* minus length of "wv:" */
  1470.     {
  1471.         UnicodeNToAnsii(buff, (S8*) dest, 3 * ENCODING_LENGTH);
  1472.         if (mmi_imps_util_strnicmp((S8*) "wv:", buff, 3) != 0) /* no "wv:" */
  1473.         {
  1474.             pfnUnicodeStrcpy((S8*) buff, (S8*) L"wv:");
  1475.             pfnUnicodeStrcat((S8*) buff, (S8*) dest);
  1476.             pfnUnicodeStrcpy((S8*) dest, (S8*) buff);
  1477.         }
  1478.     }
  1479.     OslMfree(buff);
  1480. }
  1481. /*****************************************************************************
  1482.  * FUNCTION
  1483.  *  mmi_imps_util_tolower
  1484.  * DESCRIPTION
  1485.  *  Convert a charcater to lower case
  1486.  * PARAMETERS
  1487.  *  ch      [IN]        Charcater to be converted
  1488.  * RETURNS
  1489.  *  lower case character
  1490.  *****************************************************************************/
  1491. U8 mmi_imps_util_tolower(U8 ch)
  1492. {
  1493.     /*----------------------------------------------------------------*/
  1494.     /* Local Variables                                                */
  1495.     /*----------------------------------------------------------------*/
  1496.     /*----------------------------------------------------------------*/
  1497.     /* Code Body                                                      */
  1498.     /*----------------------------------------------------------------*/
  1499.     if (ch >= 'A' && ch <= 'Z')
  1500.     {
  1501.         return (U8) (ch + ('a' - 'A'));
  1502.     }
  1503.     return ch;
  1504. }
  1505. /*****************************************************************************
  1506.  * FUNCTION
  1507.  *  mmi_imps_util_strnicmp
  1508.  * DESCRIPTION
  1509.  *  Compare two string without case with maximum length
  1510.  * PARAMETERS
  1511.  *  src         [IN]        String pointer to be compared
  1512.  *  dest        [IN]        String pointer to be compared
  1513.  *  maxlen      [IN]        Lengh to be compared
  1514.  * RETURNS
  1515.  *  Ture if two string is identical, otherwise, false
  1516.  *****************************************************************************/
  1517. S8 mmi_imps_util_strnicmp(S8 *src, S8 *dest, S32 maxlen)
  1518. {
  1519.     /*----------------------------------------------------------------*/
  1520.     /* Local Variables                                                */
  1521.     /*----------------------------------------------------------------*/
  1522.     U8 ch1, ch2;
  1523.     S8 *s1, *s2;
  1524.     /*----------------------------------------------------------------*/
  1525.     /* Code Body                                                      */
  1526.     /*----------------------------------------------------------------*/
  1527.     s1 = src;
  1528.     s2 = dest;
  1529.     while (maxlen-- > 0)
  1530.     {
  1531.         ch1 = mmi_imps_util_tolower(*s1++);
  1532.         ch2 = mmi_imps_util_tolower(*s2++);
  1533.         if (ch1 != ch2)
  1534.         {
  1535.             return TRUE;
  1536.         }
  1537.     }
  1538.     return FALSE;
  1539. }
  1540. /*****************************************************************************
  1541.  * FUNCTION
  1542.  *  mmi_imps_util_stricmp
  1543.  * DESCRIPTION
  1544.  *  Compare two strings without case
  1545.  * PARAMETERS
  1546.  *  src         [IN]        String pointer to be compared
  1547.  *  dest        [IN]        String pointer to be compared
  1548.  * RETURNS
  1549.  *  Ture if two string is identical, otherwise, false
  1550.  *****************************************************************************/
  1551. S8 mmi_imps_util_stricmp(S8 *src, S8 *dest)
  1552. {
  1553.     /*----------------------------------------------------------------*/
  1554.     /* Local Variables                                                */
  1555.     /*----------------------------------------------------------------*/
  1556.     S32 len_src = strlen(src);
  1557.     S32 len_dest = strlen(dest);
  1558.     /*----------------------------------------------------------------*/
  1559.     /* Code Body                                                      */
  1560.     /*----------------------------------------------------------------*/
  1561.     if (len_src != len_dest)
  1562.     {
  1563.         return TRUE;
  1564.     }
  1565.     else
  1566.     {
  1567.         return mmi_imps_util_strnicmp(src, dest, len_src);
  1568.     }
  1569. }
  1570. #define UI_COMMON_IMPS
  1571. /*****************************************************************************
  1572.  * FUNCTION
  1573.  *  mmi_imps_util_blink_tab
  1574.  * DESCRIPTION
  1575.  *  Common function to blink/unblink tabs
  1576.  * PARAMETERS
  1577.  *  void
  1578.  * RETURNS
  1579.  *  void
  1580.  *****************************************************************************/
  1581. void mmi_imps_util_blink_tab(void)
  1582. {
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Local Variables                                                */
  1585.     /*----------------------------------------------------------------*/
  1586.     S32 i;
  1587.     /*----------------------------------------------------------------*/
  1588.     /* Code Body                                                      */
  1589.     /*----------------------------------------------------------------*/
  1590.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1591.     {
  1592.         mmi_imps_room_struct *room = &imps_p->room_info.room_list[i];
  1593.         if (room->is_used)
  1594.         {
  1595.             if (room->unread_msg)
  1596.             {
  1597.                 Category425BlinkTab(room->tab_index);
  1598.             }
  1599.             else
  1600.             {
  1601.                 Category425UnBlinkTab(room->tab_index);
  1602.             }
  1603.         }
  1604.     }
  1605. }
  1606. /*****************************************************************************
  1607.  * FUNCTION
  1608.  *  mmi_imps_util_search_cont
  1609.  * DESCRIPTION
  1610.  *  Search contact according to his id
  1611.  * PARAMETERS
  1612.  *  id      [?]     To be search
  1613.  * RETURNS
  1614.  *  buffer that store the context of the contact
  1615.  *****************************************************************************/
  1616. mmi_imps_cont_struct *mmi_imps_util_search_cont(S8 *id)
  1617. {
  1618.     /*----------------------------------------------------------------*/
  1619.     /* Local Variables                                                */
  1620.     /*----------------------------------------------------------------*/
  1621.     S32 i, count;
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Code Body                                                      */
  1624.     /*----------------------------------------------------------------*/
  1625.     count = (S32) imps_p->cont_info.no_cont;
  1626.     for (i = 0; i < count; i++)
  1627.         if (mmi_imps_util_is_id_same((S8*) id, (S8*) imps_p->cont_info.cont_list[i].id))      /* contact found */
  1628.         {
  1629.             return &imps_p->cont_info.cont_list[i];
  1630.         }
  1631.     return NULL;
  1632. }
  1633. /*****************************************************************************
  1634.  * FUNCTION
  1635.  *  mmi_imps_util_update_status_icon
  1636.  * DESCRIPTION
  1637.  *  Update status icon when new message comes
  1638.  * PARAMETERS
  1639.  *  void
  1640.  * RETURNS
  1641.  *  void
  1642.  *****************************************************************************/
  1643. void mmi_imps_util_update_status_icon(void)
  1644. {
  1645.     /*----------------------------------------------------------------*/
  1646.     /* Local Variables                                                */
  1647.     /*----------------------------------------------------------------*/
  1648.     S32 i;
  1649.     /*----------------------------------------------------------------*/
  1650.     /* Code Body                                                      */
  1651.     /*----------------------------------------------------------------*/
  1652.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1653.     {
  1654.         mmi_imps_room_struct *room = &imps_p->room_info.room_list[i];
  1655.         if (room->is_used)
  1656.         {
  1657.             /* still some message there */
  1658.             if (room->unread_msg)
  1659.             {
  1660.                 BlinkStatusIcon(STATUS_ICON_IMPS_MSG);
  1661.                 UpdateStatusIcons();
  1662.                 return;
  1663.             }
  1664.         }
  1665.     }
  1666.     IdleResetStatusIcon(STATUS_ICON_IMPS_MSG);  /* reset message status icon */
  1667.     if (imps_p->gen_info.is_login)
  1668.     {
  1669.         IdleSetStatusIcon(STATUS_ICON_IMPS_LOGIN);
  1670.     }
  1671. }
  1672. /*****************************************************************************
  1673.  * FUNCTION
  1674.  *  mmi_imps_util_update_login_icon
  1675.  * DESCRIPTION
  1676.  *  Update status icon when login state changed
  1677.  * PARAMETERS
  1678.  *  void
  1679.  * RETURNS
  1680.  *  void
  1681.  *****************************************************************************/
  1682. void mmi_imps_util_update_login_icon(void)
  1683. {
  1684.     /*----------------------------------------------------------------*/
  1685.     /* Local Variables                                                */
  1686.     /*----------------------------------------------------------------*/
  1687.     /*----------------------------------------------------------------*/
  1688.     /* Code Body                                                      */
  1689.     /*----------------------------------------------------------------*/
  1690.     if (imps_p->gen_info.is_login)
  1691.     {
  1692.         IdleSetStatusIcon(STATUS_ICON_IMPS_LOGIN);
  1693.     }
  1694.     else
  1695.     {
  1696.         IdleResetStatusIcon(STATUS_ICON_IMPS_MSG);  /* reset message status icon */
  1697.         IdleResetStatusIcon(STATUS_ICON_IMPS_LOGIN);
  1698.     }
  1699. }
  1700. /*****************************************************************************
  1701.  * FUNCTION
  1702.  *  mmi_imps_util_disp_popup_done
  1703.  * DESCRIPTION
  1704.  *  Common function to display "Done" in popup screen
  1705.  * PARAMETERS
  1706.  *  void
  1707.  * RETURNS
  1708.  *  void
  1709.  *****************************************************************************/
  1710. void mmi_imps_util_disp_popup_done(void)
  1711. {
  1712.     /*----------------------------------------------------------------*/
  1713.     /* Local Variables                                                */
  1714.     /*----------------------------------------------------------------*/
  1715.     /*----------------------------------------------------------------*/
  1716.     /* Code Body                                                      */
  1717.     /*----------------------------------------------------------------*/
  1718.     TurnOnBacklight(TRUE);
  1719.     DisplayPopup(
  1720.         (U8*) GetString(STR_GLOBAL_DONE),
  1721.         IMG_GLOBAL_ACTIVATED,
  1722.         1,
  1723.         UI_POPUP_NOTIFYDURATION_TIME,
  1724.         (U8) SUCCESS_TONE);
  1725. }
  1726. /*****************************************************************************
  1727.  * FUNCTION
  1728.  *  mmi_imps_util_disp_warning_popup
  1729.  * DESCRIPTION
  1730.  *  Common function to display warning popup
  1731.  * PARAMETERS
  1732.  *  str_id      [IN]        Id of string to be displayed
  1733.  * RETURNS
  1734.  *  void
  1735.  *****************************************************************************/
  1736. void mmi_imps_util_disp_warning_popup(U16 str_id)
  1737. {
  1738.     /*----------------------------------------------------------------*/
  1739.     /* Local Variables                                                */
  1740.     /*----------------------------------------------------------------*/
  1741.     /*----------------------------------------------------------------*/
  1742.     /* Code Body                                                      */
  1743.     /*----------------------------------------------------------------*/
  1744.     TurnOnBacklight(TRUE);
  1745.     DisplayPopup((U8*) GetString(str_id), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, (U8) WARNING_TONE);
  1746. }
  1747. /*****************************************************************************
  1748.  * FUNCTION
  1749.  *  mmi_imps_util_disp_err_popup
  1750.  * DESCRIPTION
  1751.  *  Common function to display error popup
  1752.  * PARAMETERS
  1753.  *  str_id      [IN]        Id of string to be displayed
  1754.  * RETURNS
  1755.  *  void
  1756.  *****************************************************************************/
  1757. void mmi_imps_util_disp_err_popup(U16 str_id)
  1758. {
  1759.     /*----------------------------------------------------------------*/
  1760.     /* Local Variables                                                */
  1761.     /*----------------------------------------------------------------*/
  1762.     /*----------------------------------------------------------------*/
  1763.     /* Code Body                                                      */
  1764.     /*----------------------------------------------------------------*/
  1765.     TurnOnBacklight(TRUE);
  1766.     DisplayPopup((U8*) GetString(str_id), IMG_GLOBAL_ERROR, 1, UI_POPUP_NOTIFYDURATION_TIME, (U8) ERROR_TONE);
  1767. }
  1768. /*****************************************************************************
  1769.  * FUNCTION
  1770.  *  mmi_imps_util_disp_empty_popup
  1771.  * DESCRIPTION
  1772.  *  Common function to display empty popup
  1773.  * PARAMETERS
  1774.  *  void
  1775.  * RETURNS
  1776.  *  void
  1777.  *****************************************************************************/
  1778. void mmi_imps_util_disp_empty_popup(void)
  1779. {
  1780.     /*----------------------------------------------------------------*/
  1781.     /* Local Variables                                                */
  1782.     /*----------------------------------------------------------------*/
  1783.     /*----------------------------------------------------------------*/
  1784.     /* Code Body                                                      */
  1785.     /*----------------------------------------------------------------*/
  1786.     TurnOnBacklight(TRUE);
  1787.     DisplayPopup((PU8) GetString(STR_GLOBAL_EMPTY_LIST), IMG_GLOBAL_EMPTY, 0, UI_POPUP_NOTIFYDURATION_TIME, ERROR_TONE);
  1788. }
  1789. /*****************************************************************************
  1790.  * FUNCTION
  1791.  *  mmi_imps_util_is_on_idle
  1792.  * DESCRIPTION
  1793.  *  Check if the user is currently on IDLE screen.
  1794.  *  Add this function is to prevent too much include files in other files of IMPS
  1795.  * PARAMETERS
  1796.  *  void
  1797.  * RETURNS
  1798.  *  IsOnIdleScreen flag in the global context of IDLE screen.
  1799.  *****************************************************************************/
  1800. U8 mmi_imps_util_is_on_idle(void)
  1801. {
  1802.     /*----------------------------------------------------------------*/
  1803.     /* Local Variables                                                */
  1804.     /*----------------------------------------------------------------*/
  1805.     /*----------------------------------------------------------------*/
  1806.     /* Code Body                                                      */
  1807.     /*----------------------------------------------------------------*/
  1808.     return g_idle_context.IsOnIdleScreen;
  1809. }
  1810. #define TAB_IMPS
  1811. /*****************************************************************************
  1812.  * FUNCTION
  1813.  *  mmi_imps_tab_init
  1814.  * DESCRIPTION
  1815.  *  Initialize tab component
  1816.  * PARAMETERS
  1817.  *  void
  1818.  * RETURNS
  1819.  *  void
  1820.  *****************************************************************************/
  1821. void mmi_imps_tab_init(void)
  1822. {
  1823.     /*----------------------------------------------------------------*/
  1824.     /* Local Variables                                                */
  1825.     /*----------------------------------------------------------------*/
  1826.     S32 i, count;
  1827.     mmi_imps_room_struct *room;
  1828.     /*----------------------------------------------------------------*/
  1829.     /* Code Body                                                      */
  1830.     /*----------------------------------------------------------------*/
  1831.     MMI_tab_bar_items[0].icon = (PU8) GetImage(IMG_ID_IMPS_CONT_LIST);
  1832.     MMI_tab_bar_items[0].text = NULL;
  1833.     MMI_tab_bar_items[0].flags = 0;
  1834.     count = (S32) imps_p->room_info.no_rooms;
  1835.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1836.     {
  1837.         room = &imps_p->room_info.room_list[i];
  1838.         if (room->is_used)
  1839.         {
  1840.             S32 tab = (S32) room->tab_index;
  1841.             if (room->type == IMPS_ROOM_TYPE_SINGLE)
  1842.             {
  1843.                 MMI_tab_bar_items[tab].icon = (PU8) GetImage(IMG_ID_IMPS_TALK);
  1844.             }
  1845.             else
  1846.             {
  1847.                 MMI_tab_bar_items[tab].icon = (PU8) GetImage(IMG_ID_IMPS_CHAT_ROOM);
  1848.             }
  1849.             MMI_tab_bar_items[tab].text = NULL;
  1850.             MMI_tab_bar_items[tab].flags = 0;
  1851.         }
  1852.     }
  1853. }
  1854. /*****************************************************************************
  1855.  * FUNCTION
  1856.  *  mmi_imps_tab_jump_current
  1857.  * DESCRIPTION
  1858.  *  Jump to current tab
  1859.  * PARAMETERS
  1860.  *  void
  1861.  * RETURNS
  1862.  *  void
  1863.  *****************************************************************************/
  1864. void mmi_imps_tab_jump_current(void)
  1865. {
  1866.     /*----------------------------------------------------------------*/
  1867.     /* Local Variables                                                */
  1868.     /*----------------------------------------------------------------*/
  1869.     S32 i;
  1870.     /*----------------------------------------------------------------*/
  1871.     /* Code Body                                                      */
  1872.     /*----------------------------------------------------------------*/
  1873.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1874.         if (imps_p->room_info.room_list[i].is_used)
  1875.             if (imps_p->room_info.room_list[i].tab_index == imps_p->gen_info.curr_tab)
  1876.             {
  1877.                 imps_p->chat_info.curr_room = (U8) i;
  1878.                 break;
  1879.             }
  1880.     imps_p->room_info.room_list[imps_p->chat_info.curr_room].clear_gui_buff = TRUE;
  1881.     mmi_imps_entry_chat();
  1882.     DeleteScreenIfPresent(SCR_ID_IMPS_CONT);
  1883.     DeleteScreenIfPresent(SCR_ID_IMPS_CHAT);
  1884. }
  1885. /*****************************************************************************
  1886.  * FUNCTION
  1887.  *  mmi_imps_tab_del
  1888.  * DESCRIPTION
  1889.  *  Swap to previous tab
  1890.  * PARAMETERS
  1891.  *  tab_index       [IN]        Index of tab to be removed.
  1892.  *  hilite          [IN]        Hilited tab after removed.
  1893.  * RETURNS
  1894.  *  void
  1895.  *****************************************************************************/
  1896. void mmi_imps_tab_del(U8 tab_index, U8 hilite)
  1897. {
  1898.     /*----------------------------------------------------------------*/
  1899.     /* Local Variables                                                */
  1900.     /*----------------------------------------------------------------*/
  1901.     S32 i;
  1902.     /*----------------------------------------------------------------*/
  1903.     /* Code Body                                                      */
  1904.     /*----------------------------------------------------------------*/
  1905.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  1906.     {
  1907.         mmi_imps_room_struct *room = &imps_p->room_info.room_list[i];
  1908.         if (room->is_used)
  1909.         {
  1910.             if (imps_p->room_info.room_list[i].tab_index > tab_index)
  1911.             {
  1912.                 /* current tab is the tab to be hilite */
  1913.                 if (imps_p->room_info.room_list[i].tab_index == hilite && hilite)
  1914.                 {
  1915.                     hilite--;
  1916.                 }
  1917.                 imps_p->room_info.room_list[i].tab_index--;
  1918.             }
  1919.         }
  1920.     }
  1921.     imps_p->gen_info.no_tab--;
  1922.     imps_p->gen_info.curr_tab = hilite;
  1923. }
  1924. /*****************************************************************************
  1925.  * FUNCTION
  1926.  *  mmi_imps_tab_prev
  1927.  * DESCRIPTION
  1928.  *  Swap to previous tab
  1929.  * PARAMETERS
  1930.  *  void
  1931.  * RETURNS
  1932.  *  void
  1933.  *****************************************************************************/
  1934. void mmi_imps_tab_prev(void)
  1935. {
  1936.     /*----------------------------------------------------------------*/
  1937.     /* Local Variables                                                */
  1938.     /*----------------------------------------------------------------*/
  1939.     /*----------------------------------------------------------------*/
  1940.     /* Code Body                                                      */
  1941.     /*----------------------------------------------------------------*/
  1942.     if (imps_p->gen_info.no_tab == 1)
  1943.     {
  1944.         return;
  1945.     }
  1946.     if (imps_p->gen_info.curr_tab == 0)
  1947.     {
  1948.         imps_p->gen_info.curr_tab = imps_p->gen_info.no_tab - 1;
  1949.     }
  1950.     else
  1951.     {
  1952.         imps_p->gen_info.curr_tab--;
  1953.     }
  1954.     if (imps_p->gen_info.curr_tab == 0)
  1955.     {
  1956.         mmi_imps_pre_entry_cont();
  1957.     }
  1958.     else
  1959.     {
  1960.         mmi_imps_tab_jump_current();
  1961.     }
  1962. }
  1963. /*****************************************************************************
  1964.  * FUNCTION
  1965.  *  mmi_imps_tab_next
  1966.  * DESCRIPTION
  1967.  *  Swap to next tab
  1968.  * PARAMETERS
  1969.  *  void
  1970.  * RETURNS
  1971.  *  void
  1972.  *****************************************************************************/
  1973. void mmi_imps_tab_next(void)
  1974. {
  1975.     /*----------------------------------------------------------------*/
  1976.     /* Local Variables                                                */
  1977.     /*----------------------------------------------------------------*/
  1978.     /*----------------------------------------------------------------*/
  1979.     /* Code Body                                                      */
  1980.     /*----------------------------------------------------------------*/
  1981.     if (imps_p->gen_info.no_tab == 1)
  1982.     {
  1983.         return;
  1984.     }
  1985.     if (imps_p->gen_info.curr_tab == (imps_p->gen_info.no_tab - 1))
  1986.     {
  1987.         imps_p->gen_info.curr_tab = 0;
  1988.     }
  1989.     else
  1990.     {
  1991.         imps_p->gen_info.curr_tab++;
  1992.     }
  1993.     if (imps_p->gen_info.curr_tab == 0)
  1994.     {
  1995.         mmi_imps_pre_entry_cont();
  1996.     }
  1997.     else
  1998.     {
  1999.         mmi_imps_tab_jump_current();
  2000.     }
  2001. }
  2002. /*****************************************************************************
  2003.  * FUNCTION
  2004.  *  mmi_imps_tab_jump
  2005.  * DESCRIPTION
  2006.  *  Jump to tab by index
  2007.  * PARAMETERS
  2008.  *  index       [IN]        
  2009.  * RETURNS
  2010.  *  void
  2011.  *****************************************************************************/
  2012. void mmi_imps_tab_jump(int index)
  2013. {
  2014.     /*----------------------------------------------------------------*/
  2015.     /* Local Variables                                                */
  2016.     /*----------------------------------------------------------------*/
  2017.     /*----------------------------------------------------------------*/
  2018.     /* Code Body                                                      */
  2019.     /*----------------------------------------------------------------*/
  2020.     if (imps_p->gen_info.no_tab == 1)
  2021.     {
  2022.         return;
  2023.     }
  2024.     if (index >= imps_p->gen_info.no_tab)
  2025.     {
  2026.         return;
  2027.     }
  2028.     imps_p->gen_info.curr_tab = index;
  2029.     if (imps_p->gen_info.curr_tab == 0)
  2030.     {
  2031.         mmi_imps_pre_entry_cont();
  2032.     }
  2033.     else
  2034.     {
  2035.         mmi_imps_tab_jump_current();
  2036.     }
  2037. }
  2038. /*****************************************************************************
  2039.  * FUNCTION
  2040.  *  mmi_imps_tab_redraw
  2041.  * DESCRIPTION
  2042.  *  Redraw tab
  2043.  * PARAMETERS
  2044.  *  scr_id      [IN]        Current index of screen
  2045.  * RETURNS
  2046.  *  void
  2047.  *****************************************************************************/
  2048. void mmi_imps_tab_redraw(U16 scr_id)
  2049. {
  2050.     /*----------------------------------------------------------------*/
  2051.     /* Local Variables                                                */
  2052.     /*----------------------------------------------------------------*/
  2053.     /*----------------------------------------------------------------*/
  2054.     /* Code Body                                                      */
  2055.     /*----------------------------------------------------------------*/
  2056.     if (scr_id == SCR_ID_IMPS_CONT)
  2057.     {
  2058.         mmi_imps_tab_init();
  2059.         UpdateCategory425TabBar(NULL, (S8) imps_p->gen_info.no_tab, (S8) imps_p->gen_info.curr_tab, MMI_tab_bar_items);
  2060.         /* reset all blinking/unblinking status */
  2061.         mmi_imps_util_blink_tab();
  2062.     }
  2063.     else if (scr_id == SCR_ID_IMPS_CHAT)
  2064.     {
  2065.         mmi_imps_tab_init();
  2066.         UpdateCategory435TabBar(NULL, (S8) imps_p->gen_info.no_tab, (S8) imps_p->gen_info.curr_tab, MMI_tab_bar_items);
  2067.         /* reset all blinking/unblinking status */
  2068.         mmi_imps_util_blink_tab();
  2069.     }
  2070. }
  2071. /*****************************************************************************
  2072.  * FUNCTION
  2073.  *  mmi_imps_tab_update_event
  2074.  * DESCRIPTION
  2075.  *  Update tab related screen when interrupt event comes
  2076.  * PARAMETERS
  2077.  *  room        [IN]        Room in which the event comes.
  2078.  *  entity      [IN]        Contact that related to the event
  2079.  * RETURNS
  2080.  *  void
  2081.  *****************************************************************************/
  2082. void mmi_imps_tab_update_event(mmi_imps_room_struct *room, imps_entity_struct *entity)
  2083. {
  2084.     /*----------------------------------------------------------------*/
  2085.     /* Local Variables                                                */
  2086.     /*----------------------------------------------------------------*/
  2087.     U16 active_scr = GetActiveScreenId();
  2088.     /*----------------------------------------------------------------*/
  2089.     /* Code Body                                                      */
  2090.     /*----------------------------------------------------------------*/
  2091.     /* in multi-tab screen */
  2092.     if (active_scr == SCR_ID_IMPS_CHAT || active_scr == SCR_ID_IMPS_CONT)
  2093.     {
  2094.         if (imps_p->gen_info.curr_tab == room->tab_index && active_scr == SCR_ID_IMPS_CHAT)
  2095.         {
  2096.             /* flush data */
  2097.             UpdateCategory435LogText((U8*) room->chat_buff, pfnUnicodeStrlen((S8*) room->chat_buff));
  2098.         }
  2099.         else
  2100.         {
  2101.             /* blink tab */
  2102.             Category425BlinkTab(room->tab_index);
  2103.             room->unread_msg = TRUE;
  2104.             mmi_imps_cont_update_when_msg_come(entity);
  2105.         }
  2106.     }
  2107.     else
  2108.     {
  2109.         /* update contact list for new message comes */
  2110.         room->unread_msg = TRUE;
  2111.         mmi_imps_cont_update_when_msg_come(entity);
  2112.     }
  2113.     mmi_imps_util_update_status_icon();
  2114. }
  2115. #define TONE_IMPS
  2116. /*****************************************************************************
  2117.  * FUNCTION
  2118.  *  mmi_imps_util_play_tone
  2119.  * DESCRIPTION
  2120.  *  General function to play tone and vibration for incoming event.
  2121.  * PARAMETERS
  2122.  *  tone_type       [IN]        Type of message
  2123.  * RETURNS
  2124.  *  void
  2125.  *****************************************************************************/
  2126. void mmi_imps_util_play_tone(U8 tone_type)
  2127. {
  2128.     /*----------------------------------------------------------------*/
  2129.     /* Local Variables                                                */
  2130.     /*----------------------------------------------------------------*/
  2131.     BOOL is_in_imps = mmi_imps_util_is_in_imps();
  2132.     BOOL is_silent = IsSilentModeActivated();
  2133.     BOOL is_meeting = IsMeetingModeActivated();
  2134.     /*----------------------------------------------------------------*/
  2135.     /* Code Body                                                      */
  2136.     /*----------------------------------------------------------------*/
  2137.     if (isInCall() == FALSE)
  2138.     {
  2139.         if (!is_silent && !is_meeting)
  2140.         {
  2141.             if (is_in_imps || g_idle_context.IsOnIdleScreen == TRUE)
  2142.             {
  2143.                 if (tone_type == IMPS_MSG_TONE)
  2144.                 {
  2145.                     mdi_audio_play_string(
  2146.                         (void*)g_imps_msg_tone,
  2147.                         sizeof(g_imps_msg_tone),
  2148.                         MDI_FORMAT_SMF,
  2149.                         DEVICE_AUDIO_PLAY_ONCE,
  2150.                         NULL,
  2151.                         NULL);
  2152.                 }
  2153.                 else
  2154.                 {
  2155.                     mdi_audio_play_string(
  2156.                         (void*)g_imps_err_tone,
  2157.                         sizeof(g_imps_err_tone),
  2158.                         MDI_FORMAT_SMF,
  2159.                         DEVICE_AUDIO_PLAY_ONCE,
  2160.                         NULL,
  2161.                         NULL);
  2162.                 }
  2163.             }
  2164.         }
  2165.         else
  2166.         {
  2167.             if (is_in_imps || g_idle_context.IsOnIdleScreen == TRUE)
  2168.             {
  2169.                 PlayVibratorOnce();
  2170.             }
  2171.         }
  2172.     }
  2173.     else
  2174.     {
  2175.         if (!is_silent && !is_meeting)
  2176.         {
  2177.             playRequestedTone(SMS_IN_CALL_TONE);
  2178.         }
  2179.     }
  2180. }
  2181. /*****************************************************************************
  2182.  * FUNCTION
  2183.  *  mmi_imps_util_find_room
  2184.  * DESCRIPTION
  2185.  *  Find out the location of chat room in the list buffer according to its room id
  2186.  * PARAMETERS
  2187.  *  room_id     [IN]        Id of the room
  2188.  * RETURNS
  2189.  *  index of chat room in the list buffer
  2190.  *****************************************************************************/
  2191. S32 mmi_imps_util_find_room(S8 *room_id)
  2192. {
  2193.     /*----------------------------------------------------------------*/
  2194.     /* Local Variables                                                */
  2195.     /*----------------------------------------------------------------*/
  2196.     S32 i;
  2197.     /*----------------------------------------------------------------*/
  2198.     /* Code Body                                                      */
  2199.     /*----------------------------------------------------------------*/
  2200.     for (i = 0; i < IMPS_MAX_NO_ROOM; i++)
  2201.         if (mmi_imps_util_stricmp((S8*) imps_p->room_info.room_list[i].room_id, room_id) == 0)
  2202.         {
  2203.             break;
  2204.         }
  2205.     return i;
  2206. }
  2207. /*****************************************************************************
  2208.  * FUNCTION
  2209.  *  mmi_imps_util_find_cont
  2210.  * DESCRIPTION
  2211.  *  Find out the location of chat room in the list buffer according to its room id
  2212.  * PARAMETERS
  2213.  *  cont_id         [?]         
  2214.  *  room_id(?)      [IN]        Id of the room
  2215.  * RETURNS
  2216.  *  index of chat room in the list buffer
  2217.  *****************************************************************************/
  2218. S32 mmi_imps_util_find_cont(S8 *cont_id)
  2219. {
  2220.     /*----------------------------------------------------------------*/
  2221.     /* Local Variables                                                */
  2222.     /*----------------------------------------------------------------*/
  2223.     S32 i;
  2224.     /*----------------------------------------------------------------*/
  2225.     /* Code Body                                                      */
  2226.     /*----------------------------------------------------------------*/
  2227.     /* find contact */
  2228.     for (i = 0; i < imps_p->cont_info.no_cont; i++)
  2229.         if (mmi_imps_util_is_id_same((S8*) imps_p->cont_info.cont_list[i].id, (S8*) cont_id))
  2230.         {
  2231.             break;
  2232.         }
  2233.     return i;
  2234. }
  2235. #endif /* __MMI_IMPS__ */ /* #ifdef __MMI_IMPS__ */
  2236. #endif /* _MMI_IMPS_UTIL_C */