epoc32/include/app/RVPbkContactFieldDefaultPriorities.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/app/RVPbkContactFieldDefaultPriorities.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,163 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:  An array of default field priorities.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef RVPBKCONTACTFIELDDEFAULTPRIORITIES_H
    1.23 +#define RVPBKCONTACTFIELDDEFAULTPRIORITIES_H
    1.24 +
    1.25 +//  INCLUDES
    1.26 +#include <e32std.h>
    1.27 +#include <vpbkfieldtype.hrh> // TVPbkDefaultType
    1.28 +
    1.29 +// CONSTANTS
    1.30 +namespace VPbkContactFieldDefaultPriorities
    1.31 +    {
    1.32 +    /**
    1.33 +     * The maximum amount of elements that can be appended to the array.
    1.34 +     */
    1.35 +    const TInt KMaxElementCount = 255;
    1.36 +    /**
    1.37 +     * The maximum value of TVPbkDefaultType
    1.38 +     */
    1.39 +    const TInt KMaxElementValue = 255;
    1.40 +    }
    1.41 +
    1.42 +// CLASS DECLARATION
    1.43 +
    1.44 +/**
    1.45 + * An array of default field priorities.
    1.46 + *
    1.47 + * A helper class for client to manage default attribute priorities
    1.48 + * of the contact fields. For accessing default information the client uses
    1.49 + * the attribute manager.
    1.50 + *
    1.51 + * @see CVPbkContactManager::ContactAttributeManagerL
    1.52 + * @see CVPbkDefaultAttribute
    1.53 + */
    1.54 +class RVPbkContactFieldDefaultPriorities
    1.55 +    {
    1.56 +    public:  // Interface
    1.57 +        /**
    1.58 +         * Default constructor for an empty array.
    1.59 +         */
    1.60 +        RVPbkContactFieldDefaultPriorities();
    1.61 +        /**
    1.62 +
    1.63 +        /**
    1.64 +         * Releases resources used for storing the array.
    1.65 +         *
    1.66 +         * This object must not be used after Close() has been called to it.
    1.67 +         */
    1.68 +        void Close();
    1.69 +
    1.70 +        /**
    1.71 +         * Returns the number of elements in the array.
    1.72 +         *
    1.73 +         * @return The number of elements in the array.
    1.74 +         */
    1.75 +        TInt Count() const;
    1.76 +
    1.77 +        /**
    1.78 +         * Returns true if this array is empty.
    1.79 +         *
    1.80 +         * @return ETrue if the array is empty.
    1.81 +         */
    1.82 +        TBool IsEmpty() const;
    1.83 +        
    1.84 +        /**
    1.85 +         * Returns a type at aIndex.
    1.86 +         *
    1.87 +         * @param aIndex A zero based index of the element.
    1.88 +         * @return A type at aIndex.
    1.89 +         */
    1.90 +        TVPbkDefaultType At(const TInt aIndex) const;
    1.91 +        
    1.92 +        /**
    1.93 +         * Appends a default type to the array.
    1.94 +         *
    1.95 +         * @param aDefaultType The default type to append in to the array.
    1.96 +         * @return KErrNone or a system wide error code.
    1.97 +         */
    1.98 +        TInt Append(const TVPbkDefaultType aDefaultType);
    1.99 +
   1.100 +        /**
   1.101 +         * Outputs this objects state to a buffer.
   1.102 +         *
   1.103 +         * @return A buffer containing the state of the object.
   1.104 +         */
   1.105 +        IMPORT_C HBufC8* ExternalizeLC() const;
   1.106 +        
   1.107 +        /**
   1.108 +         * Initializes the instance from the buffer.
   1.109 +         *
   1.110 +         * @param aBuffer A buffer that was created using ExternalizeLC.
   1.111 +         */
   1.112 +        IMPORT_C void InternalizeL(const TDesC8& aBuffer);
   1.113 +
   1.114 +    private: // Data
   1.115 +        /// Own: An array of default types to use.
   1.116 +        RArray<TVPbkDefaultType> iDefaultTypes;
   1.117 +    };
   1.118 +
   1.119 +// INLINE IMPLEMENTATION
   1.120 +
   1.121 +inline RVPbkContactFieldDefaultPriorities::RVPbkContactFieldDefaultPriorities()
   1.122 +    {
   1.123 +    }
   1.124 +
   1.125 +inline void RVPbkContactFieldDefaultPriorities::Close()
   1.126 +    {
   1.127 +    iDefaultTypes.Close();
   1.128 +    }
   1.129 +
   1.130 +inline TInt RVPbkContactFieldDefaultPriorities::Count() const
   1.131 +    {
   1.132 +    return iDefaultTypes.Count();
   1.133 +    }
   1.134 +
   1.135 +inline TBool RVPbkContactFieldDefaultPriorities::IsEmpty() const
   1.136 +    {
   1.137 +    return !iDefaultTypes.Count();
   1.138 +    }
   1.139 +
   1.140 +inline TVPbkDefaultType RVPbkContactFieldDefaultPriorities::At
   1.141 +        (const TInt aIndex) const
   1.142 +    {
   1.143 +    return iDefaultTypes[aIndex];
   1.144 +    }
   1.145 +
   1.146 +inline TInt RVPbkContactFieldDefaultPriorities::Append
   1.147 +        (const TVPbkDefaultType aDefaultType)
   1.148 +    {
   1.149 +    TInt ret = KErrOverflow;
   1.150 +    if (Count() < VPbkContactFieldDefaultPriorities::KMaxElementCount)
   1.151 +        {
   1.152 +        if (aDefaultType > VPbkContactFieldDefaultPriorities::KMaxElementValue)
   1.153 +            {
   1.154 +            ret = KErrTooBig;
   1.155 +            }
   1.156 +        else
   1.157 +            {
   1.158 +            ret = iDefaultTypes.Append(aDefaultType);
   1.159 +            }
   1.160 +        }
   1.161 +    return ret;
   1.162 +    }
   1.163 +
   1.164 +#endif // RVPBKCONTACTFIELDDEFAULTPRIORITIES_H
   1.165 +
   1.166 +// End of File