?? rilsimtkit.cpp
字號:
RETURNS: HRESULT
****************************************************************************/
HRESULT CRilSimToolkitCommand::BuildSIMLOCALINFO(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
DWORD *pdw = NULL;
HRESULT hr = S_OK;
const DWORD rgdwInfoType[] = { SIMLOCALINFO_LOCATION, SIMLOCALINFO_IMEI, SIMLOCALINFO_NMR };
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMLOCALINFO\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
// The command qualifier needs to be 0, 1, or 2
if (bCmdQualifier > 0x02)
{
hr = E_FAIL;
goto Exit;
}
// Now we can allocate memory
pdw = new DWORD;
if (!pdw)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
// Everything is in the command qualifier
*pdw = rgdwInfoType[bCmdQualifier];
*lpdwSize = sizeof(DWORD);
Exit:
*ppbResult = (LPBYTE) pdw;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::BuildSIMLOCALINFO\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMPOLLINGINTERVAL
PURPOSE: Builds the SIMPOLLINGINTERVAL structure
PARAMETERS: dwNotifyCode - Which command is this?
bCmdQualifier - Specific info from the command details
ppbResult - OUT parameter to hold allocated structure
RETURNS: HRESULT
****************************************************************************/
HRESULT CRilSimToolkitCommand::BuildSIMPOLLINGINTERVAL(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
DWORD *pdw = NULL;
HRESULT hr = S_OK;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMPOLLINGINTERVAL\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
bCmdQualifier; // Avoid warning C4100: unreferenced formal parameter
// Now we can allocate memory
pdw = new DWORD;
if (!pdw)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
*pdw = m_dwDuration;
*lpdwSize = sizeof(DWORD);
Exit:
*ppbResult = (LPBYTE) pdw;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::BuildSIMPOLLINGINTERVAL\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMCALL
PURPOSE: Builds the SIMCALL structure
PARAMETERS: dwNotifyCode - Which command is this?
bCmdQualifier - Specific info from the command details
ppbResult - OUT parameter to hold allocated structure
RETURNS: HRESULT
****************************************************************************/
HRESULT CRilSimToolkitCommand::BuildSIMCALL(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
HRESULT hr = S_OK;
SIMCALL *psc = NULL;
DWORD dwSize;
BYTE bCallFlags;
DWORD dwUsedSize;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMCALL\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
// OK, let's put everything together here
dwSize = ROUNDTODWORD(sizeof(SIMCALL)) + ROUNDTODWORD(m_dwAlphaIdLen) +
ROUNDTODWORD(m_dwAddressLen) + ROUNDTODWORD(m_dwSubAddrLen) +
ROUNDTODWORD(m_dwAlphaId2Len);
psc = (SIMCALL *) new BYTE[dwSize];
if (!psc)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
memset(psc, 0, dwSize);
psc->cbSize = dwSize;
psc->dwParams = SIM_PARAM_SIMCALL_FLAGS;
psc->dwFlags = 0;
if (bCmdQualifier & 0x01)
{
// This means use redial
psc->dwFlags |= SIMCALL_REDIAL;
}
bCallFlags = (BYTE) ((bCmdQualifier >> 1) & 0x03);
if (bCallFlags == 0x02)
{
psc->dwFlags |= SIMCALL_DISCONNECTCALLS;
}
else if (bCallFlags == 0x01)
{
psc->dwFlags |= SIMCALL_HOLDCALLS;
}
else
{
ASSERT(bCallFlags == 0x00);
psc->dwFlags |= SIMCALL_IDLE;
}
// Do we have a redial duration?
if (m_dwDuration != SIMTONE_DEFAULTDURATION)
{
psc->dwParams |= SIM_PARAM_SIMCALL_REDIALDURATION;
psc->dwRedialDuration = m_dwDuration;
}
dwUsedSize = ROUNDTODWORD(sizeof(SIMCALL));
if (m_dwAddressLen)
{
psc->dwParams |= ( SIM_PARAM_SIMCALL_ADDRESSOFFSET | SIM_PARAM_SIMCALL_ADDRESSSIZE |
SIM_PARAM_SIMCALL_ADDRESSTYPE | SIM_PARAM_SIMCALL_NUMPLAN);
psc->dwNumPlan = m_dwNumPlan;
psc->dwAddressType = m_dwAddrType;
psc->dwAddressSize = m_dwAddressLen;
psc->dwAddressOffset = dwUsedSize;
StringCbCopy( ((TCHAR *) ((LPBYTE) psc + psc->dwAddressOffset)), m_dwAddressLen, m_pwszAddress );
dwUsedSize += ROUNDTODWORD(m_dwAddressLen);
}
// Set up the User Confirmation text string, if it's there
if (m_dwAlphaIdLen)
{
psc->dwParams |= (SIM_PARAM_SIMCALL_TEXTSIZE | SIM_PARAM_SIMCALL_TEXTOFFSET);
psc->dwTextSize = m_dwAlphaIdLen;
psc->dwTextOffset = dwUsedSize;
StringCbCopy( ((TCHAR *) ((LPBYTE) psc + psc->dwTextOffset)), m_dwAlphaIdLen, m_pwszAlphaId );
dwUsedSize += ROUNDTODWORD(m_dwAlphaIdLen);
}
// And finally the subaddress, if it's there
if (m_dwSubAddrLen)
{
psc->dwParams |= (SIM_PARAM_SIMCALL_SUBADDRESSSIZE | SIM_PARAM_SIMCALL_SUBADDRESSOFFSET);
psc->dwSubAddrSize = m_dwSubAddrLen;
psc->dwSubAddrOffset = dwUsedSize;
StringCbCopy( ((TCHAR *) ((LPBYTE) psc + psc->dwSubAddrOffset)), m_dwSubAddrLen, m_pwszSubAddr );
dwUsedSize += ROUNDTODWORD(m_dwSubAddrLen);
}
// Set up the Call Setup text string, if it's there
if (m_dwAlphaId2Len)
{
psc->dwParams |= (SIM_PARAM_SIMCALL_CALLSETUPTEXTSIZE | SIM_PARAM_SIMCALL_CALLSETUPTEXTOFFSET);
psc->dwCallSetupTextSize = m_dwAlphaId2Len;
psc->dwCallSetupTextOffset = dwUsedSize;
StringCbCopy( ((TCHAR *) ((LPBYTE) psc + psc->dwCallSetupTextOffset)), m_dwAlphaId2Len, m_pwszAlphaId2 );
dwUsedSize += ROUNDTODWORD(m_dwAlphaId2Len);
}
if (SIMTKIT_INVALID_VALUE != m_dwIconIdentifier)
{
psc->dwParams |= SIM_PARAM_SIMCALL_ICONID;
psc->dwIconIdentifier = m_dwIconIdentifier;
}
if (SIMTKIT_INVALID_VALUE != m_dwIconQualifier)
{
psc->dwParams |= SIM_PARAM_SIMCALL_ICONQUALIFIER;
psc->dwIconQualifier = m_dwIconQualifier;
}
// Call Setup Phase Icon
if (SIMTKIT_INVALID_VALUE != m_dwIconIdentifier2)
{
psc->dwParams |= SIM_PARAM_SIMCALL_CALLSETUPICONID;
psc->dwCallSetupIconIdentifier = m_dwIconIdentifier2;
}
if (SIMTKIT_INVALID_VALUE != m_dwIconQualifier2)
{
psc->dwParams |= SIM_PARAM_SIMCALL_CALLSETUPICONQUALIFIER;
psc->dwCallSetupIconQualifier = m_dwIconQualifier2;
}
*lpdwSize = dwSize;
Exit:
*ppbResult = (LPBYTE) psc;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMCALL\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMREFRESH
PURPOSE: Builds the SIMREFRESH structure
PARAMETERS: dwNotifyCode - Which command is this?
bCmdQualifier - Specific info from the command details
ppbResult - OUT parameter to hold allocated structure
RETURNS: HRESULT
****************************************************************************/
HRESULT CRilSimToolkitCommand::BuildSIMREFRESH(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
HRESULT hr = S_OK;
SIMFILEREFRESH *psfr = NULL;
const DWORD rgdwFlags[] = { (SIMFILE_SIMINIT | SIMFILE_FULLFILECHANGE), SIMFILE_FILECHANGE,
(SIMFILE_SIMINIT | SIMFILE_FILECHANGE), SIMFILE_SIMINIT,
SIMFILE_SIMRESET };
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMREFRESH\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
// Check parameters
// If the Refresh command qualifier (Refresh Mode) is "File Change Notification"/0x01 or
// "SIM Initialization and File Change Notification"/0x02 then there should be a list of files.
if (((bCmdQualifier == 0x01) || (bCmdQualifier == 0x02)) && !m_dwNumFiles)
{
// This isn't allowed
hr = E_INVALIDARG;
goto Exit;
}
else if (bCmdQualifier >= 0x05)
{
// 0x05 through 0xFF are reserved values, proper response is "Command type not understood".
// Return an hresult, so that calling functions can pick up and send the proper result.
hr = E_FAIL;
goto Exit;
}
if (MAX_FILES < m_dwNumFiles)
{
hr=E_FAIL;
goto Exit;
}
// OK, let's put everything together here
psfr = (SIMFILEREFRESH *) new SIMFILEREFRESH;
if (!psfr)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
memset(psfr, 0, sizeof(SIMFILEREFRESH));
psfr->cbSize = sizeof(SIMFILEREFRESH);
if (bCmdQualifier < 0x05)
{
// Flags were specified
psfr->dwParams |= SIM_PARAM_FILEREFRESH_FLAGS;
psfr->dwFlags = rgdwFlags[bCmdQualifier];
}
// All right, do we have a list of files?
if (m_dwNumFiles)
{
psfr->dwParams |= (SIM_PARAM_FILEREFRESH_FILECOUNT | SIM_PARAM_FILEREFRESH_FILEARRAY);
psfr->dwFileCount = m_dwNumFiles;
memcpy(psfr->rgdwAddress, m_pdwFiles, m_dwNumFiles * sizeof(DWORD));
}
*lpdwSize = sizeof(SIMFILEREFRESH);
Exit:
*ppbResult = (LPBYTE) psfr;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::BuildSIMREFRESH\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMUSSD
PURPOSE: Builds the SIMUSSD structure
PARAMETERS: dwNotifyCode - Which command is this?
bCmdQualifier - Specific info from the command details
ppbResult - OUT parameter to hold allocated structure
RETURNS: HRESULT
****************************************************************************/
HRESULT CRilSimToolkitCommand::BuildSIMUSSD(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
HRESULT hr = S_OK;
SIMUSSD *psu = NULL;
DWORD dwSize;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMUSSD\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
bCmdQualifier; // Avoid warning C4100: unreferenced formal parameter
// OK, let's put everything together here
dwSize = ROUNDTODWORD(sizeof(SIMUSSD)) + ROUNDTODWORD(m_dwAlphaIdLen) + ROUNDTODWORD(m_dwUSSDLen);
if ( dwSize == 0 )
{
hr = E_ABORT;
goto Exit;
}
psu = (SIMUSSD *) new BYTE[dwSize];
if (!psu)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
memset(psu, 0, dwSize);
psu->cbSize = dwSize;
// Set the num plan and address type
if ( m_dwAddrType != SIM_ADDRTYPE_UNKNOWN)
{
psu->dwParams |= SIM_PARAM_SIMUSSD_ADDRESSTYPE;
psu->dwAddressType = m_dwAddrType;
}
else
{
psu->dwAddressType = SIM_ADDRTYPE_UNKNOWN;
}
if (m_dwNumPlan != SIM_NUMPLAN_UNKNOWN)
{
psu->dwParams |= SIM_PARAM_SIMUSSD_NUMPLAN;
psu->dwNumPlan = m_dwNumPlan;
}
else
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -