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 save attachment command implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cmrsaveattachmentcommand.h"
|
|
18 |
|
|
19 |
#include <calentry.h>
|
|
20 |
#include <calattachment.h>
|
|
21 |
#include <f32file.h>
|
|
22 |
#include <DocumentHandler.h>
|
|
23 |
#include <coemain.h>
|
|
24 |
#include <esmrgui.rsg>
|
|
25 |
#include <NpdApi.h>
|
|
26 |
#include <aknnotewrappers.h>
|
|
27 |
#include <StringLoader.h>
|
|
28 |
|
|
29 |
// DEBUG
|
|
30 |
#include "emailtrace.h"
|
|
31 |
|
|
32 |
|
|
33 |
// ======== MEMBER FUNCTIONS ========
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// CMRSaveAttachmentCommand::CMRSaveAttachmentCommand
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
CMRSaveAttachmentCommand::CMRSaveAttachmentCommand(
|
|
40 |
CDocumentHandler& aDocHandler ) :
|
|
41 |
CMRAttachmentCommand(),
|
|
42 |
iDocHandler( aDocHandler )
|
|
43 |
{
|
|
44 |
FUNC_LOG;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// CMRSaveAttachmentCommand::CMRSaveAttachmentCommand
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CMRSaveAttachmentCommand::~CMRSaveAttachmentCommand()
|
|
52 |
{
|
|
53 |
FUNC_LOG;
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// CMRSaveAttachmentCommand::NewL
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CMRSaveAttachmentCommand* CMRSaveAttachmentCommand::NewL(
|
|
61 |
CDocumentHandler& aDocHandler )
|
|
62 |
{
|
|
63 |
FUNC_LOG;
|
|
64 |
|
|
65 |
CMRSaveAttachmentCommand* self =
|
|
66 |
new( ELeave )CMRSaveAttachmentCommand( aDocHandler );
|
|
67 |
CleanupStack::PushL( self );
|
|
68 |
self->ConstructL();
|
|
69 |
CleanupStack::Pop( self );
|
|
70 |
return self;
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// CMRSaveAttachmentCommand::ConstructL
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
void CMRSaveAttachmentCommand::ConstructL()
|
|
78 |
{
|
|
79 |
FUNC_LOG;
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// CMRSaveAttachmentCommand::ExecuteAttachmentCommandL
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CMRSaveAttachmentCommand::ExecuteAttachmentCommandL(
|
|
87 |
CCalEntry& aEntry,
|
|
88 |
TInt aAttachmentIndex )
|
|
89 |
{
|
|
90 |
FUNC_LOG;
|
|
91 |
|
|
92 |
CCalAttachmentFile* attachmentFile =
|
|
93 |
aEntry.AttachmentL( aAttachmentIndex )->FileAttachment(); // Ownership not gained
|
|
94 |
|
|
95 |
if ( attachmentFile ) // Ignore URI attachment
|
|
96 |
{
|
|
97 |
RFile file;
|
|
98 |
attachmentFile->FetchFileHandleL( file );
|
|
99 |
CleanupClosePushL( file );
|
|
100 |
|
|
101 |
TFileName fileName;
|
|
102 |
file.FullName( fileName );
|
|
103 |
|
|
104 |
TDataType type;
|
|
105 |
|
|
106 |
// Document handler takes care of the saving process.
|
|
107 |
TInt res = iDocHandler.CopyL( file, fileName, type, NULL );
|
|
108 |
|
|
109 |
if ( KUserCancel == res )
|
|
110 |
{
|
|
111 |
User::Leave( KErrCancel );
|
|
112 |
}
|
|
113 |
|
|
114 |
CleanupStack::PopAndDestroy( &file );
|
|
115 |
}
|
|
116 |
}
|
|
117 |
|
|
118 |
// EOF
|