phonebookui/Phonebook2/remotecontactlookup/contactactionservice/src/cfsccontactset.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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 the class CFscContactSet.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCUDES
       
    20 #include "emailtrace.h"
       
    21 #include <e32std.h>
       
    22 #include <CVPbkContactManager.h>
       
    23 #include <MVPbkContactGroup.h>
       
    24 #include <MVPbkContactLinkArray.h>
       
    25 #include <MVPbkContactOperationBase.h>
       
    26 #include "mfsccontactsetobserver.h"
       
    27 
       
    28 #include "cfsccontactset.h"
       
    29 
       
    30 // ======== LOCAL FUNCTIONS ========
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // Constructor.
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CFscContactSet::CFscContactSet( CVPbkContactManager& aVPbkContactManager )
       
    40     : iVPbkContactManager( aVPbkContactManager )
       
    41     {
       
    42     FUNC_LOG;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Destructor.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CFscContactSet::~CFscContactSet()
       
    50     {
       
    51     FUNC_LOG;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Contact count of group.
       
    56 // ---------------------------------------------------------------------------
       
    57 //    
       
    58 TInt CFscContactSet::GroupContactCountL( MVPbkStoreContact& aStoreContact )
       
    59     {
       
    60     FUNC_LOG;
       
    61     TInt result = 0;
       
    62     
       
    63     MVPbkContactGroup* group = aStoreContact.Group();
       
    64     
       
    65     if ( group )
       
    66         {
       
    67         MVPbkContactLinkArray* array = group->ItemsContainedLC(); 
       
    68         result = array->Count();
       
    69         CleanupStack::PopAndDestroy();
       
    70         }
       
    71     
       
    72     return result;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Asynchronous operation for retrieving contact from group.
       
    77 // ---------------------------------------------------------------------------
       
    78 //    
       
    79 void CFscContactSet::GetGroupContactL( MVPbkStoreContact& aStoreContact, 
       
    80     TInt aIndex, MFscContactSetObserver* aObserver )
       
    81     {
       
    82     FUNC_LOG;
       
    83     MVPbkContactGroup* group = aStoreContact.Group();
       
    84     
       
    85     iObserver = aObserver;
       
    86     
       
    87     if ( group )
       
    88         {
       
    89         iContactLinkArray = group->ItemsContainedLC();
       
    90         CleanupStack::Pop();
       
    91         
       
    92         if ( aIndex < iContactLinkArray->Count() )
       
    93             {
       
    94             const MVPbkContactLink& link = iContactLinkArray->At( aIndex );
       
    95             iVPbkOperationGetGroupContact = 
       
    96                 iVPbkContactManager.RetrieveContactL( link, *this );
       
    97             }
       
    98         else
       
    99             {
       
   100             iObserver->GetGroupContactFailed( KErrArgument );
       
   101             }
       
   102         }
       
   103     else
       
   104         {
       
   105         iObserver->GetGroupContactFailed( KErrArgument );
       
   106         }
       
   107     }
       
   108