Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Provides a helper class for process security management
19 #include <e32base_private.h>
21 // Required for logging
22 #include <rm_debug_api.h>
24 #include "c_process_pair.h"
25 #include "rm_debug_logging.h"
28 CProcessPair* CProcessPair::NewL(const TDesC& aProcessName, const TProcessId aProcessId)
30 CProcessPair* self=new (ELeave) CProcessPair();
31 CleanupStack::PushL(self);
32 self->ConstructL(aProcessName, aProcessId);
33 CleanupStack::Pop(self);
37 void CProcessPair::ConstructL(const TDesC& aProcessName, const TProcessId aProcessId)
39 //allocate the process name buffer and fill with aProcessName
40 iProcessName = aProcessName.Alloc();
41 if(iProcessName == NULL)
42 User::Leave(KErrNoMemory);
44 LOG_MSG2( "CProcessPair::ConstructL() process name: %S", &TPtr8((TUint8*)iProcessName->Ptr(), 2*iProcessName->Length(), 2*iProcessName->Length()) );
47 iProcessId = aProcessId;
50 CProcessPair::CProcessPair()
54 CProcessPair::~CProcessPair()
60 Check whether two CProcessPair objects are equal
62 @param aProcessPair a CProcessPair object to match with this one
64 @return ETrue is process id and name match, EFalse otherwise
66 TBool CProcessPair::operator==(const CProcessPair &aProcessPair) const
68 return Equals(*aProcessPair.iProcessName, aProcessPair.iProcessId);
72 Check whether this CProcessPair object has these values set
74 @param aProcessName process name to check
75 @param aProcessId process id to check
77 @return ETrue is process id and name match, EFalse otherwise
79 TBool CProcessPair::Equals(const TDesC& aProcessName, const TProcessId aProcessId) const
81 return (ProcessIdMatches(aProcessId) && (ProcessNameMatches(aProcessName)));
85 Check whether the process ids of two objects match
87 @param aProcessPair a CProcessPair object to compare with this one
89 @return ETrue is process id matches, EFalse otherwise
91 TBool CProcessPair::ProcessIdMatches(const CProcessPair &aProcessPair) const
93 return ProcessIdMatches(aProcessPair.iProcessId);
97 Check whether two process ids match
99 @param aProcessId a process ID to compare with this pair's process ID
101 @return ETrue is process id matches, EFalse otherwise
103 TBool CProcessPair::ProcessIdMatches(const TProcessId &aProcessId) const
105 return iProcessId == aProcessId;
109 Check whether the process names of two objects match in-case-sensitively
111 @param aProcessPair a CProcessPair object to compare with this one
113 @return ETrue is process names match, EFalse otherwise
115 TBool CProcessPair::ProcessNameMatches(const CProcessPair &aProcessPair) const
117 return ProcessNameMatches(*aProcessPair.iProcessName);
121 Check whether two strings match in-case-sensitively
123 @param aProcessName a process name to compare with this pair's process name
125 @return ETrue is process names match, EFalse otherwise
127 TBool CProcessPair::ProcessNameMatches(const TDesC& aProcessName) const
129 TInt equal = iProcessName->CompareF(aProcessName);
130 return (equal == 0) ? ETrue : EFalse;