65
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: A view to browse a given feed.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknNavi.h>
|
|
20 |
#include <AknNaviDe.h>
|
|
21 |
#include <AknTabGrp.h>
|
|
22 |
#include <AknNaviLabel.h>
|
|
23 |
#include <aknutils.h>
|
|
24 |
#include <AknViewAppUi.h>
|
|
25 |
#include <brctlinterface.h>
|
|
26 |
#include <CharConv.H>
|
|
27 |
#include <StringLoader.h>
|
|
28 |
#include <AknToolbar.h>
|
|
29 |
#ifdef __SERIES60_HELP
|
|
30 |
// Context-Sensitve Help File
|
|
31 |
#include <csxhelp/browser.hlp.hrh>
|
|
32 |
#include "BrowserApplication.h"
|
|
33 |
#endif // __SERIES60_HELP
|
|
34 |
|
|
35 |
#include "Browser.hrh"
|
|
36 |
#include <BrowserNG.rsg>
|
|
37 |
#include "FeedsFeedContainer.h"
|
|
38 |
#include "FeedsFeedView.h"
|
|
39 |
#include <xmlencoding.h>
|
|
40 |
#include "ApiProvider.h"
|
|
41 |
#include "BrowserSpecialLoadObserver.h"
|
|
42 |
#include "Display.h"
|
|
43 |
#include "BrowserWindowManager.h"
|
|
44 |
#include "BrowserWindow.h"
|
|
45 |
#include "BrowserAppUi.h"
|
|
46 |
#include <feedattributes.h>
|
|
47 |
#include <folderattributes.h>
|
|
48 |
#include <feedsentity.h>
|
|
49 |
#include <BidiText.h>
|
|
50 |
|
|
51 |
#include "eikon.hrh"
|
|
52 |
|
|
53 |
|
|
54 |
_LIT(KFeedsSchema, "feeds:");
|
|
55 |
_LIT(KFeedsNavSchema, "feedsnav:");
|
|
56 |
_LIT(KNext, "next");
|
|
57 |
_LIT(KTemplate, "feeds_view_template.html");
|
|
58 |
_LIT(KTokenTitle, "#Title#");
|
|
59 |
_LIT(KTokenWebUrl, "#WebUrl#");
|
|
60 |
_LIT(KTokenDate, "#Date#");
|
|
61 |
_LIT(KTokenDescription, "#Description#");
|
|
62 |
_LIT(KTokenEnclosure, "#Enclosure#");
|
|
63 |
_LIT(KTokenShowPrev, "#ShowPrev#");
|
|
64 |
_LIT(KTokenShowNext, "#ShowNext#");
|
|
65 |
_LIT(KTokenTextDir, "#dir#");
|
|
66 |
_LIT(KLTRTextDir, "\"ltr\"");
|
|
67 |
_LIT(KRTLTextDir, "\"rtl\"");
|
|
68 |
|
|
69 |
const TInt KDateSize = 30; // Size of Date strings
|
|
70 |
const TInt KTimeSize = 30; // Size of Time strings
|
|
71 |
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CFeedsFeedContainer::NewL
|
|
75 |
//
|
|
76 |
// Two-phased constructor.
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
CFeedsFeedContainer* CFeedsFeedContainer::NewL(CFeedsFeedView* aView,
|
|
80 |
MApiProvider& aApiProvider)
|
|
81 |
{
|
|
82 |
CFeedsFeedContainer* self = new (ELeave) CFeedsFeedContainer(aView, aApiProvider);
|
|
83 |
|
|
84 |
CleanupStack::PushL(self);
|
|
85 |
self->ConstructL();
|
|
86 |
CleanupStack::Pop();
|
|
87 |
|
|
88 |
return self;
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// CFeedsFeedContainer::CFeedsFeedContainer
|
|
94 |
//
|
|
95 |
// C++ default constructor.
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
CFeedsFeedContainer::CFeedsFeedContainer(CFeedsFeedView* aView,
|
|
99 |
MApiProvider& aApiProvider ) :
|
|
100 |
iView( aView ),
|
|
101 |
iApiProvider( aApiProvider ),
|
|
102 |
iBrowserControl(0)
|
|
103 |
{
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
// CFeedsFeedContainer::ConstructL
|
|
109 |
//
|
|
110 |
// Symbian 2nd phase constructor can leave.
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CFeedsFeedContainer::ConstructL()
|
|
114 |
{
|
|
115 |
EnsureTemplateL(KTemplate);
|
|
116 |
LoadTemplateL(KTemplate);
|
|
117 |
|
|
118 |
CreateWindowL();
|
|
119 |
SetMopParent( iView );
|
|
120 |
//SetRect(aRect);
|
|
121 |
ActivateL();
|
|
122 |
|
|
123 |
TRect rect(Position(), Size());
|
|
124 |
|
|
125 |
iBrowserControl = CreateBrowserControlL(this, rect,
|
|
126 |
TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw,
|
|
127 |
TBrCtlDefs::ECommandIdBase, NULL, NULL, this, NULL, NULL, NULL, NULL);
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
// CFeedsFeedContainer::~CFeedsFeedContainer
|
|
133 |
//
|
|
134 |
// Deconstructor.
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
CFeedsFeedContainer::~CFeedsFeedContainer()
|
|
138 |
{
|
|
139 |
delete iTemplate;
|
|
140 |
delete iNaviPaneTabsGroup;
|
|
141 |
delete iBrowserControl;
|
|
142 |
}
|
|
143 |
|
|
144 |
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
// CFeedsFeedContainer::OfferKeyEventL
|
|
147 |
//
|
|
148 |
// Handles key event.
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
TKeyResponse CFeedsFeedContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
152 |
{
|
|
153 |
|
|
154 |
TKeyResponse response = EKeyWasConsumed;
|
|
155 |
|
|
156 |
if (aType == EEventKey)
|
|
157 |
{
|
|
158 |
switch (aKeyEvent.iCode)
|
|
159 |
{
|
|
160 |
case EKeyLeftUpArrow: // Northwest
|
|
161 |
case EStdKeyDevice10: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
162 |
case EKeyLeftArrow: // West
|
|
163 |
case EKeyLeftDownArrow: // Southwest
|
|
164 |
case EStdKeyDevice13: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
165 |
{
|
|
166 |
ShowPrevItemL();
|
|
167 |
}
|
|
168 |
return response;
|
|
169 |
|
|
170 |
case EKeyRightUpArrow: // Northeast
|
|
171 |
case EStdKeyDevice11: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
172 |
case EKeyRightArrow: // East
|
|
173 |
case EKeyRightDownArrow: // Southeast
|
|
174 |
case EStdKeyDevice12: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
175 |
{
|
|
176 |
ShowNextItemL();
|
|
177 |
}
|
|
178 |
return response;
|
|
179 |
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
response = iBrowserControl->OfferKeyEventL(aKeyEvent, aType);
|
|
184 |
if(iBrowserControl->FocusedElementType() != TBrCtlDefs::EElementAnchor && iView->Toolbar() )
|
|
185 |
{
|
|
186 |
iView->Toolbar()->SetItemDimmed(EFeedsSeeFullStory, ETrue, ETrue);
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
|
190 |
iView->Toolbar()->SetItemDimmed(EFeedsSeeFullStory, EFalse, ETrue);
|
|
191 |
}
|
|
192 |
// now "simulate" another key event for proper handling of middle-softkey
|
|
193 |
if ( (aKeyEvent.iScanCode == EStdKeyDevice3) && (aType == EEventKeyDown) )
|
|
194 |
{
|
|
195 |
TKeyEvent keyEvent;
|
|
196 |
keyEvent.iCode = 0xf845;
|
|
197 |
keyEvent.iModifiers = 1;
|
|
198 |
keyEvent.iRepeats = 0;
|
|
199 |
keyEvent.iCode = EKeyDevice3;
|
|
200 |
keyEvent.iScanCode = EStdKeyDevice3;
|
|
201 |
response = iBrowserControl->OfferKeyEventL( keyEvent, EEventKey );
|
|
202 |
}
|
|
203 |
return response;
|
|
204 |
}
|
|
205 |
|
|
206 |
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
// CFeedsFeedContainer::GetHelpContext
|
|
209 |
//
|
|
210 |
// Get help context for the control.
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
#ifdef __SERIES60_HELP
|
|
214 |
void CFeedsFeedContainer::GetHelpContext(TCoeHelpContext& aContext) const
|
|
215 |
{
|
|
216 |
// This must be the Browser's uid becasue the help texts are under Browser topics.
|
|
217 |
aContext.iMajor = KUidBrowserApplication;
|
|
218 |
aContext.iContext = KOSS_HLP_RSS_ARTICLE;
|
|
219 |
}
|
|
220 |
#endif // __SERIES60_HELP
|
|
221 |
|
|
222 |
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
// CFeedsFeedContainer::MakeVisible
|
|
225 |
//
|
|
226 |
// Sets this control as visible or invisible.
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void CFeedsFeedContainer::MakeVisible(TBool aVisible)
|
|
230 |
{
|
|
231 |
if (iBrowserControl)
|
|
232 |
{
|
|
233 |
iBrowserControl->MakeVisible(aVisible);
|
|
234 |
}
|
|
235 |
|
|
236 |
CCoeControl::MakeVisible(aVisible);
|
|
237 |
}
|
|
238 |
|
|
239 |
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
// CFeedsFeedContainer::SizeChanged
|
|
242 |
//
|
|
243 |
// Called by framework when the view size is changed.
|
|
244 |
// -----------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CFeedsFeedContainer::SizeChanged()
|
|
247 |
{
|
|
248 |
if (iBrowserControl)
|
|
249 |
{
|
|
250 |
iBrowserControl->SetRect(Rect());
|
|
251 |
}
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
// CFeedsFeedContainer::HandleResourceChange
|
|
257 |
//
|
|
258 |
// Called by the framework when a display resource changes (i.e. skin or layout).
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
void CFeedsFeedContainer::HandleResourceChange(TInt aType)
|
|
262 |
{
|
|
263 |
CCoeControl::HandleResourceChange(aType);
|
|
264 |
iBrowserControl->HandleResourceChange(aType);
|
|
265 |
|
|
266 |
if (aType == KEikDynamicLayoutVariantSwitch)
|
|
267 |
{
|
|
268 |
TRect rect;
|
|
269 |
|
|
270 |
if (AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect))
|
|
271 |
{
|
|
272 |
SetRect(rect);
|
|
273 |
}
|
|
274 |
}
|
|
275 |
}
|
|
276 |
|
|
277 |
|
|
278 |
// -----------------------------------------------------------------------------
|
|
279 |
// CFeedsFeedContainer::CountComponentControls
|
|
280 |
//
|
|
281 |
// Returns number of components.
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
TInt CFeedsFeedContainer::CountComponentControls() const
|
|
285 |
{
|
|
286 |
TInt ctrls = 0;
|
|
287 |
if ( iBrowserControl )
|
|
288 |
{
|
|
289 |
ctrls++;// Brctl
|
|
290 |
}
|
|
291 |
return ctrls;
|
|
292 |
}
|
|
293 |
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
// CFeedsFeedContainer::NetworkConnectionNeededL
|
|
296 |
//
|
|
297 |
// Request to create a network connection.
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
void CFeedsFeedContainer::NetworkConnectionNeededL(TInt* aConnectionPtr,
|
|
301 |
TInt* aSockSvrHandle, TBool* aNewConn, TApBearerType* aBearerType)
|
|
302 |
{
|
|
303 |
iApiProvider.SpecialLoadObserver().NetworkConnectionNeededL(aConnectionPtr, aSockSvrHandle,
|
|
304 |
aNewConn, aBearerType);
|
|
305 |
}
|
|
306 |
|
|
307 |
|
|
308 |
// -----------------------------------------------------------------------------
|
|
309 |
// CFeedsFeedContainer::HandleRequestL
|
|
310 |
//
|
|
311 |
// Request the host applicaion to handle non-http request.
|
|
312 |
// -----------------------------------------------------------------------------
|
|
313 |
//
|
|
314 |
TBool CFeedsFeedContainer::HandleRequestL(RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray)
|
|
315 |
{
|
|
316 |
HBufC* url = NULL;
|
|
317 |
TBool handled = ETrue;
|
|
318 |
|
|
319 |
// The 2 arrays must be in sync. Each element in iTypeArray
|
|
320 |
// identifies the type of the corresponding element in iDesArray.
|
|
321 |
if (aTypeArray->Count() != aDesArray->Count())
|
|
322 |
{
|
|
323 |
User::Leave(KErrArgument);
|
|
324 |
}
|
|
325 |
|
|
326 |
// Get the url.
|
|
327 |
for (TInt i = 0; i < aTypeArray->Count(); i++)
|
|
328 |
{
|
|
329 |
if ((*aTypeArray)[i] == EParamRequestUrl)
|
|
330 |
{
|
|
331 |
url = HBufC::NewLC((*aDesArray)[i].Length());
|
|
332 |
url->Des().Copy((*aDesArray)[i]);
|
|
333 |
break;
|
|
334 |
}
|
|
335 |
}
|
|
336 |
|
|
337 |
// Leave if the url wasn't found.
|
|
338 |
if (url == NULL)
|
|
339 |
{
|
|
340 |
User::Leave(KErrArgument);
|
|
341 |
}
|
|
342 |
|
|
343 |
// Handle the "feeds:" schema
|
|
344 |
if (url->Find(KFeedsSchema) == 0)
|
|
345 |
{
|
|
346 |
// Extract the real url from the "feed" url.
|
|
347 |
TPtrC loadUrl(url->Ptr() + KFeedsSchema().Length(),
|
|
348 |
url->Length() - KFeedsSchema().Length());
|
|
349 |
|
|
350 |
// Handle the "feeds_nav:" schema.
|
|
351 |
if (loadUrl.Find(KFeedsNavSchema) == 0)
|
|
352 |
{
|
|
353 |
// Get the direction
|
|
354 |
TPtrC dir(loadUrl.Ptr() + KFeedsNavSchema().Length(),
|
|
355 |
loadUrl.Length() - KFeedsNavSchema().Length());
|
|
356 |
|
|
357 |
if (dir.FindF(KNext) == 0)
|
|
358 |
{
|
|
359 |
ShowNextItemL();
|
|
360 |
}
|
|
361 |
else
|
|
362 |
{
|
|
363 |
ShowPrevItemL();
|
|
364 |
}
|
|
365 |
}
|
|
366 |
else
|
|
367 |
{
|
|
368 |
// Otherwise dispatch the url to the client.
|
|
369 |
iApiProvider.FeedsClientUtilities().LoadUrlL(loadUrl);
|
|
370 |
}
|
|
371 |
}
|
|
372 |
// Otherwise, send request to SchemeHandler through default BrCtlSpecialLoadObserver
|
|
373 |
else
|
|
374 |
{
|
|
375 |
handled = iApiProvider.SpecialLoadObserver().HandleRequestL( aTypeArray, aDesArray );
|
|
376 |
}
|
|
377 |
|
|
378 |
CleanupStack::PopAndDestroy(url);
|
|
379 |
return handled;
|
|
380 |
}
|
|
381 |
|
|
382 |
|
|
383 |
// -----------------------------------------------------------------------------
|
|
384 |
// CFeedsFeedContainer::HandleDownloadL
|
|
385 |
//
|
|
386 |
// Called when the browser control wants the host application (us) to handle
|
|
387 |
// downloaded content
|
|
388 |
// -----------------------------------------------------------------------------
|
|
389 |
//
|
|
390 |
TBool CFeedsFeedContainer::HandleDownloadL(RArray<TUint>* aTypeArray,
|
|
391 |
CDesCArrayFlat* aDesArray)
|
|
392 |
{
|
|
393 |
HBufC* url = NULL;
|
|
394 |
TBool handled = EFalse;
|
|
395 |
|
|
396 |
//
|
|
397 |
// Pass first to the main special load observer to be handled.
|
|
398 |
// If it's not handled, continue here
|
|
399 |
//
|
|
400 |
handled = iApiProvider.SpecialLoadObserver().HandleDownloadL( aTypeArray, aDesArray );
|
|
401 |
|
|
402 |
if (!handled)
|
|
403 |
{
|
|
404 |
// The 2 arrays must be in sync. Each element in iTypeArray
|
|
405 |
// identifies the type of the corresponding element in iDesArray.
|
|
406 |
if (aTypeArray->Count() != aDesArray->Count())
|
|
407 |
{
|
|
408 |
User::Leave(KErrArgument);
|
|
409 |
}
|
|
410 |
|
|
411 |
// Get the url.
|
|
412 |
for (TInt i = 0; i < aTypeArray->Count(); i++)
|
|
413 |
{
|
|
414 |
if ((*aTypeArray)[i] == EParamRequestUrl)
|
|
415 |
{
|
|
416 |
url = HBufC::NewLC((*aDesArray)[i].Length());
|
|
417 |
url->Des().Copy((*aDesArray)[i]);
|
|
418 |
break;
|
|
419 |
}
|
|
420 |
}
|
|
421 |
|
|
422 |
TPtrC pUrl(url->Des());
|
|
423 |
|
|
424 |
// Leave if the url wasn't found.
|
|
425 |
if (url == NULL)
|
|
426 |
{
|
|
427 |
User::Leave(KErrArgument);
|
|
428 |
}
|
|
429 |
else
|
|
430 |
{
|
|
431 |
// Otherwise dispatch the url to the client.
|
|
432 |
iApiProvider.FeedsClientUtilities().SubscribeToL(KNullDesC, pUrl);
|
|
433 |
handled = ETrue;
|
|
434 |
}
|
|
435 |
|
|
436 |
CleanupStack::PopAndDestroy(url);
|
|
437 |
}
|
|
438 |
return handled;
|
|
439 |
}
|
|
440 |
|
|
441 |
// -----------------------------------------------------------------------------
|
|
442 |
// CFeedsFeedContainer::ComponentControl
|
|
443 |
//
|
|
444 |
// Returns pointer to particular component.
|
|
445 |
// -----------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
CCoeControl* CFeedsFeedContainer::ComponentControl(TInt aIndex) const
|
|
448 |
{
|
|
449 |
CCoeControl *ctrl = NULL;
|
|
450 |
|
|
451 |
switch (aIndex)
|
|
452 |
{
|
|
453 |
case 0:
|
|
454 |
{
|
|
455 |
ctrl = iBrowserControl;
|
|
456 |
break;
|
|
457 |
}
|
|
458 |
|
|
459 |
default:
|
|
460 |
break;
|
|
461 |
}
|
|
462 |
|
|
463 |
return ctrl;
|
|
464 |
}
|
|
465 |
|
|
466 |
|
|
467 |
// -----------------------------------------------------------------------------
|
|
468 |
// CFeedsFeedContainer::SetCurrentFeedL
|
|
469 |
//
|
|
470 |
// Sets the current feed
|
|
471 |
// -----------------------------------------------------------------------------
|
|
472 |
//
|
|
473 |
void CFeedsFeedContainer::SetCurrentFeedL(CFeedsEntity& aFeed, TInt aInitialItem)
|
|
474 |
{
|
|
475 |
iFeed = &aFeed;
|
|
476 |
iCurrentItem = aInitialItem;
|
|
477 |
|
|
478 |
// Update the view.
|
|
479 |
if (iView->iContainerOnStack)
|
|
480 |
{
|
|
481 |
// Only do this if it's view is active.
|
|
482 |
TPtrC title;
|
|
483 |
iFeed->GetStringValue(EFeedAttributeTitle,title);
|
|
484 |
if (title.Length() > 0)
|
|
485 |
{
|
|
486 |
iApiProvider.Display().SetTitleL( title );
|
|
487 |
}
|
|
488 |
else
|
|
489 |
{
|
|
490 |
iApiProvider.Display().SetTitleL( KNullDesC );
|
|
491 |
}
|
|
492 |
}
|
|
493 |
|
|
494 |
ShowFeedItemL();
|
|
495 |
}
|
|
496 |
|
|
497 |
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
// CFeedsFeedContainer::GetItemUrl
|
|
500 |
//
|
|
501 |
// Returns the current item's url.
|
|
502 |
// -----------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
const TDesC& CFeedsFeedContainer::GetItemUrl()
|
|
505 |
{
|
|
506 |
iFeed->GetChildren()[iCurrentItem]->GetStringValue(EItemAttributeLink,iUrl);
|
|
507 |
return iUrl;
|
|
508 |
}
|
|
509 |
|
|
510 |
|
|
511 |
// -----------------------------------------------------------------------------
|
|
512 |
// CFeedsFeedContainer::CurrentItem
|
|
513 |
//
|
|
514 |
// Returns the index of the current item.
|
|
515 |
// -----------------------------------------------------------------------------
|
|
516 |
//
|
|
517 |
TInt CFeedsFeedContainer::CurrentItem()
|
|
518 |
{
|
|
519 |
return iCurrentItem;
|
|
520 |
}
|
|
521 |
|
|
522 |
// -----------------------------------------------------------------------------
|
|
523 |
// CFeedsFeedContainer::ItemCount
|
|
524 |
//
|
|
525 |
// Returns the number of items.
|
|
526 |
// -----------------------------------------------------------------------------
|
|
527 |
TInt CFeedsFeedContainer::ItemCount() const
|
|
528 |
{
|
|
529 |
return iFeed->GetChildren().Count();
|
|
530 |
}
|
|
531 |
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
// CFeedsFeedContainer::ShowNextItemL
|
|
534 |
//
|
|
535 |
// Shows the next item if possible.
|
|
536 |
// -----------------------------------------------------------------------------
|
|
537 |
//
|
|
538 |
void CFeedsFeedContainer::ShowNextItemL()
|
|
539 |
{
|
|
540 |
if (iFeed->GetChildren().Count() <= 1)
|
|
541 |
{
|
|
542 |
return;
|
|
543 |
}
|
|
544 |
|
|
545 |
if ((iCurrentItem + 1) < iFeed->GetChildren().Count())
|
|
546 |
{
|
|
547 |
iCurrentItem++;
|
|
548 |
}
|
|
549 |
else
|
|
550 |
{
|
|
551 |
iCurrentItem = 0;
|
|
552 |
}
|
|
553 |
if (iView->Toolbar())
|
|
554 |
iView->Toolbar()->SetItemDimmed(EFeedsSeeFullStory, EFalse, ETrue);
|
|
555 |
ShowFeedItemL();
|
|
556 |
}
|
|
557 |
|
|
558 |
|
|
559 |
// -----------------------------------------------------------------------------
|
|
560 |
// CFeedsFeedContainer::ShowPrevItemL
|
|
561 |
//
|
|
562 |
// Shows the prev item if possible.
|
|
563 |
// -----------------------------------------------------------------------------
|
|
564 |
//
|
|
565 |
void CFeedsFeedContainer::ShowPrevItemL()
|
|
566 |
{
|
|
567 |
if (iFeed->GetChildren().Count() <= 1)
|
|
568 |
{
|
|
569 |
return;
|
|
570 |
}
|
|
571 |
|
|
572 |
if ((iCurrentItem - 1) >= 0)
|
|
573 |
{
|
|
574 |
iCurrentItem--;
|
|
575 |
}
|
|
576 |
else
|
|
577 |
{
|
|
578 |
iCurrentItem = iFeed->GetChildren().Count() - 1;
|
|
579 |
}
|
|
580 |
if (iView->Toolbar())
|
|
581 |
iView->Toolbar()->SetItemDimmed(EFeedsSeeFullStory, EFalse, ETrue);
|
|
582 |
ShowFeedItemL();
|
|
583 |
}
|
|
584 |
|
|
585 |
|
|
586 |
// -----------------------------------------------------------------------------
|
|
587 |
// CFeedsFeedContainer::Clear
|
|
588 |
//
|
|
589 |
// Clears the navigation pane.
|
|
590 |
// -----------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
void CFeedsFeedContainer::ClearNavigationPane()
|
|
593 |
{
|
|
594 |
delete iNaviPaneTabsGroup;
|
|
595 |
iNaviPaneTabsGroup = NULL;
|
|
596 |
}
|
|
597 |
|
|
598 |
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
// CFeedsFeedContainer::UpdateNavigationPaneL
|
|
601 |
//
|
|
602 |
// Handles the changes needed to the Navigation Pane.
|
|
603 |
// -----------------------------------------------------------------------------
|
|
604 |
//
|
|
605 |
void CFeedsFeedContainer::UpdateNavigationPaneL()
|
|
606 |
{
|
|
607 |
const TInt KTabId = 88888;
|
|
608 |
const TInt KMaxNaviText = 25; // format is "<int>/<int>".
|
|
609 |
_LIT(KFormat, "%d/%d");
|
|
610 |
|
|
611 |
CAknNavigationControlContainer* naviPane = NULL;
|
|
612 |
TBuf<KMaxNaviText> buf;
|
|
613 |
CAknTabGroup* tabGroup = NULL;
|
|
614 |
TInt itemCount = 0;
|
|
615 |
|
|
616 |
if (iFeed)
|
|
617 |
{
|
|
618 |
itemCount = iFeed->GetChildren().Count();
|
|
619 |
}
|
|
620 |
|
|
621 |
// Get the navigation sub-pane.
|
|
622 |
CAknViewAppUi* appUi;
|
|
623 |
TUid uid;
|
|
624 |
|
|
625 |
// Get the title sub-pane.
|
|
626 |
appUi = static_cast<CAknViewAppUi*>(CCoeEnv::Static()->AppUi());
|
|
627 |
|
|
628 |
uid.iUid = EEikStatusPaneUidNavi;
|
|
629 |
|
|
630 |
CEikStatusPaneBase::TPaneCapabilities subPane = appUi->StatusPane()->
|
|
631 |
PaneCapabilities(uid);
|
|
632 |
|
|
633 |
// Set the title if the pane belongs to the app.
|
|
634 |
if (subPane.IsPresent() && subPane.IsAppOwned())
|
|
635 |
{
|
|
636 |
naviPane = (CAknNavigationControlContainer*) appUi->StatusPane()->ControlL(uid);
|
|
637 |
}
|
|
638 |
else
|
|
639 |
{
|
|
640 |
User::Leave(KErrNotSupported);
|
|
641 |
}
|
|
642 |
|
|
643 |
// Ensure the tab group was created.
|
|
644 |
if (!iNaviPaneTabsGroup)
|
|
645 |
{
|
|
646 |
iNaviPaneTabsGroup = naviPane->CreateTabGroupL();
|
|
647 |
}
|
|
648 |
|
|
649 |
// Format Navi Pane text "index/count" style.
|
|
650 |
buf.Format(KFormat, iCurrentItem + 1, itemCount);
|
|
651 |
|
|
652 |
// Update the tab-group.
|
|
653 |
tabGroup = static_cast<CAknTabGroup*>(iNaviPaneTabsGroup->DecoratedControl());
|
|
654 |
|
|
655 |
// Already created, replacd the tab.
|
|
656 |
if (tabGroup->TabCount() != NULL)
|
|
657 |
{
|
|
658 |
tabGroup->ReplaceTabL(KTabId, buf);
|
|
659 |
}
|
|
660 |
|
|
661 |
// Otherwise add the tab.
|
|
662 |
else
|
|
663 |
{
|
|
664 |
tabGroup->AddTabL(KTabId, buf);
|
|
665 |
}
|
|
666 |
|
|
667 |
tabGroup->SetTabFixedWidthL(EAknTabWidthWithOneTab);
|
|
668 |
tabGroup->SetActiveTabById(KTabId);
|
|
669 |
|
|
670 |
// If not yet pushed, this will do the push; if already there, this brings
|
|
671 |
// it to top and draws.
|
|
672 |
naviPane->PushL(*iNaviPaneTabsGroup);
|
|
673 |
}
|
|
674 |
|
|
675 |
|
|
676 |
// -----------------------------------------------------------------------------
|
|
677 |
// CFeedsFeedContainer::ShowFeedItemL
|
|
678 |
//
|
|
679 |
// Shows the given feed item.
|
|
680 |
// -----------------------------------------------------------------------------
|
|
681 |
//
|
|
682 |
void CFeedsFeedContainer::ShowFeedItemL()
|
|
683 |
{
|
|
684 |
_LIT(KSchema, "data:");
|
|
685 |
_LIT8(KType, "text/html");
|
|
686 |
|
|
687 |
const TInt KInt64Length = 25;
|
|
688 |
|
|
689 |
HBufC* link = NULL;
|
|
690 |
HBufC* htmlTemplate = NULL;
|
|
691 |
HBufC* enclosureStr = NULL;
|
|
692 |
TDataType datatype(KType);
|
|
693 |
TUid uid;
|
|
694 |
CFeedsEntity* item = iFeed->GetChildren()[iCurrentItem];
|
|
695 |
HBufC* enclosure = NULL;
|
|
696 |
TInt enclosureLen = 0;
|
|
697 |
|
|
698 |
// Mark the item as read.
|
|
699 |
iApiProvider.FeedsClientUtilities().SetItemStatusL(iFeed->GetChildren()[iCurrentItem], EItemStatusRead);
|
|
700 |
|
|
701 |
// Load the localized strings.
|
|
702 |
enclosureStr = StringLoader::LoadLC(R_FEEDS_ENCLOSURE);
|
|
703 |
|
|
704 |
// Convert the item's UTC timestamp into a localized string.
|
|
705 |
TBuf<KDateSize + KTimeSize + 1> timestamp;
|
|
706 |
TBuf<KTimeSize> temp;
|
|
707 |
TTime ts;
|
|
708 |
|
|
709 |
item->GetTimeValue(EItemAttributeTimestamp,ts);
|
|
710 |
|
|
711 |
// Translate from UTC to local time.
|
|
712 |
TTime local;
|
|
713 |
TTime utc;
|
|
714 |
TTimeIntervalSeconds delta;
|
|
715 |
|
|
716 |
local.HomeTime();
|
|
717 |
utc.UniversalTime();
|
|
718 |
utc.SecondsFrom(local, delta);
|
|
719 |
ts -= delta;
|
|
720 |
|
|
721 |
// Create the localized time string.
|
|
722 |
//Set time
|
|
723 |
HBufC* timeFormat = iEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
|
|
724 |
ts.FormatL( timestamp, *timeFormat );
|
|
725 |
CleanupStack::PopAndDestroy( timeFormat );//timeFormat
|
|
726 |
//
|
|
727 |
timestamp.Append(_L(" "));
|
|
728 |
//Set date
|
|
729 |
HBufC* dateFormat = iEikonEnv->AllocReadResourceLC( R_QTN_DATE_USUAL_WITH_ZERO );
|
|
730 |
ts.FormatL( temp, *dateFormat );
|
|
731 |
CleanupStack::PopAndDestroy( dateFormat );//dateFormat
|
|
732 |
//
|
|
733 |
timestamp.Append(temp);
|
|
734 |
|
|
735 |
// Create the enclosure string, which is a a series of the following string.
|
|
736 |
// <div><a href="theUrl">Enclosure[theContentType]: theSize MB</a></div>
|
|
737 |
_LIT(KEnclosureMarkup, "<div><a href=\"%S\">%S[%S MB]: %S</a></div>");
|
|
738 |
|
|
739 |
TBuf16<KInt64Length> size;
|
|
740 |
TInt64 sizeInt;
|
|
741 |
TReal64 sizeReal;
|
|
742 |
TRealFormat format;
|
|
743 |
TPtrC url;
|
|
744 |
TPtrC contentType;
|
|
745 |
TPtrC len;
|
|
746 |
TPtrC title;
|
|
747 |
TPtrC desc;
|
|
748 |
|
|
749 |
format.iType = KRealFormatFixed;
|
|
750 |
format.iPlaces = 2;
|
|
751 |
|
|
752 |
// Determine how large the enclosure string needs to be.
|
|
753 |
for (TInt i = 0; i < item->GetChildren().Count(); i++)
|
|
754 |
{
|
|
755 |
CFeedsEntity* en = item->GetChildren()[i];
|
|
756 |
|
|
757 |
en->GetStringValue(EEnclosureAttributeContentType,contentType);
|
|
758 |
en->GetStringValue(EEnclosureAttributeSize,len);
|
|
759 |
en->GetStringValue(EEnclosureAttributeLink,url);
|
|
760 |
en->GetStringValue(EEnclosureAttributeTitle,title);
|
|
761 |
TLex16 lex(len);
|
|
762 |
// Convert the enclosure size to mega-bytes.
|
|
763 |
lex.Val(sizeInt);
|
|
764 |
sizeReal = sizeInt / 1000000.0;
|
|
765 |
|
|
766 |
size.Zero();
|
|
767 |
size.AppendNum(sizeReal, format);
|
|
768 |
|
|
769 |
enclosureLen += KEnclosureMarkup().Length();
|
|
770 |
enclosureLen += url.Length();
|
|
771 |
enclosureLen += enclosureStr->Length();
|
|
772 |
enclosureLen += size.Length();
|
|
773 |
enclosureLen += contentType.Length();
|
|
774 |
}
|
|
775 |
|
|
776 |
// Allocate the enclosure string.
|
|
777 |
enclosure = HBufC::NewLC(enclosureLen);
|
|
778 |
|
|
779 |
// Construct the enclosure string.
|
|
780 |
for (TInt i = 0; i < item->GetChildren().Count(); i++)
|
|
781 |
{
|
|
782 |
CFeedsEntity* en = item->GetChildren()[i];
|
|
783 |
|
|
784 |
en->GetStringValue(EEnclosureAttributeContentType,contentType);
|
|
785 |
en->GetStringValue(EEnclosureAttributeSize,len);
|
|
786 |
en->GetStringValue(EEnclosureAttributeLink,url);
|
|
787 |
en->GetStringValue(EEnclosureAttributeTitle,title);
|
|
788 |
TLex16 lex(len);
|
|
789 |
|
|
790 |
// Convert the enclosure size to mega-bytes.
|
|
791 |
lex.Val(sizeInt);
|
|
792 |
sizeReal = sizeInt / 1000000.0;
|
|
793 |
|
|
794 |
size.Zero();
|
|
795 |
size.AppendNum(sizeReal, format);
|
|
796 |
|
|
797 |
enclosure->Des().AppendFormat(KEnclosureMarkup, &(url), enclosureStr,
|
|
798 |
&size, &(contentType));
|
|
799 |
}
|
|
800 |
|
|
801 |
// Load and prepare the html template.
|
|
802 |
item->GetStringValue(EItemAttributeTitle,title);
|
|
803 |
item->GetStringValue(EItemAttributeDescription,desc);
|
|
804 |
item->GetStringValue(EItemAttributeLink,url);
|
|
805 |
|
|
806 |
htmlTemplate = ResolveTemplateL(title, timestamp, desc,
|
|
807 |
url, *enclosure);
|
|
808 |
|
|
809 |
|
|
810 |
CleanupStack::PushL(htmlTemplate);
|
|
811 |
iFeed->GetStringValue(EFeedAttributeTitle,title);
|
|
812 |
// Load the htmlTemplate in the browser control.
|
|
813 |
uid.iUid = KCharacterSetIdentifierUcs2;
|
|
814 |
|
|
815 |
link = HBufC::NewLC(KSchema().Length() + title.Length());
|
|
816 |
link->Des().Copy(KSchema);
|
|
817 |
link->Des().Append(title);
|
|
818 |
|
|
819 |
TPtrC8 ptr((const TUint8*) htmlTemplate->Ptr(), htmlTemplate->Size());
|
|
820 |
iBrowserControl->LoadDataL(*link, ptr, datatype, uid);
|
|
821 |
|
|
822 |
CleanupStack::PopAndDestroy(link);
|
|
823 |
CleanupStack::PopAndDestroy(htmlTemplate);
|
|
824 |
CleanupStack::PopAndDestroy(enclosure);
|
|
825 |
CleanupStack::PopAndDestroy(enclosureStr);
|
|
826 |
|
|
827 |
// Update the nav-pane.
|
|
828 |
UpdateNavigationPaneL();
|
|
829 |
}
|
|
830 |
|
|
831 |
|
|
832 |
// -----------------------------------------------------------------------------
|
|
833 |
// CFeedsFeedContainer::LoadTemplateL
|
|
834 |
//
|
|
835 |
// Loads the template html file.
|
|
836 |
// -----------------------------------------------------------------------------
|
|
837 |
//
|
|
838 |
void CFeedsFeedContainer::LoadTemplateL(const TDesC& aTemplateName)
|
|
839 |
{
|
|
840 |
RFs rfs;
|
|
841 |
RFile file;
|
|
842 |
TInt size;
|
|
843 |
TBuf<KMaxFileName> path;
|
|
844 |
TUint encoding;
|
|
845 |
HBufC8* buff;
|
|
846 |
CXmlEncoding* xmlEncoding = NULL;
|
|
847 |
TInt loc;
|
|
848 |
|
|
849 |
// Build the path to the file and open the file.
|
|
850 |
User::LeaveIfError(rfs.Connect());
|
|
851 |
CleanupClosePushL(rfs);
|
|
852 |
|
|
853 |
path.Append(_L("\\"));
|
|
854 |
path.Append(aTemplateName);
|
|
855 |
|
|
856 |
User::LeaveIfError(file.Open(rfs, path, EFileRead));
|
|
857 |
CleanupClosePushL(file);
|
|
858 |
|
|
859 |
// Read the file into the buffer.
|
|
860 |
User::LeaveIfError(file.Size(size));
|
|
861 |
|
|
862 |
buff = HBufC8::NewL(size);
|
|
863 |
CleanupStack::PushL(buff);
|
|
864 |
|
|
865 |
TPtr8 ptr((TUint8*) buff->Ptr(), size);
|
|
866 |
User::LeaveIfError(file.Read(ptr, size));
|
|
867 |
|
|
868 |
// Convert the buffer to ucs2 and clean up.
|
|
869 |
xmlEncoding = CXmlEncoding::NewL();
|
|
870 |
CleanupStack::PushL(xmlEncoding);
|
|
871 |
|
|
872 |
if (!xmlEncoding->DetermineCharEncodingL(ptr, KNullDesC, encoding))
|
|
873 |
{
|
|
874 |
User::Leave(KErrCorrupt);
|
|
875 |
}
|
|
876 |
|
|
877 |
iTemplate = xmlEncoding->ConvertToUcs2L(encoding, ptr);
|
|
878 |
|
|
879 |
CleanupStack::PopAndDestroy(xmlEncoding);
|
|
880 |
CleanupStack::PopAndDestroy(buff);
|
|
881 |
CleanupStack::PopAndDestroy(/*file*/);
|
|
882 |
CleanupStack::PopAndDestroy(/*rfs*/);
|
|
883 |
|
|
884 |
// Count the number of token. These counts are used in ResolveTemplate
|
|
885 |
// to determine how big the resolved buffer should be.
|
|
886 |
TPtrC findPtr;
|
|
887 |
|
|
888 |
iTitleCount = 0;
|
|
889 |
iWebUrlCount = 0;
|
|
890 |
iDateCount = 0;
|
|
891 |
iDescriptionCount = 0;
|
|
892 |
iEnclosureCount = 0;
|
|
893 |
iShowPrevCount = 0;
|
|
894 |
iShowNextCount = 0;
|
|
895 |
|
|
896 |
findPtr.Set(*iTemplate);
|
|
897 |
while ((loc = findPtr.Find(KTokenTitle())) != KErrNotFound)
|
|
898 |
{
|
|
899 |
findPtr.Set(findPtr.Mid(loc + KTokenTitle().Length()));
|
|
900 |
iTitleCount++;
|
|
901 |
}
|
|
902 |
|
|
903 |
findPtr.Set(*iTemplate);
|
|
904 |
while ((loc = findPtr.Find(KTokenWebUrl())) != KErrNotFound)
|
|
905 |
{
|
|
906 |
findPtr.Set(findPtr.Mid(loc + KTokenWebUrl().Length()));
|
|
907 |
iWebUrlCount++;
|
|
908 |
}
|
|
909 |
|
|
910 |
findPtr.Set(*iTemplate);
|
|
911 |
while ((loc = findPtr.Find(KTokenDate())) != KErrNotFound)
|
|
912 |
{
|
|
913 |
findPtr.Set(findPtr.Mid(loc + KTokenDate().Length()));
|
|
914 |
iDateCount++;
|
|
915 |
}
|
|
916 |
|
|
917 |
findPtr.Set(*iTemplate);
|
|
918 |
while ((loc = findPtr.Find(KTokenDescription())) != KErrNotFound)
|
|
919 |
{
|
|
920 |
findPtr.Set(findPtr.Mid(loc + KTokenDescription().Length()));
|
|
921 |
iDescriptionCount++;
|
|
922 |
}
|
|
923 |
|
|
924 |
findPtr.Set(*iTemplate);
|
|
925 |
while ((loc = findPtr.Find((KTokenEnclosure))) != KErrNotFound)
|
|
926 |
{
|
|
927 |
findPtr.Set(findPtr.Mid(loc + KTokenEnclosure().Length()));
|
|
928 |
iEnclosureCount++;
|
|
929 |
}
|
|
930 |
|
|
931 |
findPtr.Set(*iTemplate);
|
|
932 |
while ((loc = findPtr.Find((KTokenShowPrev))) != KErrNotFound)
|
|
933 |
{
|
|
934 |
findPtr.Set(findPtr.Mid(loc + KTokenShowPrev().Length()));
|
|
935 |
iShowPrevCount++;
|
|
936 |
}
|
|
937 |
|
|
938 |
findPtr.Set(*iTemplate);
|
|
939 |
while ((loc = findPtr.Find((KTokenShowNext))) != KErrNotFound)
|
|
940 |
{
|
|
941 |
findPtr.Set(findPtr.Mid(loc + KTokenShowNext().Length()));
|
|
942 |
iShowNextCount++;
|
|
943 |
}
|
|
944 |
}
|
|
945 |
|
|
946 |
|
|
947 |
// -----------------------------------------------------------------------------
|
|
948 |
// CFeedsFeedContainer::ResolveTemplateL
|
|
949 |
//
|
|
950 |
// Loads and resolves the tokens in the template html file.
|
|
951 |
// -----------------------------------------------------------------------------
|
|
952 |
//
|
|
953 |
HBufC* CFeedsFeedContainer::ResolveTemplateL(const TDesC& aTitle,
|
|
954 |
const TDesC& aTimestamp, const TDesC& aDescription, const TDesC& aUrl,
|
|
955 |
const TDesC& aEnclosure)
|
|
956 |
{
|
|
957 |
HBufC* ucs2Buff;
|
|
958 |
TInt loc;
|
|
959 |
|
|
960 |
// Create and init the resolved buffer.
|
|
961 |
ucs2Buff = HBufC::NewLC(iTemplate->Length() + (aTitle.Length() * iTitleCount) +
|
|
962 |
(aTimestamp.Length() * iDateCount) + (aDescription.Length() * iDescriptionCount) +
|
|
963 |
(aUrl.Length() * iWebUrlCount) +
|
|
964 |
(aEnclosure.Length() * iEnclosureCount) + iShowPrevCount + iShowNextCount);
|
|
965 |
|
|
966 |
ucs2Buff->Des().Copy(*iTemplate);
|
|
967 |
|
|
968 |
// Resolve the tokens.
|
|
969 |
TPtr ucs2Ptr(ucs2Buff->Des());
|
|
970 |
|
|
971 |
// Add the text direction information here
|
|
972 |
TBool found(EFalse);
|
|
973 |
TBidiText::TDirectionality dir = TBidiText::TextDirectionality(aTitle, &found);
|
|
974 |
TBuf<5> textDirection;
|
|
975 |
if ( dir == TBidiText::ERightToLeft )
|
|
976 |
{
|
|
977 |
textDirection.Copy(KRTLTextDir);
|
|
978 |
}
|
|
979 |
else
|
|
980 |
{
|
|
981 |
textDirection.Copy(KLTRTextDir);
|
|
982 |
}
|
|
983 |
|
|
984 |
// replace the text direction string
|
|
985 |
if ((loc = ucs2Ptr.Find(KTokenTextDir())) != KErrNotFound)
|
|
986 |
{
|
|
987 |
ucs2Ptr.Replace(loc, textDirection.Length(), textDirection);
|
|
988 |
}
|
|
989 |
|
|
990 |
// Replace the title tokens.
|
|
991 |
while ((loc = ucs2Ptr.Find(KTokenTitle())) != KErrNotFound)
|
|
992 |
{
|
|
993 |
ucs2Ptr.Replace(loc, KTokenTitle().Length(), aTitle);
|
|
994 |
}
|
|
995 |
|
|
996 |
// Replace the url tokens.
|
|
997 |
while ((loc = ucs2Ptr.Find(KTokenWebUrl())) != KErrNotFound)
|
|
998 |
{
|
|
999 |
ucs2Ptr.Replace(loc, KTokenWebUrl().Length(), aUrl);
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
// Replace the date tokens.
|
|
1003 |
while ((loc = ucs2Ptr.Find(KTokenDate())) != KErrNotFound)
|
|
1004 |
{
|
|
1005 |
ucs2Ptr.Replace(loc, KTokenDate().Length(), aTimestamp);
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
// Replace the description tokens.
|
|
1009 |
while ((loc = ucs2Ptr.Find(KTokenDescription())) != KErrNotFound)
|
|
1010 |
{
|
|
1011 |
ucs2Ptr.Replace(loc, KTokenDescription().Length(), aDescription);
|
|
1012 |
}
|
|
1013 |
|
|
1014 |
// Replace the enclosure tokens.
|
|
1015 |
while ((loc = ucs2Ptr.Find(KTokenEnclosure())) != KErrNotFound)
|
|
1016 |
{
|
|
1017 |
ucs2Ptr.Replace(loc, KTokenEnclosure().Length(), aEnclosure);
|
|
1018 |
}
|
|
1019 |
|
|
1020 |
CleanupStack::Pop(ucs2Buff);
|
|
1021 |
return ucs2Buff;
|
|
1022 |
}
|
|
1023 |
|
|
1024 |
|
|
1025 |
// -----------------------------------------------------------------------------
|
|
1026 |
// CFeedsFeedContainer::EnsureTemplateL
|
|
1027 |
//
|
|
1028 |
// If need be copy the template from ROM.
|
|
1029 |
// -----------------------------------------------------------------------------
|
|
1030 |
//
|
|
1031 |
void CFeedsFeedContainer::EnsureTemplateL(const TDesC& aName)
|
|
1032 |
{
|
|
1033 |
TInt err;
|
|
1034 |
RFs defaultRfs;
|
|
1035 |
TUint attValue = 0;
|
|
1036 |
TBuf<KMaxFileName> path;
|
|
1037 |
|
|
1038 |
// Open a connection to the working drive.
|
|
1039 |
User::LeaveIfError(defaultRfs.Connect());
|
|
1040 |
CleanupClosePushL(defaultRfs);
|
|
1041 |
User::LeaveIfError(defaultRfs.SetSessionPath(_L("c:\\")));
|
|
1042 |
|
|
1043 |
// Build the path to the file.
|
|
1044 |
path.Append(_L("\\"));
|
|
1045 |
path.Append(aName);
|
|
1046 |
|
|
1047 |
// Test whether or not the folder file is present.
|
|
1048 |
err = defaultRfs.Att(path, attValue);
|
|
1049 |
|
|
1050 |
// The file is there, just return.
|
|
1051 |
if (err == KErrNone)
|
|
1052 |
{
|
|
1053 |
CleanupStack::PopAndDestroy(/*defaultRfs*/);
|
|
1054 |
return;
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
// If the file is missing copy it from ROM.
|
|
1058 |
if ((err == KErrNotFound) || (err == KErrPathNotFound))
|
|
1059 |
{
|
|
1060 |
RFs romRfs;
|
|
1061 |
RFile file;
|
|
1062 |
RFile romFile;
|
|
1063 |
TInt size;
|
|
1064 |
HBufC8* buffer = NULL;
|
|
1065 |
|
|
1066 |
// Open an rfs for the z drive.
|
|
1067 |
User::LeaveIfError(romRfs.Connect());
|
|
1068 |
CleanupClosePushL(romRfs);
|
|
1069 |
User::LeaveIfError(romRfs.SetSessionPath(_L("z:\\")));
|
|
1070 |
|
|
1071 |
// Create the destination file.
|
|
1072 |
User::LeaveIfError(file.Create(defaultRfs, path, EFileWrite));
|
|
1073 |
CleanupClosePushL(file);
|
|
1074 |
|
|
1075 |
// Open the source file.
|
|
1076 |
User::LeaveIfError(romFile.Open(romRfs, path, EFileRead));
|
|
1077 |
CleanupClosePushL(romFile);
|
|
1078 |
|
|
1079 |
// Copy the file.
|
|
1080 |
User::LeaveIfError(romFile.Size(size));
|
|
1081 |
buffer = HBufC8::NewLC(size);
|
|
1082 |
TPtr8 bufferPtr(buffer->Des());
|
|
1083 |
|
|
1084 |
User::LeaveIfError(romFile.Read(bufferPtr, size));
|
|
1085 |
User::LeaveIfError(file.Write(bufferPtr, size));
|
|
1086 |
|
|
1087 |
// Clean up
|
|
1088 |
CleanupStack::PopAndDestroy(buffer);
|
|
1089 |
CleanupStack::PopAndDestroy(/*romFile*/);
|
|
1090 |
CleanupStack::PopAndDestroy(/*file*/);
|
|
1091 |
CleanupStack::PopAndDestroy(/*romRfs*/);
|
|
1092 |
CleanupStack::PopAndDestroy(/*defaultRfs*/);
|
|
1093 |
}
|
|
1094 |
}
|
|
1095 |
|
|
1096 |
// ---------------------------------------------------------
|
|
1097 |
// CFeedsFeedContainer::ExtractBrCtlParam()
|
|
1098 |
// ---------------------------------------------------------
|
|
1099 |
//
|
|
1100 |
TPtrC CFeedsFeedContainer::ExtractBrCtlParam
|
|
1101 |
( TUint aParamTypeToFind,
|
|
1102 |
RArray<TUint>* aTypeArray,
|
|
1103 |
CDesCArrayFlat* aDesArray,
|
|
1104 |
TBool& aParamFound ) const
|
|
1105 |
{
|
|
1106 |
// initialize output parameter
|
|
1107 |
aParamFound = EFalse;
|
|
1108 |
TPtrC16 retParamValue;
|
|
1109 |
|
|
1110 |
for ( TInt j = 0; j < aTypeArray->Count(); j++ )
|
|
1111 |
{
|
|
1112 |
const TUint paramType = (*aTypeArray)[j];
|
|
1113 |
if ( aParamTypeToFind == paramType )
|
|
1114 |
{
|
|
1115 |
// That's we need
|
|
1116 |
retParamValue.Set( aDesArray->MdcaPoint(j) );
|
|
1117 |
aParamFound = ETrue; // Indicate it in the out param
|
|
1118 |
break; // break the loop - we found it
|
|
1119 |
}
|
|
1120 |
}
|
|
1121 |
return retParamValue;
|
|
1122 |
}
|
|
1123 |
|
|
1124 |
void CFeedsFeedContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
1125 |
{
|
|
1126 |
iBrowserControl->HandlePointerEventL(aPointerEvent);
|
|
1127 |
if(iBrowserControl->FocusedElementType()!= TBrCtlDefs::EElementAnchor && iView->Toolbar() )
|
|
1128 |
{
|
|
1129 |
iView->Toolbar()->SetItemDimmed(EFeedsSeeFullStory, ETrue, ETrue);
|
|
1130 |
}
|
|
1131 |
}
|