?? rilsimtkit.cpp
字號:
}
// Parse optional Icon Identifier
if ((m_dwParseLen > 0) && ((*m_lpbParse & 0x7f) == (BYTE)ICONTAG))
{
m_lpbParse++;
m_dwParseLen--;
hr = ReadIconIdentifier();
if (FAILED(hr))
{
// Failure
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Function for TLV IconID failed while parsing Open Channel.\r\n")));
dwRetVal = SIM_RESPONSE_ERR_VALUESMISSING;
goto Exit;
}
}
// The next TLV tag will determine how the rest of the Open Channel command is parsed.
switch ((*(m_lpbParse) & 0x7f))
{
case SIMTK_OPENCHANNEL_CS:
hr = ByteParseOpenChannelCS(&dwRetVal);
break;
case SIMTK_OPENCHANNEL_GPRS:
hr = ByteParseOpenChannelGPRS(&dwRetVal);
break;
default:
// We don't know this Open Channel command, so we have to fail
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : SIMTKit: SimToolkit Open Channel parsing encountered unknown firs tag 0x%x\r\n"), *m_lpbParse));
dwRetVal = SIM_RESPONSE_ERR_COMMANDTYPE;
goto Exit;
}
if (FAILED(hr))
{
dwRetVal = SIM_RESPONSE_ERR_VALUESMISSING;
goto Exit;
}
}
else
{
// Now we're ready for some TLVs -- which TLVs we need depends on which code we have, so let's
// go through our array to see which TLVs we are interested in
pdwTLV = (DWORD *) g_rgdwTLV;
while (*pdwTLV && (pdwTLV[1] != dwNotifyCode))
{
// Skip to the next command
pdwTLV += (*pdwTLV);
}
if (!(*pdwTLV))
{
// We don't know this command, so we have to fail
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : SIMTKit: SimToolkit encountered unknown command %x\r\n"), dwNotifyCode));
dwRetVal = SIM_RESPONSE_ERR_COMMANDTYPE;
goto Exit;
}
// OK, let's go through now and see if we have each of the needed TLVs
numTLVs = ( (*pdwTLV > 1) ? (*pdwTLV - 2) : 0 );
pdwTLV += 2;
for (i = 0; i < numTLVs; i++)
{
dwTag = (pdwTLV[i] & ~OPTIONALTAG);
// Only pay attention to the lower 7 bits...
if ((m_dwParseLen == 0) || ((*m_lpbParse & 0x7f) != (BYTE) dwTag))
{
// Nope, this isn't this tag -- this is OK, so long as this is optional,
// otherwise, we have a failure on our hands
if (!(pdwTLV[i] & OPTIONALTAG))
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : SIMTKit: Mandatory TLV %x not found\r\n"), dwTag));
dwRetVal = SIM_RESPONSE_ERR_COMMANDDATA;
goto Exit;
}
}
else if (m_dwParseLen > 0)
{
// Great, let's process this one. Good thing we have an array which tells us
// which function to call, that's very useful
DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : SIMTKit: Processing tag %x\r\n"), dwTag));
m_lpbParse++;
m_dwParseLen--;
hr = (this->*rglpfnParse[dwTag])();
if (FAILED(hr))
{
// Failure
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Function for TLV %x failed\r\n"), (pdwTLV[i] & ~OPTIONALTAG)));
dwRetVal = SIM_RESPONSE_ERR_VALUESMISSING;
goto Exit;
}
}
}
// Special handling for SETUP CALL's 2nd alpha ID and icon.
if ((SIM_NOTIFY_SETUPCALL == dwNotifyCode) && (0 < m_dwParseLen))
{
if ((*m_lpbParse & 0x7f) == (BYTE)ALPHAIDTAG)
{
m_lpbParse++;
m_dwParseLen--;
hr = ReadCommonEFADNText(&m_pwszAlphaId2, &m_dwAlphaId2Len);
if (FAILED(hr))
{
// Failure
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Parsing SETUP CALL 2nd Alpha ID failed.\r\n")));
dwRetVal = SIM_RESPONSE_ERR_VALUESMISSING;
goto Exit;
}
}
if ( (0 < m_dwParseLen) &&
( (*m_lpbParse & 0x7f) == (BYTE)ICONTAG) )
{
m_lpbParse++;
m_dwParseLen--;
hr = ReadCommonIconIdentifier(&m_dwIconIdentifier2, &m_dwIconQualifier2);
if (FAILED(hr))
{
// Failure
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Parsing SETUP CALL 2nd Icon failed.\r\n")));
dwRetVal = SIM_RESPONSE_ERR_VALUESMISSING;
goto Exit;
}
}
}
}
}
// Finally, we can put everything back together into a structure
switch (dwNotifyCode)
{
case SIM_NOTIFY_MORETIME:
case SIM_NOTIFY_POLLINGOFF:
// Command Qualifier is unused -- nothing really more to do, is there?
dwResultSize = 0;
break;
// These all use the SIMTEXT structure
case SIM_NOTIFY_DISPLAYTEXT:
case SIM_NOTIFY_GETINKEY:
case SIM_NOTIFY_GETINPUT:
case SIM_NOTIFY_SETUPIDLEMODETEXT:
hr = BuildSIMTEXT(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
// These both use the SIMMENU structure
case SIM_NOTIFY_SETUPMENU:
case SIM_NOTIFY_SELECTITEM:
hr = BuildSIMMENU(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_POLLINTERVAL:
hr = BuildSIMPOLLINGINTERVAL(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_SETUPCALL:
hr = BuildSIMCALL(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_PLAYTONE:
hr = BuildSIMTONE(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_LOCALINFO:
hr = BuildSIMLOCALINFO(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_REFRESH:
hr = BuildSIMREFRESH(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
if (E_FAIL == hr)
{
// A reserved refresh mode was sent, a "command type not understood" response
// must be sent back.
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Reserved REFRESH command mode. Sending command type not understood.\r\n")));
DEBUGCHK(FALSE);
dwRetVal = SIM_RESPONSE_ERR_COMMANDTYPE;
goto Exit;
}
else if (E_INVALIDARG == hr)
{
// A refresh mode requiring a file list was sent but no file list was attached, a
//"error, required values missing" response will be sent back.
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: REFRESH command mode requiring file list sent with a file list. Responding with error values missing.\r\n")));
DEBUGCHK(FALSE);
dwRetVal = SIM_RESPONSE_ERR_VALUESMISSING;
goto Exit;
}
// SIM_RESPONSE_ERR_VALUESMISSING
break;
case SIM_NOTIFY_SENDSS:
case SIM_NOTIFY_SENDUSSD:
hr = BuildSIMUSSD(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_SENDSMS:
hr = BuildSIMSMS(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_EVENTLIST:
hr = BuildSIMEVENTLIST(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_LAUNCHBROWSER:
hr = BuildSIMLAUNCHBROWSER(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_SENDDTMF:
hr = BuildSIMSENDDTMF(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_OPENCHANNEL:
hr = BuildSIMOPENCHANNEL(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_CLOSECHANNEL:
hr = BuildSIMCLOSECHANNEL(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_SENDDATA:
hr = BuildSIMSENDDATA(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_RECEIVEDATA:
hr = BuildSIMRECEIVEDATA(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_LANGUAGENOTIFICATION:
hr = BuildSIMLANGUAGE(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
case SIM_NOTIFY_RUNATCOMMAND:
hr = BuildSIMRUNATCMD(dwNotifyCode, bCmdQualifier, &lpbResult, &dwResultSize);
break;
default:
// We don't understand this command
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Don't understand command %x\r\n"), dwNotifyCode));
ASSERT(0);
dwRetVal = SIM_RESPONSE_ERR_COMMANDTYPE;
goto Exit;
}
if (FAILED(hr))
{
// Oh, we couldn't build the information -- since we were able to parse everything
// out OK, we have to assume this is an internal error
ASSERT(hr == E_OUTOFMEMORY);
dwRetVal = SIM_RESPONSE_ERR_MOBILEINCAPABLE;
}
// Everything was parsed ok. Build up the final structure to be sent with the
// SIM toolkit notification.
if (SIM_RESPONSE_OK == dwRetVal)
{
// Build RIL SIMTKit command structure.
// Total size will be the command size plus the details.
*pdwCommandSize = ROUNDTODWORD(sizeof(RILSIMTOOLKITCMD) + dwResultSize);
pCmd = (RILSIMTOOLKITCMD*)AllocBlob(*pdwCommandSize);
if (NULL == pCmd)
{
ASSERT(FALSE);
*pdwCommandSize = 0;
dwRetVal = SIM_RESPONSE_ERR_MOBILEINCAPABLE;
goto Exit;
}
memset(pCmd, 0, *pdwCommandSize);
pCmd->cbSize = *pdwCommandSize;
if (m_fTextNotifications)
{
pCmd->dwType = dwNotifyCode;
pCmd->dwParams = RIL_PARAM_SIMTKIT_CMD_TYPE;
}
else
{
pCmd->dwId = dwCommandId;
pCmd->dwTag = dwCommandTag;
pCmd->dwType = dwNotifyCode;
pCmd->dwQualifier = bCmdQualifier;
pCmd->dwParams = RIL_PARAM_SIMTKIT_CMD_ID | RIL_PARAM_SIMTKIT_CMD_TAG | RIL_PARAM_SIMTKIT_CMD_TYPE | RIL_PARAM_SIMTKIT_CMD_QUALIFIER;
}
if (NULL != lpbResult)
{
pCmd->dwParams |= RIL_PARAM_SIMTKIT_CMD_DETAILS_SIZE | RIL_PARAM_SIMTKIT_CMD_DETAILS_OFFSET;
pCmd->dwDetailsSize = dwResultSize;
pCmd->dwDetailsOffset = ROUNDTODWORD(sizeof(RILSIMTOOLKITCMD));
memcpy((LPBYTE*)((LPBYTE)pCmd + pCmd->dwDetailsOffset), lpbResult, dwResultSize);
delete[] lpbResult;
lpbResult = NULL;
}
}
Exit:
// Error with parsing the SIM toolkit notification.
if (dwRetVal != SIM_RESPONSE_OK)
{
// Free up any previously allocated memory
delete[] lpbResult;
lpbResult = NULL;
if (NULL != pCmd)
{
FreeBlob(pCmd);
pCmd = NULL;
}
// Now try creating an error notification, if possible, to inform the upper layers
// of the SIM toolkit parsing failure.
*pdwCommandSize = ROUNDTODWORD(sizeof(RILSIMTOOLKITCMD));
pCmd = (RILSIMTOOLKITCMD*)AllocBlob(*pdwCommandSize);
// Out of memory problem, just exit.
if (NULL == pCmd)
{
ASSERT(FALSE);
*pdwCommandSize = 0;
dwRetVal = SIM_RESPONSE_ERR_MOBILEINCAPABLE;
}
else
{
memset(pCmd, 0, *pdwCommandSize);
pCmd->cbSize = *pdwCommandSize;
// Set the command ID, if available.
if (0 != dwCommandId)
{
pCmd->dwId = dwCommandId;
pCmd->dwParams |= RIL_PARAM_SIMTKIT_CMD_ID;
}
// Set the command ID, if available.
if (0 != dwCommandTag)
{
pCmd->dwTag = dwCommandTag;
pCmd->dwParams |= RIL_PARAM_SIMTKIT_CMD_TAG;
}
// Set the command type, if available.
if (0 != dwNotifyCode)
{
pCmd->dwType = dwNotifyCode;
pCmd->dwParams |= RIL_PARAM_SIMTKIT_CMD_TYPE;
}
// Set the command type, if available.
if (0 != bCmdQualifier)
{
pCmd->dwQualifier = bCmdQualifier;
pCmd->dwParams |= RIL_PARAM_SIMTKIT_CMD_QUALIFIER;
}
// Set the error value.
pCmd->dwError = dwRetVal;
pCmd->dwParams |= RIL_PARAM_SIMTKIT_CMD_ERROR;
}
} // dwRetVal != SIM_RESPONSE_OK
*ppCommand = pCmd;
// In any case, we definitely want to free m_rgpsmi if it was allocated
if (NULL != m_rgpsmi)
{
for (i = 0; i < m_numpsmi; i++)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -