emailcontacts/contactactionservice/src/CFscFieldProperty.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implementation of field property.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "CFscFieldProperty.h"
       
    21 
       
    22 // From Phonebook 2
       
    23 #include "CFscFieldOrderingManager.h"
       
    24 
       
    25 // From Virtual Phonebook
       
    26 #include <MVPbkFieldType.h>
       
    27 
       
    28 // System includes
       
    29 #include <barsread.h>
       
    30 #include <coemain.h>
       
    31 
       
    32 // --------------------------------------------------------------------------
       
    33 // CFscFieldProperty::CFscFieldProperty
       
    34 // --------------------------------------------------------------------------
       
    35 //    
       
    36 inline CFscFieldProperty::CFscFieldProperty()
       
    37     {
       
    38     FUNC_LOG;
       
    39     }
       
    40 
       
    41 // --------------------------------------------------------------------------
       
    42 // CFscFieldProperty::~CFscFieldProperty
       
    43 // --------------------------------------------------------------------------
       
    44 //    
       
    45 CFscFieldProperty::~CFscFieldProperty()
       
    46     {
       
    47     FUNC_LOG;
       
    48     delete iAddItemText;
       
    49     delete iDefaultLabel;
       
    50     }
       
    51 
       
    52 // --------------------------------------------------------------------------
       
    53 // CFscFieldProperty::ConstructL
       
    54 // --------------------------------------------------------------------------
       
    55 //    
       
    56 inline void CFscFieldProperty::ConstructL(TResourceReader& aReader,
       
    57         const MVPbkFieldTypeList& aSupportedFieldTypeList,
       
    58         CFscFieldOrderingManager& aFieldOrderingManager)
       
    59     {
       
    60     FUNC_LOG;
       
    61     aReader.ReadInt8(); // read version number
       
    62     const TInt fieldTypeResId = aReader.ReadInt32();
       
    63 
       
    64     iFieldType = aSupportedFieldTypeList.Find(fieldTypeResId);
       
    65     iMultiplicity = aReader.ReadInt8();
       
    66     iMaxLength = aReader.ReadInt16();
       
    67     iEditMode = aReader.ReadInt8();
       
    68     iDefaultCase = aReader.ReadInt8();
       
    69     iIconId = TPbk2IconId(aReader);
       
    70     iCtrlType = aReader.ReadInt8();
       
    71     iFlags = aReader.ReadUint32();
       
    72     iAddItemText = aReader.ReadHBufCL();
       
    73     iLocation = aReader.ReadInt8();
       
    74     iGroupId = aReader.ReadInt8();
       
    75     iDefaultLabel = aReader.ReadHBufCL();
       
    76 
       
    77     if (iFieldType)
       
    78         {
       
    79         // If field type is supported get ordering items
       
    80         iOrderingItem = aFieldOrderingManager.OrderingItem( *iFieldType);
       
    81         iAddItemOrdering
       
    82                 = aFieldOrderingManager.AddItemOrdering( *iFieldType);
       
    83         }
       
    84     }
       
    85 
       
    86 // --------------------------------------------------------------------------
       
    87 // CFscFieldProperty::NewLC
       
    88 // --------------------------------------------------------------------------
       
    89 //    
       
    90 CFscFieldProperty* CFscFieldProperty::NewLC(TResourceReader& aReader,
       
    91         const MVPbkFieldTypeList& aSupportedFieldTypeList,
       
    92         CFscFieldOrderingManager& aFieldOrderingManager)
       
    93     {
       
    94     FUNC_LOG;
       
    95     CFscFieldProperty* self = new( ELeave ) CFscFieldProperty;
       
    96     CleanupStack::PushL(self);
       
    97     self->ConstructL(aReader, aSupportedFieldTypeList, aFieldOrderingManager);
       
    98     return self;
       
    99     }
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CFscFieldProperty::IsSupported
       
   103 // --------------------------------------------------------------------------
       
   104 //    
       
   105 TBool CFscFieldProperty::IsSupported() const
       
   106     {
       
   107     FUNC_LOG;
       
   108     TBool ret = EFalse;
       
   109 
       
   110     if (iFieldType)
       
   111         {
       
   112         ret = ETrue;
       
   113         }
       
   114 
       
   115     return ret;
       
   116     }
       
   117 
       
   118 // --------------------------------------------------------------------------
       
   119 // CFscFieldProperty::IsSame
       
   120 // --------------------------------------------------------------------------
       
   121 //
       
   122 TBool CFscFieldProperty::IsSame(const MPbk2FieldProperty& aOther) const
       
   123     {
       
   124     FUNC_LOG;
       
   125     return aOther.FieldType().IsSame( *iFieldType);
       
   126     }
       
   127 
       
   128 // --------------------------------------------------------------------------
       
   129 // CFscFieldProperty::FieldType
       
   130 // --------------------------------------------------------------------------
       
   131 //
       
   132 const MVPbkFieldType& CFscFieldProperty::FieldType() const
       
   133     {
       
   134     FUNC_LOG;
       
   135     return *iFieldType;
       
   136     }
       
   137 
       
   138 // --------------------------------------------------------------------------
       
   139 // CFscFieldProperty::Multiplicity
       
   140 // --------------------------------------------------------------------------
       
   141 //    
       
   142 TPbk2FieldMultiplicity CFscFieldProperty::Multiplicity() const
       
   143     {
       
   144     FUNC_LOG;
       
   145     return static_cast<TPbk2FieldMultiplicity>(iMultiplicity);
       
   146     }
       
   147 
       
   148 // --------------------------------------------------------------------------
       
   149 // CFscFieldProperty::MaxLength
       
   150 // --------------------------------------------------------------------------
       
   151 //
       
   152 TInt CFscFieldProperty::MaxLength() const
       
   153     {
       
   154     FUNC_LOG;
       
   155     return iMaxLength;
       
   156     }
       
   157 
       
   158 // --------------------------------------------------------------------------
       
   159 // CFscFieldProperty::EditMode
       
   160 // --------------------------------------------------------------------------
       
   161 //
       
   162 TPbk2FieldEditMode CFscFieldProperty::EditMode() const
       
   163     {
       
   164     FUNC_LOG;
       
   165     return static_cast<TPbk2FieldEditMode>(iEditMode);
       
   166     }
       
   167 
       
   168 // --------------------------------------------------------------------------
       
   169 // CFscFieldProperty::DefaultCase
       
   170 // --------------------------------------------------------------------------
       
   171 //
       
   172 TPbk2FieldDefaultCase CFscFieldProperty::DefaultCase() const
       
   173     {
       
   174     FUNC_LOG;
       
   175     return static_cast<TPbk2FieldDefaultCase>(iDefaultCase);
       
   176     }
       
   177 
       
   178 // --------------------------------------------------------------------------
       
   179 // CFscFieldProperty::IconId
       
   180 // --------------------------------------------------------------------------
       
   181 //
       
   182 const TPbk2IconId& CFscFieldProperty::IconId() const
       
   183     {
       
   184     FUNC_LOG;
       
   185     return iIconId;
       
   186     }
       
   187 
       
   188 // --------------------------------------------------------------------------
       
   189 // CFscFieldProperty::CtrlType
       
   190 // --------------------------------------------------------------------------
       
   191 //
       
   192 TPbk2FieldCtrlType CFscFieldProperty::CtrlType() const
       
   193     {
       
   194     FUNC_LOG;
       
   195     return static_cast<TPbk2FieldCtrlType>(iCtrlType);
       
   196     }
       
   197 
       
   198 // --------------------------------------------------------------------------
       
   199 // CFscFieldProperty::Flags
       
   200 // --------------------------------------------------------------------------
       
   201 //
       
   202 TUint CFscFieldProperty::Flags() const
       
   203     {
       
   204     FUNC_LOG;
       
   205     return iFlags;
       
   206     }
       
   207 
       
   208 // --------------------------------------------------------------------------
       
   209 // CFscFieldProperty::OrderingItem
       
   210 // --------------------------------------------------------------------------
       
   211 //
       
   212 TInt CFscFieldProperty::OrderingItem() const
       
   213     {
       
   214     FUNC_LOG;
       
   215     return iOrderingItem;
       
   216     }
       
   217 
       
   218 // --------------------------------------------------------------------------
       
   219 // CFscFieldProperty::AddItemOrdering
       
   220 // --------------------------------------------------------------------------
       
   221 //
       
   222 TInt CFscFieldProperty::AddItemOrdering() const
       
   223     {
       
   224     FUNC_LOG;
       
   225     return iAddItemOrdering;
       
   226     }
       
   227 
       
   228 // --------------------------------------------------------------------------
       
   229 // CFscFieldProperty::AddItemText
       
   230 // --------------------------------------------------------------------------
       
   231 //
       
   232 const TDesC& CFscFieldProperty::AddItemText() const
       
   233     {
       
   234     FUNC_LOG;
       
   235     if (iAddItemText)
       
   236         {
       
   237         return *iAddItemText;
       
   238         }
       
   239     else
       
   240         if (iDefaultLabel)
       
   241             {
       
   242             return *iDefaultLabel;
       
   243             }
       
   244         else
       
   245             {
       
   246             return KNullDesC;
       
   247             }
       
   248     }
       
   249 
       
   250 // --------------------------------------------------------------------------
       
   251 // CFscFieldProperty::Location
       
   252 // --------------------------------------------------------------------------
       
   253 //
       
   254 TPbk2FieldLocation CFscFieldProperty::Location() const
       
   255     {
       
   256     FUNC_LOG;
       
   257     return static_cast<TPbk2FieldLocation>(iLocation);
       
   258     }
       
   259 
       
   260 // --------------------------------------------------------------------------
       
   261 // CFscFieldProperty::GroupId
       
   262 // --------------------------------------------------------------------------
       
   263 //
       
   264 TPbk2FieldGroupId CFscFieldProperty::GroupId() const
       
   265     {
       
   266     FUNC_LOG;
       
   267     return static_cast<TPbk2FieldGroupId>(iGroupId);
       
   268     }
       
   269 
       
   270 // --------------------------------------------------------------------------
       
   271 // CFscFieldProperty::DefaultLabel
       
   272 // --------------------------------------------------------------------------
       
   273 //
       
   274 const TDesC& CFscFieldProperty::DefaultLabel() const
       
   275     {
       
   276     FUNC_LOG;
       
   277     return *iDefaultLabel;
       
   278     }
       
   279 
       
   280 // End of file
       
   281