31
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2007 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: CMmsPushHandler declaration
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef __CMMSPUSHHANDLER_H
|
|
22 |
#define __CMMSPUSHHANDLER_H
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include <msvapi.h>
|
|
26 |
#include <push/cpushhandlerbase.h>
|
|
27 |
|
|
28 |
#ifdef _DEBUG
|
|
29 |
#include <flogger.h>
|
|
30 |
#endif // _DEBUG
|
|
31 |
|
|
32 |
// CONSTANTS
|
|
33 |
//
|
|
34 |
const TInt KRequiredDiskSpace = 1024; // Used for checking the diskspace
|
|
35 |
const TInt KRetryCount = 5; // Number of times to retry something (more specifically number of times RunL is entered)
|
|
36 |
const TInt KShortWait = 30*1000000; // Timeout value to be used for short timeouts
|
|
37 |
const TInt KLongWait = 5*60*1000000; // Timeout value to be used for long timeouts
|
|
38 |
|
|
39 |
// MACROS
|
|
40 |
// Related to logging
|
|
41 |
#ifdef _DEBUG
|
|
42 |
_LIT(KLogFile,"PushHandler.txt");
|
|
43 |
_LIT(KLogFolder,"mmss");
|
|
44 |
|
|
45 |
#define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,AAA)
|
|
46 |
#define LOGTEXT2(AAA,BBB) RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(AAA),BBB)
|
|
47 |
|
|
48 |
#else // no _DEBUG defined
|
|
49 |
|
|
50 |
#define LOGTEXT(AAA)
|
|
51 |
#define LOGTEXT2(AAA,BBB)
|
|
52 |
|
|
53 |
#endif // _DEBUG
|
|
54 |
|
|
55 |
// DATA TYPES
|
|
56 |
|
|
57 |
// FUNCTION PROTOTYPES
|
|
58 |
|
|
59 |
// FORWARD DECLARATIONS
|
|
60 |
|
|
61 |
// CLASS DECLARATION
|
|
62 |
|
|
63 |
/**
|
|
64 |
* ECOM listener plugin for MMS engine.
|
|
65 |
* Plugin is instantiated by the wap listener in the system watcher.
|
|
66 |
* It delivers pushed delivery reports and message notifications to MMS Mtm.
|
|
67 |
*
|
|
68 |
* @lib mmspushhandler.lib
|
|
69 |
* @since 2.0
|
|
70 |
*/
|
|
71 |
class CMmsPushHandler : public CPushHandlerBase, public MMsvSessionObserver
|
|
72 |
{
|
|
73 |
public: // Constructors and destructor
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Destructor
|
|
77 |
* @since 2.0
|
|
78 |
*/
|
|
79 |
~CMmsPushHandler();
|
|
80 |
|
|
81 |
public: // New functions
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Default 1st phase factory method.
|
|
85 |
* @since 2.0
|
|
86 |
* @return created instance of the CMmsPushHandler class
|
|
87 |
*/
|
|
88 |
static CMmsPushHandler* NewL();
|
|
89 |
|
|
90 |
public: // Functions from base classes
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Method for handling a received message asynchronously.
|
|
94 |
* @since 2.0
|
|
95 |
* @param aPushMsg object representing the received push message
|
|
96 |
* @param aStatus Status of the asynchronous call
|
|
97 |
*/
|
|
98 |
void HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus);
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Method for handling a received message synchronously.
|
|
102 |
* @since 2.0
|
|
103 |
* @param aPushMsg object representing the received push message
|
|
104 |
*/
|
|
105 |
void HandleMessageL(CPushMessage* aPushMsg);
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Cancels the requested asynchronous message handling.
|
|
109 |
* @since 2.0
|
|
110 |
*/
|
|
111 |
void CancelHandleMessage();
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Observer/callback method that gets called by Message Server.
|
|
115 |
* Currently not used for anything.
|
|
116 |
* @since 2.0
|
|
117 |
* @param aEvent specifies the event that has occurred
|
|
118 |
* @param -
|
|
119 |
* @param -
|
|
120 |
* @param -
|
|
121 |
*/
|
|
122 |
void HandleSessionEventL(
|
|
123 |
TMsvSessionEvent aEvent,
|
|
124 |
TAny* aArg1,
|
|
125 |
TAny* aArg2,
|
|
126 |
TAny* aArg3);
|
|
127 |
|
|
128 |
protected: // New functions
|
|
129 |
|
|
130 |
protected: // Functions from base classes
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Performs operations needed for cancelling the message handling.
|
|
134 |
* Called by the Active Scheduler after user calling Cancel().
|
|
135 |
* @since 2.0
|
|
136 |
*/
|
|
137 |
void DoCancel();
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Performs the actual tasks related to message handling.
|
|
141 |
* Called by the Active Scheduler.
|
|
142 |
* @since 2.0
|
|
143 |
*/
|
|
144 |
void RunL();
|
|
145 |
|
|
146 |
private: // New functions
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Default constructor.
|
|
150 |
* @since 2.0
|
|
151 |
*/
|
|
152 |
CMmsPushHandler();
|
|
153 |
|
|
154 |
/**
|
|
155 |
* 2nd phase constructor.
|
|
156 |
* @since 2.0
|
|
157 |
*/
|
|
158 |
void ConstructL();
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Performs basic sanity checks for the received message.
|
|
162 |
* Only the body is checked since header is not of interest to us.
|
|
163 |
* @since 2.0
|
|
164 |
* @return standard error code
|
|
165 |
*/
|
|
166 |
TInt PerformChecks();
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Opens a CMsvSession to Server Mtm.
|
|
170 |
* @since 2.0
|
|
171 |
* @return error code (should be KErrNone)
|
|
172 |
*/
|
|
173 |
void OpenSessionL();
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Tries to find the MMS service resources from the Server Mtm.
|
|
177 |
* @since 2.0
|
|
178 |
*/
|
|
179 |
void FindServiceL();
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Transfers a push message to Server Mtm.
|
|
183 |
* @since 2.0
|
|
184 |
*/
|
|
185 |
void TransferMessageL();
|
|
186 |
|
|
187 |
/**
|
|
188 |
* Finds/Creates a folder for MMS pushmessages to Message Store
|
|
189 |
* @since 2.5
|
|
190 |
* @return created entry's Id
|
|
191 |
*/
|
|
192 |
TMsvId GetMMSFolderL();
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Creates MMSNotifications folder into Message Store.
|
|
196 |
* @since 2.0
|
|
197 |
* @return created entry's Id
|
|
198 |
*/
|
|
199 |
TMsvId CreateMMSFolderL();
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Tries to find the correct MMSNotifications folder
|
|
203 |
* @since 2.0
|
|
204 |
* @return entryId
|
|
205 |
* if correct folder was found it is returned,
|
|
206 |
* if not found, KMsvNullIndexEntryId is returned.
|
|
207 |
*/
|
|
208 |
TMsvId FindMMSFolderL();
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Creates an entry for the pushed message if necessary and stores
|
|
212 |
* the created Id to member variable.
|
|
213 |
* @since 2.0
|
|
214 |
* @param folder's entry Id into where the new message entry will be
|
|
215 |
* created.
|
|
216 |
*/
|
|
217 |
TMsvId CreateEntryL( TMsvId aFolder );
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Checks that there is enough diskspace
|
|
221 |
* @since 2.5
|
|
222 |
* @return KErrNone if there is enough diskspace
|
|
223 |
* KErrDiskFull if below critical level.
|
|
224 |
* NOTE: The class (this) has been activated already.
|
|
225 |
*/
|
|
226 |
TInt CheckDiskSpaceL();
|
|
227 |
|
|
228 |
private: // Functions from base classes
|
|
229 |
/**
|
|
230 |
* Reserved for future expansion.
|
|
231 |
* @since 2.0
|
|
232 |
*/
|
|
233 |
void CPushHandlerBase_Reserved1();
|
|
234 |
|
|
235 |
/**
|
|
236 |
* Reserved for future expansion.
|
|
237 |
* @since 2.0
|
|
238 |
*/
|
|
239 |
void CPushHandlerBase_Reserved2();
|
|
240 |
|
|
241 |
public: // Data
|
|
242 |
|
|
243 |
protected: // Data
|
|
244 |
|
|
245 |
private: // Data
|
|
246 |
// Operations to indicate the current asynchronous operation
|
|
247 |
typedef enum TMmsPushHandlerOperations
|
|
248 |
{
|
|
249 |
EInitial = 0, // when entering RunL the first time
|
|
250 |
EMsDriveChange, // when changing MessageStore drive
|
|
251 |
ETransferCommand, // when TransferCommandL is called
|
|
252 |
ETimer, // when a sleep timer is running
|
|
253 |
EDiskSpaceWait // when waiting for disk space to come available
|
|
254 |
} TState;
|
|
255 |
|
|
256 |
// The state of the active object
|
|
257 |
TState iState;
|
|
258 |
// Entry Id of the MMS service
|
|
259 |
TMsvId iServiceId;
|
|
260 |
// Object representing the session to Server Mtm
|
|
261 |
CMsvSession* iMsvSession;
|
|
262 |
// Object representing the request made asynchronously to Server Mtm
|
|
263 |
CMsvOperation* iMsvOperation;
|
|
264 |
// Pushed message
|
|
265 |
CPushMessage* iPushMsg;
|
|
266 |
// The body of the pushed message as HBufC8 descriptor
|
|
267 |
HBufC8* iBody;
|
|
268 |
// FileServer reference
|
|
269 |
RFs iFs;
|
|
270 |
// Timer for retries
|
|
271 |
RTimer iTimer;
|
|
272 |
// retry count
|
|
273 |
TInt iRetryCount;
|
|
274 |
|
|
275 |
public: // Friend classes
|
|
276 |
protected: // Friend classes
|
|
277 |
private: // Friend classes
|
|
278 |
};
|
|
279 |
|
|
280 |
#endif // __CMMSPUSHHANDLER_H
|
|
281 |
|
|
282 |
// End of File
|