예제 #1
0
 def read_config(self):
     self.enable_proxy, data, _ = get_all_proxies()
     self.enabled_init = self.enable_proxy
     if self.enable_proxy:
         try:
             self.ip_entry.set_text(data['host'])
             self.port_entry.set_text(data['port'])
             if data['username']:
                 self.username_entry.set_text(data['username'])
             if data['password']:
                 self.password_entry.set_text(data['password'])
         except:
             # Something went wrong > disable proxy
             set_all_proxies(False)
             common.proxy_enabled = False
             self.enable_proxy = False
             self.enabled_init = False
             self.clear_entries()
     self.checkbutton.set_active(self.enable_proxy)
예제 #2
0
 def read_config(self):
     self.enable_proxy, data, _ = get_all_proxies()
     self.enabled_init = self.enable_proxy
     if self.enable_proxy:
         try:
             self.ip_entry.set_text(data['host'])
             self.port_entry.set_text(data['port'])
             if data['username']:
                 self.username_entry.set_text(data['username'])
             if data['password']:
                 self.password_entry.set_text(data['password'])
         except:
             # Something went wrong > disable proxy
             set_all_proxies(False)
             common.proxy_enabled = False
             self.enable_proxy = False
             self.enabled_init = False
             self.clear_entries()
     self.checkbutton.set_active(self.enable_proxy)
예제 #3
0
            def lengthy_process():

                if self.enable_proxy:
                    host = self.ip_entry.get_text()
                    port = self.port_entry.get_text()
                    username = self.username_entry.get_text()
                    password = self.password_entry.get_text()
                    set_all_proxies(enable=True, host=host, port=port, username=username, password=password)
                    common.proxy_enabled = True

                    success, text = test_proxy()
                    if not success:
                        title = _("Error with proxy")
                        description = text
                        return_value = 1

                        # disable proxy if we couldn't successfully enable it
                        set_all_proxies(False)
                        common.proxy_enabled = False
                    else:
                        title = _("Successfully enabled proxy")
                        description = ""
                        return_value = 0

                else:
                    set_all_proxies(False)
                    common.proxy_enabled = False
                    title = _("Successfully disabled proxy")
                    description = ""
                    return_value = 0

                def done(title, description, return_value):
                    kdialog = KanoDialog(
                        title,
                        description,
                        [
                            {
                                'label': _("OK"),
                                'color': 'green',
                                'return_value': return_value
                            }
                        ],
                        parent_window=self.win
                    )
                    response = kdialog.run()
                    self.win.get_window().set_cursor(None)
                    self.kano_button.stop_spinner()

                    if response == 0:
                        self.go_to_wifi()
                    elif response == 1:
                        self.checkbutton.set_active(False)
                        self.kano_button.set_sensitive(False)

                GObject.idle_add(done, title, description, return_value)
예제 #4
0
            def lengthy_process():

                if self.enable_proxy:
                    host = self.ip_entry.get_text()
                    port = self.port_entry.get_text()
                    username = self.username_entry.get_text()
                    password = self.password_entry.get_text()
                    set_all_proxies(enable=True,
                                    host=host,
                                    port=port,
                                    username=username,
                                    password=password)
                    common.proxy_enabled = True

                    success, text = test_proxy()
                    if not success:
                        title = _("Error with proxy")
                        description = text
                        return_value = 1

                        # disable proxy if we couldn't successfully enable it
                        set_all_proxies(False)
                        common.proxy_enabled = False
                    else:
                        title = _("Successfully enabled proxy")
                        description = ""
                        return_value = 0

                else:
                    set_all_proxies(False)
                    common.proxy_enabled = False
                    title = _("Successfully disabled proxy")
                    description = ""
                    return_value = 0

                def done(title, description, return_value):
                    kdialog = KanoDialog(title,
                                         description,
                                         [{
                                             'label': _("OK"),
                                             'color': 'green',
                                             'return_value': return_value
                                         }],
                                         parent_window=self.win)
                    response = kdialog.run()
                    self.win.get_window().set_cursor(None)
                    self.kano_button.stop_spinner()

                    if response == 0:
                        self.go_to_wifi()
                    elif response == 1:
                        self.checkbutton.set_active(False)
                        self.kano_button.set_sensitive(False)

                GObject.idle_add(done, title, description, return_value)