sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Provides a helper class for process security management sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // Required for logging sl@0: #include sl@0: sl@0: #include "c_process_pair.h" sl@0: #include "rm_debug_logging.h" sl@0: sl@0: sl@0: CProcessPair* CProcessPair::NewL(const TDesC& aProcessName, const TProcessId aProcessId) sl@0: { sl@0: CProcessPair* self=new (ELeave) CProcessPair(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aProcessName, aProcessId); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CProcessPair::ConstructL(const TDesC& aProcessName, const TProcessId aProcessId) sl@0: { sl@0: //allocate the process name buffer and fill with aProcessName sl@0: iProcessName = aProcessName.Alloc(); sl@0: if(iProcessName == NULL) sl@0: User::Leave(KErrNoMemory); sl@0: sl@0: LOG_MSG2( "CProcessPair::ConstructL() process name: %S", &TPtr8((TUint8*)iProcessName->Ptr(), 2*iProcessName->Length(), 2*iProcessName->Length()) ); sl@0: sl@0: //set process id sl@0: iProcessId = aProcessId; sl@0: } sl@0: sl@0: CProcessPair::CProcessPair() sl@0: { sl@0: } sl@0: sl@0: CProcessPair::~CProcessPair() sl@0: { sl@0: delete iProcessName; sl@0: } sl@0: sl@0: /** sl@0: Check whether two CProcessPair objects are equal sl@0: sl@0: @param aProcessPair a CProcessPair object to match with this one sl@0: sl@0: @return ETrue is process id and name match, EFalse otherwise sl@0: */ sl@0: TBool CProcessPair::operator==(const CProcessPair &aProcessPair) const sl@0: { sl@0: return Equals(*aProcessPair.iProcessName, aProcessPair.iProcessId); sl@0: } sl@0: sl@0: /** sl@0: Check whether this CProcessPair object has these values set sl@0: sl@0: @param aProcessName process name to check sl@0: @param aProcessId process id to check sl@0: sl@0: @return ETrue is process id and name match, EFalse otherwise sl@0: */ sl@0: TBool CProcessPair::Equals(const TDesC& aProcessName, const TProcessId aProcessId) const sl@0: { sl@0: return (ProcessIdMatches(aProcessId) && (ProcessNameMatches(aProcessName))); sl@0: } sl@0: sl@0: /** sl@0: Check whether the process ids of two objects match sl@0: sl@0: @param aProcessPair a CProcessPair object to compare with this one sl@0: sl@0: @return ETrue is process id matches, EFalse otherwise sl@0: */ sl@0: TBool CProcessPair::ProcessIdMatches(const CProcessPair &aProcessPair) const sl@0: { sl@0: return ProcessIdMatches(aProcessPair.iProcessId); sl@0: } sl@0: sl@0: /** sl@0: Check whether two process ids match sl@0: sl@0: @param aProcessId a process ID to compare with this pair's process ID sl@0: sl@0: @return ETrue is process id matches, EFalse otherwise sl@0: */ sl@0: TBool CProcessPair::ProcessIdMatches(const TProcessId &aProcessId) const sl@0: { sl@0: return iProcessId == aProcessId; sl@0: } sl@0: sl@0: /** sl@0: Check whether the process names of two objects match in-case-sensitively sl@0: sl@0: @param aProcessPair a CProcessPair object to compare with this one sl@0: sl@0: @return ETrue is process names match, EFalse otherwise sl@0: */ sl@0: TBool CProcessPair::ProcessNameMatches(const CProcessPair &aProcessPair) const sl@0: { sl@0: return ProcessNameMatches(*aProcessPair.iProcessName); sl@0: } sl@0: sl@0: /** sl@0: Check whether two strings match in-case-sensitively sl@0: sl@0: @param aProcessName a process name to compare with this pair's process name sl@0: sl@0: @return ETrue is process names match, EFalse otherwise sl@0: */ sl@0: TBool CProcessPair::ProcessNameMatches(const TDesC& aProcessName) const sl@0: { sl@0: TInt equal = iProcessName->CompareF(aProcessName); sl@0: return (equal == 0) ? ETrue : EFalse; sl@0: } sl@0: