emailservices/emailstore/message_store/client/inc/RMessageStoreSession.h
changeset 0 8466d47a6819
child 8 e1b6206813b4
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Message store client interface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __RMESSAGE_STORE_SESSION_H__
       
    21 #define __RMESSAGE_STORE_SESSION_H__
       
    22 
       
    23 // ========
       
    24 // INCLUDES
       
    25 // ========
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <f32file.h>
       
    29 //<cmail>
       
    30 #include "MsgStoreTypes.h"
       
    31 #include "DebugLogMacros.h"
       
    32 #include "MessageStoreClientServer.h"
       
    33 #include "MsgStoreSortResultIterator.h"
       
    34 //</cmail>
       
    35 // ====================
       
    36 // FORWARD DECLARATIONS
       
    37 // ====================
       
    38 
       
    39 class RFs;
       
    40 class CMsgStoreAccount;
       
    41 class CMsgStoreSortResultIterator;
       
    42 class RMsgStoreSortCriteria;
       
    43 class RMsgStoreSearchCriteria;
       
    44 class CMsgStoreAddress;
       
    45 
       
    46 // =========
       
    47 // CONSTANTS
       
    48 // =========
       
    49 
       
    50 _LIT( KNullDes, "" );
       
    51 
       
    52 // =========
       
    53 // Templates
       
    54 // =========
       
    55 template <class T> class CleanupResetAndDestroyClose
       
    56     {
       
    57 public:
       
    58     inline static void PushL(T& aRef);
       
    59 private:
       
    60     static void Close(TAny *aPtr);
       
    61     };
       
    62 
       
    63 template <class T> inline void CleanupResetAndDestroyClosePushL(T& aRef);
       
    64 
       
    65 template <class T> inline void CleanupResetAndDestroyClose<T>::PushL(T& aRef)
       
    66     {
       
    67     CleanupStack::PushL(TCleanupItem(&Close, &aRef));
       
    68     }
       
    69 
       
    70 template <class T> void CleanupResetAndDestroyClose<T>::Close(TAny *aPtr)
       
    71     {
       
    72     static_cast<T*>(aPtr)->ResetAndDestroy();
       
    73     static_cast<T*>(aPtr)->Close();
       
    74     }
       
    75 
       
    76 template <class T> inline void CleanupResetAndDestroyClosePushL(T& aRef)
       
    77     {
       
    78     CleanupResetAndDestroyClose<T>::PushL(aRef);
       
    79     }
       
    80 
       
    81 
       
    82 
       
    83 
       
    84 // =======
       
    85 // CLASSES
       
    86 // =======
       
    87 
       
    88 // =======================
       
    89 // CLASS: MPropertiesArray
       
    90 // =======================
       
    91 class MPropertiesArray
       
    92     {
       
    93     public:
       
    94     
       
    95  		// ==============
       
    96 		// PUBLIC METHODS
       
    97 		// ==============
       
    98 
       
    99        virtual void AddElementL( TMsgStoreId aId, TMsgStoreId aParentId, const TDesC8& aProperties ) = 0;
       
   100         
       
   101        virtual void Reset() = 0;
       
   102         
       
   103     }; // end class MPropertiesArray
       
   104 
       
   105 // =======================
       
   106 // CLASS: RMessageStoreSession
       
   107 // =======================
       
   108 class RMessageStoreSession : public RSessionBase  
       
   109 	{
       
   110 	public:
       
   111 
       
   112 		// ==============
       
   113 		// PUBLIC METHODS
       
   114 		// ==============
       
   115 		
       
   116 		RMessageStoreSession();
       
   117 		
       
   118 		~RMessageStoreSession();
       
   119 
       
   120 		TInt Connect( TBool aLaunchServerIfNeeded, TBool aRetryIndefinitely );
       
   121 
       
   122 		void Close();
       
   123 				
       
   124 		void WipeEverythingL();
       
   125         
       
   126         void EnableEncryptionL();
       
   127         
       
   128         void DisableEncryptionL();
       
   129 		
       
   130 		TBool AuthenticatedL();
       
   131 		
       
   132         TBool AuthenticateL( const TDesC& aPassword );
       
   133         
       
   134         void ClearAuthenticationL();
       
   135 
       
   136 		TBool HasPasswordL();
       
   137 		
       
   138         void SetPasswordL( const TDesC& aPassword );
       
   139         
       
   140         TBool ChangePasswordL( const TDesC& aOldPassword, const TDesC& aNewPassword ); 
       
   141         
       
   142         //account management
       
   143         TMsgStoreId CreateAccountL( const CMsgStoreAccount& aAccount, const TDesC8& aProperties );
       
   144         
       
   145         TMsgStoreId OpenAccountL( const CMsgStoreAccount& aAccount, RBuf8& aBuffer  );
       
   146         
       
   147         void DeleteAccountL( const CMsgStoreAccount& aAccount );
       
   148         
       
   149         void RenameAccountL( TInt32 aOwnerId, const TDesC& aOldName, const TDesC& aNewName );
       
   150         
       
   151         void AccountsL( RPointerArray<CMsgStoreAccount>& aAccounts );
       
   152         
       
   153 		// pass in KMsgStoreInvalidID for grandparent ID if hierarchy checking is not desired
       
   154 		TMsgStoreId CreateContainerL( TMsgStoreId             aParentId, 
       
   155 									  TMsgStoreId             aGrandparentId,
       
   156 									  TMsgStoreId             aMailBoxId,
       
   157 									  TMsgStoreContainerMasks aType,
       
   158 		                          	  const TDesC8&           aProperties,
       
   159 		                          	  TBool                   aCommitContainer = ETrue,
       
   160 		                          	  const TDesC&            aContentFilename = KNullDes );
       
   161 		
       
   162 		// pass in KMsgStoreInvalidID for grandparent ID if hierarchy checking is not desired
       
   163 		TMsgStoreId CreateContainerL( TMsgStoreId             aParentId, 
       
   164 									  TMsgStoreId             aGrandparentId,
       
   165 									  TMsgStoreId             aMailBoxId,
       
   166 									  TMsgStoreContainerMasks aType,
       
   167 		                          	  const TDesC8&           aProperties,
       
   168 		                          	  TBool                   aCommitContainer,
       
   169 		                          	  RFile&                  aFile );
       
   170 		 
       
   171 		void CommitContainerL( TMsgStoreId aId, 
       
   172 			  			       TMsgStoreId aParentId,
       
   173 			  			       TMsgStoreId aMailBoxId);
       
   174 
       
   175 		void AbandonContainerL( TMsgStoreId aId );
       
   176 		 
       
   177 		// pass in KMsgStoreInvalidID for aSourceId if hierarchy checking is not desired
       
   178 		void MoveContainerL( TMsgStoreId aId, 
       
   179 							 TMsgStoreId aSourceId,
       
   180 			 				 TMsgStoreId aDestinationId );
       
   181 		
       
   182 		// pass in KMsgStoreInvalidID for aSourceId if hierarchy checking is not desired
       
   183 		TMsgStoreId CopyContainerL( TMsgStoreId aId, 
       
   184 									TMsgStoreId aSourceId,
       
   185 									TMsgStoreId aSourceParentId,
       
   186 									TMsgStoreId aDestinationId,
       
   187 									TMsgStoreId aDestinationParentId,
       
   188 									TMsgStoreId aMailBoxId);
       
   189 		
       
   190 		// pass in KMsgStoreInvalidID for parent or grandparent ID if hierarchy checking is not desired
       
   191 		void DeleteContainerL( TMsgStoreId aId, 
       
   192 							   TMsgStoreId aParentId,
       
   193 							   TMsgStoreId aGrandparentId,
       
   194 							   TMsgStoreId aMailBoxId);
       
   195 
       
   196 		void TotalCountsL( TMsgStoreId aMailBoxId,
       
   197 						   TUint&      aMessageCounts, 
       
   198 		                   TUint&      aUnreadCounts );
       
   199 
       
   200 		void ChildrenCountsL( TMsgStoreId aId,
       
   201 		                      TUint&      aMessageCounts, 
       
   202 		                      TUint&      aUnreadCounts );
       
   203 
       
   204 		void ChildrenIdsL( TMsgStoreId             aId, 
       
   205 		                   TMsgStoreContainerMasks aType,
       
   206 		                   RArray<TMsgStoreId>&    aChildrenIds );
       
   207 		
       
   208 		// pass in KMsgStoreInvalidID for parent or grandparent ID if hierarchy checking is not desired
       
   209 		void ContainerPropertiesL( TMsgStoreId  aId, 
       
   210 		                           TMsgStoreId& aParentId,
       
   211 		                           TMsgStoreId  aGrandparentId,
       
   212 		                           RBuf8&       aBuffer,
       
   213 		                           TMsgStoreId  aMailboxId = KMsgStoreInvalidId );
       
   214 		
       
   215 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   216 		void UpdatePropertiesL( TMsgStoreId   aId,
       
   217 								TMsgStoreId   aParentId, 
       
   218 								TMsgStoreId   aMailBoxId,
       
   219 		                        const TDesC8& aProperties );		
       
   220 		
       
   221 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   222 		void UpdatePropertyL( TMsgStoreId                aId, 
       
   223 							  TMsgStoreId                aParentid, 
       
   224 							  TMsgStoreId                aMailBoxId,
       
   225 		                      const TDesC8&              aName,
       
   226 		                      TMsgStorePropertyValueType aType,
       
   227 		                      const TDesC8&              aValue );		
       
   228 		
       
   229 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   230 		TUint ContentLengthL( TMsgStoreId aId, TMsgStoreId aParentId );
       
   231 
       
   232 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   233 		void FetchContentL( TMsgStoreId aId,
       
   234 		                    TMsgStoreId aParentId,
       
   235 		                    TDes8&      aBuffer, 
       
   236 		                    TUint       aStartOffset );
       
   237 		
       
   238 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   239 		void FetchContentL( TMsgStoreId  aId, 
       
   240 		                    TMsgStoreId aParentId,		
       
   241 		                    const TDesC& aFilename );
       
   242 		
       
   243 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   244 		void ReplaceContentL( TMsgStoreId   aId, 
       
   245 							  TMsgStoreId   aParentId, 
       
   246 		                      const TDesC8& aContent );	
       
   247 		
       
   248 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   249 		void ReplaceContentWithFileL( TMsgStoreId  aId,  
       
   250 							          TMsgStoreId  aParentId, 
       
   251 		                              const TDesC& aFilename );	
       
   252 		
       
   253 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   254 		void AppendToContentL( TMsgStoreId   aId, 
       
   255 							   TMsgStoreId   aParentId, 
       
   256 		                       const TDesC8& aContent );	
       
   257 		
       
   258         // pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   259         void PrependToContentL( TMsgStoreId   aId, 
       
   260                                TMsgStoreId   aParentId, 
       
   261                                const TDesC8& aContent );    
       
   262 
       
   263         // pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   264 		void RemoveContentL( TMsgStoreId aId,
       
   265  							 TMsgStoreId aParentId );
       
   266         
       
   267         // Open the original content file to be used on the client side
       
   268         void OpenOriginalContentFileL( TMsgStoreId aId,
       
   269                                        TMsgStoreId aParentId, 
       
   270                                        RFile&      aFile );
       
   271 		
       
   272 		// pass in KMsgStoreInvalidID for parent ID if hierarchy checking is not desired
       
   273 		void ChildrenPropertiesL( TMsgStoreId             aId,
       
   274 		                          TMsgStoreId             aParentId,
       
   275 		                          TMsgStoreContainerMasks aType,
       
   276 		                          TBool                   aQuickProperties,
       
   277 		                          TBool                   aRecursive,
       
   278 		                          MPropertiesArray&       aPropertiesArray );
       
   279 		                          
       
   280         void PropertiesL( const RArray<TMsgStoreId>&   aIds, 
       
   281                           const RPointerArray<TDesC8>& aPropertyNames, 
       
   282                           MPropertiesArray&            aPropertiesArray );	          
       
   283         
       
   284         void BeginBatchInsertL();
       
   285         
       
   286         void FinishBatchInsertL();
       
   287 		
       
   288 		// OBSERVER FUNCTIONS
       
   289 		
       
   290 		void StartObservingL();
       
   291 		
       
   292 		// Returns a ID of KMsgStoreInvalidID when the search has completed.
       
   293 		void GetEvents( TRequestStatus& aStatus, 
       
   294 		                 TDes8&         aBuffer );
       
   295 		
       
   296 		void StopObserving();
       
   297         
       
   298         // SORT FUNCTIONS
       
   299         
       
   300         TMsgStoreId SortL( RMsgStoreSortCriteria& aSortCriteria, TMsgStoreId aMailBoxId, TBool aInMemorySort );
       
   301         
       
   302         TBool GetSortedRowsL( TMsgStoreId                aSortSessionId,
       
   303                               TMsgStoreId                aCurrentMessageId, 
       
   304                               TMsgStoreIteratorDirection aDirection,
       
   305                               TUint                      aCount, 
       
   306                               MPropertiesArray&          aPropertiesArray,
       
   307                               const TDesC&               aStartWith = KNullDesC,
       
   308                               TBool                      aSkipCurrentGroup = EFalse );
       
   309         
       
   310         TInt SortIteratorGroupCountL( TMsgStoreId aSortSessionId, RArray<TUint>& aItemsInGroup );
       
   311         
       
   312         void SortedIdsAndFlagsL( TMsgStoreId aSortSessionId, RArray<TMsgStoreIdAndFlag>& aIdsAndFlags );
       
   313         
       
   314         TInt SortedIndexOfL( TMsgStoreId aSortSessionId, TMsgStoreId aMessageId );
       
   315         
       
   316         void SortedIdsL( TMsgStoreId aSortSessionId, RArray<TMsgStoreId>& aMessageIds );
       
   317         
       
   318         void IdsAndGroupCountL( TMsgStoreId aSortSessionId, RArray<TMsgStoreId>& aMessageIds, RArray<TUint>& aItemsInGroup );
       
   319         
       
   320         void EndSortL( TMsgStoreId aSortSessionId );
       
   321         
       
   322 		
       
   323 		// SEARCH FUNCTIONS
       
   324 		
       
   325 		void PrepareSearchL( RMsgStoreSearchCriteria& aSearchCriteria );
       
   326 		
       
   327 		// returns empty buffer when search has completed.
       
   328 		void GetMatchesL( TRequestStatus& aStatus, TDes8& aBuffer );
       
   329 		
       
   330 		void CancelSearch();
       
   331         
       
   332         void ClearSearchResultCache();
       
   333         
       
   334         void SetMaxMruAddressCountL( TInt aMaxCount );
       
   335         
       
   336         void AddMruAddressesL( TMsgStoreId aMailBoxId, RPointerArray<CMsgStoreAddress>& aAddressArray );
       
   337         
       
   338         void MruAddressesL( TMsgStoreId aMailBoxId, RPointerArray<CMsgStoreAddress>& aAddressArray );
       
   339         
       
   340         TMsgStoreContainerType ContainerTypeById( TMsgStoreId aId );
       
   341 		
       
   342     private:
       
   343     
       
   344         void DoPropertiesListL( TMsgStorePropertiesListCmdParams& aParams,
       
   345                                 const TDesC8&                     aSerializedIds, 
       
   346                                 const TDesC8&                     aSerializedPropertyNames, 
       
   347                                 MPropertiesArray&                 aPropertiesArray );
       
   348                                 
       
   349         TInt StartServer();
       
   350         
       
   351         __LOG_DECLARATION                              
       
   352 		        
       
   353 	}; // end client RMessageStoreSession
       
   354 	
       
   355 #endif // __RMESSAGE_STORE_SESSION_H__