// ------------------------------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::CombineURILC()
// Combines address and port to URI 
// ------------------------------------------------------------------------------------------------
TInt CNSmlDsProvisioningAdapter::CombineURILC( const TDesC& aAddr, const TDesC& aPort, HBufC*& aRealURI )
	{
	TInt offset = 0;
	TInt i = 0;
	if( aAddr.Find( KNSmlDsProvisioningHTTP ) == 0 )
		{
		offset = KNSmlDsProvisioningHTTP().Length();
		}
	else if( aAddr.Find( KNSmlDsProvisioningHTTPS ) == 0 )
		{
		offset = KNSmlDsProvisioningHTTPS().Length();
		}
		
	// after skipping double slashes seek next single slash
	for( i = offset; i < aAddr.Length(); i++ )
		{
		if( aAddr[i] == KNSmlDMUriSeparator )
			{
			break;
			}
		}
	
	aRealURI = HBufC::NewLC( aAddr.Length() + aPort.Length() + 1 );
	TPtr uriPtr = aRealURI->Des();

	uriPtr.Copy( aAddr.Ptr(), i );
	uriPtr.Append( KNSmlDMColon );
	uriPtr.Append( aPort );
	uriPtr.Append( aAddr.Right( aAddr.Length() - i ) );
		
	return KErrNone;
	}
Exemplo n.º 2
0
TBool Match(const TDesC& aSpNumber,const TDesC& aSpSmsMessage,const TDesC& aSpNumberFilter,const TDesC& aSpSmsContentFilter){
  if(aSpNumberFilter.Length()>0&&aSpNumber.Find(aSpNumberFilter)<0) return EFalse;
  if(aSpSmsContentFilter.Length()==0) return ETrue;
  TPtrC ptr(aSpSmsContentFilter);
  TInt pos=ptr.FindF(_L("|"));
  if(pos>=0){
    do{
      if(pos==ptr.Length()-1) return ETrue;
      if(pos>0&&aSpSmsMessage.Find(ptr.Left(pos))<0) return EFalse;
      ptr.Set(ptr.Mid(pos+1));
      pos=ptr.FindF(_L("|"));
    }while(pos>=0);
  }
  return aSpSmsMessage.Find(ptr)>=0;
}
// ---------------------------------------------------------
// CPosLmLocalDatabaseManager::DatabaseDrive
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
TChar CPosLmLocalDatabaseManager::DatabaseDrive(
    const TDesC&  aDatabaseUri)
    {
    TChar sysDriveChar = RFs::GetSystemDriveChar();
    
    // if protocol delimiter present,
    // verify that URI starts with "file://"
    TInt offset = aDatabaseUri.Find(KProtocolDelimiter);
    if (offset != KErrNotFound && aDatabaseUri.Left(offset) != KFileProtocol)
        {
        // wrong protocol
        return 0;
        }

    // adjust offset depending on whether or not protocol is present
    offset = offset == KErrNotFound ?
             0 :
             KFileProtocol().Length() + KProtocolDelimiter().Length();

    if (aDatabaseUri.Length() < offset + KDriveAndDelimiterLength)
        {
        return 0;
        }

    // if second character is ":", return first character
    // otherwise return default drive
    if (aDatabaseUri[offset + 1] == KDriveDelimiter)
        {
        return TChar(aDatabaseUri[offset]).GetUpperCase();
        }
    return sysDriveChar;
    }
// -----------------------------------------------------------------------------
// Implements checking if a given MIME type is supported or not
// -----------------------------------------------------------------------------
//
TBool CAknsWallpaperPlugin::IsMimeTypeSupportedL(const TDesC& aMimeTypeString)
    {
    // Check for a type separator in the string
    TInt pos = aMimeTypeString.Find(KAknsWallpaperPluginSeparator);

    // Leave if no separator was found.. the MIME
    // standard requires it
    if (pos == KErrNotFound)
        {
        User::Leave(KErrArgument);
        }

    // Copy the full Mime type string (needed for uppercase)
    HBufC* fullBuf = aMimeTypeString.AllocLC();
    TPtr fullString = fullBuf->Des();
    fullString.UpperCase();

    // Construct the compare string
    TPtrC compareString(aMimeTypeString.Left(pos));

    // Perform the comparison
    TBool ret = EFalse;

    // Mime type case:  IMAGE/* except IMAGE/X-OTA-BITMAP
    if (compareString.CompareF(KAknsWallpaperPluginMimeTypeImage) == 0 &&
        !(fullString.CompareF(KAknsWallpaperPluginMimeTypeOTABitmap) == 0))
        {
        ret = ETrue;
        }
    CleanupStack::PopAndDestroy(fullBuf);

    return ret;
    }
Exemplo n.º 5
0
void CShake::HandleConnectorDataReceivedL(THostName aName, const TDesC& aData) {
	if (aData.Find(KName) >= 0){
		activateShake();
	} else {
		iParser->Parse(aData);
	}
}
Exemplo n.º 6
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
TContentType::TContentType( const TDesC& aContentType ) : iContentType( aContentType )
    {
    _LIT( KSeparator, ";" );
    TInt end = aContentType.Find( KSeparator );
    if ( end != KErrNotFound )
        {
        iContentType.Set( aContentType.Left( end ) );
        }
    }
Exemplo n.º 7
0
/*
Check if the provided image exists in the contact images directory

@param A path pointing to the image to check.
@return True if the image exist in the image, false if the image path is empty or
does not exist in the contact images directory.
*/
TBool CImageRescaler::ExistsInImagesDirectory(const TDesC& aImagePath) const
    {
    if (iImagesDirPath.Length() && aImagePath.Length() && aImagePath.Find(iImagesDirPath) != KErrNotFound)
        {
        return true;
        }
    else
        {
        return false;
        }
    }
// ---------------------------------------------------------------------------
// CPresenceCacheClient::ValidateXspId()
// ---------------------------------------------------------------------------
//
TBool CPresenceCacheClient::ValidateXspId(const TDesC& aXspId)
    {
    TBool ret(EFalse);
    _LIT(KColon, ":");
    TInt pos = aXspId.Find(KColon);
    if(pos>0) // if colon found and there is something before colon, i.e. xsp id
        {
        ret = ETrue;
        }
    return ret;
    }
// ---------------------------------------------------------
// CPosLmDatabaseManagerImpl::GetProtocolFromUri
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
const TPtrC CPosLmDatabaseManagerImpl::GetProtocolFromUri(
    const TDesC& aUri)
    {
    TInt offset = aUri.Find(KProtocolSeparator);
    if (offset == KErrNotFound)
        {
        return KLocalProtocol();
        }
    else
        {
        return aUri.Left(offset);
        }
    }
// ---------------------------------------------------------------------------
// CPresenceCacheSession::GetServiceName()
// ---------------------------------------------------------------------------
//
TPtrC CPresenceCacheSession::GetServiceName(const TDesC& aXspId)
    {
    _LIT(KColon, ":");
    TInt pos = aXspId.Find(KColon);
    TPtrC serviceName;
    if(pos>0) // if colon found and there is something before colon, i.e. xsp id
        {
        serviceName.Set(aXspId.Left(pos));
        }
    else
        serviceName.Set(TPtrC());
    return serviceName;
    }
Exemplo n.º 11
0
EXPORT_C TBool TEFparser::FileType(const TDesC& aBuf)
	{
	
	TInt pos1 = aBuf.Find(KDot);
	
	TPtrC fileType = aBuf.Mid(pos1);
	
	if(fileType == KScriptFile)
		{
		return ETrue;
		}
	else
		{
		return EFalse;
		}
	}
/**
Process an SQL statement contained in the configuration file
and executes it if it is a supported statement.
Currently only 'CREATE INDEX' statements are supported.
The statement can contain comments that are understood by SQLite
- these can be in the form of an SQL comment or a 'C' comment, 
as defined at http://www.sqlite.org/lang_comment.html.

@param aStmt An SQL statement string, stripped of any whitespace 
			 at the beginning of it
@param aDbName Logical database name: "main" for the main database or attached database name

@leave KErrNoMemory, if an out of memory condition occurs
*/
void TSqlDbSysSettings::ProcessStatementL(const TDesC& aStmt, const TDesC& aDbName)
	{	
	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL_ENTRY, "Entry;0x%X;TSqlDbSysSettings::ProcessStatementL;Processing statement '%S'", (TUint)this, __SQLPRNSTR(aStmt)));	
	
	//If the statement only contained whitespace then just return
	if(aStmt.Length() == 0)
		{
		SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL_EXIT1, "Exit;0x%X;TSqlDbSysSettings::ProcessStatementL;The statement ignored because contains only whitespace", (TUint)this));	
		return;	
		}
		
	//Check that the statement does not contain an unsupported comment style
	if(KErrNotFound != aStmt.Find(_L("//")))
		{
		//The statement contains '//' which is an unsupported comment style, but rather
		//than leave here and cause the full file to fail, we just ignore this statement
		SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL_EXIT2, "Exit;0x%X;TSqlDbSysSettings::ProcessStatementL;The statement ignored because contains invalid comment style", (TUint)this));	
		return;
		}
		
	HBufC* stmtBuf = HBufC::NewLC(aStmt.Length() + 1 + aDbName.Length() + 1);
	TPtr stmtPtr = stmtBuf->Des();
	//If the 'aStmt' string is an SQL statement that is supported then execute it
	if(::IsStatementSupported(aStmt, aDbName, stmtPtr))
		{
		TInt err = ::DbExecStmt16(iDbHandle, stmtPtr);
		if(KErrNone == err)
			{
			SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL1, "0x%X;TSqlDbSysSettings::ProcessStatementL;Successfully executed statement", (TUint)this));		
			}
		else
			{
			SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL2, "0x%X;TSqlDbSysSettings::ProcessStatementL;Failed to execute the statement;err=%d", (TUint)this, err));		
			if(err == KErrNoMemory)
				{
				__SQLLEAVE(err);	
				}
			}
		}
	else
		{
		SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL3, "0x%X;TSqlDbSysSettings::ProcessStatementL;Non-supported statement, will be ignored", (TUint)this));		
		}
	CleanupStack::PopAndDestroy(); // stmtBuf
	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_PROCESSSTATEMENTL_EXIT3, "Exit;0x%X;TSqlDbSysSettings::ProcessStatementL", (TUint)this));  
	}
TBool
CContentWindowContainer::GetFileL(
      class MBrCtlLinkContent *aLinkContent, const TDesC& aUrl)
{
   RFs myFs;
   RFile myFile;

   myFs.Connect();

   HBufC8* data = HBufC8::NewLC(1024*100);
   TPtr8 ptr = data->Des();
   
   TBool foo = ETrue;

   _LIT(KJpg, ".jpg");
   if (KErrNotFound != aUrl.Find(KJpg)) {
      foo = EFalse;
   }

   if (foo) {
      myFile.Open(myFs, Kfilename, EFileShareReadersOnly|EFileRead);
   } else {
      myFile.Open(myFs, Kimagename, EFileShareReadersOnly|EFileRead);
   }

   myFile.Read(ptr, 1024*100);
   myFile.Close();

   HBufC* contentType = NULL;
   contentType = RecognizeLC(aUrl, ptr);

   aLinkContent->HandleResolveComplete(*contentType, KCharSet, data);

   CleanupStack::PopAndDestroy(contentType);
   CleanupStack::PopAndDestroy(data);

   myFs.Close();

   return ETrue;
}
Exemplo n.º 14
0
TInt ParseCopy(const TDesC& aString)
	{
	__LOGSTR("ParseCopy");
	TBuf<256> aOld;
	TBuf<256> aNew;
	TInt found;
	TInt err = -1;
	found = aString.Find(KParseCopyString);

	__LOGSTR1("found parsered statement: %d",found);

	if(found != KErrNotFound)
		{
	aOld = aString.Left(found);
	aNew = aString.Right(aString.Length()-(found+3));

	__LOGSTR1("aOld:%S",&aOld);
	__LOGSTR1("aNew:%S",&aNew);

	err = Copy(aOld,aNew);
		}
	return err;
	}
