📄 mmibooksdnwindow.c
字号:
*/
if ( activeEditor() != data->edt )
editActivate( data->edt, TRUE );
editEventKey( e, k );
/* Handle the events we need to deal with here
*/
switch (k->code)
{
case KCD_MNUUP:
{
/* Scroll up event, just mark our event as such and it'll
be dealt with in due course
*/
MyEvent = SEARCH_SCROLL_UP;
}
break;
case KCD_MNUDOWN:
{
/* Scroll down event, just mark our event as such and it'll
be dealt with in due course
*/
MyEvent = SEARCH_SCROLL_DOWN;
}
break;
case KCD_CALL:
case KCD_LEFT:
{
/* left key is a select, we either need to send the number
back to the parent window, or call it
*/
Number = (char *) data->phbk->current.entry[ data->phbk->current.selectedName ].number;
if ( data->phbk->fromSMS )
SEND_EVENT( data->phbk->parent_win, SMS_PHBK_NUMBER, 0, (UBYTE *) Number );
else if(data->phbk->fromDivert )
SEND_EVENT( data->phbk->parent_win, DIVERT_PHBK_NUMBER, 0, (UBYTE *) Number );
else
callNumber( (UBYTE *) Number );
/* Having dealt with the number, we destroy our phone book
context and exit the handler early
*/
bookPhonebookDestroy( data->phbk->win );
return MFW_EVENT_CONSUMED;
}
break;
case KCD_RIGHT:
{
/* Right key is a cancel
*/
bookSDNDestroy( data->win );
data->phbk->search_win = 0;
return MFW_EVENT_CONSUMED;
}
break;
case KCD_HUP:
{
/* Clear key deletes the last character, or if none left will
take us out of here
*/
if ( data->edtBuf[0] == '\0' )
{
bookSDNDestroy( data->win );
data->phbk->search_win = 0;
return MFW_EVENT_CONSUMED;
}
else
{
/* Delete last character entered
*/
edtChar( data->edt, ecBack );
}
}
break;
default:
{
/* No default processing required
*/
}
break;
}
/* Initiate a new search based on the current settings, MyEvent
will have been set accordingly
*/
SEND_EVENT( data->win, MyEvent, 0, 0 );
winShow( data->win );
/* And make sure no calling routines try to do anything with the
event we have just dealt with
*/
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: bookSDNKeyLongCB
$Description: long keyboard event handler
$Returns: MFW_EVENT_CONSUMED always
$Arguments: e, event to handle, k, keyboard handle
*******************************************************************************/
static int bookSDNKeyLongCB( MfwEvt e, MfwKbd *k )
{
T_MFW_HND win = mfwParent(mfw_header());
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
tBookStandard *data = (tBookStandard *)win_data->user;
/* Just checks for clear and long being set, if so it will
destroy the window
*/
if ( (e & KEY_CLEAR) && (e & KEY_LONG) )
{
bookSDNDestroy( win );
data->phbk->search_win = 0;
}
/* Force event consumed always, prevents default behaviour
kicking in
*/
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: bookSDNCreate
$Description: Creates the Service numbers widow
$Returns: Window Handle, or NULL if unsuccessfull
$Arguments: Parent, handle of the parent window
*******************************************************************************/
static T_MFW_HND bookSDNCreate( MfwHnd parent )
{
T_MFW_WIN *win_data;
tBookStandard *data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) );
T_MFW_WIN *parent_win_data = ((T_MFW_HDR *)parent)->data;
T_phbk* phbk = (T_phbk *)parent_win_data->user;
TRACE_FUNCTION( "bookSDNCreate()" );
/* Create the window
*/
if ( ( data->win = win_create (parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookSDNWinCB ) ) == NULL )
return NULL;
/* set up the basic window elements, dialog and user data pointers
*/
data->mmi_control.dialog = (T_DIALOG_FUNC)bookSDN;
data->mmi_control.data = data;
win_data = ((T_MFW_HDR *)data->win)->data;
win_data->user = (void *)data;
data->parent_win = parent;
/* Create keyboard and menu handlers to be associated with
this window
*/
data->kbd = kbdCreate( data->win, KEY_ALL, (MfwCb) bookSDNKbdCB );
data->kbd_long = kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookSDNKeyLongCB );
data->menu = mnuCreate( data->win, MmiBookMenuDetailsList(), 0, 0 );
/* Set basic edit attributes structure and create an editor
associated with these attributes
*/
bookSetEditAttributes( 34, 38, 50, 10, 0, 0, edtCurBar1, 0, (char*) data->edtBuf, MAX_SEARCH_CHAR, &data->attr );
data->edt = edtCreate( data->win, &data->attr, 0, 0 );
/* Show the menu
*/
mnuUnhide(data->menu);
/* associate the phonebook handler
*/
data->phbk = phbk;
/* and return the newly created window handle
*/
return data->win;
}
/*******************************************************************************
Public methods
*******************************************************************************/
/*******************************************************************************
$Function: bookSDNStart
$Description: This is the entry point for the service numbers window handler
$Returns: handle of window we are creating
$Arguments: Parent, handle of the parent window
*******************************************************************************/
T_MFW_HND bookSDNStart( MfwHnd parent )
{
T_MFW_HND win;
T_MFW_WIN *win_data;
tBookStandard *data;
MfwMnu *mnu;
TRACE_FUNCTION( "bookSDNCreate()" );
/* We can't actually create the window if the phone book is
still loading, so we will deal with this up front
*/
if ( phb_get_mode() == PHB_LOADING )
{
bookShowInformation( idle_get_window(), TxtPleaseWait ,NULL, NULL );
return NULL;
}
/* Create the basic window, dealing with errors here and just terminating
if we can't create the window correctly.
*/
if ( ( win = bookSDNCreate( parent ) ) == NULL )
return NULL;
/* Okay, we have created the window, so set up our internal
working pointers and check if the current phone book has
some entries in it
*/
win_data = ((T_MFW_HDR *) win)->data;
data = (tBookStandard *)win_data->user;
data->phbk->current.status.book = PHB_SDN;
/* we need to determine if there are any entries in the phone book
before we allow the service number windows to be displayed, we
do this by searching for an empty name
*/
bookGetCurrentStatus( &data->phbk->current.status );
memset( data->edtBuf, '\0' , sizeof( data->edtBuf ) );
data->phbk->current.index = 1;
data->phbk->current.selectedName = 0;
bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
/* If the current index is still zero then we have been unable to
find an entry, in this case we need to shutdown the service
numbers window, since we can't do anything with it.
*/
if ( data->phbk->current.index == 0 )
{
bookSDNDestroy( win );
data->phbk->search_win = 0;
bookShowInformation( idle_get_window(), TxtEmptyList ,NULL, NULL );
return 0;
}
/* We are still running, so set up the menu and edit structures
accordingly, and display the window
*/
mnu = (MfwMnu *) mfwControl( data->menu );
mnu->lCursor[ mnu->level ] = data->phbk->current.selectedName;
editActivate( data->edt, 1 );
winShow( data->win );
/* return the pointer to the window
*/
return win;
}
/*******************************************************************************
$Function: bookFindNameInSDNPhonebook
$Description: This routine performs the FindNameInPhoneBook functionality,
tuned to the particular requirements of the service numbers
phonebook.
$Returns: handle of window we are creating
$Arguments: Parent, handle of the parent window
*******************************************************************************/
int bookFindNameInSDNPhonebook( const char* p_pszNumber, T_MFW_PHB_ENTRY* p_pEntry )
{
T_MFW_PHB_LIST phb_list;
#ifdef NO_ASCIIZ
T_MFW_PHB_TEXT p_pszNumberText;
#endif
//glowing, 2004-04-09, for compatible with the old version
#if TCS20_VER
SHORT phb_index;
#else
UBYTE phb_index;
#endif
UBYTE l_name[PHB_MAX_LEN];
int status;
TRACE_FUNCTION("bookFindNameInSDNPhonebook()");
/* guard against dodgy input data
*/
if( ( p_pszNumber == NULL ) || ( p_pEntry == NULL ) )
return 0;
/* initialise the search structures
*/
memset(p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY));
memset(&phb_list, 0, sizeof(phb_list));
phb_list.entry = p_pEntry;
phb_list.num_entries = 1;
//GW Set up data structure for NO_ASCIIZ
#ifdef NO_ASCIIZ
p_pszNumberText.dcs = MFW_DCS_7bits;
p_pszNumberText.len = strlen(p_pszNumber);
strcpy((char*)p_pszNumberText.data, p_pszNumber);
#endif
/* see what we can find using the standard search routine for
any phone book, giving the service numbers book as a parameter
*/
#ifdef NO_ASCIIZ
// phb_find_entries( PHB_SDN, &phb_index, MFW_PHB_NUMBER, 1, (UBYTE *) p_pszNumber, 0, &phb_list );
//2003/10/8, zhq, modified to make it compatible with aci prototype.
//status = phb_find_entries( (UBYTE)PHB_SDN, &phb_index, (UBYTE)MFW_PHB_NUMBER, 1, &p_pszNumberText, &phb_list );
status = phb_find_entries( PHB_SDN, &phb_index, (UBYTE)MFW_PHB_NUMBER, 1, &p_pszNumberText, &phb_list );
#else
status = phb_find_entries( PHB_SDN, &phb_index, MFW_PHB_NUMBER, 1, (char *) p_pszNumber, &phb_list );
#endif
/* convert the returned data to manageable information
*/
#ifdef NO_ASCIIZ
//GW Check that conversion returned a valid string
//GW Testing for 0 is stupid but since the macros PASSED and FAILED that are used by the procedure are not in the header (duh!) we can't use them.
if (mfw_SIM2GsmStr( p_pEntry->name.len, p_pEntry->name.data, PHB_MAX_LEN, l_name ) == 0)
memcpy(p_pEntry->name.data, l_name, PHB_MAX_LEN);
// else
// p_pEntry->name.data[0] = ' ';
p_pEntry->name.data[0] = 0x00;
//else lets just leave the string alone - p_pEntry->name.len is zero.
// p_pEntry->name.data[0] = 'A' + p_pEntry->name.len;
// p_pEntry->name.data[1] = '?';
// p_pEntry->name.data[2] = '0'+status;
#else
bookGsm2Alpha( p_pEntry->name );
#endif
/* if we couldn't find any information, null out the return
structure, this will stop people who don't check the return
status from getting sensible information
*/
if( phb_list.result != MFW_ENTRY_EXIST )
memset(p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY));
/* return status depends on result of search
*/
return ( phb_list.result == MFW_ENTRY_EXIST );
}
/*******************************************************************************
$Function: bookSDNDestroy
$Description: destroys the Service Numbers window
$Returns: none.
$Arguments: window, handle of the window to be destroyed
*******************************************************************************/
void bookSDNDestroy( MfwHnd window )
{
T_MFW_WIN *win = ((T_MFW_HDR *)window)->data;
tBookStandard *data = (tBookStandard *)win->user;
TRACE_FUNCTION( "bookSDNDestroy" );
/* Guard against bad incoming data
*/
if ( ! data )
return;
/* Otherwise destroy the window using the appropriate method
*/
if ( data->phbk->root_win == window )
bookPhonebookDestroy( data->phbk->win );
else
{
/* deleting the window, so make sure we free the memory
*/
data->phbk->search_win = 0;
winDelete( data->win );
FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
}
}
/*******************************************************************************
End of File
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -