PECengine/ListLibrary2/AttrListSrc/CPEngAttributeListItem.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 one attribute list item.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGATTRIBUTELISTITEM_H__
       
    19 #define __CPENGATTRIBUTELISTITEM_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <badesca.h>
       
    24 
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class	RWriteStream;
       
    28 class	RReadStream;
       
    29 
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34  * Container of the one attribute list item
       
    35  *
       
    36  * It includes:
       
    37  * - lists of presence attributes.
       
    38  * - list of contacts (contact lists, contact ids),
       
    39  * - list of new and to delete contacts
       
    40  * - flag of default lists, for current state and future
       
    41  *
       
    42  *  @lib PEngListLib2
       
    43  *  @since 3.0
       
    44  */
       
    45 NONSHARABLE_CLASS ( CPEngAttributeListItem ) : public CBase
       
    46     {
       
    47 public:     // Enumerations
       
    48 
       
    49     /**
       
    50      * Enumeration to access contact of the attribute list.
       
    51      * Need to be in order, first new, then currect of each kind
       
    52      *
       
    53      * @since 3.0
       
    54      */
       
    55     enum TPEngAttrListItemArrays
       
    56         {
       
    57         ENewContactLists			= 0,
       
    58         ECurrentContactLists		= 1,
       
    59         ENewContactIDs				= 2,
       
    60         ECurrentContactIDs			= 3
       
    61         };
       
    62 
       
    63 public:
       
    64 
       
    65     /**
       
    66      * Two-phased constructor.
       
    67      */
       
    68     static CPEngAttributeListItem* NewL( RReadStream& aStream );
       
    69     static CPEngAttributeListItem* NewLC( RReadStream& aStream );
       
    70 
       
    71     /**
       
    72      * Two-phased constructor.
       
    73      */
       
    74     static CPEngAttributeListItem* NewL(
       
    75         const RArray<TUint32>& aAttributes );
       
    76     static CPEngAttributeListItem* NewLC(
       
    77         const RArray<TUint32>& aAttributes );
       
    78 
       
    79     /**
       
    80      * Two-phased copy constructor.
       
    81      */
       
    82     static CPEngAttributeListItem* NewL(
       
    83         const CPEngAttributeListItem& aAttributeList );
       
    84 
       
    85     /**
       
    86      * Destructor.
       
    87      */
       
    88     ~CPEngAttributeListItem();
       
    89 
       
    90 
       
    91 
       
    92 public: // Functions of base class
       
    93 
       
    94     /**
       
    95      * Add contact to the defined Contacts array
       
    96      *
       
    97      * @since 3.0
       
    98      * @param aContact contact to be added to the new contact lists
       
    99      * @param aArray array to be used for the operation
       
   100      * @return KErrNone of OK, otherwise system wide error code
       
   101      */
       
   102     TInt AddContactToListL( const TDesC& aContact,
       
   103                             TPEngAttrListItemArrays aArray );
       
   104 
       
   105 
       
   106     /**
       
   107      * Delete contact from contact array
       
   108      *
       
   109      * @since 3.0
       
   110      * @param aContact contact to be deleted from the new contact lists
       
   111      * @param aArray array to be used for the operation
       
   112      * @return KErrNone of OK, otherwise system wide error code
       
   113      */
       
   114     TInt DeleteContactFromList( const TDesC& aContact,
       
   115                                 TPEngAttrListItemArrays aArray );
       
   116 
       
   117 
       
   118     /**
       
   119      * Return array of contact based on the passed enumeration
       
   120      *
       
   121      * @since 3.0
       
   122      * @param aArray array to get
       
   123      * @return des array of contacts
       
   124      */
       
   125     const CDesCArray& ArrayOfContacts(
       
   126         TPEngAttrListItemArrays aArray  ) const;
       
   127 
       
   128 
       
   129     /**
       
   130      * Return array of Presence attributes of the attribute list
       
   131      *
       
   132      * @since 3.0
       
   133      * @return presence attributes of the attribute list
       
   134      */
       
   135     const RArray<TUint32>& PresenceAttributes() const;
       
   136 
       
   137 
       
   138     /**
       
   139      * Update set of presence attribute of the attribute list
       
   140      *
       
   141      * @since 3.0
       
   142      * @param aNewPresenceAttributes new presence attributes
       
   143      */
       
   144     void UpdatePresenceAttributesL(
       
   145         const RArray<TUint32>& aNewPresenceAttributes );
       
   146 
       
   147 
       
   148     /**
       
   149      * Commit contact list in the attribute list
       
   150      *
       
   151      * @since 3.0
       
   152      * @param aContact contact list to be commited
       
   153      */
       
   154     void CommitContactListL( const TDesC& aContact );
       
   155 
       
   156 
       
   157     /**
       
   158      * Commit contact id in the attribute list
       
   159      *
       
   160      * @since 3.0
       
   161      * @param aContact contact ID to be commited
       
   162      */
       
   163     void CommitContactIdL( const TDesC& aContact );
       
   164 
       
   165 
       
   166     /**
       
   167      * Return if attribute list is currently default
       
   168      *
       
   169      * @since 3.0
       
   170      * @return ETrue if attribute list is set as current default
       
   171      */
       
   172     TBool CurrentlyDefault() const;
       
   173 
       
   174 
       
   175     /**
       
   176      * Return if attribute list is new default
       
   177      *
       
   178      * @since 3.0
       
   179      * @return ETrue if attribute list is set as new default
       
   180      */
       
   181     TBool NewDefault() const;
       
   182 
       
   183 
       
   184     /**
       
   185      * Set new default value to the attribute list
       
   186      *
       
   187      * @since 3.0
       
   188      * @param aNewDefault new default value
       
   189      * @return contacts count
       
   190      */
       
   191     TInt SetNewDefault( TBool aNewDefault );
       
   192 
       
   193 
       
   194     /**
       
   195      * Commit default attribute list settings
       
   196      *
       
   197      * @since 3.0
       
   198      */
       
   199     void CommitDefault();
       
   200 
       
   201 
       
   202     /**
       
   203      * Returns sync state of the attribute list
       
   204      *
       
   205      * @since 3.0
       
   206      * @return Sync state
       
   207      */
       
   208     TBool Synchronized() const;
       
   209 
       
   210 
       
   211     /**
       
   212      * Returns sync state of the attribute list
       
   213      *
       
   214      * @since 3.0
       
   215      * @param aSync new sync state
       
   216      */
       
   217     void SetSynchronization( TBool aSync );
       
   218 
       
   219 
       
   220     /**
       
   221      * Externalize attribute list to the stream
       
   222      *
       
   223      * @since 3.0
       
   224      * @param aStream stream to externalize to
       
   225      */
       
   226     void ExternalizeL( RWriteStream& aStream );
       
   227 
       
   228 
       
   229     /**
       
   230      * Internalize attribute list from the stream
       
   231      *
       
   232      * @since 3.0
       
   233      * @param stream to internalize from
       
   234      */
       
   235     void InternalizeL( RReadStream& aStream );
       
   236 
       
   237 
       
   238     /**
       
   239      * Get size of the entry of the attribute list
       
   240      *
       
   241      * @since 3.0
       
   242      * @return size of the attribute list entry for storing
       
   243      */
       
   244     TInt SizeOfEntry() const;
       
   245 
       
   246 
       
   247     /**
       
   248      * Get count of all contacts of the attributelist
       
   249      *
       
   250      * @since 3.0
       
   251      * @return contacts count
       
   252      */
       
   253     TInt ContactsCount() const;
       
   254 
       
   255 
       
   256 
       
   257 private:	// Function of the base class
       
   258 
       
   259     /**
       
   260      * Get desired array
       
   261      *
       
   262      * @since 3.0
       
   263      * @param aArray enumeration of array
       
   264      * @return reference to the array
       
   265      */
       
   266     CDesCArray& Array( TPEngAttrListItemArrays aArray );
       
   267 
       
   268 
       
   269     /**
       
   270      * Commit contact id in the attribute list
       
   271      *
       
   272      * @since 3.0
       
   273      * @param aCurrentArray array of current IDs
       
   274      * @param aNewArray array of new IDs
       
   275      * @param aContact contact ID to be commited
       
   276      */
       
   277     void CommitContactL( CDesCArray& aCurrentArray,
       
   278                          CDesCArray& aNewArray,
       
   279                          const TDesC& aContact );
       
   280 
       
   281 
       
   282     /**
       
   283      * Delete item from the Des Array
       
   284      *
       
   285      * @since 3.0
       
   286      * @param aArray array to be deleted from
       
   287      * @param aItem item to be deleted from array
       
   288      * @return KErrNone if it went fine
       
   289      */
       
   290     TInt DeleteItemFromArray( CDesCArray& aArray,
       
   291                               const TDesC& aItem );
       
   292 
       
   293 
       
   294     /**
       
   295      * Copy des array
       
   296      *
       
   297      * @since 3.0
       
   298      * @param aArrayTarget targer array
       
   299      * @param aArraySource source array
       
   300      */
       
   301     static void CopyDesArrayL( CDesCArray& aArrayTarget,
       
   302                                const CDesCArray& aArraySource );
       
   303 
       
   304     /**
       
   305      * Copy TInt array
       
   306      *
       
   307      * @since 3.0
       
   308      * @param aArrayTarget targer array
       
   309      * @param aArraySource source array
       
   310      */
       
   311     static void CopyTIntArrayL( RArray<TUint32>& aArrayTarget,
       
   312                                 const RArray<TUint32>& aArraySource );
       
   313 
       
   314 
       
   315     /**
       
   316      * Externalize des array to the stream
       
   317      *
       
   318      * @since 3.0
       
   319      * @param aArray array to be externalized
       
   320      * @param aStream stream to externalize to
       
   321      */
       
   322     static void ExternalizeDesArrayToStreamL( CDesCArray& aArray,
       
   323                                               RWriteStream& aStream );
       
   324 
       
   325     /**
       
   326      * Internalize des array from stream
       
   327      *
       
   328      * @since 3.0
       
   329      * @param aArray array to be internlized
       
   330      * @param aStream stream to internalized from
       
   331      */
       
   332     static TInt InternalizeDesArrayFromStreamL( CDesCArray& aArray,
       
   333                                                 RReadStream& aStream );
       
   334 
       
   335 
       
   336 private:	// constructors
       
   337 
       
   338     /**
       
   339      * Symbian constructor.
       
   340      */
       
   341     void ConstructL( const RArray<TUint32>& aAttributes );
       
   342 
       
   343     /**
       
   344      * Symbian constructor.
       
   345      */
       
   346     void ConstructL(
       
   347         const CPEngAttributeListItem& aAttributeList );
       
   348 
       
   349     /**
       
   350      * C++ constructor.
       
   351      */
       
   352     CPEngAttributeListItem();
       
   353 
       
   354 
       
   355 private:    // Data
       
   356 
       
   357     /// OWN: Attribute list is currently default
       
   358     TBool			iCurrentlyDefault;
       
   359 
       
   360     /// OWN: Attribute list is to be set as default
       
   361     TBool           iNewDefault;
       
   362 
       
   363     /// OWN: Attribute list has been already synchronized
       
   364     TBool          iSynchronized;
       
   365 
       
   366     /// OWN: List of attributes of the Attribute list
       
   367     RArray<TUint32>    iListOfAttributes;
       
   368 
       
   369     /// OWN: List of contacts lists attached to attribute list
       
   370     CDesCArraySeg  iListOfContactLists;
       
   371 
       
   372     /// OWN: List of new contacts lists to be attached to attribute list
       
   373     CDesCArrayFlat iListOfNewContactLists;
       
   374 
       
   375     /// OWN: List of contacts attached to attribute list
       
   376     CDesCArraySeg  iListOfContactIDs;
       
   377 
       
   378     /// OWN: List of new contacts to be attached to attribute list
       
   379     CDesCArrayFlat iListOfNewContactIDs;
       
   380 
       
   381     /// OWN: Store size
       
   382     TInt           iSizeOfEntry;
       
   383 
       
   384     };
       
   385 
       
   386 #endif //   __CPENGATTRIBUTELISTITEM_H__
       
   387 
       
   388 // End of File
       
   389