142 |
142 |
143 // a list of change event messages a result of the item being removed |
143 // a list of change event messages a result of the item being removed |
144 CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); |
144 CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); |
145 CleanupStack::PushL( itemChangedMessages ); |
145 CleanupStack::PushL( itemChangedMessages ); |
146 |
146 |
147 DeleteEpisodeL( episodeId, *fp, *itemChangedMessages, ETrue ); |
147 //Isadd is passed as true as its called from AddEpisodeL |
|
148 //IsAdd true means dont decrement the episode count from tables like |
|
149 //Artist Genere, Album, and Composer , which is not needed when |
|
150 //DeleteEpisodeL is called as part of Add operation |
|
151 TRAPD( err, DeleteEpisodeL( episodeId, *fp, *itemChangedMessages, ETrue, ETrue ) ); |
|
152 |
|
153 if ( err != KErrNone ) // EpisodeExistL has found a record from a previously deleted episode, cleanup it now |
|
154 { |
|
155 iDbManager.ExecuteQueryL( aDrive, KQueryPodcastDelete(), episodeId ); |
|
156 } |
148 |
157 |
149 CleanupStack::PopAndDestroy( itemChangedMessages ); |
158 CleanupStack::PopAndDestroy( itemChangedMessages ); |
150 CleanupStack::PopAndDestroy( fp ); |
159 CleanupStack::PopAndDestroy( fp ); |
151 } |
160 } |
152 // add the song |
161 // add the song |
185 // ---------------------------------------------------------------------------- |
194 // ---------------------------------------------------------------------------- |
186 // |
195 // |
187 void CMPXDbPodcast::DeleteEpisodeL( |
196 void CMPXDbPodcast::DeleteEpisodeL( |
188 TUint32 aEpisodeId, |
197 TUint32 aEpisodeId, |
189 CDesCArray& aUriArray, |
198 CDesCArray& aUriArray, |
190 CMPXMessageArray& aItemChangedMessages, |
199 CMPXMessageArray& aItemChangedMessages, TBool IsAdd, |
191 TBool aDeleteRecord) |
200 TBool aDeleteRecord) |
192 { |
201 { |
193 MPX_FUNC("CMPXDbPodcast::DeleteEpisodeL"); |
202 MPX_FUNC("CMPXDbPodcast::DeleteEpisodeL"); |
194 |
203 |
195 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPodcastGetEpisode, |
204 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryPodcastGetEpisode, |
197 CleanupClosePushL(recordset); |
206 CleanupClosePushL(recordset); |
198 if (recordset.Next() != KSqlAtRow) |
207 if (recordset.Next() != KSqlAtRow) |
199 { |
208 { |
200 User::Leave(KErrNotFound); |
209 User::Leave(KErrNotFound); |
201 } |
210 } |
202 DoDeleteEpisodeL(recordset, aUriArray, aItemChangedMessages, aDeleteRecord); |
211 DoDeleteEpisodeL(recordset, aUriArray, aItemChangedMessages, IsAdd, aDeleteRecord); |
203 CleanupStack::PopAndDestroy(&recordset); |
212 CleanupStack::PopAndDestroy(&recordset); |
204 } |
213 } |
205 |
214 |
206 // ---------------------------------------------------------------------------- |
215 // ---------------------------------------------------------------------------- |
207 // CMPXDbPodcast::DeleteCategoryL |
216 // CMPXDbPodcast::DeleteCategoryL |
1222 // ---------------------------------------------------------------------------- |
1231 // ---------------------------------------------------------------------------- |
1223 // |
1232 // |
1224 void CMPXDbPodcast::DoDeleteEpisodeL( |
1233 void CMPXDbPodcast::DoDeleteEpisodeL( |
1225 RSqlStatement& aRecordset, |
1234 RSqlStatement& aRecordset, |
1226 CDesCArray& aUriArray, |
1235 CDesCArray& aUriArray, |
1227 CMPXMessageArray& aItemChangedMessages, |
1236 CMPXMessageArray& aItemChangedMessages, TBool IsAdd , |
1228 TBool aDeleteRecord) |
1237 TBool aDeleteRecord) |
1229 { |
1238 { |
1230 MPX_FUNC("CMPXDbPodcast::DoDeleteEpisodeL"); |
1239 MPX_FUNC("CMPXDbPodcast::DoDeleteEpisodeL"); |
1231 |
1240 |
1232 // add the full path to the URI array |
1241 // add the full path to the URI array |
1233 HBufC* uri = ConstructUriL(aRecordset); |
1242 HBufC* uri = ConstructUriL(aRecordset); |
1234 CleanupStack::PushL(uri); |
1243 CleanupStack::PushL(uri); |
1235 aUriArray.AppendL(*uri); |
1244 aUriArray.AppendL(*uri); |
1236 TDriveUnit driveUnit(*uri); |
1245 TDriveUnit driveUnit(*uri); |
1237 CleanupStack::PopAndDestroy(uri); |
1246 CleanupStack::PopAndDestroy(uri); |
1238 |
1247 |
1239 // process the author |
1248 //if adding then dont delete episode category |
1240 iObserver.DeleteEpisodeForCategoryL(EMPXArtist, aRecordset.ColumnInt64(EPodcastArtist), |
1249 if(!IsAdd) |
1241 driveUnit, &aItemChangedMessages); |
1250 { |
1242 |
1251 // process the author |
1243 // process the title |
1252 iObserver.DeleteEpisodeForCategoryL(EMPXArtist, aRecordset.ColumnInt64(EPodcastArtist), |
1244 iObserver.DeleteEpisodeForCategoryL(EMPXAlbum, aRecordset.ColumnInt64(EPodcastAlbum), |
1253 driveUnit, &aItemChangedMessages ); |
1245 driveUnit, &aItemChangedMessages); |
1254 |
1246 |
1255 // process the title |
1247 // process the genre |
1256 iObserver.DeleteEpisodeForCategoryL(EMPXAlbum, aRecordset.ColumnInt64(EPodcastAlbum), |
1248 iObserver.DeleteEpisodeForCategoryL(EMPXGenre, aRecordset.ColumnInt64(EPodcastGenre), |
1257 driveUnit, &aItemChangedMessages); |
1249 driveUnit, &aItemChangedMessages); |
1258 |
1250 |
1259 // process the genre |
1251 // process the composer |
1260 iObserver.DeleteEpisodeForCategoryL(EMPXGenre, aRecordset.ColumnInt64(EPodcastGenre), |
1252 iObserver.DeleteEpisodeForCategoryL(EMPXComposer, aRecordset.ColumnInt64(EPodcastComposer), |
1261 driveUnit, &aItemChangedMessages); |
1253 driveUnit, &aItemChangedMessages); |
1262 |
|
1263 // process the composer |
|
1264 iObserver.DeleteEpisodeForCategoryL(EMPXComposer, aRecordset.ColumnInt64(EPodcastComposer), |
|
1265 driveUnit, &aItemChangedMessages); |
|
1266 } |
|
1267 |
|
1268 |
1254 |
1269 |
1255 // add a change event for removing the episode itself |
1270 // add a change event for removing the episode itself |
1256 TUint32 episodeId(aRecordset.ColumnInt64(EPodcastUniqueId)); |
1271 TUint32 episodeId(aRecordset.ColumnInt64(EPodcastUniqueId)); |
1257 MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, episodeId, |
1272 MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, episodeId, |
1258 EMPXItemDeleted, EMPXPodcast, KDBPluginUid); |
1273 EMPXItemDeleted, EMPXPodcast, KDBPluginUid); |