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

📄 si_wtaic.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
		   and pField is a string */ 
		if (( Var_Convert (pIndex, typeInteger ) == VCR_OK ) &&
			( Var_Convert (pField, typeString ) == VCR_OK ) &&
			( pIndex->val.theInt < 32768 ) )
		{
			BOOL fError;
			PhoneBookGetType stField = WTAI_GetPhoneBookType ( pField->val.theString, &fError );

			if (!fError)
			{
				/* Call wtai function */
				WTAIa_phoneBookGetFieldValue ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT16)pIndex->val.theInt, stField );
				eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
			}
		}
		Var_Delete( &pField );
		Var_Delete( &pIndex );

		return eResult;
	}
	return ERR_WAE_WMLS_LIB;
}

enumErrorCode 
WTAI_NC_PB_getFieldValue_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);
				}
			}
		}
		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;
}

PhoneBookChangeType WTAI_ChangePhoneBookType (WCHAR* pwchString, BOOL* pfError)
{
	WCHAR pwchWtai_Name[]={'n','a','m','e',0};
	WCHAR pwchWtai_Number[]={'n','u','m','b','e','r',0};

    *pfError=FALSE;

	if (pwchString!=NULL)
	{
		if (COMPARESTRING(pwchString,pwchWtai_Name)==0) 
		{
			return WTA_PB_CHANGE_NAME;
		} 
		else if (COMPARESTRING(pwchString,pwchWtai_Number)==0) 
		{
			return WTA_PB_CHANGE_NUMBER;
		} 
	}

    *pfError=TRUE;
    return 0;
}

/* phoneBookChange(index, field, newValue); */
enumErrorCode 
WTAI_NC_PB_change (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 pValue=OpS_Pop(OpS);
		pstructVar pField=OpS_Pop(OpS);
		pstructVar pIndex=OpS_Pop(OpS);

		/* Check if the parameter can be converted and
		   if pIndex is a integer less than 32768 (INT16) */ 
		if (( Var_Convert (pIndex, typeInteger ) == VCR_OK ) &&
			( Var_Convert (pValue, typeString  ) == VCR_OK ) &&
			( Var_Convert (pField, typeString  ) == VCR_OK ) &&
			( pIndex->val.theInt < 32768 ) )
		{
			BOOL fError;
			PhoneBookChangeType stField = WTAI_ChangePhoneBookType (pField->val.theString, &fError);

			if (!fError)
			{
				/* Call wtai function */
				WTAIa_phoneBookChange ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT16)pIndex->val.theInt,
											 stField, pValue->val.theString);
				eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
			}
		}
		Var_Delete( &pIndex );
		return eResult;
	}
	return ERR_WAE_WMLS_LIB;
}
enumErrorCode 
WTAI_NC_PB_change_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 if ( iResult == WTA_INVALID )
		{
			Var_AssignInvalid(pResult);
		}
		else /* Errorcode */
		{
			Var_AssignInt(pResult, iResult);
		}

		OpS_Push(OpS, &pResult);
		return ERR_WAE_WMLS_NONE;
	}
	return ERR_WAE_WMLS_LIB;
}

/* Call Logs **************************************************************/

/*	Help function for call logs 
	
	iFunction:
	
	  1 = WTAIa_callLogDialled
	  2 = WTAIa_callLogMissed
	  3 = WTAIa_callLogReceived
				
*/
enumErrorCode 
WTAI_NC_CL_HelpFunction (pstructOpS OpS, UINT8 iFunction, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	if (OpS!=NULL)
	{
		/* Get parameters from Opstack NOTE! The "popping"-order is 
		   important */
		pstructVar pReturnFirst=OpS_Pop(OpS);
	
		/* Check if the pReturnFirst is an integer */
		if (Var_Convert( pReturnFirst, typeInteger ) == VCR_OK )
		{
			/* Call wtai function */
			switch (iFunction)
			{
			case 1:
				WTAIa_callLogDialled ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (BOOL)pReturnFirst->val.theInt );
				break;
			case 2:
				WTAIa_callLogMissed ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (BOOL)pReturnFirst->val.theInt );
				break;
			case 3:
				WTAIa_callLogReceived ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (BOOL)pReturnFirst->val.theInt );
				break;
			}	
		}
		Var_Delete( &pReturnFirst );

		return ERR_WAE_WMLS_NONE;
	}

	return ERR_WAE_WMLS_LIB;
}


/* dialled (id); */
enumErrorCode 
WTAI_NC_CL_dialled (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	/* 1 = WTAIa_callLogDialled */
	return WTAI_NC_CL_HelpFunction (OpS, 1, pWTAControlStruct, iObjectID);
}
enumErrorCode 
WTAI_NC_CL_dialled_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
	pWTAControlStruct=pWTAControlStruct;
	iResult=iResult;
	pwcFieldValue=pwcFieldValue;

	if (OpS!=NULL)
	{
		pstructVar pResult=Var_New();

		if ( iResult == WTA_INVALID )
		{
			Var_AssignInvalid(pResult);
		}
		else /* logHandle entry index */
		{
			Var_AssignInt(pResult, iResult);
		}

		OpS_Push(OpS, &pResult);
		return ERR_WAE_WMLS_NONE;
	}
	return ERR_WAE_WMLS_LIB;
}

/* missed (id); */
enumErrorCode 
WTAI_NC_CL_missed (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	/* 2 = WTAIa_callLogMissed */
	return WTAI_NC_CL_HelpFunction (OpS, 2, pWTAControlStruct, iObjectID);
}
enumErrorCode 
WTAI_NC_CL_missed_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
	pWTAControlStruct=pWTAControlStruct;
	iResult=iResult;
	pwcFieldValue=pwcFieldValue;

	if (OpS!=NULL)
	{
		pstructVar pResult=Var_New();

		if ( iResult == WTA_INVALID )
		{
			Var_AssignInvalid(pResult);
		}
		else /* logHandle entry index */
		{
			Var_AssignInt(pResult, iResult);
		}

		OpS_Push(OpS, &pResult);
		return ERR_WAE_WMLS_NONE;
	}
	return ERR_WAE_WMLS_LIB;
}

/* received (id); */
enumErrorCode 
WTAI_NC_CL_received (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	/* 3 = WTAIa_callLogReceived */
	return WTAI_NC_CL_HelpFunction (OpS, 3, pWTAControlStruct, iObjectID);
}
enumErrorCode 
WTAI_NC_CL_received_finish (pstructOpS OpS, pWTACONTROL pWTAControlStruct, int iResult, WCHAR* pwcFieldValue)
{
	pWTAControlStruct=pWTAControlStruct;
	iResult=iResult;
	pwcFieldValue=pwcFieldValue;

	if (OpS!=NULL)
	{
		pstructVar pResult=Var_New();

		if ( iResult == WTA_INVALID )
		{
			Var_AssignInvalid(pResult);
		}
		else /* logHandle entry index */
		{
			Var_AssignInt(pResult, iResult);
		}

		OpS_Push(OpS, &pResult);
		return ERR_WAE_WMLS_NONE;
	}
	return ERR_WAE_WMLS_LIB;
}

CallLogGetType WTAI_GetCallLogType (WCHAR* pwchString, BOOL* pfError)
{
	WCHAR pwchWtai_Number[]={'n','u','m','b','e','r',0};
	WCHAR pwchWtai_Tstamp[]={'t','s','t','a','m','p',0};
	WCHAR pwchWtai_explanation[]={'e','x','p','l','a','n','a','t','i','o','n',0};

	if (pwchString!=NULL)
	{
		if (COMPARESTRING(pwchString,pwchWtai_Number)==0) 
		{
			return WTA_CL_GET_NUMBER;
		} 
		else if (COMPARESTRING(pwchString,pwchWtai_Tstamp)==0) 
		{
			return WTA_CL_GET_TSTAMP;
		} 
		else if (COMPARESTRING(pwchString,pwchWtai_explanation)==0) 
		{
			return WTA_CL_GET_EXPLANATION;
		} 
	}

    *pfError=TRUE;
    return 0;
}


/* callLogGetFieldValue(logHandle,field);*/
enumErrorCode 
WTAI_NC_CL_getFieldValue (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 pLogHandle=OpS_Pop(OpS);

		/* Check if the pField is a string and 
		   the pLogHandle is an integer less than 32768 (INT16) */
		if (( Var_Convert( pField, typeString      ) == VCR_OK ) &&
			( Var_Convert( pLogHandle, typeInteger ) == VCR_OK ) &&
			( pLogHandle->val.theInt < 32768 ) )
		{
			CallLogGetType stField;
			BOOL fError;

			/* Transform the field string to an enum */
			stField=WTAI_GetCallLogType (pField->val.theString,&fError);

			if (!fError)
			{
				/* Call wtai function */
				WTAIa_callLogGetFieldValue ( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT16)pLogHandle->val.theInt, stField );
				eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
			}
		}

		Var_Delete( &pField );
		Var_Delete( &pLogHandle );
		return eResult;
	}

	return ERR_WAE_WMLS_LIB;
}
enumErrorCode 
WTAI_NC_CL_getFieldValue_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;
}

