networkprotocolmodules/privacyprotocolmodule/PrivacyProtocolModule/src/privacyshutdown.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
child 40 18280709ae43
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     1 // Copyright (c) 2007-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 <e32debug.h>
       
    17 #include "lbsdevloggermacros.h"
       
    18 #include "lbsrootapi.h"
       
    19 #include "privacyshutdown.h"
       
    20 
       
    21 
       
    22 /**
       
    23 Static public constructor
       
    24 */
       
    25 CPrivacyShutdown* CPrivacyShutdown::NewL()
       
    26 	{
       
    27 	LBSLOG(ELogP1, "CPrivacyShutdown::NewL() Begin\n");
       
    28 	CPrivacyShutdown* self = new (ELeave) CPrivacyShutdown();
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	LBSLOG(ELogP1, "CPrivacyShutdown::NewL() End\n");
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 
       
    37 /** 
       
    38 Default constructor, set the timer to standard priority by default and
       
    39 add timer to active scheduler.
       
    40 */	
       
    41 CPrivacyShutdown::CPrivacyShutdown() : CTimer(CActive::EPriorityStandard),
       
    42 	iState(EShutdownStateIdle)
       
    43 	{
       
    44 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() Begin\n");
       
    45 	CActiveScheduler::Add(this);
       
    46 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() End\n");
       
    47 	}
       
    48 
       
    49 
       
    50 /** 
       
    51 Default destructor, cancel any outstanding request of timer active object
       
    52 */	
       
    53 CPrivacyShutdown::~CPrivacyShutdown()
       
    54 	{
       
    55 	LBSLOG(ELogP1, "CPrivacyShutdown::~CPrivacyShutdown() Begin\n");
       
    56 	Cancel();
       
    57 	LBSLOG(ELogP1, "CPrivacyShutdown::~CPrivacyShutdown() End\n");
       
    58 	}
       
    59 
       
    60 
       
    61 /** 
       
    62 Call CTimer base class to construct the shut down timer
       
    63 */	
       
    64 void CPrivacyShutdown::ConstructL()
       
    65 	{
       
    66 	LBSLOG(ELogP1, "CPrivacyShutdown::ConstructL() Begin\n");
       
    67 	// call the base class version
       
    68 	CTimer::ConstructL();
       
    69 	LBSLOG(ELogP1, "CPrivacyShutdown::ConstructL() End\n");
       
    70 	}
       
    71 
       
    72 
       
    73 /** 
       
    74 Start the timer by specifying the shut down delay to issue a time request 
       
    75 
       
    76 @param aDelay Time interval in micro seconds
       
    77 */	
       
    78 void CPrivacyShutdown::Start(const TTimeIntervalMicroSeconds32 aDelay)
       
    79 	{
       
    80 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() Begin\n");
       
    81 	iState = EShutdownStateTimerStarted;
       
    82 	After(aDelay);
       
    83 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() End\n");
       
    84 	}
       
    85 
       
    86 /**
       
    87 Cancel the outstanding timeout request.
       
    88 */
       
    89 void CPrivacyShutdown::DoCancel()
       
    90 	{
       
    91 	LBSLOG(ELogP1, "CPrivacyShutdown::DoCancel() Begin\n");
       
    92 	iState = EShutdownStateIdle;
       
    93 	LBSLOG(ELogP1, "CPrivacyShutdown::DoCancel() End\n");
       
    94 	}
       
    95 	
       
    96 
       
    97 /** 
       
    98 Inherited from CActive, called when timer expires.
       
    99 Shutdown LBS.
       
   100 */	
       
   101 void CPrivacyShutdown::RunL()
       
   102 	{
       
   103 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() Begin\n");
       
   104 
       
   105 	iState = EShutdownStateShutdownRequested;
       
   106 
       
   107 	RLbsSystemController systemController;
       
   108 	RProcess process;
       
   109 	systemController.OpenL(process.SecureId());
       
   110 	CleanupClosePushL(systemController);
       
   111 	
       
   112 	systemController.RequestSystemCloseDown(ETrue);
       
   113 	
       
   114 	CleanupStack::PopAndDestroy(&systemController);
       
   115 	
       
   116 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() End\n");
       
   117 	}
       
   118 
       
   119 /** Return the current state of the shutdown timer.
       
   120 */
       
   121 CPrivacyShutdown::TShutdownState CPrivacyShutdown::State() const
       
   122 	{
       
   123 	return iState;
       
   124 	}