ipsservices/ipssosplugin/src/ipsplgpropertywatcher.cpp
changeset 0 8466d47a6819
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssosplugin/src/ipsplgpropertywatcher.cpp	Thu Dec 17 08:39:21 2009 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2008 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: This file implements class CIpsPlgPropertyWatcher.
+*
+*/
+
+
+#include "emailtrace.h"
+#include "ipsplgheaders.h"
+
+// ----------------------------------------------------------------------------
+// class CIpsPlgPropertyWatcher
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CIpsPlgPropertyWatcher* CIpsPlgPropertyWatcher::NewL( 
+    TInt aPriority, 
+    CIpsPlgEventHandler& aEventHandler )
+    {
+    FUNC_LOG;
+    CIpsPlgPropertyWatcher* self = new( 
+        ELeave ) CIpsPlgPropertyWatcher( aPriority, aEventHandler );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CIpsPlgPropertyWatcher::CIpsPlgPropertyWatcher( 
+    TInt aPriority, 
+    CIpsPlgEventHandler& aEventHandler )
+    : CActive (aPriority), iEventHandler( aEventHandler )
+    {
+    FUNC_LOG;
+    }
+
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CIpsPlgPropertyWatcher::~CIpsPlgPropertyWatcher()
+    {
+    FUNC_LOG;
+    Cancel(); 
+    iProperty.Close();
+    }
+
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgPropertyWatcher::ConstructL()
+    {
+    FUNC_LOG;
+    CActiveScheduler::Add(this);
+
+    User::LeaveIfError( iProperty.Attach( KIpsPlgPropertyCatUid,
+            KIPSSosEventPropertyKey ) );
+    StartWatch();
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgPropertyWatcher::StartWatch()
+    {
+    FUNC_LOG;
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgPropertyWatcher::DoCancel()
+    {
+    FUNC_LOG;
+    iProperty.Cancel();
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgPropertyWatcher::RunL()
+    {
+    FUNC_LOG;
+    TPckgBuf<TIpsPlgPropertyEvent> event;
+    TInt error = iProperty.Get( KIpsPlgPropertyCatUid,
+            KIPSSosEventPropertyKey, event );
+    
+    if ( error == KErrNone )
+        {
+        TRAP_IGNORE( iEventHandler.NotifyPropertyEventL( event() ) );
+        }
+    
+    StartWatch();
+    }
+