/* Miscelleaneous *********************************************************/

/* miscSetIndicator(type, newState); */
enumErrorCode 
WTAI_NC_MISC_indication (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 pNewState=OpS_Pop(OpS);
		pstructVar pType=OpS_Pop(OpS);

		/* Check if the variables can be converted to integers
		   and if pType and pNewState is less than 128 (INT8) */
		if ((Var_Convert( pType, typeInteger ) == VCR_OK) &&
			(Var_Convert( pNewState, typeInteger ) == VCR_OK) &&
			(pType->val.theInt < 128) &&
			(pNewState->val.theInt < 128) )
		{
			/* Check if integers within bounds */
			if ((pType->val.theInt >=0) && (pType->val.theInt <= 7 ) &&
				(pNewState->val.theInt >= 0) )
			{
				/* Call wtai function */
				WTAIa_miscSetIndicator( iObjectID, pWTAControlStruct->pwchWTAChannelId, (INT8)pType->val.theInt,
										(INT8)pNewState->val.theInt );
				eResult=ERR_WAE_WMLS_WTAI_FUNC_CALLED;
			}
		}

		Var_Delete( &pNewState );
		Var_Delete( &pType );

		return eResult;
	}

	return ERR_WAE_WMLS_LIB;
}
enumErrorCode 
WTAI_NC_MISC_indication_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;
}

/* MiscEndContext ()*/
enumErrorCode 
WTAI_NC_MISC_endcontext (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	iObjectID=iObjectID;

	if (OpS!=NULL)
	{
		pstructVar pResult=Var_New();	

		/* End context () */
		pWTAControlStruct->fEndContext = TRUE;

		Var_NewString( pResult, 0 ); /* Create an empty string */

		OpS_Push(OpS, &pResult);
		return ERR_WAE_WMLS_WTAI_RESULT;
	}
	return ERR_WAE_WMLS_LIB;
}

/* MiscGetProtection () */
enumErrorCode
WTAI_NC_MISC_getProtection (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	iObjectID=iObjectID;

	if (OpS!=NULL)
	{
		pstructVar pResult=Var_New();	

		if (pWTAControlStruct->fContextProtected == TRUE)
		{
			Var_AssignInt(pResult, TRUE);
		}
		else
		{
			Var_AssignInt(pResult, FALSE);
		}
		OpS_Push(OpS, &pResult);
		return ERR_WAE_WMLS_WTAI_RESULT;
	}
	return ERR_WAE_WMLS_LIB;
}

/* MiscSetProtection (mode); */
enumErrorCode 
WTAI_NC_MISC_setProtection (pstructOpS OpS, pWTACONTROL pWTAControlStruct, UINT8 iObjectID)
{
	pWTAControlStruct->fContextProtected = TRUE;
	iObjectID=iObjectID;

	if (OpS!=NULL)
	{
		pstructVar pResult=Var_New();

		/* Get parameters from Opstack NOTE! The "popping"-order is 
		   important */
		pstructVar pMode=OpS_Pop(OpS);
	
		/* Check if the pMode is an integer */
		if (Var_Convert( pMode, typeInteger ) == VCR_OK)
		{
			/* Call wtai function */
			if (pMode->val.theInt==0)
			{
				/* Do not protect context */
				pWTAControlStruct->fContextProtected=FALSE;
			}
			else if (pMode->val.theInt==1)
			{
				/* Protect context */
				pWTAControlStruct->fContextProtected=TRUE;
			}

		}

		Var_NewString( pResult, 0 ); /* Create an empty string */
		/* Push result onto stack */
		OpS_Push( OpS, &pResult );

		Var_Delete( &pMode );
		Var_Delete( &pResult );
		return ERR_WAE_WMLS_WTAI_RESULT;
	}
	
	return ERR_WAE_WMLS_LIB;
}

⌨️ 快捷键说明

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