mtpfws/mtpfw/daemon/server/src/cmtpshutdown.cpp
changeset 0 d0791faffa3f
child 1 f8e15b44d440
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32std.h>
       
    17 
       
    18 #include "cmtpshutdown.h"
       
    19 #include "cmtpdataprovidercontroller.h"
       
    20 
       
    21 
       
    22 /**
       
    23 CMTPShutdown factory method. 
       
    24 @return A pointer to a new CMTPShutdown instance. Ownership IS transfered.
       
    25 @leave One of the system wide error codes if a processing failure occurs.
       
    26 */
       
    27 CMTPShutdown* CMTPShutdown::NewL()
       
    28     {
       
    29     CMTPShutdown* self = new (ELeave) CMTPShutdown;
       
    30     CleanupStack::PushL(self);
       
    31     self->ConstructL();
       
    32     CleanupStack::Pop(self);
       
    33     return self;
       
    34     }
       
    35     
       
    36 /**
       
    37 Destructor.
       
    38 */
       
    39 CMTPShutdown::~CMTPShutdown()
       
    40     {
       
    41     Cancel();
       
    42     iSingletons.Close();
       
    43     }
       
    44     
       
    45 /**
       
    46 Starts the shutdown timer.
       
    47 */   
       
    48 void CMTPShutdown::Start()
       
    49     {
       
    50     // Shutdown delay, in microseconds.
       
    51     const TUint KMTPShutdownDelay = (1000000 * 5);
       
    52     After(KMTPShutdownDelay);
       
    53     }
       
    54     
       
    55 void CMTPShutdown::RunL()
       
    56     {
       
    57     if ( iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated )
       
    58         {
       
    59         Start();
       
    60         }
       
    61     else
       
    62         {
       
    63         CActiveScheduler::Stop();
       
    64         }
       
    65     }
       
    66     
       
    67 /** 
       
    68 Constructor
       
    69 */
       
    70 CMTPShutdown::CMTPShutdown() : 
       
    71     CTimer(EPriorityNormal)
       
    72     {
       
    73     
       
    74     }    
       
    75 
       
    76 /**
       
    77 Second phase constructor.
       
    78 */    
       
    79 void CMTPShutdown::ConstructL()
       
    80     {
       
    81     CTimer::ConstructL();
       
    82     iSingletons.OpenL();
       
    83     CActiveScheduler::Add(this);
       
    84     }