📄 mmiband.c
字号:
/*******************************************************************************
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
$Module: Frequency band selection
$File: MmiBand.c
$Revision: 1.0
$Author: Condat(UK)
$Date: 03/04/02
********************************************************************************
Description:
This provides the functionality for menu options to select and display the current
band used.
********************************************************************************
$History: MmiBand.c
03/04/02 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 "p_sim.h"
#include "cus_aci.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_lng.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_cm.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_sat.h"
#include "mfw_ss.h" /*for convert*/
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_cphs.h"
#include "mfw_sat.h"
#include "Mfw_band.h"
#include "Mfw_ffs.h"
#include "dspl.h"
#include "MmiMmi.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiBand.h"
#include "MmiCPHS.h"
#include "MmiEditor.h"
#include "Mmiicons.h"
//#include "BmiEastAPI.h"
/***********************************Macros**********************************************/
#define MAX_NUMBER_OF_FREQS 5
#define NO_OF_BAND_MODES 2
#define BAND_INIT 1
#define BAND_DESTROY 2
/*********************Structure Definitions********************************************************/
typedef struct
{
T_MMI_CONTROL mmi_control;
T_MFW_HND freq_win; /* MFW win handler */
T_MFW_HND parent;
UBYTE available_freqs;
UBYTE type[MAX_NUMBER_OF_FREQS];
ListMenuData * menu_list_data;
UBYTE no_of_entries;
int max_menu_item_len;
char *menu_text[MAX_NUMBER_OF_FREQS];
} T_FREQ_INFO;
static MfwMnuAttr Freq_menuAttrib =
{
0,
&melody_menuArea,
MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
-1, /* use default font */
NULL, /* with these items */
0 /* number of items */
};
/* List of all possible frequencies */
static int band_list[MAX_NUMBER_OF_FREQS] = {
MFW_BAND_GSM_900,
MFW_BAND_DCS_1800,
MFW_BAND_PCS_1900,
MFW_BAND_E_GSM,
MFW_BAND_GSM_850
};
static char *statusString; /* Used to store list of selected frequencies */
/*********************************Function Prototypes*****************************/
char* Freq2Str(int freq);
int Freq2StrID(int freq);
static T_MFW_HND mmi_band_build_freq_list( MfwHnd parent_window, UBYTE available_freqs);
static int mmi_band_display_status(T_MFW_HND parent);
static int mmi_band_display_status_cb(T_MFW_HND parent, USHORT identifier, USHORT reason);
void mmi_band_freq_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
void mmi_band_freq_list_cb(T_MFW_HND * Parent, ListMenuData * ListData);
static void mmi_band_freq_list_destroy(MfwHnd own_window);
static int mmi_band_freq_win_cb (MfwEvt e, MfwWin *w);
/************************************Public Functions************************/
/*************************************************************************
$Function: mmi_band_radio_mode_change_auto
$Description: Changes multiband mode to automatic. Selected from menu.
$Returns: status int
$Arguments: menu and menu item (not used)
*******************************************************************************/
int mmi_band_radio_mode_change_auto(MfwMnu* m, MfwMnuItem* i)
{
T_MFW_HND parent = mfwParent( mfw_header());
T_MFW_BAND_MODE mode;
UBYTE selected_freqs;
TRACE_FUNCTION("mmi_band_radio_mode_change_auto");
if (band_radio_mode_switch(MFW_BAND_MODE_Auto, 0) >= MFW_BAND_OK)
{
ShowMessage(parent, TxtNull,TxtDone,REMIND_SUCCEED);
}
else
ShowMessage(parent, TxtNull,TxtFailed,REMIND_FAILURE);
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: mmi_band_radio_mode_change_manual
$Description: Gets a list of available manual bands. Selected from menu.
$Returns: status int
$Arguments: menu and menu item (not used)
*******************************************************************************/
int mmi_band_radio_mode_change_manual(MfwMnu* m, MfwMnuItem* i)
{
T_MFW_HND parent = mfwParent( mfw_header());
T_MFW_BAND_MODE maxMode;
UBYTE available_freqs;
T_MFW_HND win;
if (band_get_radio_modes(&maxMode, &available_freqs) >= MFW_BAND_OK)
{
if (maxMode >= MFW_BAND_MODE_Manual) /* Make sure manual is an accepted mode */
{
win = mmi_band_build_freq_list(parent, available_freqs);
if (win NEQ NULL)
{
SEND_EVENT (win, BAND_INIT, 0, 0);
}
else
ShowMessage(parent, TxtManual, TxtNotSupported,REMIND_FAILURE);
}
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: mmi_band_radio_mode_info
$Description: Get current band setting
$Returns: status int
$Arguments: menu and menu item (not used)
*******************************************************************************/
int mmi_band_radio_mode_info(MfwMnu* m, MfwMnuItem* i)
{ T_MFW_HND parent = mfwParent( mfw_header());
mmi_band_display_status(parent);
return MFW_EVENT_CONSUMED;
}
/*******************************Private Functions**********************************/
/*******************************************************************************
$Function: Freq2Str
$Description: Converts the band enum into an appropraite string
$Returns: string
$Arguments: Band (integer)
*******************************************************************************/
char* Freq2Str(int freq)
{
switch (freq)
{
case MFW_BAND_DCS_1800: return MmiRsrcGetText(TxtDCS1800);break; //xsf change TxtDCS_1800 to TxtDCS1800 09.25
case MFW_BAND_PCS_1900: return MmiRsrcGetText(TxtPCS_1900);break;
case MFW_BAND_E_GSM: return MmiRsrcGetText(TxtE_GSM);break;
case MFW_BAND_GSM_850: return MmiRsrcGetText(TxtGSM_850);break;
case MFW_BAND_GSM_900: return MmiRsrcGetText(TxtGSM900);break; //xsf change TxtGSM_900 to TxtGSM900 09.25
default: return MmiRsrcGetText(TxtError);break;
}
}
/*******************************************************************************
$Function: Freq2StrID
$Description: Converts the band enum into an appropraite string ID
$Returns: string ID
$Arguments: Band (integer)
*******************************************************************************/
int Freq2StrID(int freq)
{
switch (freq)
{
case MFW_BAND_DCS_1800: return TxtDCS_1800;break;
case MFW_BAND_PCS_1900: return TxtPCS_1900;break;
case MFW_BAND_E_GSM: return TxtE_GSM;break;
case MFW_BAND_GSM_850: return TxtGSM_850;break;
case MFW_BAND_GSM_900: return TxtGSM_900;break;
default: return TxtError;break;
}
}
/*******************************************************************************
$Function: mmi_band_display_status
$Description: Displays the current band status
$Returns: none
$Arguments: parent - parent window
*******************************************************************************/
static int mmi_band_display_status(T_MFW_HND parent)
{
T_MFW_BAND_MODE mode;
UBYTE selected_freqs;
USHORT index;
USHORT stringLen;
int bandCounter;
T_EDITOR_DATA editor_data;
if (band_get_current_radio_mode(&mode, &selected_freqs) >= MFW_BAND_OK)
{
if (mode == MFW_BAND_MODE_Auto)
{
ShowMessage(parent, TxtNull,TxtAutomatic,REMIND_COMPLETE);
}
else
{
ShowMessage(parent, TxtNull,TxtManual,REMIND_COMPLETE);
}
}
else
{
ShowMessage(parent, TxtNull,TxtReadError,REMIND_FAILURE);
}
return;
}
/*******************************************************************************
$Function: mmi_band_display_status_cb
$Description: Callback for status list window - currently does nothing
$Returns: none
$Arguments: parent - parent window
identifier - length of status string
reason - not used
*******************************************************************************/
static int mmi_band_display_status_cb(T_MFW_HND parent, USHORT identifier, USHORT reason)
{
return;
}
/*******************************************************************************
$Function: mmi_band_build_freq_list
$Description: Creates window for frequency list
$Returns: window created
$Arguments: parent window
*******************************************************************************/
static T_MFW_HND mmi_band_build_freq_list( MfwHnd parent_window, UBYTE available_freqs)
{
T_FREQ_INFO *data = (T_FREQ_INFO *)ALLOC_MEMORY (sizeof (T_FREQ_INFO));
T_MFW_WIN *win;
int index;
/*
* Create window handler
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -