コード例 #1
0
void CLocaLogicImpl::ConstructL()
{
	CALLSTACKITEM_N(_CL("CLocaLogicImpl"), _CL("ConstructL"));

	iDevStats=CDevStats::NewL(AppContext(), iDb);
	iMessageStats=CMessageStats::NewL(AppContext(), iDb);
	iRemote=CLocaRemoteEvents::NewL(AppContext(), this);
	iAcceptedMessages=CAcceptedMsgs::NewL(iDb);

	iBBSubSession=BBSession()->CreateSubSessionL(this);
	iBBSubSession->AddNotificationL(KLocaScriptTuple, ETrue);

	iEvent.iData.SetValue(&iMsgStatus);
	iEvent.iData.SetOwnsValue(EFalse);
	iEvent.iPriority()=CBBSensorEvent::VALUE;

	GetSettingsL();

	Settings().NotifyOnChange(SETTING_LOCA_BLUEJACK_MAX_MESSAGES, this);
	Settings().NotifyOnChange(SETTING_LOCA_BLUEJACK_MAX_RETRIES, this);
	Settings().NotifyOnChange(SETTING_PUBLISH_AUTHOR, this);

	iInterpreter = CSPyInterpreter::NewInterpreterL();
	iCC=CCnvCharacterSetConverter::NewL();
	iCC->PrepareToConvertToOrFromL(KCharacterSetIdentifierIso88591, Fs());
	iFunctions=new (ELeave) CDesC8ArraySeg(4);
	iErrorFunctions=new (ELeave) CDesC8ArraySeg(4);
}
コード例 #2
0
ファイル: rhodesAppView.cpp プロジェクト: 3runo5ouza/rhodes
void CRhodesAppView::InitOptions()
	{
		char* slash = "";
		char* options_page = callGetOptionsPage();
		if (!options_page) {
		options_page = "";
		} else if ( (*options_page!='/')&&(*options_page!='\\') ) {
			slash = "/";
		}
		int len = strlen(get_home_url())+strlen(slash)+strlen(options_page);
		char* sp = (char*) malloc(len+1);
		sprintf(sp,"%s%s%s",get_home_url(),slash,options_page);

		RFs session;
		User::LeaveIfError(session.Connect());
		
		CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewL();
	  	converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, session);
	  
	  	TPtrC8 ptr((const unsigned char*)sp);

	  	int state = CCnvCharacterSetConverter::KStateDefault;
	  	converter->ConvertToUnicode(iOptionsPage, ptr, state);
		
	  	session.Close();
	  	
		free(sp);
	}
コード例 #3
0
ファイル: os_symbian.cpp プロジェクト: evlinsky/FBReader
void ConvertToUnicode(RFs session, TDes16& aUnicode, const char *str)
{
  CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewL();
  converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, session);
  
  TPtrC8 ptr((const unsigned char*)str);

  int state = CCnvCharacterSetConverter::KStateDefault;
  converter->ConvertToUnicode(aUnicode, ptr, state);
}
コード例 #4
0
HBufC8* CRecogStep::ConvertDes16toHBufC8LC(TDesC& source)
	{
	HBufC8 *buf = HBufC8::NewL(source.Length());
	CleanupStack::PushL(buf);
	TPtr8 ptr=buf->Des();

	CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewLC();
	converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierAscii, iTheFs);
	converter->ConvertFromUnicode(ptr, source);
	CleanupStack::PopAndDestroy(converter);
	return buf;
	}
コード例 #5
0
ファイル: formats.cpp プロジェクト: fgroen/ayfly
TFileName ay_sys_getstr(const unsigned char *str, unsigned long length)
{
    CCnvCharacterSetConverter *aCharacterSetConverter = CCnvCharacterSetConverter::NewL();
    RFs aFileServerSession;
    TUint aForeignCharacterSet = KCharacterSetIdentifierAscii;
    // check to see if the character set is supported - if not then leave
    if (aCharacterSetConverter->PrepareToConvertToOrFromL(aForeignCharacterSet,
                    aFileServerSession) != CCnvCharacterSetConverter::EAvailable)
    User::Leave(KErrNotSupported);
    // Create a small output buffer 
    TBuf16<20> outputBuffer;
    TFileName endBuffer;
    // Create a buffer for the unconverted text - initialised with the input descriptor
    TPtrC8 remainderOfForeignText(str, length);
    // Create a "state" variable and initialise it with CCnvCharacterSetConverter::KStateDefault
    // After initialisation the state variable must not be tampered with.
    // Simply pass into each subsequent call of ConvertToUnicode()
    TInt state=CCnvCharacterSetConverter::KStateDefault;
    for(;;) // conversion loop

    {
        // Start conversion. When the output buffer is full, return the number
        // of characters that were not converted
        const TInt returnValue=aCharacterSetConverter->ConvertToUnicode(outputBuffer, remainderOfForeignText, state);
        // check to see that the descriptor isn�t corrupt - leave if it is
        if (returnValue==CCnvCharacterSetConverter::EErrorIllFormedInput)
        User::Leave(KErrCorrupt);
        else if (returnValue<0) // future-proof against "TError" expanding
        User::Leave(KErrGeneral);

        // Do something here to store the contents of the output buffer.
        // Finish conversion if there are no unconverted 
        // characters in the remainder buffer
        endBuffer += outputBuffer;
        if (returnValue==0)
        break;
        
        // Remove converted source text from the remainder buffer.
        // The remainder buffer is then fed back into loop
        remainderOfForeignText.Set(remainderOfForeignText.Right(returnValue));
    }
    delete aCharacterSetConverter;
    return endBuffer;
}
コード例 #6
0
//
//将中文字符转换成Unicode	
HBufC16* CCommonUtils::ConvertToUnicodeFromGBK(const TText8* aStr)
{	
	CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();

	if( converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierGbk,CEikonEnv::Static()->FsSession()) != CCnvCharacterSetConverter::EAvailable)
	{
		delete converter;
		return NULL;
	}

	//TText8  *str = (TText8*)"诺基亚7650C";
	TInt state= CCnvCharacterSetConverter::KStateDefault;

	TPtrC8 source( aStr );
	HBufC* ret = HBufC::NewLC( source.Length() );
	TPtr16 ptr = ret->Des();
	converter->ConvertToUnicode(ptr, source, state);
	CleanupStack::Pop(ret);

	return ret;
}
コード例 #7
0
// -----------------------------------------------------------------------------
// CSTSPinConverter::ConvertToUTF8L
//
// -----------------------------------------------------------------------------
void CSTSPinConverter::ConvertToUTF8L(const TDesC& aPinValue,
                                      TPtr8& aConvertedPIN, TBool aUpperCase)
{

    // RFs for CCnvCharacterSetConverter
    RFs fsSession;
    User::LeaveIfError(fsSession.Connect());
    CleanupClosePushL(fsSession);

    CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();

    // transform pin to UTF8
    if (converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8,
            fsSession) != CCnvCharacterSetConverter::EAvailable)
    {
        User::Leave(KErrNotSupported);
    }

    TInt error = converter->ConvertFromUnicode(aConvertedPIN, aPinValue);

    // check to see that the descriptor isn’t corrupt - leave if it is
    if (error == CCnvCharacterSetConverter::EErrorIllFormedInput)
    {
        User::Leave(KErrCorrupt);
    }
    if (error < 0)
    {
        User::Leave(KErrGeneral);
    }

    //convert to uppercase
    if (aUpperCase)
    {
        aConvertedPIN.UpperCase();
    }

    CleanupStack::PopAndDestroy(converter);
    CleanupStack::PopAndDestroy(&fsSession);

}
コード例 #8
0
// ============================================================================
// CWidgetBackupRegistryXml::FromUnicodeL
// Utility to bundle transcoding to unicode steps.
//
// @since 5.0
// @param aEncoding input buffer encoding
// @param aUnicodeSizeMultiplier how many bytes of input make one unicode char
// @param aInBuf input data in encoding
// @param aOutBuf malloc'ed output buf, caller takes ownership
// @param aFileSession CCnvCharacterSetConverter requires it
// ============================================================================
//
void CWidgetBackupRegistryXml::FromUnicodeL( TInt aEncoding,
                                     TInt aUnicodeSizeMultiplier,
                                     TPtrC16 aInBuf, HBufC8** aOutBuf,
                                     RFs& aFileSession )
    {
    *aOutBuf = NULL;

    // outbuf sizing and alloction
    HBufC8* outBuf = HBufC8::NewLC(aUnicodeSizeMultiplier * (aInBuf.Length() + 1));
    TPtr8 outPtr = outBuf->Des();

    // convert from unicode
    CCnvCharacterSetConverter* charConv = CCnvCharacterSetConverter::NewLC();
    charConv->PrepareToConvertToOrFromL( aEncoding, aFileSession );
    User::LeaveIfError(
        charConv->ConvertFromUnicode( outPtr, aInBuf));
    outPtr.ZeroTerminate();
    CleanupStack::PopAndDestroy( charConv );

    CleanupStack::Pop( outBuf ); 
    *aOutBuf = outBuf;
    }
