networkprotocolmodules/privacyprotocolmodule/PrivacyProtocolModule/src/privacyshutdown.cpp
changeset 57 3267d9ea3e98
parent 0 9cfd9a3ee49c
child 55 c92d4f3c47c5
--- a/networkprotocolmodules/privacyprotocolmodule/PrivacyProtocolModule/src/privacyshutdown.cpp	Tue Jul 13 12:25:28 2010 +0100
+++ b/networkprotocolmodules/privacyprotocolmodule/PrivacyProtocolModule/src/privacyshutdown.cpp	Wed Sep 08 15:16:57 2010 +0100
@@ -19,6 +19,10 @@
 #include "privacyshutdown.h"
 
 
+// P&S Key we check how many outstanding requests there are
+const TInt EPrivacyNumberOfRequest = 0x1028720F;
+
+
 /**
 Static public constructor
 */
@@ -39,7 +43,8 @@
 add timer to active scheduler.
 */	
 CPrivacyShutdown::CPrivacyShutdown() : CTimer(CActive::EPriorityStandard),
-	iState(EShutdownStateIdle)
+	iState(EShutdownStateIdle),
+	iTimerCount(0)
 	{
 	LBSLOG(ELogP1, "CPrivacyShutdown::CPrivacyShutdown() Begin\n");
 	CActiveScheduler::Add(this);
@@ -79,6 +84,7 @@
 	{
 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() Begin\n");
 	iState = EShutdownStateTimerStarted;
+	iTimerCount = aDelay;
 	After(aDelay);
 	LBSLOG(ELogP1, "CPrivacyShutdown::Start() End\n");
 	}
@@ -102,16 +108,27 @@
 	{
 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() Begin\n");
 
-	iState = EShutdownStateShutdownRequested;
-
-	RLbsSystemController systemController;
-	RProcess process;
-	systemController.OpenL(process.SecureId());
-	CleanupClosePushL(systemController);
-	
-	systemController.RequestSystemCloseDown(ETrue);
-	
-	CleanupStack::PopAndDestroy(&systemController);
+	// Check if there are any notifications outstanding
+	TInt outstandingRequests = 0;
+    RProperty::Get(KUidSystemCategory, EPrivacyNumberOfRequest, outstandingRequests);
+    if (outstandingRequests > 0)
+        {
+        LBSLOG(ELogP1, "CPrivacyShutdown::RunL() - Restarting Timer\n")
+        Start(iTimerCount);
+        }
+    else
+        {
+        iState = EShutdownStateShutdownRequested;
+    
+        RLbsSystemController systemController;
+        RProcess process;
+        systemController.OpenL(process.SecureId());
+        CleanupClosePushL(systemController);
+        
+        systemController.RequestSystemCloseDown(ETrue);
+        
+        CleanupStack::PopAndDestroy(&systemController);
+        }
 	
 	LBSLOG(ELogP1, "CPrivacyShutdown::RunL() End\n");
 	}