ximpfw/presence/srcpresencecache/presencecacheserver/presencecachebuddystore.h
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     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:  Store object for single buddy in a service
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CXIMPPRESENCECACHEBUDDYSTORE_H
       
    19 #define CXIMPPRESENCECACHEBUDDYSTORE_H
       
    20 
       
    21 
       
    22 #include "presenceapiobjbase.h"
       
    23 #include "ximpapiobjbase.h"
       
    24 
       
    25 class MPresenceBuddyInfo;
       
    26 class CXIMPIdentityImp;
       
    27 class CPresenceCacheSession;
       
    28 class MXIMPIdentity;
       
    29 class CPresenceCacheServiceStore;
       
    30 
       
    31 /**
       
    32  * CPresenceCacheBuddyStore. Used in Presence cache for presence storage. The 
       
    33  * identity part is always exists in this class, subscribers and presence info
       
    34  * are not guaranteed. However, if this object doesn't contain any subscribers 
       
    35  * or presence info, it doesnt serve its purpose and should be deleted.
       
    36  *
       
    37  * @lib presencecacheserver.exe
       
    38  * @since S60 v3.2
       
    39  */
       
    40 class CPresenceCacheBuddyStore: public CBase
       
    41     {
       
    42 
       
    43 public:
       
    44 
       
    45     /**
       
    46      * Symbian constructors and c++ destructor
       
    47      *
       
    48      * @param aServiceStore a parent store for this object
       
    49      * @param aIdentity identity for this object, must be in xsp format
       
    50      */
       
    51     IMPORT_C static CPresenceCacheBuddyStore* NewLC(
       
    52                                     CPresenceCacheServiceStore* aServiceStore,
       
    53                                     MXIMPIdentity* aIdentity);
       
    54     IMPORT_C static CPresenceCacheBuddyStore* NewL(
       
    55                                     CPresenceCacheServiceStore* aServiceStore,
       
    56                                     MXIMPIdentity* aIdentity);
       
    57     virtual ~CPresenceCacheBuddyStore();
       
    58 
       
    59 private:
       
    60 
       
    61     /**
       
    62      * c++ constructor
       
    63      *
       
    64      * @param aServiceStore Parent service store for this object
       
    65      */
       
    66     CPresenceCacheBuddyStore(CPresenceCacheServiceStore* aServiceStore);
       
    67     
       
    68     /**
       
    69      * Symbian second phase constructor
       
    70      * @param aIdentity, uses this identity if not NULL, otherwise creates new
       
    71      */
       
    72     void ConstructL(MXIMPIdentity* aIdentity);
       
    73 
       
    74 
       
    75 public: 
       
    76 
       
    77     /**
       
    78     * Service name of this object, taken from xsp prefix of the indentity
       
    79     *
       
    80     * @return TPtrC service name of this object
       
    81     */
       
    82     TPtrC ServiceName() const;
       
    83     
       
    84     /**
       
    85     * Sets the presnece info to this object. Takes ownership. It deletes
       
    86     * any old presence info. Calling this function multiple times with
       
    87     * different presence infos doesnt harm.
       
    88     *
       
    89     * @param aPresBuddyInfo buddy presence info to be set to this object
       
    90     */
       
    91     void SetPresenceBuddyInfo(MPresenceBuddyInfo* aPresBuddyInfo);
       
    92     
       
    93     /**
       
    94     * Removes presence info from this object and set it to NULL.
       
    95     */
       
    96     void RemovePresenceBuddyInfo();
       
    97     
       
    98     /**
       
    99     * Get the subscribed sessions pointer array. The array contains all those
       
   100     * sessions which are currently subscribed to receive changes in this object.
       
   101     *
       
   102     * @return reference to RPointerArray<CPresenceCacheSession>
       
   103     */
       
   104     RPointerArray<CPresenceCacheSession>& GetSubscribedSessions();
       
   105     
       
   106     /**
       
   107     * Add session to the list of subscribed sessions. It does not take ownership.
       
   108     * ignores if session is already there.
       
   109     *
       
   110     * @param aSession to add in subscribed list
       
   111     */
       
   112     void AddSubscribedSession(CPresenceCacheSession* aSession);
       
   113     
       
   114     /**
       
   115     * Remove session to the list of subscribed sessions. It does not take ownership.
       
   116     * ignores if session is not found.
       
   117     *
       
   118     * @param aSession to remove from subscribed list
       
   119     */
       
   120     void RemoveSubscribedSession(CPresenceCacheSession* aSession);
       
   121 
       
   122     /**
       
   123     * Sets the identity to this object. Takes ownership. It deletes
       
   124     * any old identity if present. Identity must be in xsp format.
       
   125     *
       
   126     * @param aIdentity identity to be set to this object
       
   127     */
       
   128     void SetBuddyId(MXIMPIdentity* aIdentity);
       
   129                                 
       
   130     /**
       
   131     * Gets presence info from this object.
       
   132     *
       
   133     * @return pointer to MPresenceBuddyInfo
       
   134     */
       
   135     MPresenceBuddyInfo* PresenceBuddyInfo() const;
       
   136     
       
   137     /**
       
   138     * Gets identity from this object.
       
   139     *
       
   140     * @return constant pointer to MXIMPIdentity
       
   141     */
       
   142     const MXIMPIdentity* BuddyId() const;
       
   143     
       
   144     /**
       
   145     * Matches this object's identity with that of given object. Return True if
       
   146     * matches.
       
   147     *
       
   148     * @param aOtherInstance other CPresenceCacheBuddyStore
       
   149     * @return ETrue if identity matches.
       
   150     */
       
   151     TBool EqualsIdentity(
       
   152                     const CPresenceCacheBuddyStore* aOtherInstance ) const;
       
   153                     
       
   154     /**
       
   155     * Matches this object's identity with that of given object. Return True if
       
   156     * matches.
       
   157     *
       
   158     * @param aOtherInstance MPresenceBuddyInfo object
       
   159     * @return ETrue if identity matches.
       
   160     */
       
   161     TBool EqualsIdentity(
       
   162                         const MPresenceBuddyInfo* aOtherInstance ) const;
       
   163                     
       
   164     /**
       
   165     * Matches this object's identity with that of given identity. Return True if
       
   166     * matches.
       
   167     *
       
   168     * @param aOtherIdentity other identity object
       
   169     * @return ETrue if identity matches.
       
   170     */
       
   171     TBool EqualsIdentity(
       
   172                             const MXIMPIdentity& aOtherIdentity ) const;
       
   173                     
       
   174     /**
       
   175     * Finds whether this object has any presence info.
       
   176     *
       
   177     * @return ETrue if this object contains any presence info.
       
   178     */
       
   179     TBool HasPresence() const;
       
   180     
       
   181     /**
       
   182     * Finds whether this object has any subscribers.
       
   183     *
       
   184     * @return ETrue if this object has any subscriber(s).
       
   185     */
       
   186     TBool HasSubscribers() const;          
       
   187 
       
   188 private: // data
       
   189 
       
   190      /**
       
   191      * OWN: Contains presence info or NULL
       
   192      */
       
   193     MPresenceBuddyInfo* iPresenceBuddyInfo;
       
   194 
       
   195     /**
       
   196      * OWN: Contains identity
       
   197      */
       
   198     CXIMPIdentityImp* iIdentity;
       
   199 
       
   200     /**
       
   201     *OWN: Sessions which  are subscribed to receive change in this buddy's presence
       
   202     */
       
   203     RPointerArray<CPresenceCacheSession> iSubscribedSessions;
       
   204     
       
   205     /**
       
   206     *Not Owned: Pointer to this object's service store
       
   207     */
       
   208     CPresenceCacheServiceStore* iServiceStore;
       
   209     
       
   210     };
       
   211 
       
   212 
       
   213 #endif // CXIMPPRESENCECACHEBUDDYSTORE_H