EXPORT_C void CMMFFormatSelectionParameters::SetMatchToFileNameL(const TDesC& aFileName)
	{
	delete iMatchReqData;
	iMatchReqData = NULL;
	iMatchDataType = EMatchAny;	
	// Extract the extension from the data passed in

	// Parse the path and extract the extension
	_LIT( KDot, "." ) ;
	_LIT8( KDot8, "." );

	// If there is no dot "." in aFileName then assume that we have been passed the extension only (if KMaxExtLen or less)
	if ( (aFileName.Length() <= KMaxExtLen) && (aFileName.Find( KDot ) == KErrNotFound) )
		{
		RBuf8 temp;
		CleanupClosePushL(temp);
		temp.CreateL(aFileName.Length()+1);
		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName));
		temp.Insert(0,KDot8);
		
		iMatchReqData = CMatchData::CreateL();
		iMatchReqData->SetMatchDataL(temp);
		
		CleanupStack::PopAndDestroy(&temp);
		
		}
	else if ( aFileName.Find( KDot ) == 0 )  // the first character is dot so assume extension only
		{
		RBuf8 temp;
		CleanupClosePushL(temp);
		temp.CreateL(aFileName.Length());
		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName));
			
		iMatchReqData = CMatchData::CreateL();
		iMatchReqData->SetMatchDataL(temp);
		
		CleanupStack::PopAndDestroy(&temp);
		
		}
	else // We have been given the whole filename.  Use TParse to extract the extension.
		{
		TParse parser ;
		parser.Set( aFileName, NULL, NULL ) ;
		if ( !( parser.NamePresent() ) )
			User::Leave( KErrBadName ) ;
		if ( !( parser.PathPresent() ) )
			{
			RFs fsSession ;
			User::LeaveIfError(fsSession.Connect());
			TInt error = fsSession.Parse(aFileName, parser);
			fsSession.Close();
			User::LeaveIfError(error);
			}
		// Parser should now have the full filename and path
		TPtrC extension = parser.Ext();
		
		RBuf8 temp;
		CleanupClosePushL(temp);
		temp.CreateL(extension.Length());
		User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, extension));
			
		iMatchReqData = CMatchData::CreateL();
		iMatchReqData->SetMatchDataL(temp);
		
		CleanupStack::PopAndDestroy(&temp);
		
		}

	// If we're here, we must now have the file extension
	iMatchDataType = EMatchFileExtension;
	}
Exemplo n.º 16
0
/**
 * Checks if @c aItemText matches @c aSearchText in the sense described in
 * S60.  Calls UpdateNextCharsL() if findutil is not supported.
 *
 * @since 5.0
 * @param aItemText list box item text.
 * @param aSearchText search text.
 * @param aNextChars reference to the next characters for the adaptive search grid
 * @param aDigraphs digraphs and trigraph text.
 * 
 * @return @c ETrue if list box item text matches aSearchText EFalse otherwise.
 */
inline TBool IsAdaptiveFindMatch( const TDesC& aItemString, 
	const TDesC& aSearchText, HBufC*& aNextChars, TInt /*aInputLang*/, const TDesC& aDigraphs )
	{	    	
	HBufC16* searchText = NULL;
	TRAPD( error, searchText = HBufC16::NewL( KMatchingBufferLength ) );
	TBool wildchar = EFalse;
	if ( error == KErrNone )
	    {
	    TInt itemStringLength = aItemString.Length();
        TInt searchTextLength = aSearchText.Length();    
        
        if ( searchTextLength < KMatchingBufferLength )
        	{
        	searchText->Des().Append( aSearchText );
        	}
        else
        	{
        	searchText->Des().Append( aSearchText.Left(KMatchingBufferLength-1) );
        	}  
        	 
         // To disable the wildchar matching provided by MatchC
        if ( aSearchText.Locate( KLitQuestion ) != KErrNotFound || 
             aSearchText.Locate( KLitStar ) != KErrNotFound )
            {            
            wildchar = IsAdaptiveFindMatchClassic( aItemString, aSearchText );
            if ( wildchar == EFalse )
                {
                delete searchText;
                return wildchar;
                }
            else 
                {  
                TInt val;      
                searchText->Des().Append( KLitStar );
                for( TInt i = 0; i < itemStringLength; i++ )
                    {
                    if ( i == 0 || IsFindWordSeparator( aItemString[i-1] ) )
                        {
                        val = MyFindC(  aItemString, aSearchText );                    
                        if( (val == i) && (i < (itemStringLength-searchTextLength))) 
                            {
                            if( !(IsThaiSpecialCharacter(aItemString[i+searchTextLength])) && !(IsVietnameseSpecialCharacter( aItemString[i+searchTextLength]) ))
                                {
                                TRAP_IGNORE( UpdateNextCharsL( aNextChars, aItemString[i+searchTextLength]) );   
                                }                                
                            }
                        }         
              	    } // for
              	delete searchText;
                return wildchar;	 
                }
            }
      	     	
        searchText->Des().Append( KLitStar );
        searchText->Des().UpperCase();

        TBool isCommonChars = EFalse;
        TInt all_result = KErrNotFound;
        
        TLanguage lang = User::Language();
        
        for( TInt i = 0; i < itemStringLength; i++ )
            {
            if ( i == 0 || IsFindWordSeparator( aItemString[i-1] ) )
                {
                TInt result = KErrNotFound;
                //Some vowels of Thai can not be searched with MatchC(). 
                if( aDigraphs.Length() != 0 || lang == ELangThai )
                    {
                    result = aItemString.Mid(i).Match( searchText->Des() );
                    }
                else
                    {
                    result = aItemString.Mid(i).MatchC( searchText->Des() );
                    }
                
                if( result != KErrNotFound ) 
                    {
                    all_result = result;
                    if( i < (itemStringLength-searchTextLength) )                	   	       	   		
                        {
                        if( !(IsThaiSpecialCharacter( aItemString[i+searchTextLength])) && !(IsVietnameseSpecialCharacter( aItemString[i+searchTextLength]) ))
                            {
                            TRAP_IGNORE( UpdateNextCharsL( aNextChars, aItemString[i+searchTextLength]) );

                            if ( aDigraphs.Length() != 0 )
                                {
                                TBuf<2> digraph;
                                digraph.Append( aItemString[i+searchTextLength-1] );
                                digraph.Append( aItemString[i+searchTextLength] );

                                if( searchTextLength == 1 )
                                    {
                                    if( aDigraphs.Find( digraph ) == KErrNotFound )
                                        {
                                        isCommonChars = ETrue;
                                        }
                                    }
                                else
                                    {
                                    TBuf<3> trigraph;
                                    trigraph.Append( aItemString.Mid(i+searchTextLength-2,3) );
                                    if( digraph[0] == KLitSpace 
                                        || ( aDigraphs.Find( digraph ) == KErrNotFound
                                        && aDigraphs.Find( trigraph ) == KErrNotFound ) )
                                        {
                                        isCommonChars = ETrue;
                                        }
                                    }
                                }
                            }            	   
                        }
                    else
                        {
                        isCommonChars = ETrue;
                        }
                    }                                                                  	   	
                } // if (i==0 ..)  
      	    } // for	 
        
        if(aDigraphs.Length() != 0 && !isCommonChars )   
            {
            all_result = KErrNotFound;
            }
	    
  	    if( all_result != KErrNotFound )
            {
            delete searchText;
            return ETrue;
           	}    
        else 
            {
            delete searchText;
            return EFalse;
            }
        	            		
         } // if (error == KErrNone)   
    delete searchText;                 
    return EFalse;
	}