📄 simapptoolkit.cpp
字号:
REMARKS : nil
**************************************************************/
void *CSimAppToolkit::CreateDisplayText(S8 * text, U8 dcs)
{
SATDISPLAYTEXTIND *displayText;
displayText = (SATDISPLAYTEXTIND *)CMemAllocator::MyMallocDataPtr (sizeof (SATDISPLAYTEXTIND));
displayText->clearTextType=FALSE;
displayText->immediateRes=FALSE;
displayText->isIconAvailable=FALSE;
displayText->priority=0;
displayText->dcsOfTextString = dcs;
displayText->noTextString = strlen(text);
displayText->textString=SATCovertStringForSIM((U8 *)text,displayText->noTextString, displayText->dcsOfTextString, &displayText->noTextString);
return (void *)displayText;
}
/**************************************************************
FUNCTION NAME : GetInputPlugin
PURPOSE : Plugin for GetInput indication from MMI
INPUT PARAMETERS : void
OUTPUT PARAMETERS : nil
RETURNS : void*
REMARKS : Returns buffer for SAT getInput indication
**************************************************************/
void *CSimAppToolkit::GetInputPlugin(void)
{
return(CreateGetInput("Enter a String?",8,20,TYPE_SMS_DEFAULT_SET,0,"New Delhi", SAT_8BIT_DCS));
}
/**************************************************************
FUNCTION NAME : CreateGetInput
PURPOSE : Plugin for GetInput indication from MMI
INPUT PARAMETERS : S8 * text, U8 min, U8 max, U8 type, U8 reveal, S8 *input, U8 dcs
OUTPUT PARAMETERS : nil
RETURNS : void*
REMARKS : Returns the buffer for getinput message.
**************************************************************/
void *CSimAppToolkit::CreateGetInput(S8 * text, U8 min, U8 max, U8 type, U8 reveal, S8 *input, U8 dcs)
{
SATGETINPUTIND *getInput;
getInput = (SATGETINPUTIND *)CMemAllocator::MyMallocDataPtr (sizeof (SATGETINPUTIND));
getInput->isHelpInfoAvailable = FALSE;
getInput->lenOfMinInput=min;
getInput->lenOfMaxInput=max;
getInput->typeOfInput=type;
getInput->isIconAvailable=FALSE;
getInput->isInputRevealedToUser = reveal;
getInput->dcsOfTextString = dcs;
getInput->noTextString = strlen(text);
getInput->textString=SATCovertStringForSIM((U8 *)text, getInput->noTextString, getInput->dcsOfTextString, &getInput->noTextString);
getInput->dcsOfDefaultText = dcs;
getInput->noDefaultText = strlen(input);
getInput->defaultText=SATCovertStringForSIM((U8 *)input, getInput->noDefaultText, getInput->dcsOfDefaultText, &getInput->noDefaultText);
return (void *)getInput;
}
/**************************************************************
FUNCTION NAME : GetInputPlugin
PURPOSE : Plugin for GetInkey indication from MMI
INPUT PARAMETERS : void
OUTPUT PARAMETERS : nil
RETURNS : void*
REMARKS : Returns buffer for SAT getInkey indication
**************************************************************/
void *CSimAppToolkit::GetInkeyPlugin(void)
{
return(CreateGetInkey("What is your initial?", TYPE_SMS_DEFAULT_SET, SAT_UCS2_DCS));
}
/**************************************************************
FUNCTION NAME : CreateGetInkey
PURPOSE : Plugin for CreateGetInkey indication from MMI
INPUT PARAMETERS : S8 * text, U8 type, U8 dcs
OUTPUT PARAMETERS : nil
RETURNS : void*
REMARKS : Returns the buffer for getinkey message.
**************************************************************/
void *CSimAppToolkit::CreateGetInkey(S8 * text, U8 type, U8 dcs)
{
SATGETINKEYIND *getInkey;
getInkey = (SATGETINKEYIND *)CMemAllocator::MyMallocDataPtr (sizeof (SATGETINKEYIND));
getInkey->isHelpInfoAvailable = FALSE;
getInkey->typeOfInput=type;
getInkey->dcsOfTextString = dcs;
getInkey->isIconAvailable=FALSE;
getInkey->noTextString = strlen(text);
getInkey->textString=SATCovertStringForSIM((U8 *)text,getInkey->noTextString, getInkey->dcsOfTextString, &getInkey->noTextString);
return (void *)getInkey;
}
/**************************************************************
FUNCTION NAME : SATCovertStringForSIM
PURPOSE : Internal conversion strings that care of UCS2 and Little endian/ Big endian issue
INPUT PARAMETERS : U8 *data, U16 len, U8 format, U16 *outLen
OUTPUT PARAMETERS : nil
RETURNS : U8*
REMARKS : Returns the string after conversion
**************************************************************/
U8 * CSimAppToolkit::SATCovertStringForSIM(U8 *data, U16 len, U8 format, U16 *outLen)
{
U8 *convertedData;
if (len > 0)
{
switch (format)
{
#if 0
case SAT_DEFAULT_DCS:
#ifdef __ASCII
convertedData = (U8 *)malloc((len)+1);
ConvertAsciiEncodingToDefault(convertedData,data,len);
memset((void *)&convertedData[len],0,1);
if(outLen!=NULL) *outLen=len+1;
#endif
#ifdef __UCS2_ENCODING
{
U8 *tempData;
convertedData = malloc((len/ENCODING_LENGTH)+1);
tempData=malloc(len/ENCODING_LENGTH);
UnicodeNToAnsii((PS8)tempData,(PS8)data,len);
ConvertAsciiEncodingToDefault(convertedData,tempData,(U16)(len/ENCODING_LENGTH));
OslMfree(tempData);
memset((void *)&convertedData[len/ENCODING_LENGTH],0,1);
if(outLen!=NULL) *outLen=len/ENCODING_LENGTH+1;
}
#endif
break;
#endif
case SAT_8BIT_DCS:
#ifdef __ASCII
convertedData = (U8 *)malloc((len)+1);
memcpy(convertedData,data,len);
memset((void *)&convertedData[len*ENCODING_LENGTH],0,1);
if(outLen!=NULL) *outLen=len+1;
#endif
#ifdef __UCS2_ENCODING
convertedData = malloc((len/ENCODING_LENGTH)+1);
UnicodeNToAnsii((PS8)convertedData,(PS8)data,len);
memset((void *)&convertedData[len/ENCODING_LENGTH],0,1);
if(outLen!=NULL) *outLen=len/ENCODING_LENGTH+1;
#endif
break;
case SAT_UCS2_DCS:
#ifdef __ASCII
convertedData = (U8 *)malloc((len*2)+2);
AnsiiNToUnicodeString((PS8)convertedData,(PS8)data,len);
memset((void *)&convertedData[len*2],0,2);
if(outLen!=NULL) *outLen=len*2+2;
#endif
#ifdef __UCS2_ENCODING
convertedData = malloc((len)+ENCODING_LENGTH);
memcpy(convertedData,data,len);
memset((void *)&convertedData[len],0,ENCODING_LENGTH);
if(outLen!=NULL) *outLen=len+ENCODING_LENGTH;
#endif
#ifdef MMI_ON_HARDWARE_P
{
U16 *tempData;
int i;
tempData=(U16 *)convertedData;
for(i=0;i<len*2/ENCODING_LENGTH;i+=2)
{
SWAP_USHORT(tempData);
tempData++;
}
}
#endif
break;
}
return convertedData;
}
else
{
U8 noOfNulls;
if(format==SAT_UCS2_DCS) noOfNulls=2;
else noOfNulls=1;
convertedData = (U8 *)malloc(noOfNulls);
memset((void *)convertedData,0,noOfNulls);
if(outLen!=NULL) *outLen=noOfNulls;
return convertedData;
}
}
/**************************************************************
FUNCTION NAME : AnsiiNToUnicodeString
PURPOSE : Function to convert ANSII strings to unicode
INPUT PARAMETERS : S8 *pOutBuffer, S8 *pInBuffer, U32 len
OUTPUT PARAMETERS : nil
RETURNS : U16
REMARKS : Returns the string after conversion
**************************************************************/
U16 CSimAppToolkit::AnsiiNToUnicodeString(S8 *pOutBuffer, S8 *pInBuffer, U32 len )
{
S16 count = -1;
U8 charLen = 0;
U8 arrOut[2];
while(len)
{
UnicodeToUCS2Encoding((U16)*pInBuffer,&charLen,arrOut);
pOutBuffer[++count] = arrOut[0];
pOutBuffer[++count] = arrOut[1];
pInBuffer++;
len--;
}
return count + 1;
}
/**************************************************************
FUNCTION NAME : UnicodeToUCS2Encoding
PURPOSE : Converts a UNICODE string to UCS2
INPUT PARAMETERS : U16 unicode,U8 *charLength,U8 *arrOut
OUTPUT PARAMETERS : nil
RETURNS : U8
REMARKS : Conversion of unicode to UCS
**************************************************************/
U8 CSimAppToolkit::UnicodeToUCS2Encoding(U16 unicode,U8 *charLength,U8 *arrOut)
{
U8 status = 1;
U8 index = 0;
if(*arrOut != 0)
{
if( unicode < 256 )
{
arrOut[index++] = *((U8*)(&unicode));
arrOut[index] = 0;
}
else
{
arrOut[index++] = *((U8*)(&unicode));
arrOut[index] = *(((U8*)(&unicode)) + 1);
}
*charLength = 2;
}
else
{
status = 0;
}
return status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -