PECengine/ListLibrary2/ContactListSrc/CPEngContactListModItemContainer.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Container of the one contact list item.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGCONTACTLISTMODITEMCONTAINER_H__
       
    19 #define __CPENGCONTACTLISTMODITEMCONTAINER_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "MPEngContactItemAdvance.h"
       
    24 
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class   RWriteStream;
       
    28 class   RWriteStream;
       
    29 class   MPEngContactListModStore;
       
    30 class   CPEngContactListProperty;
       
    31 
       
    32 
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37  * Container of the one contact list item.
       
    38  * Implements management of one contact list item,
       
    39  * like update of the nick name and storing of the
       
    40  * cached and permanent data properties of the contact item.
       
    41  *
       
    42  * @lib PEngListLib2
       
    43  * @since 3.0
       
    44  */
       
    45 NONSHARABLE_CLASS( CPEngContactListModItemContainer ) :
       
    46         public CBase,
       
    47         public MPEngContactItemAdvance
       
    48     {
       
    49 public:  // Enumerations
       
    50 
       
    51     /**
       
    52      * Reference access flags.
       
    53      */
       
    54     enum TAccessFlags
       
    55         {
       
    56         ELocalRef     = 0x00001,
       
    57         ENetworkRef   = 0x00010
       
    58         };
       
    59 
       
    60 
       
    61 public:  // Constructors and destructor
       
    62 
       
    63     /**
       
    64      * Two-phased constructor, constructs class with
       
    65      * passed contact id and nickname
       
    66      */
       
    67     static CPEngContactListModItemContainer* NewLC(
       
    68         MPEngContactListModStore& aStoreEntry,
       
    69         const TDesC& aContactId,
       
    70         const TDesC* aNickName );
       
    71 
       
    72     /**
       
    73      * Two-phased constructor, constructs class with passed contact id,
       
    74      * nickname is set as need to be updated
       
    75      */
       
    76     static CPEngContactListModItemContainer* NewNewNickLC(
       
    77         MPEngContactListModStore& aStoreEntry,
       
    78         const TDesC& aContactId,
       
    79         const TDesC& aNewNickName );
       
    80 
       
    81     /**
       
    82      * Two-phased constructor, constructs class from the Stream
       
    83      */
       
    84     static CPEngContactListModItemContainer* NewLC(
       
    85         MPEngContactListModStore& aStoreEntry,
       
    86         RReadStream& aStream );
       
    87 
       
    88     /**
       
    89      * Destructor.
       
    90      */
       
    91     virtual ~CPEngContactListModItemContainer();
       
    92 
       
    93 
       
    94 
       
    95 private: // Constructors
       
    96 
       
    97     /**
       
    98      * C++ constructor.
       
    99      */
       
   100     CPEngContactListModItemContainer( MPEngContactListModStore& aStoreEntry );
       
   101 
       
   102     /**
       
   103      * Constructs container with WV ID and Nickname
       
   104      */
       
   105     void ConstructL( const TDesC& aContactId,
       
   106                      const TDesC* aNickName );
       
   107 
       
   108     /**
       
   109      * Construct container with WV ID,
       
   110      * Nickname set as need to be updated
       
   111      */
       
   112     void ConstructNewNickL( const TDesC& aContactId,
       
   113                             const TDesC& aNewNickName );
       
   114 
       
   115 
       
   116 
       
   117 
       
   118 public: // Functions from  MPEngContactItem
       
   119 
       
   120     /**
       
   121      * Contact Id of the contact Item
       
   122      * @see <MPEngContactItem.h>
       
   123      */
       
   124     const TDesC& Id() const;
       
   125 
       
   126 
       
   127     /**
       
   128      * Nick name of the contact Item
       
   129      * @see <MPEngContactItem.h>
       
   130      */
       
   131     const TDesC& NickName() const;
       
   132 
       
   133 
       
   134     /**
       
   135      * Update nick name of the contact item
       
   136      * @see <MPEngContactItem.h>
       
   137      */
       
   138     void UpdateNickNameL( const TDesC& aNickName );
       
   139 
       
   140 
       
   141     /**
       
   142      * Gets a property.
       
   143      * @see <MPEngContactItem.h>
       
   144      */
       
   145     TInt GetProperty( TUint aName,
       
   146                       TUint aLevel,
       
   147                       TInt& aValue ) const;
       
   148 
       
   149     TInt GetProperty( TUint aName,
       
   150                       TUint aLevel,
       
   151                       TPtrC8& aValue ) const;
       
   152 
       
   153     TInt GetProperty( TUint aName,
       
   154                       TUint aLevel,
       
   155                       TPtrC16& aValue ) const;
       
   156 
       
   157     /**
       
   158      * Gets a property.
       
   159      * @see <MPEngContactItem.h>
       
   160      */
       
   161     TInt Property( TUint aName,
       
   162                    TUint aLevel ) const;
       
   163 
       
   164 
       
   165     /**
       
   166      * Sets a property.
       
   167      * @see <MPEngContactItem.h>
       
   168      */
       
   169     void SetPropertyL( TUint aName,
       
   170                        TUint aLevel,
       
   171                        TInt aValue );
       
   172 
       
   173     void SetPropertyL( TUint aName,
       
   174                        TUint aLevel,
       
   175                        const TDesC8& aValue );
       
   176 
       
   177     void SetPropertyL( TUint aName,
       
   178                        TUint aLevel,
       
   179                        const TDesC16& aValue );
       
   180 
       
   181 
       
   182     /**
       
   183      * Delete a property
       
   184      * @see <MPEngContactItem.h>
       
   185      */
       
   186     void DeletePropertyL( TUint aName, TUint aLevel );
       
   187     TInt GetPermanentValue( const TDesC& aKey, TPtrC8& aValue ) const;
       
   188     TInt GetCachedValue( const TDesC& aKey, TPtrC8& aValue ) const;
       
   189     void SetPermanentValueL( const TDesC& aKey, const TDesC8& aValue );
       
   190     void SetCachedValueL( const TDesC& aKey, const TDesC8& aValue );
       
   191     void DeletePermanentValueL( const TDesC& aKey );
       
   192     void DeleteCachedValueL( const TDesC& aKey );
       
   193 
       
   194     /**
       
   195      * Extensions for the future
       
   196      * @see <MPEngContactItem.h>
       
   197      */
       
   198     MPEngContactItemExt* Extension() {
       
   199         return NULL;
       
   200         };
       
   201     const MPEngContactItemExt* Extension() const {
       
   202         return NULL;
       
   203         };
       
   204 
       
   205 
       
   206 
       
   207 public: // New functions
       
   208 
       
   209     /**
       
   210      * Compare function.
       
   211      *
       
   212      * Two instances are compared based on the WV Id.
       
   213      *
       
   214      * @since 3.0
       
   215      * @param aFirst fist class for comparison
       
   216      * @param aSecond second class for comparison
       
   217      * @return -1 if fist is smaller,
       
   218      *         +1 is second is smaller,
       
   219      *         0 if they are same
       
   220      */
       
   221     static TInt Compare( const CPEngContactListModItemContainer& aFirst,
       
   222                          const CPEngContactListModItemContainer& aSecond );
       
   223 
       
   224 
       
   225     /**
       
   226      * Opens reference count.
       
   227      *
       
   228      * @since 3.0
       
   229      * @param aRefType 0 zero is indefined for default open
       
   230      *        otherwise one of the TPEngAccessFlags enumeration
       
   231      */
       
   232     void Open( TInt aRefType =  0 );
       
   233 
       
   234 
       
   235     /**
       
   236      * Closes reference count access.
       
   237      *
       
   238      * @since 3.0
       
   239      * @param aRefType 0 zero is indefined for default open
       
   240      *        otherwise one of the TPEngAccessFlags enumeration
       
   241      * @return pointer to called intance.
       
   242      *         If it is about to be deleted NULL is returned
       
   243      */
       
   244     CPEngContactListModItemContainer* CloseRef( TInt aRefType =  0 );
       
   245 
       
   246 
       
   247     /**
       
   248      * Checks reference counted access.
       
   249      *
       
   250      * @since 3.0
       
   251      * @param aRefType 0 zero is indefined for default open
       
   252      *        otherwise one of the TPEngAccessFlags enumeration
       
   253      * @return ETrue if reference is active
       
   254      */
       
   255     TBool RefActive( TInt aRefType =  0 );
       
   256 
       
   257 
       
   258     /**
       
   259      * Closes access.
       
   260      *
       
   261      * @since 3.0
       
   262      */
       
   263     void Close();
       
   264 
       
   265 
       
   266     /**
       
   267      * Externalizes the entry data to stream.
       
   268      *
       
   269      * @since 3.0
       
   270      * @param aStream write stream
       
   271      * @param aType Data to be externalized as defined in
       
   272      *        TPEngStorageType enumeration.
       
   273      */
       
   274     void ExternalizeL( RWriteStream& aStream, TInt aType ) const ;
       
   275 
       
   276 
       
   277     /**
       
   278      * Internalize from the file cached information
       
   279      * @since 3.0
       
   280      * @param aStream read stream
       
   281      * @param aType Data to be internalized as defined in
       
   282      *        TPEngStorageType enumeration.
       
   283      */
       
   284     void InternalizeL( RReadStream& aStream, TInt aType );
       
   285 
       
   286 
       
   287     /**
       
   288      * Update contact Id
       
   289      *
       
   290      * @since 3.0
       
   291      * @param aId id as it is represented by the network server
       
   292      */
       
   293     void UpdateContactId( HBufC* aId );
       
   294 
       
   295 
       
   296     /**
       
   297      * Get new Nickname
       
   298      *
       
   299      * @since 3.0
       
   300      * @return new nick name buffer pointer(can be NULL)
       
   301      */
       
   302     const HBufC* NewNick() const;
       
   303 
       
   304 
       
   305     /**
       
   306      * Get Current nick name
       
   307      *
       
   308      * @since 3.0
       
   309      * @return current nick name buffer pointer(can be NULL)
       
   310      */
       
   311     const HBufC* CurrentNick() const;
       
   312 
       
   313 
       
   314     /**
       
   315      * Get Current nick name
       
   316      *
       
   317      * @since 3.0
       
   318      * @param aNickName current nick name
       
   319      */
       
   320     void SetCurrentNickname( HBufC* aNickName );
       
   321 
       
   322 
       
   323     /**
       
   324      * Adopts the current nick name as new.
       
   325      *
       
   326      * @since 3.0
       
   327      * @return current nick name buffer pointer(can be NULL)
       
   328      */
       
   329     void AdoptCurrentNickAsNew();
       
   330 
       
   331 
       
   332     /**
       
   333      * Roll back nick name.
       
   334      * New nick name is deleted and set as NULL
       
   335      *
       
   336      * @since 3.0
       
   337      */
       
   338     void RollBackNickname();
       
   339 
       
   340 
       
   341     /**
       
   342      * Commit nickname
       
   343      * New Nick name is set as current
       
   344      *
       
   345      * @since 3.0
       
   346      */
       
   347     void CommitNickName();
       
   348 
       
   349 
       
   350 
       
   351     /**
       
   352      * Setter and getter for contact server index.
       
   353      * @since 3.1
       
   354      */
       
   355     TInt ServerIndex() const;
       
   356     void SetServerIndex(  TInt aIndex );
       
   357 
       
   358 
       
   359 
       
   360     /**
       
   361      * Is this contact a fresh one.
       
   362      *
       
   363      * @since 3.0
       
   364      * @return ETrue if it is a fresh one.
       
   365      *         Else EFalse
       
   366      */
       
   367     TBool IsFreshContact();
       
   368 
       
   369 
       
   370     /**
       
   371      * Sets the contact as fresh one or not.
       
   372      *
       
   373      * @since 3.0
       
   374      * @param ETrue if the contact is a fresh one.
       
   375      *        Else EFalse
       
   376      */
       
   377     void SetFreshContact( TBool aFresh );
       
   378 
       
   379 
       
   380 
       
   381 private:    // Data
       
   382 
       
   383     /// REF: Store entry of the whole model
       
   384     MPEngContactListModStore&                iStoreEntry;
       
   385 
       
   386     /// OWN: Access count
       
   387     TInt                                     iAccessCount;
       
   388 
       
   389     /// OWN: Reference definitions
       
   390     TInt                                     iRefDefinitions;
       
   391 
       
   392     /// OWN: Server index for server order
       
   393     TInt									 iServerIndex;
       
   394 
       
   395     /// REF: Item size
       
   396     TInt&                                    iSize;
       
   397 
       
   398     /// OWN: Contact Id
       
   399     HBufC*                                   iContactId;
       
   400 
       
   401     /// OWN: Nickname of the contact
       
   402     HBufC*                                   iNickName;
       
   403 
       
   404     /// OWN: New Nick name
       
   405     HBufC*                                   iNewNickName;
       
   406 
       
   407     /// OWN: The Contact fresh status
       
   408     TBool iFresh;
       
   409 
       
   410     /// OWN: Properties of the contact Item
       
   411     RPointerArray<CPEngContactListProperty>  iProperties;
       
   412     };
       
   413 
       
   414 #endif      // __CPENGCONTACTLISTMODITEMCONTAINER_H__
       
   415 
       
   416 // End of File
       
   417