phonebookengines/VirtualPhonebook/VPbkCntModel/src/CContactView.cpp
branchRCL_3
changeset 63 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Contacts Model store contact view implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CContactView.h"
       
    20 
       
    21 // VPbkCntModel
       
    22 #include "CContactStore.h"
       
    23 #include "CFieldFactory.h"
       
    24 #include "CContact.h"
       
    25 #include "CFieldTypeList.h"
       
    26 #include "CContactLink.h"
       
    27 #include "VPbkCntModelRemoteViewPreferences.h"
       
    28 #include "NamedRemoteViewViewDefinitionStoreUtility.h"
       
    29 
       
    30 // VPbkEng
       
    31 #include <MVPbkContactViewObserver.h>
       
    32 #include <MVPbkFieldType.h>
       
    33 #include <VPbkError.h>
       
    34 #include <CVPbkSortOrder.h>
       
    35 #include <CVPbkAsyncCallback.h>
       
    36 
       
    37 // System includes
       
    38 #include <cntitem.h>
       
    39 
       
    40 
       
    41 namespace VPbkCntModel {
       
    42 
       
    43 /// Unnamed namespace for local definitions
       
    44 namespace {
       
    45 
       
    46 } /// namespace
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CContactView::CContactView
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 inline CContactView::CContactView( 
       
    53         CContactStore& aParentStore ) :
       
    54     CViewBase( aParentStore )
       
    55     {
       
    56     }
       
    57 
       
    58 // --------------------------------------------------------------------------
       
    59 // CContactView::~CContactView
       
    60 // --------------------------------------------------------------------------
       
    61 //
       
    62 CContactView::~CContactView()
       
    63     {
       
    64     }
       
    65 
       
    66 // --------------------------------------------------------------------------
       
    67 // CContactView::NewLC
       
    68 // --------------------------------------------------------------------------
       
    69 //
       
    70 CContactView* CContactView::NewLC(
       
    71         const CVPbkContactViewDefinition& aViewDefinition,
       
    72         MVPbkContactViewObserver& aObserver,
       
    73         CContactStore& aParentStore, 
       
    74         const MVPbkFieldTypeList& aSortOrder )
       
    75     {
       
    76     CContactView* self = new ( ELeave ) CContactView( aParentStore );
       
    77     CleanupStack::PushL( self );
       
    78     self->ConstructL( aViewDefinition, aObserver, aSortOrder );
       
    79     return self;
       
    80     }
       
    81 
       
    82 // --------------------------------------------------------------------------
       
    83 // CContactView::ConstructL
       
    84 // --------------------------------------------------------------------------
       
    85 //
       
    86 void CContactView::ConstructL(
       
    87         const CVPbkContactViewDefinition& aViewDefinition,
       
    88         MVPbkContactViewObserver& aObserver, 
       
    89         const MVPbkFieldTypeList& aSortOrder )
       
    90     {
       
    91     CViewBase::ConstructL( aViewDefinition, aObserver, aSortOrder );
       
    92     }
       
    93 
       
    94 // --------------------------------------------------------------------------
       
    95 // CContactView::Type
       
    96 // --------------------------------------------------------------------------
       
    97 //
       
    98 TVPbkContactViewType CContactView::Type() const
       
    99     {
       
   100     return EVPbkContactsView;
       
   101     }
       
   102 
       
   103 // --------------------------------------------------------------------------
       
   104 // CContactView::DoInitializeViewL
       
   105 // --------------------------------------------------------------------------
       
   106 //
       
   107 void CContactView::DoInitializeViewL(
       
   108         const CVPbkContactViewDefinition& aViewDefinition,
       
   109         RContactViewSortOrder& aViewSortOrder )
       
   110     {
       
   111     if ( RemoteViewDefinition( aViewDefinition ) )
       
   112         {
       
   113         iRemoteView = CContactNamedRemoteView::NewL( 
       
   114                 *this, RemoteViewName( aViewDefinition ), 
       
   115                 Store().NativeDatabase(), aViewSortOrder, 
       
   116                 KVPbkDefaultContactViewPrefs );
       
   117                 
       
   118         iView = iRemoteView;
       
   119         }
       
   120     else
       
   121         {
       
   122         iView = CContactLocalView::NewL( *this, Store().NativeDatabase(), 
       
   123                 aViewSortOrder, KVPbkDefaultContactViewPrefs );
       
   124         }
       
   125     }
       
   126 
       
   127 // --------------------------------------------------------------------------
       
   128 // CContactView::DoTeardownView
       
   129 // --------------------------------------------------------------------------
       
   130 //
       
   131 void CContactView::DoTeardownView()
       
   132     {
       
   133     /// Do nothing
       
   134     }
       
   135 
       
   136 // --------------------------------------------------------------------------
       
   137 // CContactView::DoChangeSortOrderL
       
   138 // --------------------------------------------------------------------------
       
   139 //
       
   140 TBool CContactView::DoChangeSortOrderL(
       
   141         const CVPbkContactViewDefinition& aViewDefinition,
       
   142         RContactViewSortOrder& aSortOrder )
       
   143     {
       
   144     TBool canBeChanged = ETrue;
       
   145     if ( iRemoteView )
       
   146         {
       
   147         if ( RemoteViewName( aViewDefinition ).Compare( 
       
   148                 KVPbkAllContactsViewName ) == 0 )
       
   149             {
       
   150             // Set Contacts Model default view setting only if client
       
   151             // is using KVPbkAllContactsViewName shared view.
       
   152             NamedRemoteViewViewDefinitionStoreUtility::
       
   153                 SetNamedRemoteViewViewDefinitionL(
       
   154                     KVPbkAllContactsViewName, aSortOrder, 
       
   155                     KVPbkDefaultContactViewPrefs);
       
   156             }
       
   157         iRemoteView->ChangeSortOrderL( aSortOrder );
       
   158         
       
   159         }
       
   160     else
       
   161         {
       
   162         // CContactLocalView doesn't support ChangeSortOrderL
       
   163         canBeChanged = EFalse;
       
   164         }
       
   165     return canBeChanged;
       
   166     }
       
   167 
       
   168 } // namespace VPbkCntModel
       
   169 
       
   170 // End of File