os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/cafhelper.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/cafhelper.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,74 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "cafhelper.h"
    1.23 +#include "cafhelperinterface.h"
    1.24 +#include <e32def.h>
    1.25 +#include <e32uid.h>
    1.26 +
    1.27 +using namespace ContentAccess;
    1.28 +
    1.29 +EXPORT_C CCAFHelper* CCAFHelper::NewL()
    1.30 +	{
    1.31 +	CCAFHelper* self = CCAFHelper::NewLC();
    1.32 +	CleanupStack::Pop(self);
    1.33 +	return self;
    1.34 +	}
    1.35 +
    1.36 +EXPORT_C CCAFHelper* CCAFHelper::NewLC()
    1.37 +	{
    1.38 +	CCAFHelper* self = new (ELeave) CCAFHelper;
    1.39 +	CleanupStack::PushL(self);
    1.40 +	self->ConstructL();
    1.41 +	return self;
    1.42 +	}
    1.43 +	
    1.44 +CCAFHelper::CCAFHelper()
    1.45 +	{
    1.46 +	}
    1.47 +
    1.48 +void CCAFHelper::ConstructL()
    1.49 +	{
    1.50 +	// Dynamically load the DLL.
    1.51 +	TUidType uidType(KDynamicLibraryUid, KCAFHelperInterfaceUID);
    1.52 +	
    1.53 +	User::LeaveIfError(iLibrary.Load(KCAFHelperLibraryName, uidType));
    1.54 +	
    1.55 +	// Function at ordinal 1 creates new CCAFAgentHelper.
    1.56 +	TLibraryFunction entryFunc = iLibrary.Lookup(1);
    1.57 +	if (entryFunc == NULL)
    1.58 +    	{
    1.59 +        iLibrary.Close();
    1.60 +        User::Leave(KErrBadLibraryEntryPoint);
    1.61 +    	}
    1.62 +		
    1.63 +	// Call the function to create new CCAFAgentHelper.
    1.64 +	iHelper = (MCAFHelperInterface*)entryFunc();
    1.65 +	}
    1.66 +
    1.67 +EXPORT_C MCAFHelperInterface& CCAFHelper::operator()() const
    1.68 +	{
    1.69 +	return *iHelper;
    1.70 +	}
    1.71 +	
    1.72 +CCAFHelper::~CCAFHelper()
    1.73 +	{
    1.74 +	iHelper->Release();
    1.75 +	iLibrary.Close();
    1.76 +	}
    1.77 +