author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:45:50 +0200 | |
branch | RCL_3 |
changeset 81 | e7d2d738d3c2 |
parent 0 | a41df078684a |
child 258 | 880ff05ad710 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// Provides a helper class for process security management |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32base.h> |
|
19 |
#include <e32base_private.h> |
|
20 |
||
21 |
// Required for logging |
|
22 |
#include <rm_debug_api.h> |
|
23 |
||
24 |
#include "c_process_pair.h" |
|
25 |
#include "rm_debug_logging.h" |
|
26 |
||
27 |
||
28 |
CProcessPair* CProcessPair::NewL(const TDesC& aProcessName, const TProcessId aProcessId) |
|
29 |
{ |
|
30 |
CProcessPair* self=new (ELeave) CProcessPair(); |
|
31 |
CleanupStack::PushL(self); |
|
32 |
self->ConstructL(aProcessName, aProcessId); |
|
33 |
CleanupStack::Pop(self); |
|
34 |
return self; |
|
35 |
} |
|
36 |
||
37 |
void CProcessPair::ConstructL(const TDesC& aProcessName, const TProcessId aProcessId) |
|
38 |
{ |
|
39 |
//allocate the process name buffer and fill with aProcessName |
|
40 |
iProcessName = aProcessName.Alloc(); |
|
41 |
if(iProcessName == NULL) |
|
42 |
User::Leave(KErrNoMemory); |
|
43 |
||
44 |
LOG_MSG2( "CProcessPair::ConstructL() process name: %S", &TPtr8((TUint8*)iProcessName->Ptr(), 2*iProcessName->Length(), 2*iProcessName->Length()) ); |
|
45 |
||
46 |
//set process id |
|
47 |
iProcessId = aProcessId; |
|
48 |
} |
|
49 |
||
50 |
CProcessPair::CProcessPair() |
|
51 |
{ |
|
52 |
} |
|
53 |
||
54 |
CProcessPair::~CProcessPair() |
|
55 |
{ |
|
56 |
delete iProcessName; |
|
57 |
} |
|
58 |
||
59 |
/** |
|
60 |
Check whether two CProcessPair objects are equal |
|
61 |
||
62 |
@param aProcessPair a CProcessPair object to match with this one |
|
63 |
||
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
@return 0 if process ids and names do not match, non-zero if they do |
0 | 65 |
*/ |
66 |
TBool CProcessPair::operator==(const CProcessPair &aProcessPair) const |
|
67 |
{ |
|
68 |
return Equals(*aProcessPair.iProcessName, aProcessPair.iProcessId); |
|
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
Check whether this CProcessPair object has these values set |
|
73 |
||
74 |
@param aProcessName process name to check |
|
75 |
@param aProcessId process id to check |
|
76 |
||
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
@return 0 if process ids and names do not match, non-zero if they do |
0 | 78 |
*/ |
79 |
TBool CProcessPair::Equals(const TDesC& aProcessName, const TProcessId aProcessId) const |
|
80 |
{ |
|
81 |
return (ProcessIdMatches(aProcessId) && (ProcessNameMatches(aProcessName))); |
|
82 |
} |
|
83 |
||
84 |
/** |
|
85 |
Check whether the process ids of two objects match |
|
86 |
||
87 |
@param aProcessPair a CProcessPair object to compare with this one |
|
88 |
||
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
@return 0 if process ids do not match, non-zero if they do |
0 | 90 |
*/ |
91 |
TBool CProcessPair::ProcessIdMatches(const CProcessPair &aProcessPair) const |
|
92 |
{ |
|
93 |
return ProcessIdMatches(aProcessPair.iProcessId); |
|
94 |
} |
|
95 |
||
96 |
/** |
|
97 |
Check whether two process ids match |
|
98 |
||
99 |
@param aProcessId a process ID to compare with this pair's process ID |
|
100 |
||
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
101 |
@return 0 if process ids do not match, non-zero if they do |
0 | 102 |
*/ |
103 |
TBool CProcessPair::ProcessIdMatches(const TProcessId &aProcessId) const |
|
104 |
{ |
|
105 |
return iProcessId == aProcessId; |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
Check whether the process names of two objects match in-case-sensitively |
|
110 |
||
111 |
@param aProcessPair a CProcessPair object to compare with this one |
|
112 |
||
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
@return 0 if process names do not match, non-zero if they do |
0 | 114 |
*/ |
115 |
TBool CProcessPair::ProcessNameMatches(const CProcessPair &aProcessPair) const |
|
116 |
{ |
|
117 |
return ProcessNameMatches(*aProcessPair.iProcessName); |
|
118 |
} |
|
119 |
||
120 |
/** |
|
121 |
Check whether two strings match in-case-sensitively |
|
122 |
||
123 |
@param aProcessName a process name to compare with this pair's process name |
|
124 |
||
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
@return 0 if process names do not match, non-zero if they do |
0 | 126 |
*/ |
127 |
TBool CProcessPair::ProcessNameMatches(const TDesC& aProcessName) const |
|
128 |
{ |
|
81
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
return iProcessName->CompareF(aProcessName) == 0; |
0 | 130 |
} |
131 |