|
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: AlfContainerWidgetFactoryPlugin implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <osn/osnnew.h> |
|
19 #include <ecom/implementationproxy.h> |
|
20 #include "alf/ialfcontainerwidget.h" |
|
21 #include "alf/alfwidget.h" |
|
22 #include <libc/string.h> |
|
23 #include "alfcontainerwidget.h" |
|
24 #include "alfcontainerwidgetexception.h" |
|
25 #include "alfcontainerwidgetfactoryplugin.h" |
|
26 |
|
27 using namespace Alf; |
|
28 |
|
29 // UID of the container widget factory plugin. |
|
30 const TInt KContainerWidgetFactoryPluginUid = {0x200100FF}; |
|
31 |
|
32 // Amount of products produced by this factory. |
|
33 const int KProductCount = 1; |
|
34 |
|
35 AlfContainerWidgetFactoryPlugin* AlfContainerWidgetFactoryPlugin::newL() |
|
36 { |
|
37 return new (ELeave) AlfContainerWidgetFactoryPlugin(); |
|
38 } |
|
39 |
|
40 IAlfInterfaceBase* AlfContainerWidgetFactoryPlugin::createProduct(const char* aProduct, void* aInitData) |
|
41 { |
|
42 IAlfInterfaceBase* ret(0); |
|
43 |
|
44 if(!strcmp(aProduct, IAlfContainerWidget::type().mImplementationId)) |
|
45 { |
|
46 // Typecast the initialization data |
|
47 AlfWidgetInitData* initData = (AlfWidgetInitData*) aInitData; |
|
48 |
|
49 // Throw exception if init data is null |
|
50 if(initData == 0) |
|
51 { |
|
52 ALF_THROW(AlfContainerWidgetException, EInitializationError, "Container widget initialization data was NULL."); |
|
53 } |
|
54 |
|
55 // Assert that widget id in the initialization data is correct. |
|
56 if(initData->mWidgetId == 0) |
|
57 { |
|
58 ALF_THROW(AlfContainerWidgetException, EInitializationError, "Widget ID was NULL."); |
|
59 } |
|
60 |
|
61 // Assert that the UI Accelerator Toolkit Environment in the initialization data is correct. |
|
62 if(initData->mEnv == 0) |
|
63 { |
|
64 ALF_THROW(AlfContainerWidgetException, EInitializationError, "Environment instance was NULL."); |
|
65 } |
|
66 |
|
67 // Assert that container widget pointer in the initialization data is correct. |
|
68 if(initData->mContainerWidget == 0) |
|
69 { |
|
70 ALF_THROW(AlfContainerWidgetException, EInitializationError, "Container widget instance was NULL."); |
|
71 } |
|
72 |
|
73 // Create container widget |
|
74 ret = new (EMM) AlfContainerWidget( |
|
75 initData->mWidgetId, *initData->mContainerWidget, *initData->mEnv, initData->mNode, initData->mFilePath); |
|
76 } |
|
77 |
|
78 return ret; |
|
79 } |
|
80 |
|
81 int AlfContainerWidgetFactoryPlugin::productCount() const |
|
82 { |
|
83 return KProductCount; |
|
84 } |
|
85 |
|
86 const char* AlfContainerWidgetFactoryPlugin::productInfo(int aIndex) const |
|
87 { |
|
88 switch(aIndex) |
|
89 { |
|
90 case 0: return ialfcontainerwidget::ident.mImplementationId; |
|
91 default: break; |
|
92 } |
|
93 |
|
94 return 0; |
|
95 } |
|
96 |
|
97 IAlfInterfaceBase* AlfContainerWidgetFactoryPlugin::makeInterface(const IfId& aType) |
|
98 { |
|
99 if(!strcmp(aType.mImplementationId, IAlfFactoryPlugin::type().mImplementationId)) |
|
100 { |
|
101 return static_cast<IAlfFactoryPlugin*>(this); |
|
102 } |
|
103 |
|
104 return 0; |
|
105 } |
|
106 |
|
107 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
108 |
|
109 const TImplementationProxy ImplementationTable[] = |
|
110 { |
|
111 IMPLEMENTATION_PROXY_ENTRY( KContainerWidgetFactoryPluginUid, |
|
112 AlfContainerWidgetFactoryPlugin::newL ) |
|
113 }; |
|
114 |
|
115 // Entry point for ECom architecture to resolve the instantiation method pointer |
|
116 // for a given implementation UID. |
|
117 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
118 { |
|
119 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
120 return ImplementationTable; |
|
121 } |