예제 #1
0
// ----------------------------------------------------------------------------------------
// CFMSServer::WriteToFile() 
// ----------------------------------------------------------------------------------------
void CFMSServer::WriteToFile(TInt aReason, TInt aBearer,TDriveNumber aDrive,
		TInt aSize, TBool aWcdmaBearer )
	{
	if(iSessionCount == 0)
		{
		FLOG(_L("CFMSServer::WriteToFile- begin"));
		TInt err=iFile.Open(iFs,KFotaInterruptFileName,EFileWrite);
		if(err == KErrNone)
			{
			FLOG(_L("CFMSServer::WriteToFile--passed"));
			TBuf8<30> data;//size 30 or 32--as args is 16 bytes
			TBuf8<30> temp;
			temp.Num(aReason);
			data.Append(temp);
			data.Append(',');
			temp.Num(aBearer);// or use iFMSinterruptAob's iBearer
			data.Append(temp);
			data.Append(',');
			temp.Num((TInt)aDrive);
			data.Append(temp);
			data.Append(',');
			temp.Num(aSize);  
			data.Append(temp);
			data.Append(',');
			temp.Num(aWcdmaBearer);
			data.Append(temp);
			iFile.Write(data);
			iFile.Close();
			}
		else
			FLOG(_L("CFMSServer::WriteToFile- Failed"));
		}
	else
		FLOG(_L("CFMSServer::WriteToFile- not done as another request is there"));
	}
// ---------------------------------------------------------------------------------
// CUpnpTmFilteredAppList::IconLookUp
// Performs the icon look up
// Checks if the requested icon and given icon matches
// @param aIcon Reference to the Terminal Mode Icon object
// @return Returns boolean value(true or false)
// ---------------------------------------------------------------------------------
//
TBool CUpnpTmFilteredAppList::IconLookUp( CUpnpTerminalModeIcon& aIcon  )
    {
    OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_ICONLOOKUP_ENTRY );
    TBool matchFound(EFalse);
    const TDesC8& filterMimeType = iFilterInfo->MimeType();
    const TDesC8& filterWidth = iFilterInfo->Width();
    const TDesC8& filterHeight = iFilterInfo->Height();
    const TDesC8& filterDepth = iFilterInfo->Depth(); 

    // Check whether the icon is meant to be used only at launch time
    TBuf8<UpnpString::KShortStringLength> widthBuf;
    widthBuf.Num(aIcon.Width());
    TBuf8<UpnpString::KShortStringLength> heightBuf;
    heightBuf.Num(aIcon.Height());
    TBuf8<UpnpString::KShortStringLength> depthBuf;
    depthBuf.Num(aIcon.Depth());
    /* Check if the icon in provided in the input filter string, and if so
       then does it match with the desired icon ( type and dimension ) */
    if ( (( filterMimeType.Length() == 0 ) ||( (aIcon.MimeType()).MatchC(filterMimeType) != KErrNotFound))
         && (( filterWidth.Length() == 0 ) ||( widthBuf.MatchC(filterWidth) != KErrNotFound))
         && (( filterHeight.Length() == 0 ) ||( heightBuf.MatchC(filterHeight) != KErrNotFound))
         && (( filterDepth.Length() == 0 ) ||( depthBuf.MatchC(filterDepth) != KErrNotFound)))
            {
            matchFound = ETrue;
            }
    OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_ICONLOOKUP_EXIT );
    return matchFound;
    }
예제 #3
0
TInt CEventLogger::UpdateLogEventParam(CLogEvent& aLogEvent, TInt aRConnectionStatusId, const TUid& aDataEventType, const TInt64& aBytesSent, const TInt64& aBytesReceived)
{

    TTime time;
    TInt ret =KErrNone;
    time.UniversalTime();
    TTimeIntervalSeconds interval(0);
    if (time.SecondsFrom(iCurrentLogEvent->Time(),interval) != KErrNone)
    {
        interval = 0;	// no duration available ->error
    }
    if (KConnectionStatusIdNotAvailable != aRConnectionStatusId)
    {
        //status needs to be updated
        TBuf<KLogMaxStatusLength > logStatusBuf;
        iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok
        aLogEvent.SetStatus(logStatusBuf);
    }
    if ( aDataEventType != TUid::Null())
    {
        aLogEvent.SetEventType(aDataEventType);
    }
    aLogEvent.SetDuration(interval.Int());		//0 or not
    //check if data metrics need to be updated
    TInt64 byteInfoNotAvailable(KBytesInfoNotAvailable);
    if ((aBytesReceived != byteInfoNotAvailable) && (aBytesSent != byteInfoNotAvailable))
    {
        TBuf8<KDatabufferSize> dataBuffer;
        dataBuffer.Num(aBytesSent);
        dataBuffer.Append(TChar(','));
        dataBuffer.AppendNum(aBytesReceived);
        TRAP(ret, aLogEvent.SetDataL(dataBuffer));
    }
    return ret;
}
TInt CSenLayeredXmlProperties::SetIntPropertyL(const TDesC8& aName,
                                               const TInt aValue)
    {
    TBuf8<KFlatBufSize> buffer;
    buffer.Num(aValue);
    return SetPropertyL(aName, buffer);
    }
// -----------------------------------------------------------------------------
//  CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
// const TDesC8& aLUID, const TDesC8& aType, const TInt aResultsRef, 
// const TInt aStatusRef )
// -----------------------------------------------------------------------------
void CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
                                                    const TDesC8& /*aLUID*/, 
                                                    const TDesC8& aType, 
                                                    const TInt aResultsRef, 
                                                    const TInt aStatusRef )
    {
    _DBG_FILE("CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL(): begin");

    CBufBase *object = CBufFlat::NewL( 1 );
    CleanupStack::PushL( object );
    CSmlDmAdapter::TError retValue = FetchLeafObjectL( aURI, *object );

    TInt objSizeInBytes = object->Size();
    TBuf8<KNSmlMaxSizeBufferLength> stringObjSizeInBytes;
    stringObjSizeInBytes.Num( objSizeInBytes );
    object->Reset();
    object->InsertL( 0, stringObjSizeInBytes );
    
    iDmCallback->SetStatusL( aStatusRef, retValue );
    iDmCallback->SetResultsL( aResultsRef, *object, aType);
    CleanupStack::PopAndDestroy(); //object 

            
    _DBG_FILE("CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL(): end");
    }
예제 #6
0
void CSTPreferences::SaveSettingL(RFile& aFile, const TDesC8& aSettingName, const TDesC& aSettingValue)
{
	aFile.Write(aSettingName);
	aFile.Write(KLit8Colon);
	
	
	HBufC8* encodedSettingValue = ConvertToUtf8L(aSettingValue);
	if (encodedSettingValue)
	{
		CleanupStack::PushL(encodedSettingValue);
		
		TBuf8<16> settingLength;
		settingLength.Num(encodedSettingValue->Length());
		aFile.Write(settingLength);
		
		aFile.Write(KLit8EqualSign);
		aFile.Write(*encodedSettingValue);
		CleanupStack::PopAndDestroy(); // encodedSettingValue
	}
	else
	{
		_LIT8(KLit8Unset, "0=");
		aFile.Write(KLit8Unset);
	}
	
	aFile.Write(KLit8EndLine);
}
void CRightsCriteriaCount::WriteDescription(RFile& aFile)
	{
	TBuf8 <10> count;
	count.Num(iCount);
	aFile.Write(_L8("Count = "));
	aFile.Write(count);
	aFile.Write(_L8("\r\n"));
	}
// -----------------------------------------------------------------------------
// CSIPParamContainerBase::SetParamL
// -----------------------------------------------------------------------------
//
void CSIPParamContainerBase::SetParamL(RStringF aName, TReal aValue)
	{
	TBuf8<KMaxNumericValueAsTextLength> valueAsText;
	TRealFormat format;
	const TChar KDotChr = '.';
	format.iPoint = KDotChr; // SIP uses always dot as a decimal point
	User::LeaveIfError(valueAsText.Num(aValue,format));
	SetParamL(aName, valueAsText);
	}	
예제 #9
0
// -----------------------------------------------------------------------------
// CUpnpObjectBean::AttachRefIdL
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CUpnpObjectBean::AttachRefIdL(TXmlEngElement aElement)
{
    if(ObjRefId() != CUpnpObjectBean::KUndef)
    {
        TBuf8<KMaxIntegerLen> num;
        num.Num(ObjRefId());
        aElement.AddNewAttributeL( KRefID(), num );
    }
}
void CHttpController::SendRequestL( TInt aMethodIndex, const TDesC8& aUri, CHttpHeaders* aHeaders )
	{
	if ( !iObserver )
		{
		User::Leave( KErrHttpInvalidObserver );
		}
	RStringF method = iSession.StringPool().StringF( aMethodIndex, RHTTPSession::GetTable() );

	TUriParser8 uri;
	uri.Parse( aUri );
	iTransaction = iSession.OpenTransactionL( uri, *this, method );
	RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();

	RArray< TInt > addedElements;
	CleanupClosePushL( addedElements );

	SetHeaderL( HTTP::EUserAgent, hdr, KUserAgent, addedElements );
	SetHeaderL( HTTP::EConnection, hdr, KClose, addedElements );
	SetHeaderL( HTTP::EAccept, hdr, KAccept, addedElements );
	SetHeaderL( HTTP::EHost, hdr, uri.Extract( EUriHost ), addedElements );

	TInt count( iPersistentHeaders->Count() );
	for ( TInt i( 0 ); i < count; ++i )
		{
		if ( addedElements.FindInOrder( i ) >= 0 )
			{
			continue;
			}
		SetHeaderL( hdr, iPersistentHeaders->Key( i ), iPersistentHeaders->Value( i ) );
		}

	CleanupStack::PopAndDestroy( &addedElements );
	if ( aHeaders )
		{
		TInt count( aHeaders->Count() );
		for ( TInt i( 0 ); i < count; ++i )
			{
			SetHeaderL( hdr, aHeaders->Key( i ), aHeaders->Value( i ) );
			}
		}

	if ( aMethodIndex == HTTP::EPOST )
		{
		const TInt KMaxContentLenBufferLength = 100;
		TBuf8< KMaxContentLenBufferLength > contentLength;
		contentLength.Num( iOutputEncoder->OverallDataSize() );
		SetHeaderL( hdr, HTTP::EContentLength, contentLength );
		SetHeaderL( hdr, HTTP::EContentType, KUrlEncodedContentType );
		iTransaction.Request().SetBody( *iOutputEncoder );
		}
	iTransaction.SubmitL();
	StartTimeout();
	iState = EHttpActive;
	}
예제 #11
0
HBufC8* CPolicyPatcher::CreatePatchDataL(const CPolicyPatchInfo* aPatchInfo)
    {
    TInt patchDataLength = 0;

    TBuf8<20> keyBuf;

    const TDesC8& certSubjectName = aPatchInfo->CertSubjectName();

    if (0 == aPatchInfo->UserCertKeyLen())
        {
        // CA cert patch
        patchDataLength = KName().Length() + KNewLine().Length() +
                          KDataField().Length() + KSpace().Length() +
                          certSubjectName.Length();
        }
    else
        {
        // user cert patch
        keyBuf.Num(aPatchInfo->UserCertKeyLen());
        patchDataLength = KDNField().Length() + certSubjectName.Length() +
                          KNewLine().Length() + KKeyLenField().Length() +
                          keyBuf.Length();
        }

    HBufC8* patchData = HBufC8::NewL(patchDataLength);
    CleanupStack::PushL(patchData);

    TPtr8 ptrPatchData(patchData->Des());

    if (0 == aPatchInfo->UserCertKeyLen())
        {
        // CA cert patch
        ptrPatchData.Append(KName);
        ptrPatchData.Append(KNewLine);
        ptrPatchData.Append(KDataField);
        ptrPatchData.Append(KSpace);
        ptrPatchData.Append(certSubjectName);
        }
    else
        {
        // User cert patch
        ptrPatchData.Append(KKeyLenField);
        ptrPatchData.Append(keyBuf);
        ptrPatchData.Append(KNewLine);
        ptrPatchData.Append(KDNField);
        ptrPatchData.Append(certSubjectName);
        iUserCertPatched = ETrue;
        }

    CleanupStack::Pop(); // patchData

    return patchData;
    }
