def select_profile(builder, verifier): """called when a users selects a configuration""" notebook = builder.get_object('outer-notebook') switch = builder.get_object('connect-switch') ipv4_label = builder.get_object('ipv4-label') ipv6_label = builder.get_object('ipv6-label') twofa_label = builder.get_object('2fa-label') twofa_label_label = builder.get_object('2fa-label-label') name_label = builder.get_object('name-label') profile_label = builder.get_object('profile-label') profile_image = builder.get_object('profile-image') meta = metadata_of_selected(builder) if not meta: logger.info("no configuration selected, showing main logo") notebook.set_current_page(0) return else: logger.info("configuration was selected {} ({})".format( meta.display_name, meta.uuid)) name_label.set_text(meta.display_name) if meta.icon_data: icon = bytes2pixbuf(base64.b64decode(meta.icon_data.encode()), width=icon_size['width'] * 2, height=icon_size['height'] * 2) else: _, icon = get_pixbuf() profile_image.set_from_pixbuf(icon) profile_label.set_text(meta.connection_type) connected = is_provider_connected(uuid=meta.uuid) switch.set_state(bool(connected)) if connected: ipv4, ipv6 = connected ipv4_label.set_text(ipv4) ipv6_label.set_text(ipv6) else: ipv4_label.set_text("") ipv6_label.set_text("") if meta.username: twofa_label.set_text(meta.username) twofa_label_label.set_text("2FA:") else: twofa_label.set_text("") twofa_label_label.set_text("") notebook.show_all() notebook.set_current_page(1) if meta.token: fetch_messages(meta=meta, builder=builder, verifier=verifier) else: logger.warning("no token available so net fetching messages") return meta
def test_fetch_messages(self, *_): fetch_messages(builder=self.builder, meta=self.meta, verifier=self.verifier, lets_connect=False)
def test_fetch_messages(self, *_): fetch_messages(builder=self.builder, meta=self.meta, verifier=self.verifier)
def select_profile( builder, verifier, lets_connect): # type: (Gtk.builder, str, bool) -> Optional[Metadata] """called when a users selects a configuration""" messages_label = builder.get_object('messages-label') notebook = builder.get_object('outer-notebook') switch = builder.get_object('connect-switch') ipv4_label = builder.get_object('ipv4-label') ipv6_label = builder.get_object('ipv6-label') note_label = builder.get_object('note-label') note_label_label = builder.get_object('note-label-label') twofa_label = builder.get_object('2fa-label') twofa_label_label = builder.get_object('2fa-label-label') name_label = builder.get_object('name-label') profile_label = builder.get_object('profile-label') profile_name_label = builder.get_object('profile-name-label') profile_image = builder.get_object('profile-image') meta = metadata_of_selected(builder) logo, _ = get_brand(lets_connect) if not meta: logger.info(u"no configuration selected, showing main logo") notebook.set_current_page(0) return None else: logger.info(u"configuration was selected {} ({})".format( meta.display_name, meta.uuid)) name_label.set_text(meta.display_name) if meta.icon_data: icon = bytes2pixbuf(base64.b64decode(meta.icon_data.encode()), width=icon_size['width'] * 2, height=icon_size['height'] * 2) else: _, icon = get_pixbuf(logo) profile_image.set_from_pixbuf(icon) profile_label.set_text(meta.connection_type) profile_name_label.set_text(meta.profile_display_name) connected = is_provider_connected(uuid=meta.uuid) switch.set_state(bool(connected)) if connected: ipv4, ipv6 = connected ipv4_label.set_text(ipv4) ipv6_label.set_text(ipv6) else: ipv4_label.set_text("-") ipv6_label.set_text("-") if meta.username: twofa_label.set_text(meta.username) twofa_label_label.set_text("2FA:") else: twofa_label.set_text("") twofa_label_label.set_text("") note_label.set_text("") note_label_label.set_text("") notebook.show_all() notebook.set_current_page(1) messages_label.set_markup("") if meta.token: fetch_messages(meta=meta, builder=builder, verifier=verifier, lets_connect=lets_connect) else: logger.warning(u"no token available so not fetching messages") messages_label.set_markup( "<b><big>Warning</big></b>\nno token available so not fetching messages." ) return meta
def select_profile(builder, verifier, lets_connect): # type : (Gtk.Builder, verifier, bool) -> Optional[Metadata] """called when a users selects a configuration""" messages_label = builder.get_object('messages-label') notebook = builder.get_object('outer-notebook') switch = builder.get_object('connect-switch') ipv4_label = builder.get_object('ipv4-label') ipv6_label = builder.get_object('ipv6-label') note_label = builder.get_object('note-label') note_label_label = builder.get_object('note-label-label') twofa_label = builder.get_object('2fa-label') twofa_label_label = builder.get_object('2fa-label-label') name_label = builder.get_object('name-label') profile_label = builder.get_object('profile-label') profile_name_label = builder.get_object('profile-name-label') profile_image = builder.get_object('profile-image') meta = metadata_of_selected(builder) logo, _ = get_brand(lets_connect) if not meta: logger.info("no configuration selected, showing main logo") notebook.set_current_page(0) return else: logger.info("configuration was selected {} ({})".format( meta.display_name, meta.uuid)) name_label.set_text(meta.display_name) if meta.icon_data: icon = bytes2pixbuf(base64.b64decode(meta.icon_data.encode()), width=icon_size['width'] * 2, height=icon_size['height'] * 2) else: _, icon = get_pixbuf(logo) profile_image.set_from_pixbuf(icon) profile_label.set_text(meta.connection_type) profile_name_label.set_text(meta.profile_display_name) connected = is_provider_connected(uuid=meta.uuid) switch.set_state(bool(connected)) if connected: ipv4, ipv6 = connected ipv4_label.set_text(ipv4) ipv6_label.set_text(ipv6) else: ipv4_label.set_text("-") ipv6_label.set_text("-") if meta.username: twofa_label.set_text(meta.username) twofa_label_label.set_text("2FA:") else: twofa_label.set_text("") twofa_label_label.set_text("") if are_we_running_ubuntu1804(): note_label.set_markup( '<a href="https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1754671">Ubuntu 18.04 Leaks DNS info</a>' ) note_label_label.set_markup( '<span foreground="red">WARNING</span>:') else: note_label.set_text("") note_label_label.set_text("") notebook.show_all() notebook.set_current_page(1) messages_label.set_markup("") if meta.token: fetch_messages(meta=meta, builder=builder, verifier=verifier, lets_connect=lets_connect) else: logger.warning("no token available so not fetching messages") messages_label.set_markup( "<b><big>Warning</big></b>\nno token available so not fetching messages." ) return meta