コード例 #9
0
// ============================================================================
// CWidgetUIConfigHandler::ToUnicodeL
// Utility to bundle transcoding to unicode steps.
//
// @since 3.1
// @param aEncoding input buffer encoding
// @param aUnicodeSizeMultiplier how many bytes of input make one unicode char
// @param aInBuf input data in encoding
// @param aOutBuf malloc'ed output buf, caller takes ownership
// @param aFileSession CCnvCharacterSetConverter requires it
// ============================================================================
//
void CWidgetUIConfigHandler::ToUnicodeL( TInt aEncoding,
                                         TInt aUnicodeSizeMultiplier,
                                         TPtrC8 aInBuf, HBufC16** aOutBuf,
                                         RFs& aFileSession )
    {
    *aOutBuf = NULL;

    // outbuf sizing and alloction
    HBufC16* outBuf = HBufC16::NewLC(aUnicodeSizeMultiplier * aInBuf.Length());
    TPtr16 outPtr = outBuf->Des();

    // convert to unicode
    CCnvCharacterSetConverter* charConv = CCnvCharacterSetConverter::NewLC();
    charConv->PrepareToConvertToOrFromL( aEncoding, aFileSession );
    TInt state = CCnvCharacterSetConverter::KStateDefault;
    TInt rep = 0; // number of unconvertible characters
    TInt rIndx = 0; // index of first unconvertible character
    User::LeaveIfError(
        charConv->ConvertToUnicode( outPtr, aInBuf, state, rep, rIndx ) );
    CleanupStack::PopAndDestroy( charConv );

    CleanupStack::Pop(); // outBuf
    *aOutBuf = outBuf;
    }
コード例 #10
0
ファイル: ENP.CPP プロジェクト: cdaffara/symbiandump-mw2
//
// Get all email services
//
void CEmailNotificationParser::GetEmailServicesL()
	{

	CCnvCharacterSetConverter* charconv = CCnvCharacterSetConverter::NewL();
	CleanupStack::PushL(charconv);
	CArrayFix<CCnvCharacterSetConverter::SCharacterSet> *charsetsAvailable = charconv->CreateArrayOfCharacterSetsAvailableL(iFs);
	CleanupStack::PushL(charsetsAvailable);

	charconv->PrepareToConvertToOrFromL(KUidCharsetISO88591,*charsetsAvailable,iFs);
	
	const TMsvId current = iEntry.Entry().Id();
	iEntry.SetEntryL(KMsvRootIndexEntryId);
	// Get all POP3 and Imap services
	CMsvEntrySelection* rootChildren = iEntry.ChildrenL();
	CleanupStack::PushL(rootChildren);

	TMsvEntry entry;

	CEmailAccounts* accounts = CEmailAccounts::NewLC();

	const TInt count = rootChildren->Count(); 
	TInt j =0;
	while(j < count && iFoundServer ==EFalse)
		{
		// set context to service entry
		iEntry.SetEntryL((*rootChildren)[j]);
		entry = iEntry.Entry(); 
		if (entry.iType == KUidMsvServiceEntry && (entry.iMtm == KUidMsgTypePOP3 || entry.iMtm == KUidMsgTypeIMAP4))
			{
			TBuf8<8> port;

			if(entry.iMtm == KUidMsgTypePOP3)
				{
				// calculate hash value
				CImPop3Settings* settings = new(ELeave)CImPop3Settings;
				CleanupStack::PushL(settings);
 
 				TPopAccount id;
				accounts->GetPopAccountL(entry.Id(), id);
				accounts->LoadPopSettingsL(id, *settings);

				port.Num((TUint)KPOP3DefaultPortNumber);
				iFoundServer = CalcHashValueL( *charconv, settings->LoginName(), settings->ServerAddress(), port);
				}
			else // entry.iMtm == KUidMsgTypeIMAP4
				{
				CImImap4Settings* settings = new(ELeave)CImImap4Settings;
				CleanupStack::PushL(settings);
				
 				TImapAccount id;
				accounts->GetImapAccountL(entry.Id(), id);
				accounts->LoadImapSettingsL(id, *settings);

				port.Num((TUint)KIMAPDefaultPortNumber);
				iFoundServer = CalcHashValueL( *charconv, settings->LoginName(), settings->ServerAddress(), port);
				}
			CleanupStack::PopAndDestroy(); // settings
			}
		j++;
		}

	if(	iFoundServer )
		iServiceMsvId = entry.Id();

	CleanupStack::PopAndDestroy(4, charconv); // charconv, charsetsAvailable, rootChildren, accounts
	
	iEntry.SetEntryL(current);
	}