📄 auipineditor.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name: Basic MMI
$Project code: BMI (6349)
$Module: MMI
$File: AUIPINEditor.c
$Revision: 1.0
$Author: Condat(UK)
$Date: 22/02/01
********************************************************************************
Description: Editor for PIN entry
********************************************************************************
$History: AUIPINEditor.c
14/11/02 Original Condat(UK) BMI version.
$End
*******************************************************************************/
#define ENTITY_MFW
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_ss.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_lng.h"
#include "mfw_sat.h"
#include "mfw_kbd.h"
#include "mfw_nm.h"
#include "mfw_cm.h"
#include "dspl.h"
#include "ksd.h"
#include "psa.h"
#include "MmiDummy.h"
#include "MmiMmi.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
#include "MmiIdle.h"
#include "MmiResources.h"
#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "MmiColours.h"
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#include "AUITextEntry.h"
#include "AUIPINEditor.h"
typedef struct
{
T_MMI_CONTROL mmi_control;
T_MFW_HND parent; // The parent window
T_MFW_HND win; // The edit window
T_MFW_HND kbd; // The keyboard handler
T_MFW_HND kbd_long; // The longpress keyboard handler
T_MFW_HND timer; // The timer for timeouts
T_ED_DATA *editor; /* The ATB editor */
T_AUI_EDITOR_DATA editor_data; /* The MMI editor data, provided by caller */
T_AUI_ENTRY_DATA *entry_data; /* The MMI text entry data */
BOOL haveTitle; /* TRUE if a title is supplied */
T_ATB_TEXT title; /* Title of editor */
BOOL doNextLongPress; /* Flag used to notice/not notice long keypress */
BOOL enteredMinChars; /* Set to TRUE when at least min_enter characters have been entered */
BOOL enteredSomeChars; /* Set to TRUE if the length of the entered data is non-zero */
UBYTE emergency_call; /* Set to TRUE if number is an emergency call number */
UBYTE ss_string;
char imei[16];
}
T_AUI_PIN_DATA;
/* LOCAL FUNCTION PROTOTYPES */
static T_MFW_HND AUI_pin_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data);
static void AUI_pin_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int AUI_pin_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data);
static int AUI_pin_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard);
static int AUI_pin_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard);
static UBYTE AUI_pin_CheckEmergency(T_AUI_PIN_DATA *data);
T_MFW_SS_RETURN AUI_pin_CheckSSString(T_AUI_PIN_DATA *data);
/*******************************************************************************
$Function: AUI_pin_Start
$Description: Start the PIN editor.
$Returns: None.
$Arguments: None.
*******************************************************************************/
T_MFW_HND AUI_pin_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
{
T_MFW_HND win;
TRACE_FUNCTION ("AUI_pin_Start()");
win = AUI_pin_Create(parent, editor_data);
return win;
}
/*******************************************************************************
$Function: AUI_pin_Create
$Description: Create the PIN editor.
$Returns: Pointer to the editor's window.
$Arguments: parent - The parent window.
*******************************************************************************/
static T_MFW_HND AUI_pin_Create(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data)
{
T_AUI_PIN_DATA *data;
T_MFW_WIN *win_data;
TRACE_FUNCTION ("AUI_pin_Create()");
TRACE_EVENT_P1("Memory left (start): %d", mfwCheckMemoryLeft());
data = (T_AUI_PIN_DATA *)ALLOC_MEMORY(sizeof (T_AUI_PIN_DATA));
TRACE_EVENT_P1("Memory left (data): %d", mfwCheckMemoryLeft());
/* Create window handler */
data->win = win_create(parent, 0, E_WIN_VISIBLE, (T_MFW_CB)AUI_pin_WinCb); // Create window
TRACE_EVENT_P1("Memory left (win): %d", mfwCheckMemoryLeft());
if (data->win==NULL) // Make sure window exists
{
return NULL;
}
/* Connect the dialog data to the MFW-window */
data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_pin_ExecCb; /* Setup the destination for events */
data->mmi_control.data = data;
data->parent = parent;
win_data = ((T_MFW_HDR *)data->win)->data;
win_data->user = (void *)data;
data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_pin_KbdCb);
data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_pin_KbdLongCb);
data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0);
TRACE_EVENT_P1("Memory left (editor): %d", mfwCheckMemoryLeft());
data->editor_data = *editor_data;
data->entry_data = AUI_entry_Create(data->win, data->editor, E_PIN_UPDATE);
TRACE_EVENT_P1("Memory left (entry): %d", mfwCheckMemoryLeft());
SEND_EVENT(data->win, E_PIN_INIT, 0, 0);
/* Return window handle */
return data->win;
}
/*******************************************************************************
$Function: AUI_pin_Destroy
$Description: Destroy the PIN editor.
$Returns: None.
$Arguments: window - The editor window.
*******************************************************************************/
void AUI_pin_Destroy(T_MFW_HND win)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
TRACE_FUNCTION("AUI_pin_Destroy");
TRACE_EVENT_P1("Memory left at start: %d", mfwCheckMemoryLeft());
if (data)
{
/* Free memory allocated for title */
if (data->haveTitle)
{
FREE_MEMORY(data->title.data, (data->title.len+1)*ATB_string_Size(&data->title));
TRACE_EVENT_P1("Memory left (title dest): %d", mfwCheckMemoryLeft());
}
/* Free text entry memory */
AUI_entry_Destroy(data->entry_data);
TRACE_EVENT_P1("Memory left (entry dest): %d", mfwCheckMemoryLeft());
/* Delete window */
win_delete (data->win);
TRACE_EVENT_P1("Memory left (win dest): %d", mfwCheckMemoryLeft());
/* Free editor memory */
ATB_edit_Destroy(data->editor);
TRACE_EVENT_P1("Memory left (editor dest): %d", mfwCheckMemoryLeft());
/* Free Memory */
FREE_MEMORY ((void *)data, sizeof (T_AUI_PIN_DATA));
TRACE_EVENT_P1("Memory left (data dest): %d", mfwCheckMemoryLeft());
}
return;
}
/*******************************************************************************
$Function: AUI_pin_ExecCb
$Description: Dialog function for PIN editor.
$Returns: None.
$Arguments: None.
*******************************************************************************/
static void AUI_pin_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter)
{
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_PIN_DATA *data = (T_AUI_PIN_DATA *)win_data->user;
T_MFW_HND parent_win = data->parent;
T_ATB_TEXT text;
/* Store these in case editor is destroyed on callback */
USHORT Identifier = data->editor_data.Identifier;
T_AUI_EDIT_CB Callback = data->editor_data.Callback;
UBYTE destroyEditor = data->editor_data.destroyEditor;
TRACE_FUNCTION ("AUI_pin_ExecCb()");
switch (event)
{
/* Initialise */
case E_PIN_INIT:
TRACE_EVENT("E_PIN_INIT");
ATB_edit_Init(data->editor);
data->haveTitle = FALSE;
/* If we require an output line, shrink editor to fit it at bottom
* NB TitleString is assumed here to be a numeric string of ascii digits */
if (data->editor_data.TitleString)
{
data->haveTitle = TRUE;
text.data = data->editor_data.TitleString;
}
/* Set up title */
if (data->editor_data.TitleId!=NULL)
{
data->haveTitle = TRUE;
text.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId);
}
/* If title exists, get its dcs and length */
if (data->haveTitle)
{
if (text.data[0]==0x80)
{
text.data += 2; /* Skip over two unicode indicator bytes */
text.dcs = ATB_DCS_UNICODE;
}
#ifdef EASY_TEXT_ENABLED
else if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
{
text.dcs = ATB_DCS_UNICODE;
}
#endif
else
{
text.dcs = ATB_DCS_ASCII;
}
text.len = ATB_string_Length(&text);
/* Allocate memory for the title and copy the text there */
data->title.data = (UBYTE *)ALLOC_MEMORY((text.len+1)*ATB_string_Size(&text));
TRACE_EVENT_P1("Memory left (title): %d", mfwCheckMemoryLeft());
ATB_string_Copy(&data->title, &text);
}
/* Set flag if min_enter characters are in buffer */
if (data->editor_data.editor_attr.text.len >= data->editor_data.min_enter)
data->enteredMinChars = TRUE;
else
data->enteredMinChars = FALSE;
/* Set flag if some characters are in the buffer */
if (data->editor_data.editor_attr.text.len > 0 )
data->enteredSomeChars = TRUE;
else
data->enteredSomeChars = FALSE;
/* Show the window */
win_show(data->win);
break;
case E_PIN_UPDATE:
TRACE_EVENT("E_PIN_UPDATE");
win_show(data->win);
break;
case E_PIN_DEINIT:
TRACE_EVENT("E_PIN_DEINIT");
if (Callback)
(Callback) (parent_win, Identifier, value);
if (destroyEditor)
AUI_pin_Destroy(data->win);
break;
}
return;
}
/*******************************************************************************
$Function: AUI_pin_WinCb
$Description: PIN editor window event handler.
$Returns: None.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -