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

📄 mmibookservices.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    data->phbk->current.status.book = bookActiveBook(READ);

    /* retrieve he status of the book, and create a string for output
       based on the status
    */
  Buffer == '\0';
    if ( bookGetCurrentStatus( &data->phbk->current.status ) == MFW_PHB_OK )
  {
  /* SPR#1112 - Internal phonebook - show the current selected phonebook*/
#ifdef INT_PHONEBOOK
	if (bookGetBookAvailable() && bookGetBookSelected())
		TxtToShow = TxtPhone;
	else
		TxtToShow = TxtSIM;
#else
    TxtToShow = TxtUsed;
#endif
        sprintf( Buffer, "%d/%d",
                data->phbk->current.status.used_entries,
                data->phbk->current.status.max_entries );
  }
    else
    TxtToShow = TxtReadError;


	{
	    T_DISPLAY_DATA display_info;

		dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtToShow, TxtNull , COLOUR_STATUS);
		dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR );
	    display_info.TextString2  = Buffer;

	    /* Call Info Screen
	    */
	    info_dialog( win, &display_info );
	}

}








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

 $Function:     bookDeleteEntry

 $Description:  Delete the current entry from the phone book.
                This routine doesn't actually perform the deletion, it
                sets up a confirmation dialog, where the call back function
                is used to perform the deletion (Refer above)

 $Returns:    None

 $Arguments:  None

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

void bookDeleteEntry( T_MFW_HND Window)
{
  tBookDialogData Dialog;

    /* Initialise the dialog control block with default information
  */
	dlg_initDisplayData_TextId( &Dialog, TxtSoftOK, TxtCancel, TxtPressOk, TxtDelete, COLOUR_STATUS);
	dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)bookDeleteEntryCB, TEN_SECS, KEY_CLEAR | KEY_LEFT | KEY_RIGHT );

  /* Show the dialog
  */
  	info_dialog( Window, &Dialog );
}

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

 $Function:    	bookActivateFDN

 $Description:	information screen to tell user to activate FDN
 
 $Returns:		None

 $Arguments:	None
 
*******************************************************************************/

void bookActivateFDN( T_MFW_HND window )
{
	tBookDialogData Dialog;

    /* Initialise the dialog control block with default information
	*/
	dlg_initDisplayData_TextId( &Dialog, TxtNull, TxtNull, TxtPlease, TxtActivateFDN, COLOUR_STATUS);
	dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)NULL, FOUR_SECS, KEY_CLEAR | KEY_LEFT | KEY_RIGHT );

	/* Show the dialog
	*/
	info_dialog( window, &Dialog );
}

/* SPR#1428 - SH - New Editor: moved the following two functions
 * from MmiBookInputWindow.c, which is now a redundant file */
#ifdef NEW_EDITOR

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

 $Function:		bookInputStartNumberEditor

 $Description:	Start the input handler using default properties
 
 $Returns:		Handle of newly created window, or NULL if failure

 $Arguments:	parent, parent window handle, buffer, input buffer
 
*******************************************************************************/

MfwHnd bookInputStartNumberEditor( MfwHnd parent, void *buffer )
{
	T_AUI_EDITOR_DATA editor_data;

	TRACE_FUNCTION ("bookInputStartNumberEditor()");

	AUI_edit_SetDefault(&editor_data);
	AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
	AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)bookAddNumberCB);
	AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterNumber, NULL);
	AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, NUMBER_LENGTH);
	AUI_edit_SetMode(&editor_data, 0, ED_CURSOR_UNDERLINE);

	return AUI_edit_Start(parent, &editor_data);
}



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

 $Function:		bookInputStartNameEditor

 $Description:	Start the input handler using default properties
 
 $Returns:		Handle of newly created window, or NULL if failure

 $Arguments:	parent, parent window handle, buffer, input buffer
 
*******************************************************************************/

MfwHnd bookInputStartNameEditor( MfwHnd parent, void *buffer )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) parent )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;
	T_AUI_EDITOR_DATA editor_data;

	TRACE_FUNCTION ("bookInputStartNameEditor()");

    /* Set up the default parameters for the input window */

#if defined(CHINESE_MMI) && defined(EASY_TEXT_ENABLED)
	/*MC, the chinese editor MUST have a unicode string as input*/
	/*MC , SPR 1242 merged in from b-sample build*/
	if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
	{
		T_CHINESE_DATA chinese_data;
		chinese_data.TextString = (char*) Phbk->edt_buf_name;
		if (chinese_data.TextString[0]== 0)//if, empty string
		{
			chinese_data.TextString[0] = 0x80;//give string Unicode tag
			chinese_data.TextString[1] = 0x7F;
		}
		else
		{	
			if (chinese_data.TextString[0]!= 0x80)/*If ASCII string*/
			{
			
			/*SPR 1752, if ASCII string, use a latin editor*/
				AUI_edit_SetDefault(&editor_data);
				AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
				AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)bookAddNameCB);
				AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterName, NULL);
				AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, MAX_ALPHA_LEN);
				AUI_edit_SetMode(&editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR);

				return AUI_edit_Start(parent, &editor_data);
			}
		}
		/*MC end*/
		chinese_data.Callback = (T_AUI_EDIT_CB)bookAddNameCB;
		chinese_data.Identifier = INPUT_LEFT ;
		chinese_data.LeftSoftKey = TxtSave;
		chinese_data.DestroyEditor = TRUE;
		chinese_data.EditorSize = (USHORT)((MAX_ALPHA_LEN-4)/2);//i.e.8
		return chinese_input(parent, &chinese_data);
	}
	else
#endif /* CHINESE_MMI && EASY_TEXT_ENABLED */
	{
		AUI_edit_SetDefault(&editor_data);
		AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
		AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)bookAddNameCB);
		AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterName, NULL);
/*SPR 1752*/
#ifdef NO_ASCIIZ
		if (Phbk->edt_buf_name[0] ==0x80)
			AUI_edit_SetBuffer(&editor_data, ATB_DCS_UNICODE, &Phbk->edt_buf_name[2], MAX_ALPHA_LEN/2 -2);
		else
#endif
			AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, MAX_ALPHA_LEN);
		AUI_edit_SetMode(&editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR);

		return AUI_edit_Start(parent, &editor_data);
	}
}



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

 $Function:		bookInputDestroy

 $Description:	Destroy Input Window
 
 $Returns:		None

 $Arguments:	Handle of window to be destroyed
 
*******************************************************************************/

void bookInputDestroy( MfwHnd window )
{
	TRACE_FUNCTION ("bookInputDestroy()");
	/*MC SPR 1752, send destroy event to window*/
	SEND_EVENT( window, E_ED_DESTROY, 0, 0 );

}

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

 $Function:     bookAddNameCB

 $Description:  default call back for name entry

 $Returns:    None

 $Arguments:  win, handle of parent window, reason, for invocation

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

void bookAddNameCB( T_MFW_HND win, USHORT Identifier, SHORT reason )
{
#define TESTING_ADD_NAME

    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;
#ifdef TESTING_ADD_NAME
        	int i;
        	char debug[22];
#endif
	TRACE_FUNCTION("bookAddNameCB");

	switch (reason)
    {
		case INFO_KCD_LEFT:
        {	
            /* Construct a new entry to be written to the phone book
            */

			/*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
			if (Phbk->edt_buf_name[0] == 0x80 )//MC, if unicode
			{	//MC, if empty string, remove 0x80 at beginning
				if (Phbk->edt_buf_name[2]==0x00 &&  Phbk->edt_buf_name[3] == 0x00)
					memset(Phbk->edt_buf_name, 0, MAX_ALPHA_LEN);
			}
#ifdef TESTING_ADD_NAME
	            for (i=0; i < MAX_ALPHA_LEN;i++)
				{
					if ( Phbk->edt_buf_name[i]== 0 && Phbk->edt_buf_name[i+1] != 0)
						debug[i] = '0';
					else
						debug[i] = (char)Phbk->edt_buf_name[i];
	            }
	            
				TRACE_EVENT(debug);
#endif
            /* Store in the current phone book
            */
            if ( Phbk->UpdateAction == CREATE_ENTRY )
				storeInFile( Phbk );
            else if ( Phbk->UpdateAction == MODIFY_EXISTING )
				changeInFile( Phbk );
				
            bookShowInformation( win, MmiBookCurrentText(), NULL,NULL );

            /* And shut down, clearing the number and name windows as we go
            */
            if ( Phbk->input_number_win )
            {    
 				AUI_edit_Destroy(Phbk->input_number_win);
    		    Phbk->input_number_win = 0;
    		}
			/*SPR 1752, send destroy event rather than calling destroy function*/
			SEND_EVENT( Phbk->input_name_win, E_ED_DESTROY, 0, 0 );
    		Phbk->input_name_win = 0;
    		

			/*MC-- get rid of search window(and options menu), if just changed a chinese entry 
			(prevent showing scrambled entry)*/
			if ( Phbk->UpdateAction == MODIFY_EXISTING && Mmi_getCurrentLanguage()==CHINESE_LANGUAGE)
			{
				bookMenuDestroy(Phbk->menu_options_win);
				Phbk->menu_options_win=0;
				bookSearchDestroy( Phbk->search_win);
				Phbk->search_win=0;
			}
        }
		break;

        case INFO_KCD_RIGHT:
		case INFO_KCD_HUP:
            /* Both right and HUP can do the same task here
            */
            /*SPR 1752, send destroy event rather than calling destroy function*/
            SEND_EVENT( Phbk->input_name_win, E_ED_DESTROY, 0, 0 );
            Phbk->input_name_win = 0;
		    break;

        default:
        {
            /* otherwise no action to be performed
            */
        break;
        }
  }
  if (Phbk->root_win==Phbk->win)    /*To destroy the phonebook when entering from idle*/
    bookPhonebookDestroy(Phbk->win);
}


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

 $Function:     bookAddNumberCB

 $Description:  Default call back for number entry

 $Returns:    None

 $Arguments:  win, parent window, reason, for call back

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

void bookAddNumberCB( T_MFW_HND win, USHORT Identifier, SHORT reason )
{
    T_MFW_WIN		*win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard	*data       = (tBookStandard *) win_data->user;

	switch ( reason )
    {
        case INFO_KCD_LEFT:
			data->phbk->input_name_win = bookInputStartNameEditor( data->win, data->phbk->edt_buf_name );
	    	break;

		case INFO_KCD_RIGHT:
	    case INFO_KCD_HUP:
            /* Both right and HUP can do the same task here
            */
            AUI_edit_Destroy( data->phbk->input_number_win );
            data->phbk->input_number_win = 0;
	    	break;

		default:
            /* otherwise no action to be performed
            */
			break;
	}
}


#else /* NEW EDITOR */


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

 $Function:     bookAddNameCB

 $Description:  default call back for name entry

 $Returns:    None

 $Arguments:  win, handle of parent window, reason, for invocation

*******************************************************************************/
#define TESTING_ADD_NAME
void bookAddNameCB( T_MFW_HND win, UBYTE reason )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;
  TRACE_FUNCTION("bookAddNameCB");
  switch (reason)
    {
		case INPUT_LEFT:
        {	
#ifdef TESTING_ADD_NAME
        	int i;
        	char debug[22];
#endif
            /* Construct a new entry to be written to the phone book
            */
#ifdef NO_ASCIIZ
/*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
			if (Phbk->edt_buf_name[0] == 0x80 )//MC, if unicode
			{	//MC, if empty string, remove 0x80 at beginning
				if (Phbk->edt_buf_name[2]==0x00 &&  Phbk->edt_buf_name[3] == 0x00)
					memset(Phbk->edt_buf_name, 0, MAX_ALPHA_LEN);
#ifdef TESTING_ADD_NAME
	            for (i=0; i < MAX_ALPHA_LEN;i++)
				{
					if ( Phbk->edt_buf_name[i]== 0 && Phbk->edt_buf_name[i+1] != 0)
						debug[i] = '0';
					else
						debug[i] = (char)Phbk->edt_buf_name[i];
	            }
				TRACE_EVENT(debug);
#endif
			}
#endif

            /* Store in the current phone book
            */
            if ( Phbk->UpdateAction == CREATE_ENTRY )
          storeInFile( Phbk );
            else if ( Phbk->UpdateAction == MODIFY_EXISTING )
          changeInFile( Phbk );

				
            bookShowInformation( win, MmiBookCurrentText(), NULL,NULL );

            /* And shut down, clearing the number and name windows as we go
            */
            if ( Phbk->input_number_win )
            {
		        SEND_EVENT( Phbk->input_number_win, INPUT_DESTROY, 0, 0 );
    		    Phbk->input_number_win = 0;
    		}


			SEND_EVENT( Phbk->input_name_win, INPUT_DESTROY, 0, 0 );
			Phbk->input_name_win = 0;

#ifdef NO_ASCIIZ
/*MC-- get rid of search window(and options menu), if just changed a chinese entry 
(prevent showing scrambled entry)*/
			if ( Phbk->UpdateAction == MODIFY_EXISTING &&Mmi_getCurrentLanguage()==CHINESE_LANGUAGE)
			{	bookMenuDestroy(Phbk->menu_options_win);
				Phbk->menu_options_win=0;
				bookSearchDestroy( Phbk->search_win);
				Phbk->search_win=0;
				
			}
#endif
			

        }
		break;

        case INPUT_RIGHT:
		case INPUT_CLEAR:
        {
            /* Both right and clear can do the same task here
            */
			SEND_EVENT( Phbk->input_name_win, INPUT_DESTROY, 0, 0 );
            Phbk->input_name_win = 0;
        }
    break;

        default:
        {
            /* otherwise no action to be performed
            */
        break;
        }
  }
  if (Phbk->root_win==Phbk->win)    /*To destroy the phonebook when entering from idle*/
    bookPhonebookDestroy(Phbk->win);
}


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

 $Function:     bookAddNumberCB

 $Description:  Default call back for number entry

 $Returns:    None

 $Arguments:  win, parent window, reason, for call back

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

void bookAddNumberCB( T_MFW_HND win, UBYTE reason )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;

  switch ( reason )
    {
        case INPUT_LEFT:
        {
      data->phbk->input_name_win =
                bookInputStartNameEditor( data->win, data->phbk->edt_buf_name );
        }
    break;

        case INPUT_RIGHT:
    case INPUT_CLEAR:
        {
            /* Both right and clear can do the same task here
            */
            SEND_EVENT( data->phbk->input_number_win, INPUT_DESTROY, 0, 0 );
            data->phbk->input_number_win = 0;
        }
    break;

        default:
        {
            /* otherwise no action to be performed
            */
        break;
        }
  }
}

#endif /* NEW_EDITOR */


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

                                End of File

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

⌨️ 快捷键说明

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