77 _LIT8( KErrDescrSetSizeTempFile, "Error allocating size for temp file" ); |
81 _LIT8( KErrDescrSetSizeTempFile, "Error allocating size for temp file" ); |
78 _LIT8( KErrDescrDeleteTempFile, "Error deleting temp file" ); |
82 _LIT8( KErrDescrDeleteTempFile, "Error deleting temp file" ); |
79 _LIT8( KErrDescrSysUtil, "SysUtil failed" ); |
83 _LIT8( KErrDescrSysUtil, "SysUtil failed" ); |
80 _LIT8( KErrDescrSetTime, "Setting time failed" ); |
84 _LIT8( KErrDescrSetTime, "Setting time failed" ); |
81 _LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" ); |
85 _LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" ); |
82 _LIT8( KErrDescrScreenSaver, "Setting screen saver state failed" ); |
|
83 _LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" ); |
86 _LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" ); |
84 _LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" ); |
87 _LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" ); |
85 _LIT8( KErrDescrIrActivation, "IR activation failed" ); |
88 _LIT8( KErrDescrIrActivation, "IR activation failed" ); |
86 _LIT8( KErrDescrGetBtPower, "Getting BT power state failed" ); |
89 _LIT8( KErrDescrGetBtPower, "Getting BT power state failed" ); |
87 _LIT8( KErrDescrSetBtPower, "Setting BT power state failed" ); |
90 _LIT8( KErrDescrSetBtPower, "Setting BT power state failed" ); |
88 _LIT8( KErrDescrBtOnDenied, "Turning BT on not allowed (Offline mode)" ); |
91 _LIT8( KErrDescrBtOnDenied, "Turning BT on not allowed (Offline mode)" ); |
89 _LIT8( KErrDescrBtOffDenied, "Turning BT off not allowed (active connections)" ); |
92 _LIT8( KErrDescrBtOffDenied, "Turning BT off not allowed (active connections)" ); |
90 _LIT8( KErrDescrBtSettings, "Bluetooth settings failed" ); |
93 _LIT8( KErrDescrBtSettings, "Bluetooth settings failed" ); |
91 _LIT8( KErrDescrBtDeletePairings, "Deleting Bluetooth pairing(s) failed" ); |
94 _LIT8( KErrDescrBtDeletePairings, "Deleting Bluetooth pairing(s) failed" ); |
|
95 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
92 _LIT8( KErrDescrKeyLock, "Key lock toggle failed" ); |
96 _LIT8( KErrDescrKeyLock, "Key lock toggle failed" ); |
|
97 _LIT8( KErrDescrScreenSaver, "Setting screen saver state failed" ); |
|
98 _LIT8( KErrDescrInvalidSSTimeout, "Invalid screen saver timeout value" ); |
|
99 _LIT8( KErrDescrSSTimeoutFailed, "Setting screen saver timeout failed" ); |
|
100 #endif |
93 _LIT8( KErrDescrInvalidTime, "Auto key guard time value too large (max 3600)" ); |
101 _LIT8( KErrDescrInvalidTime, "Auto key guard time value too large (max 3600)" ); |
94 _LIT8( KErrDescrAutoKeyGuardFailed, "Setting auto key guard time failed" ); |
102 _LIT8( KErrDescrAutoKeyGuardFailed, "Setting auto key guard time failed" ); |
95 _LIT8( KErrDescrInvalidSSTimeout, "Invalid screen saver timeout value" ); |
|
96 _LIT8( KErrDescrSSTimeoutFailed, "Setting screen saver timeout failed" ); |
|
97 _LIT8( KErrDescrDrmDbConnect, "DRM DB connect failed." ); |
103 _LIT8( KErrDescrDrmDbConnect, "DRM DB connect failed." ); |
98 _LIT8( KErrDescrDrmDbDelete, "DRM DB delete failed." ); |
104 _LIT8( KErrDescrDrmDbDelete, "DRM DB delete failed." ); |
99 _LIT8( KErrDescrBatteryLevel, "Getting battery level failed." ); |
105 _LIT8( KErrDescrBatteryLevel, "Getting battery level failed." ); |
100 _LIT8( KErrDescrChargingStatus, "Getting charging status failed." ); |
106 _LIT8( KErrDescrChargingStatus, "Getting charging status failed." ); |
101 _LIT8( KErrDescrSignalStrength, "Getting signal strength failed." ); |
107 _LIT8( KErrDescrSignalStrength, "Getting signal strength failed." ); |
1086 //------------------------------------------------------------------------------ |
1098 //------------------------------------------------------------------------------ |
1087 // CHtiSysInfoServicePlugin::HandleEatDiskSpaceL |
1099 // CHtiSysInfoServicePlugin::HandleEatDiskSpaceL |
1088 //------------------------------------------------------------------------------ |
1100 //------------------------------------------------------------------------------ |
1089 void CHtiSysInfoServicePlugin::HandleEatDiskSpaceL( const TDesC8& aMessage ) |
1101 void CHtiSysInfoServicePlugin::HandleEatDiskSpaceL( const TDesC8& aMessage ) |
1090 { |
1102 { |
|
1103 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1104 |
1091 if ( aMessage.Length() != 10 ) |
1105 if ( aMessage.Length() != 10 ) |
1092 { |
1106 { |
1093 iDispatcher->DispatchOutgoingErrorMessage( |
1107 iDispatcher->DispatchOutgoingErrorMessage( |
1094 KErrArgument, |
1108 KErrArgument, |
1095 KErrDescrArgument, |
1109 KErrDescrArgument, |
1096 KSysInfoServiceUid ); |
1110 KSysInfoServiceUid ); |
1097 return; |
1111 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
1098 } |
1112 return; |
1099 |
1113 } |
1100 |
1114 |
|
1115 TFileName commonpath; |
|
1116 commonpath.Append( aMessage[1] ); |
|
1117 commonpath.Append( _L( ":" ) ); |
|
1118 commonpath.Append( KTempFilePath ); |
|
1119 commonpath.Append( KTempFileName ); |
1101 TFileName path; |
1120 TFileName path; |
1102 path.Append( aMessage[1] ); |
1121 |
1103 path.Append( _L( ":" ) ); |
|
1104 path.Append( KTempFilePath ); |
|
1105 path.Append( KTempFileName ); |
|
1106 |
|
1107 HTI_LOG_TEXT( "Temp file path:" ); |
|
1108 HTI_LOG_DES( path ); |
|
1109 |
|
1110 // check if previous temp file exists and delete it |
|
1111 if ( BaflUtils::FileExists( iFs, path ) ) |
|
1112 { |
|
1113 TInt err = iFileMan->Delete( path ); |
|
1114 if ( err ) |
|
1115 { |
|
1116 iDispatcher->DispatchOutgoingErrorMessage( |
|
1117 err, |
|
1118 KErrDescrDeleteTempFile, |
|
1119 KSysInfoServiceUid ); |
|
1120 return; |
|
1121 } |
|
1122 } |
|
1123 |
|
1124 // get free disk space |
1122 // get free disk space |
1125 TInt drive; |
1123 TInt drive; |
1126 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
1124 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
1127 TVolumeInfo volInfo; |
1125 TVolumeInfo volInfo; |
1128 TInt err = iFs.Volume( volInfo, drive ); |
1126 TInt err = iFs.Volume( volInfo, drive ); |
1155 { |
1154 { |
1156 iDispatcher->DispatchOutgoingErrorMessage( |
1155 iDispatcher->DispatchOutgoingErrorMessage( |
1157 KErrDiskFull, |
1156 KErrDiskFull, |
1158 KErrDescrNotEnoughSpace, |
1157 KErrDescrNotEnoughSpace, |
1159 KSysInfoServiceUid ); |
1158 KSysInfoServiceUid ); |
|
1159 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
1160 return; |
1160 return; |
1161 } |
1161 } |
1162 |
1162 |
1163 // check if scaceToEat is greater than KMaxTInt |
1163 // check if scaceToEat is greater than KMaxTInt |
1164 // --> it must be eaten in several chunks |
1164 // --> it must be eaten in several chunks |
1165 // --> not yet supported. |
1165 // --> not yet supported. |
1166 if ( spaceToEat > KMaxTInt ) |
1166 |
1167 { |
1167 TInt64 size; |
1168 HTI_LOG_TEXT( "Cannot allocate a file bigger than KMaxTInt" ); |
1168 for(TInt i=1; spaceToEat>0; i++) |
1169 |
1169 { |
1170 iDispatcher->DispatchOutgoingErrorMessage( |
1170 path.Zero(); |
1171 KErrOverflow, |
1171 path.Copy(commonpath); |
1172 KErrDescrSetSizeTempFile, |
1172 path.AppendNum(i); |
1173 KSysInfoServiceUid ); |
1173 if ( BaflUtils::FileExists( iFs, path ) ) |
1174 return; |
1174 { |
1175 } |
1175 continue; |
1176 |
1176 } |
1177 // create a temp file |
1177 |
1178 RFile diskEater; |
1178 if(spaceToEat > KMaxTInt) |
1179 err = diskEater.Replace( iFs, path, EFileWrite ); |
1179 size=KMaxTInt; |
1180 if ( err ) |
1180 else |
1181 { |
1181 size=spaceToEat; |
1182 iDispatcher->DispatchOutgoingErrorMessage( |
1182 |
1183 err, |
1183 err = CreatFileToEatDiskSpace(path, size); |
1184 KErrDescrCreateTempFile, |
1184 if(err) |
1185 KSysInfoServiceUid ); |
1185 { |
1186 return; |
1186 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL CreateFile Fail" ); |
1187 } |
1187 return; |
1188 |
1188 } |
1189 // set the size for temp file |
1189 |
1190 err = diskEater.SetSize( I64LOW( spaceToEat ) ); |
1190 iFs.Volume( volInfo, drive ); |
1191 if ( err ) |
1191 HTI_LOG_FORMAT( "current free space: %Ld", volInfo.iFree ); |
1192 { |
1192 spaceToEat = volInfo.iFree - spaceLeftFree; |
1193 iDispatcher->DispatchOutgoingErrorMessage( |
|
1194 err, |
|
1195 KErrDescrSetSizeTempFile, |
|
1196 KSysInfoServiceUid ); |
|
1197 diskEater.Close(); |
|
1198 return; |
|
1199 } |
|
1200 diskEater.Close(); |
|
1201 |
|
1202 err = iFs.Volume( volInfo, drive ); |
|
1203 if ( err ) |
|
1204 { |
|
1205 iDispatcher->DispatchOutgoingErrorMessage( |
|
1206 err, |
|
1207 KErrDescrVolInfo, |
|
1208 KSysInfoServiceUid ); |
|
1209 return; |
|
1210 } |
1193 } |
1211 |
1194 |
1212 // all ok, send the remaining disk size back |
1195 // all ok, send the remaining disk size back |
1213 iReply = HBufC8::NewL( 8 ); |
1196 iReply = HBufC8::NewL( 8 ); |
1214 iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 ); |
1197 iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 ); |
|
1198 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1199 } |
|
1200 |
|
1201 TInt CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace( TFileName aPath, TInt64 aSpaceToEat ) |
|
1202 { |
|
1203 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace" ); |
|
1204 |
|
1205 HTI_LOG_FORMAT( "Create file: %S", &aPath ); |
|
1206 HTI_LOG_FORMAT( "file size %Ld", aSpaceToEat ); |
|
1207 |
|
1208 // create a temp file |
|
1209 RFile diskEater; |
|
1210 TInt err = diskEater.Replace( iFs, aPath, EFileWrite ); |
|
1211 if ( err ) |
|
1212 { |
|
1213 iDispatcher->DispatchOutgoingErrorMessage( |
|
1214 err, |
|
1215 KErrDescrCreateTempFile, |
|
1216 KSysInfoServiceUid ); |
|
1217 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace Replace error" ); |
|
1218 return err; |
|
1219 } |
|
1220 |
|
1221 // set the size for temp file |
|
1222 err = diskEater.SetSize( I64LOW( aSpaceToEat ) ); |
|
1223 if ( err ) |
|
1224 { |
|
1225 iDispatcher->DispatchOutgoingErrorMessage( |
|
1226 err, |
|
1227 KErrDescrSetSizeTempFile, |
|
1228 KSysInfoServiceUid ); |
|
1229 diskEater.Close(); |
|
1230 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace SetSize error" ); |
|
1231 return err; |
|
1232 } |
|
1233 diskEater.Close(); |
|
1234 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace" ); |
|
1235 return 0; |
1215 } |
1236 } |
1216 |
1237 |
1217 //------------------------------------------------------------------------------ |
1238 //------------------------------------------------------------------------------ |
1218 // CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL |
1239 // CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL |
1219 //------------------------------------------------------------------------------ |
1240 //------------------------------------------------------------------------------ |
1220 void CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL( const TDesC8& aMessage ) |
1241 void CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL( const TDesC8& aMessage ) |
1221 { |
1242 { |
|
1243 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
1222 if ( aMessage.Length() != 2 ) |
1244 if ( aMessage.Length() != 2 ) |
1223 { |
1245 { |
1224 iDispatcher->DispatchOutgoingErrorMessage( |
1246 iDispatcher->DispatchOutgoingErrorMessage( |
1225 KErrArgument, |
1247 KErrArgument, |
1226 KErrDescrArgument, |
1248 KErrDescrArgument, |
1227 KSysInfoServiceUid); |
1249 KSysInfoServiceUid); |
|
1250 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
1228 return; |
1251 return; |
1229 } |
1252 } |
1230 |
1253 |
1231 TFileName path; |
1254 TFileName path; |
1232 path.Append( aMessage[1] ); |
1255 path.Append( aMessage[1] ); |
1233 path.Append( _L( ":" ) ); |
1256 path.Append( _L( ":" ) ); |
1234 path.Append( KTempFilePath ); |
1257 path.Append(KTempFilePath); |
1235 path.Append( KTempFileName ); |
1258 path.Append(KMatchFileName); |
1236 |
1259 TInt err = iFileMan->Delete(path); |
1237 HTI_LOG_TEXT( "Temp file path:" ); |
1260 if ( err ) |
1238 HTI_LOG_DES( path ); |
1261 { |
1239 |
1262 iDispatcher->DispatchOutgoingErrorMessage( |
1240 TInt err = KErrNone; |
|
1241 // check that temp file exists |
|
1242 if ( BaflUtils::FileExists( iFs, path ) ) |
|
1243 { |
|
1244 // try to delete the temp file |
|
1245 err = iFileMan->Delete( path ); |
|
1246 if ( err ) |
|
1247 { |
|
1248 iDispatcher->DispatchOutgoingErrorMessage( |
|
1249 err, |
1263 err, |
1250 KErrDescrDeleteTempFile, |
1264 KErrDescrDeleteTempFile, |
1251 KSysInfoServiceUid ); |
1265 KSysInfoServiceUid ); |
1252 |
1266 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
1253 return; |
1267 return; |
1254 } |
1268 } |
1255 } |
1269 |
1256 |
|
1257 // query the free disk space |
1270 // query the free disk space |
1258 TInt drive; |
1271 TInt drive; |
1259 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
1272 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
1260 TVolumeInfo volInfo; |
1273 TVolumeInfo volInfo; |
1261 err = iFs.Volume( volInfo, drive ); |
1274 err = iFs.Volume( volInfo, drive ); |
1516 iAllowSSSubscriber = NULL; |
1534 iAllowSSSubscriber = NULL; |
1517 } |
1535 } |
1518 |
1536 |
1519 iReply = HBufC8::NewL( 1 ); |
1537 iReply = HBufC8::NewL( 1 ); |
1520 iReply->Des().Append( 0 ); |
1538 iReply->Des().Append( 0 ); |
|
1539 #else |
|
1540 iDispatcher->DispatchOutgoingErrorMessage(KErrArgument, |
|
1541 KErrDescrNotSupported, KSysInfoServiceUid); |
|
1542 #endif |
|
1543 HTI_LOG_FUNC_OUT( |
|
1544 "CHtiSysInfoServicePlugin::HandleScreenSaverCommandL" ); |
1521 } |
1545 } |
1522 |
1546 |
1523 //------------------------------------------------------------------------------ |
1547 //------------------------------------------------------------------------------ |
1524 // CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL |
1548 // CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL |
1525 //------------------------------------------------------------------------------ |
1549 //------------------------------------------------------------------------------ |
1526 void CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL( |
1550 void CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL( |
1527 const TDesC8& aMessage ) |
1551 const TDesC8& aMessage ) |
1528 { |
1552 { |
1529 HTI_LOG_FUNC_IN( |
1553 HTI_LOG_FUNC_IN( |
1530 "CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL" ); |
1554 "CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL" ); |
|
1555 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
1531 if ( aMessage.Length() != 2 ) |
1556 if ( aMessage.Length() != 2 ) |
1532 { |
1557 { |
1533 iDispatcher->DispatchOutgoingErrorMessage( |
1558 iDispatcher->DispatchOutgoingErrorMessage( |
1534 KErrArgument, |
1559 KErrArgument, |
1535 KErrDescrArgument, |
1560 KErrDescrArgument, |
2855 // CHtiSysInfoServicePlugin::CleanUpTempFiles |
2887 // CHtiSysInfoServicePlugin::CleanUpTempFiles |
2856 //------------------------------------------------------------------------------ |
2888 //------------------------------------------------------------------------------ |
2857 TInt CHtiSysInfoServicePlugin::CleanUpTempFiles() |
2889 TInt CHtiSysInfoServicePlugin::CleanUpTempFiles() |
2858 { |
2890 { |
2859 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::CleanUpTempFiles" ); |
2891 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::CleanUpTempFiles" ); |
2860 |
|
2861 TFindFile finder( iFs ); |
2892 TFindFile finder( iFs ); |
2862 TFileName path( KTempFilePath ); |
2893 CDir* dir = NULL; |
2863 TInt err = finder.FindByPath( KTempFileName, &path ); |
2894 TInt err = finder.FindWildByDir(KMatchFileName, KTempFilePath, dir); |
2864 |
2895 TInt safeDeleteCount = 0; |
2865 while ( err == KErrNone ) |
2896 while ( err == KErrNone && safeDeleteCount < 20) |
2866 { |
2897 { |
2867 TFileName tempFile = finder.File(); |
2898 safeDeleteCount++; |
2868 |
2899 TFileName path; |
2869 HTI_LOG_TEXT( "Found temp file: " ); |
2900 path.Copy(finder.File()); |
2870 HTI_LOG_DES( tempFile ); |
2901 HTI_LOG_FORMAT( "found file: %S", &path ); |
2871 |
2902 TInt ret = iFileMan->Delete(path); |
2872 err = iFileMan->Delete( tempFile ); |
2903 delete dir; |
2873 |
2904 dir = NULL; |
2874 // return if deleting does not succeed to prevent mad man loop |
2905 if(ret != KErrNone) |
2875 if ( err != KErrNone ) return err; |
2906 { |
2876 |
2907 break; |
2877 // try to find next temp file |
2908 } |
2878 err = finder.FindByPath( KTempFileName, &path ); |
2909 err = finder.FindWildByDir(KMatchFileName, KTempFilePath, dir); |
2879 } |
2910 } |
2880 |
|
2881 HTI_LOG_FUNC_OUT("CHtiSysInfoServicePlugin::CleanUpTempFiles"); |
2911 HTI_LOG_FUNC_OUT("CHtiSysInfoServicePlugin::CleanUpTempFiles"); |
2882 return KErrNone; |
2912 return KErrNone; |
2883 } |
2913 } |
2884 |
2914 |
2885 //------------------------------------------------------------------------------ |
2915 //------------------------------------------------------------------------------ |