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

📄 mmimain.c

📁 GSM手机设计软件代码
💻 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:   MMI
 $File:       MmiMain.c
 $Revision:   1.0

 $Author:   Condat(UK)
 $Date:       22/02/01

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

 Description:



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

 $History: MmiMain.c

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

 $End

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

#include <stdio.h>
#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_kbd.h"
#include "mfw_tim.h"
#include "mfw_lng.h"
#include "mfw_win.h"
#include "mfw_icn.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "Mfw_td.h"/*SPR 1725*/
#ifdef SIM_TOOLKIT
#include "mfw_sat.h"
#endif
#include "dspl.h"


#include "p_mmi.h"
#include "message.h"
#include "prim.h"
#include "aci_cmh.h"
#include "mfw_mme.h"

#ifndef _SIMULATION_
#include "Sys_types.h"
#endif

#include "MmiMmi.h"
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#endif

#include "MmiIcons.h"
#include "MmiPins.h"
#include "MmiMain.h"
#include "MmiDialogs.h"
#include "MmiIdle.h"
#include "MmiStart.h"
#include "MmiCall.h"
#include "MmiSimToolkit.h"
#include "gdi.h"
#include "Audio.h"
#include "MmiLists.h"
#include "MmiSounds.h"
#include "MmiResources.h"
#include "MmiSettings.h"
#include "MmiTimeDate.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"


static MfwHnd times;	      /* clock via software timer */
static MfwHnd times_switchoff;		/* timer switch off (GB)*/

					/* GLOBAL CONTROL DATA	    */
LngInfo mainLngInfo;			/* language control block   */
MfwHnd mainMmiLng;			/* global language handler  */


#ifndef _SIMULATION_
extern void AI_Power(SYS_UWORD8 power);
#endif

static int keyAction (MfwEvt e, MfwKbd *res);
static int key (MfwEvt e, MfwKbd *kc);
static int timer (MfwEvt e, MfwTim *t);
static void backlight (void);
static int timesEvent (MfwEvt e, MfwTim *t);
static void showGoodBye (T_MFW_HND win);
static void goodbye_cb (void);



static MfwHnd mme;				/* our MME manager	     */

U16 GlobalIconStatus;
UBYTE globalMobileMode;
int MmiModule;


/* batterie and signal	  start  */
int globalBatteryUpdate(U8 value);
int globalSignalUpdate(U8 value);

void globalFlashBattery (void);

UBYTE globalBatteryPicNumber;
UBYTE globalSignalPicNumber;

UBYTE globalBatteryMode; /*  */
int globalMme(MfwEvt e, void *para);
/* batterie and signal	   end	*/

/*MC SPR 1725 removed current clock and date variables*/

static LONG second;

char stringTrace[50];
static U8 deregis = FALSE;	      /* status deregistration	     */

// SH 6/03/02 - HUPKeyOrigin is 1 if POWER_KEY is pressed in idle screen, 0 otherwise
// Means that long press of HUP key will go to idle screen, not just shut down
UBYTE HUPKeyOrigin;
int off_switch;	/* distinguish between on- and off switching to display a goodbye message*/
/* SPR877 - SH - set to TRUE if welcome animation has finished */
extern UBYTE animation_complete;

T_MFW_CFLAG_STATUS DivertStatus = MFW_CFLAG_NOTSet;
#define TIME_MINUTE	60000
#define TIMEDOWN	120000L 	/* time for powerdown 2min  */
#define TIME_SWITCH_OFF 3000	     /* switch off time delay */

/* Amounts to: 128 (format mode) + 8 (overwrite mode) */

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

 $Function:

 $Description:	general editor control

 $Returns:    none.

 $Arguments:

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

/* SPR#1428 - SH - New Editor changes - this version of editControls used
 * by new editor.  The rest is now in AUITextEntry */

#ifdef NEW_EDITOR

UBYTE editControls [KCD_MAX] =	    /* edit control keys:	*/
{
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '*', '#', ctrlNone, ctrlNone, ctrlUp, ctrlDown, ctrlLeft, ctrlRight,
    ctrlNone, ctrlNone, ctrlEnter, ctrlNone, ctrlNone, ctrlNone,
    ctrlNone, ctrlNone, ctrlEnter
};

#else /* NEW_EDITOR */

static MfwHnd myHandle = 0;		/* editors handle	    */
static MfwHnd editTim = 0;		/* the editor timer	    */
static char *formatHandle;	  // SH - pointer to format string, so that editEventKey can see it
static int *formatIndex;	// SH - pointer to format index
static int *fieldIndex; 	// SH - pointer to field position
static char *tmpBuf;	      // SH - pointer to temporary buffer for hidden alphanumeric entry

#define KEY_PAD_MAX 5

UBYTE editControls [KCD_MAX] =	    /* edit control keys:	*/
{
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    '*', '#', ecNone, ecNone, ecUp, ecDown, ecLeft, ecRight,
    ecNone, ecNone, ecEnter, ecNone, ecNone, ecNone,
    ecNone, ecNone, ecEnter
};

static UBYTE editAlphaMode;		   /* alpha mode flag	       */
static UBYTE editCalcMode;		  /* calculator mode flag	   */
static UBYTE editFormatMode;	  /* format mode flag */
static UBYTE editHiddenMode;	  /* hidden alphanumeric mode */
static UBYTE editAlphaLevel;		   /* alpha level selected     */
static UBYTE editAlphaKey;		   /* alpha mode current key   */



static UBYTE editAlpha [12][KEY_PAD_MAX] =	     /* alpha mode characters	 */
{
    {'.','+','-','=','0'},		//0 key
    {' ','?','!','1',':'}, {'a','b','c','2',')'}, {'d','e','f','3','('},     // 1 2 3
    {'g','h','i','4','$'}, {'j','k','l','5',' '}, {'m','n','o','6',','},     // 4 5 6
  {'p','q','r','s','7'}, {'t','u','v','8',';'}, {'w','x','y','z','9'},	  // 7 8 9
  {'*','#','%','&',' '}, {' ','\'','\"','@','/'}  // star and hash keys
};

static UBYTE editAlphaU [12][KEY_PAD_MAX] =	  /* upCase alpha mode characters*/
{
  {'.','+','-','=','0'},	      //0 key
    {' ','?','!','1',':'}, {'A','B','C','2',')'}, {'D','E','F','3','('},    // 1 2 3
    {'G','H','I','4','$'}, {'J','K','L','5',' '}, {'M','N','O','6',','},   // 4 5 6
  {'P','Q','R','S','7'}, {'T','U','V','8',';'}, {'W','X','Y','Z','9'}, // 7 8 9
  {'*','#','%','&',' '}, {' ','\'','\"','@','/'}		// star and hash keys
};


int upCase= TRUE;


static int editEventTim (MfwEvt e, MfwTim *t);
static void editShowHeader (void);

#endif /* NEW_EDITOR */


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

 $Function:  mainInit

 $Description:	 init MMI main module

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void mainInit (UBYTE InitCause)
{
	int i;
	
    TRACE_FUNCTION("maininit");

    mfwSetSignallingMethod(1);
    winAutoFocus(TRUE);
    mfwFocus = 0;			/* reset focus		    */


    /*MC SPR 1111*/
		/*MC check to see if  language already selected and saved to FFS*/
		if (flash_read() >= EFFS_OK)
		{	TRACE_EVENT_P1("FFS_flashData.language: %d", FFS_flashData.language);
			
			/*MC SPR 1150 if language is not 0 and not greater than the maximum language code*/
			if (FFS_flashData.language != NULL && FFS_flashData.language<= NO_OF_LANGUAGES)
				MmiRsrcSetLang(FFS_flashData.language);/*MC, change to stored language*/
			else
				MmiRsrcSetLang(ENGLISH_LANGUAGE);
		}
		else
		{	
			/* GW If flash read fails set up default settings. */
			/* This will also save the settings to flash */
			memset(&FFS_flashData, 0x00, sizeof(FFS_flashData));
			/*default language is english*/
			setUserSettings2Default();
		}
/*mc end*/
	HUPKeyOrigin = 0;  // sbh
	off_switch=0;	/* 0 is stands for mobile is swiched on */
	animation_complete = FALSE;

    kbdAlways((MfwCb)keyAction);	/* global keyboard access   */
    kbdTime(2000,1000,400);		/* long / repeat timeouts   */

    mainMmiLng = lngCreate(0,0,&mainLngInfo,0); /* language handler */

	// times clock event
    times = timCreate(0,TIME_MINUTE,(MfwCb)timesEvent);
    mme = mmeCreate(0, MfwMmeSignal|MfwMmeBattery|MfwMmeBaState, (MfwCb)globalMme);

    /*Setup when we want the backlight to come on*/
	for (i=0;i<BL_LAST_OPTION;i++)
		mme_setBacklightEvent(i,BL_MAX_LIGHT);

	mme_setBacklightEvent(BL_IDLE_TIMER,BL_SET_IDLE);
	mme_setBacklightEvent(BL_EXIT,BL_NO_LIGHT);
	
	/*and tell the backlight that the init event has happened */
	mme_backlightEvent(BL_INIT);

//RM test 14-07 second = 0;
   /*SPR 1725, replace FFS clock data with RTC*/
	time_date_init();

    deregis = FALSE;
      timStart(times);		       /*      start clock	    */


    startExec(PhoneInit,0);		 /* get it rolling	    */

}

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

 $Function:  mainExit

 $Description:	 exit MMI main module

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void mainExit (UBYTE InitCause)
{
  TRACE_FUNCTION("mainExit");

  startExit();
  sim_exit();			      /* finit SIM handler	  */
    lngDelete(mainMmiLng); mainMmiLng = 0;
    timDelete(times);
    mmeDelete(mme); mme = 0;
    kbdAlways(0);
    dspl_ClearAll();
	time_date_delete();/*SPR 1725*/

}

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

 $Function:  keyAction

 $Description:	 handler called on every keyboard action

 $Returns:

 $Arguments:

*******************************************************************************/
static int keyAction (MfwEvt e, MfwKbd *res)
{



  //this function "keyAction" is called 4*times from MFW per each keypress
  // twice for keypress and twice for keyrelease
  // the variable "toggle" is using to avoid to play the keypadtone twice !
    static UBYTE toggle = TRUE;

  // this mask is use to filter the keyevent "e"
  // want to use KEY_0, KEY_1,......  KEY_HASH
  USHORT  mask = 0x0FFF;


  //terminate the ringing in all situation (it doesnt matter where the user is
  if ( (e & KEY_HUP) && (e & KEY_MAKE) )
  {
    UBYTE currentRinger = getCurrentRingerSettings();

	// terminate the ringing
      audio_StopSoundbyID( AUDIO_BUZZER, currentRinger );

  }

  //the power-off-key !
  if ( (e & KEY_POWER) && (e & KEY_MAKE))
  {	
    TRACE_EVENT("KEY_POWER pressed !!!!");

	if (pinsIsFocussed() EQ FOCUSSED_PINS)
    {
    	pin_exit();
    	HUPKeyOrigin=1;
    }
    else if (idleIsFocussed())
	{
    	HUPKeyOrigin=1;
	}
    
    if ((HUPKeyOrigin==1) && (off_switch == 0))
	{
		/*
		** Only pass through this once, off_switch must be 0 because Key_Action is called twice
		** for each key press.
		*/
		TRACE_EVENT("In idle window.");
	    showGoodBye ( idle_get_window () ); //gb
	    times_switchoff = timCreate(0,THREE_SECS,(MfwCb)goodbye_cb);
	    timStart(times_switchoff);
	    off_switch++;
	    deregis = TRUE;
    }
  }

  HUPKeyOrigin = 0;

  //every other calls
  if(toggle)
  {
#ifdef SIM_TOOLKIT
	satEvtDownload(SatEvtUserAction);
#endif
    //"KEY_MAKE"  makes sure to call it only by keypress
    if ((FFS_flashData.settings_status & SettingsKeypadClick) && (e & KEY_MAKE))
    {
      TRACE_EVENT ("Keypad Click activ");
      //play KeypadClick
      audio_PlaySoundID(0, TONES_KEYBEEP, 200, 0 );
    }
    //"KEY_MAKE"  makes sure to call it only by keypress
    else if ((FFS_flashData.settings_status & SettingsKeypadDTMF) && (e & KEY_MAKE))
    {
      TRACE_EVENT ("Keypad DTMF activ");
      switch (e &= mask)
	{
	case KEY_0:
	  audio_PlaySoundID(0, (TONES_DTMF_0), 0, 0 );
	break;
	case KEY_1:
	  audio_PlaySoundID(0, TONES_DTMF_1, 0, 0 );
	break;
	case KEY_2:
	  audio_PlaySoundID(0, TONES_DTMF_2, 0, 0 );
	break;
	case KEY_3:
	  audio_PlaySoundID(0, TONES_DTMF_3, 0, 0 );
	break;
	case KEY_4:
	  audio_PlaySoundID(0, TONES_DTMF_4, 0, 0 );
	break;
	case KEY_5:
	  audio_PlaySoundID(0, TONES_DTMF_5, 0, 0 );
	break;
	case KEY_6:
	  audio_PlaySoundID(0, TONES_DTMF_6, 0, 0 );
	break;
	case KEY_7:
	  audio_PlaySoundID(0, TONES_DTMF_7, 0, 0 );
	break;
	case KEY_8:
	  audio_PlaySoundID(0, TONES_DTMF_8, 0, 0 );
	break;
	case KEY_9:
	  audio_PlaySoundID(0, TONES_DTMF_9, 0, 0 );
	break;
	case KEY_STAR:
	  audio_PlaySoundID(0, TONES_DTMF_STAR, 0, 0 );
	break;
	case KEY_HASH:
	  audio_PlaySoundID(0, TONES_DTMF_HASH, 0, 0 );
	break;
	default:
	  break;

      }
    }

  }

⌨️ 快捷键说明

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