20 #define C_PS_MRU_ADAPTER_H |
20 #define C_PS_MRU_ADAPTER_H |
21 |
21 |
22 // INCLUDES |
22 // INCLUDES |
23 #include <CPsDataPlugin.h> |
23 #include <CPsDataPlugin.h> |
24 //<cmail> |
24 //<cmail> |
25 #include "MFSMailEventObserver.h" |
25 #include "mfsmaileventobserver.h" |
26 //</cmail> |
26 //</cmail> |
27 |
27 |
28 // FORWARD DECLARATION |
28 // FORWARD DECLARATION |
29 class CPsData; |
29 class CPsData; |
30 class CFSMailClient; |
30 class CFSMailClient; |
31 |
31 class MDesCArray; |
|
32 |
|
33 class CDelayMailboxCreationHelper; |
32 // CLASS DECLARATION |
34 // CLASS DECLARATION |
33 |
35 |
34 /** |
36 /** |
35 * MRU Data Store |
37 * MRU Data Store |
36 * This class acts as a MRU Data store, which allows access to |
38 * This class acts as a MRU Data store, which allows access to |
37 * FS Email Framework MRU data |
39 * FS Email Framework MRU data |
38 * |
40 * |
39 * @since S60 v3.2 |
41 * @since S60 v3.2 |
40 */ |
42 */ |
41 class CPsMruAdapter : public CPsDataPlugin, public MFSMailEventObserver |
43 class CPsMruAdapter : public CPsDataPlugin, public MFSMailEventObserver |
42 { |
44 { |
43 public: |
45 public: |
44 |
46 |
45 /** |
47 /** |
46 * Two phase construction |
48 * Two phase construction |
47 */ |
49 */ |
48 static CPsMruAdapter* NewL(TAny* aPsDataPluginParameters); |
50 static CPsMruAdapter* NewL(TAny* aPsDataPluginParameters); |
49 |
51 |
50 /** |
52 /** |
51 * Destructor |
53 * Destructor |
52 */ |
54 */ |
53 virtual ~CPsMruAdapter(); |
55 virtual ~CPsMruAdapter(); |
54 |
56 |
55 /** |
57 /** |
56 * Returns the additional data for given item id |
58 * Returns the additional data for given item id |
57 * Returns NULL (in current implementation) |
59 * Returns NULL (in current implementation) |
58 */ |
60 */ |
59 TAny* RequestForDataExtensionL( TInt ItemId ); |
61 TAny* RequestForDataExtensionL( TInt ItemId ); |
60 |
62 |
61 // from base class CPsDataPlugin |
63 // from base class CPsDataPlugin |
62 |
64 |
63 /** |
65 /** |
64 * Requests for data from this store |
66 * Requests for data from this store |
95 * Handles mailbox events from plugins. |
97 * Handles mailbox events from plugins. |
96 */ |
98 */ |
97 void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, |
99 void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, |
98 TAny* aParam1, TAny* aParam2, TAny* aParam3 ); |
100 TAny* aParam1, TAny* aParam2, TAny* aParam3 ); |
99 |
101 |
|
102 /** |
|
103 * If problem with NewMailbox this function will be called |
|
104 * by CDelayMailboxCreationHelper to try it after some delay |
|
105 */ |
|
106 TBool DeleayedMailboxCreationEventL(); |
|
107 |
|
108 /** |
|
109 * If problem with NewMailbox this function will be called |
|
110 * by CDelayMailboxCreationHelper to try it after some delay |
|
111 */ |
|
112 void DeleayMailboxCreationEventL( TFSMailMsgId &aMailbox ); |
|
113 |
100 private: |
114 private: |
101 |
115 |
102 /** |
116 /** |
103 * Constructor |
117 * Constructor |
104 */ |
118 */ |
105 CPsMruAdapter(); |
119 CPsMruAdapter(); |
106 |
120 |
107 /** |
121 /** |
108 * 2nd phase construtor |
122 * 2nd phase construtor |
109 */ |
123 */ |
110 void ConstructL(MDataStoreObserver* aObserverForDataStore, |
124 void ConstructL(MDataStoreObserver* aObserverForDataStore, |
111 MStoreListObserver* aStoreListObserver); |
125 MStoreListObserver* aStoreListObserver); |
112 |
126 |
113 /** |
127 /** |
114 * Updates given data store |
128 * Updates given data store |
115 */ |
129 */ |
116 TBool FillDataStoreL( TDesC& aDataStoreURI ); |
130 TBool FillDataStoreL( TDesC& aDataStoreURI ); |
117 |
131 |
118 /** |
132 /** |
119 * Updates given data store |
133 * Updates given data store |
120 */ |
134 */ |
121 TBool FillDataStoreL( TFSMailMsgId& aId ); |
135 TBool FillDataStoreL( TFSMailMsgId& aId ); |
122 |
136 |
123 /** |
137 /** |
124 * Updates a list of supported data stores |
138 * Updates a list of supported data stores |
125 */ |
139 */ |
126 void UpdateSupportedDataStoresList(); |
140 void UpdateSupportedDataStoresList(); |
127 |
141 |
128 /** |
142 /** |
129 * Starts observing mailbox |
143 * Starts observing mailbox |
130 */ |
144 */ |
131 TBool AddMailboxObserverL( TFSMailMsgId& aId ); |
145 TBool AddMailboxObserverL( TFSMailMsgId& aId ); |
132 |
146 |
133 /** |
147 /** |
134 * Stops observing mailbox |
148 * Stops observing mailbox |
135 */ |
149 */ |
136 TBool RemoveMailboxObserver( TFSMailMsgId& aId ); |
150 TBool RemoveMailboxObserver( TFSMailMsgId& aId ); |
137 |
151 |
138 /** |
152 /** |
139 * Stops all mailbox observers |
153 * Stops all mailbox observers |
140 */ |
154 */ |
141 void RemoveAllMailboxObservers(); |
155 void RemoveAllMailboxObservers(); |
142 |
156 |
143 /** |
157 /** |
144 * Converts Uri to TFsMailMsgId |
158 * Converts Uri to TFsMailMsgId |
145 */ |
159 */ |
146 TBool GetMailboxIdentifierFromUri( TDesC& aUri, TFSMailMsgId& aId ); |
160 TBool GetMailboxIdentifierFromUri( TDesC& aUri, TFSMailMsgId& aId ); |
147 |
161 |
148 /** |
162 /** |
149 * Converts TFsMailMsgId to Uri |
163 * Converts TFsMailMsgId to Uri |
150 */ |
164 */ |
151 TBool GetUriFromMailboxIdentifier( TFSMailMsgId& aId, HBufC& aUri ); |
165 TBool GetUriFromMailboxIdentifier( TFSMailMsgId& aId, HBufC& aUri ); |
152 |
166 |
153 /** |
167 /** |
154 * Updates given data store |
168 * Updates given data store |
155 */ |
169 */ |
156 TBool FillDataStoreL( TFSMailMsgId& aId, TDesC& aDataStoreURI ); |
170 TBool FillDataStoreL( TFSMailMsgId& aId, TDesC& aDataStoreURI ); |
|
171 |
|
172 /** |
|
173 * Calls MDataStoreObserver::AddData for every mru email - used for trapping |
|
174 */ |
|
175 void AddMruEmailsL( MDesCArray* aMruList, TDesC& aDataStoreURI ); |
157 |
176 |
158 private: // data |
177 private: // data |
159 |
178 |
160 /** |
179 /** |
161 * Holds the observer object to communicate add/modify/delete of contacts |
180 * Holds the observer object to communicate add/modify/delete of contacts |
162 * Not owned. |
181 * Not owned. |
163 */ |
182 */ |
164 MDataStoreObserver* iDataStoreObserver; |
183 MDataStoreObserver* iDataStoreObserver; |
165 |
184 |
166 /** |
185 /** |
167 * An observer instance used to send the datastore to the adapter |
186 * An observer instance used to send the datastore to the adapter |
168 */ |
187 */ |
169 MStoreListObserver* iStoreListObserver; |
188 MStoreListObserver* iStoreListObserver; |
170 |
189 |
171 /** |
190 /** |
172 * Supported Uris(data stores) |
191 * Supported Uris(data stores) |
173 */ |
192 */ |
174 RPointerArray<HBufC> iSupportedUris; |
193 RPointerArray<HBufC> iSupportedUris; |
175 |
194 |
176 /** |
195 /** |
177 * List of mailboxes currently being observed |
196 * List of mailboxes currently being observed |
178 */ |
197 */ |
179 RArray<TFSMailMsgId> iObservedMailboxes; |
198 RArray<TFSMailMsgId> iObservedMailboxes; |
180 |
199 |
181 /** |
200 /** |
182 * Fs Email framework client |
201 * Fs Email framework client |
183 */ |
202 */ |
184 CFSMailClient* iMailClient; |
203 CFSMailClient* iMailClient; |
185 }; |
204 |
186 |
205 /** |
|
206 * Class for postponing the mailbox creation in MRU list - Event may come beforet the mailbox exists |
|
207 */ |
|
208 CDelayMailboxCreationHelper *iDelayMailboxCreationPtr; |
|
209 |
|
210 /** |
|
211 * This mailboxes should be handled by CDelayMailboxCreationHelper |
|
212 */ |
|
213 RArray<TFSMailMsgId> iDelayedCreatedMailboxes; |
|
214 |
|
215 }; // class CPsMruAdapter |
|
216 |
|
217 //----------------------------------------------------------------------------- |
|
218 //----------------------------------------------------------------------------- |
|
219 |
|
220 |
|
221 // Helper class for thread synchronization |
|
222 // used when mailbox is not ready when TFSEventNewMailbox event comes |
|
223 // Waits 30*0.5 sec to try posponed mailbox registration |
|
224 |
|
225 // wait 500 ms to try adding the mailbox - because sync problems |
|
226 #define KDelayToRunAddMailbox 500 |
|
227 // try it 15 second - 30 times |
|
228 #define KNumberOfDelayedTrials 30 |
|
229 |
|
230 |
|
231 class CDelayMailboxCreationHelper : public CTimer |
|
232 { |
|
233 public: |
|
234 static CDelayMailboxCreationHelper* NewLC( CPsMruAdapter *aPsMruAdapterPtr ); |
|
235 static CDelayMailboxCreationHelper* NewL( CPsMruAdapter *aPsMruAdapterPtr ); |
|
236 // d-tor |
|
237 virtual ~CDelayMailboxCreationHelper(); |
|
238 // Start timer to call CPsMruAdapter::DeleayedMailboxCreationEventL by RunL |
|
239 void StartDelayedCall(); |
|
240 protected: |
|
241 // on timer event - calls CPsMruAdapter::DeleayedMailboxCreationEventL |
|
242 virtual void RunL(); |
|
243 // when leave from RunL, if err handled return KErrNone |
|
244 TInt RunError( TInt aError ); |
|
245 // two phase constr. |
|
246 void ConstructL(); |
|
247 private: |
|
248 CDelayMailboxCreationHelper( CPsMruAdapter *aPsMruAdapterPtr ); // EPriorityLow, EPriorityIdle |
|
249 // callback not owning pointer assigned during construction |
|
250 CPsMruAdapter *iPsMruAdapterPtr; |
|
251 // unsuccessful calls still allowed counter |
|
252 TInt iNumberOfDelayedTrials; |
|
253 }; // class CDelayMailboxCreationHelper |
187 |
254 |
188 #endif // C_PS_MRU_ADAPTER_H |
255 #endif // C_PS_MRU_ADAPTER_H |