📄 plxuilib.c
字号:
MAX_SAVEDATA_NAME, guiBuffer);
SetLeftSoftkeyFunction (InputNameOnOK, KEY_EVENT_UP);
SetCategory5RightSoftkeyFunction (InputNameOnCancel, KEY_EVENT_UP);
}
static void InputNameOnOK (void)
{
PLIB_RegisterIMEDoneNotify (InputNameMenuOnOK);
PLIB_IMEOptionEntry ();
}
static void InputNameOnCancel (void)
{
SavedataNotify (PEVENT_USERABORT);
}
static void InputNameMenuOnOK (void)
{
S32 handle;
UINT wrlen = 0;
unsigned long freesize;
WCHAR * path = MakeFullPathName();
if ( path == NULL ) {
DisplayPopup ((U8*)GetString (STR_ID_PLX_UIL_NAMEINVALID), IMG_GLOBAL_ERROR, 1, UI_POPUP_NOTIFYDURATION_TIME, ERROR_TONE);
DeleteUptoScrID (SCR_ID_PLX_UIL_INPUT);
return;
}
freesize = GetFreeFsSize (path);
#ifdef _SAVEDATA_TEMPFILE
if ( (unsigned long)gSaveDataPara.fsize >= freesize ) {
#else
if ( (unsigned long)gSaveDataPara.datalen >= freesize ) {
#endif
SavedataNotify (PEVENT_SPACEFULL);
return;
}
handle = FS_Open (path, FS_READ_ONLY);
if ( handle > 0 ) {
FS_Close (handle);
DisplayPopup ((U8*)GetString (STR_ID_PLX_UIL_DUPNAME), IMG_GLOBAL_ERROR, 1, UI_POPUP_NOTIFYDURATION_TIME, ERROR_TONE);
DeleteUptoScrID (SCR_ID_PLX_UIL_INPUT);
return;
}
#ifdef _SAVEDATA_TEMPFILE
/* 11-22 modified for 06A */
#include "PlxConfig.h"
#if defined(PROJECT_BRANCH_06A)
handle = FS_Move (gSaveDataPara.tmppath, path, FS_MOVE_KILL, NULL, NULL, 0);
#else
handle = FS_Move (gSaveDataPara.tmppath, path, FS_MOVE_KILL, NULL);
#endif // defined(PROJECT_BRANCH_06A)
/* 11-22 modified for 06A end */
if ( handle < 0 ) {
SavedataNotify (PEVENT_FSFAIL);
return;
}
#else
handle = FS_Open (path, FS_CREATE);
if ( handle <= 0 ) {
SavedataNotify (PEVENT_FSFAIL);
return;
}
FS_Write (handle, (void*)gSaveDataPara.pdata, (UINT)gSaveDataPara.datalen, &wrlen);
FS_Close (handle);
#endif
SavedataNotify(PEVENT_SUCCESS);
}
static void SavedataNotify (int result)
{
SAVEDATACALLBACK callback = gUserNotify.cbSaveData;
gSaveDataPara.isback = 1;
DeleteScreenIfPresent (SCR_ID_PLX_UIL_FMONITOR);
// GoBackToHistory (gScreenID);
#ifdef _SAVEDATA_TEMPFILE
if ( gSaveDataPara.fhandle > 0 ) {
FS_Delete (gSaveDataPara.tmppath);
}
#else
if ( gSaveDataPara.pdata )
PlxAppFree (gSaveDataPara.pdata);
#endif
if ( callback ) {
gUserNotify.cbSaveData = NULL;
callback (result);
}
}
static WCHAR * MakeFullPathName (void)
{
static WCHAR filename[MAX_SAVEDATA_PATH];
S32 len;
len = pfnUnicodeStrlen ((char*)gSaveDataPara.path)
+ pfnUnicodeStrlen ((char*)gSaveDataPara.name)
+ pfnUnicodeStrlen ((char*)gSaveDataPara.ext) + 1;
if ( len >= MAX_SAVEDATA_PATH)
return NULL;
pfnUnicodeStrcpy ((char*)filename, (char*)gSaveDataPara.path);
pfnUnicodeStrcat ((char*)filename, (char*)gSaveDataPara.name);
if ( pfnUnicodeStrlen ((char*)gSaveDataPara.ext) > 0 ) {
pfnUnicodeStrcat ((char*)filename, ".\x00\x00\x00");
pfnUnicodeStrcat ((char*)filename, (char*)gSaveDataPara.ext);
}
return filename;
}
#ifdef _SAVEDATA_TEMPFILE
static int TrySaveFile (int drive, WCHAR * dstPath, WCHAR * ext, void * data, int datalen);
static int SaveTempFile (WCHAR * dstPath, WCHAR * ext, void * data, int datalen)
{
int fhandle;
#ifdef MMI_ON_WIN32
AnsiiToUnicodeString ((char*)dstPath, (char *)"D:\\savetmp");
fhandle = FS_Open (dstPath, FS_CREATE);
FS_Write (fhandle, data, datalen, NULL);
FS_Close (fhandle);
return fhandle;
#else
int drive;
if (((drive = FS_GetDrive(FS_DRIVE_V_NORMAL, 2, FS_NO_ALT_DRIVE)) >= 'A') &&
(drive <= 'Z'))
{
if ( (fhandle=TrySaveFile (drive, dstPath, ext, data, datalen)) > 0 ) {
return fhandle;
}
}
if (((drive = FS_GetDrive(FS_DRIVE_V_NORMAL, 1, FS_NO_ALT_DRIVE)) >= 'A') &&
(drive <= 'Z'))
{
if ( (fhandle=TrySaveFile (drive, dstPath, ext, data, datalen)) > 0 ) {
return fhandle;
}
}
if (((drive = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, FS_NO_ALT_DRIVE)) >= 'A') &&
(drive <= 'Z'))
{
if ( (fhandle=TrySaveFile (drive, dstPath, ext, data, datalen)) > 0 ) {
return fhandle;
}
}
if (((drive = FS_GetDrive(FS_DRIVE_I_SYSTEM, 2, FS_NO_ALT_DRIVE)) >= 'A') &&
(drive <= 'Z'))
{
if ( (fhandle=TrySaveFile (drive, dstPath, ext, data, datalen)) > 0 ) {
return fhandle;
}
}
if (((drive = FS_GetDrive(FS_DRIVE_I_SYSTEM, 1, FS_NO_ALT_DRIVE)) >= 'A') &&
(drive <= 'Z'))
{
if ( (fhandle=TrySaveFile (drive, dstPath, ext, data, datalen)) > 0 ) {
return fhandle;
}
}
return 0;
#endif
}
static int TrySaveFile (int drive, WCHAR * dstPath, WCHAR * ext, void * data, int datalen)
{
char t[64];
unsigned long freesize;
int fhandle;
UINT written;
sprintf (t, "%c:\\", drive);
AnsiiToUnicodeString ((char*)dstPath, t);
freesize = GetFreeFsSize (dstPath);
if ( (unsigned long)datalen > freesize ) {
dstPath[0] = 0x0000;
return 0;
}
/* we prefer to store in our own directory */
pfnUnicodeStrcat ((char*)dstPath, (const char *)L"pollex\\");
fhandle = FS_Open (dstPath, FS_READ_ONLY);
if ( fhandle <= 0 ) {
AnsiiToUnicodeString ((char *)dstPath, t);
}
else {
FS_Close (fhandle);
}
/* Since we don't allow reenter SaveData and we must delete temp file each time
So here we just give an specific filename instead of a random filename */
pfnUnicodeStrcat ((char *)dstPath, (const char *)L"savetemp");
if ( pfnUnicodeStrlen ((char*)ext) > 0 ) {
pfnUnicodeStrcat ((char *)dstPath, (char*)L".");
pfnUnicodeStrcat ((char *)dstPath, (char*)ext);
}
fhandle = FS_Open (dstPath, FS_CREATE);
if ( fhandle <= 0 ) {
dstPath[0] = 0x0000;
return 0;
}
FS_Write (fhandle, data, datalen, &written);
FS_Close (fhandle);
if ( (int)written != datalen ) {
return 0;
}
return fhandle;
}
#endif
static int CheckMediaType (char * ext)
{
if ( strlen (ext) == 0 )
return MEDIA_UNKNOWN;
if ( strcmp (ext, "mid") == 0 ||
strcmp (ext, "vm") == 0 ||
strcmp (ext, "imy") == 0 ||
strcmp (ext, "wav") == 0 ||
strcmp (ext, "amr") == 0 ||
#ifdef AAC_DECODE
strcmp (ext, "aac") == 0 ||
#endif
#ifdef AMRWB_DECODE
strcmp (ext, "awb") == 0 ||
#endif
#ifdef DAF_DECODE
strcmp (ext, "mp3") == 0 ||
#endif
strcmp (ext, "aif") == 0 ||
strcmp (ext, "aiff") == 0 ||
strcmp (ext, "aifc") == 0 ||
strcmp (ext, "au") == 0 ||
#ifdef MP4_CODEC
strcmp (ext, "m4a") == 0 ||
#endif
#if defined( EXT_AUDIO_CHIP ) || defined( MMF_DECODE)
strcmp (ext, "mmf") == 0 ||
#endif
#ifdef WMA_DECODE
strcmp (ext, "wma") == 0 ||
#endif
strcmp (ext, "snd") == 0 ) {
return MEDIA_AUDIO;
}
if ( strcmp (ext, "bmp") == 0 ||
#ifdef JPG_DECODE
strcmp (ext, "jpg") == 0 ||
strcmp (ext, "jpeg") == 0 ||
#endif
strcmp (ext, "gif") == 0 ||
strcmp (ext, "png") == 0 ||
strcmp (ext, "wbmp") == 0 ||
strcmp (ext, "wbm") == 0 ) {
return MEDIA_IMAGE;
}
#if defined(ISP_SUPPORT)
if ( strcmp (ext, "3gp") == 0 ||
strcmp (ext, "3gpp") == 0 ||
strcmp (ext, "mp4") == 0 ) {
return MEDIA_VIDEO;
}
#endif
#if defined(CAMERA_MODULE)
if (strcmp (ext, "avi") == 0 ) {
return MEDIA_VIDEO;
}
#endif
return MEDIA_UNKNOWN;
}
static char * lookUpContentTable
(const char * name, const char * ext)
{
int i;
if ( name == NULL && ext == NULL )
return NULL;
for ( i = 0; gContentTab[i].name != NULL; i++ ) {
if ( name == NULL ) {
if ( mystricmp ((char*)gContentTab[i].ext, (char*)ext) == 0 ) {
return (char*)gContentTab[i].ext;
}
}
else if ( ext == NULL ) {
if ( mystrnicmp ((char*)gContentTab[i].name, (char*)name,
strlen(gContentTab[i].name)) == 0 ) {
return (char*)gContentTab[i].ext;
}
}
}
return NULL;
}
static unsigned char mytolower (unsigned char ch)
{
if( ch >='A' && ch <= 'Z' )
return (unsigned char) (ch + ('a' - 'A'));
return ch;
}
static char mystrnicmp (char *src, char *dest, int maxlen)
{
unsigned char ch1, ch2;
char *s1, *s2;
s1 = src;
s2 = dest;
while (maxlen-- > 0)
{
ch1 = mytolower ((unsigned char)*s1++);
ch2 = mytolower ((unsigned char)*s2++);
if(ch1 != ch2)
return TRUE;
}
return FALSE;
}
static char mystricmp (char *src, char *dest)
{
int len_src = strlen(src);
int len_dest = strlen(dest);
if(len_src != len_dest)
return TRUE;
else
return mystrnicmp (src, dest, len_src);
}
/************************************************************************/
/* Data account get info implementation */
/************************************************************************/
void PLIB_GetAccountInfo (int accountID, void (*callback)(void * info))
{
int idx = accountID;
if ( gUserNotify.cbAccountInfo )
return;
gUserNotify.cbAccountInfo = callback;
if ( accountID < MAX_DATA_ACCOUNT_GSM_LIMIT ) {
gDtcnt.actInfo = &gDtcnt.gsm[idx];
gDtcnt.actInfo->accID = accountID;
SetDefDataAccountName (gDtcnt.defname, idx);
GetGSMAccountReq (idx);
}
else {
idx -= MAX_DATA_ACCOUNT_GSM_LIMIT;
gDtcnt.actInfo = &gDtcnt.gprs[idx];
gDtcnt.actInfo->accID = accountID;
SetDefDataAccountName (gDtcnt.defname, idx);
GetGPRSAccountReq (idx);
}
}
static void GetGSMAccountReq (int accID)
{
#ifdef MMI_ON_HARDWARE_P
mmi_cc_get_csd_profile_req_struct *myMsgPtr;
MYQUEUE Message;
myMsgPtr = (mmi_cc_get_csd_profile_req_struct*) OslConstructDataPtr(sizeof(mmi_cc_get_csd_profile_req_struct));
myMsgPtr->prof_id = (unsigned char)accID;
SetProtocolEventHandler (GetGSMAccountRsp,PRT_MMI_CC_GET_CSD_PROFILE_RSP);
Message.oslSrcId=MOD_MMI;
Message.oslDestId=MOD_L4C;
Message.oslMsgId = PRT_MMI_CC_GET_CSD_PROFILE_REQ;
Message.oslDataPtr = (oslParaType *)myMsgPtr;
Message.oslPeerBuffPtr= NULL;
OslMsgSendExtQueue(&Message);
#else
PlxPostMessage ((void*)wndproc, LIBMSG_GETACCOUNT, accID, 0);
#endif
}
static void GetGSMAccountRsp (void* para)
{
PACCOUNTINFO info = gDtcnt.actInfo;
#ifdef MMI_ON_HARDWARE_P
mmi_cc_get_csd_profile_rsp_struct *localPtr;
if ( info == NULL )
return;
localPtr = (mmi_cc_get_csd_profile_rsp_struct *)para;
if(localPtr->name.name_dcs == DATA_ACCOUNT_UCS)
{
int i = 0;
if (localPtr->name.name_length == 0) {
pfnUnicodeStrcpy((char*)info->name, gDtcnt.defname);
}
else {
while( i != localPtr->name.name_length)
{
((char*)info->name)[i] = localPtr->name.name[i+1];
((char*)info->name)[i+1] = localPtr->name.name[i];
i+=2;
}
((char*)info->name)[localPtr->name.name_length] = '\0';
((char*)info->name)[localPtr->name.name_length+1] = '\0';
}
}
else if(localPtr->name.name_dcs == DATA_ACCOUNT_ASCII)
{
if (localPtr->name.name_length == 0) {
pfnUnicodeStrcpy((char*)info->name, gDtcnt.defname);
}
else {
AnsiiNToUnicodeString((char*)info->name, (char*)localPtr->name.name, localPtr->name.name_length);
}
}
strcpy (info->user, (char*)localPtr->user_id);
strcpy (info->pass, (char*)localPtr->passwd);
if ((localPtr->dest.type) & 0x10) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -