def run_connect_dialog(self, pipe_manager, server_address, transport_type, username, domains = None): dialog = SAMConnectDialog(server_address, transport_type, username) dialog.show_all() if (domains == None): # loop to handle the failures while True: response_id = dialog.run() if (response_id != gtk.RESPONSE_OK): dialog.hide() return None else: try: self.server_address = dialog.get_server_address() self.transport_type = dialog.get_transport_type() self.username = dialog.get_username() self.domain_index = 0 password = dialog.get_password() pipe_manager = SAMPipeManager(self.server_address, self.transport_type, self.username, password) domains = pipe_manager.fetch_and_get_domain_names() break except RuntimeError, re: msg = "Failed to connect: " + re.args[1] + "." print msg traceback.print_exc() self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg, dialog) except Exception, ex: msg = "Failed to connect: " + str(ex) + "." print msg traceback.print_exc() self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, msg, dialog)
def run_connect_all_dialog(self): """Runs the connection dialog and saves connection arguments to self.connection_args returns True if arguments were uptained successfully""" #TODO in this function: handle domain selection args = {} #args and their default values important_args = {"server":"", "username":"", "transport_type":0, } for item in important_args.keys(): args.update(self.connection_args.has_key(item) and {item:self.connection_args[item]} or {item:important_args[item]}) dialog = SAMConnectDialog(**args) dialog.show_all() # loop to handle the failures while True: response_id = dialog.run() if (response_id != gtk.RESPONSE_OK): dialog.hide() return False else: server = dialog.get_server_address() username = dialog.get_username() if server != "" and username != "": self.connection_args.update({"server":server}) self.connection_args.update({"username":username}) self.connection_args.update({"transport_type":dialog.get_transport_type()}) self.connection_args.update({"password":dialog.get_password()}) self.connection_args.update({"connect_now":True}) self.additional_connection_args.update({"domain_index":0}) #TODO: get domain index break else: self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "You must enter a server address and username.") dialog.hide() return True