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

MTK

开发平台:

C/C++

  1.                     {
  2.                         CharInfo = pCharInfoBuffer[i] - ZI8_BASE_PINYIN + 0x0061;
  3.                         memcpy(output_string + out, &CharInfo, 2);
  4.                         out = out + 2;
  5.                         i = i + 1;
  6.                     }
  7.                     break;
  8.                 case INPUT_MODE_MMI_SM_STROKE:
  9.                 case INPUT_MODE_MMI_TR_STROKE:
  10.                     while ((pCharInfoBuffer[i] != 0x0000) && (i <= 7))
  11.                     {
  12.                         memcpy(output_string + out, &pCharInfoBuffer[i], 2);
  13.                         out = out + 2;
  14.                         i = i + 1;
  15.                     }
  16.                     break;
  17.                 default:
  18.                     break;
  19.             }
  20.             *out_len = i;
  21.             return TRUE;
  22.         }
  23.         memcpy(output_string, input_string, 2);
  24.         *out_len = 1;
  25.         return TRUE;
  26.     }
  27.     *out_len = 0;
  28.     return FALSE;
  29. }
  30. /*****************************************************************************
  31.  * FUNCTION
  32.  *  mmi_phb_generic_quick_search_convert_cache
  33.  * DESCRIPTION
  34.  *  This function convert first character of name field into cache.
  35.  * PARAMETERS
  36.  *  index       [IN]        Phonebook entry index
  37.  * RETURNS
  38.  *  void
  39.  *****************************************************************************/
  40. void mmi_phb_generic_quick_search_convert_cache(U16 index)
  41. {
  42.     /*----------------------------------------------------------------*/
  43.     /* Local Variables                                                */
  44.     /*----------------------------------------------------------------*/
  45.     U16 code;
  46.     U16 mode;
  47.     U16 pCharInfoBuffer[MMI_PHB_CONVERT_BUFF_ZI];
  48.     /*----------------------------------------------------------------*/
  49.     /* Code Body                                                      */
  50.     /*----------------------------------------------------------------*/
  51.     memcpy(&code, PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  52.     /* Change to proper input method. */
  53.     switch (MMI_current_input_mode)
  54.     {
  55.         case INPUT_MODE_MMI_MULTITAP_BPMF:
  56.             mode = ZI8_GETMODE_BOPOMOFO;
  57.             break;
  58.         case INPUT_MODE_MMI_MULTITAP_PINYIN:
  59.             mode = ZI8_GETMODE_PINYIN;
  60.             break;
  61.         case INPUT_MODE_MMI_SM_STROKE:
  62.         case INPUT_MODE_MMI_TR_STROKE:
  63.             mode = ZI8_GETMODE_STROKES;
  64.             break;
  65.         default:
  66.             memcpy(&g_phb_generic_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  67.             return;
  68.     }
  69.     /* Begin to convert and store the result according to the input method. */
  70.     if ((code >= 0x4e00) && (code <= 0x9fa5) &&
  71.         Zi8GetCharInfo(code, (U16*) pCharInfoBuffer, MMI_PHB_CONVERT_BUFF_ZI, mode))
  72.     {
  73.         switch (MMI_current_input_mode)
  74.         {
  75.             case INPUT_MODE_MMI_MULTITAP_BPMF:
  76.                 g_phb_generic_qsearch_cache[index] = pCharInfoBuffer[0] - ZI8_BASE_BPMF + 0x3105;
  77.                 break;
  78.             case INPUT_MODE_MMI_MULTITAP_PINYIN:
  79.                 g_phb_generic_qsearch_cache[index] = pCharInfoBuffer[0] - ZI8_BASE_PINYIN + 0x0061;
  80.                 break;
  81.             case INPUT_MODE_MMI_SM_STROKE:
  82.             case INPUT_MODE_MMI_TR_STROKE:
  83.                 g_phb_generic_qsearch_cache[index] = pCharInfoBuffer[0];
  84.                 break;
  85.             default:
  86.                 memcpy(&g_phb_generic_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  87.                 break;
  88.         }
  89.     }
  90.     else
  91.     {
  92.         memcpy(&g_phb_generic_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  93.     }
  94. }
  95. //KP Jerry add on 2007-3-21 start
  96. #elif defined(__MMI_CSTAR__)
  97. BOOL mmi_phb_generic_quick_search_convert_to_spelling(U8* input_string, U8* output_string, U8* out_len) 
  98. {
  99.     int c;
  100.     int mode;
  101.     U16 code;
  102.     U16 buf[16];
  103.     mode = MMI_current_input_mode;
  104. switch (mode)
  105. {
  106. case INPUT_MODE_MMI_MULTITAP_BPMF:
  107. case INPUT_MODE_MMI_MULTITAP_PINYIN:
  108. case INPUT_MODE_MMI_SM_STROKE:
  109. case INPUT_MODE_MMI_TR_STROKE:         
  110.         break;
  111. default:
  112.             *out_len = 0;
  113. return FALSE;
  114. }
  115.     if ( (input_string[0] == 0) && (input_string[1] == 0) )
  116.     {
  117.         *out_len = 0;
  118. return FALSE;
  119.     }
  120.     memcpy(&code, input_string, 2);
  121.     c = CstarQueryCharInfo(code, buf, 16, mode);
  122.     if (c <= 0)
  123.     {
  124.         memcpy(output_string, input_string, 2);
  125.         *out_len = 1;
  126.         return TRUE;
  127.     }
  128.     if (c > 7)
  129.         c = 7;
  130.     memcpy(output_string, buf, sizeof(U16) * c);
  131.     *out_len = (U8)c;
  132.     return TRUE;
  133. }
  134. void mmi_phb_generic_quick_search_convert_cache(U16 index)
  135. {
  136.     int c;
  137.     int mode;
  138.     U16 code;
  139.     U16 buf[16];
  140.     mode = MMI_current_input_mode;
  141. switch (mode)
  142.     {   
  143.         case INPUT_MODE_MMI_MULTITAP_BPMF:
  144.         case INPUT_MODE_MMI_MULTITAP_PINYIN:
  145.         case INPUT_MODE_MMI_SM_STROKE:
  146.         case INPUT_MODE_MMI_TR_STROKE:                              
  147.             break;
  148.         default:
  149.             memcpy(&g_phb_generic_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  150.             return;
  151.     }
  152.     memcpy(&code, PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  153.     c = CstarQueryCharInfo(code, buf, 16, mode);
  154.     if (c <= 0)
  155.     {
  156.         memcpy(&g_phb_generic_qsearch_cache[index], PhoneBook[g_phb_name_index[index]].alpha_id.name, 2);
  157.         return;
  158.     }
  159.     g_phb_generic_qsearch_cache[index] = buf[0];
  160. }
  161. //KP Jerry add on 2007-3-21 end
  162. #elif defined(__MMI_ITAP__)
  163. /* under construction !*/
  164. /* under construction !*/
  165. /* under construction !*/
  166. /* under construction !*/
  167. /* under construction !*/
  168. /* under construction !*/
  169. /* under construction !*/
  170. /* under construction !*/
  171. /* under construction !*/
  172. /* under construction !*/
  173. /* under construction !*/
  174. /* under construction !*/
  175. /* under construction !*/
  176. /* under construction !*/
  177. /* under construction !*/
  178. /* under construction !*/
  179. /* under construction !*/
  180. /* under construction !*/
  181. /* under construction !*/
  182. /* under construction !*/
  183. /* under construction !*/
  184. /* under construction !*/
  185. /* under construction !*/
  186. /* under construction !*/
  187. /* under construction !*/
  188. /* under construction !*/
  189. /* under construction !*/
  190. /* under construction !*/
  191. /* under construction !*/
  192. /* under construction !*/
  193. /* under construction !*/
  194. /* under construction !*/
  195. /* under construction !*/
  196. /* under construction !*/
  197. /* under construction !*/
  198. /* under construction !*/
  199. /* under construction !*/
  200. /* under construction !*/
  201. /* under construction !*/
  202. /* under construction !*/
  203. /* under construction !*/
  204. /* under construction !*/
  205. /* under construction !*/
  206. /* under construction !*/
  207. /* under construction !*/
  208. /* under construction !*/
  209. /* under construction !*/
  210. /* under construction !*/
  211. /* under construction !*/
  212. /* under construction !*/
  213. /* under construction !*/
  214. /* under construction !*/
  215. /* under construction !*/
  216. /* under construction !*/
  217. /* under construction !*/
  218. /* under construction !*/
  219. /* under construction !*/
  220. /* under construction !*/
  221. /* under construction !*/
  222. /* under construction !*/
  223. /* under construction !*/
  224. /* under construction !*/
  225. /* under construction !*/
  226. /* under construction !*/
  227. /* under construction !*/
  228. /* under construction !*/
  229. /* under construction !*/
  230. /* under construction !*/
  231. /* under construction !*/
  232. /* under construction !*/
  233. /* under construction !*/
  234. /* under construction !*/
  235. /* under construction !*/
  236. /* under construction !*/
  237. /* under construction !*/
  238. /* under construction !*/
  239. /* under construction !*/
  240. /* under construction !*/
  241. /* under construction !*/
  242. /* under construction !*/
  243. /* under construction !*/
  244. /* under construction !*/
  245. /* under construction !*/
  246. /* under construction !*/
  247. /* under construction !*/
  248. /* under construction !*/
  249. /* under construction !*/
  250. /* under construction !*/
  251. /* under construction !*/
  252. /* under construction !*/
  253. /* under construction !*/
  254. /* under construction !*/
  255. /* under construction !*/
  256. /* under construction !*/
  257. /* under construction !*/
  258. /* under construction !*/
  259. /* under construction !*/
  260. /* under construction !*/
  261. /* under construction !*/
  262. /* under construction !*/
  263. /* under construction !*/
  264. /* under construction !*/
  265. /* under construction !*/
  266. /* under construction !*/
  267. /* under construction !*/
  268. /* under construction !*/
  269. /* under construction !*/
  270. /* under construction !*/
  271. /* under construction !*/
  272. /* under construction !*/
  273. /* under construction !*/
  274. /* under construction !*/
  275. /* under construction !*/
  276. /* under construction !*/
  277. /* under construction !*/
  278. /* under construction !*/
  279. /* under construction !*/
  280. /* under construction !*/
  281. /* under construction !*/
  282. /* under construction !*/
  283. /* under construction !*/
  284. /* under construction !*/
  285. /* under construction !*/
  286. /* under construction !*/
  287. /* under construction !*/
  288. /* under construction !*/
  289. /* under construction !*/
  290. /* under construction !*/
  291. /* under construction !*/
  292. /* under construction !*/
  293. /* under construction !*/
  294. /* under construction !*/
  295. /* under construction !*/
  296. /* under construction !*/
  297. /* under construction !*/
  298. /* under construction !*/
  299. /* under construction !*/
  300. /* under construction !*/
  301. /* under construction !*/
  302. /* under construction !*/
  303. /* under construction !*/
  304. /* under construction !*/
  305. /* under construction !*/
  306. /* under construction !*/
  307. /* under construction !*/
  308. /* under construction !*/
  309. /* under construction !*/
  310. /* under construction !*/
  311. /* under construction !*/
  312. /* under construction !*/
  313. /* under construction !*/
  314. /* under construction !*/
  315. /* under construction !*/
  316. /* under construction !*/
  317. /* under construction !*/
  318. /* under construction !*/
  319. /* under construction !*/
  320. /* under construction !*/
  321. /* under construction !*/
  322. /* under construction !*/
  323. /* under construction !*/
  324. /* under construction !*/
  325. /* under construction !*/
  326. /* under construction !*/
  327. /* under construction !*/
  328. /* under construction !*/
  329. /* under construction !*/
  330. /* under construction !*/
  331. /* under construction !*/
  332. /* under construction !*/
  333. /* under construction !*/
  334. /* under construction !*/
  335. /* under construction !*/
  336. /* under construction !*/
  337. /* under construction !*/
  338. /* under construction !*/
  339. /* under construction !*/
  340. /* under construction !*/
  341. /* under construction !*/
  342. /* under construction !*/
  343. /* under construction !*/
  344. /* under construction !*/
  345. /* under construction !*/
  346. /* under construction !*/
  347. /* under construction !*/
  348. /* under construction !*/
  349. /* under construction !*/
  350. /* under construction !*/
  351. /* under construction !*/
  352. /* under construction !*/
  353. /* under construction !*/
  354. /* under construction !*/
  355. /* under construction !*/
  356. /* under construction !*/
  357. /* under construction !*/
  358. /* under construction !*/
  359. /* under construction !*/
  360. /* under construction !*/
  361. /* under construction !*/
  362. /* under construction !*/
  363. /* under construction !*/
  364. /* under construction !*/
  365. /* under construction !*/
  366. /* under construction !*/
  367. /* under construction !*/
  368. /* under construction !*/
  369. /* under construction !*/
  370. /* under construction !*/
  371. /* under construction !*/
  372. /* under construction !*/
  373. /* under construction !*/
  374. /* under construction !*/
  375. /* under construction !*/
  376. /* under construction !*/
  377. /* under construction !*/
  378. /* under construction !*/
  379. /* under construction !*/
  380. /* under construction !*/
  381. #else /* No default input method library */
  382. /*****************************************************************************
  383.  * FUNCTION
  384.  *  mmi_phb_generic_quick_search_convert_to_spelling
  385.  * DESCRIPTION
  386.  *  This function is just for template.
  387.  * PARAMETERS
  388.  *  input_string        [?]             
  389.  *  output_string       [?]             
  390.  *  out_len             [?]             
  391.  *  a(?)                [IN/OUT]        First variable, used as returns
  392.  *  b(?)                [IN]            Second variable
  393.  * RETURNS
  394.  *  the description of return value, if any.
  395.  *****************************************************************************/
  396. BOOL mmi_phb_generic_quick_search_convert_to_spelling(U8 *input_string, U8 *output_string, U8 *out_len)
  397. {
  398.     /*----------------------------------------------------------------*/
  399.     /* Local Variables                                                */
  400.     /*----------------------------------------------------------------*/
  401.     /*----------------------------------------------------------------*/
  402.     /* Code Body                                                      */
  403.     /*----------------------------------------------------------------*/
  404.     memcpy(output_string, input_string, 2);
  405.     *out_len = 1;
  406.     return TRUE;
  407. }
  408. /*****************************************************************************
  409.  * FUNCTION
  410.  *  mmi_phb_generic_quick_search_convert_cache
  411.  * DESCRIPTION
  412.  *  This function convert first character of name field into cache.
  413.  * PARAMETERS
  414.  *  index       [IN]        Phonebook entry index
  415.  * RETURNS
  416.  *  void
  417.  *****************************************************************************/
  418. void mmi_phb_generic_quick_search_convert_cache(U16 index)
  419. {
  420.     /*----------------------------------------------------------------*/
  421.     /* Local Variables                                                */
  422.     /*----------------------------------------------------------------*/
  423.     /*----------------------------------------------------------------*/
  424.     /* Code Body                                                      */
  425.     /*----------------------------------------------------------------*/
  426.     g_phb_generic_qsearch_cache[index] = (U16) PhoneBook[g_phb_name_index[index]].alpha_id.name[0];
  427. }
  428. #endif 
  429. /*****************************************************************************
  430.  * FUNCTION
  431.  *  mmi_phb_generic_quick_search_make_cache
  432.  * DESCRIPTION
  433.  *  
  434.  * PARAMETERS
  435.  *  void
  436.  * RETURNS
  437.  *  void
  438.  *****************************************************************************/
  439. void mmi_phb_generic_quick_search_make_cache(void)
  440. {
  441.     /*----------------------------------------------------------------*/
  442.     /* Local Variables                                                */
  443.     /*----------------------------------------------------------------*/
  444.     U16 index;
  445.     U16 pre_store_index;
  446.     U16 store_index;
  447.     /*----------------------------------------------------------------*/
  448.     /* Code Body                                                      */
  449.     /*----------------------------------------------------------------*/
  450. #if defined(__MMI_T9__)
  451.     /* Switch to the proper input language, only for T9 */
  452.     switch (MMI_current_input_mode)
  453.     {
  454.     #if defined(__MMI_T9_TR_CHINESE__)
  455.         case INPUT_MODE_MMI_MULTITAP_BPMF:
  456.             T9ChangeLanguageToTRChineseBoPoMo();
  457.             break;
  458.         case INPUT_MODE_MMI_TR_STROKE:
  459.             T9ChangeLanguageToTRChineseStroke();
  460.             break;
  461.     #endif /* defined(__MMI_T9_TR_CHINESE__) */ 
  462.     #if defined(__MMI_T9_SM_CHINESE__)
  463.         case INPUT_MODE_MMI_MULTITAP_PINYIN:
  464.             T9ChangeLanguageToSMChinesePinYin();
  465.             break;
  466.         case INPUT_MODE_MMI_SM_STROKE:
  467.             T9ChangeLanguageToSMChineseStroke();
  468.             break;
  469.     #endif /* defined(__MMI_T9_SM_CHINESE__) */ 
  470.         default:
  471.             break;
  472.     }
  473. #endif /* defined(__MMI_T9__) */ 
  474.     /* Begin to convert first character of name field to associated input method string. */
  475.     for (index = 0; index < PhoneBookEntryCount; index++)
  476.     {
  477.         store_index = g_phb_name_index[index];
  478.         if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) > 0)
  479.         {
  480.             /* The Entry Name is an UCS2 string */
  481.             if (PhoneBook[store_index].alpha_id.name_dcs == PHB_UCS2)
  482.             {
  483.                 if (index != 0)
  484.                 {
  485.                     pre_store_index = g_phb_name_index[index - 1];
  486.                     /* If character is the same, do not convert again. */
  487.                     if ((PhoneBook[pre_store_index].alpha_id.name[0] == PhoneBook[store_index].alpha_id.name[0]) &&
  488.                         (PhoneBook[pre_store_index].alpha_id.name[1] == PhoneBook[store_index].alpha_id.name[1]))
  489.                     {
  490.                         g_phb_generic_qsearch_cache[index] = g_phb_generic_qsearch_cache[index - 1];
  491.                         continue;
  492.                     }
  493.                 }
  494.                 mmi_phb_generic_quick_search_convert_cache(index);
  495.             }
  496.             else
  497.                 /* This is an ASCII string */
  498.             {
  499.                 g_phb_generic_qsearch_cache[index] = (U16) PhoneBook[store_index].alpha_id.name[0];
  500.             }
  501.         }
  502.         /* The name field is Empty */
  503.         else
  504.         {
  505.             g_phb_generic_qsearch_cache[index] = 0x0000;
  506.         }
  507.     }
  508.     g_phb_generic_qsearch_is_cache = 1; /* Convert cache done */
  509. }
  510. /*****************************************************************************
  511.  * FUNCTION
  512.  *  mmi_phb_generic_quick_search_find_entry
  513.  * DESCRIPTION
  514.  *  
  515.  * PARAMETERS
  516.  *  keyword     [?]     
  517.  * RETURNS
  518.  *  
  519.  *****************************************************************************/
  520. S32 mmi_phb_generic_quick_search_find_entry(U8 *keyword)
  521. {
  522.     /*----------------------------------------------------------------*/
  523.     /* Local Variables                                                */
  524.     /*----------------------------------------------------------------*/
  525.     U8 key_length;
  526.     U8 flag;
  527.     U16 i;
  528.     U16 code1, code2;
  529.     U16 result_count;
  530.     U8 same_count;
  531.     U8 convert_result;
  532.     S32 distance;
  533.     S8 *string1, *string2 = NULL;
  534.     S8 convert_string[22 * ENCODING_LENGTH];    /* 7*3 + 1 => (char1 + char2 + char3 + Null Terminator) */
  535.     U8 char1[7 * ENCODING_LENGTH];              /* Cache 1st character convert result */
  536.     U8 char2[7 * ENCODING_LENGTH];              /* Cache 2nd character convert result */
  537.     U8 char3[7 * ENCODING_LENGTH];              /* Cache 3rd character convert result */
  538.     U8 len1, len2, len3;
  539.     U16 store_index;
  540.     U8 prev_ucs2 = 0;                           /* Is previous record ucs2 encoding */
  541.     /*----------------------------------------------------------------*/
  542.     /* Code Body                                                      */
  543.     /*----------------------------------------------------------------*/
  544.     /* Check if cache already build up before using */
  545.     if (!g_phb_generic_qsearch_is_cache)
  546.     {
  547.         StopTimer(PHB_QUICK_SEARCH_TIMER);
  548.         mmi_phb_generic_quick_search_make_cache();
  549.     }
  550.     /* Count the input string length to decide behavior */
  551.     key_length = (U8) pfnUnicodeStrlen((S8*) keyword);
  552.     result_count = 0;
  553.     /* For each entry, check if it is in the quick search sub-list */
  554.     for (i = 0; i < PhoneBookEntryCount; i++)
  555.     {
  556.         flag = FALSE;
  557.         store_index = g_phb_name_index[i];
  558.         /*
  559.          * search length == 1, compare whole list with first character only.
  560.          */
  561.         if (key_length == 1)
  562.         {
  563.             code1 = (U16) g_phb_generic_qsearch_cache[i];
  564.             memcpy(&code2, keyword, 2);
  565.             if (mmi_phb_compare_chars(code1, code2) == 0)
  566.             {
  567.                 flag = TRUE;
  568.             }
  569.         }
  570.         /*
  571.          * search length > 1, compare subset list with maximum search character.
  572.          */
  573.         else if (key_length > 1)
  574.         {
  575.             code1 = (U16) g_phb_generic_qsearch_cache[i];
  576.             memcpy(&code2, keyword, 2);
  577.             /* Compare character in cache first. If match, compare the rest part. */
  578.             if (mmi_phb_compare_chars(code1, code2) == 0)
  579.             {
  580.                 //store_index = g_phb_name_index[i];
  581.                 flag = FALSE;
  582.                 if (PhoneBook[store_index].alpha_id.name_dcs == MMI_PHB_UCS2)
  583.                 {
  584.                     /* Use previous record convert result as cache */
  585.                     if (i != 0)
  586.                     {
  587.                         string2 = (S8*) PhoneBook[g_phb_name_index[i - 1]].alpha_id.name;
  588.                     }
  589.                     /* Current record */
  590.                     string1 = (S8*) PhoneBook[store_index].alpha_id.name;
  591.                     /*
  592.                      *  Convert 1st character
  593.                      */
  594.                     if ((i != 0) && (string2[0] == string1[0]) && (string2[1] == string1[1]) && prev_ucs2)
  595.                     {
  596.                         convert_result = 10;    /* Use 10 to represent that first character is the same as previous one */
  597.                     }
  598.                     else
  599.                     {
  600.                         U16 code;
  601.                         memcpy(&code, &PhoneBook[store_index].alpha_id.name[0], 2);
  602.                         if ((code >= 0x4e00) && (code <= 0x9fa5))
  603.                         {
  604.                             convert_result = mmi_phb_generic_quick_search_convert_to_spelling(
  605.                                                 &PhoneBook[store_index].alpha_id.name[0],
  606.                                                 char1,
  607.                                                 &len1);
  608.                         }
  609.                         else
  610.                         {
  611.                             convert_result = FALSE;
  612.                         }
  613.                     }
  614.                     if (convert_result)
  615.                     {
  616.                         memset(convert_string, 0, 22 * ENCODING_LENGTH);        /* Clear String in advance, to make sure there will be terminator */
  617.                         len1 = (len1 > 7) ? 7 : len1;
  618.                         memcpy(convert_string, char1, (len1 * ENCODING_LENGTH));
  619.                         /*
  620.                          *  Convert 2nd Character
  621.                          */
  622.                         if (len1 < key_length)
  623.                         {
  624.                             if ((convert_result == 10) && (string2[2] == string1[2]) && (string2[3] == string1[3]) &&
  625.                                 prev_ucs2)
  626.                             {
  627.                                 convert_result = 20;    /* Use 20 to represent that second character is the same as previous one */
  628.                             }
  629.                             else
  630.                             {
  631.                                 convert_result = mmi_phb_generic_quick_search_convert_to_spelling(
  632.                                                     &PhoneBook[store_index].alpha_id.name[2],
  633.                                                     char2,
  634.                                                     &len2);
  635.                             }
  636.                             if (convert_result)
  637.                             {
  638.                                 len2 = (len2 > 7) ? 7 : len2;
  639.                                 memcpy((convert_string + len1 * ENCODING_LENGTH), char2, (len2 * ENCODING_LENGTH));
  640.                                 /*
  641.                                  *  Convert 3rd Character
  642.                                  */
  643.                                 if ((len1 + len2) < key_length)
  644.                                 {
  645.                                     if ((convert_result == 20) && (string2[4] == string1[4]) &&
  646.                                         (string2[5] == string1[5]) && prev_ucs2)
  647.                                     {
  648.                                         convert_result = 30;    /* Use 30 to represent that third character is the same as previous one */
  649.                                     }
  650.                                     else
  651.                                     {
  652.                                         convert_result = mmi_phb_generic_quick_search_convert_to_spelling(
  653.                                                             &PhoneBook[store_index].alpha_id. name[4],
  654.                                                             char3,
  655.                                                             &len3);
  656.                                     }
  657.                                     if (convert_result)
  658.                                     {
  659.                                         len3 = (len3 > 7) ? 7 : len3;
  660.                                         memcpy(
  661.                                             (convert_string + (len1 + len2) * ENCODING_LENGTH),
  662.                                             char3,
  663.                                             (len3 * ENCODING_LENGTH));
  664.                                     }
  665.                                     else
  666.                                     {
  667.                                         memcpy(
  668.                                             (convert_string + len1 * ENCODING_LENGTH),
  669.                                             &PhoneBook[store_index].alpha_id.name[4],
  670.                                             2);
  671.                                     }
  672.                                 }
  673.                             }
  674.                             else
  675.                             {
  676.                                 memcpy(
  677.                                     (convert_string + len1 * ENCODING_LENGTH),
  678.                                     &PhoneBook[store_index].alpha_id.name[2],
  679.                                     2);
  680.                             }
  681.                         }
  682.                         /* Chinese convert successfully, use convert result to compare */
  683.                         string1 = convert_string;
  684.                         prev_ucs2 = 1;
  685.                     }
  686.                     else    /* Not Chinese */
  687.                     {
  688.                         string1 = (S8*) PhoneBook[store_index].alpha_id.name;
  689.                         prev_ucs2 = 0;
  690.                     }
  691.                 }
  692.                 else    /* ASCII */
  693.                 {
  694.                     string1 = (S8*) PhoneBook[store_index].alpha_id.name;
  695.                     prev_ucs2 = 0;
  696.                 }
  697.                 mmi_phb_compare_ucs2_strings((S8*) string1, (S8*) keyword, &same_count, &distance);
  698.                 if (same_count == key_length)
  699.                 {
  700.                     flag = TRUE;
  701.                 }
  702.             }
  703.         }
  704.         /*
  705.          *search length == 0, display whole list.
  706.          */
  707.         else
  708.         {
  709.             flag = TRUE;
  710.         }    
  711.         /* Add to list if entry is a subset of a quick search result */
  712.         if (flag)
  713.         {
  714.             /* g_phb_qsearch[i] = 1; */
  715.             g_phb_generic_qsearch_bitmask[i >> BYTE_SIZE_SHIFT_ARITHMETIC] |= 1 << (i % BYTE_SIZE);
  716.             if (PhoneBook[store_index].field & 0x1E)
  717.             {
  718.                 result_count++;
  719.             }
  720.         }
  721.         else
  722.         {
  723.             /* g_phb_qsearch[i] = 0; */
  724.             g_phb_generic_qsearch_bitmask[i >> BYTE_SIZE_SHIFT_ARITHMETIC] &= (kal_uint8) (~(1 << (i % BYTE_SIZE)));
  725.         }
  726.     }
  727.     if (result_count == 0)  /* Clear send key when no entry found */
  728.     {
  729.         ClearKeyHandler(KEY_SEND, KEY_EVENT_UP);
  730.     }
  731.     return result_count;
  732. }
  733. /*****************************************************************************
  734.  * FUNCTION
  735.  *  mmi_phb_generic_filter_list_get_item
  736.  * DESCRIPTION
  737.  *  
  738.  * PARAMETERS
  739.  *  item_index          [IN]        
  740.  *  str_buff            [IN]        
  741.  *  img_buff_p          [?]         
  742.  *  str_img_mask        [IN]        
  743.  * RETURNS
  744.  *  
  745.  *****************************************************************************/
  746. pBOOL mmi_phb_generic_filter_list_get_item(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  747. {
  748.     /*----------------------------------------------------------------*/
  749.     /* Local Variables                                                */
  750.     /*----------------------------------------------------------------*/
  751.     U16 store_index = 0;
  752.     S32 i = -1;
  753.     S32 inner_index = 0;
  754.     
  755.     /*----------------------------------------------------------------*/
  756.     /* Code Body                                                      */
  757.     /*----------------------------------------------------------------*/   
  758. while (i < item_index)
  759. {
  760. store_index = g_phb_name_index[inner_index];
  761.         if (g_phb_generic_qsearch_bitmask[inner_index >> BYTE_SIZE_SHIFT_ARITHMETIC] & (1 << (inner_index % BYTE_SIZE)))
  762.         {
  763.             if (PhoneBook[store_index].field & 0x1E)
  764.             {
  765.                 i++;  
  766.             }
  767.         }
  768. inner_index++;
  769. }
  770.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name))
  771.     {
  772.         pfnUnicodeStrcpy((S8*) str_buff, (S8*) PhoneBook[store_index].alpha_id.name);
  773.     }
  774.     else
  775.     {
  776.         mmi_phb_convert_get_ucs2_number((S8*) str_buff, store_index);
  777.     }
  778.     if (store_index >= MAX_PB_PHONE_ENTRIES)
  779.     {
  780.         *img_buff_p = get_image(IMG_STORAGE_SIM);
  781.     }
  782.     else
  783.     {
  784.         *img_buff_p = get_image(IMG_STORAGE_HANDSET);
  785.     }
  786.     return TRUE;
  787. }
  788. /*****************************************************************************
  789.  * FUNCTION
  790.  *  mmi_phb_generic_filter_list_get_hint
  791.  * DESCRIPTION
  792.  *  
  793.  * PARAMETERS
  794.  *  item_index      [IN]        
  795.  *  hint_array      [?]         
  796.  * RETURNS
  797.  *  
  798.  *****************************************************************************/
  799. S32 mmi_phb_generic_filter_list_get_hint(S32 item_index, UI_string_type *hint_array)
  800. {
  801.     /*----------------------------------------------------------------*/
  802.     /* Local Variables                                                */
  803.     /*----------------------------------------------------------------*/
  804.     U16 store_index = 0;
  805.     S8 temp_number[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
  806.     S32 i = -1;
  807.     S32 inner_index = 0;
  808.     /*----------------------------------------------------------------*/
  809.     /* Code Body                                                      */
  810.     /*----------------------------------------------------------------*/
  811.     while (i < item_index)
  812.     {
  813.         store_index = g_phb_name_index[inner_index];
  814.         if (g_phb_generic_qsearch_bitmask[inner_index >> BYTE_SIZE_SHIFT_ARITHMETIC] & (1 << (inner_index % BYTE_SIZE)))
  815.         {
  816.             if (PhoneBook[store_index].field & 0x1E)
  817.             {
  818.                 i++;  
  819.             }
  820.         }
  821. inner_index++;
  822. }
  823.     mmi_phb_convert_get_ucs2_number((S8*) temp_number, store_index);
  824.     if (pfnUnicodeStrlen((S8*) PhoneBook[store_index].alpha_id.name) && pfnUnicodeStrlen((S8*) temp_number))
  825.     {
  826.         pfnUnicodeStrcpy((S8*) hint_array[0], (S8*) temp_number);
  827.     }
  828.     else
  829.     {
  830.         return 0;
  831.     }
  832.     return 1;   /* One hint data only, can be more hints. */
  833. }
  834. /*****************************************************************************
  835.  * FUNCTION
  836.  *  mmi_phb_generic_quick_search_change_input_mode
  837.  * DESCRIPTION
  838.  *  
  839.  * PARAMETERS
  840.  *  void
  841.  * RETURNS
  842.  *  void
  843.  *****************************************************************************/
  844. void mmi_phb_generic_quick_search_change_input_mode(void)
  845. {
  846.     /*----------------------------------------------------------------*/
  847.     /* Local Variables                                                */
  848.     /*----------------------------------------------------------------*/
  849.     /*----------------------------------------------------------------*/
  850.     /* Code Body                                                      */
  851.     /*----------------------------------------------------------------*/
  852.     // memset(g_phb_qsearch,1,MAX_PB_ENTRIES);  /*All records are in the subset at the beginning*/
  853.     memset(g_phb_generic_qsearch_bitmask, 0xff, (MAX_PB_ENTRIES + 7) / 8);
  854.     g_phb_generic_qsearch_is_cache = 0;
  855.     /*
  856.      * Make cache according to the current input method.
  857.      * Start a timer to avoid convert cache each time when user change input method quickly.
  858.      */
  859.     StopTimer(PHB_QUICK_SEARCH_TIMER);
  860.     StartTimer(PHB_QUICK_SEARCH_TIMER, 500, mmi_phb_generic_quick_search_make_cache);
  861. }
  862. /*****************************************************************************
  863.  * FUNCTION
  864.  *  mmi_phb_get_index_by_store_location_fourth
  865.  * DESCRIPTION
  866.  *  call back function for dynamic list to get index according to the fileter list.
  867.  * PARAMETERS
  868.  *  nIndex      [IN]        Highlight index position
  869.  * RETURNS
  870.  *  void
  871.  *****************************************************************************/
  872. void mmi_phb_get_index_by_store_location_fourth(S32 nIndex)
  873. {
  874.     /*----------------------------------------------------------------*/
  875.     /* Local Variables                                                */
  876.     /*----------------------------------------------------------------*/
  877.     U16 store_index = 0;
  878.     S32 i = -1;
  879.     S32 inner_index = 0;
  880.     /*----------------------------------------------------------------*/
  881.     /* Code Body                                                      */
  882.     /*----------------------------------------------------------------*/
  883.     while (i < nIndex)
  884.     {
  885.         store_index = g_phb_name_index[inner_index];
  886.         if (g_phb_generic_qsearch_bitmask[inner_index >> BYTE_SIZE_SHIFT_ARITHMETIC] & (1 << (inner_index % BYTE_SIZE)))
  887.         {
  888.             if (PhoneBook[store_index].field & 0x1E)
  889.             {
  890.                 i++;  
  891.             }
  892.         }
  893. inner_index++;
  894. }
  895.     g_phb_cntx.active_index_fourth = store_index;
  896. }
  897. #if defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__)
  898. extern void EntryQuickSearchInputMethodScreen(void);
  899. /*****************************************************************************
  900.  * FUNCTION
  901.  *  mmi_phb_generic_quick_search_go_back_editor
  902.  * DESCRIPTION
  903.  *  Go back screen after change input method.
  904.  * PARAMETERS
  905.  *  void
  906.  * RETURNS
  907.  *  void
  908.  *****************************************************************************/
  909. void mmi_phb_generic_quick_search_go_back_editor(void)
  910. {
  911.     /*----------------------------------------------------------------*/
  912.     /* Local Variables                                                */
  913.     /*----------------------------------------------------------------*/
  914.     /*----------------------------------------------------------------*/
  915.     /* Code Body                                                      */
  916.     /*----------------------------------------------------------------*/
  917.     GoBackToHistory(SCR_PBOOK_LIST);
  918. }
  919. /*****************************************************************************
  920.  * FUNCTION
  921.  *  mmi_phb_generic_highlight_quick_search_input_method
  922.  * DESCRIPTION
  923.  *  Highlight function to enter change input method
  924.  * PARAMETERS
  925.  *  void
  926.  * RETURNS
  927.  *  void
  928.  *****************************************************************************/
  929. void mmi_phb_generic_highlight_quick_search_input_method(void)
  930. {
  931.     /*----------------------------------------------------------------*/
  932.     /* Local Variables                                                */
  933.     /*----------------------------------------------------------------*/
  934.     /*----------------------------------------------------------------*/
  935.     /* Code Body                                                      */
  936.     /*----------------------------------------------------------------*/
  937.     SetLeftSoftkeyFunction(EntryQuickSearchInputMethodScreen, KEY_EVENT_UP);
  938.     SetKeyHandler(EntryQuickSearchInputMethodScreen, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  939.     RegisterInputMethodScreenCloseFunction(mmi_phb_generic_quick_search_go_back_editor);
  940. }
  941. /*****************************************************************************
  942.  * FUNCTION
  943.  *  mmi_phb_generic_highlight_quick_search_op_option
  944.  * DESCRIPTION
  945.  *  Highlight function to enter entry option.
  946.  * PARAMETERS
  947.  *  void
  948.  * RETURNS
  949.  *  void
  950.  *****************************************************************************/
  951. void mmi_phb_generic_highlight_quick_search_done(void)
  952. {
  953.     /*----------------------------------------------------------------*/
  954.     /* Local Variables                                                */
  955.     /*----------------------------------------------------------------*/
  956.     /*----------------------------------------------------------------*/
  957.     /* Code Body                                                      */
  958.     /*----------------------------------------------------------------*/
  959.     SetLeftSoftkeyFunction(mmi_phb_entry_sms_choose_number, KEY_EVENT_UP);
  960.     SetKeyHandler(mmi_phb_entry_sms_choose_number, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  961. }
  962. /*****************************************************************************
  963.  * FUNCTION
  964.  *  mmi_phb_generic_entry_quick_search_option
  965.  * DESCRIPTION
  966.  *  
  967.  * PARAMETERS
  968.  *  void
  969.  * RETURNS
  970.  *  void
  971.  *****************************************************************************/
  972. void mmi_phb_generic_entry_quick_search_option(void)
  973. {
  974.     /*----------------------------------------------------------------*/
  975.     /* Local Variables                                                */
  976.     /*----------------------------------------------------------------*/
  977.     U16 nStrItemList[10];
  978.     U8 *guiBuffer;
  979.     U16 nNumofItem;
  980.     /*----------------------------------------------------------------*/
  981.     /* Code Body                                                      */
  982.     /*----------------------------------------------------------------*/
  983.     EntryNewScreen(SCR_ID_PHB_SMS_QUICK_SEARCH_OPTIONS, NULL, mmi_phb_generic_entry_quick_search_option, NULL);
  984.     guiBuffer = GetCurrGuiBuffer(SCR_ID_PHB_SMS_QUICK_SEARCH_OPTIONS);
  985.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  986.     nNumofItem = GetNumOfChild(MENU_ID_PHB_SMS_QUICK_SEARCH_OPTION);
  987.     GetSequenceStringIds(MENU_ID_PHB_SMS_QUICK_SEARCH_OPTION, nStrItemList);
  988.     SetParentHandler(MENU_ID_PHB_SMS_QUICK_SEARCH_OPTION);
  989.     ShowCategory15Screen(
  990.         STR_GLOBAL_OPTIONS,
  991.         IMG_SCR_PBOOK_CAPTION,
  992.         STR_GLOBAL_OK,
  993.         IMG_GLOBAL_OK,
  994.         STR_GLOBAL_BACK,
  995.         IMG_GLOBAL_BACK,
  996.         nNumofItem,
  997.         nStrItemList,
  998.         (U16*) gIndexIconsImageList,
  999.         LIST_MENU,
  1000.         //1,
  1001.         0,
  1002.         guiBuffer);
  1003. //    RegisterInputMethodScreenCloseFunction(fmgr_return_to_editor);
  1004.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1005.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1006.     return;
  1007. }
  1008. /*****************************************************************************
  1009.  * FUNCTION
  1010.  *  mmi_phb_generic_exit_quick_search_option
  1011.  * DESCRIPTION
  1012.  *  Exit function of phonebook quick search option
  1013.  * PARAMETERS
  1014.  *  void
  1015.  * RETURNS
  1016.  *  void
  1017.  *****************************************************************************/
  1018. void mmi_phb_generic_exit_quick_search_option(void)
  1019. {
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Local Variables                                                */
  1022.     /*----------------------------------------------------------------*/
  1023.     /*----------------------------------------------------------------*/
  1024.     /* Code Body                                                      */
  1025.     /*----------------------------------------------------------------*/
  1026.     g_phb_cntx.end_scr_id = SCR_ID_PHB_SMS_QUICK_SEARCH_OPTIONS;
  1027. }
  1028. #endif /* defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__) */
  1029. /*****************************************************************************
  1030.  * FUNCTION
  1031.  *  mmi_phb_frm_enter_send_entry
  1032.  * DESCRIPTION
  1033.  *  Displays the PHB list for SMS to send SMS
  1034.  *  to one or many numbers
  1035.  * PARAMETERS
  1036.  *  void
  1037.  * RETURNS
  1038.  *  void
  1039.  *****************************************************************************/
  1040. void mmi_phb_frm_enter_send_entry(void)
  1041. {    
  1042.     /*----------------------------------------------------------------*/
  1043.     /* Local Variables                                                */
  1044.     /*----------------------------------------------------------------*/
  1045.     U16 i;
  1046.     U16 SMSEntryCount = 0;
  1047. U16 entryCount;
  1048.     U16 store_index;
  1049.     U8 *guiBuffer;
  1050.     //MMI_BOOL alpha_index = MMI_TRUE;
  1051.     
  1052.     /*----------------------------------------------------------------*/
  1053.     /* Code Body                                                      */
  1054.     /*----------------------------------------------------------------*/
  1055.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_frm_enter_send_entry.>n", __FILE__,
  1056.                          __LINE__));
  1057. #ifdef __SYNCML_SUPPORT__
  1058.     if (mmi_syncml_is_phb_sync_now())
  1059.     {
  1060.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1061.     }
  1062.     else
  1063. #endif /* __SYNCML_SUPPORT__ */
  1064.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  1065.     {
  1066.         /* Allocate buffer for phonebook memeber list filter */
  1067.         mmi_phb_list_allocate_filter();
  1068.         /* Build list according to filter */
  1069.         for (i = 0; i < PhoneBookEntryCount; i++)
  1070.         {
  1071.             store_index = g_phb_name_index[i];
  1072.             if (PhoneBook[store_index].field & 0x1E)
  1073.             {
  1074.                 g_phb_cntx.list_filter[SMSEntryCount] = store_index;
  1075.                 SMSEntryCount++;
  1076.             }
  1077.         }
  1078.         if (SMSEntryCount)
  1079.         {
  1080.             g_phb_cntx.highlight_entry = 0;
  1081.             phbListView = MMI_PHB_LIST_FOR_FRM;
  1082.             EntryNewScreen(SCR_PBOOK_LIST, mmi_phb_exit_list, mmi_phb_frm_enter_send_entry, NULL);
  1083.             guiBuffer = GetCurrGuiBuffer(SCR_PBOOK_LIST);
  1084.     
  1085.             if (g_phb_cntx.new_highlight_entry < 0xffff)
  1086.             {
  1087.                 change_list_menu_category_history(guiBuffer, g_phb_cntx.new_highlight_entry, SMSEntryCount, 0);
  1088.                 g_phb_cntx.new_highlight_entry = 0xffff;
  1089.             }
  1090.            RegisterHighlightHandler(mmi_phb_get_index_by_store_location_fourth);
  1091.     
  1092.            RegisterCat200SearchFunction(mmi_phb_generic_quick_search_find_entry);
  1093.             /* First Time enter or any entry has been modified.. */
  1094.             if ((guiBuffer == NULL) || (g_phb_cntx.refresh_list == MMI_PHB_ENTRY_REFRESH))
  1095.             {
  1096.                 g_phb_cntx.highlight_entry = 0;
  1097.                 memset(g_phb_generic_qsearch_input, 0, ENCODING_LENGTH);
  1098.                 memset(g_phb_generic_qsearch_bitmask, 0xff, (MAX_PB_ENTRIES + 7) / 8);
  1099.                 entryCount = SMSEntryCount;
  1100.                 guiBuffer = NULL;
  1101.                 g_phb_cntx.refresh_list = MMI_PHB_ENTRY_QSEARCH;    /* '2' is used only for this screen. */
  1102.             }
  1103.             else
  1104.             {
  1105.                 entryCount = (U16) mmi_phb_generic_quick_search_find_entry(g_phb_generic_qsearch_input);
  1106.             }
  1107.             
  1108. #ifdef __MMI_UI_HINTS_IN_MENUITEM__
  1109.     set_force_icon_on_highlight_only_in_menuitem();
  1110. #endif
  1111. #if defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__)         
  1112.             ShowCategory200Screen(
  1113.                 STR_SCR_PBOOK_VIEW_CAPTION,
  1114.                 IMG_SCR_PBOOK_CAPTION,
  1115.                 STR_GLOBAL_OPTIONS,
  1116.                 IMG_GLOBAL_OPTIONS,
  1117.                 STR_GLOBAL_BACK,
  1118.                 IMG_GLOBAL_BACK,
  1119.                 entryCount,
  1120.         mmi_phb_generic_filter_list_get_item,
  1121.         mmi_phb_generic_filter_list_get_hint,
  1122.                 g_phb_cntx.highlight_entry,
  1123.                 IMG_ID_PHB_QUICK_SEARCH_FIND,
  1124.                 (U8*) g_phb_generic_qsearch_input,
  1125.                 MMI_PHB_GENERIC_QUICK_SEARCH_INPUT_LENGTH,
  1126.                 guiBuffer);
  1127.             SetCategory200LeftSoftkeyFunction(mmi_phb_generic_entry_quick_search_option, KEY_EVENT_UP);
  1128.             SetLeftSoftkeyFunction(mmi_phb_generic_entry_quick_search_option, KEY_EVENT_UP);
  1129. #else /* defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__) */                    
  1130.             ShowCategory200Screen(
  1131.                 STR_SCR_PBOOK_VIEW_CAPTION,
  1132.                 IMG_SCR_PBOOK_CAPTION,
  1133.                 STR_GLOBAL_OK,
  1134.                 IMG_GLOBAL_OK,
  1135.                 STR_GLOBAL_BACK,
  1136.                 IMG_GLOBAL_BACK,
  1137.                 entryCount,
  1138.         mmi_phb_generic_filter_list_get_item,
  1139.         mmi_phb_generic_filter_list_get_hint,
  1140.                 g_phb_cntx.highlight_entry,
  1141.                 IMG_ID_PHB_QUICK_SEARCH_FIND,
  1142.                 (U8*) g_phb_generic_qsearch_input,
  1143.                 MMI_PHB_GENERIC_QUICK_SEARCH_INPUT_LENGTH,
  1144.                 guiBuffer);
  1145.             SetCategory200LeftSoftkeyFunction(mmi_phb_entry_sms_choose_number, KEY_EVENT_UP);
  1146.             SetLeftSoftkeyFunction(mmi_phb_entry_sms_choose_number, KEY_EVENT_UP);
  1147. #endif /* defined(__MMI_MULTITAP_FOR_STAR_AND_POUND__) */ 
  1148.             SetCategory200RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1149.         SetKeyHandler(mmi_frm_sms_end_key_from_send, KEY_END, KEY_EVENT_DOWN);
  1150.         
  1151.         if (guiBuffer == NULL)
  1152.         {
  1153.             g_phb_generic_qsearch_is_cache = 0;
  1154.             mmi_phb_generic_quick_search_make_cache();
  1155.         }
  1156.         }
  1157.         else
  1158.         {
  1159.             DisplayPopup(
  1160.                 (PU8) GetString(STR_ID_PHB_NO_ENTRY_TO_SELECT),
  1161.                 IMG_GLOBAL_EMPTY,
  1162.                 TRUE,
  1163.                 PHB_NOTIFY_TIMEOUT,
  1164.                 EMPTY_LIST_TONE);
  1165.             mmi_phb_list_free_filter();
  1166.         }
  1167.     }
  1168.     else
  1169.     {
  1170.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1171.     }
  1172. }
  1173. #else /* defined(__MMI_PHB_QUICK_SEARCH__) */
  1174. /*****************************************************************************
  1175.  * FUNCTION
  1176.  *  mmi_phb_frm_enter_send_entry
  1177.  * DESCRIPTION
  1178.  *  Displays the PHB list for SMS to send SMS
  1179.  *  to one or many numbers
  1180.  * PARAMETERS
  1181.  *  void
  1182.  * RETURNS
  1183.  *  void
  1184.  *****************************************************************************/
  1185. void mmi_phb_frm_enter_send_entry(void)
  1186. {
  1187.     /*----------------------------------------------------------------*/
  1188.     /* Local Variables                                                */
  1189.     /*----------------------------------------------------------------*/
  1190.     U16 i;
  1191.     U16 EntryCount = 0;
  1192.     U16 store_index;
  1193.     /*----------------------------------------------------------------*/
  1194.     /* Code Body                                                      */
  1195.     /*----------------------------------------------------------------*/
  1196.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s]  Line: [%d] <<mmi_phb_frm_enter_send_entry.>n", __FILE__,
  1197.                          __LINE__));
  1198. #ifdef __SYNCML_SUPPORT__
  1199.     if (mmi_syncml_is_phb_sync_now())
  1200.     {
  1201.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1202.     }
  1203.     else
  1204. #endif /* __SYNCML_SUPPORT__ */
  1205.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  1206.     {
  1207.         /* Allocate buffer for phonebook memeber list filter */
  1208.         mmi_phb_list_allocate_filter();
  1209.         /* Build list according to filter */
  1210.         for (i = 0; i < PhoneBookEntryCount; i++)
  1211.         {
  1212.             store_index = g_phb_name_index[i];
  1213.             if (PhoneBook[store_index].field & 0x1E)
  1214.             {
  1215.                 g_phb_cntx.list_filter[EntryCount] = store_index;
  1216.                 EntryCount++;
  1217.             }
  1218.         }
  1219.         if (EntryCount)
  1220.         {
  1221.             g_phb_cntx.highlight_entry = 0;
  1222.             phbListView = MMI_PHB_LIST_FOR_FRM;
  1223.             mmi_phb_entry_list(
  1224.                 EntryCount,                                 /* Total Entry */
  1225.                 STR_SCR_PBOOK_VIEW_CAPTION,                 /* Title String */
  1226.                 IMG_SCR_PBOOK_CAPTION,                      /* Title Image */
  1227.                 STR_GLOBAL_OK,                              /* LSK */
  1228.                 IMG_GLOBAL_OK,                              /* LSK */
  1229.                 mmi_phb_get_index_by_store_location_second, /* Highlight Callback */
  1230.                 mmi_phb_entry_sms_choose_number,            /* LSK Callback */
  1231.                 mmi_phb_entry_sms_choose_number,            /* SEND Key Callback */
  1232.                 mmi_phb_filter_list_get_item,               /* List Callback */
  1233.                 mmi_phb_filter_list_get_hint,               /* Hint Callback */
  1234.                 mmi_phb_frm_enter_send_entry,               /* Re-Entry Callback */
  1235.                 TRUE,                                       /* Alpha Index */
  1236.                 TRUE);                                      /* Right Arrow Key */
  1237.             SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1238.             SetKeyHandler(mmi_frm_sms_end_key_from_send, KEY_END, KEY_EVENT_DOWN);
  1239.         }
  1240.         else
  1241.         {
  1242.             DisplayPopup(
  1243.                 (PU8) GetString(STR_ID_PHB_NO_ENTRY_TO_SELECT),
  1244.                 IMG_GLOBAL_EMPTY,
  1245.                 TRUE,
  1246.                 PHB_NOTIFY_TIMEOUT,
  1247.                 EMPTY_LIST_TONE);
  1248.             mmi_phb_list_free_filter();
  1249.         }
  1250.     }
  1251.     else
  1252.     {
  1253.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1254.     }
  1255. }
  1256. #endif /* defined(__MMI_PHB_QUICK_SEARCH__) */
  1257. //quick search end
  1258. #if defined(__MMI_MESSAGES_SEND_BY_GROUP__)
  1259. /*****************************************************************************
  1260.  * FUNCTION
  1261.  *  mmi_phb_sms_enter_send_by_group
  1262.  * DESCRIPTION
  1263.  *  Displays the Caller Groups list for SMS to send message
  1264.  *  to all numbers belonging to this group
  1265.  * PARAMETERS
  1266.  *  void
  1267.  * RETURNS
  1268.  *  void
  1269.  *****************************************************************************/
  1270. void mmi_phb_sms_enter_send_by_group(void)
  1271. {
  1272.     /*----------------------------------------------------------------*/
  1273.     /* Local Variables                                                */
  1274.     /*----------------------------------------------------------------*/
  1275.     /*----------------------------------------------------------------*/
  1276.     /* Code Body                                                      */
  1277.     /*----------------------------------------------------------------*/
  1278.     mmi_phb_get_address_from_caller_group((U8)MMI_PHB_ENTRY_FIELD_NUMBER, mmi_msg_send_msg_to_group);
  1279. }
  1280. #endif /* defined(__MMI_MESSAGES_SEND_BY_GROUP__) */ 
  1281. #if defined(__MMI_MESSAGES_SEND_BY_GROUP__) || defined(__UNIFIED_COMPOSER_SUPPORT__)
  1282. /*****************************************************************************
  1283.  * FUNCTION
  1284.  *  mmi_phb_sms_send_data_for_group
  1285.  * DESCRIPTION
  1286.  *  Sends the names & numbers info of the selected
  1287.  *  caller group to SMS
  1288.  * PARAMETERS
  1289.  *  void
  1290.  * RETURNS
  1291.  *  void
  1292.  *****************************************************************************/
  1293. void mmi_phb_sms_send_data_for_group(void)
  1294. {
  1295.     /*----------------------------------------------------------------*/
  1296.     /* Local Variables                                                */
  1297.     /*----------------------------------------------------------------*/
  1298.     U16 *indices;
  1299.     U16 i, j = 0;
  1300.     S16 pError;
  1301.     U16 store_index;
  1302.     U8 optid_record, optid_index, current_record = 0;
  1303.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1304.     /*----------------------------------------------------------------*/
  1305.     /* Code Body                                                      */
  1306.     /*----------------------------------------------------------------*/
  1307.     /* Clear key immediately to avoid user press twice. */
  1308.     ClearKeyHandler(KEY_LSK, KEY_EVENT_UP);
  1309. #ifdef __MMI_PHB_USIM_FIELD__
  1310.     if (g_phb_cntx.active_index >= MAX_PB_CALLER_GROUPS)
  1311.     {
  1312. #if (MAX_PB_ENTRIES >= 1000)
  1313.         indices = (U16*)g_phb_list_filter;
  1314. #else
  1315.         indices = OslMalloc(MAX_PB_SIM_ENTRIES*sizeof(U16));
  1316. #endif /* MAX_PB_ENTRIES >= 1000 */
  1317.         for (i = 0; i < PhoneBookEntryCount ; ++i)
  1318.         {
  1319.             store_index = g_phb_name_index[i];
  1320.             if (store_index >= MAX_PB_PHONE_ENTRIES)
  1321.             {
  1322.                 /* Compare caller group ID */
  1323.                 if (g_phb_cntx.group_type[store_index-MAX_PB_PHONE_ENTRIES] == 
  1324.                     (g_phb_cntx.active_index_second+1-MAX_PB_CALLER_GROUPS) && 
  1325.                     PhoneBook[store_index].field & phb_list_view_type)
  1326.                 {         
  1327.                     indices[j++] = store_index;
  1328.                 }
  1329.             }
  1330.         }
  1331.         MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_FUNC_SendDataForCallerGrp, j ));
  1332.         phb_group_view_call_back(j, indices);
  1333. #if (MAX_PB_ENTRIES < 1000)
  1334.         OslMfree(indices);
  1335. #endif /* MAX_PB_ENTRIES < 1000 */
  1336.         return;
  1337.     }
  1338. #endif /* __MMI_PHB_USIM_FIELD__ */
  1339. #if (MAX_PB_ENTRIES >= 1000)
  1340.     indices = (U16*) g_phb_list_filter;
  1341. #else /* (MAX_PB_ENTRIES >= 1000) */ 
  1342. #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__)     /* Associate caller group in SIM card entry */
  1343.     indices = OslMalloc(MAX_PB_ENTRIES * sizeof(U16));
  1344. #else 
  1345.     indices = OslMalloc(MAX_PB_PHONE_ENTRIES * sizeof(U16));
  1346. #endif 
  1347. #endif /* MAX_PB_ENTRIES >= 1000 */
  1348.     for (i = 0; i < PhoneBookEntryCount; ++i)
  1349.     {
  1350.         store_index = g_phb_name_index[i];
  1351.     #if !defined(__MMI_PHB_CALLERGROUP_IN_SIM__)    /* Associate caller group in SIM card entry */
  1352.         if (store_index < MAX_PB_PHONE_ENTRIES)
  1353.     #endif 
  1354.         {
  1355.             /* Get optional IDs record. */
  1356.             optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1357.             optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1358.             if (optid_record != current_record)
  1359.             {
  1360.                 ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1361.                 current_record = optid_record;
  1362.             }
  1363.             /* Compare caller group ID */
  1364.             if (PhbOptIDs[optid_index].callerGroupID == (g_phb_cntx.active_index_second + 1) &&
  1365.                 PhoneBook[store_index].field & phb_list_view_type)
  1366.             {
  1367.                 indices[j++] = store_index;
  1368.             }
  1369.         }
  1370.     }
  1371.     MMI_TRACE((MMI_TRACE_G4_PHB, MMI_PHB_FUNC_SendDataForCallerGrp, j));
  1372.     phb_group_view_call_back(j, indices);
  1373. #if (MAX_PB_ENTRIES < 1000)
  1374.     OslMfree(indices);
  1375. #endif /* MAX_PB_ENTRIES < 1000 */
  1376. }
  1377. /*****************************************************************************
  1378.  * FUNCTION
  1379.  *  mmi_phb_get_caller_group_data
  1380.  * DESCRIPTION
  1381.  *  Get the all numbers belonging to this group for UM to send message
  1382.  * PARAMETERS
  1383.  *  address_type                 [IN]        address type: number or e-mail
  1384.  *  get_address_call_back        [IN]        call back function after user chooses a group
  1385.  * RETURNS
  1386.  *  void
  1387.  *****************************************************************************/
  1388. void mmi_phb_get_address_from_caller_group(U8 address_type, mmi_phb_get_index_from_group_callback_type get_address_call_back)
  1389. {
  1390.     /*----------------------------------------------------------------*/
  1391.     /* Local Variables                                                */
  1392.     /*----------------------------------------------------------------*/
  1393.     /*----------------------------------------------------------------*/
  1394.     /* Code Body                                                      */
  1395.     /*----------------------------------------------------------------*/
  1396. #ifdef __SYNCML_SUPPORT__
  1397.     if (mmi_syncml_is_phb_sync_now())
  1398.     {
  1399.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  1400.     }
  1401.     else
  1402. #endif /* __SYNCML_SUPPORT__ */
  1403.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  1404.     {
  1405.         if (PhoneBookEntryCount)
  1406.         {
  1407.             phbListView = MMI_PHB_LIST_FOR_GET_ADDRESS_FROM_GROUP;
  1408.             phb_list_view_type = address_type;
  1409.             phb_group_view_call_back = get_address_call_back;
  1410.             mmi_phb_entry_callergroup();    /* Entry caller group main screen. */
  1411.         }
  1412.         else
  1413.         {
  1414.             DisplayPopup(
  1415.                 (PU8) GetString(STR_NO_ENTRIES_MESSAGE),
  1416.                 IMG_GLOBAL_EMPTY,
  1417.                 TRUE,
  1418.                 PHB_NOTIFY_TIMEOUT,
  1419.                 EMPTY_LIST_TONE);
  1420.         }
  1421.     }
  1422.     else
  1423.     {
  1424.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  1425.     }
  1426. }
  1427. #endif /* defined(__MMI_MESSAGES_SEND_BY_GROUP__) || defined(__UNIFIED_COMPOSER_SUPPORT__) */ 
  1428. #if defined(__UNIFIED_COMPOSER_SUPPORT__)
  1429. /*****************************************************************************
  1430.  * FUNCTION
  1431.  *  mmi_phb_get_email_p
  1432.  * DESCRIPTION
  1433.  *  Get the all numbers belonging to this group for UM to send message
  1434.  * PARAMETERS
  1435.  *  store_index                 [IN]        store index of the phonebook entry
  1436.  *  address_length              [OUT]       email address length
  1437.  * RETURNS
  1438.  *  email address pointer
  1439.  *****************************************************************************/
  1440. U8* mmi_phb_get_email_p(U16 store_index, U8* address_length)
  1441. {
  1442.     /*----------------------------------------------------------------*/
  1443.     /* Local Variables                                                */
  1444.     /*----------------------------------------------------------------*/
  1445.     S16 pError;
  1446.     /*----------------------------------------------------------------*/
  1447.     /* Code Body                                                      */
  1448.     /*----------------------------------------------------------------*/
  1449. #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  1450.     if (store_index < MAX_PB_PHONE_ENTRIES) /* in NVRAM */
  1451.     {
  1452.         ReadRecord(
  1453.             NVRAM_EF_PHB_FIELDS_LID,
  1454.             (U16) (store_index + 1),
  1455.             (void*)&PhoneBookOptionalFields,
  1456.             OPTIONAL_FIELDS_RECORD_SIZE,
  1457.             &pError);
  1458.         *address_length = strlen((PS8)PhoneBookOptionalFields.emailAddress);
  1459.         return (U8*)PhoneBookOptionalFields.emailAddress;
  1460.     }
  1461. #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  1462. #ifdef __MMI_PHB_USIM_FIELD__
  1463.     if (store_index >= MAX_PB_PHONE_ENTRIES)    /* in USIM */
  1464.     {
  1465.         *address_length = phb_email[store_index - MAX_PB_PHONE_ENTRIES].email_length;
  1466.         return (U8*) phb_email[store_index - MAX_PB_PHONE_ENTRIES].email_address;
  1467.     }
  1468. #endif /* __MMI_PHB_USIM_FIELD__ */
  1469.     *address_length = 0;
  1470.     return NULL;
  1471. }
  1472. #endif /* defined(__UNIFIED_COMPOSER_SUPPORT__) */
  1473. /*****************************************************************************
  1474.  * FUNCTION
  1475.  *  mmi_phb_sms_send_data_choose_entry
  1476.  * DESCRIPTION
  1477.  *  
  1478.  * PARAMETERS
  1479.  *  void
  1480.  * RETURNS
  1481.  *  void
  1482.  *****************************************************************************/
  1483. void mmi_phb_sms_send_data_choose_entry(void)
  1484. {
  1485.     /*----------------------------------------------------------------*/
  1486.     /* Local Variables                                                */
  1487.     /*----------------------------------------------------------------*/
  1488.     /*----------------------------------------------------------------*/
  1489.     /* Code Body                                                      */
  1490.     /*----------------------------------------------------------------*/
  1491.     mmi_phb_entry_list_choose_number(
  1492.         g_phb_name_index[g_phb_cntx.active_index_second],
  1493.         mmi_phb_sms_send_data_choose_entry,
  1494.         mmi_phb_sms_send_data_for_entry_list,
  1495.         mmi_phb_sms_send_data_for_entry,
  1496.         STR_SMS_NUM_CANNOT_BE_EMPTY,
  1497.         FALSE);
  1498. }
  1499. /*****************************************************************************
  1500.  * FUNCTION
  1501.  *  mmi_phb_sms_send_data_for_entry_name_only
  1502.  * DESCRIPTION
  1503.  *  
  1504.  * PARAMETERS
  1505.  *  void
  1506.  * RETURNS
  1507.  *  void
  1508.  *****************************************************************************/
  1509. void mmi_phb_sms_send_data_for_entry_name_only(void)
  1510. {
  1511.     /*----------------------------------------------------------------*/
  1512.     /* Local Variables                                                */
  1513.     /*----------------------------------------------------------------*/
  1514.     /*----------------------------------------------------------------*/
  1515.     /* Code Body                                                      */
  1516.     /*----------------------------------------------------------------*/
  1517.     mmi_phb_sms_send_data_for_entry(NULL);
  1518. }
  1519. /*****************************************************************************
  1520.  * FUNCTION
  1521.  *  mmi_phb_sms_send_data_for_entry_list
  1522.  * DESCRIPTION
  1523.  *  
  1524.  * PARAMETERS
  1525.  *  void
  1526.  * RETURNS
  1527.  *  void
  1528.  *****************************************************************************/
  1529. void mmi_phb_sms_send_data_for_entry_list(void)
  1530. {
  1531.     /*----------------------------------------------------------------*/
  1532.     /* Local Variables                                                */
  1533.     /*----------------------------------------------------------------*/
  1534.     /*----------------------------------------------------------------*/
  1535.     /* Code Body                                                      */
  1536.     /*----------------------------------------------------------------*/
  1537.     /* DeleteNScrId(SCR_PBOOK_LIST); */
  1538.     mmi_phb_sms_send_data_for_entry((PS8) g_phb_cntx.number_to_dial[g_phb_cntx.active_index_third]);
  1539. }
  1540. /*****************************************************************************
  1541.  * FUNCTION
  1542.  *  mmi_phb_sms_send_data_for_entry
  1543.  * DESCRIPTION
  1544.  *  Sends the name & number info of the selected PHB entry to SMS
  1545.  * PARAMETERS
  1546.  *  number      [IN]        Input number string
  1547.  * RETURNS
  1548.  *  void
  1549.  *****************************************************************************/
  1550. extern void mmi_frm_sms_get_phb_number(U8 name[], U8 number[]);
  1551. void mmi_phb_sms_send_data_for_entry(S8 *number)
  1552. {
  1553.     /*----------------------------------------------------------------*/
  1554.     /* Local Variables                                                */
  1555.     /*----------------------------------------------------------------*/
  1556.     U8 type = 0;
  1557.     U16 store_index;
  1558.     /*----------------------------------------------------------------*/
  1559.     /* Code Body                                                      */
  1560.     /*----------------------------------------------------------------*/
  1561.     store_index = g_phb_name_index[g_phb_cntx.active_index_second];
  1562. #if defined(__MMI_MESSAGES_CHAT__)
  1563.     if ((phbListView == MMI_PHB_LIST_FOR_CHAT) || (phbListView == MMI_PHB_LIST_FOR_CHAT_NO_CHECK))
  1564.     {
  1565.         if (pfnUnicodeStrlen((PS8) PhoneBook[store_index].alpha_id.name) == 0 &&
  1566.             phbListView == MMI_PHB_LIST_FOR_CHAT_NO_CHECK)
  1567.         {
  1568.             DisplayPopup(
  1569.                 (PU8) GetString(STR_SMS_NAME_CANNOT_BE_EMPTY),
  1570.                 IMG_GLOBAL_ERROR,
  1571.                 FALSE,
  1572.                 PHB_NOTIFY_TIMEOUT,
  1573.                 ERROR_TONE);
  1574.         }
  1575.         else
  1576.         {
  1577.             SetNameNumberForChatScreen(PhoneBook[store_index].alpha_id.name, (U8*) number);
  1578.         }
  1579.         return;
  1580.     }
  1581. #endif /* defined(__MMI_MESSAGES_CHAT__) */ 
  1582.     if (number[0] == '+')
  1583.     {
  1584.         type = 1;
  1585.     }
  1586.     if (pfnUnicodeStrlen((PS8) number) <= ((MAX_PB_NUMBER_LENGTH / ENCODING_LENGTH) + type))
  1587.     {
  1588.         if (pfnUnicodeStrlen((PS8) number) == 0)
  1589.         {
  1590.             DisplayPopup(
  1591.                 (PU8) GetString(STR_SMS_NUM_CANNOT_BE_EMPTY),
  1592.                 IMG_GLOBAL_UNFINISHED,
  1593.                 1,
  1594.                 PHB_NOTIFY_TIMEOUT,
  1595.                 (U8) ERROR_TONE);
  1596.         }
  1597.         else if (phbListView == MMI_PHB_LIST_FOR_FRM)
  1598.         {
  1599.             mmi_frm_sms_get_phb_number(PhoneBook[store_index].alpha_id.name, (U8*) number);
  1600.         }
  1601.         else
  1602.         {
  1603.             mmi_msg_get_number_from_phb(PhoneBook[store_index].alpha_id.name, (U8*) number);
  1604.         }
  1605.     }
  1606.     else
  1607.     {
  1608.         DisplayPopup(
  1609.             (PU8) GetString(STR_SMS_NUM_LEN_EXCEEDED),
  1610.             IMG_GLOBAL_UNFINISHED,
  1611.             1,
  1612.             PHB_NOTIFY_TIMEOUT,
  1613.             (U8) ERROR_TONE);
  1614.     }
  1615. }
  1616. #ifdef __MMI_PHB_SEND_MMS_FROM_PHB__
  1617. /*****************************************************************************
  1618.  * FUNCTION
  1619.  *  mmi_phb_mms_send_data_for_entry
  1620.  * DESCRIPTION
  1621.  *  Sends the name & number info of the selected PHB entry to SMS
  1622.  * PARAMETERS
  1623.  *  number      [IN]        Input number string
  1624.  * RETURNS
  1625.  *  void
  1626.  *****************************************************************************/
  1627. void mmi_phb_mms_send_data_for_entry(S8 *number)
  1628. {
  1629. #ifdef WAP_SUPPORT
  1630.     /*----------------------------------------------------------------*/
  1631.     /* Local Variables                                                */
  1632.     /*----------------------------------------------------------------*/
  1633.     /*----------------------------------------------------------------*/
  1634.     /* Code Body                                                      */
  1635.     /*----------------------------------------------------------------*/
  1636.     if (pfnUnicodeStrlen((PS8) number) <= MAX_PB_NUMBER_LENGTH)
  1637.     {
  1638.         if (pfnUnicodeStrlen((PS8) number) == 0)
  1639.         {
  1640.             DisplayPopup(
  1641.                 (PU8) GetString(STR_SMS_NUM_CANNOT_BE_EMPTY),
  1642.                 IMG_GLOBAL_UNFINISHED,
  1643.                 1,
  1644.                 PHB_NOTIFY_TIMEOUT,
  1645.                 (U8) ERROR_TONE);
  1646.         }
  1647.         else
  1648.         {
  1649.             mms_address_insert_hdlr((char*)number);
  1650.         }
  1651.     }
  1652.     else
  1653. #endif /* WAP_SUPPORT */ /* WAP_SUPOPRT */
  1654.     {
  1655.         DisplayPopup(
  1656.             (PU8) GetString(STR_SMS_NUM_LEN_EXCEEDED),
  1657.             IMG_GLOBAL_UNFINISHED,
  1658.             1,
  1659.             PHB_NOTIFY_TIMEOUT,
  1660.             (U8) ERROR_TONE);
  1661.     }
  1662. }
  1663. /*****************************************************************************
  1664.  * FUNCTION
  1665.  *  mmi_phb_mms_send_data_for_entry_list
  1666.  * DESCRIPTION
  1667.  *  
  1668.  * PARAMETERS
  1669.  *  void
  1670.  * RETURNS
  1671.  *  void
  1672.  *****************************************************************************/
  1673. void mmi_phb_mms_send_data_for_entry_list(void)
  1674. {
  1675.     /*----------------------------------------------------------------*/
  1676.     /* Local Variables                                                */
  1677.     /*----------------------------------------------------------------*/
  1678.     /*----------------------------------------------------------------*/
  1679.     /* Code Body                                                      */
  1680.     /*----------------------------------------------------------------*/
  1681.     mmi_phb_mms_send_data_for_entry((PS8) g_phb_cntx.number_to_dial[g_phb_cntx.active_index_third]);
  1682. }
  1683. /*****************************************************************************
  1684.  * FUNCTION
  1685.  *  mmi_phb_mms_send_data_choose_entry
  1686.  * DESCRIPTION
  1687.  *  
  1688.  * PARAMETERS
  1689.  *  void
  1690.  * RETURNS
  1691.  *  void
  1692.  *****************************************************************************/
  1693. void mmi_phb_mms_send_data_choose_entry(void)
  1694. {
  1695.     /*----------------------------------------------------------------*/
  1696.     /* Local Variables                                                */
  1697.     /*----------------------------------------------------------------*/
  1698.     /*----------------------------------------------------------------*/
  1699.     /* Code Body                                                      */
  1700.     /*----------------------------------------------------------------*/
  1701.     mmi_phb_entry_list_choose_number(
  1702.         g_phb_name_index[g_phb_cntx.active_index_second],
  1703.         mmi_phb_mms_send_data_choose_entry,
  1704.         mmi_phb_mms_send_data_for_entry_list,
  1705.         mmi_phb_mms_send_data_for_entry,
  1706.         STR_SMS_NUM_CANNOT_BE_EMPTY,
  1707.         FALSE);
  1708. }
  1709. #endif /* __MMI_PHB_SEND_MMS_FROM_PHB__ */ 
  1710. #define MMI_PHB_UPDATE_INLINE_LIST
  1711. /*****************************************************************************
  1712.  * FUNCTION
  1713.  *  mmi_phb_update_delete_image
  1714.  * DESCRIPTION
  1715.  *  Deletes the image id from PHB records if
  1716.  *  one of the downloaded/factory/system images
  1717.  *  are deleted.
  1718.  * PARAMETERS
  1719.  *  imageId     [IN]        
  1720.  * RETURNS
  1721.  *  void
  1722.  *****************************************************************************/
  1723. void mmi_phb_update_delete_image(U16 imageId)
  1724. {
  1725.     /*----------------------------------------------------------------*/
  1726.     /* Local Variables                                                */
  1727.     /*----------------------------------------------------------------*/
  1728.     U16 i;
  1729.     U8 flag = 0;
  1730.     S16 pError;
  1731.     U8 optid_record = 0, optid_index, current_record = 0;
  1732.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1733.     /*----------------------------------------------------------------*/
  1734.     /* Code Body                                                      */
  1735.     /*----------------------------------------------------------------*/
  1736.     for (i = 0; i < MAX_PB_PHONE_ENTRIES; ++i)
  1737.     {
  1738.         /* Get optional IDs record. */
  1739.         optid_record = (i / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1740.         optid_index = i - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1741.         if (optid_record != current_record)
  1742.         {
  1743.             if (current_record != 0 && flag == 1)   /* Write result back for previous optional ID record. */
  1744.             {
  1745.                 WriteRecord(NVRAM_EF_PHB_IDS_LID, current_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1746.                 flag = 0;
  1747.             }
  1748.             /* Read out next record. */
  1749.             ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1750.             current_record = optid_record;
  1751.         }
  1752.         if (PhbOptIDs[optid_index].pictureTagID == imageId)
  1753.         {
  1754.             PhbOptIDs[optid_index].pictureTagID = IMG_PHB_DEFAULT;
  1755.             flag = 1;
  1756.         }
  1757.     }
  1758.     /* Write back for last record. */
  1759.     if (flag)
  1760.     {
  1761.         WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1762.     }
  1763. }
  1764. /*****************************************************************************
  1765.  * FUNCTION
  1766.  *  mmi_phb_update_delete_image_caller_group
  1767.  * DESCRIPTION
  1768.  *  Deletes the image id from caller group if
  1769.  *  one of the downloaded/factory/system images
  1770.  *  are deleted.
  1771.  * PARAMETERS
  1772.  *  imageId     [IN]        
  1773.  * RETURNS
  1774.  *  void
  1775.  *****************************************************************************/
  1776. void mmi_phb_update_delete_image_caller_group(U16 imageId)
  1777. {
  1778.     /*----------------------------------------------------------------*/
  1779.     /* Local Variables                                                */
  1780.     /*----------------------------------------------------------------*/
  1781.     U8 i;
  1782.     U8 flag = 0;
  1783.     S16 pError;
  1784.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  1785.     /*----------------------------------------------------------------*/
  1786.     /* Code Body                                                      */
  1787.     /*----------------------------------------------------------------*/
  1788.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  1789.     for (i = 0; i < MAX_PB_CALLER_GROUPS; ++i)
  1790.     {
  1791.         if (callerGroups[i].pictureTagID == imageId)
  1792.         {
  1793.             callerGroups[i].pictureTagID = IMG_PHB_DEFAULT;
  1794.             flag = 1;
  1795.         }
  1796.     }
  1797.     if (flag)
  1798.     {
  1799.         WriteRecord(NVRAM_EF_PHB_CALLER_GROUPS_LID, 1, callerGroups, CALLER_GROUPS_RECORD_SIZE, &pError);
  1800.     }
  1801. }
  1802. /*****************************************************************************
  1803.  * FUNCTION
  1804.  *  mmi_phb_update_delete_audio
  1805.  * DESCRIPTION
  1806.  *  Deletes the audio id from PHB records if
  1807.  *  one of the downloaded/factory/system/composed
  1808.  *  images are deleted.
  1809.  * PARAMETERS
  1810.  *  audioId     [IN]        
  1811.  * RETURNS
  1812.  *  void
  1813.  *****************************************************************************/
  1814. void mmi_phb_update_delete_audio(U16 audioId)
  1815. {
  1816.     /*----------------------------------------------------------------*/
  1817.     /* Local Variables                                                */
  1818.     /*----------------------------------------------------------------*/
  1819.     U16 i;
  1820.     U8 flag = 0;
  1821.     S16 pError;
  1822.     U8 optid_record = 0, optid_index, current_record = 0;
  1823.     PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
  1824.     /*----------------------------------------------------------------*/
  1825.     /* Code Body                                                      */
  1826.     /*----------------------------------------------------------------*/
  1827.     for (i = 0; i < MAX_PB_PHONE_ENTRIES; ++i)
  1828.     {
  1829.         /* Get optional IDs record. */
  1830.         optid_record = (i / OPTIONAL_IDS_RECORD_TOTAL) + 1;
  1831.         optid_index = i - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
  1832.         if (optid_record != current_record)
  1833.         {
  1834.             if (current_record != 0 && flag == 1)   /* Write result back for previous optional ID record. */
  1835.             {
  1836.                 WriteRecord(NVRAM_EF_PHB_IDS_LID, current_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1837.                 flag = 0;
  1838.             }
  1839.             /* Read out next record. */
  1840.             ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1841.             current_record = optid_record;
  1842.         }
  1843.         if (PhbOptIDs[optid_index].ringToneID == audioId)
  1844.         {
  1845.             PhbOptIDs[optid_index].ringToneID = 0;
  1846.             flag = 1;
  1847.         }
  1848.     }
  1849.     /* Write back for last record. */
  1850.     if (flag)
  1851.     {
  1852.         WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
  1853.     }
  1854. }
  1855. /*****************************************************************************
  1856.  * FUNCTION
  1857.  *  mmi_phb_update_delete_audio_caller_group
  1858.  * DESCRIPTION
  1859.  *  Deletes the audio id from CallerGroup records if
  1860.  *  one of the downloaded/factory/system/composed
  1861.  *  images are deleted.
  1862.  * PARAMETERS
  1863.  *  audioId     [IN]        
  1864.  * RETURNS
  1865.  *  void
  1866.  *****************************************************************************/
  1867. void mmi_phb_update_delete_audio_caller_group(U16 audioId)
  1868. {
  1869.     /*----------------------------------------------------------------*/
  1870.     /* Local Variables                                                */
  1871.     /*----------------------------------------------------------------*/
  1872.     U8 i, flag = 0;
  1873.     S16 pError;
  1874.     PHB_CALLER_GROUP_STRUCT *callerGroups;
  1875.     /*----------------------------------------------------------------*/
  1876.     /* Code Body                                                      */
  1877.     /*----------------------------------------------------------------*/
  1878.     callerGroups = (PHB_CALLER_GROUP_STRUCT*) g_phb_cntx.caller_group;
  1879.     for (i = 0; i < MAX_PB_CALLER_GROUPS; ++i)
  1880.     {
  1881.         if (callerGroups[i].ringToneID == audioId)
  1882.         {
  1883.             callerGroups[i].ringToneID = 0;
  1884.             flag = 1;
  1885.         }
  1886.     }
  1887.     if (flag)
  1888.     {
  1889.         WriteRecord(NVRAM_EF_PHB_CALLER_GROUPS_LID, 1, callerGroups, CALLER_GROUPS_RECORD_SIZE, &pError);
  1890.     }
  1891. }
  1892. #define MMI_PHB_INTERFACE_FOR_SPEED_DIAL
  1893. /*****************************************************************************
  1894.  * FUNCTION
  1895.  *  mmi_phb_speed_dial_enter_phb
  1896.  * DESCRIPTION
  1897.  *  Displays the PHB list for Speed key mapping
  1898.  * PARAMETERS
  1899.  *  void
  1900.  * RETURNS
  1901.  *  void
  1902.  *****************************************************************************/
  1903. void mmi_phb_speed_dial_enter_phb(void)
  1904. {
  1905.     /*----------------------------------------------------------------*/
  1906.     /* Local Variables                                                */
  1907.     /*----------------------------------------------------------------*/
  1908.     /*----------------------------------------------------------------*/
  1909.     /* Code Body                                                      */
  1910.     /*----------------------------------------------------------------*/
  1911.     phbListView = MMI_PHB_LIST_FOR_SPEED_DIAL;
  1912.     mmi_phb_list_pre_entry_second_level();
  1913. }
  1914. /*****************************************************************************
  1915.  * FUNCTION
  1916.  *  mmi_phb_pre_send_data
  1917.  * DESCRIPTION
  1918.  *  Send choosed number to MMS
  1919.  * PARAMETERS
  1920.  *  void
  1921.  * RETURNS
  1922.  *  void
  1923.  *****************************************************************************/
  1924. void mmi_phb_pre_send_data(void)
  1925. {
  1926.     /*----------------------------------------------------------------*/
  1927.     /* Local Variables                                                */
  1928.     /*----------------------------------------------------------------*/
  1929.     /*----------------------------------------------------------------*/
  1930.     /* Code Body                                                      */
  1931.     /*----------------------------------------------------------------*/
  1932.     phb_list_view_call_back(pbName, (S8*) g_phb_cntx.number_to_dial[g_phb_cntx.active_index_third]);
  1933. }
  1934. /*****************************************************************************
  1935.  * FUNCTION
  1936.  *  mmi_phb_entry_choose_number
  1937.  * DESCRIPTION
  1938.  *  Entry Choose entry screen if there are more then one entry with number field.
  1939.  * PARAMETERS
  1940.  *  void
  1941.  * RETURNS
  1942.  *  void
  1943.  *****************************************************************************/
  1944. void mmi_phb_entry_choose_number(void)
  1945. {
  1946.     /*----------------------------------------------------------------*/
  1947.     /* Local Variables                                                */
  1948.     /*----------------------------------------------------------------*/
  1949.     U16 i;
  1950.     U8 *guiBuffer;
  1951.     U16 numberTypeImageList[5];
  1952.     S16 pError;
  1953.     U16 store_index;
  1954.     /*----------------------------------------------------------------*/
  1955.     /* Code Body                                                      */
  1956.     /*----------------------------------------------------------------*/
  1957.     if (phbListView == MMI_PHB_LIST_FOR_MMS_ALL)
  1958.     {
  1959.         store_index = g_phb_name_index[g_phb_cntx.active_index_second];
  1960.     }
  1961.     else
  1962.     {
  1963.         store_index = g_phb_cntx.active_index_second;
  1964.     }
  1965.     pfnUnicodeStrcpy(pbName, (PS8) PhoneBook[store_index].alpha_id.name);
  1966.     /* For SMS insert phonebook name */
  1967.     if (phb_list_view_type == MMI_PHB_ENTRY_FIELD_NAME)
  1968.     {
  1969.         g_phb_cntx.number_to_dial[0] = NULL;
  1970.         g_phb_cntx.active_index_third = 0;
  1971.         mmi_phb_pre_send_data();
  1972.         return;
  1973.     }
  1974.     mmi_phb_convert_get_ucs2_number(pbNumber, store_index); /* BCD number format. */
  1975. #ifndef __MMI_PHB_USIM_FIELD__
  1976.     if ((phb_list_view_type & MMI_PHB_ENTRY_FIELD_ALL_NUMBER) && (store_index >= MAX_PB_PHONE_ENTRIES))   /* In SIM */
  1977.     {
  1978.         if (!pfnUnicodeStrlen(pbNumber))
  1979.         {
  1980.             DisplayPopup(
  1981.                 (PU8) GetString(STR_NO_NUMBER_TO_DIAL),
  1982.                 IMG_GLOBAL_ERROR,
  1983.                 FALSE,
  1984.                 PHB_NOTIFY_TIMEOUT,
  1985.                 ERROR_TONE);
  1986.         }
  1987.         else
  1988.         {
  1989.             g_phb_cntx.number_to_dial[0] = (U8*) pbNumber;
  1990.             g_phb_cntx.active_index_third = 0;
  1991.             mmi_phb_pre_send_data();
  1992.         }
  1993.     }
  1994.     else
  1995. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  1996.     {
  1997.         i = 0;
  1998.         if ((phb_list_view_type& MMI_PHB_ENTRY_FIELD_ALL_NUMBER) && pfnUnicodeStrlen(pbNumber))
  1999.         {
  2000.             g_phb_cntx.number_to_dial[i] = (U8*) pbNumber;
  2001.             numberTypeImageList[i++] = IMG_MOBILE_NUMBER;
  2002.         }
  2003.     #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  2004.     #ifdef __MMI_PHB_USIM_FIELD__
  2005.         if (store_index >= MAX_PB_PHONE_ENTRIES)
  2006.         {
  2007.             mmi_phb_op_set_option_data_by_usim_index((U16) store_index, &PhoneBookOptionalFields);
  2008.         }
  2009.         else
  2010.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  2011.         {
  2012.             ReadRecord(
  2013.                 NVRAM_EF_PHB_FIELDS_LID,
  2014.                 (U16) (store_index + 1),
  2015.                 (void*)&PhoneBookOptionalFields,
  2016.                 OPTIONAL_FIELDS_RECORD_SIZE,
  2017.                 &pError);
  2018.         }
  2019.         if (phb_list_view_type & MMI_PHB_ENTRY_FIELD_ALL_NUMBER)
  2020.         {
  2021.             AnsiiToUnicodeString(pbHomeNumber, (PS8) PhoneBookOptionalFields.homeNumber);
  2022.             if (pfnUnicodeStrlen(pbHomeNumber))
  2023.             {
  2024.                 g_phb_cntx.number_to_dial[i] = (PU8) pbHomeNumber;
  2025.                 numberTypeImageList[i++] = IMG_HOME_NUMBER;
  2026.             }
  2027.             AnsiiToUnicodeString(pbOfficeNumber, (PS8) PhoneBookOptionalFields.officeNumber);
  2028.             if (pfnUnicodeStrlen(pbOfficeNumber))
  2029.             {
  2030.                 g_phb_cntx.number_to_dial[i] = (PU8) pbOfficeNumber;
  2031.                 numberTypeImageList[i++] = IMG_OFFICE_NUMBER;
  2032.             }
  2033.             AnsiiToUnicodeString(pbFaxNumber, (PS8) PhoneBookOptionalFields.faxNumber);
  2034.             if (pfnUnicodeStrlen(pbFaxNumber))
  2035.             {
  2036.                 g_phb_cntx.number_to_dial[i] = (PU8) pbFaxNumber;
  2037.                 numberTypeImageList[i++] = IMG_FAX_NUMBER;
  2038.             }
  2039.         }
  2040.         if (phb_list_view_type & MMI_PHB_ENTRY_FIELD_EMAIL)
  2041.         {
  2042.             AnsiiToUnicodeString(pbEmailAddress, (PS8) PhoneBookOptionalFields.emailAddress);
  2043.             if (pfnUnicodeStrlen(pbEmailAddress))
  2044.             {
  2045.                 g_phb_cntx.number_to_dial[i] = (PU8) pbEmailAddress;
  2046.                 numberTypeImageList[i++] = IMG_EMAIL_ADDRESS;
  2047.             }
  2048.         }
  2049.     #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  2050.         if (!i)
  2051.         {
  2052.             DisplayPopup(
  2053.                 (PU8) GetString(STR_NO_NUMBER_TO_DIAL),
  2054.                 IMG_GLOBAL_ERROR,
  2055.                 FALSE,
  2056.                 PHB_NOTIFY_TIMEOUT,
  2057.                 ERROR_TONE);
  2058.         }
  2059.         else if (i == 1)
  2060.         {
  2061.             g_phb_cntx.active_index_third = 0;
  2062.             mmi_phb_pre_send_data();
  2063.         }
  2064.         else
  2065.         {
  2066.             EntryNewScreen(
  2067.                 SCR_ID_PHB_MMS_CHOOSE_ENTRY,
  2068.                 mmi_phb_exit_mms_choose_number,
  2069.                 mmi_phb_entry_choose_number,
  2070.                 NULL);
  2071.             guiBuffer = GetCurrGuiBuffer(SCR_ID_PHB_MMS_CHOOSE_ENTRY);
  2072.             RegisterHighlightHandler(mmi_phb_get_index_third_level);
  2073.             ShowCategory53Screen(
  2074.                 STR_CHOOSE_NUMBER_CAPTION,
  2075.                 IMG_SCR_PBOOK_CAPTION,
  2076.                 STR_GLOBAL_OK,
  2077.                 IMG_GLOBAL_OK,
  2078.                 STR_GLOBAL_BACK,
  2079.                 IMG_GLOBAL_BACK,
  2080.                 i,
  2081.                 g_phb_cntx.number_to_dial,
  2082.                 numberTypeImageList,
  2083.                 NULL,
  2084.                 0,
  2085.                 0,
  2086.                 guiBuffer);
  2087.             SetLeftSoftkeyFunction(mmi_phb_pre_send_data, KEY_EVENT_UP);
  2088.             SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2089.         }
  2090.     }
  2091. }
  2092. /*****************************************************************************
  2093.  * FUNCTION
  2094.  *  mmi_phb_list_entry_for_number_and_email
  2095.  * DESCRIPTION
  2096.  *  This function provide call back function before enter phonebook list
  2097.  * PARAMETERS
  2098.  *  
  2099.  * RETURNS
  2100.  *  void
  2101.  *****************************************************************************/
  2102. void mmi_phb_list_entry_for_number_and_email(void)
  2103. {
  2104.     /*----------------------------------------------------------------*/
  2105.     /* Local Variables                                                */
  2106.     /*----------------------------------------------------------------*/
  2107.     U16 i;
  2108.     U16 EntryCount = 0;
  2109.     U16 store_index;
  2110.     /*----------------------------------------------------------------*/
  2111.     /* Code Body                                                      */
  2112.     /*----------------------------------------------------------------*/
  2113.     PRINT_INFORMATION_2((MMI_TRACE_G4_PHB,
  2114.                          "File: [%s]  Line: [%d] <<mmi_phb_list_entry_for_number_and_email.>n", __FILE__,
  2115.                          __LINE__));
  2116. #ifdef __SYNCML_SUPPORT__
  2117.     if (mmi_syncml_is_phb_sync_now())
  2118.     {
  2119.         mmi_phb_entry_not_ready(STR_ID_SYNC_PLEASE_WAIT);
  2120.     }
  2121.     else
  2122. #endif /* __SYNCML_SUPPORT__ */
  2123.     if (g_phb_cntx.phb_ready && !g_phb_cntx.processing)
  2124.     {
  2125.         /* Allocate buffer for phonebook memeber list filter */
  2126.         mmi_phb_list_allocate_filter();
  2127.         /* Build list according to filter */
  2128.         for (i = 0; i < PhoneBookEntryCount; i++)
  2129.         {
  2130.             store_index = g_phb_name_index[i];
  2131.             if (phb_list_view_type == MMI_PHB_ENTRY_FIELD_NAME || 
  2132.                 PhoneBook[store_index].field & phb_list_view_type)
  2133.             {
  2134.                 g_phb_cntx.list_filter[EntryCount] = store_index;
  2135.                 EntryCount++;
  2136.             }
  2137.         }
  2138.         if (EntryCount)
  2139.         {
  2140.             g_phb_cntx.highlight_entry = 0;
  2141.             phbListView = MMI_PHB_LIST_FOR_OTHER_APP;
  2142.             mmi_phb_entry_list(
  2143.                 EntryCount,                                 /* Total Entry */
  2144.                 STR_SCR_PBOOK_VIEW_CAPTION,                 /* Title String */
  2145.                 IMG_SCR_PBOOK_CAPTION,                      /* Title Image */
  2146.                 STR_GLOBAL_OK,                              /* LSK */
  2147.                 IMG_GLOBAL_OK,                              /* LSK */
  2148.                 mmi_phb_get_index_by_store_location_second, /* Highlight Callback */
  2149.                 mmi_phb_entry_choose_number,            /* LSK Callback */
  2150.                 mmi_phb_entry_choose_number,            /* SEND Key Callback */
  2151.                 mmi_phb_mms_email_list_get_item,            /* List Callback */
  2152.                 mmi_phb_mms_email_list_get_hint,            /* Hint Callback */
  2153.                 mmi_phb_list_entry_for_number_and_email, /* Re-Entry Callback */
  2154.                 TRUE,                                       /* Alpha Index */
  2155.                 TRUE);                                      /* Right Arrow Key */
  2156.         }
  2157.         else
  2158.         {
  2159.             DisplayPopup(
  2160.                 (PU8) GetString(STR_ID_PHB_NO_ENTRY_TO_SELECT),
  2161.                 IMG_GLOBAL_EMPTY,
  2162.                 TRUE,
  2163.                 PHB_NOTIFY_TIMEOUT,
  2164.                 EMPTY_LIST_TONE);
  2165.             mmi_phb_list_free_filter();
  2166.         }
  2167.     }
  2168.     else
  2169.     {
  2170.         mmi_phb_entry_not_ready(STR_PROCESSING_PHONEBOOK);
  2171.     }
  2172. }
  2173. /*****************************************************************************
  2174.  * FUNCTION
  2175.  *  mmi_phb_list_pre_entry_for_number_and_email
  2176.  * DESCRIPTION
  2177.  *  This function provide call back function before enter phonebook list
  2178.  * PARAMETERS
  2179.  *  filter_type        [IN]        filter type
  2180.  *  list_view_call_back    [IN]        call back function after user chooses an entry
  2181.  * RETURNS
  2182.  *  void
  2183.  *****************************************************************************/
  2184. void mmi_phb_list_pre_entry_for_number_and_email(U8 filter_type, mmi_phb_get_data_callback_type list_view_call_back)
  2185. {
  2186.     phb_list_view_type = filter_type;
  2187.     phb_list_view_call_back = list_view_call_back;
  2188.     mmi_phb_list_entry_for_number_and_email();
  2189. }
  2190. /*------------------------------------------------------  Interface for MMS  ------------------------------------------------------*/
  2191. #define MMI_PHB_INTERFACE_FOR_MMS
  2192. #if (defined(MMS_SUPPORT) && (defined(OBIGO_SUPPORT) || defined (JATAAYU_SUPPORT)))
  2193. /*****************************************************************************
  2194.  * FUNCTION
  2195.  *  EntryPhbFromMMSNumber
  2196.  * DESCRIPTION
  2197.  *  Entry phonebook list from MMS, list entry with number field only
  2198.  * PARAMETERS
  2199.  *  void
  2200.  * RETURNS
  2201.  *  void
  2202.  *****************************************************************************/
  2203. void EntryPhbFromMMSNumber(void)
  2204. {
  2205.     /*----------------------------------------------------------------*/
  2206.     /* Local Variables                                                */
  2207.     /*----------------------------------------------------------------*/
  2208.     /*----------------------------------------------------------------*/
  2209.     /* Code Body                                                      */
  2210.     /*----------------------------------------------------------------*/
  2211.     mmi_phb_list_pre_entry_for_number_and_email(MMI_PHB_ENTRY_FIELD_ALL_NUMBER, mmi_phb_mms_send_data_to_mms);
  2212. }
  2213. /*****************************************************************************
  2214.  * FUNCTION
  2215.  *  EntryPhbFromMMSEmail
  2216.  * DESCRIPTION
  2217.  *  Entry phonebook list from MMS, list entry with email field only
  2218.  * PARAMETERS
  2219.  *  void
  2220.  * RETURNS
  2221.  *  void
  2222.  *****************************************************************************/
  2223. void EntryPhbFromMMSEmail(void)
  2224. {
  2225.     /*----------------------------------------------------------------*/
  2226.     /* Local Variables                                                */
  2227.     /*----------------------------------------------------------------*/
  2228.     /*----------------------------------------------------------------*/
  2229.     /* Code Body                                                      */
  2230.     /*----------------------------------------------------------------*/
  2231.     mmi_phb_list_pre_entry_for_number_and_email(MMI_PHB_ENTRY_FIELD_EMAIL, mmi_phb_mms_send_data_to_mms);
  2232. }
  2233. /*****************************************************************************
  2234.  * FUNCTION
  2235.  *  EntryPhbFromMMSAll
  2236.  * DESCRIPTION
  2237.  *  Entry phonebook list from MMS, list all entry
  2238.  * PARAMETERS
  2239.  *  void
  2240.  * RETURNS
  2241.  *  void
  2242.  *****************************************************************************/
  2243. void EntryPhbFromMMSAll(void)
  2244. {
  2245.     /*----------------------------------------------------------------*/
  2246.     /* Local Variables                                                */
  2247.     /*----------------------------------------------------------------*/
  2248.     /*----------------------------------------------------------------*/
  2249.     /* Code Body                                                      */
  2250.     /*----------------------------------------------------------------*/
  2251.     phbListView = MMI_PHB_LIST_FOR_MMS_ALL;
  2252.     mmi_phb_list_pre_entry_second_level();
  2253. }
  2254. /*****************************************************************************
  2255.  * FUNCTION
  2256.  *  mmi_phb_entry_mms_choose_number
  2257.  * DESCRIPTION
  2258.  *  Entry Choose entry screen if there are more then one entry with number field.
  2259.  * PARAMETERS
  2260.  *  void
  2261.  * RETURNS
  2262.  *  void
  2263.  *****************************************************************************/
  2264. void mmi_phb_entry_mms_choose_number(void)
  2265. {
  2266.     /*----------------------------------------------------------------*/
  2267.     /* Local Variables                                                */
  2268.     /*----------------------------------------------------------------*/
  2269.     U16 i;
  2270.     U8 *guiBuffer;
  2271.     U16 numberTypeImageList[5];
  2272.     S16 pError;
  2273.     U16 store_index;
  2274.     /*----------------------------------------------------------------*/
  2275.     /* Code Body                                                      */
  2276.     /*----------------------------------------------------------------*/
  2277.     store_index = g_phb_name_index[g_phb_cntx.active_index_second];
  2278.     pfnUnicodeStrcpy(pbName, (PS8) PhoneBook[store_index].alpha_id.name);
  2279.     mmi_phb_convert_get_ucs2_number(pbNumber, store_index); /* BCD number format. */
  2280. #ifndef __MMI_PHB_USIM_FIELD__
  2281.     if (store_index >= MAX_PB_PHONE_ENTRIES)   /* In SIM */
  2282.     {
  2283.         if (!pfnUnicodeStrlen(pbNumber))
  2284.         {
  2285.             DisplayPopup(
  2286.                 (PU8) GetString(STR_NO_NUMBER_TO_DIAL),
  2287.                 IMG_GLOBAL_ERROR,
  2288.                 FALSE,
  2289.                 PHB_NOTIFY_TIMEOUT,
  2290.                 ERROR_TONE);
  2291.         }
  2292.         else
  2293.         {
  2294.             g_phb_cntx.number_to_dial[0] = (U8*) pbNumber;
  2295.             g_phb_cntx.active_index_third = 0;
  2296.             mmi_phb_mms_pre_send_data_to_mms();
  2297.         }
  2298.     }
  2299.     else
  2300. #endif /* __MMI_PHB_USIM_FIELD__ */ 
  2301.     {
  2302.         i = 0;
  2303.         if (pfnUnicodeStrlen(pbNumber))
  2304.         {
  2305.             g_phb_cntx.number_to_dial[i] = (U8*) pbNumber;
  2306.             numberTypeImageList[i++] = IMG_MOBILE_NUMBER;
  2307.         }
  2308.     #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
  2309.     #ifdef __MMI_PHB_USIM_FIELD__
  2310.         if (store_index >= MAX_PB_PHONE_ENTRIES)
  2311.         {
  2312.             mmi_phb_op_set_option_data_by_usim_index((U16) store_index, &PhoneBookOptionalFields);
  2313.         }
  2314.         else
  2315.     #endif /* __MMI_PHB_USIM_FIELD__ */ 
  2316.         {
  2317.             ReadRecord(
  2318.                 NVRAM_EF_PHB_FIELDS_LID,
  2319.                 (U16) (store_index + 1),
  2320.                 (void*)&PhoneBookOptionalFields,
  2321.                 OPTIONAL_FIELDS_RECORD_SIZE,
  2322.                 &pError);
  2323.         }
  2324.         /* All Number */
  2325.         AnsiiToUnicodeString(pbHomeNumber, (PS8) PhoneBookOptionalFields.homeNumber);
  2326.         if (pfnUnicodeStrlen(pbHomeNumber))
  2327.         {
  2328.             g_phb_cntx.number_to_dial[i] = (PU8) pbHomeNumber;
  2329.             numberTypeImageList[i++] = IMG_HOME_NUMBER;
  2330.         }
  2331.         AnsiiToUnicodeString(pbOfficeNumber, (PS8) PhoneBookOptionalFields.officeNumber);
  2332.         if (pfnUnicodeStrlen(pbOfficeNumber))
  2333.         {
  2334.             g_phb_cntx.number_to_dial[i] = (PU8) pbOfficeNumber;
  2335.             numberTypeImageList[i++] = IMG_OFFICE_NUMBER;
  2336.         }
  2337.         AnsiiToUnicodeString(pbFaxNumber, (PS8) PhoneBookOptionalFields.faxNumber);
  2338.         if (pfnUnicodeStrlen(pbFaxNumber))
  2339.         {
  2340.             g_phb_cntx.number_to_dial[i] = (PU8) pbFaxNumber;
  2341.             numberTypeImageList[i++] = IMG_FAX_NUMBER;
  2342.         }
  2343.         /* Email */
  2344.         AnsiiToUnicodeString(pbEmailAddress, (PS8) PhoneBookOptionalFields.emailAddress);
  2345.         if (pfnUnicodeStrlen(pbEmailAddress))
  2346.         {
  2347.             g_phb_cntx.number_to_dial[i] = (PU8) pbEmailAddress;
  2348.             numberTypeImageList[i++] = IMG_EMAIL_ADDRESS;
  2349.         }
  2350.     #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */ 
  2351.         if (!i)
  2352.         {
  2353.             DisplayPopup(
  2354.                 (PU8) GetString(STR_NO_NUMBER_TO_DIAL),
  2355.                 IMG_GLOBAL_ERROR,
  2356.                 FALSE,
  2357.                 PHB_NOTIFY_TIMEOUT,
  2358.                 ERROR_TONE);
  2359.         }
  2360.         else if (i == 1)
  2361.         {
  2362.             g_phb_cntx.active_index_third = 0;
  2363.             mmi_phb_mms_pre_send_data_to_mms();
  2364.         }
  2365.         else
  2366.         {
  2367.             EntryNewScreen(
  2368.                 SCR_ID_PHB_MMS_CHOOSE_ENTRY,
  2369.                 mmi_phb_exit_mms_choose_number,
  2370.                 mmi_phb_entry_mms_choose_number,
  2371.                 NULL);
  2372.             guiBuffer = GetCurrGuiBuffer(SCR_ID_PHB_MMS_CHOOSE_ENTRY);
  2373.             RegisterHighlightHandler(mmi_phb_get_index_third_level);
  2374.             ShowCategory53Screen(
  2375.                 STR_CHOOSE_NUMBER_CAPTION,
  2376.                 IMG_SCR_PBOOK_CAPTION,
  2377.                 STR_GLOBAL_OK,
  2378.                 IMG_GLOBAL_OK,
  2379.                 STR_GLOBAL_BACK,
  2380.                 IMG_GLOBAL_BACK,
  2381.                 i,
  2382.                 g_phb_cntx.number_to_dial,
  2383.                 numberTypeImageList,
  2384.                 NULL,
  2385.                 0,
  2386.                 0,
  2387.                 guiBuffer);
  2388.             SetLeftSoftkeyFunction(mmi_phb_mms_pre_send_data_to_mms, KEY_EVENT_UP);
  2389.             SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  2390.         }
  2391.     }
  2392. }
  2393. /*****************************************************************************
  2394.  * FUNCTION
  2395.  *  mmi_phb_mms_pre_send_data_to_mms
  2396.  * DESCRIPTION
  2397.  *  Send choosed number to MMS
  2398.  * PARAMETERS
  2399.  *  void
  2400.  * RETURNS
  2401.  *  void
  2402.  *****************************************************************************/
  2403. void mmi_phb_mms_pre_send_data_to_mms(void)
  2404. {
  2405.     /*----------------------------------------------------------------*/
  2406.     /* Local Variables                                                */
  2407.     /*----------------------------------------------------------------*/
  2408.     /*----------------------------------------------------------------*/
  2409.     /* Code Body                                                      */
  2410.     /*----------------------------------------------------------------*/
  2411.     mmi_phb_mms_send_data_to_mms(pbName, (S8*) g_phb_cntx.number_to_dial[g_phb_cntx.active_index_third]);
  2412. }
  2413. /*****************************************************************************
  2414.  * FUNCTION
  2415.  *  mmi_phb_mms_send_data_to_mms
  2416.  * DESCRIPTION
  2417.  *  send entry name and choosed number to MMS by sending primitives
  2418.  * PARAMETERS
  2419.  *  name        [IN]        Name field to be sent
  2420.  *  number      [IN]        Number field to be sent.
  2421.  * RETURNS
  2422.  *  void
  2423.  *****************************************************************************/
  2424. void mmi_phb_mms_send_data_to_mms(S8 *name, S8 *number)
  2425. {
  2426.     /*----------------------------------------------------------------*/
  2427.     /* Local Variables                                                */
  2428.     /*----------------------------------------------------------------*/