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

📄 mmibookcontroller.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 4 页
字号:
/*******************************************************************************

          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.
  20/08/02     ver0.101  fzq modified

 
 $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"
#include "mfw_edt.h"
#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"
#include "Mmihost.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,
  bookEditOne,
  bookDeleteOne, 
  NULL 
};
extern T_idle idle_data;	//add by xzy 2002/12/02
extern voice_info voice_dial[VOICEDIAL_MAX];
extern unsigned char voice_index[VOICEDIAL_MAX];
extern char voice_filename[VOICEDIAL_MAX][12];
extern void PlayVmRecord_cb(void * parameter);
/*******************************************************************************

                                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");

  if (Phbk->UpdateAction!=ADD_FROM_IDLE&&Phbk->deletenumber!=1)//
  	{
  	memset(Phbk->phbk->edt_buf_foradd,'\0',PHB_number_len+3);
      memset( Phbk->phbk->edt_buf_number, '\0', PHB_number_len+3);
      Phbk->deletenumber=0;
  	}
  else
  	{
  		strncpy((char *) data->phbk->edt_buf_number, (char*)data->phbk->edt_buf_foradd, PHB_number_len );
  	}
  memset( Phbk->phbk->edt_buf_name,   '\0', PHB_name_len+5);
    // Indicate this is an additional entry being created
    
  Phbk->UpdateAction = CREATE_ENTRY;
  Phbk->BookType=     SIM_BOOK_SEL;

  Phbk->phbk->current.status.book=PHB_ADN;
  bookGetCurrentStatus( &Phbk->phbk->current.status );
  if ( Phbk->phbk->current.status.avail_entries )
  {
    Phbk->input_win=bookInputStart(win);
  }
  else
  {        
    tIndexTagNames Tag = ( Phbk->phbk->current.status.used_entries )
        ? TxtPhbkFull : TxtOperationNotAvail;
    bookShowInformation( win, Tag,NULL, NULL );
  }    
  return MFW_EVENT_CONSUMED;
}

/* 2003/12/01 sunsj add number enter */
PROTECTED_MENU_HANDLER( bookNvmNumberEnter )
{
    //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;
    char           temp[100];

    if (Phbk->UpdateAction!=ADD_FROM_IDLE&&Phbk->deletenumber!=1)//
  	{
  	    memset(Phbk->phbk->edt_buf_foradd,'\0',PHB_number_len+3);
        memset( Phbk->phbk->edt_buf_number, '\0', PHB_number_len+3 );
        Phbk->deletenumber=0;
  	}
    else
  	{
  		strncpy((char *) data->phbk->edt_buf_number, (char*)data->phbk->edt_buf_foradd, PHB_number_len );
  	}
    memset( Phbk->phbk->edt_buf_name, '\0',PHB_name_len+5);
    memset( Phbk->phbk->edt_buf_home, '\0',PHB_number_len+3);
    memset( Phbk->phbk->edt_buf_office, '\0',PHB_number_len+3);
    memset( Phbk->phbk->edt_buf_memo,'\0',PHB_memo_len+3);
    Phbk->UpdateAction = CREATE_ENTRY;
    Phbk->BookType   =  NVM_BOOK_SEL;
    Phbk->FirstNumber=   NUMBER;
       
    if ( NVMTotal<ALL_NVM_LIST )               
        Phbk->input_win =bookInputStart(win); 
    else
		bookShowInformation( win, TxtPhbkFull,NULL, NULL );  
    
    return MFW_EVENT_CONSUMED;
}

PROTECTED_MENU_HANDLER( bookNumberEnter )
{
  //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;
  char           temp[100];

  sprintf(temp,"Number win:%d",(int *)win);
  TRACE_EVENT(temp);

  TRACE_FUNCTION("booknumberEnter");   

  if (Phbk->UpdateAction!=ADD_FROM_IDLE&&Phbk->deletenumber!=1)//
  	{
  	memset(Phbk->phbk->edt_buf_foradd,'\0',PHB_number_len+3);
     memset( Phbk->phbk->edt_buf_number, '\0', PHB_number_len+3 );
     Phbk->deletenumber=0;
  	}
  else
  	{
  		strncpy((char *) data->phbk->edt_buf_number, (char*)data->phbk->edt_buf_foradd, PHB_number_len );
  	}
  memset( Phbk->phbk->edt_buf_name, '\0',PHB_name_len+5);
  memset( Phbk->phbk->edt_buf_home, '\0',PHB_number_len+3);
  memset( Phbk->phbk->edt_buf_office, '\0',PHB_number_len+3);
  memset( Phbk->phbk->edt_buf_memo,'\0',PHB_memo_len+3);
  Phbk->UpdateAction = CREATE_ENTRY;
  Phbk->BookType   =  NVM_BOOK_SEL;
  Phbk->FirstNumber=   NUMBER;
       
  if ( NVMTotal<ALL_NVM_LIST )               
    Phbk->input_win =bookInputStart(win); 

⌨️ 快捷键说明

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