|
1 /* |
|
2 * Copyright (c) 2002, 2003 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 * Mms Notification dispatcher |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MMSWATCHER_H |
|
22 #define MMSWATCHER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <msvapi.h> |
|
27 |
|
28 #include "mmscenrepobserver.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // DATA TYPES |
|
35 |
|
36 enum TMmsWatcherStates |
|
37 { |
|
38 EInvalid = 0, |
|
39 EStartup, |
|
40 EMessageVariation, |
|
41 EGarbageCollection, |
|
42 EScheduling, |
|
43 EWaiting, |
|
44 }; |
|
45 |
|
46 // FUNCTION PROTOTYPES |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 class CWatcherLog; |
|
50 class CEnvironmentChangeNotifier; |
|
51 #ifdef __WINS__ |
|
52 class CMmsPollingTimer; |
|
53 #endif |
|
54 |
|
55 // CLASS DECLARATION |
|
56 |
|
57 // Small class for push entry |
|
58 class CMmsPushEntry :public CBase |
|
59 { |
|
60 public: // Constructors and destructor |
|
61 |
|
62 CMmsPushEntry(); |
|
63 virtual ~CMmsPushEntry(); |
|
64 |
|
65 public: |
|
66 HBufC8* iData; |
|
67 TInt iStatus; |
|
68 CMsvOperation* iOperation; |
|
69 }; |
|
70 |
|
71 /** |
|
72 * Mms Watcher performs all tasks that require waiting for some events |
|
73 * @lib mmswatcher.lib |
|
74 * @since 1.0 |
|
75 */ |
|
76 class CMmsWatcher : |
|
77 public CActive, |
|
78 public MMsvSessionObserver, |
|
79 public MMmsCenRepNotifyHandler |
|
80 { |
|
81 public: // Constructors and destructor |
|
82 |
|
83 /** |
|
84 * Two-phased constructor. |
|
85 * @param aFs file system handle |
|
86 * @param aLog watcher logger class reference (not used) |
|
87 */ |
|
88 static CMmsWatcher* NewL(TAny* aWatcherParams); |
|
89 |
|
90 /** |
|
91 * Destructor. |
|
92 */ |
|
93 virtual ~CMmsWatcher(); |
|
94 |
|
95 public: // New functions |
|
96 |
|
97 public: // Functions from base classes |
|
98 |
|
99 /** |
|
100 * From MMmsCenRepNotifyHandler |
|
101 * HandleCenRepNotificationL is a callback function which is called when |
|
102 * a CenRepObserver receives an event. |
|
103 * There can be several observers running and they all call this callback |
|
104 * when they need to. |
|
105 * @param aRepositoryUid identifies the repository where the key under |
|
106 * observation is located. |
|
107 * @param aKey identifies the particular key under observation. |
|
108 * @param aValue specifies the new changed value of the key. |
|
109 */ |
|
110 void HandleCenRepNotificationL( |
|
111 const TUid aRepositoryUid, |
|
112 const TInt32 aKey, |
|
113 const TInt aValue ); |
|
114 |
|
115 /** |
|
116 * From MMsvSessionObserver needed to open message server session |
|
117 * NOTE that CMmsPollingTimer uses this same callback. |
|
118 * @param aEvent event code from message server, |
|
119 * rest of parameters depend on event. See Symbian documentation. |
|
120 */ |
|
121 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny*, TAny*, TAny*); |
|
122 |
|
123 protected: // New functions |
|
124 |
|
125 protected: // Functions from base classes |
|
126 |
|
127 private: |
|
128 |
|
129 /** |
|
130 * By default Symbian OS constructor is private. |
|
131 */ |
|
132 void ConstructL(); |
|
133 |
|
134 /** |
|
135 * constructor. |
|
136 * @param apriority actrive object priority. |
|
137 * @param aLog watcher logger class reference (not used). |
|
138 */ |
|
139 CMmsWatcher(TInt aPriority, CWatcherLog& aLog); |
|
140 |
|
141 /** |
|
142 * Perform one operation in state machine |
|
143 */ |
|
144 void DoRunL(); |
|
145 |
|
146 /** |
|
147 * From CActive: Active object completion |
|
148 */ |
|
149 void RunL(); |
|
150 |
|
151 /** |
|
152 * From CActive: Cancel current operation. |
|
153 */ |
|
154 void DoCancel(); |
|
155 |
|
156 /** |
|
157 * remove first entry from queuedMessages array |
|
158 */ |
|
159 void Dequeue(); |
|
160 |
|
161 /** |
|
162 * remove handled entry |
|
163 */ |
|
164 void RemoveSent(); |
|
165 |
|
166 /** |
|
167 * Send next waiting entry to Server mtm |
|
168 */ |
|
169 void HandleNextInQueueL(); |
|
170 |
|
171 /** |
|
172 * create notification |
|
173 * @param aUrl address of the message (path & filename) |
|
174 * @param aSize size of the message (file) |
|
175 * @return pointer to buffer containing the encoded notification |
|
176 */ |
|
177 HBufC8* CreateNotificationL(TDesC8& aUrl, TInt aSize); |
|
178 |
|
179 /** |
|
180 * Initialization including garbage collection |
|
181 */ |
|
182 void StartupL(); |
|
183 |
|
184 /** |
|
185 * Garbage collection |
|
186 */ |
|
187 void GarbageCollectionL(); |
|
188 |
|
189 /** |
|
190 * Operator message variation |
|
191 */ |
|
192 void MessageVariationL(); |
|
193 |
|
194 /** |
|
195 * Create an entry into MMS folder |
|
196 * @param aFolder folder id |
|
197 * @return id of created entry. KMsvNullIndexEntryId if cannot be created |
|
198 */ |
|
199 TMsvId CreateEntryL( TMsvId aFolder ); |
|
200 |
|
201 /** |
|
202 * Open msv server session |
|
203 * Either the first time, or because it has been closed |
|
204 */ |
|
205 void OpenSessionL(); |
|
206 |
|
207 /** |
|
208 * Environment change functionS |
|
209 */ |
|
210 static TInt EnvironmentChanged(TAny* aThis); |
|
211 void HandleEnvironmentChange(); |
|
212 |
|
213 /** |
|
214 * GetMessagingEntriesL reads service entryId and NotificationFolderId |
|
215 * from MmsSettings. If values are null, they are created. |
|
216 */ |
|
217 void GetMessagingEntriesL( const TBool aMessageStoreHasChanged = EFalse ); |
|
218 |
|
219 #ifdef __WINS__ |
|
220 /** |
|
221 * LocalModeL reads the localmode status from settings |
|
222 */ |
|
223 TBool LocalModeL(); |
|
224 |
|
225 /** |
|
226 * ReadLocalModeDirectoriesL is only for emulator use |
|
227 */ |
|
228 void ReadLocalModeConfigData(); |
|
229 #endif |
|
230 |
|
231 public: // Data |
|
232 |
|
233 protected: // Data |
|
234 |
|
235 private: // Data |
|
236 TMsvId iService; |
|
237 TMsvId iNotificationFolder; |
|
238 TInt iState; |
|
239 CWatcherLog& iLog; |
|
240 TInt iLastError; |
|
241 CMsvSession* iSession; |
|
242 CArrayPtrFlat<CMmsPushEntry>* iQueuedMessages; |
|
243 CMsvOperation* iOperation; |
|
244 RTimer iTimer; |
|
245 RFs iFs; |
|
246 TInt iMessageDrive; // default is C: |
|
247 // Collection of event flags telling which event has triggered garbage |
|
248 // collection. More than one event may be specified at the same time. |
|
249 TUint32 iEvents; |
|
250 // Copy of the events, must be saved in case MMS Server MTM is unreachable |
|
251 TUint32 iOldEvents; |
|
252 // The moment when media became unavailable |
|
253 TTime iMediaUnavailableTime; |
|
254 // To keep track of MessageStore availability |
|
255 // (based on mediaAvailable/unavailable events) |
|
256 TBool iMediaAvailable; |
|
257 // Observer to watch environment time changes |
|
258 CEnvironmentChangeNotifier* iNotifier; |
|
259 // Observer of offline mode changes |
|
260 CMmsCenRepObserver* iOfflineObserver; |
|
261 // encapsulation version |
|
262 TInt16 iMmsVersion; |
|
263 #ifdef __WINS__ |
|
264 // MMS Watcher might be used for polling localmode directory |
|
265 // (emulator only) |
|
266 TInt iPollingInterval; |
|
267 CMmsPollingTimer* iPollingTimer; |
|
268 // Specifies the folder from where incoming mms messages are looked for |
|
269 // Local mode works automatically in emulator only |
|
270 TFileName iLocalModeIn; |
|
271 #endif |
|
272 |
|
273 public: // Friend classes |
|
274 protected: // Friend classes |
|
275 private: // Friend classes |
|
276 |
|
277 }; |
|
278 |
|
279 // panic function |
|
280 GLREF_C void gPanic( TMmsPanic aPanic ); |
|
281 |
|
282 #endif // MMSWATCHER_H |
|
283 |
|
284 // End of File |