65
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2007 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: Manages the feed related views and implements the FeedsViewBridge.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <AknView.h>
|
|
19 |
#include <AknViewAppUi.h>
|
|
20 |
#include <BaUtils.h>
|
|
21 |
#include <BaDesca.h>
|
|
22 |
#include <brctlinterface.h>
|
|
23 |
#include <GulIcon.h>
|
|
24 |
#include <data_caging_path_literals.hrh>
|
|
25 |
#include <eikmenup.h>
|
|
26 |
#include <StringLoader.h>
|
|
27 |
|
|
28 |
#include <BrowserNG.rsg>
|
|
29 |
#include <brctldialogsprovider.h>
|
|
30 |
#include <browserdialogsprovider.h>
|
|
31 |
#include <brctldefs.h>
|
|
32 |
#include <internetconnectionmanager.h>
|
|
33 |
#include <FeatMgr.h>
|
|
34 |
#include <Uri16.h>
|
|
35 |
|
|
36 |
#include "Browser.hrh"
|
|
37 |
#include "BrowserAppUi.h"
|
|
38 |
#include "CommonConstants.h"
|
|
39 |
#include "BrowserWindow.h"
|
|
40 |
#include "BrowserWindowManager.h"
|
|
41 |
#include "BrowserUIVariant.hrh"
|
|
42 |
#include "Preferences.h"
|
|
43 |
#include "BrowserGotoPane.h"
|
|
44 |
#include "BrowserAdaptiveListPopup.h"
|
|
45 |
#include "FeedsFeedView.h"
|
|
46 |
#include "FeedsFolderView.h"
|
|
47 |
#include "BrowserDialogs.h"
|
|
48 |
#include "FeedsTopicView.h"
|
|
49 |
#include "BrowserUtil.h"
|
|
50 |
#include "BrowserSpecialLoadObserver.h"
|
|
51 |
|
|
52 |
#include "FeedsClientUtilities.h"
|
|
53 |
|
|
54 |
#include "BrowserBmOTABinSender.h"
|
|
55 |
|
|
56 |
// CONSTANTS
|
|
57 |
_LIT(KSupportedMimeTypes, "application/rss+xml;application/atom+xml;text/xml;application/xml");
|
|
58 |
const TInt KLastUpdateGranularity = 10;
|
|
59 |
|
|
60 |
const TInt KWmlSettingsAutomaticUpdatingNotSet = 32767;
|
|
61 |
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
// CFeedsClientUtilities::NewL
|
|
64 |
//
|
|
65 |
// Two-phased constructor.
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
CFeedsClientUtilities* CFeedsClientUtilities::NewL(CAknViewAppUi& aAppUI, MApiProvider& aApiProvider)
|
|
69 |
{
|
|
70 |
CFeedsClientUtilities* self = new (ELeave) CFeedsClientUtilities(aAppUI, aApiProvider);
|
|
71 |
|
|
72 |
CleanupStack::PushL(self);
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop();
|
|
75 |
|
|
76 |
return self;
|
|
77 |
}
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
// CFeedsClientUtilities::CFeedsClientUtilities
|
|
81 |
//
|
|
82 |
// C++ default constructor.
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
CFeedsClientUtilities::CFeedsClientUtilities(CAknViewAppUi& aAppUI, MApiProvider& aApiProvider):
|
|
86 |
iAppUI(aAppUI), iApiProvider(aApiProvider), iIsUpdatingFeed(EFalse), iWaitDialog(0),
|
|
87 |
iEnteredURL(0), iFolderView(0), iTopicView(0), iFeedView(0),
|
|
88 |
iIsConnected(EFalse), iItemIds(20), iItemStatus(20), iMimeTypes(0),
|
|
89 |
iFeedUpdateTimeIds(KLastUpdateGranularity), iFeedUpdateTimeTimestamps(KLastUpdateGranularity),
|
|
90 |
iPendingFolderItemTitle(NULL), iPendingFolderItemUrl(NULL), iExportFileName(NULL),
|
|
91 |
iSearchAgent(NULL),
|
|
92 |
iSearchOptList(NULL),
|
|
93 |
iFeedImportRequested(EFalse),
|
|
94 |
iRequestCanceled(EFalse),
|
|
95 |
iIsWaitDialogDisplayed(EFalse),
|
|
96 |
iFeedsInterface(*this,0),
|
|
97 |
iCanceledRequest(CTransaction::ENone)
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
// CFeedsClientUtilities::ConstructL
|
|
104 |
//
|
|
105 |
// Symbian 2nd phase constructor can leave.
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
void CFeedsClientUtilities::ConstructL()
|
|
109 |
{
|
|
110 |
iApiProvider.Preferences().AddObserverL( this );
|
|
111 |
|
|
112 |
// Set up MimeTypes
|
|
113 |
iMimeTypes = HBufC::NewL( KSupportedMimeTypes().Length() + 1 );
|
|
114 |
TPtr ptr( iMimeTypes->Des() );
|
|
115 |
ptr.Append( KSupportedMimeTypes() );
|
|
116 |
ptr.ZeroTerminate();
|
|
117 |
|
|
118 |
iWaitDialog = CFeedsWaitDialog::NewL(*this);
|
|
119 |
}
|
|
120 |
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
// CFolderItem::Search
|
|
123 |
//
|
|
124 |
// Searches for a FolderItem with the given name. If "this"
|
|
125 |
// isn't a folder it only checks whether or not it matches
|
|
126 |
// the given name. If "this" is a folder it also checks
|
|
127 |
// all embedded items.
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
const CFeedsEntity* CFeedsClientUtilities::Search(const TDesC& aName,const CFeedsEntity& aFolder) const
|
|
131 |
{
|
|
132 |
TPtrC title;
|
|
133 |
if (aFolder.GetType() == EFolder)
|
|
134 |
{
|
|
135 |
aFolder.GetStringValue(EFolderAttributeTitle,title);
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
aFolder.GetStringValue(EFeedAttributeTitle,title);
|
|
140 |
}
|
|
141 |
if (aName.CompareF(title) == 0)
|
|
142 |
{
|
|
143 |
return &aFolder;
|
|
144 |
}
|
|
145 |
if (aFolder.GetType() == EFolder)
|
|
146 |
{
|
|
147 |
for(TInt i=0;i<aFolder.GetChildren().Count();i++)
|
|
148 |
{
|
|
149 |
const CFeedsEntity *item;
|
|
150 |
CFeedsEntity *child = aFolder.GetChildren()[i];
|
|
151 |
if((item = Search(aName,*child)) != NULL)
|
|
152 |
{
|
|
153 |
return item;
|
|
154 |
}
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
// Otherwise no match was found.
|
|
159 |
return NULL;
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// CFolderItem::Search
|
|
165 |
//
|
|
166 |
// Searches for a FolderItem with the given id. If "this"
|
|
167 |
// isn't a folder it only checks whether or not it matches
|
|
168 |
// the given id. If "this" is a folder it also checks
|
|
169 |
// all embedded items.
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
const CFeedsEntity* CFeedsClientUtilities::Search(TInt aFolderItemId,const CFeedsEntity& aFolder) const
|
|
173 |
{
|
|
174 |
if (aFolderItemId == aFolder.GetId())
|
|
175 |
{
|
|
176 |
return &aFolder;
|
|
177 |
}
|
|
178 |
if (aFolder.GetType() == EFolder)
|
|
179 |
{
|
|
180 |
for(TInt i=0;i<aFolder.GetChildren().Count();i++)
|
|
181 |
{
|
|
182 |
const CFeedsEntity *item;
|
|
183 |
CFeedsEntity *child = aFolder.GetChildren()[i];
|
|
184 |
if ((item = Search(aFolderItemId,*child)) != NULL)
|
|
185 |
{
|
|
186 |
return item;
|
|
187 |
}
|
|
188 |
}
|
|
189 |
}
|
|
190 |
|
|
191 |
// Otherwise no match was found.
|
|
192 |
return NULL;
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
// -----------------------------------------------------------------------------
|
|
197 |
// CFeedsClientUtilities::~CFeedsClientUtilities
|
|
198 |
//
|
|
199 |
// Deconstructor.
|
|
200 |
// -----------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
CFeedsClientUtilities::~CFeedsClientUtilities()
|
|
203 |
{
|
|
204 |
DisconnectFromServer();
|
|
205 |
|
|
206 |
iApiProvider.Preferences().RemoveObserver( this );
|
|
207 |
|
|
208 |
delete iWaitDialog;
|
|
209 |
delete iMimeTypes;
|
|
210 |
|
|
211 |
iFeedUpdateTimeIds.Close();
|
|
212 |
iFeedUpdateTimeTimestamps.Close();
|
|
213 |
|
|
214 |
delete iPendingFolderItemTitle;
|
|
215 |
delete iPendingFolderItemUrl;
|
|
216 |
delete iExportFileName;
|
|
217 |
delete iEnteredURL;
|
|
218 |
delete iSearchAgent;
|
|
219 |
|
|
220 |
iItemIds.Close();
|
|
221 |
iItemStatus.Close();
|
|
222 |
iItemStatusOrig.Close();
|
|
223 |
|
|
224 |
}
|
|
225 |
|
|
226 |
// -----------------------------------------------------------------------------
|
|
227 |
// CFeedsClientUtilities::RequestCompleted()
|
|
228 |
// -----------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
void CFeedsClientUtilities::RequestCompleted(CTransaction* aTrans,TInt /*aEvent*/)
|
|
231 |
{
|
|
232 |
TInt status = aTrans->GetStatusCode();
|
|
233 |
|
|
234 |
switch (aTrans->Type())
|
|
235 |
{
|
|
236 |
case CTransaction::EFetchRootFolderItem:
|
|
237 |
FolderItemRequestCompleted(status, CTransaction::EFetchRootFolderItem);
|
|
238 |
|
|
239 |
break;
|
|
240 |
|
|
241 |
case CTransaction::EWatchForChanges:
|
|
242 |
break;
|
|
243 |
|
|
244 |
case CTransaction::EExportOPML:
|
|
245 |
case CTransaction::EImportOPML:
|
|
246 |
FolderItemRequestCompleted(status, aTrans->Type());
|
|
247 |
break;
|
|
248 |
|
|
249 |
case CTransaction::EAddFolderItem:
|
|
250 |
case CTransaction::EDeleteFolderItem:
|
|
251 |
case CTransaction::EChangeFolderItem:
|
|
252 |
case CTransaction::EMoveFolderItem:
|
|
253 |
case CTransaction::EMoveFolderItemTo:
|
|
254 |
case CTransaction::EUpdateFolderItem:
|
|
255 |
FolderItemRequestCompleted(status, aTrans->Type());
|
|
256 |
break;
|
|
257 |
|
|
258 |
case CTransaction::EChangeSettings:
|
|
259 |
break;
|
|
260 |
|
|
261 |
case CTransaction::EFetchFeed:
|
|
262 |
FeedRequestCompleted(status);
|
|
263 |
break;
|
|
264 |
case CTransaction::EUpdateItemStatus:
|
|
265 |
break;
|
|
266 |
|
|
267 |
default:
|
|
268 |
FolderItemRequestCompleted(status, aTrans->Type());
|
|
269 |
break;
|
|
270 |
}
|
|
271 |
}
|
|
272 |
|
|
273 |
// -----------------------------------------------------------------------------
|
|
274 |
// CFeedsClientUtilities::NetworkConnectionNeededL()
|
|
275 |
// -----------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
void CFeedsClientUtilities::NetworkConnectionNeededL(
|
|
278 |
TInt* aConnectionPtr, TInt& aSockSvrHandle,
|
|
279 |
TBool& aNewConn, TApBearerType& aBearerType )
|
|
280 |
{
|
|
281 |
iApiProvider.SpecialLoadObserver().NetworkConnectionNeededL(
|
|
282 |
aConnectionPtr, &aSockSvrHandle, &aNewConn, &aBearerType );
|
|
283 |
//Wait dialog is shown only in the case of a new connection.
|
|
284 |
if ( aNewConn )
|
|
285 |
{
|
|
286 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_UPDATING_FEED);
|
|
287 |
iIsWaitDialogDisplayed = ETrue;
|
|
288 |
}
|
|
289 |
}
|
|
290 |
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
// CFeedsClientUtilities::HandlePreferencesChangeL()
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CFeedsClientUtilities::HandlePreferencesChangeL(
|
|
296 |
const TPreferencesEvent aEvent,
|
|
297 |
TPreferencesValues& aValues,
|
|
298 |
TBrCtlDefs::TBrCtlSettings aSettingType )
|
|
299 |
{
|
|
300 |
// no specific TBrCtlDefs::TBrCtlSettings are defined for FeedsSettings
|
|
301 |
// so we trigger for an Unknown setting
|
|
302 |
if( (EPreferencesItemChange == aEvent || EPreferencesDeactivate == aEvent) &&
|
|
303 |
(TBrCtlDefs::ESettingsUnknown == aSettingType ) )
|
|
304 |
{
|
|
305 |
SetPreferencesToFeedL( aValues );
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
// -----------------------------------------------------------------------------
|
|
310 |
// CFeedsClientUtilities::SetPreferencesToFeedL()
|
|
311 |
// -----------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
void CFeedsClientUtilities::SetPreferencesToFeedL( const TPreferencesValues& aValues )
|
|
314 |
{
|
|
315 |
if ( iIsWaitDialogDisplayed )
|
|
316 |
{
|
|
317 |
return;
|
|
318 |
}
|
|
319 |
TFeedsServerSetting setting;
|
|
320 |
|
|
321 |
// always set to 32767 in the case of feed level auto updating.
|
|
322 |
//setting.iAutoUpdate = KWmlSettingsAutomaticUpdatingNotSet;
|
|
323 |
setting.iAutoUpdate = EFalse;
|
|
324 |
setting.iAutoUpdateFreq = KWmlSettingsAutomaticUpdatingNotSet;
|
|
325 |
setting.iAutoUpdateWhileRoaming = aValues.iAutomaticUpdatingWhileRoaming;
|
|
326 |
|
|
327 |
TUint32 autoUpdatingAP( 0 );
|
|
328 |
#ifndef __WINSCW__
|
|
329 |
if (aValues.iAutomaticUpdatingAP != KWmlNoDefaultAccessPoint)
|
|
330 |
{
|
|
331 |
autoUpdatingAP = Util::IapIdFromWapIdL( iApiProvider, aValues.iAutomaticUpdatingAP );
|
|
332 |
}
|
|
333 |
#endif //__WINSCW__
|
|
334 |
setting.iAutoUpdateAP = autoUpdatingAP;
|
|
335 |
|
|
336 |
SetFeedsServerSettingsL( setting );
|
|
337 |
}
|
|
338 |
|
|
339 |
// -----------------------------------------------------------------------------
|
|
340 |
// CFeedsClientUtilities::DisconnectManualUpdateConnectionL()
|
|
341 |
//
|
|
342 |
// Disconnect connection provided by client for manual update.
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
//
|
|
345 |
void CFeedsClientUtilities::DisconnectManualUpdateConnectionL()
|
|
346 |
{
|
|
347 |
if ( iIsConnected )
|
|
348 |
{
|
|
349 |
// Ensure that the connection is available.
|
|
350 |
ConnectToServerL(EFalse);
|
|
351 |
|
|
352 |
// Pass the updated settings to the server.
|
|
353 |
iFeedsInterface.DisconnectManualUpdateConnectionL();
|
|
354 |
}
|
|
355 |
}
|
|
356 |
|
|
357 |
// -----------------------------------------------------------------------------
|
|
358 |
// CFeedsClientUtilities::DisconnectFeedsViewL()
|
|
359 |
//
|
|
360 |
// Disconnect connection used by FeedsView.
|
|
361 |
// -----------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void CFeedsClientUtilities::DisconnectFeedsViewL()
|
|
364 |
{
|
|
365 |
if( iFeedView )
|
|
366 |
{
|
|
367 |
iFeedView->DisconnectL();
|
|
368 |
}
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// CFeedsClientUtilities::LoadUrlL()
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
//
|
|
375 |
void CFeedsClientUtilities::LoadUrlL( const TDesC& aUrl )
|
|
376 |
{
|
|
377 |
|
|
378 |
if( iApiProvider.IsPageLoaded() &&
|
|
379 |
iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
|
|
380 |
!iApiProvider.Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
|
|
381 |
{
|
|
382 |
// there is already a window, so create a new one if not over the max number of windows allowed
|
|
383 |
if(iApiProvider.WindowMgr().WindowCount() == iApiProvider.WindowMgr().MaxWindowCount())
|
|
384 |
{
|
|
385 |
// Show warning to user
|
|
386 |
TBrowserDialogs::ErrorNoteL( R_BROWSER_NOTE_MAX_WINDOWS );
|
|
387 |
return;
|
|
388 |
}
|
|
389 |
|
|
390 |
if(iApiProvider.WindowMgr().WindowCount() < iApiProvider.WindowMgr().MaxWindowCount())
|
|
391 |
{
|
|
392 |
CBrowserWindow *win = iApiProvider.WindowMgr().CreateWindowL( 0, &KNullDesC );
|
|
393 |
if (win != NULL)
|
|
394 |
{
|
|
395 |
CleanupStack::PushL( win );
|
|
396 |
iApiProvider.WindowMgr().SwitchWindowL( win->WindowId() );
|
|
397 |
CleanupStack::Pop(); // win
|
|
398 |
}
|
|
399 |
}
|
|
400 |
}
|
|
401 |
|
|
402 |
iApiProvider.WindowMgr().CurrentWindow()->SetHasFeedsContent(ETrue);
|
|
403 |
iApiProvider.FetchL( aUrl );
|
|
404 |
}
|
|
405 |
|
|
406 |
// -----------------------------------------------------------------------------
|
|
407 |
// CFeedsClientUtilities::ShowFolderViewL
|
|
408 |
//
|
|
409 |
// Shows the folder view, loading the folder list from the FeedsServer if need be.
|
|
410 |
// -----------------------------------------------------------------------------
|
|
411 |
//
|
|
412 |
void CFeedsClientUtilities::ShowFolderViewL(TUid aCalledFromView /*= KUidBrowserBookmarksViewId*/)
|
|
413 |
{
|
|
414 |
|
|
415 |
if ( iIsWaitDialogDisplayed )
|
|
416 |
{
|
|
417 |
return;
|
|
418 |
}
|
|
419 |
// Record the view from which feeds was launched.
|
|
420 |
// If this function is not called with an argument,
|
|
421 |
// its default value "KUidBrowserBookmarksViewId" is used.
|
|
422 |
// This is specified in the header FeedsClientUtilities.h
|
|
423 |
SetCalledFromView(aCalledFromView);
|
|
424 |
|
|
425 |
// Ensure that "this" is ready for uses.
|
|
426 |
LazyInitL(EFalse);
|
|
427 |
|
|
428 |
// Show wait dialog.
|
|
429 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_OPENING_FEED);
|
|
430 |
iIsWaitDialogDisplayed = ETrue;
|
|
431 |
|
|
432 |
// Set the view to show once the folder is ready.
|
|
433 |
iNextViewId = KUidBrowserFeedsFolderViewId;
|
|
434 |
iIsUpdatingFeed = EFalse;
|
|
435 |
|
|
436 |
// Get the root folder.
|
|
437 |
FetchRootFolderL();
|
|
438 |
iCurrentRequest = CTransaction::EFetchRootFolderItem;
|
|
439 |
}
|
|
440 |
|
|
441 |
|
|
442 |
// -----------------------------------------------------------------------------
|
|
443 |
// CFeedsClientUtilities::ShowTopicViewL
|
|
444 |
//
|
|
445 |
// Shows the topic view, loading the given feed associated with the given folder item.
|
|
446 |
// -----------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
void CFeedsClientUtilities::ShowTopicViewL(const CFeedsEntity& aFolderItem)
|
|
449 |
{
|
|
450 |
TTime timestamp;
|
|
451 |
|
|
452 |
if ( iIsWaitDialogDisplayed )
|
|
453 |
{
|
|
454 |
return;
|
|
455 |
}
|
|
456 |
|
|
457 |
// Ensure that "this" is ready for uses.
|
|
458 |
LazyInitL(EFalse);
|
|
459 |
|
|
460 |
// Show wait dialog.
|
|
461 |
timestamp = aFolderItem.GetTimeValue(EFeedAttributeTimestamp,timestamp);
|
|
462 |
if ( timestamp.Int64() == 0 )
|
|
463 |
{
|
|
464 |
if ( iApiProvider.Connection().Connected() )
|
|
465 |
{
|
|
466 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_UPDATING_FEED);
|
|
467 |
}
|
|
468 |
}
|
|
469 |
else
|
|
470 |
{
|
|
471 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_OPENING_FEED);
|
|
472 |
}
|
|
473 |
iIsWaitDialogDisplayed = ETrue;
|
|
474 |
|
|
475 |
// Set the view to show once the feed is ready.
|
|
476 |
iNextViewId = KUidBrowserFeedsTopicViewId;
|
|
477 |
iIsUpdatingFeed = EFalse;
|
|
478 |
|
|
479 |
// Fetch the feed.
|
|
480 |
FetchFeedL(aFolderItem);
|
|
481 |
iCurrentRequest = CTransaction::EFetchFeed;
|
|
482 |
}
|
|
483 |
|
|
484 |
// -----------------------------------------------------------------------------
|
|
485 |
// CFeedsClientUtilities::SupportedMimeTypesL
|
|
486 |
//
|
|
487 |
// Returns the feed related mime-types supported by the bridge. This makes
|
|
488 |
// for a clean way to pass downloaded feeds content from the client to the FeedsServer
|
|
489 |
// (via CFeedsClientUtilities::HandleFeedL).
|
|
490 |
// -----------------------------------------------------------------------------
|
|
491 |
//
|
|
492 |
TPtrC CFeedsClientUtilities::SupportedMimeTypesL()
|
|
493 |
{
|
|
494 |
return iMimeTypes->Des();
|
|
495 |
}
|
|
496 |
|
|
497 |
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
// CFeedsClientUtilities::SubscribeToL
|
|
500 |
//
|
|
501 |
// Shows the folder view and subscribes to the given feed.
|
|
502 |
// -----------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
void CFeedsClientUtilities::SubscribeToL(const TDesC& aTitle, const TDesC& aUrl)
|
|
505 |
{
|
|
506 |
SetCalledFromView(KUidBrowserContentViewId);
|
|
507 |
|
|
508 |
// If the root folder is available then Add the feed.
|
|
509 |
if (iFeedsInterface.RootFolder() != NULL)
|
|
510 |
{
|
|
511 |
// Ensure that "this" is ready for uses.
|
|
512 |
LazyInitL( EFalse );
|
|
513 |
CFeedsMap* temp = CFeedsMap::NewL();
|
|
514 |
temp->SetStringAttribute(EFeedAttributeTitle,aTitle);
|
|
515 |
temp->SetStringAttribute(EFeedAttributeLink,aUrl);
|
|
516 |
temp->SetIntegerAttribute(EFeedAttributeAutoUpdateFreq,0);
|
|
517 |
|
|
518 |
// Set the next view to show after the new add folder item is added.
|
|
519 |
iNextViewId = KUidBrowserFeedsFolderViewId;
|
|
520 |
|
|
521 |
iFeedsInterface.AddL(EFeed,*temp, *(iFeedsInterface.RootFolder()));
|
|
522 |
|
|
523 |
delete temp;
|
|
524 |
// Ensure the Folder View shows the root-folder when AddFolderItemL completes.
|
|
525 |
iFolderView->SetCurrentFolder(*(iFeedsInterface.RootFolder()), ETrue);
|
|
526 |
}
|
|
527 |
|
|
528 |
// Otherwise queue the folder item until the root folder is fetched (see above).
|
|
529 |
else
|
|
530 |
{
|
|
531 |
// Ensure that "this" is ready for uses. ETrue is passed to ensure that
|
|
532 |
// the root folder will be fetched if it isn't already available.
|
|
533 |
LazyInitL( ETrue );
|
|
534 |
|
|
535 |
delete iPendingFolderItemTitle;
|
|
536 |
iPendingFolderItemTitle = NULL;
|
|
537 |
delete iPendingFolderItemUrl;
|
|
538 |
iPendingFolderItemUrl = NULL;
|
|
539 |
|
|
540 |
iPendingFolderItemTitle = aTitle.AllocL();
|
|
541 |
TRAPD(err, iPendingFolderItemUrl = aUrl.AllocL());
|
|
542 |
if (err != KErrNone)
|
|
543 |
{
|
|
544 |
delete iPendingFolderItemTitle;
|
|
545 |
iPendingFolderItemTitle = NULL;
|
|
546 |
|
|
547 |
User::Leave(err);
|
|
548 |
}
|
|
549 |
}
|
|
550 |
}
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
// -----------------------------------------------------------------------------
|
|
556 |
// CFeedsClientUtilities::FeedsServerSettings
|
|
557 |
//
|
|
558 |
// Returns Feeds Server related settings.
|
|
559 |
// -----------------------------------------------------------------------------
|
|
560 |
//
|
|
561 |
TInt CFeedsClientUtilities::FeedsServerSettingsL(TFeedsServerSetting& aSetting)
|
|
562 |
{
|
|
563 |
// Ensure that the connection is available.
|
|
564 |
ConnectToServerL(EFalse);
|
|
565 |
|
|
566 |
return iFeedsInterface.GetSettingsL(aSetting);
|
|
567 |
}
|
|
568 |
|
|
569 |
|
|
570 |
// -----------------------------------------------------------------------------
|
|
571 |
// CFeedsClientUtilities::SetFeedsServerSettings
|
|
572 |
//
|
|
573 |
// Sets Feeds Server related settings.
|
|
574 |
// -----------------------------------------------------------------------------
|
|
575 |
//
|
|
576 |
void CFeedsClientUtilities::SetFeedsServerSettingsL(const TFeedsServerSetting& aNewSetting)
|
|
577 |
{
|
|
578 |
// Ensure that the connection is available.
|
|
579 |
ConnectToServerL(EFalse);
|
|
580 |
|
|
581 |
// Pass the updated settings to the server.
|
|
582 |
iFeedsInterface.SetSettingsL(aNewSetting);
|
|
583 |
}
|
|
584 |
|
|
585 |
|
|
586 |
// -----------------------------------------------------------------------------
|
|
587 |
// CFeedsClientUtilities::SetBrowserControlSettingL
|
|
588 |
//
|
|
589 |
// Sets a Browser Control related settings. These settings are directly passed to all
|
|
590 |
// Browser Control instances used by the CFeedsViewBridge. As such see the Browser
|
|
591 |
// Control documentation for infomation about the settings.
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
//
|
|
594 |
void CFeedsClientUtilities::SetBrowserControlSettingL(TUint aSetting, TUint aValue)
|
|
595 |
{
|
|
596 |
// Pass the setting to the Feed View's Browser Control.
|
|
597 |
iApiProvider.BrCtlInterface().SetBrowserSettingL(aSetting, aValue);
|
|
598 |
}
|
|
599 |
|
|
600 |
// -----------------------------------------------------------------------------
|
|
601 |
// CFeedsClientUtilities::FolderItemRequestCompleted
|
|
602 |
//
|
|
603 |
// Called by RequestHandlerCompleted when the root FolderItem is either ready
|
|
604 |
// or an error occured.
|
|
605 |
// -----------------------------------------------------------------------------
|
|
606 |
//
|
|
607 |
void CFeedsClientUtilities::FolderItemRequestCompleted(TInt aStatus, CTransaction::TTransactionType aTransType/*=ENone*/)
|
|
608 |
{
|
|
609 |
TRAP_IGNORE( FolderItemRequestCompletedL(aStatus, aTransType) );
|
|
610 |
}
|
|
611 |
|
|
612 |
// -----------------------------------------------------------------------------
|
|
613 |
// CFeedsClientUtilities::FolderItemRequestCompletedL
|
|
614 |
//
|
|
615 |
// Called by FolderItemRequestCompleted.
|
|
616 |
// -----------------------------------------------------------------------------
|
|
617 |
//
|
|
618 |
void CFeedsClientUtilities::FolderItemRequestCompletedL(TInt aStatus, CTransaction::TTransactionType aTransType/*=ENone*/)
|
|
619 |
{
|
|
620 |
if (aTransType == iCanceledRequest)
|
|
621 |
{
|
|
622 |
iCanceledRequest = CTransaction::ENone;
|
|
623 |
return;
|
|
624 |
}
|
|
625 |
|
|
626 |
iWaitDialog->Close();
|
|
627 |
|
|
628 |
iIsWaitDialogDisplayed = EFalse;
|
|
629 |
|
|
630 |
// Show the view if everything went ok.
|
|
631 |
if (aStatus == KErrNone)
|
|
632 |
{
|
|
633 |
switch(aTransType)
|
|
634 |
{
|
|
635 |
case CTransaction::EExportOPML:
|
|
636 |
//launch send ui
|
|
637 |
SendOPMLFileL();
|
|
638 |
break;
|
|
639 |
|
|
640 |
case CTransaction::EImportOPML:
|
|
641 |
// Delete temp file here if it exists
|
|
642 |
if(iTempOPMLImportFilePath.Length() > 0)
|
|
643 |
{
|
|
644 |
RFs tempRFs;
|
|
645 |
if (tempRFs.Connect() != KErrNone)
|
|
646 |
{
|
|
647 |
break;
|
|
648 |
}
|
|
649 |
CleanupClosePushL(tempRFs);
|
|
650 |
tempRFs.Delete( iTempOPMLImportFilePath );
|
|
651 |
tempRFs.Close();
|
|
652 |
CleanupStack::PopAndDestroy(); // cleanup tempRFs and reset temp file import path
|
|
653 |
iTempOPMLImportFilePath = _L("");
|
|
654 |
}
|
|
655 |
|
|
656 |
// Again show folder view to trigger a redraw
|
|
657 |
ShowFolderViewL();
|
|
658 |
break;
|
|
659 |
|
|
660 |
default:
|
|
661 |
// if an import OPML was requested, do that now
|
|
662 |
if(iFeedImportRequested)
|
|
663 |
{
|
|
664 |
// clear flag
|
|
665 |
iFeedImportRequested = EFalse;
|
|
666 |
|
|
667 |
// show wait dialog
|
|
668 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_WAIT_IMPORTING_FEEDS);
|
|
669 |
iIsWaitDialogDisplayed = ETrue;
|
|
670 |
|
|
671 |
|
|
672 |
if(iTempOPMLImportFilePath.Length())
|
|
673 |
{
|
|
674 |
iFeedsInterface.ImportOPMLL( iTempOPMLImportFilePath );
|
|
675 |
}
|
|
676 |
iCurrentRequest = CTransaction::EImportOPML;
|
|
677 |
}
|
|
678 |
|
|
679 |
// Set the updated folder
|
|
680 |
iFolderView->RootFolderChangedL(*(iFeedsInterface.RootFolder()));
|
|
681 |
|
|
682 |
// Show it.
|
|
683 |
if (iNextViewId == KUidBrowserFeedsFolderViewId)
|
|
684 |
{
|
|
685 |
ShowFolderViewLocalL();
|
|
686 |
}
|
|
687 |
|
|
688 |
// If the user tried to subscribe to a feed before it was connected
|
|
689 |
// to the server then add the item now.
|
|
690 |
if (iPendingFolderItemTitle != NULL)
|
|
691 |
{
|
|
692 |
TRAPD(err, SubscribeToL(*iPendingFolderItemTitle, *iPendingFolderItemUrl));
|
|
693 |
if (err == KErrNone)
|
|
694 |
{
|
|
695 |
delete iPendingFolderItemTitle;
|
|
696 |
iPendingFolderItemTitle = NULL;
|
|
697 |
delete iPendingFolderItemUrl;
|
|
698 |
iPendingFolderItemUrl = NULL;
|
|
699 |
}
|
|
700 |
// Don't reset next-view; iNextViewId is EFolderViewId after above SubscribeToL() call
|
|
701 |
|
|
702 |
// Otherwise try to add the folder item next time.
|
|
703 |
}
|
|
704 |
else if(iNextViewId == KUidBrowserFeedsFolderViewId)
|
|
705 |
{
|
|
706 |
// Reset next-view.
|
|
707 |
iNextViewId = KUidBrowserNullViewId;
|
|
708 |
}
|
|
709 |
|
|
710 |
// Reset the "last updated" cache now that a new folder list is available.
|
|
711 |
ResetFeedUpdateTime();
|
|
712 |
}
|
|
713 |
}
|
|
714 |
// Otherwise show an error.
|
|
715 |
else
|
|
716 |
{
|
|
717 |
// If the server terminated, reconnect to it.
|
|
718 |
if (aStatus == KErrServerTerminated)
|
|
719 |
{
|
|
720 |
DisconnectFromServer();
|
|
721 |
ConnectToServerL();
|
|
722 |
|
|
723 |
}
|
|
724 |
|
|
725 |
ShowServerError(aStatus, aTransType);
|
|
726 |
|
|
727 |
// This happens when user subscribe to a feed from content view
|
|
728 |
// If it failed, we want to show the content view.
|
|
729 |
if (aStatus == KErrAlreadyExists)
|
|
730 |
{
|
|
731 |
// Set content view as the last view id.
|
|
732 |
iApiProvider.SetLastActiveViewId( KUidBrowserContentViewId );
|
|
733 |
|
|
734 |
// Show the view.
|
|
735 |
// We already started switching to the feeds folder view and shut off full screen
|
|
736 |
// This will force the DoActivate on the ContentView and set back to full screen
|
|
737 |
iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserFeedsFolderViewId );
|
|
738 |
iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserContentViewId );
|
|
739 |
}
|
|
740 |
|
|
741 |
// Reset next-view.
|
|
742 |
iNextViewId = KUidBrowserNullViewId;
|
|
743 |
}
|
|
744 |
}
|
|
745 |
|
|
746 |
// -----------------------------------------------------------------------------
|
|
747 |
// CFeedsClientUtilities::FeedRequestCompleted
|
|
748 |
//
|
|
749 |
// Called when the asynchronous request is complete.
|
|
750 |
// -----------------------------------------------------------------------------
|
|
751 |
//
|
|
752 |
void CFeedsClientUtilities::FeedRequestCompleted(TInt aEvent)
|
|
753 |
{
|
|
754 |
TRAP_IGNORE( FeedRequestCompletedL(aEvent) );
|
|
755 |
}
|
|
756 |
|
|
757 |
// -----------------------------------------------------------------------------
|
|
758 |
// CFeedsClientUtilities::FeedRequestCompletedL
|
|
759 |
//
|
|
760 |
// Called when the asynchronous request is complete.
|
|
761 |
// -----------------------------------------------------------------------------
|
|
762 |
//
|
|
763 |
void CFeedsClientUtilities::FeedRequestCompletedL(TInt aStatus)
|
|
764 |
{
|
|
765 |
if (CTransaction::EFetchFeed == iCanceledRequest)
|
|
766 |
{
|
|
767 |
iCanceledRequest = CTransaction::ENone;
|
|
768 |
return;
|
|
769 |
}
|
|
770 |
// Close the wait dialog.
|
|
771 |
iWaitDialog->Close();
|
|
772 |
iIsWaitDialogDisplayed = EFalse;
|
|
773 |
|
|
774 |
// Show the view if everything went ok.
|
|
775 |
if (aStatus == KErrNone)
|
|
776 |
{
|
|
777 |
// Extract out the intial item status -- later on, iItemStatusOrig is
|
|
778 |
// used to determine which item status' change.
|
|
779 |
RArray<TInt> ignore(20);
|
|
780 |
|
|
781 |
iItemIds.Reset();
|
|
782 |
iItemStatus.Reset();
|
|
783 |
iItemStatusOrig.Reset();
|
|
784 |
|
|
785 |
CleanupClosePushL(ignore);
|
|
786 |
ItemStatusL(iItemIds, iItemStatus, *(iFeedsInterface.Feed()));
|
|
787 |
ItemStatusL(ignore, iItemStatusOrig, *(iFeedsInterface.Feed()));
|
|
788 |
CleanupStack::PopAndDestroy(/*ignore*/);
|
|
789 |
|
|
790 |
// update folder view for unread count
|
|
791 |
TInt unreadCount = 0;
|
|
792 |
for (TInt i = 0; i < iItemStatus.Count(); i++)
|
|
793 |
{
|
|
794 |
if ( iItemStatus[i] == EItemStatusUnread || iItemStatus[i] == EItemStatusNew )
|
|
795 |
{
|
|
796 |
unreadCount++;
|
|
797 |
}
|
|
798 |
}
|
|
799 |
iFolderView->SetUnreadCountL( unreadCount );
|
|
800 |
|
|
801 |
// The method was called because of a updated feed. In general, update
|
|
802 |
// the current view to reflect the updated feed.
|
|
803 |
if (iIsUpdatingFeed)
|
|
804 |
{
|
|
805 |
if (iApiProvider.LastActiveViewId() == KUidBrowserFeedsTopicViewId)
|
|
806 |
{
|
|
807 |
iTopicView->SetCurrentFeedL(*(CurrentFeed()), 0);
|
|
808 |
}
|
|
809 |
}
|
|
810 |
|
|
811 |
// Otherwise, this is a newly requested feed, so show the next
|
|
812 |
// view now that it is available.
|
|
813 |
else
|
|
814 |
{
|
|
815 |
if (iNextViewId == KUidBrowserFeedsFeedViewId)
|
|
816 |
{
|
|
817 |
ShowFeedViewLocalL(0);
|
|
818 |
}
|
|
819 |
else if (iNextViewId == KUidBrowserFeedsTopicViewId)
|
|
820 |
{
|
|
821 |
ShowTopicViewLocalL(0);
|
|
822 |
}
|
|
823 |
}
|
|
824 |
|
|
825 |
// Update the feed's "last updated" value in the cache.
|
|
826 |
UpdateFeedUpdatedTimeL(*(iFeedsInterface.Feed()));
|
|
827 |
}
|
|
828 |
|
|
829 |
// Otherwise show an error.
|
|
830 |
else
|
|
831 |
{
|
|
832 |
// If the server terminated, reconnect to it.
|
|
833 |
if (aStatus == KErrServerTerminated)
|
|
834 |
{
|
|
835 |
DisconnectFromServer();
|
|
836 |
ConnectToServerL();
|
|
837 |
|
|
838 |
}
|
|
839 |
|
|
840 |
ShowServerError(aStatus);
|
|
841 |
}
|
|
842 |
|
|
843 |
// Reset updating feed.
|
|
844 |
iIsUpdatingFeed = EFalse;
|
|
845 |
|
|
846 |
// Reset next-view.
|
|
847 |
iNextViewId = KUidBrowserNullViewId;
|
|
848 |
}
|
|
849 |
|
|
850 |
|
|
851 |
// -----------------------------------------------------------------------------
|
|
852 |
// CFeedsClientUtilities::DialogDismissedL
|
|
853 |
//
|
|
854 |
// Called when the user presses the cancel button.
|
|
855 |
// -----------------------------------------------------------------------------
|
|
856 |
//
|
|
857 |
void CFeedsClientUtilities::DialogDismissedL()
|
|
858 |
{
|
|
859 |
// Cancel all activities that can be cancelled.
|
|
860 |
iIsWaitDialogDisplayed = EFalse;
|
|
861 |
|
|
862 |
|
|
863 |
// If there is an ongoing search by the search agent, make sure
|
|
864 |
// it's cancelled and search agent destroyed
|
|
865 |
if(iSearchAgent != NULL)
|
|
866 |
{
|
|
867 |
iSearchAgent->CancelSearch();
|
|
868 |
delete(iSearchAgent);
|
|
869 |
iSearchAgent = NULL;
|
|
870 |
}
|
|
871 |
else
|
|
872 |
{
|
|
873 |
iCanceledRequest = iCurrentRequest;
|
|
874 |
iFeedsInterface.CancelAllL();
|
|
875 |
}
|
|
876 |
}
|
|
877 |
|
|
878 |
|
|
879 |
// -----------------------------------------------------------------------------
|
|
880 |
// CFeedsClientUtilities::FetchRootFolderL
|
|
881 |
//
|
|
882 |
// Get the root folder from the Feeds server.
|
|
883 |
// -----------------------------------------------------------------------------
|
|
884 |
//
|
|
885 |
void CFeedsClientUtilities::FetchRootFolderL()
|
|
886 |
{
|
|
887 |
iFeedsInterface.GetRootFolderL();
|
|
888 |
}
|
|
889 |
|
|
890 |
// -----------------------------------------------------------------------------
|
|
891 |
// CFeedsClientUtilities::AddFolderItemL
|
|
892 |
//
|
|
893 |
// Add a new folder item.
|
|
894 |
// -----------------------------------------------------------------------------
|
|
895 |
//
|
|
896 |
void CFeedsClientUtilities::AddFolderItemL(const TDesC& aTitle, const TDesC& aUrl,
|
|
897 |
TBool aIsFolder, const CFeedsEntity& aParent, TInt aFreq)
|
|
898 |
{
|
|
899 |
|
|
900 |
CFeedsMap* temp = CFeedsMap::NewL();
|
|
901 |
|
|
902 |
temp->SetStringAttribute(EFeedAttributeTitle,aTitle);
|
|
903 |
temp->SetStringAttribute(EFeedAttributeLink,aUrl);
|
|
904 |
temp->SetIntegerAttribute(EFeedAttributeAutoUpdateFreq,aFreq);
|
|
905 |
|
|
906 |
// Set the next view to show after the new add folder item is added.
|
|
907 |
iNextViewId = KUidBrowserFeedsFolderViewId;
|
|
908 |
|
|
909 |
iFeedsInterface.AddL(aIsFolder?EFolder:EFeed,*temp, aParent);
|
|
910 |
|
|
911 |
delete temp;
|
|
912 |
}
|
|
913 |
|
|
914 |
|
|
915 |
// -----------------------------------------------------------------------------
|
|
916 |
// CFeedsClientUtilities::ChangeFolderItemL
|
|
917 |
//
|
|
918 |
// Change the folder item. If this is a folder then KNullDesC should be passed
|
|
919 |
// to the aUrl argument.
|
|
920 |
// -----------------------------------------------------------------------------
|
|
921 |
//
|
|
922 |
void CFeedsClientUtilities::ChangeFolderItemL(CFeedsEntity& aFolderItem,
|
|
923 |
const TDesC& aTitle, const TDesC& aUrl,TInt aFreq)
|
|
924 |
{
|
|
925 |
CFeedsMap* temp = CFeedsMap::NewL();
|
|
926 |
temp->SetStringAttribute(EFeedAttributeTitle,aTitle);
|
|
927 |
temp->SetStringAttribute(EFeedAttributeLink,aUrl);
|
|
928 |
temp->SetIntegerAttribute(EFeedAttributeAutoUpdateFreq,aFreq);
|
|
929 |
// Set the next view to show after the new add folder item is added.
|
|
930 |
iNextViewId = KUidBrowserFeedsFolderViewId;
|
|
931 |
|
|
932 |
aFolderItem.ChangeValueL(*temp);
|
|
933 |
delete temp;
|
|
934 |
}
|
|
935 |
|
|
936 |
|
|
937 |
// -----------------------------------------------------------------------------
|
|
938 |
// CFeedsClientUtilities::DeleteFolderItemsL
|
|
939 |
//
|
|
940 |
// Delete the folder items.
|
|
941 |
// -----------------------------------------------------------------------------
|
|
942 |
//
|
|
943 |
void CFeedsClientUtilities::DeleteFolderItemsL(RPointerArray<const CFeedsEntity>& aFolderItems)
|
|
944 |
{
|
|
945 |
iFeedsInterface.DeleteL(aFolderItems);
|
|
946 |
}
|
|
947 |
|
|
948 |
|
|
949 |
// -----------------------------------------------------------------------------
|
|
950 |
// CFeedsClientUtilities::MoveFolderItemsToL
|
|
951 |
//
|
|
952 |
// Move the folder items to a different parent.
|
|
953 |
// -----------------------------------------------------------------------------
|
|
954 |
//
|
|
955 |
void CFeedsClientUtilities::MoveFolderItemsToL(RPointerArray<const CFeedsEntity>& aFolderItems,
|
|
956 |
const CFeedsEntity& aParent)
|
|
957 |
{
|
|
958 |
iFeedsInterface.MoveToFolderL(aFolderItems, aParent);
|
|
959 |
}
|
|
960 |
|
|
961 |
|
|
962 |
// -----------------------------------------------------------------------------
|
|
963 |
// CFeedsClientUtilities::MoveFolderItemsL
|
|
964 |
//
|
|
965 |
// Move the folder item to a different index.
|
|
966 |
// -----------------------------------------------------------------------------
|
|
967 |
//
|
|
968 |
void CFeedsClientUtilities::MoveFolderItemsL(RPointerArray<const CFeedsEntity>& aFolderItems,
|
|
969 |
TInt aIndex)
|
|
970 |
{
|
|
971 |
iFeedsInterface.MoveL(aFolderItems, aIndex);
|
|
972 |
}
|
|
973 |
|
|
974 |
|
|
975 |
// -----------------------------------------------------------------------------
|
|
976 |
// CFeedsClientUtilities::FetchFeedL
|
|
977 |
//
|
|
978 |
// Get the given feed from the Feeds server.
|
|
979 |
// -----------------------------------------------------------------------------
|
|
980 |
//
|
|
981 |
void CFeedsClientUtilities::FetchFeedL(const CFeedsEntity& aFeedEntity, TBool aForceUpdate,
|
|
982 |
TBool aNoCache)
|
|
983 |
{
|
|
984 |
// Fetch the new feed.
|
|
985 |
iFeedsInterface.FetchL(aFeedEntity, aForceUpdate, aNoCache);
|
|
986 |
}
|
|
987 |
|
|
988 |
|
|
989 |
// -----------------------------------------------------------------------------
|
|
990 |
// CFeedsClientUtilities::UpdateFeedL
|
|
991 |
//
|
|
992 |
// Updates the feed with the given id.
|
|
993 |
// -----------------------------------------------------------------------------
|
|
994 |
//
|
|
995 |
void CFeedsClientUtilities::UpdateFeedL(const CFeedsEntity& aFeedEntity)
|
|
996 |
{
|
|
997 |
if(iIsWaitDialogDisplayed)
|
|
998 |
{
|
|
999 |
return;
|
|
1000 |
}
|
|
1001 |
// Show wait dialog iff connection is already established.
|
|
1002 |
if(iApiProvider.Connection().Connected())
|
|
1003 |
{
|
|
1004 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_UPDATING_FEED);
|
|
1005 |
iIsWaitDialogDisplayed = ETrue;
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
iIsUpdatingFeed = ETrue;
|
|
1009 |
|
|
1010 |
// Fetch the feed.
|
|
1011 |
FetchFeedL(aFeedEntity, ETrue);
|
|
1012 |
iCurrentRequest = CTransaction::EFetchFeed;
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
|
|
1016 |
// -----------------------------------------------------------------------------
|
|
1017 |
// CFeedsClientUtilities::UpdateFolderItemsL
|
|
1018 |
//
|
|
1019 |
// Updates the given feeds in the background.
|
|
1020 |
// -----------------------------------------------------------------------------
|
|
1021 |
//
|
|
1022 |
void CFeedsClientUtilities::UpdateFolderItemsL(const RPointerArray<const CFeedsEntity>&
|
|
1023 |
aFolderItems)
|
|
1024 |
{
|
|
1025 |
if (iIsWaitDialogDisplayed)
|
|
1026 |
{
|
|
1027 |
return;
|
|
1028 |
}
|
|
1029 |
// Show wait dialog iff connection is already established.
|
|
1030 |
if (iApiProvider.Connection().Connected())
|
|
1031 |
{
|
|
1032 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_UPDATING_FEED);
|
|
1033 |
iIsWaitDialogDisplayed = ETrue;
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
// Fetch the feeds.
|
|
1037 |
iFeedsInterface.UpdateL(aFolderItems);
|
|
1038 |
iCurrentRequest = CTransaction::EUpdateFolderItem;
|
|
1039 |
}
|
|
1040 |
|
|
1041 |
|
|
1042 |
// -----------------------------------------------------------------------------
|
|
1043 |
// CFeedsClientUtilities::UpdateFolderItemsL
|
|
1044 |
//
|
|
1045 |
// Updates all of feeds in the background.
|
|
1046 |
// -----------------------------------------------------------------------------
|
|
1047 |
//
|
|
1048 |
void CFeedsClientUtilities::UpdateFolderItemsL()
|
|
1049 |
{
|
|
1050 |
if (iIsWaitDialogDisplayed)
|
|
1051 |
{
|
|
1052 |
return;
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
// Show wait dialog iff connection is already established.
|
|
1056 |
if (iApiProvider.Connection().Connected())
|
|
1057 |
{
|
|
1058 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_UPDATING_ALL_WAIT_DIALOG);
|
|
1059 |
iIsWaitDialogDisplayed = ETrue;
|
|
1060 |
}
|
|
1061 |
|
|
1062 |
// Fetch the feeds.
|
|
1063 |
RPointerArray<const CFeedsEntity> aFolderItem;
|
|
1064 |
aFolderItem.Append((iFeedsInterface.RootFolder()));
|
|
1065 |
|
|
1066 |
iFeedsInterface.UpdateL(aFolderItem);
|
|
1067 |
iCurrentRequest = CTransaction::EUpdateFolderItem;
|
|
1068 |
}
|
|
1069 |
|
|
1070 |
// -----------------------------------------------------------------------------
|
|
1071 |
// CFeedsClientUtilities::ImportFeeds
|
|
1072 |
//
|
|
1073 |
// Import feeds from OPML file
|
|
1074 |
// -----------------------------------------------------------------------------
|
|
1075 |
//
|
|
1076 |
|
|
1077 |
void CFeedsClientUtilities::ImportFeedsL()
|
|
1078 |
{
|
|
1079 |
if (iIsWaitDialogDisplayed)
|
|
1080 |
{
|
|
1081 |
return;
|
|
1082 |
}
|
|
1083 |
|
|
1084 |
// construct search agent
|
|
1085 |
if(NULL != iSearchAgent)
|
|
1086 |
{
|
|
1087 |
delete(iSearchAgent);
|
|
1088 |
iSearchAgent = NULL;
|
|
1089 |
}
|
|
1090 |
iSearchAgent = CFeedsFileSearchAgent::NewL(*this);
|
|
1091 |
|
|
1092 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_WAIT_SEARCHING_FOR_FEEDS);
|
|
1093 |
iIsWaitDialogDisplayed = ETrue;
|
|
1094 |
|
|
1095 |
// Start search
|
|
1096 |
if(NULL != iSearchAgent)
|
|
1097 |
{
|
|
1098 |
iSearchAgent->StartSearchingL();
|
|
1099 |
}
|
|
1100 |
}
|
|
1101 |
|
|
1102 |
// -----------------------------------------------------------------------------
|
|
1103 |
// CFeedsClientUtilities::FeedsFileSearchCompleteL
|
|
1104 |
//
|
|
1105 |
// Implemented from the MFeedsFileSearchAgentCallback mixin, this
|
|
1106 |
// callback is called when the search for files in the filesystem has completed
|
|
1107 |
// -----------------------------------------------------------------------------
|
|
1108 |
//
|
|
1109 |
|
|
1110 |
void CFeedsClientUtilities::FeedsFileSearchCompleteL(TInt aCount)
|
|
1111 |
{
|
|
1112 |
TFileEntry * fileEntry;
|
|
1113 |
TInt i;
|
|
1114 |
|
|
1115 |
iWaitDialog->Close();
|
|
1116 |
iIsWaitDialogDisplayed = EFalse;
|
|
1117 |
|
|
1118 |
// If nothing is found, indicate that, cleanup and quit
|
|
1119 |
if(aCount == 0)
|
|
1120 |
{
|
|
1121 |
HBufC* note = StringLoader::LoadLC(R_FEEDS_NO_FEEDS_FOUND_ON_DEVICE);
|
|
1122 |
iApiProvider.DialogsProvider().DialogAlertL(_L(""),*note);
|
|
1123 |
CleanupStack::PopAndDestroy( note );
|
|
1124 |
}
|
|
1125 |
else
|
|
1126 |
{
|
|
1127 |
//
|
|
1128 |
// construct results dialog box to show search results
|
|
1129 |
//
|
|
1130 |
if(NULL != iSearchOptList)
|
|
1131 |
{
|
|
1132 |
delete(iSearchOptList);
|
|
1133 |
iSearchOptList = NULL;
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
iSearchOptList = new( ELeave ) CArrayFixFlat<TBrCtlSelectOptionData>(aCount);
|
|
1137 |
|
|
1138 |
HBufC* title = StringLoader::LoadLC(R_FEEDS_POPUP_TITLE_FEEDS_FILES_FOUND);
|
|
1139 |
|
|
1140 |
// loop through the search results
|
|
1141 |
for(i = 0; i < aCount; i++)
|
|
1142 |
{
|
|
1143 |
if(iSearchAgent)
|
|
1144 |
{
|
|
1145 |
// grab file found from the search agent results and add it
|
|
1146 |
// as an option
|
|
1147 |
fileEntry = iSearchAgent->GetFileEntry(i);
|
|
1148 |
if(NULL != fileEntry)
|
|
1149 |
{
|
|
1150 |
TBrCtlSelectOptionData t(fileEntry->iEntry.iName, EFalse, EFalse, EFalse);
|
|
1151 |
iSearchOptList->AppendL(t);
|
|
1152 |
}
|
|
1153 |
}
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
TBool ret(iApiProvider.DialogsProvider().DialogSelectOptionL( *title,
|
|
1157 |
ESelectTypeNone, *iSearchOptList));
|
|
1158 |
|
|
1159 |
CleanupStack::PopAndDestroy(title);
|
|
1160 |
|
|
1161 |
//
|
|
1162 |
// If the user selects an option, import it
|
|
1163 |
//
|
|
1164 |
if ( ret )
|
|
1165 |
{
|
|
1166 |
for( i = 0; i < aCount; i++)
|
|
1167 |
{
|
|
1168 |
if( (*iSearchOptList)[i].IsSelected() )
|
|
1169 |
{
|
|
1170 |
if(iSearchAgent)
|
|
1171 |
{
|
|
1172 |
fileEntry = iSearchAgent->GetFileEntry(i);
|
|
1173 |
if(NULL != fileEntry)
|
|
1174 |
{
|
|
1175 |
BeginImportOPMLFeedsFileL(fileEntry->iPath);
|
|
1176 |
}
|
|
1177 |
}
|
|
1178 |
break;
|
|
1179 |
}
|
|
1180 |
}
|
|
1181 |
}
|
|
1182 |
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
// destroy the search agent
|
|
1186 |
delete(iSearchAgent);
|
|
1187 |
iSearchAgent = NULL;
|
|
1188 |
}
|
|
1189 |
|
|
1190 |
// -----------------------------------------------------------------------------
|
|
1191 |
// CFeedsClientUtilities::BeginImportOPMLFeedsFileL
|
|
1192 |
//
|
|
1193 |
// Given a path, save it in the class, show the root folder view and set
|
|
1194 |
// a flag to indicate we're importing. When the root folder is done opening,
|
|
1195 |
// then begin the actual import
|
|
1196 |
// -----------------------------------------------------------------------------
|
|
1197 |
//
|
|
1198 |
|
|
1199 |
void CFeedsClientUtilities::BeginImportOPMLFeedsFileL( TFileName& aFilepath )
|
|
1200 |
{
|
|
1201 |
// save path
|
|
1202 |
iTempOPMLImportFilePath = aFilepath;
|
|
1203 |
|
|
1204 |
// Switch to feeds view, setting the flag will import
|
|
1205 |
// from the tempOPMLImportFilePath when the view is ready
|
|
1206 |
iFeedImportRequested = ETrue;
|
|
1207 |
ShowFolderViewL();
|
|
1208 |
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
// -----------------------------------------------------------------------------
|
|
1212 |
// CFeedsClientUtilities::ExportFeeds
|
|
1213 |
//
|
|
1214 |
// Export feeds to OPML file
|
|
1215 |
// -----------------------------------------------------------------------------
|
|
1216 |
//
|
|
1217 |
|
|
1218 |
void CFeedsClientUtilities::ExportFeedsL(RPointerArray<const CFeedsEntity>& aFolderItems, const TDesC &aExportFileName)
|
|
1219 |
{
|
|
1220 |
if (iIsWaitDialogDisplayed)
|
|
1221 |
{
|
|
1222 |
return;
|
|
1223 |
}
|
|
1224 |
|
|
1225 |
iWaitDialog->ShowWaitDialogL(R_FEEDS_WAIT_PROCESSING);
|
|
1226 |
iIsWaitDialogDisplayed = ETrue;
|
|
1227 |
|
|
1228 |
if (iExportFileName)
|
|
1229 |
{
|
|
1230 |
delete iExportFileName;
|
|
1231 |
iExportFileName = NULL;
|
|
1232 |
}
|
|
1233 |
|
|
1234 |
iExportFileName = aExportFileName.AllocL();
|
|
1235 |
iFeedsInterface.ExportFoldersL(aFolderItems, aExportFileName);
|
|
1236 |
iCurrentRequest = CTransaction::EExportOPML;
|
|
1237 |
}
|
|
1238 |
|
|
1239 |
// -----------------------------------------------------------------------------
|
|
1240 |
// CFeedsClientUtilities::ShowFolderViewLocalL
|
|
1241 |
//
|
|
1242 |
// Shows the folder view.
|
|
1243 |
// -----------------------------------------------------------------------------
|
|
1244 |
//
|
|
1245 |
void CFeedsClientUtilities::ShowFolderViewLocalL()
|
|
1246 |
{
|
|
1247 |
// Set this as the last view id -- this is used in ShowLastViewL.
|
|
1248 |
iApiProvider.SetLastActiveViewId(KUidBrowserFeedsFolderViewId);
|
|
1249 |
|
|
1250 |
// Show the view.
|
|
1251 |
iApiProvider.SetViewToBeActivatedIfNeededL(KUidBrowserFeedsFolderViewId);
|
|
1252 |
}
|
|
1253 |
|
|
1254 |
|
|
1255 |
// -----------------------------------------------------------------------------
|
|
1256 |
// CFeedsClientUtilities::ShowTopicViewLocalL
|
|
1257 |
//
|
|
1258 |
// Shows the topic view.
|
|
1259 |
// -----------------------------------------------------------------------------
|
|
1260 |
//
|
|
1261 |
void CFeedsClientUtilities::ShowTopicViewLocalL(TInt aInitialItem)
|
|
1262 |
{
|
|
1263 |
// Set this as the last view id -- this is used in ShowLastViewL.
|
|
1264 |
iApiProvider.SetLastActiveViewId(KUidBrowserFeedsTopicViewId);
|
|
1265 |
|
|
1266 |
// Set the inital item.
|
|
1267 |
if (iTopicView == NULL)
|
|
1268 |
{
|
|
1269 |
TRect rect(iAppUI.ClientRect());
|
|
1270 |
iTopicView = CFeedsTopicView::NewL( iApiProvider, rect );
|
|
1271 |
iAppUI.AddViewL( iTopicView ); // transfer ownership to CAknViewAppUi
|
|
1272 |
}
|
|
1273 |
|
|
1274 |
iTopicView->SetInitialItem(aInitialItem);
|
|
1275 |
|
|
1276 |
// Show the view.
|
|
1277 |
iApiProvider.SetViewToBeActivatedIfNeededL(KUidBrowserFeedsTopicViewId);
|
|
1278 |
}
|
|
1279 |
|
|
1280 |
|
|
1281 |
// -----------------------------------------------------------------------------
|
|
1282 |
// CFeedsClientUtilities::ShowFeedViewLocalL
|
|
1283 |
//
|
|
1284 |
// Shows the feed view.
|
|
1285 |
// -----------------------------------------------------------------------------
|
|
1286 |
//
|
|
1287 |
void CFeedsClientUtilities::ShowFeedViewLocalL(TInt aInitialItem)
|
|
1288 |
{
|
|
1289 |
// Set this as the last view id -- this is used in ShowLastViewL.
|
|
1290 |
iApiProvider.SetLastActiveViewId(KUidBrowserFeedsFeedViewId);
|
|
1291 |
|
|
1292 |
// Set the inital item.
|
|
1293 |
if (iFeedView == NULL)
|
|
1294 |
{
|
|
1295 |
TRect rect(iAppUI.ClientRect());
|
|
1296 |
iFeedView = CFeedsFeedView::NewL( iApiProvider, rect );
|
|
1297 |
iAppUI.AddViewL( iFeedView ); // transfer ownership to CAknViewAppUi
|
|
1298 |
}
|
|
1299 |
|
|
1300 |
iFeedView->SetInitialItem(aInitialItem);
|
|
1301 |
|
|
1302 |
// Show the view.
|
|
1303 |
iApiProvider.SetViewToBeActivatedIfNeededL(KUidBrowserFeedsFeedViewId);
|
|
1304 |
}
|
|
1305 |
|
|
1306 |
|
|
1307 |
// -----------------------------------------------------------------------------
|
|
1308 |
// CFeedsClientUtilities::CurrentRootFolder
|
|
1309 |
//
|
|
1310 |
// Returns the current root folder.
|
|
1311 |
// -----------------------------------------------------------------------------
|
|
1312 |
//
|
|
1313 |
const CFeedsEntity* CFeedsClientUtilities::CurrentRootFolder()
|
|
1314 |
{
|
|
1315 |
return iFeedsInterface.RootFolder();
|
|
1316 |
}
|
|
1317 |
|
|
1318 |
|
|
1319 |
// -----------------------------------------------------------------------------
|
|
1320 |
// CFeedsClientUtilities::CurrentFeed
|
|
1321 |
//
|
|
1322 |
// Returns the current feed.
|
|
1323 |
// -----------------------------------------------------------------------------
|
|
1324 |
//
|
|
1325 |
CFeedsEntity* CFeedsClientUtilities::CurrentFeed()
|
|
1326 |
{
|
|
1327 |
return iFeedsInterface.Feed();
|
|
1328 |
}
|
|
1329 |
|
|
1330 |
// -----------------------------------------------------------------------------
|
|
1331 |
// CFeedsClientUtilities::AddItemL
|
|
1332 |
//
|
|
1333 |
// Add a menu item to the given menu.
|
|
1334 |
// -----------------------------------------------------------------------------
|
|
1335 |
//
|
|
1336 |
void CFeedsClientUtilities::AddItemL(CEikMenuPane& aMenuPane, TInt aCommand,
|
|
1337 |
TInt aTitleId)
|
|
1338 |
{
|
|
1339 |
CEikMenuPaneItem::SData item;
|
|
1340 |
HBufC* buf = NULL;
|
|
1341 |
|
|
1342 |
buf = StringLoader::LoadLC(aTitleId);
|
|
1343 |
item.iText.Copy(*buf);
|
|
1344 |
CleanupStack::PopAndDestroy(buf);
|
|
1345 |
buf = NULL;
|
|
1346 |
|
|
1347 |
item.iCommandId = aCommand;
|
|
1348 |
item.iFlags = 0;
|
|
1349 |
item.iCascadeId = 0;
|
|
1350 |
aMenuPane.AddMenuItemL(item);
|
|
1351 |
}
|
|
1352 |
|
|
1353 |
|
|
1354 |
// -----------------------------------------------------------------------------
|
|
1355 |
// CFeedsClientUtilities::AddCascadeL
|
|
1356 |
//
|
|
1357 |
// Add a sub-menu to the given menu.
|
|
1358 |
// -----------------------------------------------------------------------------
|
|
1359 |
//
|
|
1360 |
void CFeedsClientUtilities::AddCascadeL(CEikMenuPane& aMenuPane, TInt aCommand,
|
|
1361 |
TInt aTitleId, TInt aCascade)
|
|
1362 |
{
|
|
1363 |
CEikMenuPaneItem::SData item;
|
|
1364 |
HBufC* buf = NULL;
|
|
1365 |
|
|
1366 |
buf = StringLoader::LoadLC(aTitleId);
|
|
1367 |
item.iText.Copy(*buf);
|
|
1368 |
CleanupStack::PopAndDestroy(buf);
|
|
1369 |
buf = NULL;
|
|
1370 |
|
|
1371 |
item.iCommandId = aCommand;
|
|
1372 |
item.iFlags = 0;
|
|
1373 |
item.iCascadeId = aCascade;
|
|
1374 |
aMenuPane.AddMenuItemL(item);
|
|
1375 |
}
|
|
1376 |
|
|
1377 |
|
|
1378 |
// -----------------------------------------------------------------------------
|
|
1379 |
// CFeedsClientUtilities::SetItemStatus
|
|
1380 |
//
|
|
1381 |
// Sets the item's status (read/unread/new).
|
|
1382 |
// -----------------------------------------------------------------------------
|
|
1383 |
//
|
|
1384 |
void CFeedsClientUtilities::SetItemStatusL(CFeedsEntity* aItem, TFeedItemStatus aStatus)
|
|
1385 |
{
|
|
1386 |
TInt ret;
|
|
1387 |
CFeedsMap* temp = CFeedsMap::NewL();
|
|
1388 |
temp->SetIntegerAttribute(EItemAttributeStatus,aStatus);
|
|
1389 |
ret = aItem->ChangeValueL(*temp);
|
|
1390 |
delete temp;
|
|
1391 |
|
|
1392 |
if (ret != KErrNone)
|
|
1393 |
{
|
|
1394 |
ShowServerError(ret);
|
|
1395 |
}
|
|
1396 |
}
|
|
1397 |
|
|
1398 |
|
|
1399 |
// -----------------------------------------------------------------------------
|
|
1400 |
// CFeedsClientUtilities::ItemStatus
|
|
1401 |
//
|
|
1402 |
// Returns the item's status (read/unread/new).
|
|
1403 |
// -----------------------------------------------------------------------------
|
|
1404 |
//
|
|
1405 |
TFeedItemStatus CFeedsClientUtilities::ItemStatus(TInt aItemId)
|
|
1406 |
{
|
|
1407 |
TInt pos;
|
|
1408 |
TFeedItemStatus status = EItemStatusUndefined;
|
|
1409 |
|
|
1410 |
if ((pos = iItemIds.Find(aItemId)) != KErrNotFound)
|
|
1411 |
{
|
|
1412 |
status = iItemStatus[pos];
|
|
1413 |
}
|
|
1414 |
else
|
|
1415 |
{
|
|
1416 |
// TODO: panic
|
|
1417 |
}
|
|
1418 |
|
|
1419 |
return status;
|
|
1420 |
}
|
|
1421 |
|
|
1422 |
|
|
1423 |
// -----------------------------------------------------------------------------
|
|
1424 |
// CFeedsClientUtilities::ItemStatusWriteToServerL
|
|
1425 |
//
|
|
1426 |
// Writes the item status out to the server.
|
|
1427 |
// -----------------------------------------------------------------------------
|
|
1428 |
//
|
|
1429 |
void CFeedsClientUtilities::ItemStatusWriteToServerL()
|
|
1430 |
{
|
|
1431 |
RArray<TInt> ids(20);
|
|
1432 |
RArray<TFeedItemStatus> status(20);
|
|
1433 |
TInt unreadCountDelta = 0;
|
|
1434 |
TInt unreadCount = 0;
|
|
1435 |
|
|
1436 |
if (iItemStatus.Count() == 0)
|
|
1437 |
{
|
|
1438 |
return;
|
|
1439 |
}
|
|
1440 |
|
|
1441 |
CleanupClosePushL(ids);
|
|
1442 |
CleanupClosePushL(status);
|
|
1443 |
|
|
1444 |
// Build new status arrays that only contains items that changed.
|
|
1445 |
for (TInt i = 0; i < iItemStatus.Count(); i++)
|
|
1446 |
{
|
|
1447 |
if (iItemStatus[i] != iItemStatusOrig[i])
|
|
1448 |
{
|
|
1449 |
// update orig, since the old orig doesn't hold true any more
|
|
1450 |
// important to do so:
|
|
1451 |
// because this method will be called whenever deactivateView of FeedsView is called
|
|
1452 |
iItemStatusOrig[i] = iItemStatus[i];
|
|
1453 |
|
|
1454 |
ids.AppendL(iItemIds[i]);
|
|
1455 |
status.AppendL(iItemStatus[i]);
|
|
1456 |
|
|
1457 |
// In current UI, status can only change from New -> Read, or Unread -> Read
|
|
1458 |
if ( iItemStatus[i] == EItemStatusRead )
|
|
1459 |
{
|
|
1460 |
unreadCountDelta--;
|
|
1461 |
}
|
|
1462 |
}
|
|
1463 |
}
|
|
1464 |
|
|
1465 |
// update folder view
|
|
1466 |
unreadCount = iFolderView->UnreadCountChangedL( unreadCountDelta );
|
|
1467 |
|
|
1468 |
// Write the item status out to the server.
|
|
1469 |
iFeedsInterface.UpdateFeedItemStatusL(ids, status, unreadCount);
|
|
1470 |
CleanupStack::PopAndDestroy(/*status*/);
|
|
1471 |
CleanupStack::PopAndDestroy(/*ids*/);
|
|
1472 |
}
|
|
1473 |
|
|
1474 |
|
|
1475 |
// -----------------------------------------------------------------------------
|
|
1476 |
// CFeedsClientUtilities::FaviconL
|
|
1477 |
//
|
|
1478 |
// Returns the Favicon to the given url or NULL if one isn't found.
|
|
1479 |
// -----------------------------------------------------------------------------
|
|
1480 |
//
|
|
1481 |
CGulIcon* CFeedsClientUtilities::FaviconL(const TDesC& aUrl)
|
|
1482 |
{
|
|
1483 |
CGulIcon* icon = NULL;
|
|
1484 |
|
|
1485 |
// TODO: Do this if access to the database is too slow.
|
|
1486 |
// First search the local cache.
|
|
1487 |
|
|
1488 |
// If not found extract it from the Feeds View's Browser Control and add
|
|
1489 |
// it to the local cache.
|
|
1490 |
|
|
1491 |
// Get the favicon from the Browser Control.
|
|
1492 |
icon = iApiProvider.WindowMgr().CurrentWindow()->BrCtlInterface().GetBitmapData(aUrl, TBrCtlDefs::EBitmapFavicon);
|
|
1493 |
if (icon != NULL)
|
|
1494 |
{
|
|
1495 |
icon->SetMask(NULL);
|
|
1496 |
}
|
|
1497 |
|
|
1498 |
return icon;
|
|
1499 |
}
|
|
1500 |
|
|
1501 |
|
|
1502 |
// -----------------------------------------------------------------------------
|
|
1503 |
// CFeedsClientUtilities::LazyInitL
|
|
1504 |
//
|
|
1505 |
// Ensures that the views and the connection to the FeedsServer are ready.
|
|
1506 |
// -----------------------------------------------------------------------------
|
|
1507 |
//
|
|
1508 |
void CFeedsClientUtilities::LazyInitL(TBool aGetRootFolder)
|
|
1509 |
{
|
|
1510 |
// Create Views
|
|
1511 |
if(iFolderView == NULL)
|
|
1512 |
{
|
|
1513 |
TRect rect(iAppUI.ClientRect());
|
|
1514 |
iFolderView = CFeedsFolderView::NewL( iApiProvider, rect );
|
|
1515 |
iAppUI.AddViewL( iFolderView ); // transfer ownership to CAknViewAppUi
|
|
1516 |
}
|
|
1517 |
|
|
1518 |
|
|
1519 |
|
|
1520 |
// Connect to the server.
|
|
1521 |
ConnectToServerL(aGetRootFolder);
|
|
1522 |
}
|
|
1523 |
|
|
1524 |
|
|
1525 |
// -----------------------------------------------------------------------------
|
|
1526 |
// CFeedsClientUtilities::ShowServerError
|
|
1527 |
//
|
|
1528 |
// Show a server error.
|
|
1529 |
// -----------------------------------------------------------------------------
|
|
1530 |
//
|
|
1531 |
void CFeedsClientUtilities::ShowServerError(TInt aStatus, CTransaction::TTransactionType aRequestType/*=ENone*/)
|
|
1532 |
{
|
|
1533 |
TInt labelId;
|
|
1534 |
|
|
1535 |
// Determine which label to use.
|
|
1536 |
switch(aStatus)
|
|
1537 |
{
|
|
1538 |
case KErrNoMemory:
|
|
1539 |
labelId = R_FEEDS_OUT_OF_MEMORY;
|
|
1540 |
break;
|
|
1541 |
// Few errors wont be shown as pop up dialog as they will appear in list box main pane
|
|
1542 |
case KErrCorrupt:
|
|
1543 |
// A pop up error note should be displayed if import is requested,
|
|
1544 |
// else error will be displayed in main pane itself
|
|
1545 |
if (aRequestType == CTransaction::EImportOPML)
|
|
1546 |
{
|
|
1547 |
labelId = R_FEEDS_MALFORMED_FEED_ERROR;
|
|
1548 |
break;
|
|
1549 |
}
|
|
1550 |
case KErrNotSupported:
|
|
1551 |
case KErrTimedOut:
|
|
1552 |
case KErrBadName:
|
|
1553 |
return;
|
|
1554 |
|
|
1555 |
case -KErrNotSupported:
|
|
1556 |
// Show the special http not supported on WINSCW error
|
|
1557 |
TRAP_IGNORE(TBrowserDialogs::InfoNoteL(R_BROWSER_INFO_NOTE, R_FEEDS_HTTP_UNSUPPORTED_WINSCW));
|
|
1558 |
return;
|
|
1559 |
|
|
1560 |
case KErrAlreadyExists:
|
|
1561 |
labelId = R_FEEDS_NAME_ALREADY_IN_USE;
|
|
1562 |
break;
|
|
1563 |
|
|
1564 |
|
|
1565 |
case KErrArgument:
|
|
1566 |
// A pop up error note should be displayed if import is requested,
|
|
1567 |
// else error will be displayed in main pane itself
|
|
1568 |
if (aRequestType == CTransaction::EImportOPML)
|
|
1569 |
{
|
|
1570 |
labelId = R_FEEDS_MALFORMED_FEED_ERROR;
|
|
1571 |
break;
|
|
1572 |
}
|
|
1573 |
|
|
1574 |
case KErrNotFound:
|
|
1575 |
// A pop up error note should be displayed if import is requested,
|
|
1576 |
// else will be handled in default case.
|
|
1577 |
if (aRequestType == CTransaction::EImportOPML)
|
|
1578 |
{
|
|
1579 |
labelId = R_FEEDS_FILE_NOT_FOUND_ERROR;
|
|
1580 |
break;
|
|
1581 |
}
|
|
1582 |
default:
|
|
1583 |
if (aStatus > 0) // All network errors
|
|
1584 |
{
|
|
1585 |
// Error will shown in listbox main pane
|
|
1586 |
return;
|
|
1587 |
}
|
|
1588 |
|
|
1589 |
// Otherwise.
|
|
1590 |
else
|
|
1591 |
{
|
|
1592 |
labelId = R_FEEDS_GENERAL_ERROR;
|
|
1593 |
}
|
|
1594 |
break;
|
|
1595 |
}
|
|
1596 |
|
|
1597 |
// Show the error dialog.
|
|
1598 |
if (aStatus != KErrCancel)
|
|
1599 |
{
|
|
1600 |
TRAP_IGNORE(TBrowserDialogs::InfoNoteL(R_BROWSER_INFO_NOTE, labelId));
|
|
1601 |
}
|
|
1602 |
}
|
|
1603 |
|
|
1604 |
|
|
1605 |
// -----------------------------------------------------------------------------
|
|
1606 |
// CFeedsClientUtilities::ConnectToServerL
|
|
1607 |
//
|
|
1608 |
// Connect to the server.
|
|
1609 |
// -----------------------------------------------------------------------------
|
|
1610 |
//
|
|
1611 |
void CFeedsClientUtilities::ConnectToServerL(TBool aGetRootFolder)
|
|
1612 |
{
|
|
1613 |
if (!iIsConnected)
|
|
1614 |
{
|
|
1615 |
User::LeaveIfError(iFeedsInterface.Connect());
|
|
1616 |
iIsConnected = ETrue;
|
|
1617 |
}
|
|
1618 |
|
|
1619 |
if (aGetRootFolder)
|
|
1620 |
{
|
|
1621 |
// Set this to no-view so the folder view isn't shown after it's fetched.
|
|
1622 |
iNextViewId = KUidBrowserNullViewId;
|
|
1623 |
|
|
1624 |
FetchRootFolderL();
|
|
1625 |
}
|
|
1626 |
}
|
|
1627 |
|
|
1628 |
|
|
1629 |
// -----------------------------------------------------------------------------
|
|
1630 |
// CFeedsClientUtilities::DisconnectFromServer
|
|
1631 |
//
|
|
1632 |
// Disconnect from the server.
|
|
1633 |
// -----------------------------------------------------------------------------
|
|
1634 |
//
|
|
1635 |
void CFeedsClientUtilities::DisconnectFromServer()
|
|
1636 |
{
|
|
1637 |
if( !iIsConnected )
|
|
1638 |
{
|
|
1639 |
//Nothing connected, return, this is causing crash.
|
|
1640 |
return;
|
|
1641 |
}
|
|
1642 |
iFeedsInterface.Close();
|
|
1643 |
|
|
1644 |
iIsConnected = EFalse;
|
|
1645 |
}
|
|
1646 |
|
|
1647 |
|
|
1648 |
// -----------------------------------------------------------------------------
|
|
1649 |
// CFeedsClientUtilities::FeedUpdatedTime
|
|
1650 |
//
|
|
1651 |
// Since the folder list isn't updated after it is fetched the FeedsClientUtilities
|
|
1652 |
// tracks the last update times for feeds the user visits in the current session.
|
|
1653 |
// This method returns the "last updated" timestamp of the given item.
|
|
1654 |
// -----------------------------------------------------------------------------
|
|
1655 |
//
|
|
1656 |
TTime CFeedsClientUtilities::FeedUpdatedTime(const CFeedsEntity& aItem)
|
|
1657 |
{
|
|
1658 |
TTime timestamp;
|
|
1659 |
TInt pos;
|
|
1660 |
|
|
1661 |
|
|
1662 |
// Search the cache for the feed's url.
|
|
1663 |
if ((pos = iFeedUpdateTimeIds.Find(aItem.GetId())) != KErrNotFound)
|
|
1664 |
{
|
|
1665 |
timestamp = iFeedUpdateTimeTimestamps[pos];
|
|
1666 |
}
|
|
1667 |
|
|
1668 |
// Otherwise return the item's timestamp.
|
|
1669 |
else
|
|
1670 |
{
|
|
1671 |
aItem.GetTimeValue(EFeedAttributeTimestamp,timestamp);
|
|
1672 |
}
|
|
1673 |
|
|
1674 |
// Return the cached value.
|
|
1675 |
return timestamp;
|
|
1676 |
}
|
|
1677 |
|
|
1678 |
|
|
1679 |
// -----------------------------------------------------------------------------
|
|
1680 |
// CFeedsClientUtilities::ResetFeedUpdateTime
|
|
1681 |
//
|
|
1682 |
// Resets the "last updated" cache.
|
|
1683 |
// -----------------------------------------------------------------------------
|
|
1684 |
//
|
|
1685 |
void CFeedsClientUtilities::ResetFeedUpdateTime()
|
|
1686 |
{
|
|
1687 |
// Reset the arrays.
|
|
1688 |
iFeedUpdateTimeIds.Reset();
|
|
1689 |
iFeedUpdateTimeTimestamps.Reset();
|
|
1690 |
}
|
|
1691 |
|
|
1692 |
|
|
1693 |
// -----------------------------------------------------------------------------
|
|
1694 |
// CFeedsClientUtilities::UpdateFeedUpdatedTimeL
|
|
1695 |
//
|
|
1696 |
// Update the feed's "last updated" value in the cache.
|
|
1697 |
// -----------------------------------------------------------------------------
|
|
1698 |
//
|
|
1699 |
void CFeedsClientUtilities::UpdateFeedUpdatedTimeL(const CFeedsEntity& aFeed)
|
|
1700 |
{
|
|
1701 |
TInt pos;
|
|
1702 |
TInt err;
|
|
1703 |
|
|
1704 |
// TODO: Use the feed's id instead of the url. This would require the
|
|
1705 |
// packed folder to store the feed id as well.
|
|
1706 |
|
|
1707 |
// Search the cache for the feed's url and if found then update the timestamp.
|
|
1708 |
if ((pos = iFeedUpdateTimeIds.Find(aFeed.GetId())) != KErrNotFound)
|
|
1709 |
{
|
|
1710 |
TTime time;
|
|
1711 |
aFeed.GetTimeValue(EFeedAttributeTimestamp,time);
|
|
1712 |
iFeedUpdateTimeTimestamps[pos] = time;
|
|
1713 |
}
|
|
1714 |
|
|
1715 |
// Otherwise add a new slot.
|
|
1716 |
else
|
|
1717 |
{
|
|
1718 |
User::LeaveIfError(iFeedUpdateTimeIds.Append(aFeed.GetId()));
|
|
1719 |
TTime time;
|
|
1720 |
aFeed.GetTimeValue(EFeedAttributeTimestamp,time);
|
|
1721 |
|
|
1722 |
err = iFeedUpdateTimeTimestamps.Append(time);
|
|
1723 |
|
|
1724 |
// Ensure the arrays don't get out of sync if the second append fails.
|
|
1725 |
if (err != KErrNone)
|
|
1726 |
{
|
|
1727 |
iFeedUpdateTimeIds.Remove(iFeedUpdateTimeIds.Count() - 1);
|
|
1728 |
User::LeaveIfError(err);
|
|
1729 |
}
|
|
1730 |
}
|
|
1731 |
}
|
|
1732 |
|
|
1733 |
|
|
1734 |
// -----------------------------------------------------------------------------
|
|
1735 |
// CFeedsClientUtilities::InitMenuItemL()
|
|
1736 |
// -----------------------------------------------------------------------------
|
|
1737 |
//
|
|
1738 |
void CFeedsClientUtilities::InitMenuItemL( CEikMenuPane* aMenuPane,
|
|
1739 |
TInt aCommandId,
|
|
1740 |
TInt aResourceId,
|
|
1741 |
TInt aCascadeId,
|
|
1742 |
TInt aFlags )
|
|
1743 |
{
|
|
1744 |
CEikMenuPaneItem::SData item;
|
|
1745 |
item.iCommandId = aCommandId;
|
|
1746 |
item.iFlags = aFlags;
|
|
1747 |
item.iCascadeId = aCascadeId;
|
|
1748 |
HBufC* buf = StringLoader::LoadLC( aResourceId );
|
|
1749 |
item.iText.Copy( *buf );
|
|
1750 |
CleanupStack::PopAndDestroy( buf ); // buf
|
|
1751 |
buf = NULL;
|
|
1752 |
|
|
1753 |
aMenuPane->AddMenuItemL( item );
|
|
1754 |
}
|
|
1755 |
|
|
1756 |
// -----------------------------------------------------------------------------
|
|
1757 |
// CFeedsClientUtilities::SendOPMLFileL()
|
|
1758 |
// -----------------------------------------------------------------------------
|
|
1759 |
//
|
|
1760 |
void CFeedsClientUtilities::SendOPMLFileL( )
|
|
1761 |
{
|
|
1762 |
RFs rfs;
|
|
1763 |
|
|
1764 |
_LIT(KPath, "C:\\system\\temp\\");
|
|
1765 |
TBuf<KMaxFileName> path(KPath);
|
|
1766 |
|
|
1767 |
User::LeaveIfError(rfs.Connect());
|
|
1768 |
CleanupClosePushL(rfs);
|
|
1769 |
|
|
1770 |
path.Append(*iExportFileName);
|
|
1771 |
|
|
1772 |
MBmOTABinSender& sender = iApiProvider.BmOTABinSenderL();
|
|
1773 |
|
|
1774 |
sender.ResetAndDestroy();
|
|
1775 |
sender.SendOPMLFileL(path);
|
|
1776 |
|
|
1777 |
CleanupStack::PopAndDestroy(/*rfs*/);
|
|
1778 |
}
|
|
1779 |
|
|
1780 |
// -----------------------------------------------------------------------------
|
|
1781 |
// CFeedsClientUtilities::HandleCommandL()
|
|
1782 |
// -----------------------------------------------------------------------------
|
|
1783 |
//
|
|
1784 |
void CFeedsClientUtilities::HandleCommandL( TUid aViewId, TInt aCommand )
|
|
1785 |
{
|
|
1786 |
switch (aCommand)
|
|
1787 |
{
|
|
1788 |
case EWmlCmdBackToPage:
|
|
1789 |
{
|
|
1790 |
iApiProvider.SetViewToReturnOnClose( aViewId );
|
|
1791 |
iApiProvider.SetViewToBeActivatedIfNeededL( KUidBrowserContentViewId );
|
|
1792 |
break;
|
|
1793 |
}
|
|
1794 |
|
|
1795 |
case EFeedsImport:
|
|
1796 |
ImportFeedsL();
|
|
1797 |
break;
|
|
1798 |
|
|
1799 |
default:
|
|
1800 |
// pass common commands to app ui
|
|
1801 |
iAppUI.HandleCommandL( aCommand );
|
|
1802 |
}
|
|
1803 |
}
|
|
1804 |
|
|
1805 |
// -----------------------------------------------------------------------------
|
|
1806 |
// CFeedsClientUtilities::DynInitMenuPaneL()
|
|
1807 |
// -----------------------------------------------------------------------------
|
|
1808 |
//
|
|
1809 |
void CFeedsClientUtilities::DynInitMenuPaneL(
|
|
1810 |
TInt aResourceId,
|
|
1811 |
CEikMenuPane* aMenuPane )
|
|
1812 |
{
|
|
1813 |
|
|
1814 |
// Option menu items common to all three feeds views
|
|
1815 |
if ((aResourceId == R_FEEDS_FOLDER_VIEW_MENU) ||
|
|
1816 |
(aResourceId == R_FEEDS_FEED_VIEW_MENU) ||
|
|
1817 |
(aResourceId == R_FEEDS_TOPIC_VIEW_MENU))
|
|
1818 |
{
|
|
1819 |
// browser prefs
|
|
1820 |
InitMenuItemL( aMenuPane, EWmlCmdPreferences, R_WMLBROWSER_SETTINGS_TITLE );
|
|
1821 |
|
|
1822 |
// Help
|
|
1823 |
InitMenuItemL( aMenuPane, EAknCmdHelp, R_BROWSER_MENU_ITEM_HELP, R_FEEDS_HELP_SUBMENU );
|
|
1824 |
|
|
1825 |
// exit
|
|
1826 |
InitMenuItemL( aMenuPane, EWmlCmdUserExit, R_BROWSER_MENU_ITEM_EXIT );
|
|
1827 |
}
|
|
1828 |
}
|
|
1829 |
|
|
1830 |
// -----------------------------------------------------------------------------
|
|
1831 |
// CFeedsClientUtilities::SetCalledFromView()
|
|
1832 |
// -----------------------------------------------------------------------------
|
|
1833 |
//
|
|
1834 |
void CFeedsClientUtilities::SetCalledFromView(TUid aViewId)
|
|
1835 |
{
|
|
1836 |
iCalledFromView = aViewId;
|
|
1837 |
}
|
|
1838 |
|
|
1839 |
// -----------------------------------------------------------------------------
|
|
1840 |
// CFeedsClientUtilities::CalledFromView()
|
|
1841 |
// -----------------------------------------------------------------------------
|
|
1842 |
//
|
|
1843 |
TUid CFeedsClientUtilities::CalledFromView()
|
|
1844 |
{
|
|
1845 |
return iCalledFromView;
|
|
1846 |
}
|
|
1847 |
|
|
1848 |
// -----------------------------------------------------------------------------
|
|
1849 |
// CFeedsClientUtilities::ItemStatusL
|
|
1850 |
//
|
|
1851 |
// Returns the INITIAL status of each of the items in the feed.
|
|
1852 |
// The caller can then modify the values and call UpdateFeedItemStatusL
|
|
1853 |
// to request the feeds server to update the feed's item status.
|
|
1854 |
// -----------------------------------------------------------------------------
|
|
1855 |
//
|
|
1856 |
void CFeedsClientUtilities::ItemStatusL(RArray<TInt>& aItemIds,
|
|
1857 |
RArray<TFeedItemStatus>& aItemStatus, const CFeedsEntity& aFeed) const
|
|
1858 |
{
|
|
1859 |
TInt status;
|
|
1860 |
|
|
1861 |
aItemIds.Reset();
|
|
1862 |
aItemStatus.Reset();
|
|
1863 |
|
|
1864 |
for(TInt index=0 ; index< aFeed.GetChildren().Count() ; index++)
|
|
1865 |
{
|
|
1866 |
CFeedsEntity *feedEntity = aFeed.GetChildren()[index];
|
|
1867 |
|
|
1868 |
feedEntity->GetIntegerValue(EItemAttributeStatus,status);
|
|
1869 |
|
|
1870 |
User::LeaveIfError(aItemIds.Append(feedEntity->GetId()));
|
|
1871 |
User::LeaveIfError(aItemStatus.Append((TFeedItemStatus)status));
|
|
1872 |
}
|
|
1873 |
}
|