networkprotocolmodules/privacyprotocolmodule/PrivacyProtocolModule/src/privacyshutdown.cpp
changeset 57 3267d9ea3e98
parent 0 9cfd9a3ee49c
child 55 c92d4f3c47c5
equal deleted inserted replaced
48:81c9bee26a45 57:3267d9ea3e98
    15 
    15 
    16 #include <e32debug.h>
    16 #include <e32debug.h>
    17 #include "lbsdevloggermacros.h"
    17 #include "lbsdevloggermacros.h"
    18 #include "lbsrootapi.h"
    18 #include "lbsrootapi.h"
    19 #include "privacyshutdown.h"
    19 #include "privacyshutdown.h"
       
    20 
       
    21 
       
    22 // P&S Key we check how many outstanding requests there are
       
    23 const TInt EPrivacyNumberOfRequest = 0x1028720F;
    20 
    24 
    21 
    25 
    22 /**
    26 /**
    23 Static public constructor
    27 Static public constructor
    24 */
    28 */
    37 /** 
    41 /** 
    38 Default constructor, set the timer to standard priority by default and
    42 Default constructor, set the timer to standard priority by default and
    39 add timer to active scheduler.
    43 add timer to active scheduler.
    40 */	
    44 */	
    41 CPrivacyShutdown::CPrivacyShutdown() : CTimer(CActive::EPriorityStandard),
    45 CPrivacyShutdown::CPrivacyShutdown() : CTimer(CActive::EPriorityStandard),
    42 	iState(EShutdownStateIdle)
    46 	iState(EShutdownStateIdle),
       
    47 	iTimerCount(0)
    43 	{
    48 	{
    44 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() Begin\n");
    49 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() Begin\n");
    45 	CActiveScheduler::Add(this);
    50 	CActiveScheduler::Add(this);
    46 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() End\n");
    51 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() End\n");
    47 	}
    52 	}
    77 */	
    82 */	
    78 void CPrivacyShutdown::Start(const TTimeIntervalMicroSeconds32 aDelay)
    83 void CPrivacyShutdown::Start(const TTimeIntervalMicroSeconds32 aDelay)
    79 	{
    84 	{
    80 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() Begin\n");
    85 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() Begin\n");
    81 	iState = EShutdownStateTimerStarted;
    86 	iState = EShutdownStateTimerStarted;
       
    87 	iTimerCount = aDelay;
    82 	After(aDelay);
    88 	After(aDelay);
    83 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() End\n");
    89 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() End\n");
    84 	}
    90 	}
    85 
    91 
    86 /**
    92 /**
   100 */	
   106 */	
   101 void CPrivacyShutdown::RunL()
   107 void CPrivacyShutdown::RunL()
   102 	{
   108 	{
   103 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() Begin\n");
   109 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() Begin\n");
   104 
   110 
   105 	iState = EShutdownStateShutdownRequested;
   111 	// Check if there are any notifications outstanding
   106 
   112 	TInt outstandingRequests = 0;
   107 	RLbsSystemController systemController;
   113     RProperty::Get(KUidSystemCategory, EPrivacyNumberOfRequest, outstandingRequests);
   108 	RProcess process;
   114     if (outstandingRequests > 0)
   109 	systemController.OpenL(process.SecureId());
   115         {
   110 	CleanupClosePushL(systemController);
   116         LBSLOG(ELogP1, "CPrivacyShutdown::RunL() - Restarting Timer\n")
   111 	
   117         Start(iTimerCount);
   112 	systemController.RequestSystemCloseDown(ETrue);
   118         }
   113 	
   119     else
   114 	CleanupStack::PopAndDestroy(&systemController);
   120         {
       
   121         iState = EShutdownStateShutdownRequested;
       
   122     
       
   123         RLbsSystemController systemController;
       
   124         RProcess process;
       
   125         systemController.OpenL(process.SecureId());
       
   126         CleanupClosePushL(systemController);
       
   127         
       
   128         systemController.RequestSystemCloseDown(ETrue);
       
   129         
       
   130         CleanupStack::PopAndDestroy(&systemController);
       
   131         }
   115 	
   132 	
   116 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() End\n");
   133 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() End\n");
   117 	}
   134 	}
   118 
   135 
   119 /** Return the current state of the shutdown timer.
   136 /** Return the current state of the shutdown timer.