|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // System include files |
|
19 #include <ecom/ecom.h> |
|
20 #include <ecom/implementationinformation.h> |
|
21 |
|
22 // User include files |
|
23 #include "hscontentcontrolfactory.h" |
|
24 |
|
25 // Local constants |
|
26 |
|
27 // TODO: Content controller ECom interface UID |
|
28 const TUid KInterfaceUidContentController = { 0x20026F51 }; |
|
29 |
|
30 // ======== LOCAL FUNCTIONS ======== |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CleanupResetAndDestroy() |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 template<class T> |
|
37 static void CleanupResetAndDestroy( TAny* aObj ) |
|
38 { |
|
39 if( aObj ) |
|
40 { |
|
41 static_cast<T*>( aObj )->ResetAndDestroy(); |
|
42 } |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CleanupResetAndDestroyPushL |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 template<class T> |
|
50 static void CleanupResetAndDestroyPushL(T& aArray) |
|
51 { |
|
52 CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) ); |
|
53 } |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CHsContentControlFactory::NewL() |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CHsContentControlFactory* CHsContentControlFactory::NewL() |
|
62 { |
|
63 CHsContentControlFactory* self = new ( ELeave ) CHsContentControlFactory(); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // CHsContentControlFactory::ConstructL() |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 void CHsContentControlFactory::ConstructL() |
|
75 { |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------------------------- |
|
79 // CHsContentControlFactory::CHsContentControlFactory() |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 CHsContentControlFactory::CHsContentControlFactory() |
|
83 { |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // CHsContentControlFactory::~CHsContentControlFactory() |
|
88 // ---------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C CHsContentControlFactory::~CHsContentControlFactory() |
|
91 { |
|
92 iHsContentControlUis.ResetAndDestroy(); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------------- |
|
96 // CHsContentControlFactory::GetHsContentController() |
|
97 // --------------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C MHsContentControlUi* CHsContentControlFactory::GetHsContentController( |
|
100 const TDesC8& aControlType ) |
|
101 { |
|
102 MHsContentControlUi* retval( FindHsContentController( aControlType ) ); |
|
103 |
|
104 if ( !retval ) |
|
105 { |
|
106 TRAP_IGNORE( |
|
107 // Get implementations via ECom |
|
108 RImplInfoPtrArray plugins; |
|
109 CleanupResetAndDestroyPushL( plugins ); |
|
110 |
|
111 REComSession::ListImplementationsL( |
|
112 KInterfaceUidContentController, plugins ); |
|
113 |
|
114 for ( TInt i = 0; i < plugins.Count(); i++ ) |
|
115 { |
|
116 CImplementationInformation* information( plugins[i] ); |
|
117 |
|
118 if ( information->OpaqueData().Compare( aControlType ) == 0 ) |
|
119 { |
|
120 CHsContentControlUi* ccUi = CHsContentControlUi::NewL( |
|
121 information->ImplementationUid() ); |
|
122 |
|
123 ccUi->SetContentControlTypeL( information->OpaqueData() ); |
|
124 |
|
125 iHsContentControlUis.AppendL( ccUi ); |
|
126 |
|
127 retval = ccUi; |
|
128 |
|
129 // All done |
|
130 break; |
|
131 } |
|
132 } |
|
133 |
|
134 CleanupStack::PopAndDestroy(); // plugins |
|
135 ); // TRAP_IGNORE |
|
136 } |
|
137 |
|
138 return retval; |
|
139 } |
|
140 |
|
141 // ---------------------------------------------------------------------------- |
|
142 // CHsContentControlFactory::FindHsContentController() |
|
143 // ---------------------------------------------------------------------------- |
|
144 // |
|
145 MHsContentControlUi* CHsContentControlFactory::FindHsContentController( |
|
146 const TDesC8& aControlType ) |
|
147 { |
|
148 for ( TInt i = 0; i < iHsContentControlUis.Count(); i++ ) |
|
149 { |
|
150 CHsContentControlUi* cc( iHsContentControlUis[ i ] ); |
|
151 |
|
152 if ( cc->ContentControlType().Compare( aControlType ) == 0 ) |
|
153 { |
|
154 return cc; |
|
155 } |
|
156 } |
|
157 |
|
158 return NULL; |
|
159 } |
|
160 |
|
161 // End of file |