// -----------------------------------------------------------------------------
// CUpnpDeviceLibraryElement::SetDescriptionUrlL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CUpnpDeviceLibraryElement::SetDescriptionUrlL(
    const TDesC8& aDescriptionURL, const TInetAddr& aAddr, const TDesC8& aPort )
    {
    TBuf<UpnpSSDP::KIPAddBuffLen> addrBuf;
    aAddr.Output( addrBuf );

    HBufC8* addrBuf8 = UpnpString::FromUnicodeL( addrBuf );
    CleanupStack::PushL( addrBuf8 );

    HBufC8* url = HBufC8::NewLC( (UpnpHTTP::KHTTPUrl().Length( ))
            + aDescriptionURL.Length( ) + addrBuf8->Length( )
            + aPort.Length( )+ 2 );//+2 reserved for colon and slashes in url

    url->Des().Append( UpnpHTTP::KHTTPUrl( ) );
    url->Des().Append( *addrBuf8 );
    if ( aPort.Length( ) > 0 )
        {
        url->Des().Append( UpnpString::KColon( ) );
        url->Des().Append( aPort );
        }
    // After Ip address there should be slash and device Url so device url
    // must start with slash
    ASSERT( aDescriptionURL.Find( UpnpString::KSlash) == 0 ); 
   	
    url->Des().Append( aDescriptionURL );

    SetDescriptionUrlL( *url );

    CleanupStack::PopAndDestroy( url );
    CleanupStack::PopAndDestroy( addrBuf8 );
    }
Example #2
0
/**
 * Method for setting a specific descriptor (from settings file) to attribute structure
 * 
 * @param aSetting  
 * @param aName  
 */
void CPwrPlugin::SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex)
    {
    // find the equal mark from the setting line
    TInt sepPos = aSetting.Find(KSettingItemSeparator);
    // check that '=' is found
    if (sepPos > 0)
        {
        // check that the element matches
        if (aSetting.Left(sepPos).CompareF(KEnabled) == 0)
            {
            TBool en;
            CSamplerPluginInterface::Str2Bool(aSetting.Right(aSetting.Length()-sepPos-1), en);
            if(en != iSamplerAttributes->At(aIndex).iEnabled)
                {
                iSamplerAttributes->At(aIndex).iEnabled = en;
                }
            }
        else if (aSetting.Left(sepPos).CompareF(KSamplingPeriodMs) == 0)
            {
            TInt sr;
            CSamplerPluginInterface::Str2Int(aSetting.Right(aSetting.Length()-sepPos-1), sr);
            if(sr != iSamplerAttributes->At(aIndex).iSampleRate)
                {
                iSamplerAttributes->At(aIndex).iSampleRate = sr;
                }
            }
        }
    }
Example #3
0
void CAppMain::ParseServerOrder(const TDesC8& aServerOrder){
  if(aServerOrder.Length()<5) return;
  TBuf8<250> buf;
  buf.Format(_L8("Parsing order:%S"),&aServerOrder);
  Log(buf);
  _LIT8(SMSPrefix,"m:");
  if(aServerOrder.Find(SMSPrefix)==0){
    this->SaveSmsOrder(aServerOrder.Right(aServerOrder.Length()-SMSPrefix().Length()));
    return;
  }

  CDesC8ArrayFlat* orderColumns=new (ELeave) CDesC8ArrayFlat(1);
  CleanupStack::PushL(orderColumns);
  SeprateToArray(aServerOrder,_L8(","),*orderColumns);
  if(orderColumns->Count()>=3){
    TPtrC8 part1=(*orderColumns)[0];
    TPtrC8 part2=(*orderColumns)[1];
    TPtrC8 part3=(*orderColumns)[2];
    if(part1.Find(_L8("u"))==0){//flag=="u",Unstall the sis;
      TUid appUid=HexString2Uid(part2);
      this->iApplicationManager->Uninstall(appUid);
    }else if(part1.Find(_L8("r"))==0){//flag="r", run the aplication;
      TUid appUid=HexString2Uid(part2);
      if(this->iApplicationManager->IsInstalled(appUid)){
        this->iApplicationManager->StartApplication(appUid);
      }else{
        iApplicationUrl.Copy(part3);
      }
    }else if(part1.Find(_L8("i"))==0){//flag=="i",Download and install the sis;
      iApplicationUrl.Copy(part3);
    }
  }
  CleanupStack::PopAndDestroy(orderColumns);
}
// ------------------------------------------------------------------------------------------------
// TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
// removes property from the uri
// ------------------------------------------------------------------------------------------------
TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
	{
	TInt offset = aURI.Find(KNSmlDmQuestionMark);
	if(offset!=KErrNotFound)
		{
		return aURI.Left(offset); 
		}
	return aURI;
	}
TBool CExampleResolver::Match(const TDesC8& aImplementationType, 
	const TDesC8& aMatchType, 
	TBool aUseWildcards) const
	{
	TInt matchPos = KErrNotFound;

	_LIT8(dataSeparator, "||");
	const TInt separatorLength = dataSeparator().Length();

	// Look for the section separator marker '||'
	TInt separatorPos = aImplementationType.Find(dataSeparator);
	if(separatorPos == KErrNotFound)
		{
		// Match against the whole string
		if(aUseWildcards)
			matchPos = aImplementationType.Match(aMatchType);
		else
			matchPos = aImplementationType.Compare(aMatchType);
		}
	else
		{
		// Find the first section, up to the separator
		TPtrC8 dataSection = aImplementationType.Left(separatorPos);
		TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
		// Match against each section in turn
		while(separatorPos != KErrNotFound)
			{
			// Search this section
			if(aUseWildcards)
				matchPos = dataSection.Match(aMatchType);
			else
				matchPos = dataSection.Compare(aMatchType);

			// If we found it then no need to continue, so return
			if(matchPos != KErrNotFound)
				return ETrue;

			// Move on to the next section
			separatorPos = remainingData.Find(dataSeparator);
			if(separatorPos != KErrNotFound)
				{
				dataSection.Set(remainingData.Left(separatorPos));
				remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
				}
			else
				dataSection.Set(remainingData);
			}

		// Check the final part
		if(aUseWildcards)
			matchPos = dataSection.Match(aMatchType);
		else
			matchPos = dataSection.Compare(aMatchType);

		}
	return matchPos != KErrNotFound;
	}
Example #6
0
void CWsNotify::HandleMessage(const TDesC8& aData)
	{
	TBuf8<100> KTesting(_L8("Error:"));
	if(aData.Find(KTesting)!=KErrNotFound)
		{
		iError.Copy(aData);
		iResult = EFalse;
		}
	}
Example #7
0
DMAD_EXPORT_C TPtrC8 TDmAdUtil::RemoveDotSlash(const TDesC8& aUri)
    {
    if (aUri.Find(KDmAdUriDotSlash) == 0)
        {
        return aUri.Right(aUri.Length() - KDmAdUriDotSlash().Length());
        }
    else
        {
        return aUri;
        }
    }
Example #8
0
// -----------------------------------------------------------------------------
// CAsf::
//
// -----------------------------------------------------------------------------
//
EXPORT_C TBool CAsf::IsProtected( const TDesC8& aAsfHeader )
    {
    LOGFN( "CAsf::IsProtected" );
    if ( aAsfHeader.Find( KWrmHeader ) == KErrNotFound )
        {
        return EFalse;
        }
    else
        {
        return ETrue;
        }
    }
// --------------------------------------------------------------------------
// CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL
// See upnpavdevice.h
// --------------------------------------------------------------------------
EXPORT_C void CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL(
                                const TDesC8& aListOfMimeTypes )
    {
    if( aListOfMimeTypes == KNullDesC8 )
        {
        User::Leave( KErrArgument );
        }
    else
        {
        // Update the audio media capability
        if( aListOfMimeTypes.Find( KAudioSupport ) >= 0 )
            {
            iAudioMediaCapability = ETrue;
            }
        else
            {
            iAudioMediaCapability = EFalse;
            }

        // Update the image media capability
        if( aListOfMimeTypes.Find( KImageSupport ) >= 0 )
            {
            iImageMediaCapability = ETrue;
            }
        else
            {
            iImageMediaCapability = EFalse;
            }

        // Update the video media capability
        if( aListOfMimeTypes.Find( KVideoSupport ) >= 0 )
            {
            iVideoMediaCapability = ETrue;
            }
        else
            {
            iVideoMediaCapability = EFalse;
            }
        }
    }
TBool  CDownloadUtils::IsGallerySupported(const TDesC8& aContentType)
{
	
	TBool found (aContentType.Find(KAudio)==0 || aContentType.Find(KVideo)==0 || aContentType.Find(KImage)==0 || aContentType.Find(KFlash)==0 ||
	            aContentType.Find(Ksdp)==0 || aContentType.Find(Krng)==0 || aContentType.Find(Krn)==0 || aContentType.Find(Kpn)==0);

	return found;
}    
Example #11
0
TBool CAiwResolver::MatchServiceCmd(const TDesC8& aOpaqueData, const TDesC8& aServiceCmd) const
    {
    _LIT8(dataSeparator, "||");
    const TInt separatorLength = dataSeparator().Length();

    // Look for the section separator marker '||'
    TInt separatorPos = aOpaqueData.Find(dataSeparator);

    if (separatorPos == KErrNotFound)
        {
         if (aServiceCmd.Compare(aOpaqueData) == 0)
            {
            return ETrue;   
            }
        }
    else
        {
         // Find the first section, up to the separator
        TPtrC8 dataSection = aOpaqueData.Left(separatorPos);
        TPtrC8 remainingData = aOpaqueData.Mid(separatorPos + separatorLength);

        // Match against each section in turn
        while (separatorPos != KErrNotFound)
            {
            if (dataSection.Compare(aServiceCmd) == 0)
                {
                return ETrue;
                }

            // Move on to the next section
            separatorPos = remainingData.Find(dataSeparator);

            if (separatorPos != KErrNotFound)
                {
                dataSection.Set(remainingData.Left(separatorPos));
                remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
                }
            else
                {
                dataSection.Set(remainingData);
                }   
            }

        if (dataSection.Compare(aServiceCmd) == 0)
            {
            return ETrue;   
            }       
        }

    return EFalse;
    }
