📄 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"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#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 "mmicolours.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 selected_freqs; /* SPR#998 - SH - Used to store list of selected frequencies */
T_MFW_BAND_MODE mode; /* SPR#998 - SH */
UBYTE type[MAX_NUMBER_OF_FREQS];
ListMenuData * menu_list_data;
UBYTE no_of_entries;
} T_FREQ_INFO;
static const MfwMnuAttr Freq_menuAttrib =
{
&melody_menuArea,
MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
-1, /* use default font */
NULL, /* with these items */
0, /* number of items */
COLOUR_LIST_SMS,
TxtNull,
MNUATTRSPARE};
/* List of all possible frequencies */
static const 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
};
/* SPR#998 - SH - Static handle to allow callback functions to access data */
static T_FREQ_INFO *current_data = NULL;
/*********************************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);
/* SPR#998 - SH - Functions used by new checkbox menus */
int mmi_band_menu_func(MfwMnu* menu, MfwMnuItem* item);
USHORT mmi_band_menu_flag( struct MfwMnuTag *menu, struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item );
/************************************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;
TRACE_FUNCTION("mmi_band_radio_mode_change_auto");
if (band_radio_mode_switch(MFW_BAND_MODE_Auto, 0) >= MFW_BAND_OK)
{
ShowMessage(parent, TxtDone, TxtNull);
}
else
ShowMessage(parent, TxtFailed, TxtNull);
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);
}
}
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(TxtDCS_1800);break;
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(TxtGSM_900);break;
default: return MmiRsrcGetText(TxtError);break;
}
}
/*******************************************************************************
$Function: Freq2Str
$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)
{
/* SPR#998 - SH - Now store mode in data->mode */
T_MFW_WIN *win_data = ((T_MFW_HDR *) parent)->data;
T_FREQ_INFO *data = (T_FREQ_INFO *)win_data->user;
if (band_get_current_radio_mode(&data->mode, &data->selected_freqs) >= MFW_BAND_OK)
{
if (data->mode == MFW_BAND_MODE_Auto)
{
ShowMessage(parent, TxtAutomatic, TxtNull);
}
else
{
ShowMessage(parent, TxtManual, TxtNull);
}
}
else
{
ShowMessage(parent, TxtReadError, TxtNull);
}
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
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -