author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sat, 13 Nov 2010 13:54:36 +0000 | |
branch | 3rded |
changeset 343 | 9c56bf585696 |
parent 176 | 1c8b56cb6409 |
child 390 | d7abecc9d189 |
permissions | -rw-r--r-- |
2 | 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 "PodcastSearchView.h" |
|
20 |
#include "PodcastAppUi.h" |
|
21 |
#include "FeedEngine.h" |
|
22 |
#include "ShowEngine.h" |
|
23 |
#include "SettingsEngine.h" |
|
24 |
#include "PodcastApp.h" |
|
25 |
#include "PodcastUtils.h" |
|
26 |
#include <caknfileselectiondialog.h> |
|
27 |
#include <podcast.rsg> |
|
28 |
#include <podcast.mbg> |
|
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
29 |
#include <akntitle.h> |
2 | 30 |
#include <gulicon.h> |
31 |
#include <eikenv.h> |
|
32 |
#include <e32const.h> |
|
33 |
#include <eikdialg.h> |
|
34 |
#include <aknquerydialog.h> |
|
35 |
#include <caknmemoryselectiondialog.h> |
|
36 |
#include <caknfilenamepromptdialog.h> |
|
37 |
#include <BAUTILS.H> |
|
38 |
#include <pathinfo.h> |
|
39 |
#include <f32file.h> |
|
40 |
||
41 |
const TInt KMaxFeedNameLength = 100; |
|
42 |
#define KMaxMessageLength 200 |
|
43 |
#define KMaxTitleLength 100 |
|
44 |
_LIT(KSearchResultFormat, "%d\t%S\t%S"); |
|
45 |
||
46 |
CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel) |
|
47 |
{ |
|
48 |
CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel); |
|
49 |
CleanupStack::Pop( self ); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel) |
|
54 |
{ |
|
55 |
CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel); |
|
56 |
CleanupStack::PushL( self ); |
|
57 |
self->ConstructL(); |
|
58 |
return self; |
|
59 |
} |
|
60 |
||
61 |
CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
62 |
{ |
|
63 |
} |
|
64 |
||
65 |
void CPodcastSearchView::ConstructL() |
|
66 |
{ |
|
67 |
BaseConstructL(R_PODCAST_SEARCHVIEW); |
|
68 |
CPodcastListView::ConstructL(); |
|
69 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
70 |
CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
71 |
CleanupStack::PushL( icons ); |
|
72 |
||
73 |
CFbsBitmap* bitmap = NULL; |
|
74 |
CFbsBitmap* mask = NULL;// |
|
75 |
||
138
6c8c5122867a
Removed the "Reset database" menu option; Updated help files
teknolog
parents:
67
diff
changeset
|
76 |
AknIconUtils::CreateIconL(bitmap, |
6c8c5122867a
Removed the "Reset database" menu option; Updated help files
teknolog
parents:
67
diff
changeset
|
77 |
mask, |
6c8c5122867a
Removed the "Reset database" menu option; Updated help files
teknolog
parents:
67
diff
changeset
|
78 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
6c8c5122867a
Removed the "Reset database" menu option; Updated help files
teknolog
parents:
67
diff
changeset
|
79 |
EMbmPodcastFeed, |
6c8c5122867a
Removed the "Reset database" menu option; Updated help files
teknolog
parents:
67
diff
changeset
|
80 |
EMbmPodcastFeed_mask); |
2 | 81 |
CleanupStack::PushL( bitmap ); |
82 |
CleanupStack::PushL( mask ); |
|
83 |
icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
84 |
CleanupStack::Pop(2); // bitmap, mask |
|
85 |
||
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
86 |
iListContainer->SetListboxIcons(icons); |
2 | 87 |
CleanupStack::Pop(icons); // icons |
88 |
||
89 |
SetEmptyTextL(R_PODCAST_EMPTY_SEARCH); |
|
90 |
} |
|
91 |
||
92 |
CPodcastSearchView::~CPodcastSearchView() |
|
93 |
{ |
|
94 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
175
cd124c4eb6b9
Started port to 3rd edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
138
diff
changeset
|
95 |
} |
2 | 96 |
|
97 |
TUid CPodcastSearchView::Id() const |
|
98 |
{ |
|
99 |
return KUidPodcastSearchViewID; |
|
100 |
} |
|
101 |
||
102 |
void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
103 |
TUid aCustomMessageId, |
|
104 |
const TDesC8& aCustomMessage) |
|
105 |
{ |
|
106 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
107 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
108 |
|
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
109 |
HBufC* text = iEikonEnv->AllocReadResourceLC(R_SEARCH_RESULTS); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
110 |
|
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
111 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
112 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
113 |
|
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
114 |
titlePane->SetTextL(*text , ETrue ); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
115 |
CleanupStack::PopAndDestroy(text); |
56 | 116 |
UpdateListboxItemsL(); |
2 | 117 |
} |
118 |
||
119 |
void CPodcastSearchView::DoDeactivate() |
|
120 |
{ |
|
121 |
CPodcastListView::DoDeactivate(); |
|
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
122 |
|
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
123 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
124 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
125 |
|
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
126 |
titlePane->SetTextToDefaultL(); |
2 | 127 |
} |
128 |
||
129 |
||
130 |
void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) |
|
131 |
{ |
|
132 |
DP("CPodcastSearchView::HandleListBoxEventL BEGIN"); |
|
133 |
switch(aEventType) |
|
134 |
{ |
|
135 |
case EEventEnterKeyPressed: |
|
136 |
case EEventItemDoubleClicked: |
|
137 |
case EEventItemActioned: |
|
138 |
{ |
|
139 |
HandleCommandL(EPodcastAddSearchResult); |
|
140 |
} |
|
141 |
break; |
|
142 |
default: |
|
143 |
break; |
|
144 |
} |
|
145 |
DP("CPodcastSearchView::HandleListBoxEventL END"); |
|
146 |
} |
|
147 |
||
148 |
void CPodcastSearchView::UpdateListboxItemsL() |
|
149 |
{ |
|
150 |
DP("CPodcastSearchView::UpdateListboxItemsL BEGIN"); |
|
151 |
if(!iListContainer->IsVisible()) { |
|
152 |
DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)"); |
|
153 |
return; |
|
154 |
} |
|
155 |
const RFeedInfoArray* searchItems = NULL; |
|
156 |
searchItems = &iPodcastModel.FeedEngine().GetSearchResults(); |
|
157 |
TInt len = searchItems->Count(); |
|
158 |
TListItemProperties itemProps; |
|
159 |
iListContainer->Listbox()->Reset(); |
|
160 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
161 |
iItemIdArray.Reset(); |
|
162 |
iItemArray->Reset(); |
|
163 |
||
164 |
if (len > 0) |
|
165 |
{ |
|
166 |
for (int i=0;i<len;i++) |
|
167 |
{ |
|
168 |
CFeedInfo *fi = (*searchItems)[i]; |
|
169 |
iItemIdArray.Append(fi->Uid()); |
|
170 |
TInt iconIndex = 0; |
|
171 |
||
172 |
TBuf<512> descr; |
|
173 |
descr.Copy(fi->Description().Left(512)); |
|
15
93d9f66bf50b
Cleaning description better for second line in search results
teknolog
parents:
14
diff
changeset
|
174 |
PodcastUtils::RemoveAllFormatting(descr); |
2 | 175 |
iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr); |
176 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
177 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps); |
|
178 |
} |
|
179 |
} |
|
180 |
else |
|
181 |
{ |
|
182 |
TBuf<KMaxFeedNameLength> itemName; |
|
183 |
iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS); |
|
184 |
iItemArray->Reset(); |
|
185 |
iItemIdArray.Reset(); |
|
186 |
||
187 |
TListItemProperties itemProps; |
|
188 |
itemProps.SetDimmed(ETrue); |
|
189 |
itemProps.SetHiddenSelection(ETrue); |
|
190 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); |
|
191 |
} |
|
192 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
193 |
DP("CPodcastSearchView::UpdateListboxItemsL END"); |
|
194 |
} |
|
195 |
||
196 |
/** |
|
197 |
* Command handling function intended for overriding by sub classes. |
|
198 |
* Default implementation is empty. |
|
199 |
* @param aCommand ID of the command to respond to. |
|
200 |
*/ |
|
201 |
void CPodcastSearchView::HandleCommandL(TInt aCommand) |
|
202 |
{ |
|
203 |
switch(aCommand) |
|
204 |
{ |
|
205 |
case EPodcastAddSearchResult: |
|
206 |
{ |
|
207 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
208 |
||
209 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
210 |
{ |
|
211 |
CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index]; |
|
212 |
||
213 |
// ask if user wants to add the feed |
|
214 |
TBuf<KMaxMessageLength> templ; |
|
215 |
TBuf<KMaxMessageLength> message; |
|
216 |
||
217 |
iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY); |
|
218 |
message.Format(templ, &newInfo->Title()); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
219 |
if(ShowQueryMessageL(message)) { |
2 | 220 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo); |
221 |
||
222 |
if (added) |
|
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
223 |
{ |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
224 |
// this is a bit of a hack, first we activate the feeds view normally |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
225 |
AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID, TUid::Uid(0), KNullDesC8); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
226 |
// and then we send the UID of the recently added feed back to feed view for updating |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
227 |
// this is needed so the update? query comes on top of feed view, not search view |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
228 |
AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID, TUid::Uid(newInfo->Uid()), KNullDesC8); |
2 | 229 |
} |
230 |
else |
|
231 |
{ |
|
232 |
TBuf<KMaxMessageLength> message; |
|
233 |
iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
234 |
ShowErrorMessageL(message); |
2 | 235 |
} |
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 |
break; |
|
240 |
default: |
|
241 |
CPodcastListView::HandleCommandL(aCommand); |
|
242 |
break; |
|
243 |
} |
|
244 |
} |
|
245 |
||
7 | 246 |
void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) |
2 | 247 |
{ |
248 |
DP("CPodcastSearchView::OpmlParsingComplete BEGIN"); |
|
56 | 249 |
|
2 | 250 |
DP("CPodcastSearchView::OpmlParsingComplete END"); |
251 |
} |