X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FSystemPlugins%2FHotplug%2Fplugin.py;h=84cbbcb62d605790db46280ec427e6f9c41abe1c;hp=b19007c993d93c7e7ea895c1809ab09d3d53388e;hb=03706708fac0d7ac8cf0b63af9e473416f42e1b5;hpb=b37fb8b50e48795882cd933c8ef9fe31b3ef007d diff --git a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py index b19007c..84cbbcb 100644 --- a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py @@ -1,66 +1,300 @@ from Plugins.Plugin import PluginDescriptor -from twisted.internet.protocol import Protocol, Factory -from twisted.internet import reactor from Components.Harddisk import harddiskmanager +from Tools.Directories import fileExists hotplugNotifier = [ ] +bdpoll = None -class Hotplug(Protocol): - def connectionMade(self): - self.received = "" +def processHotplugData(self, v): + print "hotplug:", v + action = v.get("ACTION") + device = v.get("DEVPATH") + physdevpath = v.get("PHYSDEVPATH") + media_state = v.get("X_E2_MEDIA_STATUS") - def dataReceived(self, data): - self.received += data + dev = device.split('/')[-1] - def connectionLost(self, reason): - data = self.received.split('\0')[:-1] + if action is not None and action == "add": + error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(dev, physdevpath) + if bdpoll and removable or is_cdrom: + bdpoll.addDevice(dev, is_cdrom, medium_found) + elif action is not None and action == "remove": + if bdpoll: + bdpoll.removeDevice(dev) + harddiskmanager.removeHotplugPartition(dev) + elif media_state is not None: + if media_state == '1': + harddiskmanager.removeHotplugPartition(dev) + harddiskmanager.addHotplugPartition(dev, physdevpath) + elif media_state == '0': + harddiskmanager.removeHotplugPartition(dev) - v = {} + for callback in hotplugNotifier: + try: + callback(dev, action or media_state) + except AttributeError: + hotplugNotifier.remove(callback) - for x in data: - i = x.find('=') - var, val = x[:i], x[i+1:] - v[var] = val +CDROM_DRIVE_STATUS = 0x5326 +CDROM_MEDIA_CHANGED = 0x5325 +CDSL_CURRENT = ((int)(~0>>1)) +CDS_NO_INFO = 0 +CDS_NO_DISC = 1 +CDS_TRAY_OPEN = 2 +CDS_DRIVE_NOT_READY = 3 +CDS_DISC_OK = 4 +ENOMEDIUM = 159 +IOC_NRBITS = 8 +IOC_NRSHIFT = 0 +IOC_TYPESHIFT = (IOC_NRSHIFT+IOC_NRBITS) +BLKRRPART = ((0x12<