⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plxbrowhistory.c

📁 mtk wap和mms代码。。适应mtk 25。26平台
💻 C
📖 第 1 页 / 共 2 页
字号:
		else
			g_plxBrowHistories[0].szURLName = PlxAppMalloc(PLXBROW_URL_NAME_LEN*2);
			
		if(NULL == g_plxBrowHistories[0].szURLName )
		{
			for(i=0; i<PLXBROW_HISTORY_MAX_ITEM -1; i++)
			{
				g_plxBrowHistories[i].szURLName =g_plxBrowHistories[i+1].szURLName;
			}
		}
		else
		{
			if(nWideUrlLen <PLXBROW_URL_NAME_LEN-1)
				pfnUnicodeStrcpy(g_plxBrowHistories[0].szURLName,szTempWideUrl);
			else
			{
				pfnUnicodeStrncpy(g_plxBrowHistories[0].szURLName,szTempWideUrl,PLXBROW_URL_NAME_LEN-1);
			}
		}
	}
	PlxAppFree(szTempWideUrl);
	return nEnd;
	
}




/****************************************************************************
* Function	static void	plxBrowEmptyHistories()
* Purpose	empty histories array 
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void	plxBrowEmptyHistories(void)
{
	int i;
	
	for (i = 0; i<PLXBROW_HISTORY_MAX_ITEM; i++)
	{
		if (g_plxBrowHistories[i].szURLName) 
		{
			PlxAppFree(g_plxBrowHistories[i].szURLName) ;
			g_plxBrowHistories[i].szURLName =NULL;
		}
	}
	curNumOfHistoryItems = 0;
	return;
	
}


/****************************************************************************
* Function	static void EntryPlxBrowHistoryScreen(void)
* Purpose	enter history list screen 
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void EntryPlxBrowHistoryScreen(void)
{
	U8* guiBuffer;
	int	i;
	
	plxBrowLoadHistories();
	for(i = 0; i< PLXBROW_HISTORY_MAX_ITEM; i ++)
	{
		if(NULL != g_plxBrowHistories[i].szURLName)
		{
			g_plxBrowHistoryItems[i] = g_plxBrowHistories[i].szURLName;
			g_plxBrowHistoryIcons[i] = (U16)(IMG_GLOBAL_L1 + i);
		}
		else
			break;
	}
	EntryNewScreen(SCR_ID_PLX_BROW_HISTORY,NULL, EntryPlxBrowHistoryScreen, NULL);
	guiBuffer = GetCurrGuiBuffer(SCR_ID_PLX_BROW_HISTORY);	
	RegisterHighlightHandler(plxBrowGetCurHiliteHisItemID);

	ShowCategory84Screen(STR_ID_PLX_BROW_HISTORY, IMG_ID_PLX_BROW_HISTORY,
				STR_ID_PLX_BROW_OPTION,IMG_GLOBAL_OK,
				STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
				curNumOfHistoryItems,
				(U8**)g_plxBrowHistoryItems, g_plxBrowHistoryIcons,LIST_MENU, curSelHistoryItemID, guiBuffer);

	SetKeyHandler(plxBrowJumpToSelHistoryUrlScreen, KEY_ENTER, KEY_EVENT_UP);
	SetRightSoftkeyFunction(ExitPlxBrowHistoryScreen,KEY_EVENT_UP);
	SetLeftSoftkeyFunction(EntryPlxBrowHistoryMenu, KEY_EVENT_UP);
//	ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
	SetKeyHandler(PlxBrowHistoyKeyEndHandler,KEY_END, KEY_EVENT_DOWN);
	SetKeyHandler(ExitPlxBrowHistoryScreen,KEY_LEFT_ARROW, KEY_EVENT_DOWN);
	SetKeyHandler(EntryPlxBrowHistoryMenu,KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
}

#if 0
/****************************************************************************
* Function	static pBOOL plxBrowGetNextHistoryItem( S32 item_index, UI_string_type str_buff, UI_image_type* img_buff_p, U8 str_img_mask )
* Purpose		get the bookmark item by item index 	
* Params	
* Return	
* Remarks	
\****************************************************************************/

static pBOOL plxBrowGetNextHistoryItem( S32 item_index, UI_string_type str_buff, UI_image_type* img_buff_p, U8 str_img_mask )
{	
	if(0 > item_index || PLXBROW_HISTORY_MAX_ITEM <= item_index)
		return FALSE;

	pfnUnicodeStrcpy((S8*)str_buff, g_plxBrowHistories[item_index].szURLName);
	*img_buff_p = (UI_image_type)GetImage((U16)(IMG_GLOBAL_L1 + item_index));
	return TRUE;
}

#endif

/****************************************************************************
* Function	static void plxBrowGetCurHiliteHisItemID(S32 item_index)
* Purpose	get current high light history item index
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void plxBrowGetCurHiliteHisItemID(S32 item_index)
{
	curSelHistoryItemID = item_index;
}


/****************************************************************************
* Function	static void plxBrowJumpToSelHistoryUrlScreen(void)
* Purpose	jump to show the selected high light history item
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void plxBrowJumpToSelHistoryUrlScreen(void)
{
	int 		nWideUrlLen;
	char 	*szTempUtf8Url;
	
	if(0> curSelHistoryItemID || curSelHistoryItemID >= curNumOfHistoryItems ||
		NULL == g_plxBrowHistories[curSelHistoryItemID].szURLName)
		return;
	nWideUrlLen = pfnUnicodeStrlen((const S8*)(g_plxBrowHistories[curSelHistoryItemID].szURLName));
	if(NULL == (szTempUtf8Url = PlxAppMalloc(nWideUrlLen * 3 + 2)))
	{
		if(TRUE == IsScreenPresent(SCR_ID_PLX_BROW_HISTORY))
			GoBackHistory();
		PLIB_MessageBox(PMBTYPE_ERROR , NULL, (const WCHAR *)get_string(STR_ID_PLX_BROW_ERR_MEMORYMALLOC), UI_POPUP_NOTIFYDURATION_TIME);
		return;
	}
	PlxWideCharToUTF8((const char *)g_plxBrowHistories[curSelHistoryItemID].szURLName, nWideUrlLen,
		szTempUtf8Url,nWideUrlLen * 3 + 2);

	//退出历史界面,这里并不保存历史记录
	if(hPlxBrowHistoryMenu)
		PlxDestroyDMenu(hPlxBrowHistoryMenu);
	hPlxBrowHistoryMenu = NULL;
	curSelHistoryItemID = 0;
	EntryOfPlxBrowserView((const char*)szTempUtf8Url);
	PlxAppFree(szTempUtf8Url);
}


/****************************************************************************
* Function	static void ExitPlxBrowHistoryScreen(void)
* Purpose	exit history screen to page view screen
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void ExitPlxBrowHistoryScreen(void)
{
	if(TRUE == IsScreenPresent(SCR_ID_PLX_BROW_VIEW))
	{
		curSelHistoryItemID = 0;
		GoBackToHistory(SCR_ID_PLX_BROW_VIEW);
	}
	else
	{
		GoBackHistory();
		DeInitPlxBrowHistory();
	}
}


/****************************************************************************
* Function	static void EntryPlxBrowHistoryMenu(void)
* Purpose	enter history menu screen
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void EntryPlxBrowHistoryMenu(void)
{
	plxBrowCreateHistroyMenu();
	if (NULL == hPlxBrowHistoryMenu) 
		return;
	plxBrowModifyHistoryMenu();
	PlxSetDMenuDispInfo(0, IMG_ID_PLX_BROW_HISTORY, 0,0, 0,0);
	PlxShowDMenu(hPlxBrowHistoryMenu, SCR_ID_PLX_BROW_HISTORY_MENU, STR_ID_PLX_BROW_HISTORY,
		plxBrowHistoryMenuNty,EntryPlxBrowHistoryMenu);
//	ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
	SetKeyHandler(PlxBrowHistoyKeyEndHandler,KEY_END, KEY_EVENT_DOWN);

}



/****************************************************************************
* Function	static int plxBrowCreateHistroyMenu(void)
* Purpose	create history menu
* Params	
* Return	
* Remarks	
\****************************************************************************/
static int plxBrowCreateHistroyMenu(void)
{
	if(NULL != hPlxBrowHistoryMenu)
		return 0;
	hPlxBrowHistoryMenu = PlxCreateDMenu(0);
	if (NULL == hPlxBrowHistoryMenu) 
	{
		return -1;	//create menu failed
	}
	PlxInsertDMenuItem(hPlxBrowHistoryMenu, -1, MF_ENABLED, DMENU_ID_PLX_BROW_HISTORY_VIEW,
		(const char *)get_string(STR_ID_PLX_BROW_HISTORY_VIEW), IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON);
	PlxInsertDMenuItem(hPlxBrowHistoryMenu, -1, MF_ENABLED, DMENU_ID_PLX_BROW_HISTORY_DELETE,
		(const char *)get_string(STR_ID_PLX_BROW_BOOKMARK_DELETE), IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON);
	PlxInsertDMenuItem(hPlxBrowHistoryMenu, -1, MF_ENABLED, DMENU_ID_PLX_BROW_HISTORY_DELETEALL,
		(const char *)get_string(STR_ID_PLX_BROW_HISTORY_DELETEALL), IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON);
	return 0;
}


/****************************************************************************
* Function	static void  plxBrowModifyHistoryMenu(void)
* Purpose	enable or disable history menu item
* Params	
* Return	
* Remarks	
\****************************************************************************/

static void  plxBrowModifyHistoryMenu(void)
{	
	unsigned short isMenuEnabled;
	isMenuEnabled = curNumOfHistoryItems > 0 ? MF_ENABLED : MF_DISABLED; 
	PlxModifyDMenuItem(hPlxBrowHistoryMenu,DMENU_ID_PLX_BROW_HISTORY_VIEW,(unsigned short)(isMenuEnabled|MF_BYCOMMAND),(unsigned long)DMENU_ID_PLX_BROW_HISTORY_VIEW,
					(const char *)get_string(STR_ID_PLX_BROW_HISTORY_VIEW),(unsigned short)IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON);
	PlxModifyDMenuItem(hPlxBrowHistoryMenu,DMENU_ID_PLX_BROW_HISTORY_DELETE,(unsigned short)(isMenuEnabled|MF_BYCOMMAND),(unsigned long)DMENU_ID_PLX_BROW_HISTORY_DELETE,
					(const char *)get_string(STR_ID_PLX_BROW_BOOKMARK_DELETE),(unsigned short)IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON);
	PlxModifyDMenuItem(hPlxBrowHistoryMenu,DMENU_ID_PLX_BROW_HISTORY_DELETEALL,(unsigned short)(isMenuEnabled|MF_BYCOMMAND),(unsigned long)DMENU_ID_PLX_BROW_HISTORY_DELETEALL,
					(const char *)get_string(STR_ID_PLX_BROW_HISTORY_DELETEALL),(unsigned short)IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON);

	return ;
}



/****************************************************************************
* Function	static int plxBrowHistoryMenuNty(HDMENU hMenu, unsigned long id, unsigned long event)
* Purpose	notify function for history menus
* Params	
* Return	
* Remarks	
\****************************************************************************/
static int plxBrowHistoryMenuNty(HDMENU hMenu, unsigned long id, unsigned long event)
{

	switch(event) 
	{
	case ENT_RIGHT:
	case ENT_OK:
		switch(id) 
		{
		case DMENU_ID_PLX_BROW_HISTORY_VIEW:
			plxBrowJumpToSelHistoryUrlScreen();
			//temp solution for the problem of wrong focus item in dynamic menu 
			//when there are two screen id in history stack but only one menu resoure in memory;
			if(FALSE == IsScreenPresent(SCR_ID_PLX_BROW_VIEW))
				DeleteBetweenScreen(SCR_ID_PLX_BROW_HISTORY_MENU,SCR_ID_PLX_BROW_HISTORY_MENU);
			break;

		case DMENU_ID_PLX_BROW_HISTORY_DELETE:
			if(ENT_OK == event)
				EntryPBHisDelMsgSelScreen();
			break;
		
		case DMENU_ID_PLX_BROW_HISTORY_DELETEALL:
			if(ENT_OK == event)
				EntryPBHisDelAllMsgSelScreen();
			break;

		default:
			return -1;
		}
		break;
		
	case ENT_LEFT:
//		if(id == DMENU_ID_PLX_BROW_HISTORY_DELETE || id == DMENU_ID_PLX_BROW_HISTORY_DELETEALL)
//			break;
	case ENT_BACK:
		GoBackHistory();
		if(hMenu)
			PlxDestroyDMenu(hMenu);
		hPlxBrowHistoryMenu = NULL;
		break;
	default:
		return -1;
	}

	return 0;
}


/****************************************************************************
* Function	static void EntryPBHisDelMsgSelScreen (void)
* Purpose		enter the delete confirm screen
* Params	
* Return	
* Remarks	
\****************************************************************************/

static void EntryPBHisDelMsgSelScreen (void)
{
	int   nToneId = WARNING_TONE;
	PLIB_ConfirmBox(NULL, (const WCHAR *) get_string(STR_ID_PLX_BROW_DELETE_CONFIRM), NULL,NULL, 
				NULL,0, (void*)&nToneId, 0, DelHistoryConfirmCB);
	SetKeyHandler(PlxBrowHistoyKeyEndHandler,KEY_END, KEY_EVENT_DOWN);
}


