Ejemplo n.º 1
0
def delete_profile(builder, lets_connect):  # type: (Gtk.builder, bool) -> None
    """called when the user presses the - button"""
    logger.info("delete provider clicked")
    meta = metadata_of_selected(builder)

    if not meta:
        logger.info("nothing selected")
        return

    window = builder.get_object('eduvpn-window')

    dialog = Gtk.MessageDialog(
        window, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING,
        Gtk.ButtonsType.YES_NO,
        "Are you sure you want to remove '{}'?".format(meta.display_name))
    dialog.format_secondary_text("This action can't be undone.")
    response = dialog.run()
    if response == Gtk.ResponseType.YES:
        logger.info("deleting provider config")
        try:
            delete_provider(meta.uuid)
            notification = init_notify(lets_connect)
            notify(notification, "eduVPN provider deleted",
                   "Deleted '{}'".format(meta.display_name))
        except Exception as e:
            error_helper(window, "can't delete profile", str(e))
            dialog.hide()
            raise
        GLib.idle_add(
            lambda: refresh_start(builder, lets_connect=lets_connect))
    elif response == Gtk.ResponseType.NO:
        logger.info("not deleting provider config")
    dialog.hide()
Ejemplo n.º 2
0
def _background(meta, dialog, builder, config_dict, lets_connect):
    try:
        uuid = store_provider(meta, config_dict)
        monitor_vpn(uuid=uuid, callback=lambda *args, **kwargs: vpn_change(builder=builder, lets_connect=lets_connect))
        notification = init_notify(lets_connect)
        GLib.idle_add(lambda: notify(notification, "eduVPN provider added",
                                     "added provider '{}'".format(meta.display_name)))
    except Exception as e:
        error = e
        GLib.idle_add(lambda: error_helper(dialog, "can't store configuration", "{}: {}".format(type(error).__name__,
                                                                                                str(error))))
        GLib.idle_add(lambda: dialog.hide())
        raise
    else:
        GLib.idle_add(lambda: dialog.hide())
        GLib.idle_add(lambda: refresh_start(builder, lets_connect=lets_connect))
Ejemplo n.º 3
0
 def run(self):
     # attach a callback to VPN connection monitor
     monitor_all_vpn(self.vpn_change)
     self.window.show_all()
     refresh_start(self.builder, self.lets_connect)
Ejemplo n.º 4
0
 def test_update_providers(self, _):
     refresh_start(builder=self.builder, lets_connect=False)