ipsservices/ipssosplugin/src/ipsplgoperationwait.cpp
branchGCC_SURGE
changeset 55 cdd802add233
parent 28 011f79704660
parent 54 997a02608b3a
equal deleted inserted replaced
28:011f79704660 55:cdd802add233
     1 /*
       
     2 * Copyright (c) 2006 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: 
       
    15 *       Simple wait operation for async functions
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "emailtrace.h"
       
    21 #include "ipsplgheaders.h"
       
    22 
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CIpsPlgOperationWait* CIpsPlgOperationWait::NewL( 
       
    28     TInt aPriority )
       
    29     {
       
    30     FUNC_LOG;
       
    31     CIpsPlgOperationWait* self = CIpsPlgOperationWait::NewLC( aPriority );
       
    32     CleanupStack::Pop( self );
       
    33     return self;
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CIpsPlgOperationWait* CIpsPlgOperationWait::NewLC( 
       
    40     TInt aPriority )
       
    41     {
       
    42     FUNC_LOG;
       
    43     CIpsPlgOperationWait* self = new( ELeave ) CIpsPlgOperationWait( aPriority );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CIpsPlgOperationWait::CIpsPlgOperationWait( TInt aPriority ) : CActive( aPriority )
       
    53     {
       
    54     FUNC_LOG;
       
    55     }
       
    56     
       
    57 // ---------------------------------------------------------------------------
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CIpsPlgOperationWait::~CIpsPlgOperationWait()
       
    61     {
       
    62     FUNC_LOG;
       
    63     Cancel();
       
    64     }
       
    65     
       
    66 // ---------------------------------------------------------------------------
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void CIpsPlgOperationWait::ConstructL()
       
    70     {
       
    71     FUNC_LOG;
       
    72     CActiveScheduler::Add( this );
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CIpsPlgOperationWait::Start( )
       
    79     {
       
    80     FUNC_LOG;
       
    81     SetActive();
       
    82     iWait.Start();
       
    83     }
       
    84     
       
    85 // ---------------------------------------------------------------------------
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CIpsPlgOperationWait::DoCancel()
       
    89     {
       
    90     FUNC_LOG;
       
    91     if( iStatus == KRequestPending )
       
    92         {
       
    93         TRequestStatus* s=&iStatus;
       
    94         User::RequestComplete( s, KErrCancel );
       
    95         }
       
    96     StopScheduler();
       
    97     }
       
    98     
       
    99 // ---------------------------------------------------------------------------
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CIpsPlgOperationWait::RunL()
       
   103     {
       
   104     FUNC_LOG;
       
   105     StopScheduler();
       
   106     }
       
   107 
       
   108 void CIpsPlgOperationWait::StopScheduler()
       
   109     {
       
   110     FUNC_LOG;
       
   111     if ( iWait.IsStarted() )
       
   112         {
       
   113         /*if (iWait.CanStopNow())
       
   114             {*/
       
   115         iWait.AsyncStop();
       
   116         /*    }
       
   117         else
       
   118             {
       
   119             iWait.AsyncStop(TCallBack(SchedulerStoppedCallBack, env));
       
   120             }*/
       
   121         }
       
   122     }
       
   123