31
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-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: mms operation common base class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef MMSBASEOPERATION_H
|
|
22 |
#define MMSBASEOPERATION_H
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include <mentact.h> // base class CMsgActive
|
|
26 |
#include <es_sock.h> // for RConnection & RSocketServ
|
|
27 |
#include <msvstd.h>
|
|
28 |
#include <babackup.h>
|
|
29 |
#include <logwrap.h>
|
|
30 |
#include <badesca.h>
|
|
31 |
|
|
32 |
// CONSTANTS
|
|
33 |
// used for recipient arrays, just increment for expanding the array.
|
|
34 |
const TInt KMmsArrayAllocationNumber = 6;
|
|
35 |
|
|
36 |
// MACROS
|
|
37 |
|
|
38 |
// DATA TYPES
|
|
39 |
|
|
40 |
// FUNCTION PROTOTYPES
|
|
41 |
|
|
42 |
// FORWARD DECLARATIONS
|
|
43 |
class CMmsSettings;
|
|
44 |
class RFs;
|
|
45 |
class CMsvServerEntry;
|
|
46 |
class CMmsConnectionInitiator;
|
|
47 |
class CMmsServerEntry;
|
|
48 |
class CMmsSession;
|
|
49 |
class CMmsHeaders;
|
|
50 |
class CMmsEncode;
|
|
51 |
class CMmsDecode;
|
|
52 |
class CMmsScheduledEntry;
|
|
53 |
class CLogClient;
|
|
54 |
class CLogViewEvent;
|
|
55 |
class CLogEvent;
|
|
56 |
class CMmsLog;
|
|
57 |
class CMmsPhoneClient;
|
|
58 |
|
|
59 |
// CLASS DECLARATION
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Base class for all MMS operations.
|
|
63 |
* State machine that contains basic structure for all MMS operations
|
|
64 |
* (send, receive, forward, etc.)
|
|
65 |
*
|
|
66 |
* @lib mmssrv.lib
|
|
67 |
* @since 2.5
|
|
68 |
*/
|
|
69 |
class CMmsBaseOperation : public CMsgActive, public MBackupOperationObserver
|
|
70 |
{
|
|
71 |
public: // Constructors and destructor
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Two-phased constructor.
|
|
75 |
* @param aFs open file system handle
|
|
76 |
* @param aMmsSettings pointer to Mms Settings class, values already loaded
|
|
77 |
*/
|
|
78 |
static CMmsBaseOperation* NewL( RFs& aFs, CMmsSettings* aMmsSettings );
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Destructor.
|
|
82 |
*/
|
|
83 |
virtual ~CMmsBaseOperation();
|
|
84 |
|
|
85 |
public: // New functions
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Check if network operations are allowed
|
|
89 |
* @return ETrue if network operations are allowed
|
|
90 |
* EFalse if network operations are forbidden
|
|
91 |
*/
|
|
92 |
static TBool NetworkOperationsAllowed();
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Allocate 64 bit TID
|
|
96 |
* @return TID based on current time
|
|
97 |
*/
|
|
98 |
static TInt64 AllocateTID();
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Mark failed operation to notification entry
|
|
102 |
* @param reference to the entry where the flags are to be set
|
|
103 |
*/
|
|
104 |
static void MarkNotificationOperationFailed( TMsvEntry& aEntry );
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Mark notification as deleted successfully from mmbox
|
|
108 |
* @param reference to the entry where the flags are to be set
|
|
109 |
*/
|
|
110 |
static void MarkNotificationDeletedFromMmbox( TMsvEntry& aEntry );
|
|
111 |
|
|
112 |
/**
|
|
113 |
* If a notification is in MMBox folder
|
|
114 |
* The corresponding duplicate in Inbox has to be marked and freed.
|
|
115 |
* iServerEntry must point to the original notification
|
|
116 |
* @param aState tells how the entry should be marked
|
|
117 |
* possible values:
|
|
118 |
* EMmsNotificationOperationFailed - the operation has failed
|
|
119 |
* EMmsDeletedFromMmbox - the message was deleted from MMBox
|
|
120 |
* @param reference to a server entry pointing to the original notification
|
|
121 |
* Function leaves if the duplicate cannot be accessed (has disappeared already)
|
|
122 |
*/
|
|
123 |
static void MarkDuplicateL( TInt aState, CMsvServerEntry& aServerEntry );
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Reserve the notification
|
|
127 |
* @param reference to the entry where the flags are to be set
|
|
128 |
* @param the operation that is to be ongoing
|
|
129 |
*/
|
|
130 |
static void MarkNotificationOperationReserved( TMsvEntry& aEntry, const TUint32 aOperation );
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Log date given as seconds from 1.1.1970.
|
|
134 |
* @param aDateInSeconds date to be logged
|
|
135 |
*/
|
|
136 |
static void LogNetworkFormatDateL( const TInt64& aDateInSeconds );
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Log date given as TTime.
|
|
140 |
* @param aDate date to be logged
|
|
141 |
*/
|
|
142 |
static void LogDateL( const TTime& aDate );
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Check if the application is registered
|
|
146 |
* @param aApplicationId application id to check
|
|
147 |
* @return ETrue if registered, EFalse if not registered
|
|
148 |
*/
|
|
149 |
static TBool RegisteredL( const TDesC& aApplicationId );
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Start the state machine.
|
|
153 |
* @param aSelection list of message entry ids to be handled.
|
|
154 |
* @param aServerEntry CMsvServerEntry pointer from CMmsServer
|
|
155 |
* @param aSettings MMSC settings (entry points)
|
|
156 |
* @param aService current MMS service id
|
|
157 |
* @param aStatus TRequestStatus of the calling active object
|
|
158 |
*/
|
|
159 |
void StartL(
|
|
160 |
CMsvEntrySelection& aSelection,
|
|
161 |
CMsvServerEntry& aServerEntry,
|
|
162 |
TMsvId aService,
|
|
163 |
TRequestStatus& aStatus );
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Check if the message contains any attachment types that must not be sent.
|
|
167 |
* @since 3.0
|
|
168 |
* @param aServerEntry CMsvServerEntry reference that points to the message
|
|
169 |
* to be checked.
|
|
170 |
* @param aFs share protected file session
|
|
171 |
* @return KErrNone if the message is clear to send
|
|
172 |
* if the message has an attachment the type of which is on the
|
|
173 |
* closed content list
|
|
174 |
* EFalse if the message contains no forbidden content types.
|
|
175 |
*/
|
|
176 |
static TInt CheckClosedContentL( CMsvServerEntry& aServerEntry, RFs& aFs );
|
|
177 |
|
|
178 |
public: // Functions from base classes
|
|
179 |
|
|
180 |
/**
|
|
181 |
* From MBackupOperationObserver
|
|
182 |
* Called when a backup or restore operation either starts or ends.
|
|
183 |
* @param aBackupOperationAttributes Operation attributes
|
|
184 |
*/
|
|
185 |
void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes);
|
|
186 |
|
|
187 |
protected: // New functions
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Derived classes may call common constructor
|
|
191 |
* @param aMmsSettings pointer to Mms Settings class, values already loaded
|
|
192 |
*/
|
|
193 |
virtual void ConstructL( CMmsSettings* aMmsSettings );
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Select next state for state machine
|
|
197 |
*/
|
|
198 |
virtual void SelectNextState();
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Switch states
|
|
202 |
*/
|
|
203 |
virtual void ChangeStateL();
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Fall through.
|
|
207 |
* Base operation for all states that are no-op in some derived classes.
|
|
208 |
* This function just completes itself.
|
|
209 |
* This function should not be overridden, but should be used by all
|
|
210 |
* derived classes when no-op state is required.
|
|
211 |
*/
|
|
212 |
void FallThrough();
|
|
213 |
|
|
214 |
// The following functions are default implementations for all states.
|
|
215 |
// The function names end to L to allow derived classes to
|
|
216 |
// override that default functions with leaving functions.
|
|
217 |
// All default implementations do not leave.
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Initialize common variables.
|
|
221 |
* @param aSelection list of message entry ids to be handled.
|
|
222 |
* @param aServerEntry CMsvServerEntry pointer from CMmsServer
|
|
223 |
* @param aSettings MMSC settings (entry points)
|
|
224 |
* @param aService current MMS service id
|
|
225 |
*/
|
|
226 |
virtual void InitializeL(
|
|
227 |
CMsvEntrySelection& aSelection,
|
|
228 |
CMsvServerEntry& aServerEntry,
|
|
229 |
TMsvId aService );
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Encode the PDU to be sent to MMSC.
|
|
233 |
*/
|
|
234 |
virtual void EncodePDUL();
|
|
235 |
|
|
236 |
/**
|
|
237 |
* Make a network connection to gateway before attempting a transaction.
|
|
238 |
* This would normally connect to GPRS or CDMA or WBCDMA access point
|
|
239 |
*/
|
|
240 |
virtual void ConnectToIAPL();
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Initialize protocol session.
|
|
244 |
*/
|
|
245 |
virtual void InitializeSessionL();
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Submit a transaction (default is POST transaction).
|
|
249 |
*/
|
|
250 |
virtual void SubmitTransactionL();
|
|
251 |
|
|
252 |
/**
|
|
253 |
* Create new entry to receive data from MMSC.
|
|
254 |
*/
|
|
255 |
virtual void CreateEntryL();
|
|
256 |
|
|
257 |
/**
|
|
258 |
* Decode response PDU from MMSC.
|
|
259 |
*/
|
|
260 |
virtual void DecodeResponseL();
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Store response data from MMSC (if not stored during decoding).
|
|
264 |
* This function would store e.g. message id, error code from MMSC
|
|
265 |
* and response text.
|
|
266 |
*/
|
|
267 |
virtual void StoreResponseL();
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Encode acknowledgement message for MMSC (for received message).
|
|
271 |
*/
|
|
272 |
virtual void EncodeAckL();
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Send acknowledgement message for MMSC (for received message).
|
|
276 |
*/
|
|
277 |
virtual void SendAckL();
|
|
278 |
|
|
279 |
/**
|
|
280 |
* Update the trigger entry status.
|
|
281 |
*/
|
|
282 |
virtual void UpdateEntryStatusL();
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Add MMS event to log.
|
|
286 |
*/
|
|
287 |
virtual void LogL();
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Move trigger entry after handling.
|
|
291 |
* (Move sent item to sent folder, delete notification, etc.)
|
|
292 |
*/
|
|
293 |
virtual void MoveEntryL();
|
|
294 |
|
|
295 |
/**
|
|
296 |
* Disconnect and do any other finalizing steps.
|
|
297 |
*/
|
|
298 |
virtual void FinalizeL();
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Wait for backup end.
|
|
302 |
*/
|
|
303 |
virtual void WaitForBackupEnd();
|
|
304 |
|
|
305 |
// Utility functions that may be used by all derived classes
|
|
306 |
|
|
307 |
/**
|
|
308 |
* Set sending state of scheduled entries
|
|
309 |
* @param aSelection entries to handle
|
|
310 |
*/
|
|
311 |
virtual void SetSendMask( const CMsvEntrySelection& aSelection );
|
|
312 |
|
|
313 |
/**
|
|
314 |
* Reset sending state of scheduled entries
|
|
315 |
* @param aSelection entries to handle
|
|
316 |
* @param aError error code
|
|
317 |
*/
|
|
318 |
virtual void UnSetSendMask( CMsvEntrySelection& aSelection, TInt aError);
|
|
319 |
|
|
320 |
/**
|
|
321 |
* Reset sending state of scheduled entry
|
|
322 |
* @param aId entry id
|
|
323 |
* @param aError error code
|
|
324 |
*/
|
|
325 |
virtual void UnSetSendMask( const TMsvId aId, TInt aError );
|
|
326 |
|
|
327 |
/**
|
|
328 |
* Save error status
|
|
329 |
* @param aError error code
|
|
330 |
* @param aScheduledEntry entry to be updated
|
|
331 |
*/
|
|
332 |
virtual void UpdateRecipient(
|
|
333 |
TInt aError,
|
|
334 |
CMmsScheduledEntry& aScheduledEntry );
|
|
335 |
|
|
336 |
/**
|
|
337 |
* Map the response status from MMSC to iError
|
|
338 |
* @param aResponse structure where the response code from MMSC is stored
|
|
339 |
*/
|
|
340 |
virtual void MapResponseStatus( CMmsHeaders& aResponse );
|
|
341 |
|
|
342 |
/**
|
|
343 |
* Initialize members needed for logging.
|
|
344 |
* Called only when logging needed
|
|
345 |
* (send message, possibly receive message).
|
|
346 |
*/
|
|
347 |
virtual void InitializeLoggingL();
|
|
348 |
|
|
349 |
/**
|
|
350 |
* Find duplicate notification
|
|
351 |
* @param aParent entry id, under where the duplicate is searched
|
|
352 |
* @param aHeaders the original mms headers, whose duplicate is searched
|
|
353 |
* @param aDuplicate entry id of the found duplicate
|
|
354 |
*/
|
|
355 |
virtual TInt FindDuplicateNotificationL( TMsvId aParent, CMmsHeaders& aHeaders, TMsvId& aDuplicate );
|
|
356 |
|
|
357 |
/**
|
|
358 |
* check if the notification is free to start a new operation
|
|
359 |
*/
|
|
360 |
virtual TBool FreeNotification( TMsvEntry aEntry, const TUint32 aOperation );
|
|
361 |
|
|
362 |
/**
|
|
363 |
* Put recipient information and description to log event.
|
|
364 |
* The caller may add more information afterwards.
|
|
365 |
* @param aMmsHeaders reference to headers where the recipient information can be found
|
|
366 |
* @param aEntry reference to entry that contains id and description
|
|
367 |
*/
|
|
368 |
virtual void CommonLogEventInitializationL( CMmsHeaders& aMmsHeaders, TMsvEntry& aEntry );
|
|
369 |
|
|
370 |
// start of ROAMING CHECK handling
|
|
371 |
/**
|
|
372 |
* Start the roaming check, will complete asynchronously
|
|
373 |
*/
|
|
374 |
virtual void RoamingCheck();
|
|
375 |
|
|
376 |
/**
|
|
377 |
* Check result of roaming state query
|
|
378 |
*/
|
|
379 |
virtual void GetRoamingState();
|
|
380 |
// end of ROAMING CHECK handling
|
|
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
protected: // Functions from base classes
|
|
386 |
|
|
387 |
/**
|
|
388 |
* C++ default constructor.
|
|
389 |
*/
|
|
390 |
CMmsBaseOperation( RFs& aFs );
|
|
391 |
|
|
392 |
/**
|
|
393 |
* From CMsgActive: Active object completion
|
|
394 |
* We must override this, because we may have a selection of
|
|
395 |
* entries to handle. If one entry fails, we must be able to
|
|
396 |
* continue to the next one ( depending on the error ). At least
|
|
397 |
* we must be able to check what to do next. Do some cleanup, and
|
|
398 |
* maybe disconnect.
|
|
399 |
*/
|
|
400 |
virtual void RunL();
|
|
401 |
|
|
402 |
/**
|
|
403 |
* From CMsgActive: State machine state operation
|
|
404 |
*/
|
|
405 |
virtual void DoRunL();
|
|
406 |
|
|
407 |
/**
|
|
408 |
* From CMsgActive: Active object cancellation
|
|
409 |
*/
|
|
410 |
virtual void DoCancel();
|
|
411 |
|
|
412 |
/**
|
|
413 |
* From CMsgActive: Complete current operation.
|
|
414 |
* Do whatever cleanup is possible. (Delete incomplete entry etc.)
|
|
415 |
* @param aError Error code received by RunL
|
|
416 |
*/
|
|
417 |
virtual void DoComplete( TInt& aError );
|
|
418 |
|
|
419 |
private:
|
|
420 |
|
|
421 |
/**
|
|
422 |
* Check connection state after connecting to IAP
|
|
423 |
*/
|
|
424 |
void CheckConnectionState();
|
|
425 |
|
|
426 |
|
|
427 |
public: // Data
|
|
428 |
// states for the state machine
|
|
429 |
enum TMmsOperationStates
|
|
430 |
{
|
|
431 |
EMmsOperationIdle,
|
|
432 |
EMmsOperationCheckingRoaming,
|
|
433 |
EMmsOperationEncodingPDU,
|
|
434 |
EMmsOperationConnectingToIAP,
|
|
435 |
EMmsOperationInitializingSession,
|
|
436 |
EMmsOperationSubmittingTransaction,
|
|
437 |
EMmsOperationCreatingEntry,
|
|
438 |
EMmsOperationDecodingResponse,
|
|
439 |
EMmsOperationStoringResponseData,
|
|
440 |
EMmsOperationEncodingAck,
|
|
441 |
EMmsOperationSendingAck,
|
|
442 |
EMmsOperationUpdatingEntryStatus,
|
|
443 |
EMmsOperationLogging,
|
|
444 |
EMmsOperationMovingEntry,
|
|
445 |
EMmsOperationFinalizing,
|
|
446 |
EMmsOperationWaitingForBackupEnd
|
|
447 |
};
|
|
448 |
|
|
449 |
enum TMmsMarkDuplicateState
|
|
450 |
{
|
|
451 |
EMmsNotificationOperationFailed,
|
|
452 |
EMmsDeletedFromMmbox
|
|
453 |
};
|
|
454 |
|
|
455 |
protected: // Data
|
|
456 |
RFs& iFs; // file system
|
|
457 |
TInt iError;
|
|
458 |
TInt iState;
|
|
459 |
TMsvId iService;
|
|
460 |
// These three pointers come from the caller, they must not be deleted
|
|
461 |
// by this class or any derived class.
|
|
462 |
CMsvServerEntry* iServerEntry;
|
|
463 |
CMsvEntrySelection* iSelection; // Array of messages to be handled
|
|
464 |
CMmsSettings* iMmsSettings;
|
|
465 |
|
|
466 |
RSocketServ iSocketServ;
|
|
467 |
RConnection iConnection;
|
|
468 |
CMmsSession* iMmsSession;
|
|
469 |
|
|
470 |
// state we must retry in case of backup/restore error
|
|
471 |
TInt iCriticalState;
|
|
472 |
// is there an open connection to MMSC
|
|
473 |
TBool iConnected;
|
|
474 |
TInt iCurrentMessageNo;
|
|
475 |
// access point array
|
|
476 |
CArrayFixFlat<TUint32>* iIAPArray;
|
|
477 |
// The number of access point used (in case there are more than one)
|
|
478 |
TInt iConnectionIndex;
|
|
479 |
// Home page URI corresponding to the connection made
|
|
480 |
HBufC* iUri;
|
|
481 |
CMmsConnectionInitiator* iConnectionInitiator;
|
|
482 |
CMsvEntrySelection* iFailed; // failed messages
|
|
483 |
CMsvEntrySelection* iSuccessful; // successfully handled messages
|
|
484 |
CBufFlat* iEncodeBuffer;
|
|
485 |
CMmsServerEntry* iEntryWrapper; // entry wrapper for encode and decode
|
|
486 |
CMmsHeaders* iResponse; // the response message from MMSC is decoded here
|
|
487 |
// When sending messages encode the outgoing message
|
|
488 |
// When receiving messages, encode the response to MMSC
|
|
489 |
CMmsEncode* iEncoder;
|
|
490 |
// When sending messages, decode send confirmation from MMSC
|
|
491 |
// When receiving messages, decode the incoming message
|
|
492 |
CMmsDecode* iDecoder;
|
|
493 |
TBool iBackupStart;
|
|
494 |
TBool iBackupEnd;
|
|
495 |
RTimer iTimer; // timer for backup operations - we don't wait forever
|
|
496 |
TBool iHaveTimer; // have we created the local timer
|
|
497 |
// we wait only once - otherwise we might run into an endless loop
|
|
498 |
TBool iDoNotWaitForBackupEnd;
|
|
499 |
TBool iMustWait; // small delay
|
|
500 |
CLogClient* iLogClient; // For updating log
|
|
501 |
CLogViewEvent* iLogViewEvent; // log view
|
|
502 |
CLogEvent* iLogEvent;
|
|
503 |
TLogString iLogString;
|
|
504 |
CMmsLog* iMmsLog;
|
|
505 |
CDesCArray* iRemoteParties; // Pure addresses to log
|
|
506 |
TInt iNumberOfRemoteParties;
|
|
507 |
// start of ROAMING CHECK handling
|
|
508 |
// Roaming check variables included in base operation
|
|
509 |
// Only those operations that actually need roaming chech implement the actual handling
|
|
510 |
// Base class will default to "home" without actually checking anything
|
|
511 |
TInt iRegistrationStatus; // 0 = home network
|
|
512 |
CMmsPhoneClient* iPhone;
|
|
513 |
// end of ROAMING CHECK handling
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
private: // Data
|
|
518 |
|
|
519 |
public: // Friend classes
|
|
520 |
protected: // Friend classes
|
|
521 |
private: // Friend classes
|
|
522 |
|
|
523 |
};
|
|
524 |
|
|
525 |
#endif // MMSBASEOPERATION
|
|
526 |
|
|
527 |
// End of File
|