|
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: CCSXHDocument class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CSXHDocument.h" |
|
20 #include "CSXHAppUi.h" |
|
21 |
|
22 #include "CSXHHelpDataBase.h" |
|
23 #include "CSXHKywdTOC1.h" |
|
24 #include "CSXHViewIDs.h" |
|
25 #include <eikprogi.h> |
|
26 |
|
27 #include <cshelp.rsg> |
|
28 #include <AknProgressDialog.h> |
|
29 |
|
30 |
|
31 // Standard Symbian OS construction sequence |
|
32 CCSXHDocument* CCSXHDocument::NewL(CEikApplication& aApp) |
|
33 { |
|
34 CCSXHDocument* self = NewLC(aApp); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CCSXHDocument* CCSXHDocument::NewLC(CEikApplication& aApp) |
|
40 { |
|
41 CCSXHDocument* self = new (ELeave) CCSXHDocument(aApp); |
|
42 CleanupStack::PushL(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CCSXHDocument::CCSXHDocument(CEikApplication& aApp) : CAknDocument(aApp) |
|
47 {// no implementation required |
|
48 } |
|
49 |
|
50 CCSXHDocument::~CCSXHDocument() |
|
51 { |
|
52 delete iHelpDataBase; |
|
53 } |
|
54 |
|
55 CEikAppUi* CCSXHDocument::CreateAppUiL() |
|
56 { |
|
57 // Create the application user interface, and return a pointer to it, |
|
58 // the framework takes ownership of this object. ConstructL of the AppUi |
|
59 // object will be called by the Application Framework |
|
60 iHelpAppUi = new (ELeave) CCSXHAppUi; |
|
61 |
|
62 iHelpDataBase = CCSXHHelpDataBase::NewL(CCSXHAppUi::GetCoeEnv(),AppCaption()); |
|
63 iDisplayTopic = iHelpDataBase->GetMainTopics(); |
|
64 iPrevTopic = NULL; |
|
65 |
|
66 iProgressDialog = NULL; |
|
67 |
|
68 return iHelpAppUi; |
|
69 } |
|
70 // -------------------------------------------------------------------------- |
|
71 // Sets the topic to be displayed next |
|
72 // -------------------------------------------------------------------------- |
|
73 void CCSXHDocument::SetDisplayTopic(CCSXHHelpContentBase* aDisplayTopic) |
|
74 { |
|
75 iDisplayTopic = aDisplayTopic; |
|
76 iPrevTopic = NULL; |
|
77 |
|
78 if(iDisplayTopic == NULL) |
|
79 iDisplayTopic = iHelpDataBase->GetMainTopics(); |
|
80 } |
|
81 // -------------------------------------------------------------------------- |
|
82 // Sets the topic to be displayed next and the previous topic |
|
83 // The previous topic is needed to highlight the correct item in the listbox |
|
84 // -------------------------------------------------------------------------- |
|
85 void CCSXHDocument::SetDisplayAndPrevTopic(CCSXHHelpContentBase* aDisplayTopic) |
|
86 { |
|
87 iPrevTopic = iDisplayTopic; |
|
88 iDisplayTopic = aDisplayTopic; |
|
89 |
|
90 if(iDisplayTopic == NULL) |
|
91 iDisplayTopic = iHelpDataBase->GetMainTopics(); |
|
92 |
|
93 } |
|
94 |
|
95 void CCSXHDocument::SendMessageToAppUiL(TInt aCommand) |
|
96 { |
|
97 iHelpAppUi->ProcessCommandL(aCommand); |
|
98 } |
|
99 |
|
100 // -------------------------------------------------------------------------- |
|
101 // Sets the context topic as the next topic to be displayed |
|
102 // -------------------------------------------------------------------------- |
|
103 TBool CCSXHDocument::SetContextTopicAsDisplayTopicL(const TDesC8& aContextMessage) |
|
104 { |
|
105 CCSXHHelpContentBase* topic = iHelpDataBase->GetContextTopic(aContextMessage); |
|
106 if(topic) |
|
107 { |
|
108 SetDisplayTopic(topic); |
|
109 return ETrue; |
|
110 } |
|
111 return EFalse; |
|
112 } |
|
113 CCSXHHelpContentBase* CCSXHDocument::GetHtmlTopicForUrlL(const TDesC& url) |
|
114 { |
|
115 return iHelpDataBase->GetHtmlTopicForUrlL(url); |
|
116 } |
|
117 |
|
118 void CCSXHDocument::InitProgressBarL() |
|
119 { |
|
120 |
|
121 iProgressDialog = new(ELeave)CAknProgressDialog( |
|
122 REINTERPRET_CAST(CEikDialog**,&iProgressDialog)); |
|
123 iProgressDialog->PrepareLC(R_CSHELP_SEARCH_PROGRESS_NOTE); |
|
124 |
|
125 CEikProgressInfo* pBar = iProgressDialog->GetProgressInfoL(); |
|
126 iTotalKeywordsInResultView = iHelpDataBase->InitGenerateKeywordTOC2ListL( |
|
127 STATIC_CAST(CCSXHKywdTOC1*,iDisplayTopic)); |
|
128 pBar->SetFinalValue(iTotalKeywordsInResultView); |
|
129 iIdle = CIdle::NewL(CActive::EPriorityLow); |
|
130 TCallBack callback(CallBack, this); |
|
131 iIdle->Start(callback); |
|
132 iProgressDialog->RunDlgLD(CAknNoteDialog::ENoTone); |
|
133 } |
|
134 |
|
135 void CCSXHDocument::FreeProgressBarL() |
|
136 { |
|
137 delete iIdle; |
|
138 iIdle = NULL; |
|
139 if(iProgressDialog) |
|
140 { |
|
141 iProgressDialog->ProcessFinishedL(); |
|
142 iProgressDialog = NULL; |
|
143 } |
|
144 } |
|
145 |
|
146 TInt CCSXHDocument::CallBack(TAny* aThis) |
|
147 { |
|
148 TInt err(KErrNone); |
|
149 TBool res(EFalse); |
|
150 CCSXHDocument* self = STATIC_CAST(CCSXHDocument*, aThis); |
|
151 TRAP( err, res = self->DoCallBackL() ); |
|
152 if(err != KErrNone ) |
|
153 { |
|
154 TRAP_IGNORE(self->FreeProgressBarL()); |
|
155 } |
|
156 return res; |
|
157 } |
|
158 TBool CCSXHDocument::DoCallBackL() |
|
159 { |
|
160 if(!iProgressDialog) |
|
161 { |
|
162 delete iIdle; |
|
163 iIdle = NULL; |
|
164 return EFalse; |
|
165 } |
|
166 |
|
167 CEikProgressInfo* pBar= iProgressDialog->GetProgressInfoL(); |
|
168 pBar->SetAndDraw(iHelpDataBase->GetKeywordSearchCount()); |
|
169 |
|
170 if(iHelpDataBase->GetKeywordSearchCount() >= iTotalKeywordsInResultView) |
|
171 { |
|
172 FreeProgressBarL(); |
|
173 return EFalse; |
|
174 } |
|
175 |
|
176 return ETrue; |
|
177 } |
|
178 |