phonebookengines/VirtualPhonebook/VPbkLdapStore/src/TStoreContactField.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Contact field class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "tstorecontactfield.h"
       
    21 #include "contact.h"
       
    22 #include "ldapcontact.h"
       
    23 #include "ldapcontactfield.h"
       
    24 #include "contactstore.h"
       
    25 #include "contactlink.h"
       
    26 #include "fieldtypemappings.h"
       
    27 #include <mvpbkbasecontact.h>
       
    28 #include <mvpbkcontactstoreproperties.h>
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // LDAP Store namespace
       
    32 // -----------------------------------------------------------------------------
       
    33 namespace LDAPStore {
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // TStoreContactField::TStoreContactField
       
    37 // C++ default constructor can NOT contain any code, that might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 TStoreContactField::TStoreContactField()
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 //                      TStoreContactField public methods
       
    46 // -----------------------------------------------------------------------------
       
    47 // TStoreContactField::SetContact
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 void TStoreContactField::SetContact(CContact& aContact)
       
    51     {
       
    52     iContact = &aContact;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // TStoreContactField::SetField
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void TStoreContactField::SetField(CLDAPContactField& aField)
       
    60     {
       
    61     iField = &aField;
       
    62     iFieldData.SetField(aField);
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // TStoreContactField::Field
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CLDAPContactField* TStoreContactField::Field()
       
    70     {
       
    71     return iField;
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 //                      MVPbkObjectHierarchy implementation
       
    76 // -----------------------------------------------------------------------------
       
    77 // TStoreContactField::ParentObject
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 MVPbkObjectHierarchy& TStoreContactField::ParentObject() const
       
    81     {
       
    82     return *iContact;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 //                      MVPbkBaseContactField implementation
       
    87 // -----------------------------------------------------------------------------
       
    88 // TStoreContactField::ParentContact
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 MVPbkBaseContact& TStoreContactField::ParentContact() const
       
    92     {
       
    93     return *iContact;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // TStoreContactField::MatchFieldType
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 const MVPbkFieldType* TStoreContactField::MatchFieldType(
       
   101     TInt /*aMatchPriority*/ ) const
       
   102     {
       
   103     return iContact->Store().FieldTypeMappings().Match(iField->Type());
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // TStoreContactField::BestMatchingFieldType
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 const MVPbkFieldType* TStoreContactField::BestMatchingFieldType() const
       
   111     {
       
   112     return MatchFieldType(0);
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // TStoreContactField::FieldData
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 const MVPbkContactFieldData& TStoreContactField::FieldData() const
       
   120     {
       
   121     return iFieldData;
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // TStoreContactField::IsSame
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 TBool TStoreContactField::IsSame(const MVPbkBaseContactField& aOther) const
       
   129     {
       
   130     if (&ParentContact() == &aOther.ParentContact())
       
   131         {
       
   132         return iField == static_cast<const TStoreContactField&>(aOther).iField; 
       
   133         }
       
   134     return EFalse;
       
   135     }
       
   136    
       
   137 // -----------------------------------------------------------------------------
       
   138 //                      MVPbkStoreContactField implementation
       
   139 // -----------------------------------------------------------------------------
       
   140 // TStoreContactField::SupportsLabel
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 TBool TStoreContactField::SupportsLabel() const
       
   144     {
       
   145     // Store supports label - nope
       
   146     return iContact->ParentStore().StoreProperties().SupportsFieldLabels();
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // TStoreContactField::FieldLabel
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TPtrC TStoreContactField::FieldLabel() const
       
   154     {
       
   155     return KNullDesC();
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // TStoreContactField::SetFieldLabelL
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void TStoreContactField::SetFieldLabelL(const TDesC& /*aText*/)
       
   163     {
       
   164     User::Leave(KErrNotSupported);
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // TStoreContactField::MaxLabelLength
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 TInt TStoreContactField::MaxLabelLength() const
       
   172     {
       
   173     return 0;
       
   174     }
       
   175     
       
   176 // -----------------------------------------------------------------------------
       
   177 // TStoreContactField::FieldData
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 MVPbkContactFieldData& TStoreContactField::FieldData()
       
   181     {
       
   182     return iFieldData;
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // TStoreContactField::CloneLC
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 MVPbkStoreContactField* TStoreContactField::CloneLC() const
       
   190     {
       
   191     TStoreContactField* clone = new (ELeave) TStoreContactField;
       
   192     clone->SetContact(*this->iContact);
       
   193     clone->SetField(*this->iField);
       
   194     CleanupDeletePushL(clone);
       
   195     return clone;
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // TStoreContactField::CreateLinkLC
       
   200 // -----------------------------------------------------------------------------
       
   201 //    
       
   202 MVPbkContactLink* TStoreContactField::CreateLinkLC() const
       
   203     {
       
   204     return CContactLink::NewLC(iContact->Store(),iContact->Index(),iField->Type());
       
   205     }
       
   206 
       
   207 }  // End of namespace LDAPStore
       
   208 // -----------------------------------------------------------------------------
       
   209 //  End of File
       
   210 // -----------------------------------------------------------------------------