📄 supsvc.cpp
字号:
szWalk = BeginLineSpecificCommand(szCmd, MAX_PATH, 0);
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,4", nValue);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
} else {
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,4,,,%u", nValue, dwClass);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
}
(void)strncpyz(szWalk, "\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_REMOVECALLFORWARDING, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetCallForwardingStatus(DWORD dwParam, DWORD dwReason, DWORD dwInfoClasses, DWORD dwStatus)
{
FUNCTION_TRACE(RILDrv_SetCallForwardingStatus);
RILRetailTrace((TEXT("+RILDrv_SetCallForwardingStatus()!\r\n")));
UINT i;
UINT nValue;
DWORD dwClass = 0;
char szCmd[MAX_PATH];
LPSTR szWalk = szCmd;
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// Check thet the stsatus value is in the correct range
if (RIL_SVCSTAT_DISABLED != dwStatus && RIL_SVCSTAT_ENABLED != dwStatus) {
hr = E_INVALIDARG;
goto Error;
}
// Determine the reason value
for (i = 0; i < NUM_FWDREASONS; i++) {
if (dwReason == g_rgdwFwdReasons[i]) {
nValue = i;
break;
}
}
if (NUM_FWDREASONS == i) {
hr = E_INVALIDARG;
goto Error;
}
szWalk = BeginLineSpecificCommand(szCmd, MAX_PATH, 0);
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
//(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,%u", nValue, (RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1));
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,%u,,,%u", nValue,
(RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1), 1);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
} else {
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCFC=%u,%u,,,%u", nValue,
(RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1), dwClass);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
}
(void)strncpyz(szWalk, "\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_SETCALLFORWARDINGSTATUS, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
static HRESULT ParseGetCallWaitingSettings(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetCallWaitingSettings);
UINT i;
UINT nStatus;
UINT nValue;
DWORD* pdwInfoClasses = NULL;
HRESULT hr = S_OK;
pBlob = NULL;
cbBlob = 0;
pdwInfoClasses = (DWORD*)AllocBlob(sizeof(DWORD));
if (!pdwInfoClasses) {
hr = E_OUTOFMEMORY;
goto Error;
}
memset(pdwInfoClasses, 0x00, sizeof(DWORD));
// Parse "<prefix>"
if (!ParseRspPrefix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
// Parse "+CCWA: "
while (MatchStringBeginning(szRsp, "+CCWA: ", szRsp)) {
// Parse "<status>,<class>"
if (!ParseUInt(szRsp, TRUE, nStatus, szRsp) ||
!MatchStringBeginning(szRsp, ",", szRsp) ||
!ParseUInt(szRsp, TRUE, nValue, szRsp)) {
goto Continue;
}
if (1 == nStatus) {
// Set all required info classes bits
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (nValue & (0x01 << i)) {
*pdwInfoClasses |= g_rgdwInfoClasses[i];
}
}
}
Continue:
// Find "<postfix>"
if (!FindRspPostfix(szRsp, szRsp)) {
hr = E_FAIL;
goto Error;
}
}
pBlob = (void*)pdwInfoClasses;
cbBlob = sizeof(DWORD);
Error:
if (FAILED(hr)) {
FreeBlob(pdwInfoClasses);
}
return hr;
}
//
//
//
HRESULT RILDrv_GetCallWaitingSettings(DWORD dwParam, DWORD dwInfoClasses)
{
char szBuf[50];
UINT i;
DWORD dwClass = 0;
FUNCTION_TRACE(RILDrv_GetCallWaitingSettings);
RILRetailTrace((TEXT("+RILDrv_GetCallWaitingSettings!\r\n")));
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
strcpy(szBuf, "AT+CCWA=,2\r");
}
else {
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
#ifdef EMP_DRIVER
// EMP only supports voice (1), data (2) or combination (3)
if ((1 != dwClass) && (2 != dwClass) && (3 != dwClass))
{
hr = E_NOTIMPL;
goto Error;
}
#endif
#ifdef PHILIP_DRIVER
sprintf(szBuf, "AT+CCWA=,2\r");
#else
sprintf(szBuf, "AT+CCWA=,2,%u\r", dwClass);
#endif
}
if (!QueueCmd(pHandle, szBuf, CMDOPT_NONE, APIID_GETCALLWAITINGSETTINGS, ParseGetCallWaitingSettings, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetCallWaitingStatus(DWORD dwParam, DWORD dwInfoClasses, DWORD dwStatus)
{
FUNCTION_TRACE(RILDrv_SetCallWaitingStatus);
RILRetailTrace((TEXT("+RILDrv_SetCallWaitingStatus()!\r\n")));
UINT i;
DWORD dwClass = 0;
char szCmd[MAX_PATH];
LPSTR szWalk = szCmd;
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// Check that the status value is in the correct range
if (RIL_SVCSTAT_DISABLED != dwStatus && RIL_SVCSTAT_ENABLED != dwStatus) {
hr = E_INVALIDARG;
goto Error;
}
// unspecified infoclass is treated as default
if ((RIL_INFOCLASS_NONE == dwInfoClasses) || ((RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX) == dwInfoClasses)) {
(void)_snprintfz(szCmd, MAX_PATH, "AT+CCWA=%u,%u", (RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1),(RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1));
szWalk = strchr(szCmd, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
} else {
(void)strncpyz(szCmd, "AT", MAX_PATH);
szWalk += 2;
for (i = 0 ; i < NUM_INFOCLASSES; i++) {
if (dwInfoClasses & g_rgdwInfoClasses[i]) {
dwClass |= (0x01 << i);
}
}
#ifdef EMP_DRIVER
// EMP only supports voice (1), data (2) or their combination (3)
if ((1 != dwClass) && (2 != dwClass) && (3 != dwClass))
{
hr = E_NOTIMPL;
goto Error;
}
#endif
#ifdef PHILIP_DRIVER
dwClass = 1;
#endif
(void)_snprintfz(szWalk, MAX_PATH - (szWalk - szCmd), "+CCWA=%u,%u,%u",(RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1),(RIL_SVCSTAT_DISABLED == dwStatus ? 0 : 1),
dwClass);
szWalk = strchr(szWalk, '\0'); // NO_TYPO: 27
DEBUGCHK(NULL != szWalk);
}
(void) strncpyz(szWalk, "\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
if (!QueueCmd(pHandle, szCmd, CMDOPT_NONE, APIID_SETCALLWAITINGSTATUS, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
// Send a USSD string.
//
// lpbData -- points to a Unicode string
// dwSize -- size (in bytes) of Unicode string
//
HRESULT RILDrv_SendSupServiceData(DWORD dwParam, const BYTE* lpbData, DWORD dwSize)
{
RILRetailTrace((TEXT("+RILDrv_SendSupServiceData()!\r\n")));
FUNCTION_TRACE(RILDrv_SendSupServiceData);
DEBUGCHK(NULL != lpbData);
DEBUGCHK(0 != dwSize);
DEBUGCHK(2 == sizeof(WCHAR)); // for >>1 to substitute /sizeof(WCHAR)
char szCmd[MAX_PATH+1]; // Add one to the buffer so that we can pass in the address to AppendQuotedEncodedString without Prefix error.
HRESULT hr = S_OK;
LPSTR szWalk = szCmd;
const char pszCUSDPostfix[] = ",15\r"; // 15 = default alphabet, language unspecified
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle || !lpbData) {
hr = E_FAIL;
goto Error;
}
// Use this code for +CSCS settings that don't require us to modify the data bytes (including the one in our init string)
(void)strncpyz(szWalk, "AT+CUSD=1,", MAX_PATH);
szWalk = strchr(szCmd, '\0'); // Guaranteed to succeed thanks to _strcpyz
DEBUGCHK(0 != szWalk);
// Convert the Unicode into the current TE character set.
// This copies directly into the command string buffer.
if (!AppendQuotedEncodedString(ENCODING_TECHARSET, (LPCWSTR)lpbData, szWalk, (PUCHAR)&szCmd[MAX_PATH], FALSE))
{
hr = E_FAIL;
goto Error;
}
if ( (szWalk + sizeof(pszCUSDPostfix)) > &szCmd[MAX_PATH])
{
hr = E_FAIL;
goto Error;
}
// Append the command postfix after the string we just copied
(void)strncpyz(szWalk, ",15\r", MAX_PATH - (szWalk - szCmd)); // NO_TYPO: 30
if (!QueueCmd(pHandle, szCmd, CMDOPT_SUPPRESSLOGGING, APIID_SENDSUPSERVICEDATA, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
//
//
//
HRESULT RILDrv_CancelSupServiceDataSession(DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_CancelSupServiceDataSession);
HRESULT hr = S_OK;
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
if (!QueueCmd(pHandle, "AT+CUSD=2\r", CMDOPT_NONE, APIID_CANCELSUPSERVICEDATASESSION, NULL, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
Error:
return hr;
}
static HRESULT ParseGetHideConnectedIdSettings(LPCSTR szRsp, void*& pBlob, UINT& cbBlob)
{
FUNCTION_TRACE(ParseGetHideConnectedIdSettings);
RILHIDECONNECTEDIDSETTINGS* phcids = NULL;
HRESULT hr = S_OK;
UINT nValue;
pBlob = NULL;
cbBlob = 0;
// Parse "<prefix>%COLR: <status>"
if (!ParseRspPrefix(szRsp, szRsp) ||
!MatchStringBeginning(szRsp, "%COLR: ", szRsp)) {
hr = E_FAIL;
goto Error;
}
if ( !ParseUInt(szRsp, TRUE, nValue, szRsp) )
{
nValue = -1;
}
phcids = (RILHIDECONNECTEDIDSETTINGS*)AllocBlob(sizeof(RILHIDECONNECTEDIDSETTINGS));
if (!phcids) {
hr = E_OUTOFMEMORY;
goto Error;
}
memset(phcids, 0x00, sizeof(RILHIDECONNECTEDIDSETTINGS));
phcids->cbSize = sizeof(RILHIDECONNECTEDIDSETTINGS);
phcids->dwStatus = RIL_SVCSTAT_DEFAULT ;
switch ( nValue )
{
case -1: // COLR Status Not Present
phcids->dwProvisioning = RIL_SVCPROV_NOTPROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
break;
case 0: // COLR Status Not Provided
phcids->dwProvisioning = RIL_SVCPROV_NOTPROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
break;
case 1: // COLR Status Provided
phcids->dwProvisioning = RIL_SVCPROV_PROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_ENABLED ;
break;
case 2: // COLR Status Unknown
phcids->dwProvisioning = RIL_SVCPROV_NOTPROVISIONED;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
break;
default:
phcids->dwProvisioning = RIL_SVCPROV_UNKNOWN;
phcids->dwStatus = RIL_SVCSTAT_DISABLED ;
}
phcids->dwParams |= RIL_PARAM_HCIDS_PROVISIONING;
phcids->dwParams |= RIL_PARAM_HCIDS_STATUS;
pBlob = (void*)phcids;
cbBlob = sizeof(RILHIDECONNECTEDIDSETTINGS);
Error:
if (FAILED(hr)) {
FreeBlob(phcids);
}
return hr;
}
//
// Get COLR status
//
HRESULT RILDrv_GetHideConnectedIdSettings(DWORD dwParam)
{
FUNCTION_TRACE(RILDrv_GetHideConnectedIdSettings);
HRESULT hr = S_OK;
#ifdef EMP_DRIVER
// This feature is not supported on EMP platform
hr = E_NOTIMPL;
goto Error;
#else
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
// COLR get MMI GSM 2.30
if (!QueueCmd(pHandle, "ATD*#77#;\r", CMDOPT_NONE, APIID_SENDSUPSERVICEDATA, ParseGetHideConnectedIdSettings, NULL, hr)) {
hr = E_FAIL;
goto Error;
}
#endif
Error:
return hr;
}
//
//
//
HRESULT RILDrv_SetHideConnectedIdStatus(DWORD dwParam, DWORD dwParam2)
{
FUNCTION_TRACE(RILDrv_GetHideConnectedIdSettings);
HRESULT hr = S_OK;
#ifdef EMP_DRIVER
// This feature is not supported on EMP platform
hr = E_NOTIMPL;
goto Error;
#else
CRilInstanceHandle* pHandle = ExtractHandle(dwParam);
if (!pHandle) {
hr = E_FAIL;
goto Error;
}
if ( RIL_SVCSTAT_DISABLED == dwParam2 )
{
if (!QueueCmd(pHandle, "ATD#77#;\r", CMDOPT_NONE, APIID_SENDSUPSERVICEDATA, NULL, NULL, hr)) {
hr = E_FAIL;
}
}
else if ( RIL_SVCSTAT_ENABLED == dwParam2 )
{
if (!QueueCmd(pHandle, "ATD*77#;\r", CMDOPT_NONE, APIID_SENDSUPSERVICEDATA, NULL, NULL, hr)) {
hr = E_FAIL;
}
}
else
{
hr = E_FAIL;
}
#endif
Error:
return hr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -