+ def deleteFile(self):
+ if self.currList == "filelist":
+ self.service = self.filelist.getServiceRef()
+ else:
+ self.service = self.playlist.getSelection()
+ if self.service is None:
+ return
+ if self.service.type != 4098 and self.session.nav.getCurrentlyPlayingServiceReference() is not None:
+ if self.service == self.session.nav.getCurrentlyPlayingServiceReference():
+ self.stopEntry()
+
+ serviceHandler = eServiceCenter.getInstance()
+ offline = serviceHandler.offlineOperations(self.service)
+ info = serviceHandler.info(self.service)
+ name = info and info.getName(self.service)
+ result = False
+ if offline is not None:
+ # simulate first
+ if not offline.deleteFromDisk(1):
+ result = True
+ if result == True:
+ self.session.openWithCallback(self.deleteConfirmed_offline, MessageBox, _("Do you really want to delete %s?") % (name))
+ else:
+ self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR)
+
+ def deleteConfirmed_offline(self, confirmed):
+ if confirmed:
+ serviceHandler = eServiceCenter.getInstance()
+ offline = serviceHandler.offlineOperations(self.service)
+ result = False
+ if offline is not None:
+ # really delete!
+ if not offline.deleteFromDisk(0):
+ result = True
+ if result == False:
+ self.session.open(MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR)
+ else:
+ self.removeListEntry()
+
+ def removeListEntry(self):
+ currdir = self.filelist.getCurrentDirectory()
+ self.filelist.changeDir(currdir)
+ deleteend = False
+ while not deleteend:
+ index = 0
+ deleteend = True
+ if len(self.playlist) > 0:
+ for x in self.playlist.list:
+ if self.service == x[0]:
+ self.playlist.deleteFile(index)
+ deleteend = False
+ break
+ index += 1
+ self.playlist.updateList()
+ if self.currList == "playlist":
+ if len(self.playlist) == 0:
+ self.switchToFileList()
+