1 from Plugins.Plugin import PluginDescriptor
2 from Components.Scanner import scanDevice
3 from Screens.InfoBar import InfoBar
6 print "execute", option
10 (_, scanner, files, session) = option
11 scanner.open(files, session)
13 def mountpoint_choosen(option):
17 from Screens.ChoiceBox import ChoiceBox
19 (description, mountpoint, session) = option
20 res = scanDevice(mountpoint)
22 list = [ (r.description, r, res[r], session) for r in res ]
26 from Screens.MessageBox import MessageBox
27 session.open(MessageBox, "No displayable files on this medium found!", MessageBox.TYPE_ERROR)
30 session.openWithCallback(execute, ChoiceBox,
31 title = "The following files were found...",
35 from Screens.ChoiceBox import ChoiceBox
37 from Components.Harddisk import harddiskmanager
39 parts = [ (r.description, r.mountpoint, session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)]
41 session.openWithCallback(mountpoint_choosen, ChoiceBox, title = _("Please Select Medium to be Scanned"), list = parts)
43 def main(session, **kwargs):
47 mountpoint_choosen(args)
49 from Components.Harddisk import harddiskmanager
52 if menuid != "mainmenu":
55 from Tools.BoundFunction import boundFunction
56 return [(("%s (files)") % r.description, boundFunction(menuEntry, r.description, r.mountpoint), "hotplug_%s" % r.mountpoint, None) for r in harddiskmanager.getMountedPartitions(onlyhotplug = True)]
60 def partitionListChanged(action, device):
62 if InfoBar.instance.execing:
63 if action == 'add' and device.is_hotplug:
64 print "mountpoint", device.mountpoint
65 print "description", device.description
66 print "force_mounted", device.force_mounted
67 mountpoint_choosen((device.description, device.mountpoint, global_session))
69 print "main infobar is not execing... so we ignore hotplug event!"
71 print "hotplug event.. but no infobar"
73 def sessionstart(reason, session):
75 global_session = session
77 def autostart(reason, **kwargs):
80 harddiskmanager.on_partition_list_change.append(partitionListChanged)
82 harddiskmanager.on_partition_list_change.remove(partitionListChanged)
85 def Plugins(**kwargs):
87 PluginDescriptor(name="MediaScanner", description="Scan Files...", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
88 # PluginDescriptor(where = PluginDescriptor.WHERE_MENU, fnc=menuHook),
89 PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart),
90 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart)