?? rilsimtkittext.cpp
字號(hào):
LPWSTR wszTitle = NULL;
LPWSTR wszDefault = NULL;
size_t cbTitleBufSize = 0;
size_t cbDefaultBufSize = 0;
HRESULT hr = S_OK;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::ParseGetInput\r\n")));
pbParse = m_lpbParse;
dwLength = 0;
// At this point the GetInput notification should be in the form of:
//
// ,<dcs>,<text>,<response>,<echo>,<helpInfo>,<minLgth>,<maxLgth>
// [,<dcs>,<default>[,<iconId>,<dispMode>]]
// ,<dcs>
// Data encoding Scheme:
// 0 7bit GSM default alphabet (packed)
// 4 8bit data
// 8 UCS2 alphabet
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwDCS, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<text>
// Must manage returned memory
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseEncodedText(pbParse, dwDCS, wszTitle, cbTitleBufSize, pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<response>
// integer: expected response character format.
// Digits (0-9, *, # and +) only from SMS default alphabet (unpacked)
// Digits (0-9, *, # and +) only from SMS default alphabet (packed)
// Digits from UCS2 alphabet
// SMS default alphabet (unpacked)
// SMS default alphabet (packed)
// UCS2 alphabet
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwResponse, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<echo>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwEcho, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<helpInfo>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwHelpInfo, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<minLgth>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwMinLength, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<maxLgth>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwMaxLength, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// Optional:
// ,<dcs>,<default>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
// <dcs>
if (!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwDCS, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<default>
// Must manage returned memory
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseEncodedText(pbParse, dwDCS, wszDefault, cbDefaultBufSize, pbParse))
{
hr = E_FAIL;
goto Exit;
}
// Optional:
//[,<iconId>,<dispMode>]
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
// <iconID>
if (!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwIconID, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<dispMode>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwDispMode, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
}
}
// Parsing successful, set proper values for build command functions
switch (dwResponse)
{
case SIMTKIT_TEXTPARSE_GETINPUT_DIGIT_UNPACKED:
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_INPUT_KEYPADDIGITS;
break;
case SIMTKIT_TEXTPARSE_GETINPUT_DIGIT_PACKED:
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_INPUT_KEYPADDIGITS;
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_PACKEDRESPONSE;
break;
case SIMTKIT_TEXTPARSE_GETINPUT_DIGIT_UCS2:
// Need to revisit and properly setup results for UCS2.
break;
case SIMTKIT_TEXTPARSE_GETINPUT_ALPHA_UNPACKED:
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_INPUT_SMDEFAULTALPHABET;
break;
case SIMTKIT_TEXTPARSE_GETINPUT_ALPHA_PACKED:
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_INPUT_SMDEFAULTALPHABET;
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_PACKEDRESPONSE;
break;
case SIMTKIT_TEXTPARSE_GETINPUT_ALPHA_UCS2:
// Need to revisit and properly setup results for UCS2.
break;
default:
break;
}
// <CR><LF>
if (!ParseRspPostfix((LPCSTR)pbParse, (LPCSTR&)pbParse) )
{
hr = E_FAIL;
goto Exit;
}
if (dwEcho)
{
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_NOECHO;
}
if (dwHelpInfo)
{
*pbCmdQualifier |= SIMTKIT_TEXTPARSE_HELPINFO;
}
m_dwMinResponse = dwMinLength;
m_dwMaxResponse = dwMaxLength;
m_pwszText = wszTitle;
m_dwTextLen = cbTitleBufSize;
m_pwszDefaultText = wszDefault;
m_dwDefaultTextLen = cbDefaultBufSize;
if (SIMTKIT_INVALID_VALUE != dwIconID)
{
m_dwIconIdentifier = dwIconID;
}
if (SIMTKIT_INVALID_VALUE != dwDispMode)
{
m_dwIconQualifier = dwDispMode;
}
Exit:
if (FAILED(hr))
{
delete[] wszTitle;
delete[] wszDefault;
}
dwLength = pbParse - m_lpbParse;
m_lpbParse = pbParse;
m_dwParseLen -= dwLength;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::ParseGetInput\r\n")));
return hr;
}
HRESULT CRilSimToolkitCommand::ParsePlayTone(void)
{
BYTE* pbParse;
LPWSTR wszText = NULL;
size_t cbTextBufSize = 0;
DWORD dwLength;
DWORD dwTone;
DWORD dwDuration;
HRESULT hr = S_OK;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::ParsePlayTone\r\n")));
pbParse = m_lpbParse;
dwLength = 0;
// At this point the PlayTone notification should be in the form of:
//
// [,<alphaId>[,<tone>[,<duration>]]]
// Optional: ,<alphaId>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
if (!ParseEncodedText(pbParse, SIMTKIT_TEXT_ENCODING_ALPHAID, wszText, cbTextBufSize, pbParse))
{
hr = E_FAIL;
goto Exit;
}
}
// Optional: ,<tone>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
if(!ParseHexDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_LEADINGZERO, dwTone, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
m_dwTone = dwTone;
}
// Optional: ,<duration>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
if(!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwDuration, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
m_dwDuration = dwDuration;
}
// <CR><LF>
if (!ParseRspPostfix((LPCSTR)pbParse, (LPCSTR&)pbParse) )
{
hr = E_FAIL;
goto Exit;
}
// Parsing successful, set proper values for build command functions
m_pwszAlphaId = wszText;
m_dwAlphaIdLen = cbTextBufSize;
Exit:
if (FAILED(hr))
{
delete[] wszText;
}
dwLength = pbParse - m_lpbParse;
m_lpbParse = pbParse;
m_dwParseLen -= dwLength;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::ParsePlayTone\r\n")));
return hr;
}
HRESULT CRilSimToolkitCommand::ParseUnsolicitedData(void)
{
BYTE* pbParse;
LPWSTR wszText = NULL;
size_t cbTextBufSize = 0;
DWORD dwIconID = SIMTKIT_INVALID_VALUE;
DWORD dwDispMode = SIMTKIT_INVALID_VALUE;
DWORD dwLength;
HRESULT hr = S_OK;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::ParseUnsolicitedData\r\n")));
pbParse = m_lpbParse;
dwLength = 0;
// At this point the basic UnsolicitedData notification should be in the form of:
//
// [,<alphaId>[,<iconId>,<dispMode>]]
// Optional: ,<alphaId>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
if (!ParseEncodedText(pbParse, SIMTKIT_TEXT_ENCODING_ALPHAID, wszText, cbTextBufSize, pbParse))
{
hr = E_FAIL;
goto Exit;
}
}
// Optional: ,<iconId>,<dispMode>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
if (!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwIconID, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// ,<dispMode>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwDispMode, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
}
// <CR><LF>
if (!ParseRspPostfix((LPCSTR)pbParse, (LPCSTR&)pbParse) )
{
hr = E_FAIL;
goto Exit;
}
// Parsing successful, set proper values for build command functions
if (wszText)
{
m_pwszAlphaId = wszText;
m_dwAlphaIdLen = cbTextBufSize;
}
if (SIMTKIT_INVALID_VALUE != dwIconID)
{
m_dwIconIdentifier = dwIconID;
}
if (SIMTKIT_INVALID_VALUE != dwDispMode)
{
m_dwIconQualifier = dwDispMode;
}
Exit:
if (FAILED(hr))
{
delete[] wszText;
}
dwLength = pbParse - m_lpbParse;
m_lpbParse = pbParse;
m_dwParseLen -= dwLength;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: -CRilSimToolkitCommand::ParseUnsolicitedData\r\n")));
return hr;
}
HRESULT CRilSimToolkitCommand::ParseRefresh(BYTE* pbCmdQualifier)
{
BYTE* pbParse;
DWORD* pdwFileList = NULL;
LPBYTE pbFileData = NULL;
WORD wFileAddress;
size_t cbFileSize = 0;
DWORD dwRefMode;
DWORD dwNumFiles = 0;
DWORD dwLength;
DWORD dwCurrentFile;
HRESULT hr = S_OK;
DEBUGMSG(ZONE_FUNCTION, (TEXT("RilDrv : SIMTKit: +CRilSimToolkitCommand::ParseRefresh\r\n")));
pbParse = m_lpbParse;
dwLength = 0;
// At this point the Refresh notification should be in the form of:
//
// ,<refMode>[,<numFiles>,<fileList>]
// ,<refMode>
if (!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse) ||
!ParseHexDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_LEADINGZERO, dwRefMode, (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// Optional: ,<numFiles>,<fileList>
if (MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
// <numFiles>,
if (!ParseDWord((LPCSTR)pbParse, SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO, dwNumFiles, (LPCSTR&)pbParse) ||
!MatchStringBeginning((LPCSTR)pbParse, ",", (LPCSTR&)pbParse))
{
hr = E_FAIL;
goto Exit;
}
// Create buffer for list of files.
pdwFileList = new DWORD[dwNumFiles];
// <fileList>
// string type, hex notation: gives the full paths for the SIM files,
// each file being delimited by commas within the string
for (dwCurrentFile = 0 ; dwCurrentFile < dwNumFiles ; dwCurrentFile++)
{
// Get the string encoded hex for the file and convert it to bytes
// Memory allocated: We must manage the memory returned in pbFileData.
if (!ParseBytes(pbParse, pbFileData, cbFileSize, pbParse))
{
hr = E_FAIL;
goto Exit;
}
// Sanity check that we have a correctly formed full path to a
// elementary file. A full path lists the Master file first which
// starts with 0x3F
if (*pbFileData != 0x3F)
{
DEBUGMSG(ZONE_ERROR, (TEXT("RilDrv : SIMTKit: Expected master file 3F in file list, saw %x\r\n"), *pbFileData));
hr = E_INVALIDARG;
goto Exit;
}
// From TLV.cpp ReadFileList()
// Grab the last word -- we're only interested in the last word in each file
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -