simpledatamodeladapter/src/presenceplugincontactstatehandler.cpp
branchRCL_3
changeset 17 2669f8761a99
parent 16 2580314736af
child 18 fbd2e7cec7ef
equal deleted inserted replaced
16:2580314736af 17:2669f8761a99
     1 /*
       
     2 * Copyright (c) 2010 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:  IETF SIMPLE Protocol implementation for XIMP Framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "presenceplugincontactstatehandler.h"
       
    20 #include "presenceplugincontactstate.h"
       
    21 
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CPresencePluginContactStateHandler::CPresencePluginContactStateHandler
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CPresencePluginContactStateHandler::CPresencePluginContactStateHandler()
       
    30     : iCurrentStateIndex( 0 )
       
    31     {
       
    32     }
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CPresencePluginContactStateHandler::~CPresencePluginContactStateHandler
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CPresencePluginContactStateHandler::~CPresencePluginContactStateHandler()
       
    40     {
       
    41     iStateArray.ResetAndDestroy();
       
    42     iClientStatus = NULL;
       
    43     }
       
    44 
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CPresencePluginContactStateHandler::NewL
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CPresencePluginContactStateHandler* CPresencePluginContactStateHandler::NewL()
       
    51     {
       
    52     CPresencePluginContactStateHandler* self =
       
    53             new (ELeave) CPresencePluginContactStateHandler();
       
    54     return self;
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CPresencePluginContactStateHandler::Start
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void CPresencePluginContactStateHandler::Start( TRequestStatus* aStatus )
       
    63     {
       
    64     iClientStatus = aStatus;
       
    65     *iClientStatus = KRequestPending;
       
    66     iCurrentStateIndex = 0;
       
    67     HandleNextState();
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CPresencePluginContactStateHandler::Complete
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void CPresencePluginContactStateHandler::Complete( TInt aError )
       
    76     {
       
    77     if( iClientStatus && *iClientStatus == KRequestPending )
       
    78         {
       
    79         User::RequestComplete( iClientStatus, aError );
       
    80         }
       
    81     }
       
    82 
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CPresencePluginContactStateHandler::ProgressToNextState
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CPresencePluginContactStateHandler::ProgressToNextState()
       
    89     {
       
    90     iCurrentStateIndex++;
       
    91     HandleNextState();
       
    92     }
       
    93 
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CPresencePluginContactStateHandler::HandleNextState
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CPresencePluginContactStateHandler::HandleNextState()
       
   100     {
       
   101     TRAPD( error, State()->HandleL() );
       
   102     if ( KErrNone != error )
       
   103         {
       
   104         Complete( error );
       
   105         }
       
   106     }
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CPresencePluginContactStateHandler::AddStateL
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CPresencePluginContactStateHandler::AddStateL(
       
   114     CPresencepluginContactState* aState )
       
   115     {
       
   116     CleanupStack::PushL( aState );
       
   117     iStateArray.AppendL( aState );
       
   118     CleanupStack::Pop( aState );
       
   119     }
       
   120 
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CPresencePluginContactStateHandler::State
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 CPresencepluginContactState* CPresencePluginContactStateHandler::State()
       
   127     {
       
   128     return iStateArray[ iCurrentStateIndex ];
       
   129     }