phonebookui/Phonebook2/UIServices/src/CPbk2ExitServiceMonitor.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Phonebook 2 UI Services exit service monitor.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2ExitServiceMonitor.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "MPbk2ConnectionObserver.h"
       
    23 #include "RPbk2UIService.h"
       
    24 
       
    25 // --------------------------------------------------------------------------
       
    26 // CPbk2ExitServiceMonitor::CPbk2ExitServiceMonitor
       
    27 // --------------------------------------------------------------------------
       
    28 //
       
    29 CPbk2ExitServiceMonitor::CPbk2ExitServiceMonitor
       
    30         ( RPbk2UIService& aPbk2AppService,
       
    31           MPbk2ConnectionObserver& aObserver ) :
       
    32             CActive( EPriorityStandard ),
       
    33             iPbk2AppService( aPbk2AppService ),
       
    34             iObserver( aObserver )
       
    35     {
       
    36     CActiveScheduler::Add( this );
       
    37     }
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // CPbk2ExitServiceMonitor::~CPbk2ExitServiceMonitor
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 CPbk2ExitServiceMonitor::~CPbk2ExitServiceMonitor()
       
    44     {
       
    45     Cancel();
       
    46     }
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CPbk2ExitServiceMonitor::NewL
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 CPbk2ExitServiceMonitor* CPbk2ExitServiceMonitor::NewL
       
    53         ( RPbk2UIService& aPbk2AppService,
       
    54           MPbk2ConnectionObserver& aObserver )
       
    55     {
       
    56     CPbk2ExitServiceMonitor* self = new ( ELeave ) CPbk2ExitServiceMonitor
       
    57         ( aPbk2AppService, aObserver );
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // --------------------------------------------------------------------------
       
    65 // CPbk2ExitServiceMonitor::ConstructL
       
    66 // --------------------------------------------------------------------------
       
    67 //
       
    68 void CPbk2ExitServiceMonitor::ConstructL()
       
    69     {
       
    70     iPbk2AppService.ExitRequestL( iStatus, iExitCommandId );
       
    71     SetActive();
       
    72     }
       
    73 
       
    74 // --------------------------------------------------------------------------
       
    75 // CPbk2ExitServiceMonitor::RunL
       
    76 // --------------------------------------------------------------------------
       
    77 //
       
    78 void CPbk2ExitServiceMonitor::RunL()
       
    79     {
       
    80     if ( iStatus.Int() == KErrNone )
       
    81         {
       
    82         // Ask it is ok to exit the server application
       
    83         TBool okToExit = iObserver.OkToExitL
       
    84             ( iExitCommandId, EPbk2ExitServiceApplication );
       
    85 
       
    86         // Always complete the notification protocol
       
    87         iPbk2AppService.ExitServiceL( okToExit, iExitCommandId );
       
    88 
       
    89         // Always request new notification
       
    90         iPbk2AppService.ExitRequestL( iStatus, iExitCommandId );
       
    91         SetActive();
       
    92         }
       
    93     else
       
    94         {
       
    95         User::Leave( iStatus.Int() );
       
    96         }
       
    97     }
       
    98 
       
    99 // --------------------------------------------------------------------------
       
   100 // CPbk2ExitServiceMonitor::RunError
       
   101 // --------------------------------------------------------------------------
       
   102 //
       
   103 TInt CPbk2ExitServiceMonitor::RunError( TInt aError )
       
   104     {
       
   105     return aError;
       
   106     }
       
   107 
       
   108 // --------------------------------------------------------------------------
       
   109 // CPbk2ExitServiceMonitor::DoCancel
       
   110 // --------------------------------------------------------------------------
       
   111 //
       
   112 void CPbk2ExitServiceMonitor::DoCancel()
       
   113     {
       
   114     iPbk2AppService.CancelExitRequest();
       
   115     }
       
   116 
       
   117 // End of File