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

📄 mmibookcontroller.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:       MmiBookController.c
 $Revision:   1.0

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

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

 Description:

  The book controller module provides the external
  interface to the phone book. It provides ALL external
  entry points to the phone book system.

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

 $History: MmiBookController.c

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

 $End

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


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

                                Include Files

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

/* MMI phone book specific 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 "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 "MmiTimers.h"


#include "MmiBookController.h"
#include "MmiBookUtils.h"

/* MMI specific includes, outside scope of phone book
*/
#include "MmiPins.h"
#include "MmiSmsMenu.h"
#include "MmiSmsSend.h"
#include "MmiCall.h"
#include "MmiIdle.h"


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

                                Definitions

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

/* Since we want to make sure all of the menu handlers get
   treated the same way, and have a protected handler, define
   a new macro, in terms of the MENU_HANDLER, which will
   invoke the protected function correctly (See below for
   further details)
*/
#define PROTECTED_MENU_HANDLER( Name ) \
static MENU_HANDLER( Protected##Name ); \
MENU_HANDLER( Name ) \
{ \
    return Protected( Name, Protected##Name, Menu, Item ); \
} \
static MENU_HANDLER( Protected##Name )



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

                                Local structures

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

/* A number of the actions the phone book is required to perform
   can only be activated when the user enters a security PIN number,
   the PIN2 code. In order to make the operation of the module
   clear, we will build a list of the protected actions, and then
   drive all menu operations through a single clearing process.

   The module will use the following action list perform the
   protection, note that the last entry in this list must be
   NULL
*/
typedef tBookStatus (*tProtectFunction)( tBookMfwMenu *Menu, tBookMfwMenuItem *Item );

tProtectFunction ProtectedActions[] = {
  bookNameEnter,
  bookNameEdit,
  bookNameDelete,
  bookNameDeleteAll,
  NULL };



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

                                Private methods

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

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

 $Function:     Mmir_BaseAddress

 $Description:  returns the base address of the Master Index Table

 $Returns:    As above

 $Arguments:  none.

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

/* Provide a local routine which will perform the protection
   method. This will scan the list of protected actions, looking
   for the provided function, if it isn't a protected function
   then we will just call it directly, otherwise we will guard
   it with the PIN2 security code if we have a protected book
*/
static int Protected( tProtectFunction FunTag, tProtectFunction FunPtr, tBookMfwMenu *Menu, tBookMfwMenuItem *Item )
{
    pBookMfwWin    win_data = (pBookMfwWin) bookWindowData();
  pBookPhonebook book     = ((pBookStandard)win_data->user)->phbk;
  int i;

  /* Check for a protected book being used (details to be sorted
     out at a later date)
  */
  if ( phb_get_mode() == PHB_RESTRICTED )
  {
    /* Is the requested function one of the ones we need
       to protect ?
    */
    TRACE_FUNCTION("Phone Book in FDN mode:ask for pin 2");
    for ( i = 0; ProtectedActions[i]; i++ )
    {
      if ( FunTag == ProtectedActions[i] )
      {
        /* Yup, so we need to store the pending action for
           this window, this will be invoked by the checking
           operation, indirectly, if the check is successful
        */
        book->pin2_next = (T_VOID_FUNC) FunPtr;

        //We're cheating and passing the current window to the
        //handler via the unused menu parameter -- MC
        book->menu = (tBookMfwMenu*) bookCurrentWindow();
        book->item = Item;

        /* Call out to get the pin2 number checked, this will
           respond with a message back to this object, which
           we will deal with on receipt
        */
        return pin2_check( bookCurrentWindow());
      }
    }
  }

  /* we've come through the list of functions and either don't
     have a protected action to perform, or the book itself
     is not protected, so just invoke the requested action
  */
  return (FunPtr)( (tBookMfwMenu*) bookCurrentWindow()/*Menu*/, Item );
}



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

                                Public methods

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

/* Menu Handlers

   We are routing all of the phone book functionality through
   this module to allow the functional modules to be developed
   independantly where possible.

   This gives a single interface point for the rest of the
   MMI subsystem.

   All of the following functions use the MENU_HANDLER macro,
   as such they all have a common interface, this is not therefore
   documented in each case. The following information is common
   for each menu handler


   $Returns:  Status from worker routine

   $Arguments:  Menu, the menu from which the function was activated
                Item, the item associated with the call

*/


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

 $Function:     bookNameEnter

 $Description:

    Add new name to the phone book

 $Returns:    Refer Menu Handlers Definition Block Above

 $Arguments:  Refer Menu Handlers Definition Block Above

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

PROTECTED_MENU_HANDLER( bookNameEnter )
{
  //recast the menu parameter as the current window -- MC
    T_MFW_HND     win         = (T_MFW_HND)Menu;
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;

  TRACE_FUNCTION("bookNameEnter");
    /* Clear the input editor structures before we go any further
    */

  if (Phbk->UpdateAction!=ADD_FROM_IDLE)
      memset( Phbk->phbk->edt_buf_number, '\0', PHB_MAX_LEN );
  /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
  	  memset( Phbk->phbk->edt_buf_name,   '\0', MAX_ALPHA_LEN );
    /* Indicate this is an additional entry being created
    */
    Phbk->UpdateAction = CREATE_ENTRY;

    /* Determine if we have room to add any new entries
    */
  bookGetCurrentStatus( &Phbk->phbk->current.status );
  if ( Phbk->phbk->current.status.avail_entries )
  {
        /* We are okay to input the number, use a worker routine
           from the input handler module to actually deal with this
        */
    Phbk->input_number_win = bookInputStartNumberEditor( win, Phbk->edt_buf_number );
  }
  else
  {
        /* We have no room available to add the name, so check if
           we have filled the namespace or not
        */
        tIndexTagNames Tag = ( Phbk->phbk->current.status.used_entries )
            ? TxtPhbkFull : TxtOperationNotAvail;
        bookShowInformation( win, Tag,NULL, NULL );
  }

    /* Always return event consumed
    */
    return MFW_EVENT_CONSUMED;
}


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

 $Function:     bookNameEdit

 $Description:

    Edit the name in the phone book

 $Returns:    Refer Menu Handlers Definition Block Above

 $Arguments:  Refer Menu Handlers Definition Block Above

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

PROTECTED_MENU_HANDLER( bookNameEdit )
{
  //recast the menu parameter as the current window -- MC
    T_MFW_HND     win         = /*mfwParent( mfw_header() )*/(T_MFW_HND)Menu;
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;

    /* Indicate this is an edit of a current entry
    */
    Phbk->UpdateAction = MODIFY_EXISTING;
	/*MC SPR 1327, if UPN don't change phonebook type*/
    if (data->phbk->current.status.book != PHB_UPN)
		data->phbk->current.status.book = bookActiveBook(READ);

	/*api - clear buffers before edit
	*/
	memset( Phbk->phbk->edt_buf_number, '\0', PHB_MAX_LEN );
  	memset( Phbk->phbk->edt_buf_name,   '\0', MAX_ALPHA_LEN );

TRACE_EVENT_P2("current phbk is = %d and current entry is = %d", data->phbk->current.status.book,data->phbk->current.entry[ data->phbk->current.selectedName ].book);
	
	if(data->phbk->current.status.book == PHB_ADN_FDN)
	{
		if(data->phbk->current.entry[ data->phbk->current.selectedName ].book==PHB_FDN)
		{
			bookActivateFDN((T_MFW_HND)Menu);
		}	
		else
		{
		    	/* And populate the buffers with the information to be modified
    			*/
				#ifdef NO_ASCIIZ
				/*MC , SPR 1242 copy whole name, merged from b-sample build*/
				  memcpy( Phbk->phbk->edt_buf_name,   Phbk->current.entry[ Phbk->current.selectedName ].name.data, MAX_ALPHA_LEN /*Phbk->current.entry[ Phbk->current.selectedName ].name.len*/);
				#else
				  memcpy( Phbk->phbk->edt_buf_name,   Phbk->current.entry[ Phbk->current.selectedName ].name, MAX_ALPHA_LEN );
				#endif
			    memcpy( Phbk->phbk->edt_buf_number, Phbk->current.entry[ Phbk->current.selectedName ].number, PHB_MAX_LEN );

			    /* And edit the entry we currently have active
			    */
			    Phbk->input_number_win = bookInputStartNumberEditor( win, Phbk->edt_buf_number );
		}
	}
    else
    	{
		    /* And populate the buffers with the information to be modified
    		*/
			#ifdef NO_ASCIIZ
			/*MC , SPR 1242 copy whole name, merged from b-sample build*/
			  memcpy( Phbk->phbk->edt_buf_name,   Phbk->current.entry[ Phbk->current.selectedName ].name.data, MAX_ALPHA_LEN/*Phbk->current.entry[ Phbk->current.selectedName ].name.len*/);
			#else
			  memcpy( Phbk->phbk->edt_buf_name,   Phbk->current.entry[ Phbk->current.selectedName ].name, MAX_ALPHA_LEN );
			#endif
		    memcpy( Phbk->phbk->edt_buf_number, Phbk->current.entry[ Phbk->current.selectedName ].number, PHB_MAX_LEN );
	
		    /* And edit the entry we currently have active
		    */
		   Phbk->input_number_win = bookInputStartNumberEditor( win, Phbk->edt_buf_number );
    	}
    /* Always return event consumed
    */
    return MFW_EVENT_CONSUMED;
}

⌨️ 快捷键说明

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