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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * JBrowserMMIBookmarks.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for bookmark implementation.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  *------------------------------------------------------------------------------
  72.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  73.  *============================================================================
  74.  ****************************************************************************/
  75. #ifndef _MMI_JBROWSERMMIBOOKMARKS_C
  76. #define _MMI_JBROWSERMMIBOOKMARKS_C
  77. /*  Include: MMI header file */
  78. #include "MMI_features.h"
  79. #if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
  80. #include "PixtelDataTypes.h"
  81. #include "Unicodexdcl.h"
  82. #include "HistoryGprot.h"
  83. #include "GlobalDefs.h"
  84. #include "SettingProfile.h"
  85. #include "DebugInitDef.h"
  86. #include "CommonScreens.h"
  87. #include "EventsGprot.h"
  88. #include "wgui_inputs.h"
  89. #include "wgui_categories.h"
  90. #include "wgui_categories_inputs.h"
  91. #include "OrganizerDef.h"
  92. #include "DateTimeGprot.h"
  93. #include "TimerEvents.h"
  94. #include "wgui_categories_popup.h"
  95. #include "settingGprots.h"
  96. #include "JBrowserMMIDefs.h"
  97. #include "JBrowserMMIProts.h"
  98. #include "JBrowserMMITypes.h"
  99. #include "JBrowserMMIGprots.h"
  100. #include "JProvWap.h"
  101. #include "jdd_ui_datatypes.h"
  102. #include "jdd_ui_utils.h"
  103. /*  Include: NVRAM header file */
  104. #include "NVRAMType.h"
  105. #include "NVRAMProt.h"
  106. #include "NVRAMEnum.h"
  107. /*  Include: Jataayu header file */
  108. #include "ddl.h"
  109. #include "jcal.h"
  110. #include "jdd_memapi.h"
  111. U8 g_brw_bkm_selected_title[(BRW_BKM_MAX_TITLE_LENGTH) * ENCODING_LENGTH];
  112. U8 g_brw_bkm_selected_url[(BRW_BKM_MAX_URL_LENGTH) * ENCODING_LENGTH];  /* Dara changed as will be used in other file */
  113. brw_status_enum edit_flag;  /* Dara changed as will be used in other file */
  114. PROV_RETCODE mmi_brw_add_prov_bookmark(U8 *, U8 *);
  115. /* Extern Function,variables */
  116. extern pBOOL GetUCS2Flag(PS8 buffer);
  117. static U8 g_brw_bkm_add_flag;
  118. /*****************************************************************************
  119.  * FUNCTION
  120.  *  mmi_brw_entry_bookmark_list
  121.  * DESCRIPTION
  122.  *  Entry function for Bookmark list screen
  123.  * PARAMETERS
  124.  *  void
  125.  * RETURNS
  126.  *  void
  127.  *****************************************************************************/
  128. void mmi_brw_entry_bookmark_list(void)
  129. {
  130.     /*----------------------------------------------------------------*/
  131.     /* Local Variables                                                */
  132.     /*----------------------------------------------------------------*/
  133.     U8 *guiBuffer;
  134.     U16 nEmptyId = STR_ID_BRW_EMPTY;
  135.     U8 highlight_index = 0;
  136.     /*----------------------------------------------------------------*/
  137.     /* Code Body                                                      */
  138.     /*----------------------------------------------------------------*/
  139.     EntryNewScreen(SCR_ID_BRW_BOOKMARKS, NULL, mmi_brw_entry_bookmark_list, NULL);
  140.     guiBuffer = GetCurrGuiBuffer(SCR_ID_BRW_BOOKMARKS);
  141.     //      SetParentHandler(0);//comment by tk
  142.     //      RegisterHighlightHandler(ExecuteCurrHiliteHandler);//comment by tk
  143.     /* read bookmark from NVRAM */
  144.     mmi_brw_read_bookmark_from_nvram();
  145.     /* Display 'Empty' if no bookmarks are present */
  146.     if (g_brw_cntx.total_bookmark_items == 0)
  147.     {
  148.         ShowCategory15Screen(
  149.             STR_ID_BRW_BOOKMARKS,
  150.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  151.             STR_GLOBAL_OPTIONS,
  152.             0,
  153.             STR_GLOBAL_BACK,
  154.             0,
  155.             1,
  156.             &nEmptyId,
  157.             (U16*) gIndexIconsImageList,
  158.             LIST_MENU,
  159.             0,
  160.             guiBuffer);
  161.         SetLeftSoftkeyFunction(mmi_brw_pre_entry_bookmark_options, KEY_EVENT_UP);
  162.         SetKeyHandler(mmi_brw_pre_entry_bookmark_options, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  163.     }
  164.     else
  165.     {
  166.         if (guiBuffer != NULL)
  167.         {
  168.             if (g_brw_bkm_add_flag)
  169.             {
  170.                 guiBuffer = NULL;
  171.                 highlight_index = g_brw_cntx.index_highlighted_item;
  172.                 g_brw_bkm_add_flag = 0;
  173.             }
  174.         }
  175.         ShowCategory184Screen(
  176.             STR_ID_BRW_BOOKMARKS,
  177.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  178.             STR_GLOBAL_OPTIONS,
  179.             0,
  180.             STR_GLOBAL_BACK,
  181.             0,
  182.             g_brw_cntx.total_bookmark_items,
  183.             mmi_brw_bookmark_list_get_item,
  184.             0,
  185.             highlight_index,
  186.             guiBuffer);
  187.         SetLeftSoftkeyFunction(mmi_brw_pre_entry_bookmark_options, KEY_EVENT_UP);
  188.         SetKeyHandler(mmi_brw_pre_entry_bookmark_options, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  189.     }
  190.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  191.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  192. }
  193. /*****************************************************************************
  194.  * FUNCTION
  195.  *  mmi_brw_bookmark_list_get_item
  196.  * DESCRIPTION
  197.  *  Item call back function for dynamic list of bookmarks
  198.  * PARAMETERS
  199.  *  item_index          [IN]        Highlighted item index
  200.  *  str_buff            [IN]        Buffer to be shown
  201.  *  img_buff_p          [?]         [?]         image to be shown
  202.  *  str_img_mask        [IN]        
  203.  * RETURNS
  204.  *  void
  205.  *****************************************************************************/
  206. pBOOL mmi_brw_bookmark_list_get_item(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
  207. {
  208.     /*----------------------------------------------------------------*/
  209.     /* Local Variables                                                */
  210.     /*----------------------------------------------------------------*/
  211.     S8 pOutBuffer[8];
  212.     /*----------------------------------------------------------------*/
  213.     /* Code Body                                                      */
  214.     /*----------------------------------------------------------------*/
  215.     if ((item_index < 0) || (item_index > BRW_MAX_BOOKMARKS))
  216.     {
  217.         return FALSE;
  218.     }
  219.     /* Display title if settings option is 'Show history by title'*/
  220. if (g_brw_cntx.show_history_as_url)
  221. {
  222. /* truncate the URL to 38 charactes and append three '.'(dots) if the length of URL exceeds 
  223.    MAX_SUBMENU_CHARACTERS charactes */
  224. if (strlen((S8*) g_brw_cntx.bookmark_url_p[item_index].url) > MAX_SUBMENU_CHARACTERS)
  225. {
  226. AnsiiNToUnicodeString(
  227. (S8*) str_buff,
  228. (S8*) g_brw_cntx.bookmark_url_p[item_index].url,
  229. BRW_MAX_VISIBLE_URL_LENGTH);
  230. str_buff[BRW_MAX_VISIBLE_URL_LENGTH] = '';
  231. AnsiiToUnicodeString(pOutBuffer, (S8*) "...");
  232. pfnUnicodeStrcat((S8*) str_buff, (S8*) pOutBuffer);
  233. }
  234. else
  235. {
  236. AnsiiToUnicodeString((S8*) str_buff, (S8*) g_brw_cntx.bookmark_url_p[item_index].url);
  237. }
  238. }
  239. else
  240. {
  241. if ((g_brw_cntx.bookmark_title_p[item_index].dcs == BRW_DCS_ASCII) &&
  242. (strlen((S8*) g_brw_cntx.bookmark_title_p[item_index].title)) != 0)
  243. {
  244. AnsiiToUnicodeString((S8*) str_buff, (S8*) g_brw_cntx.bookmark_title_p[item_index].title);
  245. }
  246. else if ((g_brw_cntx.bookmark_title_p[item_index].dcs == BRW_DCS_UCS) &&
  247.  (pfnUnicodeStrlen((S8*) g_brw_cntx.bookmark_title_p[item_index].title)) != 0)
  248. {
  249. pfnUnicodeStrcpy((S8*) str_buff, (S8*) g_brw_cntx.bookmark_title_p[item_index].title);
  250. }
  251. /* end */
  252. else
  253. {
  254. /* truncate the URL to 38 charactes and append three '.'(dots) if the length of URL exceeds 
  255.    MAX_SUBMENU_CHARACTERS charactes */
  256. if (strlen((S8*) g_brw_cntx.bookmark_url_p[item_index].url) > MAX_SUBMENU_CHARACTERS)
  257. {
  258. AnsiiNToUnicodeString(
  259. (S8*) str_buff,
  260. (S8*) g_brw_cntx.bookmark_url_p[item_index].url,
  261. BRW_MAX_VISIBLE_URL_LENGTH);
  262. str_buff[BRW_MAX_VISIBLE_URL_LENGTH] = '';
  263. AnsiiToUnicodeString(pOutBuffer, (S8*) "...");
  264. pfnUnicodeStrcat((S8*) str_buff, (S8*) pOutBuffer);
  265. }
  266. else
  267. {
  268. AnsiiToUnicodeString((S8*) str_buff, (S8*) g_brw_cntx.bookmark_url_p[item_index].url);
  269. }
  270. }
  271. }
  272.     *img_buff_p = get_image(gIndexIconsImageList[item_index]);
  273.     return TRUE;
  274. }
  275. /*****************************************************************************
  276.  * FUNCTION
  277.  *  mmi_brw_calculate_number_of_bookmarks_stored
  278.  * DESCRIPTION
  279.  *  Function to calculate the total number of bookmarks stored
  280.  * PARAMETERS
  281.  *  void
  282.  * RETURNS
  283.  *  void
  284.  *****************************************************************************/
  285. void mmi_brw_calculate_number_of_bookmarks_stored(void)
  286. {
  287.     /*----------------------------------------------------------------*/
  288.     /* Local Variables                                                */
  289.     /*----------------------------------------------------------------*/
  290.     U16 bkm_count = 0;
  291.     /*----------------------------------------------------------------*/
  292.     /* Code Body                                                      */
  293.     /*----------------------------------------------------------------*/
  294.     for (bkm_count = 0; bkm_count < BRW_MAX_BOOKMARKS; bkm_count++)
  295.     {
  296.         if ((strlen((S8*) g_brw_cntx.bookmark_title_p[bkm_count].title)) == 0)
  297.         {
  298.             /* If both title and url are '0' exit the loop */
  299.             if ((strlen((S8*) g_brw_cntx.bookmark_url_p[bkm_count].url)) == 0)
  300.             {
  301.                 break;
  302.             }
  303.         }
  304.         g_brw_cntx.total_bookmark_items++;
  305.     }
  306. }
  307. /*****************************************************************************
  308.  * FUNCTION
  309.  *  mmi_brw_pre_entry_bookmark_options
  310.  * DESCRIPTION
  311.  *  Pre Entry function for Bookmark options screen.
  312.  * PARAMETERS
  313.  *  void
  314.  * RETURNS
  315.  *  void
  316.  *****************************************************************************/
  317. void mmi_brw_pre_entry_bookmark_options(void)
  318. {
  319.     /*----------------------------------------------------------------*/
  320.     /* Local Variables                                                */
  321.     /*----------------------------------------------------------------*/
  322.     /*----------------------------------------------------------------*/
  323.     /* Code Body                                                      */
  324.     /*----------------------------------------------------------------*/
  325.     /* Get the current highlited bookmark index */
  326.     g_brw_cntx.index_highlighted_item = (U8) GetHighlightedItem();
  327.     mmi_brw_entry_bookmark_options();
  328. }
  329. /*****************************************************************************
  330.  * FUNCTION
  331.  *  mmi_brw_entry_bookmark_options
  332.  * DESCRIPTION
  333.  *  Entry function for Bookmark options screen.
  334.  * PARAMETERS
  335.  *  void
  336.  * RETURNS
  337.  *  void
  338.  *****************************************************************************/
  339. void mmi_brw_entry_bookmark_options(void)
  340. {
  341.     /*----------------------------------------------------------------*/
  342.     /* Local Variables                                                */
  343.     /*----------------------------------------------------------------*/
  344.     U16 UC_list_of_items[6];
  345.     U8 *guiBuffer;
  346.     S32 num_of_items;
  347.     /*----------------------------------------------------------------*/
  348.     /* Code Body                                                      */
  349.     /*----------------------------------------------------------------*/
  350.     EntryNewScreen(SCR_ID_BRW_BOOKMARK_OPTIONS, NULL, mmi_brw_entry_bookmark_options, NULL);
  351.     guiBuffer = GetCurrGuiBuffer(SCR_ID_BRW_BOOKMARK_OPTIONS);
  352.     /* If no bookmarks are present, Display scren with only one option i.e 'Add bookmark' */
  353.     if (g_brw_cntx.total_bookmark_items == 0)
  354.     {
  355.         num_of_items = GetNumOfChild(MENU_ID_BRW_BKM_OPTIONS_1);
  356.         GetSequenceStringIds(MENU_ID_BRW_BKM_OPTIONS_1, UC_list_of_items);
  357.         SetParentHandler(MENU_ID_BRW_BKM_OPTIONS_1);
  358.         RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  359.         ShowCategory15Screen(
  360.             STR_ID_BRW_OPTION,
  361.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  362.             STR_GLOBAL_OK,
  363.             0,
  364.             STR_GLOBAL_BACK,
  365.             0,
  366.             num_of_items,
  367.             UC_list_of_items,
  368.             (U16*) gIndexIconsImageList,
  369.             LIST_MENU,
  370.             0,
  371.             guiBuffer);
  372.     }
  373.     else
  374.     {
  375.         num_of_items = GetNumOfChild(MENU_ID_BRW_BKM_OPTIONS_2);
  376.         GetSequenceStringIds(MENU_ID_BRW_BKM_OPTIONS_2, UC_list_of_items);
  377.         SetParentHandler(MENU_ID_BRW_BKM_OPTIONS_2);
  378.         RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  379.         ShowCategory15Screen(
  380.             STR_ID_BRW_OPTION,
  381.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  382.             STR_GLOBAL_OK,
  383.             0,
  384.             STR_GLOBAL_BACK,
  385.             0,
  386.             num_of_items,
  387.             UC_list_of_items,
  388.             (U16*) gIndexIconsImageList,
  389.             LIST_MENU,
  390.             0,
  391.             guiBuffer);
  392.     }
  393.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  394.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  395. }
  396. /*****************************************************************************
  397.  * FUNCTION
  398.  *  mmi_brw_pre_entry_add_bookmark
  399.  * DESCRIPTION
  400.  *  Pre Entry function for Add bookmark screen
  401.  * PARAMETERS
  402.  *  void
  403.  * RETURNS
  404.  *  void
  405.  *****************************************************************************/
  406. void mmi_brw_pre_entry_add_bookmark(void)
  407. {
  408.     /* If Bookmark list is full, Dispaly 'Bookmark list is full' */
  409.     if (g_brw_cntx.total_bookmark_items >= BRW_MAX_BOOKMARKS)
  410.     {
  411. DisplayPopup((PU8) GetString(STR_ID_BRW_BOOKMARK_FULL),
  412. IMG_GLOBAL_ERROR,
  413. 1,
  414. JBROWSER_POPUP_TIME,
  415. ERROR_TONE);
  416.     }
  417.     else
  418.     {
  419. memset(g_brw_bkm_selected_title, 0, sizeof(g_brw_bkm_selected_title));
  420. AnsiiToUnicodeString((S8*) g_brw_bkm_selected_url, (S8*) ("http://"));
  421. /* Set edit flag */
  422. edit_flag = BRW_STATUS_NO;
  423. mmi_brw_entry_add_bookmark_screen_for_all();
  424. }
  425. }
  426. /*****************************************************************************
  427.  * FUNCTION
  428.  *  mmi_brw_entry_add_bookmark_screen_for_all
  429.  * DESCRIPTION
  430.  *  Entry function for Add bookmark screen
  431.  * PARAMETERS
  432.  *  void
  433.  * RETURNS
  434.  *  void
  435.  *****************************************************************************/
  436. void mmi_brw_entry_add_bookmark_screen_for_all(void)
  437. {
  438.     /*----------------------------------------------------------------*/
  439.     /* Local Variables                                                */
  440.     /*----------------------------------------------------------------*/
  441.     U8 *guiBuffer;
  442.     U8 *inputBuffer;
  443.     U16 inputBufferSize;
  444.     InlineItem brw_bookmark_inline_edit_list[4];
  445.     U16 IconsImageList[4] = {0};
  446. U16 stringID = 0;
  447.     /*----------------------------------------------------------------*/
  448.     /* Code Body                                                      */
  449.     /*----------------------------------------------------------------*/
  450.    
  451. memset(brw_bookmark_inline_edit_list, 0, sizeof(brw_bookmark_inline_edit_list));
  452.     EntryNewScreen(SCR_ID_BRW_ADD_BOOKMARK, mmi_brw_exit_add_bookmark_screen_for_all, NULL, NULL);
  453.         guiBuffer = GetCurrGuiBuffer(SCR_ID_BRW_ADD_BOOKMARK);
  454.         InitializeCategory57Screen();
  455.         
  456.         /* For title caption */
  457.         SetInlineItemActivation(
  458.             &brw_bookmark_inline_edit_list[BRW_INLINE_TITLE_CAPTION],
  459.             INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  460.             0);
  461.         SetInlineItemCaption(
  462.             &brw_bookmark_inline_edit_list[BRW_INLINE_TITLE_CAPTION],
  463.             (U8*) GetString(STR_ID_BRW_TITLE));
  464.         /* For title string */
  465.         SetInlineItemActivation(&brw_bookmark_inline_edit_list[BRW_INLINE_TITLE], KEY_LSK, KEY_EVENT_UP);
  466.         SetInlineItemFullScreenEdit(
  467.             &brw_bookmark_inline_edit_list[BRW_INLINE_TITLE],
  468.             STR_ID_BRW_EDIT,
  469.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  470.             (U8*) g_brw_bkm_selected_title,
  471.             BRW_BKM_MAX_TITLE_LENGTH,
  472.             INPUT_TYPE_ALPHANUMERIC_SENTENCECASE | INPUT_TYPE_USE_ENCODING_BASED_LENGTH | INPUT_TYPE_ONE_LESS_CHARACTER);
  473.         SetInlineFullScreenEditCustomFunction(
  474.             &brw_bookmark_inline_edit_list[BRW_INLINE_TITLE],
  475.             mmi_brw_full_screen_edit);
  476.         /* For Address caption */
  477.         SetInlineItemActivation(
  478.             &brw_bookmark_inline_edit_list[BRW_INLINE_ADDRESS_CAPTION],
  479.             INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  480.             0);
  481.         SetInlineItemCaption(
  482.             &brw_bookmark_inline_edit_list[BRW_INLINE_ADDRESS_CAPTION],
  483.             (U8*) GetString(STR_ID_BRW_ADDRESS));
  484.         /* For Address string (URL) */
  485.         SetInlineItemActivation(&brw_bookmark_inline_edit_list[BRW_INLINE_URL], KEY_LSK, KEY_EVENT_UP);
  486.         SetInlineItemFullScreenEdit(
  487.             &brw_bookmark_inline_edit_list[BRW_INLINE_URL],
  488.             STR_ID_BRW_EDIT,
  489.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  490.             (U8*) g_brw_bkm_selected_url,
  491.             BRW_BKM_MAX_URL_LENGTH,
  492.             INPUT_TYPE_ALPHANUMERIC_LOWERCASE | INPUT_TYPE_OVERRIDE_DEFAULT | INPUT_TYPE_USE_ONLY_ENGLISH_MODES);
  493.         SetInlineFullScreenEditCustomFunction(&brw_bookmark_inline_edit_list[BRW_INLINE_URL], mmi_brw_full_screen_edit);
  494.         inputBuffer = GetCurrNInputBuffer(SCR_ID_BRW_ADD_BOOKMARK, &inputBufferSize);
  495.         if (inputBuffer != NULL)
  496.         {
  497.             SetCategory57Data(brw_bookmark_inline_edit_list, 4, inputBuffer);
  498.         }
  499.         SetParentHandler(0);
  500.         /* Set the softkey label to be displayed in  Category57 screen */
  501.         RegisterHighlightHandler(mmi_brw_change_label_highlight_hdlr);
  502.         IconsImageList[0] = gIndexIconsImageList[0];
  503.         IconsImageList[2] = gIndexIconsImageList[1];
  504. if (edit_flag == BRW_STATUS_FROM_ENTER_ADDRESS || edit_flag == BRW_ADD_BKM_FROM_USE_URL)
  505. {
  506. if ((GetInlineDoneFlag(guiBuffer) == 0))
  507. {
  508. SetInlineDoneFlag(guiBuffer);
  509. }
  510. set_wgui_inline_list_menu_status(1);
  511. }
  512. if (edit_flag == BRW_STATUS_NO || edit_flag == BRW_STATUS_FROM_ENTER_ADDRESS
  513. || edit_flag == BRW_ADD_BKM_FROM_USE_URL)
  514. {
  515. stringID = STR_ID_BRW_ADD_BOOKMARK;
  516. }
  517. else if (edit_flag == BRW_STATUS_YES)
  518. {
  519. stringID = STR_ID_BRW_EDIT_BOOKMARK;
  520. }
  521.         ShowCategory57Screen(
  522.         stringID,
  523.             GetRootTitleIcon(SERVICES_WAP_MENU_ID),
  524.             STR_GLOBAL_OK,
  525.             IMG_GLOBAL_OK,
  526.             STR_GLOBAL_BACK,
  527.             IMG_GLOBAL_BACK,
  528.             4,
  529.             (U16*) IconsImageList,
  530.             brw_bookmark_inline_edit_list,
  531.             0,
  532.             guiBuffer);
  533.         /* Register function for right soft key */
  534.         SetCategory57RightSoftkeyFunctions(mmi_brw_entry_confirmation_hdlr, GoBackHistory);
  535.     }
  536. /*****************************************************************************
  537.  * FUNCTION
  538.  *  mmi_brw_exit_add_bookmark_screen_for_all
  539.  * DESCRIPTION
  540.  *  Exit function for Add/Edit bookmark screen
  541.  * PARAMETERS
  542.  *  void
  543.  * RETURNS
  544.  *  void
  545.  *****************************************************************************/
  546. void mmi_brw_exit_add_bookmark_screen_for_all(void)
  547. {
  548.     /*----------------------------------------------------------------*/
  549.     /* Local Variables                                                */
  550.     /*----------------------------------------------------------------*/
  551.     history Scr;
  552.     S16 nHistory = 0;
  553.     U16 inputBufferSize;    /* added for inline edit history */
  554.     /*----------------------------------------------------------------*/
  555.     /* Code Body                                                      */
  556.     /*----------------------------------------------------------------*/
  557.     Scr.scrnID = SCR_ID_BRW_ADD_BOOKMARK;
  558.     CloseCategory57Screen();
  559.     Scr.entryFuncPtr = mmi_brw_entry_add_bookmark_screen_for_all;
  560.     pfnUnicodeStrcpy((S8*) Scr.inputBuffer, (S8*) & nHistory);
  561.     GetCategory57History(Scr.guiBuffer);
  562.     inputBufferSize = (U16) GetCategory57DataSize();    /* added for inline edit history */
  563.     GetCategory57Data((U8*) Scr.inputBuffer);           /* added for inline edit history */
  564.     AddNHistory(Scr, (U16) inputBufferSize);            /* added for inline edit history */
  565. }
  566. /*****************************************************************************
  567.  * FUNCTION
  568.  *  mmi_brw_pre_entry_edit_bookmark
  569.  * DESCRIPTION
  570.  *  Pre Entry function for Edit bookmark screen
  571.  * PARAMETERS
  572.  *  void
  573.  * RETURNS
  574.  *  void
  575.  *****************************************************************************/
  576. void mmi_brw_pre_entry_edit_bookmark(void)
  577. {
  578.     if (g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].dcs == BRW_DCS_UCS)
  579.     {
  580.         pfnUnicodeStrcpy(
  581.             (S8*) g_brw_bkm_selected_title,
  582.             (S8*) g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].title);
  583.     }
  584.     else
  585.     {
  586.         AnsiiToUnicodeString(
  587.             (S8*) g_brw_bkm_selected_title,
  588.             (S8*) g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].title);
  589.     }
  590.     AnsiiToUnicodeString(
  591.         (S8*) g_brw_bkm_selected_url,
  592.         (S8*) g_brw_cntx.bookmark_url_p[g_brw_cntx.index_highlighted_item].url);
  593.     /* Set edit flag */
  594.     edit_flag = BRW_STATUS_YES;
  595. mmi_brw_entry_add_bookmark_screen_for_all();
  596. }
  597. /*****************************************************************************
  598.  * FUNCTION
  599.  *  mmi_brw_change_label_highlight_hdlr
  600.  * DESCRIPTION
  601.  *  Custom Highlight handler to change the label of LSK in case of inline edit screen.
  602.  * PARAMETERS
  603.  *  index       [IN]        
  604.  * RETURNS
  605.  *  void
  606.  *****************************************************************************/
  607. void mmi_brw_change_label_highlight_hdlr(S32 index)
  608. {
  609.     /*----------------------------------------------------------------*/
  610.     /* Local Variables                                                */
  611.     /*----------------------------------------------------------------*/
  612.     /*----------------------------------------------------------------*/
  613.     /* Code Body                                                      */
  614.     /*----------------------------------------------------------------*/
  615.     if ((index == BRW_INLINE_TITLE) || (index == BRW_INLINE_URL))
  616.     {
  617.         /* Change the softkey label to 'Edit' */
  618.         ChangeLeftSoftkey(STR_GLOBAL_EDIT, 0);
  619.     }
  620. }
  621. /*****************************************************************************
  622.  * FUNCTION
  623.  *  mmi_brw_full_screen_edit
  624.  * DESCRIPTION
  625.  *  Callback for full screen edit from inline edit screen.
  626.  * PARAMETERS
  627.  *  void
  628.  * RETURNS
  629.  *  void
  630.  *****************************************************************************/
  631. void mmi_brw_full_screen_edit(void)
  632. {
  633.     /*----------------------------------------------------------------*/
  634.     /* Local Variables                                                */
  635.     /*----------------------------------------------------------------*/
  636.     /*----------------------------------------------------------------*/
  637.     /* Code Body                                                      */
  638.     /*----------------------------------------------------------------*/
  639.     ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
  640.     SetLeftSoftkeyFunction(EntryScrForInputMethodAndDone, KEY_EVENT_UP);
  641.     SetInputMethodAndDoneCaptionIcon(GetRootTitleIcon(SERVICES_WAP_MENU_ID));
  642. }
  643. /*****************************************************************************
  644.  * FUNCTION
  645.  *  mmi_brw_entry_confirmation_hdlr
  646.  * DESCRIPTION
  647.  *  Entry screen for confirmation
  648.  * PARAMETERS
  649.  *  void
  650.  *  a(?)        [IN/OUT]        
  651.  *  b(?)        [IN]            
  652.  * RETURNS
  653.  *  void
  654.  *****************************************************************************/
  655. void mmi_brw_entry_confirmation_hdlr(void)
  656. {
  657.     /*----------------------------------------------------------------*/
  658.     /* Local Variables                                                */
  659.     /*----------------------------------------------------------------*/
  660.     /*----------------------------------------------------------------*/
  661.     /* Code Body                                                      */
  662.     /*----------------------------------------------------------------*/
  663.     DisplayConfirm(
  664.         STR_GLOBAL_YES,
  665.         IMG_GLOBAL_YES,
  666.         STR_GLOBAL_NO,
  667.         IMG_GLOBAL_NO,
  668.         get_string(STR_ID_BRW_SAVE_BOOKMARK),
  669.         IMG_GLOBAL_QUESTION,
  670.         0);
  671.     SetLeftSoftkeyFunction(mmi_brw_save_bookmark, KEY_EVENT_UP);
  672.     SetRightSoftkeyFunction(brw_GoBackHistory, KEY_EVENT_UP);
  673. }
  674. /*****************************************************************************
  675.  * FUNCTION
  676.  *  brw_GoBackHistory
  677.  * DESCRIPTION
  678.  *  To go back to history
  679.  * PARAMETERS
  680.  *  void
  681.  * RETURNS
  682.  *  void
  683.  *****************************************************************************/
  684. void brw_GoBackHistory(void)
  685. {
  686.     /*----------------------------------------------------------------*/
  687.     /* Local Variables                                                */
  688.     /*----------------------------------------------------------------*/
  689.     /*----------------------------------------------------------------*/
  690.     /* Code Body                                                      */
  691.     /*----------------------------------------------------------------*/
  692. if (edit_flag == BRW_ADD_BKM_FROM_USE_URL)
  693. {
  694. GoBacknHistory(1);
  695. }
  696. else
  697. {
  698.     GoBacknHistory(2);
  699. }
  700.     edit_flag = BRW_STATUS_NO;
  701. }
  702. /*****************************************************************************
  703.  * FUNCTION
  704.  *  mmi_brw_save_bookmark
  705.  * DESCRIPTION
  706.  *  Function to save the bookmark to NVRAM
  707.  * PARAMETERS
  708.  *  void
  709.  * RETURNS
  710.  *  void
  711.  *****************************************************************************/
  712. void mmi_brw_save_bookmark(void)
  713. {
  714.     /*----------------------------------------------------------------*/
  715.     /* Local Variables                                                */
  716.     /*----------------------------------------------------------------*/
  717.     MMI_BOOL IsValidURL;
  718.     /*----------------------------------------------------------------*/
  719.     /* Code Body                                                      */
  720.     /*----------------------------------------------------------------*/
  721.     IsValidURL = mmi_brw_validate_url(g_brw_bkm_selected_url);
  722.     if (IsValidURL == MMI_TRUE)
  723.     {
  724.         mmi_brw_save_bookmark_item();
  725.         g_brw_bkm_add_flag = 1;
  726.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, JBROWSER_POPUP_TIME, SUCCESS_TONE);
  727. if (edit_flag == BRW_ADD_BKM_FROM_USE_URL)
  728. {
  729. DeleteNHistory(1);
  730. }
  731. else
  732. {
  733. DeleteNHistory(2);
  734.     }
  735.     }
  736.     else
  737.     {
  738.         DisplayPopup((PU8) GetString(STR_ID_BRW_INVALID_URL), IMG_GLOBAL_ERROR, 1, JBROWSER_POPUP_TIME, ERROR_TONE);
  739.     }
  740. }
  741. /*****************************************************************************
  742.  * FUNCTION
  743.  *  mmi_brw_save_bookmark_item
  744.  * DESCRIPTION
  745.  *  Function to save particular bookmark item to NVRAM
  746.  * PARAMETERS
  747.  *  void
  748.  * RETURNS
  749.  *  void
  750.  *****************************************************************************/
  751. void mmi_brw_save_bookmark_item(void)
  752. {
  753.     /*----------------------------------------------------------------*/
  754.     /* Local Variables                                                */
  755.     /*----------------------------------------------------------------*/
  756.     /*----------------------------------------------------------------*/
  757.     /* Code Body                                                      */
  758.     /*----------------------------------------------------------------*/
  759.     /* New bookmark is to be added (Add Bookmark menu) */
  760.     if (edit_flag == BRW_STATUS_NO || edit_flag == BRW_STATUS_FROM_ENTER_ADDRESS
  761. || edit_flag == BRW_ADD_BKM_FROM_USE_URL)
  762.     {
  763.         if (GetUCS2Flag((S8*) g_brw_bkm_selected_title))
  764.         {
  765.             g_brw_cntx.bookmark_title_p[g_brw_cntx.total_bookmark_items].dcs = BRW_DCS_UCS;
  766.             pfnUnicodeStrcpy(
  767.                 (S8*) (g_brw_cntx.bookmark_title_p[g_brw_cntx.total_bookmark_items].title),
  768.                 (S8*) g_brw_bkm_selected_title);
  769.         }
  770.         else
  771.         {
  772.             g_brw_cntx.bookmark_title_p[g_brw_cntx.total_bookmark_items].dcs = BRW_DCS_ASCII;
  773.             UnicodeToAnsii(
  774.                 (S8*) (g_brw_cntx.bookmark_title_p[g_brw_cntx.total_bookmark_items].title),
  775.                 (S8*) g_brw_bkm_selected_title);
  776.         }
  777.         UnicodeToAnsii(
  778.             (S8*) (g_brw_cntx.bookmark_url_p[g_brw_cntx.total_bookmark_items].url),
  779.             (S8*) g_brw_bkm_selected_url);
  780.         g_brw_cntx.index_highlighted_item = g_brw_cntx.total_bookmark_items;
  781.     }
  782.     /* Existing bookmark is to be edited (Edit menu) */
  783.     else
  784.     {
  785.         if (GetUCS2Flag((S8*) g_brw_bkm_selected_title))
  786.         {
  787.             g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].dcs = BRW_DCS_UCS;
  788.             pfnUnicodeStrcpy(
  789.                 (S8*) (g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].title),
  790.                 (S8*) g_brw_bkm_selected_title);
  791.         }
  792.         else
  793.         {
  794.             g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].dcs = BRW_DCS_ASCII;
  795.             UnicodeToAnsii(
  796.                 (S8*) (g_brw_cntx.bookmark_title_p[g_brw_cntx.index_highlighted_item].title),
  797.                 (S8*) g_brw_bkm_selected_title);
  798.         }
  799.         UnicodeToAnsii(
  800.             (S8*) (g_brw_cntx.bookmark_url_p[g_brw_cntx.index_highlighted_item].url),
  801.             (S8*) g_brw_bkm_selected_url);
  802.     }
  803.     mmi_brw_write_bookmark_to_nvram();
  804.     if (edit_flag == BRW_STATUS_NO || edit_flag == BRW_STATUS_FROM_ENTER_ADDRESS
  805. || edit_flag == BRW_ADD_BKM_FROM_USE_URL)
  806.     {
  807.         g_brw_cntx.total_bookmark_items++;
  808.     }
  809.     else
  810.     {
  811.         edit_flag = BRW_STATUS_NO;
  812.     }
  813. }
  814. /*****************************************************************************
  815.  * FUNCTION
  816.  *  mmi_brw_delete_confirm
  817.  * DESCRIPTION
  818.  *  This function displays the confirmation screen for deletion of bookmark
  819.  * PARAMETERS
  820.  *  void
  821.  * RETURNS
  822.  *  void
  823.  *****************************************************************************/
  824. void mmi_brw_delete_confirm(void)
  825. {
  826.     /*----------------------------------------------------------------*/
  827.     /* Local Variables                                                */
  828.     /*----------------------------------------------------------------*/
  829.     /*----------------------------------------------------------------*/
  830.     /* Code Body                                                      */
  831.     /*----------------------------------------------------------------*/
  832.     DisplayConfirm(
  833.         STR_GLOBAL_YES,
  834.         IMG_GLOBAL_YES,
  835.         STR_GLOBAL_NO,
  836.         IMG_GLOBAL_NO,
  837.         get_string(STR_ID_BRW_DELETE_BOOKMARK),
  838.         IMG_GLOBAL_QUESTION,
  839.         WARNING_TONE);
  840.     SetLeftSoftkeyFunction(mmi_brw_delete_bookmark, KEY_EVENT_UP);
  841.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  842. }
  843. /*****************************************************************************
  844.  * FUNCTION
  845.  *  mmi_brw_delete_bookmark
  846.  * DESCRIPTION
  847.  *  Delete the selected bookmark
  848.  * PARAMETERS
  849.  *  void
  850.  * RETURNS
  851.  *  void
  852.  *****************************************************************************/
  853. void mmi_brw_delete_bookmark(void)
  854. {
  855.     /*----------------------------------------------------------------*/
  856.     /* Local Variables                                                */
  857.     /*----------------------------------------------------------------*/
  858.     U16 bkm_count;
  859.     /*----------------------------------------------------------------*/
  860.     /* Code Body                                                      */
  861.     /*----------------------------------------------------------------*/
  862.     for (bkm_count = g_brw_cntx.index_highlighted_item; bkm_count < g_brw_cntx.total_bookmark_items - 1; bkm_count++)
  863.     {
  864.         memcpy(
  865.             &g_brw_cntx.bookmark_title_p[bkm_count],
  866.             &g_brw_cntx.bookmark_title_p[bkm_count + 1],
  867.             sizeof(g_brw_cntx.bookmark_title_p[bkm_count]));
  868.         memcpy(
  869.             &g_brw_cntx.bookmark_url_p[bkm_count],
  870.             &g_brw_cntx.bookmark_url_p[bkm_count + 1],
  871.             sizeof(g_brw_cntx.bookmark_url_p[bkm_count]));
  872.     }
  873.     /* Set the last bookmark item as 0 */
  874.     memset(
  875.         &g_brw_cntx.bookmark_title_p[g_brw_cntx.total_bookmark_items - 1],
  876.         0,
  877.         sizeof(g_brw_cntx.bookmark_title_p[g_brw_cntx.total_bookmark_items - 1]));
  878.     memset(
  879.         &g_brw_cntx.bookmark_url_p[g_brw_cntx.total_bookmark_items - 1],
  880.         0,
  881.         sizeof(g_brw_cntx.bookmark_url_p[g_brw_cntx.total_bookmark_items - 1]));
  882.     mmi_brw_write_bookmark_to_nvram();
  883.     g_brw_cntx.total_bookmark_items--;
  884.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, JBROWSER_POPUP_TIME, SUCCESS_TONE);
  885.     DeleteUptoScrID(SCR_ID_BRW_BOOKMARKS);
  886. }
  887. /*****************************************************************************
  888.  * FUNCTION
  889.  *  mmi_brw_confirm_delete_all_bookmark
  890.  * DESCRIPTION
  891.  *  This function displays the confirmation screen for deletion of all the bookmarks
  892.  * PARAMETERS
  893.  *  void
  894.  * RETURNS
  895.  *  void
  896.  *****************************************************************************/
  897. void mmi_brw_confirm_delete_all_bookmark(void)
  898. {
  899.     /*----------------------------------------------------------------*/
  900.     /* Local Variables                                                */
  901.     /*----------------------------------------------------------------*/
  902.     /*----------------------------------------------------------------*/
  903.     /* Code Body                                                      */
  904.     /*----------------------------------------------------------------*/
  905.     DisplayConfirm(
  906.         STR_GLOBAL_YES,
  907.         IMG_GLOBAL_YES,
  908.         STR_GLOBAL_NO,
  909.         IMG_GLOBAL_NO,
  910.         get_string(STR_ID_BRW_DELETE_ALL_BOOKMARK),
  911.         IMG_GLOBAL_QUESTION,
  912.         WARNING_TONE);
  913.     SetLeftSoftkeyFunction(mmi_brw_delete_all_bookmark, KEY_EVENT_UP);
  914.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  915. }
  916. /*****************************************************************************
  917.  * FUNCTION
  918.  *  mmi_brw_delete_all_bookmark
  919.  * DESCRIPTION
  920.  *  Deletes all the bookmarks
  921.  * PARAMETERS
  922.  *  void
  923.  * RETURNS
  924.  *  void
  925.  *****************************************************************************/
  926. void mmi_brw_delete_all_bookmark(void)
  927. {
  928.     /*----------------------------------------------------------------*/
  929.     /* Local Variables                                                */
  930.     /*----------------------------------------------------------------*/
  931.     /*----------------------------------------------------------------*/
  932.     /* Code Body                                                      */
  933.     /*----------------------------------------------------------------*/
  934.     /* Set all the bookmark entries as '0' */
  935.     memset(g_brw_cntx.bookmark_title_p, 0, (NVRAM_BRW_BOOKMARK_TITLE_SIZE * NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS));
  936.     memset(g_brw_cntx.bookmark_url_p, 0, (NVRAM_BRW_BOOKMARK_URL_SIZE * NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS));
  937.     mmi_brw_write_bookmark_to_nvram();
  938.     g_brw_cntx.total_bookmark_items = 0;
  939.     DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, JBROWSER_POPUP_TIME, SUCCESS_TONE);
  940.     DeleteUptoScrID(SCR_ID_BRW_BOOKMARKS);
  941. }
  942. /*****************************************************************************
  943.  * FUNCTION
  944.  *  mmi_brw_goto_highlighted_bookmark
  945.  * DESCRIPTION
  946.  *  This function fetches the current highlighted bookmark url
  947.  * PARAMETERS
  948.  *  void
  949.  * RETURNS
  950.  *  void
  951.  *****************************************************************************/
  952. void mmi_brw_goto_highlighted_bookmark(void)
  953. {
  954.     /*----------------------------------------------------------------*/
  955.     /* Local Variables                                                */
  956.     /*----------------------------------------------------------------*/
  957.     /*----------------------------------------------------------------*/
  958.     /* Code Body                                                      */
  959.     /*----------------------------------------------------------------*/
  960.     AnsiiToUnicodeString(
  961.         (S8*) brw_current_url,
  962.         (S8*) g_brw_cntx.bookmark_url_p[g_brw_cntx.index_highlighted_item].url);
  963.     /* added by tk to set the current fetch url */
  964.     mmi_brw_set_current_url((S8*) brw_current_url);
  965.     /* jdi call to fetch the url */
  966.     mmi_brw_pre_entry_goto_url();
  967. }
  968. /*****************************************************************************
  969.  * FUNCTION
  970.  *  mmi_brw_read_bookmark_from_nvram
  971.  * DESCRIPTION
  972.  *  This function reads bookmark from NVRAM
  973.  * PARAMETERS
  974.  *  void
  975.  * RETURNS
  976.  *  void
  977.  *****************************************************************************/
  978. void mmi_brw_read_bookmark_from_nvram(void)
  979. {
  980.     /*----------------------------------------------------------------*/
  981.     /* Local Variables                                                */
  982.     /*----------------------------------------------------------------*/
  983.     U16 record_count;
  984.     S16 NvramError;
  985.     /*----------------------------------------------------------------*/
  986.     /* Code Body                                                      */
  987.     /*----------------------------------------------------------------*/
  988.     /* Read bookmarks from NVRAM if not already read */
  989.     if ((g_brw_cntx.bookmark_title_p == NULL) && (g_brw_cntx.bookmark_url_p == NULL))
  990.     {
  991.         g_brw_cntx.bookmark_title_p =
  992.             (nvram_brw_bkm_title_struct*) jdd_MemAlloc(
  993.                                             NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS,
  994.                                             NVRAM_BRW_BOOKMARK_TITLE_SIZE);
  995.         g_brw_cntx.bookmark_url_p =
  996.             (nvram_brw_bkm_url_struct*) jdd_MemAlloc(NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS, NVRAM_BRW_BOOKMARK_URL_SIZE);
  997.         memset(g_brw_cntx.bookmark_title_p, 0, (NVRAM_BRW_BOOKMARK_TITLE_SIZE * NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS));
  998.         memset(g_brw_cntx.bookmark_url_p, 0, (NVRAM_BRW_BOOKMARK_URL_SIZE * NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS));
  999.         for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS; record_count++)
  1000.         {
  1001.             ReadRecord(
  1002.                 NVRAM_EF_BRW_BOOKMARK_TITLE_LID,
  1003.                 record_count,
  1004.                 &g_brw_cntx.bookmark_title_p[(record_count - 1) * TITLES_PER_RECORD],
  1005.                 NVRAM_BRW_BOOKMARK_TITLE_SIZE,
  1006.                 &NvramError);
  1007.         }
  1008.         for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS; record_count++)
  1009.         {
  1010.             ReadRecord(
  1011.                 NVRAM_EF_BRW_BOOKMARK_URL_LID,
  1012.                 record_count,
  1013.                 &g_brw_cntx.bookmark_url_p[(record_count - 1) * URLS_PER_RECORD],
  1014.                 NVRAM_BRW_BOOKMARK_URL_SIZE,
  1015.                 &NvramError);
  1016.         }
  1017.         mmi_brw_calculate_number_of_bookmarks_stored();
  1018.     }
  1019. }
  1020. /*****************************************************************************
  1021.  * FUNCTION
  1022.  *  mmi_brw_write_bookmark_to_nvram
  1023.  * DESCRIPTION
  1024.  *  This function writes bookmark data to NVRAM
  1025.  * PARAMETERS
  1026.  *  void
  1027.  * RETURNS
  1028.  *  void
  1029.  *****************************************************************************/
  1030. void mmi_brw_write_bookmark_to_nvram(void)
  1031. {
  1032.     /*----------------------------------------------------------------*/
  1033.     /* Local Variables                                                */
  1034.     /*----------------------------------------------------------------*/
  1035.     U16 record_count;
  1036.     S16 NvramError;
  1037.     /*----------------------------------------------------------------*/
  1038.     /* Code Body                                                      */
  1039.     /*----------------------------------------------------------------*/
  1040.     /* Read bookmarks from NVRAM if not already read */
  1041.     for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS; record_count++)
  1042.     {
  1043.         WriteRecord(
  1044.             NVRAM_EF_BRW_BOOKMARK_TITLE_LID,
  1045.             record_count,
  1046.             &g_brw_cntx.bookmark_title_p[(record_count - 1) * TITLES_PER_RECORD],
  1047.             NVRAM_BRW_BOOKMARK_TITLE_SIZE,
  1048.             &NvramError);
  1049.     }
  1050.     for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS; record_count++)
  1051.     {
  1052.         WriteRecord(
  1053.             NVRAM_EF_BRW_BOOKMARK_URL_LID,
  1054.             record_count,
  1055.             &g_brw_cntx.bookmark_url_p[(record_count - 1) * URLS_PER_RECORD],
  1056.             NVRAM_BRW_BOOKMARK_URL_SIZE,
  1057.             &NvramError);
  1058.     }
  1059. }
  1060. /*****************************************************************************
  1061.  * FUNCTION
  1062.  *  mmi_brw_add_prov_bookmark
  1063.  * DESCRIPTION
  1064.  *  This function provides external interface to save a bookmark
  1065.  * PARAMETERS
  1066.  *  bkm_title_p     [?]     
  1067.  *  bkm_url_p       [?]     
  1068.  * RETURNS
  1069.  *  void
  1070.  *****************************************************************************/
  1071. PROV_RETCODE mmi_brw_add_prov_bookmark(U8 *bkm_title_p, U8 *bkm_url_p)
  1072. {
  1073.     /*----------------------------------------------------------------*/
  1074.     /* Local Variables                                                */
  1075.     /*----------------------------------------------------------------*/
  1076.     S32 length = 0;
  1077.     /*----------------------------------------------------------------*/
  1078.     /* Code Body                                                      */
  1079.     /*----------------------------------------------------------------*/
  1080.     mmi_brw_read_bookmark_from_nvram();
  1081.     /* Bookmark list is full */
  1082.     if (g_brw_cntx.total_bookmark_items >= BRW_MAX_BOOKMARKS)
  1083.     {
  1084.         return PROV_BKM_FULL;
  1085.     }
  1086.     length = pfnUnicodeStrlen((PS8) bkm_title_p);
  1087.     memset((void*)g_brw_bkm_selected_title, 0, sizeof(g_brw_bkm_selected_title));
  1088.     if (GetUCS2Flag((S8*) bkm_title_p))
  1089.     {
  1090.         if (length > ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1))
  1091.         {
  1092.             length = ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1);
  1093.         }
  1094.     }
  1095.     else
  1096.     {
  1097.         if (length > (BRW_BKM_MAX_TITLE_LENGTH - 1))
  1098.         {
  1099.             length = (BRW_BKM_MAX_TITLE_LENGTH - 1);
  1100.         }
  1101.     }
  1102.     pfnUnicodeStrncpy((S8*) g_brw_bkm_selected_title, (S8*) bkm_title_p, length);
  1103.     memset((void*)g_brw_bkm_selected_url, 0, (BRW_BKM_MAX_URL_LENGTH) * ENCODING_LENGTH);
  1104.     length = pfnUnicodeStrlen((PS8) bkm_url_p);
  1105.     if ((pfnUnicodeStrncmp((PS8) bkm_url_p, (PS8) L"http://", 7) != 0) &&
  1106.         (pfnUnicodeStrncmp((PS8) bkm_url_p, (PS8) L"https://", 8) != 0))
  1107.     {
  1108.         AnsiiToUnicodeString((S8*) g_brw_bkm_selected_url, (S8*) ("http://"));
  1109.         length += 7;
  1110.         if (length >= BRW_BKM_MAX_URL_LENGTH)
  1111.         {
  1112.             length = BRW_BKM_MAX_URL_LENGTH - 1;
  1113.         }
  1114.         pfnUnicodeStrncat((S8*) g_brw_bkm_selected_url, (S8*) bkm_url_p, length - 7);
  1115.     }
  1116.     else
  1117.     {
  1118.         if (length >= BRW_BKM_MAX_URL_LENGTH)
  1119.         {
  1120.             length = BRW_BKM_MAX_URL_LENGTH - 1;
  1121.         }
  1122.         pfnUnicodeStrncat((S8*) g_brw_bkm_selected_url, (S8*) bkm_url_p, length);
  1123.     }
  1124.     /* Bookmark is to be added */
  1125.     edit_flag = BRW_STATUS_NO;
  1126.     if (mmi_brw_validate_url(g_brw_bkm_selected_url))
  1127.     {
  1128.         mmi_brw_save_bookmark_item();
  1129.         return PROV_BKM_OK;
  1130.     }
  1131.     else
  1132.     {
  1133.         return PROV_BKM_INVALID;
  1134.     }
  1135. }
  1136. /*****************************************************************************
  1137.  * FUNCTION
  1138.  *  mmi_brw_bookmark_set_as_homepage
  1139.  * DESCRIPTION
  1140.  *  This function sets the bookmark url as homepage
  1141.  * PARAMETERS
  1142.  *  void
  1143.  * RETURNS
  1144.  *  void
  1145.  *****************************************************************************/
  1146. void mmi_brw_bookmark_set_as_homepage(void)
  1147. {
  1148.     /*----------------------------------------------------------------*/
  1149.     /* Local Variables                                                */
  1150.     /*----------------------------------------------------------------*/
  1151.     /*----------------------------------------------------------------*/
  1152.     /* Code Body                                                      */
  1153.     /*----------------------------------------------------------------*/
  1154.     AnsiiToUnicodeString(
  1155.         (S8*) brw_current_url,
  1156.         (S8*) g_brw_cntx.bookmark_url_p[g_brw_cntx.index_highlighted_item].url);
  1157.     mmi_brw_set_as_homepage(brw_current_url);
  1158. }
  1159. /*****************************************************************************
  1160.  * FUNCTION
  1161.  *  mmi_brw_save_page_url_title_to_bookmark
  1162.  * DESCRIPTION
  1163.  *  This function saves the current url title string and url string to bookmarklist.
  1164.  * PARAMETERS
  1165.  *  void
  1166.  * RETURNS
  1167.  *  void
  1168.  *****************************************************************************/
  1169. void mmi_brw_save_page_url_title_to_bookmark(void)
  1170. {
  1171.     /*----------------------------------------------------------------*/
  1172.     /* Local Variables                                                */
  1173.     /*----------------------------------------------------------------*/
  1174.  /*  MMI_JDD_UI_WINDOW_INFO_STRUCT *jdd_window_info_struct_p = NULL; */
  1175. JC_UINT32 uiWindowID = 0;
  1176. U16 length = 0;
  1177. U16 titleLength = 0;
  1178. JC_PAGE_INFO PageInfo;
  1179.     /*----------------------------------------------------------------*/
  1180.     /* Code Body                                                      */
  1181.     /*----------------------------------------------------------------*/
  1182. uiWindowID = mmi_jdd_ui_get_appWindowID(E_TASK_BROWSER_CORE);
  1183. mmi_brw_read_bookmark_from_nvram();
  1184. /* If Bookmark list is full, Dispaly 'Bookmark list is full' */
  1185. if (g_brw_cntx.total_bookmark_items >= BRW_MAX_BOOKMARKS)
  1186.     {
  1187. DisplayPopup((PU8) GetString(STR_ID_BRW_BOOKMARK_FULL),
  1188. IMG_GLOBAL_ERROR,
  1189. 1,
  1190. JBROWSER_POPUP_TIME,
  1191. ERROR_TONE);
  1192.         SetLeftSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  1193.     }
  1194. else
  1195. {
  1196. jdi_BrowserGetCurrentPageInfo (pBrowserCtxt,&PageInfo);  
  1197. length = pfnUnicodeStrlen((PS8) PageInfo.psUrl);
  1198. if (length >= BRW_BKM_MAX_URL_LENGTH)
  1199.         {
  1200.             DisplayPopup(
  1201. (PU8) GetString(STR_ID_BRW_URL_LEN_EXCEED),
  1202. IMG_GLOBAL_ERROR,
  1203. 1,
  1204. JBROWSER_POPUP_TIME,
  1205. ERROR_TONE);
  1206.         }
  1207. else 
  1208. {
  1209. titleLength = pfnUnicodeStrlen((PS8) PageInfo.psTitle);
  1210. memset((void*)g_brw_bkm_selected_title, 0, sizeof(g_brw_bkm_selected_title));
  1211. if (GetUCS2Flag((S8*) PageInfo.psTitle))
  1212. {
  1213. if (titleLength > ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1))
  1214. {
  1215. titleLength = ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1);
  1216. }
  1217. }
  1218. else
  1219. {
  1220. if (titleLength > (BRW_BKM_MAX_TITLE_LENGTH - 1))
  1221. {
  1222. titleLength = (BRW_BKM_MAX_TITLE_LENGTH - 1);
  1223. }
  1224. }
  1225. edit_flag = BRW_STATUS_NO;
  1226. pfnUnicodeStrncpy(
  1227. (S8*) g_brw_bkm_selected_title,
  1228. (S8*) PageInfo.psTitle, titleLength);
  1229. pfnUnicodeStrcpy((S8*) g_brw_bkm_selected_url, (S8*) PageInfo.psUrl);
  1230. mmi_brw_save_ren_page_to_bookmark();
  1231. }
  1232. }
  1233. }
  1234. /*****************************************************************************
  1235.  * FUNCTION
  1236.  *  mmi_brw_save_ren_page_to_bookmark
  1237.  * DESCRIPTION
  1238.  *  Function to save the Rendered page URL/Title to bookmark List.
  1239.  * PARAMETERS
  1240.  *  void
  1241.  * RETURNS
  1242.  *  void
  1243.  *****************************************************************************/
  1244. void mmi_brw_save_ren_page_to_bookmark(void)
  1245. {
  1246.     /*----------------------------------------------------------------*/
  1247.     /* Local Variables                                                */
  1248.     /*----------------------------------------------------------------*/
  1249.     MMI_BOOL IsValidURL;
  1250.     /*----------------------------------------------------------------*/
  1251.     /* Code Body                                                      */
  1252.     /*----------------------------------------------------------------*/
  1253.     IsValidURL = mmi_brw_validate_url(g_brw_bkm_selected_url);
  1254.     if (IsValidURL == MMI_TRUE)
  1255.     {
  1256. mmi_brw_save_bookmark_item();
  1257.         g_brw_bkm_add_flag = 1;
  1258.         DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, JBROWSER_POPUP_TIME, SUCCESS_TONE);
  1259.     }
  1260.     else
  1261.     {
  1262.         DisplayPopup((PU8) GetString(STR_ID_BRW_INVALID_URL), IMG_GLOBAL_ERROR, 1, JBROWSER_POPUP_TIME, ERROR_TONE);
  1263. }
  1264. }
  1265. #endif /* defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT) */ 
  1266. #endif /* _MMI_JBROWSERMMIBOOKMARKS_C */