📄 mmibookutils.c
字号:
/*******************************************************************************
$Function: bookDefaultCallBack
$Description:
This is a simple call back function which is invoked when
a not implemented dialog is displayed. We don't want anyone
outside of this module using it so define it as static,
this will still be callable from the info dialogs as it
will use the reference we set up.
$Returns: zero, always
$Arguments: win, parent window
identifier, of the window
reason, for the window
*******************************************************************************/
static tBookStatus bookDefaultCallBack( tBookMfwHnd win, UBYTE identifier, UBYTE reason )
{
if ( win )
winShow( win );
return 0;
}
/*******************************************************************************
$Function: bookWindowData
$Description:
This routine is designed to be invoked from within a menu
handler or call back function and will return a pointer to
the window data associated with the current MFW element.
$Returns: pointer to the data area
$Arguments: none.
*******************************************************************************/
void *bookWindowData( void )
{
tBookMfwHnd WinPtr;
if ( ( WinPtr = bookCurrentWindow() ) == NULL )
return(void *) NULL;
return(void *)((tBookMfwHdr *) WinPtr)->data;
}
/*******************************************************************************
$Function: bookMenuSelectedNumber
$Description:
This will return the currently selected entry in the phone
book, when the routine is being called from a menu handler
$Returns: pointer to the selected number buffer
$Arguments: none.
*******************************************************************************/
char *bookMenuSelectedNumber( void )
{
tBookMfwHnd WinData;
/* Have we got a valid window ?
*/
if ( ( WinData = (tBookMfwHnd) bookWindowData() ) == NULL )
return NULL;
return NULL;
}
/*******************************************************************************
$Function: bookPhoneBookLoading
$Description: access routine for the local static menu area
Utility functions to determine if the phone book is
still in the loading state
$Returns: BOOK_FAILURE if loading, otherwise BOOK_SUCCESS
$Arguments: none.
*******************************************************************************/
tBookStatus bookPhoneBookLoading( void )
{
// rewrite by clrobert, invoke phb_get_mode() twice is not necessary
// from
/*
int temp;
char tempst[20];
TRACE_FUNCTION("bookPhoneBookLoading");
temp = phb_get_mode();
sprintf(tempst,"phb_get_mode %d",temp);
TRACE_EVENT(tempst);
return ( (phb_get_mode() == PHB_LOADING)||(phb_get_mode() == MFW_PHB_FAIL) ) ? BOOK_FAILURE : BOOK_SUCCESS;
*/
// to
int mode;
mode = phb_get_mode();
return(((mode == PHB_LOADING) || (mode == MFW_PHB_FAIL)) ? BOOK_FAILURE : BOOK_SUCCESS);
}
/*******************************************************************************
$Function: bookInfoDialog
$Description:
Utility functions just to throw a string onto the screen
primarily for debug purposes, the modal version will wait
for a user input before removing the message, the non-modal
will clear after three seconds
$Returns: One.
$Arguments: String1, String2, character strings to be displayed.
*******************************************************************************/
tBookStatus bookInfoDialog( char *String1, char *String2 )
{
tBookMfwHnd Win = bookCurrentWindow();
tBookDialogData Dialog;
// Initialise the dialog control block with default information
dialog_info_init(&Dialog);//gdy add
Dialog.KeyEvents = KEY_CLEAR|KEY_LEFT|KEY_RIGHT;
Dialog.TextId = 0;
Dialog.TextId2 = 0;
Dialog.TextString = String1;
Dialog.TextString2 = String2;
Dialog.LeftSoftKey = 0;
Dialog.RightSoftKey = 0;
Dialog.Time = 3000;
Dialog.Callback = (T_VOID_FUNC) bookDefaultCallBack;
Dialog.Identifier = 0;
// Show the dialog
info_dialog( Win, &Dialog );
return 1;
}
/*******************************************************************************
$Function: bookNotImplemented
$Description:
This will present an information dialog indicating the current
feature is still under development. This routine will use the
current MFW element to detect the handle of the parent window
if the incoming window handle is NULL.
$Returns: One
$Arguments: Parent, window, can be NULL
*******************************************************************************/
tBookStatus bookNotImplemented( tBookMfwHnd Parent )
{
tBookMfwHnd Win = ( Parent ) ? Parent : bookCurrentWindow();
tBookDialogData Dialog;
/* Initialise the dialog control block with default information
*/
dialog_info_init(&Dialog);//gdy add
Dialog.KeyEvents = KEY_CLEAR;
Dialog.TextId = 0;
Dialog.TextId2 = 0;
Dialog.TextString = MmiRsrcGetText( TxtNotImplemented );
Dialog.TextString2 = NULL;
Dialog.LeftSoftKey = 0;
Dialog.RightSoftKey = 0;
Dialog.Time = 3000;
Dialog.Callback = (T_VOID_FUNC) bookDefaultCallBack;
Dialog.Identifier = 0;
/* Show the dialog
*/
info_dialog( Win, &Dialog );
return 1;
}
/* Menu handler to invoke the routine above
*/
tBookStatus bookMenuNotImplemented( tBookMfwMenu *Menu, tBookMfwMenuItem *Item )
{
return bookNotImplemented( NULL );
}
/*******************************************************************************
$Function: set_edt_attr
$Description:
Sets up the edit attribute structure with the provided parameters
$Returns: None
$Arguments: winPx, winPy, winSx, winSy, positioning information
fgColor, colour for foreground
font, mode, controls, pretty much what they say
*text, initial text to be edited
size, of the text (in bytes)
attr, the block to be set up with the other parameters
*******************************************************************************/
void bookSetEditAttributes(
U16 winPx, U16 winPy, U16 winSx, U16 winSy,
U8 fgColor, U8 font, U8 mode, U8 *controls,
char *text, U16 size,
MfwEdtAttr* attr)
{
/* Populate the structure with the parameters
*/
attr->win.px = winPx;
attr->win.py = winPy;
attr->win.sx = winSx;
attr->win.sy = winSy;
attr->fgColor = fgColor;
attr->font = font;
attr->mode = mode;
attr->controls = controls;
attr->text = text;
attr->size = size;
}
/*******************************************************************************
Public memory allocation overrides
*******************************************************************************/
/* Memory allocation and freeing functions
These routines provided guarded access to the malloc and free
routines used in the MMI application. The wrapper functions
provided here allow debugging and tracking information to be
easily derived, it also allows the memory allocation and
deallocation to be changed if required.
Note that the free routine takes a pointer to the pointer
to the memory being freed. This allows the actual pointer
value to be set to NULL as part of the free operation, this
helps protect against reusing the pointer after the memory
has been deallocated.
Sample usage:
tStructure *ptr;
if ( ( ptr = (tStructure *) bookMemAlloc( sizeof(tStructure) ) ) != NULL )
{
// use the allocated memory
//
...
// free the memory
//
bookMemFree( &ptr );
}
*/
/*******************************************************************************
$Function: bookMemAlloc
$Description: memory allocator
$Returns: pointer to allocated memory, NULL if failure
$Arguments: Numbytes, number of contiguous bytes to allocate
*******************************************************************************/
void *bookMemAlloc( long int NumBytes )
{
return sysAlloc( (unsigned short) NumBytes );
}
/*******************************************************************************
$Function: bookMemFree
$Description: frees previously allocated memory
$Returns: none. (But *Pointer will be set to NULL)
$Arguments: **Pointer, pointer to pointer to allocated memory
*******************************************************************************/
void bookMemFree( void **Pointer )
{
if ( ! Pointer )
return;
if ( *Pointer )
{
sysFree( *Pointer );
*Pointer = NULL;
}
}
/*******************************************************************************
Name Handling Functions
*******************************************************************************/
/*******************************************************************************
$Function: bookGetCurrentStatus
$Description: Determines the current status of the phone book
$Returns: status byte
$Arguments: currentStatus, pointer to structure to be populated with
status information
*******************************************************************************/
UBYTE bookGetCurrentStatus( T_MFW_PHB_STATUS *currentStatus )
{
UBYTE temp;
TRACE_FUNCTION( "bookGetCurrentStatus()" );
//currentStatus->book=PHB_ADN;
temp=phb_get_status( currentStatus );
if ( temp!=MFW_PHB_FAIL )
{
char temp[255];
sprintf(temp,"book %d max_entries %d used_entries %d aval_entries %d",
currentStatus->book,currentStatus->max_entries,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -