|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "calattachmentmanagerimpl.h" |
|
17 |
|
18 /** Create a new attachment manager. |
|
19 @param aSession An open calendar session to be used. |
|
20 @param aProgressCallBack The class to be called back when the attachment manager is created. |
|
21 Note that if an entry view or instance view has been created already, then this callback will happen immediately. |
|
22 @pre A calendar file has been opened on a calendar session. |
|
23 @post Once the callback is complete, the attachment manager will be constructed and ready for use. |
|
24 @return A pointer to a new attachment manager. |
|
25 @publishedPartner |
|
26 @released |
|
27 @capability None |
|
28 */ |
|
29 EXPORT_C CCalAttachmentManager* CCalAttachmentManager::NewL(CCalSession& aSession, MCalProgressCallBack& aProgressCallBack) |
|
30 { |
|
31 CCalAttachmentManager* self = new (ELeave) CCalAttachmentManager(); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(aSession, aProgressCallBack); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 CCalAttachmentManager::CCalAttachmentManager() |
|
39 { |
|
40 } |
|
41 |
|
42 /** Destructor for the attachment manager. |
|
43 @publishedPartner |
|
44 @released |
|
45 @pre An attachment manager has been constructed |
|
46 @post The attachment manager is destroyed |
|
47 @capability None |
|
48 */ |
|
49 EXPORT_C CCalAttachmentManager::~CCalAttachmentManager() |
|
50 { |
|
51 delete iAttachmentManagerImpl; |
|
52 } |
|
53 |
|
54 void CCalAttachmentManager::ConstructL(CCalSession& aSession, MCalProgressCallBack& aProgressCallBack) |
|
55 { |
|
56 iAttachmentManagerImpl = CCalAttachmentManagerImpl::NewL(aSession, aProgressCallBack); |
|
57 } |
|
58 |
|
59 /** Fetches the details of all unique file attachments referenced from entries within the calendar store, sorted as specified. |
|
60 This does not include URI attachments. |
|
61 Note that the full attachment data is not loaded in this operation, only the metadata for each of the file attachments. |
|
62 If an attachment is referenced by more than one entry, it will appear only once in the iterator. |
|
63 @param aSortOrder The order in which to sort the attachments. |
|
64 @return A pointer to an iterator of attachments. The caller takes ownership. |
|
65 @pre None |
|
66 @post A new attachment iterator is returned containing the sorted file attachments. |
|
67 @publishedPartner |
|
68 @released |
|
69 @capability ReadUserData |
|
70 */ |
|
71 EXPORT_C CCalAttachmentIterator* CCalAttachmentManager::FetchAttachmentsL(TSortOrder aSortOrder) const |
|
72 { |
|
73 CCalAttachmentIteratorImpl* impl = iAttachmentManagerImpl->FetchAttachmentsL(aSortOrder); |
|
74 CleanupStack::PushL(impl); |
|
75 CCalAttachmentIterator* iterator = new (ELeave) CCalAttachmentIterator(*impl); |
|
76 CleanupStack::Pop(impl); |
|
77 return iterator; |
|
78 } |
|
79 |
|
80 /** Fetches the local UIDs of all entries in the database that reference this file attachment. |
|
81 This does nothing if a URI attachment is passed in, or if the file attachment has not been stored in the calendar database yet. |
|
82 @param aUids On return, an array of local UIDs of all the entries that contain this file attachment. |
|
83 @param aAttachment The file attachment object whose referencing entries will be returned. |
|
84 @leave KErrArgument The attachment is not a file attachment - i.e. of type CCalAttachment::EFile. |
|
85 @pre None |
|
86 @post None |
|
87 @publishedPartner |
|
88 @released |
|
89 @capability ReadUserData |
|
90 */ |
|
91 EXPORT_C void CCalAttachmentManager::EntriesReferencingFileAttachmentL(RArray<TCalLocalUid>& aUids, const CCalAttachment& aAttachment) const |
|
92 { |
|
93 __ASSERT_ALWAYS(aAttachment.Type() == CCalAttachment::EFile, User::Leave(KErrArgument)); |
|
94 iAttachmentManagerImpl->EntriesReferencingFileAttachmentL(aUids, aAttachment.Impl()); |
|
95 } |
|
96 |
|
97 // |
|
98 // CCalAttachmentIterator // |
|
99 // |
|
100 |
|
101 // This takes ownership of aIterator |
|
102 CCalAttachmentIterator::CCalAttachmentIterator(CCalAttachmentIteratorImpl& aIterator) : |
|
103 iAttachmentIteratorImpl(&aIterator) |
|
104 { |
|
105 } |
|
106 |
|
107 /** Destructor. |
|
108 Clears resources of the attachment iterator. |
|
109 @pre An attachment iterator has been constructed from a CCalAttachmentManager::FetchAttachmentsL call. |
|
110 @post The iterator is destroyed. |
|
111 @publishedPartner |
|
112 @released |
|
113 @capability None |
|
114 */ |
|
115 EXPORT_C CCalAttachmentIterator::~CCalAttachmentIterator() |
|
116 { |
|
117 delete iAttachmentIteratorImpl; |
|
118 } |
|
119 |
|
120 /** Checks to see if there are more attachments in the iterator. |
|
121 If there are, the next one can be fetched by calling NextL. |
|
122 @return ETrue if there are more attachments, EFalse if not. |
|
123 @pre None |
|
124 @post None |
|
125 @publishedPartner |
|
126 @released |
|
127 @capability None |
|
128 */ |
|
129 EXPORT_C TBool CCalAttachmentIterator::HasMore() const |
|
130 { |
|
131 return iAttachmentIteratorImpl->HasMore(); |
|
132 } |
|
133 |
|
134 /** Returns the next attachment in the iterator, or NULL if there are no more attachments. |
|
135 @return A pointer to a new attachment object. Ownership is returned. NULL if the iterator has finished. |
|
136 @leave KErrNotFound if an attachment has been deleted since the original search that returned the iterator of attachments. |
|
137 Otherwise one of the system-wide error codes. |
|
138 @pre None |
|
139 @post The iterator moves to the next attachment in its results list. |
|
140 @publishedPartner |
|
141 @released |
|
142 @capability None |
|
143 */ |
|
144 EXPORT_C CCalAttachment* CCalAttachmentIterator::NextL() |
|
145 { |
|
146 return iAttachmentIteratorImpl->NextL(); |
|
147 } |
|
148 |
|
149 /** Returns the total number of attachments in the iterator. |
|
150 @return The number of attachments. |
|
151 @pre None |
|
152 @post None |
|
153 @publishedPartner |
|
154 @released |
|
155 @capability None |
|
156 */ |
|
157 EXPORT_C TInt CCalAttachmentIterator::Count() const |
|
158 { |
|
159 return iAttachmentIteratorImpl->Count(); |
|
160 } |