def save(self): props = { 'connection': {'id': self.name, 'type': 'gsm', 'name': 'connection', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': {'band': self.band, 'username': self.username, 'number': '*99#', 'network-type': self.network_type, 'apn': self.apn, 'name': 'gsm'}, 'ppp': {'name': 'ppp'}, 'serial': {'baud': 115200, 'name': 'serial'}, 'ipv4': {'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'name': 'ipv4', 'routes': []}, } if not props['ipv4']['ignore-auto-dns']: props['ipv4']['dns'] = [] else: dns = [i for i in [self.primary_dns, self.secondary_dns] if i] props['ipv4']['dns'] = map(convert, dns) props = patch_list_signature(props) if self.profile: self.manager.update_profile(self.profile, props) # store password associated to this connection secrets = {'password': self.password} self.profile.secrets.update(secrets, ask=True) logger.debug("Profile modified: %s" % self.profile) else: uuid = props['connection']['uuid'] if self.parent_model.profiles_model.has_profile(uuid=uuid): msg = _('A profile with uuid "%s" exists') % uuid raise RuntimeError(msg) sm = None # SignalMatch object def new_profile_cb(path): self.profile_path = path logger.debug("Profile added: %s" % self.profile_path) self.profile = self.manager.get_profile_by_uuid(uuid) secrets = {'password': self.password} self.profile.secrets.update(secrets, ask=True) self.parent_model.profile_added(self) sm.remove() # remove SignalMatch handler sm = self.bus.add_signal_receiver(new_profile_cb, "NewConnection", WADER_PROFILES_INTFACE) self.manager.add_profile(props) if self.state == DISCONNECTED and self.device_callable: # only perform this operations if we are disconnected and # a device is available device = self.device_callable() if not device: return if self.band is not None: device.SetBand(self.band, dbus_interface=NET_INTFACE, reply_handler=lambda: True, error_handler=logger.error) if self.network_type is not None: device.SetNetworkMode(self.network_type, dbus_interface=NET_INTFACE, reply_handler=lambda: True, error_handler=logger.error)
def update(self, props): """Updates the profile with settings ``props``""" self.props = props # emit Updated self.Updated(patch_list_signature(self.props))
def get_settings(self): """Returns the profile settings""" return patch_list_signature(self.props)
def update(self, props): """Updates the profile with settings ``props``""" self._write(props) self._load_info() self.Updated(patch_list_signature(self.props))
def update(self, props): """Updates the profile with settings ``props``""" self.props = props self._write() # emit the signal self.Updated(patch_list_signature(props))