21 #include <tstaskmonitorglobals.h> |
21 #include <tstaskmonitorglobals.h> |
22 #include <stddef.h> |
22 #include <stddef.h> |
23 #include <qnamespace.h> |
23 #include <qnamespace.h> |
24 |
24 |
25 #include "tsscreenshotplugin.h" |
25 #include "tsscreenshotplugin.h" |
26 #include "tsorientationmonitor.h" |
26 #include "tsscreenshotnotifier.h" |
27 #include "tsscreenshotmsg.h" |
27 #include "tsscreenshotmsg.h" |
|
28 #include "tsidlist.h" |
28 |
29 |
29 const TInt KInvalidGroupId(~0); |
30 const TInt KInvalidGroupId(~0); |
30 const TUid KHbPsHardwareCoarseOrientationCategoryUid = {0x20022E82}; |
31 const TUid KHbPsHardwareCoarseOrientationCategoryUid = {0x20022E82}; |
31 const TUint KHbPsHardwareCoarseWsOrientationKey = 0x4F726965; |
32 const TUint KHbPsHardwareCoarseWsOrientationKey = 0x4F726965; |
32 |
33 |
55 aEnv.RegisterEventHandler(this, |
56 aEnv.RegisterEventHandler(this, |
56 this, |
57 this, |
57 TWservCrEvent::EWindowGroupChanged | |
58 TWservCrEvent::EWindowGroupChanged | |
58 TWservCrEvent::EDeviceOrientationChanged); |
59 TWservCrEvent::EDeviceOrientationChanged); |
59 iWindowGroupId = KInvalidGroupId; |
60 iWindowGroupId = KInvalidGroupId; |
60 TRAP_IGNORE( ConstructL() ); |
61 iBlockedList = CTsIdList::NewL(); |
61 } |
62 } |
62 |
63 |
63 // ----------------------------------------------------------------------------- |
|
64 void CTsScreenshotPlugin::ConstructL() |
|
65 { |
|
66 iMonitor = CTsOrientationMonitor::NewL( *this ); |
|
67 } |
|
68 |
64 |
69 // ----------------------------------------------------------------------------- |
65 // ----------------------------------------------------------------------------- |
70 /** |
66 /** |
71 * Destructor |
67 * Destructor |
72 */ |
68 */ |
73 CTsScreenshotPlugin::~CTsScreenshotPlugin() |
69 CTsScreenshotPlugin::~CTsScreenshotPlugin() |
74 { |
70 { |
75 delete iMonitor; |
71 delete iBlockedList; |
76 Env().UnregisterEventHandler(this); |
72 Env().UnregisterEventHandler(this); |
77 iCache.ResetAndDestroy(); |
73 iCache.ResetAndDestroy(); |
78 } |
74 } |
79 |
75 |
80 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
140 TakeScreenshot( iWindowGroupId ); |
143 TakeScreenshot( iWindowGroupId ); |
141 } |
144 } |
142 iWindowGroupId = aEvent.WindowGroupIdentifier(); |
145 iWindowGroupId = aEvent.WindowGroupIdentifier(); |
143 break; |
146 break; |
144 case TWservCrEvent::EDeviceOrientationChanged: |
147 case TWservCrEvent::EDeviceOrientationChanged: |
145 TakeScreenshot( iWindowGroupId ); |
148 if( !iBlockedList->IsPresent( iWindowGroupId ) ) |
|
149 { |
|
150 TakeScreenshot( iWindowGroupId ); |
|
151 } |
146 break; |
152 break; |
147 } |
153 } |
148 } |
154 } |
149 |
155 |
150 // ----------------------------------------------------------------------------- |
156 // ----------------------------------------------------------------------------- |
180 |
186 |
181 //prepare destination bitmap |
187 //prepare destination bitmap |
182 CFbsBitmap *bitmap = new (ELeave) CFbsBitmap(); |
188 CFbsBitmap *bitmap = new (ELeave) CFbsBitmap(); |
183 CleanupStack::PushL(bitmap); |
189 CleanupStack::PushL(bitmap); |
184 |
190 |
185 |
|
186 User::LeaveIfError(bitmap->Create(screenConfig->SizeInPixels(), |
191 User::LeaveIfError(bitmap->Create(screenConfig->SizeInPixels(), |
187 screenConfig->DisplayMode())); |
192 screenConfig->DisplayMode())); |
188 |
193 |
189 screenDevice->CopyScreenToBitmapL(bitmap, |
194 screenDevice->CopyScreenToBitmapL(bitmap, |
190 screenConfig->SizeInPixels()); |
195 screenConfig->SizeInPixels()); |
191 |
196 |
192 |
|
193 //prepare and send message |
197 //prepare and send message |
194 RBuf8 message; |
198 CTsScreenshotNotifier* notifier = |
195 CleanupClosePushL(message); |
199 CTsScreenshotNotifier::NewL(*this, aId, bitmap, OrientationToAngle()); |
196 message.CreateL(CTsScreenshotMsg::Size() + sizeof(TInt)); |
|
197 RDesWriteStream stream(message); |
|
198 CleanupClosePushL(stream); |
|
199 stream.WriteInt32L(RegisterScreenshotMessage); |
|
200 |
|
201 CTsScreenshotMsg * screenshotMsg = |
|
202 CTsScreenshotMsg::NewLC(aId, |
|
203 *bitmap, |
|
204 Low, |
|
205 OrientationToAngle()); |
|
206 stream << (*screenshotMsg); |
|
207 CleanupStack::PopAndDestroy(screenshotMsg); |
|
208 CleanupStack::PopAndDestroy(&stream); |
|
209 User::LeaveIfError(SendMessage(message)); |
|
210 CleanupStack::PopAndDestroy(&message); |
|
211 iCache.AppendL(bitmap); |
|
212 CleanupStack::Pop(bitmap); |
200 CleanupStack::Pop(bitmap); |
|
201 CleanupStack::PushL(notifier); |
|
202 iCache.AppendL(notifier); |
|
203 CleanupStack::Pop(notifier); |
213 } |
204 } |
214 |
205 |
215 // ----------------------------------------------------------------------------- |
206 // ----------------------------------------------------------------------------- |
216 // |
207 // |
217 TInt CTsScreenshotPlugin::OrientationToAngle() |
208 TInt CTsScreenshotPlugin::OrientationToAngle() |
224 switch( orientation ) |
215 switch( orientation ) |
225 { |
216 { |
226 case EDisplayOrientation90CW: retVal = 270;break; |
217 case EDisplayOrientation90CW: retVal = 270;break; |
227 case EDisplayOrientation180: retVal = 180;break; |
218 case EDisplayOrientation180: retVal = 180;break; |
228 case EDisplayOrientation270CW: retVal = 90;break; |
219 case EDisplayOrientation270CW: retVal = 90;break; |
229 case EDisplayOrientationNormal:retVal = iAngle; break; |
|
230 case EDisplayOrientationAuto: |
220 case EDisplayOrientationAuto: |
231 { |
221 { |
232 RProperty::Get( KHbPsHardwareCoarseOrientationCategoryUid, |
222 RProperty::Get( KHbPsHardwareCoarseOrientationCategoryUid, |
233 KHbPsHardwareCoarseWsOrientationKey, sensor ); |
223 KHbPsHardwareCoarseWsOrientationKey, sensor ); |
234 retVal = ( sensor == Qt::Vertical ) ? 270 : 0; |
224 retVal = ( sensor == Qt::Vertical ) ? 270 : 0; |
238 } |
228 } |
239 return retVal; |
229 return retVal; |
240 } |
230 } |
241 |
231 |
242 // ----------------------------------------------------------------------------- |
232 // ----------------------------------------------------------------------------- |
243 void CTsScreenshotPlugin::OrientationChanged( TInt aAngle ) |
233 void CTsScreenshotPlugin::SendMessageL( const TDesC8& aMessage ) |
244 { |
234 { |
245 iAngle = aAngle; |
235 User::LeaveIfError( SendMessage( aMessage ) ); |
246 } |
236 } |
247 |
237 |
248 // ----------------------------------------------------------------------------- |
238 // ----------------------------------------------------------------------------- |
249 void CTsScreenshotPlugin::NotifyWindowGroupToBackground( TInt windowGroupId ) |
239 void CTsScreenshotPlugin::NotifyWindowGroupToBackground( TInt windowGroupId ) |
250 { |
240 { |
265 CleanupClosePushL(stream); |
255 CleanupClosePushL(stream); |
266 stream.WriteInt32L(WindowGroupToBackgroundMessage); |
256 stream.WriteInt32L(WindowGroupToBackgroundMessage); |
267 stream.WriteInt32L(windowGroupId); |
257 stream.WriteInt32L(windowGroupId); |
268 CleanupStack::PopAndDestroy(&stream); |
258 CleanupStack::PopAndDestroy(&stream); |
269 } |
259 } |
270 User::LeaveIfError(SendMessage(message)); |
260 SendMessageL(message); |
271 CleanupStack::PopAndDestroy(&message); |
261 CleanupStack::PopAndDestroy(&message); |
272 } |
262 } |