author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 |
// e32\ewsrv\ky_capt.cpp |
|
15 |
// Provides the operations of setting and cancelling capture-keys |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include <e32svr.h> |
|
20 |
#include <k32keys.h> |
|
21 |
||
22 |
const TInt KCaptureKeyArrayGranularity=5; |
|
23 |
||
24 |
EXPORT_C CCaptureKeys::CCaptureKeys() |
|
25 |
: iCKarray(KCaptureKeyArrayGranularity, _FOFF(TCaptureKey,iHandle)) |
|
26 |
{ |
|
27 |
} |
|
28 |
||
29 |
EXPORT_C void CCaptureKeys::Construct() |
|
30 |
// |
|
31 |
// |
|
32 |
// |
|
33 |
{ |
|
34 |
} |
|
35 |
||
36 |
EXPORT_C CCaptureKeys::~CCaptureKeys() |
|
37 |
// |
|
38 |
// Destructor |
|
39 |
// |
|
40 |
{ |
|
41 |
iCKarray.Close(); |
|
42 |
} |
|
43 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
/** |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
@note This function can Leave and does not obey the |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
coding standard |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
*/ |
0 | 48 |
void CCaptureKeys::CheckCaptureKey(const TCaptureKey& aCaptureKey) |
49 |
{ |
|
50 |
||
51 |
if ((aCaptureKey.iModifiers.iValue&~aCaptureKey.iModifiers.iMask)!=0) |
|
52 |
User::Leave(KErrArgument); |
|
53 |
} |
|
54 |
||
55 |
EXPORT_C void CCaptureKeys::AddCaptureKeyL(const TCaptureKey& aCaptureKey) |
|
56 |
// |
|
57 |
// Adds the specified capture-key to the list |
|
58 |
// |
|
59 |
{ |
|
60 |
||
61 |
AddCaptureKeyL(aCaptureKey,0); |
|
62 |
} |
|
63 |
||
64 |
EXPORT_C void CCaptureKeys::AddCaptureKeyL(const TCaptureKey& aCaptureKey, TUint8 aPriority) |
|
65 |
// |
|
66 |
// Adds the specified capture-key to the beginning of the list |
|
67 |
// |
|
68 |
{ |
|
69 |
||
70 |
TCaptureKey captureKey(aCaptureKey); |
|
71 |
captureKey.iKeyCodePattern.iFiller = aPriority;// Priority is stored in spare data member 'iFiller' |
|
72 |
CheckCaptureKey(captureKey); |
|
73 |
User::LeaveIfError(iCKarray.Insert(captureKey,0)); |
|
74 |
} |
|
75 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
/** |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
77 |
@note This function can Leave and does not obey the |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
coding standard |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
*/ |
0 | 80 |
EXPORT_C void CCaptureKeys::SetCaptureKey(TUint32 aHandle, const TCaptureKey& aCaptureKey) |
81 |
// |
|
82 |
// Finds the first capture-key from the list that matches the handle and sets |
|
83 |
// it to the new value. |
|
84 |
// |
|
85 |
{ |
|
86 |
||
87 |
SetCaptureKey(aHandle,aCaptureKey,0); |
|
88 |
} |
|
89 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
/** |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
@note This function can Leave and does not obey the |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
coding standard |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
*/ |
0 | 94 |
EXPORT_C void CCaptureKeys::SetCaptureKey(TUint32 aHandle, const TCaptureKey& aCaptureKey, TUint8 aPriority) |
95 |
// |
|
96 |
// Finds the first capture-key from the list that matches the handle and sets |
|
97 |
// it to the new value. |
|
98 |
// |
|
99 |
{ |
|
100 |
||
101 |
TCaptureKey captureKey(aCaptureKey); |
|
102 |
captureKey.iKeyCodePattern.iFiller = aPriority;// Priority is stored in spare data member 'iFiller' |
|
103 |
CheckCaptureKey(captureKey); |
|
104 |
TCaptureKey ck; |
|
105 |
ck.iHandle=aHandle; |
|
106 |
TInt r=iCKarray.Find(ck); |
|
107 |
if (r>=0) |
|
108 |
iCKarray[r]=captureKey; |
|
109 |
} |
|
110 |
||
111 |
EXPORT_C void CCaptureKeys::CancelCaptureKey(TUint32 aHandle) |
|
112 |
// |
|
113 |
// Removes the first capture-key from the list that matches the handle; |
|
114 |
// |
|
115 |
{ |
|
116 |
||
117 |
TCaptureKey ck; |
|
118 |
ck.iHandle=aHandle; |
|
119 |
TInt r=iCKarray.Find(ck); |
|
120 |
if (r>=0) |
|
121 |
iCKarray.Remove(r); |
|
122 |
} |
|
123 |
||
124 |
EXPORT_C void CCaptureKeys::CancelAllCaptureKeys(TUint32 aApp) |
|
125 |
// |
|
126 |
// Removes all capture-keys from the list that match the given application handle |
|
127 |
// |
|
128 |
{ |
|
129 |
||
130 |
TInt i=iCKarray.Count(); |
|
131 |
while(--i>=0) |
|
132 |
{ |
|
133 |
if (iCKarray[i].iApp==aApp) |
|
134 |
iCKarray.Remove(i); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
EXPORT_C void CCaptureKeys::ProcessCaptureKeys(TKeyData& aKeyData) const |
|
139 |
// |
|
140 |
// Sets aKeyData.iIsCaptureKey to true if the given aKeyCode match a capture-key in the list |
|
141 |
// and sets aKeyData.iApp to the handle of the last application that set it; |
|
142 |
// otherwise sets aKeyData.iIsCaptureKey to false and aKeyData.iApp to 0. |
|
143 |
// |
|
144 |
{ |
|
145 |
||
146 |
TCharExtended ch=aKeyData.iKeyCode; |
|
147 |
aKeyData.iIsCaptureKey=EFalse; |
|
148 |
aKeyData.iApp = 0x0; |
|
149 |
TInt c=iCKarray.Count(); |
|
150 |
TInt i; |
|
151 |
TInt priority=KMinTInt; |
|
152 |
for (i=0; i<c; i++) |
|
153 |
{ |
|
154 |
const TCaptureKey& ck=iCKarray[i]; |
|
155 |
if ( ch.MatchesPattern(ck.iKeyCodePattern) && MatchesMaskedValue(aKeyData.iModifiers, ck.iModifiers) ) |
|
156 |
{ |
|
157 |
if(ck.iKeyCodePattern.iFiller>priority) |
|
158 |
{ |
|
159 |
priority=ck.iKeyCodePattern.iFiller; |
|
160 |
aKeyData.iApp=ck.iApp; |
|
161 |
aKeyData.iHandle=ck.iHandle; |
|
162 |
aKeyData.iIsCaptureKey=ETrue; |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |