25
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: MR viewer attahcment field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cmrviewerattachmentfield.h"
|
|
18 |
|
|
19 |
#include "mesmrlistobserver.h"
|
|
20 |
#include "mesmrmeetingrequestentry.h"
|
|
21 |
#include "nmrlayoutmanager.h"
|
|
22 |
#include "nmrbitmapmanager.h"
|
|
23 |
#include "cmrimage.h"
|
|
24 |
#include "cesmrrichtextviewer.h"
|
|
25 |
#include "cesmreditor.h"
|
|
26 |
#include "cesmrrichtextlink.h"
|
|
27 |
#include "cmrattachmentcommandhandler.h"
|
|
28 |
#include "ccalremoteattachmentapi.h"
|
|
29 |
#include "ccalremoteattachmentinfo.h"
|
|
30 |
#include "mcalremoteattachmentoperation.h"
|
|
31 |
#include "cesmrglobalnote.h"
|
|
32 |
|
|
33 |
#include <AknsBasicBackgroundControlContext.h>
|
|
34 |
#include <calentry.h>
|
|
35 |
#include <calattachment.h>
|
|
36 |
#include <StringLoader.h>
|
|
37 |
#include <esmrgui.rsg>
|
|
38 |
#include <gulicon.h>
|
|
39 |
#include <ct/rcpointerarray.h>
|
|
40 |
#include <AknBidiTextUtils.h>
|
|
41 |
#include <badesca.h>
|
|
42 |
|
|
43 |
// DEBUG
|
|
44 |
#include "emailtrace.h"
|
|
45 |
|
|
46 |
|
|
47 |
// unnamed namespace for local definitions
|
|
48 |
namespace { // codescanner::namespace
|
|
49 |
//CONSTANTS
|
|
50 |
|
|
51 |
_LIT( KNewLine, "\f" );
|
|
52 |
|
|
53 |
const TInt KOneKiloByte( 1024 );
|
|
54 |
const TInt KOneMegaByte( 1048576 ); // (1024^2 or 2^20):
|
|
55 |
const TInt KMargin = 5;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Checks that command is valid attachment viewer command.
|
|
59 |
* @param aCommmand Command ID
|
|
60 |
*/
|
|
61 |
TBool IsValidAttachmentViewerCommand( TInt aCommand )
|
|
62 |
{
|
|
63 |
TBool ret( EFalse );
|
|
64 |
|
|
65 |
switch( aCommand )
|
|
66 |
{
|
|
67 |
case EESMRViewerOpenAttachment:
|
|
68 |
case EESMRViewerSaveAttachment:
|
|
69 |
case EESMRViewerSaveAllAttachments:
|
|
70 |
case EESMRViewerCancelAttachmentDownload:
|
|
71 |
ret = ETrue;
|
|
72 |
break;
|
|
73 |
|
|
74 |
default:
|
|
75 |
ret = EFalse;
|
|
76 |
break;
|
|
77 |
}
|
|
78 |
|
|
79 |
return ret;
|
|
80 |
}
|
|
81 |
|
|
82 |
}//namespace
|
|
83 |
|
|
84 |
// ======== MEMBER FUNCTIONS ========
|
|
85 |
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
// CMRViewerAttachmentsField::CMRViewerAttachmentsField
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
CMRViewerAttachmentsField::CMRViewerAttachmentsField()
|
|
91 |
{
|
|
92 |
FUNC_LOG;
|
|
93 |
SetFocusType( EESMRHighlightFocus );
|
|
94 |
SetFieldId( EESMRFieldViewerAttachments );
|
|
95 |
}
|
|
96 |
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
// CMRViewerAttachmentsField::~CMRViewerAttachmentsField
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
CMRViewerAttachmentsField::~CMRViewerAttachmentsField( )
|
|
102 |
{
|
|
103 |
FUNC_LOG;
|
|
104 |
delete iBgCtrlContext;
|
|
105 |
delete iFieldIcon;
|
|
106 |
delete iLockIcon;
|
|
107 |
delete iAttachmentCommandHandler;
|
|
108 |
delete iRemoteAttUris;
|
|
109 |
delete iAttachmentInfo;
|
|
110 |
delete iRemoteAttApi;
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// CMRViewerAttachmentsField::NewL
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
CMRViewerAttachmentsField* CMRViewerAttachmentsField::NewL()
|
|
118 |
{
|
|
119 |
FUNC_LOG;
|
|
120 |
CMRViewerAttachmentsField* self = new( ELeave )CMRViewerAttachmentsField();
|
|
121 |
CleanupStack::PushL ( self );
|
|
122 |
self->ConstructL ( );
|
|
123 |
CleanupStack::Pop ( self );
|
|
124 |
return self;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
// CMRViewerAttachmentsField::ConstructL
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void CMRViewerAttachmentsField::ConstructL( )
|
|
132 |
{
|
|
133 |
FUNC_LOG;
|
|
134 |
SetComponentsToInheritVisibility( ETrue );
|
|
135 |
|
|
136 |
iFieldIcon = CMRImage::NewL(
|
|
137 |
NMRBitmapManager::EMRBitmapAttachment,
|
|
138 |
this );
|
|
139 |
|
|
140 |
iRichTextViewer = CESMRRichTextViewer::NewL( this );
|
|
141 |
CESMRField::ConstructL( iRichTextViewer ); // ownership transferred
|
|
142 |
iRichTextViewer->SetEdwinSizeObserver ( this );
|
|
143 |
iRichTextViewer->SetLinkObserver (this );
|
|
144 |
iRichTextViewer->SetParent( this );
|
|
145 |
|
|
146 |
// Draw bg instead of using skin bg
|
|
147 |
TRect tempRect( 0, 0, 0, 0 );
|
|
148 |
NMRBitmapManager::TMRBitmapStruct bitmapStruct;
|
|
149 |
bitmapStruct = NMRBitmapManager::GetBitmapStruct(
|
|
150 |
NMRBitmapManager::EMRBitmapInputCenter );
|
|
151 |
|
|
152 |
iBgCtrlContext = CAknsBasicBackgroundControlContext::NewL(
|
|
153 |
bitmapStruct.iItemId,
|
|
154 |
tempRect,
|
|
155 |
EFalse );
|
|
156 |
|
|
157 |
iRichTextViewer->SetSkinBackgroundControlContextL( iBgCtrlContext );
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// CMRViewerAttachmentsField::MinimumSize
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
TSize CMRViewerAttachmentsField::MinimumSize()
|
|
165 |
{
|
|
166 |
TRect parentRect( Parent()->Rect() );
|
|
167 |
|
|
168 |
TRect fieldRect =
|
|
169 |
NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect();
|
|
170 |
|
|
171 |
TRect viewerRect( NMRLayoutManager::GetLayoutText(
|
|
172 |
fieldRect,
|
|
173 |
NMRLayoutManager::EMRTextLayoutTextEditor ).TextRect() );
|
|
174 |
|
|
175 |
// Adjust field size so that there's room for expandable editor.
|
|
176 |
fieldRect.Resize( 0, iRichTextSize.iHeight - viewerRect.Height() );
|
|
177 |
|
|
178 |
return fieldRect.Size();
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
// CMRViewerAttachmentsField::InitializeL
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
void CMRViewerAttachmentsField::InitializeL()
|
|
186 |
{
|
|
187 |
FUNC_LOG;
|
|
188 |
TAknLayoutText layoutText =
|
|
189 |
NMRLayoutManager::GetLayoutText( Rect(),
|
|
190 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
191 |
iRichTextViewer->SetFontL( layoutText.Font() );
|
|
192 |
if( iAttachmentCount > 1 )
|
|
193 |
{
|
|
194 |
iRichTextViewer->SetLineSpacingL( LineSpacing() );
|
|
195 |
}
|
|
196 |
|
|
197 |
iRichTextViewer->ApplyLayoutChangesL();
|
|
198 |
|
|
199 |
//wake up current contact menu selection by calling this
|
|
200 |
iRichTextViewer->FocusChanged( ENoDrawNow );
|
|
201 |
}
|
|
202 |
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
// CMRViewerAttachmentsField::InternalizeL
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void CMRViewerAttachmentsField::InternalizeL( MESMRCalEntry& aEntry )
|
|
208 |
{
|
|
209 |
FUNC_LOG;
|
|
210 |
|
|
211 |
delete iAttachmentCommandHandler;
|
|
212 |
iAttachmentCommandHandler = NULL;
|
|
213 |
|
|
214 |
iEntry = &aEntry;
|
|
215 |
|
|
216 |
CreateRemoteAttApiL();
|
|
217 |
UpdateAttachmentsListL();
|
|
218 |
|
|
219 |
if ( iAttachmentCount )
|
|
220 |
{
|
|
221 |
//wake up current contact menu selection by calling this
|
|
222 |
iRichTextViewer->FocusChanged( ENoDrawNow );
|
|
223 |
iDisableRedraw = ETrue;
|
|
224 |
iAttachmentCommandHandler =
|
|
225 |
CMRAttachmentCommandHandler::NewL( iEntry->Entry(), *iEventQueue );
|
|
226 |
|
|
227 |
if ( iRemoteAttApi )
|
|
228 |
{
|
|
229 |
iAttachmentCommandHandler->SetRemoteAttachmentInformationL(
|
|
230 |
*iRemoteAttApi,
|
|
231 |
*iAttachmentInfo );
|
|
232 |
}
|
|
233 |
}
|
|
234 |
else
|
|
235 |
{
|
|
236 |
iObserver->HideControl( EESMRFieldViewerAttachments );
|
|
237 |
}
|
|
238 |
}
|
|
239 |
|
|
240 |
// ---------------------------------------------------------------------------
|
|
241 |
// CMRViewerAttachmentsField::ExternalizeL
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
//
|
|
244 |
void CMRViewerAttachmentsField::ExternalizeL( MESMRCalEntry& /*aEntry*/ )
|
|
245 |
{
|
|
246 |
FUNC_LOG;
|
|
247 |
// No implementation
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// CMRViewerAttachmentsField::CountComponentControls
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
TInt CMRViewerAttachmentsField::CountComponentControls( ) const
|
|
255 |
{
|
|
256 |
FUNC_LOG;
|
|
257 |
TInt count( 0 );
|
|
258 |
if ( iFieldIcon )
|
|
259 |
{
|
|
260 |
++count;
|
|
261 |
}
|
|
262 |
|
|
263 |
if ( iRichTextViewer )
|
|
264 |
{
|
|
265 |
++count;
|
|
266 |
}
|
|
267 |
|
|
268 |
if ( iLockIcon )
|
|
269 |
{
|
|
270 |
++count;
|
|
271 |
}
|
|
272 |
|
|
273 |
return count;
|
|
274 |
|
|
275 |
}
|
|
276 |
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
// CMRViewerAttachmentsField::ComponentControl
|
|
279 |
// ---------------------------------------------------------------------------
|
|
280 |
//
|
|
281 |
CCoeControl* CMRViewerAttachmentsField::ComponentControl( TInt aInd ) const
|
|
282 |
{
|
|
283 |
FUNC_LOG;
|
|
284 |
switch ( aInd )
|
|
285 |
{
|
|
286 |
case 0:
|
|
287 |
return iFieldIcon;
|
|
288 |
case 1:
|
|
289 |
return iRichTextViewer;
|
|
290 |
case 2:
|
|
291 |
return iLockIcon;
|
|
292 |
default:
|
|
293 |
return NULL;
|
|
294 |
}
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// CMRViewerAttachmentsField::SizeChanged
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
void CMRViewerAttachmentsField::SizeChanged( )
|
|
302 |
{
|
|
303 |
FUNC_LOG;
|
|
304 |
TRect rect( Rect() );
|
|
305 |
|
|
306 |
TAknLayoutRect rowLayoutRect(
|
|
307 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
|
|
308 |
TRect rowRect( rowLayoutRect.Rect() );
|
|
309 |
|
|
310 |
// Layouting field icon
|
|
311 |
if( iFieldIcon )
|
|
312 |
{
|
|
313 |
TAknWindowComponentLayout iconLayout(
|
|
314 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
315 |
NMRLayoutManager::EMRLayoutSingleRowAColumnGraphic ) );
|
|
316 |
AknLayoutUtils::LayoutControl( iFieldIcon, rowRect, iconLayout );
|
|
317 |
}
|
|
318 |
|
|
319 |
// Layouting lock icon
|
|
320 |
if( iLockIcon )
|
|
321 |
{
|
|
322 |
TAknWindowComponentLayout iconLayout(
|
|
323 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
324 |
NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
|
|
325 |
AknLayoutUtils::LayoutImage( iLockIcon, rowRect, iconLayout );
|
|
326 |
}
|
|
327 |
|
|
328 |
// Layouting viewer rect
|
|
329 |
TAknLayoutText viewerLayoutText;
|
|
330 |
if( iLockIcon )
|
|
331 |
{
|
|
332 |
viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect,
|
|
333 |
NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
|
|
334 |
}
|
|
335 |
else
|
|
336 |
{
|
|
337 |
viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect,
|
|
338 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
339 |
}
|
|
340 |
|
|
341 |
TRect viewerRect( viewerLayoutText.TextRect() );
|
|
342 |
|
|
343 |
// Resize height according to actual height required by edwin.
|
|
344 |
viewerRect.Resize( 0, iSize.iHeight - viewerRect.Height() );
|
|
345 |
iRichTextViewer->SetRect( viewerRect );
|
|
346 |
|
|
347 |
// Layouting focus
|
|
348 |
TRect bgRect( 0, 0, 0, 0 );
|
|
349 |
if( iAttachmentCount > 1 )
|
|
350 |
{
|
|
351 |
bgRect.SetRect(
|
|
352 |
TPoint( viewerRect.iTl.iX,
|
|
353 |
viewerRect.iTl.iY - FocusMargin() ),
|
|
354 |
TPoint( viewerRect.iBr.iX,
|
|
355 |
viewerRect.iBr.iY + FocusMargin() ) );
|
|
356 |
}
|
|
357 |
else
|
|
358 |
{
|
|
359 |
TAknLayoutRect bgLayoutRect =
|
|
360 |
NMRLayoutManager::GetLayoutRect(
|
|
361 |
rowRect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
362 |
bgRect = bgLayoutRect.Rect();
|
|
363 |
}
|
|
364 |
|
|
365 |
// Move focus rect so that it's relative to field's position.
|
|
366 |
bgRect.Move( -Position() );
|
|
367 |
SetFocusRect( bgRect );
|
|
368 |
|
|
369 |
// Failures are ignored.
|
|
370 |
TRAP_IGNORE(
|
|
371 |
// Set font
|
|
372 |
iRichTextViewer->SetFontL( viewerLayoutText.Font() );
|
|
373 |
if( iAttachmentCount > 1 )
|
|
374 |
{
|
|
375 |
// Set line spacing
|
|
376 |
iRichTextViewer->SetLineSpacingL( LineSpacing() );
|
|
377 |
}
|
|
378 |
|
|
379 |
// Apply changes.
|
|
380 |
iRichTextViewer->ApplyLayoutChangesL();
|
|
381 |
)
|
|
382 |
}
|
|
383 |
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
// CMRViewerAttachmentsField::OfferKeyEventL
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
TKeyResponse CMRViewerAttachmentsField::OfferKeyEventL(
|
|
389 |
const TKeyEvent& aEvent,
|
|
390 |
TEventCode aType )
|
|
391 |
{
|
|
392 |
FUNC_LOG;
|
|
393 |
TKeyResponse response( EKeyWasNotConsumed );
|
|
394 |
|
|
395 |
if( iAttachmentCount > 0 )
|
|
396 |
{
|
|
397 |
response = iRichTextViewer->OfferKeyEventL( aEvent, aType );
|
|
398 |
}
|
|
399 |
|
|
400 |
return response;
|
|
401 |
}
|
|
402 |
|
|
403 |
// ---------------------------------------------------------------------------
|
|
404 |
// CMRViewerAttachmentsField::HandleEdwinSizeEventL
|
|
405 |
// ---------------------------------------------------------------------------
|
|
406 |
//
|
|
407 |
TBool CMRViewerAttachmentsField::HandleEdwinSizeEventL( CEikEdwin* aEdwin,
|
|
408 |
TEdwinSizeEvent /*aType*/, TSize aSize )
|
|
409 |
{
|
|
410 |
FUNC_LOG;
|
|
411 |
TBool reDraw( EFalse );
|
|
412 |
|
|
413 |
if( iRichTextSize.iHeight != aSize.iHeight && iAttachmentCount > 0 )
|
|
414 |
{
|
|
415 |
// Let's save the required size of the rich text viewer
|
|
416 |
iRichTextSize = aSize;
|
|
417 |
|
|
418 |
if ( iObserver && aEdwin == iRichTextViewer )
|
|
419 |
{
|
|
420 |
iObserver->ControlSizeChanged( this );
|
|
421 |
reDraw = ETrue;
|
|
422 |
|
|
423 |
if ( !iOutlineFocus )
|
|
424 |
{
|
|
425 |
RecordField();
|
|
426 |
}
|
|
427 |
}
|
|
428 |
}
|
|
429 |
|
|
430 |
return reDraw;
|
|
431 |
}
|
|
432 |
|
|
433 |
// ---------------------------------------------------------------------------
|
|
434 |
// CMRViewerAttachmentsField::ListObserverSet
|
|
435 |
// ---------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
void CMRViewerAttachmentsField::ListObserverSet()
|
|
438 |
{
|
|
439 |
FUNC_LOG;
|
|
440 |
iRichTextViewer->SetListObserver( iObserver );
|
|
441 |
}
|
|
442 |
|
|
443 |
// ---------------------------------------------------------------------------
|
|
444 |
// CMRViewerAttachmentsField::ExecuteGenericCommandL
|
|
445 |
// ---------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
TBool CMRViewerAttachmentsField::ExecuteGenericCommandL( TInt aCommand )
|
|
448 |
{
|
|
449 |
FUNC_LOG;
|
|
450 |
|
|
451 |
TBool handled( EFalse );
|
|
452 |
|
|
453 |
//handle locked field first
|
|
454 |
if( IsLocked() )
|
|
455 |
{
|
|
456 |
if( aCommand == EESMRViewerOpenAttachment ||
|
|
457 |
aCommand == EAknCmdOpen )
|
|
458 |
{
|
|
459 |
HandleTactileFeedbackL();
|
|
460 |
|
|
461 |
CESMRGlobalNote::ExecuteL(
|
|
462 |
CESMRGlobalNote::EESMRUnableToEdit );
|
|
463 |
return ETrue;
|
|
464 |
}
|
|
465 |
}
|
|
466 |
|
|
467 |
if ( IsValidAttachmentViewerCommand(aCommand) && iAttachmentCommandHandler )
|
|
468 |
{
|
|
469 |
const CESMRRichTextLink* currentLink = iRichTextViewer->GetSelectedLink();
|
|
470 |
|
|
471 |
ASSERT( currentLink );
|
|
472 |
|
|
473 |
TBool remoteCommand(
|
|
474 |
iAttachmentCommandHandler->IsRemoteAttachmentL( *currentLink) );
|
|
475 |
|
|
476 |
if ( !remoteCommand )
|
|
477 |
{
|
|
478 |
iAttachmentCommandHandler->HandleAttachmentCommandL(
|
|
479 |
aCommand,
|
|
480 |
*currentLink );
|
|
481 |
|
|
482 |
HandleTactileFeedbackL();
|
|
483 |
}
|
|
484 |
else
|
|
485 |
{
|
|
486 |
iAttachmentCommandHandler->HandleRemoteAttachmentCommandL(
|
|
487 |
aCommand,
|
|
488 |
*currentLink );
|
|
489 |
|
|
490 |
HandleTactileFeedbackL();
|
|
491 |
}
|
|
492 |
|
|
493 |
handled = ETrue;
|
|
494 |
}
|
|
495 |
return handled;
|
|
496 |
}
|
|
497 |
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
// CMRViewerAttachmentsField::SetOutlineFocusL
|
|
500 |
// ---------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
void CMRViewerAttachmentsField::SetOutlineFocusL( TBool aFocus )
|
|
503 |
{
|
|
504 |
FUNC_LOG;
|
|
505 |
CESMRField::SetOutlineFocusL( aFocus );
|
|
506 |
|
|
507 |
if ( aFocus && iAttachmentCount)
|
|
508 |
{
|
|
509 |
ChangeMiddleSoftKeyL(
|
|
510 |
EAknSoftkeyContextOptions,
|
|
511 |
R_QTN_MSK_OPEN );
|
|
512 |
}
|
|
513 |
}
|
|
514 |
|
|
515 |
// -----------------------------------------------------------------------------
|
|
516 |
// CMRViewerAttachmentsField::HandleRichTextLinkSelection
|
|
517 |
// -----------------------------------------------------------------------------
|
|
518 |
//
|
|
519 |
TBool CMRViewerAttachmentsField::HandleRichTextLinkSelection(
|
|
520 |
const CESMRRichTextLink* aLink )
|
|
521 |
{
|
|
522 |
FUNC_LOG;
|
|
523 |
TBool ret( EFalse );
|
|
524 |
|
|
525 |
// Open context menu in editor and viewer modes with link selection
|
|
526 |
if ( aLink->Type() == CESMRRichTextLink::ETypeAttachment )
|
|
527 |
{
|
|
528 |
TRAP_IGNORE( NotifyEventL( EMRLaunchAttachmentContextMenu ));
|
|
529 |
ret = ETrue;
|
|
530 |
|
|
531 |
TRAP_IGNORE( HandleTactileFeedbackL() );
|
|
532 |
}
|
|
533 |
|
|
534 |
return ret;
|
|
535 |
}
|
|
536 |
|
|
537 |
// -----------------------------------------------------------------------------
|
|
538 |
// CMRViewerAttachmentsField::UpdateAttachmentsListL
|
|
539 |
// -----------------------------------------------------------------------------
|
|
540 |
//
|
|
541 |
void CMRViewerAttachmentsField::UpdateAttachmentsListL()
|
|
542 |
{
|
|
543 |
FUNC_LOG;
|
|
544 |
|
|
545 |
|
|
546 |
if ( iRemoteAttApi )
|
|
547 |
{
|
|
548 |
// Let's fetch remote attachment information
|
|
549 |
iRemoteAttApi->AttachmentInfo(
|
|
550 |
*iAttachmentInfo,
|
|
551 |
*iRemoteAttUris );
|
|
552 |
}
|
|
553 |
|
|
554 |
RBuf buffer; // codescanner::resourcenotoncleanupstack
|
|
555 |
buffer.CleanupClosePushL();
|
|
556 |
|
|
557 |
RCPointerArray<CESMRRichTextLink> attachmentLinks;
|
|
558 |
CleanupClosePushL( attachmentLinks );
|
|
559 |
|
|
560 |
TAknLayoutText layoutText = NMRLayoutManager::GetLayoutText(
|
|
561 |
Rect(),
|
|
562 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
563 |
|
|
564 |
iAttachmentCount = iEntry->Entry().AttachmentCountL();
|
|
565 |
attachmentLinks.ReserveL( iAttachmentCount );
|
|
566 |
for ( TInt i = 0; i < iAttachmentCount; ++i )
|
|
567 |
{
|
|
568 |
CCalAttachment* attachment = iEntry->Entry().AttachmentL( i ); // Ownership not gained
|
|
569 |
|
|
570 |
const CFont* font = layoutText.Font();
|
|
571 |
TInt maxFileNameLengthInPixels( MaxTextLengthInPixelsL() );
|
|
572 |
|
|
573 |
// Size information needs to be reduced from max filename length
|
|
574 |
HBufC* attachmentSizeOnly(
|
|
575 |
AttachmentNameAndSizeL( KNullDesC(), *attachment ) );
|
|
576 |
TInt sizeInformationLengthInPixels(
|
|
577 |
font->TextWidthInPixels( *attachmentSizeOnly ) );
|
|
578 |
maxFileNameLengthInPixels -= sizeInformationLengthInPixels;
|
|
579 |
|
|
580 |
// Trimming file name to fit to one line
|
|
581 |
TPtrC text = attachment->Label();
|
|
582 |
HBufC* clippedTextHBufC = ClipTextLC(
|
|
583 |
text, *font, maxFileNameLengthInPixels );
|
|
584 |
TPtr clippedText = clippedTextHBufC->Des();
|
|
585 |
clippedText.Trim();
|
|
586 |
|
|
587 |
if ( clippedText.Length() > 0 )
|
|
588 |
{
|
|
589 |
HBufC* buf = AttachmentNameAndSizeL( clippedText, *attachment );
|
|
590 |
CleanupStack::PushL( buf );
|
|
591 |
|
|
592 |
// Creating rich text link
|
|
593 |
CESMRRichTextLink* link = CESMRRichTextLink::NewL(
|
|
594 |
buffer.Length(),
|
|
595 |
buf->Length(),
|
|
596 |
text,
|
|
597 |
CESMRRichTextLink::ETypeAttachment,
|
|
598 |
CESMRRichTextLink::ETriggerKeyRight );
|
|
599 |
CleanupStack::PushL( link );
|
|
600 |
attachmentLinks.AppendL( link );
|
|
601 |
CleanupStack::Pop( link );
|
|
602 |
|
|
603 |
// Append attachment name and size with line feed to buffer
|
|
604 |
buffer.ReAllocL( buffer.Length() +
|
|
605 |
clippedText.Length() +
|
|
606 |
buf->Length() +
|
|
607 |
KNewLine().Length() );
|
|
608 |
|
|
609 |
buffer.Append( buf->Des() );
|
|
610 |
buffer.Append( KNewLine );
|
|
611 |
|
|
612 |
CleanupStack::PopAndDestroy( buf );
|
|
613 |
}
|
|
614 |
|
|
615 |
CleanupStack::PopAndDestroy( clippedTextHBufC );
|
|
616 |
}
|
|
617 |
|
|
618 |
// Remove unnecessary new line from the end of buffer.
|
|
619 |
if ( buffer.Length() >= KNewLine().Length() )
|
|
620 |
{
|
|
621 |
buffer.SetLength( buffer.Length() - KNewLine().Length() );
|
|
622 |
}
|
|
623 |
|
|
624 |
// Adding all rich text links to the rich text viewer
|
|
625 |
if ( buffer.Length() > 0 )
|
|
626 |
{
|
|
627 |
iRichTextViewer->SetTextL( &buffer );
|
|
628 |
iRichTextViewer->SetFontL( layoutText.Font() );
|
|
629 |
if( iAttachmentCount > 1 )
|
|
630 |
{
|
|
631 |
iRichTextViewer->SetLineSpacingL( LineSpacing() );
|
|
632 |
}
|
|
633 |
|
|
634 |
while ( attachmentLinks.Count() > 0 )
|
|
635 |
{
|
|
636 |
CESMRRichTextLink* link = attachmentLinks[0];
|
|
637 |
CleanupStack::PushL( link );
|
|
638 |
attachmentLinks.Remove( 0 );
|
|
639 |
iRichTextViewer->AddLinkL( link );
|
|
640 |
CleanupStack::Pop( link );
|
|
641 |
}
|
|
642 |
|
|
643 |
iRichTextViewer->ApplyLayoutChangesL();
|
|
644 |
|
|
645 |
iRichTextViewer->SetMargins( KMargin ); // What's this?
|
|
646 |
iRichTextViewer->HandleTextChangedL();
|
|
647 |
}
|
|
648 |
|
|
649 |
CleanupStack::PopAndDestroy( &attachmentLinks );
|
|
650 |
CleanupStack::PopAndDestroy( &buffer );
|
|
651 |
|
|
652 |
if ( iAttachmentCount )
|
|
653 |
{
|
|
654 |
ChangeMiddleSoftKeyL(
|
|
655 |
EAknSoftkeyContextOptions,
|
|
656 |
R_QTN_MSK_OPEN );
|
|
657 |
}
|
|
658 |
}
|
|
659 |
|
|
660 |
// -----------------------------------------------------------------------------
|
|
661 |
// CMRViewerAttachmentsField::ClipTextLC
|
|
662 |
// -----------------------------------------------------------------------------
|
|
663 |
//
|
|
664 |
HBufC* CMRViewerAttachmentsField::ClipTextLC(
|
|
665 |
const TDesC& aText, const CFont& aFont, TInt aWidth )
|
|
666 |
{
|
|
667 |
FUNC_LOG;
|
|
668 |
HBufC* text = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine );
|
|
669 |
TPtr textPtr = text->Des();
|
|
670 |
AknBidiTextUtils::ConvertToVisualAndClip(
|
|
671 |
aText, textPtr, aFont, aWidth, aWidth );
|
|
672 |
return text;
|
|
673 |
}
|
|
674 |
|
|
675 |
// ---------------------------------------------------------------------------
|
|
676 |
// CMRViewerAttachmentsField::AttachmentNameAndSizeL
|
|
677 |
// ---------------------------------------------------------------------------
|
|
678 |
//
|
|
679 |
HBufC* CMRViewerAttachmentsField::AttachmentNameAndSizeL(
|
|
680 |
const TDesC& aDes,
|
|
681 |
const CCalAttachment& aAttachment )
|
|
682 |
{
|
|
683 |
HBufC* stringholder = NULL;
|
|
684 |
|
|
685 |
CDesCArrayFlat* attachmentStrings =
|
|
686 |
new(ELeave)CDesCArrayFlat( 1 );
|
|
687 |
CleanupStack::PushL( attachmentStrings );
|
|
688 |
|
|
689 |
CArrayFixFlat<TInt>* integers =
|
|
690 |
new (ELeave) CArrayFixFlat<TInt>(1);
|
|
691 |
CleanupStack::PushL( integers );
|
|
692 |
|
|
693 |
CCalAttachment::TType attType( aAttachment.Type() );
|
|
694 |
|
|
695 |
TInt attachmentSize(0);
|
|
696 |
if ( CCalAttachment::EFile == attType )
|
|
697 |
{
|
|
698 |
attachmentSize = aAttachment.FileAttachment()->Size();
|
|
699 |
}
|
|
700 |
else if ( iAttachmentInfo && iAttachmentInfo->AttachmentCount() )
|
|
701 |
{
|
|
702 |
TInt remoteAttCount( iAttachmentInfo->AttachmentCount() );
|
|
703 |
for ( TInt i(0); i < remoteAttCount; ++i )
|
|
704 |
{
|
|
705 |
TPtrC label( aAttachment.Label() );
|
|
706 |
TPtrC remoteLabel(
|
|
707 |
iAttachmentInfo->AttachmentL(i).AttachmentLabel() );
|
|
708 |
if ( !label.Compare( remoteLabel ) )
|
|
709 |
{
|
|
710 |
attachmentSize = iAttachmentInfo->AttachmentL(i).AttachmentSizeInBytes();
|
|
711 |
}
|
|
712 |
}
|
|
713 |
}
|
|
714 |
|
|
715 |
if ( attachmentSize >= KOneMegaByte )
|
|
716 |
{
|
|
717 |
attachmentStrings->AppendL( aDes );
|
|
718 |
|
|
719 |
integers->AppendL( attachmentSize / KOneMegaByte );
|
|
720 |
|
|
721 |
stringholder = StringLoader::LoadLC(
|
|
722 |
R_MEET_REQ_ATTACHMENT_FILE_MEGABYTE,
|
|
723 |
*attachmentStrings,
|
|
724 |
*integers );
|
|
725 |
}
|
|
726 |
else if (( attachmentSize < KOneKiloByte ) && (attachmentSize != 0))
|
|
727 |
{
|
|
728 |
attachmentStrings->AppendL( aDes );
|
|
729 |
|
|
730 |
stringholder = StringLoader::LoadLC(
|
|
731 |
R_MEET_REQ_ATTACHMENT_FILE_LESS_THAN_KILOBYTE ,
|
|
732 |
*attachmentStrings );
|
|
733 |
}
|
|
734 |
else
|
|
735 |
{
|
|
736 |
attachmentStrings->AppendL( aDes );
|
|
737 |
|
|
738 |
integers->AppendL( attachmentSize / KOneKiloByte );
|
|
739 |
|
|
740 |
stringholder = StringLoader::LoadLC(
|
|
741 |
R_MEET_REQ_ATTACHMENT_FILE_KILOBYTE,
|
|
742 |
*attachmentStrings,
|
|
743 |
*integers );
|
|
744 |
}
|
|
745 |
|
|
746 |
CleanupStack::Pop( stringholder );
|
|
747 |
CleanupStack::PopAndDestroy( integers );
|
|
748 |
CleanupStack::PopAndDestroy( attachmentStrings );
|
|
749 |
|
|
750 |
return stringholder;
|
|
751 |
}
|
|
752 |
|
|
753 |
// ---------------------------------------------------------------------------
|
|
754 |
// CMRViewerAttachmentsField::HandleLongtapEventL
|
|
755 |
// ---------------------------------------------------------------------------
|
|
756 |
//
|
|
757 |
void CMRViewerAttachmentsField::HandleLongtapEventL( const TPoint& aPosition )
|
|
758 |
{
|
|
759 |
FUNC_LOG;
|
|
760 |
|
|
761 |
if ( iRichTextViewer->Rect().Contains( aPosition ) )
|
|
762 |
{
|
|
763 |
iRichTextViewer->LinkSelectedL();
|
|
764 |
}
|
|
765 |
}
|
|
766 |
|
|
767 |
// ---------------------------------------------------------------------------
|
|
768 |
// CMRViewerAttachmentsField::HandleRawPointerEventL
|
|
769 |
// ---------------------------------------------------------------------------
|
|
770 |
//
|
|
771 |
TBool CMRViewerAttachmentsField::HandleRawPointerEventL(
|
|
772 |
const TPointerEvent& aPointerEvent )
|
|
773 |
{
|
|
774 |
FUNC_LOG;
|
|
775 |
// Handles short on attachment fields actual attachments
|
|
776 |
TBool ret( EFalse );
|
|
777 |
|
|
778 |
if( iAttachmentCount > 0 &&
|
|
779 |
aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
780 |
{
|
|
781 |
if( iRichTextViewer->Rect().Contains( aPointerEvent.iPosition ) )
|
|
782 |
{
|
|
783 |
iRichTextViewer->HandlePointerEventL( aPointerEvent );
|
|
784 |
ret = ETrue;
|
|
785 |
}
|
|
786 |
}
|
|
787 |
|
|
788 |
return ret;
|
|
789 |
}
|
|
790 |
|
|
791 |
// ---------------------------------------------------------------------------
|
|
792 |
// CMRViewerAttachmentsField::DynInitMenuPaneL
|
|
793 |
// ---------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
void CMRViewerAttachmentsField::DynInitMenuPaneL(
|
|
796 |
TInt aResourceId,
|
|
797 |
CEikMenuPane* aMenuPane )
|
|
798 |
{
|
|
799 |
FUNC_LOG;
|
|
800 |
|
|
801 |
if ( R_MR_VIEWER_ATTACHMENT_MENU == aResourceId )
|
|
802 |
{
|
|
803 |
DynInitMenuPaneForCurrentAttachmentL( aMenuPane );
|
|
804 |
}
|
|
805 |
}
|
|
806 |
|
|
807 |
// ---------------------------------------------------------------------------
|
|
808 |
// CMRViewerAttachmentsField::LockL
|
|
809 |
// ---------------------------------------------------------------------------
|
|
810 |
//
|
|
811 |
void CMRViewerAttachmentsField::LockL()
|
|
812 |
{
|
|
813 |
FUNC_LOG;
|
|
814 |
if( IsLocked() )
|
|
815 |
{
|
|
816 |
return;
|
|
817 |
}
|
|
818 |
|
|
819 |
CESMRField::LockL();
|
|
820 |
|
|
821 |
delete iLockIcon;
|
|
822 |
iLockIcon = NULL;
|
|
823 |
iLockIcon = CMRImage::NewL(
|
|
824 |
NMRBitmapManager::EMRBitmapLockField,
|
|
825 |
this,
|
|
826 |
ETrue );
|
|
827 |
}
|
|
828 |
|
|
829 |
// ---------------------------------------------------------------------------
|
|
830 |
// CMRViewerAttachmentsField::LineSpacing
|
|
831 |
// ---------------------------------------------------------------------------
|
|
832 |
//
|
|
833 |
TInt CMRViewerAttachmentsField::LineSpacing()
|
|
834 |
{
|
|
835 |
FUNC_LOG;
|
|
836 |
// Calculates the line spacing based on default one line layout data
|
|
837 |
TInt lineSpacing( 0 );
|
|
838 |
|
|
839 |
TRect rect( Rect() );
|
|
840 |
|
|
841 |
TAknLayoutRect rowLayoutRect =
|
|
842 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
843 |
TRect rowRect = rowLayoutRect.Rect();
|
|
844 |
|
|
845 |
TAknLayoutText labelLayout =
|
|
846 |
NMRLayoutManager::GetLayoutText(
|
|
847 |
rect, NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
848 |
|
|
849 |
TRect defaultTextRect = labelLayout.TextRect();
|
|
850 |
|
|
851 |
TInt difference = rowRect.Height() - defaultTextRect.Height();
|
|
852 |
|
|
853 |
lineSpacing = difference * 2;
|
|
854 |
|
|
855 |
return lineSpacing;
|
|
856 |
}
|
|
857 |
|
|
858 |
// ---------------------------------------------------------------------------
|
|
859 |
// CMRViewerAttachmentsField::FocusMargin
|
|
860 |
// ---------------------------------------------------------------------------
|
|
861 |
//
|
|
862 |
TInt CMRViewerAttachmentsField::FocusMargin()
|
|
863 |
{
|
|
864 |
FUNC_LOG;
|
|
865 |
// Calculates focus margin based on default one line layout data
|
|
866 |
TInt focusMagin( 0 );
|
|
867 |
|
|
868 |
TRect rect( Rect() );
|
|
869 |
|
|
870 |
TAknLayoutRect rowLayoutRect =
|
|
871 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
872 |
TRect rowRect = rowLayoutRect.Rect();
|
|
873 |
|
|
874 |
TAknLayoutText labelLayout =
|
|
875 |
NMRLayoutManager::GetLayoutText(
|
|
876 |
rect, NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
877 |
|
|
878 |
TRect defaultTextRect = labelLayout.TextRect();
|
|
879 |
|
|
880 |
TAknLayoutRect bgLayoutRect =
|
|
881 |
NMRLayoutManager::GetLayoutRect(
|
|
882 |
rect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
883 |
TRect defaultBgRect( bgLayoutRect.Rect() );
|
|
884 |
|
|
885 |
TInt difference = defaultBgRect.Height() - defaultTextRect.Height();
|
|
886 |
|
|
887 |
focusMagin = TReal( difference / 2 );
|
|
888 |
|
|
889 |
return focusMagin;
|
|
890 |
}
|
|
891 |
|
|
892 |
// ---------------------------------------------------------------------------
|
|
893 |
// CMRViewerAttachmentsField::CreateRemoteAttApiL
|
|
894 |
// ---------------------------------------------------------------------------
|
|
895 |
//
|
|
896 |
void CMRViewerAttachmentsField::CreateRemoteAttApiL()
|
|
897 |
{
|
|
898 |
FUNC_LOG;
|
|
899 |
|
|
900 |
delete iAttachmentCommandHandler;
|
|
901 |
iAttachmentCommandHandler = NULL;
|
|
902 |
|
|
903 |
delete iRemoteAttUris;
|
|
904 |
iRemoteAttUris = NULL;
|
|
905 |
|
|
906 |
delete iAttachmentInfo;
|
|
907 |
iAttachmentInfo = NULL;
|
|
908 |
|
|
909 |
TInt attachmentCount( iEntry->Entry().AttachmentCountL() );
|
|
910 |
if ( attachmentCount )
|
|
911 |
{
|
|
912 |
iRemoteAttUris = new (ELeave) CDesCArrayFlat( 4 );
|
|
913 |
iAttachmentInfo = CCalRemoteAttachmentInfo::NewL();
|
|
914 |
}
|
|
915 |
|
|
916 |
for (TInt i(0); i < attachmentCount; ++i )
|
|
917 |
{
|
|
918 |
// Ownership not gained
|
|
919 |
CCalAttachment* att = iEntry->Entry().AttachmentL( i );
|
|
920 |
CCalAttachment::TType attachhmentType( att->Type() );
|
|
921 |
|
|
922 |
if ( CCalAttachment::EUri == attachhmentType )
|
|
923 |
{
|
|
924 |
if ( !iRemoteAttApi )
|
|
925 |
{
|
|
926 |
TPtrC8 uri( att->Value() );
|
|
927 |
iRemoteAttApi = CCalRemoteAttachmentApi::NewL( uri );
|
|
928 |
}
|
|
929 |
|
|
930 |
HBufC* uri16 = HBufC16::NewLC(att->Value().Length() );
|
|
931 |
uri16->Des().Copy( att->Value() );
|
|
932 |
iRemoteAttUris->AppendL( *uri16 );
|
|
933 |
CleanupStack::PopAndDestroy( uri16 );
|
|
934 |
}
|
|
935 |
}
|
|
936 |
}
|
|
937 |
|
|
938 |
// ---------------------------------------------------------------------------
|
|
939 |
// CMRViewerAttachmentsField::DynInitMenuPaneForCurrentAttachmentL
|
|
940 |
// ---------------------------------------------------------------------------
|
|
941 |
//
|
|
942 |
void CMRViewerAttachmentsField::DynInitMenuPaneForCurrentAttachmentL(
|
|
943 |
CEikMenuPane* aMenuPane )
|
|
944 |
{
|
|
945 |
FUNC_LOG;
|
|
946 |
TInt commandInProgress(
|
|
947 |
iAttachmentCommandHandler->CurrentCommandInProgress() );
|
|
948 |
|
|
949 |
// Get selected attachment
|
|
950 |
CCalAttachment* selectedAttachment = NULL;
|
|
951 |
|
|
952 |
const CESMRRichTextLink* currentLink = iRichTextViewer->GetSelectedLink();
|
|
953 |
ASSERT( currentLink );
|
|
954 |
|
|
955 |
TPtrC currentAttachmentName( currentLink->Value() );
|
|
956 |
for ( TInt i(0); i < iAttachmentCount && !selectedAttachment; ++i )
|
|
957 |
{
|
|
958 |
CCalAttachment* attachment = iEntry->Entry().AttachmentL( i );
|
|
959 |
TPtrC attachmentLabel ( attachment->Label() );
|
|
960 |
|
|
961 |
if ( !attachmentLabel.Compare( currentAttachmentName ) )
|
|
962 |
{
|
|
963 |
selectedAttachment = attachment;
|
|
964 |
}
|
|
965 |
}
|
|
966 |
|
|
967 |
ASSERT( selectedAttachment );
|
|
968 |
|
|
969 |
|
|
970 |
/*
|
|
971 |
* Case 1: Download in progress
|
|
972 |
*/
|
|
973 |
if( commandInProgress )
|
|
974 |
{
|
|
975 |
// A) If selected attachment is remote attachment and download is in progress
|
|
976 |
// or attachment is queued for downloading
|
|
977 |
if( selectedAttachment->Type() == CCalAttachment::EUri &&
|
|
978 |
EESMRViewerSaveAllAttachments == commandInProgress )
|
|
979 |
{
|
|
980 |
aMenuPane->SetItemDimmed(
|
|
981 |
EESMRViewerOpenAttachment,
|
|
982 |
ETrue );
|
|
983 |
|
|
984 |
aMenuPane->SetItemDimmed(
|
|
985 |
EESMRViewerSaveAttachment,
|
|
986 |
ETrue );
|
|
987 |
|
|
988 |
aMenuPane->SetItemDimmed(
|
|
989 |
EESMRViewerSaveAllAttachments,
|
|
990 |
ETrue );
|
|
991 |
}
|
|
992 |
|
|
993 |
// B) If selected attachment is local attachment
|
|
994 |
else if( selectedAttachment->Type() == CCalAttachment::EFile )
|
|
995 |
{
|
|
996 |
// Always hide cancel attachment download item
|
|
997 |
aMenuPane->SetItemDimmed(
|
|
998 |
EESMRViewerCancelAttachmentDownload,
|
|
999 |
ETrue );
|
|
1000 |
|
|
1001 |
// If attachment count is one, hide 'Save All' also
|
|
1002 |
if ( iAttachmentCount == 1 )
|
|
1003 |
{
|
|
1004 |
aMenuPane->SetItemDimmed(
|
|
1005 |
EESMRViewerSaveAllAttachments,
|
|
1006 |
ETrue );
|
|
1007 |
}
|
|
1008 |
}
|
|
1009 |
|
|
1010 |
// C) If selected attachment is Uri, and some other command is in progress
|
|
1011 |
// than save all
|
|
1012 |
else if( selectedAttachment->Type() == CCalAttachment::EUri &&
|
|
1013 |
commandInProgress != EESMRViewerSaveAllAttachments )
|
|
1014 |
{
|
|
1015 |
// If this attachment is the one being downloaded
|
|
1016 |
if( IsAttachmentDownloadInProgress( *selectedAttachment ) )
|
|
1017 |
{
|
|
1018 |
aMenuPane->SetItemDimmed(
|
|
1019 |
EESMRViewerOpenAttachment,
|
|
1020 |
ETrue );
|
|
1021 |
|
|
1022 |
aMenuPane->SetItemDimmed(
|
|
1023 |
EESMRViewerSaveAttachment,
|
|
1024 |
ETrue );
|
|
1025 |
|
|
1026 |
aMenuPane->SetItemDimmed(
|
|
1027 |
EESMRViewerSaveAllAttachments,
|
|
1028 |
ETrue );
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
|
|
1032 |
// if this attacment is not the one being downloaded
|
|
1033 |
else
|
|
1034 |
{
|
|
1035 |
// Always hide cancel attachment download item
|
|
1036 |
aMenuPane->SetItemDimmed(
|
|
1037 |
EESMRViewerCancelAttachmentDownload,
|
|
1038 |
ETrue );
|
|
1039 |
|
|
1040 |
// If attachment count is one, hide 'Save All' also
|
|
1041 |
if ( iAttachmentCount == 1 )
|
|
1042 |
{
|
|
1043 |
aMenuPane->SetItemDimmed(
|
|
1044 |
EESMRViewerSaveAllAttachments,
|
|
1045 |
ETrue );
|
|
1046 |
}
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
/*
|
|
1052 |
* Case 2: No download in progress
|
|
1053 |
*/
|
|
1054 |
else
|
|
1055 |
{
|
|
1056 |
// Always hide cancel attachment download item
|
|
1057 |
aMenuPane->SetItemDimmed(
|
|
1058 |
EESMRViewerCancelAttachmentDownload,
|
|
1059 |
ETrue );
|
|
1060 |
|
|
1061 |
// If attachment count is one, hide 'Save All' also
|
|
1062 |
if ( iAttachmentCount == 1 )
|
|
1063 |
{
|
|
1064 |
aMenuPane->SetItemDimmed(
|
|
1065 |
EESMRViewerSaveAllAttachments,
|
|
1066 |
ETrue );
|
|
1067 |
}
|
|
1068 |
}
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
// ---------------------------------------------------------------------------
|
|
1072 |
// CMRViewerAttachmentsField::IsAttachmentDownloadInProgress
|
|
1073 |
// ---------------------------------------------------------------------------
|
|
1074 |
//
|
|
1075 |
TBool CMRViewerAttachmentsField::IsAttachmentDownloadInProgress(
|
|
1076 |
const CCalAttachment& aAttachment )
|
|
1077 |
{
|
|
1078 |
TBool ret( EFalse );
|
|
1079 |
|
|
1080 |
RPointerArray<MCalRemoteAttachmentOperation>& remoteOperations(
|
|
1081 |
iAttachmentCommandHandler->RemoteOperations() );
|
|
1082 |
|
|
1083 |
TPtrC currentAttachmentName( aAttachment.Label() );
|
|
1084 |
|
|
1085 |
TInt downloadOperationCount( remoteOperations.Count() );
|
|
1086 |
if ( downloadOperationCount )
|
|
1087 |
{
|
|
1088 |
for ( TInt i(0); i < downloadOperationCount; ++i )
|
|
1089 |
{
|
|
1090 |
// There are download operations in progress
|
|
1091 |
const MCalRemoteAttachment& attachInfo =
|
|
1092 |
remoteOperations[i]->AttachmentInformation();
|
|
1093 |
|
|
1094 |
TPtrC label( attachInfo.AttachmentLabel() );
|
|
1095 |
|
|
1096 |
if ( label.Compare( currentAttachmentName ) == 0 )
|
|
1097 |
{
|
|
1098 |
ret = ETrue;
|
|
1099 |
}
|
|
1100 |
}
|
|
1101 |
}
|
|
1102 |
|
|
1103 |
return ret;
|
|
1104 |
}
|
|
1105 |
|
|
1106 |
// ---------------------------------------------------------------------------
|
|
1107 |
// CMRViewerAttachmentsField::SupportsLongTapFunctionalityL
|
|
1108 |
// ---------------------------------------------------------------------------
|
|
1109 |
//
|
|
1110 |
TBool CMRViewerAttachmentsField::SupportsLongTapFunctionalityL(
|
|
1111 |
const TPointerEvent &aPointerEvent )
|
|
1112 |
{
|
|
1113 |
FUNC_LOG;
|
|
1114 |
TBool ret( EFalse );
|
|
1115 |
|
|
1116 |
if ( iRichTextViewer->Rect().Contains( aPointerEvent.iPosition ) )
|
|
1117 |
{
|
|
1118 |
if( iRichTextViewer->PointerEventOccuresOnALinkL( aPointerEvent ) )
|
|
1119 |
{
|
|
1120 |
ret = ETrue;
|
|
1121 |
}
|
|
1122 |
}
|
|
1123 |
|
|
1124 |
return ret;
|
|
1125 |
}
|
|
1126 |
|
|
1127 |
// ---------------------------------------------------------------------------
|
|
1128 |
// CMRViewerAttachmentsField::MaxTextLengthInPixelsL
|
|
1129 |
// ---------------------------------------------------------------------------
|
|
1130 |
//
|
|
1131 |
TInt CMRViewerAttachmentsField::MaxTextLengthInPixelsL()
|
|
1132 |
{
|
|
1133 |
FUNC_LOG;
|
|
1134 |
/*
|
|
1135 |
* RichTextViewer length cannot be used here directly, since
|
|
1136 |
* this value is not always available. Value needs to be calculated.
|
|
1137 |
*/
|
|
1138 |
TRect tempFieldRect( TPoint( 0, 0 ), MinimumSize() );
|
|
1139 |
|
|
1140 |
// Rich Text viewer width is the same as other common rich text components
|
|
1141 |
// width
|
|
1142 |
TAknLayoutRect rowLayoutRect(
|
|
1143 |
NMRLayoutManager::GetFieldRowLayoutRect( tempFieldRect, 1 ) );
|
|
1144 |
TRect rowRect( rowLayoutRect.Rect() );
|
|
1145 |
|
|
1146 |
TAknLayoutText layoutText( NMRLayoutManager::GetLayoutText(
|
|
1147 |
rowRect,
|
|
1148 |
NMRLayoutManager::EMRTextLayoutTextEditor ) );
|
|
1149 |
|
|
1150 |
TRect tempRichTextViewerRect( layoutText.TextRect() );
|
|
1151 |
|
|
1152 |
return tempRichTextViewerRect.Width();
|
|
1153 |
}
|
|
1154 |
|
|
1155 |
//EOF
|