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

📄 plxbrowpublic.c

📁 mtk wap和mms代码。。适应mtk 25。26平台
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
*
*                      Pollex Mobile Platform
*
*  Copyright (c) 2004 by Pollex Mobile Software Co., Ltd.
*                       All Rights Reserved
*
*  Module  :    
*
*  Purpose :
*  
\**************************************************************************/

#ifdef MMI_ON_WIN32
#include <windows.h>
#endif

#include "kal_non_specific_general_types.h"		/* include this for kal data type */
#if defined(MMI_ON_HARDWARE_P)
#include "kal_release.h"
#endif
#include "lcd_sw_rnd.h"

#include "fs_type.h"
#include "fs_func.h"
#include "fs_errcode.h"

#include "GlobalScrEnum.h"
#include "StdC.h"
#include "gui.h"
#include "CommonScreens.h"
#include "gdi_include.h"
#include "Wgui_categories_popup.h"

#include "plxbrowPort.h"
#include "plxBrowPublic.h"
#include "../public/PlxPublic.h"
#include "../main/plxDefs.h"
#include "plxBrowDefs.h"
#include "plxbrow.h"


extern int WB_IsFlashAvailable(unsigned long lSize, const char * dir);




//Browser UI Path Solution
#ifdef __PLXBROW_DIR_SYSTEM_
#define PLXBROW_DIR_POLLEX_SYSTEM					"c:\\Pollex"
#endif
#define PLXBROW_DIR_POLLEX 							"d:\\Pollex"

#define PLXBROW_DIR_BROWSER 						"\\Browser"
#define PLXBROW_DIR_BROWSER_PROFILES    			PLXBROW_DIR_BROWSER"\\Profiles"
#define PLXBROW_DIR_BROWSER_PUSHBOX    				PLXBROW_DIR_BROWSER"\\PushBox"
#define PLXBROW_DIR_BROWSER_TEMP   				    PLXBROW_DIR_BROWSER"\\Temp"
#define PLXBROW_DIR_BROWSER_DOWNLOADS   		    PLXBROW_DIR_BROWSER"\\Downloads"
#define PLXBROW_DIR_BROWSER_DOWNLOADS_PAGES      	PLXBROW_DIR_BROWSER_DOWNLOADS"\\Pages"
#define PLXBROW_DIR_BROWSER_DOWNLOADS_IMAGES    	PLXBROW_DIR_BROWSER_DOWNLOADS"\\Images"
#define PLXBROW_DIR_BROWSER_DOWNLAODS_AUDIOS    	PLXBROW_DIR_BROWSER_DOWNLOADS"\\Audios"
#define PLXBROW_DIR_BROWSER_DOWNLOADS_VIDEOS    	PLXBROW_DIR_BROWSER_DOWNLOADS"\\Videos"
//history
#define PLXBROW_HISTORY_FILENAME					PLXBROW_DIR_BROWSER_PROFILES"\\History.dat"   
//bookmark
#define PLXBROW_BOOKMARK_FILENAME					PLXBROW_DIR_BROWSER_PROFILES"\\Bookmark.dat"    
//pages
#define PLXBROW_FILE_DOWNLOAD_PATH					PLXBROW_DIR_BROWSER_DOWNLOADS_PAGES"\\"  //must have "\\"  
//pushbox
#define PLXBROW_PUSHBOX_DIR_PATH					PLXBROW_DIR_BROWSER_PUSHBOX   
//setting
#define PLXBROW_SETTING_FILENAME					PLXBROW_DIR_BROWSER_PROFILES"\\Setting.dat"
//cache
#define  PLXBROW_CACHE_FILENAME						PLXBROW_DIR_BROWSER_TEMP"\\Cache.dat" 
//cookie
#define	PLXBROW_COOKIE_FILENAME						PLXBROW_DIR_BROWSER_TEMP"\\Cookie.dat"

static  char BrowserUIAppRoot[PLXBROW_MAX_PATH] = {'\0'};
static  char BrowserUISysRoot[PLXBROW_MAX_PATH] = {'\0'};
static  char TempUIPath[PLXBROW_MAX_PATH] = {'\0'};


/****************************************************************************
* Function	char* plxBrowStrDup( const char* SrcStr )
* Purpose  	get a copy of SrcStr 
* Params	
* Return	
* Remarks	
\****************************************************************************/

/*函数strdup的模拟函数*/
char* plxBrowStrDup( const char* SrcStr )
{
	int len;	
	char* DstStr;
	
	if( SrcStr == NULL ) 
		return NULL;
	
	len = strlen(SrcStr);

	DstStr = PlxAppMalloc( len + 1 );
	if (DstStr == NULL)
		return NULL;
	strcpy( DstStr, SrcStr);
	
	return DstStr;
}


/****************************************************************************
* Function	WCHAR* plxBrowWideStrDup( const WCHAR* szWideStr )
* Purpose		 
* Params	
* Return	
* Remarks	
\****************************************************************************/
WCHAR* plxBrowWideStrDup( const WCHAR* szWideStr )
{
	int len;	
	WCHAR* DstStr;
	
	if( szWideStr == NULL ) 
		return NULL;
	
	len = pfnUnicodeStrlen((const char*)szWideStr);

	DstStr = PlxAppMalloc( 2*(len + 1) );
	if (DstStr == NULL)
		return NULL;
	pfnUnicodeStrcpy((PS8)DstStr, (const PS8)szWideStr);
	
	return DstStr;
}


/****************************************************************************
* Function	static int plxBrowToupper(int c)
* Purpose		 
* Params	
* Return	
* Remarks	
\****************************************************************************/
static int plxBrowToupper(int c)
{
	return islower(c) ? (c - 'a' + 'A') :(c);
}

/****************************************************************************
* Function	int plxBrowStrncasecmp(const char *s1, const char *s2, unsigned int n)
* Purpose		 
* Params	
* Return	
* Remarks	
\****************************************************************************/
int plxBrowStrnicmp(const char *s1, const char *s2, unsigned int n)
{

	if (n == 0)
		return 0;
	
	while (n-- != 0 && plxBrowToupper(*s1) == plxBrowToupper(*s2))
	{
		if (n == 0 || *s1 == '\0' || *s2 == '\0')
			break;
		s1++;
		s2++;
	}
	
	return plxBrowToupper(*(unsigned char *) s1) - plxBrowToupper(*(unsigned char *) s2);
}


/****************************************************************************
* Function	void PlxBrowInitCreateSysDir(void)
* Purpose		 
* Params	
* Return	
* Remarks	
\****************************************************************************/
void PlxBrowInitCreateSysDir(void)
{
	char  *szTempDir = NULL;

//	szTempDir =GetPBUIRootDirectory();
//	strcpy(TempUIPath,szTempDir);
	PlxBrowCreateUIDirectory(NULL, NULL);
}




/****************************************************************************
* Function	 void PlxBrowCreateUIDirectory(const char* strAppRoot)
* Purpose	 Create the Directories needed by Browser UI 
* Params		strAppRoot must be in utf8 encode 	
* Return	
* Remarks	
\****************************************************************************/
 void PlxBrowCreateUIDirectory( const char* strSysRoot, const char* strAppRoot)
{
	char		szCurrPath[PLXBROW_MAX_PATH * 2];
	char		*szWidePath;
	int		flag = 0;
	int		i;
	int          nRootLen;
	char        *p;
	const char*      Dirs[] = {	// do no change the order
				//		PLXBROW_DIR_POLLEX,
						PLXBROW_DIR_BROWSER,
						PLXBROW_DIR_BROWSER_PROFILES,
						PLXBROW_DIR_BROWSER_PUSHBOX,
						PLXBROW_DIR_BROWSER_TEMP,
						PLXBROW_DIR_BROWSER_DOWNLOADS,
						PLXBROW_DIR_BROWSER_DOWNLOADS_PAGES,
						PLXBROW_DIR_BROWSER_DOWNLOADS_IMAGES,
						PLXBROW_DIR_BROWSER_DOWNLOADS_VIDEOS,
						PLXBROW_DIR_BROWSER_DOWNLAODS_AUDIOS
					};
	int          DirAttr[sizeof(Dirs)/sizeof(char*)] = {0, 1,1,1, 0,0,0,0,0,};

    if(NULL == (szWidePath = PlxAppMalloc(PLXBROW_MAX_PATH *2 )))
    {
        PLIB_MessageBox(PMBTYPE_ERROR,NULL,( const WCHAR *)get_string(STR_ID_PLX_BROW_ERR_MEMORYMALLOC),UI_POPUP_NOTIFYDURATION_TIME);
        return;
    }
    FS_GetCurrentDir((WCHAR *)szCurrPath ,PLXBROW_MAX_PATH);
    
#ifdef __PLXBROW_SUPPORT_HOTPLUG_
	if(PMSDC_OK == PlxBrowIsMemCardPluged())
#endif
    {
        
        if(NULL == strAppRoot || 0 == (nRootLen = strlen(strAppRoot)))
        {
            if(0 == strlen(BrowserUIAppRoot))
                strcpy(BrowserUIAppRoot,PLXBROW_DIR_POLLEX);
        }
        else
        {
            if(0 == strncmp((const char*)PLXBROW_DIR_BROWSER,(const char*)"\\",1) || 
                0 == strncmp((const char*)PLXBROW_DIR_BROWSER,(const char*)"/",1))
            {
                for(p = (char*)(strAppRoot + nRootLen -1); p >=(char*)strAppRoot; p--)
                {
                    if(0 != strncmp((const char*)p,(const char*)"\\",1) && 
                        0 != strncmp((const char*)p,(const char*)"/",1))
                        break;
                }
                strncpy(BrowserUIAppRoot,(const char*)strAppRoot, p - strAppRoot + 1);
            }
            else 
            {
                strcpy(BrowserUIAppRoot,(const char*)strAppRoot);
                
                p = (char*)(strAppRoot + nRootLen -1);
                if(0 != strncmp((const char*)p,(const char*)"\\",1) && 
                    0 != strncmp((const char*)p,(const char*)"/",1))
                    strcat(BrowserUIAppRoot,(const char*)"\\");
            }
        }
        
       
        AnsiiToUnicodeString((S8 *)szWidePath, (S8 *)BrowserUIAppRoot);
        if(FS_NO_ERROR != FS_SetCurrentDir((const WCHAR *)szWidePath) )
        {
            if(FS_NO_ERROR == FS_CreateDir((const WCHAR *)szWidePath))
                FS_SetAttributes((const WCHAR *)szWidePath, (BYTE) (FS_ATTR_DIR | FS_ATTR_HIDDEN));
            else
            {
                //	PLIB_MessageBox(PMBTYPE_ERROR, NULL,( const WCHAR *)get_string(STR_ID_PLX_BROW_SAVEPAGE_ERR_DOWNLOADPATH ,UI_POPUP_NOTIFYDURATION_TIME);
                flag ++;
            }
        }
        
        
        for(i = 0; i< sizeof(Dirs)/sizeof(char*); i++)
        {
            if(NULL != Dirs[i] && 0 != strlen((const char*)Dirs[i]))
            {
                AnsiiToUnicodeString((S8*)szWidePath,(S8*)BrowserUIAppRoot);
                AnsiiToUnicodeString((S8 *)(szWidePath + 2* pfnUnicodeStrlen((const S8*)szWidePath)), (S8 *)Dirs[i]);
                if(FS_NO_ERROR != FS_SetCurrentDir((const WCHAR *)szWidePath))
                {
                    if(FS_NO_ERROR == FS_CreateDir((const WCHAR *)szWidePath))
                    {
                        if(1 == DirAttr[i])
                            FS_SetAttributes((const WCHAR *)szWidePath, (BYTE) (FS_ATTR_DIR | FS_ATTR_HIDDEN));
                    }
                    else
                    {
                        //	PLIB_MessageBox(PMBTYPE_ERROR, NULL,( const WCHAR *)get_string(STR_ID_PLX_BROW_SAVEPAGE_ERR_DOWNLOADPATH ,UI_POPUP_NOTIFYDURATION_TIME);
                        flag ++;	
                    }
                }
            }
        }
    }
#ifdef __PLXBROW_DIR_SYSTEM_
	if(NULL == strSysRoot || 0 == (nRootLen = strlen(strSysRoot)))
	{
		if(0 == strlen(BrowserUISysRoot))
			strcpy(BrowserUISysRoot,PLXBROW_DIR_POLLEX_SYSTEM);
	}
	else
	{
		if(0 == strncmp((const char*)PLXBROW_DIR_BROWSER,(const char*)"\\",1) || 
				 0 == strncmp((const char*)PLXBROW_DIR_BROWSER,(const char*)"/",1))
		{
			for(p = (char*)(strSysRoot + nRootLen -1); p >=(char*)strSysRoot; p--)
			{
				if(0 != strncmp((const char*)p,(const char*)"\\",1) && 
					 0 != strncmp((const char*)p,(const char*)"/",1))
					break;
			}
			strncpy(BrowserUISysRoot,(const char*)strSysRoot, p - strSysRoot + 1);
		}
		else 
		{
			strcpy(BrowserUISysRoot,(const char*)strSysRoot);

			p = (char*)(strSysRoot + nRootLen -1);
			if(0 != strncmp((const char*)p,(const char*)"\\",1) && 
					 0 != strncmp((const char*)p,(const char*)"/",1))
			strcat(BrowserUISysRoot,(const char*)"\\");
		}
	}

	AnsiiToUnicodeString((S8 *)szWidePath, (S8 *)BrowserUISysRoot);
	if(FS_NO_ERROR != FS_SetCurrentDir((const WCHAR *)szWidePath) )
	{
		FS_CreateDir((const WCHAR *)szWidePath);
		FS_SetAttributes((const WCHAR *)szWidePath, (BYTE) (FS_ATTR_DIR | FS_ATTR_HIDDEN| FS_ATTR_SYSTEM));
	}
	for(i = 0; i< 2; i++)
	{
		if(NULL != Dirs[i] && 0 != strlen((const char*)Dirs[i]))
		{
			AnsiiToUnicodeString((S8*)szWidePath,(S8*)BrowserUISysRoot);
			AnsiiToUnicodeString((S8 *)(szWidePath + 2* pfnUnicodeStrlen((const S8*)szWidePath)), (S8 *)Dirs[i]);
			if(FS_NO_ERROR != FS_SetCurrentDir((const WCHAR *)szWidePath))
			{
				FS_CreateDir((const WCHAR *)szWidePath);
				FS_SetAttributes((const WCHAR *)szWidePath, (BYTE) (FS_ATTR_DIR | FS_ATTR_HIDDEN| FS_ATTR_SYSTEM));
			}
		}
	}
#endif //__PLXBROW_DIR_SYSTEM_	
	
	FS_SetCurrentDir((const WCHAR *)szCurrPath);
	PlxAppFree(szWidePath);
}



/****************************************************************************
* Function	char* GetPBUIHistoryFilePath(void)
* Purpose		 
* Params	
* Return	
* Remarks	
\****************************************************************************/
char* GetPBUIHistoryFilePath(void)
{
#ifdef __PLXBROW_DIR_SYSTEM_
	strcpy(TempUIPath,(const char*)BrowserUISysRoot);
#else
	strcpy(TempUIPath,(const char*)BrowserUIAppRoot);
#endif
	strcat(TempUIPath,(const char*)PLXBROW_HISTORY_FILENAME);
	return TempUIPath;
}


/****************************************************************************
* Function	char* GetPBUIBookmarkFilePath(void)
* Purpose		 
* Params	
* Return	
* Remarks	

⌨️ 快捷键说明

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