Ejemplo n.º 1
0
void CRuleManager::WriteFavToFile()
	{
	TFileName filename;
	GetAppPath(filename);
	filename.Append(KFavRuleFile);
	
	int pos = filename.LocateReverse('\\');
	if (pos != KErrNotFound)
		{
		TPtrC dirName = filename.Left(pos + 1);
		CCoeEnv::Static()->FsSession().MkDirAll(dirName);
		}

	RFile file;
	TInt err;

	err = file.Replace(CCoeEnv::Static()->FsSession(), filename,
			EFileWrite);
	if (KErrNone != err)
		{
		return;
		}
	CleanupClosePushL(file);	

	WriteToFile(file,iFavRule);
	TBuf8<4> num;
	num.AppendNum(iFavRule->GetFavCount());
	file.Write(num);

	CleanupStack::PopAndDestroy(); // file	
	}
Ejemplo n.º 2
0
void CRuleManager::WriteToFile(RPointerArray<CRule>* aRules)
	{
	TFileName filename;
	GetAppPath(filename);
	filename.Append(KRuleFile);
	
	int pos = filename.LocateReverse('\\');
	if (pos != KErrNotFound)
		{
		TPtrC dirName = filename.Left(pos + 1);
		CCoeEnv::Static()->FsSession().MkDirAll(dirName);
		}

	RFile file;
	TInt err;

	err = file.Replace(CCoeEnv::Static()->FsSession(), filename,
			EFileWrite);
	if (KErrNone != err)
		{
		return;
		}
	CleanupClosePushL(file);
	
	for(TInt i=0; i<aRules->Count(); i++)
		{
		CRule* rule = (*aRules)[i];
		WriteToFile(file,rule);
		}

	CleanupStack::PopAndDestroy(); // file	
	}
Ejemplo n.º 3
0
void CGNAppletAppUi::ConstructL(void)
{
	TFileName file;
	int pos;

	BaseConstructL(ENoAppResourceFile);

	file.Copy(Application()->AppFullName());
	pos = file.LocateReverse('\\');
	file.Replace(pos, file.Length() - pos, _L("\\gnapplet.exe"));

	EikDll::StartExeL(file);

	User::Exit(0);
}
Ejemplo n.º 4
0
void CRuleManager::WriteToFile(CRule* aRule)
	{
	TFileName filename;
	GetAppPath(filename);
	filename.Append(KRuleFile);
	
	int pos = filename.LocateReverse('\\');
	if (pos != KErrNotFound)
		{
		TPtrC dirName = filename.Left(pos + 1);
		CCoeEnv::Static()->FsSession().MkDirAll(dirName);
		}

	RFile file;
	TInt err;

	if (BaflUtils::FileExists(CCoeEnv::Static()->FsSession(), filename))
		err = file.Open(CCoeEnv::Static()->FsSession(), filename, EFileWrite
				| EFileStreamText);
	else
		err = file.Replace(CCoeEnv::Static()->FsSession(), filename,
				EFileWrite);
	if (KErrNone != err)
		{
		return;
		}
	CleanupClosePushL(file);

	TInt end = 0;
	file.Seek(ESeekEnd, end);

	WriteToFile(file,aRule);

	CleanupStack::PopAndDestroy(); // file

	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::StopProcessByFullNameL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::StopProcessByFullNameL(const TDesC8& aName) {
    RDEBUG("[CTerminalControlServer]-> StopProcessByFullNameL() >>>");


    TInt rounds = 5;
    TFileName lMatchStr;
    lMatchStr.Copy(aName);
    lMatchStr.LowerCase();

    TBool lIsAbsolute = EFalse;
    if(lMatchStr.LocateReverse(TChar('\\')) != KErrNotFound) {
        lIsAbsolute = ETrue;
    }
    while(rounds--) {
        TInt ret = KErrNone;
        TFullName processName;
        TFindProcess findProcess;

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

            if(KErrNone == (ret = process.Open(findProcess))) {
                RDEBUG("[CTerminalControlServer]-> Process.Open() returned");

                TFileName lStrSource(process.FileName());
                lStrSource.LowerCase();
                if(lIsAbsolute) {
                    RDEBUG("[CTerminalControlServer]-> INFO: The input was specified as an absolute path...");
                    if(lStrSource.Compare(lMatchStr) == 0) {
                        RDEBUG("[CTerminalControlServer]-> Process with correct Filename found => Kill(0) ");
                        process.Kill(0);
                    }
                }
                else {
                    RDEBUG("[CTerminalControlServer]-> INFO: The input was specified as an application name...");
                    TInt lLastDirSepIndex = lStrSource.LocateReverse('\\');
                    TInt lExeIndex = lStrSource.Find(_L(".exe"));
                    if(lLastDirSepIndex < lExeIndex) {
                        TInt lAppNameIndex = lStrSource.Find(lMatchStr);

                        /*
                         * The logic works like this, if the value of lStrSource was 'z:\sys\bin\calendar.exe', lMatchStr would contain calendar
                         * the values of the variables will be as follows
                         * lLastDirSepIndex = 10
                         * lAppNameIndex = 11
                         * lExeIndex = 19
                         *
                         * The below logic would make sure that the right process is killed
                         */
                        if((lAppNameIndex == (lLastDirSepIndex + 1)) && ((lAppNameIndex + lMatchStr.Length()) == lExeIndex)) {
                            RDEBUG("[CTerminalControlServer]-> Process with correct Filename found => Kill(0)");
                            process.Kill(0);
                        }
                    }
                }
            }
            else {
                RDEBUG_2("[CTerminalControlServer]-> Process.Open() returned %d", ret);
            }
        }
        if(KErrNone != ret) {
            RDEBUG_2("[CTerminalControlServer]-> findProcess.Next() returned %d", ret);
        }
    }
    RDEBUG("[CTerminalControlServer]-> StopProcessByFullNameL() <<<");
}
void CLbtContainerAttrFilter::ProcessFilter(CLbtContainerTriggerEntry* aEntry,TInt& aIsFilterPresent,TBool& aIsEntryRequested  )
	{
	FUNC_ENTER("CLbtContainerAttrFilter::ProcessFilter");
	TInt isFilterPresent = 0;
	TBool isEntryRequested=EFalse;
	if(aEntry)
		{
		CLbtTriggerEntry* trigEntry=aEntry->TriggerEntry();
        CLbtExtendedTriggerInfo* contExtInfo=aEntry->ExtendedTriggerInfo();
        TInt i=0;
        if(trigEntry!=NULL)
        	{
            if( iTriggerStateArray.Count()>0 )
            	{
                 isFilterPresent++;
                 for(i=0;i<iTriggerStateArray.Count();i++)
 	                {
                    if(trigEntry->State()==iTriggerStateArray[i])
                        {
                        isEntryRequested=ETrue;
                        break;
                        }
                    }
                }
            if( (isFilterPresent>0 && isEntryRequested ) || 
                (isFilterPresent==0) )
                {
                	if(iTriggerValidityArray.Count()>0)
                		{
                isFilterPresent++;
                isEntryRequested=EFalse;
                for(i=0;i<iTriggerValidityArray.Count();i++)
                   {
                   if(aEntry->DynInfo()->iValidity == iTriggerValidityArray[i])
                      {
                      isEntryRequested=ETrue;
                      }                
                   }
                }
              }
                   
            if((isFilterPresent>0 && isEntryRequested && iTriggerTypeArray.Count()>0) || (iTriggerTypeArray.Count()>0 && isFilterPresent==0))
                {
                 isFilterPresent++;
                 isEntryRequested=EFalse;
                 for(i=0;i<iTriggerTypeArray.Count();i++)
                    {
                    if(trigEntry->Type()==iTriggerTypeArray[i])
                       {
                       isEntryRequested=ETrue;
                       }
                
                    }
                 }
                   
            if((isFilterPresent>0 && isEntryRequested && iIdArray.Count()>0) || (iIdArray.Count()>0 && isFilterPresent==0 ))
                {
                isFilterPresent++;
                isEntryRequested=EFalse;
                for(i=0;i<iIdArray.Count();i++)
                    {
                    if(trigEntry->Id()==iIdArray[i])
                        {
                        isEntryRequested=ETrue;
                        }
                    }

                 }
                    
            if((isFilterPresent>0 && isEntryRequested && iManagerUiArray.Count()>0) || (iManagerUiArray.Count()>0 && isFilterPresent==0 )) 
                {
                isFilterPresent++;
                isEntryRequested=EFalse;
                for(i=0;i<iManagerUiArray.Count();i++)
                    {
                    if(trigEntry->ManagerUi()==iManagerUiArray[i])
                        {
                        isEntryRequested=ETrue;
                        }
                    }
                }
             
            if((isFilterPresent>0 && isEntryRequested && iStartupProcessArray.Count()>0) || (iStartupProcessArray.Count()>0 && isFilterPresent==0 )) 
                {
                // This filter applies to only startup triggers
                if( trigEntry->Type() == CLbtTriggerEntry::ETypeStartup )
                	{
                	CLbtStartupTrigger* startupTrigger = static_cast<CLbtStartupTrigger*>(trigEntry);
                	isFilterPresent++;
	                isEntryRequested=EFalse;
	                
	                TFileName fileName;
                	TSecureId secureId;
	                startupTrigger->GetProcessId(fileName, secureId);
					
					// Append the EXE extension
	                if (fileName.LocateReverse('.') == KErrNotFound)
						{
						if (fileName.Length() + 4 > KMaxFileName)
							return;
						fileName.Append( KFileExtensionExe );
						}

					LOGSTRING( "Trigger File Name : \"%S\" ", &fileName );
	                for(i=0;i<iStartupProcessArray.Count();i++)
	                    {
						LOGSTRING( "Filter startup name: \"%S\" ", &iStartupProcessArray[i] );
	                    if( FilesIdentical(fileName, iStartupProcessArray[i] ) )
	                    	{
	                    	LOG("Files Are Identical");
	                    	isEntryRequested=ETrue;
	                    	break;
	                    	}
	                    }
                	}                
                }
                
           }// end of if(trigEntry!=NULL)
              
             if(contExtInfo!=NULL)
             	{
                 if((isFilterPresent>0 && isEntryRequested && iHystRadiusArray.Count()>0) || (iHystRadiusArray.Count()>0 && isFilterPresent==0 ))  
                    {
                    isFilterPresent++;
                    isEntryRequested=EFalse;
                    for(i=0;i<iHystRadiusArray.Count();i++)
                	    {
                	    if(contExtInfo->HysteresisRadius()==iHystRadiusArray[i])
                    	    {                    	    
                            isEntryRequested=ETrue;
                    	    }                        
                	    }
                    }
                     
                    
                    if((isFilterPresent>0 && isEntryRequested && iTriggerFiredArray.Count()>0) || (iTriggerFiredArray.Count()>0 && isFilterPresent==0 ))  
                        {
                        isFilterPresent++;
                        isEntryRequested=EFalse;
                        for(i=0;i<iTriggerFiredArray.Count();i++)
                    	    {
                    	    if(contExtInfo->IsTriggerFired()==iTriggerFiredArray[i])
                    		    {
                                isEntryRequested=ETrue;
                        
                    		    }
                   		    }
                        }

                     if((isFilterPresent>0 && isEntryRequested && iSidArray.Count()>0) || (iSidArray.Count()>0 && isFilterPresent==0 ))  
                        {
                        isFilterPresent++;
                        isEntryRequested=EFalse;
                        for(i=0;i<iSidArray.Count();i++)
                    	    {
                    	    if(contExtInfo->OwnerSid()==iSidArray[i])
                        	    {                        	    
                                isEntryRequested=ETrue;
                        	    }
                            
                    	    }
                        }
                        
                      if((isFilterPresent>0 && isEntryRequested && iTriggerFireOnCreationArray.Count()>0) || (iTriggerFireOnCreationArray.Count()>0 && isFilterPresent==0 ))  
                        {
                        isFilterPresent++;
                        isEntryRequested=EFalse;
                        for(i=0;i<iTriggerFireOnCreationArray.Count();i++)
                    	    {
                    	    if(contExtInfo->IsTriggerFireOnCreation()==iTriggerFireOnCreationArray[i])
                        	    {
                        	    
                                isEntryRequested=ETrue;
                        	    }
                            
                    	    }
                        }          
                    
                    } // end of if(contExtInfo!=NULL)                  
        
		}//end of if(aEntry)
	aIsFilterPresent = isFilterPresent;
	aIsEntryRequested = isEntryRequested;
	}
//--------------------------------------------------------------------------
// CLbtContainerAttrFilter::DoesFileContainePathInfo
//--------------------------------------------------------------------------
//
TBool CLbtContainerAttrFilter::DoesFileContainePathInfo( TFileName& aFileName )
	{
	return (aFileName.LocateReverse('\\') != KErrNotFound);
	}
TUid CDeploymentComponentData::SetDataL(const TFileName &aData,
        const TDesC8& aMimeType)
    {
    RDEBUG_2("CDeploymentComponentData::SetDataL() TFileName: (%S)", &aData);
    
    _LIT(KNewPath, "c:\\private\\200267FB\\");

    TUid ret(TUid::Null());
    iMimeType = aMimeType.Left(KMaxMimeLength) ;
    RFs fs;
    User::LeaveIfError(fs.Connect() );
    CleanupClosePushL(fs);
    CFileMan *fm = CFileMan::NewL(fs);
    CleanupStack::PushL(fm);
    TFileName fn;
    fn.Copy(iDataFileName);

    RDEBUG("App Mgmt before copy start");

    
    TInt maxLength = iDataFileName.Length();
    TChar charvaldot = '.';
    TChar charvalslash = '\\';
    
    TInt pos = iDataFileName.LocateReverse(charvaldot);
    
    TInt lengthDeleted = maxLength-pos;
    
    iDataFileName.Delete(pos, lengthDeleted);
    
    TInt srcpos = aData.LocateReverse(charvaldot);
    
    TBuf<15> extn(aData.Mid(srcpos));
    
    iDataFileName.Append(extn);
    
    TFileName newfilepath;
    newfilepath.Copy(iDataFileName);
    
    User::LeaveIfError(fm->Move(aData,KNewPath()));
    
    TFileName oldfilepath(KNewPath());
    oldfilepath.Append(aData.Mid(aData.LocateReverse(charvalslash)));
    
    User::LeaveIfError(fm->Rename(oldfilepath, newfilepath));
   
    
    //User::LeaveIfError(fm->Copy(aData, fn) );

    RDEBUG("App Mgmt before copy End");


    if (IsSISInstallFile(aMimeType) )
        {
        ret = ResolveUidL(fs);
        }

    CleanupStack::PopAndDestroy(fm);
    CleanupStack::PopAndDestroy( &fs);
    RDEBUG_2("CDeploymentComponentData::SetDataL() (%d)", ret.iUid);

    return ret;
    }
/**
Performs any necessary configuration file updates to the database if a 
configuration file exists for the database that has not yet been processed.
If a configuration file is processed then the database settings table will 
be updated with the version of the configuration file that was processed.

@param aStoredDbConfigFileVersion The configuration file version that is
								  currently stored in the settings table
@param aFileData The database file data

@param aDbName Logical database name: "main" for the main database or attached database name

@leave One of the system-wide error codes or SQL errors of ESqlDbError type

@panic SqlDb 2 In _DEBUG mode if iDbHandle is NULL (uninitialized TSqlDbSysSettings object)
*/
void TSqlDbSysSettings::ConfigureDatabaseL(TInt aStoredDbConfigFileVersion, const TSqlSrvFileData& aFileData, 
										   const TDesC& aDbName)
	{	
	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL_ENTRY, "Entry;0x%X;TSqlDbSysSettings::ConfigureDatabaseL", (TUint)this));    
	
	__ASSERT_DEBUG(iDbHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));

	if(!aFileData.IsSecureFileNameFmt())
		{
		//As a first implementation, config files will only be supported for 
		//shared, secure databases - not for private, secure databases or public databases
		SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL_EXIT1, "Exit;0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Not a secure db", (TUint)this));    
		return;	
		}
		
	//Determine whether there is a configuration file 
	//for this database that has not yet been processed
	const CDbConfigFiles* dbConfigFiles = aFileData.DbConfigFiles();
	if(dbConfigFiles)
		{
		//Get the database file name and extension to search for a corresponding config file
		TPtrC dbName = aFileData.FileName();
		TParse parse;
		__SQLLEAVE_IF_ERROR(parse.Set(dbName, NULL, NULL));
		TPtrC dbFileNameAndExt = parse.NameAndExt();
		HBufC* matchingConfigFile = dbConfigFiles->FindConfigFile(dbFileNameAndExt);
		if(matchingConfigFile)
			{
			//There exists a config file for this database - now check whether its
			//version is greater than the version stored in the settings table and 
			//only process the file if it is
			TFileName configFileName;
			configFileName.Copy(matchingConfigFile->Des());
			TInt offset = configFileName.LocateReverse('.') ;
			if(KErrNotFound != offset)
				{
				TInt lengthOfExt = configFileName.Length() - offset - 1;
				TPtrC versionNum = configFileName.Right(lengthOfExt);				
				TLex lex(versionNum);
				TInt fileVersion = 0;
				if(KErrNone == lex.Val(fileVersion))
					{
					if(fileVersion > aStoredDbConfigFileVersion)
						{
						//The latest version of the configuration file has not yet been processed, so do it now
						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL1, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Config file '%S'", (TUint)this, __SQLPRNSTR(configFileName)));	
						ExecuteConfigurationUpdateL(aFileData, configFileName, fileVersion, aDbName);
						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL2, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Config file '%S' was processed, no errors", (TUint)this, __SQLPRNSTR(configFileName)));	
						}
					else
						{
						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL3, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;Config file '%S' as this or a later version has already been processed", (TUint)this, __SQLPRNSTR(configFileName)));	
						}
					}
				else
					{
					//Invalid config file name extension - it cannot be converted to an integer
					__SQLLEAVE(KErrCorrupt);
					}
				}
			else
				{
				//Invalid config file name - it doesn't contain the character '.'
				__SQLLEAVE(KErrCorrupt);
				}
			}
		else
			{
			SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL4, "0x%X;TSqlDbSysSettings::ConfigureDatabaseL;No config file found for database '%S'", (TUint)this, __SQLPRNSTR(dbFileNameAndExt)));	
			}
		}		
	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, TSQLDBSYSSETTINGS_CONFIGUREDATABASEL_EXIT2, "Exit;0x%X;TSqlDbSysSettings::ConfigureDatabaseL", (TUint)this));    
	}