wvuing/wvuieng/EngSrc/CCAStorageObserver.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003-2005 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:  Observes storage events and reacts according to settings
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CCASTORAGEOBSERVER_H
       
    20 #define CCASTORAGEOBSERVER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "PublicEngineDefinitions.h"
       
    24 #include "MCAStoredContactsObserver.h"
       
    25 #include "MCAContactLists.h"
       
    26 
       
    27 #include "impsbuilddefinitions.h"
       
    28 #include <e32base.h>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class MCASettings;
       
    32 class MCAStoredContacts;
       
    33 class MCAStoredContact;
       
    34 class MCAPresence;
       
    35 class MCABlocking;
       
    36 class MCAIncomingMessages;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  Observes storage events and reacts according to settings
       
    42 *
       
    43 *
       
    44 *  @lib CAEngine.lib
       
    45 *  @since 2.1
       
    46 */
       
    47 class CCAStorageObserver :	public CBase,
       
    48             public MCAStoredContactsObserver
       
    49     {
       
    50     public:  // Constructors and destructor
       
    51 
       
    52         /**
       
    53         * Two-phased constructor.
       
    54         * @param aApplicationSettings Settings manager interface
       
    55         * @param aContactStorage Contact storage interface
       
    56         * @param aPresenceHandler Presence manager interface
       
    57         * @param aBlockingManager Blocking manager interface
       
    58         * @param aIncomingMessages Incoming messages interface
       
    59         */
       
    60         static CCAStorageObserver* NewL(
       
    61             MCASettings& aApplicationSettings,
       
    62             MCAStoredContacts& aContactStorage,
       
    63             MCAPresence& aPresenceHandler,
       
    64             MCABlocking& aBlockingManager );
       
    65 
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69         virtual ~CCAStorageObserver();
       
    70 
       
    71     private: // From MCAStoredContactsObserver
       
    72 
       
    73         /**
       
    74          * Called when a contact is deleted.
       
    75          * @since 2.1
       
    76          * @param aId The ID of the deleted contact
       
    77          * @param aFromPEC, ETrue, if event is coming from PEC
       
    78          */
       
    79         void HandleContactDelete( const TDesC& aId );
       
    80 
       
    81         /**
       
    82          * Called when a contact is added.
       
    83          * @since 2.1
       
    84          * @param aId The ID of the added contact
       
    85          * @param aFromPEC, ETrue, if event is coming from PEC
       
    86          */
       
    87         void HandleAddition( MCAContactList& aList, MCAStoredContact& aContact );
       
    88 
       
    89         /**
       
    90          * Called when a contact is changed.
       
    91          * @since 2.1
       
    92          */
       
    93         void HandleChange( MCAContactList* aList, MCAStoredContact* aId,
       
    94                            TStorageManagerGlobals::TCAObserverEventType aEventType,
       
    95                            TBool aUserIdChanged );
       
    96 
       
    97         /**
       
    98          * Called when backup/restore starts/stops.
       
    99          * There is no distinction between backup/restore (Symbian limitation).
       
   100          * However, the called party should fetch new list(s) as they
       
   101          * may have changed if the operation was restore operation.
       
   102          * @param aEventType The type of backup/restore event
       
   103          * @since 2.1
       
   104          */
       
   105         void HandleBackupRestoreEvent( const TStorageManagerGlobals::
       
   106                                        TCAObserverEventType aEventType );
       
   107 
       
   108     private:
       
   109 
       
   110         /**
       
   111         * By default Symbian OS constructor is private.
       
   112         */
       
   113         void ConstructL();
       
   114 
       
   115         /**
       
   116         * C++ default constructor.
       
   117         * @see CCAStorageObserver::NewL for parameters
       
   118         */
       
   119         CCAStorageObserver( MCASettings& aApplicationSettings,
       
   120                             MCAStoredContacts& aContactStorage,
       
   121                             MCAPresence& aPresenceHandler,
       
   122                             MCABlocking& aBlockingManager );
       
   123 
       
   124         /**
       
   125          * Handles deletion of contact
       
   126          * @param aUserId User id
       
   127          */
       
   128         void IMHandleDelete( const TDesC& aUserId );
       
   129 
       
   130         /**
       
   131          * Handles addition of contact
       
   132          * @param aContact contact data
       
   133          */
       
   134         void IMHandleAddition( MCAStoredContact& aContact );
       
   135 
       
   136         /**
       
   137          * Calls blocking manager's delete contact
       
   138          * @param aUserId User id
       
   139          */
       
   140         void DoBlockingManagerDeleteL( const TDesC& aUserId );
       
   141 
       
   142         /**
       
   143          * Calls blocking manager's add contact
       
   144          * @param aUserId User Id
       
   145          */
       
   146         void DoBlockingManagerAdditionL( const TDesC& aUserId );
       
   147 
       
   148         /**
       
   149          * Checks contact's blocking status and pending messages
       
   150          * @param aContact contact data
       
   151          */
       
   152         void DoUpdateContactStatus( MCAStoredContact& aContact );
       
   153         /**
       
   154          * Handles the possible errors
       
   155          * @param aError error code
       
   156          */
       
   157         void HandleError( TInt aError );
       
   158 
       
   159     private:    // Data
       
   160         // Doesn't own.
       
   161         MCASettings& iApplicationSettings;
       
   162         // Doesn't own.
       
   163         MCAStoredContacts& iContactStorage;
       
   164         // Doesn't own.
       
   165         MCAPresence& iPresenceHandler;
       
   166         // Doesn't own.
       
   167         MCABlocking& iBlockingManager;
       
   168 
       
   169         // Owns
       
   170         HBufC* iLastUserId;
       
   171     };
       
   172 
       
   173 #endif      // CCASTORAGEOBSERVER_H
       
   174 
       
   175 // End of File