void CSetDRMProtectedTestDevice::DoWriteToFileL(TBool aFlag)
{
    RFs fs;
    CleanupClosePushL(fs);
    User::LeaveIfError(fs.Connect());

    RFile file;
    CleanupClosePushL(file);

    // File doesn't yet exist
    // It is the responsibility of the calling test function to delete the file after use
    User::LeaveIfError(file.Create(fs, KCITestFileName, EFileWrite));
    TBuf8<KMaxCITestFileDataLength> outputBuf;
    outputBuf.Num(aFlag);
    User::LeaveIfError(file.Write(outputBuf));
    CleanupStack::PopAndDestroy(2); // fs, file
}
// ---------------------------------------------------------------------------------
// CUpnpTmClientProfileService::GetMaxNumProfilesActionL
// @param aAction pointer to action object
// @return Returns upnp error code
// ---------------------------------------------------------------------------------
//
TUpnpErrorCode CUpnpTmClientProfileService::GetMaxNumProfilesActionL( CUpnpAction* aAction )
{
    OstTraceFunctionEntry0( CUPNPTMCLIENTPROFILESERVICE_GETMAXNUMPROFILESACTIONL_ENTRY );
    TUint profileCount;
    TTerminalModeErrorCode ret = iTmServerImpl.GetMaxNumProfiles( profileCount );
    if ( ret != ETerminalModeSuccess )
    {
        OstTrace0( TRACE_ERROR, DUP1_CUPNPTMCLIENTPROFILESERVICE_GETMAXNUMPROFILESACTIONL, "CUpnpTmClientProfileService::GetMaxNumProfilesActionL" );
        return TUpnpErrorCode( ret );
    }
    OstTrace1( TRACE_NORMAL, CUPNPTMCLIENTPROFILESERVICE_GETMAXNUMPROFILESACTIONL, "CUpnpTmClientProfileService::GetMaxNumProfilesActionL;profileCount=%d", profileCount );
    TBuf8<UpnpString::KMaxTUintLength> countBuf;
    countBuf.Num(profileCount);

    aAction->SetArgumentL( KNumProfilesAllowed, countBuf );
    OstTraceFunctionExit0( CUPNPTMCLIENTPROFILESERVICE_GETMAXNUMPROFILESACTIONL_EXIT );
    return EHttpOk;
}
EXPORT_C void CSenBaseIdentityManager::UpdateTouchIdentityDBL(MSenServiceDescription& asd)
	{
	CSenIdentityProvider* Idp = NULL;
	
	Idp = iIdentity->IdentityProviderL(asd);
	if(Idp != NULL)
		{
		TUint32 current_tick(0);
		TBuf8<32> tickBuf;
				
		CSenElement& IdpElem = Idp->AsElement();
		current_tick = User::NTickCount();
		tickBuf.Num(current_tick);
		IdpElem.AddAttrL(KTouch(), tickBuf);
		}
//	CleanupUnusedIdentityDBL();   
                                  // (don't de-serialize old items). Serialized 
	                              // objects cannot be de-allocated on the fly.
	}
