📄 jbrowsermmibookmarks.c
字号:
void mmi_brw_goto_highlighted_bookmark(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AnsiiToUnicodeString(
(S8*) brw_current_url,
(S8*) g_brw_cntx.bookmark_url_p[g_brw_cntx.index_highlighted_item].url);
/* added by tk to set the current fetch url */
mmi_brw_set_current_url((S8*) brw_current_url);
/* jdi call to fetch the url */
mmi_brw_pre_entry_goto_url();
}
/*****************************************************************************
* FUNCTION
* mmi_brw_read_bookmark_from_nvram
* DESCRIPTION
* This function reads bookmark from NVRAM
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_brw_read_bookmark_from_nvram(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 record_count;
S16 NvramError;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Read bookmarks from NVRAM if not already read */
if ((g_brw_cntx.bookmark_title_p == NULL) && (g_brw_cntx.bookmark_url_p == NULL))
{
g_brw_cntx.bookmark_title_p =
(nvram_brw_bkm_title_struct*) jdd_MemAlloc(
NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS,
NVRAM_BRW_BOOKMARK_TITLE_SIZE);
g_brw_cntx.bookmark_url_p =
(nvram_brw_bkm_url_struct*) jdd_MemAlloc(NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS, NVRAM_BRW_BOOKMARK_URL_SIZE);
memset(g_brw_cntx.bookmark_title_p, 0, (NVRAM_BRW_BOOKMARK_TITLE_SIZE * NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS));
memset(g_brw_cntx.bookmark_url_p, 0, (NVRAM_BRW_BOOKMARK_URL_SIZE * NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS));
for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS; record_count++)
{
ReadRecord(
NVRAM_EF_BRW_BOOKMARK_TITLE_LID,
record_count,
&g_brw_cntx.bookmark_title_p[(record_count - 1) * TITLES_PER_RECORD],
NVRAM_BRW_BOOKMARK_TITLE_SIZE,
&NvramError);
}
for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS; record_count++)
{
ReadRecord(
NVRAM_EF_BRW_BOOKMARK_URL_LID,
record_count,
&g_brw_cntx.bookmark_url_p[(record_count - 1) * URLS_PER_RECORD],
NVRAM_BRW_BOOKMARK_URL_SIZE,
&NvramError);
}
mmi_brw_calculate_number_of_bookmarks_stored();
}
}
/*****************************************************************************
* FUNCTION
* mmi_brw_write_bookmark_to_nvram
* DESCRIPTION
* This function writes bookmark data to NVRAM
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_brw_write_bookmark_to_nvram(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 record_count;
S16 NvramError;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Read bookmarks from NVRAM if not already read */
for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_TITLE_RECORDS; record_count++)
{
WriteRecord(
NVRAM_EF_BRW_BOOKMARK_TITLE_LID,
record_count,
&g_brw_cntx.bookmark_title_p[(record_count - 1) * TITLES_PER_RECORD],
NVRAM_BRW_BOOKMARK_TITLE_SIZE,
&NvramError);
}
for (record_count = 1; record_count <= NVRAM_BRW_NUM_BOOKMARK_URL_RECORDS; record_count++)
{
WriteRecord(
NVRAM_EF_BRW_BOOKMARK_URL_LID,
record_count,
&g_brw_cntx.bookmark_url_p[(record_count - 1) * URLS_PER_RECORD],
NVRAM_BRW_BOOKMARK_URL_SIZE,
&NvramError);
}
}
/*****************************************************************************
* FUNCTION
* mmi_brw_add_prov_bookmark
* DESCRIPTION
* This function provides external interface to save a bookmark
* PARAMETERS
* bkm_title_p [?]
* bkm_url_p [?]
* RETURNS
* void
*****************************************************************************/
PROV_RETCODE mmi_brw_add_prov_bookmark(U8 *bkm_title_p, U8 *bkm_url_p)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 length = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
mmi_brw_read_bookmark_from_nvram();
/* Bookmark list is full */
if (g_brw_cntx.total_bookmark_items >= BRW_MAX_BOOKMARKS)
{
return PROV_BKM_FULL;
}
length = pfnUnicodeStrlen((PS8) bkm_title_p);
memset((void*)g_brw_bkm_selected_title, 0, sizeof(g_brw_bkm_selected_title));
if (GetUCS2Flag((S8*) bkm_title_p))
{
if (length > ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1))
{
length = ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1);
}
}
else
{
if (length > (BRW_BKM_MAX_TITLE_LENGTH - 1))
{
length = (BRW_BKM_MAX_TITLE_LENGTH - 1);
}
}
pfnUnicodeStrncpy((S8*) g_brw_bkm_selected_title, (S8*) bkm_title_p, length);
memset((void*)g_brw_bkm_selected_url, 0, (BRW_BKM_MAX_URL_LENGTH) * ENCODING_LENGTH);
length = pfnUnicodeStrlen((PS8) bkm_url_p);
if ((pfnUnicodeStrncmp((PS8) bkm_url_p, (PS8) L"http://", 7) != 0) &&
(pfnUnicodeStrncmp((PS8) bkm_url_p, (PS8) L"https://", 8) != 0))
{
AnsiiToUnicodeString((S8*) g_brw_bkm_selected_url, (S8*) ("http://"));
length += 7;
if (length >= BRW_BKM_MAX_URL_LENGTH)
{
length = BRW_BKM_MAX_URL_LENGTH - 1;
}
pfnUnicodeStrncat((S8*) g_brw_bkm_selected_url, (S8*) bkm_url_p, length - 7);
}
else
{
if (length >= BRW_BKM_MAX_URL_LENGTH)
{
length = BRW_BKM_MAX_URL_LENGTH - 1;
}
pfnUnicodeStrncat((S8*) g_brw_bkm_selected_url, (S8*) bkm_url_p, length);
}
/* Bookmark is to be added */
edit_flag = BRW_STATUS_NO;
if (mmi_brw_validate_url(g_brw_bkm_selected_url))
{
mmi_brw_save_bookmark_item();
return PROV_BKM_OK;
}
else
{
return PROV_BKM_INVALID;
}
}
/*****************************************************************************
* FUNCTION
* mmi_brw_bookmark_set_as_homepage
* DESCRIPTION
* This function sets the bookmark url as homepage
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_brw_bookmark_set_as_homepage(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AnsiiToUnicodeString(
(S8*) brw_current_url,
(S8*) g_brw_cntx.bookmark_url_p[g_brw_cntx.index_highlighted_item].url);
mmi_brw_set_as_homepage(brw_current_url);
}
/*****************************************************************************
* FUNCTION
* mmi_brw_save_page_url_title_to_bookmark
* DESCRIPTION
* This function saves the current url title string and url string to bookmarklist.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_brw_save_page_url_title_to_bookmark(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/* MMI_JDD_UI_WINDOW_INFO_STRUCT *jdd_window_info_struct_p = NULL; */
JC_UINT32 uiWindowID = 0;
U16 length = 0;
U16 titleLength = 0;
JC_PAGE_INFO PageInfo;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
uiWindowID = mmi_jdd_ui_get_appWindowID(E_TASK_BROWSER_CORE);
mmi_brw_read_bookmark_from_nvram();
/* If Bookmark list is full, Dispaly 'Bookmark list is full' */
if (g_brw_cntx.total_bookmark_items >= BRW_MAX_BOOKMARKS)
{
DisplayPopup((PU8) GetString(STR_ID_BRW_BOOKMARK_FULL),
IMG_GLOBAL_ERROR,
1,
JBROWSER_POPUP_TIME,
ERROR_TONE);
SetLeftSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
}
else
{
jdi_BrowserGetCurrentPageInfo (pBrowserCtxt,&PageInfo);
length = pfnUnicodeStrlen((PS8) PageInfo.psUrl);
if (length >= BRW_BKM_MAX_URL_LENGTH)
{
DisplayPopup(
(PU8) GetString(STR_ID_BRW_URL_LEN_EXCEED),
IMG_GLOBAL_ERROR,
1,
JBROWSER_POPUP_TIME,
ERROR_TONE);
}
else
{
titleLength = pfnUnicodeStrlen((PS8) PageInfo.psTitle);
memset((void*)g_brw_bkm_selected_title, 0, sizeof(g_brw_bkm_selected_title));
if (GetUCS2Flag((S8*) PageInfo.psTitle))
{
if (titleLength > ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1))
{
titleLength = ((BRW_BKM_MAX_TITLE_LENGTH / 2) - 1);
}
}
else
{
if (titleLength > (BRW_BKM_MAX_TITLE_LENGTH - 1))
{
titleLength = (BRW_BKM_MAX_TITLE_LENGTH - 1);
}
}
edit_flag = BRW_STATUS_NO;
pfnUnicodeStrncpy(
(S8*) g_brw_bkm_selected_title,
(S8*) PageInfo.psTitle, titleLength);
pfnUnicodeStrcpy((S8*) g_brw_bkm_selected_url, (S8*) PageInfo.psUrl);
mmi_brw_save_ren_page_to_bookmark();
}
}
}
/*****************************************************************************
* FUNCTION
* mmi_brw_save_ren_page_to_bookmark
* DESCRIPTION
* Function to save the Rendered page URL/Title to bookmark List.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_brw_save_ren_page_to_bookmark(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
MMI_BOOL IsValidURL;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
IsValidURL = mmi_brw_validate_url(g_brw_bkm_selected_url);
if (IsValidURL == MMI_TRUE)
{
mmi_brw_save_bookmark_item();
g_brw_bkm_add_flag = 1;
DisplayPopup((PU8) GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, JBROWSER_POPUP_TIME, SUCCESS_TONE);
}
else
{
DisplayPopup((PU8) GetString(STR_ID_BRW_INVALID_URL), IMG_GLOBAL_ERROR, 1, JBROWSER_POPUP_TIME, ERROR_TONE);
}
}
#endif /* defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT) */
#endif /* _MMI_JBROWSERMMIBOOKMARKS_C */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -