⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmibookutils.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 3 页
字号:
 $Arguments:	none.
 
*******************************************************************************/

tBookStatus bookPhoneBookLoading( void )
{
	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;
}









/*******************************************************************************

 $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
	*/
	dlg_initDisplayData_TextStr( &Dialog, TxtNull, TxtNull, String1, String2, COLOUR_STATUS);
	dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)bookDefaultCallBack, THREE_SECS, KEY_CLEAR);

	/* 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
	*/
	dlg_initDisplayData_TextStr( &Dialog, TxtNull, TxtNull, MmiRsrcGetText( TxtNotImplemented ), NULL, COLOUR_STATUS);
	dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)bookDefaultCallBack, THREE_SECS, KEY_CLEAR);

	/* 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 );
}






/* SPR#1428 - SH - New Editor changes: No longer required */
#ifndef NEW_EDITOR

/*******************************************************************************

 $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
 
 GW - Changed colour from 8 bits (foreground) to 2x32bits fgd and bgd
For the colour display we pass a 32 bit word that defines the size and position of the editor.
This can be either a specific size or a more generic ('middle of the screen'/full width of display)
*******************************************************************************/
void bookSetEditAttributes(
    int  zone_id,
	U32  colIndex,
	U8  font,  U8  mode,  U8  *controls,
	char *text,   U16 size,
	MfwEdtAttr*   attr)
{
	/* Populate the structure with the parameters
	*/
	calculateWindow(attr, zone_id );
	attr->edtCol = colIndex;
	attr->font = font;
	attr->mode = mode;
	attr->controls = controls;
	attr->text = text;
	attr->size = size;
}
#endif /* NEW_EDITOR */










/*******************************************************************************
                                                                              
                             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()" );


    temp = phb_get_status( currentStatus );
    {
		char temp[255];
		sprintf(temp,"book %d max_entries %d used_entries %d aval_entries %d",
				currentStatus->book,currentStatus->max_entries,
				currentStatus->used_entries,
				currentStatus->avail_entries);
		TRACE_EVENT(temp);
    }
    return temp;
}








/*******************************************************************************

 $Function:    	bookFindNames

 $Description:	Fine name in phone book
 
 $Returns:		status of search

 $Arguments:	number, number of entries to search, current,
                pointer to structure containing search context
 
*******************************************************************************/

UBYTE bookFindName( UBYTE number, tMmiPhbData *current )
{
    UBYTE   ret;
	int     index, Count = 0;
	UBYTE   l_name[MAX_ALPHA_LEN];/*MC SPR 1257, name strings should use MAX_ALPHA_LEN*/
    UBYTE   book_type, index_type;
    int i;
    char debug[22];
	
	TRACE_FUNCTION( "bookFindName()" );

    /* Firstly, check for an empty book
    */
	bookGetCurrentStatus( &current->status );
    if ( current->status.used_entries < 1 )
    {
        current->index = 0;
        return MFW_PHB_OK;
    }

    /* Okay, we have some entries to search, so initialise the current
       entry buffer to empty
    */
	memset( current->entry, 0, MAX_SEARCH_CALL_LIST * sizeof( T_MFW_PHB_ENTRY ) );

   
   
    current->list.entry         = current->entry;
    current->list.num_entries   = number;

    /* Sort out how we index the information
    */
    book_type  = current->status.book;
    index_type = MFW_PHB_INDEX;
    if ( ( book_type == bookActiveBook(WRITE) ) || ( book_type == PHB_SDN ) )
        index_type = MFW_PHB_ALPHA;

    /* Sort out the type of search we are performing
    */
	if ((book_type == PHB_LDN) || (book_type == PHB_LRN)|| (book_type == PHB_LMN))
        index_type = MFW_PHB_INDEX;
    else
    {
	    if ( current->KindOfSearch == SEARCH_BY_NAME )
    	    index_type = MFW_PHB_ALPHA;
	    else if ( current->KindOfSearch == SEARCH_BY_NUMBER )
    	    index_type = MFW_PHB_NUMBER;
	    else if ( current->KindOfSearch == SEARCH_BY_LOCATION )
    	    index_type = MFW_PHB_INDEX;
    }

   
    /* read the appropriate entries from the phone book
    */
	{
		char temp[255];
		sprintf(temp,"book %d index %d indextype %d number %d",
					book_type,current->index,index_type,number);
		TRACE_EVENT(temp);		
	}	
 
	if (book_type == PHB_ADN)	/*Quick test */
		{
		TRACE_EVENT("book_type == PHB_ADN");
		ret = phb_read_entries( PHB_ADN_FDN, current->index, index_type, number, &current->list );
		}
	else
		{
		TRACE_EVENT("book_type == OTHER");
		ret = phb_read_entries( book_type, current->index, index_type, number, &current->list );
		}
	
    /* Populate the output structures
    */
    if (current->list.result == MFW_NO_ENTRY)
        current->index = 0;

	for ( index = 0; index < number; index++ )
#ifdef NO_ASCIIZ
	
#ifdef EASY_TEXT_ENABLED
{/*MC , SPR 1242 merged in this section from b-sample build*/
	
        /* GSM character sets
        */
        TRACE_EVENT( (char*)current->entry[index].name.data);
        TRACE_EVENT("Convert from SIM to UCS2");

    	TRACE_EVENT_P1("length of name string: %d", current->entry[index].name.len);
    	/*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
		if (current->entry[index].name.data[0] == 0x80 )
		{	for (i=1; i<MAX_ALPHA_LEN; i+=1)
			{
				l_name[i+1] = current->entry[index].name.data[i];
			}
       	 	l_name[0] =	current->entry[index].name.data[0]; 
       		l_name[1] = MAX_ALPHA_LEN;
		
			memcpy( current->entry[index].name.data, (char*)l_name, MAX_ALPHA_LEN );
			/*MC, we'll just use the length provided by the MFW*/
			if (current->entry[index].name.len%2 == 1)/*if length of string odd*/
   		 		current->entry[index].name.len++;/* INCREASE LENGTH BY 1*/

			/*make sure all chars after length are 0*/
			for (i=current->entry[index].name.len; i<MAX_ALPHA_LEN; i++)
			{	current->entry[index].name.data[i] = 0; }
			
			for (i=0; i < MAX_ALPHA_LEN;i++)
			{
				if ( current->entry[index].name.data[i]== 0 && current->entry[index].name.data[i+1] != 0)
					debug[i] = '0';
				else
					debug[i] = (char)current->entry[index].name.data[i];
	        }
		
			
   		 TRACE_EVENT("Decoded entry");
    	TRACE_EVENT(debug);
			
		}

		else

		{	bookGsm2Alpha( (UBYTE *) current->entry[index].name.data );

			
		}
	}
			
#endif
/*MC end*/
#else
	{	TRACE_EVENT_P1("length of name string: %d", current->entry[index].name.len);
			bookGsm2Alpha( (UBYTE *) current->entry[index].name );
	}
#endif

    /* Needed to make international calls from the phonebook
    */
	for ( index = 0; index < number; index++ )
	{		
		if ( current->entry[index].ton )
		{
			TRACE_EVENT("Pre-pending +");
			/* Pre-pend a '+' to the phone number string because
               this number is international
            */
			memmove( (char *) &current->entry[ index ].number[ 1 ],
		        (char *) current->entry[ index ].number, PHB_MAX_LEN - 1 );

			/* Now pre-pend the '+'
            */
			current->entry[index].number[0] = '+';
		}
	}
TRACE_EVENT("Book searched");	
    return current->result = ret;
}









/*******************************************************************************

 $Function:    	bookEvent

 $Description:	Event handler for a phone book event
 
 $Returns:		MFW_EVENT_CONSUMED if recognised message, otherwise
                MFW_EVENT_PASSED

 $Arguments:	e, event, para, general parameter giving context of call
 
*******************************************************************************/

int bookEvent( MfwEvt e, void *para )
{
	T_MFW_PHB_STATUS *status;

    TRACE_FUNCTION( "bookEvent" );

    /* deal with the incoming event
    */
	switch( e )
    {
        case E_PHB_UPN_LIST :
        {
            upnList = (T_MFW_UPN_LIST *)para;
            /* tbd */
        }
        break;

		case E_PHB_STATUS:
        {
			status = (T_MFW_PHB_STATUS *)para;
			if ( ( status->book == PHB_FDN ) || ( status->book == PHB_ADN ) )
			{
				if ( pinsSetIsFocussed() == FOCUSSED_PINS )
					backpinFDNactdeact();
			}
        }
        break;

		case E_PHB_ERROR:
        {
            /* tbd */
        }
        break;
        
        /* SPR#1112 - SH - New events to indicate status of phonebook */

        case E_PHB_READY:
        {
            TRACE_EVENT("E_PHB_READY");
#ifdef INT_PHONEBOOK
			/* SPR#1112 - SH - If we're copying or moving a list,
			 * the current operation has been successful - keep copying. */	 
            if (ipbCopyIndex)
            {
            	TRACE_EVENT("Copying/moving in progress.");
            	bookCopyMultiple(ipbWin, ipbMove, 0);
            }
#endif
        }
        break;

        case E_PHB_BUSY:
        {
            TRACE_EVENT("E_PHB_BUSY");
        }
        break;
        
        /* end SPR#1112 */
        
        default:
        {
            /* indicate we haven't dealt with event
            */
			return MFW_EVENT_PASSED;
        }
        break;
    }

    /* got to here, we have dealt with the event
    */
    return MFW_EVENT_CONSUMED;
}





/*******************************************************************************

 $Function:     bookCopyPhbName

 $Description:  Copiers a phonebook name structure (for NO_ASCII set or cleared)

 $Returns:    None

 $Arguments:	destEntry - destination phonebook entry structure
 				srcEntry - source phonebook entry structure
				maxLen - max number oc chars to be copied 

*******************************************************************************/
//GW Created function to copy name (and length when required).
void bookCopyPhbName( T_MFW_PHB_ENTRY* destEntry, T_MFW_PHB_ENTRY* srcEntry, int maxLen )
{
	int len; //length of string to be copied
	if ((destEntry==NULL) || (srcEntry==NULL))
		return;
#ifdef NO_ASCIIZ
	//Ensure we do not copy more than the PHB array can hold.
	if ((maxLen <  PHB_MAX_LEN) && (maxLen >0))
		len = maxLen;
	else
		len = PHB_MAX_LEN;

#else
/*MC SPR1319, name string is only up to MAX_ALPHA_LEN in length*/
	//Ensure we do not copy more than the PHB array can hold.
	if ((maxLen < MAX_ALPHA_LEN) && (maxLen >0))
		len = maxLen;
	else
		len = MAX_ALPHA_LEN;
#endif
#ifdef NO_ASCIIZ	
	memset (destEntry->name.data, 0, PHB_MAX_LEN);
	memcpy( destEntry->name.data, srcEntry->name.data, len);
	if (srcEntry->name.len < len)
		destEntry->name.len = srcEntry->name.len;
	else
	{	//we have truncated the name - add termination (if possible)
		destEntry->name.len = len;
		if (len < PHB_MAX_LEN)
		{	// there is space in array for termination - add it.
			destEntry->name.data[len] = 0x00;
			
		}
	}
#else

	memcpy( destEntry->name, srcEntry->name, maxLen);
#endif		
}



/*******************************************************************************
                                                                              
                                End of File
                                                                              
*******************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -