28 #include "ccalremoteattachmentapi.h" |
28 #include "ccalremoteattachmentapi.h" |
29 #include "ccalremoteattachmentinfo.h" |
29 #include "ccalremoteattachmentinfo.h" |
30 #include "mcalremoteattachmentoperation.h" |
30 #include "mcalremoteattachmentoperation.h" |
31 #include "cesmrglobalnote.h" |
31 #include "cesmrglobalnote.h" |
32 |
32 |
33 #include <aknsbasicbackgroundcontrolcontext.h> |
33 #include <AknsBasicBackgroundControlContext.h> |
34 #include <calentry.h> |
34 #include <calentry.h> |
35 #include <calattachment.h> |
35 #include <calattachment.h> |
36 #include <stringloader.h> |
36 #include <StringLoader.h> |
37 #include <esmrgui.rsg> |
37 #include <esmrgui.rsg> |
38 #include <gulicon.h> |
38 #include <gulicon.h> |
39 #include <ct/rcpointerarray.h> |
39 #include <ct/rcpointerarray.h> |
40 #include <aknbiditextutils.h> |
40 #include <AknBidiTextUtils.h> |
41 #include <badesca.h> |
41 #include <badesca.h> |
42 |
42 |
43 // DEBUG |
43 // DEBUG |
44 #include "emailtrace.h" |
44 #include "emailtrace.h" |
45 |
45 |
316 } |
316 } |
317 |
317 |
318 // Layouting lock icon |
318 // Layouting lock icon |
319 if( iLockIcon ) |
319 if( iLockIcon ) |
320 { |
320 { |
321 TAknWindowComponentLayout iconLayout( |
321 TAknWindowComponentLayout iconLayout( |
322 NMRLayoutManager::GetWindowComponentLayout( |
322 NMRLayoutManager::GetWindowComponentLayout( |
323 NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); |
323 NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); |
324 AknLayoutUtils::LayoutImage( iLockIcon, rowRect, iconLayout ); |
324 AknLayoutUtils::LayoutImage( iLockIcon, rowRect, iconLayout ); |
325 } |
325 } |
326 |
326 |
327 // Layouting viewer rect |
327 // Layouting viewer rect |
328 TAknLayoutText viewerLayoutText; |
328 TAknLayoutText viewerLayoutText; |
329 if( iLockIcon ) |
329 if( iLockIcon ) |
330 { |
330 { |
331 viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect, |
331 viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect, |
332 NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); |
332 NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); |
333 } |
333 } |
334 else |
334 else |
335 { |
335 { |
336 viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect, |
336 viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect, |
337 NMRLayoutManager::EMRTextLayoutTextEditor ); |
337 NMRLayoutManager::EMRTextLayoutTextEditor ); |
338 } |
338 } |
339 |
339 |
340 TRect viewerRect( viewerLayoutText.TextRect() ); |
340 TRect viewerRect( viewerLayoutText.TextRect() ); |
341 |
341 |
342 // Resize height according to actual height required by edwin. |
342 // Resize height according to actual height required by edwin. |
343 viewerRect.Resize( 0, iSize.iHeight - viewerRect.Height() ); |
343 viewerRect.Resize( 0, iSize.iHeight - viewerRect.Height() ); |
344 iRichTextViewer->SetRect( viewerRect ); |
344 iRichTextViewer->SetRect( viewerRect ); |
345 |
345 |
346 // Layouting focus |
346 // Layouting focus |
347 TRect bgRect( 0, 0, 0, 0 ); |
347 TRect bgRect( 0, 0, 0, 0 ); |
348 if( iAttachmentCount > 1 ) |
348 if( iAttachmentCount > 1 ) |
349 { |
349 { |
350 bgRect.SetRect( |
350 bgRect.SetRect( |
574 |
574 |
575 iAttachmentCount = iEntry->Entry().AttachmentCountL(); |
575 iAttachmentCount = iEntry->Entry().AttachmentCountL(); |
576 attachmentLinks.ReserveL( iAttachmentCount ); |
576 attachmentLinks.ReserveL( iAttachmentCount ); |
577 for ( TInt i = 0; i < iAttachmentCount; ++i ) |
577 for ( TInt i = 0; i < iAttachmentCount; ++i ) |
578 { |
578 { |
579 CCalAttachment* att = iEntry->Entry().AttachmentL( i ); // Ownership not gained |
579 CCalAttachment* attachment = iEntry->Entry().AttachmentL( i ); // Ownership not gained |
580 |
580 |
581 // Reducing space required by file size information from |
581 const CFont* font = layoutText.Font(); |
582 // max line width, so that file name can be trimmed to correct |
582 TInt maxFileNameLengthInPixels( MaxTextLengthInPixelsL() ); |
583 // length |
583 |
584 TInt maxLineWidth = layoutText.TextRect().Width(); |
584 // Size information needs to be reduced from max filename length |
585 const CFont* font = layoutText.Font(); |
585 HBufC* attachmentSizeOnly( |
586 |
586 AttachmentNameAndSizeL( KNullDesC(), *attachment ) ); |
587 HBufC* attachmentSize = AttachmentNameAndSizeL( KNullDesC(), *att ); |
587 TInt sizeInformationLengthInPixels( |
588 TInt attachmentSizeLength = attachmentSize->Length(); |
588 font->TextWidthInPixels( *attachmentSizeOnly ) ); |
589 maxLineWidth -= font->TextWidthInPixels( *attachmentSize ); |
589 maxFileNameLengthInPixels -= sizeInformationLengthInPixels; |
590 delete attachmentSize; |
590 |
591 attachmentSize = NULL; |
591 // Trimming file name to fit to one line |
592 |
592 TPtrC text = attachment->Label(); |
593 // TODO: correct icon zise to correct one. Ask from UI specifier. |
593 HBufC* clippedTextHBufC = ClipTextLC( |
594 TSize iconSize( 20, 20); |
594 text, *font, maxFileNameLengthInPixels ); |
595 maxLineWidth -= iconSize.iWidth; |
595 TPtr clippedText = clippedTextHBufC->Des(); |
596 |
596 clippedText.Trim(); |
597 // Trimming file name to fit to one line |
|
598 TPtrC text = att->Label(); |
|
599 HBufC* clippedTextHBufC = ClipTextLC( text, *font, maxLineWidth ); |
|
600 TPtr clippedText = clippedTextHBufC->Des(); |
|
601 clippedText.Trim(); |
|
602 |
597 |
603 if ( clippedText.Length() > 0 ) |
598 if ( clippedText.Length() > 0 ) |
604 { |
599 { |
605 // Creating rich text link |
600 HBufC* buf = AttachmentNameAndSizeL( clippedText, *attachment ); |
606 CESMRRichTextLink* link = CESMRRichTextLink::NewL( |
601 CleanupStack::PushL( buf ); |
607 buffer.Length(), |
602 |
608 clippedText.Length() + attachmentSizeLength, |
603 // Creating rich text link |
609 text, |
604 CESMRRichTextLink* link = CESMRRichTextLink::NewL( |
610 CESMRRichTextLink::ETypeAttachment, |
605 buffer.Length(), |
611 CESMRRichTextLink::ETriggerKeyRight ); |
606 buf->Length(), |
612 CleanupStack::PushL( link ); |
607 text, |
613 attachmentLinks.AppendL( link ); |
608 CESMRRichTextLink::ETypeAttachment, |
614 CleanupStack::Pop( link ); |
609 CESMRRichTextLink::ETriggerKeyRight ); |
615 |
610 CleanupStack::PushL( link ); |
616 HBufC* buf = AttachmentNameAndSizeL( clippedText, *att ); |
611 attachmentLinks.AppendL( link ); |
617 CleanupStack::PushL( buf ); |
612 CleanupStack::Pop( link ); |
618 |
613 |
619 // Append attachment name and size with line feed to buffer |
614 // Append attachment name and size with line feed to buffer |
620 buffer.ReAllocL( buffer.Length() + |
615 buffer.ReAllocL( buffer.Length() + |
621 clippedText.Length() + |
616 clippedText.Length() + |
622 buf->Length() + |
617 buf->Length() + |
623 KNewLine().Length() ); |
618 KNewLine().Length() ); |
624 |
619 |
625 buffer.Append( buf->Des() ); |
620 buffer.Append( buf->Des() ); |
626 buffer.Append( KNewLine ); |
621 buffer.Append( KNewLine ); |
627 |
622 |
628 CleanupStack::PopAndDestroy( buf ); |
623 CleanupStack::PopAndDestroy( buf ); |
629 } |
624 } |
630 |
625 |
631 CleanupStack::PopAndDestroy( clippedTextHBufC ); |
626 CleanupStack::PopAndDestroy( clippedTextHBufC ); |
632 } |
627 } |
633 |
628 |
978 } |
973 } |
979 } |
974 } |
980 |
975 |
981 ASSERT( selectedAttachment ); |
976 ASSERT( selectedAttachment ); |
982 |
977 |
983 |
978 |
984 /* |
979 /* |
985 * Case 1: Download in progress |
980 * Case 1: Download in progress |
986 */ |
981 */ |
987 if( commandInProgress ) |
982 if( commandInProgress ) |
988 { |
983 { |
989 // A) If selected attachment is remote attachment and download is in progress |
984 // A) If selected attachment is remote attachment and download is in progress |
990 // or attachment is queued for downloading |
985 // or attachment is queued for downloading |
991 if( selectedAttachment->Type() == CCalAttachment::EUri && |
986 if( selectedAttachment->Type() == CCalAttachment::EUri && |
992 EESMRViewerSaveAllAttachments == commandInProgress ) |
987 EESMRViewerSaveAllAttachments == commandInProgress ) |
993 { |
988 { |
994 aMenuPane->SetItemDimmed( |
989 aMenuPane->SetItemDimmed( |
995 EESMRViewerOpenAttachment, |
990 EESMRViewerOpenAttachment, |
996 ETrue ); |
991 ETrue ); |
997 |
992 |
998 aMenuPane->SetItemDimmed( |
993 aMenuPane->SetItemDimmed( |
999 EESMRViewerSaveAttachment, |
994 EESMRViewerSaveAttachment, |
1000 ETrue ); |
995 ETrue ); |
1001 |
996 |
1002 aMenuPane->SetItemDimmed( |
997 aMenuPane->SetItemDimmed( |
1003 EESMRViewerSaveAllAttachments, |
998 EESMRViewerSaveAllAttachments, |
1004 ETrue ); |
999 ETrue ); |
1005 } |
1000 } |
1006 |
1001 |
1007 // B) If selected attachment is local attachment |
1002 // B) If selected attachment is local attachment |
1008 else if( selectedAttachment->Type() == CCalAttachment::EFile ) |
1003 else if( selectedAttachment->Type() == CCalAttachment::EFile ) |
1009 { |
1004 { |
1010 // Always hide cancel attachment download item |
1005 // Always hide cancel attachment download item |
1011 aMenuPane->SetItemDimmed( |
1006 aMenuPane->SetItemDimmed( |
1012 EESMRViewerCancelAttachmentDownload, |
1007 EESMRViewerCancelAttachmentDownload, |
1013 ETrue ); |
1008 ETrue ); |
1014 |
1009 |
1015 // If attachment count is one, hide 'Save All' also |
1010 // If attachment count is one, hide 'Save All' also |
1016 if ( iAttachmentCount == 1 ) |
1011 if ( iAttachmentCount == 1 ) |
1017 { |
1012 { |
1018 aMenuPane->SetItemDimmed( |
1013 aMenuPane->SetItemDimmed( |
1019 EESMRViewerSaveAllAttachments, |
1014 EESMRViewerSaveAllAttachments, |
1020 ETrue ); |
1015 ETrue ); |
1021 } |
1016 } |
1022 } |
1017 } |
1023 |
1018 |
1024 // C) If selected attachment is Uri, and some other command is in progress |
1019 // C) If selected attachment is Uri, and some other command is in progress |
1025 // than save all |
1020 // than save all |
1026 else if( selectedAttachment->Type() == CCalAttachment::EUri && |
1021 else if( selectedAttachment->Type() == CCalAttachment::EUri && |
1027 commandInProgress != EESMRViewerSaveAllAttachments ) |
1022 commandInProgress != EESMRViewerSaveAllAttachments ) |
1028 { |
1023 { |
1029 // If this attachment is the one being downloaded |
1024 // If this attachment is the one being downloaded |
1030 if( IsAttachmentDownloadInProgress( *selectedAttachment ) ) |
1025 if( IsAttachmentDownloadInProgress( *selectedAttachment ) ) |
1031 { |
1026 { |
1032 aMenuPane->SetItemDimmed( |
1027 aMenuPane->SetItemDimmed( |
1033 EESMRViewerOpenAttachment, |
1028 EESMRViewerOpenAttachment, |
1034 ETrue ); |
1029 ETrue ); |
1035 |
1030 |
1036 aMenuPane->SetItemDimmed( |
1031 aMenuPane->SetItemDimmed( |
1037 EESMRViewerSaveAttachment, |
1032 EESMRViewerSaveAttachment, |
1038 ETrue ); |
1033 ETrue ); |
1039 |
1034 |
1040 aMenuPane->SetItemDimmed( |
1035 aMenuPane->SetItemDimmed( |
1041 EESMRViewerSaveAllAttachments, |
1036 EESMRViewerSaveAllAttachments, |
1042 ETrue ); |
1037 ETrue ); |
1043 } |
1038 } |
1044 |
1039 |
1045 |
1040 |
1046 // if this attacment is not the one being downloaded |
1041 // if this attacment is not the one being downloaded |
1047 else |
1042 else |
1048 { |
1043 { |
1049 // Always hide cancel attachment download item |
1044 // Always hide cancel attachment download item |
1050 aMenuPane->SetItemDimmed( |
1045 aMenuPane->SetItemDimmed( |
1051 EESMRViewerCancelAttachmentDownload, |
1046 EESMRViewerCancelAttachmentDownload, |
1052 ETrue ); |
1047 ETrue ); |
1053 |
1048 |
1054 // If attachment count is one, hide 'Save All' also |
1049 // If attachment count is one, hide 'Save All' also |
1055 if ( iAttachmentCount == 1 ) |
1050 if ( iAttachmentCount == 1 ) |
1056 { |
1051 { |
1057 aMenuPane->SetItemDimmed( |
1052 aMenuPane->SetItemDimmed( |
1058 EESMRViewerSaveAllAttachments, |
1053 EESMRViewerSaveAllAttachments, |
1059 ETrue ); |
1054 ETrue ); |
1060 } |
1055 } |
1061 } |
1056 } |
1062 } |
1057 } |
1063 } |
1058 } |
1064 |
1059 |
1065 /* |
1060 /* |
1066 * Case 2: No download in progress |
1061 * Case 2: No download in progress |
1067 */ |
1062 */ |
1068 else |
1063 else |
1069 { |
1064 { |
1070 // Always hide cancel attachment download item |
1065 // Always hide cancel attachment download item |
1071 aMenuPane->SetItemDimmed( |
1066 aMenuPane->SetItemDimmed( |
1072 EESMRViewerCancelAttachmentDownload, |
1067 EESMRViewerCancelAttachmentDownload, |
1073 ETrue ); |
1068 ETrue ); |
1074 |
1069 |
1075 // If attachment count is one, hide 'Save All' also |
1070 // If attachment count is one, hide 'Save All' also |
1076 if ( iAttachmentCount == 1 ) |
1071 if ( iAttachmentCount == 1 ) |
1077 { |
1072 { |
1078 aMenuPane->SetItemDimmed( |
1073 aMenuPane->SetItemDimmed( |
1079 EESMRViewerSaveAllAttachments, |
1074 EESMRViewerSaveAllAttachments, |
1084 |
1079 |
1085 // --------------------------------------------------------------------------- |
1080 // --------------------------------------------------------------------------- |
1086 // CMRViewerAttachmentsField::IsAttachmentDownloadInProgress |
1081 // CMRViewerAttachmentsField::IsAttachmentDownloadInProgress |
1087 // --------------------------------------------------------------------------- |
1082 // --------------------------------------------------------------------------- |
1088 // |
1083 // |
1089 TBool CMRViewerAttachmentsField::IsAttachmentDownloadInProgress( |
1084 TBool CMRViewerAttachmentsField::IsAttachmentDownloadInProgress( |
1090 const CCalAttachment& aAttachment ) |
1085 const CCalAttachment& aAttachment ) |
1091 { |
1086 { |
1092 TBool ret( EFalse ); |
1087 TBool ret( EFalse ); |
1093 |
1088 |
1094 RPointerArray<MCalRemoteAttachmentOperation>& remoteOperations( |
1089 RPointerArray<MCalRemoteAttachmentOperation>& remoteOperations( |
1095 iAttachmentCommandHandler->RemoteOperations() ); |
1090 iAttachmentCommandHandler->RemoteOperations() ); |
1096 |
1091 |
1097 TPtrC currentAttachmentName( aAttachment.Label() ); |
1092 TPtrC currentAttachmentName( aAttachment.Label() ); |
1098 |
1093 |
1099 TInt downloadOperationCount( remoteOperations.Count() ); |
1094 TInt downloadOperationCount( remoteOperations.Count() ); |
1100 if ( downloadOperationCount ) |
1095 if ( downloadOperationCount ) |
1101 { |
1096 { |
1102 for ( TInt i(0); i < downloadOperationCount; ++i ) |
1097 for ( TInt i(0); i < downloadOperationCount; ++i ) |
1103 { |
1098 { |
1104 // There are download operations in progress |
1099 // There are download operations in progress |
1105 const MCalRemoteAttachment& attachInfo = |
1100 const MCalRemoteAttachment& attachInfo = |
1106 remoteOperations[i]->AttachmentInformation(); |
1101 remoteOperations[i]->AttachmentInformation(); |
1107 |
1102 |
1108 TPtrC label( attachInfo.AttachmentLabel() ); |
1103 TPtrC label( attachInfo.AttachmentLabel() ); |
1109 |
1104 |
1110 if ( label.Compare( currentAttachmentName ) == 0 ) |
1105 if ( label.Compare( currentAttachmentName ) == 0 ) |
1111 { |
1106 { |
1112 ret = ETrue; |
1107 ret = ETrue; |
1113 } |
1108 } |
1114 } |
1109 } |
1115 } |
1110 } |
1116 |
1111 |
1117 return ret; |
1112 return ret; |
1118 } |
1113 } |
1119 |
1114 |
|
1115 // --------------------------------------------------------------------------- |
|
1116 // CMRViewerAttachmentsField::SupportsLongTapFunctionalityL |
|
1117 // --------------------------------------------------------------------------- |
|
1118 // |
|
1119 TBool CMRViewerAttachmentsField::SupportsLongTapFunctionalityL( |
|
1120 const TPointerEvent &aPointerEvent ) |
|
1121 { |
|
1122 FUNC_LOG; |
|
1123 TBool ret( EFalse ); |
|
1124 |
|
1125 if ( iRichTextViewer->Rect().Contains( aPointerEvent.iPosition ) ) |
|
1126 { |
|
1127 if( iRichTextViewer->PointerEventOccuresOnALinkL( aPointerEvent ) ) |
|
1128 { |
|
1129 ret = ETrue; |
|
1130 } |
|
1131 } |
|
1132 |
|
1133 return ret; |
|
1134 } |
|
1135 |
|
1136 // --------------------------------------------------------------------------- |
|
1137 // CMRViewerAttachmentsField::MaxTextLengthInPixelsL |
|
1138 // --------------------------------------------------------------------------- |
|
1139 // |
|
1140 TInt CMRViewerAttachmentsField::MaxTextLengthInPixelsL() |
|
1141 { |
|
1142 FUNC_LOG; |
|
1143 /* |
|
1144 * RichTextViewer length cannot be used here directly, since |
|
1145 * this value is not always available. Value needs to be calculated. |
|
1146 */ |
|
1147 TRect tempFieldRect( TPoint( 0, 0 ), MinimumSize() ); |
|
1148 |
|
1149 // Rich Text viewer width is the same as other common rich text components |
|
1150 // width |
|
1151 TAknLayoutRect rowLayoutRect( |
|
1152 NMRLayoutManager::GetFieldRowLayoutRect( tempFieldRect, 1 ) ); |
|
1153 TRect rowRect( rowLayoutRect.Rect() ); |
|
1154 |
|
1155 TAknLayoutText layoutText( NMRLayoutManager::GetLayoutText( |
|
1156 rowRect, |
|
1157 NMRLayoutManager::EMRTextLayoutTextEditor ) ); |
|
1158 |
|
1159 TRect tempRichTextViewerRect( layoutText.TextRect() ); |
|
1160 |
|
1161 return tempRichTextViewerRect.Width(); |
|
1162 } |
|
1163 |
1120 //EOF |
1164 //EOF |