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

📄 mmibooksearchwindow.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    tBookStandard	*data		= (tBookStandard *) win_data->user;

	TRACE_FUNCTION ("bookSearchKbdLongCB()");
	
	/* deal with the clear event
	*/
	if ( ( e & KEY_CLEAR ) && ( e & KEY_LONG ) )
	{
		bookSearchDestroy( win );
		data->phbk->search_win = 0;
	}

	/* consume the event
	*/
	return MFW_EVENT_CONSUMED;
}







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

 $Function:    	bookSearchCreate

 $Description:	Create the search window
 
 $Returns:		handle of window or NULL if error

 $Arguments:	parent, handle of parent window
 
*******************************************************************************/

static T_MFW_HND bookSearchCreate( MfwHnd parent )
{
	T_MFW_WIN		*parent_win_data = ( (T_MFW_HDR *) parent )->data;
	T_phbk			*phbk = (T_phbk *)parent_win_data->user;
	T_MFW_WIN		*win_data;
	tBookStandard	*data;
	char debug[50];

	TRACE_FUNCTION ("bookSearchCreate()");

	/* allocate memory for our control block
	*/
	if ( ( data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) ) ) == NULL )
		return NULL;

	/* Create the window if we can
	*/
	if ( ( data->win = win_create( parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookSearchWindowCB ) ) == NULL )
	{
		FREE_MEMORY( (void *) data, sizeof( tBookStandard ) );
		return NULL;
	}

	/* Okay, we have created the control block and the window, so
	   we now need to configure the dialog and data pointers
	*/
    data->mmi_control.dialog	= (T_DIALOG_FUNC) bookSearchDialog;
    data->mmi_control.data		= data;
    win_data					= ((T_MFW_HDR *)data->win)->data;
 	win_data->user				= (void *) data;
	data->phbk					= phbk;
	data->parent_win			= parent;

	/* create keyboards and menus for our window
	*/
	data->kbd		= kbdCreate( data->win, KEY_ALL,            (MfwCb) bookSearchKbdCB );
    data->kbd_long	= kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookSearchKbdLongCB );
	data->menu		= mnuCreate( data->win, MmiBookMenuDetailsList(), 0, 0 );

	mnuLang (data->menu,0);

	/* 1945 MZ Initialise the edtBuf   */
	memset(data->edtBuf,'\0', STANDARD_EDITOR_SIZE );
	
	{

	/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
		AUI_edit_SetAttr(&data->editor_attr, BOOKSEARCH_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT,
			ED_MODE_ALPHA, ED_CURSOR_BAR, ATB_DCS_ASCII, (UBYTE *) data->edtBuf, MAX_SEARCH_CHAR);
		data->editor = ATB_edit_Create( &data->editor_attr, 0 );
		data->entry_data = AUI_entry_Create(data->win, data->editor, SEARCH_REDRAW);
		ATB_edit_Init(data->editor);
#else /* NEW_EDITOR */
	bookSetEditAttributes(BOOKSEARCH_EDITOR,  COLOUR_EDITOR_XX, 0, edtCurBar1, 0, 
		(char *) data->edtBuf, MAX_SEARCH_CHAR, &data->attr );
		data->edt = edtCreate( data->win, &data->attr, 0, 0 );
#endif /* NEW_EDITOR */
	}


	/* allow the window and menu to be created
	*/
	mnuUnhide(data->menu);
	winShow(data->win);

	/* And return the handle of the newly created window
	*/
    return data->win;
}

                                                                                                                                                                                                                                                   

/*******************************************************************************
                                                                              
                                Public Methods
                                                                              
*******************************************************************************/




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

 $Function:    	bookSearchStart

 $Description:	Starts the search window
 
 $Returns:		handle of newly created window, or NULL if error

 $Arguments:	parent, handle of parent window
 
*******************************************************************************/

T_MFW_HND bookSearchStart( MfwHnd parent )
{
	T_MFW_HND win;
    T_MFW_WIN		*win_data;
    tBookStandard   *data;
	MfwMnu			*mnu;
	tMmiPhbData		*Current;

	/* if the phone book is still loading, we can't do anything
	   with it, so return a NULL, after showing an information
	   dialog
	*/
	if ( phb_get_mode() == PHB_LOADING )
	{
		bookShowInformation( idle_get_window(),  TxtPleaseWait ,NULL, NULL );
		return NULL;
	}

	/* try to create the window
	*/
    if ( ( win = bookSearchCreate( parent ) ) == NULL )
		return NULL;

	/* having created the window, we now need to initialise it to
	   sensible data
	*/
	win_data	= ( (T_MFW_HDR *) win)->data;
    data		= (tBookStandard *) win_data->user;
	Current		= &data->phbk->current;

	/* establish the status of the phone book
	*/
	if ( ( Current->status.book != PHB_UPN ) && ( Current->status.book != PHB_SDN ) )
	    Current->status.book = bookActiveBook(READ);
	bookGetCurrentStatus( &Current->status );

	/* try to establish if we have information in the phone book
	*/
	Current->index = 1;
	Current->selectedName = 0;
	bookFindName( MAX_SEARCH_NAME, Current );

	if ( ! Current->index )
	{
		bookSearchDestroy( win );
		bookShowInformation( idle_get_window(), TxtEmptyList, NULL, NULL );
		return NULL;
	}

	/* clear the edit buffer prior to displaying the editor and menus
	*/



		memset( data->edtBuf, '\0', sizeof( data->edtBuf ) );
		/* SPR#1428 - SH - New Editor: don't need editActivate */
#ifndef NEW_EDITOR
		editActivate( data->edt, true );
#endif /* NEW_EDITOR */

	mnu = (MfwMnu *) mfwControl( data->menu );
	mnu->lCursor[mnu->level] = Current->selectedName;
	winShow(data->win);

	/* return the handle to the newly created window
	*/
    return win;
}




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

 $Function:    	bookSearchDestroy

 $Description:	Destroy the search window
 
 $Returns:		None

 $Arguments:	Window, handle of the window to be destroyed
 
*******************************************************************************/

void bookSearchDestroy( MfwHnd window )
{
	T_MFW_WIN		*win  = ((T_MFW_HDR *) window)->data;
	tBookStandard	*data = (tBookStandard *) win->user;

	TRACE_FUNCTION( "bookSearchDestroy()" );

	/* Only destroy if the data is valid
	*/
	if ( data )
	{
	/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
		/* Editor now not automatically destroyed by winDelete,
		 * so destroy it here. */
		if (data->entry_data)
		{
			AUI_entry_Destroy(data->entry_data);
			data->entry_data = 0;
		}
		if (data->editor)
		{
			ATB_edit_Destroy(data->editor);
			data->editor = 0;
		}
#endif /* NEW_EDITOR */

		/* If we're the root window we destroy using it's function
		*/
		if ( data->phbk->root_win == window )
		{
			bookPhonebookDestroy( data->phbk->win );
			return;
		}

		/* delete ourself
		*/
		data->phbk->search_win = 0;
		winDelete( data->win );
		FREE_MEMORY( (void *) data, sizeof( tBookStandard ) );
	}
}







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

 $Function:    	bookSearchName

 $Description:	locate a requested name in the phone book
 
 $Returns:		status of the findName routine

 $Arguments:	pattern, to be searched for
				number,  of elements to limit the search to
				current, pointer to a buffer to store the results
 
*******************************************************************************/

UBYTE bookSearchName (char *pattern,UBYTE number,tMmiPhbData *current)
{
    UBYTE ret;
    #ifdef NO_ASCIIZ
	T_MFW_PHB_TEXT l_name;
    char debug[50];
    #else
	UBYTE l_name[PHB_MAX_LEN];
	#endif
	UBYTE len;
	int	  i;

	TRACE_FUNCTION( "bookSearchName()" );

	/* if using UPN phone book, return status of findname
	*/
	if ( current->status.book == PHB_UPN )
		return ret = current->result = bookFindName( MAX_SEARCH_NAME, current );

	/* otherwise we need to be a little bit more clever with this
	*/
    memset( current->entry, 0, MAX_SEARCH_CALL_LIST * sizeof( T_MFW_PHB_ENTRY ) );
	bookGetCurrentStatus( &current->status );

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

	/* convert from GSM characters
	*/
	#ifdef NO_ASCIIZ
	
	memset( l_name.data, 0, PHB_MAX_LEN );
	mfw_Gsm2SIMStr( MFW_DCS_7bits, (UBYTE *) pattern, PHB_MAX_LEN, l_name.data, &l_name.len );
	#else
    memset( l_name, 0, PHB_MAX_LEN );
	mfw_Gsm2SIMStr( MFW_DCS_7bits, (UBYTE *) pattern, PHB_MAX_LEN, l_name, &len );
	#endif
	/* perform a search to locate a match with this criteria
	*/
    if ( strlen(pattern) != 0  )
    {
#ifdef WIN32
#ifndef NO_ASCIIZ
	sprintf(debug, "Search str: %s", l_name.data);
	TRACE_EVENT(debug);
        ret = phb_find_entries( current->status.book, &current->index, MFW_PHB_ALPHA, number, (UBYTE *) l_name, len, &current->list );
#endif
#else
//not WIN32

#ifdef NO_ASCIIZ
        ret = phb_find_entries( current->status.book, &current->index, MFW_PHB_ALPHA, number, &l_name, &current->list );
#else
        ret = phb_find_entries( current->status.book, &current->index, MFW_PHB_ALPHA, number, (char *) l_name, &current->list );
#endif //NO_ASCIIZ

#endif //WIN32
    }
    else
    {
        /* we don't have any name information, so start at the beginning
        */
    	current->index = 1;
	    current->selectedName = 0;
	    bookFindName( MAX_SEARCH_NAME, current );
    }
    
	/* check for match
	*/
	if ( ( current->list.num_entries < MAX_SEARCH_NAME )
		|| ( current->list.result == MFW_NO_ENTRY ) || ( ret == PHB_FAIL ) )
	{
		/* no, then try to find again
		*/
		ret = bookFindName( MAX_SEARCH_NAME, current );
	}
	else
	{
		for ( i = 0; i < number; i++ )
#ifdef NO_ASCIIZ
{
			/* convert from Sim to GSM and then copy to output buffer
			*/
/*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
			mfw_SIM2GsmStr( current->entry[i].name.len, current->entry[i].name.data, MAX_ALPHA_LEN, l_name.data );
			memcpy( current->entry[i].name.data, l_name.data, MAX_ALPHA_LEN );
			current->entry[i].name.len = l_name.len;
}
#else
/* convert from GSM to Alpha characters
			*/
			bookGsm2Alpha( (UBYTE *) current->entry[i].name );
#endif
	}

	/* return the status, and store it as part of current as well
	*/
	return current->result = ret;
}



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

⌨️ 快捷键说明

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