def accept(self): host = str(self.host.text()) dns = [] item = self.dns.firstItem() while item: dns.append(str(item.text())) item = item.next() self.done = 0 def handler(): self.done += 1 if self.done == 2: self.setEnabled(True) QDialog.accept(self) def error(exception): self.setEnabled(True) def cancel(): self.setEnabled(True) if self.old_host != host: self.setEnabled(False) ch = comlink.callHandler("baselayout", "Net.Stack", "setHostName", "tr.org.pardus.comar.net.stack.set") ch.registerDone(handler) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(host) else: self.done += 1 if self.old_dns != dns: self.setEnabled(False) ch = comlink.callHandler("baselayout", "Net.Stack", "setNameServers", "tr.org.pardus.comar.net.stack.set") ch.registerDone(handler) ch.registerCancel(cancel) ch.registerError(cancel) ch.registerDBusError(cancel) ch.registerAuthError(cancel) ch.call(dns) else: self.done += 1 if self.done == 2: self.setEnabled(True) QDialog.accept(self)
def accept(self): host = str(self.host.text()) dns = [] item = self.dns.firstItem() while item: dns.append(str(item.text())) item = item.next() self.done = 0 def handler(): self.done += 1 if self.done == 2: self.setEnabled(True) QDialog.accept(self) def error(exception): self.setEnabled(True) def cancel(): self.setEnabled(True) if self.old_host != host: self.setEnabled(False) ch = comlink.callHandler("baselayout", "Net.Stack", "setHostName", "tr.org.pardus.comar.net.stack.set") ch.registerDone(handler) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(host) else: self.done += 1 if self.old_dns != dns: self.setEnabled(False) ch = comlink.callHandler("baselayout", "Net.Stack", "setNameServers", "tr.org.pardus.comar.net.stack.set") ch.registerDone(handler) ch.registerCancel(cancel) ch.registerError(cancel) ch.registerDBusError(cancel) ch.registerAuthError(cancel) ch.call(dns, False) else: self.done += 1 if self.done == 2: self.setEnabled(True) QDialog.accept(self)
def slotDelete(self): conn = self.conn m = i18n("Should I delete the\n'%s'\nconnection?") if KMessageBox.Yes == KMessageBox.questionYesNo( self, unicode(m) % conn.name, i18n("Delete connection?")): ch = comlink.callHandler( self.conn.script, "Net.Link", "deleteConnection", "tr.org.pardus.comar.net.link.deleteconnection") ch.call(conn.name)
def slotToggle(self, on): if self.ignore_signal: return state = "down" if on: state = "up" self.view.setEnabled(False) ch = comlink.callHandler(self.conn.script, "Net.Link", "setState", "tr.org.pardus.comar.net.link.setstate") ch.call(self.conn.name, state) self.view.setEnabled(True)
def slotToggle(self, on): if self.ignore_signal: return dev = self.parent() state = "down" if on: state = "up" self.view.setEnabled(False) ch = comlink.callHandler(self.conn.script, "Net.Link", "setState", "tr.org.pardus.comar.net.link.setstate") ch.call(self.conn.name, state) self.view.setEnabled(True)
def useValues(self): name = str(self.name.edit.text()) conn = self.conn def saveConnection(set_conn): if set_conn: # create connection / update device comlink.call(self.link.script, "Net.Link", "setConnection", name, self.device_uid) if "net" in self.link.modes: # set address address = str(self.address.text()) netmask = str(self.netmask.currentText()) gateway = str(self.gateway.text()) if self.r1.isChecked(): mode = "auto" address = "" netmask = "" gateway = "" else: mode = "manual" comlink.call(self.link.script, "Net.Link", "setAddress", name, mode, address, netmask, gateway) # set name servers nameserver = "" if self.dns1.isChecked(): namemode = "default" elif self.dns2.isChecked(): namemode = "auto" elif self.dns3.isChecked(): namemode = "custom" nameserver = str(self.dns_text.text()) comlink.call(self.link.script, "Net.Link", "setNameService", name, namemode, nameserver) if "devicemode" in self.link.modes: from string import lower selected_device_mode = str(lower(self.selected_device_mode.currentText())) comlink.call(self.link.script, "Net.Link", "setConnectionMode", name, selected_device_mode) if "remote" in self.link.modes: # set remote address remote = str(self.remote.text()) comlink.call(self.link.script, "Net.Link", "setRemote", name, remote, self.apmac) if "auth" in self.link.modes: i = self.auth_mode.currentItem() if i == 0: comlink.call(self.link.script, "Net.Link", "setAuthentication", name, "none", "", "") else: mode = self.link.auth_modes[i-1] if mode.type == "pass": pw = unicode(self.auth_passphrase.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, "", pw) elif mode.type == "login": u = unicode(self.auth_user.text()) pw = unicode(self.auth_password.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, u, pw) # close dialog self.parent().setEnabled(True) self.cleanup() self.parent().parent().close(True) def error(exception): self.parent().setEnabled(True) def cancel(): self.parent().setEnabled(True) self.parent().setEnabled(False) if conn and conn.name != name: ch = comlink.callHandler(self.link.script, "Net.Link", "deleteConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, True) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(conn.name) else: ch = comlink.callHandler(self.link.script, "Net.Link", "setConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, False) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(name, self.device_uid)
def slotDelete(self): conn = self.conn m = i18n("Should I delete the\n'%s'\nconnection?") if KMessageBox.Yes == KMessageBox.questionYesNo(self, unicode(m) % conn.name, i18n("Delete connection?")): ch = comlink.callHandler(self.conn.script, "Net.Link", "deleteConnection", "tr.org.pardus.comar.net.link.set") ch.call(conn.name)
def useValues(self): name = str(self.name.edit.text()) conn = self.conn def saveConnection(set_conn): if set_conn: # create connection / update device comlink.call(self.link.script, "Net.Link", "setConnection", name, self.device_uid) if "net" in self.link.modes: # set address address = str(self.address.text()) netmask = str(self.netmask.text()) gateway = str(self.gateway.text()) if self.r1.isChecked(): mode = "auto" address = "" netmask = "" gateway = "" else: mode = "manual" comlink.call(self.link.script, "Net.Link", "setAddress", name, mode, address, netmask, gateway) # set name servers nameserver = "" if self.dns1.isChecked(): namemode = "default" elif self.dns2.isChecked(): namemode = "auto" elif self.dns3.isChecked(): namemode = "custom" nameserver = str(self.dns_text.text()) comlink.call(self.link.script, "Net.Link", "setNameService", name, namemode, nameserver) if "remote" in self.link.modes: # set remote address remote = str(self.remote.text()) comlink.call(self.link.script, "Net.Link", "setRemote", name, remote, self.apmac) if "auth" in self.link.modes: i = self.auth_mode.currentItem() if i == 0: comlink.call(self.link.script, "Net.Link", "setAuthentication", name, "none", "", "") else: mode = self.link.auth_modes[i-1] if mode.type == "pass": pw = unicode(self.auth_passphrase.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, "", pw) elif mode.type == "login": u = unicode(self.auth_user.text()) pw = unicode(self.auth_password.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, u, pw) if "vpn" in self.link.modes: domain = str(self.domain.text()) port = str(self.port.text()) protocol = str(self.protocol.currentText()).lower() chipher = str(self.chipher.currentText()) if self.chipher.currentText() == "-": chipher = str("") ca = str(self.ca) cert = str(self.cert) key = str(self.key) comlink.call(self.link.script,"Net.Link","setVpn", name, domain, port, protocol, ca, cert, key, chipher) # close dialog self.parent().setEnabled(True) self.cleanup() self.parent().parent().close(True) def error(exception): self.parent().setEnabled(True) def cancel(): self.parent().setEnabled(True) self.parent().setEnabled(False) if conn and conn.name != name: ch = comlink.callHandler(self.link.script, "Net.Link", "deleteConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, True) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(conn.name) else: ch = comlink.callHandler(self.link.script, "Net.Link", "setConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, False) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(name, self.device_uid)
def useValues(self): name = str(self.name.edit.text()) conn = self.conn def saveConnection(set_conn): if set_conn: # create connection / update device comlink.call(self.link.script, "Net.Link", "setConnection", name, self.device_uid) if "net" in self.link.modes: # set address address = str(self.address.text()) netmask = str(self.netmask.currentText()) gateway = str(self.gateway.text()) if self.r1.isChecked(): mode = "auto" if not self.auto_addr.isChecked(): address = "" netmask = "" if not self.auto_gate.isChecked(): gateway = "" else: mode = "manual" comlink.call(self.link.script, "Net.Link", "setAddress", name, mode, address, netmask, gateway) # set name servers nameserver = "" if self.dns1.isChecked(): namemode = "default" elif self.dns2.isChecked(): namemode = "auto" elif self.dns3.isChecked(): namemode = "custom" nameserver = str(self.dns_text.text()) comlink.call(self.link.script, "Net.Link", "setNameService", name, namemode, nameserver) if "remote" in self.link.modes: # set remote address remote = str(self.remote.text()) comlink.call(self.link.script, "Net.Link", "setRemote", name, remote, self.apmac) if self.channel != None: print "setting channel to : ", self.channel print "name : ", name comlink.call(self.link.script, "Net.Link", "setChannel", name, self.channel) if "auth" in self.link.modes: i = self.security_mode_combo.currentItem() if i == 0: comlink.call(self.link.script, "Net.Link", "setAuthentication", name, "none", "", "", "", "", "", "", "", "", "") else: mode = self.link.auth_modes[i - 1] if mode.type == "pass": pw = unicode(self.auth_passphrase_line.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, "", pw, "", "", "", "", "", "", "") elif mode.type == "login": if mode.id == "802.1x": u = unicode(self.auth_user_line.text()) pw = unicode(self.auth_passphrase_line.text()) an = unicode(self.auth_anon_id_line.text()) au = unicode(self.auth_mode_combo.currentText()) p2 = unicode(self.auth_inner_combo.currentText()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, u, pw, au, an, p2,\ str(self.auth_client_cert), str(self.auth_ca_cert), str(self.auth_private_key), str(self.auth_private_key_pass_line.text())) else: u = unicode(self.auth_user_line.text()) pw = unicode(self.auth_passphrase_line.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, u, pw, "", "", "", "", "", "", "") # close dialog self.parent().setEnabled(True) self.cleanup() self.parent().parent().close(True) def error(exception): self.parent().setEnabled(True) def cancel(): self.parent().setEnabled(True) self.parent().setEnabled(False) if conn and conn.name != name: ch = comlink.callHandler(self.link.script, "Net.Link", "deleteConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, True) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(conn.name) else: ch = comlink.callHandler(self.link.script, "Net.Link", "setConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, False) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(name, self.device_uid)
def useValues(self): name = str(self.name.edit.text()) conn = self.conn def saveConnection(set_conn): if set_conn: # create connection / update device comlink.call(self.link.script, "Net.Link", "setConnection", name, self.device_uid) if "net" in self.link.modes: # set address address = str(self.address.text()) netmask = str(self.netmask.currentText()) gateway = str(self.gateway.text()) if self.r1.isChecked(): mode = "auto" if not self.auto_addr.isChecked(): address = "" netmask = "" if not self.auto_gate.isChecked(): gateway = "" else: mode = "manual" comlink.call(self.link.script, "Net.Link", "setAddress", name, mode, address, netmask, gateway) # set name servers nameserver = "" if self.dns1.isChecked(): namemode = "default" elif self.dns2.isChecked(): namemode = "auto" elif self.dns3.isChecked(): namemode = "custom" nameserver = str(self.dns_text.text()) comlink.call(self.link.script, "Net.Link", "setNameService", name, namemode, nameserver) if "remote" in self.link.modes: # set remote address remote = str(self.remote.text()) comlink.call(self.link.script, "Net.Link", "setRemote", name, remote, self.apmac) if self.channel != None: print "setting channel to : ", self.channel print "name : ", name comlink.call(self.link.script, "Net.Link", "setChannel", name, self.channel) if "auth" in self.link.modes: i = self.security_mode_combo.currentItem() if i == 0: comlink.call(self.link.script, "Net.Link", "setAuthentication", name, "none", "", "", "", "", "", "", "", "","") else: mode = self.link.auth_modes[i-1] if mode.type == "pass": pw = unicode(self.auth_passphrase_line.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, "", pw, "", "", "", "", "", "", "") elif mode.type == "login": if mode.id == "802.1x": u = unicode(self.auth_user_line.text()) pw = unicode(self.auth_passphrase_line.text()) an = unicode(self.auth_anon_id_line.text()) au = unicode(self.auth_mode_combo.currentText()) p2 = unicode(self.auth_inner_combo.currentText()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, u, pw, au, an, p2,\ str(self.auth_client_cert), str(self.auth_ca_cert), str(self.auth_private_key), str(self.auth_private_key_pass_line.text())) else: u = unicode(self.auth_user_line.text()) pw = unicode(self.auth_passphrase_line.text()) comlink.call(self.link.script, "Net.Link", "setAuthentication", name, mode.id, u, pw, "", "", "", "", "", "", "") # close dialog self.parent().setEnabled(True) self.cleanup() self.parent().parent().close(True) def error(exception): self.parent().setEnabled(True) def cancel(): self.parent().setEnabled(True) self.parent().setEnabled(False) if conn and conn.name != name: ch = comlink.callHandler(self.link.script, "Net.Link", "deleteConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, True) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(conn.name) else: ch = comlink.callHandler(self.link.script, "Net.Link", "setConnection", "tr.org.pardus.comar.net.link.set") ch.registerDone(saveConnection, False) ch.registerCancel(cancel) ch.registerError(error) ch.registerDBusError(error) ch.registerAuthError(error) ch.call(name, self.device_uid)