|
1 /* |
|
2 * Copyright (c) 2005-2008 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 the License "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: A view to browse a given feed. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknviewappui.h> |
|
20 #include <aknutils.h> |
|
21 #include <AknToolbar.h> |
|
22 #include <BrCtlInterface.h> |
|
23 #include <eikbtgpc.h> |
|
24 #include <eikmenup.h> |
|
25 #include <hlplch.h> |
|
26 |
|
27 #include "BrowserAppUi.h" |
|
28 #include "CommonConstants.h" |
|
29 #include "Browser.hrh" |
|
30 #include <BrowserNG.rsg> |
|
31 #include "BrowserUtil.h" |
|
32 #include <FeedAttributes.h> |
|
33 #include <FolderAttributes.h> |
|
34 #include "FeedsFeedContainer.h" |
|
35 #include "FeedsFeedView.h" |
|
36 |
|
37 #include "Logger.h" |
|
38 |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CFeedsFeedView::NewL |
|
42 // |
|
43 // Two-phased constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CFeedsFeedView* CFeedsFeedView::NewL( MApiProvider& aApiProvider, TRect& aRect ) |
|
47 |
|
48 { |
|
49 CFeedsFeedView* self = new (ELeave) CFeedsFeedView(aApiProvider); |
|
50 |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(aRect); |
|
53 CleanupStack::Pop(); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CFeedsFeedView::CFeedsFeedView |
|
61 // |
|
62 // C++ default constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CFeedsFeedView::CFeedsFeedView(MApiProvider& aApiProvider) |
|
66 : CBrowserViewBase( aApiProvider ),iPageScalerEnabled(EFalse),iPenEnabled(EFalse) |
|
67 { |
|
68 iPenEnabled = AknLayoutUtils::PenEnabled(); |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CFeedsFeedView::ConstructL |
|
74 // |
|
75 // Symbian 2nd phase constructor can leave. |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CFeedsFeedView::ConstructL(TRect& aRect) |
|
79 { |
|
80 // this is here in case content view wasn't activated yet on browser startup. |
|
81 iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserContentViewId ); |
|
82 |
|
83 BaseConstructL(R_FEEDS_FEED_VIEW); |
|
84 |
|
85 iContainer = CFeedsFeedContainer::NewL( this, ApiProvider() ); |
|
86 iContainer->SetRect( aRect ); |
|
87 iContainer->MakeVisible(EFalse); |
|
88 |
|
89 if(iPenEnabled) |
|
90 { |
|
91 Toolbar()->SetToolbarObserver(this);; |
|
92 } |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CFeedsFeedView::~CFeedsFeedView |
|
98 // |
|
99 // Deconstructor. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 CFeedsFeedView::~CFeedsFeedView() |
|
103 { |
|
104 DoDeactivate(); |
|
105 |
|
106 delete iContainer; |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CFeedsFeedView::Id |
|
111 // |
|
112 // Returns the id of the view. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TUid CFeedsFeedView::Id() const |
|
116 { |
|
117 return KUidBrowserFeedsFeedViewId; |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CFeedsFeedView::HandleCommandL |
|
122 // |
|
123 // Processes commands. |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CFeedsFeedView::HandleCommandL(TInt aCommand) |
|
127 { |
|
128 TBool handled = EFalse; |
|
129 |
|
130 // Handle softkeys and other Symbian commands first. |
|
131 switch (aCommand) |
|
132 { |
|
133 case EAknSoftkeyBack: |
|
134 iApiProvider.FeedsClientUtilities().ShowTopicViewLocalL(iContainer->CurrentItem()); |
|
135 handled = ETrue; |
|
136 break; |
|
137 |
|
138 case EAknSoftkeyNext: |
|
139 iContainer->ShowNextItemL(); |
|
140 handled = ETrue; |
|
141 break; |
|
142 |
|
143 #ifdef __SERIES60_HELP |
|
144 case EAknCmdHelp: |
|
145 { |
|
146 iApiProvider.SetLastActiveViewId(Id()); |
|
147 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), |
|
148 AppUi()->AppHelpContextL()); |
|
149 handled = ETrue; |
|
150 break; |
|
151 } |
|
152 #endif //__SERIES60_HELP |
|
153 } |
|
154 |
|
155 if (handled) |
|
156 { |
|
157 return; |
|
158 } |
|
159 |
|
160 switch (aCommand) |
|
161 { |
|
162 case EFeedsBack: |
|
163 iApiProvider.FeedsClientUtilities().ShowTopicViewLocalL(iContainer->CurrentItem()); |
|
164 break; |
|
165 |
|
166 case EFeedsShowNextItem: |
|
167 iContainer->ShowNextItemL(); |
|
168 break; |
|
169 |
|
170 case EFeedsShowPrevItem: |
|
171 iContainer->ShowPrevItemL(); |
|
172 break; |
|
173 |
|
174 case EFeedsSeeFullStory: |
|
175 iApiProvider.FeedsClientUtilities().LoadUrlL(iContainer->GetItemUrl()); |
|
176 break; |
|
177 |
|
178 default: |
|
179 iApiProvider.FeedsClientUtilities().HandleCommandL(Id(),aCommand); |
|
180 break; |
|
181 } |
|
182 } |
|
183 |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CFeedsFeedView::DoActivateL |
|
187 // |
|
188 // Called when the view is activated. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CFeedsFeedView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
192 TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
193 { |
|
194 // fix bug RFON-7FJS2Z: need to activate status pane going back from full story page to feeds view |
|
195 StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
196 StatusPane()->MakeVisible( ETrue ); |
|
197 |
|
198 if (!iContainerOnStack) |
|
199 { |
|
200 AppUi()->AddToViewStackL(*this, iContainer); |
|
201 iContainer->SetRect(ClientRect()); |
|
202 if(iContainer->iBrowserControl->BrowserSettingL(TBrCtlDefs::ESettingsPageOverview)) |
|
203 { |
|
204 TRAP_IGNORE(iContainer->iBrowserControl->SetBrowserSettingL(TBrCtlDefs::ESettingsPageOverview, EFalse)); |
|
205 iPageScalerEnabled = ETrue; |
|
206 } |
|
207 TRAP_IGNORE(iContainer->iBrowserControl->HandleCommandL( |
|
208 (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandGainFocus)); |
|
209 |
|
210 iContainer->MakeVisible(ETrue); |
|
211 iContainerOnStack = ETrue; |
|
212 // resize screen after calling SetRect. This way looks better |
|
213 iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch); |
|
214 } |
|
215 |
|
216 // Set the current feed. |
|
217 iContainer->SetCurrentFeedL(*(iApiProvider.FeedsClientUtilities().CurrentFeed()), iInitialItem); |
|
218 |
|
219 iApiProvider.SetLastActiveViewId(Id()); |
|
220 UpdateToolbarButtonsState(); |
|
221 } |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CFeedsFeedView::DoDeactivate |
|
226 // |
|
227 // Called when the view is deactivated. |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CFeedsFeedView::DoDeactivate() |
|
231 { |
|
232 if (iContainerOnStack) |
|
233 { |
|
234 iContainer->ClearNavigationPane(); |
|
235 |
|
236 if(iPageScalerEnabled) |
|
237 { |
|
238 TRAP_IGNORE(iContainer->iBrowserControl->SetBrowserSettingL(TBrCtlDefs::ESettingsPageOverview, ETrue)); |
|
239 iPageScalerEnabled = EFalse; |
|
240 } |
|
241 TRAP_IGNORE(iContainer->iBrowserControl->HandleCommandL( |
|
242 (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandLoseFocus)); |
|
243 |
|
244 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
245 iContainer->MakeVisible(EFalse); |
|
246 |
|
247 iInitialItem = iContainer->CurrentItem(); |
|
248 iContainerOnStack = EFalse; |
|
249 |
|
250 // when exit from feeds view, viewMgr might be deleted already |
|
251 if ( !ApiProvider().ExitInProgress() ) |
|
252 { |
|
253 TRAP_IGNORE(iApiProvider.FeedsClientUtilities().ItemStatusWriteToServerL()); |
|
254 } |
|
255 } |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CFeedsFeedView::DynInitMenuPaneL |
|
261 // |
|
262 // Disables unrelated menu options. |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CFeedsFeedView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
266 { |
|
267 __ASSERT_DEBUG( (aMenuPane != NULL), Util::Panic( Util::EUninitializedData )); |
|
268 |
|
269 // Handle the main menu. |
|
270 if (aResourceId == R_FEEDS_FEED_VIEW_MENU) |
|
271 { |
|
272 // Back to Page (if page loaded) |
|
273 if ( iApiProvider.IsPageLoaded() ) |
|
274 { |
|
275 iApiProvider.FeedsClientUtilities().AddItemL( *aMenuPane, EWmlCmdBackToPage, R_BROWSER_MENU_ITEM_BACK_TO_PAGE ); |
|
276 } |
|
277 } |
|
278 |
|
279 iApiProvider.FeedsClientUtilities().DynInitMenuPaneL(aResourceId, aMenuPane ); |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CFeedsFeedView::SetInitialItem |
|
284 // |
|
285 // Sets the initial item once the view is activated. |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CFeedsFeedView::SetInitialItem(TInt aItemIndex) |
|
289 { |
|
290 iInitialItem = aItemIndex; |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CFeedsTopicView::UpdateToolbarButtonsState |
|
295 // |
|
296 // Updates the state of the toolbar buttons depending on the situation |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 |
|
300 void CFeedsFeedView::UpdateToolbarButtonsState() |
|
301 { |
|
302 if ( iContainer->ItemCount() > 1 ) |
|
303 { |
|
304 Toolbar()->SetItemDimmed(EFeedsShowPrevItem, EFalse, ETrue); |
|
305 Toolbar()->SetItemDimmed(EFeedsShowNextItem, EFalse, ETrue); |
|
306 } |
|
307 else |
|
308 { |
|
309 Toolbar()->SetItemDimmed(EFeedsShowPrevItem, ETrue, ETrue); |
|
310 Toolbar()->SetItemDimmed(EFeedsShowNextItem, ETrue, ETrue); |
|
311 } |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CFeedsFeedView::CommandSetResourceIdL |
|
316 // --------------------------------------------------------------------------- |
|
317 TInt CFeedsFeedView::CommandSetResourceIdL() |
|
318 { |
|
319 // It is never called, but this function have to be implemented |
|
320 return KWmlEmptyResourceId; |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------- |
|
324 // CFeedsFeedView::HandleClientRectChange |
|
325 // --------------------------------------------------------- |
|
326 // |
|
327 void CFeedsFeedView::HandleClientRectChange() |
|
328 { |
|
329 if( iContainer ) |
|
330 { |
|
331 iContainer->MakeVisible(EFalse); |
|
332 iContainer->SetRect(ClientRect()); |
|
333 iContainer->MakeVisible(ETrue); |
|
334 } |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CFeedsFeedView::DisconnectL |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 void CFeedsFeedView::DisconnectL() |
|
342 { |
|
343 if( iContainer ) |
|
344 { |
|
345 iContainer->iBrowserControl->HandleCommandL( TBrCtlDefs::ECommandDisconnect + TBrCtlDefs::ECommandIdBase ); |
|
346 } |
|
347 } |