phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardActiveIncremental.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Virtual Phonebook VCard active incremental
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CVPbkVCardActiveIncremental.h"
       
    20 
       
    21 CVPbkVCardActiveIncremental::CVPbkVCardActiveIncremental(
       
    22     TInt                                            aPriority, 
       
    23     MVPbkVCardIncremental&                          aIncremental,
       
    24     CVPbkVCardData&                                 aData,
       
    25     MVPbkSingleContactOperationObserver&            aObserver)
       
    26     :   CActive(aPriority), 
       
    27         iIncremental( aIncremental ),
       
    28         iData( aData ),
       
    29         iObserver( aObserver )
       
    30     {
       
    31     CActiveScheduler::Add(this);
       
    32     }
       
    33 
       
    34 void CVPbkVCardActiveIncremental::Start()
       
    35     {
       
    36     if (!IsActive())
       
    37         {
       
    38         TRequestStatus* status = &iStatus;
       
    39         User::RequestComplete(status, KErrNone);
       
    40         SetActive();
       
    41         }
       
    42     }
       
    43 
       
    44 void CVPbkVCardActiveIncremental::StartWaiting()
       
    45     {
       
    46     if (!IsActive())
       
    47         {
       
    48         TRequestStatus* status = &iStatus;
       
    49         User::RequestComplete(status, KRequestPending);
       
    50         SetActive();
       
    51         }
       
    52     }
       
    53 
       
    54 void CVPbkVCardActiveIncremental::Complete( TInt aError )
       
    55     {
       
    56     if ( IsActive() && iStatus == KRequestPending )
       
    57         {
       
    58         TRequestStatus* status = &iStatus;
       
    59         User::RequestComplete( status, aError );
       
    60         User::WaitForRequest( iStatus );
       
    61         }
       
    62     }
       
    63 
       
    64 CVPbkVCardActiveIncremental::~CVPbkVCardActiveIncremental()
       
    65     {
       
    66     CActive::Cancel();
       
    67     }
       
    68 
       
    69 void CVPbkVCardActiveIncremental::RunL()
       
    70     {
       
    71     User::LeaveIfError( iStatus.Int() );
       
    72 
       
    73     TInt steps( 0 );
       
    74     TInt retval( iIncremental.Next( steps ) );
       
    75     User::LeaveIfError( retval );
       
    76 
       
    77     if ( steps > 0 )
       
    78         {
       
    79         Start();
       
    80         }      
       
    81     else
       
    82         {
       
    83         iIncremental.CloseL();
       
    84         }
       
    85     }
       
    86 
       
    87 void CVPbkVCardActiveIncremental::DoCancel()
       
    88     {
       
    89     // do nothing
       
    90     }
       
    91 
       
    92 TInt CVPbkVCardActiveIncremental::RunError( TInt aError )
       
    93     {
       
    94     iIncremental.HandleLeave( aError );
       
    95     return KErrNone;
       
    96     }
       
    97 
       
    98 void CVPbkVCardActiveIncremental::Cancel()
       
    99     {
       
   100     CActive::Cancel();
       
   101     }
       
   102 
       
   103 void CVPbkVCardActiveIncremental::StartL()
       
   104     {
       
   105     Start();
       
   106     }
       
   107 // End of file