profilesservices/ProfileEngine/WrapperSrc/CProEngProfileActivationDelegate.cpp
changeset 0 8c5d936e5675
child 8 f62c3a3d66b8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/profilesservices/ProfileEngine/WrapperSrc/CProEngProfileActivationDelegate.cpp	Thu Dec 17 08:52:52 2009 +0200
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2002-2004 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:  Implementation of CProEngProfileActivationDelegate.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "CProEngProfileActivationDelegate.h"
+#include    <centralrepository.h>
+#include    <MProEngProfileActivationObserver.h>
+#include    "ProfileEnginePrivatePSKeys.h"  // KProEngActiveProfileChanged
+#include    "ProfileEngineSDKCRKeys.h" // KCRUidProfileEngine etc.
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CProEngProfileActivationDelegate::CProEngProfileActivationDelegate
+// -----------------------------------------------------------------------------
+//
+CProEngProfileActivationDelegate::CProEngProfileActivationDelegate(
+        MProEngProfileActivationObserver& aObserver )
+    : CProEngPubSubObserverBase( KProEngActiveProfileChanged ),
+      iObserver( aObserver )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CProEngProfileActivationDelegate::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CProEngProfileActivationDelegate::ConstructL()
+    {
+    iRepository = CRepository::NewL( KCRUidProfileEngine );
+    }
+
+// -----------------------------------------------------------------------------
+// CProEngProfileActivationDelegate::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CProEngProfileActivationDelegate* CProEngProfileActivationDelegate::NewL(
+        MProEngProfileActivationObserver& aObserver )
+    {
+    CProEngProfileActivationDelegate* self =
+        new ( ELeave ) CProEngProfileActivationDelegate( aObserver );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CProEngProfileActivationDelegate::~CProEngProfileActivationDelegate
+// -----------------------------------------------------------------------------
+//
+CProEngProfileActivationDelegate::~CProEngProfileActivationDelegate()
+    {
+    delete iRepository;
+    }
+
+// -----------------------------------------------------------------------------
+// CProEngProfileActivationDelegate::NotifyObserverL
+// -----------------------------------------------------------------------------
+//
+void CProEngProfileActivationDelegate::NotifyObserverL()
+    {
+    // Read the id of the current active profile and pass it to the observer
+    TInt profileId( 0 );
+    User::LeaveIfError( iRepository->Get( KProEngActiveProfile, profileId ) );
+    iObserver.HandleProfileActivatedL( profileId );
+    }
+
+// -----------------------------------------------------------------------------
+// CProEngProfileActivationDelegate::NotifyError
+// -----------------------------------------------------------------------------
+//
+void CProEngProfileActivationDelegate::NotifyError( TInt aError )
+    {
+    iObserver.HandleProfileActivationNotificationError( aError );
+    }
+
+//  End of File
+