21 |
21 |
22 #include <e32std.h> |
22 #include <e32std.h> |
23 #include <e32base.h> |
23 #include <e32base.h> |
24 |
24 |
25 #include "CFSMailClient.hrh" |
25 #include "CFSMailClient.hrh" |
|
26 #include "cemailextensionbase.h" |
26 |
27 |
27 //<cmail> |
28 //<cmail> |
28 #include "MFSMailBrandManager.h" |
29 #include "MFSMailBrandManager.h" |
29 #include "CFSMailPlugin.h" |
30 #include "CFSMailPlugin.h" |
30 //</cmail> |
31 //</cmail> |
31 |
32 |
32 class CFSFWImplementation; |
33 class CFSFWImplementation; |
33 class CFSMailPluginManager; |
34 class CFSMailPluginManager; |
34 |
35 |
35 /** |
36 /** |
36 * @mainpage Freestyle Email API |
37 * @mainpage Freestyle Email API |
37 * |
38 * |
38 * @section sec1 Introduction |
39 * @section sec1 Introduction |
39 * |
40 * |
40 * This is the mail API and framework used by the Freestyle email |
41 * This is the mail API and framework used by the Freestyle email |
41 * client. It provides access to the message store for reading email |
42 * client. It provides access to the message store for reading email |
42 * and to the sync engine for starting and stopping synchronizations. |
43 * and to the sync engine for starting and stopping synchronizations. |
43 * |
44 * |
44 * @section sec2 Typical Usage From UI |
45 * @section sec2 Typical Usage From UI |
45 * |
46 * |
46 * // Initialize the access to the mail framework |
47 * // Initialize the access to the mail framework |
47 * CFSMailClient* mail = CFSMailClient::NewL(); |
48 * CFSMailClient* mail = CFSMailClient::NewL(); |
48 * CleanupClosePushL(*mail); |
49 * CleanupClosePushL(*mail); |
49 * |
50 * |
50 * // List mailboxes for user to select which one to open |
51 * // List mailboxes for user to select which one to open |
51 * RPointerArray<CFSMailBox> mailBoxes; |
52 * RPointerArray<CFSMailBox> mailBoxes; |
52 * mailBoxes.Reset(); |
53 * mailBoxes.Reset(); |
53 * TFSMailMsgId plugin; // null id if all mailboxes required |
54 * TFSMailMsgId plugin; // null id if all mailboxes required |
54 * mail->ListMailBoxes(plugin,mailBoxes); |
55 * mail->ListMailBoxes(plugin,mailBoxes); |
55 * // Lets select the first one this time |
56 * // Lets select the first one this time |
56 * CFSMailBox * currentMailbox = mailboxes[0]; |
57 * CFSMailBox * currentMailbox = mailboxes[0]; |
57 * |
58 * |
58 * // list all mailbox folders for user |
59 * // list all mailbox folders for user |
59 * RPointerArray<CFSMailFolder> folders = currentMailBox->ListFolders( ); |
60 * RPointerArray<CFSMailFolder> folders = currentMailBox->ListFolders( ); |
60 * |
61 * |
61 * // or get default folder, for example inbox |
62 * // or get default folder, for example inbox |
62 * TFSMailMsgId folderId; |
63 * TFSMailMsgId folderId; |
63 * folderId = mailBox->GetStandardFolderId( EFSInbox ); |
64 * folderId = mailBox->GetStandardFolderId( EFSInbox ); |
64 * CFSMailFolder* inbox = mail->GetFolderByUid(currentMailBox->GetId(),folderId); |
65 * CFSMailFolder* inbox = mail->GetFolderByUid(currentMailBox->GetId(),folderId); |
65 * |
66 * |
66 * // List messages in inbox |
67 * // List messages in inbox |
67 * // select message details to be listed |
68 * // select message details to be listed |
68 * TFSMailDetails details(EFSMsgDataStructure); |
69 * TFSMailDetails details(EFSMsgDataStructure); |
69 * |
70 * |
70 * // set sorting criteria |
71 * // set sorting criteria |
71 * TFSMailSortCriteria criteria; |
72 * TFSMailSortCriteria criteria; |
72 * criteria.iField = EFSMailSortByDate; |
73 * criteria.iField = EFSMailSortByDate; |
73 * criteria.iOrder = EFSMailAscending; |
74 * criteria.iOrder = EFSMailAscending; |
74 * RArray<TFSMailSortCriteria> sorting; |
75 * RArray<TFSMailSortCriteria> sorting; |
75 * sorting.Append(criteria); |
76 * sorting.Append(criteria); |
76 * |
77 * |
77 * // get email list iterator from plugin |
78 * // get email list iterator from plugin |
78 * MFSMailIterator* iterator = folder->ListMessagesL(details,sorting); |
79 * MFSMailIterator* iterator = folder->ListMessagesL(details,sorting); |
79 * |
80 * |
80 * // list all messages from folder |
81 * // list all messages from folder |
81 * TFSMailMsgId currentMessageId; // first call contains NULL id as begin id |
82 * TFSMailMsgId currentMessageId; // first call contains NULL id as begin id |
82 * RPointerArray<CFSMailMessage> messages; |
83 * RPointerArray<CFSMailMessage> messages; |
83 * messages.Reset(); |
84 * messages.Reset(); |
84 * iterator->NextL(currentMessageId, folder->GetMessageCount(), messages); |
85 * iterator->NextL(currentMessageId, folder->GetMessageCount(), messages); |
85 * |
86 * |
86 * // Show the first 5 messages to in the UI |
87 * // Show the first 5 messages to in the UI |
87 * for(TInt i=0;i<messages.Count() && i<5;i++) |
88 * for(TInt i=0;i<messages.Count() && i<5;i++) |
88 * { |
89 * { |
89 * MyHeaderShowMethod(messages[i]->GetSender().GetEmailAddress(), |
90 * MyHeaderShowMethod(messages[i]->GetSender().GetEmailAddress(), |
90 * messages[i]->GetSubject() |
91 * messages[i]->GetSubject() |
91 * messages[i]->GetDate()); |
92 * messages[i]->GetDate()); |
92 * |
93 * |
93 * // get email body |
94 * // get email body |
94 * CFSMailMessagePart* body = messages[i]->PlainTextBodyPartL(); |
95 * CFSMailMessagePart* body = messages[i]->PlainTextBodyPartL(); |
95 * if(body) |
96 * if(body) |
96 * { |
97 * { |
97 * TBuf<n> text; |
98 * TBuf<n> text; |
98 * TInt startOffset = 0; |
99 * TInt startOffset = 0; |
99 * body->GetContentToBufferL(text,startOffset); |
100 * body->GetContentToBufferL(text,startOffset); |
100 * MyPlainTextBodyShowMethod(text); |
101 * MyPlainTextBodyShowMethod(text); |
101 * delete body; |
102 * delete body; |
102 * } |
103 * } |
103 * |
104 * |
104 * //list email attachments |
105 * //list email attachments |
105 * RPointerArray<CFSMailMessagePart> attachments; |
106 * RPointerArray<CFSMailMessagePart> attachments; |
106 * attachments.Reset(); |
107 * attachments.Reset(); |
109 * { |
110 * { |
110 * MyShowAttachmentNameMethod(attachments[i]->AttachmentName()); |
111 * MyShowAttachmentNameMethod(attachments[i]->AttachmentName()); |
111 * } |
112 * } |
112 * attachments.ResetAndDestroy(); |
113 * attachments.ResetAndDestroy(); |
113 * } |
114 * } |
114 * |
115 * |
115 * // clean iterator and tables |
116 * // clean iterator and tables |
116 * messages.ResetAndDestroy(); |
117 * messages.ResetAndDestroy(); |
117 * delete iterator; |
118 * delete iterator; |
118 * sorting.Reset(); |
119 * sorting.Reset(); |
119 * delete folder; |
120 * delete folder; |
120 * |
121 * |
121 * // User should call close when terminating mail framework usage |
122 * // User should call close when terminating mail framework usage |
122 * // when shutting down application close mail client singleton |
123 * // when shutting down application close mail client singleton |
123 * CleanupStack::PopAndDestroy(mail); |
124 * CleanupStack::PopAndDestroy(mail); |
124 * |
125 * |
125 * @section sec3 Observing Email Events. |
126 * @section sec3 Observing Email Events. |
126 * |
127 * |
127 * // To be able to observe events an user has to |
128 * // To be able to observe events an user has to |
128 * // implement MFSMailEventObserver interface. |
129 * // implement MFSMailEventObserver interface. |
129 * // Here the COwnMailObserver class implements the interface. |
130 * // Here the COwnMailObserver class implements the interface. |
130 * COwnMailObserver* ownObserver = COwnMailObserver::NewL(); |
131 * COwnMailObserver* ownObserver = COwnMailObserver::NewL(); |
131 * |
132 * |
132 * // Register to observe mail store events |
133 * // Register to observe mail store events |
133 * mail->AddObserverL(*ownObserver); |
134 * mail->AddObserverL(*ownObserver); |
134 * |
135 * |
135 * // Now callbacks are done via the EventL function defined |
136 * // Now callbacks are done via the EventL function defined |
136 * // in the MFSMailEventObserver and implemented in this case |
137 * // in the MFSMailEventObserver and implemented in this case |
137 * // by the COwnMailObserver |
138 * // by the COwnMailObserver |
138 * |
139 * |
139 * // When user does not wish to observe events anymore |
140 * // When user does not wish to observe events anymore |
140 * // he has to unregister |
141 * // he has to unregister |
141 * mail->RemoveObserver( *ownObserver ); |
142 * mail->RemoveObserver( *ownObserver ); |
142 * |
143 * |
143 * // Remember that it must be done for each observer |
144 * // Remember that it must be done for each observer |
144 * // in the end of the observation because the AddObserverL |
145 * // in the end of the observation because the AddObserverL |
145 * // does not replace the observer |
146 * // does not replace the observer |
146 * |
147 * |
147 * @section sec_groups Classes |
148 * @section sec_groups Classes |
148 * |
149 * |
149 * The following classes form the public API of the frame work. |
150 * The following classes form the public API of the frame work. |
150 * |
151 * |
151 * @section sec_info More Information |
152 * @section sec_info More Information |
152 * |
153 * |
153 * Copyright © 2006 Nokia. All rights reserved. |
154 * Copyright © 2006 Nokia. All rights reserved. |
154 * |
155 * |
155 * This material, including documentation and any related computer programs, |
156 * This material, including documentation and any related computer programs, |
156 * is protected by copyright controlled by Nokia. All rights are reserved. |
157 * is protected by copyright controlled by Nokia. All rights are reserved. |
157 * Copying, including reproducing, storing, adapting or translating, any or |
158 * Copying, including reproducing, storing, adapting or translating, any or |
158 * all of this material requires the prior written consent of Nokia. This |
159 * all of this material requires the prior written consent of Nokia. This |
159 * material also contains confidential information which may not be disclosed |
160 * material also contains confidential information which may not be disclosed |
160 * to others without the prior written consent of Nokia. |
161 * to others without the prior written consent of Nokia. |
161 */ |
162 */ |
162 |
163 |
163 NONSHARABLE_CLASS(CFSMailClient) : public CBase |
164 NONSHARABLE_CLASS(CFSMailClient) : public CExtendableEmail |
164 { |
165 { |
165 public: |
166 public: |
166 |
167 |
167 /** |
168 /** |
168 * Creates a new CFSMailClient singleton instance or increments |
169 * Creates a new CFSMailClient singleton instance or increments |
234 * @param aMessageId message id |
235 * @param aMessageId message id |
235 * @param aDetails defines which details are included in email object |
236 * @param aDetails defines which details are included in email object |
236 * |
237 * |
237 * @return email object (CFSMailMessage), ownership is transferred to user |
238 * @return email object (CFSMailMessage), ownership is transferred to user |
238 */ |
239 */ |
239 IMPORT_C CFSMailMessage* GetMessageByUidL(const TFSMailMsgId aMailBoxId, const TFSMailMsgId aFolderId, |
240 IMPORT_C CFSMailMessage* GetMessageByUidL(const TFSMailMsgId aMailBoxId, const TFSMailMsgId aFolderId, |
240 const TFSMailMsgId aMessageId, const TFSMailDetails aDetails ); |
241 const TFSMailMsgId aMessageId, const TFSMailDetails aDetails ); |
241 /** |
242 /** |
242 * deletes emails defined in message id list |
243 * deletes emails defined in message id list |
243 * |
244 * |
244 * @param aMailBoxId id of mailbox containing emails |
245 * @param aMailBoxId id of mailbox containing emails |
245 * @param aFolderId id of folder containing email |
246 * @param aFolderId id of folder containing email |
246 * @param aMessageIds defines ids of email to be deleted |
247 * @param aMessageIds defines ids of email to be deleted |
247 */ |
248 */ |
248 IMPORT_C void DeleteMessagesByUidL( const TFSMailMsgId aMailBoxId, const TFSMailMsgId aFolderId, |
249 IMPORT_C void DeleteMessagesByUidL( const TFSMailMsgId aMailBoxId, const TFSMailMsgId aFolderId, |
249 const RArray<TFSMailMsgId>& aMessageIds ); |
250 const RArray<TFSMailMsgId>& aMessageIds ); |
250 |
251 |
251 /** |
252 /** |
252 * Deletes mail account. This asynchronous operation returns id that can |
253 * Deletes mail account. This asynchronous operation returns id that can |
253 * be later used for cancelling the operation. |
254 * be later used for cancelling the operation. |
254 * |
255 * |
343 */ |
344 */ |
344 IMPORT_C TInt AuthenticateL(MFSMailRequestObserver& aOperationObserver); |
345 IMPORT_C TInt AuthenticateL(MFSMailRequestObserver& aOperationObserver); |
345 |
346 |
346 /** |
347 /** |
347 * get framework temp directory |
348 * get framework temp directory |
348 */ |
349 */ |
349 IMPORT_C TDesC& GetTempDirL( ); |
350 IMPORT_C TDesC& GetTempDirL( ); |
350 |
351 |
351 /** |
352 /** |
352 * clean framework temp directory |
353 * clean framework temp directory |
353 */ |
354 */ |
354 IMPORT_C void CleanTempDirL( ); |
355 IMPORT_C void CleanTempDirL( ); |
355 |
356 |
356 /** |
357 /** |
357 * cancels single pending asynchronous request |
358 * cancels single pending asynchronous request |
358 * |
359 * |
359 * @param aRequestId identifies request |
360 * @param aRequestId identifies request |
360 */ |
361 */ |
361 IMPORT_C void CancelL( const TInt aRequestId ); |
362 IMPORT_C void CancelL( const TInt aRequestId ); |
362 |
363 |
363 /** |
364 /** |
364 * cancels all pending asynchronous requests |
365 * cancels all pending asynchronous requests |
365 */ |
366 */ |
366 IMPORT_C void CancelAllL( ); |
367 IMPORT_C void CancelAllL( ); |
367 |
368 |
368 /** |
369 /** |
369 * Calls plugin to change the name of the mailbox |
370 * Calls plugin to change the name of the mailbox |
370 * |
371 * |
371 * @param aMailboxId mailbox id |
372 * @param aMailboxId mailbox id |
372 * @param aMailboxName new name for the mailbox |
373 * @param aMailboxName new name for the mailbox |
373 */ |
374 */ |
374 IMPORT_C void SetMailboxName( const TFSMailMsgId aMailboxId, const TDesC& aMailboxName ); |
375 IMPORT_C void SetMailboxName( const TFSMailMsgId aMailboxId, const TDesC& aMailboxName ); |
375 |
376 |
|
377 //<qmail> |
|
378 /** |
|
379 * increments reference count to framework singleton |
|
380 * visibility change to public by Qmail |
|
381 */ |
|
382 IMPORT_C TInt IncReferenceCount(); |
|
383 //</qmail> |
|
384 |
|
385 public: // from CExtendableEmail |
|
386 |
|
387 /** |
|
388 * @see CExtendableEmail::ReleaseExtension |
|
389 */ |
|
390 IMPORT_C virtual void ReleaseExtension( CEmailExtension* aExtension ); |
|
391 |
|
392 /** |
|
393 * Requests extension. Default implementation performs lookup only and |
|
394 * derived class should implement actual instantiation because it knows |
|
395 * extensions it supports |
|
396 * array but does not delete it. |
|
397 * @param aExtension extension to release |
|
398 */ |
|
399 IMPORT_C virtual CEmailExtension* ExtensionL( const TUid& aInterfaceUid ); |
|
400 |
376 protected: |
401 protected: |
377 |
402 |
378 private: |
403 private: |
379 |
404 |
380 /** |
405 /** |