phonebookui/Phonebook2/ServerApplication/src/Pbk2ContactAssignerFactory.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Phonebook 2 contact assigner factory.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "Pbk2ContactAssignerFactory.h"
       
    21 
       
    22 // Phonebook 2
       
    23 #include "CPbk2ContactTextDataAssigner.h"
       
    24 #include "CPbk2ContactImppDataAssigner.h"
       
    25 #include "CPbk2ContactImageAssigner.h"
       
    26 #include "CPbk2ContactRingingToneAssigner.h"
       
    27 #include "CPbk2ContactEmptyDataAssigner.h"
       
    28 #include "CPbk2ContactSpeedDialAttributeAssigner.h"
       
    29 #include "CPbk2ContactSpeedDialAttributeUnassigner.h"
       
    30 #include <Pbk2MimeTypeHandler.h>
       
    31 
       
    32 // Virtual Phonebook
       
    33 #include <VPbkPublicUid.h>
       
    34 #include <TVPbkFieldVersitProperty.h>
       
    35 #include <MVPbkFieldType.h>
       
    36 
       
    37 // --------------------------------------------------------------------------
       
    38 // Pbk2ContactAssignerFactory::CreateContactDataAssignerL
       
    39 // --------------------------------------------------------------------------
       
    40 //
       
    41 MPbk2ContactAssigner*
       
    42     Pbk2ContactAssignerFactory::CreateContactDataAssignerL
       
    43         ( MPbk2ContactAssignerObserver& aObserver,
       
    44           TInt aMimeType,
       
    45           const MVPbkFieldType* aFieldType,
       
    46           CVPbkContactManager& aContactManager,
       
    47           CPbk2FieldPropertyArray& aFieldProperties )
       
    48     {
       
    49     MPbk2ContactAssigner* assigner = NULL;
       
    50 
       
    51     if ( aMimeType == Pbk2MimeTypeHandler::EMimeTypeImage )
       
    52         {
       
    53         assigner = CPbk2ContactImageAssigner::NewL
       
    54             ( aObserver, aContactManager, aFieldProperties );
       
    55         }
       
    56     else if ( ( aMimeType == Pbk2MimeTypeHandler::EMimeTypeAudio )
       
    57             || ( aMimeType == Pbk2MimeTypeHandler::EMimeTypeVideo ) )
       
    58         {
       
    59         assigner = CPbk2ContactRingingToneAssigner::NewL( aObserver );
       
    60         }
       
    61     else if ( aFieldType )
       
    62         {
       
    63         TVPbkFieldVersitProperty versitProp;
       
    64         versitProp.SetName(EVPbkVersitNameIMPP);
       
    65         if (aFieldType->Matches(versitProp, 0))
       
    66             {
       
    67             assigner = CPbk2ContactImppDataAssigner::NewL( aObserver );
       
    68             }
       
    69         else
       
    70             {
       
    71             assigner = CPbk2ContactTextDataAssigner::NewL( aObserver );
       
    72             }
       
    73         }
       
    74     else
       
    75         {
       
    76         assigner = CPbk2ContactEmptyDataAssigner::NewL( aObserver );
       
    77         }
       
    78 
       
    79     return assigner;
       
    80     }
       
    81 
       
    82 // --------------------------------------------------------------------------
       
    83 // Pbk2ContactAssignerFactory::CreateContactAttributeAssignerL
       
    84 // --------------------------------------------------------------------------
       
    85 //
       
    86 MPbk2ContactAssigner*
       
    87     Pbk2ContactAssignerFactory::CreateContactAttributeAssignerL
       
    88         ( MPbk2ContactAssignerObserver& aObserver,
       
    89           CVPbkContactManager& aContactManager,
       
    90           TPbk2AttributeAssignData aAttributeAssignData,
       
    91           TBool aAttributeRemoval )
       
    92     {
       
    93     MPbk2ContactAssigner* assigner = NULL;
       
    94 
       
    95     if ( aAttributeAssignData.iAttributeUid ==
       
    96          TUid::Uid( KVPbkSpeedDialAttributeImplementationUID ) )
       
    97         {
       
    98         if ( !aAttributeRemoval )
       
    99             {
       
   100             assigner = CPbk2ContactSpeedDialAttributeAssigner::NewL
       
   101                 ( aObserver, aContactManager );
       
   102             }
       
   103         else
       
   104             {
       
   105             assigner = CPbk2ContactSpeedDialAttributeUnassigner::NewL
       
   106                 ( aObserver, aContactManager );
       
   107             }
       
   108         }
       
   109 
       
   110     return assigner;
       
   111     }
       
   112 
       
   113 // End of File