PhoneBookSearch.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:182k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * PhoneBookSearch.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file is intends for sorting, search, quick search function in Phonebook application
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _PHONEBOOKSEARCH_C
- #define _PHONEBOOKSEARCH_C
- #include "MMI_features.h"
- #if defined(__MMI_T9__)
- #if defined(__MMI_T9_V7__)
- #include "t9ccapi.h"
- #include "T9Main.h"
- #else /* defined(__MMI_T9_V7__) */
- #include "T9api.h"
- #include "T9Main.h"
- #endif /* defined(__MMI_T9_V7__) */
- #endif /* defined(__MMI_T9__) */
- #if defined(__MMI_ZI__)
- #include "Zi8api.h"
- #ifndef ZI8_GETMODE_BOPOMOFO_NAME
- #define ZI8_GETMODE_BOPOMOFO_NAME ZI8_GETMODE_BOPOMOFO
- #endif
- #ifndef ZI8_GETMODE_PINYIN_NAME
- #define ZI8_GETMODE_PINYIN_NAME ZI8_GETMODE_PINYIN
- #endif
- #endif /* defined(__MMI_ZI__) */
- //KP Jerry add on 2007-3-8 start
- #if defined(__MMI_CSTAR__)
- #include "cstarime.h"
- #endif
- //KP Jerry add on 2007-3-8 end
- #if defined(__MMI_ITAP__)
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* defined(__MMI_ITAP__) */
- #include "stdC.h"
- #include "L4Dr1.h"
- #include "PixtelDataTypes.h"
- #include "GlobalConstants.h"
- #include "DebugInitDef.h"
- #include "ProtocolEvents.h"
- #include "wgui_categories.h"
- #include "wgui_categories_inputs.h"
- #include "wgui_status_icons.h"
- #include "PhonebookDef.h"
- #include "PhoneBookTypes.h"
- #include "PhonebookProt.h"
- #include "PhonebookGprot.h"
- #include "HistoryGprot.h"
- #include "QueueGProt.h"
- #include "mainmenudef.h"
- #include "Unicodexdcl.h"
- #include "GlobalDefs.h"
- #include "CommonScreens.h"
- #include "TimerEvents.h"
- #include "NVRAMProt.h"
- #include "NVRAMType.h"
- #include "NVRAMEnum.h"
- #if defined(__MMI_PHB_EMAIL_SORT__)
- #include "Nvram_user_defs.h" /* For email sorting. Need Accessing NVRAM data */
- #include "NVRAMProt.h"
- #endif /* defined(__MMI_PHB_EMAIL_SORT__) */
- #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
- #include "mdi_datatype.h"
- #include "mdi_audio.h"
- #endif /* defined(__MMI_INTELLIGENT_CALL_ALERT__) */
- #ifdef __FLIGHT_MODE_SUPPORT__
- #include "SimDetectionGprot.h"
- #endif
- #ifdef __SYNCML_SUPPORT__
- #include "SyncMLDef.h"
- #include "SyncMLGprot.h"
- #endif /* __SYNCML_SUPPORT__ */
- /*
- * Typedef
- */
- typedef void (*phb_comp_func) (U16 first, U16 second, U8 *same_count, S32 *distance);
- /*
- * Define
- */
- #define MMI_PHB_COMPARE_LENGTH 10 /* Compare 10 characters */
- #define MMI_PHB_CONVERT_BUFF_ZI 32 /* ZI convert function need 32 bytes for buffer. */
- #define MMI_PHB_QUICK_SEARCH_INPUT_LENGTH 6
- #define MMI_PHB_SORT_LENGTH 10 /* Compare 10 characters */
- #define MAX_PHB_NUMBER_COMP 20 /* Compare 20 entries for number filed */
- #define BYTE_SIZE 8 /* for g_phb_qsearch_bitmask */
- #define BYTE_SIZE_SHIFT_ARITHMETIC 3
- /*
- * Local Variable
- */
- #if defined(__MMI_PHB_QUICK_SEARCH__)
- static U16 g_phb_qsearch_cache[MAX_PB_ENTRIES];
- /* static U8 g_phb_qsearch[MAX_PB_ENTRIES]; */
- static U8 g_phb_qsearch_bitmask[(MAX_PB_ENTRIES + 7) / 8];
- static U8 g_phb_qsearch_input[(MMI_PHB_QUICK_SEARCH_INPUT_LENGTH + 1) * ENCODING_LENGTH];
- static U8 g_phb_qsearch_is_cache = 0; /* Check if cache already build */
- #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
- #if defined(__MMI_PHB_PINYIN_SORT__)
- static U8 g_phb_name_pinyin_index[MAX_PB_ENTRIES][(MMI_PHB_SORT_LENGTH + 1) * ENCODING_LENGTH];
- #endif
- static U8 g_phb_compare_length = 0xff; /* number compare length */
- /*
- * Global Variable
- */
- extern MMI_PHB_LIST_VIEW phbListView;
- extern S8 pbName[(MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH];
- extern MMI_PHB_ENTRY_BCD_STRUCT PhoneBook[];
- extern U16 g_phb_name_index[];
- extern U16 PhoneBookEntryCount;
- #ifdef __MMI_PHB_USIM_FIELD__
- extern MMI_PHB_NUMBER_BCD_STRUCT phb_anr[MAX_PB_SIM_ENTRIES][3];
- #ifdef __MMI_PHB_EMAIL_SORT__
- extern MMI_PHB_EMAIL_STRUCT phb_email[MAX_PB_SIM_ENTRIES];
- #endif
- #endif /* __MMI_PHB_USIM_FIELD__ */
- extern U8 MMI_current_input_mode;
- extern U8 gInsertSimAppFlag;
- extern MMI_PHB_LOOKUP_NODE_STRUCT LookUpTable[];
- #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
- extern U8 g_phb_is_speaking_name;
- #endif
- #if defined(__MMI_T9__)
- #if defined(__MMI_T9_V7__)
- extern T9CCAWFieldInfo FieldInfo;
- #else
- extern T9FieldInfo FieldInfo;
- #endif
- #endif /* defined(__MMI_T9__) */
- #if defined(__MMI_ITAP__)
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* defined(__MMI_ITAP__) */
- extern PHB_OPTIONAL_FIELDS_STRUCT PhoneBookOptionalFields;
- extern S8 pbEmailAddress[];
- /*
- * Local Function
- */
- static void mmi_phb_sort_name_fast_quicksort(U16 left, U16 right, phb_comp_func compare);
- static void mmi_phb_sort_name_quicksort(U16 left, U16 right, phb_comp_func compare);
- static void mmi_phb_sort_name_insertionsort(U16 low, U16 high, phb_comp_func compare);
- static void mmi_phb_sort_name_swap(U16 a, U16 b);
- /*
- * Global Function
- */
- #define MMI_PHB_SEARCH_INIT
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_search_init
- * DESCRIPTION
- * Initial function for phonebook search and sort.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_search_init(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetHiliteHandler(MITEM101_PBOOK_SEARCH_ENTRY, mmi_phb_highlight_search_name);
- SetHiliteHandler(MITEM1010_SEARCH, mmi_phb_highlight_search_name_option_search);
- SetHiliteHandler(MITEM1011_INPUT_MEHTHOD, mmi_phb_highlight_search_name_option_input_method);
- #if defined(__MMI_PHB_QUICK_SEARCH__)
- SetHiliteHandler(MENU_ID_PHB_QUICK_SEARCH, mmi_phb_highlight_quick_search_list);
- #if defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__)
- SetHiliteHandler(MENU_ID_PHB_QUICK_SEARCH_INPUT_METHOD, mmi_phb_highlight_quick_search_input_method);
- SetHiliteHandler(MENU_ID_PHB_QUICK_SEARCH_OP_OPTION, mmi_phb_highlight_quick_search_op_option);
- #endif /* defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__) */
- #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
- }
- #define MMI_PHB_SORT
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_build_name_index
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_sort_build_name_index(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (PhoneBookEntryCount > 1)
- {
- #if defined(__MMI_PHB_PINYIN_SORT__)
- if (g_phb_cntx.sort_type == MMI_PHB_SORT_PINYIN)
- {
- mmi_phb_sort_name_fast_quicksort(
- 0,
- (U16) (PhoneBookEntryCount - 1),
- mmi_phb_sort_compare_name_index_by_pinyin_cache);
- }
- else
- #endif /* defined(__MMI_PHB_PINYIN_SORT__) */
- mmi_phb_sort_name_fast_quicksort(
- 0,
- (U16) (PhoneBookEntryCount - 1),
- mmi_phb_sort_compare_name_index_by_encoding);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_insert_name_index
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * store_index [IN]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- U16 mmi_phb_sort_insert_name_index(U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 pos;
- U16 i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (PhoneBookEntryCount == 0)
- {
- g_phb_name_index[PhoneBookEntryCount] = store_index;
- PhoneBookEntryCount++;
- return 0;
- }
- else
- {
- pos = mmi_phb_sort_insert_name_index_find_pos(0, (PhoneBookEntryCount - 1), store_index);
- for (i = PhoneBookEntryCount; i > pos; i--)
- {
- g_phb_name_index[i] = g_phb_name_index[i - 1];
- }
- g_phb_name_index[pos] = store_index;
- PhoneBookEntryCount++;
- return pos;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_insert_name_index_find_pos
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * low [IN]
- * high [IN]
- * store_index [IN]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- U16 mmi_phb_sort_insert_name_index_find_pos(S32 low, S32 high, U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 mid = 0;
- S16 flag = 0;
- U8 same_count;
- S32 distance;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (low <= high)
- {
- mid = (low + high) / 2;
- #if defined(__MMI_PHB_PINYIN_SORT__)
- if (g_phb_cntx.sort_type == MMI_PHB_SORT_PINYIN)
- {
- mmi_phb_sort_compare_name_index_by_pinyin(store_index, g_phb_name_index[mid], &same_count, &distance);
- }
- else
- #endif /* defined(__MMI_PHB_PINYIN_SORT__) */
- mmi_phb_sort_compare_name_index_by_encoding(store_index, g_phb_name_index[mid], &same_count, &distance);
- if (distance > 0)
- {
- low = mid + 1;
- flag = -1;
- }
- else /* Either > 0 or < 0, not possible ==0 */
- {
- high = mid - 1;
- flag = 1;
- }
- }
- if (flag == -1)
- {
- return (U16) (mid + 1);
- }
- else
- {
- return (U16) mid;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_compare_name_index
- * DESCRIPTION
- * Compare two phonebook by name string. If name is empty use number instead.
- * PARAMETERS
- * first [IN] Store_index of first compare element
- * second [IN] Store_index of second compare element
- * string1 [IN] First name string
- * string2 [IN] Second name string
- * same_count [IN/OUT] Same count of two element
- * distance [IN/OUT] Difference of two element
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_sort_compare_name_index(U16 first, U16 second, S8 *string1, S8 *string2, U8 *same_count, S32 *distance)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 number1[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
- S8 number2[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Use number to sort if name empty */
- if (pfnUnicodeStrlen(string1) == 0)
- {
- mmi_phb_convert_get_ucs2_number(number1, first);
- string1 = (S8*) number1;
- }
- /* Use number to sort if name empty */
- if (pfnUnicodeStrlen(string2) == 0)
- {
- mmi_phb_convert_get_ucs2_number(number2, second);
- string2 = (S8*) number2;
- }
- /* Compare two strings */
- mmi_phb_compare_ucs2_strings(string1, string2, same_count, distance);
- /* sort according storage location, let entry in NVRAM put before in SIM. (store_index can decide store location) */
- if (*distance == 0)
- {
- if (first < second)
- {
- *distance = -1;
- }
- else if (first > second)
- {
- *distance = 1;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_compare_name_index_by_encoding
- * DESCRIPTION
- * Compare two phonebook entry element by encoding.
- * PARAMETERS
- * first [IN] Store_index of first compare element
- * second [IN] Store_index of second compare element
- * same_count [IN/OUT] Same count of two element
- * distance [IN/OUT] Difference of two element
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_sort_compare_name_index_by_encoding(U16 first, U16 second, U8 *same_count, S32 *distance)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *string1, *string2;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- string1 = (S8*) PhoneBook[first].alpha_id.name;
- string2 = (S8*) PhoneBook[second].alpha_id.name;
- mmi_phb_sort_compare_name_index(first, second, string1, string2, same_count, distance);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_compare_name_index_by_pinyin_cache
- * DESCRIPTION
- * Compare two phonebook entry element by pinyin by using prior convert result.
- * PARAMETERS
- * first [IN] Store_index of first compare element
- * second [IN] Store_index of second compare element
- * same_count [IN/OUT] Same count of two element
- * distance [IN/OUT] Difference of two element
- * RETURNS
- * void
- *****************************************************************************/
- #if defined(__MMI_PHB_PINYIN_SORT__)
- void mmi_phb_sort_compare_name_index_by_pinyin_cache(U16 first, U16 second, U8 *same_count, S32 *distance)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *string1, *string2;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (PhoneBook[first].alpha_id.name_dcs == MMI_PHB_ASCII)
- {
- string1 = (S8*) PhoneBook[first].alpha_id.name;
- }
- else
- {
- string1 = (S8*) g_phb_name_pinyin_index[first];
- }
- if (PhoneBook[second].alpha_id.name_dcs == MMI_PHB_ASCII)
- {
- string2 = (S8*) PhoneBook[second].alpha_id.name;
- }
- else
- {
- string2 = (S8*) g_phb_name_pinyin_index[second];
- }
- mmi_phb_sort_compare_name_index(first, second, string1, string2, same_count, distance);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_compare_name_index_by_pinyin
- * DESCRIPTION
- * Compare two phonebook entry element by pinyin.
- * PARAMETERS
- * first [IN] Store_index of first compare element
- * second [IN] Store_index of second compare element
- * same_count [IN/OUT] Same count of two element
- * distance [IN/OUT] Difference of two element
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_sort_compare_name_index_by_pinyin(U16 first, U16 second, U8 *same_count, S32 *distance)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *string1, *string2;
- S8 buffer1[(MMI_PHB_SORT_LENGTH + 1) * ENCODING_LENGTH];
- S8 buffer2[(MMI_PHB_SORT_LENGTH + 1) * ENCODING_LENGTH];
- U16 count;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (PhoneBook[first].alpha_id.name_dcs == MMI_PHB_ASCII)
- {
- string1 = (S8*) PhoneBook[first].alpha_id.name;
- }
- else
- {
- count = mmi_phb_util_convert_to_pinyin(
- PhoneBook[first].alpha_id.name,
- (U8*) buffer1,
- (MMI_PHB_SORT_LENGTH * ENCODING_LENGTH));
- buffer1[count++] = 0x00;
- buffer1[count] = 0x00;
- string1 = (S8*) buffer1;
- }
- if (PhoneBook[second].alpha_id.name_dcs == MMI_PHB_ASCII)
- {
- string2 = (S8*) PhoneBook[second].alpha_id.name;
- }
- else
- {
- count = mmi_phb_util_convert_to_pinyin(
- PhoneBook[second].alpha_id.name,
- (U8*) buffer2,
- (MMI_PHB_SORT_LENGTH * ENCODING_LENGTH));
- buffer2[count++] = 0x00;
- buffer2[count] = 0x00;
- string2 = (S8*) buffer2;
- }
- mmi_phb_sort_compare_name_index(first, second, string1, string2, same_count, distance);
- }
- #endif /* defined(__MMI_PHB_PINYIN_SORT__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_name_fast_quicksort
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * left [IN]
- * right [IN]
- * compare [IN]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.(?)
- *****************************************************************************/
- void mmi_phb_sort_name_fast_quicksort(U16 left, U16 right, phb_comp_func compare)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_phb_sort_name_quicksort(left, right, compare);
- mmi_phb_sort_name_insertionsort(left, right, compare);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_name_quicksort
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * left [IN]
- * right [IN]
- * compare [IN]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.(?)
- *****************************************************************************/
- void mmi_phb_sort_name_quicksort(U16 left, U16 right, phb_comp_func compare)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 const Min = 4; /* Lower bound to sort */
- U16 i;
- U16 j;
- U16 pivot;
- S32 distance;
- U8 same_count;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- MMI_ASSERT(compare != NULL);
- if ((right - left) > Min)
- {
- i = (right + left) / 2;
- /* left > mid */
- (*compare) (g_phb_name_index[left], g_phb_name_index[i], &same_count, &distance);
- if (distance > 0)
- {
- mmi_phb_sort_name_swap(left, i);
- }
- /* left > right */
- (*compare) (g_phb_name_index[left], g_phb_name_index[right], &same_count, &distance);
- if (distance > 0)
- {
- mmi_phb_sort_name_swap(left, right);
- }
- /* mid > right */
- (*compare) (g_phb_name_index[i], g_phb_name_index[right], &same_count, &distance);
- if (distance > 0)
- {
- mmi_phb_sort_name_swap(i, right);
- }
- j = right - 1;
- mmi_phb_sort_name_swap(i, j);
- i = left;
- pivot = g_phb_name_index[j]; /* kal_mem_cpy(&v, (void const*)&a[j], sizeof(pindex_struct)); */
- for (;;)
- {
- do /* ++i < pivot */
- {
- (*compare) (g_phb_name_index[++i], pivot, &same_count, &distance);
- }
- while (distance < 0);
- do /* --j > pivot */
- {
- (*compare) (g_phb_name_index[--j], pivot, &same_count, &distance);
- }
- while (distance > 0);
- if (j < i)
- {
- break;
- }
- mmi_phb_sort_name_swap(i, j);
- }
- mmi_phb_sort_name_swap(i, (U16) (right - 1));
- mmi_phb_sort_name_quicksort(left, j, compare);
- mmi_phb_sort_name_quicksort((U16) (i + 1), right, compare);
- }
- } /* end of phb_quicksort */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_name_insertionsort
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * low [IN]
- * high [IN]
- * compare [IN]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.(?)
- *****************************************************************************/
- void mmi_phb_sort_name_insertionsort(U16 low, U16 high, phb_comp_func compare)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i;
- U16 j;
- U16 pivot;
- S32 distance;
- U8 same_count;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ASSERT(compare != NULL);
- for (i = low + 1; i <= high; ++i)
- {
- pivot = g_phb_name_index[i];
- j = i;
- while (j > low)
- {
- (*compare) (g_phb_name_index[j - 1], pivot, &same_count, &distance);
- if (distance <= 0)
- {
- break;
- }
- g_phb_name_index[j] = g_phb_name_index[j - 1];
- j--;
- }
- g_phb_name_index[j] = pivot;
- }
- } /* end of phb_insertion_sort */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_sort_name_swap
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * a [IN/OUT] First variable, used as returns
- * b [IN] Second variable
- * RETURNS
- * the description of return value, if any.(?)
- *****************************************************************************/
- void mmi_phb_sort_name_swap(U16 a, U16 b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 tmp;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- tmp = g_phb_name_index[a];
- g_phb_name_index[a] = g_phb_name_index[b];
- g_phb_name_index[b] = tmp;
- }
- #define MMI_PHB_SEARCH_NAME
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_highlight_search_name
- * DESCRIPTION
- * Highlight handler for "Search Entry" in PHB main menu
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_highlight_search_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_highlight_search_name.>n", __FILE__,
- __LINE__));
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- SetLeftSoftkeyFunction(mmi_phb_search_name_pre_entry, KEY_EVENT_UP);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(mmi_phb_search_name_pre_entry, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- phbListView = MMI_PHB_LIST_FOR_PHB;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_highlight_search_name_option_search
- * DESCRIPTION
- * Highlight handler for "Search" in Search Option menu
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_highlight_search_name_option_search(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_highlight_search_name_option_search.>n",
- __FILE__, __LINE__));
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- SetLeftSoftkeyFunction(mmi_phb_search_name, KEY_EVENT_UP);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(mmi_phb_search_name, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_highlight_search_name_option_input_method
- * DESCRIPTION
- * Highlight handler for "Input Method" in Search Option menu
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_highlight_search_name_option_input_method(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB,
- "File: [%s] Line: [%d] <<mmi_phb_highlight_search_name_option_input_method.>n", __FILE__,
- __LINE__));
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- SetInputMethodAndDoneCaptionIcon(IMG_SCR_PBOOK_CAPTION);
- SetLeftSoftkeyFunction(EntryInputMethodScreen, KEY_EVENT_UP);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(EntryInputMethodScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_search_name_pre_entry
- * DESCRIPTION
- * Calls mmi_phb_entry_search_name() after few checks
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_search_name_pre_entry(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_search_name_pre_entry.>n", __FILE__,
- __LINE__));
- #ifdef __SYNCML_SUPPORT__
- if (mmi_syncml_is_phb_sync_now())
- {
- mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
- }
- else
- #endif /* __SYNCML_SUPPORT__ */
- if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
- {
- memset(pbName, 0, ENCODING_LENGTH);
- if (PhoneBookEntryCount)
- {
- mmi_phb_entry_search_name();
- }
- else
- {
- DisplayPopup(
- (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
- IMG_GLOBAL_EMPTY,
- TRUE,
- PHB_NOTIFY_TIMEOUT,
- EMPTY_LIST_TONE);
- }
- }
- else
- {
- mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_entry_search_name
- * DESCRIPTION
- * Gets name input from user
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_entry_search_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- S8 state;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_entry_search_name.>n", __FILE__,
- __LINE__));
- EntryNewScreen(SCR_SEARCH_NAME_ENTRY, mmi_phb_exit_search_name, NULL, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_SEARCH_NAME_ENTRY);
- if (guiBuffer != NULL)
- {
- state = get_multiline_inputbox_category_history_state(SCR_SEARCH_NAME_ENTRY, guiBuffer);
- if (state != -1)
- {
- phbListView = (U8) state;
- }
- }
- #if defined UI_SMALL_CATEGORY_EDITOR
- enable_resized_small_screen();
- #endif
- ShowCategory5Screen_ext(
- STR_SCR_SEARCH_NAME_CAPTION,
- IMG_SCR_PBOOK_CAPTION,
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OPTIONS,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- (INPUT_TYPE_ALPHANUMERIC_UPPERCASE | INPUT_TYPE_USE_ENCODING_BASED_LENGTH | INPUT_TYPE_ONE_LESS_CHARACTER),
- (PU8) pbName,
- MAX_SEARCH_NAME_LENGTH + 1,
- guiBuffer,
- INPUT_TYPE_EXT_NO_SHOW_NEW_LINE_SYMBOL,
- NULL,
- NULL);
- SetLeftSoftkeyFunction(mmi_phb_entry_search_name_option, KEY_EVENT_UP);
- SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(mmi_phb_search_name, KEY_SEND, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_exit_search_name
- * DESCRIPTION
- * Exit function for mmi_phb_entry_search_name()
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_exit_search_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history h;
- S8 state = (S8) phbListView;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_phb_cntx.start_scr_id == 0) /* start from Shortcut */
- {
- g_phb_cntx.start_scr_id = GetCurrScrnId();
- }
- g_phb_cntx.end_scr_id = SCR_SEARCH_NAME_ENTRY;
- h.scrnID = SCR_SEARCH_NAME_ENTRY;
- h.entryFuncPtr = mmi_phb_entry_search_name;
- pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) pbName);
- GetCategoryHistory(h.guiBuffer);
- set_multiline_inputbox_category_history_state(SCR_SEARCH_NAME_ENTRY, h.guiBuffer, state);
- AddHistory(h);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_entry_search_name_option
- * DESCRIPTION
- * Draws the Search Options menu
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_entry_search_name_option(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer;
- U16 nStrItemList[2];
- U16 nNumofItem;
- S8 state;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_entry_search_name_option.>n", __FILE__,
- __LINE__));
- EntryNewScreen(SCR_SEARCH_OPTIONS, mmi_phb_exit_search_name_option, NULL, NULL);
- guiBuffer = GetCurrGuiBuffer(SCR_SEARCH_OPTIONS);
- if (guiBuffer != NULL)
- {
- state = get_list_menu_category_history_state(SCR_PBOOK_LIST, guiBuffer);
- if (state != -1)
- {
- phbListView = (U8) state; /* Restore State in history. */
- }
- }
- nNumofItem = GetNumOfChild(MITEM101_SEARCH_OPTIONS);
- GetSequenceStringIds(MITEM101_SEARCH_OPTIONS, nStrItemList);
- SetParentHandler(MITEM101_SEARCH_OPTIONS);
- RegisterHighlightHandler(ExecuteCurrHiliteHandler);
- ShowCategory15Screen(
- STR_GLOBAL_OPTIONS,
- IMG_SCR_PBOOK_CAPTION,
- STR_GLOBAL_OK,
- IMG_GLOBAL_OK,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- nNumofItem,
- nStrItemList,
- (U16*) gIndexIconsImageList,
- LIST_MENU,
- 0,
- guiBuffer);
- RegisterInputMethodScreenCloseFunction(mmi_phb_go_back_2_history);
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_exit_search_name_option
- * DESCRIPTION
- * Exit function for mmi_phb_entry_search_name_option()
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_exit_search_name_option(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history h;
- S16 nHistory = 0;
- S8 state = (S8) phbListView;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_phb_cntx.end_scr_id = SCR_SEARCH_OPTIONS;
- h.scrnID = SCR_SEARCH_OPTIONS;
- h.entryFuncPtr = mmi_phb_entry_search_name_option;
- pfnUnicodeStrcpy((S8*) h.inputBuffer, (S8*) & nHistory);
- GetCategoryHistory(h.guiBuffer);
- set_list_menu_category_history_state(SCR_PBOOK_LIST, h.guiBuffer, state); /* Keep State in history. */
- AddHistory(h);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_search_name
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * void
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.(?)
- *****************************************************************************/
- void mmi_phb_search_name(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_phb_cntx.highlight_entry = mmi_phb_search_name_find_closet();
- if (phbListView == MMI_PHB_LIST_FOR_PHB)
- {
- mmi_phb_list_pre_entry(); /* Dynamic List */
- }
- else if ((phbListView == MMI_PHB_LIST_FOR_SMS) || (phbListView == MMI_PHB_LIST_FOR_SMS_SEARCH_NAME))
- {
- mmi_phb_list_pre_entry_second_level();
- }
- DeleteNScrId(SCR_SEARCH_NAME_ENTRY);
- /* Not Found, Not Possible, will return closet entry */
- // DisplayPopup((PU8)GetString(STR_NOENTRY_FOUND_MSG), IMG_GLOBAL_WARNING, FALSE, PHB_NOTIFY_TIMEOUT, WARNING_TONE);
- // DeleteNScrId(SCR_SEARCH_NAME_ENTRY);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_search_name_find_closet
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * void
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- U16 mmi_phb_search_name_find_closet(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 result_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (pfnUnicodeStrlen((S8*) pbName) == 0)
- {
- return 0;
- }
- result_index = mmi_phb_search_name_binary_search(0, (PhoneBookEntryCount - 1), (S8*) pbName);
- /* Check boundary */
- if (result_index >= PhoneBookEntryCount)
- {
- result_index = PhoneBookEntryCount - 1;
- }
- return result_index;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_search_name_binary_search
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * low [IN]
- * high [IN]
- * ucs2_name [?]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- U16 mmi_phb_search_name_binary_search(S32 low, S32 high, S8 *ucs2_name)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 mid = 0;
- S16 flag = 0;
- U8 same_count;
- S32 distance;
- U16 index;
- S8 *string;
- S8 number[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
- #if defined(__MMI_PHB_PINYIN_SORT__)
- S8 buffer1[(MMI_PHB_SORT_LENGTH + 1) * ENCODING_LENGTH];
- S8 buffer2[(MMI_PHB_SORT_LENGTH + 1) * ENCODING_LENGTH];
- U16 count;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (GetUCS2Flag(ucs2_name))
- {
- count = mmi_phb_util_convert_to_pinyin((U8*) ucs2_name, (U8*) buffer1, (MMI_PHB_SORT_LENGTH * ENCODING_LENGTH));
- buffer1[count++] = 0x00;
- buffer1[count] = 0x00;
- ucs2_name = (S8*) buffer1;
- }
- #endif /* defined(__MMI_PHB_PINYIN_SORT__) */
- /*
- * Use binary search to find nearest name.
- */
- while (low <= high)
- {
- mid = (low + high) / 2;
- /*
- * Prepare entry data to compare
- */
- index = g_phb_name_index[mid];
- #if defined(__MMI_PHB_PINYIN_SORT__)
- if (PhoneBook[index].alpha_id.name_dcs == MMI_PHB_ASCII)
- {
- string = (S8*) PhoneBook[index].alpha_id.name;
- }
- else
- {
- count = mmi_phb_util_convert_to_pinyin(
- PhoneBook[index].alpha_id.name,
- (U8*) buffer2,
- (MMI_PHB_SORT_LENGTH * ENCODING_LENGTH));
- buffer2[count++] = 0x00;
- buffer2[count] = 0x00;
- string = (S8*) buffer2;
- }
- #else /* defined(__MMI_PHB_PINYIN_SORT__) */
- string = (S8*) PhoneBook[index].alpha_id.name;
- #endif /* defined(__MMI_PHB_PINYIN_SORT__) */
- /*
- * Use number to compare if name is empty
- */
- if (pfnUnicodeStrlen(string) == 0)
- {
- mmi_phb_convert_get_ucs2_number(number, index);
- string = (S8*) number;
- }
- /*
- * Compare search pattern with entry
- */
- mmi_phb_compare_ucs2_strings(ucs2_name, string, &same_count, &distance);
- if (distance > 0)
- {
- low = mid + 1;
- flag = -1;
- }
- /*
- * Distance == 0 or < 0 here
- * If there are duplicate entry, this will help to move up until first entry.
- */
- else
- {
- high = mid - 1;
- flag = 1;
- }
- }
- if (flag == -1)
- {
- return (U16) (mid + 1);
- }
- else
- {
- return (U16) mid;
- }
- }
- #define MMI_PHB_QUICKSEARCH
- #if defined(__MMI_PHB_QUICK_SEARCH__) || defined(MMI_ON_WIN32)
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_highlight_quick_search_list
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_highlight_quick_search_list(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- #if defined(MMI_ON_WIN32)
- SetLeftSoftkeyFunction(PopupNoSupport, KEY_EVENT_UP);
- SetKeyHandler(PopupNoSupport, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- #else
- SetLeftSoftkeyFunction(mmi_phb_quick_search_list_pre_entry, KEY_EVENT_UP);
- SetKeyHandler(mmi_phb_quick_search_list_pre_entry, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
- #endif /* MMI_ON_WIN32 */
- SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
- SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
- }
- #endif /* defined(__MMI_PHB_QUICK_SEARCH__) || defined(MMI_ON_WIN32) */
- #if defined(__MMI_PHB_QUICK_SEARCH__)
- #if defined(__MMI_T9__) && (defined(__MMI_LANG_TR_CHINESE__) || defined(__MMI_LANG_SM_CHINESE__))
- #if defined(__MMI_T9_V7__)
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_to_spelling
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * input_string [?]
- * output_string [?]
- * out_len [?]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- BOOL mmi_phb_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 out = 0;
- U8 i = 0;
- T9STATUS t9ReturnCodes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Should already switch to the proper input language in "mmi_phb_quick_search_convert_cache()". */
- if (input_string[0] != 0 || input_string[1] != 0)
- {
- if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
- {
- t9ReturnCodes = T9CCGetCharStrokes(&FieldInfo.CCFieldInfo, (U16*) input_string, 0);
- }
- else
- {
- t9ReturnCodes = T9CCGetCharSpell(&FieldInfo.CCFieldInfo, (U16*) input_string, 0);
- }
- if (t9ReturnCodes == 0)
- {
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- while ((FieldInfo.CCFieldInfo.pbSpellBuf[i] != 0x00) && (i <= 7))
- {
- *((U16*) (output_string + out)) = BPMFInternalToUnicode(FieldInfo.CCFieldInfo.pbSpellBuf[i]);
- out = out + 2;
- i = i + 1;
- }
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- while ((FieldInfo.CCFieldInfo.pbSpellBuf[i] != 0x00) && (i <= 7))
- {
- output_string[out] = FieldInfo.CCFieldInfo.pbSpellBuf[i];
- output_string[out + 1] = 0;
- out = out + 2;
- i = i + 1;
- }
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- while ((FieldInfo.CCFieldInfo.pbKeyBuf[i] != 0x00) &&
- (i < FieldInfo.CCFieldInfo.nKeyBufLen) && (i <= 7))
- {
- *((U16*) (output_string + out)) = StrokeInternalToUnicode(FieldInfo.CCFieldInfo.pbKeyBuf[i]);
- out = out + 2;
- i = i + 1;
- }
- break;
- default:
- break;
- }
- *out_len = i;
- return TRUE;
- }
- /* Input String Does not Converted. */
- memcpy(output_string, input_string, 2);
- *out_len = 1;
- return TRUE;
- }
- *out_len = 0;
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_cache
- * DESCRIPTION
- * This function convert first character of name field into cache.
- * PARAMETERS
- * index [IN] Phonebook entry index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_quick_search_convert_cache(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- T9STATUS t9ReturnCodes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* move change language function out from loop to speed up */
- if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
- {
- t9ReturnCodes = T9CCGetCharStrokes(&FieldInfo.CCFieldInfo, (U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name, 0);
- }
- else
- {
- t9ReturnCodes = T9CCGetCharSpell(&FieldInfo.CCFieldInfo, (U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name, 0);
- }
- if (t9ReturnCodes == 0)
- {
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- g_phb_qsearch_cache[index] = BPMFInternalToUnicode(FieldInfo.CCFieldInfo.pbSpellBuf[0]);
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- g_phb_qsearch_cache[index] = FieldInfo.CCFieldInfo.pbSpellBuf[0];
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- g_phb_qsearch_cache[index] = StrokeInternalToUnicode(FieldInfo.CCFieldInfo.pbKeyBuf[0]);
- break;
- default:
- g_phb_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
- break;
- }
- }
- else
- {
- g_phb_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
- }
- }
- #else /* defined(__MMI_T9_V7__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_to_spelling
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * input_string [?]
- * output_string [?]
- * out_len [?]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- BOOL mmi_phb_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 out = 0;
- U8 i = 0;
- T9Event t9EventInput;
- T9STATUS t9ReturnCodes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Should already switch to the proper input language in "mmi_phb_quick_search_convert_cache()". */
- if (input_string[0] != 0 || input_string[1] != 0)
- {
- if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
- {
- t9EventInput.mType = T9EVTSTROKES;
- }
- else
- {
- t9EventInput.mType = T9EVTSPELLING;
- }
- t9EventInput.data.sLDBData.psBuf = (U16*) input_string;
- t9EventInput.data.sLDBData.mCtrlID = 0;
- t9ReturnCodes = T9HandleEvent(&FieldInfo, &t9EventInput);
- if (t9ReturnCodes == 0)
- {
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- while ((FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i] != 0x00) && (i <= 7))
- {
- *((U16*) (output_string + out)) = BPMFInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i]);
- out = out + 2;
- i = i + 1;
- }
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- while ((FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i] != 0x00) && (i <= 7))
- {
- output_string[out] = FieldInfo.uLangData.pAuxChinese->pbSpellBuf[i];
- output_string[out + 1] = 0;
- out = out + 2;
- i = i + 1;
- }
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- while ((FieldInfo.uLangData.pAuxChinese->pbKeyBuf[i] != 0x00) &&
- (i < FieldInfo.uLangData.pAuxChinese->nKeyBufLen) && (i <= 7))
- {
- *((U16*) (output_string + out)) = StrokeInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbKeyBuf[i]);
- out = out + 2;
- i = i + 1;
- }
- break;
- default:
- break;
- }
- *out_len = i;
- return TRUE;
- }
- /* Input String Does not Converted. */
- memcpy(output_string, input_string, 2);
- *out_len = 1;
- return TRUE;
- }
- *out_len = 0;
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_cache
- * DESCRIPTION
- * This function convert first character of name field into cache.
- * PARAMETERS
- * index [IN] Phonebook entry index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_quick_search_convert_cache(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- T9Event t9EventInput;
- T9STATUS t9ReturnCodes;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* move change language function out from loop to speed up */
- if (MMI_current_input_mode == INPUT_MODE_MMI_SM_STROKE || MMI_current_input_mode == INPUT_MODE_MMI_TR_STROKE)
- {
- t9EventInput.mType = T9EVTSTROKES;
- }
- else
- {
- t9EventInput.mType = T9EVTSPELLING;
- }
- t9EventInput.data.sLDBData.psBuf = (U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name;
- t9EventInput.data.sLDBData.mCtrlID = 0;
- t9ReturnCodes = T9HandleEvent(&FieldInfo, &t9EventInput);
- if (t9ReturnCodes == 0)
- {
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- g_phb_qsearch_cache[index] = BPMFInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbSpellBuf[0]);
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- g_phb_qsearch_cache[index] = FieldInfo.uLangData.pAuxChinese->pbSpellBuf[0];
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- g_phb_qsearch_cache[index] = StrokeInternalToUnicode(FieldInfo.uLangData.pAuxChinese->pbKeyBuf[0]);
- break;
- default:
- g_phb_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
- break;
- }
- }
- else
- {
- g_phb_qsearch_cache[index] = *((U16*) PhoneBook[g_phb_name_index[index]].alpha_id.name);
- }
- }
- #endif /* defined(__MMI_T9_V7__) */
- #elif defined(__MMI_ZI__)
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_to_spelling
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * input_string [?]
- * output_string [?]
- * out_len [?]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- BOOL mmi_phb_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 out = 0;
- U8 i = 0;
- U16 code;
- U16 mode;
- U16 pCharInfoBuffer[MMI_PHB_CONVERT_BUFF_ZI];
- U16 CharInfo;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Change convert mode according to input method. */
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- /* mode = ZI8_GETMODE_BOPOMOFO; */
- mode = ZI8_GETMODE_BOPOMOFO_NAME;
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- /* mode = ZI8_GETMODE_PINYIN; */
- mode = ZI8_GETMODE_PINYIN_NAME;
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- mode = ZI8_GETMODE_STROKES;
- break;
- default:
- return FALSE;
- break;
- }
- if (input_string[0] != 0 || input_string[1] != 0)
- {
- memcpy(&code, input_string, 2);
- if ((code >= 0x4e00) && (code <= 0x9fa5) &&
- Zi8GetCharInfo(code, (U16*) pCharInfoBuffer, MMI_PHB_CONVERT_BUFF_ZI, mode))
- {
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- /* Do not convert tone */
- while ((pCharInfoBuffer[i] != 0x0000) &&
- ((pCharInfoBuffer[i] < 0xf431) || (pCharInfoBuffer[i] > 0xf435)))
- {
- CharInfo = pCharInfoBuffer[i] - ZI8_BASE_BPMF + 0x3105;
- memcpy(output_string + out, &CharInfo, 2);
- out = out + 2;
- i = i + 1;
- }
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- /* Do not convert tone */
- while ((pCharInfoBuffer[i] != 0x0000) &&
- ((pCharInfoBuffer[i] < 0xf431) || (pCharInfoBuffer[i] > 0xf435)))
- {
- CharInfo = pCharInfoBuffer[i] - ZI8_BASE_PINYIN + 0x0061;
- memcpy(output_string + out, &CharInfo, 2);
- out = out + 2;
- i = i + 1;
- }
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- while ((pCharInfoBuffer[i] != 0x0000) && (i <= 7))
- {
- memcpy(output_string + out, &pCharInfoBuffer[i], 2);
- out = out + 2;
- i = i + 1;
- }
- break;
- default:
- break;
- }
- *out_len = i;
- return TRUE;
- }
- memcpy(output_string, input_string, 2);
- *out_len = 1;
- return TRUE;
- }
- *out_len = 0;
- return FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_cache
- * DESCRIPTION
- * This function convert first character of name field into cache.
- * PARAMETERS
- * index [IN] Phonebook entry index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_quick_search_convert_cache(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 code;
- U16 mode;
- U16 pCharInfoBuffer[MMI_PHB_CONVERT_BUFF_ZI];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memcpy(&code, PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- /* Change to proper input method. */
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- mode = ZI8_GETMODE_BOPOMOFO;
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- mode = ZI8_GETMODE_PINYIN;
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- mode = ZI8_GETMODE_STROKES;
- break;
- default:
- memcpy(&g_phb_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- return;
- }
- /* Begin to convert and store the result according to the input method. */
- if ((code >= 0x4e00) && (code <= 0x9fa5) &&
- Zi8GetCharInfo(code, (U16*) pCharInfoBuffer, MMI_PHB_CONVERT_BUFF_ZI, mode))
- {
- switch (MMI_current_input_mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- g_phb_qsearch_cache[index] = pCharInfoBuffer[0] - ZI8_BASE_BPMF + 0x3105;
- break;
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- g_phb_qsearch_cache[index] = pCharInfoBuffer[0] - ZI8_BASE_PINYIN + 0x0061;
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- g_phb_qsearch_cache[index] = pCharInfoBuffer[0];
- break;
- default:
- memcpy(&g_phb_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- break;
- }
- }
- else
- {
- memcpy(&g_phb_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- }
- }
- //KP Jerry add on 2007-3-8 start
- #elif defined(__MMI_CSTAR__)
- BOOL mmi_phb_quick_search_convert_to_spelling(U8* input_string, U8* output_string, U8* out_len)
- {
- int c;
- int mode;
- U16 code;
- U16 buf[16];
- mode = MMI_current_input_mode;
- switch (mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- break;
- default:
- *out_len = 0;
- return FALSE;
- }
- if ( (input_string[0] == 0) && (input_string[1] == 0) )
- {
- *out_len = 0;
- return FALSE;
- }
- memcpy(&code, input_string, 2);
- c = CstarQueryCharInfo(code, buf, 16, mode);
- if (c <= 0)
- {
- memcpy(output_string, input_string, 2);
- *out_len = 1;
- return TRUE;
- }
- if (c > 7)
- c = 7;
- memcpy(output_string, buf, sizeof(U16) * c);
- *out_len = (U8)c;
- return TRUE;
- }
- void mmi_phb_quick_search_convert_cache(U16 index)
- {
- int c;
- int mode;
- U16 code;
- U16 buf[16];
- mode = MMI_current_input_mode;
- switch (mode)
- {
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- case INPUT_MODE_MMI_SM_STROKE:
- case INPUT_MODE_MMI_TR_STROKE:
- break;
- default:
- memcpy(&g_phb_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- return;
- }
- memcpy(&code, PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- c = CstarQueryCharInfo(code, buf, 16, mode);
- if (c <= 0)
- {
- memcpy(&g_phb_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
- return;
- }
- g_phb_qsearch_cache[index] = buf[0];
- }
- //KP Jerry add on 2007-3-8 end
- #elif defined(__MMI_ITAP__)
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #else /* No default input method library */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_to_spelling
- * DESCRIPTION
- * This function is just for template.
- * PARAMETERS
- * input_string [?]
- * output_string [?]
- * out_len [?]
- * a(?) [IN/OUT] First variable, used as returns
- * b(?) [IN] Second variable
- * RETURNS
- * the description of return value, if any.
- *****************************************************************************/
- BOOL mmi_phb_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memcpy(output_string, input_string, 2);
- *out_len = 1;
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_convert_cache
- * DESCRIPTION
- * This function convert first character of name field into cache.
- * PARAMETERS
- * index [IN] Phonebook entry index
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_quick_search_convert_cache(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_phb_qsearch_cache[index] = (U16) PhoneBook[g_phb_name_index[index]].alpha_id.name[0];
- }
- #endif
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_make_cache
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_quick_search_make_cache(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 index;
- U16 pre_store_index;
- U16 store_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #if defined(__MMI_T9__)
- /* Switch to the proper input language, only for T9 */
- switch (MMI_current_input_mode)
- {
- #if defined(__MMI_T9_TR_CHINESE__)
- case INPUT_MODE_MMI_MULTITAP_BPMF:
- T9ChangeLanguageToTRChineseBoPoMo();
- break;
- case INPUT_MODE_MMI_TR_STROKE:
- T9ChangeLanguageToTRChineseStroke();
- break;
- #endif /* defined(__MMI_T9_TR_CHINESE__) */
- #if defined(__MMI_T9_SM_CHINESE__)
- case INPUT_MODE_MMI_MULTITAP_PINYIN:
- T9ChangeLanguageToSMChinesePinYin();
- break;
- case INPUT_MODE_MMI_SM_STROKE:
- T9ChangeLanguageToSMChineseStroke();
- break;
- #endif /* defined(__MMI_T9_SM_CHINESE__) */
- default:
- break;
- }
- #endif /* defined(__MMI_T9__) */
- /* Begin to convert first character of name field to associated input method string. */
- for (index = 0; index < PhoneBookEntryCount; index++)
- {
- store_index = g_phb_name_index[index];
- if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) > 0)
- {
- /* The Entry Name is an UCS2 string */
- if (PhoneBook[store_index].alpha_id.name_dcs == PHB_UCS2)
- {
- if (index != 0)
- {
- pre_store_index = g_phb_name_index[index - 1];
- /* If character is the same, do not convert again. */
- if ((PhoneBook[pre_store_index].alpha_id.name[0] == PhoneBook[store_index].alpha_id.name[0]) &&
- (PhoneBook[pre_store_index].alpha_id.name[1] == PhoneBook[store_index].alpha_id.name[1]))
- {
- g_phb_qsearch_cache[index] = g_phb_qsearch_cache[index - 1];
- continue;
- }
- }
- mmi_phb_quick_search_convert_cache(index);
- }
- else
- /* This is an ASCII string */
- {
- g_phb_qsearch_cache[index] = (U16) PhoneBook[store_index].alpha_id.name[0];
- }
- }
- /* The name field is Empty */
- else
- {
- g_phb_qsearch_cache[index] = 0x0000;
- }
- }
- g_phb_qsearch_is_cache = 1; /* Convert cache done */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_quick_search_find_entry
- * DESCRIPTION
- *
- * PARAMETERS
- * keyword [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 mmi_phb_quick_search_find_entry(U8 *keyword)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 key_length;
- U8 flag;
- U16 i;
- U16 code1, code2;
- U16 result_count;
- U8 same_count;
- U8 convert_result;
- S32 distance;
- S8 *string1, *string2 = NULL;
- S8 convert_string[22 * ENCODING_LENGTH]; /* 7*3 + 1 => (char1 + char2 + char3 + Null Terminator) */
- U8 char1[7 * ENCODING_LENGTH]; /* Cache 1st character convert result */
- U8 char2[7 * ENCODING_LENGTH]; /* Cache 2nd character convert result */
- U8 char3[7 * ENCODING_LENGTH]; /* Cache 3rd character convert result */
- U8 len1, len2, len3;
- U16 store_index;
- U8 prev_ucs2 = 0; /* Is previous record ucs2 encoding */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Check if cache already build up before using */
- if (!g_phb_qsearch_is_cache)
- {
- StopTimer(PHB_QUICK_SEARCH_TIMER);
- mmi_phb_quick_search_make_cache();
- }
- /* Count the input string length to decide behavior */
- key_length = (U8) pfnUnicodeStrlen((S8*) keyword);
- result_count = 0;
- /* For each entry, check if it is in the quick search sub-list */
- for (i = 0; i < PhoneBookEntryCount; i++)
- {
- flag = FALSE;
- /*
- * search length == 1, compare whole list with first character only.
- */
- if (key_length == 1)
- {
- code1 = (U16) g_phb_qsearch_cache[i];
- memcpy(&code2, keyword, 2);
- if (mmi_phb_compare_chars(code1, code2) == 0)
- {
- flag = TRUE;
- }
- }
- /*
- * search length > 1, compare subset list with maximum search character.
- */
- else if (key_length > 1)
- {
- code1 = (U16) g_phb_qsearch_cache[i];
- memcpy(&code2, keyword, 2);
- /* Compare character in cache first. If match, compare the rest part. */
- if (mmi_phb_compare_chars(code1, code2) == 0)
- {
- store_index = g_phb_name_index[i];
- flag = FALSE;
- if (PhoneBook[store_index].alpha_id.name_dcs == MMI_PHB_UCS2)
- {
- /* Use previous record convert result as cache */
- if (i != 0)
- {
- string2 = (S8*) PhoneBook[g_phb_name_index[i - 1]].alpha_id.name;
- }
- /* Current record */
- string1 = (S8*) PhoneBook[store_index].alpha_id.name;
- /*
- * Convert 1st character
- */
- if ((i != 0) && (string2[0] == string1[0]) && (string2[1] == string1[1]) && prev_ucs2)
- {
- convert_result = 10; /* Use 10 to represent that first character is the same as previous one */
- }
- else
- {
- U16 code;
- memcpy(&code, &PhoneBook[store_index].alpha_id.name[0], 2);
- if ((code >= 0x4e00) && (code <= 0x9fa5))
- {
- convert_result = mmi_phb_quick_search_convert_to_spelling(
- &PhoneBook[store_index].alpha_id.name[0],
- char1,
- &len1);
- }
- else
- {
- convert_result = FALSE;
- }
- }
- if (convert_result)
- {
- memset(convert_string, 0, 22 * ENCODING_LENGTH); /* Clear String in advance, to make sure there will be terminator */
- len1 = (len1 > 7) ? 7 : len1;
- memcpy(convert_string, char1, (len1 * ENCODING_LENGTH));
- /*
- * Convert 2nd Character
- */
- if (len1 < key_length)
- {
- if ((convert_result == 10) && (string2[2] == string1[2]) && (string2[3] == string1[3]) &&
- prev_ucs2)
- {
- convert_result = 20; /* Use 20 to represent that second character is the same as previous one */
- }
- else
- {
- convert_result = mmi_phb_quick_search_convert_to_spelling(
- &PhoneBook[store_index].alpha_id.name[2],
- char2,
- &len2);
- }
- if (convert_result)
- {
- len2 = (len2 > 7) ? 7 : len2;
- memcpy((convert_string + len1 * ENCODING_LENGTH), char2, (len2 * ENCODING_LENGTH));
- /*
- * Convert 3rd Character
- */
- if ((len1 + len2) < key_length)
- {
- if ((convert_result == 20) && (string2[4] == string1[4]) &&
- (string2[5] == string1[5]) && prev_ucs2)
- {
- convert_result = 30; /* Use 30 to represent that third character is the same as previous one */
- }
- else
- {
- convert_result = mmi_phb_quick_search_convert_to_spelling(
- &PhoneBook[store_index].alpha_id. name[4],
- char3,
- &len3);
- }
- if (convert_result)
- {
- len3 = (len3 > 7) ? 7 : len3;
- memcpy(
- (convert_string + (len1 + len2) * ENCODING_LENGTH),
- char3,
- (len3 * ENCODING_LENGTH));
- }
- else
- {
- memcpy(
- (convert_string + len1 * ENCODING_LENGTH),
- &PhoneBook[store_index].alpha_id.name[4],
- 2);
- }
- }
- }
- else
- {
- memcpy(
- (convert_string + len1 * ENCODING_LENGTH),
- &PhoneBook[store_index].alpha_id.name[2],
- 2);
- }
- }
- /* Chinese convert successfully, use convert result to compare */
- string1 = convert_string;
- prev_ucs2 = 1;
- }
- else /* Not Chinese */
- {
- string1 = (S8*) PhoneBook[store_index].alpha_id.name;
- prev_ucs2 = 0;
- }
- }
- else /* ASCII */
- {
- string1 = (S8*) PhoneBook[store_index].alpha_id.name;
- prev_ucs2 = 0;
- }
- mmi_phb_compare_ucs2_strings((S8*) string1, (S8*) keyword, &same_count, &distance);
- if (same_count == key_length)
- {
- flag = TRUE;
- }
- }
- }
- /*
- *search length == 0, display whole list.
- */
- else
- {
- flag = TRUE;
- }
- /* Add to list if entry is a subset of a quick search result */
- if (flag)
- {
- /* g_phb_qsearch[i] = 1; */
- g_phb_qsearch_bitmask[i >> BYTE_SIZE_SHIFT_ARITHMETIC] |= 1 << (i % BYTE_SIZE);
- result_count++;
- }
- else
- {
- /* g_phb_qsearch[i] = 0; */
- g_phb_qsearch_bitmask[i >> BYTE_SIZE_SHIFT_ARITHMETIC] &= (kal_uint8) (~(1 << (i % BYTE_SIZE)));
- }
- }
- if (result_count == 0) /* Clear send key when no entry found */
- {
- ClearKeyHandler(KEY_SEND, KEY_EVENT_UP);
- #if defined(__MMI_INTELLIGENT_CALL_ALERT__)
- StopTimer(PHB_LIST_SPEAK_NAME_TIMER);
- if (g_phb_is_speaking_name)
- {