presencecache/presencecachesymbian/presencecacheclient2/inc/presencecacheclientnotification.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implementation for presence cache reader notification handling
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef PRESENCECACHECLIENTNOTIFICATION_H
       
    19 #define PRESENCECACHECLIENTNOTIFICATION_H
       
    20 
       
    21 #include "presencecacheclient.h"
       
    22 
       
    23 // #include "presencecachedefs2.h"
       
    24 
       
    25 
       
    26 /**
       
    27  * Implementation for presence cache reader notification. This object is 
       
    28  * instantiated by CPresenceCacheClient. This class handles client-server
       
    29  * messaging for notifications.
       
    30  *
       
    31  * @since S60 v5.0
       
    32  */
       
    33  NONSHARABLE_CLASS( CPresenceCacheClientNotification ) : public CActive
       
    34     {
       
    35 
       
    36 public:
       
    37 
       
    38         /**
       
    39         * Two-phased constructor.
       
    40         * @param aClient presence cache client
       
    41         */
       
    42         static CPresenceCacheClientNotification* NewL( CPresenceCacheClient& aClient );
       
    43         
       
    44         /**
       
    45         * Destructor.
       
    46         */
       
    47         virtual ~CPresenceCacheClientNotification();
       
    48         
       
    49         /**
       
    50          * Subscribe for given presence buddy's change in presence. 
       
    51          *
       
    52          * @param aIdentity buddy id, in xsp format
       
    53          * @return KErrNone if successful, KErrArgument if observer not set
       
    54          * @leave Only in system error cases e.g. if failed to allocate memory.
       
    55          */
       
    56         TInt SubscribePresenceBuddyChangeL(const TDesC& aIdentity);   
       
    57         
       
    58         /**
       
    59          * Unsubscribe for given presence buddy's change in presence. 
       
    60          *
       
    61          * @param aIdentity buddy id, in xsp format
       
    62          * @leave Only in system error cases e.g. if failed to allocate memory.
       
    63          */
       
    64         void UnsubscribePresenceBuddyChangeL(const TDesC& aIdentity);          
       
    65         
       
    66 private:
       
    67 
       
    68     /**
       
    69     * C++ constructor
       
    70     */
       
    71     CPresenceCacheClientNotification( CPresenceCacheClient& aClient );
       
    72     
       
    73     /**
       
    74     * Symbian second phase constructor
       
    75     */
       
    76     void ConstructL();
       
    77     
       
    78     void StartNotifySubscription();
       
    79     
       
    80     /**
       
    81      * Client callback handler Accesor 
       
    82      */
       
    83     MPresenceCacheReadHandler2* ClientNotifyHandler(); 
       
    84     
       
    85     /**
       
    86      * Get presence from Cache server to a client observer
       
    87      * @param aClient client callback observer
       
    88      * @param aSize notification size
       
    89      */
       
    90     void PreseneceFromServerToClientL( MPresenceCacheReadHandler2& aClient, TInt aSize );
       
    91        
       
    92                                        
       
    93 public:  //From CActive
       
    94 
       
    95     void RunL();
       
    96 
       
    97     void DoCancel();
       
    98     
       
    99     TInt RunError( TInt aError );
       
   100     
       
   101 private: // Data
       
   102     
       
   103         /**
       
   104          * presence cache client handling client-server messages
       
   105          */
       
   106         CPresenceCacheClient& iClient;
       
   107                 
       
   108         /**
       
   109          * Size of presence notification for client-sever messages
       
   110          */
       
   111         TPckgBuf<TInt> iSizePckg;  
       
   112         
       
   113         /**
       
   114          * Whether the first notification subscription is done
       
   115          */
       
   116         TBool iNotificationSubscribed;
       
   117         
       
   118     };
       
   119 
       
   120 #endif // PRESENCECACHECLIENTNOTIFICATION_H
       
   121 
       
   122 
       
   123