📄 si_wtaic.c
字号:
/*
* Copyright (C) Ericsson Mobile Communications AB, 2000.
* Licensed to AU-System AB.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and AU-System AB, and may be used and copied
* only in accordance with the terms of the said agreement.
*
* Neither Ericsson Mobile Communications AB nor AU-System AB
* assumes any responsibility or liability for any errors or inaccuracies in
* this software, or any consequential, incidental or indirect damage arising
* out of the use of the Generic WAP Client software.
*/
/*========================================================================
WAP WTA Implementation Project
==========================================================================
File: si_wtaiC.c
Description: Network common wtai script functions. Implementation file.
Author: Jens Pommer, AU-System Radio AB
Revision history:
Date Sign Comment
991026 JPR First version
991104 JPR Updated
000209 JPR Corrections
000217 JPR Functions updated
000221 JPR Phonebook functions implemented
000225 JPR SendDtmf-functionality updated
000228 FAR URI functionality updated
000229 JPR Correction in adapter calls
001011 ASPN Lower-case filenames
001024 ASPN "finish" functions added,
functions changed to handle new signaling,
AddWTAIResultVariable function removed, not used
001102 ASPN Constant names changed
001106 ASPN Corrections
=========================================================================*/
#include "si_wtaic.h"
#include "aapiwta.h"
#include "capiwta.h"
#include "wmlelm.h"
#include "xml_conv.h"
#include "wmlif.h"
#ifdef USE_WIP_MALLOC
#include "wip_mem.h"
#endif
/* {Function Name, Time Cost, Nbr of Arguments} */
const structWTAILibCall arrayScriptwtaiNC[5][6] =
{
/* Voice Call Control */
{
{WTAI_NC_VC_setup, WTAI_NC_VC_setup_finish, 1, 2},
{WTAI_NC_VC_accept, WTAI_NC_VC_accept_finish, 1, 2},
{WTAI_NC_VC_release, WTAI_NC_VC_release_finish, 1, 1},
{WTAI_NC_VC_sendDTMF, WTAI_NC_VC_sendDTMF_finish, 1, 2},
{WTAI_NC_VC_callStatus, WTAI_NC_VC_callStatus_finish, 1, 2},
{WTAI_NC_VC_list, WTAI_NC_VC_list_finish, 1, 1}
},
/* Network Text */
{
{WTAI_NC_NT_send, WTAI_NC_NT_send_finish, 1, 2},
{WTAI_NC_NT_list, WTAI_NC_NT_list_finish, 1, 2},
{WTAI_NC_NT_remove, WTAI_NC_NT_remove_finish, 1, 1},
{WTAI_NC_NT_getFieldValue, WTAI_NC_NT_getFieldValue_finish,1, 2},
{NULL, NULL, 0, 0},
{NULL, NULL, 0, 0}
},
/* Phone Book */
{
{WTAI_NC_PB_write, WTAI_NC_PB_write_finish, 1, 3},
{WTAI_NC_PB_search, WTAI_NC_PB_search_finish, 1, 2},
{WTAI_NC_PB_remove, WTAI_NC_PB_remove_finish, 1, 1},
{WTAI_NC_PB_getFieldValue, WTAI_NC_PB_getFieldValue_finish,1, 2},
{WTAI_NC_PB_change, WTAI_NC_PB_change_finish, 1, 3},
{NULL, NULL, 0, 0}
},
/* Call Logs */
{
{WTAI_NC_CL_dialled, WTAI_NC_CL_dialled_finish, 1, 1},
{WTAI_NC_CL_missed, WTAI_NC_CL_missed_finish, 1, 1},
{WTAI_NC_CL_received, WTAI_NC_CL_received_finish, 1, 1},
{WTAI_NC_CL_getFieldValue, WTAI_NC_CL_getFieldValue_finish,1, 2},
{NULL, NULL, 0, 0},
{NULL, NULL, 0, 0}
},
/* Miscelleaneous */
{
{WTAI_NC_MISC_indication, WTAI_NC_MISC_indication_finish, 1, 2},
{WTAI_NC_MISC_endcontext, NULL, 1, 0},
{WTAI_NC_MISC_getProtection,NULL, 1, 0},
{WTAI_NC_MISC_setProtection,NULL, 1, 1},
{NULL, NULL, 0, 0},
{NULL, NULL, 0, 0}
}
};
/*========================================================================
==========================================================================
PRIVATE FUNCTIONS
==========================================================================
=========================================================================*/
/*========================================================================
==========================================================================
EXTERNAL FUNCTIONS
==========================================================================
=========================================================================*/
/* Voice Call Control ****************************************************/
/* voiceCallSetup(number, mode); */
enumErrorCode
WTAI_NC_VC_setup (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
BYTE* pbStr=NULL;
if (OpS!=NULL)
{
BOOL fOverflow = FALSE;
enumErrorCode eResult = ERR_WAE_WMLS_NONE;
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pMode=OpS_Pop(OpS);
pstructVar pNumber=OpS_Pop(OpS);
/* Check if the number parameter is a string and the mode parameter
is an integer. */
if ( (Var_Convert( pNumber, typeString )==VCR_OK) &&
(Var_Convert( pMode, typeInteger )==VCR_OK) )
{
/* Check mode */
if ((pMode->val.theInt==1)||(pMode->val.theInt==0))
{
/* Convert to CHAR */
pbStr = wip_wchar2byte( pNumber->val.theString, &fOverflow );
if (! fOverflow)
{
/* Call wtai function */
WTAIa_voiceCallSetup ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (const CHAR*)pbStr); /* objectId, wtaChannelId, number */
OpS_Push(OpS, &pMode);
eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
}
DEALLOC( &pbStr );
}
}
Var_Delete( &pNumber );
Var_Delete( &pMode );
return eResult;
}
return ERR_WAE_WMLS_LIB;
}
enumErrorCode
WTAI_NC_VC_setup_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
pwcFieldValue=pwcFieldValue;
if (OpS!=NULL)
{
/* Create result variable */
pstructVar pResult = Var_New();
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pMode = OpS_Pop(OpS);
if ( (iResult >= 0) && (Var_Convert( pMode, typeInteger )==VCR_OK) )
{
if ( pMode->val.theInt==0 )
{
AddCall(& pWTAControlStruct->pCallList, (INT8)iResult);
}
Var_AssignInt(pResult, iResult);
}
else
{
Var_AssignInvalid(pResult);
}
Var_Delete( &pMode );
OpS_Push(OpS, &pResult);
return ERR_WAE_WMLS_NONE;
}
return ERR_WAE_WMLS_LIB;
}
/* voiceCallAccept(callHandle, mode); */
enumErrorCode
WTAI_NC_VC_accept (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
if (OpS!=NULL)
{
enumErrorCode eResult = ERR_WAE_WMLS_NONE;
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pMode=OpS_Pop(OpS);
pstructVar pCallId=OpS_Pop(OpS);
/* Check if the id parameter is a integer less than 128 (INT8) */
if ( (Var_Convert(pCallId, typeInteger)==VCR_OK) &&
(pCallId->val.theInt<128) )
{
/* Call wtai function */
WTAIa_voiceCallAccept ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT8)pCallId->val.theInt );
OpS_Push( OpS, &pMode );
eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
}
Var_Delete( &pMode );
Var_Delete( &pCallId );
return eResult;
}
return ERR_WAE_WMLS_LIB;
}
enumErrorCode
WTAI_NC_VC_accept_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
pwcFieldValue=pwcFieldValue;
if (OpS!=NULL)
{
/* Create result variable */
pstructVar pResult=Var_New();
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pMode=OpS_Pop(OpS);
if ( (iResult == WTA_SUCCESS) && (Var_Convert( pMode, typeInteger )==VCR_OK) )
{
if ( pMode->val.theInt==0 )
{
AddCall(& pWTAControlStruct->pCallList, (INT8)iResult);
}
Var_NewString( pResult, 0 ); /* Create an empty string */
}
else
{
/* invalid will be the result if the function fails */
Var_AssignInvalid( pResult );
}
Var_Delete( &pMode );
OpS_Push( OpS, &pResult );
return ERR_WAE_WMLS_NONE;
}
return ERR_WAE_WMLS_LIB;
}
/* voiceCallRelease(callHandle); */
enumErrorCode
WTAI_NC_VC_release (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
if (OpS!=NULL)
{
enumErrorCode eResult=ERR_WAE_WMLS_NONE;
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pCallId=OpS_Pop(OpS);
/* Check if the id parameter is a integer less than 128 (INT8) */
if ( (Var_Convert(pCallId, typeInteger)==VCR_OK) && (pCallId->val.theInt<128) )
{
/* Call wtai function */
WTAIa_voiceCallRelease ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT8)pCallId->val.theInt );
eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
}
Var_Delete( &pCallId );
return eResult;
}
return ERR_WAE_WMLS_LIB;
}
enumErrorCode
WTAI_NC_VC_release_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
pWTAControlStruct=pWTAControlStruct;
pwcFieldValue=pwcFieldValue;
if (OpS!=NULL)
{
pstructVar pResult=Var_New();
if ( iResult == WTA_SUCCESS)
{
Var_NewString( pResult, 0 ); /* Create an empty string */
}
else
{
Var_AssignInvalid(pResult);
}
OpS_Push(OpS, &pResult);
return ERR_WAE_WMLS_NONE;
}
return ERR_WAE_WMLS_LIB;
}
/* voiceCallsendDTMF(callHandle, dtmf); */
enumErrorCode
WTAI_NC_VC_sendDTMF (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
BYTE* pbStr=NULL;
if (OpS!=NULL)
{
enumErrorCode eResult=ERR_WAE_WMLS_NONE;
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pDtmf=OpS_Pop(OpS);
pstructVar pId=OpS_Pop(OpS);
/* Check if the dtmf parameter is a string and the id is an integer */
if (( Var_Convert(pDtmf, typeString)==VCR_OK ) &&
( Var_Convert(pId, typeInteger)==VCR_OK ) &&
(pId->val.theInt < 128) )
{
BOOL fOverflow=FALSE;
/* Convert to CHAR */
pbStr = wip_wchar2byte( pDtmf->val.theString, &fOverflow );
if (! fOverflow)
{
/* Call wtai function */
WTAIa_voiceCallSendDTMF (iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT8)pId->val.theInt, (const CHAR*)pbStr);
eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
}
DEALLOC( &pbStr );
}
Var_Delete( &pDtmf );
Var_Delete( &pId );
return eResult;
}
return ERR_WAE_WMLS_LIB;
}
enumErrorCode
WTAI_NC_VC_sendDTMF_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
pWTAControlStruct=pWTAControlStruct;
pwcFieldValue=pwcFieldValue;
if (OpS!=NULL)
{
pstructVar pResult=Var_New();
if ( iResult == WTA_SUCCESS)
{
Var_NewString( pResult, 0 ); /* Create an empty string */
}
else
{
Var_AssignInvalid(pResult);
}
OpS_Push(OpS, &pResult);
return ERR_WAE_WMLS_NONE;
}
return ERR_WAE_WMLS_LIB;
}
CallStatusType WTAI_GetCallStatusType (WCHAR* pwchString, BOOL* pfError)
{
WCHAR pwchWtai_Number[]={'n','u','m','b','e','r',0};
WCHAR pwchWtai_Status[]={'s','t','a','t','u','s',0};
WCHAR pwchWtai_Mode[]={'m','o','d','e',0};
WCHAR pwchWtai_Name[]={'n','a','m','e',0};
WCHAR pwchWtai_Duration[]={'d','u','r','a','t','i','o','n',0};
if (pwchString!=NULL)
{
if (COMPARESTRING(pwchString,pwchWtai_Number)==0)
{
return WTA_VC_CS_NUMBER;
}
else if (COMPARESTRING(pwchString,pwchWtai_Status)==0)
{
return WTA_VC_CS_STATUS;
}
else if (COMPARESTRING(pwchString,pwchWtai_Mode)==0)
{
return WTA_VC_CS_MODE;
}
else if (COMPARESTRING(pwchString,pwchWtai_Name)==0)
{
return WTA_VC_CS_NAME;
}
else if (COMPARESTRING(pwchString,pwchWtai_Duration)==0)
{
return WTA_VC_CS_DURATION;
}
}
/* Modified by GBU,000524, changed order of statements
return 0;
*pfError=TRUE;
*/
*pfError=TRUE;
return 0;
}
/* voiceCallCallStatus (callHandle, field); */
enumErrorCode
WTAI_NC_VC_callStatus (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
if (OpS!=NULL)
{
enumErrorCode eResult=ERR_WAE_WMLS_NONE;
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pField=OpS_Pop(OpS);
pstructVar pCallId=OpS_Pop(OpS);
/* Check if the parameter pField is a string and if the pCallId is an
integer (handle to the call) */
if ((Var_Convert(pField, typeString)==VCR_OK)&&(Var_Convert(pCallId, typeInteger)==VCR_OK))
{
CallStatusType stField;
BOOL fError;
/* Check if the id parameter is less than 128 (INT8) */
if ( pCallId->val.theInt < 128 )
{
/* Transform the field string to an enum */
stField=WTAI_GetCallStatusType (pField->val.theString,&fError);
if (!fError)
{
/* Call wtai function */
WTAIa_voiceCallCallStatus ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT8)pCallId->val.theInt,stField);
eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
}
}
}
Var_Delete( &pCallId );
Var_Delete( &pField );
return eResult;
}
return ERR_WAE_WMLS_LIB;
}
enumErrorCode
WTAI_NC_VC_callStatus_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
enumErrorCode eResult=ERR_WAE_WMLS_LIB;
pWTAControlStruct=pWTAControlStruct;
if (OpS!=NULL)
{
pstructVar pResult=Var_New();
if ( (iResult==WTA_SUCCESS) )
{
if (pwcFieldValue==NULL)
{
Var_NewString( pResult, 0 ); /* Create an empty string */
}
else
{
WCHAR* pwcFieldValueCopy=NULL;
/* Copy string */
pwcFieldValueCopy = (WCHAR*)(GenCopyString (2,pwcFieldValue));
if (pwcFieldValueCopy != NULL)
{
/* OK - store string in result (string is NOT copied) */
Var_AssignStringDirect( pResult,
STRINGLENGTH( pwcFieldValueCopy ), &pwcFieldValueCopy );
}
}
}
else
{
Var_AssignInvalid(pResult);
}
/* Push result onto stack */
OpS_Push( OpS, &pResult );
eResult=ERR_WAE_WMLS_NONE;
}
if (pwcFieldValue!=NULL)
{
/* Delete incoming string */
#ifdef USE_WIP_MALLOC
wip_free(pwcFieldValue);
#else
free(pwcFieldValue);
#endif
}
return eResult;
}
/* voiceCallList (returnFirst); */
enumErrorCode
WTAI_NC_VC_list (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
if (OpS!=NULL)
{
enumErrorCode eResult=ERR_WAE_WMLS_NONE;
/* Get parameters from Opstack NOTE! The "popping"-order is
important */
pstructVar pReturnFirst=OpS_Pop(OpS);
/* Check if the parameter if the pCallId is an integer (handle to the call) */
if (Var_Convert(pReturnFirst, typeInteger)==VCR_OK)
{
/* Call wtai function */
WTAIa_voiceCallList ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (BOOL)pReturnFirst->val.theInt );
eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
}
Var_Delete( &pReturnFirst );
return eResult;
}
return ERR_WAE_WMLS_LIB;
}
enumErrorCode
WTAI_NC_VC_list_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
pWTAControlStruct=pWTAControlStruct;
pwcFieldValue=pwcFieldValue;
if (OpS!=NULL)
{
pstructVar pResult=Var_New();
if ( iResult >= 0 )
{
Var_AssignInt(pResult, iResult); /* return a callHandle */
}
else
{
Var_AssignInvalid(pResult); /* return invalid */
}
OpS_Push(OpS, &pResult);
return ERR_WAE_WMLS_NONE;
}
return ERR_WAE_WMLS_LIB;
}
/* Network Text **********************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -