18 |
18 |
19 #include <calentry.h> |
19 #include <calentry.h> |
20 #include <calattachment.h> |
20 #include <calattachment.h> |
21 #include <f32file.h> |
21 #include <f32file.h> |
22 #include <esmrgui.rsg> |
22 #include <esmrgui.rsg> |
23 #include <NpdApi.h> |
|
24 #include <aknnotewrappers.h> |
23 #include <aknnotewrappers.h> |
25 #include <StringLoader.h> |
24 #include <StringLoader.h> |
26 #include <DocumentHandler.h> |
25 #include <DocumentHandler.h> |
27 |
26 |
28 // DEBUG |
27 // DEBUG |
29 #include "emailtrace.h" |
28 #include "emailtrace.h" |
30 |
29 |
31 // Unnamed namespace for local definitions |
|
32 namespace { // codescanner::namespace |
|
33 |
|
34 // Notepad data type |
|
35 _LIT8( KNotePadTextDataType, "text/plain" ); |
|
36 |
|
37 } |
|
38 |
30 |
39 // ======== MEMBER FUNCTIONS ======== |
31 // ======== MEMBER FUNCTIONS ======== |
40 |
32 |
41 // --------------------------------------------------------------------------- |
33 // --------------------------------------------------------------------------- |
42 // CMROpenAttachmentCommand::CMROpenAttachmentCommand |
34 // CMROpenAttachmentCommand::CMROpenAttachmentCommand |
46 CDocumentHandler& aDocHandler ) |
38 CDocumentHandler& aDocHandler ) |
47 : iDocHandler( aDocHandler ) |
39 : iDocHandler( aDocHandler ) |
48 { |
40 { |
49 FUNC_LOG; |
41 FUNC_LOG; |
50 } |
42 } |
51 |
43 |
52 // --------------------------------------------------------------------------- |
44 // --------------------------------------------------------------------------- |
53 // CMROpenAttachmentCommand::CMROpenAttachmentCommand |
45 // CMROpenAttachmentCommand::CMROpenAttachmentCommand |
54 // --------------------------------------------------------------------------- |
46 // --------------------------------------------------------------------------- |
55 // |
47 // |
56 CMROpenAttachmentCommand::~CMROpenAttachmentCommand() |
48 CMROpenAttachmentCommand::~CMROpenAttachmentCommand() |
64 // |
56 // |
65 CMROpenAttachmentCommand* CMROpenAttachmentCommand::NewL( |
57 CMROpenAttachmentCommand* CMROpenAttachmentCommand::NewL( |
66 CDocumentHandler& aDocHandler ) |
58 CDocumentHandler& aDocHandler ) |
67 { |
59 { |
68 FUNC_LOG; |
60 FUNC_LOG; |
69 |
61 |
70 CMROpenAttachmentCommand* self = |
62 CMROpenAttachmentCommand* self = |
71 new (ELeave) CMROpenAttachmentCommand( aDocHandler ); |
63 new (ELeave) CMROpenAttachmentCommand( aDocHandler ); |
72 CleanupStack::PushL( self ); |
64 CleanupStack::PushL( self ); |
73 self->ConstructL(); |
65 self->ConstructL(); |
74 CleanupStack::Pop( self ); |
66 CleanupStack::Pop( self ); |
91 void CMROpenAttachmentCommand::ExecuteAttachmentCommandL( |
83 void CMROpenAttachmentCommand::ExecuteAttachmentCommandL( |
92 CCalEntry& aEntry, |
84 CCalEntry& aEntry, |
93 TInt aAttachmentIndex ) |
85 TInt aAttachmentIndex ) |
94 { |
86 { |
95 FUNC_LOG; |
87 FUNC_LOG; |
96 |
88 |
97 // Ownership not gained |
89 // Ownership not gained |
98 CCalAttachmentFile* attachmentFile = |
90 CCalAttachmentFile* attachmentFile = |
99 aEntry.AttachmentL( aAttachmentIndex )->FileAttachment(); |
91 aEntry.AttachmentL( aAttachmentIndex )->FileAttachment(); |
100 |
92 |
101 RFile file; |
93 RFile file; |
102 attachmentFile->FetchFileHandleL( file ); |
94 attachmentFile->FetchFileHandleL( file ); |
103 CleanupClosePushL( file ); |
95 CleanupClosePushL( file ); |
104 |
96 |
105 TDataType datatype( |
97 TDataType datatype( |
106 aEntry.AttachmentL( aAttachmentIndex )->MimeType() ); |
98 aEntry.AttachmentL( aAttachmentIndex )->MimeType() ); |
107 |
99 |
108 TInt err( KErrNone ); |
100 // Doc handler will try to open file |
109 if( datatype == KNotePadTextDataType() ) |
101 TRAPD( err, iDocHandler.OpenFileEmbeddedL( file, datatype ) ); |
110 { |
102 |
111 // Notepad will try to open text/plain type data |
|
112 err = CNotepadApi::ExecFileViewerL( |
|
113 file, |
|
114 NULL, |
|
115 ETrue, |
|
116 EFalse, |
|
117 KCharacterSetIdentifierIso88591 ); |
|
118 } |
|
119 else |
|
120 { |
|
121 // Doc handler will try to open other than text files |
|
122 TRAP( err, iDocHandler.OpenFileEmbeddedL( file, datatype ) ); |
|
123 } |
|
124 |
|
125 CleanupStack::PopAndDestroy( &file ); |
103 CleanupStack::PopAndDestroy( &file ); |
126 |
104 |
127 if( err != KErrNone ) |
105 if( err != KErrNone ) |
128 { |
106 { |
129 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |
107 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |