|
1 /* |
|
2 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 * |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of the License "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * EmbedDev AB - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "PodcastAppui.h" |
|
20 #include <Podcast.rsg> |
|
21 #include "Podcast.hrh" |
|
22 #include "PodcastFeedView.h" |
|
23 #include "PodcastShowsView.h" |
|
24 #include "PodcastQueueView.h" |
|
25 #include "PodcastSettingsView.h" |
|
26 #include "PodcastSearchView.h" |
|
27 #include "ShowEngine.h" |
|
28 #include "PodcastModel.h" |
|
29 #include "debug.h" |
|
30 #include "..\help\podcatcher.hlp.hrh" |
|
31 #include "PodcastApp.h" |
|
32 |
|
33 #include <HLPLCH.H> |
|
34 #include <avkon.hrh> |
|
35 |
|
36 const TUint KDelayLaunch = 1000; |
|
37 |
|
38 CPodcastAppUi::CPodcastAppUi(CPodcastModel* aPodcastModel):iPodcastModel(aPodcastModel) |
|
39 { |
|
40 |
|
41 } |
|
42 |
|
43 void CPodcastAppUi::ConstructL() |
|
44 { |
|
45 DP("CPodcastAppUi::ConstructL() BEGIN"); |
|
46 BaseConstructL(CAknAppUi::EAknEnableSkin); |
|
47 |
|
48 DP("Constructing FeedView"); |
|
49 iFeedView = CPodcastFeedView::NewL(*iPodcastModel); |
|
50 this->AddViewL(iFeedView); |
|
51 |
|
52 DP("Constructing ShowsView"); |
|
53 iShowsView = CPodcastShowsView::NewL(*iPodcastModel); |
|
54 this->AddViewL(iShowsView); |
|
55 |
|
56 DP("Constructing QueueView"); |
|
57 iQueueView = CPodcastQueueView::NewL(*iPodcastModel); |
|
58 this->AddViewL(iQueueView); |
|
59 |
|
60 DP("Constructing SearchView"); |
|
61 iSearchView = CPodcastSearchView::NewL(*iPodcastModel); |
|
62 this->AddViewL(iSearchView); |
|
63 |
|
64 DP("Constructing SettingsView"); |
|
65 iSettingsView = CPodcastSettingsView::NewL(*iPodcastModel); |
|
66 this->AddViewL(iSettingsView); |
|
67 |
|
68 iNaviPane =( CAknNavigationControlContainer * ) StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
69 NaviShowTabGroupL(); |
|
70 |
|
71 // start a timer to let ConstructL finish before we display any dialogs or start downloading |
|
72 // this provides another entry point in HandleTimeout below |
|
73 iStartTimer = CTimeout::NewL(*this); |
|
74 iStartTimer->After(KDelayLaunch); |
|
75 DP("CPodcastAppUi::ConstructL() END"); |
|
76 } |
|
77 |
|
78 CPodcastAppUi::~CPodcastAppUi() |
|
79 { |
|
80 if(iNaviDecorator) |
|
81 { |
|
82 iNaviPane->Pop(iNaviDecorator); |
|
83 delete iNaviDecorator; |
|
84 } |
|
85 delete iStartTimer; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CPodcastAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
90 // This function is called by the EIKON framework just before it displays |
|
91 // a menu pane. Its default implementation is empty, and by overriding it, |
|
92 // the application can set the state of menu items dynamically according |
|
93 // to the state of application data. |
|
94 // ------------------------------------------------------------------------------ |
|
95 // |
|
96 void CPodcastAppUi::DynInitMenuPaneL( |
|
97 TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) |
|
98 { |
|
99 // no implementation required |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CPodcastAppUi::HandleCommandL(TInt aCommand) |
|
104 // takes care of command handling |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CPodcastAppUi::HandleCommandL( TInt aCommand ) |
|
108 { |
|
109 switch ( aCommand ) |
|
110 { |
|
111 case EAknSoftkeyExit: |
|
112 { |
|
113 Exit(); |
|
114 break; |
|
115 } |
|
116 case EEikCmdExit: |
|
117 { |
|
118 TApaTask task(CEikonEnv::Static()->WsSession()); |
|
119 task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); |
|
120 task.SendToBackground(); |
|
121 break; |
|
122 } |
|
123 case EPodcastHelp: |
|
124 { |
|
125 CArrayFix<TCoeHelpContext>* buf = CPodcastAppUi::AppHelpContextL(); |
|
126 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf); |
|
127 } |
|
128 break; |
|
129 default: |
|
130 break; |
|
131 } |
|
132 } |
|
133 |
|
134 CArrayFix<TCoeHelpContext>* CPodcastAppUi::HelpContextL() const |
|
135 { |
|
136 CArrayFixFlat<TCoeHelpContext>* array = |
|
137 new(ELeave)CArrayFixFlat<TCoeHelpContext>(1); |
|
138 CleanupStack::PushL(array); |
|
139 // todo: view detection doesn't seem to work |
|
140 if (ViewShown(KUidPodcastSearchViewID)) { |
|
141 array->AppendL(TCoeHelpContext(KUidPodcast,KContextSettings)); |
|
142 } else { |
|
143 array->AppendL(TCoeHelpContext(KUidPodcast,KContextApplication)); |
|
144 } |
|
145 |
|
146 CleanupStack::Pop(array); |
|
147 return array; |
|
148 } |
|
149 |
|
150 void CPodcastAppUi::NaviShowTabGroupL() |
|
151 { |
|
152 iNaviDecorator = iNaviPane->CreateTabGroupL(); |
|
153 |
|
154 iTabGroup = STATIC_CAST(CAknTabGroup*, iNaviDecorator->DecoratedControl()); |
|
155 iTabGroup->SetTabFixedWidthL(EAknTabWidthWithTwoTabs); |
|
156 |
|
157 HBufC *label1 = iEikonEnv->AllocReadResourceLC(R_TABGROUP_FEEDS); |
|
158 iTabGroup->AddTabL(KTabIdFeeds,*label1); |
|
159 |
|
160 HBufC *label3 = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE); |
|
161 iTabGroup->AddTabL(KTabIdQueue,*label3); |
|
162 |
|
163 // HBufC *label4 = iEikonEnv->AllocReadResourceLC(R_TABGROUP_SEARCH); |
|
164 // iTabGroup->AddTabL(KTabIdSearch,*label4); |
|
165 // |
|
166 // CleanupStack::PopAndDestroy(label4); |
|
167 CleanupStack::PopAndDestroy(label3); |
|
168 CleanupStack::PopAndDestroy(label1); |
|
169 |
|
170 iTabGroup->SetActiveTabByIndex(0); |
|
171 iTabGroup->SetObserver(this); |
|
172 |
|
173 iNaviPane->Pop(); |
|
174 iNaviPane->PushL(*iNaviDecorator); |
|
175 } |
|
176 |
|
177 void CPodcastAppUi::TabChangedL (TInt aIndex) |
|
178 { |
|
179 DP("CPodcastListView::TabChangedL "); |
|
180 |
|
181 TUid newview = TUid::Uid(0); |
|
182 TUid messageUid = TUid::Uid(0); |
|
183 |
|
184 if (aIndex == KTabIdFeeds) { |
|
185 newview = KUidPodcastFeedViewID; |
|
186 } else if (aIndex == KTabIdQueue) { |
|
187 newview = KUidPodcastQueueViewID; |
|
188 } else { |
|
189 User::Leave(KErrTooBig); |
|
190 } |
|
191 |
|
192 if(newview.iUid != 0) |
|
193 { |
|
194 ActivateLocalViewL(newview, messageUid, KNullDesC8()); |
|
195 } |
|
196 } |
|
197 |
|
198 void CPodcastAppUi::SetActiveTab(TInt aIndex) { |
|
199 iTabGroup->SetActiveTabByIndex(aIndex); |
|
200 } |
|
201 |
|
202 void CPodcastAppUi::HandleTimeout(const CTimeout& /*aId*/, TInt /*aError*/) |
|
203 { |
|
204 iFeedView->CheckResumeDownload(); |
|
205 } |
|
206 |
|
207 void CPodcastAppUi::UpdateQueueTab(TInt aQueueLength) |
|
208 { |
|
209 if (aQueueLength == 0) |
|
210 { |
|
211 HBufC *queue = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE); |
|
212 iTabGroup->ReplaceTabL(KTabIdQueue, *queue); |
|
213 CleanupStack::PopAndDestroy(queue); |
|
214 } |
|
215 else |
|
216 { |
|
217 HBufC *queueTemplate = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE_COUNTER); |
|
218 HBufC *queueCounter = HBufC::NewLC(queueTemplate->Length()+2); |
|
219 queueCounter->Des().Format(*queueTemplate, aQueueLength); |
|
220 |
|
221 iTabGroup->ReplaceTabL(KTabIdQueue, *queueCounter); |
|
222 CleanupStack::PopAndDestroy(queueCounter); |
|
223 CleanupStack::PopAndDestroy(queueTemplate); |
|
224 } |
|
225 } |
|
226 |
|
227 void CPodcastAppUi::TabLeft() |
|
228 { |
|
229 TInt ati = iTabGroup->ActiveTabIndex(); |
|
230 if(ati > 0) { |
|
231 SetActiveTab(ati-1); |
|
232 TabChangedL(ati-1); |
|
233 } |
|
234 } |
|
235 |
|
236 void CPodcastAppUi::TabRight() |
|
237 { |
|
238 TInt ati = iTabGroup->ActiveTabIndex(); |
|
239 |
|
240 if(ati < iTabGroup->TabCount()-1) { |
|
241 SetActiveTab(ati+1); |
|
242 TabChangedL(ati+1); |
|
243 } |
|
244 } |