// create a custom interface Mux implementation
MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDevSoundCIMuxUtility::CreateCustomInterfaceMuxL(TUid aInterfaceId)
	{
	// The Uid of the plugin will be used as string for matching the best suitable plug in.
	TInt uidAsInteger = aInterfaceId.iUid;
	TBuf8<KMuxTempBufferSize> tempBuffer;
	tempBuffer.Num(uidAsInteger, EHex);
	TUid interfaceUid = {KUidDevSoundCustomInterfaceMux};
	
	TUid destructorKey;
	MMMFDevSoundCustomInterfaceMuxPlugin* self = 
		static_cast<MMMFDevSoundCustomInterfaceMuxPlugin*>
		(MmPluginUtils::CreateImplementationL(interfaceUid, destructorKey, tempBuffer, KRomOnlyResolverUid));

	// pass the destructor key so class can destroy itself
	self->PassDestructorKey(destructorKey);
	CleanupReleasePushL(*self);

	// attempt to construct the plugin
	self->CompleteConstructL(this);
	CleanupStack::Pop(); // self
		
	return self;
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::GetProcessDataL
// ----------------------------------------------------------------------------------------
CBufFlat* CTerminalControlServer::GetProcessDataL( const TDesC8 &aProcessName, TDesC8 &aDataName )
{
    RDEBUG("CTerminalControlServer::GetProcessDataL");

    _LIT8(KProcessDataFormat,
          "\
<process-information name=\"%S\">\r\n\
\t<process-data name=\"%S\" value=\"%S\"/>\r\n\
</process-information>\r\n\
");

    TTcProcessInfo info = FindLocalProcessInfoL( aProcessName );

    CBufFlat* processData;
    processData = 0;
    processData = CBufFlat::NewL(128);
    CleanupStack::PushL( processData );

    // Set process data
    if(aDataName == _L8("ID"))
    {
        TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf;
        numBuf.Num((TUint)info.iId);
        processData->InsertL(0, numBuf);
    }
    else if(aDataName == _L8("FromRAM"))
    {
        TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf;
        numBuf.Num((TUint)!info.iCodeInRom);
        processData->InsertL(0, numBuf);
    }
    else if(aDataName == _L8("MemoryInfo"))
    {
        TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> valueBuf;
        valueBuf.Num((TUint)info.iMemoryInfo.iCodeSize+
                     info.iMemoryInfo.iConstDataSize+
                     info.iMemoryInfo.iInitialisedDataSize+
                     info.iMemoryInfo.iUninitialisedDataSize);

        TInt responseLength = KProcessDataFormat().Length() + aProcessName.Length()
                              + aDataName.Length() + valueBuf.Length();

        HBufC8* buffer = HBufC8::NewLC( responseLength );

        buffer->Des().Format( KProcessDataFormat, &aProcessName, &aDataName, &valueBuf );
        processData->InsertL(0, *buffer);

        CleanupStack::PopAndDestroy( buffer );
    }
    else if(aDataName == _L8("Filename"))
    {
        TBuf8<sizeof(TFileName)> fname;
        fname.Copy(info.iFileName);
        processData->InsertL(0, fname);
    }
    else
    {
        User::Leave( KErrNotFound );
    }

    CleanupStack::Pop( processData );

    return processData;
}
예제 #17
0
// ---------------------------------------------------------
// CNSmlCmdsBase::DoSyncHdrL
// Makes SyncHdr element and calls parser to generate xml
// ---------------------------------------------------------
EXPORT_C void CNSmlCmdsBase::DoSyncHdrL() 
	{
	// create generator instance first
	if ( !iGenerator )
		{
		iGenerator = new( ELeave ) CWBXMLSyncMLGenerator( iVersionPublicId );
		}
	// create workspace
	iGenerator->CreateWorkspaceL( iWorkspaceSize );
	//initialise SyncHdr
	SmlSyncHdr_t* syncHdr = new( ELeave ) SmlSyncHdr_t; 
	CleanupStack::PushL( syncHdr );
	//element type
	syncHdr->elementType = SML_PE_HEADER;
	//VerDTD element  
	
//1.2 CHANGES: 1.2 and 1.1 version support
	PcdataNewL ( syncHdr->version, *iVerDTD );
//changes end
	
	//VerProto element  
	PcdataNewL ( syncHdr->proto, *iVerProto );
	//sessionID element
	PcdataNewL ( syncHdr->sessionID, *iSessionID );
	//msgID element
	TBuf8<16> stringMsgID; 
	stringMsgID.Num( ++iCurrMsgID );
	PcdataNewL( syncHdr->msgID, stringMsgID );
	//Target element
	delete iSentSyncHdrTarget;
	iSentSyncHdrTarget = NULL;
	if ( iRespURI )
		{
		// Target changes if a server has issued RespURI in previous message
		DoTargetL( syncHdr->target, iRespURI->HostName() );
		iSentSyncHdrTarget = CNSmlURI::NewL( iRespURI->HostName() );
		}
	else
		{
		DoTargetL( syncHdr->target, iSyncServer->HostName() ); 
		iSentSyncHdrTarget = CNSmlURI::NewL( iSyncServer->HostName() );
		}
	//Source element
	HBufC* imeiCode = HBufC::NewLC( 50 );
	TPtr imeiCodePtr = imeiCode->Des();  
	iPhoneInfo->PhoneDataL( CNSmlPhoneInfo::EPhoneSerialNumber, imeiCodePtr );
	CNSmlAgentBase::TAuthenticationType authType;
	authType = iAgent->AuthTypeL();
	if ( ( !iAlreadyAuthenticated ) &&  ( authType == CNSmlAgentBase::EMD5 ) )
		{
		DoSourceL( syncHdr->source, imeiCodePtr, *iSyncMLUserName);
		}
	else
		{
		DoSourceL( syncHdr->source, imeiCodePtr ); 
		}
	delete iSentSyncHdrSource;
	iSentSyncHdrSource = NULL;
	iSentSyncHdrSource = CNSmlURI::NewL( *imeiCode );
	CleanupStack::PopAndDestroy(); //imeiCode
	// Cred element 
	if ( authType == CNSmlAgentBase::ENoAuth || iAgent->AlreadyAuthenticated() )
		{
		syncHdr->cred = NULL;
		}
	else
		{
		syncHdr->cred = new( ELeave ) SmlCred_t;
		SmlMetInfMetInf_t* metInf;
		DoMetInfLC( metInf ); 
		if ( authType == CNSmlAgentBase::EMD5 )
			{
			PcdataNewL( metInf->type, KNSmlAgentAuthMD5 );
			PcdataNewL( metInf->format, KNSmlAgentBase64Format );
			}
		else  // Basic
			{
			PcdataNewL( metInf->type, KNSmlAgentAuthBasic );
			}
		DoMetaL( syncHdr->cred->meta, metInf );
		CleanupStack::Pop(); //metInf

		HBufC8* credential;
		if ( authType == CNSmlAgentBase::EMD5 )
			{
			credential = iAgent->Md5CredentialL();
			}
		else // Basic
			{
			credential = iAgent->BasicCredentialL();
			}
		CleanupStack::PushL( credential ); 
		PcdataNewL ( syncHdr->cred->data, *credential );
		CleanupStack::PopAndDestroy(); //credential
		}
	// MaxMsgSize
	SmlMetInfMetInf_t* maxMsgMetInf;
	DoMetInfLC( maxMsgMetInf );
	TBuf<16> maxMsgSize;
	maxMsgSize.Num( iWorkspaceSize );
	HBufC8* maxMsgSizeInUTF8 = NULL;
	NSmlUnicodeConverter::HBufC8InUTF8LC( maxMsgSize, maxMsgSizeInUTF8 );
	PcdataNewL( maxMsgMetInf->maxmsgsize, *maxMsgSizeInUTF8 );
	CleanupStack::PopAndDestroy(); //maxMsgSizeInUTF8
	if ( iSynchHdrMaxObjSize > 0 )
		{
		DoMaxObjSizeL( *maxMsgMetInf, iSynchHdrMaxObjSize );
		}
	DoMetaL( syncHdr->meta, maxMsgMetInf );
	CleanupStack::Pop(); //maxMsgMetInf
	TInt ret;
	ret = iGenerator->smlStartMessage( syncHdr );
	if ( ret != KWBXMLGeneratorOk )
		{
		User::Leave( ret );
		}
	CleanupStack::PopAndDestroy(); //syncHdr
	iCurrCmdID = 0;
	//save Status response information for response status controlling
	CreateAndInitResponseItemL( KNSmlAgentSyncHdr );
	}
예제 #18
0
void CSTTrackerConnection::CreateUriL()
{
	TInetAddr localAddress;
	TInt getAddressRes = KErrGeneral;
	// only send IP if we are connected via proxy
	//if (Preferences()->IncomingConnectionsMode() == EEnabledWithProxy)
	//	getAddressRes = iNetMgr->Address(localAddress);
	
	CBufFlat* uriBuf = CBufFlat::NewL(512);
	CleanupStack::PushL(uriBuf);
	
	//TPtrC8 activeTracker = iTorrent.AnnounceList()->ActiveAddress();
	//LWRITE(iLog, _L("Active tracker: "));
	//LWRITELN(iLog, activeTracker);
	
	uriBuf->InsertL(uriBuf->Size(), *iAddress);
	uriBuf->InsertL(uriBuf->Size(), _L8("?"));
	
	uriBuf->InsertL(uriBuf->Size(), _L8("info_hash="));	
	HBufC8* encoded = EscapeUtils::EscapeEncodeL(iTorrent.InfoHash(), EscapeUtils::EEscapeUrlEncoded);
	CleanupStack::PushL(encoded);
	uriBuf->InsertL(uriBuf->Size(), *encoded);
	CleanupStack::PopAndDestroy(); // encoded
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&peer_id="));
	encoded = EscapeUtils::EscapeEncodeL(TorrentMgr()->PeerId(), EscapeUtils::EEscapeUrlEncoded);
	CleanupStack::PushL(encoded);
	uriBuf->InsertL(uriBuf->Size(), *encoded);
	CleanupStack::PopAndDestroy(); // encoded
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&key="));
	TBuf8<32> keyBuf;
	keyBuf.Num(TorrentMgr()->Key());
	uriBuf->InsertL(uriBuf->Size(), keyBuf);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&port="));
	TBuf8<32> portBuf;
	if (getAddressRes == KErrNone)
		portBuf.Num(localAddress.Port());
	else
		portBuf.Num(Preferences()->IncomingPort());
	uriBuf->InsertL(uriBuf->Size(), portBuf);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&uploaded="));
	TBuf8<24> bytesUploaded;
	bytesUploaded.Num(iTorrent.BytesUploaded());
	uriBuf->InsertL(uriBuf->Size(), bytesUploaded);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&downloaded="));
	TBuf8<24> bytesDownloaded;
	bytesDownloaded.Num(iTorrent.BytesDownloaded());
	uriBuf->InsertL(uriBuf->Size(), bytesDownloaded);
	
	uriBuf->InsertL(uriBuf->Size(), _L8("&left="));
	TBuf8<24> bytesLeft;
	bytesLeft.Num(iTorrent.BytesLeft());
	uriBuf->InsertL(uriBuf->Size(), bytesLeft);

	// it seems that some trackers support only compact responses
	uriBuf->InsertL(uriBuf->Size(), _L8("&compact=1"));

	if (iEvent != ETrackerEventNotSpecified)
	{
		uriBuf->InsertL(uriBuf->Size(), _L8("&event="));
		
		switch (iEvent)
		{
			case ETrackerEventStarted:
				uriBuf->InsertL(uriBuf->Size(), _L8("started"));
			break;
			
			case ETrackerEventStopped:
				uriBuf->InsertL(uriBuf->Size(), _L8("stopped"));
			break;
			
			case ETrackerEventCompleted:
				uriBuf->InsertL(uriBuf->Size(), _L8("completed"));
			break;
			
			default:
			break;
		}
	}
	
	if (getAddressRes == KErrNone)
	{
		TBuf<64> ipBuf;
		localAddress.Output(ipBuf);
		TBuf8<64> ipBuf8;
		ipBuf8.Copy(ipBuf);
		
		uriBuf->InsertL(uriBuf->Size(), _L8("&ip="));
		uriBuf->InsertL(uriBuf->Size(), ipBuf8);
		
		#ifdef LOG_TO_FILE
		// debug info
		LWRITE(iLog, _L("Sent to tracker: "));
		LWRITE(iLog, ipBuf);
		TBuf8<32> portBuf;
		portBuf.Num(localAddress.Port());
		LWRITE(iLog, _L(":"));
		LWRITELN(iLog, portBuf);
		#endif
		//		
	}
	
	iUri = uriBuf->Ptr(0).AllocL();
	CleanupStack::PopAndDestroy(); // uriBuf
	
	//iLog->WriteL(_L("[Trackerconnection] GET "));
	//iLog->WriteLineL(*iUri);
}
예제 #19
0
void CWspHeaderReader::DecodeWellKnownParamTokenL(TWspPrimitiveDecoder& aDecoder, TInt& aBytesRead,
												  TPtrC8& aRawParamBlock, CHeaderFieldPart& aHeaderFieldPart) const
	{
	TInt err = 0;
	TUint32 parameterToken = 0;
	aBytesRead = aDecoder.Integer(parameterToken);
	THTTPHdrVal paramValue;
	RStringF paramDesValue;
	CleanupClosePushL(paramDesValue);
	RStringF paramName = iStrPool.StringF(parameterToken, WSPParam::Table);
	switch( parameterToken )
		{
		case WSPParam::EQ:
			{
			// Decode Q value
			TUint32 qIntValue = 0;
			err = aDecoder.UintVar(qIntValue);
			User::LeaveIfError(err);
			aBytesRead += err;
			TReal q;
			TInt numDecimals = 0;
			TBuf8<KMaxNumQDigits> qDesC;
			if( qIntValue > 100 )
				{
				// Value is -100 and then divide by 1000
				qIntValue -= 100;
				q = ((TReal)(qIntValue/1000.));
				numDecimals = 3;
				}
			else
				{
				// Value is -1 and then divide by 100
				--qIntValue;
				if( qIntValue%10 ==0 )
					numDecimals = 1;
				else
					numDecimals = 2;
				q = ((TReal)(qIntValue/100.));
				}
			TRealFormat realFt(KMaxNumQDigits,numDecimals); // set max width and 3 decimal places
			// always use a decimal separator rather than the one supplied 
			// by the current locale
			realFt.iPoint = TChar('.'); 
			qDesC.Num(q, realFt);
			paramDesValue = iStrPool.OpenFStringL(qDesC);
			paramValue.SetStrF(paramDesValue);
			} break;
		case WSPParam::ECharset:
			{
			if( aRawParamBlock[aBytesRead] == 128 )
				{
				paramDesValue = iStrPool.StringF(WSPStdConstants::EAny, WSPStdConstants::Table);
				paramValue.SetStrF(paramDesValue);
				// Need to call Integer to update offset in WSP Decoder
				TUint8 updateDecoder =  0;
				err = aDecoder.Val7Bit(updateDecoder);
				User::LeaveIfError(err);
				aBytesRead += err;
				}
			else
				{
				switch( aDecoder.VarType() )
					{
					case TWspPrimitiveDecoder::E7BitVal:
					case TWspPrimitiveDecoder::ELengthVal:
						{
						TUint32 value = 0;
						err = aDecoder.Integer(value);
						User::LeaveIfError(err);
						aBytesRead += err;
						GetCharacterSetFromValueL(value, paramDesValue);
						paramValue.SetStrF(paramDesValue);
						} break;
					default:
						User::Leave(KErrCorrupt);
						break;
					}
				}
			} break;
		case WSPParam::ELevel:
			{
			// This is a version value
			err = aDecoder.VersionL(iStrPool,paramDesValue);
			User::LeaveIfError(err);
			aBytesRead += err;
			paramValue.SetStrF(paramDesValue);
			} break;
		case WSPParam::EType:
		case WSPParam::ESize:
		case WSPParam::EPadding:
		case WSPParam::ESEC:
		case WSPParam::EMaxAge:
			{
			TUint32 integerValue = 0;
			err = aDecoder.Integer(integerValue);
			User::LeaveIfError(err);
			aBytesRead += err;
			paramValue.SetInt(integerValue);
			} break;
		case WSPParam::ECreationDate:
		case WSPParam::EModificationDate:
		case WSPParam::EReadDate:
			{
			TDateTime dateTime(1970, EJanuary, 0, 0, 0, 0, 0);
			err = aDecoder.Date(dateTime);
			User::LeaveIfError(err);
			aBytesRead += err;
			paramValue.SetDateTime(dateTime);
			}
		case WSPParam::ENameDep:
		case WSPParam::EFilenameDep:
		case WSPParam::EStartDep:
		case WSPParam::EStartInfoDep:
		case WSPParam::ECommentDep:
		case WSPParam::EDomainDep:
		case WSPParam::EPathDep:
			{
			TPtrC8 textString;
			err = aDecoder.String(textString);
			User::LeaveIfError(err);
			aBytesRead += err;
			paramDesValue = iStrPool.OpenFStringL(textString);
			paramValue.SetStrF(paramDesValue);
			} break;
		case WSPParam::EMAC:
		case WSPParam::EName:
		case WSPParam::EFilename:
		case WSPParam::EStart:
		case WSPParam::EStartInfo:
		case WSPParam::EComment:
		case WSPParam::EDomain:
		case WSPParam::EPath:
			{
			// Check if the string has <no-value> ie <octet 0>
			if( aRawParamBlock[aBytesRead] == 0 )
				{
				paramDesValue = iStrPool.OpenFStringL(KNullDesC8());
				paramValue.SetStrF(paramDesValue);
				// Need to call Integer to update offset in WSP Decoder
				TUint32 updateDecoder =  0;
				err = aDecoder.Integer(updateDecoder);
				User::LeaveIfError(err);
				}
			else
				{
				TPtrC8 textString;
				err = aDecoder.String(textString);
				User::LeaveIfError(err);
				paramDesValue = iStrPool.OpenFStringL(textString);
				paramValue.SetStrF(paramDesValue);
				}
			aBytesRead += err;
			} break;
		case WSPParam::EDifferences:
			{
			aBytesRead += DecodeGenericParamTokenL(aDecoder, iStrTable, paramValue, paramDesValue);
			} break;
		case WSPParam::EContentTypeType:
			{
			aBytesRead += DecodeGenericParamTokenL(aDecoder, WSPContentTypes::Table, paramValue, paramDesValue);
			} break;
		case WSPParam::ESecure:
			{
			// <octet 0> no-value
			paramDesValue = iStrPool.OpenFStringL(KNullDesC8());
			paramValue.SetStrF(paramDesValue);
			// Need to call Integer to update offset in WSP Decoder
			TUint32 updateDecoder =  0;
			err = aDecoder.Integer(updateDecoder);
			User::LeaveIfError(err);
			aBytesRead += err;
			} break;
		default:
			User::Leave(KErrCorrupt);
			break;
		}

	// Add the parameter name and value
	TPtrC8 paramDes(paramName.DesC());
	SetNewParamL(aHeaderFieldPart, paramDes, paramValue);
	CleanupStack::PopAndDestroy(&paramDesValue);
	}
예제 #20
0
//
// 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);
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::GetRunningProcessesL
// ----------------------------------------------------------------------------------------
CBufFlat* CTerminalControlServer::GetRunningProcessesL( )
{
    RDEBUG("CTerminalControlServer::GetRunningProcessesL");

    TFullName    processName;
    TFindProcess findProcess;
    CBufFlat *buffer = CBufFlat::NewL(128);
    iProcessInfoArray->Reset();

    while( KErrNone == findProcess.Next( processName ) )
    {
        TTcProcessInfo info;
        RProcess process;

        if( KErrNone == process.Open( findProcess ) )
        {
            //
            // Add process information to local array
            //
            info.iProcessName = processName;
            info.iFileName    = process.FileName();

            info.iHandle      = process.Handle();
            info.iId          = process.Id();
            info.iSecureId    = process.SecureId();

            info.iProtected   = EFalse;

            process.GetMemoryInfo( info.iMemoryInfo );

            User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            if( !info.iCodeInRom )
            {
                User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            }

            iProcessInfoArray->AppendL( info );

            //
            // Add process also to return buffer
            //
            /*
            TInt appendPosition = buffer->Size();
            if(iProcessInfoArray->Count() >= 2)
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, proName);
                }
            else
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, proName);
                }
            }

            */

            // Enumerate names from 1
            TInt appendPosition = buffer->Size();
            TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf;
            TBuf8<sizeof(KFormatProcessNamePrefix)+20> nameBuf;

            numBuf.Num(iProcessInfoArray->Count());
            nameBuf.Zero();
            nameBuf.Append(KFormatProcessNamePrefix);
            nameBuf.Append(numBuf);

            if(iProcessInfoArray->Count() >= 2)
            {
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, nameBuf);
            }
            else
            {
                buffer->InsertL(appendPosition, nameBuf);
            }
        }
    }
    /*
    	TUint32 flags = Exec::ProcessFlags(KCurrentProcessHandle);
    	if (flags & KProcessFlagSystemPermanent)
    		return ESystemPermanent;
    	if (flags & KProcessFlagSystemCritical)
    		return ESystemCritical;
    	if (flags & KThreadFlagProcessPermanent)
    		return EAllThreadsCritical;
    	return ENotCritical;
    */
    return buffer;
}
예제 #22
0
// -----------------------------------------------------------------------------
// CUpnpSsdpServer::UdpMessageReceivedL
// UDP message received.
// -----------------------------------------------------------------------------
//
void CUpnpSsdpServer::UdpMessageReceivedL( CUdpMessage* aMessage )
    {
    if ( !aMessage )
        {
        return;
        }
    CUpnpSsdpMessage* message = ( CUpnpSsdpMessage* ) aMessage;
   
       // Unless it's response, check if HOST header has explicitly specified port number - 1900
       // If not, then add this port
       if ( !message->IsSsdpResponse() )
           {
           TPtrC8 host = message->GetHeaderValue( KHdrHost );
           
           // : Not found so port is not specified
           if( host.Find( UpnpString::KColon() ) == KErrNotFound )
            {
            TBuf8<KMaxIntegerLength> defaultPort;
               defaultPort.Num( KMulticastPort );
               
               HBufC8* newHost = HBufC8::NewLC( host.Length() +
                                       UpnpString::KColon().Length() +
                                       defaultPort.Length() );
               
               newHost->Des().Zero();
               newHost->Des().Append( host );
               newHost->Des().Append( UpnpString::KColon() );
               newHost->Des().Append( defaultPort );
                   
               message->AddHostL( *newHost );
               CleanupStack::PopAndDestroy(newHost);
            }
           }
   
    if ( iMasterServer )
        {
        iMasterServer->MessageFromMulticastL( message );
        }
    else
        {
        if ( message->IsSsdpMSearch() )
            {
            LOGS( "SSDP *** Search received");
            ResponseL( message );
            // add additional notification to upper-layer 
            // used for detection IP address change
            iSsdpServerObserver->SsdpEventL( message );
            }
        else if (message->IsSsdpNotify())
            {
            LOGS( "SSDP *** Notify received");
            iSsdpServerObserver->SsdpEventL( message );
            }
        else if (message->IsSsdpResponse())
            {
            LOGS( "SSDP *** Response received");
            iSsdpServerObserver->SsdpEventL( message );
            }
        else
            {
            LOGS( "SSDP *** UNKNOWN MESSAGE RECEIVED");
            }
        }
    }
