ximpfw/presence/srcpresencecache/presencecacheclient/presencecacheclientnotification.h
changeset 0 e6b17d312c8b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ximpfw/presence/srcpresencecache/presencecacheclient/presencecacheclientnotification.h	Thu Dec 17 08:54:49 2009 +0200
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation for presence cache reader notification handling
+*
+*/
+
+#ifndef PRESENCECACHECLIENTNOTIFICATION_H
+#define PRESENCECACHECLIENTNOTIFICATION_H
+
+#include "presencecacheclient.h"
+
+#include "presencecachedefs.h"
+#include "presenceapiobjbase.h"
+
+
+/**
+ * Implementation for presence cache reader notification. This object is 
+ * instantiated by CPresenceCacheClient. This class handles client-server
+ * messaging for notifications.
+ *
+ * @ingroup ximpprescacheapi
+ * @since S60 v5.0
+ */
+ NONSHARABLE_CLASS( CPresenceCacheClientNotification ) : public CActive
+    {
+
+public:
+
+        /**
+        * Two-phased constructor.
+        * @param aClient presence cache client
+        */
+        static CPresenceCacheClientNotification* NewL( CPresenceCacheClient& aClient );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CPresenceCacheClientNotification();
+        
+        /**
+         * Subscribe for given presence buddy's change in presence. 
+         *
+         * @param aIdentity buddy id, in xsp format
+         * @return KErrNone if successful, KErrArgument if observer not set
+         * @leave Only in system error cases e.g. if failed to allocate memory.
+         */
+        TInt SubscribePresenceBuddyChangeL(const MXIMPIdentity& aIdentity);   
+        
+        /**
+         * Unsubscribe for given presence buddy's change in presence. 
+         *
+         * @param aIdentity buddy id, in xsp format
+         * @leave Only in system error cases e.g. if failed to allocate memory.
+         */
+        void UnsubscribePresenceBuddyChangeL(const MXIMPIdentity& aIdentity);          
+        
+private:
+
+    /**
+    * C++ constructor
+    */
+    CPresenceCacheClientNotification( CPresenceCacheClient& aClient );
+    
+    /**
+    * Symbian second phase constructor
+    */
+    void ConstructL();
+    
+    void StartNotifySubscription();
+    
+    /**
+     * Client callback handler Accesor 
+     */
+    MPresCacheReadHandler* ClientNotifyHandler(); 
+    
+    /**
+     * Get presence from Cache server to a client observer
+     * @param aClient client callback observer
+     * @param aSize notification size
+     */
+    void PreseneceFromServerToClientL( MPresCacheReadHandler& aClient, TInt aSize );
+       
+                                       
+public:  //From CActive
+
+    void RunL();
+
+    void DoCancel();
+    
+    TInt RunError( TInt aError );
+    
+private: // Data
+    
+        /**
+         * presence cache client handling client-server messages
+         */
+        CPresenceCacheClient& iClient;
+                
+        /**
+         * Size of presence notification for client-sever messages
+         */
+        TPckgBuf<TInt> iSizePckg;  
+        
+        /**
+         * Whether the first notification subscription is done
+         */
+        TBool iNotificationSubscribed;
+        
+    };
+
+#endif // PRESENCECACHECLIENTNOTIFICATION_H
+
+
+