messagingapp/msgsettings/msginit/src/startupmonitor.cpp
changeset 31 ebfee66fde93
parent 23 238255e8b033
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgsettings/msginit/src/startupmonitor.cpp	Fri Jun 04 10:25:39 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*       CStartUpMonitor implementation file
+*
+*/
+
+
+// INCLUDE FILES
+#include <startupdomainpskeys.h>
+#include "simscnumberdetector.h"
+#include "startupmonitor.h"
+
+// CONSTANTS
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CStartUpMonitor::CStartUpMonitor
+//
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CStartUpMonitor::CStartUpMonitor( CMsgSimOperation* aWatcher )
+    : CActive( CActive::EPriorityStandard ),
+    iWatcher( aWatcher )
+    {    
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CStartUpMonitor::ConstructL()
+//
+// Symbian OS default constructor can leave.
+// ---------------------------------------------------------
+//
+void CStartUpMonitor::ConstructL()
+    {
+  
+    User::LeaveIfError( iStartupProperty.Attach( KPSUidStartup, KPSGlobalSystemState ) );
+    // Complete self
+    iStatus = KRequestPending;
+    TRequestStatus* pStatus = &iStatus;
+    SetActive();
+    User::RequestComplete( pStatus, KErrNone );
+  
+    }
+
+// ---------------------------------------------------------
+// CStartUpMonitor::NewL
+//
+// Two-phased constructor.
+// ---------------------------------------------------------
+//
+CStartUpMonitor* CStartUpMonitor::NewL( CMsgSimOperation* aWatcher )
+    {
+    
+    CStartUpMonitor* self = new ( ELeave )
+        CStartUpMonitor( aWatcher );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CStartUpMonitor::~CStartUpMonitor
+//
+// Destructor
+// ---------------------------------------------------------
+//
+CStartUpMonitor::~CStartUpMonitor()
+    {
+    Cancel();
+    }
+
+// ---------------------------------------------------------
+// CStartUpMonitor::DoCancel
+//
+// From active object framework
+// ---------------------------------------------------------
+//
+void CStartUpMonitor::DoCancel()
+    {
+    iStartupProperty.Cancel();
+    }
+
+// ---------------------------------------------------------
+// CStartUpMonitor::RunL
+//
+// From active object framework
+// ---------------------------------------------------------
+//
+void CStartUpMonitor::RunL()
+    {
+
+    TInt startupState = 0;
+    iStartupProperty.Get( startupState );
+
+    if ( startupState == ESwStateNormalRfOn ||
+        startupState == ESwStateNormalRfOff ||
+        startupState == ESwStateNormalBTSap )
+        {
+        iWatcher->HandleStartupReadyL();       
+        }
+    else
+        {
+        iStatus = KRequestPending;
+        iStartupProperty.Subscribe( iStatus );
+        SetActive();
+        }
+
+    }
+
+//  End of File