예제 #23
0
// ---------------------------------------------------------------------------
// T_SIPAdapter::CheckSettingsL
// Checks saved settings.
// ---------------------------------------------------------------------------
//
void T_SIPAdapter::CheckSettingsL(  )
    {
    __UHEAP_MARK;

    CSIPProfileRegistryObserver* observer = 
        CSIPProfileRegistryObserver::NewLC(); // CS:1
    CSIPManagedProfileRegistry* registry =
        CSIPManagedProfileRegistry::NewLC( *observer ); // CS:2
    RPointerArray<CSIPProfile> profiles;
    CleanupClosePushL( profiles ); // CS:3
    registry->ProfilesL( profiles );

    EUNIT_ASSERT( 3 == profiles.Count() );

    TUint32 tuintValue( KErrNone );
    TBuf8<100> bufValue;
    TBool boolValue( EFalse );

    // First SIP profile.
    CSIPManagedProfile* profile = 
        static_cast<CSIPManagedProfile*>( profiles[0] );

    const TDesC8* provider1 = NULL;
    profile->GetParameter( KSIPProviderName, provider1 );
    bufValue.Copy( *provider1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProviderId1() == bufValue );

    TSIPProfileTypeInfo type1 = profile->Type();
    bufValue.Num( type1.iSIPProfileClass );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( TSIPProfileTypeInfo::EIms == type1.iSIPProfileClass );

    profile->GetParameter( KSIPAccessPointId, tuintValue );
    bufValue.Num( tuintValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( 1 < tuintValue );
    tuintValue = 0;

    const TDesC8* puid1 = NULL;
    profile->GetParameter( KSIPUserAor, puid1 );
    bufValue.Copy( *puid1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KPublicUsername1() == bufValue );

    profile->GetParameter( KSIPSigComp, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = EFalse;

    profile->GetParameter( KSIPSecurityNegotiation, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = ETrue;

    profile->GetParameter( KSIPAutoRegistration, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = EFalse;

    const TDesC8* proxy1 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPServerAddress, proxy1 );
    bufValue.Copy( *proxy1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyAddress1() == bufValue );

    const TDesC8* proxyUser1 = NULL;
    profile->GetParameter( KSIPPrivateIdentity, proxyUser1 );
    bufValue.Copy( *proxyUser1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KPrivateIdentity1() == bufValue );

    const TDesC8* proxyPw1 = NULL;
    TInt error = profile->GetParameter( KSIPOutboundProxy, KSIPDigestPassword, proxyPw1 );
    
    // Passwords are changed to write only (in API) so can't read the contents.      
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* proxyRealm1 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPDigestRealm, proxyRealm1 );
    bufValue.Copy( *proxyRealm1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyRealm1() == bufValue );

    const TDesC8* registrarUri1 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPServerAddress, registrarUri1 );
    bufValue.Copy( *registrarUri1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarAddr1() == bufValue );

    const TDesC8* registrarPw1 = NULL;
    error = profile->GetParameter( KSIPRegistrar, KSIPDigestPassword, registrarPw1 );
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* registrarRealm1 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPDigestRealm, registrarRealm1 );
    bufValue.Copy( *registrarRealm1 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarRealm1() == bufValue );

    profile->GetParameter( KSIPDefaultProfile, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = EFalse;

    profile->GetParameter( KSIPProfileLocked, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( ETrue == boolValue );
    boolValue = ETrue;

    // Second SIP profile.
    profile = NULL;
    profile = static_cast<CSIPManagedProfile*>( profiles[1] );

    const TDesC8* provider2 = NULL;
    profile->GetParameter( KSIPProviderName, provider2 );
    bufValue.Copy( *provider2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProviderId2() == bufValue );

    TSIPProfileTypeInfo type2 = profile->Type();
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( TSIPProfileTypeInfo::EInternet == type2.iSIPProfileClass );

    profile->GetParameter( KSIPSnapId, tuintValue );
    bufValue.Num( tuintValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( 1 < tuintValue );
    tuintValue = 0;

    const TDesC8* puid2 = NULL;
    profile->GetParameter( KSIPUserAor, puid2 );
    bufValue.Copy( *puid2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KPublicUsername2() == bufValue );

    profile->GetParameter( KSIPSigComp, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    profile->GetParameter( KSIPSecurityNegotiation, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    profile->GetParameter( KSIPAutoRegistration, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    const TDesC8* proxy2 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPServerAddress, proxy2 );
    bufValue.Copy( *proxy2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyAddress2() == bufValue );

    const TDesC8* proxyUsr2 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPDigestUserName, proxyUsr2 );
    bufValue.Copy( *proxyUsr2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyUsername2() == bufValue );

    const TDesC8* proxyPw2 = NULL;
    error = profile->GetParameter( KSIPOutboundProxy, KSIPDigestPassword, proxyPw2 );
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* proxyRealm2 = NULL;
    profile->GetParameter( KSIPOutboundProxy, KSIPDigestRealm, proxyRealm2 );
    bufValue.Copy( *proxyRealm2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProxyRealm2() == bufValue );

    const TDesC8* registrarUri2 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPServerAddress, registrarUri2 );
    bufValue.Copy( *registrarUri2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarAddr2() == bufValue );

    const TDesC8* registrarUsr2 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPDigestUserName, registrarUsr2 );
    bufValue.Copy( *registrarUsr2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarUsername2() == bufValue );

    const TDesC8* registrarPw2 = NULL;
    error = profile->GetParameter( KSIPRegistrar, KSIPDigestPassword, registrarPw2 );
    EUNIT_ASSERT( KErrPermissionDenied == error );
    error = KErrNone;

    const TDesC8* registrarRealm2 = NULL;
    profile->GetParameter( KSIPRegistrar, KSIPDigestRealm, registrarRealm2 );
    bufValue.Copy( *registrarRealm2 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KRegistrarRealm2() == bufValue );

    profile->GetParameter( KSIPDefaultProfile, boolValue );
    bufValue.Num( boolValue );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( EFalse == boolValue );
    boolValue = ETrue;

    // Profile not locked, SIPAdapter did not handle the setting, setting not
    // stored, should return KErrNotFound.
    TInt err = profile->GetParameter( KSIPProfileLocked, boolValue );
    DBG_PRINT_2( "read KSIPProfileLocked from profile, error code %d", err );
    EUNIT_ASSERT( KErrNotFound == err );


    // Third SIP profile.
    profile = NULL;
    profile = static_cast<CSIPManagedProfile*>( profiles[2] );

    const TDesC8* provider3 = NULL;
    profile->GetParameter( KSIPProviderName, provider3 );
    bufValue.Copy( *provider3 );
    EUNIT_PRINT( bufValue );
    EUNIT_ASSERT( KProviderId3() == bufValue );


    profile = NULL;
    // &profiles, registry, observer
    CleanupStack::PopAndDestroy( 3, observer );

    __UHEAP_MARKEND;
    }
	EXPORT_C void StartApplicationL(const TUid& aUid, const TDesC& aDocumentName, TInt aRetryInterval, TApaCommand aCommand)
	{
		TUid appToBeStarted = aUid;
		TInt pushed=0;
#ifdef DEBUG
		RFs fs; User::LeaveIfError(fs.Connect()); 
		CleanupClosePushL(fs); pushed++;
		RFile f; User::LeaveIfError(f.Replace(fs, _L("c:\\processmanagement.txt"), EFileWrite));
		CleanupClosePushL(f); pushed++;

		f.Write(_L8("starting\n"));
#endif
		TInt retries=0;
		LOG(_L8("new'ing ls session..."));
		RApaLsSession *lsp;
		lsp=new (ELeave) RApaLsSession;
		LOG(_L8("\n"));
		CleanupStack::PushL(lsp); ++pushed;
		RApaLsSession& ls(*lsp);

		while(retries<80) {
			TInt i_pushed=0;
			LOG(_L8("connecting ls session..."));
			TInt err=ls.Connect();
			LOG(_L8(": "));
			TBuf8<12> msg; msg.Num(err); msg.Append(_L("\n"));
			LOG(msg);
			if (err==KErrNone) {
				CleanupClosePushL(ls); ++i_pushed;
				pushed+=i_pushed;
				break;
			} else {
				CleanupStack::PopAndDestroy(i_pushed);
			}
			LOG(_L8("waiting..."));
			retries++;
			User::After(TTimeIntervalMicroSeconds32(aRetryInterval*1000));
			LOG(_L8("done.\n"));
		}
		LOG(_L8("ls session created\n"));

		LOG(_L8("creating info..."));
		TApaAppInfo* infop=0;
		infop=new (ELeave) TApaAppInfo;
		LOG(_L8("1 "));
		CleanupStack::PushL(infop); ++pushed;
		LOG(_L8("2 "));
		TApaAppInfo& info(*infop);
		LOG(_L8("done\n"));
	
		RWsSession ws;
		User::LeaveIfError(ws.Connect());
		CleanupClosePushL(ws); ++pushed;
		TApaTaskList tl(ws);
		TApaTask app_task=tl.FindApp(aUid);
		TBool exists=app_task.Exists();
		while( !exists && retries<80) {
			TInt pushed=0;

			LOG(_L8("getting info..."));
			TInt err=ls.GetAppInfo(info, appToBeStarted);
			LOG(_L8("done: "));
			TBuf8<12> msg; msg.Num(err); msg.Append(_L("\n"));
			LOG(msg);
			if (err==KErrNone) {
#ifndef __S60V3__
				CApaCommandLine* cmd=CApaCommandLine::NewLC(info.iFullName); pushed++;
#else
				CApaCommandLine* cmd=CApaCommandLine::NewLC(); pushed++;
				cmd->SetExecutableNameL(info.iFullName);
#endif
				cmd->SetCommandL( aCommand );
				if ( aDocumentName.Length() > 0 )
					{					
					cmd->SetDocumentNameL(aDocumentName);
					}
#ifndef __S60V3__
				TRAP(err, EikDll::StartAppL(*cmd));
#else
				err=ls.StartApp(*cmd);
#endif
				CleanupStack::PopAndDestroy(pushed);
				LOG(_L8("StartAppL: "));
				msg.Num(err); msg.Append(_L("\n"));
				LOG(msg);
				if (err==KErrNone) break;	
			} else {
				LOG(_L8("popping..."));
				CleanupStack::PopAndDestroy(pushed);
				LOG(_L8("done\n"));
			}
			LOG(_L8("waiting..."));
			retries++;
			User::After(TTimeIntervalMicroSeconds32(aRetryInterval*1000));
			LOG(_L8("done.\n"));
		}
		LOG(_L8("done\n"));
		CleanupStack::PopAndDestroy(pushed);
	}
예제 #25
0
// -----------------------------------------------------------------------------
// CUpnpObjectBean::AttachIdL
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CUpnpObjectBean::AttachIdL(TXmlEngElement aElement)
{
    TBuf8<KMaxIntegerLen> num;
    num.Num(ObjId());
    aElement.AddNewAttributeL( KIdAttrName(), num );
}
예제 #26
0
// -----------------------------------------------------------------------------
// CUpnpObjectBean::AttachParentIdL
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CUpnpObjectBean::AttachParentIdL(TXmlEngElement aElement)
{
    TBuf8<KMaxIntegerLen> num;
    num.Num(ObjParentId());
    aElement.AddNewAttributeL( KParentID(), num );
}
void CHttpClientHeaderWriter::EncodeHostL(RHeaderField& aHeader) const
/**
	Encodes the host header. RFC2616 section 14.23

		Host			=	"Host" ":" host [ ":" port ]

	The host header value may be empty.
	@internalComponent
	@param		aHeader	The host header field to encode.
	@leave		RHeaderField::BeginRawDataL
	@leave		RHeaderField::PartsL
	@leave		RHeaderField::WriteRawDataL
	@leave		KErrHttpEncodeHost	There were no parts, or the part value type
									or the parameter value type was not a string
									or a folded string.
*/
	{
	__START_PERFORMANCE_LOGGER();
	// Our convention will be that a string called HTTP::EPort will be used to
	// set a parameter holding the integer port number
	// Check part 1
	THeaderFieldPartIter iter1 = aHeader.PartsL();
	iter1.First();
	if( iter1.AtEnd() )
		{
		User::Leave(KErrHttpEncodeHost);
		}
	const CHeaderFieldPart* part = iter1();
	if( part == NULL)
		{
		User::Leave(KErrHttpEncodeHost);
		}
	THTTPHdrVal pt1val = part->Value();
	if( pt1val.Type() != THTTPHdrVal::KStrFVal )
		{
		User::Leave(KErrHttpEncodeHost);
		}
	// Write the host string
	RStringF hostStr = pt1val.StrF();
	aHeader.BeginRawDataL();
	aHeader.WriteRawDataL(hostStr.DesC());

	// Check for a port number
	THeaderFieldParamIter iter2 = part->Parameters();
	iter2.First();
	if( !iter2.AtEnd() )
		{
		// Got a parameter - if its the port, check then write it
		const CHeaderFieldParam* param = iter2();
		if( !param )
			{
			User::Leave(KErrHttpEncodeHostPort);
			}
		if( param->Name() == iStringPool.StringF(HTTP::EPort,iStringTable) )
			{
			// Get the port value
			THTTPHdrVal portVal = param->Value();
			if (portVal.Type() != THTTPHdrVal::KTIntVal)
				{
				User::Leave(KErrHttpEncodeHostPort);
				}
			TBuf8<KMaxNumPortDigits> portDesC;
			const TInt portValue = portVal.Int();
			if(portValue > KMaxNumPortValue) 
				{
				User::Leave(KErrHttpEncodeHostPort);
				}
			portDesC.Num(portValue);
			aHeader.WriteRawDataL(':');
			aHeader.WriteRawDataL(portDesC);
			}
		}
	aHeader.CommitRawData();
	__END_PERFORMANCE_LOGGER(_L(",CHttpClientHeaderWriter::EncodeHostL()"));
	}