64
|
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 attahcment field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cmropenattachmentcommand.h"
|
|
18 |
|
|
19 |
#include <calentry.h>
|
|
20 |
#include <calattachment.h>
|
|
21 |
#include <f32file.h>
|
|
22 |
#include <esmrgui.rsg>
|
|
23 |
#include <aknnotewrappers.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <DocumentHandler.h>
|
|
26 |
|
|
27 |
// DEBUG
|
|
28 |
#include "emailtrace.h"
|
|
29 |
|
|
30 |
|
|
31 |
// ======== MEMBER FUNCTIONS ========
|
|
32 |
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
// CMROpenAttachmentCommand::CMROpenAttachmentCommand
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
CMROpenAttachmentCommand::CMROpenAttachmentCommand(
|
|
38 |
CDocumentHandler& aDocHandler )
|
|
39 |
: iDocHandler( aDocHandler )
|
|
40 |
{
|
|
41 |
FUNC_LOG;
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// CMROpenAttachmentCommand::CMROpenAttachmentCommand
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CMROpenAttachmentCommand::~CMROpenAttachmentCommand()
|
|
49 |
{
|
|
50 |
FUNC_LOG;
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// CMROpenAttachmentCommand::NewL
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
CMROpenAttachmentCommand* CMROpenAttachmentCommand::NewL(
|
|
58 |
CDocumentHandler& aDocHandler )
|
|
59 |
{
|
|
60 |
FUNC_LOG;
|
|
61 |
|
|
62 |
CMROpenAttachmentCommand* self =
|
|
63 |
new (ELeave) CMROpenAttachmentCommand( aDocHandler );
|
|
64 |
CleanupStack::PushL( self );
|
|
65 |
self->ConstructL();
|
|
66 |
CleanupStack::Pop( self );
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
// CMROpenAttachmentCommand::ConstructL
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
void CMROpenAttachmentCommand::ConstructL()
|
|
75 |
{
|
|
76 |
FUNC_LOG;
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// CMROpenAttachmentCommand::ExecuteAttachmentCommandL
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CMROpenAttachmentCommand::ExecuteAttachmentCommandL(
|
|
84 |
CCalEntry& aEntry,
|
|
85 |
TInt aAttachmentIndex )
|
|
86 |
{
|
|
87 |
FUNC_LOG;
|
|
88 |
|
|
89 |
// Ownership not gained
|
|
90 |
CCalAttachmentFile* attachmentFile =
|
|
91 |
aEntry.AttachmentL( aAttachmentIndex )->FileAttachment();
|
|
92 |
|
|
93 |
RFile file;
|
|
94 |
attachmentFile->FetchFileHandleL( file );
|
|
95 |
CleanupClosePushL( file );
|
|
96 |
|
|
97 |
TDataType datatype(
|
|
98 |
aEntry.AttachmentL( aAttachmentIndex )->MimeType() );
|
|
99 |
|
|
100 |
// Doc handler will try to open file
|
|
101 |
TRAPD( err, iDocHandler.OpenFileEmbeddedL( file, datatype ) );
|
|
102 |
|
|
103 |
CleanupStack::PopAndDestroy( &file );
|
|
104 |
|
|
105 |
if( err != KErrNone )
|
|
106 |
{
|
|
107 |
CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
|
|
108 |
CleanupStack::PushL( note );
|
|
109 |
HBufC* buf = StringLoader::LoadLC(
|
|
110 |
R_MEET_REQ_INFO_CANNOT_OPEN_ATTACHMENT );
|
|
111 |
note->ExecuteLD( *buf );
|
|
112 |
CleanupStack::PopAndDestroy( buf );
|
|
113 |
CleanupStack::Pop( note );
|
|
114 |
}
|
|
115 |
}
|
|
116 |
|
|
117 |
// EOF
|