|
1 /* |
|
2 * Copyright (c) 2005 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 * UI Extension class for Meeting Request Utils. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CMRUTILSUISERVICES_H |
|
22 #define CMRUTILSUISERVICES_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "MMRUtilsUiServices.h" |
|
26 #include "MRHelpers.h" |
|
27 #include <msvapi.h> |
|
28 #include <e32base.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CMRUtilsInternal; |
|
32 class CCalSession; |
|
33 class MMRUtilsEmailSender; |
|
34 class CMRMailboxUtils; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Implements MMRUtilsUiServices. |
|
40 */ |
|
41 class CMRUtilsUiServices |
|
42 : public CBase, |
|
43 public MMRUtilsUiServices, |
|
44 public MMsvSessionObserver |
|
45 { |
|
46 public: // Constructors and destructors |
|
47 |
|
48 static CMRUtilsUiServices* NewL( CMRUtilsInternal& aMRUtils, |
|
49 CCalSession& aCalSession, |
|
50 CMsvSession* aMsvSession, |
|
51 CMRMailboxUtils& aMRMailboxUtils ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 ~CMRUtilsUiServices(); |
|
57 |
|
58 protected: // From MMRUtilsUiServices |
|
59 |
|
60 TInt RespondWithUiL( const RPointerArray<CCalEntry>& aEntries, |
|
61 CCalAttendee::TCalStatus aStatus, |
|
62 TMsvId aMailbox ); |
|
63 |
|
64 TInt CancelWithUiL( const RPointerArray<CCalEntry>& aEntries, |
|
65 TMsvId aMailbox ); |
|
66 |
|
67 TInt DeleteWithUiL( const CCalEntry& aEntry, TMsvId aMailbox ); |
|
68 |
|
69 TInt DeleteWithUiL( CCalInstance* aInstance, TMsvId aMailbox ); |
|
70 |
|
71 void ReplyToL( CMRUtilsInternal::TMailRecipients aRecipients, |
|
72 const CCalEntry& aCalEntry, |
|
73 const TDesC& aSenderAddr, |
|
74 TMsvId aMailbox ); |
|
75 |
|
76 void SendL( const CCalEntry& aCalEntry, TMsvId aMailbox ); |
|
77 |
|
78 protected: // From MMsvSessionObserver |
|
79 |
|
80 void HandleSessionEventL( TMsvSessionEvent aEvent, |
|
81 TAny* aArg1, |
|
82 TAny* aArg2, |
|
83 TAny* aArg3 ); |
|
84 |
|
85 protected: // New functions |
|
86 |
|
87 /** |
|
88 * Method which performs, if applicable, response/cancel operation |
|
89 * as a sub-operation of delete. The result of sub-operation is |
|
90 * neglected. |
|
91 * @param aEntry entry to be deleted |
|
92 * @param aInstance, may be NULL |
|
93 * @param aMailbox mailbox used for sending response/cancel |
|
94 */ |
|
95 void PerformDeleteSubOpL( const CCalEntry& aEntry, |
|
96 const CCalInstance* aInstance, |
|
97 TMsvId aMailbox ); |
|
98 |
|
99 /** |
|
100 * Goes through entries in the array, checks which should be |
|
101 * cancelled/responded, and updates database status. |
|
102 * @param aEntries |
|
103 * @param aValidIndexes |
|
104 * @param aIsCancellation ETrue if operation is cancellation |
|
105 * @param aStatus used if aIsCancellation = EFalse |
|
106 */ |
|
107 void EvaluateAndUpdateL( const RPointerArray<CCalEntry>& aEntries, |
|
108 RArray<TInt>& aValidIndexes, |
|
109 TBool aIsCancellation, |
|
110 CCalAttendee::TCalStatus aStatus = |
|
111 CCalAttendee::ENeedsAction ); |
|
112 |
|
113 /** |
|
114 * Checks whether the given entry can be cancelled. |
|
115 * @param aEntry entry to evaluate |
|
116 * @return ETrue if can be cancelled |
|
117 */ |
|
118 TBool IsValidForCancelL( const CCalEntry& aEntry ); |
|
119 |
|
120 /** |
|
121 * Checks whether the given entry can be responded to. |
|
122 * @param aEntry entry to evaluate |
|
123 * @return ETrue if can be responded to |
|
124 */ |
|
125 TBool IsValidForResponseL( const CCalEntry& aEntry ); |
|
126 |
|
127 /** |
|
128 * Helper method for checking that request is not cancelled or |
|
129 * out of date. |
|
130 * @param aEntry entry to evaluate |
|
131 * @return ETrue if request is valid |
|
132 */ |
|
133 TBool IsValidRequestL( const CCalEntry& aEntry ) const; |
|
134 |
|
135 /** |
|
136 * Updates entry status in db. |
|
137 * @param aEntry |
|
138 * @param aIsCancellation ETrue if operation is cancellation |
|
139 * @param aStatus used if aIsCancellation = EFalse |
|
140 */ |
|
141 void UpdateDbStatusL( const CCalEntry& aEntry, |
|
142 TBool aIsCancellation, |
|
143 CCalAttendee::TCalStatus aStatus ) const; |
|
144 |
|
145 /** |
|
146 * Queries user for sending options and if requested sends |
|
147 * cancellations or responsed. Utilizes QuerySendChoiceL |
|
148 * and CreateToBeSentL for doing it's tasks. |
|
149 * Parameter aInstance is used only in context of deleting one |
|
150 * instance, in that case also aEntries contains only one entry. |
|
151 * @param aEntries array of entries |
|
152 * @param aValidIndexes indexes in aEntries valid for response/cancel |
|
153 * @param aInstance, may be NULL |
|
154 * @param aMailbox mailbox used for sending response/cancel |
|
155 * @param aIsCancellation ETrue if operation is cancellation |
|
156 * @param aStatus used if aIsCancellation = EFalse |
|
157 */ |
|
158 TInt QueryAndSendL( const RPointerArray<CCalEntry>& aEntries, |
|
159 const RArray<TInt>& aValidIndexes, |
|
160 const CCalInstance* aInstance, |
|
161 TMsvId aMailbox, |
|
162 TBool aIsCancellation, |
|
163 CCalAttendee::TCalStatus aStatus = |
|
164 CCalAttendee::ENeedsAction ); |
|
165 |
|
166 /** |
|
167 * Queries send/edit choice for a cancellation or response. |
|
168 * Returns command code or an error code. |
|
169 * @param aBase base entry for data shown in the query |
|
170 * @param aIsCancellation ETrue if operation is cancellation |
|
171 * @param aStatus used if sending response, not cancellation |
|
172 * @return command code or an error code. |
|
173 */ |
|
174 TInt QuerySendChoiceL( const CCalEntry& aBase, |
|
175 TBool aIsCancellation, |
|
176 CCalAttendee::TCalStatus aStatus ) const; |
|
177 |
|
178 /** |
|
179 * Creates a response or cancellation based on the given request. |
|
180 * @param aBase base entry for creating response |
|
181 * @param aInstance, may be NULL |
|
182 * @param aDescription description text for the response |
|
183 * @param aIsCancellation ETrue if operation is cancellation |
|
184 * @return created entry, ownership is transferred |
|
185 */ |
|
186 CCalEntry* CreateToBeSentLC( const CCalEntry& aBase, |
|
187 const CCalInstance* aInstance, |
|
188 const TDesC& aDescription, |
|
189 TBool aIsCancellation ) const; |
|
190 |
|
191 /** |
|
192 * Creates a response based on the given request. |
|
193 * @param aBase base entry for creating response |
|
194 * @param aInstance, may be NULL |
|
195 * @param aDescription description text for the response |
|
196 * @return created entry, ownership is transferred |
|
197 */ |
|
198 CCalEntry* CreateResponseLC( const CCalEntry& aBase, |
|
199 const CCalInstance* aInstance, |
|
200 const TDesC& aDescription ) const; |
|
201 |
|
202 /** |
|
203 * Creates a cancellation based on the given request. |
|
204 * @param aBase base entry for creating cancellation |
|
205 * @param aInstance, may be NULL |
|
206 * @param aDescription description text for the cancellation |
|
207 * @return created entry, ownership is transferred |
|
208 */ |
|
209 CCalEntry* CreateCancelLC( const CCalEntry& aBase, |
|
210 const CCalInstance* aInstance, |
|
211 const TDesC& aDescription ) const; |
|
212 |
|
213 /** |
|
214 * Creates a new entry based on given arguments. |
|
215 * Entry is left in the cleanupstack |
|
216 * @param aBase base entry |
|
217 * @param aInstance, may be NULL |
|
218 * @param aMethod method type for the new entry |
|
219 * @param aSequenceNumber sequence number for the new entry |
|
220 * @param aCopyType specifies what data is copied |
|
221 * @return created entry, ownership is transferred |
|
222 */ |
|
223 CCalEntry* CreateFromLC( const CCalEntry& aBase, |
|
224 const CCalInstance* aInstance, |
|
225 CCalEntry::TMethod aMethod, |
|
226 TInt aSequenceNumber, |
|
227 MRHelpers::TCopyFields aCopyType ) const; |
|
228 |
|
229 /** |
|
230 * Looks up SMTP service which is related to given service. |
|
231 * This is used for reading SMTP settings. |
|
232 */ |
|
233 TMsvId CorrespondingSmtpServiceL( TMsvId aRelatedService ); |
|
234 |
|
235 /** |
|
236 * Helper method for lazy creation of msv session. |
|
237 */ |
|
238 void EnsureMsvSessionExistsL(); |
|
239 |
|
240 protected: // Constructors and destructors |
|
241 |
|
242 /** |
|
243 * C++ default constructor. |
|
244 */ |
|
245 CMRUtilsUiServices( CMRUtilsInternal& aMRUtils, |
|
246 CMsvSession* aMsvSession, |
|
247 CMRMailboxUtils& aMRMailboxUtils ); |
|
248 |
|
249 /** |
|
250 * Constructor, second phase. |
|
251 */ |
|
252 void ConstructL( CCalSession& aCalSession ); |
|
253 |
|
254 protected: // Data |
|
255 |
|
256 // resource file offset |
|
257 TInt iResourceFileOffset; |
|
258 |
|
259 // msv session ownership |
|
260 TBool iOwnMsvSession; |
|
261 |
|
262 // MR Utils reference |
|
263 CMRUtilsInternal& iMRUtils; |
|
264 |
|
265 CMRMailboxUtils& iMRMailboxUtils; |
|
266 |
|
267 // ownership determined by iOwnMsvSession |
|
268 CMsvSession* iMsvSession; |
|
269 |
|
270 // own, email sender utility |
|
271 MMRUtilsEmailSender* iEmailSender; |
|
272 }; |
|
273 |
|
274 #endif // CMRUTILSUISERVICES_H |
|
275 |
|
276 // End of File |