0
|
1 |
// Copyright (c) 1996-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 |
// 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 |
|
|
44 |
void CCaptureKeys::CheckCaptureKey(const TCaptureKey& aCaptureKey)
|
|
45 |
{
|
|
46 |
|
|
47 |
if ((aCaptureKey.iModifiers.iValue&~aCaptureKey.iModifiers.iMask)!=0)
|
|
48 |
User::Leave(KErrArgument);
|
|
49 |
}
|
|
50 |
|
|
51 |
EXPORT_C void CCaptureKeys::AddCaptureKeyL(const TCaptureKey& aCaptureKey)
|
|
52 |
//
|
|
53 |
// Adds the specified capture-key to the list
|
|
54 |
//
|
|
55 |
{
|
|
56 |
|
|
57 |
AddCaptureKeyL(aCaptureKey,0);
|
|
58 |
}
|
|
59 |
|
|
60 |
EXPORT_C void CCaptureKeys::AddCaptureKeyL(const TCaptureKey& aCaptureKey, TUint8 aPriority)
|
|
61 |
//
|
|
62 |
// Adds the specified capture-key to the beginning of the list
|
|
63 |
//
|
|
64 |
{
|
|
65 |
|
|
66 |
TCaptureKey captureKey(aCaptureKey);
|
|
67 |
captureKey.iKeyCodePattern.iFiller = aPriority;// Priority is stored in spare data member 'iFiller'
|
|
68 |
CheckCaptureKey(captureKey);
|
|
69 |
User::LeaveIfError(iCKarray.Insert(captureKey,0));
|
|
70 |
}
|
|
71 |
|
|
72 |
EXPORT_C void CCaptureKeys::SetCaptureKey(TUint32 aHandle, const TCaptureKey& aCaptureKey)
|
|
73 |
//
|
|
74 |
// Finds the first capture-key from the list that matches the handle and sets
|
|
75 |
// it to the new value.
|
|
76 |
//
|
|
77 |
{
|
|
78 |
|
|
79 |
SetCaptureKey(aHandle,aCaptureKey,0);
|
|
80 |
}
|
|
81 |
|
|
82 |
EXPORT_C void CCaptureKeys::SetCaptureKey(TUint32 aHandle, const TCaptureKey& aCaptureKey, TUint8 aPriority)
|
|
83 |
//
|
|
84 |
// Finds the first capture-key from the list that matches the handle and sets
|
|
85 |
// it to the new value.
|
|
86 |
//
|
|
87 |
{
|
|
88 |
|
|
89 |
TCaptureKey captureKey(aCaptureKey);
|
|
90 |
captureKey.iKeyCodePattern.iFiller = aPriority;// Priority is stored in spare data member 'iFiller'
|
|
91 |
CheckCaptureKey(captureKey);
|
|
92 |
TCaptureKey ck;
|
|
93 |
ck.iHandle=aHandle;
|
|
94 |
TInt r=iCKarray.Find(ck);
|
|
95 |
if (r>=0)
|
|
96 |
iCKarray[r]=captureKey;
|
|
97 |
}
|
|
98 |
|
|
99 |
void CCaptureKeys::removeCaptureKey(TUint aIndex)
|
|
100 |
//
|
|
101 |
// Removes the capture-key at the given aIndex from the list
|
|
102 |
//
|
|
103 |
{
|
|
104 |
|
|
105 |
iCKarray.Remove(aIndex);
|
|
106 |
}
|
|
107 |
|
|
108 |
EXPORT_C void CCaptureKeys::CancelCaptureKey(TUint32 aHandle)
|
|
109 |
//
|
|
110 |
// Removes the first capture-key from the list that matches the handle;
|
|
111 |
//
|
|
112 |
{
|
|
113 |
|
|
114 |
TCaptureKey ck;
|
|
115 |
ck.iHandle=aHandle;
|
|
116 |
TInt r=iCKarray.Find(ck);
|
|
117 |
if (r>=0)
|
|
118 |
iCKarray.Remove(r);
|
|
119 |
}
|
|
120 |
|
|
121 |
EXPORT_C void CCaptureKeys::CancelAllCaptureKeys(TUint32 aApp)
|
|
122 |
//
|
|
123 |
// Removes all capture-keys from the list that match the given application handle
|
|
124 |
//
|
|
125 |
{
|
|
126 |
|
|
127 |
TInt i=iCKarray.Count();
|
|
128 |
while(--i>=0)
|
|
129 |
{
|
|
130 |
if (iCKarray[i].iApp==aApp)
|
|
131 |
iCKarray.Remove(i);
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
EXPORT_C void CCaptureKeys::ProcessCaptureKeys(TKeyData& aKeyData) const
|
|
136 |
//
|
|
137 |
// Sets aKeyData.iIsCaptureKey to true if the given aKeyCode match a capture-key in the list
|
|
138 |
// and sets aKeyData.iApp to the handle of the last application that set it;
|
|
139 |
// otherwise sets aKeyData.iIsCaptureKey to false and aKeyData.iApp to 0.
|
|
140 |
//
|
|
141 |
{
|
|
142 |
|
|
143 |
TCharExtended ch=aKeyData.iKeyCode;
|
|
144 |
aKeyData.iIsCaptureKey=EFalse;
|
|
145 |
aKeyData.iApp = 0x0;
|
|
146 |
TInt c=iCKarray.Count();
|
|
147 |
TInt i;
|
|
148 |
TInt priority=KMinTInt;
|
|
149 |
for (i=0; i<c; i++)
|
|
150 |
{
|
|
151 |
const TCaptureKey& ck=iCKarray[i];
|
|
152 |
if ( ch.MatchesPattern(ck.iKeyCodePattern) && MatchesMaskedValue(aKeyData.iModifiers, ck.iModifiers) )
|
|
153 |
{
|
|
154 |
if(ck.iKeyCodePattern.iFiller>priority)
|
|
155 |
{
|
|
156 |
priority=ck.iKeyCodePattern.iFiller;
|
|
157 |
aKeyData.iApp=ck.iApp;
|
|
158 |
aKeyData.iHandle=ck.iHandle;
|
|
159 |
aKeyData.iIsCaptureKey=ETrue;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|