PECengine/ListLibrary2/AttrListSrc/CPEngAttributeListManager.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:  Attribute list manager
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGATTRIBUTELISTMANAGER_H__
       
    19 #define __CPENGATTRIBUTELISTMANAGER_H__
       
    20 
       
    21 
       
    22 //  INCLUDES
       
    23 #include "CPEngStoreEntry.h"
       
    24 #include "MPEngAttributeListManager.h"
       
    25 #include "CPEngAttributeListItem.h"
       
    26 #include <e32base.h>
       
    27 #include <badesca.h>
       
    28 
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class   MPEngPresenceAttrManager;
       
    33 class   MPEngStorageManager;
       
    34 class   MPEngListLibFactory;
       
    35 class   CPEngSessionSlotId;
       
    36 
       
    37 
       
    38 // DATA TYPES
       
    39 typedef TBool ( CPEngAttributeListItem::*ItemDefaultSet )( void ) const;
       
    40 
       
    41 
       
    42 // CLASS DECLARATION
       
    43 /**
       
    44  * Attribute lists manager
       
    45  *
       
    46  * @lib PEngListLib2
       
    47  * @since 3.0
       
    48  */
       
    49 NONSHARABLE_CLASS( CPEngAttributeListManager ) :
       
    50         public CPEngStoreEntry,
       
    51         public MPEngAttributeListManager
       
    52     {
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Two-phased constructor.
       
    57      */
       
    58     static CPEngAttributeListManager* NewL( MPEngListLibFactory& aFactory,
       
    59     const CPEngSessionSlotId& aSessionSlot );
       
    60 
       
    61     /**
       
    62      * Two-phased constructor.
       
    63      */
       
    64     static CPEngAttributeListManager* NewLC( MPEngListLibFactory& aFactory,
       
    65                                              const CPEngSessionSlotId& aSessionSlot );
       
    66 
       
    67     /**
       
    68      * Destructor.
       
    69      */
       
    70     ~CPEngAttributeListManager();
       
    71 
       
    72 
       
    73 public: // Session recognize functions
       
    74 
       
    75     /**
       
    76      * Session ID
       
    77      * @since 3.0
       
    78      * @return session Id
       
    79      */
       
    80     const CPEngSessionSlotId& SessionId() const;
       
    81 
       
    82     /**
       
    83      * Increase ref count
       
    84      *
       
    85      * @since 3.0
       
    86      */
       
    87     void Open();
       
    88 
       
    89 
       
    90 
       
    91 public: // Functions from MPEngAttributeListManager
       
    92 
       
    93     /**
       
    94      * Close reference to the Class
       
    95      * @see <MPEngAttributeListManager.h>
       
    96      */
       
    97     void Close();
       
    98 
       
    99 
       
   100     /**
       
   101      * Create Empty attribute list
       
   102      * @see <MPEngAttributeListManager.h>
       
   103      */
       
   104     MPEngAttributeList2* CreateEmptyAttributeListL();
       
   105 
       
   106 
       
   107     /**
       
   108      * Get default attribute list
       
   109      * @see <MPEngAttributeListManager.h>
       
   110      */
       
   111     MPEngAttributeList2* GetDefaultAttributeListL(
       
   112         TPEngAttributeListsSet2 aAttrListsSet );
       
   113 
       
   114 
       
   115     /**
       
   116      * Set new default attribute list
       
   117      * @see <MPEngAttributeListManager.h>
       
   118      */
       
   119     void SetAsDefaultAttributeListL(
       
   120         MPEngAttributeList2& aAttrList );
       
   121 
       
   122 
       
   123     /**
       
   124      * Delete default attribute list
       
   125      * @see <MPEngAttributeListManager.h>
       
   126      */
       
   127     void DeleteDefaultAttributeListL();
       
   128 
       
   129 
       
   130     /**
       
   131      * Get attribute list attached to the contact Id
       
   132      * @see <MPEngAttributeListManager.h>
       
   133      */
       
   134     MPEngAttributeList2* GetAttributeListForUserL(
       
   135         const TDesC& aContactId,
       
   136         TPEngAttributeListsSet2 aAttrListsSet );
       
   137 
       
   138 
       
   139     /**
       
   140      * Get attribute list attached to the contact list
       
   141      * @see <MPEngAttributeListManager.h>
       
   142      */
       
   143     MPEngAttributeList2* GetAttributeListForContactListL(
       
   144         const TDesC& aContactList,
       
   145         TPEngAttributeListsSet2 aAttrListsSet );
       
   146 
       
   147     /**
       
   148      * Attach attribute list to the contact list
       
   149      * @see <MPEngAttributeListManager.h>
       
   150      */
       
   151     void AttachAttributeListToContactListL(
       
   152         const TDesC& aContactList,
       
   153         MPEngAttributeList2& aAttrList );
       
   154 
       
   155 
       
   156     /**
       
   157      * Attach attribute list to the contact id
       
   158      * @see <MPEngAttributeListManager.h>
       
   159      */
       
   160     void AttachAttributeListToUserL(
       
   161         const TDesC& aContactId,
       
   162         MPEngAttributeList2& aAttrList );
       
   163 
       
   164     /**
       
   165      * Delete attribute list from Contact list
       
   166      * @see <MPEngAttributeListManager.h>
       
   167      */
       
   168     void DeleteAttributeListFromContactListL(
       
   169         const TDesC& aContactList );
       
   170 
       
   171     /**
       
   172      * Delete attribute list from Contact Id
       
   173      * @see <MPEngAttributeListManager.h>
       
   174      */
       
   175     void DeleteAttributeListFromUserL(
       
   176         const TDesC& aContactId );
       
   177 
       
   178 
       
   179 
       
   180 public: // From CPEngStoreEntry
       
   181 
       
   182     /**
       
   183      * ExternalizeL provides way to externalize data from store entry.
       
   184      * @see <CPEngStoreEntry.h>
       
   185      */
       
   186     void ExternalizeL( RWriteStream& aStream,
       
   187                        TPEngStorageType aStorageType ) const;
       
   188 
       
   189     /**
       
   190      * InternalizeL provides way to internalise data to store entry.
       
   191      * @see <CPEngStoreEntry.h>
       
   192      */
       
   193     void InternalizeL( RReadStream& aStream,
       
   194                        TPEngStorageType aStorageType );
       
   195 
       
   196 
       
   197     /**
       
   198      * This method is used to retrieve ID for storing.
       
   199      * @see <CPEngStoreEntry.h>
       
   200      */
       
   201     const TDesC& StorageId() const;
       
   202 
       
   203 
       
   204     /**
       
   205      * This method is used to ask entry size in bytes.
       
   206      * @see <CPEngStoreEntry.h>
       
   207      */
       
   208     TUint32 EntrySize() const;
       
   209 
       
   210 
       
   211     /**
       
   212      * Handle change of the Storage IDs
       
   213      * @see <CPEngStoreEntry.h>
       
   214      * @since 3.0
       
   215      */
       
   216     void HandleSIDsChangeL( CPtrCArray& aChangedSIDs );
       
   217 
       
   218 
       
   219     /**
       
   220      * Called when SIDs notifier fails
       
   221      * @see <CPEngStoreEntry.h>
       
   222      * @since 3.0
       
   223      */
       
   224     void HandleSIDNotifyError( TInt aError );
       
   225 
       
   226 
       
   227 
       
   228 public: // New functions
       
   229 
       
   230 
       
   231     /**
       
   232      * Find attribute list
       
   233      *
       
   234      * @since 3.0
       
   235      * @param aAttributeList attribute list to look for
       
   236      * @return index in array or KErrNotFound
       
   237      */
       
   238     TInt FindAttributeList( const RArray<TUint32>& aAttributeList ) const;
       
   239 
       
   240 
       
   241     /**
       
   242      * Find current default attribure list
       
   243      *
       
   244      * @since 3.0
       
   245      * @return index in array or KErrNotFound
       
   246      */
       
   247     TInt FindCurrentDefaultAttributeList() const;
       
   248 
       
   249 
       
   250     /**
       
   251      * Find new default attribute list
       
   252      *
       
   253      * @since 3.0
       
   254      * @return index in array if found or KErrNotFound
       
   255      */
       
   256     TInt FindNewDefaultAttributeList() const;
       
   257 
       
   258 
       
   259 protected:  // Functions of the base class
       
   260 
       
   261     /**
       
   262      * Store Manager content to the storage
       
   263      * @since 3.0
       
   264      */
       
   265     TInt StoreChangesL();
       
   266 
       
   267 
       
   268 private:    // new functions
       
   269 
       
   270     /**
       
   271      * Compare two attribute lists
       
   272      *
       
   273      * @since 3.0
       
   274      * @param aListA attribute list A
       
   275      * @param aListB attribute list B
       
   276      * @return ETrue is same, EFalse if not
       
   277      */
       
   278     TBool CompareAttributeLists( const RArray<TUint32>& aListA,
       
   279                                  const RArray<TUint32>& aListB ) const;
       
   280 
       
   281     /**
       
   282      * Find ID in the Des Array
       
   283      *
       
   284      * @since 3.0
       
   285      * @param aArray array to search in
       
   286      * @param aItem item to look for
       
   287      * @return inder or KErrNotFound
       
   288      */
       
   289     TInt FindItemInArray( const CDesCArray& aArray,
       
   290                           const TDesC& aItem ) const;
       
   291 
       
   292 
       
   293     /**
       
   294      * Find Contact in the defined array of attribute list
       
   295      *
       
   296      * @since 3.0
       
   297      * @param aArray array to search in
       
   298      * @param aItem item to look for
       
   299      * @return inder or KErrNotFound
       
   300      */
       
   301     TInt FindContactInAttrLists(
       
   302         const TDesC& aContact,
       
   303         CPEngAttributeListItem::TPEngAttrListItemArrays aArray ) const;
       
   304 
       
   305 
       
   306     /**
       
   307      * Find Default attribute list
       
   308      *
       
   309      * @since 3.0
       
   310      * @param aArray array to search in
       
   311      * @return inder or KErrNotFound
       
   312      */
       
   313     TInt FindDefaultAttrList( ItemDefaultSet aDefaultSetCall ) const;
       
   314 
       
   315 
       
   316     /**
       
   317      * Get attribute list attached to the contact
       
   318      *
       
   319      * @since 3.0
       
   320      * @param aContact contact
       
   321      * @param aAttrListsSet attribute list set
       
   322      * Rest of parameters define what internal array used for operation
       
   323      * @param aArrayCurrent enumeration of current array of contacts
       
   324      * @param aArrayNew enumeration of the new array of contacts
       
   325      * @param aToDeleteContacts array of contacts for deleting
       
   326      */
       
   327     MPEngAttributeList2* GetAttributeListForContactL(
       
   328         const TDesC& aContact,
       
   329         TPEngAttributeListsSet2 aAttrListsSet,
       
   330         CPEngAttributeListItem::TPEngAttrListItemArrays aArrayCurrent,
       
   331         CPEngAttributeListItem::TPEngAttrListItemArrays aArrayNew );
       
   332 
       
   333 
       
   334     /**
       
   335      * Attach attribute list to the contact
       
   336      *
       
   337      * @since 3.0
       
   338      * @param aContact contact
       
   339      * @param aList attribute list models
       
   340      * Rest of parameters define what internal array used for operation
       
   341      * @param aArrayCurrent enumeration of current array of contacts
       
   342      * @param aArrayNew enumeration of the new array of contacts
       
   343      * @param aToDeleteContacts array of contacts for deleting
       
   344      */
       
   345     void AttachAttributeListToContactL(
       
   346         const TDesC& aContact,
       
   347         MPEngAttributeList2& aList,
       
   348         CPEngAttributeListItem::TPEngAttrListItemArrays aArrayCurrent,
       
   349         CPEngAttributeListItem::TPEngAttrListItemArrays aArrayNew,
       
   350         CDesCArray& aToDeleteContacts );
       
   351 
       
   352 
       
   353     /**
       
   354      * Delete attribute list from the contact
       
   355      *
       
   356      * @since 3.0
       
   357      * @param aContact contact
       
   358      * Rest of parameters define what internal array used for operation
       
   359      * @param aArrayNew enumeration of the new array of contacts
       
   360      * @param aToDeleteContacts array of contacts for deleting
       
   361      */
       
   362     void DeleteAttributeListFromContactL(
       
   363         const TDesC& aContact,
       
   364         CPEngAttributeListItem::TPEngAttrListItemArrays aArrayNew,
       
   365         CDesCArray& aToDeleteContacts );
       
   366 
       
   367 protected:  // constructors
       
   368 
       
   369     /**
       
   370      * Symbian constructor.
       
   371      */
       
   372     void ConstructL( const CPEngSessionSlotId& aSessionSlot );
       
   373 
       
   374     /**
       
   375      * C++ constructor.
       
   376      */
       
   377     CPEngAttributeListManager( MPEngListLibFactory& aFactory );
       
   378 
       
   379 
       
   380 protected:  // Data
       
   381 
       
   382     /// OWN: Access count
       
   383     TInt                                    iAccessCount;
       
   384 
       
   385     /// REF: Factory
       
   386     MPEngListLibFactory&                    iFactory;
       
   387 
       
   388     /// OWN: Session Slot Id
       
   389     CPEngSessionSlotId*                     iSessionId;
       
   390 
       
   391     /// OWN: Attribute list engine synchronized with server
       
   392     TBool                                   iSynchronized;
       
   393 
       
   394     /// OWN: Presence attribute manager
       
   395     MPEngPresenceAttrManager*               iAttributeManager;
       
   396 
       
   397     /// OWN: Array of the attributes exists, elements OWNED
       
   398     RPointerArray<CPEngAttributeListItem>   iAttributeLists;
       
   399 
       
   400     /// OWN: Array of contact IDs for which attr lists should be deleted
       
   401     CDesC16ArrayFlat                        iDeleteAttrListContactIDs;
       
   402 
       
   403     /// OWN: Array of contact lists for which attr lists should be deleted
       
   404     CDesC16ArrayFlat                        iDeleteAttrListContactLists;
       
   405 
       
   406     /// OWN: Flag if default attribute list should be deleted
       
   407     TBool                                   iDeleteDefaultAttrList;
       
   408     };
       
   409 
       
   410 #endif // __CPENGATTRIBUTELISTMANAGER_H__
       
   411 
       
   412 // End of File
       
   413