|
1 /* |
|
2 * Copyright (c) 2007-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cmrcmailremoteattachmentplugin.h" |
|
19 #include "cmrcmailremoteattachmentpluginattinfofetcher.h" |
|
20 #include "cfsmailclient.h" |
|
21 #include "mcalremoteattachmentinfo.h" |
|
22 #include "cmrcmailremoteattachmentplugindownloader.h" |
|
23 #include "mcalremoteattachment.h" |
|
24 |
|
25 #include "emailtrace.h" |
|
26 |
|
27 #include <f32file.h> |
|
28 #include <bamdesca.h> |
|
29 |
|
30 // Unnamed namespace for local definitions |
|
31 namespace { // namespace::codescanner |
|
32 |
|
33 } // namespace |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CMRCmailRemoteAttachmentPlugin::CMRCmailRemoteAttachmentPlugin |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CMRCmailRemoteAttachmentPlugin::CMRCmailRemoteAttachmentPlugin() |
|
42 { |
|
43 FUNC_LOG; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CMRCmailRemoteAttachmentPlugin::~CMRCmailRemoteAttachmentPlugin |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CMRCmailRemoteAttachmentPlugin::~CMRCmailRemoteAttachmentPlugin() |
|
51 { |
|
52 FUNC_LOG; |
|
53 |
|
54 delete iAttinfoFetcher; |
|
55 |
|
56 if ( iMailClient ) |
|
57 { |
|
58 // DEcrement mail client reference count |
|
59 iMailClient->Close(); |
|
60 iMailClient = NULL; |
|
61 } |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CMRCmailRemoteAttachmentPlugin::NewL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CMRCmailRemoteAttachmentPlugin* CMRCmailRemoteAttachmentPlugin::NewL() |
|
69 { |
|
70 FUNC_LOG; |
|
71 |
|
72 CMRCmailRemoteAttachmentPlugin* self = |
|
73 new (ELeave) CMRCmailRemoteAttachmentPlugin; |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop( self ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CMRCmailRemoteAttachmentPlugin::ConstructL |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CMRCmailRemoteAttachmentPlugin::ConstructL() |
|
85 { |
|
86 FUNC_LOG; |
|
87 |
|
88 iMailClient = CFSMailClient::NewL(); |
|
89 |
|
90 iAttinfoFetcher = |
|
91 CMRCmailRemoteAttachmentPluginAttinfoFetcher::NewL( |
|
92 *iMailClient ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CMRCmailRemoteAttachmentPlugin::AttachmentInfo |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CMRCmailRemoteAttachmentPlugin::AttachmentInfo( |
|
100 MCalRemoteAttachmentInfo& aAttachmentInfo, |
|
101 MDesCArray& aAttachmentUrlArray ) const |
|
102 { |
|
103 FUNC_LOG; |
|
104 |
|
105 TRAP_IGNORE( iAttinfoFetcher->FetchAttachmentInformationL( |
|
106 aAttachmentInfo, |
|
107 aAttachmentUrlArray ) ) |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CMRCmailRemoteAttachmentPlugin::DownloadAttachmentsL |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CMRCmailRemoteAttachmentPlugin::DownloadAttachmentsL( |
|
115 const RPointerArray<MCalRemoteAttachment>& aAttachments, |
|
116 RPointerArray<MCalRemoteAttachmentOperation>& aOperations, |
|
117 MCalRemoteAttachmentOperationObserver& aObserver ) |
|
118 { |
|
119 FUNC_LOG; |
|
120 |
|
121 TInt attachmentCount( aAttachments.Count() ); |
|
122 aOperations.ReserveL( attachmentCount ); |
|
123 for ( TInt i(0); i < attachmentCount; ++i ) |
|
124 { |
|
125 CMRCmailRemoteAttachmentDownloader* downloadCommand = |
|
126 CMRCmailRemoteAttachmentDownloader::NewL( |
|
127 *iMailClient, |
|
128 aObserver, |
|
129 aAttachments[i]->AttachmentIdentifier() ); |
|
130 |
|
131 // Ownership transferred |
|
132 aOperations.AppendL( downloadCommand ); |
|
133 } |
|
134 } |
|
135 |
|
136 // EOF |
|
137 |