1 /* |
|
2 * Copyright (c) 2004 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 "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: Container class for cost warning view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <txtrich.h> |
|
20 /* don't need to change it to lower case */ |
|
21 #include <AknsBasicBackgroundControlContext.h> // CAknsBasicBackgroundControlContext |
|
22 #include <eikedwin.h> |
|
23 #include <utf.h> |
|
24 #include <stringloader.h> |
|
25 |
|
26 |
|
27 #include <internetradio.rsg> |
|
28 #include "irui.h" |
|
29 #include "ir.hrh" |
|
30 #include "ircommon.h" |
|
31 #include "irdebug.h" |
|
32 #include "irbaseview.h" |
|
33 #include "ircostwarningview.h" |
|
34 #include "ircostwarningcontainer.h" |
|
35 #include "irapplication.h" |
|
36 #include "irnetworkcontroller.h" |
|
37 #include "irsettings.h" |
|
38 |
|
39 |
|
40 const TInt KNoOfLines = 50; |
|
41 const TInt KNoOfCharacters = 3000; |
|
42 const TInt KScrollbar = 15; |
|
43 //----------------------------------------------------------------------------- |
|
44 // CIRCostWarningContainer::NewL |
|
45 // Creates a new instance of CIRCostWarningContainer |
|
46 //----------------------------------------------------------------------------- |
|
47 // |
|
48 CIRCostWarningContainer* CIRCostWarningContainer::NewL(const TRect& aRect , |
|
49 CIRCostWarningView& aView) |
|
50 { |
|
51 IRLOG_DEBUG( "CIRCostWarningContainer::NewL - Entering" ); |
|
52 CIRCostWarningContainer* self = CIRCostWarningContainer::NewLC(aRect,aView); |
|
53 CleanupStack::Pop(self); |
|
54 IRLOG_DEBUG( "CIRCostWarningContainer::NewL - Exiting." ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 //----------------------------------------------------------------------------- |
|
59 // CIRCostWarningContainer::NewLC |
|
60 // Creates a new instance of CIRCostWarningContainer and leaves it on the cleanup stack. |
|
61 //----------------------------------------------------------------------------- |
|
62 // |
|
63 CIRCostWarningContainer* CIRCostWarningContainer::NewLC(const TRect& aRect , |
|
64 CIRCostWarningView& aView) |
|
65 { |
|
66 IRLOG_DEBUG( "CIRCostWarningContainer::NewLC - Entering" ); |
|
67 CIRCostWarningContainer* self = new (ELeave) CIRCostWarningContainer(aView); |
|
68 CleanupStack::PushL(self); |
|
69 self->ConstructL(aRect); |
|
70 IRLOG_DEBUG( "CIRCostWarningContainer::NewLC - Exiting." ); |
|
71 return self; |
|
72 } |
|
73 // --------------------------------------------------------- |
|
74 // C++ default constructor. |
|
75 // C++ default constructor can NOT contain any code, that might leave. |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 |
|
79 CIRCostWarningContainer::CIRCostWarningContainer( CIRCostWarningView& aMsgView ): |
|
80 iMsgView(aMsgView) |
|
81 { |
|
82 IRLOG_DEBUG( "CIRCostWarningContainer::CIRCostWarningContainer - Entering" ); |
|
83 IRLOG_DEBUG( "CIRCostWarningContainer::CIRCostWarningContainer - Exiting" ); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CIRCostWarningContainer::ConstructL() |
|
88 // Two Phase constructor |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 void CIRCostWarningContainer::ConstructL( const TRect& aRect ) |
|
92 { |
|
93 IRLOG_DEBUG( "CIRCostWarningContainer::ConstructL - Entering" ); |
|
94 CIRUi* ui = reinterpret_cast<CIRUi*>( iCoeEnv->AppUi() ); |
|
95 CreateWindowL(); |
|
96 iEditor = CreateEditorL(); |
|
97 SetReadOnly(ETrue); |
|
98 |
|
99 SetRect(aRect); |
|
100 iEditor->SetRect(aRect); |
|
101 |
|
102 // for Skin Support, Create background control context: |
|
103 iBackGroundControlContext = CAknsBasicBackgroundControlContext::NewL( |
|
104 KAknsIIDQsnBgAreaMain, // Default mainpane skinning |
|
105 Rect(), // Layout to the entire client rect |
|
106 EFalse ); |
|
107 |
|
108 if ( iBackGroundControlContext ) |
|
109 { |
|
110 iEditor->SetSkinBackgroundControlContextL( iBackGroundControlContext ); |
|
111 } |
|
112 if (!ui->iIRSettings->IsFlagCostWarningL()) |
|
113 { |
|
114 ui->SetCommandSetL(R_IR_CBA_CONTINUE_EXIT); |
|
115 UpdateTermsL(); |
|
116 } |
|
117 else |
|
118 { |
|
119 ui->SetCommandSetL(R_IR_CBA_ACCEPT_DECLINE); |
|
120 UpdateTermsL(); |
|
121 } |
|
122 iEditor->SetCursorPosL(0, EFalse ); |
|
123 |
|
124 IRLOG_DEBUG( "CIRCostWarningContainer::ConstructL - Exiting" ); |
|
125 |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CIRCostWarningContainer::~CIRCostWarningContainer() |
|
130 // Destructor |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 CIRCostWarningContainer::~CIRCostWarningContainer() |
|
134 { |
|
135 IRLOG_DEBUG( "CIRCostWarningContainer::~CIRCostWarningContainer - Entering" ); |
|
136 delete iBackGroundControlContext; |
|
137 delete iEditor; |
|
138 if (iRichText) |
|
139 { |
|
140 delete iRichText; |
|
141 iRichText = NULL; |
|
142 } |
|
143 delete iTermsData; |
|
144 IRLOG_DEBUG( "CIRCostWarningContainer::~CIRCostWarningContainer - Exiting" ); |
|
145 } |
|
146 |
|
147 |
|
148 //---------------------------------------------------------------------------- |
|
149 // CIRCostWarningContainer::ComponentControl() const |
|
150 // returns a pointer to the control under this view depending on the index |
|
151 // passed,to the framework. |
|
152 //---------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CIRCostWarningContainer::CountComponentControls() const |
|
155 { |
|
156 IRLOG_DEBUG( "CIRCostWarningContainer::CountComponentControls - Entering" ); |
|
157 return iEditor ? 1 : 0; |
|
158 } |
|
159 |
|
160 |
|
161 //---------------------------------------------------------------------------- |
|
162 // CIRCostWarningContainer::ComponentControl() const |
|
163 // returns a pointer to the control under this view depending on the index |
|
164 // passed,to the framework. |
|
165 //---------------------------------------------------------------------------- |
|
166 // |
|
167 CCoeControl* CIRCostWarningContainer::ComponentControl( TInt aIndex ) const |
|
168 { |
|
169 IRLOG_DEBUG( "CIRCostWarningContainer::ComponentControl - Entering" ); |
|
170 |
|
171 CCoeControl* ctrl = NULL; |
|
172 |
|
173 switch(aIndex) |
|
174 { |
|
175 case 0: |
|
176 ctrl = iEditor; |
|
177 break; |
|
178 default: |
|
179 break; |
|
180 } |
|
181 IRLOG_DEBUG( "CIRCostWarningContainer::ComponentControl - Exiting" ); |
|
182 return ctrl; |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // TKeyResponse CIRCostWarningContainer::OfferKeyEventL( ) |
|
188 // From class CCoeControl. |
|
189 // We need to catch the selection key event in order to do a couple of things |
|
190 // in moving state make the movement, and in normal state open channel |
|
191 // specific popup menu. Up and down buttons are forwarded to the list. |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 TKeyResponse CIRCostWarningContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType ) |
|
195 { |
|
196 |
|
197 IRLOG_DEBUG( "CIRCostWarningContainer::OfferKeyEventL - Entering" ); |
|
198 TKeyResponse res = EKeyWasNotConsumed; |
|
199 |
|
200 if (aType == EEventKey) |
|
201 { |
|
202 if (aKeyEvent.iCode == EKeyDownArrow) |
|
203 { |
|
204 iEditor->MoveCursorL (TCursorPosition::EFPageDown, EFalse); |
|
205 res = EKeyWasConsumed; |
|
206 } |
|
207 else if (aKeyEvent.iCode == EKeyUpArrow) |
|
208 { |
|
209 iEditor->MoveCursorL (TCursorPosition::EFPageUp, EFalse); |
|
210 res = EKeyWasConsumed; |
|
211 } |
|
212 else |
|
213 { |
|
214 res = iEditor->OfferKeyEventL(aKeyEvent, aType); |
|
215 } |
|
216 } |
|
217 IRLOG_DEBUG( "CIRCostWarningContainer::OfferKeyEventL - Exiting" ); |
|
218 return res; |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // CIRCostWarningContainer::UpdateTermsL |
|
224 // To update the required data whenever called |
|
225 // |
|
226 // --------------------------------------------------------- |
|
227 // |
|
228 void CIRCostWarningContainer::UpdateTermsL() |
|
229 { |
|
230 IRLOG_DEBUG( "CIRCostWarningContainer::UpdateTermsL - Entering" ); |
|
231 CreateRichTextDataL(); |
|
232 iEditor->DrawNow(); |
|
233 ActivateL(); |
|
234 IRLOG_DEBUG( "CIRCostWarningContainer::UpdateTermsL - Exiting" ); |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------- |
|
238 // CIRCostWarningContainer::SizeChanged |
|
239 // --------------------------------------------------------- |
|
240 // |
|
241 void CIRCostWarningContainer::SizeChanged() |
|
242 { |
|
243 IRLOG_DEBUG( "CIRCostWarningContainer::SizeChanged - Entering" ); |
|
244 if ( iEditor ) |
|
245 { |
|
246 TRect rectParent = Rect(); |
|
247 TPoint point1( rectParent.iTl.iX, rectParent.iTl.iY ); |
|
248 TRect scrollBarRect = iEditor->ScrollBarFrame()->VerticalScrollBar()->Rect(); |
|
249 iEditor->SetExtent( point1, TSize( rectParent.Width() - scrollBarRect.Width(), |
|
250 rectParent.Height() - KScrollbar ) ); |
|
251 iEditor->DrawNow(); |
|
252 } |
|
253 |
|
254 IRLOG_DEBUG( "CIRCostWarningContainer::SizeChanged - Exiting" ); |
|
255 } |
|
256 |
|
257 |
|
258 // --------------------------------------------------------- |
|
259 // CIRCostWarningContainer::CreateEditorL |
|
260 // Creates the CEikRichTextEditor object |
|
261 // |
|
262 // --------------------------------------------------------- |
|
263 // |
|
264 CEikRichTextEditor* CIRCostWarningContainer::CreateEditorL() const |
|
265 { |
|
266 IRLOG_DEBUG( "CIRCostWarningContainer::CreateEditorL - Entering" ); |
|
267 CEikRichTextEditor* editor = new (ELeave) CEikRichTextEditor; |
|
268 CleanupStack::PushL( editor ); |
|
269 editor->SetContainerWindowL(*this); |
|
270 TInt edwinflags = CEikEdwin::EReadOnly | CEikEdwin::EEdwinAlternativeWrapping ; |
|
271 editor->ConstructL(this, KNoOfLines,KNoOfCharacters,edwinflags ); |
|
272 |
|
273 // create vertical scrollbar |
|
274 editor->CreateScrollBarFrameL(); |
|
275 editor->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
276 CEikScrollBarFrame::EAuto ); |
|
277 editor->ActivateL(); |
|
278 CleanupStack::Pop(editor); // editor |
|
279 IRLOG_DEBUG( "CIRCostWarningContainer::CreateEditorL - Exiting" ); |
|
280 return editor; |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // void CIRCostWarningContainer::Draw( const TRect& aRect ) const |
|
285 // From class CCoeControl. |
|
286 // Draws the control. |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CIRCostWarningContainer::Draw( const TRect& aRect ) const |
|
290 { |
|
291 IRLOG_DEBUG( "CIRCostWarningContainer::Draw - Entering" ); |
|
292 CWindowGc& gc = SystemGc(); |
|
293 |
|
294 // for clearing gap between editor and the view rect |
|
295 if ( IsReadyToDraw() ) |
|
296 { |
|
297 DrawUtils::ClearBetweenRects( gc, aRect, iEditor->Rect() ); |
|
298 if ( iBackGroundControlContext ) |
|
299 {//Draw the skin background |
|
300 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
301 AknsDrawUtils::Background( skin, iBackGroundControlContext, this, gc, aRect ); |
|
302 } |
|
303 } |
|
304 IRLOG_DEBUG( "CIRCostWarningContainer::Draw - Exiting" ); |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------- |
|
308 // CIRCostWarningContainer::SetReadOnly |
|
309 // Making the editor as ReadOnly |
|
310 // |
|
311 // --------------------------------------------------------- |
|
312 // |
|
313 void CIRCostWarningContainer::SetReadOnly( TBool aReadOnly ) |
|
314 { |
|
315 IRLOG_DEBUG( "CIRCostWarningContainer::SetReadOnly - Entering" ); |
|
316 iEditor->SetReadOnly(aReadOnly); |
|
317 IRLOG_DEBUG( "CIRCostWarningContainer::SetReadOnly - Exiting" ); |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------- |
|
321 // CIRCostWarningContainer::SetDataContentL |
|
322 // Setting the RichText into the Editor |
|
323 // |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 void CIRCostWarningContainer::SetDataContentL( CRichText& aText ) |
|
327 { |
|
328 IRLOG_DEBUG( "CIRCostWarningContainer::CIRCostWarningContainer - Entering" ); |
|
329 iEditor->SetDocumentContentL(aText); |
|
330 TRect rectParent = Rect(); |
|
331 TPoint point1( rectParent.iTl.iX, rectParent.iTl.iY ); |
|
332 TRect scrollBarRect = iEditor->ScrollBarFrame()->VerticalScrollBar()->Rect(); |
|
333 iEditor->SetExtent( point1, TSize( rectParent.Width() - scrollBarRect.Width(), |
|
334 rectParent.Height() - KScrollbar ) ); |
|
335 IRLOG_DEBUG( "CIRCostWarningContainer::SetDataContentL - Exiting" ); |
|
336 } |
|
337 |
|
338 // --------------------------------------------------------- |
|
339 // CIRCostWarningContainer::CreateRichTextDataL |
|
340 // Creating the CRichText object |
|
341 // |
|
342 // --------------------------------------------------------- |
|
343 // |
|
344 void CIRCostWarningContainer::CreateRichTextDataL() |
|
345 { |
|
346 IRLOG_DEBUG( "CIRCostWarningContainer::CreateRichTextDataL - Entering" ); |
|
347 CIRUi* ui = reinterpret_cast<CIRUi*>( iCoeEnv->AppUi() ); |
|
348 CParaFormatLayer* globalParaLayer = CParaFormatLayer::NewL(); |
|
349 CleanupStack::PushL(globalParaLayer); |
|
350 |
|
351 |
|
352 CCharFormatLayer* globalCharLayer = NULL; |
|
353 TRgb textColor; |
|
354 |
|
355 TCharFormat charFormat; |
|
356 TCharFormatMask formatMask; |
|
357 |
|
358 iEditor->RichText()->GetCharFormat( charFormat, formatMask, 0, 0 ); |
|
359 MAknsSkinInstance * skin=AknsUtils::SkinInstance () ; |
|
360 TInt error = AknsUtils::GetCachedColor( |
|
361 skin, |
|
362 textColor, |
|
363 KAknsIIDQsnTextColors, |
|
364 EAknsCIQsnTextColorsCG6 ); |
|
365 |
|
366 if( error != KErrNone ) |
|
367 { |
|
368 textColor = KRgbBlack; |
|
369 } |
|
370 |
|
371 charFormat.iFontPresentation.iTextColor = textColor; |
|
372 charFormat.iFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
373 formatMask.SetAll(); |
|
374 |
|
375 globalCharLayer = CCharFormatLayer::NewL( charFormat, formatMask ); |
|
376 CleanupStack::PushL( globalCharLayer ); |
|
377 |
|
378 iRichText = CRichText::NewL( globalParaLayer, globalCharLayer ); |
|
379 CParaFormat *para=CParaFormat::NewL(); |
|
380 CleanupStack::PushL( para ); |
|
381 TParaFormatMask paraMask; |
|
382 paraMask.SetAttrib(EAttSpaceAfter); |
|
383 |
|
384 |
|
385 if (!ui->iIRSettings->IsFlagCostWarningL()) |
|
386 { |
|
387 |
|
388 TCharFormat charFormat; |
|
389 TCharFormatMask charFormatMask; |
|
390 TPtrC costHeading; |
|
391 HBufC *CWHeading = StringLoader::LoadLC(R_IRAPP_COST_WARNING_HEADING); |
|
392 costHeading.Set(*CWHeading); |
|
393 charFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
394 charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); |
|
395 iRichText->SetInsertCharFormatL(charFormat,charFormatMask,iRichText->DocumentLength()); |
|
396 iRichText->InsertL(iRichText->DocumentLength(),costHeading); |
|
397 iRichText->InsertL(iRichText->DocumentLength(),CEditableText::ELineBreak ); |
|
398 iRichText->InsertL(iRichText->DocumentLength(), CEditableText::ELineBreak ); |
|
399 iRichText->CancelInsertCharFormat(); |
|
400 CleanupStack::PopAndDestroy(CWHeading); |
|
401 |
|
402 TPtrC costText; |
|
403 HBufC *CWInfo = StringLoader::LoadLC(R_IRAPP_COST_WARNING_INFO); |
|
404 costText.Set(*CWInfo); |
|
405 charFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
406 charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); |
|
407 iRichText->SetInsertCharFormatL(charFormat,charFormatMask,iRichText->DocumentLength()); |
|
408 iRichText->InsertL(iRichText->DocumentLength(),costText); |
|
409 iRichText->CancelInsertCharFormat(); |
|
410 CleanupStack::PopAndDestroy(CWInfo); |
|
411 } |
|
412 else |
|
413 { |
|
414 ReadTermsFromFileL(); |
|
415 LayoutTermsL(); |
|
416 } |
|
417 |
|
418 |
|
419 SetDataContentL( *iRichText ); |
|
420 |
|
421 iEditor->SetCharFormatLayer( globalCharLayer ); |
|
422 iEditor->SetCursorPosL(0, EFalse ); |
|
423 |
|
424 CleanupStack::PopAndDestroy(para); // para |
|
425 CleanupStack::Pop(globalCharLayer); // globalCharLayer |
|
426 CleanupStack::PopAndDestroy(globalParaLayer); // globalParaLayer |
|
427 IRLOG_DEBUG( "CIRCostWarningContainer::CreateRichTextDataL - Exiting" ); |
|
428 } |
|
429 |
|
430 // --------------------------------------------------------- |
|
431 // CIRCostWarningContainer::GetEditor |
|
432 // Getting the contents of RichText to the Editor |
|
433 // |
|
434 // --------------------------------------------------------- |
|
435 CRichText* CIRCostWarningContainer::GetEditor() const |
|
436 { |
|
437 IRLOG_DEBUG( "CIRCostWarningContainer::GetEditor" ); |
|
438 return iEditor->RichText(); |
|
439 } |
|
440 |
|
441 // ---------------------------------------------------- |
|
442 // CIRCostWarningContainer::HandleResourceChange |
|
443 // Handles a change to the application's resources which are shared across |
|
444 // the environment. |
|
445 // ---------------------------------------------------- |
|
446 void CIRCostWarningContainer::HandleResourceChange( TInt aType ) |
|
447 { |
|
448 IRLOG_DEBUG( "CIRCostWarningContainer::HandleResourceChange - Entering" ); |
|
449 CCoeControl::HandleResourceChange( aType ); |
|
450 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
451 { |
|
452 TRect rect; |
|
453 TBool bRes = AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane , rect); |
|
454 SetRect(rect); |
|
455 |
|
456 iEditor->HandleResourceChange( aType ); |
|
457 |
|
458 if ( iBackGroundControlContext ) |
|
459 { |
|
460 iBackGroundControlContext->SetRect( Rect() ); |
|
461 } |
|
462 } |
|
463 else if( ( aType == KAknsMessageSkinChange ) && ( iBackGroundControlContext ) ) |
|
464 { |
|
465 TRAPD( ignore, iEditor->SetSkinBackgroundControlContextL( iBackGroundControlContext ) ); |
|
466 if(ignore) |
|
467 { |
|
468 return; |
|
469 } |
|
470 if (iRichText) |
|
471 { |
|
472 delete iRichText; |
|
473 iRichText=NULL; |
|
474 } |
|
475 TRAPD(err ,UpdateTermsL()); |
|
476 if(err) |
|
477 { |
|
478 return; |
|
479 } |
|
480 TRAPD( error ,iEditor->SetCursorPosL(0, EFalse )); |
|
481 if(error) |
|
482 { |
|
483 return; |
|
484 } |
|
485 |
|
486 } |
|
487 IRLOG_DEBUG( "CIRCostWarningContainer::HandleResourceChange - Exiting" ); |
|
488 } |
|
489 |
|
490 |
|
491 // ---------------------------------------------------- |
|
492 // CIRCostWarningContainer::ReadTermsFromFileL() |
|
493 // Reads the text from a HTML file |
|
494 // |
|
495 // ---------------------------------------------------- |
|
496 void CIRCostWarningContainer::ReadTermsFromFileL() |
|
497 { |
|
498 IRLOG_DEBUG( "CIRCostWarningContainer::ReadTermsFromFileL - Entering" ); |
|
499 RFs& fs = static_cast<CEikonEnv*>(iCoeEnv)->FsSession(); |
|
500 TFileName privatePath; |
|
501 User::LeaveIfError(fs.PrivatePath(privatePath)); |
|
502 HBufC* termsFileName = StringLoader::LoadL(R_IRAPP_TERMS_FILE); |
|
503 TParse parse; |
|
504 parse.Set(*termsFileName, &privatePath, NULL); |
|
505 delete termsFileName; |
|
506 TFileName fileName = parse.FullName(); |
|
507 CompleteWithAppPath(fileName); |
|
508 RFile fileHandle; |
|
509 User::LeaveIfError(fileHandle.Open(fs, fileName, EFileRead)); |
|
510 CleanupClosePushL(fileHandle); |
|
511 TInt fileSize; |
|
512 User::LeaveIfError( fileHandle.Size( fileSize ) ); |
|
513 HBufC8* termsData = HBufC8::NewLC( fileSize ); |
|
514 TPtr8 pData8( termsData->Des() ); |
|
515 User::LeaveIfError( fileHandle.Read( pData8 ) ); |
|
516 delete iTermsData; |
|
517 iTermsData = NULL; |
|
518 iTermsData = CnvUtfConverter::ConvertToUnicodeFromUtf8L( pData8 ); |
|
519 CleanupStack::PopAndDestroy( termsData ); |
|
520 CleanupStack::PopAndDestroy( &fileHandle ); |
|
521 IRLOG_DEBUG( "CIRCostWarningContainer::ReadTermsFromFileL - Exiting" ); |
|
522 } |
|
523 |
|
524 // ---------------------------------------------------- |
|
525 // CIRCostWarningContainer::LayoutTermsL() |
|
526 // Inserts the text into the RichText object (Heading of Terms & Conditions). |
|
527 // |
|
528 // ---------------------------------------------------- |
|
529 void CIRCostWarningContainer::LayoutTermsL() |
|
530 { |
|
531 IRLOG_DEBUG( "CIRCostWarningContainer::LayoutTermsL - Entering" ); |
|
532 TCharFormat charFormat; |
|
533 TCharFormatMask charFormatMask; |
|
534 |
|
535 TInt dataCounter(0); |
|
536 iTotalTextHeight = 0; |
|
537 TIRTermsTextType type(EIRTermsTextInvalid); |
|
538 TPtrC text; |
|
539 |
|
540 charFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
541 charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); |
|
542 iRichText->SetInsertCharFormatL(charFormat,charFormatMask,iRichText->DocumentLength()); |
|
543 |
|
544 HBufC *CWHeading = StringLoader::LoadLC(R_IRAPP_TERMS_CONDITIONS_HEADING); |
|
545 TPtrC termsHeading; |
|
546 |
|
547 termsHeading.Set( *CWHeading ); |
|
548 |
|
549 iRichText->InsertL(iRichText->DocumentLength(),termsHeading); |
|
550 iRichText->InsertL(iRichText->DocumentLength(), CEditableText::ELineBreak ); |
|
551 |
|
552 iRichText->CancelInsertCharFormat(); |
|
553 CleanupStack::PopAndDestroy(CWHeading); |
|
554 |
|
555 while (GetNextTermsL(dataCounter, text, type)) |
|
556 { |
|
557 if( type != EIRTermsTextHeading && type != EIRTermsTextNormal) |
|
558 { |
|
559 User::Leave(KErrCorrupt); |
|
560 } |
|
561 |
|
562 } |
|
563 IRLOG_DEBUG( "CIRCostWarningContainer::LayoutTermsL - Exiting" ); |
|
564 |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // GetNextTermsL() |
|
569 // Inserts the text into the RichText object (Body of Terms & Conditions). |
|
570 // --------------------------------------------------------------------------- |
|
571 // |
|
572 TBool CIRCostWarningContainer::GetNextTermsL(TInt& aCounter, |
|
573 TPtrC& aTermsText, TIRTermsTextType& aTermsType) |
|
574 { |
|
575 IRLOG_DEBUG( "CIRCostWarningContainer::GetNextTermsL - Entering" ); |
|
576 TCharFormat charFormat; |
|
577 TCharFormatMask charFormatMask; |
|
578 TBool textFound(EFalse); |
|
579 _LIT(KIRHeadingStartTag, "<h1>"); |
|
580 _LIT(KIRHeadingEndTag, "</h1>"); |
|
581 _LIT(KIRNormalStartTag, "<p>"); |
|
582 _LIT(KIRNormalEndTag, "</p>"); |
|
583 TPtr data = iTermsData->Des(); |
|
584 |
|
585 TInt heading = data.Mid(aCounter).Find(KIRHeadingStartTag); |
|
586 TInt normal = data.Mid(aCounter).Find(KIRNormalStartTag); |
|
587 |
|
588 |
|
589 if ((heading != KErrNotFound) || (normal != KErrNotFound)) |
|
590 { |
|
591 if( ((heading != KErrNotFound) && (normal != KErrNotFound) && (heading<normal)) || |
|
592 (normal == KErrNotFound) ) |
|
593 { |
|
594 aTermsType = EIRTermsTextHeading; |
|
595 aCounter = aCounter + heading + KIRHeadingStartTag().Length(); |
|
596 } |
|
597 else |
|
598 { |
|
599 aTermsType = EIRTermsTextNormal; |
|
600 aCounter = aCounter + normal + KIRNormalStartTag().Length(); |
|
601 } |
|
602 if( aTermsType == EIRTermsTextNormal ) |
|
603 { |
|
604 aTermsText.Set(data.Mid(aCounter, data.Mid(aCounter).Find(KIRNormalEndTag))); |
|
605 aCounter = aCounter + aTermsText.Length() + KIRNormalEndTag().Length(); |
|
606 charFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
607 charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); |
|
608 |
|
609 iRichText->SetInsertCharFormatL(charFormat,charFormatMask,iRichText->DocumentLength()); |
|
610 iRichText->InsertL(iRichText->DocumentLength(),aTermsText); |
|
611 iRichText->InsertL(iRichText->DocumentLength(), CEditableText::ELineBreak ); |
|
612 iRichText->CancelInsertCharFormat(); |
|
613 } |
|
614 else |
|
615 { |
|
616 aTermsText.Set(data.Mid(aCounter, data.Mid(aCounter).Find(KIRHeadingEndTag))); |
|
617 aCounter = aCounter + aTermsText.Length() + KIRHeadingEndTag().Length(); |
|
618 charFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
619 charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); |
|
620 iRichText->SetInsertCharFormatL(charFormat,charFormatMask,iRichText->DocumentLength()); |
|
621 iRichText->InsertL(iRichText->DocumentLength(),aTermsText); |
|
622 iRichText->InsertL(iRichText->DocumentLength(), CEditableText::ELineBreak ); |
|
623 iRichText->CancelInsertCharFormat(); |
|
624 } |
|
625 textFound = ETrue; |
|
626 } |
|
627 IRLOG_DEBUG( "CIRCostWarningContainer::GetNextTermsL - Exiting" ); |
|
628 return textFound; |
|
629 |
|
630 |
|
631 } |
|
632 |
|
633 |
|
634 // --------------------------------------------------------------------------------- |
|
635 // |
|
636 // CIRCostWarningContainer::TandCAcceptL() |
|
637 // For setting the terms and conditions flag |
|
638 // --------------------------------------------------------------------------------- |
|
639 void CIRCostWarningContainer::TandCAcceptL() const |
|
640 { |
|
641 IRLOG_DEBUG( "CIRCostWarningContainer::TandCAcceptL - Entering" ); |
|
642 CIRUi* ui = static_cast<CIRUi*>( iCoeEnv->AppUi() ); |
|
643 //set the t&c flag,so that it doesnot come up the next time |
|
644 ui->iIRSettings->SetFlagTermsAndConditionsL(); |
|
645 // ui->iNetworkController->ChooseAccessPointL() |
|
646 if(ui->GetPlsActiavted()) |
|
647 { |
|
648 ui->ActivateLocalViewL(KIRPlsViewID); |
|
649 } |
|
650 else |
|
651 { |
|
652 if(ui->IsFirstTime()) |
|
653 { |
|
654 ui->ActivateLocalViewL(KIRFirstTimeViewId); |
|
655 } |
|
656 else |
|
657 { |
|
658 ui->ActivateLocalViewL(KIRMainChoiceViewID); |
|
659 } |
|
660 } |
|
661 |
|
662 IRLOG_DEBUG( "CIRCostWarningContainer::TandCAcceptL - Exiting" ); |
|
663 } |
|
664 |
|
665 // --------------------------------------------------------------------------- |
|
666 // |
|
667 // CIRCostWarningContainer::CostWarningContinueL() |
|
668 // For displaying the soft keys |
|
669 // --------------------------------------------------------------------------- |
|
670 void CIRCostWarningContainer::CostWarningContinueL() |
|
671 { |
|
672 IRLOG_DEBUG( "CIRCostWarningContainer::CostWarningContinueL - Entering" ); |
|
673 CIRUi* ui = static_cast<CIRUi*>( iCoeEnv->AppUi() ); |
|
674 ui->iIRSettings->SetFlagCostWarningL(); |
|
675 if (iRichText) |
|
676 { |
|
677 delete iRichText; |
|
678 iRichText=NULL; |
|
679 } |
|
680 UpdateTermsL(); |
|
681 iEditor->SetCursorPosL(0,EFalse ); |
|
682 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
683 cba->SetCommandSetL( R_IR_CBA_ACCEPT_DECLINE ); |
|
684 cba->DrawDeferred(); |
|
685 DrawNow(); |
|
686 IRLOG_DEBUG( "CIRCostWarningContainer::CostWarningContinueL - Exiting" ); |
|
687 } |
|
688 |
|
689 // --------------------------------------------------------------------------- |
|
690 // CIRCostWarningContainer::HandlePointerEventL() |
|
691 // Handles pointer events. |
|
692 // --------------------------------------------------------------------------- |
|
693 void CIRCostWarningContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
694 { |
|
695 IRLOG_DEBUG( "CIRCostWarningContainer::HandlePointerEventL - Entering" ); |
|
696 if(iEditor) |
|
697 { |
|
698 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
699 IRLOG_DEBUG( "CIRCostWarningContainer::HandlePointerEventL - Exiting" ); |
|
700 } |
|
701 } |
|