1 /* |
|
2 * Copyright (c) 2007 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 "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: Encapsulates factory plugin loading mechanism |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <ecom/ecom.h> |
|
21 //#include <alf/alfecompluginfactoryuid.rh> |
|
22 #include <alf/ialfwidgetfactory.h> |
|
23 #include <alf/ialffactoryplugin.h> |
|
24 #include <osn/osnnew.h> |
|
25 |
|
26 #include "alf/alfecompluginfactoryuid.rh" |
|
27 #include "alfwidgetfactoryloaderimpl.h" |
|
28 |
|
29 using namespace std; |
|
30 |
|
31 namespace Alf |
|
32 { |
|
33 |
|
34 static const char* const KWidgetFactory ="alfwidgetfactory"; |
|
35 const int KPluginIuid = 0x11201113; |
|
36 |
|
37 AlfWidgetFactoryLoaderImpl::AlfWidgetFactoryLoaderImpl(): |
|
38 mFactoryPlugin(0), |
|
39 mWidgetFactory(0), |
|
40 mDtorKey(0) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 AlfWidgetFactoryLoaderImpl::~AlfWidgetFactoryLoaderImpl() |
|
46 { |
|
47 delete mWidgetFactory; |
|
48 if (mFactoryPlugin) |
|
49 { |
|
50 delete mFactoryPlugin; |
|
51 REComSession::DestroyedImplementation(TUid::Uid(mDtorKey)); |
|
52 } |
|
53 |
|
54 } |
|
55 |
|
56 IAlfWidgetFactory* AlfWidgetFactoryLoaderImpl::load(CAlfEnv& aEnv) |
|
57 { |
|
58 if (!mWidgetFactory) |
|
59 { |
|
60 TEComResolverParams resolverParams; |
|
61 resolverParams.SetDataType(TPtrC8((TUint8*)KWidgetFactory)); |
|
62 resolverParams.SetWildcardMatch(ETrue); |
|
63 |
|
64 TAny* plugin = NULL; |
|
65 |
|
66 TUid tmpDtor; |
|
67 |
|
68 TRAPD(err,plugin = REComSession::CreateImplementationL( |
|
69 TUid::Uid(KPluginIuid),tmpDtor, |
|
70 resolverParams)) |
|
71 |
|
72 |
|
73 if (!err) |
|
74 { |
|
75 mDtorKey = tmpDtor.iUid; |
|
76 mFactoryPlugin = reinterpret_cast<IAlfFactoryPlugin*>(plugin); |
|
77 IAlfInterfaceBase* tmp(0); |
|
78 tmp = mFactoryPlugin->createProduct(KWidgetFactory,&aEnv); |
|
79 mWidgetFactory = |
|
80 IAlfInterfaceBase::makeInterface<IAlfWidgetFactory>(tmp); |
|
81 } |
|
82 } |
|
83 |
|
84 return mWidgetFactory; |
|
85 } |
|
86 |
|
87 } |
|
88 |
|
89 |
|
90 // End of File |
|
91 |
|