1 /* |
|
2 * Copyright (c) 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: CCSXHHtmlTopicView class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDES |
|
19 #include "CSXHHtmlTopicView.h" |
|
20 #include "CSXHHtmlTopicContainer.h" |
|
21 #include "CSXHHtmlTOC2.h" |
|
22 #include "CSXHAppUi.h" |
|
23 #include "CSXHDocument.h" |
|
24 #include <cshelp.rsg> |
|
25 #include "CsHelp.hrh" |
|
26 |
|
27 #include "CSXHViewIDs.h" |
|
28 #include "CSXHKywdTOC1.h" |
|
29 #include "CSXHHelpDataBase.h" |
|
30 #include "CSXHContextTopic.h" |
|
31 #include "CSXHHtmlTOC2.h" |
|
32 #include "CSXHHtmlTOC1.h" |
|
33 |
|
34 #include <avkon.hrh> |
|
35 #include <aknnotewrappers.h> |
|
36 #include <brctldefs.h> |
|
37 #include <f32file.h> |
|
38 #include <apgcli.h> |
|
39 #include <akntitle.h> |
|
40 |
|
41 #include <AiwMenu.h> |
|
42 #include <AiwCommon.h> |
|
43 #include <AiwServiceHandler.h> |
|
44 #include <AknGlobalNote.h> |
|
45 TInt CCSXHHtmlTopicView::iFontSize = TBrCtlDefs::EFontSizeLevelLarger; |
|
46 |
|
47 CCSXHHtmlTopicView* CCSXHHtmlTopicView::NewL(const TUid& aUid, const TInt& aFlags,const |
|
48 TRect& aRect) |
|
49 { |
|
50 CCSXHHtmlTopicView* temp = new(ELeave) CCSXHHtmlTopicView(aUid,aFlags); |
|
51 CleanupStack::PushL(temp); |
|
52 temp->ConstructL(aRect); |
|
53 CleanupStack::Pop(temp); |
|
54 return temp; |
|
55 } |
|
56 |
|
57 CCSXHHtmlTopicView::CCSXHHtmlTopicView(const TUid& aUid, const TInt& aFlags): |
|
58 iUid(aUid),iAppFlags(aFlags) |
|
59 { |
|
60 } |
|
61 CCSXHHtmlTopicView::~CCSXHHtmlTopicView() |
|
62 { |
|
63 if(iBCContainer) |
|
64 { |
|
65 delete iBCContainer; |
|
66 iBCContainer = NULL; |
|
67 } |
|
68 } |
|
69 |
|
70 void CCSXHHtmlTopicView::ConstructL(const TRect& /*aRect*/) |
|
71 { |
|
72 BaseConstructL(iAppFlags); |
|
73 } |
|
74 |
|
75 void CCSXHHtmlTopicView::SetViewTypeL(TInt type) |
|
76 { |
|
77 if(type == iContextTopicView) |
|
78 return; |
|
79 |
|
80 if(type == EContextHtmlView) |
|
81 { |
|
82 iContextTopicView = ETrue; |
|
83 SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_CLOSE_OPENLINK); |
|
84 } |
|
85 else |
|
86 { |
|
87 iContextTopicView = EFalse; |
|
88 SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_BACK_OPENLINK); |
|
89 } |
|
90 } |
|
91 |
|
92 TInt CCSXHHtmlTopicView::GetViewType() |
|
93 { |
|
94 return iContextTopicView ? EContextHtmlView : EHtmlView; |
|
95 } |
|
96 |
|
97 TUid CCSXHHtmlTopicView::Id() const |
|
98 { |
|
99 return iUid; |
|
100 } |
|
101 // -------------------------------------------------------------------------- |
|
102 // Launches an application based on the Application UID and a View ID |
|
103 // -------------------------------------------------------------------------- |
|
104 void CCSXHHtmlTopicView::HandleCommandL(TInt aCommand ) |
|
105 { |
|
106 switch(aCommand) |
|
107 { |
|
108 case EAknSoftkeyBack: |
|
109 { |
|
110 if(iBCContainer->HandleBackKeyL()) |
|
111 return; |
|
112 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
113 //if not the current view, return |
|
114 TUid viewId = doc->GetDisplayTopic()->GetViewID(); |
|
115 if( viewId != KCSXHHtmlTopicViewID && viewId != KCSXHKywdToc2ViewID ) |
|
116 { |
|
117 return; |
|
118 } |
|
119 CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic()); |
|
120 CCSXHKywdTOC1* kywdParent = displayTopic->GetKywdParent(); |
|
121 if(kywdParent) |
|
122 { |
|
123 doc->SetDisplayAndPrevTopic(kywdParent); |
|
124 AppUi()->HandleCommandL(ECSXHOpenItem); |
|
125 } |
|
126 else |
|
127 { |
|
128 HandleCommandL(ECSXHOpenApplicationTopics); |
|
129 } |
|
130 break; |
|
131 } |
|
132 case ECSXHOpenApplicationTopics: |
|
133 { |
|
134 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
135 if(iBCContainer->GetCurrActiveObject()) |
|
136 { |
|
137 doc->SetDisplayTopic(iBCContainer->GetCurrActiveObject()); |
|
138 CCSXHAppUi::GetInstance()->ResetTOC2ViewContainer(); |
|
139 } |
|
140 CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic()); |
|
141 doc->SetDisplayAndPrevTopic(displayTopic->GetParent()); |
|
142 AppUi()->HandleCommandL(ECSXHOpenItem); |
|
143 } |
|
144 break; |
|
145 case ECSXHTOC1ListView: |
|
146 { |
|
147 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
148 if(iBCContainer->GetCurrActiveObject()) |
|
149 { |
|
150 doc->SetDisplayTopic(iBCContainer->GetCurrActiveObject()); |
|
151 CCSXHAppUi::GetInstance()->ResetTOC2ViewContainer(); |
|
152 } |
|
153 |
|
154 CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic()); |
|
155 //These two steps are necessary to set the correct display and prev topics |
|
156 doc->SetDisplayTopic(displayTopic->GetParent()); |
|
157 doc->SetDisplayAndPrevTopic(doc->GetHelpDataBase()->GetMainTopics()); |
|
158 AppUi()->HandleCommandL(ECSXHOpenItem); |
|
159 } |
|
160 break; |
|
161 case ECsHelpCmdFontLarge: |
|
162 { |
|
163 TInt CurrentFontSize = iBCContainer->GetCurrentValueL(TBrCtlDefs::ESettingsFontSize); |
|
164 iBCContainer->SetSelectedFontSizeL(++CurrentFontSize); |
|
165 iFontSize = CurrentFontSize; |
|
166 } |
|
167 break; |
|
168 case ECsHelpCmdFontSmall: |
|
169 { |
|
170 TInt CurrentFontSize = iBCContainer->GetCurrentValueL(TBrCtlDefs::ESettingsFontSize); |
|
171 iBCContainer->SetSelectedFontSizeL(--CurrentFontSize); |
|
172 iFontSize = CurrentFontSize; |
|
173 } |
|
174 break; |
|
175 case ECSXHOpenHyperLink: |
|
176 { |
|
177 iBCContainer->HandleCommandOpenHyperLinkL(); |
|
178 } |
|
179 break; |
|
180 case ECSXHSearchText: |
|
181 { |
|
182 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
183 if(iBCContainer->GetCurrActiveObject()) |
|
184 { |
|
185 doc->SetDisplayTopic(iBCContainer->GetCurrActiveObject()); |
|
186 CCSXHAppUi::GetInstance()->ResetTOC2ViewContainer(); |
|
187 } |
|
188 } |
|
189 AppUi()->HandleCommandL( aCommand ); |
|
190 break; |
|
191 case EAknSoftkeyExit: |
|
192 case EAknSoftkeyClose: |
|
193 AppUi()->HandleCommandL( aCommand ); |
|
194 break; |
|
195 default: |
|
196 break; |
|
197 } |
|
198 } |
|
199 // -------------------------------------------------------------------------- |
|
200 // Handlign for view activation. For a context view, the actual display topic |
|
201 // has to be modified |
|
202 // -------------------------------------------------------------------------- |
|
203 void CCSXHHtmlTopicView::DoActivateL(const TVwsViewId& aPrevViewId,TUid,const TDesC8&) |
|
204 { |
|
205 iPrevious = aPrevViewId; |
|
206 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
207 |
|
208 if(!iBCContainer) |
|
209 { |
|
210 TRAPD(Result,iBCContainer = CCSXHHtmlTopicContainer::NewL(ClientRect(),*doc,this)); |
|
211 if(KErrNone != Result) |
|
212 return; |
|
213 } |
|
214 |
|
215 //Set the correct display topic here for context sensitive launch |
|
216 if(doc->GetDisplayTopic()->GetViewID() == KCSXHContextHtmlTopicViewID) |
|
217 { |
|
218 CCSXHContextTopic *topic = STATIC_CAST(CCSXHContextTopic*,doc->GetDisplayTopic()); |
|
219 doc->SetDisplayTopic(topic->GetTopic()); |
|
220 iContextTopicView = ETrue; |
|
221 } |
|
222 else |
|
223 { |
|
224 iContextTopicView = EFalse; |
|
225 } |
|
226 |
|
227 CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic()); |
|
228 TRAPD(err,iBCContainer->SetAndLoadInitialTopicL(displayTopic)); |
|
229 |
|
230 if( KErrNone != err ) |
|
231 { |
|
232 delete iBCContainer; |
|
233 iBCContainer = NULL; |
|
234 return; |
|
235 } |
|
236 if( iContextTopicView ) |
|
237 { |
|
238 SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_CLOSE_OPENLINK); |
|
239 } |
|
240 else |
|
241 { |
|
242 SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_BACK_OPENLINK); |
|
243 } |
|
244 iBCContainer->SetMopParent(this); |
|
245 iBCContainer->SetRect(ClientRect()); |
|
246 AppUi()->AddToStackL(*this, iBCContainer); |
|
247 iBCContainer->MakeVisible(ETrue); |
|
248 } |
|
249 |
|
250 void CCSXHHtmlTopicView::DoDeactivate() |
|
251 { |
|
252 if(iBCContainer) |
|
253 { |
|
254 iBCContainer->MakeVisible(EFalse); |
|
255 TRAP_IGNORE(iBCContainer->CancelFetchL()); |
|
256 // FEP causes crash if it still hold the observer. |
|
257 // fix as FEP suggested. |
|
258 iBCContainer->SetFocus( EFalse ); |
|
259 AppUi()->RemoveFromStack(iBCContainer); |
|
260 } |
|
261 } |
|
262 // -------------------------------------------------------------------------- |
|
263 // When a view which was previously activated, goes to background and gets |
|
264 // activated again, the DoActivateL will not be called only ViewActivatedL |
|
265 // will be called. Special handling is required for the context view for the |
|
266 // scenario, open context help from any application, with out changing the |
|
267 // help view, open context help from another application, the contents of the |
|
268 // context view has to be refreshed with the new topic |
|
269 // -------------------------------------------------------------------------- |
|
270 void CCSXHHtmlTopicView::ViewActivatedL(const TVwsViewId& aPrevViewId, |
|
271 TUid aCustomMessageId, |
|
272 const TDesC8& aCustomMessage) |
|
273 { |
|
274 |
|
275 if(iBCContainer) |
|
276 { |
|
277 //This handling is required for the following scenario |
|
278 //Context sensitive help launch more than once with no |
|
279 //other view navigation in the help application |
|
280 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
281 if(doc->GetDisplayTopic()->GetViewID() == KCSXHContextHtmlTopicViewID) |
|
282 { |
|
283 CCSXHContextTopic *topic = static_cast<CCSXHContextTopic*>(doc->GetDisplayTopic()); |
|
284 doc->SetDisplayTopic(topic->GetTopic()); |
|
285 CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic()); |
|
286 iBCContainer->RefreshL(displayTopic); |
|
287 SetSoftKeysL(R_CSHELP_SOFTKEYS_OPTIONS_CLOSE_OPENLINK); |
|
288 } |
|
289 iBCContainer->CheckForMSK(); |
|
290 } |
|
291 CAknView::ViewActivatedL(aPrevViewId,aCustomMessageId,aCustomMessage); |
|
292 } |
|
293 |
|
294 void CCSXHHtmlTopicView::SetSoftKeysL(TInt aSoftKeys) |
|
295 { |
|
296 if( Cba() ) |
|
297 { |
|
298 Cba()->SetCommandSetL( aSoftKeys ); |
|
299 Cba()->DrawDeferred(); |
|
300 } |
|
301 } |
|
302 // -------------------------------------------------------------------------- |
|
303 // Dynamically updating Options menu item |
|
304 // -------------------------------------------------------------------------- |
|
305 void CCSXHHtmlTopicView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
306 { |
|
307 |
|
308 if( R_CSXH_MENU_HTMLTOPICVIEW == aResourceId) |
|
309 { |
|
310 TInt CurrentFontSize = iBCContainer->GetCurrentValueL(TBrCtlDefs::ESettingsFontSize); |
|
311 |
|
312 if(CurrentFontSize == TBrCtlDefs::EFontSizeLevelNormal) |
|
313 { |
|
314 aMenuPane->SetItemDimmed(ECsHelpCmdFontSmall,ETrue); |
|
315 } |
|
316 else if(CurrentFontSize == TBrCtlDefs::EFontSizeLevelAllLarge) |
|
317 { |
|
318 aMenuPane->SetItemDimmed(ECsHelpCmdFontLarge,ETrue); |
|
319 } |
|
320 |
|
321 if(!iBCContainer->IsHyperLinkFocused()) |
|
322 { |
|
323 aMenuPane->SetItemDimmed(ECSXHOpenHyperLink,ETrue); |
|
324 } |
|
325 } |
|
326 } |
|
327 // -------------------------------------------------------------------------- |
|
328 // MSK Handling |
|
329 // -------------------------------------------------------------------------- |
|
330 void CCSXHHtmlTopicView::SetMiddleSoftKey(TBool aValue) |
|
331 { |
|
332 #ifndef __SERIES60_30__ |
|
333 if(AknLayoutUtils::MSKEnabled()) |
|
334 { |
|
335 Cba()->MakeCommandVisible(ECSXHOpenHyperLink,aValue); |
|
336 Cba()->DrawDeferred(); |
|
337 } |
|
338 #endif |
|
339 } |
|
340 |
|
341 TInt CCSXHHtmlTopicView::GetCurrentFontSize() |
|
342 { |
|
343 return iFontSize; |
|
344 } |
|
345 |
|
346 void CCSXHHtmlTopicView::ResourceChangeHdl(TInt aType) |
|
347 { |
|
348 if(iBCContainer) |
|
349 iBCContainer->HandleResourceChangeImpl(aType); |
|
350 } |
|
351 |
|
352 #ifdef FF_HELP_TUTORIAL_MERGE |
|
353 // -------------------------------------------------------------------------- |
|
354 // CCSXHAppUi::LaunchTutorial |
|
355 // Lauch tutorial if exist, else popup a error message. |
|
356 // -------------------------------------------------------------------------- |
|
357 void CCSXHHtmlTopicView::LaunchTutorialL() |
|
358 { |
|
359 CCSXHDocument *doc = static_cast<CCSXHDocument*>(AppUi()->Document()); |
|
360 CCSXHHtmlTOC2 *displayTopic = STATIC_CAST(CCSXHHtmlTOC2*,doc->GetDisplayTopic()); |
|
361 TCoeHelpContext helpContext; |
|
362 displayTopic->GetHelpContext(helpContext); |
|
363 CCSXHAppUi::GetInstance()->SetHelpContext(helpContext); |
|
364 if( CCSXHAppUi::GetInstance()->IsApplicationPresentInTutorialL() ) |
|
365 { |
|
366 CCSXHAppUi::GetInstance()->CallTutorialAiwProviderL(); |
|
367 } |
|
368 else |
|
369 { |
|
370 HBufC* ErrorMessage = iCoeEnv->AllocReadResourceLC(R_TYPE_NO_HELP_TOPICS); |
|
371 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
372 note->ShowNoteL(EAknGlobalInformationNote, *ErrorMessage); |
|
373 |
|
374 CleanupStack::PopAndDestroy(note); |
|
375 CleanupStack::PopAndDestroy(ErrorMessage); |
|
376 } |
|
377 } |
|
378 #endif // FF_HELP_TUTORIAL_MERGE |
|