browserplugins/browsersysteminfoplugin/src/SystemInfoObserver.cpp
branchRCL_3
changeset 48 8e6fa1719340
parent 0 84ad3b177aa3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/browserplugins/browsersysteminfoplugin/src/SystemInfoObserver.cpp	Wed Sep 01 12:31:04 2010 +0100
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "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: 
+*
+*/
+
+
+// INCLUDE FILES
+#include "SystemInfoObserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::CSystemInfoObserver
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+CSystemInfoObserver* CSystemInfoObserver::NewL( MSystemInfoObserverClient* aClient, TInt aId )
+    {
+    CSystemInfoObserver* self = new ( ELeave ) CSystemInfoObserver( aClient, aId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::CSystemInfoObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+CSystemInfoObserver::CSystemInfoObserver( MSystemInfoObserverClient* aClient, TInt aId )
+    : CActive( EPriorityStandard ),
+      iClient( aClient ),
+      iId( aId )
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+void CSystemInfoObserver::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::~CSystemInfoObserver()
+// Destructor
+// -----------------------------------------------------------------------------
+CSystemInfoObserver::~CSystemInfoObserver()
+    {
+    Cancel();
+    if ( iClient )
+      {
+        iClient->Close( iId );
+      }
+    }
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::RequestNotification
+// -----------------------------------------------------------------------------
+void CSystemInfoObserver::RequestNotificationL()
+    {
+    if ( !IsActive() )
+        {
+        iClient->SubscribeL( iId, iStatus );
+        SetActive();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::RunL
+// -----------------------------------------------------------------------------
+void CSystemInfoObserver::RunL()
+    {
+    if( iStatus == KErrNone )
+       {
+       iClient->UpdateL( iId );
+       iClient->SubscribeL( iId, iStatus );  // FUTURE consider letting client decide if to do this
+       SetActive();
+       }
+    }
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::RunError
+// -----------------------------------------------------------------------------
+TInt CSystemInfoObserver::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CSystemInfoObserver::DoCancel
+// -----------------------------------------------------------------------------
+void CSystemInfoObserver::DoCancel()
+    {
+    iClient->Cancel( iId );
+    }
+
+//  End of File