📄 plxmms_main.c
字号:
#ifdef MMS_DEBUG
PlxTrace("will EnterMmsMain\r\n");
#endif
EnterMmsMain();
#ifdef MMS_DEBUG
PlxTrace("CreateMmsMain end\r\n");
#endif
}
void ClearMainMMSE(void)
{
if(g_main_data.mmse)
{
MMSE_Cancel(g_main_data.mmse);
MMSE_Close(g_main_data.mmse);
g_main_data.mmse = NULL;
}
}
/***************************************************************************
* Function EnterMmsMain
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
void EnterMmsMain(void)
{
U16 nStrItemList[MAX_SUB_MENUS];
U16 nIconList[MAX_SUB_MENUS];
U8* pHintList[MAX_SUB_MENUS];
U16 nNumofItem = 0;
U8* guiBuffer = NULL;
S32 i;
//set handlers
for(i = 0; i < PLXMMS_MAINMENU_COUNT; i++)
{
if(i > 0 && i <= 4)
GetBoxMsgCount(i);
if(i == MMS_MAIN_SETTING ||
i == MMS_MAIN_NEW)
{
SetHintHandler(mms_main_func_table[i].id,
NULL);
}
else
{
SetHintHandler(mms_main_func_table[i].id,
MmsMainHintHandler);
}
}
#ifdef MMS_DEBUG
for ( i = 0; i < 3; i++ )
PlxTrace ("[MMS] box message count[%d]-[%d]", i, g_main_data.box_msg_count[i]);
#endif
if(GetActiveScreenId() != SCR_ID_PLX_MMS_MAIN)
{
//set enter and exit
EntryNewScreen(SCR_ID_PLX_MMS_MAIN,
/*ExitMmsMain*/NULL, EnterMmsMain, NULL);
//get gui buffer
guiBuffer = GetCurrGuiBuffer(SCR_ID_PLX_MMS_MAIN);
//set parent
SetParentHandler(MENU_ID_PLX_MMS);
}
else
{
EntryNewScreen(SCR_ID_PLX_MMS_MAIN,
NULL, EnterMmsMain, NULL);
//get gui buffer
guiBuffer = GetCurrGuiBuffer(SCR_ID_PLX_MMS_MAIN);
//delete old main in history
SetDelScrnIDCallbackHandler(SCR_ID_PLX_MMS_MAIN, NULL);
DeleteScreenIfPresent(SCR_ID_PLX_MMS_MAIN);
}
nNumofItem = GetNumOfChild(MENU_ID_PLX_MMS);
GetSequenceStringIds(MENU_ID_PLX_MMS, nStrItemList);
GetSequenceImageIds(MENU_ID_PLX_MMS, nIconList);
ConstructHintsList(MENU_ID_PLX_MMS, pHintList);
RegisterHighlightHandler(MmsMainHiliteHandler);
ShowCategory52Screen(STR_ID_PLX_MMS_MSG, IMG_ID_PLX_MMS,
STR_GLOBAL_OK, IMG_GLOBAL_OK,
STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
nNumofItem, nStrItemList, nIconList,
pHintList, LIST_MENU, g_main_data.cur_item, guiBuffer);
SetRightSoftkeyFunction(ExitMmsMain, KEY_EVENT_UP);
SetKeyHandler(ExitMmsMain, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
SetKeyHandler(PlxMmsGoBackToIdle, KEY_END, KEY_EVENT_DOWN);
SetDelScrnIDCallbackHandler(SCR_ID_PLX_MMS_MAIN, PlxMmsDelHistoryHdlr);
}
/***************************************************************************
* Function ExitMmsMain
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
void ExitMmsMain(void)
{
g_main_data.cur_item = 0;
g_mms_main_endKeyDownFuncPtr = NULL;
GoBackHistory();
}
/***************************************************************************
* Function MmsAppInit
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
BOOL MmsAppInit(PlxMmsAppData* pApp)
{
void* mmse = NULL;
if(!pApp)
return FALSE;
MMS_Memset((void*)pApp, 0, sizeof(PlxMmsAppData));
//open mmse
mmse = MMSE_Open(MMSE_ACCESS_READ);
if(!mmse)
return FALSE;
//set notify
MMSE_SetNotify(mmse, (void*)MmseCallback, MMSE_NOTIFY);
MMSE_SetOption(mmse, (PMMSEOPTION)(&g_default_option));
#ifdef MMS_UISETTINGFILE
if(!SaveSettingToFile((MmsUIOption*)&g_default_option))
{
MMSE_Close(mmse);
return FALSE;
}
#endif
pApp->mmse = mmse;
return TRUE;
}
/***************************************************************************
* Function MmsMainHiliteHandler
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
void MmsMainHiliteHandler(S32 index)
{
SetLeftSoftkeyFunction(
(mms_main_func_table[index]).entry, KEY_EVENT_UP);
SetKeyHandler((mms_main_func_table[index]).entry, KEY_ENTER, KEY_EVENT_UP);
SetKeyHandler((mms_main_func_table[index]).entry, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
g_main_data.cur_item = index;
}
/***************************************************************************
* Function MmsMainHintHandler
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
void MmsMainHintHandler(U16 index)
{
U8 ascValue[MAX_SUB_MENU_HINT_SIZE];
U8 uniValue[MAX_SUB_MENU_HINT_SIZE];
int count = 0;
int i = 0;
switch(index)
{
case MMS_MAIN_SENT:
i++;
case MMS_MAIN_DRAFT:
i++;
case MMS_MAIN_OUTBOX:
i++;
case MMS_MAIN_INBOX:
//get count
#ifdef MMS_SAVEONCARD
#ifdef MMI_ON_HARDWARE_P
if(PLIB_TestMSDC() != PMSDC_OK
#ifdef MMS_SELECTSTOREPATH
&& g_cur_path == g_plug_path
#endif
)
count = 0;
else
#endif
#endif
count = g_main_data.box_msg_count[i];
sprintf((char*)ascValue, " %d ", count);
AnsiiToUnicodeString((PS8)uniValue, (PS8)ascValue);
pfnUnicodeStrcpy((S8*)hintData[index], (S8*)uniValue);
break;
case MMS_MAIN_NEW:
case MMS_MAIN_SETTING:
hintData[index][0] = 0;
hintData[index][1] = 0;
break;
default:
hintData[index][0] = 0;
hintData[index][1] = 0;
}
}
/***************************************************************************
* Function GetBoxMsgCount
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
void GetBoxMsgCount(int i)
{
MMFOLDERINFO info;
#ifdef MMS_DEBUG
PlxTrace("GetBoxMsgCount, folder = %d\r\n", i);
#endif
#ifdef MMS_SAVEONCARD
#ifdef MMI_ON_HARDWARE_P
if(PLIB_TestMSDC() != PMSDC_OK
#ifdef MMS_SELECTSTOREPATH
&& g_cur_path == g_plug_path
#endif
)
{
#ifdef MMS_DEBUG
PlxTrace ("[MMS] GetBoxMsgCount [%d] no card");
#endif
g_main_data.box_msg_count[i-1] = 0;
return;
}
#endif
#endif
if(MMSE_GetFolderInfo(g_main_data.mmse, (const char*)i, &info) == MMSE_SUCCESS)
{
#ifdef MMS_DEBUG
PlxTrace("msg count = %d\r\n", info.TotalCount);
#endif
g_main_data.box_msg_count[i-1] = info.TotalCount;
}
}
/***************************************************************************
* Function MmseCallback
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
S32 MmseCallback(void* hWnd, UINT nMsg, long wParam, long lParam)
{
U8 i;
S16 old_type, new_type;
BOOL bDeal = FALSE;
MMSEOPTION option;
#ifdef MMS_SAVEONCARD
#ifdef MMI_ON_HARDWARE_P
if(PLIB_TestMSDC() != PMSDC_OK
#ifdef MMS_SELECTSTOREPATH
&& g_cur_path == g_plug_path
#endif
)
return 0;
#endif
#endif
if(!g_main_data.mmse || nMsg != MMSE_NOTIFY)
return 0;
//message status
old_type = (S16)(lParam & 0xFFFF);
new_type = (S16)((lParam>>16) & 0xFFFF);
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~~`MmseCallback, id=%x, old=%d, new=%d\r\n",
wParam, old_type, new_type);
#endif
//call sub window
for(i = 0; i < PLXMMS_MAINMENU_COUNT; i++)
{
if(mms_main_func_table[i].callback)
{
if(mms_main_func_table[i].callback(wParam, old_type, new_type))
bDeal = TRUE;
}
}
//add a message
if(old_type == MMT_NULL &&
(new_type == MMT_RECEIVING ||
new_type == MMT_AUTORECEIVING ||
new_type == MMT_UNRECEIVE ||
new_type == MMT_UNREADDELIVERYREPORT)
)
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~a new, cur id = %d\r\n", GetActiveScreenId());
#endif
if(GetActiveScreenId() == SCR_ID_PLX_MMS_MAIN &&
(new_type == MMT_RECEIVING ||
new_type == MMT_AUTORECEIVING))
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~will reenter main\r\n");
#endif
EnterMmsMain();
}
else
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~get inbox count\r\n");
#endif
GetBoxMsgCount((int)MMSE_FOLDER_INBOX);
}
}
else if(old_type == MMT_DRAFT &&
new_type == MMT_SENDING)
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~get outbox count\r\n");
#endif
GetBoxMsgCount((int)MMSE_FOLDER_OUTBOX);
}
else if(old_type == MMT_SENDING &&
new_type == MMT_SENT)
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~get sent count\r\n");
#endif
GetBoxMsgCount((int)MMSE_FOLDER_SENT);
}
//send ok
if(old_type == MMT_SENDING &&
new_type == MMT_SENT)
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~``send ok!!!\r\n");
#endif
PLIB_MessageBox(PMBTYPE_SUCCESS, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_SENDOK), 0);
}
//send failed
if(old_type == MMT_SENDING &&
new_type == MMT_UNSEND)
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~`send failed!!!\r\n");
#endif
PLIB_MessageBox(PMBTYPE_ERROR, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_SENDFAILE), 1000);
}
//receive ok, popup notinfication
if( ((old_type == MMT_RECEIVING ||
old_type == MMT_AUTORECEIVING) &&
new_type == MMT_UNREAD) ||
(old_type == MMT_NULL &&
new_type == MMT_UNREADDELIVERYREPORT)
)
{
int i = 0;
//idle icon
StatusIconTest(TRUE, 1, TRUE);
if(new_type == MMT_UNREADDELIVERYREPORT)
{
PLIB_MessageBox(PMBTYPE_SUCCESS, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_DELIVERYREPORTSUB), 0);
}
else
{
#ifdef MMS_DEBUG
BOOL bHasEdit = IsScreenPresent(SCR_ID_PLX_MMS_EDIT);
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~~~`bHasEdit = %d\r\n", bHasEdit);
#endif
if(IsScreenPresent(SCR_ID_PLX_MMS_VIEW) ||
GetActiveScreenId() == SCR_ID_PLX_MMS_VIEW ||
IsScreenPresent(SCR_ID_PLX_MMS_VIEW_DELIVERYREPORT) ||
GetActiveScreenId() == SCR_ID_PLX_MMS_VIEW_DELIVERYREPORT ||
IsScreenPresent(SCR_ID_PLX_MMS_EDIT) ||
GetActiveScreenId() == SCR_ID_PLX_MMS_EDIT)
{
if(old_type == MMT_RECEIVING)
{
PLIB_MessageBox(/*PMBTYPE_SUCCESS*/PMBTYPE_MSGRECVED, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_RECVOK), 5000);
}
else
{
PLIB_MessageBox(/*PMBTYPE_SUCCESS*/PMBTYPE_MSGRECVED, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_NEWMSG), 5000);
}
}
else
{
int icon = IMG_ID_PLX_MMS_MMSRECVOK;
g_main_data.new_msg_back_screen = GetActiveScreenId();
g_main_data.new_msg_id = (long)wParam;
if(old_type == MMT_RECEIVING)
{
if(gKeyPadLockFlag && GetActiveScreenId() == IDLE_SCREEN_ID)
{
PLIB_MessageBox(PMBTYPE_MSGRECVED, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_RECVOK), 5000);
}
else
{
if(GetKeyHandler(KEY_END, KEY_EVENT_DOWN) != PlxMmsGoBackToIdle)
g_mms_main_endKeyDownFuncPtr = GetKeyHandler(KEY_END, KEY_EVENT_DOWN);
PLIB_ConfirmBox(NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_RECVOK),
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_VIEW),
(WCHAR*)GetString(STR_GLOBAL_BACK),
(void*)&icon, 0, (void*)&i, 0, IfViewNewCallback);
}
}
else
{
if(gKeyPadLockFlag && GetActiveScreenId() == IDLE_SCREEN_ID)
{
PLIB_MessageBox(PMBTYPE_MSGRECVED, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_NEWMSG), 5000);
}
else
{
if(GetKeyHandler(KEY_END, KEY_EVENT_DOWN) != PlxMmsGoBackToIdle)
g_mms_main_endKeyDownFuncPtr = GetKeyHandler(KEY_END, KEY_EVENT_DOWN);
PLIB_ConfirmBox(NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_NEWMSG),
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_VIEW),
(WCHAR*)GetString(STR_GLOBAL_BACK),
(void*)&icon, 0, (void*)&i, 0, IfViewNewCallback);
}
}
SetKeyHandler(PlxMmsGoBackToIdle, KEY_END, KEY_EVENT_DOWN);
}
}
}
//receive failed
if( (old_type == MMT_RECEIVING ||
old_type == MMT_AUTORECEIVING) &&
new_type == MMT_UNRECEIVE )
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~~~`````receive failed!!!\r\n");
#endif
if(old_type == MMT_RECEIVING)
{
StatusIconTest(TRUE, 1, FALSE);
PLIB_MessageBox(PMBTYPE_ERROR, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_RECVFAIL), 5000);
}
else //auto
{
StatusIconTest(TRUE, 1, TRUE);
PLIB_MessageBox(PMBTYPE_MSGARRIVE, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_NEWMSG), 5000);
}
}
if(old_type == MMT_NULL &&
new_type == MMT_UNRECEIVE)
{
#ifdef MMS_DEBUG
PlxTrace("~~~~~~~~~~~~~~~~~~~~~~~~`````receive failed directly!!!\r\n");
#endif
if(MMSE_GetOption(g_main_data.mmse, &option) == MMSE_SUCCESS)
{
if((option.ReceiveFlag & MMRF_AUTORETRIEVE) == 0)
{
StatusIconTest(TRUE, 1, TRUE);
PLIB_MessageBox(PMBTYPE_MSGARRIVE, NULL,
(WCHAR*)GetString(STR_ID_PLX_MMS_BOX_NEWMSG), 5000);
}
}
}
return 1;
}
/***************************************************************************
* Function EditNewEntry
* Purpose
* Params
* Return
* Remarks
\**************************************************************************/
void EditNewEntry(void)
{
#ifdef MMS_SAVEONCARD
#ifdef MMI_ON_HARDWARE_P
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -