smsprotocols/smsstack/smsprot/Inc/smspreassemblystore.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalAll
       
    19 */
       
    20 
       
    21 #ifndef __SMSPREASSEMBLYSTOR_H__
       
    22 #define __SMSPREASSEMBLYSTOR_H__
       
    23 
       
    24 #include <e32base.h>
       
    25 #include "gsmustor.h"
       
    26 #include "smsprot.h"
       
    27 
       
    28 /**
       
    29  *  @internalComponent
       
    30  */
       
    31 const TDriveNumber KStoreDrive = EDriveC;
       
    32 _LIT(KStoreSubDir, "sms\\");
       
    33 
       
    34 // Flat array object's granularity.
       
    35 const TInt KFlatArrayGranularity = 8;
       
    36 
       
    37 /**
       
    38  *  Provides Utility functions for re-assembly store.
       
    39  *  
       
    40  *  @internalComponent
       
    41  */
       
    42 class CReassemblyStoreUtility : public CBase
       
    43 	{
       
    44 public:
       
    45 	static void PrivatePath(RFs& aFs, TDes& aPath);
       
    46 	static void PopulateEntry(TSmsReassemblyEntry& aEntry,const CSmsMessage& aSmsMessage,TInt aNumSmss);
       
    47 	};
       
    48 
       
    49 /**
       
    50  *  Provides generic information useful for the reassembly of SMS messages.
       
    51  *  
       
    52  *  This class should reflect parts of a complete SMS message to be stored in
       
    53  *  the reassembly store.
       
    54  *  @internalComponent
       
    55  */
       
    56 class TReassemblyEntry : public TSmsReassemblyEntry
       
    57 	{
       
    58 	private:
       
    59 	/*
       
    60 	In TSmsReassemblyEntry, the below 2 functions are public.
       
    61 	In this class main intention is to make these 2 function private
       
    62 	so that client can't use those 2 functions. This class will be used in
       
    63 	CReassemblyStore class which does not deal with storing the data in
       
    64 	permanent store file. So there is no need of these 2 functions.
       
    65 	*/
       
    66 	TStreamId DataStreamId() const;
       
    67 	void SetDataStreamId(TStreamId aStreamId);
       
    68 	};
       
    69 
       
    70 /**
       
    71  *  This class is based on template design pattern. The re-assembly store logic is divided
       
    72  *	into invariant & variant part. The invariant part logic is specified here.
       
    73  *	Variant part logic is left to sub-class to implement. 
       
    74  *	Invariant part deals with addition/updation/deletion of SMS message in re-assembly store
       
    75  *	without knowing where or how the message is stored.	Variant part logic
       
    76  *	mainly deals with storing/reading SMS messages in/from persistent file. So in future if 
       
    77  *	situation demand then storing part can be changed without any changes in invariant part.
       
    78  *	In that case new class has to be derived from this class & all pure virtual function has
       
    79  *	to be implemented.
       
    80  *  @internalComponent
       
    81  */
       
    82 class CReassemblyStore : public CBase
       
    83 	{
       
    84 public:
       
    85 	void InitializeL();
       
    86 	void PurgeL(const TTimeIntervalMinutes& aTimeIntervalMinutes,TBool aPurgeIncompleteOnly);
       
    87 	void DeleteEnumeratedSIMEntries();
       
    88 	TInt NumberOfCompleteMessages();
       
    89 
       
    90 	void AddSegmentToReassemblyStoreL(CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms, TInt& aIndex, TBool& aIsComplete, TBool aIsEnumeration, TInt& aCount, TInt& aTotal);
       
    91 	void DeleteMessageL(const CSmsMessage& aSmsMessage, TBool aPassed);
       
    92 	void UpdateLogServerIdOfMessageL(const CSmsMessage& aSmsMessage, TInt aIndex);
       
    93 	void SetMessagePassedToClientL(const CSmsMessage& aSmsMessage, TBool aPassed=ETrue);
       
    94 	void GetMessageL(TInt aIndex, CSmsMessage& aSmsMessage);
       
    95 
       
    96 protected:
       
    97 	CReassemblyStore(RFs& aFs);
       
    98 	virtual ~CReassemblyStore();
       
    99 
       
   100 	virtual void NewMessagePDUL(TInt& aIndex,CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms);
       
   101 	void MatchPDUToExistingMessage(const CSmsMessage& aSmsMessage, TInt& aIndex);
       
   102 	virtual void UpdateExistingMessageL(CSmsMessage& aSmsMessage,
       
   103 								const TGsmSms& aGsmSms, TInt aIndex,
       
   104 								TBool& aComplete,
       
   105 								TBool& aDuplicateMsgRef,
       
   106 								TBool& aDuplicateSlot);
       
   107 
       
   108 	TBool FindMessageL(const CSmsMessage& aSmsMessage, TBool aPassed, TInt& aIndex);
       
   109 	const CArrayFix<TReassemblyEntry>& Entries() const {return iEntryArray;}
       
   110 
       
   111 public:
       
   112 	/*
       
   113 	This function will open the file where SMS messages are stored
       
   114 	*/
       
   115 	virtual void OpenStoreL()=0;
       
   116 	/*
       
   117 	This function will close the file where SMS messages are stored
       
   118 	*/
       
   119 	virtual void Close()=0;
       
   120 
       
   121 private:
       
   122 	/*
       
   123 	This function will fill-up the entries for all the messages stored in re-assembly store.
       
   124 	*/
       
   125 	virtual void PopulateEntryArrayL(CArrayFix<TReassemblyEntry>& aEntryArray) = 0;
       
   126 	/*
       
   127 	This function will add a new message in the persistent file.
       
   128 	*/
       
   129 	virtual void AddNewMessageL(CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms) = 0;
       
   130 	/*
       
   131 	This function will update an existing message in the persistent file.
       
   132 	*/
       
   133 	virtual void UpdateExistingMessageL(CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms, TBool& aDuplicateMsgRef, TBool& aDuplicateSlot) = 0;
       
   134 	/*
       
   135 	This function will return an SMS message based on the provided entry information.
       
   136 	*/
       
   137 	virtual void RetrieveMessageL(const TReassemblyEntry& aEntry, CSmsMessage& aSmsMessage) = 0;
       
   138 	/*
       
   139 	This function will delete a SMS message based on the provided entry information.
       
   140 	*/
       
   141 	virtual void DeleteEntryL(const TReassemblyEntry& aEntry) = 0;
       
   142 	/*
       
   143 	This function will update the Set Passed To Client field of the provided entry.
       
   144 	*/
       
   145 	virtual void SetPassedToClientL(const TReassemblyEntry& aEntry, TBool aBool) = 0;
       
   146 	/*
       
   147 	This function will update the log server id of the provided entry.
       
   148 	*/
       
   149 	virtual void UpdateLogServerIdL(const TReassemblyEntry& aEntry, TLogId aLogServerId) = 0;
       
   150 	/*
       
   151 	This function will begin the transaction.
       
   152 	*/
       
   153 	virtual void BeginTransactionLC() = 0;
       
   154 	/*
       
   155 	This function will commit the transaction.
       
   156 	*/
       
   157 	virtual void CommitTransactionL() = 0;
       
   158 
       
   159 protected:
       
   160 	/*
       
   161 	Ideally RFs should not be a member variable of this class.
       
   162 	But at the time of creating CSmsMessage it needs reference to RFs
       
   163 	That is the reason why it is here.
       
   164 	*/
       
   165 	RFs& iFs;
       
   166 	CArrayFixFlat<TReassemblyEntry>	iEntryArray;
       
   167 	TTime iLastReceivedTime;
       
   168 	TTime iLastRealTime;
       
   169 	};
       
   170 
       
   171 #endif // !defined __SMSPREASSEMBLYSTOR_H__