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