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