commsfwtools/preparedefaultcommsdatabase/src/CommsDatNotifier.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-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 // Notification handling for client requests for notificaiton on database changes
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23  
       
    24 #if (!defined COMMSDATNOTIFIER_H)
       
    25 #define       COMMSDATNOTIFIER_H 
       
    26 
       
    27 #include <e32property.h>
       
    28 
       
    29 namespace CommsDatInternal
       
    30 {
       
    31 
       
    32 using namespace CommsDat;
       
    33 
       
    34 NONSHARABLE_CLASS(TCommsDatPubSubNotification)
       
    35 //@internalComponent
       
    36 //@released
       
    37 	{
       
    38 public:
       
    39 	TCommsDatPubSubNotification();
       
    40 	void Set(TUid aUid, TInt aVal);
       
    41 public:
       
    42 	TUid iUid;
       
    43 	TInt iValue;
       
    44 	};
       
    45 
       
    46 _LIT(KCommsdatNotifierExecutable,"ShimNotifierSvr");
       
    47 /** Commsdat Notifier 
       
    48 * 
       
    49 * @internalComponent */
       
    50 class RCommsdatNotifier : public RSessionBase   
       
    51 	{
       
    52 public:
       
    53 	RCommsdatNotifier();
       
    54 	TVersion Version() const;
       
    55 	
       
    56 	TInt Connect();
       
    57 	void RequestNotification(TRequestStatus& aStatus);
       
    58 	void CancelNotification(TRequestStatus& aStatus);
       
    59 	void CancelAllNotifications();
       
    60 	void Close();
       
    61 private:	
       
    62 	TInt StartNotifierProcess();   	
       
    63 	};
       
    64 
       
    65 	
       
    66 NONSHARABLE_CLASS(CCDNotifier) : public CBase
       
    67 /*
       
    68 This class records notification requests from clients and completes them when
       
    69 own TRequestStatus is completed by storage server.
       
    70 
       
    71 CommsDat doesn't need to act on the info itself. 
       
    72 It is just acting as a broker for the client to completely hide the db server. 
       
    73 
       
    74 FUTURE - At the moment CommsDat makes a simple general request for notification on the whole repository.
       
    75 Because this is all that Commdb does.  It would be good to change this to register for individual areas of change.
       
    76 
       
    77 This class also publishes notification of changes made to the database by this client process
       
    78 where pub/sub notification is required
       
    79 */
       
    80 {
       
    81 public :
       
    82 
       
    83     CCDNotifier(CMDBSessionImpl& aOwner);
       
    84     
       
    85     ~CCDNotifier();
       
    86    
       
    87     static CCDNotifier* NewL(CMDBSessionImpl& aOwner);
       
    88 
       
    89     void ConstructL();
       
    90     
       
    91     // Functions to inform clients of commsdat events.
       
    92 
       
    93     TInt RegisterNotifyL(TRequestStatus& aStatus);
       
    94     
       
    95     TInt CancelNotify(TRequestStatus& aStatus);
       
    96 
       
    97     TInt CancelAllNotifications();
       
    98 
       
    99     TInt NotifyClients(TInt aEventType);
       
   100     
       
   101     void SuppressRollBackEvents()   
       
   102         {
       
   103         iSuppressRollBackEvents = ETrue;
       
   104         }
       
   105     
       
   106     // Functions for publish and subscribe notification
       
   107 
       
   108    	void MaybeNotifyChange(TMDBElementId aElementId);        
       
   109 	void MaybeNotifyChangeForDelete(TMDBElementId aElementId, TBool aModemBearerDeleted);
       
   110 	
       
   111     void NotifyAllChanges();
       
   112 
       
   113     void ClearPubSubNotifications();
       
   114     
       
   115     TUint32 GetNewNumber(TUid aUid);
       
   116 
       
   117   	void ConvertToUid(TMDBElementId aId, TCommsDatPubSubNotification& aNotification);
       
   118 
       
   119 private :
       
   120 
       
   121     TBool                                   iSuppressRollBackEvents;
       
   122     RArray<TCommsDatPubSubNotification>     iNotifications;
       
   123     
       
   124     RCommsdatNotifier iNotifier;
       
   125 
       
   126     CMDBSessionImpl& iOwner;
       
   127 };
       
   128 
       
   129 //
       
   130 
       
   131 } // namespace CommsDatInternal
       
   132 
       
   133 #endif //COMMSDATNOTIFIER_H