contacts_plat/virtual_phonebook_engine_api/inc/RVPbkContactFieldDefaultPriorities.h
changeset 0 e686773b3f54
child 22 5577f3882caa
child 32 2828b4d142c0
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  An array of default field priorities.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef RVPBKCONTACTFIELDDEFAULTPRIORITIES_H
       
    20 #define RVPBKCONTACTFIELDDEFAULTPRIORITIES_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <vpbkfieldtype.hrh> // TVPbkDefaultType
       
    25 
       
    26 // CONSTANTS
       
    27 namespace VPbkContactFieldDefaultPriorities
       
    28     {
       
    29     /**
       
    30      * The maximum amount of elements that can be appended to the array.
       
    31      */
       
    32     const TInt KMaxElementCount = 255;
       
    33     /**
       
    34      * The maximum value of TVPbkDefaultType
       
    35      */
       
    36     const TInt KMaxElementValue = 255;
       
    37     }
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42  * An array of default field priorities.
       
    43  *
       
    44  * A helper class for client to manage default attribute priorities
       
    45  * of the contact fields. For accessing default information the client uses
       
    46  * the attribute manager.
       
    47  *
       
    48  * @see CVPbkContactManager::ContactAttributeManagerL
       
    49  * @see CVPbkDefaultAttribute
       
    50  */
       
    51 class RVPbkContactFieldDefaultPriorities
       
    52     {
       
    53     public:  // Interface
       
    54         /**
       
    55          * Default constructor for an empty array.
       
    56          */
       
    57         RVPbkContactFieldDefaultPriorities();
       
    58         /**
       
    59 
       
    60         /**
       
    61          * Releases resources used for storing the array.
       
    62          *
       
    63          * This object must not be used after Close() has been called to it.
       
    64          */
       
    65         void Close();
       
    66 
       
    67         /**
       
    68          * Returns the number of elements in the array.
       
    69          *
       
    70          * @return The number of elements in the array.
       
    71          */
       
    72         TInt Count() const;
       
    73 
       
    74         /**
       
    75          * Returns true if this array is empty.
       
    76          *
       
    77          * @return ETrue if the array is empty.
       
    78          */
       
    79         TBool IsEmpty() const;
       
    80         
       
    81         /**
       
    82          * Returns a type at aIndex.
       
    83          *
       
    84          * @param aIndex A zero based index of the element.
       
    85          * @return A type at aIndex.
       
    86          */
       
    87         TVPbkDefaultType At(const TInt aIndex) const;
       
    88         
       
    89         /**
       
    90          * Appends a default type to the array.
       
    91          *
       
    92          * @param aDefaultType The default type to append in to the array.
       
    93          * @return KErrNone or a system wide error code.
       
    94          */
       
    95         TInt Append(const TVPbkDefaultType aDefaultType);
       
    96 
       
    97         /**
       
    98          * Outputs this objects state to a buffer.
       
    99          *
       
   100          * @return A buffer containing the state of the object.
       
   101          */
       
   102         IMPORT_C HBufC8* ExternalizeLC() const;
       
   103         
       
   104         /**
       
   105          * Initializes the instance from the buffer.
       
   106          *
       
   107          * @param aBuffer A buffer that was created using ExternalizeLC.
       
   108          */
       
   109         IMPORT_C void InternalizeL(const TDesC8& aBuffer);
       
   110 
       
   111     private: // Data
       
   112         /// Own: An array of default types to use.
       
   113         RArray<TVPbkDefaultType> iDefaultTypes;
       
   114     };
       
   115 
       
   116 // INLINE IMPLEMENTATION
       
   117 
       
   118 inline RVPbkContactFieldDefaultPriorities::RVPbkContactFieldDefaultPriorities()
       
   119     {
       
   120     }
       
   121 
       
   122 inline void RVPbkContactFieldDefaultPriorities::Close()
       
   123     {
       
   124     iDefaultTypes.Close();
       
   125     }
       
   126 
       
   127 inline TInt RVPbkContactFieldDefaultPriorities::Count() const
       
   128     {
       
   129     return iDefaultTypes.Count();
       
   130     }
       
   131 
       
   132 inline TBool RVPbkContactFieldDefaultPriorities::IsEmpty() const
       
   133     {
       
   134     return !iDefaultTypes.Count();
       
   135     }
       
   136 
       
   137 inline TVPbkDefaultType RVPbkContactFieldDefaultPriorities::At
       
   138         (const TInt aIndex) const
       
   139     {
       
   140     return iDefaultTypes[aIndex];
       
   141     }
       
   142 
       
   143 inline TInt RVPbkContactFieldDefaultPriorities::Append
       
   144         (const TVPbkDefaultType aDefaultType)
       
   145     {
       
   146     TInt ret = KErrOverflow;
       
   147     if (Count() < VPbkContactFieldDefaultPriorities::KMaxElementCount)
       
   148         {
       
   149         if (aDefaultType > VPbkContactFieldDefaultPriorities::KMaxElementValue)
       
   150             {
       
   151             ret = KErrTooBig;
       
   152             }
       
   153         else
       
   154             {
       
   155             ret = iDefaultTypes.Append(aDefaultType);
       
   156             }
       
   157         }
       
   158     return ret;
       
   159     }
       
   160 
       
   161 #endif // RVPBKCONTACTFIELDDEFAULTPRIORITIES_H
       
   162 
       
   163 // End of File