59 |
59 |
60 |
60 |
61 NONSHARABLE_CLASS(CAppFwProxy): public CBase |
61 NONSHARABLE_CLASS(CAppFwProxy): public CBase |
62 { |
62 { |
63 public: |
63 public: |
|
64 class CAlfGuardedSynchCall: public CActive |
|
65 { |
|
66 public: |
|
67 CAlfGuardedSynchCall(const TAlfCommandParams& aParams):CActive(CActive::EPriorityStandard), iPckg(aParams), iPtr(0,0) |
|
68 { |
|
69 CActiveScheduler::Add(this); |
|
70 iStatus = KErrNotFound; |
|
71 } |
|
72 |
|
73 static void DoGuardedOpL(const TAlfCommandParams& aInParams, |
|
74 TDes8& aOutParams, |
|
75 RNotifier& aNotifier, |
|
76 const TDesC8* aInParams2 = 0 // ugly extension, really |
|
77 ) |
|
78 { |
|
79 CAlfGuardedSynchCall* me = new (ELeave) CAlfGuardedSynchCall(aInParams); |
|
80 |
|
81 CleanupStack::PushL(me); |
|
82 User::LeaveIfError(me->iTimer.CreateLocal()); |
|
83 me->iRetBuf = aOutParams.AllocL(); |
|
84 me->iPtr.Set((TUint8*)me->iRetBuf->Ptr(),0,aOutParams.MaxSize()); |
|
85 if (aInParams2) |
|
86 { |
|
87 me->iAltInBuf = aInParams2->AllocL(); |
|
88 } |
|
89 CleanupStack::Pop(); // me |
|
90 |
|
91 if (aInParams2) |
|
92 { |
|
93 aNotifier.StartNotifierAndGetResponse(me->iStatus, |
|
94 TUid::Uid(KAlfAppFwProxyUid), |
|
95 *me->iAltInBuf, me->iPtr); |
|
96 } |
|
97 else |
|
98 { |
|
99 aNotifier.StartNotifierAndGetResponse(me->iStatus, |
|
100 TUid::Uid(KAlfAppFwProxyUid), |
|
101 me->iPckg, me->iPtr); |
|
102 } |
|
103 |
|
104 me->iTimer.After(me->iTimerStatus, 100000); // 100ms |
|
105 User::WaitForRequest(me->iStatus, me->iTimerStatus); |
|
106 TBool timedOut = (me->iStatus == KRequestPending); |
|
107 |
|
108 me->iTimer.Cancel(); // Cancel timer anyway |
|
109 |
|
110 if (!timedOut) |
|
111 { |
|
112 TInt err = me->iStatus.Int(); |
|
113 User::WaitForRequest(me->iTimerStatus); |
|
114 aOutParams.Copy(*me->iRetBuf); |
|
115 delete me; |
|
116 User::LeaveIfError(err); |
|
117 } |
|
118 else |
|
119 { |
|
120 me->SetActive(); |
|
121 User::Leave( KErrTimedOut ); |
|
122 } |
|
123 } |
|
124 |
|
125 static TInt DoGuardedOp(const TAlfCommandParams& aInParams, |
|
126 TDes8& aOutParams, |
|
127 RNotifier& aNotifier) |
|
128 { |
|
129 TInt ret = KErrNone; |
|
130 TRAP(ret, DoGuardedOpL(aInParams, aOutParams, aNotifier);) |
|
131 return ret; |
|
132 } |
|
133 |
|
134 ~CAlfGuardedSynchCall() |
|
135 { |
|
136 Cancel(); |
|
137 delete iRetBuf; |
|
138 delete iAltInBuf; |
|
139 iTimer.Close(); |
|
140 } |
|
141 |
|
142 void RunL() |
|
143 { |
|
144 delete this; |
|
145 } |
|
146 |
|
147 void DoCancel() |
|
148 { |
|
149 // Cancel will call User::WaitForRequest for iStatus (if this ao is active) |
|
150 } |
|
151 |
|
152 TPckgC<TAlfCommandParams> iPckg; |
|
153 HBufC8* iRetBuf; |
|
154 HBufC8* iAltInBuf; |
|
155 TPtr8 iPtr; |
|
156 RTimer iTimer; |
|
157 TRequestStatus iTimerStatus; |
|
158 }; |
|
159 |
64 class CAlfLayoutListener: public CActive |
160 class CAlfLayoutListener: public CActive |
65 { |
161 { |
66 public: |
162 public: |
67 CAlfLayoutListener(CAppFwProxy& aNotif):CActive(CActive::EPriorityStandard), iNotif(aNotif) |
163 CAlfLayoutListener(CAppFwProxy& aNotif):CActive(CActive::EPriorityStandard), iNotif(aNotif) |
68 { |
164 { |
109 TBool Connect() |
206 TBool Connect() |
110 { |
207 { |
111 if (!iConnected) |
208 if (!iConnected) |
112 { |
209 { |
113 // perhaps should check also whether eikon server / notifier server exists.. |
210 // perhaps should check also whether eikon server / notifier server exists.. |
|
211 // This is currently unsafe (synch) call to a process that may be blocked by window server, keep fingers crossed |
114 iConnected = (iNotif.Connect() == KErrNone); |
212 iConnected = (iNotif.Connect() == KErrNone); |
115 } |
213 } |
116 return iConnected; |
214 return iConnected; |
117 } |
215 } |
118 |
216 |
119 TBool LayoutMirrored() |
217 TBool LayoutMirrored() |
120 { |
218 { |
121 if ( Connect() && iLayoutMirrored == KErrNotFound) |
219 if ( Connect() && iLayoutMirrored == KErrNotFound) |
122 { |
220 { |
123 TRequestStatus status; |
221 TRequestStatus status; |
124 TAlfCommandParams params={EAlfIsMirrorred,0,0,0}; |
222 TAlfCommandParams inParams={EAlfIsMirrorred,0,0,0}; |
125 TPckgC<TAlfCommandParams> pkg(params); |
223 TBuf8<1> outParams; |
126 TBuf8<1> awkwardApiDummy; |
224 TInt ret = CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif ); |
127 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, awkwardApiDummy); |
225 |
128 User::WaitForRequest(status); |
|
129 // order updates |
226 // order updates |
130 iLayoutUpdateAo = new CAlfLayoutListener(*this); |
227 iLayoutUpdateAo = new CAlfLayoutListener(*this); |
131 if (iLayoutUpdateAo) |
228 if (iLayoutUpdateAo) |
132 { |
229 { |
133 TRAP_IGNORE(iLayoutUpdateAo->RunL()); |
230 TRAP_IGNORE(iLayoutUpdateAo->RunL()); |
134 } |
231 } |
135 |
232 |
136 iLayoutMirrored = (status.Int() > 0); |
233 iLayoutMirrored = ret > 0; |
137 } |
234 } |
138 |
235 |
139 return iLayoutMirrored==KErrNotFound?EFalse:iLayoutMirrored; |
236 return iLayoutMirrored==KErrNotFound?EFalse:iLayoutMirrored; |
140 } |
237 } |
141 |
238 |
142 TInt SoftKeyOrientation() |
239 TInt SoftKeyOrientation() |
143 { |
240 { |
144 TInt ret = 0; |
241 TInt ret = 0; |
145 if ( Connect() ) |
242 if ( Connect() ) |
146 { |
243 { |
147 TRequestStatus status; |
244 TAlfCommandParams inParams={EAlfCbaLocation,0,0,0}; |
148 TAlfCommandParams params={EAlfCbaLocation,0,0,0}; |
245 TBuf8<1> outParams; |
149 TPckgC<TAlfCommandParams> pkg(params); |
246 ret = CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif ); |
150 TBuf8<1> awkwardApiDummy; |
|
151 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, awkwardApiDummy); |
|
152 User::WaitForRequest(status); |
|
153 ret = status.Int(); |
|
154 } |
247 } |
155 |
248 |
156 return ret; |
249 return ret; |
157 } |
250 } |
158 |
251 |
159 TRect LayoutMetricsRect(TInt aType) |
252 TRect LayoutMetricsRect(TInt aType) |
160 { |
253 { |
161 TRect ret=TRect(0,0,0,0); |
254 TRect ret=TRect(0,0,0,0); |
162 if ( Connect() ) |
255 if ( Connect() ) |
163 { |
256 { |
164 TRequestStatus status; |
257 TAlfCommandParams inParams={EAlfLayoutMetricsRect,aType,0,0}; |
165 TAlfCommandParams params={EAlfLayoutMetricsRect,aType,0,0}; |
258 TPckg<TRect> outParams(ret); |
166 TPckgC<TAlfCommandParams> pkg(params); |
259 CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif ); |
167 TPckg<TRect> retpkg(ret); |
|
168 |
|
169 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg); |
|
170 User::WaitForRequest(status); |
|
171 } |
260 } |
172 |
261 |
173 return ret; |
262 return ret; |
174 } |
263 } |
175 |
264 |
176 TInt GetCachedColor(TRgb& aRgb, const TAknsItemID& aID, |
265 TInt GetCachedColor(TRgb& aRgb, const TAknsItemID& aID, |
177 const TInt aIndex ) |
266 const TInt aIndex ) |
178 { |
267 { |
179 if ( Connect() ) |
268 if ( Connect() ) |
180 { |
269 { |
181 TRequestStatus status; |
270 TAlfCommandParams inParams={EAlfGetCachedColor,aID.iMajor,aID.iMinor,aIndex}; |
182 TAlfCommandParams params={EAlfGetCachedColor,aID.iMajor,aID.iMinor,aIndex}; |
271 TPckg<TRgb> outParams(aRgb); |
183 TPckgC<TAlfCommandParams> pkg(params); |
272 return CAlfGuardedSynchCall::DoGuardedOp( inParams, outParams , iNotif); |
184 TPckg<TRgb> retpkg(aRgb); |
|
185 |
|
186 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg); |
|
187 User::WaitForRequest(status); |
|
188 return status.Int(); |
|
189 } |
273 } |
190 |
274 |
191 return KErrCouldNotConnect; |
275 return KErrCouldNotConnect; |
192 } |
276 } |
193 |
277 |
194 void GetSkinBitmapL(CFbsBitmap* aBitmap, CFbsBitmap* aMask, const TAknsItemID& aID, const TDesC& aFileName, TInt aBitmapId, |
278 void GetSkinBitmapL(CFbsBitmap* aBitmap, CFbsBitmap* aMask, const TAknsItemID& aID, const TDesC& aFileName, TInt aBitmapId, |
195 TInt aMaskId, const TSize& aSize, TScaleMode aScaleMode) |
279 TInt aMaskId, const TSize& aSize, TScaleMode aScaleMode) |
196 { |
280 { |
197 if ( Connect() ) |
281 if ( Connect() ) |
198 { |
282 { |
199 TRequestStatus status; |
283 TAlfCommandParams fakeParams={0,0,0,0}; |
200 TAlfCommandParams2 params={EAlfGetSkinBitmap,aID.iMajor,aID.iMinor,aBitmapId,aMaskId,aFileName, aSize, aScaleMode}; |
284 TAlfCommandParams2 inParams={EAlfGetSkinBitmap,aID.iMajor,aID.iMinor,aBitmapId,aMaskId,aFileName, aSize, aScaleMode}; |
201 TPckgC<TAlfCommandParams2> pkg(params); |
285 TPckgC<TAlfCommandParams2> inBuf(inParams); |
202 TInt2 handles = {0,0}; |
286 TInt2 handles = {0,0}; |
203 TPckg<TInt2> retpkg(handles); |
287 TPckg<TInt2> outParams(handles); |
204 |
288 CAlfGuardedSynchCall::DoGuardedOpL( fakeParams, outParams , iNotif, &inBuf ); |
205 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg); |
|
206 User::WaitForRequest(status); |
|
207 User::LeaveIfError(status.Int()); |
|
208 if (!handles.iInt1) |
289 if (!handles.iInt1) |
209 { |
290 { |
210 User::Leave(KErrNotFound); |
291 User::Leave(KErrNotFound); |
211 } |
292 } |
212 User::LeaveIfError(aBitmap->Duplicate(handles.iInt1)); |
293 User::LeaveIfError(aBitmap->Duplicate(handles.iInt1)); |
219 |
300 |
220 void GetSkinBackgroundBitmapL(CFbsBitmap* aBitmap, const TAknsItemID& aID ) |
301 void GetSkinBackgroundBitmapL(CFbsBitmap* aBitmap, const TAknsItemID& aID ) |
221 { |
302 { |
222 if ( Connect() ) |
303 if ( Connect() ) |
223 { |
304 { |
224 TRequestStatus status; |
305 TAlfCommandParams inParams={EAlfGetSkinBackgroundBitmap,aID.iMajor,aID.iMinor,0}; |
225 TAlfCommandParams params={EAlfGetSkinBackgroundBitmap,aID.iMajor,aID.iMinor,0}; |
|
226 TPckgC<TAlfCommandParams> pkg(params); |
|
227 TInt handle = 0; |
306 TInt handle = 0; |
228 TPckg<TInt> retpkg(handle); |
307 TPckg<TInt> outParams(handle); |
229 |
308 CAlfGuardedSynchCall::DoGuardedOpL( inParams, outParams , iNotif ); |
230 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg); |
|
231 User::WaitForRequest(status); |
|
232 User::LeaveIfError(status.Int()); |
|
233 User::LeaveIfError(aBitmap->Duplicate(handle)); |
309 User::LeaveIfError(aBitmap->Duplicate(handle)); |
234 } |
310 } |
235 } |
311 } |
236 |
312 |
237 void GetCachedSkinItemDataArrayL(const TAknsItemID& aID, TInt aType, TAlfCachedSkinItemArray& aArray) |
313 void GetCachedSkinItemDataArrayL(const TAknsItemID& aID, TInt aType, TAlfCachedSkinItemArray& aArray) |
238 { |
314 { |
239 if ( Connect() ) |
315 if ( Connect() ) |
240 { |
316 { |
241 TRequestStatus status; |
317 TAlfCommandParams inParams={EGetCachedSkinItemData,aID.iMajor,aID.iMinor,aType}; |
242 TAlfCommandParams params={EGetCachedSkinItemData,aID.iMajor,aID.iMinor,aType}; |
318 TPckg<TAlfCachedSkinItemArray> outParams(aArray); |
243 TPckgC<TAlfCommandParams> pkg(params); |
319 CAlfGuardedSynchCall::DoGuardedOpL( inParams, outParams , iNotif ); |
244 TPckg<TAlfCachedSkinItemArray> retpkg(aArray); |
|
245 |
|
246 iNotif.StartNotifierAndGetResponse(status,TUid::Uid(KAlfAppFwProxyUid), pkg, retpkg); |
|
247 User::WaitForRequest(status); |
|
248 User::LeaveIfError(status.Int()); |
|
249 } |
320 } |
250 } |
321 } |
251 |
322 |
252 void GetListOfWindowGroupsL(TRequestStatus& aStatus, TPtr8& aPtr) |
|
253 { |
|
254 if ( Connect() ) |
|
255 { |
|
256 TAlfCommandParams params={EGetListOfWindowGroups,0,0,0}; |
|
257 TPckgC<TAlfCommandParams> pkg(params); |
|
258 iNotif.StartNotifierAndGetResponse(aStatus,TUid::Uid(KAlfAppFwProxyUid), pkg, aPtr); |
|
259 } |
|
260 } |
|
261 public: |
323 public: |
262 TBool iLayoutMirrored; |
324 TBool iLayoutMirrored; |
263 RNotifier iNotif; |
325 RNotifier iNotif; |
264 TBool iConnected; |
326 TBool iConnected; |
265 CAlfLayoutListener* iLayoutUpdateAo; |
327 CAlfLayoutListener* iLayoutUpdateAo; |