emailcontacts/contactactionservice/src/cfscstorecontactset.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 the class CFscStoreContactSet.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCUDES
       
    20 #include "emailtrace.h"
       
    21 #include <e32std.h>
       
    22 //<cmail>
       
    23 #include "mfsccontactsetobserver.h"
       
    24 //</cmail>
       
    25 #include <MVPbkStoreContact.h>
       
    26 
       
    27 #include "cfscstorecontactset.h"
       
    28 
       
    29 // ======== LOCAL FUNCTIONS ========
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Two-phased constructor.
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CFscStoreContactSet* CFscStoreContactSet::NewL( 
       
    38     CVPbkContactManager& aVPbkContactManager,
       
    39     const RFscStoreContactList& aStoreContactList )
       
    40     {
       
    41     FUNC_LOG;
       
    42 
       
    43     CFscStoreContactSet* self = 
       
    44         new ( ELeave ) CFscStoreContactSet( aVPbkContactManager );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL( aStoreContactList );
       
    47     CleanupStack::Pop( self );
       
    48         
       
    49     return self;
       
    50     }
       
    51     
       
    52 // ---------------------------------------------------------------------------
       
    53 // Destructor.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CFscStoreContactSet::~CFscStoreContactSet()
       
    57     {
       
    58     FUNC_LOG;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Contact count.
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 TInt CFscStoreContactSet::ContactCount() const
       
    66     {
       
    67     FUNC_LOG;
       
    68     if ( iStoreContactList->Count() )
       
    69         {
       
    70         MVPbkStoreContact* store = (*iStoreContactList)[0];
       
    71         if ( !store->Group() )
       
    72             {
       
    73             return iStoreContactList->Count();
       
    74             }
       
    75         }
       
    76     return 0;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Group count.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 TInt CFscStoreContactSet::GroupCount() const
       
    84     {
       
    85     FUNC_LOG;
       
    86     if ( iStoreContactList->Count() )
       
    87         {
       
    88         MVPbkStoreContact* store = (*iStoreContactList)[0];
       
    89         if ( store->Group() )
       
    90             {
       
    91             return iStoreContactList->Count();
       
    92             }
       
    93         }
       
    94     return 0;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Checks if collection has next contact.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 TBool CFscStoreContactSet::HasNextContact() const
       
   102     {
       
   103     FUNC_LOG;
       
   104     TBool result = EFalse;
       
   105     
       
   106     if ( iCurrentStoreContact < iStoreContactList->Count() )
       
   107         {
       
   108         if ( !(*iStoreContactList)[0]->Group() )
       
   109             {
       
   110             result = ETrue;
       
   111             }
       
   112         }
       
   113     
       
   114     return result;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // Checks if collection has next group.
       
   119 // Just for interface compatibility - always EFalse.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 TBool CFscStoreContactSet::HasNextGroup() const
       
   123     {
       
   124     FUNC_LOG;
       
   125     TBool result = EFalse;
       
   126     
       
   127     if ( iCurrentStoreContact < iStoreContactList->Count() )
       
   128         {
       
   129         if ( (*iStoreContactList)[0]->Group() )
       
   130             {
       
   131             result = ETrue;
       
   132             }
       
   133         }
       
   134     
       
   135     return result;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // Sets the index to point to the first contact in the list.
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CFscStoreContactSet::SetToFirstContact()
       
   143     {
       
   144     FUNC_LOG;
       
   145     iCurrentStoreContact = 0;
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // Sets the index to point to the first group in the list.
       
   150 // Just for interface compatibility.
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void CFscStoreContactSet::SetToFirstGroup()
       
   154     {
       
   155     FUNC_LOG;
       
   156     iCurrentStoreContact = 0;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // Retrieves store contact.
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CFscStoreContactSet::NextContactL( 
       
   164     MFscContactSetObserver* aObserver )
       
   165     {
       
   166     FUNC_LOG;
       
   167     if ( HasNextContact() )
       
   168         {
       
   169         aObserver->NextContactComplete( 
       
   170                 (*iStoreContactList)[ iCurrentStoreContact++ ] );
       
   171         }
       
   172     else
       
   173         {
       
   174         aObserver->NextContactFailed( KErrArgument );
       
   175         }
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // Used for retrieving link for contact.
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 MVPbkContactLink* CFscStoreContactSet::NextContactLinkL()
       
   183     {
       
   184     FUNC_LOG;
       
   185     return NULL;
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // Retrieves store contact for group.
       
   190 // Just for interface compatibility.
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 void CFscStoreContactSet::NextGroupL( 
       
   194     MFscContactSetObserver* aObserver )
       
   195     {
       
   196     FUNC_LOG;
       
   197     if ( HasNextGroup() )
       
   198         {
       
   199         aObserver->NextGroupComplete( 
       
   200                 (*iStoreContactList)[ iCurrentStoreContact++ ] );
       
   201         }
       
   202     else
       
   203         {
       
   204         aObserver->NextGroupFailed( KErrArgument );
       
   205         }
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // Used for retrieving link for group.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 MVPbkContactLink* CFscStoreContactSet::NextGroupLinkL()
       
   213     {
       
   214     FUNC_LOG;
       
   215     return NULL;
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // Cancel NextContactL method.
       
   220 // Just for interface compatibility.
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 void CFscStoreContactSet::CancelNextContactL()
       
   224     {
       
   225     FUNC_LOG;
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // Cancel NextGroupL method.
       
   230 // Just for interface compatibility.
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 void CFscStoreContactSet::CancelNextGroupL()
       
   234     {
       
   235     FUNC_LOG;
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // Called when the operation is completed.
       
   240 // Just for interface compatibility.
       
   241 // ---------------------------------------------------------------------------
       
   242 //    
       
   243 void CFscStoreContactSet::VPbkSingleContactOperationComplete(
       
   244     MVPbkContactOperationBase& /*aOperation*/, 
       
   245     MVPbkStoreContact* /*aContact*/ )
       
   246     {
       
   247     FUNC_LOG;
       
   248     }
       
   249     
       
   250 // ---------------------------------------------------------------------------
       
   251 // Called if the operation fails.
       
   252 // Just for interface compatibility.
       
   253 // ---------------------------------------------------------------------------
       
   254 //    
       
   255 void CFscStoreContactSet::VPbkSingleContactOperationFailed(
       
   256     MVPbkContactOperationBase& /*aOperation*/, TInt /*aError*/ )
       
   257     {
       
   258     FUNC_LOG;
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // Constructor.
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 CFscStoreContactSet::CFscStoreContactSet( 
       
   266     CVPbkContactManager& aVPbkContactManager )
       
   267     : CFscContactSet( aVPbkContactManager )
       
   268     {
       
   269     FUNC_LOG;
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------------------------
       
   273 // Second phase constructor.
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 void CFscStoreContactSet::ConstructL( 
       
   277     const RFscStoreContactList& aStoreContactList )
       
   278     {
       
   279     FUNC_LOG;
       
   280     iStoreContactList = &aStoreContactList;
       
   281     }     
       
   282     
       
   283 // ======== GLOBAL FUNCTIONS ========
       
   284