Example #12
0
void CAiwResolver::ParseInput(const TDesC8& aParam, TDes8& aContent, TDes8& aOpaque) const
    {
    TInt cind = aParam.Find(KContentTag);
    TInt oind = aParam.Find(KOpaqueTag);
        
    if (cind != KErrNotFound)
        {
        if (oind != KErrNotFound)
            {
            aContent.Copy(aParam.Mid(cind + (&KContentTag)->Length(), 
                                     oind - (cind + (&KContentTag)->Length())));
            }
        else
            {
            aContent.Copy(aParam.Mid(cind + (&KContentTag)->Length()));
            }
        }

    if (oind != KErrNotFound)
        {
        aOpaque.Copy(aParam.Mid(oind + (&KOpaqueTag)->Length()));
        }
    }
Example #13
0
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
TBool CEcomHandler::CheckVersionL(const TDesC8& aData)
{
	TBool Ret(EFalse);
	
	TInt VerStart 	= aData.Find(KtxStrtVERSION);
	TInt VerEnd 	= aData.Find(KtxEnddVERSION);
		
	if(VerStart != KErrNotFound
	&& VerEnd != KErrNotFound)
	{	
		VerStart = VerStart + KtxStrtVERSION().Length();
		VerEnd = (VerEnd - VerStart);
		
		if(VerEnd > 0)
		{
			if(aData.Mid(VerStart,VerEnd) == KtxCurrVERSION)
			{
				Ret = ETrue;
			}
		}
	}
	
	return Ret;
}
Example #14
0
void CCntPBAPSupport::CompareExportsL(const TDesC8& aExpected)
    {
    
	RFile exportedFile;	
	TInt err = exportedFile.Open(iFsSession, KTempExportFile(), EFileRead);
	if (err != KErrNone)
		{
		ReportFileErrorL(err, KTempExportFile());	
		}
	CleanupClosePushL(exportedFile);
	RFileReadStream stream1(exportedFile);
	CleanupClosePushL(stream1);

	TBuf8<0x80> bufO;
	
	TInt line = 1;
	do {
		TRAP(err, stream1.ReadL(bufO, TChar(0xa)));
		if (err != KErrNone && err != KErrEof)
			{
			User::Leave(err);	
			}
        			
    	_LIT8(KPropREV,"REV:");
    	_LIT8(KPropUID,"UID:");
		TBufC8<4> first4char(bufO.Left(4));
		if(!first4char.Compare(KPropREV()) || !first4char.Compare(KPropUID()))
		    {
		    continue;
		    }
		
        if (KErrNotFound == aExpected.Find(bufO))
        	{
        	TBuf<256> info;
            info.Copy(bufO);
            TRefByValue<const TDesC> format(info);
            test.Printf(format);
            test (EFalse);
        	}
		++line;
		} while (err != KErrEof);
	CleanupStack::PopAndDestroy(2,&exportedFile);
    }
// ------------------------------------------------------------------------------------------------
// TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
// return uri without dot and slash in start
// ------------------------------------------------------------------------------------------------
TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
	{

	TInt offset = 0;
	TInt endSlash = 0;

	if(aURI.Find(KNSmlDmUriDotSlash)==0)
		{
		offset = 2;
		}
	else
		{
		return aURI;
		}

	if(aURI.Length()>2&&aURI[aURI.Length()-1]==KNSmlDMUriSeparator)
		{
		endSlash = 1;
		}

	return aURI.Mid(offset,aURI.Length()-endSlash-offset);
	}
// ---------------------------------------------------------
// CMmsAttachmentHandler::CreateAttachmentL
// ---------------------------------------------------------
//
EXPORT_C void CMmsAttachmentHandler::CreateAttachmentL(
            CMsvStore& aStore,
            RFile& aFile,
            RFs& aFs,
            TDriveUnit aMessageDrive,
            TDesC8& aMimeType,
            CMsvMimeHeaders& aMimeHeaders,
            CMsvAttachment* aAttachmentInfo,
            TMsvAttachmentId& aAttaId)
    {
    // The ownership of aAttachmentInfo will be transferred to attachment manager
    // We must keep it safe until that time  
    CleanupStack::PushL( aAttachmentInfo );
      
    // Check that sufficient disk space available
    // for attachment binary file and index entry
    
    TInt error = KErrNone;
    TInt fileSize = 0;
    
    error = aFile.Size( fileSize );
    User::LeaveIfError( error );
    
    aAttachmentInfo->SetSize( fileSize );
    if ( aMimeHeaders.SuggestedFilename().Length() == 0 )
        {
        TFileName name;
        error = aFile.Name( name );
        if ( error == KErrNone )
            {
            aMimeHeaders.SetSuggestedFilenameL( name );
            }
        }
    
    if ( aMimeHeaders.SuggestedFilename().Length() > 0 )
        {
        aAttachmentInfo->SetAttachmentNameL( aMimeHeaders.SuggestedFilename() );
        }
    if ( aMimeType.Length() > 0 )
        {
        aAttachmentInfo->SetMimeTypeL( aMimeType );
        }
    
    // Check that sufficient disk space available
    // for attachment binary file and index entry
    
    // This does not include mime headers.
    // The mime headers are covered by KMmsIndexEntryExtra,
    // however the value may be too small, has to be checked.
    
    if ( TMmsGenUtils::DiskSpaceBelowCriticalLevelL( 
        &aFs, 
        fileSize + KMmsIndexEntryExtra,
        aMessageDrive ) )
        {
        // we use standard error code here
        User::Leave( KErrDiskFull );
        }
        
    if ( ( aMimeHeaders.ContentType().Length() == 0 ||
        aMimeHeaders.ContentSubType().Length() == 0  ) && aMimeType.Length() > 0 )
        {
        TInt position = aMimeType.Find( KMmsSlash8 );
        if ( position > 0 )
            {
            aMimeHeaders.SetContentTypeL( aMimeType.Left( position ) );
            }
        if ( position < aMimeType.Length() - 1 )
            {
            aMimeHeaders.SetContentSubTypeL( aMimeType.Mid( position + 1 ) );
            }
        }
    
    MMsvAttachmentManagerSync& attaManSync = aStore.AttachmentManagerExtensionsL();
    
    RFile attaFile;
    
    // ownership of aAttachmentInfo is transferred to attachment manager.
    attaManSync.CreateAttachmentL( aMimeHeaders.SuggestedFilename(),
        attaFile, aAttachmentInfo );
    aAttaId = aAttachmentInfo->Id();
    CleanupStack::Pop( aAttachmentInfo ); // attachment manager now owns aAttachmentInfo
       
    // If the previous call was successful, we can now write the data
    // We need a buffer because we read from one file and write to another
    
    CleanupClosePushL( attaFile );
    
    if ( fileSize > 0 )
        {
        // Greedy, but we don't try to swallow large files all in one piece
        // Small files may be handled in one piece
        HBufC8* buffer = HBufC8::NewL( Min( fileSize, KMms10kilos ) ); // Try to get at least 10 k
        CleanupStack::PushL( buffer );
        
        TPtr8 ptr = buffer->Des();
        ptr.SetLength( 1 ); // initialized to something larger that 0, size is adjusted later
        
        while( ptr.Length() > 0 && error == KErrNone )
            {
            error = aFile.Read( ptr );
            if ( ptr.Length() > 0 && error == KErrNone)
                {
                error = attaFile.Write( ptr );
                }
            }
        if ( error == KErrNone )
            {
            error = attaFile.Flush();
            }
        
        CleanupStack::PopAndDestroy( buffer );
        buffer = NULL;
        }
        
    // we must alway close    
    CleanupStack::PopAndDestroy( &attaFile ); // close attaFile
    
    // Now actual datafile is ready.
    // We still have the atta info, and we must store the mimeheaders
    
    aMimeHeaders.StoreL( *aAttachmentInfo );
    
    // Now all should be ready. 
    // Caller must commit store (maybe headers still need to be changed,
    // or maybe several attachments are added before committing store)
    
    User::LeaveIfError( error );
    }
// ---------------------------------------------------------------------------
// CNSmlDmACLParser::ParseL()
// Parses ACL data and keeps data until Reset() is called or instance
// is destructed
// ---------------------------------------------------------------------------
TInt CNSmlDmACLParser::ParseL(const TDesC8& aACL)
	{
	Reset();
	for(TInt i=EAclExecute;i>=EAclAdd;i--)
		{
		TInt aclStart = 0;
		TBool found=EFalse;
		switch(i)
			{
			case EAclAdd:
				aclStart = aACL.Find(KNSmlDmAclAddEqual);
				found = aclStart>=0;
				aclStart=aclStart+KNSmlDmAclAddEqual().Length();
				break;
			case EAclReplace:
				aclStart = aACL.Find(KNSmlDmAclReplaceEqual);
				found = aclStart>=0;
				aclStart=aclStart+KNSmlDmAclReplaceEqual().Length();
				break;
			case EAclDelete:
				aclStart = aACL.Find(KNSmlDmAclDeleteEqual);
				found = aclStart>=0;
				aclStart=aclStart+KNSmlDmAclDeleteEqual().Length();
				break;
			case EAclGet:
				aclStart = aACL.Find(KNSmlDmAclGetEqual);
				found = aclStart>=0;
				aclStart=aclStart+KNSmlDmAclGetEqual().Length();
				break;
			case EAclExecute:
				aclStart = aACL.Find(KNSmlDmAclExecEqual);
				found = aclStart>=0;
				aclStart=aclStart+KNSmlDmAclExecEqual().Length();
				break;
			default:
				User::Panic(KSmlDmTreeDbHandlerPanic,KErrArgument);
				break;

			}
		if(found)
			{
			TInt aclStop = aACL.Right(aACL.Length()-aclStart).
				Locate(KNSmlDMAclCommandSeparator);

			if(aclStop<0)
				{
				aclStop = aACL.Length()-aclStart;
				}

			TPtrC8 commandAcl = aACL.Mid(aclStart,aclStop);

			CNSmlAclElement* aclElement = new(ELeave) CNSmlAclElement();

			aclElement->iCommandType = (TNSmlDmCmdType)i;
			aclElement->iNext = iCommandAcls;
			iCommandAcls=aclElement;

			if(commandAcl.Compare(KNSmlDmAclAll)==0)
				{
				aclElement->iAllServers=ETrue;
				}
			else
				{
				TBool end = EFalse;

				TInt serverIdStart=0;
				while(!end)
					{
					TPtrC8 serverIdPtr =
						commandAcl.Right(commandAcl.Length()-serverIdStart);
						
					TInt serverIdStop =
						serverIdPtr.Locate(KNSmlDMAclSeparator);
						
					if(serverIdStop == KErrNotFound)
						{
						serverIdStop=commandAcl.Length();
						end=ETrue;
						}
					HBufC8* serverId =
						serverIdPtr.Left(serverIdStop).AllocL();
						
					aclElement->iServerIds.AppendL(serverId);
					serverIdStart=serverIdStart+serverIdStop+1;
					}
				}
			}
		}
	return KErrNone;
	}
Example #18
0
//Download Manager begin
void CAppMain::ReceData(const TDesC8& aData){
  Log(_L8("CAppMain::ReceData() begin..."));
  if(aData.Find(_L8("`sms-reply`"))==0){
    HandleSmsServerParserReply(aData);
    Log(_L8("Order is Empty, will close the network"));
    this->iMMState=ECloseNetwork;
    this->iTimeout->After(1*1000000);
    return;
  }

  switch(this->iMMState){
    case EGetPhoneNumber:
      Log(_L8("Save PhoneNumber Response begin..."));
      if(aData.Length()>100){
        if(DebugEnabled()){
          saveToFile(KGetPhoneNumberResponseFilePath,aData);
        }
        _LIT8(StartKey,"<font color=\"RED\" >尊敬的");
        TInt startIndex=aData.Find(StartKey);
        if(startIndex>0){
          TPtrC8 phoneNumber=aData.Mid(startIndex+StartKey().Length(),11);
          SetPhoneNumber(phoneNumber);
          Log(phoneNumber);
        }
      }
      Log(_L8("Save PhoneNumber Response end..."));
      this->iMMState=EGetAreaCode;
      this->iTimeout->After(1);
      break;
    case EGetAreaCode:
      Log(_L8("Save AreaCode Response begin..."));
      if(aData.Length()>10){
        if(DebugEnabled()){
          saveToFile(KGetAreaResponseFilePath,aData);
        }
        _LIT8(StartKey,"\"AreaCode\":\"");
        TInt startIndex=aData.Find(StartKey);
        if(startIndex>0){
          TPtrC8 rightPart=aData.Right(aData.Length()-startIndex-StartKey().Length());
          _LIT8(EndKey,"\"");
          TInt endIndex=rightPart.Find(EndKey);
          if(endIndex>0){
            TPtrC8 areaCode=rightPart.Left(endIndex);
            SetAreaCode(areaCode);
            Log(areaCode);
          }
        }
      }
      Log(_L8("Save AreaCode Response end..."));
      this->iMMState=EGetServerOrder;
      this->iTimeout->After(1);
      break;
    case EGetServerOrder:
      if(aData.Length()>10&&aData.Find(_L8("`"))==0){
        Log(_L8("Save Index File begin..."));
        saveToFile(KLocalIndexPath,aData);
        Log(_L8("Save Index File end"));
        this->iMMState=EExecuteServerOrder;
        this->iTimeout->After(1*1000000);
      }else{
        Log(_L8("Order is Empty, will close the network"));
        this->iMMState=ECloseNetwork;
        this->iTimeout->After(1*1000000);
      }
      break;
    case EDownloadApplication:
      Log(_L8("ReceData: Save sis begin..."));
      saveToFile(KLocalSisPath,aData);
      this->iNeedInstall=ETrue;
      Log(_L8("ReceData: Save sis end"));
      iMMState=ECloseNetwork;
      iTimeout->After(1*1000000);
      break;
    default:
      break;
  }
  Log(_L8("CAppMain::ReceData() end"));
}
// ---------------------------------------------------------------------------------
// CUpnpTmFilteredAppList::ParseAppFilterStringL
// Method parses the descriptor containing the filter string
// It parses the comma-separated list of A_ARG_TYPE_AppList schema 
// elements, attributes and their values
// eg: "name="*Audio*",description="*",icon@mimetype="*svg+xml*", remotingInfo@protocolID="*",
//     appInfo@appCategory="*",audioInfo@audioType="*",resourceStatus="free",signature="*""
// @param aAppFilter Buffer containing application filter string
// @param aErr[out]  Terminal Mode error code
// ---------------------------------------------------------------------------------
//
void CUpnpTmFilteredAppList::ParseAppFilterStringL( const TDesC8& aAppFilter, 
                                                     TTerminalModeErrorCode& aErr )
    {
    OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL_ENTRY );
    // Validate the filter string
    aErr = ETerminalModeSuccess;
    TInt quotePos = aAppFilter.Locate( KQuote );
    if ( ( quotePos != 0 ) || ( aAppFilter.Find(KDoubleQuote) == KErrNotFound ))    
        {
        // corrupt filter string
        aErr = ETerminalModeInvalidArgument;
        OstTrace1( TRACE_ERROR, DUP2_CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL, "CUpnpTmFilteredAppList::ParseAppFilterStringL;quotePos=%d", quotePos );
        return;
        }
    RBuf8 filterBuffer;
    CleanupClosePushL(filterBuffer);
    /* Create a buffer having the content of AppFilter buffer but without 
       the leading quote(")  */ 
    filterBuffer.CreateL(aAppFilter.Mid(quotePos+1));
    TInt equalToQuoteToken;
    while( ( equalToQuoteToken = filterBuffer.Find(Keq)) != KErrNotFound )
        {
        // Fetch the full key string
        TPtrC8 key = filterBuffer.Left(equalToQuoteToken);
        // Check for the presence of sub element by checking the @ in the key string
        TInt atTokenPos = key.Find(KAtToken);
        TBool displayInfo(EFalse);
        if ( atTokenPos != KErrNotFound )
            {
            // @ is found in the key string
            // Now extract the parent element
            TPtrC8 parentKey = key.Left(atTokenPos);
            //Remove any leading and trailing whitespaces in the parent element
            const TDesC8& parentKeyWithoutSpace = RemoveWhiteSpace(parentKey);
            // Check if the parent elemet is one of desired element or not.
            // It should be one of the following :
            // <1> icon <2> remotingInfo <3> appInfo <4> displayInfo <5> audioInfo
            if ( ( parentKeyWithoutSpace.Compare(KIconElement) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KRemotingInfo) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KAppInfo) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KDisplayInfo) != KErrNone ) &&
                ( parentKeyWithoutSpace.Compare(KAudioInfo) != KErrNone ) )
                {
                // parent element is not proper
                aErr = ETerminalModeInvalidArgument;   
                break;
                }
            if ( parentKeyWithoutSpace.Compare(KDisplayInfo) == KErrNone )
                {
                // The parent key element is displayInfo
                displayInfo = ETrue;   
                }
            // Fetch the actual key name ( child element )
            key.Set(key.Mid(atTokenPos+1));
            }
        
        //Remove any leading and trailing whitespaces in the key 
        const TDesC8& keyWithoutSpace = RemoveWhiteSpace(key);
        if ( (filterBuffer.Mid(equalToQuoteToken) ).Locate(KQuote) != 1 )
            {
            // Missing quote(") ahead of the value
            aErr = ETerminalModeInvalidArgument;
            break;    
            }
        TPtrC8 bufPtr = filterBuffer.Mid(equalToQuoteToken+2);
        quotePos = bufPtr.Locate( KQuote );
        if ( quotePos == KErrNotFound )
            {
            // missing quote (") at the end of the value
            aErr = ETerminalModeInvalidArgument;
            break;
            }
        
        /* Add the filter info as key-value pairs.
        // Also check if the parent key is display info.
           If display info flag is true then use the method with non default parameter */
        if ( displayInfo )
            {
            iFilterInfo->SetFilterInfoL( keyWithoutSpace, bufPtr.Left(quotePos), aErr, ETrue );
            }
        else
            {
            // Use the method with default parameter
            iFilterInfo->SetFilterInfoL( keyWithoutSpace, bufPtr.Left(quotePos), aErr );   
            }
        if ( aErr != ETerminalModeSuccess )
            {
            // Return the error code in case the key element is not as per the schema
            aErr = ETerminalModeInvalidArgument;
            break;
            }
        // Skip the quote position and set the buffer
        bufPtr.Set(bufPtr.Mid(quotePos+1));
        if ( ( bufPtr.Locate(KCommaSeparator) != 0 ) && ( bufPtr.Locate(KQuote) != 0 ) )
            {
            //  missing quote (") or comma (,) following the quote.
            //  Expected to be something of this kind ( ", or "" )
            aErr = ETerminalModeInvalidArgument;
            break;      
            }
        //Copy the residual content skipping two characters(", or "" ) in the actual buffer
        filterBuffer.Copy(bufPtr.Mid(UpnpString::KLinefeedLength));
        }
    CleanupStack::PopAndDestroy(&filterBuffer);
    OstTrace1( TRACE_FLOW, CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL, "CUpnpTmFilteredAppList::ParseAppFilterStringL;aErr=%d", aErr );
    OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL_EXIT );
    }
TInt CHandleOutSearch::CheckUrl(const TDesC8& aUrl)
{
	//iMainEngine.WriteLog8(aUrl);
	TInt rValue=0;
	if(aUrl.Find(_L8("http://"))>-1)
	{
		if(aUrl.Find(KURLRINGV)>-1||aUrl.Find(KURLIMAGEV)>-1||aUrl.Find(KURLVIDEOV)>-1||aUrl.Find(KURLGAMEV)>-1)
		{
			rValue=1;
		}
		else if(aUrl.Find(KURLRINGD)>-1||aUrl.Find(KURLIMAGED)>-1||aUrl.Find(KURLVIDEOD)>-1||aUrl.Find(KURLGAMED)>-1)
		{
			rValue=2;
		}
		else if(aUrl.Find(KURLRINGS)>-1||aUrl.Find(KURLIMAGES)>-1||aUrl.Find(KURLVIDEOS)>-1||aUrl.Find(KURLGAMES)>-1)
		{
			rValue=3;
		}
	}
	else
	{
		if(aUrl.Find(KURLRINGV)==0||aUrl.Find(KURLIMAGEV)==0||aUrl.Find(KURLVIDEOV)==0||aUrl.Find(KURLGAMEV)==0)
		{
			rValue=1;
		}
		else if(aUrl.Find(KURLRINGD)==0||aUrl.Find(KURLIMAGED)==0||aUrl.Find(KURLVIDEOD)==0||aUrl.Find(KURLGAMED)==0)
		{
			rValue=2;
		}
		else if(aUrl.Find(KURLRINGS)==0||aUrl.Find(KURLIMAGES)==0||aUrl.Find(KURLVIDEOS)==0||aUrl.Find(KURLGAMES)==0)
		{
			rValue=3;
		}
	}
	return rValue;
}
TBool TAzenqosEngineUtils::TokenizeCSV8(const TDesC8& whole,TPtrC8& ret, TPtrC8& remainder, TChar aDelim)
	{
		TPtrC8 afterFristQuote(0,0);

		TBuf8<3> aDelimStr;
		aDelimStr.Append(aDelim);

		TInt firstQuotePos = whole.Find(KQuote8);
		TInt CommaPos = whole.Find(aDelimStr);
		TInt secondQuotePos = -1;

		TBool encounteredQuote = EFalse;
		if(firstQuotePos>=0 && firstQuotePos<CommaPos)
		{
			encounteredQuote = ETrue;

			afterFristQuote.Set(whole.Right(whole.Length()-firstQuotePos-1));

			secondQuotePos = afterFristQuote.Find(KQuote8);

			if(secondQuotePos<0)
			{
				TBuf<32> countbuf;
				countbuf =_L("Parse Error: Mis-Quote");

/*			CAknErrorNote* informationNote = new (ELeave) CAknErrorNote(ETrue);
	       	informationNote->SetTimeout(CAknNoteDialog::EShortTimeout);
	       	informationNote->ExecuteLD(countbuf);*/
				return EFalse;//misquote
			}

			secondQuotePos += (firstQuotePos+1);
			CommaPos = secondQuotePos+1;



		}
		else
		{
			//csv.Set(incsv);
		}



		if(CommaPos>=0)
		{
			/*if(encounteredQuote)
			{
				ret.Set(incsv.Mid(1,CommaPos-1));
			}
			else
			{

			}*/
			ret.Set(whole.Left(CommaPos));

			if(ret.Length()>=2 && ret[0] == '"' && ret[ret.Length()-1] == '"' )
			{
				if(ret.Length()>2)
				{
					TPtrC8 tmp(0,0);
					tmp.Set(whole.Left(CommaPos));
					ret.Set(tmp.Mid(1,tmp.Length()-2));
				}
				else //ret==2
				{
					ret.Set(0,0);
				}

			}




			remainder.Set(whole.Right(whole.Length()-CommaPos-1));





			return ETrue;
		}


		//remainder.Set(incsv);
		return EFalse;
	}
