From e069e53536e4894507a72da79e7e8af55a0d31b1 Mon Sep 17 00:00:00 2001 From: Shane Wang Date: Tue, 22 May 2012 19:33:23 +0800 Subject: Hob: reimplement the proxy page This patch is to reimplement the proxy page in the "Advanced Settings" dialog per the new design in https://bugzilla.yoctoproject.org/attachment.cgi?id=442 and https://bugzilla.yoctoproject.org/attachment.cgi?id=443. [Yocto #2247] (Bitbake rev: 911a60c09c1539a3f10c2bcdb26d40e458c31303) Signed-off-by: Shane Wang Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hig.py | 273 +++++++++++++++++++++++++++++----------- 1 file changed, 203 insertions(+), 70 deletions(-) (limited to 'bitbake/lib/bb/ui/crumbs/hig.py') diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 721d145a6a..1bc155d008 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py @@ -172,6 +172,45 @@ class AdvancedSettingDialog (CrumbsDialog): hbox.show_all() return hbox, entry + def details_cb(self, button, parent, protocol): + dialog = ProxyDetailsDialog(title = protocol.upper() + " Proxy Details", + user = self.configuration.proxies[protocol][1], + passwd = self.configuration.proxies[protocol][2], + parent = parent, + flags = gtk.DIALOG_MODAL + | gtk.DIALOG_DESTROY_WITH_PARENT + | gtk.DIALOG_NO_SEPARATOR) + dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) + response = dialog.run() + if response == gtk.RESPONSE_OK: + self.configuration.proxies[protocol][1] = dialog.user + self.configuration.proxies[protocol][2] = dialog.passwd + self.refresh_proxy_components() + dialog.destroy() + + def gen_proxy_entry_widget(self, protocol, parent, need_button=True): + hbox = gtk.HBox(False, 12) + + label = gtk.Label(protocol.upper() + " proxy") + hbox.pack_start(label, expand=True, fill=False, padding=24) + + proxy_entry = gtk.Entry() + proxy_entry.set_size_request(300, -1) + hbox.pack_start(proxy_entry, expand=False, fill=False) + + hbox.pack_start(gtk.Label(":"), expand=False, fill=False) + + port_entry = gtk.Entry() + port_entry.set_size_request(60, -1) + hbox.pack_start(port_entry, expand=False, fill=False) + + details_button = HobAltButton("Details") + details_button.connect("clicked", self.details_cb, parent, protocol) + hbox.pack_start(details_button, expand=False, fill=False) + + hbox.show_all() + return hbox, proxy_entry, port_entry, details_button + def rootfs_combo_changed_cb(self, rootfs_combo, all_package_format, check_hbox): combo_item = self.rootfs_combo.get_active_text() for child in check_hbox.get_children(): @@ -309,7 +348,7 @@ class AdvancedSettingDialog (CrumbsDialog): def __init__(self, title, configuration, all_image_types, all_package_formats, all_distros, all_sdk_machines, - max_threads, enable_proxy, parent, flags, buttons=None): + max_threads, parent, flags, buttons=None): super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) # class members from other objects @@ -320,7 +359,6 @@ class AdvancedSettingDialog (CrumbsDialog): self.all_distros = all_distros self.all_sdk_machines = all_sdk_machines self.max_threads = max_threads - self.enable_proxy = enable_proxy # class members for internal use self.distro_combo = None @@ -356,15 +394,10 @@ class AdvancedSettingDialog (CrumbsDialog): data += ("SDK_MACHINE: " + self._get_sorted_value(self.configuration.curr_sdk_machine)) data += ("TOOLCHAIN_BUILD: " + self._get_sorted_value(self.configuration.toolchain_build)) data += ("IMAGE_FSTYPES: " + self._get_sorted_value(self.configuration.image_fstypes)) - if self.enable_proxy: - data += ("ALL_PROXY: " + self._get_sorted_value(self.configuration.all_proxy)) - data += ("HTTP_PROXY: " + self._get_sorted_value(self.configuration.http_proxy)) - data += ("HTTPS_PROXY: " + self._get_sorted_value(self.configuration.https_proxy)) - data += ("FTP_PROXY: " + self._get_sorted_value(self.configuration.ftp_proxy)) - data += ("GIT_PROXY_HOST: " + self._get_sorted_value(self.configuration.git_proxy_host)) - data += ("GIT_PROXY_PORT: " + self._get_sorted_value(self.configuration.git_proxy_port)) - data += ("CVS_PROXY_HOST: " + self._get_sorted_value(self.configuration.cvs_proxy_host)) - data += ("CVS_PROXY_PORT: " + self._get_sorted_value(self.configuration.cvs_proxy_port)) + data += ("ENABLE_PROXY: " + self._get_sorted_value(self.configuration.enable_proxy)) + if self.configuration.enable_proxy: + for protocol in self.configuration.proxies.keys(): + data += (protocol + ": " + self._get_sorted_value(self.configuration.combine_proxy(protocol))) for key in self.configuration.extra_setting.keys(): data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) return hashlib.md5(data).hexdigest() @@ -529,60 +562,56 @@ class AdvancedSettingDialog (CrumbsDialog): sub_vbox = gtk.VBox(False, 6) advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) - self.proxy_checkbox = gtk.CheckButton("Enable proxy") + label = self.gen_label_widget("Set the proxies that will be used during fetching source code") + tooltip = "Set the proxies that will be used during fetching source code or set none for direct the Internet connection" + info = HobInfoButton(tooltip, self) + hbox = gtk.HBox(False, 12) + hbox.pack_start(label, expand=True, fill=True) + hbox.pack_start(info, expand=False, fill=False) + sub_vbox.pack_start(hbox, expand=False, fill=False) + + self.direct_checkbox = gtk.RadioButton(None, "Direct internet connection") + self.direct_checkbox.set_tooltip_text("Check this box to connect the Internet directly without any proxy") + self.direct_checkbox.set_active(not self.configuration.enable_proxy) + sub_vbox.pack_start(self.direct_checkbox, expand=False, fill=False) + + self.proxy_checkbox = gtk.RadioButton(self.direct_checkbox, "Manual proxy configuration") self.proxy_checkbox.set_tooltip_text("Check this box to setup the proxy you specified") - self.proxy_checkbox.set_active(self.enable_proxy) - self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) + self.proxy_checkbox.set_active(self.configuration.enable_proxy) sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) - label = self.gen_label_widget("Set all proxy:") - tooltip = "Set the all proxy that will be used if the proxy for a URL isn't specified." - proxy_widget, self.all_proxy_text = self.gen_entry_widget(self.configuration.all_proxy, self, tooltip, False) - self.all_proxy_text.set_editable(self.enable_proxy) - self.all_proxy_text.set_sensitive(self.enable_proxy) - sub_vbox.pack_start(label, expand=False, fill=False) - sub_vbox.pack_start(proxy_widget, expand=False, fill=False) + self.same_checkbox = gtk.CheckButton("Use the same proxy for all protocols") + self.same_checkbox.set_tooltip_text("Use the same proxy as the first proxy i.e. http proxy for all protocols") + self.same_checkbox.set_active(self.configuration.same_proxy) + hbox = gtk.HBox(False, 12) + hbox.pack_start(self.same_checkbox, expand=False, fill=False, padding=24) + sub_vbox.pack_start(hbox, expand=False, fill=False) - label = self.gen_label_widget("Set http proxy:") - tooltip = "Set the http proxy that will be used in do_fetch() source code" - proxy_widget, self.http_proxy_text = self.gen_entry_widget(self.configuration.http_proxy, self, tooltip, False) - self.http_proxy_text.set_editable(self.enable_proxy) - self.http_proxy_text.set_sensitive(self.enable_proxy) - sub_vbox.pack_start(label, expand=False, fill=False) + proxy_widget, self.http_proxy, self.http_proxy_port, self.http_proxy_details = self.gen_proxy_entry_widget( + "http", self, True) sub_vbox.pack_start(proxy_widget, expand=False, fill=False) - label = self.gen_label_widget("Set https proxy:") - tooltip = "Set the https proxy that will be used in do_fetch() source code" - proxy_widget, self.https_proxy_text = self.gen_entry_widget(self.configuration.https_proxy, self, tooltip, False) - self.https_proxy_text.set_editable(self.enable_proxy) - self.https_proxy_text.set_sensitive(self.enable_proxy) - sub_vbox.pack_start(label, expand=False, fill=False) + proxy_widget, self.https_proxy, self.https_proxy_port, self.https_proxy_details = self.gen_proxy_entry_widget( + "https", self, True) sub_vbox.pack_start(proxy_widget, expand=False, fill=False) - label = self.gen_label_widget("Set ftp proxy:") - tooltip = "Set the ftp proxy that will be used in do_fetch() source code" - proxy_widget, self.ftp_proxy_text = self.gen_entry_widget(self.configuration.ftp_proxy, self, tooltip, False) - self.ftp_proxy_text.set_editable(self.enable_proxy) - self.ftp_proxy_text.set_sensitive(self.enable_proxy) - sub_vbox.pack_start(label, expand=False, fill=False) + proxy_widget, self.ftp_proxy, self.ftp_proxy_port, self.ftp_proxy_details = self.gen_proxy_entry_widget( + "ftp", self, True) sub_vbox.pack_start(proxy_widget, expand=False, fill=False) - label = self.gen_label_widget("Set git proxy:") - tooltip = "Set the git proxy that will be used in do_fetch() source code" - proxy_widget, self.git_proxy_text = self.gen_entry_widget(self.configuration.git_proxy_host + ':' + self.configuration.git_proxy_port, self, tooltip, False) - self.git_proxy_text.set_editable(self.enable_proxy) - self.git_proxy_text.set_sensitive(self.enable_proxy) - sub_vbox.pack_start(label, expand=False, fill=False) + proxy_widget, self.git_proxy, self.git_proxy_port, self.git_proxy_details = self.gen_proxy_entry_widget( + "git", self, True) sub_vbox.pack_start(proxy_widget, expand=False, fill=False) - label = self.gen_label_widget("Set cvs proxy:") - tooltip = "Set the cvs proxy that will be used in do_fetch() source code" - proxy_widget, self.cvs_proxy_text = self.gen_entry_widget(self.configuration.cvs_proxy_host + ':' + self.configuration.cvs_proxy_port, self, tooltip, False) - self.cvs_proxy_text.set_editable(self.enable_proxy) - self.cvs_proxy_text.set_sensitive(self.enable_proxy) - sub_vbox.pack_start(label, expand=False, fill=False) + proxy_widget, self.cvs_proxy, self.cvs_proxy_port, self.cvs_proxy_details = self.gen_proxy_entry_widget( + "cvs", self, True) sub_vbox.pack_start(proxy_widget, expand=False, fill=False) + self.direct_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) + self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) + self.same_checkbox.connect("toggled", self.same_checkbox_toggled_cb) + + self.refresh_proxy_components() return advanced_vbox def create_others_page(self): @@ -599,20 +628,59 @@ class AdvancedSettingDialog (CrumbsDialog): return advanced_vbox + def refresh_proxy_components(self): + self.same_checkbox.set_sensitive(self.configuration.enable_proxy) + + self.http_proxy.set_text(self.configuration.combine_host_only("http")) + self.http_proxy.set_editable(self.configuration.enable_proxy) + self.http_proxy.set_sensitive(self.configuration.enable_proxy) + self.http_proxy_port.set_text(self.configuration.combine_port_only("http")) + self.http_proxy_port.set_editable(self.configuration.enable_proxy) + self.http_proxy_port.set_sensitive(self.configuration.enable_proxy) + self.http_proxy_details.set_sensitive(self.configuration.enable_proxy) + + self.https_proxy.set_text(self.configuration.combine_host_only("https")) + self.https_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.https_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.https_proxy_port.set_text(self.configuration.combine_port_only("https")) + self.https_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.https_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.https_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + + self.ftp_proxy.set_text(self.configuration.combine_host_only("ftp")) + self.ftp_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.ftp_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.ftp_proxy_port.set_text(self.configuration.combine_port_only("ftp")) + self.ftp_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.ftp_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.ftp_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + + self.git_proxy.set_text(self.configuration.combine_host_only("git")) + self.git_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.git_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.git_proxy_port.set_text(self.configuration.combine_port_only("git")) + self.git_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.git_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.git_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + + self.cvs_proxy.set_text(self.configuration.combine_host_only("cvs")) + self.cvs_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.cvs_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.cvs_proxy_port.set_text(self.configuration.combine_port_only("cvs")) + self.cvs_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.cvs_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + self.cvs_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) + def proxy_checkbox_toggled_cb(self, button): - self.enable_proxy = self.proxy_checkbox.get_active() - self.all_proxy_text.set_editable(self.enable_proxy) - self.all_proxy_text.set_sensitive(self.enable_proxy) - self.http_proxy_text.set_editable(self.enable_proxy) - self.http_proxy_text.set_sensitive(self.enable_proxy) - self.https_proxy_text.set_editable(self.enable_proxy) - self.https_proxy_text.set_sensitive(self.enable_proxy) - self.ftp_proxy_text.set_editable(self.enable_proxy) - self.ftp_proxy_text.set_sensitive(self.enable_proxy) - self.git_proxy_text.set_editable(self.enable_proxy) - self.git_proxy_text.set_sensitive(self.enable_proxy) - self.cvs_proxy_text.set_editable(self.enable_proxy) - self.cvs_proxy_text.set_sensitive(self.enable_proxy) + self.configuration.enable_proxy = self.proxy_checkbox.get_active() + if not self.configuration.enable_proxy: + self.configuration.same_proxy = False + self.same_checkbox.set_active(self.configuration.same_proxy) + self.refresh_proxy_components() + + def same_checkbox_toggled_cb(self, button): + self.configuration.same_proxy = self.same_checkbox.get_active() + self.refresh_proxy_components() def response_cb(self, dialog, response_id): package_format = [] @@ -656,12 +724,17 @@ class AdvancedSettingDialog (CrumbsDialog): self.configuration.extra_setting[key] = value it = self.setting_store.iter_next(it) - self.configuration.all_proxy = self.all_proxy_text.get_text() - self.configuration.http_proxy = self.http_proxy_text.get_text() - self.configuration.https_proxy = self.https_proxy_text.get_text() - self.configuration.ftp_proxy = self.ftp_proxy_text.get_text() - self.configuration.git_proxy_host, self.configuration.git_proxy_port = self.git_proxy_text.get_text().split(':') - self.configuration.cvs_proxy_host, self.configuration.cvs_proxy_port = self.cvs_proxy_text.get_text().split(':') + self.configuration.split_proxy("http", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) + if self.configuration.same_proxy: + self.configuration.split_proxy("https", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) + self.configuration.split_proxy("ftp", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) + self.configuration.split_proxy("git", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) + self.configuration.split_proxy("cvs", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) + else: + self.configuration.split_proxy("https", self.https_proxy.get_text() + ":" + self.https_proxy_port.get_text()) + self.configuration.split_proxy("ftp", self.ftp_proxy.get_text() + ":" + self.ftp_proxy_port.get_text()) + self.configuration.split_proxy("git", self.git_proxy.get_text() + ":" + self.git_proxy_port.get_text()) + self.configuration.split_proxy("cvs", self.cvs_proxy.get_text() + ":" + self.cvs_proxy_port.get_text()) md5 = self.config_md5() self.settings_changed = (self.md5 != md5) @@ -1150,3 +1223,63 @@ class ImageSelectionDialog (CrumbsDialog): self.image_names.append(f) break iter = self.image_store.iter_next(iter) + +class ProxyDetailsDialog (CrumbsDialog): + + def __init__(self, title, user, passwd, parent, flags, buttons=None): + super(ProxyDetailsDialog, self).__init__(title, parent, flags, buttons) + self.connect("response", self.response_cb) + + self.auth = not (user == None or passwd == None or user == "") + self.user = user or "" + self.passwd = passwd or "" + + # create visual elements on the dialog + self.create_visual_elements() + + def create_visual_elements(self): + self.auth_checkbox = gtk.CheckButton("Use authentication") + self.auth_checkbox.set_tooltip_text("Check this box to set the username and the password") + self.auth_checkbox.set_active(self.auth) + self.auth_checkbox.connect("toggled", self.auth_checkbox_toggled_cb) + self.vbox.pack_start(self.auth_checkbox, expand=False, fill=False) + + hbox = gtk.HBox(False, 6) + self.user_label = gtk.Label("Username:") + self.user_text = gtk.Entry() + self.user_text.set_text(self.user) + hbox.pack_start(self.user_label, expand=False, fill=False) + hbox.pack_end(self.user_text, expand=False, fill=False) + self.vbox.pack_start(hbox, expand=False, fill=False) + + hbox = gtk.HBox(False, 6) + self.passwd_label = gtk.Label("Password:") + self.passwd_text = gtk.Entry() + self.passwd_text.set_text(self.passwd) + hbox.pack_start(self.passwd_label, expand=False, fill=False) + hbox.pack_end(self.passwd_text, expand=False, fill=False) + self.vbox.pack_start(hbox, expand=False, fill=False) + + self.refresh_auth_components() + self.show_all() + + def refresh_auth_components(self): + self.user_label.set_sensitive(self.auth) + self.user_text.set_editable(self.auth) + self.user_text.set_sensitive(self.auth) + self.passwd_label.set_sensitive(self.auth) + self.passwd_text.set_editable(self.auth) + self.passwd_text.set_sensitive(self.auth) + + def auth_checkbox_toggled_cb(self, button): + self.auth = self.auth_checkbox.get_active() + self.refresh_auth_components() + + def response_cb(self, dialog, response_id): + if response_id == gtk.RESPONSE_OK: + if self.auth: + self.user = self.user_text.get_text() + self.passwd = self.passwd_text.get_text() + else: + self.user = None + self.passwd = None -- cgit v1.2.3-54-g00ecf