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

📄 mmibookservices.c

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

          CONDAT (UK)

********************************************************************************

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.

********************************************************************************

 $Project name: Basic MMI
 $Project code: BMI (6349)
 $Module:   PhoneBook
 $File:       MmiBookServices.c
 $Revision:   1.0

 $Author:   Condat(UK)
 $Date:       25/10/00

********************************************************************************

 Description:

    This provides the implementation of service functions for use with the
  phone book module

********************************************************************************
 $History: MmiBookServices.c

  25/10/00      Original Condat(UK) BMI version.

 $End

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




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

                                Include Files

*******************************************************************************/
#define ENTITY_MFW

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else

#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif

#include "mfw_sys.h"

#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_lng.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_tim.h"

#include "mfw_sim.h"
#include "mfw_cm.h"
#include "mfw_nm.h"
#include "mfw_phb.h"
#include "mfw_mme.h"
#include "mfw_sat.h"
#include "mfw_sms.h"
#include "mfw_cnvt.h"	//GW Added for 'mfw_SIM2GsmStr'

#include "dspl.h"

#include "ksd.h"
#include "psa.h"

#include "MmiMain.h"
#include "MmiBookController.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"



#include "MmiMenu.h"
#include "MmiCall.h"
#include "MmiIcons.h"
#include "MmiIdle.h"

#include "MmiSoftKeys.h"
#include "MmiSounds.h"
#include "MmiIdle.h"
#include "MmiNetwork.h"
#include "MmiSat_i.h"
#include "MmiAoc.h"

#include "gdi.h"
#include "audio.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "mfw_ffs.h"
#include "MmiTimers.h"

#include "MmiBookShared.h"
#include "MmiBookController.h"
#include "mmiDialogs.h"
#include "mmiColours.h"

/* SPR#1428 - SH - New Editor: Include needed for MmiBookInputWindow functions, see below*/
#ifdef NEW_EDITOR
#ifdef EASY_TEXT_ENABLED
#include "MmiChineseInput.h"
#endif
#endif

#define TRACE_PB_DEBUG


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

                                Private data elements

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

static MfwHnd phb;
/* SPR#1112 - SH - Internal phonebook flags */
#ifdef INT_PHONEBOOK
BOOL ipbBookSelected = FALSE;
BOOL ipbBookAvailable = FALSE;
#endif



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

                                Private methods

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




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

 $Function:     bookDeleteEntryCB

 $Description:  Delete the current entry from the phone book.
                This routine is invoked as a callback from the confirmation
                dialog and will perform the delete if the OK key has been
                selected.

 $Returns:    None

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

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

static void bookDeleteEntryCB( T_MFW_HND win, USHORT id, UBYTE reason )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;

	TRACE_EVENT_P1("bookDeleteEntryCB index %d", Phbk->current.entry[Phbk->current.selectedName].index);
	
    /* This call back is invoked from the delete entry dialog confirmation
       screen, and will only respond to the left key (OK) being selected.
    */
    switch ( reason )
    {
    case INFO_KCD_LEFT:
        {
      if  (( Phbk->current.status.book == PHB_UPN) ||
      			(Phbk->current.status.book == PHB_FDN ))
            deleteFromFile( Phbk, Phbk->current.status.book );
      else
        deleteFromFile( Phbk, bookActiveBook(WRITE) );

            /* retrieve he status of the book, and create a string for output
               based on the status
            */
          bookShowInformation( Phbk->win, MmiBookCurrentText(), NULL,NULL );
          SEND_EVENT(win, E_MNU_ESCAPE, NULL, NULL);
        }
    break;

        default:
        {
            /* No action required
            */
        }
        break;
    }
}








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

                                Public Methods

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








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

 $Function:     bookInitialise

 $Description:  Initialise the phone book application

 $Returns:    none, side effect is to set up the static phone
                book element

 $Arguments:  none

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

void bookInitialise( MfwHnd parent )
{
  TRACE_FUNCTION( "bookInitialise()" );
  
  /* SPR#1112 - SH - Added E_PHB_READY and E_PHB_BUSY */
  phb  = phb_create( 0, (MfwEvt) (E_PHB_UPN_LIST | E_PHB_ERROR | E_PHB_STATUS
  	| E_PHB_READY | E_PHB_BUSY), (MfwCb) bookEvent );

}

/* SPR#1112 - Initialise internal phonebook */
#ifdef INT_PHONEBOOK

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

 $Function:     bookInitInternal

 $Description:  Initialise the internal phone book application

 $Returns:    none, side effect is to set up the static phone
                book element

 $Arguments:  none

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

void bookInitInternal( void )
{
	UBYTE intphonebook;
	T_MFW ret;
	
	ret = GI_pb_GetPhonebook(&intphonebook);

	if (ret==MFW_PHB_OK)
	{
		bookSetBookAvailable(TRUE);
		GI_pb_Initialise();
		if (intphonebook)
		{
			bookSetBookSelected(TRUE);
		}
		else
			bookSetBookSelected(FALSE);
	}
	else
		bookSetBookAvailable(FALSE);
	
	return;
}


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

 $Function:		bookGetBookSelected

 $Description:	Is the internal phonebook selected?

 $Returns:		TRUE if internal phonebook is selected, FALSE otherwise

 $Arguments:	none

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

BOOL bookGetBookSelected()
{
	return ipbBookSelected;
}


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

 $Function:		bookSetBookSelected

 $Description:	Select or deselect the internal phonebook

 $Returns:		None.

 $Arguments:	TRUE to select internal phonebook, FALSE to select SIM phonebook

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

void bookSetBookSelected(UBYTE bookSelected)
{
	ipbBookSelected = bookSelected;

	return;
}


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

 $Function:		bookGetBookAvailable

 $Description:	Is the internal phonebook available for use?

 $Returns:		TRUE if internal phonebook is available, FALSE otherwise

 $Arguments:	none

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

BOOL bookGetBookAvailable()
{
	return ipbBookAvailable;
}


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

 $Function:		bookSetBookAvailable

 $Description:	Indicate whether or not the internal phonebook is available for use

 $Returns:		None.

 $Arguments:	TRUE to if internal phonebook is available, FALSE otherwise

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

void bookSetBookAvailable(UBYTE bookAvailable)
{
	ipbBookAvailable = bookAvailable;

	return;
}

#endif




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

 $Function:     bookExit

 $Description:  Exit the phone book application, this will delete the static
                phone book element

 $Returns:    none

 $Arguments:  none

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

void bookExit( void )
{
    TRACE_FUNCTION( "bookExit()" );
	phb_delete( phb );
	/* SPR#1112 - SH - Now redundant */
   // bookDeletePhoneBook();

/* SPR#1112 - SH - Exit internal phonebook if activated */
#ifdef INT_PHONEBOOK
	if (bookGetBookAvailable())
		GI_pb_Exit();
#endif

	return;
}








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

 $Function:     bookAddName

 $Description:  Adds a new number to the phone book

 $Returns:    tbd

 $Arguments:  tbd

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

void bookAddName( T_MFW_HND win, char *number )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = (T_phbk          *)data->phbk;

    /* Populate the name and number records with the provided number
    */


/*MC SPR 1257, name strings should use MAX_ALPHA_LEN*/
  memset( Phbk->edt_buf_name,   0,      MAX_ALPHA_LEN );
    memcpy( Phbk->edt_buf_number, (char*)number,    PHB_MAX_LEN );

    /* Populate the input specifier structure and use it to
       perform the next action, note when we return we start
       adding a new name.
    */
    TRACE_EVENT ("bookAddName");
  data->phbk->input_name_win = bookInputStartNameEditor(
        data->win, (char*)Phbk->edt_buf_name );
}








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

 $Function:     bookShowInformation

 $Description:  general information dialog routine

 $Returns:    none

 $Arguments:  parent, window,
                text, to be displayed,
                cb_function, call back on completion of window

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

void bookShowInformation( MfwHnd parent, int txtId, char *text, T_VOID_FUNC cb_function )
{
    T_DISPLAY_DATA display_info;

    TRACE_FUNCTION( "bookShowInformation()" );

	dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, txtId, TxtNull, COLOUR_BOOK_POPUP);
    dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) cb_function, THREE_SECS, KEY_CLEAR );
    display_info.TextString   = text;

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


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

 $Function:     bookShowInfoScreen

 $Description:  SPR1112 - SH - Show an info screen
 
 $Returns:    none

 $Arguments: parent, window,
             txtId1 - first line ID
             txtId2 - second line ID
             time - timeout for dialog

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

T_MFW_HND bookShowInfoScreen( MfwHnd parent, int txtId1, int txtId2, T_VOID_FUNC cb_function,
	USHORT Identifier, ULONG Time)
{
    T_DISPLAY_DATA display_info;

    TRACE_FUNCTION( "bookShowInformation()" );

    dlg_initDisplayData_TextId(&display_info, TxtNull, TxtNull, txtId1, txtId2, COLOUR_BOOK_POPUP);
    dlg_initDisplayData_events(&display_info, (T_VOID_FUNC)cb_function, Time, KEY_CLEAR);
    
    display_info.Identifier	= Identifier;

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

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

 $Function:     bookFindIndexMatchPB

 $Description:  Locates the best match from a supplied list of phonebook entries

 $Returns:      0 if error, 1 if successful

 $Arguments:  listPB, pointer to phonebook entries
                    numEntries, number of entries in listPB
                    srcNumberr, pointer to pattern to match

 $History:
 SPR#1727 - DS - Merged from 1.6 branch.

*******************************************************************************/
int bookFindIndexMatchPB(T_MFW_PHB_LIST* listPB, UBYTE numEntries, const char* srcNumber)
{
    int indexMatch = -1;
    int i = 0;
    int j = 0;
    int maxMatchChars = 0;

⌨️ 快捷键说明

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