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

📄 plxbrowpush.c

📁 mtk wap和mms代码。。适应mtk 25。26平台
💻 C
📖 第 1 页 / 共 5 页
字号:
						  STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
						  nNumofItem, nStrItemList, SettingsSubmenuImageList,
						  LIST_MENU, 0, guiBuffer);
	
	/* 9.Register function with right softkey */
	SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
	ClearKeyHandler(KEY_END, KEY_EVENT_DOWN);
	SetKeyHandler(WBPushKeyEndHandler,KEY_END,KEY_EVENT_UP);

}

#endif
/****************************************************************************
* Function	EntryWBPushMenu
* Purpose	enter push menu screen
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void EntryWBPushMenu(void)
{
	CreateWBPushMenu();
	if (NULL == wbPushMenu) 
		return;
	ModifyWBPushMenu();
	PlxSetDMenuDispInfo(0, IMG_ID_PLX_BROW_PUSHBOX, 0,0, 0,0);
	PlxShowDMenu(wbPushMenu, SCR_ID_PLX_BROW_PUSH_MENU, STR_ID_PLX_BROW_PUSHBOX,
		WBPushMenuNty,EntryWBPushMenu);
	SetKeyHandler(WBPushKeyEndHandler,KEY_END,KEY_EVENT_DOWN);
#ifdef __PLXBROW_PUSH_TEST_
	SetKeyHandler(TestSIPush,KEY_VOL_UP, KEY_EVENT_UP);
	SetKeyHandler(TestTextPush,KEY_VOL_DOWN, KEY_EVENT_UP);
#endif //__PLXBROW_PUSH_TEST_	

}



/****************************************************************************
* Function	static int CreateWBPushMenu(void)
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/
static int CreateWBPushMenu(void)
{
	if(NULL != wbPushMenu)
		return 0;
	wbPushMenu = PlxCreateDMenu(0);
	if (NULL == wbPushMenu) 
	{
		return -1;	//create menu failed
	}
	PlxInsertDMenuItem(wbPushMenu, -1, MF_ENABLED, DMENU_ID_PLX_BROW_PUSHBOX_READ,//浏览
		(const char *)get_string(STR_ID_PLX_BROW_READ), IMG_GLOBAL_L1);
	
	PlxInsertDMenuItem(wbPushMenu, -1, MF_ENABLED, DMENU_ID_PLX_BROW_PUSHBOX_DELETE,//delete
	(const char *)get_string(STR_ID_PLX_BROW_DEL), IMG_GLOBAL_L2);

	PlxInsertDMenuItem(wbPushMenu, -1, MF_ENABLED, DMENU_ID_PLX_BROW_PUSHBOX_DELETEALL,//删除全部
		(const char *)get_string(STR_ID_PLX_BROW_DELALL), IMG_GLOBAL_L3);
	return 0;
}


/****************************************************************************
* Function	static void  ModifyWBPushMenu(void)
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void  ModifyWBPushMenu(void)
{	
	unsigned short isMenuEnabled;
	isMenuEnabled =  curPushItems> 0 ? MF_ENABLED : MF_DISABLED; 
	PlxModifyDMenuItem(wbPushMenu,0,(unsigned short)(isMenuEnabled|MF_BYPOSITION),(unsigned long)DMENU_ID_PLX_BROW_PUSHBOX_READ,
					(const char *)get_string(STR_ID_PLX_BROW_READ),(unsigned short)IMG_GLOBAL_L1);

	PlxModifyDMenuItem(wbPushMenu,1,(unsigned short)(isMenuEnabled|MF_BYPOSITION), (unsigned long)DMENU_ID_PLX_BROW_PUSHBOX_DELETE,
					(const char *)get_string(STR_ID_PLX_BROW_DEL),(unsigned short)IMG_GLOBAL_L2);
	
	PlxModifyDMenuItem(wbPushMenu,2,(unsigned short)(isMenuEnabled|MF_BYPOSITION), (unsigned long)DMENU_ID_PLX_BROW_PUSHBOX_DELETEALL,
					(const char *)get_string(STR_ID_PLX_BROW_DELALL),(unsigned short)IMG_GLOBAL_L3);

	return ;
}



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

	switch(event) 
	{
	case ENT_RIGHT:
	case ENT_OK:
		switch(id) 
		{
		case DMENU_ID_PLX_BROW_PUSHBOX_READ:
			WBPushUserRead();
			break;

		case DMENU_ID_PLX_BROW_PUSHBOX_DELETE:
			if(ENT_OK == event)
				WBPushDelItem();
			break;
	
		case DMENU_ID_PLX_BROW_PUSHBOX_DELETEALL:
			if(ENT_OK == event)
				WBPushDelAllItems();
			break;

		default:
			return -1;
		}
		break;

	case ENT_LEFT:
//		if(id == DMENU_ID_PLX_BROW_PUSHBOX_DELETE || id == DMENU_ID_PLX_BROW_PUSHBOX_DELETEALL)
//			break;
	case ENT_BACK:
		GoBackHistory();
		if(hMenu)
			PlxDestroyDMenu(hMenu);
		wbPushMenu = NULL;
		break;
	default:
		return -1;
	}

	return 0;
}


/****************************************************************************
* Function	InsertNewItemToSpePushChain
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void  InsertNewItemToSpePushChain(PPUSH pNewPush, PPUSH pStatItem, PPUSH pEndItem, int nNumOfPush)
{
		int		i;
		PPUSH   pMv;

		if(pStatItem != NULL && pStatItem->pNext == pEndItem)
		{
			pNewPush->pNext = pStatItem->pNext;
			pStatItem->pNext = pNewPush;
			curPushItems ++;
			return;
		}
		for(i = 0, pMv = pStatItem ; i < nNumOfPush, pMv != NULL; i ++)
		{
			if(i == nNumOfPush / 2)
			{
				if(0 <= pfnUnicodeStrcmp((const S8*)pNewPush->fileName, (const S8*)pMv->fileName))
					InsertNewItemToSpePushChain(pNewPush, pStatItem, pMv, i + 1);
				else
				{
					InsertNewItemToSpePushChain(pNewPush, pMv, NULL, nNumOfPush - i );
				}
				break;
			}			
			pMv = pMv->pNext;
		}

}


/****************************************************************************
* Function	InsertNewItemToPushChain
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/
static  void InsertNewItemToPushChain(PPUSH pNewPush)
{

	if(pNewPush == NULL  || pNewPush->pNext != NULL)
		return;
	if(pPushChain == NULL)
	{
		pPushChain = pNewPush;
		curPushItems ++;
		return;
	}
	else if( 0 <= pfnUnicodeStrcmp((const S8*)pNewPush->fileName, (const S8*)pPushChain->fileName))
	{
		pNewPush->pNext = pPushChain;
		pPushChain = pNewPush;
		curPushItems ++;
		return;
	}
	else
	{
		InsertNewItemToSpePushChain(pNewPush, pPushChain, NULL, curPushItems);
	}
	return;
}


/****************************************************************************
* Function	DumpPushChain
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/
static  void DumpPushChain(void)
{
#ifdef  __PLXBROW_DEBUG_ 
	PPUSH		 pMv;
	int			i;

	PlxTrace("--------[%d]DumpPushChain -----------",__LINE__);
	for(pMv = pPushChain, i = 0; pMv != NULL ; pMv = pMv->pNext)
	{
		i ++;
		PlxTrace("No.%d",i);
		DumpPush(pMv);
	}
#endif
}


/****************************************************************************
* Function	DumpPush
* Purpose	
* Params	
* Return	
* Remarks	
\****************************************************************************/
static void DumpPush(PPUSH pPush)
{
#if defined (__PLXBROW_PUSH_TEST_) || defined (__PLXBROW_DEBUG_) 
	char	szUtfFileName[PLXBROW_PUSH_FILENAME_MAX_LEN];

	if(pPush == NULL)
	{
		PlxTrace("Note:  pPush == NULL -----");
		return;
	}
	PlxWideCharToUTF8((const char *)pPush->fileName, pfnUnicodeStrlen((const S8*)pPush->fileName), (char *) szUtfFileName, PLXBROW_PUSH_FILENAME_MAX_LEN);
	PlxTrace("----- file =  %s -----", szUtfFileName);
	WAP_DataOut((const unsigned char *)pPush, (unsigned short)sizeof(PUSH), (const unsigned char * )"pPush:");
	WAP_DataOut((const unsigned char *)pPush->pData, (unsigned short) ((pPush->fileUnit).lItemSize), (const unsigned char *)"pPush->pData");
#endif 
}

/****************************************************************************
* Function	BuildPushItemChain
* Purpose	read push from files, and make them to a chain in RAM
* Params	
* Return	
* Remarks	
\****************************************************************************/
int BuildPushItemChain(void){
	FS_DOSDirEntry findInfo;
	int 			findHandle;
	char	  		fileName[PLXBROW_PUSH_FILENAME_MAX_LEN];
	char   			pattern[12]; 
	PPUSH 			pPush;
	int	  			ret = 0;
	char  			*szCurrPath;
#ifdef 	__PLXBROW_DEBUG_
	char			buf[50];
#endif

	if(TRUE == bIsPushLoad)
		return 0;
	curPushItems = 0;
	if(NULL == (szCurrPath = PlxAppMalloc(FS_MAX_PATH)))
	{
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d]  BuildPushItemChain -----> szCurrPath malloc failed", __LINE__);
#endif
		return -2;
	}
	FS_GetCurrentDir((WCHAR *) szCurrPath,FS_MAX_PATH/2);

	if( 0 > SetPushDir ())
	{
		PlxAppFree(szCurrPath);
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d]  BuildPushItemChain ----->SetPushDir failed", __LINE__);
#endif
		return -1;
	}
//	pfnUnicodeStrcpy((S8*)pattern,"*\x00.\x00p\x00s\x00h\x00\x00\x00");
	AnsiiToUnicodeString((S8 *)pattern, (S8 *)"*.psh");
	findHandle = FS_FindFirst((const WCHAR*)pattern, 0, 0, &findInfo, (WCHAR*)fileName, PLXBROW_PUSH_FILENAME_MAX_LEN/2 -1);
	if (0 > findHandle) {
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d]  BuildPushItemChain -----> Push not find, findHandle[%d]",  __LINE__, findHandle);
#endif
		FS_SetCurrentDir((const WCHAR *) szCurrPath);
		PlxAppFree(szCurrPath);
		return 0;
	}
	do {
		pPush = PlxAppMalloc(sizeof(PUSH));
		if (0 == pPush) { 
			FS_FindClose(findHandle);
			FS_SetCurrentDir((const WCHAR *) szCurrPath);
			PlxAppFree(szCurrPath);
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d]  BuildPushItemChain-----> push malloc failed", __LINE__);
#endif
			return -1;
		}		
		pPush->pNext = 0;

		if(0 > WBPushGetHeader((U16*)fileName, &pPush->fileUnit)) 
		{
			PlxAppFree(pPush);
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d]  BuildPushItemChain----->WBPushGetHeader error   ",  __LINE__);
#endif
			continue;
		}

#ifdef 	__PLXBROW_DEBUG_
		PlxWideCharToUTF8((const char *)fileName, pfnUnicodeStrlen((const S8*)fileName),( char *)buf, 50);
		PlxTrace ("[%d]  BuildPushItemChain -----> findHandle[%d], Push found filename = %s", __LINE__, findHandle,buf);
#endif
		if(0 >= pPush->fileUnit.lItemSize - sizeof(FILEUNIT))
		{
			PlxAppFree(pPush);
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d] BuildPushItemChain-----> pPush->fileUnit.lItemSize - sizeof(FILEUNIT) <=0  ", __LINE__);
#endif
			continue;
		}
		pPush->pData = PlxAppMalloc(pPush->fileUnit.lItemSize - sizeof(FILEUNIT));
		if (0 == pPush->pData) {
			PlxAppFree(pPush);
#ifdef 	__PLXBROW_DEBUG_
		PlxTrace ("[%d]  BuildPushItemChain-----> pPush->pData is NULL",  __LINE__);
#endif
			continue;
		}
//		pPush->pNext = pPushChain;
//		pPushChain = pPush;
		if(0 > WBPushReadItem((U16*)fileName, pPush->pData, pPush->fileUnit.lItemSize - sizeof(FILEUNIT)))
			memset(pPush->pData, 0x0,pPush->fileUnit.lItemSize - sizeof(FILEUNIT));
//		UCS2Strcpy(pPush->fileName, (S8 *)fileName);
		if(PUSHITEM_FILENAME_MAX_LEN / 2 > pfnUnicodeStrlen((const S8*)fileName))
			pfnUnicodeStrcpy((S8*)pPush->fileName,(const S8*)fileName);
		else  //the filename is changed more longer by user, abandon it. 
		{
			PlxAppFree(pPush);
			continue;
		}
		//sorted 
		InsertNewItemToPushChain(pPush);
		++ ret;
	}while (FS_NO_ERROR == FS_FindNext(findHandle, &findInfo, (WCHAR*)fileName, PLXBROW_PUSH_FILENAME_MAX_LEN / 2 - 1));
	FS_FindClose(findHandle);
	FS_SetCurrentDir((const WCHAR *) szCurrPath);
	PlxAppFree(szCurrPath);
	bIsPushLoad = TRUE;
	curPushItems = ret;
	DumpPushChain();
	return 0;
}

/****************************************************************************
* Function	DestroyPushChain
* Purpose	destroy pthe push item's chain
* Params	
* Return	
* Remarks	
\****************************************************************************/
void DestroyPushChain(void){
	PPUSH pPush;

	while (pPushChain != NULL) {
		pPush = pPushChain;
		pPushChain = pPush->pNext;
		if(pPush->pData != NULL)
			PlxAppFree(pPush->pData);
		PlxAppFree(pPush);
	}
	
	pPushChain = NULL;
	curPushItems = 0;
	bIsPushLoad = FALSE;
}

/****************************************************************************
* Function	AddPushItem
* Purpose	add a push item to the chain
* Params	
* Return	
* Remarks	
\****************************************************************************/
int AddPushItem(U16 *fileName){
	PPUSH pPush;
	S32 fileHandle;
	UINT nRead;
	char szCurrPath[FS_MAX_PATH];
	
	FS_GetCurrentDir((WCHAR * )szCurrPath, FS_MAX_PATH/2);

	if(0 > SetPushDir())
	{
		return -1;
	}

⌨️ 快捷键说明

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