def _get_device_from_model(self, model, dev_info): plugin = PluginManager.get_plugin_by_remote_name(model) if plugin: device = dev_info['callout'].split('/')[-1] set_property = partial(plugin.set_property, emit=True) set_property(MDM_INTFACE, 'Device', device) # XXX: Fix MasterDevice set_property(MDM_INTFACE, 'MasterDevice', 'iokit:com.vodafone.BMC.NotImplemented') # XXX: Fix CDMA set_property(MDM_INTFACE, 'Type', MM_MODEM_TYPE_REV['GSM']) set_property(MDM_INTFACE, 'Driver', 'notimplemented') set_property(MDM_INTFACE, 'IpMethod', MM_IP_METHOD_PPP) set_property(MDM_INTFACE, 'Enabled', False) set_property(MDM_INTFACE, 'UnlockRequired', "") # set to unknown set_property(NET_INTFACE, 'AccessTechnology', 0) # set to -1 so any comparison will fail and will update it set_property(NET_INTFACE, 'AllowedMode', -1) plugin.opath = self._generate_opath() plugin.ports = Ports(dev_info['callout'], dev_info['dialin']) return plugin
def get_os_object(): """ Returns a ``OSPlugin`` instance corresponding to current OS used If the OS is unknown it will return None """ global _os_obj if _os_obj is not None: return _os_obj from wader.common.plugin import PluginManager from wader.common.interfaces import IOSPlugin for osplugin in PluginManager.get_plugins(IOSPlugin): if osplugin.is_valid(): osplugin.initialize() _os_obj = osplugin return _os_obj return None
def identify_device_cb(model): # plugin to return ret = None if model in plugin.mapping: ret = plugin.mapping[model]() elif plugin.__remote_name__ != model: # so we basically have a device identified by vendor & product id # but we know nothing of this model try: ret = PluginManager.get_plugin_by_remote_name(model) except ex.UnknownPluginNameError: plugin.name = model if ret is not None: # we found another plugin during the process ret.patch(plugin) return check_auth_state(ret) # return the original plugin, most of the time this should work return check_auth_state(plugin)
def _get_device_from_info(self, sysfs_path, info): """Returns a `DevicePlugin` out of ``info``""" # order the ports before probing ports = info['DEVICES'] natsort(ports) query = [info.get(key) for key in [VENDOR, MODEL]] plugin = PluginManager.get_plugin_by_vendor_product_id(*query) if plugin: dport = cport = None plugin.sysfs_path = sysfs_path plugin.opath = self._generate_opath() set_property = partial(plugin.set_property, emit=False) # set DBus properties (Modem interface) set_property(consts.MDM_INTFACE, 'IpMethod', consts.MM_IP_METHOD_PPP) set_property(consts.MDM_INTFACE, 'MasterDevice', 'udev:%s' % sysfs_path) # XXX: Fix CDMA set_property(consts.MDM_INTFACE, 'Type', consts.MM_MODEM_TYPE_REV['GSM']) set_property(consts.MDM_INTFACE, 'Driver', info[DRIVER]) set_property(consts.MDM_INTFACE, 'Enabled', False) # set to unknown set_property(consts.NET_INTFACE, 'AccessTechnology', 0) # set to -1 so any comparison will fail and will update it set_property(consts.NET_INTFACE, 'AllowedMode', -1) # preprobe stuff if hasattr(plugin, 'preprobe_init'): # this plugin requires special initialisation before probing plugin.preprobe_init(ports, info) # now get the ports ports_need_probe = True if info[DRIVER] == 'hso': dport, cport = self._get_hso_ports(ports) ports_need_probe = False # if these two properties are present, use them right away and # do not probe if ('ID_MM_PORT_TYPE_MODEM' in info or 'ID_MM_PORT_TYPE_AUX' in info): try: dport = info['ID_MM_PORT_TYPE_MODEM'] log.msg("%s: ID_MM_PORT_TYPE_MODEM" % dport) except KeyError: pass try: cport = info['ID_MM_PORT_TYPE_AUX'] log.msg("%s: ID_MM_PORT_TYPE_AUX" % cport) except KeyError: pass ports_need_probe = False if ports_need_probe: # the ports were not hardcoded nor was an HSO device dport, cport = probe_ports(ports) if not dport and not cport: # this shouldn't happen msg = 'No data port and no control port with ports: %s' raise RuntimeError(msg % ports) set_property(consts.MDM_INTFACE, 'Device', dport.split('/')[-1]) if info[DRIVER] == 'cdc_acm': # MBM device # XXX: Not all CDC devices support DHCP, to override see # plugin attribute 'ipmethod' # XXX: Also need to support Ericsson devices via 'hso' dialer # so that we can use the plain backend. At least F3607GW # supports a get_ip4_config() style AT command to get # network info, else we need to implement a DHCP client # set DBus properties (Modem.Gsm.Hso interface) hso_device = self._get_hso_device(sysfs_path) set_property(consts.MDM_INTFACE, 'Device', hso_device) set_property(consts.MDM_INTFACE, 'IpMethod', consts.MM_IP_METHOD_DHCP) if plugin.dialer in 'hso': # set DBus properties (Modem.Gsm.Hso interface) hso_device = self._get_hso_device(sysfs_path) set_property(consts.MDM_INTFACE, 'Device', hso_device) if hasattr(plugin, 'ipmethod'): # allows us to specify a method in a driver independent way set_property(consts.MDM_INTFACE, 'IpMethod', plugin.ipmethod) plugin.ports = Ports(dport, cport) return plugin raise RuntimeError("Could not find a plugin with info %s" % info)