authenticationservices/authenticationserver/source/server/pluginobserver.cpp
changeset 102 deec7e509f66
parent 94 0e6c5a9328b5
child 108 ca9a0fc2f082
equal deleted inserted replaced
94:0e6c5a9328b5 102:deec7e509f66
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22  @released
       
    23 */
       
    24 
       
    25 
       
    26 #include <e32debug.h>
       
    27 #include <s32mem.h>
       
    28 #include "authserver_impl.h"
       
    29 #include "log.h"
       
    30 
       
    31 using namespace AuthServer;
       
    32 
       
    33 /**
       
    34   CPluginObserver registers for ECOM notification when new authentication plugins are added 
       
    35   or removed and updates the plugin manager accordingly. 
       
    36  
       
    37   */
       
    38 
       
    39 /** 
       
    40   Constructs a new CPluginObserver object and puts it on the cleanup stack.
       
    41   */
       
    42 
       
    43 CPluginObserver* CPluginObserver::NewLC(CPluginMgr& aPluginMgr)
       
    44 	{
       
    45 	CPluginObserver* self = new (ELeave) CPluginObserver(aPluginMgr);
       
    46 	CleanupStack::PushL(self);
       
    47 	self->ConstructL();
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 /** 
       
    52   Constructs a new CPluginObserver object.
       
    53   */
       
    54 
       
    55 CPluginObserver* CPluginObserver::NewL(CPluginMgr& aPluginMgr)
       
    56 	{
       
    57 	CPluginObserver* self = CPluginObserver::NewLC(aPluginMgr);
       
    58 	CleanupStack::Pop(self);
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 CPluginObserver::CPluginObserver(CPluginMgr& aPluginMgr) : CActive(EPriorityStandard), iPluginMgr(aPluginMgr)
       
    63 	{
       
    64 	
       
    65 	}
       
    66 
       
    67 CPluginObserver::~CPluginObserver()
       
    68 	{
       
    69 	Cancel();
       
    70 		
       
    71 	// Close our ECOM session
       
    72 	if(iEcomSession)
       
    73 		{
       
    74 		iEcomSession->CancelNotifyOnChange(iStatus);
       
    75 		iEcomSession->Close();
       
    76 		REComSession::FinalClose();
       
    77 		}
       
    78 	}
       
    79 
       
    80 void CPluginObserver::ConstructL()
       
    81 	{
       
    82 	// Add ourselves to the current active scheduler so we can get dynamic 
       
    83 	// updates when authentication plugins are removed or new plugins are added
       
    84 	CActiveScheduler::Add(this);
       
    85 	
       
    86 	iEcomSession = &REComSession::OpenL();
       
    87 	
       
    88 	// register for ECOM update notifications in case a new agent appears
       
    89 	iEcomSession->NotifyOnChange(iStatus);
       
    90 	SetActive();
       
    91 	}
       
    92 	
       
    93 void CPluginObserver::DoCancel()
       
    94 	{
       
    95 	// Abort any update notification 
       
    96 	iEcomSession->CancelNotifyOnChange(iStatus);
       
    97 	}
       
    98 
       
    99 void CPluginObserver::RunL()
       
   100 	{
       
   101 	// Leave if there has been an error
       
   102 	User::LeaveIfError(iStatus.Int());
       
   103 	
       
   104 	// the ownership is with auth server, so dont delete it.
       
   105 	iPluginMgr.BuildAuthPluginsListL();
       
   106 	
       
   107 	// request notification of any further changes
       
   108 	iEcomSession->NotifyOnChange(iStatus);
       
   109 	SetActive();
       
   110 	}
       
   111 	
       
   112 TInt CPluginObserver::RunError(TInt aError)
       
   113     {
       
   114     _LIT(KAuthError, "Authserver Panic :");
       
   115     User::Panic(KAuthError, aError);
       
   116 	    			
       
   117 	return KErrNone;
       
   118 	}
       
   119