gboolean ce_page_vpn_can_export (CEPageVpn *page) { CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (page); return (nm_vpn_editor_plugin_get_capabilities (priv->plugin) & NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT) != 0; }
static void finish_setup (CEPageVpn *self, gpointer unused, GError *error, gpointer user_data) { CEPage *parent = CE_PAGE (self); CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (self); GError *vpn_error = NULL; if (error) return; g_return_if_fail (priv->plugin != NULL); priv->ui = nm_vpn_plugin_ui_interface_ui_factory (priv->plugin, parent->connection, &vpn_error); if (!priv->ui) { g_warning ("Could not load VPN user interface for service '%s': %s.", priv->service_type, (vpn_error && vpn_error->message) ? vpn_error->message : "(unknown)"); g_error_free (vpn_error); return; } g_signal_connect (priv->ui, "changed", G_CALLBACK (vpn_plugin_changed_cb), self); parent->page = GTK_WIDGET (nm_vpn_plugin_ui_widget_interface_get_widget (priv->ui)); if (!parent->page) { g_warning ("Could not load VPN user interface for service '%s'.", priv->service_type); return; } g_object_ref_sink (parent->page); gtk_widget_show_all (parent->page); }
CEPage * ce_page_vpn_new (NMConnectionEditor *editor, NMConnection *connection, GtkWindow *parent_window, NMClient *client, const char **out_secrets_setting_name, GError **error) { CEPageVpn *self; CEPageVpnPrivate *priv; const char *service_type; GError *local = NULL; self = CE_PAGE_VPN (ce_page_new (CE_TYPE_PAGE_VPN, editor, connection, parent_window, client, NULL, NULL, _("VPN"))); if (!self) { g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load VPN user interface.")); return NULL; } priv = CE_PAGE_VPN_GET_PRIVATE (self); priv->setting = nm_connection_get_setting_vpn (connection); g_assert (priv->setting); service_type = nm_setting_vpn_get_service_type (priv->setting); g_assert (service_type); priv->service_type = g_strdup (service_type); priv->plugin = vpn_get_plugin_by_service (service_type); if (!priv->plugin) { g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not find VPN plugin for “%s”."), service_type); g_object_unref (self); return NULL; } priv->plugin = g_object_ref (priv->plugin); priv->editor = nm_vpn_editor_plugin_get_editor (priv->plugin, CE_PAGE (self)->connection, &local); if (!priv->editor) { g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load editor VPN plugin for “%s” (%s)."), service_type, local ? local->message : _("unknown failure")); g_clear_error (&local); g_object_unref (self); return NULL; } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); *out_secrets_setting_name = NM_SETTING_VPN_SETTING_NAME; return CE_PAGE (self); }
static gboolean ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error) { CEPageVpn *self = CE_PAGE_VPN (page); CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (self); return nm_vpn_editor_update_connection (priv->editor, connection, error); }
static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { CEPageVpn *self = CE_PAGE_VPN (page); CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (self); return nm_vpn_plugin_ui_widget_interface_update_connection (priv->ui, connection, error); }
static void dispose (GObject *object) { CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (object); g_clear_object (&priv->ui); g_clear_pointer (&priv->service_type, g_free); G_OBJECT_CLASS (ce_page_vpn_parent_class)->dispose (object); }
static void dispose (GObject *object) { CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (object); if (priv->editor) { g_signal_handlers_disconnect_by_func (priv->editor, G_CALLBACK (vpn_plugin_changed_cb), object); g_clear_object (&priv->editor); } g_clear_pointer (&priv->service_type, g_free); g_clear_object (&priv->plugin); G_OBJECT_CLASS (ce_page_vpn_parent_class)->dispose (object); }
CEPage * ce_page_vpn_new (NMConnection *connection, GtkWindow *parent_window, NMClient *client, NMRemoteSettings *settings, const char **out_secrets_setting_name, GError **error) { CEPageVpn *self; CEPageVpnPrivate *priv; const char *service_type; self = CE_PAGE_VPN (ce_page_new (CE_TYPE_PAGE_VPN, connection, parent_window, client, settings, NULL, NULL, _("VPN"))); if (!self) { g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load VPN user interface.")); return NULL; } priv = CE_PAGE_VPN_GET_PRIVATE (self); priv->setting = nm_connection_get_setting_vpn (connection); g_assert (priv->setting); service_type = nm_setting_vpn_get_service_type (priv->setting); g_assert (service_type); priv->service_type = g_strdup (service_type); priv->plugin = vpn_get_plugin_by_service (service_type); if (!priv->plugin) { g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not find VPN plugin service for '%s'."), service_type); g_object_unref (self); return NULL; } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); *out_secrets_setting_name = NM_SETTING_VPN_SETTING_NAME; return CE_PAGE (self); }
static void dispose (GObject *object) { CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (object); if (priv->disposed) return; priv->disposed = TRUE; if (priv->ui) g_object_unref (priv->ui); g_free (priv->service_type); G_OBJECT_CLASS (ce_page_vpn_parent_class)->dispose (object); }
gboolean ce_page_vpn_save_secrets (CEPage *page, NMConnection *connection) { CEPageVpn *self = CE_PAGE_VPN (page); CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (self); GError *error = NULL; gboolean success = FALSE; success = nm_vpn_plugin_ui_widget_interface_save_secrets (priv->ui, connection, &error); if (!success) { g_warning ("%s: couldn't save VPN secrets: (%d) %s", __func__, error ? error->code : -1, error ? error->message : "unknown"); if (error) g_error_free (error); } return success; }
static void finish_setup (CEPageVpn *self, gpointer unused, GError *error, gpointer user_data) { CEPage *parent = CE_PAGE (self); CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (self); if (error) return; g_return_if_fail (NM_IS_VPN_EDITOR_PLUGIN (priv->plugin)); g_return_if_fail (NM_IS_VPN_EDITOR (priv->editor)); g_signal_connect (priv->editor, "changed", G_CALLBACK (vpn_plugin_changed_cb), self); parent->page = GTK_WIDGET (nm_vpn_editor_get_widget (priv->editor)); if (!parent->page) { g_warning ("Could not load VPN user interface for service '%s'.", priv->service_type); return; } g_object_ref_sink (parent->page); gtk_widget_show_all (parent->page); }
CEPage * ce_page_vpn_new (NMConnection *connection, GtkWindow *parent_window, GError **error) { CEPageVpn *self; CEPageVpnPrivate *priv; CEPage *parent; const char *service_type; self = CE_PAGE_VPN (g_object_new (CE_TYPE_PAGE_VPN, CE_PAGE_CONNECTION, connection, CE_PAGE_PARENT_WINDOW, parent_window, NULL)); parent = CE_PAGE (self); priv = CE_PAGE_VPN_GET_PRIVATE (self); parent->title = g_strdup (_("VPN")); priv->setting = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); g_assert (priv->setting); service_type = nm_setting_vpn_get_service_type (priv->setting); g_assert (service_type); priv->service_type = g_strdup (service_type); priv->plugin = vpn_get_plugin_by_service (service_type); if (!priv->plugin) { g_set_error (error, 0, 0, _("Could not find VPN plugin service for '%s'."), service_type); g_object_unref (self); return NULL; } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); if (!ce_page_initialize (parent, NM_SETTING_VPN_SETTING_NAME, error)) { g_object_unref (self); return NULL; } return CE_PAGE (self); }