|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Implementation for CFepLayoutEngine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "peninputlayoutplugininterface.h" |
|
20 #include "peninputuilayoutbase.h" |
|
21 #include "peninputlayouteng.h" |
|
22 #include "peninputimefinder.h" |
|
23 #include <PtiEngine.h> //CPtiEngine |
|
24 |
|
25 // ======== LOCAL FUNCTIONS ======== |
|
26 |
|
27 // |
|
28 // Cleaup function |
|
29 // |
|
30 void Cleanup( TAny* aAny ) |
|
31 { |
|
32 RImplInfoPtrArray* implArray = |
|
33 reinterpret_cast< RImplInfoPtrArray*> ( aAny ); |
|
34 if(implArray) |
|
35 { |
|
36 implArray->ResetAndDestroy(); |
|
37 implArray->Close(); |
|
38 } |
|
39 } |
|
40 |
|
41 |
|
42 // ======== MEMBER FUNCTIONS ======== |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CFepLayoutEngine::NewL |
|
46 // Factory function |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CFepLayoutEngine* CFepLayoutEngine::NewL() |
|
50 { |
|
51 CFepLayoutEngine *engine = new (ELeave) CFepLayoutEngine(); |
|
52 CleanupStack::PushL( engine ); |
|
53 engine->ConstructL(); |
|
54 CleanupStack::Pop(engine); // engine |
|
55 return engine; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CFepLayoutEngine::NewL |
|
60 // Factory function |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C CFepLayoutEngine* CFepLayoutEngine::NewL(CPtiEngine* aPtiEngine) |
|
64 { |
|
65 CFepLayoutEngine *engine = new (ELeave) CFepLayoutEngine(aPtiEngine); |
|
66 CleanupStack::PushL( engine ); |
|
67 engine->ConstructL(); |
|
68 CleanupStack::Pop(engine); // engine |
|
69 return engine; |
|
70 } |
|
71 // --------------------------------------------------------------------------- |
|
72 // CFepLayoutEngine::CFepLayoutEngine |
|
73 // Default constructor |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CFepLayoutEngine::CFepLayoutEngine(CPtiEngine* aPtiEngine) |
|
77 :iPtiEngine(aPtiEngine) |
|
78 { |
|
79 iLayoutId.iUid=0; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CFepLayoutEngine::ConstructL |
|
84 // 2nd phase Constructor |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CFepLayoutEngine::ConstructL() |
|
88 { |
|
89 FindImeLayoutL(KHwrInputMethodId); |
|
90 iImeFinder = CImePluginFinder::NewL(); |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CFepLayoutEngine::~CFepLayoutEngine |
|
96 // Destructor |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CFepLayoutEngine::~CFepLayoutEngine() |
|
100 { |
|
101 iLayoutIdList.Reset(); |
|
102 delete iCurInterface; |
|
103 iCurInterface = NULL; |
|
104 delete iImeFinder; |
|
105 iTouchSupportLanguages.Close(); |
|
106 iImePluginIdList.Close(); |
|
107 REComSession::FinalClose(); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CFepLayoutEngine::GetUiLayout |
|
112 // Create UI layout |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C MPenUiLayoutBase* CFepLayoutEngine::GetUiLayout(TUid aInputMethodId, |
|
116 MLayoutOwner* aLayoutOwner,const TAny* aData) |
|
117 { |
|
118 MPenUiLayoutBase* uiLayout=NULL; |
|
119 if(aInputMethodId != iLayoutId) |
|
120 { |
|
121 iLayoutId = aInputMethodId; |
|
122 delete iCurInterface; |
|
123 iCurInterface = NULL; |
|
124 |
|
125 if( aInputMethodId == TUid::Null() ) |
|
126 { |
|
127 return NULL; |
|
128 } |
|
129 |
|
130 TUid destructor_ID_Key; |
|
131 TAny* pFunc = NULL; |
|
132 TRAPD(err, |
|
133 pFunc = REComSession::CreateImplementationL(aInputMethodId, |
|
134 destructor_ID_Key) |
|
135 ); |
|
136 |
|
137 |
|
138 if(err != KErrNone) |
|
139 return NULL; |
|
140 else |
|
141 iCurInterface = reinterpret_cast<CFepUiLayoutInterface*>(pFunc); |
|
142 |
|
143 iCurInterface->SetDestructorKey(destructor_ID_Key); |
|
144 |
|
145 } |
|
146 |
|
147 if(iCurInterface) |
|
148 { |
|
149 TRAP_IGNORE(uiLayout = iCurInterface-> |
|
150 CreateFepUiLayoutL(aLayoutOwner,aData)); |
|
151 } |
|
152 |
|
153 return uiLayout; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CFepLayoutEngine::FindImeLayoutL |
|
158 // Find layout for a input mode |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CFepLayoutEngine::FindImeLayoutL(TInt aInputMethodId) |
|
162 { |
|
163 |
|
164 if(iInputMethodId == aInputMethodId) |
|
165 return; |
|
166 |
|
167 iInputMethodId = aInputMethodId; |
|
168 |
|
169 RImplInfoPtrArray infoArray; |
|
170 TInt i; |
|
171 |
|
172 iLayoutIdList.Reset(); |
|
173 |
|
174 CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) ); |
|
175 |
|
176 TUid id; |
|
177 id.iUid = aInputMethodId; |
|
178 |
|
179 REComSession::ListImplementationsL(id, infoArray); |
|
180 |
|
181 for (i = 0; i < infoArray.Count(); i++) |
|
182 { |
|
183 iLayoutIdList.AppendL(infoArray[i]->ImplementationUid().iUid); |
|
184 } |
|
185 |
|
186 CleanupStack::PopAndDestroy(&infoArray); // infoArray |
|
187 |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CFepLayoutEngine::UiLayoutListL |
|
192 // Get the layout list |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 EXPORT_C const RArray<TInt>& CFepLayoutEngine::UiLayoutListL(TInt aInputMethodId) |
|
196 { |
|
197 FindImeLayoutL(aInputMethodId); |
|
198 return iLayoutIdList; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // CFepLayoutEngine::ImePluginListL |
|
203 // Get the IME plugin list by required mode |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C const RArray<TInt>& CFepLayoutEngine::ImePluginListL(TInt aLanguage, TInt aPluginMode) |
|
207 { |
|
208 if( !iImeFinder->Initialized() ) |
|
209 { |
|
210 iImeFinder->InitializeL(iPtiEngine); |
|
211 } |
|
212 |
|
213 iImeFinder->GetImePlugins(aLanguage, aPluginMode, iImePluginIdList); |
|
214 return iImePluginIdList; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CFepLayoutEngine::TouchSupportLanguagesL |
|
219 // Get touch input language list |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 EXPORT_C const RArray<TInt>& CFepLayoutEngine::TouchSupportLanguagesL() |
|
223 { |
|
224 if( !iImeFinder->Initialized() ) |
|
225 { |
|
226 iImeFinder->InitializeL(iPtiEngine); |
|
227 } |
|
228 |
|
229 iImeFinder->SupportLanguages(iTouchSupportLanguages); |
|
230 return iTouchSupportLanguages; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CFepLayoutEngine::IsSupportPluginMode |
|
235 // Get touch input language list |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 EXPORT_C TBool CFepLayoutEngine::IsSupportPluginMode( TLanguage aLanguage, TPluginInputMode aMode ) |
|
239 { |
|
240 return iImeFinder->IsSupportPluginMode( aLanguage, aMode ); |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // CFepLayoutEngine::InitializeL |
|
245 // Initialize finder |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 EXPORT_C void CFepLayoutEngine::InitializeL() |
|
249 { |
|
250 if(iPtiEngine && iImeFinder) |
|
251 { |
|
252 iImeFinder->InitializeL(iPtiEngine); |
|
253 } |
|
254 } |
|
255 // End of file |
|
256 |