15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
|
20 #include "../../../symbian_version.hrh" |
|
21 |
|
22 |
20 #include "HtiScreenshotServicePlugin.h" |
23 #include "HtiScreenshotServicePlugin.h" |
21 #include <HtiDispatcherInterface.h> |
24 #include <HtiDispatcherInterface.h> |
22 #include <HtiLogging.h> |
25 #include <HtiLogging.h> |
23 |
26 |
24 #include <imageconversion.h> |
27 #include <imageconversion.h> |
25 #include <ezcompressor.h> |
28 #include <ezcompressor.h> |
26 #include <hal.h> |
29 #include <hal.h> |
|
30 |
|
31 #include <AknLayoutConfig.h> |
|
32 #include <apgtask.h> |
|
33 #include <AknCapServerDefs.h> |
|
34 |
|
35 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
36 #include <alf/alfdrawer.h> |
|
37 #endif |
27 |
38 |
28 // CONSTANTS |
39 // CONSTANTS |
29 const static TUid KScreenshotServiceUid = {0x1020DEC3}; |
40 const static TUid KScreenshotServiceUid = {0x1020DEC3}; |
30 |
41 |
31 enum TScreenCommands |
42 enum TScreenCommands |
53 // Selects the screen to use |
64 // Selects the screen to use |
54 ECmdSelectScreen = 0x30, |
65 ECmdSelectScreen = 0x30, |
55 |
66 |
56 // Gets the current screen size and orientation |
67 // Gets the current screen size and orientation |
57 ECmdScreenMode = 0x3A, |
68 ECmdScreenMode = 0x3A, |
|
69 |
|
70 // Rotates the screen to portrait or landscape |
|
71 ECmdRotateScreen = 0x3B, |
58 |
72 |
59 // Screencapture on updated part of screen only |
73 // Screencapture on updated part of screen only |
60 ECmdDeltaCaptureMask = 0x80, |
74 ECmdDeltaCaptureMask = 0x80, |
61 ECmdDeltaScreen = 0x81, |
75 ECmdDeltaScreen = 0x81, |
62 ECmdDeltaScreenRegion = 0x82, |
76 ECmdDeltaScreenRegion = 0x82, |
89 |
103 |
90 //1 byte for cmd and 2*4 for 4 coordinates |
104 //1 byte for cmd and 2*4 for 4 coordinates |
91 const static TInt KMinScreenRegionCmdLength = 9; |
105 const static TInt KMinScreenRegionCmdLength = 9; |
92 const static TInt KScreenDisplayOffset = 1; |
106 const static TInt KScreenDisplayOffset = 1; |
93 const static TInt KScreenMIMEOffset = KScreenDisplayOffset + 1; |
107 const static TInt KScreenMIMEOffset = KScreenDisplayOffset + 1; |
|
108 const static TInt KScreenScreenNumber = KScreenMIMEOffset + 8; |
94 const static TInt KRegionDisplayOffset = KMinScreenRegionCmdLength; |
109 const static TInt KRegionDisplayOffset = KMinScreenRegionCmdLength; |
95 const static TInt KRegionMIMEOffset = KRegionDisplayOffset + 1; |
110 const static TInt KRegionMIMEOffset = KRegionDisplayOffset + 1; |
96 |
111 const static TInt KRegionScreenNumber = KRegionMIMEOffset + 8; |
97 |
112 |
98 const static TInt KSeriesDurationOffset = 1; |
113 const static TInt KSeriesDurationOffset = 1; |
99 const static TInt KSeriesIntervalOffset = KSeriesDurationOffset + 4; |
114 const static TInt KSeriesIntervalOffset = KSeriesDurationOffset + 4; |
100 const static TInt KSeriesDisplayOffset = KSeriesIntervalOffset + 4; |
115 const static TInt KSeriesDisplayOffset = KSeriesIntervalOffset + 4; |
101 const static TInt KSeriesMIMEOffset = KSeriesDisplayOffset + 1; |
116 const static TInt KSeriesMIMEOffset = KSeriesDisplayOffset + 1; |
|
117 const static TInt KSeriesScreenNumber = KSeriesMIMEOffset + 8; |
102 const static TInt KMinSeriesCmdLength = KSeriesMIMEOffset; |
118 const static TInt KMinSeriesCmdLength = KSeriesMIMEOffset; |
103 |
119 |
104 const static TInt KRegionSeriesTlX = KSeriesDisplayOffset + 1; |
120 const static TInt KRegionSeriesTlX = KSeriesDisplayOffset + 1; |
105 const static TInt KRegionSeriesTlY = KRegionSeriesTlX + 2; |
121 const static TInt KRegionSeriesTlY = KRegionSeriesTlX + 2; |
106 const static TInt KRegionSeriesBlX = KRegionSeriesTlY + 2; |
122 const static TInt KRegionSeriesBlX = KRegionSeriesTlY + 2; |
107 const static TInt KRegionSeriesBlY = KRegionSeriesBlX + 2; |
123 const static TInt KRegionSeriesBlY = KRegionSeriesBlX + 2; |
108 const static TInt KRegionSeriesMIMEOffset = KRegionSeriesBlY + 2; |
124 const static TInt KRegionSeriesMIMEOffset = KRegionSeriesBlY + 2; |
|
125 const static TInt KRegionSeriesScreenNumber = KRegionSeriesMIMEOffset + 8; |
109 const static TInt KMinRegionSeriesCmdLength = KRegionSeriesMIMEOffset; |
126 const static TInt KMinRegionSeriesCmdLength = KRegionSeriesMIMEOffset; |
110 |
127 |
111 const static TInt KDeltaResetCmdLength = 1; |
128 const static TInt KDeltaResetCmdLength = 1; |
112 const static TInt KScreenModeCmdLength = 1; |
129 const static TInt KScreenModeCmdLength = 1; |
113 |
130 |
114 const static TInt KScreenNrOffset = 1; |
131 const static TInt KScreenNrOffset = 1; |
115 const static TInt KSelectScreenCmdLength = 2; |
132 const static TInt KSelectScreenCmdLength = 2; |
|
133 const static TInt KRotateScreenCmdLength = 2; |
116 |
134 |
117 _LIT( KSeriesShotPath, "c:\\Hti\\SeriesShot\\" ); |
135 _LIT( KSeriesShotPath, "c:\\Hti\\SeriesShot\\" ); |
118 |
136 |
119 //errors' descriptions |
137 //errors' descriptions |
120 _LIT8( KErrDescrInvalid, "invalid arguments" ); |
138 _LIT8( KErrDescrInvalid, "invalid arguments" ); |
1187 KScreenshotServiceUid ); |
1205 KScreenshotServiceUid ); |
1188 return; |
1206 return; |
1189 } |
1207 } |
1190 } |
1208 } |
1191 |
1209 |
|
1210 bool screenNumberSet = false; |
|
1211 //check screen number |
|
1212 if ( (aMessage.Length() > KScreenScreenNumber) && |
|
1213 ((aMessage[aMessage.Length()-1] == 0) || (aMessage[aMessage.Length()-1] == 1))) |
|
1214 { |
|
1215 TInt screenNumber = aMessage[aMessage.Length()-1]; |
|
1216 HTI_LOG_FORMAT( "set screen number: %d", screenNumber ); |
|
1217 screenNumberSet = true; |
|
1218 TInt screens; |
|
1219 TInt ret = HAL::Get(HAL::EDisplayNumberOfScreens, screens); |
|
1220 if(ret) |
|
1221 { |
|
1222 HTI_LOG_FORMAT( "HAL::Get failed %d", ret ); |
|
1223 User::Leave(ret); |
|
1224 } |
|
1225 HTI_LOG_FORMAT( "HAL::Get number of screens %d", screens ); |
|
1226 if( ( screenNumber>screens-1 ) || ( screenNumber<0 ) ) |
|
1227 { |
|
1228 iDispatcher->DispatchOutgoingErrorMessage( |
|
1229 KErrArgument, KErrDescrScreenNotSupported, KScreenshotServiceUid); |
|
1230 return; |
|
1231 } |
|
1232 SetScreenNumber(screenNumber); |
|
1233 } |
|
1234 |
1192 CreateBitmapL( empty, displayMode ); |
1235 CreateBitmapL( empty, displayMode ); |
|
1236 |
1193 //check mime |
1237 //check mime |
1194 if ( aMessage.Length() > KScreenMIMEOffset ) |
1238 if ( aMessage.Length() > KScreenMIMEOffset ) |
1195 { |
1239 { |
1196 mime.Set( aMessage.Mid( KScreenMIMEOffset ) ); |
1240 if(screenNumberSet) |
|
1241 { |
|
1242 mime.Set( aMessage.Mid( KScreenMIMEOffset, aMessage.Length()-1-KScreenMIMEOffset ) ); |
|
1243 } |
|
1244 else |
|
1245 { |
|
1246 mime.Set( aMessage.Mid( KScreenMIMEOffset ) ); |
|
1247 } |
1197 if ( !IsMIMETypeSupported( mime ) ) |
1248 if ( !IsMIMETypeSupported( mime ) ) |
1198 { |
1249 { |
1199 iDispatcher->DispatchOutgoingErrorMessage( |
1250 iDispatcher->DispatchOutgoingErrorMessage( |
1200 KErrArgument, |
1251 KErrArgument, |
1201 KErrDescrMIMENotSupported, |
1252 KErrDescrMIMENotSupported, |
1202 KScreenshotServiceUid ); |
1253 KScreenshotServiceUid ); |
1203 return; |
1254 return; |
1204 } |
1255 } |
1205 } |
1256 } |
1206 } |
1257 } |
1207 break; |
1258 break; |
1208 |
1259 |
1209 case ECmdScreenRegion: |
1260 case ECmdScreenRegion: |
1210 case ECmdScreenRegionZip: |
1261 case ECmdScreenRegionZip: |
1211 case ECmdDeltaScreenRegion: |
1262 case ECmdDeltaScreenRegion: |
1212 case ECmdDeltaScreenRegionZip: |
1263 case ECmdDeltaScreenRegionZip: |
1213 { |
1264 { |
|
1265 //check screen number |
|
1266 bool screenNumberSet = false; |
|
1267 if ( (aMessage.Length() > KRegionScreenNumber) && |
|
1268 ((aMessage[aMessage.Length()-1] == 0) || (aMessage[aMessage.Length()-1] == 1))) |
|
1269 { |
|
1270 TInt screenNumber = aMessage[aMessage.Length()-1]; |
|
1271 screenNumberSet = true; |
|
1272 TInt screens; |
|
1273 TInt ret = HAL::Get(HAL::EDisplayNumberOfScreens, screens); |
|
1274 if(ret) |
|
1275 { |
|
1276 HTI_LOG_FORMAT( "HAL::Get failed %d", ret ); |
|
1277 User::Leave(ret); |
|
1278 } |
|
1279 HTI_LOG_FORMAT( "HAL::Get number of screens %d", screens ); |
|
1280 if( ( screenNumber>screens-1 ) || ( screenNumber<0 ) ) |
|
1281 { |
|
1282 iDispatcher->DispatchOutgoingErrorMessage( |
|
1283 KErrArgument, KErrDescrScreenNotSupported, KScreenshotServiceUid); |
|
1284 return; |
|
1285 } |
|
1286 SetScreenNumber(screenNumber); |
|
1287 } |
|
1288 |
1214 if ( aMessage.Length() >= KMinScreenRegionCmdLength ) |
1289 if ( aMessage.Length() >= KMinScreenRegionCmdLength ) |
1215 { |
1290 { |
1216 TRect region; |
1291 TRect region; |
1217 const TUint8* ptr = aMessage.Ptr(); |
1292 const TUint8* ptr = aMessage.Ptr(); |
1218 region.iTl.iX = ParseInt16( ptr + 1 ); |
1293 region.iTl.iX = ParseInt16( ptr + 1 ); |
1269 KErrArgument, |
1344 KErrArgument, |
1270 KErrDescrRegionOutOfScreen, |
1345 KErrDescrRegionOutOfScreen, |
1271 KScreenshotServiceUid ); |
1346 KScreenshotServiceUid ); |
1272 return; |
1347 return; |
1273 } |
1348 } |
1274 |
1349 |
1275 //check mime |
1350 //check mime |
1276 if ( aMessage.Length() > KRegionMIMEOffset ) |
1351 if ( aMessage.Length() > KRegionMIMEOffset ) |
1277 { |
1352 { |
1278 mime.Set( aMessage.Mid( KRegionMIMEOffset ) ); |
1353 if(!screenNumberSet) |
|
1354 { |
|
1355 mime.Set( aMessage.Mid( KRegionMIMEOffset ) ); |
|
1356 } |
|
1357 else |
|
1358 { |
|
1359 mime.Set( aMessage.Mid( KRegionMIMEOffset, aMessage.Length()-1-KRegionMIMEOffset ) ); |
|
1360 } |
1279 if ( !IsMIMETypeSupported( mime ) ) |
1361 if ( !IsMIMETypeSupported( mime ) ) |
1280 { |
1362 { |
1281 iDispatcher->DispatchOutgoingErrorMessage( |
1363 iDispatcher->DispatchOutgoingErrorMessage( |
1282 KErrArgument, |
1364 KErrArgument, |
1283 KErrDescrMIMENotSupported, |
1365 KErrDescrMIMENotSupported, |
1284 KScreenshotServiceUid ); |
1366 KScreenshotServiceUid ); |
1285 return; |
1367 return; |
1286 } |
1368 } |
1287 } |
1369 } |
|
1370 |
1288 } |
1371 } |
1289 else |
1372 else |
1290 { |
1373 { |
1291 iDispatcher->DispatchOutgoingErrorMessage( |
1374 iDispatcher->DispatchOutgoingErrorMessage( |
1292 KErrArgument, |
1375 KErrArgument, |
1306 KErrArgument, |
1389 KErrArgument, |
1307 KErrDescrInvalid, |
1390 KErrDescrInvalid, |
1308 KScreenshotServiceUid ); |
1391 KScreenshotServiceUid ); |
1309 return; |
1392 return; |
1310 } |
1393 } |
|
1394 |
|
1395 bool screenNumberSet = false; |
|
1396 if ( (aMessage.Length() > KSeriesScreenNumber) && |
|
1397 ((aMessage[aMessage.Length()-1] == 0) || (aMessage[aMessage.Length()-1] == 1)) ) |
|
1398 { |
|
1399 TInt screenNumber = aMessage[aMessage.Length()-1]; |
|
1400 screenNumberSet = true; |
|
1401 TInt screens; |
|
1402 TInt ret = HAL::Get(HAL::EDisplayNumberOfScreens, screens); |
|
1403 if(ret) |
|
1404 { |
|
1405 HTI_LOG_FORMAT( "HAL::Get failed %d", ret ); |
|
1406 User::Leave(ret); |
|
1407 } |
|
1408 HTI_LOG_FORMAT( "HAL::Get number of screens %d", screens ); |
|
1409 if( ( screenNumber>screens-1 ) || ( screenNumber<0 ) ) |
|
1410 { |
|
1411 iDispatcher->DispatchOutgoingErrorMessage( |
|
1412 KErrArgument, KErrDescrScreenNotSupported, KScreenshotServiceUid); |
|
1413 return; |
|
1414 } |
|
1415 SetScreenNumber(screenNumber); |
|
1416 } |
|
1417 |
1311 TInt duration = ParseInt32( aMessage.Ptr() + KSeriesDurationOffset ); |
1418 TInt duration = ParseInt32( aMessage.Ptr() + KSeriesDurationOffset ); |
1312 TInt interval = ParseInt32( aMessage.Ptr() + KSeriesIntervalOffset ); |
1419 TInt interval = ParseInt32( aMessage.Ptr() + KSeriesIntervalOffset ); |
1313 |
1420 |
1314 TDisplayMode displayMode = ( TDisplayMode ) aMessage[KSeriesDisplayOffset]; |
1421 TDisplayMode displayMode = ( TDisplayMode ) aMessage[KSeriesDisplayOffset]; |
1315 if ( displayMode >= EColorLast ) |
1422 if ( displayMode >= EColorLast ) |
1318 KErrArgument, |
1425 KErrArgument, |
1319 KErrDescrInvalidMode, |
1426 KErrDescrInvalidMode, |
1320 KScreenshotServiceUid ); |
1427 KScreenshotServiceUid ); |
1321 return; |
1428 return; |
1322 } |
1429 } |
1323 |
1430 |
1324 if ( aMessage.Length() > KSeriesMIMEOffset ) |
1431 if ( aMessage.Length() > KSeriesMIMEOffset ) |
1325 { |
1432 { |
1326 mime.Set( aMessage.Mid( KSeriesMIMEOffset ) ); |
1433 if(screenNumberSet) |
|
1434 { |
|
1435 mime.Set( aMessage.Mid( KSeriesMIMEOffset, aMessage.Length()-1-KSeriesMIMEOffset ) ); |
|
1436 } |
|
1437 else |
|
1438 { |
|
1439 mime.Set( aMessage.Mid( KSeriesMIMEOffset ) ); |
|
1440 } |
1327 if ( !IsMIMETypeSupported( mime ) ) |
1441 if ( !IsMIMETypeSupported( mime ) ) |
1328 { |
1442 { |
1329 iDispatcher->DispatchOutgoingErrorMessage( |
1443 iDispatcher->DispatchOutgoingErrorMessage( |
1330 KErrArgument, |
1444 KErrArgument, |
1331 KErrDescrMIMENotSupported, |
1445 KErrDescrMIMENotSupported, |
1340 return; |
1454 return; |
1341 |
1455 |
1342 case ECmdScreenRegionSeries: |
1456 case ECmdScreenRegionSeries: |
1343 case ECmdScreenRegionZipSeries: |
1457 case ECmdScreenRegionZipSeries: |
1344 { |
1458 { |
|
1459 bool screenNumberSet = false; |
|
1460 if ( (aMessage.Length() > KRegionSeriesScreenNumber) && |
|
1461 ((aMessage[aMessage.Length()-1] == 0) || (aMessage[aMessage.Length()-1] == 1)) ) |
|
1462 { |
|
1463 TInt screenNumber = aMessage[aMessage.Length()-1]; |
|
1464 screenNumberSet = true; |
|
1465 TInt screens; |
|
1466 TInt ret = HAL::Get(HAL::EDisplayNumberOfScreens, screens); |
|
1467 if(ret) |
|
1468 { |
|
1469 HTI_LOG_FORMAT( "HAL::Get failed %d", ret ); |
|
1470 User::Leave(ret); |
|
1471 } |
|
1472 HTI_LOG_FORMAT( "HAL::Get number of screens %d", screens ); |
|
1473 if( ( screenNumber>screens-1 ) || ( screenNumber<0 ) ) |
|
1474 { |
|
1475 iDispatcher->DispatchOutgoingErrorMessage( |
|
1476 KErrArgument, KErrDescrScreenNotSupported, KScreenshotServiceUid); |
|
1477 return; |
|
1478 } |
|
1479 SetScreenNumber(screenNumber); |
|
1480 } |
|
1481 |
1345 if ( aMessage.Length() < KMinRegionSeriesCmdLength ) |
1482 if ( aMessage.Length() < KMinRegionSeriesCmdLength ) |
1346 { |
1483 { |
1347 iDispatcher->DispatchOutgoingErrorMessage( |
1484 iDispatcher->DispatchOutgoingErrorMessage( |
1348 KErrArgument, |
1485 KErrArgument, |
1349 KErrDescrInvalid, |
1486 KErrDescrInvalid, |
1401 KErrArgument, |
1538 KErrArgument, |
1402 KErrDescrRegionOutOfScreen, |
1539 KErrDescrRegionOutOfScreen, |
1403 KScreenshotServiceUid ); |
1540 KScreenshotServiceUid ); |
1404 return; |
1541 return; |
1405 } |
1542 } |
1406 |
1543 |
1407 if ( aMessage.Length() > KRegionSeriesMIMEOffset ) |
1544 if ( aMessage.Length() > KRegionSeriesMIMEOffset ) |
1408 { |
1545 { |
1409 mime.Set( aMessage.Mid( KRegionSeriesMIMEOffset ) ); |
1546 if(screenNumberSet) |
|
1547 { |
|
1548 mime.Set( aMessage.Mid( KRegionSeriesMIMEOffset, aMessage.Length()-1-KRegionSeriesMIMEOffset ) ); |
|
1549 } |
|
1550 else |
|
1551 { |
|
1552 mime.Set( aMessage.Mid( KRegionSeriesMIMEOffset ) ); |
|
1553 } |
1410 if ( !IsMIMETypeSupported( mime ) ) |
1554 if ( !IsMIMETypeSupported( mime ) ) |
1411 { |
1555 { |
1412 iDispatcher->DispatchOutgoingErrorMessage( |
1556 iDispatcher->DispatchOutgoingErrorMessage( |
1413 KErrArgument, |
1557 KErrArgument, |
1414 KErrDescrMIMENotSupported, |
1558 KErrDescrMIMENotSupported, |
1524 respMsg.Append( focusScreen ); |
1668 respMsg.Append( focusScreen ); |
1525 iDispatcher->DispatchOutgoingMessage( |
1669 iDispatcher->DispatchOutgoingMessage( |
1526 respMsg.AllocL(), KScreenshotServiceUid ); |
1670 respMsg.AllocL(), KScreenshotServiceUid ); |
1527 } |
1671 } |
1528 return; |
1672 return; |
1529 |
1673 case ECmdRotateScreen: |
|
1674 { |
|
1675 if (aMessage.Length() != KRotateScreenCmdLength) |
|
1676 { |
|
1677 iDispatcher->DispatchOutgoingErrorMessage(KErrArgument, |
|
1678 KErrDescrInvalid, KScreenshotServiceUid); |
|
1679 return; |
|
1680 } |
|
1681 HandleRotateScreen(aMessage.Right(aMessage.Length() -1)); |
|
1682 return; |
|
1683 } |
1530 default: |
1684 default: |
1531 //Error: unknown command |
1685 //Error: unknown command |
1532 iDispatcher->DispatchOutgoingErrorMessage( |
1686 iDispatcher->DispatchOutgoingErrorMessage( |
1533 KErrArgument, |
1687 KErrArgument, |
1534 KErrDescrUnknownCommand, |
1688 KErrDescrUnknownCommand, |
1557 } |
1711 } |
1558 |
1712 |
1559 HTI_LOG_FUNC_OUT( "HtiScreenshotServicePlugin::ProcessMessage" ); |
1713 HTI_LOG_FUNC_OUT( "HtiScreenshotServicePlugin::ProcessMessage" ); |
1560 } |
1714 } |
1561 |
1715 |
1562 |
1716 // ---------------------------------------------------------------------------- |
|
1717 void CHtiScreenshotServicePlugin::HandleRotateScreen(const TDesC8& aData) |
|
1718 { |
|
1719 HTI_LOG_FUNC_IN( "CHtiScreenshotServicePlugin::HandleRotateScreen" ); |
|
1720 |
|
1721 TInt orientation = aData[0]; |
|
1722 if (orientation > 1 || orientation < 0) |
|
1723 { |
|
1724 iDispatcher->DispatchOutgoingErrorMessage(KErrArgument, |
|
1725 KErrDescrInvalid, KScreenshotServiceUid); |
|
1726 return; |
|
1727 } |
|
1728 |
|
1729 TBool isLandScape = orientation; |
|
1730 |
|
1731 RWsSession ws; |
|
1732 User::LeaveIfError(ws.Connect()); |
|
1733 CWsScreenDevice* screenDevice = new (ELeave) CWsScreenDevice(ws); |
|
1734 CleanupStack::PushL(screenDevice); |
|
1735 User::LeaveIfError(screenDevice->Construct()); |
|
1736 TSize currentScreenSize = screenDevice->SizeInPixels(); |
|
1737 |
|
1738 TBool needsRotating = ETrue; |
|
1739 if (currentScreenSize.iWidth > currentScreenSize.iHeight && isLandScape) |
|
1740 { |
|
1741 // we are already in landscape |
|
1742 HTI_LOG_TEXT("The screen are already in landscape."); |
|
1743 needsRotating = EFalse; |
|
1744 } |
|
1745 if (currentScreenSize.iWidth < currentScreenSize.iHeight |
|
1746 && (!isLandScape)) |
|
1747 { |
|
1748 // we are already in portrait |
|
1749 HTI_LOG_TEXT("The screen are already in portrait."); |
|
1750 needsRotating = EFalse; |
|
1751 } |
|
1752 |
|
1753 CAknLayoutConfig* layoutConfigPtr = CAknLayoutConfig::NewL(); |
|
1754 CleanupStack::PushL(layoutConfigPtr); |
|
1755 |
|
1756 CAknLayoutConfig& layoutConfig = *layoutConfigPtr; |
|
1757 |
|
1758 const CAknLayoutConfig::THardwareStateArray& hwStates = |
|
1759 layoutConfig.HardwareStates(); |
|
1760 const CAknLayoutConfig::TScreenModeArray& screenModes = |
|
1761 layoutConfig.ScreenModes(); |
|
1762 |
|
1763 TInt newHwStateIndex = KErrNotFound; |
|
1764 |
|
1765 // lets select alternate state from current |
|
1766 TSize newScreenSize; |
|
1767 if (needsRotating) |
|
1768 { |
|
1769 newScreenSize = TSize(currentScreenSize.iHeight, |
|
1770 currentScreenSize.iWidth); |
|
1771 HTI_LOG_FORMAT("Rotate the screen to the new width %d", newScreenSize.iWidth); |
|
1772 HTI_LOG_FORMAT("Rotate the screen to the new height %d", newScreenSize.iHeight); |
|
1773 } |
|
1774 else // basicly select current state again to ensure correct mode is informed to akncapserver |
|
1775 { |
|
1776 newScreenSize = TSize(currentScreenSize.iWidth, |
|
1777 currentScreenSize.iHeight); |
|
1778 } |
|
1779 |
|
1780 for (TInt i = 0; i < hwStates.Count(); i++) |
|
1781 { |
|
1782 const CAknLayoutConfig::THardwareState hwState = hwStates.At(i); |
|
1783 |
|
1784 const CAknLayoutConfig::TScreenMode normal = screenModes.Find( |
|
1785 hwState.ScreenMode()); |
|
1786 |
|
1787 if (normal.SizeInPixels() == newScreenSize) |
|
1788 { |
|
1789 newHwStateIndex = i; |
|
1790 break; |
|
1791 } |
|
1792 } |
|
1793 |
|
1794 if (newHwStateIndex >= 0) |
|
1795 { |
|
1796 const CAknLayoutConfig::THardwareState newHwState = hwStates.At( |
|
1797 newHwStateIndex); |
|
1798 TApaTaskList taskList(ws); |
|
1799 TApaTask aknCapsrvTask = taskList.FindApp(KAknCapServerUid); |
|
1800 TInt keyCode = newHwState.KeyCode(); |
|
1801 HTI_LOG_FORMAT( "Send key code %d to akncapserver", keyCode ); |
|
1802 aknCapsrvTask.SendKey(keyCode, 0); |
|
1803 } |
|
1804 |
|
1805 TBuf8<1> okMsg; |
|
1806 okMsg.Append(0); |
|
1807 iDispatcher->DispatchOutgoingMessage(okMsg.AllocL(), |
|
1808 KScreenshotServiceUid); |
|
1809 |
|
1810 CleanupStack::PopAndDestroy(layoutConfigPtr); |
|
1811 CleanupStack::PopAndDestroy(screenDevice); |
|
1812 ws.Close(); |
|
1813 |
|
1814 HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::HandleRotateScreen" ); |
|
1815 } |
1563 // ---------------------------------------------------------------------------- |
1816 // ---------------------------------------------------------------------------- |
1564 void CHtiScreenshotServicePlugin::CreateBitmapL( TRect& aRegion, |
1817 void CHtiScreenshotServicePlugin::CreateBitmapL( TRect& aRegion, |
1565 TDisplayMode aMode ) |
1818 TDisplayMode aMode ) |
1566 { |
1819 { |
1567 HTI_LOG_FUNC_IN( "CreateBitmapL" ); |
1820 HTI_LOG_FUNC_IN( "CreateBitmapL" ); |
1575 delete iScreen;//in case ICLComplete was not called |
1828 delete iScreen;//in case ICLComplete was not called |
1576 iScreen = NULL; |
1829 iScreen = NULL; |
1577 iScreen = new( ELeave ) CFbsBitmap; |
1830 iScreen = new( ELeave ) CFbsBitmap; |
1578 User::LeaveIfError( iScreen->Create( imageSize, displayMode ) ); |
1831 User::LeaveIfError( iScreen->Create( imageSize, displayMode ) ); |
1579 |
1832 |
|
1833 TInt err = KErrNone; |
|
1834 TRect region; |
1580 if ( aRegion.IsEmpty() ) |
1835 if ( aRegion.IsEmpty() ) |
1581 { |
1836 { |
1582 iScreenDevice->CopyScreenToBitmap( iScreen ); |
1837 err = iScreenDevice->CopyScreenToBitmap( iScreen ); |
|
1838 region = imageSize; |
1583 } |
1839 } |
1584 else |
1840 else |
1585 { |
1841 { |
1586 iScreenDevice->CopyScreenToBitmap( iScreen, aRegion ); |
1842 err = iScreenDevice->CopyScreenToBitmap( iScreen, aRegion ); |
1587 } |
1843 region = aRegion; |
1588 |
1844 } |
|
1845 if (err == KErrNoMemory) |
|
1846 { |
|
1847 HTI_LOG_TEXT( "screenshot in camera mode" ); |
|
1848 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
1849 err = CAlfDrawer::FallbackCopyScreenToBitmap(*iScreenDevice, iScreen, region); |
|
1850 #endif |
|
1851 } |
1589 |
1852 |
1590 if ( iDeltaCapture ) |
1853 if ( iDeltaCapture ) |
1591 { |
1854 { |
1592 HTI_LOG_TEXT( "DeltaCapture enabled" ); |
1855 HTI_LOG_TEXT( "DeltaCapture enabled" ); |
1593 |
1856 |
1959 HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::StartShot" ); |
2222 HTI_LOG_FUNC_OUT( "CHtiScreenshotServicePlugin::StartShot" ); |
1960 return iScreen ? ETrue : EFalse; |
2223 return iScreen ? ETrue : EFalse; |
1961 } |
2224 } |
1962 |
2225 |
1963 // ---------------------------------------------------------------------------- |
2226 // ---------------------------------------------------------------------------- |
|
2227 void CHtiScreenshotServicePlugin::SetScreenNumber(TInt aScreenNumber) |
|
2228 { |
|
2229 HTI_LOG_FUNC_IN("CHtiScreenshotServicePlugin::SetScreenNumber"); |
|
2230 TInt currentScreen = iScreenDevice->GetScreenNumber(); |
|
2231 HTI_LOG_FORMAT("current screen: %d", currentScreen); |
|
2232 HTI_LOG_FORMAT("new screen number: %d", aScreenNumber); |
|
2233 if(aScreenNumber == currentScreen) |
|
2234 { |
|
2235 return; |
|
2236 } |
|
2237 |
|
2238 // Clear the previous delta bitmap to avoid error |
|
2239 iPreviousBitmap->Reset(); |
|
2240 //delete old screendevice and create a new one |
|
2241 delete iScreenDevice; |
|
2242 iScreenDevice = NULL; |
|
2243 iScreenDevice = new (ELeave) CWsScreenDevice(iWs); |
|
2244 User::LeaveIfError(iScreenDevice->Construct(aScreenNumber)); |
|
2245 HTI_LOG_FUNC_OUT("CHtiScreenshotServicePlugin::SetScreenNumber"); |
|
2246 } |
|
2247 |
|
2248 // ---------------------------------------------------------------------------- |
1964 CSeriesShot* CSeriesShot::NewL( MSeriesShotObserver* aServicePlugin ) |
2249 CSeriesShot* CSeriesShot::NewL( MSeriesShotObserver* aServicePlugin ) |
1965 { |
2250 { |
1966 HTI_LOG_FUNC_IN( "CSeriesShot::NewL" ); |
2251 HTI_LOG_FUNC_IN( "CSeriesShot::NewL" ); |
1967 CSeriesShot* self = new (ELeave) CSeriesShot( aServicePlugin ); |
2252 CSeriesShot* self = new (ELeave) CSeriesShot( aServicePlugin ); |
1968 CleanupStack::PushL (self); |
2253 CleanupStack::PushL (self); |