43 #include "DRMRightsCleaner.h" |
43 #include "DRMRightsCleaner.h" |
44 #include "DRMRightsServer.h" |
44 #include "DRMRightsServer.h" |
45 #include "DrmKeyStorage.h" |
45 #include "DrmKeyStorage.h" |
46 #include "utf.h" // charconv, ConvertFromUnicodeToUtf8L |
46 #include "utf.h" // charconv, ConvertFromUnicodeToUtf8L |
47 #include "drmlog.h" |
47 #include "drmlog.h" |
|
48 #include "DRMRightsServer.h" |
48 |
49 |
49 #ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL |
50 #ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL |
50 #include "DRMClockClient.h" |
51 #include "DRMClockClient.h" |
51 #endif // RD_DRM_RIGHTS_MANAGER_REMOVAL |
52 #endif // RD_DRM_RIGHTS_MANAGER_REMOVAL |
52 |
53 |
159 // CDRMRightsDB::CDRMRightsDB |
160 // CDRMRightsDB::CDRMRightsDB |
160 // C++ default constructor can NOT contain any code, that |
161 // C++ default constructor can NOT contain any code, that |
161 // might leave. |
162 // might leave. |
162 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
163 // |
164 // |
164 CDRMRightsDB::CDRMRightsDB( RFs& aFs ) : |
165 CDRMRightsDB::CDRMRightsDB( RFs& aFs, CDRMRightsServer* aServer ) : |
165 iFileServer( aFs ), |
166 iFileServer( aFs ), |
166 iImei( NULL ), |
167 iImei( NULL ), |
167 iLastUpdate( Time::NullTTime() ) |
168 iLastUpdate( Time::NullTTime() ), |
|
169 iRightsServer( aServer ) |
168 { |
170 { |
169 }; |
171 }; |
170 |
172 |
171 |
173 |
172 // ----------------------------------------------------------------------------- |
174 // ----------------------------------------------------------------------------- |
213 // ----------------------------------------------------------------------------- |
215 // ----------------------------------------------------------------------------- |
214 // |
216 // |
215 CDRMRightsDB* CDRMRightsDB::NewLC( RFs& aFs, |
217 CDRMRightsDB* CDRMRightsDB::NewLC( RFs& aFs, |
216 const TDesC& aDatabasePath, |
218 const TDesC& aDatabasePath, |
217 const TDesC8& aKey, |
219 const TDesC8& aKey, |
218 const TDesC& aImei ) |
220 const TDesC& aImei, |
219 { |
221 CDRMRightsServer* aServer ) |
220 CDRMRightsDB* self = new( ELeave ) CDRMRightsDB( aFs ); |
222 { |
|
223 CDRMRightsDB* self = new( ELeave ) CDRMRightsDB( aFs, aServer ); |
221 CleanupStack::PushL( self ); |
224 CleanupStack::PushL( self ); |
222 self->ConstructL( aDatabasePath, aKey, aImei ); |
225 self->ConstructL( aDatabasePath, aKey, aImei ); |
223 |
226 |
224 return self; |
227 return self; |
225 }; |
228 }; |
230 // ----------------------------------------------------------------------------- |
233 // ----------------------------------------------------------------------------- |
231 // |
234 // |
232 CDRMRightsDB* CDRMRightsDB::NewL( RFs& aFs, |
235 CDRMRightsDB* CDRMRightsDB::NewL( RFs& aFs, |
233 const TDesC& aDatabaseFile, |
236 const TDesC& aDatabaseFile, |
234 const TDesC8& aKey, |
237 const TDesC8& aKey, |
235 const TDesC& aImei ) |
238 const TDesC& aImei, |
236 { |
239 CDRMRightsServer* aServer ) |
237 CDRMRightsDB* self = NewLC( aFs, aDatabaseFile, aKey, aImei ); |
240 { |
|
241 CDRMRightsDB* self = NewLC( aFs, aDatabaseFile, aKey, aImei, aServer ); |
238 CleanupStack::Pop(); |
242 CleanupStack::Pop(); |
239 |
243 |
240 return self; |
244 return self; |
241 }; |
245 }; |
242 |
246 |
1066 } |
1070 } |
1067 } |
1071 } |
1068 CleanupStack::PopAndDestroy(); // rights |
1072 CleanupStack::PopAndDestroy(); // rights |
1069 |
1073 |
1070 DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL <-" ) ); |
1074 DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL <-" ) ); |
|
1075 |
|
1076 return retVal; |
|
1077 } |
|
1078 |
|
1079 |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // CDRMRightsDB::DeleteExpiredL |
|
1082 // ----------------------------------------------------------------------------- |
|
1083 // |
|
1084 TBool CDRMRightsDB::DeleteExpiredL( const TFileName& aFileName, |
|
1085 const TTime& aTime, |
|
1086 const TDesC8& aContentId ) |
|
1087 { |
|
1088 CDRMRightsData* rights = NULL; |
|
1089 TInt amountLeft = -1; |
|
1090 TBool retVal = EFalse; |
|
1091 TBool parents = EFalse; |
|
1092 |
|
1093 DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL(2) ->" ) ); |
|
1094 |
|
1095 // if there is a consumption session ongoing, we can't delete it at all |
|
1096 // or the decryption will not function properly after pause etc |
|
1097 if( iRightsServer->IsAccessingUrl( aContentId ) != KErrNotFound ) |
|
1098 { |
|
1099 return EFalse; |
|
1100 } |
|
1101 |
|
1102 // Indicate that the DB is updated |
|
1103 iLastUpdate.HomeTime(); |
|
1104 |
|
1105 // Open the rights file |
|
1106 DRMLOG( _L("Opening the file")); |
|
1107 rights = CDRMRightsData::OpenLC( aFileName, iFileServer ); |
|
1108 |
|
1109 DRMLOG( _L("Running Delete")); |
|
1110 amountLeft = rights->DeleteExpiredPermissionsL( aTime, parents ); |
|
1111 |
|
1112 DRMLOG2( _L("Checking for left RO:s %d"), amountLeft ); |
|
1113 |
|
1114 // See if any permissions are left if not check if the whole file |
|
1115 // can be proposed to be deleted or not, Java files require uninstallation |
|
1116 // so those need to be checked |
|
1117 if( !amountLeft && !parents ) |
|
1118 { |
|
1119 // get the common data |
|
1120 const CDRMCommonData* common= rights->GetCommonDataL(); |
|
1121 |
|
1122 // If it is a java file, dont allow deletion |
|
1123 if( !common->ContentName().Right(4).CompareF(KJavaExtension) ) |
|
1124 { |
|
1125 DRMLOG( _L("Is java file, do not delete")); |
|
1126 retVal = EFalse; |
|
1127 } |
|
1128 else if( !common->ContentName().Right(4).CompareF(KSISExtension) ) |
|
1129 { |
|
1130 DRMLOG( _L("Is an installation package, do not delete")); |
|
1131 retVal = EFalse; |
|
1132 } |
|
1133 else |
|
1134 { |
|
1135 retVal = ETrue; |
|
1136 } |
|
1137 } |
|
1138 CleanupStack::PopAndDestroy(); // rights |
|
1139 |
|
1140 DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL <-" ) ); |
|
1141 |
|
1142 if( iRightsServer->HasActiveCountConstraint( aContentId )) |
|
1143 { |
|
1144 retVal = EFalse; |
|
1145 } |
1071 |
1146 |
1072 return retVal; |
1147 return retVal; |
1073 } |
1148 } |
1074 |
1149 |
1075 |
1150 |