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 bookmark shortcut target |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <coemain.h> // For CCoeEnv |
|
20 #include <w32std.h> // For RWsSession |
|
21 #include <apgtask.h> // For TApaTaskList |
|
22 #include <gulicon.h> // For CGulIcon |
|
23 #include <AknsUtils.h> // For AknsUtils |
|
24 #include <data_caging_path_literals.hrh> |
|
25 |
|
26 #include "aiscutcontentmodel.h" |
|
27 #include "caiscuttargetbkm.h" |
|
28 #include "caiscutengine.h" |
|
29 #include <aiscutplugin.mbg> |
|
30 |
|
31 #include "debug.h" |
|
32 |
|
33 |
|
34 |
|
35 _LIT16(KParam, "1 "); |
|
36 const TInt KTBUF16 = 16; |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CAiScutTargetBkm::CAiScutTargetBkm(CAiScutEngine& aEngine, TShortcutType aType) |
|
45 : CAiScutTarget(aEngine, aType) |
|
46 { |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CAiScutTargetBkm::ConstructL(const TAiScutParser& aParser) |
|
55 { |
|
56 iDefinition = aParser.Get(EScutDefComplete).AllocL(); |
|
57 iBkmUid = aParser.ParseUid(aParser.Get(EScutDefParamValue)); |
|
58 } |
|
59 |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CAiScutTargetBkm* CAiScutTargetBkm::NewL( |
|
66 CAiScutEngine& aEngine, TShortcutType aType, const TAiScutParser& aParser) |
|
67 { |
|
68 CAiScutTargetBkm* self = new (ELeave) CAiScutTargetBkm(aEngine, aType); |
|
69 |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(aParser); |
|
72 CleanupStack::Pop(self); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CAiScutTargetBkm::~CAiScutTargetBkm() |
|
83 { |
|
84 delete iCaption; |
|
85 delete iDefinition; |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // Returns the shortcut definition string. |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 TPtrC CAiScutTargetBkm::Definition() const |
|
94 { |
|
95 return iDefinition ? TPtrC(*iDefinition) : TPtrC(); |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Returns the shortcut target caption. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CAiScutTargetBkm::GetCaption(TPtrC& aDes, TAiScutAppTitleType /*aTitleType*/) const |
|
104 { |
|
105 // Use lazy evaluation, create the caption only when it is first needed. |
|
106 if (!iCaption) |
|
107 { |
|
108 // Get the caption. |
|
109 TRAP_IGNORE(GetCaptionL()); |
|
110 } |
|
111 |
|
112 aDes.Set(iCaption ? *iCaption : KNullDesC()); |
|
113 |
|
114 return 0; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // Returns the shortcut target caption. |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CAiScutTargetBkm::GetCaptionL() const |
|
122 { |
|
123 RFavouritesDb& db = iEngine.FavouritesDb(); |
|
124 |
|
125 CFavouritesItem* favItem = CFavouritesItem::NewLC(); |
|
126 TInt err = db.Get(iBkmUid.iUid, *favItem); |
|
127 iCaption = favItem->Name().AllocL(); |
|
128 |
|
129 CleanupStack::PopAndDestroy(favItem); |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // Returns the shortcut target icon. |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CAiScutTargetBkm::GetIcon(CGulIcon*& aIcon) const |
|
138 { |
|
139 if ( CAiScutTarget::GetIcon(aIcon) != KErrNone ) |
|
140 { |
|
141 |
|
142 CGulIcon* tempIcon = NULL; |
|
143 |
|
144 TFileName pluginIconFile(KDC_APP_BITMAP_DIR); |
|
145 pluginIconFile.Append(KBitmapFile); |
|
146 |
|
147 TRAP_IGNORE( |
|
148 tempIcon = AknsUtils::CreateGulIconL( |
|
149 AknsUtils::SkinInstance(), |
|
150 KAknsIIDQgnPropAiShortcut, |
|
151 pluginIconFile, |
|
152 EMbmAiscutpluginQgn_menu_url, |
|
153 EMbmAiscutpluginQgn_menu_url_mask |
|
154 ) |
|
155 ); |
|
156 |
|
157 aIcon = tempIcon; |
|
158 } |
|
159 |
|
160 return 0; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // Checks if the target bookmark is accessible. |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CAiScutTargetBkm::IsAccessibleL(TInt /*aCheckType*/) |
|
168 { |
|
169 if (iBkmUid == KNullUid) |
|
170 { |
|
171 return EFalse; |
|
172 } |
|
173 |
|
174 // Search bookmark from favourites. |
|
175 RFavouritesDb& db = iEngine.FavouritesDb(); |
|
176 |
|
177 TBool exists = EFalse; |
|
178 TInt err = db.ItemExists(iBkmUid.iUid, exists); |
|
179 if (err != KErrNone) |
|
180 { |
|
181 exists = EFalse; |
|
182 } |
|
183 |
|
184 return exists; |
|
185 } |
|
186 |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CAiScutTargetBkm::LaunchL() |
|
193 { |
|
194 /* |
|
195 1. Start/Continue the browser and nothing is specified (the default case) Parameter = <Any text> |
|
196 2. Start/Continue the browser specifying a Bookmark Parameter = "1"+"<Space>"+"<Uid of the Bookmark>" |
|
197 3. Start/Continue the browser specifying a Saved deck Parameter = "2"+"<Space>"+"<Uid of the Saved deck>" |
|
198 4. Start/Continue the browser specifying a URL Parameter = "4"+"<Space>"+"<Url>" |
|
199 5. Start/Continue the browser specifying a URL and an Access Point Parameter = "4"+"<Space>"+"<Url>"+"<Space>"+"<Uid of Ap>" |
|
200 6. Start/Continue the browser with the start page. |
|
201 (Used when starting the browser with a long press of "0" in the |
|
202 Idle state of the phone. Parameter = "5" |
|
203 7. Start/Continue the browser specifying a Bookmark folder Parameter = "6"+"<Space>"+"<Uid of the Folder>" |
|
204 */ |
|
205 |
|
206 TApaTaskList taskList(iEngine.Env()->WsSession()); |
|
207 TApaTask task = taskList.FindApp(KScutBrowserUid); |
|
208 |
|
209 |
|
210 TBuf<KTBUF16> param(KParam); |
|
211 param.AppendNum(iBkmUid.iUid); |
|
212 |
|
213 __PRINT( __DBG_FORMAT("XAI: CAiScutTargetBkm::LaunchL '%S' "), ¶m); |
|
214 |
|
215 if (task.Exists()) |
|
216 { |
|
217 HBufC8* param8 = HBufC8::NewLC(param.Length()); |
|
218 param8->Des().Copy(param); |
|
219 task.SendMessage(KNullUid, *param8); // Uid is not used. |
|
220 CleanupStack::PopAndDestroy(param8); |
|
221 } |
|
222 else |
|
223 { |
|
224 TThreadId id; |
|
225 User::LeaveIfError(iEngine.ApaSession().StartDocument( |
|
226 param, KScutBrowserUid, id)); |
|
227 } |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // Return application uid this target launches. |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 TUid CAiScutTargetBkm::AppUid() const |
|
235 { |
|
236 return KScutBrowserUid; |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // Return the bkm id |
|
241 // --------------------------------------------------------------------------- |
|
242 TUid CAiScutTargetBkm::AdditionalUid() const |
|
243 { |
|
244 return iBkmUid; |
|
245 } |
|
246 |
|
247 // End of File. |
|