DMAD_EXPORT_C HBufC8* TDmAdUtil::IntToDes8LC(const TInt aInt) { HBufC8* buf = HBufC8::NewLC(10); //10 = max length of 32bit integer TPtr8 ptrBuf = buf->Des(); ptrBuf.Num(aInt); return buf; }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::IntToDes8L // Converts integer to 8bit descriptor // -------------------------------------------------------------------------- HBufC8* CNSmlDmAOAdapter::IntToDes8L( TInt aLuid ) const { HBufC8* buf = HBufC8::NewL( 10 ); //10 = max length of 32bit integer TPtr8 ptrBuf = buf->Des(); ptrBuf.Num( aLuid ); return buf; }
// ----------------------------------------------------------------------------- // CMceSdpCodec::ConvertTRealToDesLC // ----------------------------------------------------------------------------- // HBufC8* CMceSdpCodec::ConvertTRealToDesLC( const TReal& aConv ) { const TInt KMceMaxTRealLen = 20; HBufC8* buf = HBufC8::NewLC( KMceMaxTRealLen ); TPtr8 ptr = buf->Des(); TRealFormat format; format.iType = KRealFormatGeneral; format.iWidth = KMceMaxTRealLen; format.iPoint = KMceRealPoint; ptr.Num( aConv, format ); return buf; }
TInt CPwrPlugin::ResetAndActivateL(CProfilerSampleStream& aStream) { LOGTEXT(_L("CPwrPlugin::ResetAndActivate() - entry")); // check if sampler enabled if(iSamplerAttributes->At(0).iEnabled) { // create a new listener instance for every trace, destroy it on stop iPowerListener = CProfilerPowerListener::NewL(this); iStream = &aStream; TInt length = this->CreateFirstSample(); iVersion[0] = (TUint8)length; LOGSTRING2("CPwrPlugin::ResetAndActivate() - AddSample, length %d", length); TInt ret = this->AddSample(iVersion, length+1, 0); LOGSTRING2("CPwrPlugin::ConstructL() - sampling period %d", this->iPeriod); HBufC8* iBufRes = HBufC8::NewMaxLC(10); TPtr8 iPtrRes = iBufRes->Des(); // check if sampling rate set to something reasonable, relevant only in SYNC case if(iSamplerAttributes->At(0).iSampleRate != -1) { iPtrRes.Num(iSamplerAttributes->At(0).iSampleRate); } else { iPtrRes.Append(KNullDesC8); } // set disabled SetEnabled(ETrue); // activate power listener ret = iPowerListener->StartL(iPtrRes); LOGTEXT(_L("CPwrPlugin::ResetAndActivate() - exit")); CleanupStack::PopAndDestroy(); if(ret != KErrNone) return ret; } return KErrNone; }
HBufC8 *OrganizerItemGuidTransform::guidLC(const QOrganizerItem &item) { // Read guid from organizer item QString globalUidString = item.guid(); if (globalUidString.isEmpty()) { // Generate a new quid // TODO: is this long enough for us? We could add imei or second random number to it... HBufC8* globalUidBuf = HBufC8::NewLC(KGuidLength); TPtr8 ptr = globalUidBuf->Des(); ptr.Num(qrand()); return globalUidBuf; // ownership passed } else { // Use the given guid HBufC8* globalUidBuf = HBufC8::NewLC(globalUidString.length()); TPtr8 ptr = globalUidBuf->Des(); QByteArray bytes = globalUidString.toUtf8(); ptr = toPtrC8(bytes); return globalUidBuf; // ownership passed } }
// ----------------------------------------------------------------------------- // CNSmlDsProvisioningAdapter::SaveL // ----------------------------------------------------------------------------- void CNSmlDsProvisioningAdapter::SaveL(TInt aItem) { _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): begin"); TPckgBuf<TUint32> uid; RSyncMLDataSyncProfile profile; TBool ret = EFalse; if(iProfiles[aItem]->iServerId != NULL) { RSyncMLDataSyncProfile ProfileToSearch; RArray<TSmlProfileId> arr; iSession.ListProfilesL( arr, ESmlDataSync ); TInt ProfileId = KErrNotFound; CleanupClosePushL(arr); for ( TInt index = 0; index < arr.Count(); index++ ) { TRAPD( error, ProfileToSearch.OpenL(iSession, arr[index], ESmlOpenRead ) ); if ( error == KErrNone ) { if ( ( iProfiles[aItem]->iServerId->Des()).Compare(ProfileToSearch.ServerId() ) == 0 ) { ret = ETrue; ProfileId = (TInt)arr[index]; ProfileToSearch.Close(); break; } } ProfileToSearch.Close(); } CleanupStack::PopAndDestroy( &arr ); if( ret ) { profile.OpenL(iSession, ProfileId , ESmlOpenReadWrite ); } else { profile.CreateL( iSession ); } CleanupClosePushL( profile ); } else { profile.CreateL( iSession ); CleanupClosePushL( profile ); } // ui needs this to be set 0 profile.SetCreatorId(0);//iProfiles[aItem]->iProfile.SetCreatorId(0); profile.SetSanUserInteractionL( iProfiles[aItem]->iServerAlertedAction ); if ( iProfiles[aItem]->iDisplayName ) { profile.SetDisplayNameL( iProfiles[aItem]->iDisplayName->Des() ); } if ( iProfiles[aItem]->iServerId ) { profile.SetServerIdL( iProfiles[aItem]->iServerId->Des() ); } if ( iProfiles[aItem]->iUsername ) { profile.SetUserNameL( iProfiles[aItem]->iUsername->Des() ); } if ( iProfiles[aItem]->iPassword ) { profile.SetPasswordL( iProfiles[aItem]->iPassword->Des() ); } // creates profile -> must be done before opening the connection profile.UpdateL(); RSyncMLConnection connection; connection.OpenL( profile, KUidNSmlMediumTypeInternet.iUid ); CleanupClosePushL( connection ); if ( (iProfiles[aItem]->iVisitParameter && iProfiles[aItem]->iVisitParameter->Data().Length() == uid.MaxLength() ) || iToNapIDInternetIndicator) { TUint apId = 0; TInt ERROR = KErrNone; TInt err1 = KErrNone; if (iToNapIDInternetIndicator) { //Get Access Point from DB or SNAP TRAP(err1, apId = WPAdapterUtil::GetAPIDL()); } else { uid.Copy(iProfiles[aItem]->iVisitParameter->Data() ); RCmManagerExt cmmanagerExt; cmmanagerExt.OpenL(); CleanupClosePushL(cmmanagerExt); RCmConnectionMethodExt cm; cm = cmmanagerExt.ConnectionMethodL( uid()); CleanupClosePushL( cm ); TRAP( ERROR, apId = cm.GetIntAttributeL(CMManager::ECmIapId) ); CleanupStack::PopAndDestroy(2); //cmmanager,cm } //Get default access point in failure of getting AP if (ERROR != KErrNone || err1 != KErrNone) { apId = GetDefaultIAPL(); } HBufC8* iapBuf = HBufC8::NewLC( 8 ); TPtr8 ptrBuf = iapBuf->Des(); ptrBuf.Num( apId ); connection.SetPropertyL( KNSmlIAPId, *iapBuf ); CleanupStack::PopAndDestroy(); //iapBuf } if( iProfiles[aItem]->iHostAddress ) { // see if address contains also port TBool portFound = EFalse; TInt startPos(0); if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTP)==0) { startPos=KNSmlDsProvisioningHTTP().Length(); } else if(iProfiles[aItem]->iHostAddress->Find(KNSmlDsProvisioningHTTPS)==0) { startPos=KNSmlDsProvisioningHTTPS().Length(); } TPtrC uriPtr = iProfiles[aItem]->iHostAddress->Mid(startPos); if(uriPtr.Locate(KNSmlDMColon)!=KErrNotFound) { portFound = ETrue; } if( portFound == EFalse ) { HBufC *uri = 0; // port not found from URI -> see if it is given separately if( iProfiles[aItem]->iPort ) { // parse address and port into URI if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(), iProfiles[aItem]->iPort->Des(), uri ) == KErrNone ) { if(iProfiles[aItem]->iHostAddress) { delete iProfiles[aItem]->iHostAddress; iProfiles[aItem]->iHostAddress = NULL; } iProfiles[aItem]->iHostAddress = uri->Des().AllocL(); } CleanupStack::PopAndDestroy(); // uri } else { // use default port if( CombineURILC( iProfiles[aItem]->iHostAddress->Des(), KNSmlDsDefaultPort(), uri ) == KErrNone ) { if(iProfiles[aItem]->iHostAddress) { delete iProfiles[aItem]->iHostAddress; iProfiles[aItem]->iHostAddress = NULL; } iProfiles[aItem]->iHostAddress = uri->Des().AllocL(); } CleanupStack::PopAndDestroy(); // uri } } connection.SetServerURIL( ConvertTo8LC( iProfiles[aItem]->iHostAddress->Des() ) ); CleanupStack::PopAndDestroy(); // ConvertTo8LC } // set authtype, HTTPUserName, HTTPPassword if( iProfiles[aItem]->iHTTPUserName || iProfiles[aItem]->iHTTPPassword ) { connection.SetPropertyL( KNSmlHTTPAuth, KNSmlTrueVal ); if( iProfiles[aItem]->iHTTPUserName ) { connection.SetPropertyL( KNSmlHTTPUsername, iProfiles[aItem]->iHTTPUserName->Des() ); } if( iProfiles[aItem]->iHTTPPassword ) { connection.SetPropertyL( KNSmlHTTPPassword, iProfiles[aItem]->iHTTPPassword->Des() ); } } else { connection.SetPropertyL( KNSmlHTTPAuth, KNSmlFalseVal ); } connection.UpdateL(); CleanupStack::PopAndDestroy(); // connection if(iProfiles[aItem]->iProtocolVersion == ESmlVersion1_1_2 || iProfiles[aItem]->iProtocolVersion == ESmlVersion1_2 ) { profile.SetProtocolVersionL(iProfiles[aItem]->iProtocolVersion); } TInt iDataProvElementCount = iProfiles[aItem]->iDataProvElement.Count(); _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: before Start"); for ( TInt i = 0; i < iDataProvElementCount; i++ ) { _DBG_FILE( "CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: In"); RSyncMLDataProvider dataProvider; TRAPD(error, dataProvider.OpenL(iSession, iProfiles[aItem]->iDataProvElement[i]->iUid)); if (!error) { CleanupClosePushL(dataProvider); if (ret) { RArray<TSmlTaskId> providers; profile.ListTasksL(providers); TInt dataprovcount = providers.Count(); for (TInt i = 0; i < dataprovcount; i++) { TSmlTaskId taskID = providers[i]; RSyncMLTask task; task.OpenL(profile, taskID); CleanupClosePushL(task); if (dataProvider.Identifier() == task.DataProvider()) { profile.DeleteTaskL(taskID); CleanupStack::PopAndDestroy(); break; } CleanupStack::PopAndDestroy(); } providers.Reset(); providers.Close(); } HBufC* localDB = dataProvider.DefaultDataStoreName().AllocLC(); _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): DB value"); DBG_ARGS( iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des().Ptr()); RSyncMLTask task; task.CreateL( profile, iProfiles[aItem]->iDataProvElement[i]->iUid, iProfiles[aItem]->iDataProvElement[i]->iRemoteDBUri->Des(), localDB->Des()); CleanupClosePushL(task); TRAPD(err, task.UpdateL()); if (err != KErrAlreadyExists && err != KErrNone) { User::Leave(err); } CleanupStack::PopAndDestroy(3); // task, localDB, dataProvider } } _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): Resource For loop: after End"); profile.UpdateL(); iProfiles[aItem]->iProfileId = profile.Identifier(); CleanupStack::PopAndDestroy( &profile ); _DBG_FILE("CNSmlDsProvisioningAdapter::SaveL(): end"); }