1 /* |
|
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for key lock |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "caiscuttargetkeylock.h" |
|
20 #include <featmgr.h> |
|
21 |
|
22 // Amount of attempts to try to connect to server. |
|
23 const TInt KTriesToConnectServer(3); |
|
24 |
|
25 // Delay between retries to connect. |
|
26 const TInt KTimeBeforeRetryingServerConnection(50000); |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // CAiScutKeyLock::CAiScutKeyLock |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 CAiScutTargetKeyLock::CAiScutTargetKeyLock(CAiScutEngine& aEngine, TShortcutType aType) |
|
33 : CAiScutTarget(aEngine, aType) |
|
34 { |
|
35 } |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CAiScutKeyLock::ConstructL |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 void CAiScutTargetKeyLock::ConstructL(const TDesC& aTarget) |
|
42 { |
|
43 iDefinition = aTarget.AllocL(); |
|
44 |
|
45 TInt err(KErrGeneral); |
|
46 TInt thisTry(0); |
|
47 |
|
48 // Try connect successfully with server limited a number of times |
|
49 err = iKeyLock.Connect(); |
|
50 while ((err != KErrNone) && (thisTry++ < KTriesToConnectServer)) |
|
51 { |
|
52 User::After(KTimeBeforeRetryingServerConnection); |
|
53 err = iKeyLock.Connect(); |
|
54 } |
|
55 User::LeaveIfError(err); |
|
56 |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CAiScutKeyLock::NewL |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 CAiScutTargetKeyLock* CAiScutTargetKeyLock::NewL( |
|
64 CAiScutEngine& aEngine, TShortcutType aType, const TDesC& aTarget) |
|
65 { |
|
66 CAiScutTargetKeyLock* self = new (ELeave) CAiScutTargetKeyLock(aEngine, aType); |
|
67 |
|
68 CleanupStack::PushL(self); |
|
69 self->ConstructL(aTarget); |
|
70 CleanupStack::Pop(self); |
|
71 |
|
72 return self; |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CAiScutKeyLock::~CAiScutKeyLock |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CAiScutTargetKeyLock::~CAiScutTargetKeyLock() |
|
80 { |
|
81 delete iDefinition; |
|
82 iKeyLock.Close(); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // Returns the shortcut definition string |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 TPtrC CAiScutTargetKeyLock::Definition() const |
|
90 { |
|
91 return iDefinition ? TPtrC(*iDefinition) : TPtrC(); |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Returns the shortcut target caption. |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 TInt CAiScutTargetKeyLock::GetCaption(TPtrC& aDes, TAiScutAppTitleType /*aTitleType*/) const |
|
100 { |
|
101 aDes.Set(KNullDesC()); |
|
102 return 0; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // Returns the shortcut target icon. |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CAiScutTargetKeyLock::GetIcon(CGulIcon*& aIcon) const |
|
111 { |
|
112 aIcon = NULL; |
|
113 return 0; |
|
114 } |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // Checks if the target is accessible |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TBool CAiScutTargetKeyLock::IsAccessibleL(TInt /*aCheckType*/) |
|
122 { |
|
123 return ETrue; |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CAiScutTargetKeyLock::LaunchL() |
|
132 { |
|
133 EnableKeyLock(); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Return application uid this target launches. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 TUid CAiScutTargetKeyLock::AppUid() const |
|
141 { |
|
142 return KNullUid; |
|
143 } |
|
144 |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // CAiScutTargetKeyLock::EnableKeyLock |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 void CAiScutTargetKeyLock::EnableKeyLock() |
|
151 { |
|
152 iKeyLock.EnableKeyLock(); |
|
153 } |
|
154 |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CAiScutTargetKeyLock::IsKeyLockEnabled |
|
158 // ---------------------------------------------------------------------------- |
|
159 // |
|
160 TBool CAiScutTargetKeyLock::IsKeyLockEnabled() |
|
161 { |
|
162 return iKeyLock.IsKeyLockEnabled(); |
|
163 } |
|
164 |
|
165 // End of File. |
|