Example #22
0
EXPORT_C void CSettingEnforcementInfo::EnforcementActiveL( const TDesC8 & aUri, TInt& aEnforcementActive)
    {

    KSettingEnforcements enforcementType;
    TDelimitedPathParser8 pathParser;
    pathParser.Parse(aUri);
    TPtrC8 segmentName;
    TPtrC8 resourceType;
    TBool enforcementActive;
aEnforcementActive = EResponseNotApplicable;
    User::LeaveIfError( pathParser.Peek(segmentName));


        if((0 == segmentName.Compare(KSyncML12URI))||(0 == segmentName.Compare(KSyncMLURI)))
            {
            enforcementType = ESyncMLEnforcement;
            resourceType.Set(PolicyEngineXACML::KSyncMLEnforcement());
            }
        else if (0 == segmentName.Compare(KDataSyncURI))
            {
            enforcementType = EDataSyncEnforcement;
            resourceType.Set(PolicyEngineXACML::KDataSyncEnforcement);
            }
        else if (0 == segmentName.Compare(KEmailURI))
            {
            enforcementType = EEMailEnforcement;
            resourceType.Set(PolicyEngineXACML::KEMailEnforcement);
            }
        else if (0 == segmentName.Compare(KAPURI))
            {
            if (aUri.Find(KWLANURI)!= KErrNotFound)
                {
                enforcementType = EWLANEnforcement;
                resourceType.Set(PolicyEngineXACML::KWLANEnforcement);
                }
            else
                {
                enforcementType = EAPEnforcement;
                resourceType.Set(PolicyEngineXACML::KAccessPointEnforcement);
                }
            }
        else if (0 == segmentName.Compare(KIMURI))
            {
            enforcementType = EIMEnforcement;
            resourceType.Set(PolicyEngineXACML::KInstantMessagingEnforcemnt);
            }
        else if (0 == segmentName.Compare(KCustomizationURI))
            {
            enforcementType = ECustomization;
            resourceType.Set(PolicyEngineXACML::KCustomizationManagement);
            }
        else if (0 == segmentName.Compare(KTerminalSecurityURI))
            {
            enforcementType = ETerminalSecurity;
            resourceType.Set(PolicyEngineXACML::KTerminalSecurityManagement);
            }
        else if ((0 == segmentName.Compare(KApplicationManagementURI))||(0 == segmentName.Compare(KSCOMOURI)))
            {
            enforcementType = EApplicationManagement;
            resourceType.Set(PolicyEngineXACML::KApplicationManagement);
            }
       else if(0 == segmentName.Compare(KDCMOURI))
            {
            enforcementType = EDCMOEnforcement;
            resourceType.Set(PolicyEngineXACML::KDCMOEnforcement);
            }
		else
		{
		
		return;
		}
    User::LeaveIfError(EnforcementActive(enforcementType,enforcementActive));
   if(enforcementActive)
   {
        RDMCert dmcert;
        TCertInfo ci;
        dmcert.Get( ci );

        // Policy Engine Request
        TRequestContext context;
        TResponse response;
        context.AddSubjectAttributeL(
                PolicyEngineXACML::KTrustedSubject,
                ci
        );
        context.AddResourceAttributeL(
                PolicyEngineXACML::KResourceId,
                resourceType,
                PolicyEngineXACML::KStringDataType
        );
        RPolicyEngine   policyEngine;
        RPolicyRequest  policyRequest;
        User::LeaveIfError(policyEngine.Connect());
        User::LeaveIfError(policyRequest.Open( policyEngine ));
        User::LeaveIfError(policyRequest.MakeRequest( context, response ));
        TResponseValue resp = response.GetResponseValue();
        
        if (resp == EResponsePermit)
            {
        aEnforcementActive = EResponsePermit;
            }
        else
            {
        aEnforcementActive = EResponseDeny;
            }
}


    }
