PECengine/StorageManager2/ClientSrc/CPEngObserverContainer.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Storage Id change observer container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CPENGOBSERVERCONTAINER_H__
       
    21 #define __CPENGOBSERVERCONTAINER_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <badesca.h>
       
    26 
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class MPEngSIDChangeObserver;
       
    30 class MPEngSIdContainer;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  *  Observer container
       
    36  *
       
    37  *  Container of one Sids observer.
       
    38  *  It holds reference to the
       
    39  *
       
    40  *  @lib PEngStorMan2.dll
       
    41  *  @since 3.0
       
    42  */
       
    43 NONSHARABLE_CLASS( CPEngObserverContainer ) :
       
    44         public CBase
       
    45     {
       
    46 public:  // Constructors and destructor
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      */
       
    51     static CPEngObserverContainer* NewLC(
       
    52         MPEngSIDChangeObserver& aChangeObserver,
       
    53         TInt aPriority );
       
    54 
       
    55     /**
       
    56      * Destructor.
       
    57      */
       
    58     virtual ~CPEngObserverContainer();
       
    59 
       
    60 public: // New functions
       
    61 
       
    62     /**
       
    63      *  Mark changed Storage Id
       
    64      *
       
    65      *  @since 3.0
       
    66      *  @param aChangedSId changed Storahe Id
       
    67      */
       
    68     void SIdHasChangedL( const TDesC& aChangedSId );
       
    69 
       
    70     /**
       
    71      *  Remove SId container
       
    72      *
       
    73      *  @since 3.0
       
    74      *  @param aSIdContainer Storage Id container to remove
       
    75      */
       
    76     void RemoveSIdContainer( MPEngSIdContainer* aSIdContainer );
       
    77 
       
    78     /**
       
    79      *  Notify changes of the storage IDs to observer
       
    80      *
       
    81      *  Leave error is trapped inside and informed to the observer
       
    82      *  in the notify error method
       
    83      *
       
    84      *  @since 3.0
       
    85      *	@param aPriority priority of the notification
       
    86      *		if priority does not match to the own one, notification
       
    87      *		is ignored
       
    88      */
       
    89     void NotifySIdsChanges( TInt aPriority );
       
    90 
       
    91     /**
       
    92      *  Notify SId listen error
       
    93      *
       
    94      *  @since 3.0
       
    95      *  @param aError error code
       
    96      */
       
    97     void NotifySIdListenError( TInt aError );
       
    98 
       
    99     /**
       
   100      *	Add SIDs containers
       
   101      *
       
   102      *	@since 3.0
       
   103      *	@param aSIdContainers new storage Id containers
       
   104      *	@param aOldSIdContainers array used for rollback in case
       
   105      *						error will occur while appending
       
   106      *	@param aKeepOldIds if ETrue, then engaged SIDs in
       
   107      *									the existing listener are kept
       
   108      *	@return KErrNone if operation went fine
       
   109      *						or system wide error code
       
   110      */
       
   111     TInt UpdateSIdsContainers(
       
   112         const RPointerArray<MPEngSIdContainer>& aSIdContainers,
       
   113         RPointerArray<MPEngSIdContainer>& aOldSIdContainers,
       
   114         TBool aKeepOldIds );
       
   115 
       
   116     /**
       
   117      *	Add new SIds containers
       
   118      *
       
   119      *	@since 3.0
       
   120      *	@param aSIdContaners new storage Id containers to be added
       
   121      *	@param aKeepOldIds if ETrue, then engaged SIDs in
       
   122      *									the existing listener are kept
       
   123      *	@return KErrNone if operation went fine
       
   124      *						or system wide error code
       
   125      */
       
   126     TInt UpdateSIdsContainers(
       
   127         const RPointerArray<MPEngSIdContainer>& aSIdContaners,
       
   128         TBool aKeepOldIds );
       
   129 
       
   130 
       
   131     /**
       
   132      *	Remove engaged Storage Ids from existing Storage IDs listener
       
   133      *
       
   134      *	@since 3.0
       
   135      *	@param aSIDsToRemove Storage Ids to be removed
       
   136      */
       
   137     void RemoveSIdsFromSIdsObserver( const MDesCArray& aSIdsToRemove );
       
   138 
       
   139 
       
   140     /**
       
   141      *	Remove all engaged Storage Ids from existing listener
       
   142      *
       
   143      *	@since 3.0
       
   144      */
       
   145     void RestartObserver();
       
   146 
       
   147     /**
       
   148      *  Count of Engaged SIDs
       
   149      *
       
   150      *  @since 3.0
       
   151        *  @return number of SIds observer is still listening
       
   152      */
       
   153     TInt EngagedSIdsCount();
       
   154 
       
   155     /**
       
   156      *  Observer pointer
       
   157      *
       
   158      *  @since 3.0
       
   159        *  @return Observer pointer
       
   160      */
       
   161     const MPEngSIDChangeObserver* Observer() const;
       
   162 
       
   163     /**
       
   164      * Set suspend mode of the Observer
       
   165      *
       
   166      * @since 3.0
       
   167      * @param aSuspendMode suspend mode
       
   168      */
       
   169     void SetSuspendMode( TBool aSuspendMode );
       
   170 
       
   171 private:  // New functions
       
   172 
       
   173     /**
       
   174      *	Reset Engaged SIds array,
       
   175      *
       
   176      *  @since 3.0
       
   177      */
       
   178     void ResetEngagedIdsArray();
       
   179 
       
   180 private:
       
   181 
       
   182     /**
       
   183      * C++ default constructor.
       
   184      */
       
   185     CPEngObserverContainer( MPEngSIDChangeObserver& aChangeObserver,
       
   186                             TInt aPriority );
       
   187 
       
   188     /**
       
   189      * By default Symbian 2nd phase constructor is private.
       
   190      */
       
   191     void ConstructL();
       
   192 
       
   193 
       
   194 private:    // Data
       
   195     /// REF: Storage ID change observer
       
   196     MPEngSIDChangeObserver&				iObserver;
       
   197 
       
   198     /// REF: SID containers observer is interested in
       
   199     RPointerArray<MPEngSIdContainer>	iEngagedSIds;
       
   200 
       
   201     /// Priority of the observer
       
   202     TInt								iObserverPriority;
       
   203 
       
   204     /// Flag is observer is suspended
       
   205     TBool								iSuspended;
       
   206 
       
   207     /// OWN: Buffer of changed SIDs
       
   208     CPtrCArray							iChangedSIds;
       
   209 
       
   210     /// Changes notification is in progress
       
   211     TBool								iProcessing;
       
   212 
       
   213     /// REF: Flag if object is alive
       
   214     TBool*								iAliveFlag;
       
   215     };
       
   216 
       
   217 #endif      // __CPENGOBSERVERCONTAINER_H__
       
   218 
       
   219 // End of File