contentmgmt/contentaccessfwfordrm/source/cafutils/cafhelper.cpp
changeset 15 da2ae96f639b
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     1 /*
       
     2 * Copyright (c) 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 #include "cafhelper.h"
       
    20 #include "cafhelperinterface.h"
       
    21 #include <e32def.h>
       
    22 #include <e32uid.h>
       
    23 
       
    24 using namespace ContentAccess;
       
    25 
       
    26 EXPORT_C CCAFHelper* CCAFHelper::NewL()
       
    27 	{
       
    28 	CCAFHelper* self = CCAFHelper::NewLC();
       
    29 	CleanupStack::Pop(self);
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 EXPORT_C CCAFHelper* CCAFHelper::NewLC()
       
    34 	{
       
    35 	CCAFHelper* self = new (ELeave) CCAFHelper;
       
    36 	CleanupStack::PushL(self);
       
    37 	self->ConstructL();
       
    38 	return self;
       
    39 	}
       
    40 	
       
    41 CCAFHelper::CCAFHelper()
       
    42 	{
       
    43 	}
       
    44 
       
    45 void CCAFHelper::ConstructL()
       
    46 	{
       
    47 	// Dynamically load the DLL.
       
    48 	TUidType uidType(KDynamicLibraryUid, KCAFHelperInterfaceUID);
       
    49 	
       
    50 	User::LeaveIfError(iLibrary.Load(KCAFHelperLibraryName, uidType));
       
    51 	
       
    52 	// Function at ordinal 1 creates new CCAFAgentHelper.
       
    53 	TLibraryFunction entryFunc = iLibrary.Lookup(1);
       
    54 	if (entryFunc == NULL)
       
    55     	{
       
    56         iLibrary.Close();
       
    57         User::Leave(KErrBadLibraryEntryPoint);
       
    58     	}
       
    59 		
       
    60 	// Call the function to create new CCAFAgentHelper.
       
    61 	iHelper = (MCAFHelperInterface*)entryFunc();
       
    62 	}
       
    63 
       
    64 EXPORT_C MCAFHelperInterface& CCAFHelper::operator()() const
       
    65 	{
       
    66 	return *iHelper;
       
    67 	}
       
    68 	
       
    69 CCAFHelper::~CCAFHelper()
       
    70 	{
       
    71 	iHelper->Release();
       
    72 	iLibrary.Close();
       
    73 	}
       
    74