Esempio n. 1
0
def refresh_start(builder, lets_connect):
    # type: (Gtk.builder, bool) -> None
    logger.info(u"composing list of current eduVPN configurations")
    config_list = builder.get_object('configs-model')
    introduction = builder.get_object('introduction')
    main_image = builder.get_object('main_image')
    window = builder.get_object('eduvpn-window')

    logo, name = get_brand(lets_connect)
    main_image.set_from_file(logo)
    window.set_title("{} Configuration Manager".format(name))

    config_list.clear()
    providers = list(list_providers())
    providers.sort(key=lambda x: x.display_name)

    if len(providers) > 0:
        logger.info(u"hiding introduction")
        introduction.hide()
        for meta in providers:
            connection_type = u"<b>{}</b>\n{}\n<small><i>{}</i></small>".format(meta.display_name,
                                                                                meta.connection_type,
                                                                                meta.profile_display_name)
            if meta.icon_data:
                icon = bytes2pixbuf(base64.b64decode(meta.icon_data.encode()))
            else:
                icon, _ = get_pixbuf(logo)
            config_list.append((meta.uuid, meta.display_name, icon, connection_type))
    else:
        logger.info(u"showing introduction")
        introduction.show()
Esempio n. 2
0
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 update_providers(builder):
    logger.info("composing list of current eduVPN configurations")
    config_list = builder.get_object('configs-model')
    introduction = builder.get_object('introduction')
    config_list.clear()
    providers = list(list_providers())

    if len(providers) > 0:
        logger.info("hiding introduction")
        introduction.hide()
        for meta in providers:
            connection_type = "{}\n{}".format(meta.display_name, meta.connection_type)
            if meta.icon_data:
                icon = bytes2pixbuf(base64.b64decode(meta.icon_data.encode()))
            else:
                icon, _ = get_pixbuf()
            config_list.append((meta.uuid, meta.display_name, icon, connection_type))
    else:
        logger.info("showing introduction")
        introduction.show()
Esempio n. 4
0
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
Esempio n. 5
0
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