ximpfw/presence/srcpresencedatamodel/presencecache/presencebuddyinfolistimp.h
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2007, 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:  MPresenceBuddyInfoList implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CXIMPPRESENCEBUDDYINFOLISTIMP_H
       
    19 #define CXIMPPRESENCEBUDDYINFOLISTIMP_H
       
    20 
       
    21 #include <s32buf.h>
       
    22 #include <presencebuddyinfolist.h>
       
    23 
       
    24 #include "presenceapiobjbase.h"
       
    25 #include "presencetypehelpers.h"
       
    26 #include "ximpapidataobjbase.h"
       
    27 
       
    28 class MXIMPIdentity;
       
    29 class MPresenceBuddyInfo;
       
    30 
       
    31 /**
       
    32  * MPresenceBuddyInfoList API object implementation. By default the this
       
    33  * list owns the MPresenceBuddyInfo objects.
       
    34  * If the pointer array doesn't needed to own the objects, simply call
       
    35  * SetOwnObjects(EFalse) method before delete. 
       
    36  *
       
    37  * @lib ximpdatamodel.dll
       
    38  * @since S60 v3.2
       
    39  */
       
    40 NONSHARABLE_CLASS( CPresenceBuddyInfoListImp ): public CXIMPApiDataObjBase,
       
    41                                                 public MPresenceBuddyInfoList                                                
       
    42     {
       
    43     public:
       
    44     /** The class ID. */
       
    45     enum { KClassId = PRIMP_CLSID_CXIMPPRESENCEBUDDYINFOLIST };
       
    46 
       
    47 
       
    48 public:
       
    49     
       
    50     //if aServiceName is KNullDesC then multiple services buddies are allowed
       
    51     IMPORT_C static CPresenceBuddyInfoListImp* NewLC(const TDesC& aServiceName);
       
    52     IMPORT_C static CPresenceBuddyInfoListImp* NewL(const TDesC& aServiceName);
       
    53     virtual ~CPresenceBuddyInfoListImp();
       
    54 
       
    55 private:
       
    56 
       
    57     CPresenceBuddyInfoListImp();
       
    58     void ConstructL(const TDesC& aServiceName);
       
    59     void ConstructL(); // to use with internalize
       
    60 
       
    61 public: // From MXIMPBase
       
    62 
       
    63     /**
       
    64      * Implementation of MXIMPBase interface methods
       
    65      * @see MXIMPBase
       
    66      */
       
    67     XIMPIMP_DECLARE_IF_BASE_METHODS
       
    68 
       
    69 public: // From CXIMPApiDataObjBase
       
    70 
       
    71     /**
       
    72      * @see CXIMPApiDataObjBase
       
    73      */
       
    74     XIMPIMP_DECLARE_DATAOBJ_BASE_METHODS
       
    75 
       
    76 public: // From MPresenceBuddyInfoList
       
    77 
       
    78     RPointerArray<MPresenceBuddyInfo>& GetObjectCollection();
       
    79     
       
    80     TPtrC ServiceName() const;
       
    81     
       
    82     TInt Count() const;
       
    83     
       
    84     TInt AddOrReplace(MPresenceBuddyInfo* aPresenceBuddyInfo);
       
    85     
       
    86     TInt FindAndRemove(const MXIMPIdentity& aIdentity);
       
    87     
       
    88     MPresenceBuddyInfo* FindAndGet(const MXIMPIdentity& aIdentity) const;
       
    89     
       
    90 public: // New functions
       
    91 
       
    92     /**
       
    93      * Internalizes object data from given stream. Must call 
       
    94      * SetCountForInternalize before calling this function.
       
    95      * @param aStream Stream to read.
       
    96      */
       
    97     IMPORT_C void InternalizeL( RReadStream& aStream );
       
    98     
       
    99     /**
       
   100      * Add buddy presence info object in this collection. Without any
       
   101      * check for duplicates. Takes ownership.
       
   102      * @param aPresenceBuddyInfo object to add.
       
   103      */
       
   104     IMPORT_C TInt BlindAddL(MPresenceBuddyInfo* aPresenceBuddyInfo);
       
   105     
       
   106     /**
       
   107      * Set to own/disown objects. Call this function with EFalse to
       
   108      * set this list not to own objects.
       
   109      */
       
   110     IMPORT_C void SetOwnObjects(TBool aOwnObjects);
       
   111     
       
   112 private:
       
   113 
       
   114     /**
       
   115      * Extract service name from XspId
       
   116      * @param aXspId XspId URI
       
   117      * @return service name
       
   118      */
       
   119     TPtrC ExtractService( const TDesC& aXspId );    
       
   120 
       
   121 private: // data
       
   122 
       
   123 
       
   124     /**
       
   125      * OWN if iOwnDataObjects is true.
       
   126      */
       
   127     RPointerArray< MPresenceBuddyInfo> iBuddyCollection;
       
   128 
       
   129     /**
       
   130      * OWN: 
       
   131      */
       
   132     RBuf16 iService;
       
   133     
       
   134     /**
       
   135     *OWN
       
   136     */
       
   137     TBool iOwnDataObjects;
       
   138     
       
   139     };
       
   140 
       
   141 
       
   142 #endif // CXIMPPRESENCEBUDDYINFOLISTIMP_H