/****************************************************************************
* Function	static void DelHistoryConfirmCB(PLIBEVENT event)
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void DelHistoryConfirmCB(PLIBEVENT event)
{
	if(PEVENT_POSITIVE == event)
		HistoryDelMsgSelLskFunc();
	else if( PEVENT_NEGTIVE == event)
		HistoryDelAllMsgSelRskFunc();
}


/****************************************************************************
* Function	static void HistoryDelAllMsgSelLskFunc(void)
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/

static void HistoryDelMsgSelLskFunc(void)
{
	U16 prevScrId;
	int		i;

	if(curSelHistoryItemID < 0 || curSelHistoryItemID >= curNumOfHistoryItems)
		return;

	if (g_plxBrowHistories[curSelHistoryItemID].szURLName) 
	{
		PlxAppFree(g_plxBrowHistories[curSelHistoryItemID].szURLName);
		g_plxBrowHistories[curSelHistoryItemID].szURLName =NULL;
	}	
	for( i = curSelHistoryItemID; i < curNumOfHistoryItems-1; i++)
		g_plxBrowHistories[i].szURLName = g_plxBrowHistories[i+1].szURLName;
	g_plxBrowHistories[curNumOfHistoryItems -1].szURLName = NULL; 
	
	curNumOfHistoryItems --;
	if(curNumOfHistoryItems > 0)
	{
		GoBack2TheHistory();
	}
	else
	{
		if(NULL != hPlxBrowHistoryMenu)
		{
			PlxDestroyDMenu(hPlxBrowHistoryMenu);
			hPlxBrowHistoryMenu = NULL;
		}

		if(TRUE == IsScreenPresent(SCR_ID_PLX_BROW_VIEW))
			GoBackToHistory(SCR_ID_PLX_BROW_VIEW);
		else
		{	
			if(MMI_TRUE == GetPreviousScrnIdOf(SCR_ID_PLX_BROW_HISTORY,&prevScrId))
				GoBackToHistory(prevScrId);
			else
				GoBackHistory();
			DeInitPlxBrowHistory();
		}
	}
	PLIB_MessageBox(PMBTYPE_SUCCESS,NULL, (const WCHAR *)get_string(STR_ID_PLX_BROW_DELETE_SUCCESS), UI_POPUP_NOTIFYDURATION_TIME);
}


/****************************************************************************
* Function	static void EntryPBHisDelAllMsgSelScreen (void)
* Purpose		enter the delete confirm screen
* Params	
* Return	
* Remarks	
\****************************************************************************/

static void EntryPBHisDelAllMsgSelScreen (void)
{
	int   nToneId = WARNING_TONE;
	PLIB_ConfirmBox(NULL, (const WCHAR *) get_string(STR_ID_PLX_BROW_DELETEALL_CONFIRM), NULL,NULL, 
				NULL,0, (void*)&nToneId, 0, DelAllHistoryConfirmCB);
	SetKeyHandler(PlxBrowHistoyKeyEndHandler,KEY_END, KEY_EVENT_DOWN);
}


/****************************************************************************
* Function	static void DelAllHistoryConfirmCB(PLIBEVENT event)
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void DelAllHistoryConfirmCB(PLIBEVENT event)
{
	if(PEVENT_POSITIVE == event)
		HistoryDelAllMsgSelLskFunc();
	else if( PEVENT_NEGTIVE == event)
		HistoryDelAllMsgSelRskFunc();
}


/****************************************************************************
* Function	static void HistoryDelAllMsgSelLskFunc(void)
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/

static void HistoryDelAllMsgSelLskFunc(void)
{
	U16 prevScrId;


	plxBrowEmptyHistories();
	curSelHistoryItemID = 0;
	if(NULL != hPlxBrowHistoryMenu)
	{
		PlxDestroyDMenu(hPlxBrowHistoryMenu);
		hPlxBrowHistoryMenu = NULL;
	}
	if(TRUE == IsScreenPresent(SCR_ID_PLX_BROW_VIEW))
		GoBackToHistory(SCR_ID_PLX_BROW_VIEW);
	else
	{	
		if(MMI_TRUE == GetPreviousScrnIdOf(SCR_ID_PLX_BROW_HISTORY,&prevScrId))
			GoBackToHistory(prevScrId);
		else
			GoBackHistory();
		DeInitPlxBrowHistory();
	}
	PLIB_MessageBox(PMBTYPE_SUCCESS,NULL, (const WCHAR *)get_string(STR_ID_PLX_BROW_DELETE_SUCCESS), UI_POPUP_NOTIFYDURATION_TIME);
}


/****************************************************************************
* Function	static void HistoryDelAllMsgSelRskFunc(void)
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/

static void HistoryDelAllMsgSelRskFunc(void)
{
	GoBack2TheHistory();
}


/****************************************************************************
* Function	int plxBrowGetCurrNumOfHistoryItem(void)
* Purpose	get current num of history items, use this func to decide whether enable or show the history menu
* Params	
* Return	
* Remarks	
\****************************************************************************/
#if 0
int plxBrowGetCurrNumOfHistoryItem(void)
{
	return curNumOfHistoryItems;
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -