📄 mfw_sat.c
字号:
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417) $Workfile:: mfw_sat.c $|
| $Author: root $ CONDAT GmbH $Revision: 1.1.1.1 $|
| CREATED: 07.05.99 $Modtime:: 23/02/00 20:23 $|
| STATE : code |
+--------------------------------------------------------------------+
MODULE : MFW_SAT
PURPOSE : SIM Application Toolkit Handling
EXPORT :
TO DO :
$History:: mfw_sat.c $
*
* ***************** Version 12 *****************
* User: Xsp Date: 24/02/00 Time: 5:42
* Updated in $/GSM/Condat/MS/SRC/MFW
* Debugged MmiSimToolkit...
*
* ***************** Version 11 *****************
* User: Fk Date: 23.02.00 Time: 18:33
* Updated in $/GSM/Condat/MS/SRC/MFW
* Comprehension flags provided for default Terminal Response
*
* ***************** Version 10 *****************
* User: Xsp Date: 16/02/00 Time: 19:22
* Updated in $/GSM/Condat/MS/SRC/MFW
* Fixed double allocation in satCreate()...
*
* ***************** Version 9 *****************
* User: Xsp Date: 14/02/00 Time: 18:11
* Updated in $/GSM/Condat/MS/SRC/MFW
* Solved compiler errors...
*
* ***************** Version 8 *****************
* User: Xsp Date: 14/02/00 Time: 14:43
* Updated in $/GSM/Condat/MS/SRC/MFW
* Added window pointers to sat structure...
*
* ***************** Version 7 *****************
* User: Fk Date: 11.02.00 Time: 15:40
* Updated in $/GSM/Condat/MS/SRC/MFW
* New event 'SAT Session End' derived from empty command
*
* ***************** Version 6 *****************
* User: Fk Date: 10.02.00 Time: 16:43
* Updated in $/GSM/Condat/MS/SRC/MFW
* Filter for Terminal Profile
*
* ***************** Version 5 *****************
* User: Vo Date: 17.11.99 Time: 10:47
* Updated in $/GSM/Condat/MS/SRC/MFW
|
| ***************** Version 4 *****************
| User: Le Date: 1.10.99 Time: 15:28
| Updated in $/GSM/Condat/MS/SRC/MFW
*
* ***************** Version 3 *****************
* User: Es Date: 9.07.99 Time: 14:32
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 2 *****************
* User: Es Date: 8.07.99 Time: 12:04
* Updated in $/GSM/DEV/MS/SRC/MFW
*
* ***************** Version 1 *****************
* User: Es Date: 6.07.99 Time: 12:42
* Created in $/GSM/DEV/MS/SRC/MFW
* SIM application toolkit handler
* Initial
*/
#define ENTITY_MFW
#include <stdio.h>
#include <string.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "tok.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#include "tok.h"
#endif
#include "message.h"
#include "prim.h"
#include "aci_cmh.h"
#include "ati_cmd.h"
//#include "aci_cmd.h"
#include "aci.h"
#include "p_sim.h"
#include "psa.h"
#include "psa_sim.h"
#include "psa_cc.h"
#include "psa_sat.h"
#include "mfw_mfw.h"
#include "mfw_sys.h"
#include "aci_cmh.h"
#include "mfw_win.h"
#include "mfw_sat.h"
#include "mfw_phb.h"
#include "mfw_nm.h"
#include "mfw_sima.h"
#include "mfw_nmi.h"
#include "mfw_sim.h"
#include "mfw_simi.h"
#include "mfw_cphs.h"
#include "mfw_cphsi.h"
#include "mfw_sms.h"
#include "mfw_smsi.h"
#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
extern char mfwSATLPRefresh;
#define TRM_RSP_LEN (256) /*SPR#2121 - DS - Length of Terminal Response buffer */
#define CMD_DETAILS_LEN (5) /*SPR#2121 - DS - Length of default command details buffer */
char mfwSatMoAccepted = 0;
static U8 lenResponse; /* len of terminal response */
const static U8 defResponse [] = /* default response values */
{
0x81, 0x03, 0x00, 0x00, 0x00, /* command details */
0x82, 0x02, 0x82, 0x81, /* device identities */
0x83, 0x01, 0x32 /* result */
};
static U8 defCmdDetails [CMD_DETAILS_LEN]; /*SPR#2121 - DS - Default SAT command details */
static U8 satNoResponse = 0; /* flag: no resp. from MFW */
static U8 curCR; /* current TLV CR flag */
static U8 curTag; /* current TLV tag */
static U8 curLen; /* current TLV length */
static U8 *curVal; /* current TLV value */
SHORT curSatCallId;
static U8 *curCmd; /* current command pointer */
static S16 curCmdLen; /* len of current command */
static U8 *curData; /* data storage /end buffer */
static SatCmd cmd; /* temp storage for command */
SatCmd* sat_cmd_saved; /* SPR#2321 - DS - Copy of SAT cmd details */
static U8 partialCompr; /* partial comprehension */
static U16 eventList;
typedef struct
{
U8 count;
USHORT fields[MFW_MAX_NT_SIZE];
} T_MFW_UPDATE_FIELDS;
static T_MFW_UPDATE_FIELDS udNotify; /* update fields */
static int fuRef;
static BOOL fu_aborted;
static int satCommand (U32 cmd, void *h);
static void satResponse (U8 res);
const static satMfWSuppTPrf[] = { /* Profile supported by MFW */
#ifdef SAT_TP1_PRF_DNL
SAT_TP1_PRF_DNL | SAT_TP1_MENU_SEL,
SAT_TP2_CMD_RES | SAT_TP2_CC | SAT_TP2_MOSMC | SAT_TP2_ALPHA_ID
| SAT_TP2_UCS2_ENTRY | SAT_TP2_UCS2_DSPL | SAT_TP2_DSPL_EXT,
SAT_TP3_DSPL_TXT | SAT_TP3_GET_INKEY | SAT_TP3_GET_INPUT
| SAT_TP3_PLAY_TONE | SAT_TP3_REFRESH,
SAT_TP4_SEL_ITEM | SAT_TP4_SETUP_MENU | SAT_TP4_SEND_SMS
| SAT_TP4_SEND_SS | SAT_TP4_SEND_USSD | SAT_TP4_SETUP_CALL,
SAT_TP5_EVENT_LIST | SAT_TP5_USER_ACT | SAT_TP5_SCR_AVAIL,
0x0, 0x0,
SAT_TP8_BIN_GET_INKEY | SAT_TP8_IDLE_TXT | SAT_TP8_AI2_SETUP_CALL,
#if defined(WAP)
SAT_TP9_SUST_DSPL_TXT|SAT_TP9_LAUNCH_BROWSER,
#else
SAT_TP9_SUST_DSPL_TXT,
#endif /*WAP*/
0x0, 0x0,
SAT_TP12_OPEN_CHANNEL | SAT_TP12_CLOSE_CHANNEL | SAT_TP12_RECEIVE_DATA |
SAT_TP12_SEND_DATA,
SAT_TP13_CSD_SUPP_BY_ME | SAT_TP13_GPRS_SUPP_BY_ME
#else
/*0x09, 0x73, 0x17, 0x37 /* c032 rsa */
#endif
};
extern MfwHdr *current_mfw_elem;
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SAT |
| STATE : code ROUTINE : satInit |
+--------------------------------------------------------------------+
PURPOSE : initialize SAT handler
*/
MfwRes satInit (U8 *profile, U8 plen)
{
int i;
U8 combProfile [MAX_STK_PRF];
TRACE_FUNCTION("satInit()");
mfwCommand[MfwTypSat] = (MfwCb) satCommand;
satNoResponse = 0;
mfwSatMoAccepted = 0;
mfwSATLPRefresh = 0;
eventList= 0;
fu_aborted = FALSE;
plen = MINIMUM(plen, MAX_STK_PRF);
sat_cmd_saved = NULL; /* SPR#2321 - DS - Initialise ptr to saved cmd */
for (i = 0; i < (int)plen; i++) // check profile against
{ // MFW capability
if (i < sizeof(satMfWSuppTPrf))
combProfile[i] = profile[i] & satMfWSuppTPrf[i];
else
combProfile[i] = 0;
}
sAT_PercentSATC(CMD_SRC_LCL,plen,combProfile);
/* install the call back for file change notification */
fuRef = -1;
psaSAT_FUNotifyRegister(satRefreshNotification);
psaSAT_FURegister (satChangeNotify);
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SAT |
| STATE : code ROUTINE : satExit |
+--------------------------------------------------------------------+
PURPOSE : finalize SAT handler
*/
MfwRes satExit (void)
{
mfwCommand[MfwTypSat] = 0;
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SAT |
| STATE : code ROUTINE : satCreate |
+--------------------------------------------------------------------+
PURPOSE : create SAT control
*/
MfwHnd satCreate (MfwHnd w, MfwEvt e, MfwCb f, SatCmd *c)
{
MfwSat *sat = (MfwSat*) mfwAlloc(sizeof(MfwSat));
MfwHdr *hdr = (MfwHdr *)mfwAlloc(sizeof(MfwHdr));
MfwHdr *insert_status =0;
if (!hdr || !sat)
{
TRACE_ERROR("ERROR: satCreate() Mem Alloc Failed.");
if(hdr)
mfwFree((U8*)hdr,sizeof(MfwHdr));
if(sat)
mfwFree((U8*)sat,sizeof(MfwSat));
return 0;
}
sat->map = e;
sat->evt = 0;
sat->handler = f;
sat->cmd = c;
sat->parentWindow = w;
sat->currentWindow = NULL;
hdr->data = sat;
hdr->type = MfwTypSat;
insert_status = mfwInsert(NULL,hdr);
if(!insert_status)
{
TRACE_ERROR("ERROR: satCreate() Failed to Install Handler. ");
mfwFree((U8*)hdr,sizeof(MfwHdr));
mfwFree((U8*)sat ,sizeof(MfwSat));
return 0;
}
return insert_status;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SAT |
| STATE : code ROUTINE : satDelete |
+--------------------------------------------------------------------+
PURPOSE : delete SAT control
*/
MfwRes satDelete (MfwHnd h)
{
MfwRes res;
if (!h)
return MfwResIllHnd;
res = (mfwRemove(h)) ? MfwResOk : MfwResIllHnd;
mfwFree(((MfwHdr *) h)->data,sizeof(MfwSat));
mfwFree(h,sizeof(MfwHdr));
return res;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SAT |
| STATE : code ROUTINE : satString |
+--------------------------------------------------------------------+
PURPOSE : user string to SIM
SPR#2121 - DS - Dynamically allocate memory for Terminal Response.
*/
MfwRes satString (SatCmd *cmd, SatTxt *txt, U8 *res, int rlen)
{
S16 ti;
U8* trmResponse = NULL;
TRACE_FUNCTION("satString()");
/* Allocate memory for Terminal Response buffer */
trmResponse = (U8*)mfwAlloc(TRM_RSP_LEN);
if (trmResponse == NULL)
{
/* Memory allocation failed */
TRACE_ERROR("ERROR: Failed to allocate memory for TR buffer");
return MfwResNoMem;
}
/*SPR#2121 - DS - Set up terminal response with default values */
lenResponse = sizeof(defResponse); /* prep. terminal response */
memcpy(trmResponse,defResponse,lenResponse);
trmResponse[2] = cmd->number; /* command number */
trmResponse[3] = cmd->type; /* command type */
trmResponse[4] = cmd->qual; /* command qualifier */
ti = sizeof(defResponse) - 2; /* result length */
if(res[1] != SatResAiNoCause) /* only attach additional information if existent*/
{
trmResponse[ti++] = rlen; /* dito */
while (rlen--)
trmResponse[ti++] = *res++; /* result data */
}
else /* result ok no additional resultcode attached*/
{
trmResponse[ti++] = 0x01;
trmResponse[ti++] = *res;
}
trmResponse[ti++] = 0x8D; /* text string tag + CR */
if (txt->len + 1 > 161) /* incl. coding scheme byte */
{
TRACE_ERROR("Text too long!!!");
return MfwResErr;
}
if (txt->len + 1 > 127)
trmResponse[ti++] = 0x81;
trmResponse[ti++] = txt->len + 1;
trmResponse[ti++] = txt->code; /* data coding scheme */
memcpy(trmResponse+ti,(U8*)txt+txt->text,txt->len);
sAT_PercentSATR(CMD_SRC_LCL,(S16)(ti+txt->len),trmResponse);
/* Deallocate memory used for Terminal Response buffer */
if (trmResponse != NULL)
{
mfwFree(trmResponse, TRM_RSP_LEN);
trmResponse = NULL;
}
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_SAT |
| STATE : code ROUTINE : satItem |
+--------------------------------------------------------------------+
PURPOSE : user selected popup item to SIM
SPR#2121 - DS - Dynamically allocate memory for Terminal Response.
*/
MfwRes satItem (SatCmd *cmd, U8 itemId, U8 *res, int rlen)
{
S16 ti;
U8* trmResponse;
TRACE_FUNCTION("satItem()");
/* Allocate memory for Terminal Response buffer */
trmResponse = (U8*)mfwAlloc(TRM_RSP_LEN);
if (trmResponse == NULL)
{
/* Memory allocation failed */
TRACE_ERROR("ERROR: Failed to allocate memory for TR buffer");
return MfwResNoMem;
}
/*SPR#2121 - DS - Set up terminal response with default values */
lenResponse = sizeof(defResponse); /* prep. terminal response */
memcpy(trmResponse,defResponse,lenResponse);
trmResponse[2] = cmd->number; /* command number */
trmResponse[3] = cmd->type; /* command type */
trmResponse[4] = cmd->qual; /* command qualifier */
ti = sizeof(defResponse) - 2; /* result length */
if(res[1] != SatResAiNoCause) /* only attach additional information if existent*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -