?? rilsimtkit.cpp
字號:
{
delete[] (BYTE*)m_rgpsmi[i];
}
delete[] m_rgpsmi;
}
if (NULL != m_rgpsfr)
{
for (i = 0; i < m_numpsfr; i++)
{
delete[] (BYTE*)m_rgpsfr[i];
}
delete[] m_rgpsfr;
}
delete[] m_pwszAlphaId;
delete[] m_pwszAlphaId2;
delete[] m_pwszText;
delete[] m_pwszDefaultText;
delete[] m_pwszAddress;
delete[] m_pwszSubAddr;
delete[] m_pwszUSSD;
delete[] m_lpbTPDU;
delete[] m_lpbEventList;
delete[] m_pdwFiles;
delete[] m_pwszURL;
delete[] m_lpbBearer;
delete[] m_pwszDTMF;
delete[] m_lpbChannelData;
delete[] m_pwszLanguage;
delete[] m_lpbLocalAddr;
delete[] m_lpbDestAddr;
delete[] m_pwszLogin;
delete[] m_pwszPassword;
delete[] m_lpbBearerDesc;
delete[] m_lpbAccessName;
return dwRetVal;
}
/****************************************************************************
FUNCTION: BuildSIMMENU
PURPOSE: Builds the SIMMENU 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::BuildSIMMENU(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
SIMMENU *psm = NULL;
SIMMENUITEM *psmi;
HRESULT hr = S_OK;
DWORD dwSize, i;
unsigned int uiSize;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMMENU\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
// How much space do we need to allocate?
BOOL fSafeDword = FALSE;
if ( TRUE == safeIntUAdd( ROUNDTODWORD(sizeof(SIMMENU)), ROUNDTODWORD(m_dwAlphaIdLen), &uiSize ))
{
for (i = 0, fSafeDword = TRUE; (i < m_numpsmi) && (TRUE == fSafeDword); i++)
{
fSafeDword = safeIntUAdd(uiSize, ROUNDTODWORD(m_rgpsmi[i]->cbSize), &uiSize);
}
}
if ( FALSE == fSafeDword )
{
hr = E_ABORT;
goto Exit;
}
else
{
dwSize = uiSize;
}
if ( dwSize == 0 )
{
hr = E_ABORT;
goto Exit;
}
psm = (SIMMENU *) new BYTE[dwSize];
if (!psm)
{
hr = E_OUTOFMEMORY;
goto Exit;
}
// Populate this structure
memset(psm, 0, dwSize);
psm->cbSize = dwSize;
psm->dwParams = SIM_PARAM_SIMMENU_FLAGS | SIM_PARAM_SIMMENU_MENUITEMCOUNT |
SIM_PARAM_SIMMENU_MENUITEMSIZE | SIM_PARAM_SIMMENU_MENUITEMOFFSET;
psm->dwFlags = (bCmdQualifier & 0x80) ? SIMMENU_HELPINFO : 0;
if (m_dwAlphaIdLen)
{
psm->dwParams |= (SIM_PARAM_SIMMENU_TEXTSIZE | SIM_PARAM_SIMMENU_TEXTOFFSET);
psm->dwTextSize = m_dwAlphaIdLen;
psm->dwTextOffset = ROUNDTODWORD(sizeof(SIMMENU));
StringCbCopy( ((TCHAR *) ((LPBYTE) psm + psm->dwTextOffset)), m_dwAlphaIdLen, m_pwszAlphaId );
}
if (m_dwItemId != -1)
{
psm->dwParams |= SIM_PARAM_SIMMENU_DEFAULTITEM;
psm->dwDefaultItem = m_dwItemId;
}
if (SIMTKIT_INVALID_VALUE != m_dwIconIdentifier)
{
psm->dwParams |= SIM_PARAM_SIMMENU_ICONID;
psm->dwIconIdentifier = m_dwIconIdentifier;
}
if (SIMTKIT_INVALID_VALUE != m_dwIconQualifier)
{
psm->dwParams |= SIM_PARAM_SIMMENU_ICONQUALIFIER;
psm->dwIconQualifier = m_dwIconQualifier;
}
// Now for the menu items
psm->dwMenuItemCount = m_numpsmi;
psm->dwMenuItemOffset = (m_dwAlphaIdLen) ? (psm->dwTextOffset + ROUNDTODWORD(psm->dwTextSize))
: ROUNDTODWORD(sizeof(SIMMENU));
psm->dwMenuItemSize = dwSize - psm->dwMenuItemOffset;
psmi = (SIMMENUITEM *) ((LPBYTE) psm + psm->dwMenuItemOffset);
for (i = 0; i < m_numpsmi; i++)
{
DWORD cbSize = m_rgpsmi[i]->cbSize;
memcpy(psmi, m_rgpsmi[i], cbSize);
psmi = (SIMMENUITEM *) ((LPBYTE) psmi + cbSize);
}
*lpdwSize = dwSize;
Exit:
*ppbResult = (LPBYTE) psm;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::BuildSIMMENU\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMTEXT
PURPOSE: Builds the SIMTEXT 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::BuildSIMTEXT(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
SIMTEXT *pst = NULL;
HRESULT hr = S_OK;
DWORD dwSize;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMTEXT\r\n")));
// OK, now let's pack this all into a SIMTEXT structure -- in this case, there is
// no default text, so we don't have to worry about that
dwSize = ROUNDTODWORD(sizeof(SIMTEXT)) + ROUNDTODWORD(m_dwTextLen) + ROUNDTODWORD(m_dwDefaultTextLen);
pst = (SIMTEXT *) new BYTE[dwSize];
if (!pst)
{
// Memory allocation error.
hr = E_OUTOFMEMORY;
goto Exit;
}
// Populate this structure
memset(pst, 0, dwSize);
pst->cbSize = dwSize;
pst->dwParams = SIM_PARAM_SIMTEXT_FLAGS;
// Min and max response
if ((dwNotifyCode == SIM_NOTIFY_GETINPUT) || (dwNotifyCode == SIM_NOTIFY_GETINKEY))
{
pst->dwParams |= (SIM_PARAM_SIMTEXT_MINRESPONSE | SIM_PARAM_SIMTEXT_MAXRESPONSE);
pst->dwMinResponse = m_dwMinResponse;
pst->dwMaxResponse = m_dwMaxResponse;
}
// The value of the command qualifier is different between DISPLAY TEXT and GET INKEY
// DISPLAY TEXT also has the optional immediate response setting.
pst->dwFlags = 0;
if (dwNotifyCode == SIM_NOTIFY_DISPLAYTEXT)
{
if (bCmdQualifier & 0x01)
{
pst->dwFlags |= SIMTEXT_HIGHPRIORITY;
}
if (!(bCmdQualifier & 0x80))
{
pst->dwFlags |= SIMTEXT_DELAYCLEAR;
}
if (m_fImmediateResponse)
{
pst->dwFlags |= SIMTEXT_IMMEDIATERESPONSE;
}
}
else
{
// GET INPUT and GET INKEY -- first two bits tell us what characters can be input
if (!(bCmdQualifier & 0x01))
{
pst->dwFlags |= SIMTEXT_KEYPADDIGITS;
}
else if (!(bCmdQualifier & 0x02))
{
pst->dwFlags |= SIMTEXT_GSMDEFAULTALPHABET;
}
if (bCmdQualifier & 0x80)
{
pst->dwFlags |= SIMTEXT_HELPINFO;
}
if (dwNotifyCode == SIM_NOTIFY_GETINPUT)
{
if (bCmdQualifier & 0x04)
{
pst->dwFlags |= SIMTEXT_NOECHO;
}
if (bCmdQualifier & 0x08)
{
pst->dwFlags |= SIMTEXT_PACKEDRESPONSE;
}
}
else if (dwNotifyCode == SIM_NOTIFY_GETINKEY)
{
if (bCmdQualifier & 0x04)
{
pst->dwFlags |= SIMTEXT_YESNO;
}
}
}
// Is there specified text? A null text string is valid and will be marked
// by having a text length of zero.
if (m_dwTextLen)
{
pst->dwParams |= SIM_PARAM_SIMTEXT_TEXTSIZE | SIM_PARAM_SIMTEXT_TEXTOFFSET;
pst->dwTextSize = m_dwTextLen;
pst->dwTextOffset = ROUNDTODWORD(sizeof(SIMTEXT));
StringCbCopy( ((TCHAR *) ((LPBYTE) pst + pst->dwTextOffset)), m_dwTextLen, m_pwszText );
}
// Is there default text?
if (m_dwDefaultTextLen)
{
pst->dwParams |= (SIM_PARAM_SIMTEXT_DEFAULTTEXTOFFSET | SIM_PARAM_SIMTEXT_DEFAULTTEXTSIZE);
pst->dwDefaultTextSize = m_dwDefaultTextLen;
pst->dwDefaultTextOffset = pst->dwTextOffset + ROUNDTODWORD(pst->dwTextSize);
StringCbCopy( ((TCHAR *) ((LPBYTE) pst + pst->dwDefaultTextOffset)), m_dwDefaultTextLen, m_pwszDefaultText );
}
if (SIMTKIT_INVALID_VALUE != m_dwIconIdentifier)
{
pst->dwParams |= SIM_PARAM_SIMTEXT_ICONID;
pst->dwIconIdentifier = m_dwIconIdentifier;
}
if (SIMTKIT_INVALID_VALUE != m_dwIconQualifier)
{
pst->dwParams |= SIM_PARAM_SIMTEXT_ICONQUALIFIER;
pst->dwIconQualifier = m_dwIconQualifier;
}
*lpdwSize = dwSize;
Exit:
*ppbResult = (LPBYTE) pst;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::BuildSIMTEXT\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMTONE
PURPOSE: Builds the SIMTONE 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::BuildSIMTONE(DWORD dwNotifyCode, BYTE bCmdQualifier, LPBYTE *ppbResult, DWORD *lpdwSize)
{
SIMTONE *pst = NULL;
HRESULT hr = S_OK;
DWORD dwSize;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::BuildSIMTONE\r\n")));
dwNotifyCode; // Avoid warning C4100: unreferenced formal parameter
bCmdQualifier; // Avoid warning C4100: unreferenced formal parameter
// OK, let's see how much space we need now
dwSize = ROUNDTODWORD(sizeof(SIMTONE)) + ROUNDTODWORD(m_dwAlphaIdLen);
pst = (SIMTONE *) new BYTE[dwSize];
if (!pst)
{
// Oops
hr = E_OUTOFMEMORY;
goto Exit;
}
memset(pst, 0, dwSize);
pst->cbSize = dwSize;
pst->dwParams = SIM_PARAM_SIMTONE_DURATION | SIM_PARAM_SIMTONE_TONE;
pst->dwTone = m_dwTone;
pst->dwDuration = m_dwDuration;
if (m_dwAlphaIdLen)
{
pst->dwParams |= (SIM_PARAM_SIMTONE_TEXTSIZE | SIM_PARAM_SIMTONE_TEXTOFFSET);
pst->dwTextSize = m_dwAlphaIdLen;
pst->dwTextOffset = ROUNDTODWORD(sizeof(SIMTONE));
StringCbCopy( ((TCHAR *) ((LPBYTE) pst + pst->dwTextOffset)), m_dwAlphaIdLen, m_pwszAlphaId );
}
if (SIMTKIT_INVALID_VALUE != m_dwIconIdentifier)
{
pst->dwParams |= SIM_PARAM_SIMTONE_ICONID;
pst->dwIconIdentifier = m_dwIconIdentifier;
}
if (SIMTKIT_INVALID_VALUE != m_dwIconQualifier)
{
pst->dwParams |= SIM_PARAM_SIMTONE_ICONQUALIFIER;
pst->dwIconQualifier = m_dwIconQualifier;
}
*lpdwSize = dwSize;
Exit:
*ppbResult = (LPBYTE) pst;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::BuildSIMTONE\r\n")));
return hr;
}
/****************************************************************************
FUNCTION: BuildSIMLOCALINFO
PURPOSE: Builds the SIMLOCALINFO structure
PARAMETERS: dwNotifyCode - Which command is this?
bCmdQualifier - Specific info from the command details
ppbResult - OUT parameter to hold allocated structure
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -