metadataengine/client/inc/mdenotifierao.h
changeset 0 c53acadfccc6
child 3 b73a2e62868f
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:  Notifier client side active object
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __MDENOTIFIERAOAO_H__
       
    20 #define __MDENOTIFIERAOAO_H__
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "mdccommon.h"
       
    26 #include "mdecondition.h"
       
    27 
       
    28 
       
    29 // forward declarations
       
    30 class RMdEEngineSession;
       
    31 class CMdESessionImpl;
       
    32 class CMdENamespaceDef;
       
    33 class CMdERelation;
       
    34 class TMdERelation;
       
    35 
       
    36 // local constants
       
    37 const TInt KDefaultBufferSize = 1024; // 1 KB
       
    38 /**
       
    39 * CMdENotifierAO
       
    40 * An active object that receives notifications from server
       
    41 * side whenever a registrated event has occurred.
       
    42 */
       
    43 NONSHARABLE_CLASS(CMdENotifierAO) : public CActive
       
    44     {
       
    45     public: // Constructors and destructors
       
    46 
       
    47 		/**
       
    48 		 * Two-phased constructor.
       
    49 		 * @param aSessionImpl session impl
       
    50 		 * @param aSession the server handler
       
    51 		 * @return the created instance
       
    52 		 */
       
    53 		 static CMdENotifierAO* NewL(
       
    54 		     CMdESessionImpl& aSessionImpl, RMdEEngineSession& aSession );
       
    55 
       
    56         /**
       
    57         * Two-phased constructor.
       
    58         * @param aSessionImpl session impl
       
    59         * @param aSession the server handler
       
    60         * @return the created instance
       
    61         */
       
    62         static CMdENotifierAO* NewLC(
       
    63             CMdESessionImpl& aSessionImpl, RMdEEngineSession& aSession );
       
    64 
       
    65         /**
       
    66         * Destructor.
       
    67         */
       
    68         virtual ~CMdENotifierAO();
       
    69 
       
    70         /**
       
    71         * register for receiving events
       
    72         * @param aMode observer mode: object, event or relation
       
    73         * @param aObserver observer to be notified when event occurs
       
    74         * @param aCondition condition when to notify
       
    75         */
       
    76         void RegisterL( TUint32 aType, TAny* aObserver, CMdECondition* aCondition, CMdENamespaceDef& aNamespaceDef );
       
    77 
       
    78         /**
       
    79         * compares an observer against one stored in this AO
       
    80         * @param aMode observer mode: object, event or relation
       
    81         * @param aObserver observer pointer
       
    82         */
       
    83         TBool Match( TUint32 aType, TAny* aObserver, CMdENamespaceDef& aNamespaceDef );
       
    84 
       
    85         /**
       
    86         * ID of this client side notifier object
       
    87         */
       
    88         TInt Id();
       
    89 
       
    90     protected: // Functions from base classes
       
    91 
       
    92         /**
       
    93         * From CActive
       
    94         * Callback function.
       
    95         * Invoked to handle responses from the server.
       
    96         */
       
    97         void RunL();
       
    98 
       
    99         /**
       
   100         * From CActive
       
   101         * Handles errors that occur during notifying the observer.
       
   102         */
       
   103         TInt RunError(TInt aError);
       
   104 
       
   105         /**
       
   106         * From CActive
       
   107         * Cancels any outstanding operation.
       
   108         */
       
   109         void DoCancel();
       
   110 
       
   111     private: // Constructors and destructors
       
   112 
       
   113         /**
       
   114         * constructor
       
   115         * @param aSessionImpl session impl
       
   116         * @param aSession the server handler
       
   117         */
       
   118         CMdENotifierAO(
       
   119             CMdESessionImpl& aSessionImpl, RMdEEngineSession& aSession );
       
   120 
       
   121         /**
       
   122         * 2nd phase constructor
       
   123         */
       
   124         void ConstructL();
       
   125 
       
   126         /**
       
   127         * notify the corresponding client observer pointer
       
   128         * @param aItem the item (in coded form) to be notified
       
   129         * @param aStatus what has actually happened with the item
       
   130         */
       
   131         void DoNotifyObserver();
       
   132 		
       
   133 		
       
   134 		void DecodeIdBufferL();
       
   135 		void DecodeRelationItemBufferL();
       
   136 
       
   137     private: // Data
       
   138 
       
   139         /** the session impl. */
       
   140         CMdESessionImpl& iSessionImpl;
       
   141 
       
   142         /** the session */
       
   143         RMdEEngineSession& iSession;
       
   144 
       
   145         /** observer to be notified, actual class depends on type */
       
   146         TAny* iObserver;
       
   147 
       
   148         /** notifier type */
       
   149         TUint32 iType;
       
   150 
       
   151 		/** Namespace definition's ID */
       
   152         TDefId iNamespaceDefId;
       
   153 
       
   154         /** size of result block */
       
   155         TPckgBuf<TInt> iResultSize;
       
   156 
       
   157         CMdCSerializationBuffer* iDataBuffer;
       
   158 
       
   159 		RArray<TItemId> iIdArray;
       
   160 
       
   161 		RArray<TMdERelation> iRelationItemArray;
       
   162     };
       
   163 
       
   164 #endif //__MDENOTIFIERAOAO_H__