1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/gsmustor.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,525 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Declares the classes TSAREntry and CSARStore
1.18 +// Abbreviations:
1.19 +// PDU - Packet Data Unit
1.20 +// SAR - Segmentation and Reassembly Store
1.21 +// SR - Status Report
1.22 +//
1.23 +//
1.24 +
1.25 +
1.26 +
1.27 +/**
1.28 + @file
1.29 +*/
1.30 +
1.31 +#ifndef GSMUSTOR_H__
1.32 +#define GSMUSTOR_H__
1.33 +
1.34 +#include <e32base.h>
1.35 +#include <s32std.h>
1.36 +#include <s32file.h>
1.37 +#include <gsmumsg.h>
1.38 +#include <babackup.h>
1.39 +
1.40 +/**
1.41 + * Filestore second UID for SAR stores.
1.42 + * @publishedAll
1.43 + * @released
1.44 + */
1.45 +const TUid KSARStoreUid={0x1000089d};
1.46 +
1.47 +//
1.48 +// forward declarations
1.49 +//
1.50 +class RReadStream;
1.51 +class RWriteStream;
1.52 +
1.53 +/**
1.54 + * Provides generic information useful for the segmentation and reassembly of
1.55 + * SMS messages and reassembly of WAP datagrams.
1.56 + *
1.57 + * The constituent parts of both concatenated SMS messages and concatenated 7-bit
1.58 + * WAP datagrams contain a reference, the total number of parts and the index
1.59 + * of the part in the complete message or datagram.
1.60 + *
1.61 + * Field for the segmentation store are:
1.62 + *
1.63 + * Reference - concatenation reference
1.64 + * Total - total number of PDUs in SMS message
1.65 + * Count - number of PDUs sent
1.66 + * Data1 - total PDUs delivered<<16 and failed
1.67 + * Data2 - log server id
1.68 + * Data3 - validity period
1.69 + * Data4 - type and min and max message reference
1.70 + * Description1 - first 32 characters from buffer
1.71 + * Description2 - original address
1.72 + * Time - time on SMS message
1.73 + *
1.74 + * Abstracts an entry which is stored in the CSARStore
1.75 + *
1.76 + * The data stored in Data1-4 has a different meaning depending on if it is used
1.77 + * by the Reassembly store or the Segmentation store. The lists below detail
1.78 + * the uses:
1.79 + *
1.80 + * Reassembly store:
1.81 + *
1.82 + * Data1: byte 3: bits7to4; byte 1: identifier1; byte 0: identifier2.
1.83 + *
1.84 + * Data2: Log server ID.
1.85 + *
1.86 + * Data3: byte 0: PDU type.
1.87 + *
1.88 + * Data4: SMS message storage .
1.89 + *
1.90 + * Segmentation store:
1.91 + *
1.92 + * Data1: bytes 3, 2: N delivered; byte 1,0 N failed.
1.93 + *
1.94 + * Data2: Log server ID.
1.95 + *
1.96 + * Data3: SMS submit validity period.
1.97 + *
1.98 + * Data4: byte 3,2 message PDU type; byte 1: reference1; byte 0: reference2.
1.99 + *
1.100 + * WAP reassembly store:
1.101 + *
1.102 + * Data1: to port.
1.103 + *
1.104 + * Data2: not used .
1.105 + *
1.106 + * Data3: not used.
1.107 + *
1.108 + * Data4: not used.
1.109 + *
1.110 + * <pre>
1.111 + *
1.112 + * The data stored in Data1-4 has a different meaning depending on if it is used
1.113 + * by the Reassembly store or the Segmentation store. The tables below detail
1.114 + * the uses:
1.115 + *
1.116 + * Reassembly Store:
1.117 + *
1.118 + * -----------------------------------------------------------------
1.119 + * | member | 3 | 2 | 1 | 0 |
1.120 + * -----------------------------------------------------------------
1.121 + * | iData1 | bits7to4 | identifier1 | identifier2 |
1.122 + * | iData2 | Log server ID |
1.123 + * | iData3 | | PDU type |
1.124 + * | iData4 | SMS message storage |
1.125 + * -----------------------------------------------------------------
1.126 + *
1.127 + * Segmentation Store:
1.128 + *
1.129 + * -----------------------------------------------------------------
1.130 + * | member | 3 | 2 | 1 | 0 |
1.131 + * -----------------------------------------------------------------
1.132 + * | iData1 | N delivered | N failed |
1.133 + * | iData2 | Log server ID |
1.134 + * | iData3 | SMS submit validity period |
1.135 + * | iData4 | message PDU type | reference1 | reference2 |
1.136 + * -----------------------------------------------------------------
1.137 + *
1.138 + * WAP Reassembly Store:
1.139 + *
1.140 + * -----------------------------------------------------------------
1.141 + * | member | 3 | 2 | 1 | 0 |
1.142 + * -----------------------------------------------------------------
1.143 + * | iData1 | to port |
1.144 + * | iData2 | not used |
1.145 + * | iData3 | not used |
1.146 + * | iData4 | not used |
1.147 + * -----------------------------------------------------------------
1.148 + *
1.149 + * </pre>
1.150 + *
1.151 + * @publishedAll
1.152 + * @released
1.153 + *
1.154 + */
1.155 +class TSAREntry
1.156 + {
1.157 +public:
1.158 + enum
1.159 + {
1.160 + ESmsSAREntryDescriptionLength=32
1.161 + };
1.162 +public:
1.163 + IMPORT_C TSAREntry();
1.164 + inline TInt Reference() const;
1.165 + inline void SetReference(TInt aReference);
1.166 + inline TInt Total() const;
1.167 + inline void SetTotal(TInt aTotal);
1.168 + inline TInt Count() const;
1.169 + inline void SetCount(TInt aCount);
1.170 + inline TBool IsComplete() const;
1.171 +
1.172 + /**
1.173 + * Gets the Log server ID field.
1.174 + *
1.175 + * @return Log server ID field
1.176 + */
1.177 + inline TInt LogServerId() const {return iData2;}
1.178 + /**
1.179 + * Sets the Log server ID field.
1.180 + *
1.181 + * @param aId Log server ID field
1.182 + */
1.183 + inline void SetLogServerId(TInt aId) {iData2 = aId;}
1.184 +
1.185 + inline TPtrC Description1() const;
1.186 + inline void SetDescription1(const TDesC& aDescription);
1.187 + inline TPtrC Description2() const;
1.188 + inline void SetDescription2(const TDesC& aDescription);
1.189 +
1.190 + inline TInt Data3() const;
1.191 + inline void SetData3(TInt aData);
1.192 +
1.193 + inline const TTime& Time() const;
1.194 + inline void SetTime(const TTime& aTime);
1.195 +
1.196 + inline TStreamId DataStreamId() const;
1.197 + inline void SetDataStreamId(TStreamId aStreamId);
1.198 +
1.199 + IMPORT_C void InternalizeL(RReadStream& aStream);
1.200 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.201 +
1.202 +private:
1.203 + inline TBool IsDeleted() const;
1.204 + inline void SetIsDeleted(TBool aIsDeleted);
1.205 + inline TBool IsAdded() const;
1.206 + inline void SetIsAdded(TBool aIsAdded);
1.207 +
1.208 +private:
1.209 + enum TSAREntryFlags
1.210 + {
1.211 + ESAREntryIsDeleted=0x01, ///< indicates that this entry is deleted
1.212 + ESAREntryIsAdded=0x02 ///< indicated that this entry is added
1.213 + };
1.214 +private:
1.215 + TInt iReference; ///< concatenation reference
1.216 + TInt iTotal; ///< total number of PDUs in this SMS message
1.217 + TInt iCount; ///< number of PDUs sent/received for this SMS message
1.218 +protected:
1.219 + TInt iData1; /// TODO should be TUint32
1.220 + TInt iData2; ///< Log server ID
1.221 + TInt iData3;
1.222 + TInt iData4;
1.223 +private:
1.224 + TBuf<ESmsSAREntryDescriptionLength> iDescription1; ///< first 32 characters from buffer
1.225 + TBuf<ESmsSAREntryDescriptionLength> iDescription2; ///< original address
1.226 + TTime iTime; ///< time when message was sent/received
1.227 + TStreamId iDataStreamId;
1.228 + TInt iFlags; // Not externalized
1.229 + friend class CSARStore;
1.230 + friend class CSmsPermanentFileStore;
1.231 + friend class CPreallocatedFile;
1.232 + };
1.233 +
1.234 +
1.235 +/**
1.236 + * Abstraction of an SMS reassembly store entry for incoming SMS messages.
1.237 + *
1.238 + * This class should reflect parts of a complete SMS message to be stored in
1.239 + * the reassembly store.
1.240 + * @publishedAll
1.241 + * @released
1.242 + */
1.243 +class TSmsReassemblyEntry : public TSAREntry
1.244 + {
1.245 +private:
1.246 + enum
1.247 + {
1.248 + KMarkedAsPassedToClientFlag = 0x80000000,
1.249 + KPduTypeMask = 0xFF,
1.250 + KReassemblyEntryClear = 0x00
1.251 + };
1.252 +
1.253 +public:
1.254 + // iData1
1.255 + /**
1.256 + * Gets bits 7 to 4 from Data1 field.
1.257 + *
1.258 + * @return Bits 7 to 4 of Data 1
1.259 + */
1.260 + inline TInt Bits7to4() const {return (iData1 >> 16) & 0xffff;}
1.261 + /**
1.262 + * Gets Identifier1 from Data1 field.
1.263 + *
1.264 + * @return Identifier1
1.265 + */
1.266 + inline TInt Identifier1() const {return (iData1 >> 8) & 0xff;}
1.267 + /**
1.268 + * Gets Identifier2 from Data1 field.
1.269 + *
1.270 + * @return Identifier2
1.271 + */
1.272 + inline TInt Identifier2() const {return (iData1 >> 0) & 0xff;}
1.273 + inline void SetBits7to4andIdentifiers(TInt aBits7to4, TInt aId1, TInt aId2)
1.274 + /**
1.275 + * Sets bits 7 to 4, Identifier1, and Identifier2, in Data1 field.
1.276 + *
1.277 + * @param aBits7to4 Bits 7 to 4
1.278 + * @param aId1 Identifier1
1.279 + * @param aId2 Identifier2
1.280 + */
1.281 + {iData1 = (TInt)((aBits7to4 << 16) | ((aId1 & 0xff)<< 8) | (aId2 & 0xff)); }
1.282 +
1.283 + // iData3
1.284 + /**
1.285 + * Gets PDU type.
1.286 + *
1.287 + * @return PDU type
1.288 + */
1.289 + inline CSmsPDU::TSmsPDUType PduType() const {return (CSmsPDU::TSmsPDUType)(iData3 & 0xff);} // 8 bits
1.290 + /**
1.291 + * Sets PDU type.
1.292 + *
1.293 + * @param aPduType PDU type
1.294 + */
1.295 + inline void SetPduType(CSmsPDU::TSmsPDUType aPduType) {iData3 = (iData3 & ~KPduTypeMask) | (TInt)(aPduType & KPduTypeMask);}
1.296 +
1.297 + /**
1.298 + * Tests if Passed To Client flag is set.
1.299 + *
1.300 + * @return True if Passed To Client flag is set.
1.301 + */
1.302 + inline TBool PassedToClient() const {return (iData3 & KMarkedAsPassedToClientFlag) ? ETrue:EFalse;}
1.303 + /**
1.304 + * Sets Passed To Client flag.
1.305 + *
1.306 + * @param aPassed True if Passed To Client flag is set.
1.307 + */
1.308 + inline void SetPassedToClient(TBool aPassed) {iData3 = (iData3 & ~KMarkedAsPassedToClientFlag) | (aPassed ? KMarkedAsPassedToClientFlag : KReassemblyEntryClear);}
1.309 +
1.310 + // iData4
1.311 + /**
1.312 + * Gets storage information.
1.313 + *
1.314 + * @return Storage information
1.315 + */
1.316 + inline CSmsMessage::TMobileSmsStorage Storage() const {return (CSmsMessage::TMobileSmsStorage)(iData4 & 0xff);}
1.317 + /**
1.318 + * Sets storage information.
1.319 + *
1.320 + * @param aStorage Storage information
1.321 + */
1.322 + inline void SetStorage(CSmsMessage::TMobileSmsStorage aStorage) {iData4 = (CSmsMessage::TMobileSmsStorage)aStorage;}
1.323 + };
1.324 +
1.325 +
1.326 +/**
1.327 + * Abstraction of an SMS segmentation store entry for outgoing SMS messages.
1.328 + *
1.329 + * This class should reflect parts of a complete SMS message to be stored in
1.330 + * the segmentation store.
1.331 + * @publishedAll
1.332 + * @released
1.333 + */
1.334 +class TSmsSegmentationEntry : public TSAREntry
1.335 + {
1.336 +public:
1.337 + // iData1
1.338 + /**
1.339 + * Gets number of delivered PDUs.
1.340 + *
1.341 + * @return Number of delivered PDUs
1.342 + */
1.343 + inline TInt Delivered() const {return (iData1 >> 16);}
1.344 + /**
1.345 + * Gets number of permanently failed PDUs.
1.346 + *
1.347 + * @return Number of permanently failed PDUs
1.348 + */
1.349 + inline TInt Failed() const {return (iData1 & 0xffff);}
1.350 + inline void SetDeliveredAndFailed(TInt aDelivered, TInt aFailed)
1.351 + /**
1.352 + * Sets the number of delivered and failed PDUs.
1.353 + *
1.354 + * @param aDelivered Number of delivered PDUs
1.355 + * @param aFailed Number of permanently failed PDUs
1.356 + */
1.357 + {iData1 = ((aDelivered << 16) | (aFailed & 0xffff));}
1.358 +
1.359 + // iData3
1.360 + /**
1.361 + * Gets the Validity Period.
1.362 + *
1.363 + * @return Validity Period
1.364 + */
1.365 + inline TInt ValidityPeriod() const {return (iData3); }
1.366 + /**
1.367 + * Sets the Validity Period.
1.368 + *
1.369 + * @param aValPer Validity Period
1.370 + */
1.371 + inline void SetValidityPeriod(TInt aValPer) {iData3 = aValPer; }
1.372 +
1.373 + // iData4
1.374 + /**
1.375 + * Tests if a status report is expected.
1.376 + *
1.377 + * @return True if a status report is expected
1.378 + */
1.379 + inline TBool ExpectStatusReport() const {return (((iData4 >> 24) & 0x01) == 0x01); }
1.380 + /**
1.381 + * Gets the type of the PDU.
1.382 + *
1.383 + * @return Type of the PDU
1.384 + */
1.385 + inline CSmsPDU::TSmsPDUType PduType() const {return (CSmsPDU::TSmsPDUType)((iData4 >> 16) & 0xff); }
1.386 + /**
1.387 + * Gets the message reference (low byte).
1.388 + *
1.389 + * @return Message reference (low byte)
1.390 + */
1.391 + inline TInt Reference1() const {return ((iData4 >> 8) & 0xff); }
1.392 + /**
1.393 + * Gets the message reference (high byte).
1.394 + *
1.395 + * @return Message reference (high byte)
1.396 + */
1.397 + inline TInt Reference2() const {return ((iData4 >> 0) & 0xff); }
1.398 + inline void SetPduTypeAndRefs(TBool aSR, TInt aPduType, TInt aRef1, TInt aRef2)
1.399 + /**
1.400 + * Sets status report flag, PDU type, and message references.
1.401 + *
1.402 + * @param aSR True if a status report is expected
1.403 + * @param aPduType Type of the PDU
1.404 + * @param aRef1 Message reference (low byte)
1.405 + * @param aRef2 Message reference (high byte)
1.406 + */
1.407 + {iData4 = (((aSR & 0x01) << 24) | (aPduType << 16) | ((aRef1 & 0xff ) << 8) | (aRef2 & 0xff));}
1.408 + };
1.409 +
1.410 +
1.411 +/**
1.412 + * Abstraction of a WAP reassembly store entry.
1.413 + * This class should reflect a complete WAP message.
1.414 + * @publishedAll
1.415 + * @released
1.416 + */
1.417 +class TWapReassemblyEntry : public TSAREntry
1.418 + {
1.419 +public:
1.420 + /**
1.421 + * Gets the destination port number.
1.422 + *
1.423 + * @return Destination port number
1.424 + */
1.425 + inline TInt ToPort() const {return iData1;}
1.426 + /**
1.427 + * Sets the destination port number.
1.428 + *
1.429 + * @param aToPort Destination port number
1.430 + */
1.431 + inline void SetToPort(TInt aToPort){iData1 = aToPort;}
1.432 + };
1.433 +
1.434 +/**
1.435 + * Controls the segmentation and reassembly (SAR) store, used for SMS segmentation
1.436 + * and reassembly, and WAP reassembly.
1.437 + * @publishedAll
1.438 + * @released
1.439 + */
1.440 +class CSARStore : public CBase
1.441 + {
1.442 +public:
1.443 + IMPORT_C void OpenL(const TDesC& aFullName,const TUid& aThirdUid);
1.444 + IMPORT_C void Close();
1.445 + IMPORT_C void CompactL();
1.446 +
1.447 + IMPORT_C const CArrayFix<TSAREntry>& Entries() const;
1.448 + IMPORT_C void PurgeL(const TTimeIntervalMinutes& aTimeIntervalMinutes,TBool aPurgeIncompleteOnly);
1.449 + IMPORT_C void PurgeL(TInt aKSegmentationLifetimeMultiplier,TBool aPurgeIncompleteOnly);
1.450 + IMPORT_C void DeleteEntryL(TInt aIndex);
1.451 +
1.452 + IMPORT_C void BeginTransactionLC();
1.453 + IMPORT_C void CommitTransactionL(); //Pops this off this cleanup stack and commits iFileStore
1.454 + void Revert();
1.455 +
1.456 + inline RFs& FileSession() const;
1.457 + inline TBool InTransaction()const;
1.458 + IMPORT_C void DoOpenL();
1.459 + IMPORT_C void PrivatePath(TDes& aPath);
1.460 +
1.461 +
1.462 +protected:
1.463 + IMPORT_C CSARStore(RFs& aFs);
1.464 + IMPORT_C ~CSARStore();
1.465 +
1.466 + IMPORT_C CFileStore& FileStore();
1.467 + IMPORT_C const CFileStore& FileStore() const;
1.468 +
1.469 + IMPORT_C void AddEntryL(const TSAREntry& aEntry);
1.470 + IMPORT_C void ChangeEntryL(TInt aIndex,const TSAREntry& aNewEntry);
1.471 +
1.472 + IMPORT_C TStreamId ExtraStreamId() const;
1.473 + IMPORT_C void SetExtraStreamIdL(const TStreamId& aExtraStreamId);
1.474 +
1.475 +private:
1.476 + void DoDeleteEntryL(TInt aIndex); // Deletes stream but doesn't call iFileStore->CommitL()
1.477 + void InternalizeEntryArrayL();
1.478 + void ExternalizeEntryArrayL();
1.479 + void DoCommitAndCompactL();
1.480 + void RemoveDeletedEntries();
1.481 + void ReinstateDeletedEntries();
1.482 +
1.483 +private:
1.484 + enum
1.485 + {
1.486 + KNumStoreCommitsBeforeCompaction=16
1.487 + };
1.488 +
1.489 +protected:
1.490 + RFs& iFs; ///< File server handle.
1.491 +private:
1.492 +
1.493 + CFileStore* iFileStore; ///< pointer to the file store
1.494 + CArrayFixFlat<TSAREntry> iEntryArray; ///< array of SAR entries
1.495 + TStreamId iExtraStreamId; ///< used for any other data that needs persisting
1.496 + TInt iCommitCount; ///< counts number of Commit's - used for CompactL
1.497 + TPtrC iFullName; ///< holds the name of the File Store
1.498 + TUid iThirdUid;
1.499 + TBool iInTransaction; ///< For debugging purposes to ensure only one transaction at a time
1.500 + };
1.501 +
1.502 +/**
1.503 + * Closes all SAR stores if a backup event starts.
1.504 + *
1.505 + * This is internal and not intended for use.
1.506 + * @publishedAll
1.507 + * @released
1.508 + */
1.509 +class CGsmuBackupObserver : public CBase, MBackupOperationObserver
1.510 + {
1.511 + public:
1.512 + IMPORT_C static CGsmuBackupObserver* NewL();
1.513 + IMPORT_C ~CGsmuBackupObserver();
1.514 + IMPORT_C void AddSARStoreL(CSARStore& aSARStore);
1.515 + IMPORT_C void RemoveSARStore(const CSARStore& aSARStore);
1.516 +
1.517 + private:
1.518 + CGsmuBackupObserver();
1.519 + void ConstructL();
1.520 + void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes);
1.521 +
1.522 + CBaBackupSessionWrapper* iBackup;
1.523 + RPointerArray<CSARStore> iSARStores;
1.524 + };
1.525 +
1.526 +#include "gsmustor.inl"
1.527 +
1.528 +#endif // !defined GSMUSTOR_H__