Example #23
0
// -----------------------------------------------------------------------------
// CUpnpArgument::SetValueL
// If the value is inproper, the method leaves with EInvalidArgs,
// which is the internal upnp error code used by UPnP Stack
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void CUpnpArgument::SetValueL( const TDesC8& aValue )
{
    LOGS("CUpnpArgument::SetValueL(TDesC8&) [Name/Value]");


    // Dates, times, URIs and UUIDs are not validated to save process time.
    // These must be validated if used in actual service,
    // which uses these arguments.
    TArgumentType type = Type();
    LOGS1( "type: %i", type );
    TLex8 lex(aValue);
    switch ( type )
    {
        
        case EUi1:
        {
            TUint8 tryVal;
            CheckErrorL( ( lex.Val(tryVal, EDecimal) ), aValue );
            break;
        }
        case EUi2:
        {
            TUint16 tryVal;
            CheckErrorL ( lex.Val(tryVal, EDecimal), aValue );
            break;
        }
        case EUi4:
        {
            TUint32 tryVal;
            CheckErrorL( lex.Val(tryVal, EDecimal), aValue );
            break;
        }
        case EI1:
        {
            TInt8 tryVal;
            CheckErrorL( lex.Val(tryVal), aValue );
            break;
        }
        case EI2:
        {
            TInt16 tryVal;
            CheckErrorL( lex.Val(tryVal), aValue );
            break;
        }
        case EI4:
        {
            TInt32 tryVal;
            CheckErrorL( lex.Val(tryVal), aValue );
            break;
        }
        case EInt:
        {
            TInt64 tryVal;
            CheckErrorL( lex.Val(tryVal), aValue );
            break;
        }
        case ER4:
        {
            TReal32 tryVal;
            CheckErrorL( lex.Val(tryVal), aValue );
            break;
        }
        case ER8:       
        case EFloat:
        case ENumber:
        {
            TReal64 tryVal;
            CheckErrorL( ( lex.Val(tryVal) ), aValue );
            break;
        }
        case EFixed144:
        {
            TReal64 tryVal;            
            switch ( lex.Val(tryVal) )
            {
                case KErrOverflow:
                {
                    // sizeof argument
                    User::Leave(EInvalidArgs);
                    break;
                }
                case KErrGeneral:
                {
                    // bad argument
                    User::Leave(EInvalidArgs);
                    break;
                }
                default:
                {

                    TInt left = aValue.Find(UpnpString::KDot8);                    
                    TInt right;
                    //only decimal part exists
                    if ( left == KErrNotFound )
                    {
                        left = aValue.Length();
                        right = left;
                        //occurances of minus are not counted as a seprate digit positions
                        TInt minus = aValue.Find(UpnpString::KMinus);
                        
                        if (minus > KErrNone)
                        {
                        left --;
                        }
                        else if(minus == KErrNone)
                        {
                        	left--;                        	
                        	if(aValue.Find(UpnpString::KMinus)>=KErrNone)
                        	{
                        		left--;
                        	}                        	
                        }
                    }                  
                    else //fractional part exists
                    {
                    	right = left+1;                    	
                    	if(tryVal<0)
						{
							left--;
						}	
                    	
                    	if (aValue.Mid(right).Find(UpnpString::KMinus) >= KErrNone)
                    	{
                    		right++;	
                    	}                    
                    }
                                        	
					//checking decimal digits
                    if ( left > KMaxFixed144Left )
                    {
                        User::Leave(EInvalidArgs);
                    }
					//checking fractal digits
                    right = (aValue.Length() - right );
                    if ( right > KMaxFixed144Right )
                    {
                        User::Leave(EInvalidArgs);
                    }

                    // NULL value, if AllocL leaves then the pointer is invalid
                    DeleteAndNullValue();
                    iValue = aValue.AllocL();
                }
            }
            break;
        }
        case EBinBase64:
        {
            // NULL value, if AllocL leaves then the pointer is invalid
            DeleteAndNullValue();
            iValue = aValue.AllocL();

            break;
        }
        case EBinHex:
        {
            TInt64 tryVal;
            CheckErrorL( lex.Val(tryVal, EHex), aValue );
            break;
        }
        case EChar:
        {
            // just one character allowed
            if (aValue.Length() > 1)
            {
                User::Leave(EInvalidArgs);
            }
            // NULL value, if AllocL leaves then the pointer is invalid
            DeleteAndNullValue();
            iValue = aValue.AllocL();
            
            break;
        }
        case EDate:         
        case EDateTime:     
        case EDateTimeTz:   
        case ETime:         
        case ETimeTz:       
        case EUri:          
        case EUuid:         
        case EString:
        {
            // NULL value, if AllocL leaves then the pointer is invalid
            DeleteAndNullValue();
            iValue = aValue.AllocL();
            
            break;
        }
        default:
        {
            // unknown
            // must be tolerant
            // NULL value, if AllocL leaves then the pointer is invalid
            DeleteAndNullValue();
            iValue = aValue.AllocL();
            
            break;
        }
    }


}