|
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 "cmrcmailremoteattachmentpluginattinfofetcher.h" |
|
19 #include "tmrcmailremoteattachmentpluginurlparser.h" |
|
20 #include "mcalremoteattachmentinfo.h" |
|
21 #include "mcalremoteattachment.h" |
|
22 #include "cfsmailclient.h" |
|
23 #include "emailtrace.h" |
|
24 |
|
25 #include <ct/rcpointerarray.h> |
|
26 |
|
27 // Unnamed namespace for local definitions |
|
28 namespace { // namespace::codescanner |
|
29 |
|
30 } // namespace |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CMRCmailRemoteAttachmentPluginAttinfoFetcher::CMRCmailRemoteAttachmentPluginAttinfoFetcher |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CMRCmailRemoteAttachmentPluginAttinfoFetcher::CMRCmailRemoteAttachmentPluginAttinfoFetcher( |
|
39 CFSMailClient& aMailClient ) |
|
40 : iMailClient( aMailClient ) |
|
41 { |
|
42 FUNC_LOG; |
|
43 } |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CMRCmailRemoteAttachmentPluginAttinfoFetcher::~CMRCmailRemoteAttachmentPluginAttinfoFetcher |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CMRCmailRemoteAttachmentPluginAttinfoFetcher::~CMRCmailRemoteAttachmentPluginAttinfoFetcher() |
|
51 { |
|
52 FUNC_LOG; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CMRCmailRemoteAttachmentPluginAttinfoFetcher::NewL |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CMRCmailRemoteAttachmentPluginAttinfoFetcher* |
|
60 CMRCmailRemoteAttachmentPluginAttinfoFetcher::NewL( |
|
61 CFSMailClient& aMailClient ) |
|
62 { |
|
63 FUNC_LOG; |
|
64 |
|
65 CMRCmailRemoteAttachmentPluginAttinfoFetcher* self = |
|
66 new (ELeave) CMRCmailRemoteAttachmentPluginAttinfoFetcher( |
|
67 aMailClient ); |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CMRCmailRemoteAttachmentPluginAttinfoFetcher::ConstructL |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CMRCmailRemoteAttachmentPluginAttinfoFetcher::ConstructL() |
|
80 { |
|
81 FUNC_LOG; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CMRCmailRemoteAttachmentPluginAttinfoFetcher::FetchAttachmentInformationL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CMRCmailRemoteAttachmentPluginAttinfoFetcher::FetchAttachmentInformationL( |
|
89 MCalRemoteAttachmentInfo& aAttachmentInfo, |
|
90 MDesCArray& aAttachmentUrlArray ) |
|
91 { |
|
92 FUNC_LOG; |
|
93 |
|
94 TInt attachmentInfoCount( aAttachmentUrlArray.MdcaCount() ); |
|
95 |
|
96 for ( TInt i(0); i < attachmentInfoCount; ++i ) |
|
97 { |
|
98 TMRCMailRemoteAttachmentPluginURLParser mailIdParser; |
|
99 |
|
100 TPtrC uri( aAttachmentUrlArray.MdcaPoint(i) ); |
|
101 |
|
102 TInt err = mailIdParser.Parse( uri ); |
|
103 User::LeaveIfError( err ); |
|
104 |
|
105 AddAttachmentInformationL( mailIdParser, uri, aAttachmentInfo ); |
|
106 } |
|
107 |
|
108 |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CMRCmailRemoteAttachmentPluginAttinfoFetcher::FetchAttachmentInformationL |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CMRCmailRemoteAttachmentPluginAttinfoFetcher::AddAttachmentInformationL( |
|
116 TMRCMailRemoteAttachmentPluginURLParser& aParser, |
|
117 const TDesC& aUri, |
|
118 MCalRemoteAttachmentInfo& aAttachmentInfo ) |
|
119 { |
|
120 FUNC_LOG; |
|
121 |
|
122 // Fetch message |
|
123 CFSMailMessage* message = iMailClient.GetMessageByUidL( |
|
124 aParser.iMailboxUid, |
|
125 aParser.iFolderUid, |
|
126 aParser.iMessageUid, |
|
127 EFSMsgDataStructure ); |
|
128 |
|
129 CleanupStack::PushL( message ); |
|
130 |
|
131 CFSMailMessagePart* attachment = |
|
132 message->ChildPartL( aParser.iMessagepartUid ); |
|
133 CleanupStack::PushL( attachment ); |
|
134 |
|
135 TPtrC attachmentName( attachment->AttachmentNameL() ); |
|
136 TInt attachmentSize( attachment->ContentSize() ); |
|
137 |
|
138 MCalRemoteAttachment::TCalRemoteAttachmentState attachmentState( |
|
139 MCalRemoteAttachment::EAttachmentStateNotDownloaded ); |
|
140 |
|
141 if ( EFSFull == attachment->FetchLoadState() ) |
|
142 { |
|
143 attachmentState = MCalRemoteAttachment::EAttachmentStateDownloaded; |
|
144 } |
|
145 |
|
146 aAttachmentInfo.AddAttachmentInfoL( |
|
147 aUri, |
|
148 attachmentName, |
|
149 attachmentSize, |
|
150 attachmentState ); |
|
151 |
|
152 CleanupStack::PopAndDestroy( attachment ); |
|
153 CleanupStack::PopAndDestroy( message ); |
|
154 } |
|
155 |
|
156 // EOF |