[network-manager-pptp/jk/libnm-port: 3/4] all: port pptp plugin to libnm
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-pptp/jk/libnm-port: 3/4] all: port pptp plugin to libnm
- Date: Fri, 29 May 2015 08:06:14 +0000 (UTC)
commit fe9cdadfc4807a8596412a3546d11a5b82a36af4
Author: Jiří Klimeš <jklimes redhat com>
Date: Fri Mar 6 13:35:37 2015 +0100
all: port pptp plugin to libnm
auth-dialog/main.c | 7 +-
configure.ac | 6 +-
properties/advanced-dialog.c | 5 +-
properties/import-export.c | 4 +-
properties/nm-pptp.c | 94 +++++++++++++++-------------
src/nm-pptp-pppd-plugin.c | 2 +-
src/nm-pptp-service.c | 141 ++++++++++++++++++++----------------------
src/nm-pptp-service.h | 7 +-
8 files changed, 130 insertions(+), 136 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index ba9a547..3249192 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -34,9 +34,8 @@
#define SECRET_API_SUBJECT_TO_CHANGE
#include <libsecret/secret.h>
-#include <nm-setting-vpn.h>
-#include <nm-vpn-plugin-utils.h>
#include <nm-vpn-password-dialog.h>
+#include <NetworkManager.h>
#include "src/nm-pptp-service.h"
@@ -271,13 +270,13 @@ main (int argc, char *argv[])
return 1;
}
- if (!nm_vpn_plugin_utils_read_vpn_details (0, &data, &secrets)) {
+ if (!nm_vpn_plugin_old_read_vpn_details (0, &data, &secrets)) {
fprintf (stderr, "Failed to read '%s' (%s) data and secrets from stdin.\n",
vpn_name, vpn_uuid);
return 1;
}
- nm_vpn_plugin_utils_get_secret_flags (secrets, NM_PPTP_KEY_PASSWORD, &pw_flags);
+ nm_vpn_plugin_old_get_secret_flags (secrets, NM_PPTP_KEY_PASSWORD, &pw_flags);
if (!get_secrets (vpn_uuid, vpn_name, retry, allow_interaction, external_ui_mode,
g_hash_table_lookup (secrets, NM_PPTP_KEY_PASSWORD),
diff --git a/configure.ac b/configure.ac
index c5dd55b..6a96eb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,10 +67,8 @@ GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32"
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.74)
PKG_CHECK_MODULES(NM,
- NetworkManager >= 0.9.10
- libnm-util >= 0.9.10
- libnm-glib >= 0.9.10
- libnm-glib-vpn >= 0.9.10)
+ NetworkManager >= 1.0
+ libnm >= 1.0)
if test x"$with_gnome" != xno; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4)
diff --git a/properties/advanced-dialog.c b/properties/advanced-dialog.c
index 54c4325..7429319 100644
--- a/properties/advanced-dialog.c
+++ b/properties/advanced-dialog.c
@@ -35,8 +35,7 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
-#include <nm-connection.h>
-#include <nm-setting-vpn.h>
+#include <NetworkManager.h>
#include "advanced-dialog.h"
#include "nm-pptp.h"
@@ -90,7 +89,7 @@ advanced_dialog_new_hash_from_connection (NMConnection *connection,
GError **error)
{
GHashTable *hash;
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
diff --git a/properties/import-export.c b/properties/import-export.c
index 356a6de..c9cb1b7 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -34,9 +34,7 @@
#include <glib/gi18n-lib.h>
-#include <nm-setting-vpn.h>
-#include <nm-setting-connection.h>
-#include <nm-setting-ip4-config.h>
+#include <NetworkManager.h>
#include "import-export.h"
#include "nm-pptp.h"
diff --git a/properties/nm-pptp.c b/properties/nm-pptp.c
index 9211ee3..96da82b 100644
--- a/properties/nm-pptp.c
+++ b/properties/nm-pptp.c
@@ -34,10 +34,7 @@
#include <string.h>
#include <gtk/gtk.h>
-#include <nm-vpn-plugin-ui-interface.h>
-#include <nm-setting-vpn.h>
-#include <nm-setting-connection.h>
-#include <nm-setting-ip4-config.h>
+#include <NetworkManager.h>
#include "nm-pptp-service-defines.h"
#include "nm-pptp.h"
@@ -56,18 +53,18 @@ typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data);
/************** plugin class **************/
-static void pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
+static void pptp_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class);
G_DEFINE_TYPE_EXTENDED (PptpPluginUi, pptp_plugin_ui, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN,
pptp_plugin_ui_interface_init))
/************** UI widget class **************/
-static void pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class);
+static void pptp_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class);
G_DEFINE_TYPE_EXTENDED (PptpPluginUiWidget, pptp_plugin_ui_widget, G_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE,
+ G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR,
pptp_plugin_ui_widget_interface_init))
#define PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PPTP_TYPE_PLUGIN_UI_WIDGET,
PptpPluginUiWidgetPrivate))
@@ -82,6 +79,14 @@ typedef struct {
gboolean new_connection;
} PptpPluginUiWidgetPrivate;
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_DESC,
+ PROP_SERVICE,
+
+ LAST_PROP
+};
GQuark
pptp_plugin_ui_error_quark (void)
@@ -213,7 +218,7 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
static void
setup_password_widget (PptpPluginUiWidget *self,
const char *entry_name,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *secret_name,
gboolean new_connection)
{
@@ -284,7 +289,7 @@ pw_type_combo_changed_cb (GtkWidget *combo, gpointer user_data)
static void
init_one_pw_combo (PptpPluginUiWidget *self,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *combo_name,
const char *secret_key,
const char *entry_name)
@@ -343,7 +348,7 @@ static gboolean
init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **error)
{
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
GtkWidget *widget;
const char *value;
@@ -412,7 +417,7 @@ init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **err
}
static GObject *
-get_widget (NMVpnPluginUiWidgetInterface *iface)
+get_widget (NMVpnEditor *iface)
{
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
@@ -423,13 +428,13 @@ get_widget (NMVpnPluginUiWidgetInterface *iface)
static void
hash_copy_advanced (gpointer key, gpointer data, gpointer user_data)
{
- NMSettingVPN *s_vpn = NM_SETTING_VPN (user_data);
+ NMSettingVpn *s_vpn = NM_SETTING_VPN (user_data);
nm_setting_vpn_add_data_item (s_vpn, (const char *) key, (const char *) data);
}
static void
-save_password_and_flags (NMSettingVPN *s_vpn,
+save_password_and_flags (NMSettingVpn *s_vpn,
GtkBuilder *builder,
const char *entry_name,
const char *combo_name,
@@ -466,13 +471,13 @@ save_password_and_flags (NMSettingVPN *s_vpn,
}
static gboolean
-update_connection (NMVpnPluginUiWidgetInterface *iface,
+update_connection (NMVpnEditor *iface,
NMConnection *connection,
GError **error)
{
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
GtkWidget *widget;
const char *str;
gboolean valid = FALSE;
@@ -526,19 +531,19 @@ is_new_func (const char *key, const char *value, gpointer user_data)
*is_new = FALSE;
}
-static NMVpnPluginUiWidgetInterface *
+static NMVpnEditor *
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
{
- NMVpnPluginUiWidgetInterface *object;
+ NMVpnEditor *object;
PptpPluginUiWidgetPrivate *priv;
char *ui_file;
gboolean new = TRUE;
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
if (error)
g_return_val_if_fail (*error == NULL, NULL);
- object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (PPTP_TYPE_PLUGIN_UI_WIDGET, NULL));
+ object = NM_VPN_EDITOR (g_object_new (PPTP_TYPE_PLUGIN_UI_WIDGET, NULL));
if (!object) {
g_set_error (error, PPTP_PLUGIN_UI_ERROR, 0, "could not create pptp object");
return NULL;
@@ -632,7 +637,7 @@ pptp_plugin_ui_widget_init (PptpPluginUiWidget *plugin)
}
static void
-pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
+pptp_plugin_ui_widget_interface_init (NMVpnEditorInterface *iface_class)
{
/* interface implementation */
iface_class->get_widget = get_widget;
@@ -640,7 +645,7 @@ pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
}
static NMConnection *
-import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
+import (NMVpnEditorPlugin *iface, const char *path, GError **error)
{
NMConnection *connection = NULL;
char *contents = NULL;
@@ -686,7 +691,7 @@ out:
}
static gboolean
-export (NMVpnPluginUiInterface *iface,
+export (NMVpnEditorPlugin *iface,
const char *path,
NMConnection *connection,
GError **error)
@@ -695,7 +700,7 @@ export (NMVpnPluginUiInterface *iface,
}
static char *
-get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
+get_suggested_filename (NMVpnEditorPlugin *iface, NMConnection *connection)
{
NMSettingConnection *s_con;
const char *id;
@@ -711,14 +716,14 @@ get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
return g_strdup_printf ("%s (pptp).conf", id);
}
-static guint32
-get_capabilities (NMVpnPluginUiInterface *iface)
+static NMVpnEditorPluginCapability
+get_capabilities (NMVpnEditorPlugin *iface)
{
- return (NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT | NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT);
+ return (NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT | NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT);
}
-static NMVpnPluginUiWidgetInterface *
-ui_factory (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error)
+static NMVpnEditor *
+get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error)
{
return nm_vpn_plugin_ui_widget_interface_new (connection, error);
}
@@ -728,13 +733,13 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME:
+ case PROP_NAME:
g_value_set_string (value, PPTP_PLUGIN_NAME);
break;
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC:
+ case PROP_DESC:
g_value_set_string (value, PPTP_PLUGIN_DESC);
break;
- case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE:
+ case PROP_SERVICE:
g_value_set_string (value, PPTP_PLUGIN_SERVICE);
break;
default:
@@ -751,16 +756,16 @@ pptp_plugin_ui_class_init (PptpPluginUiClass *req_class)
object_class->get_property = get_property;
g_object_class_override_property (object_class,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME,
- NM_VPN_PLUGIN_UI_INTERFACE_NAME);
+ PROP_NAME,
+ NM_VPN_EDITOR_PLUGIN_NAME);
g_object_class_override_property (object_class,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC,
- NM_VPN_PLUGIN_UI_INTERFACE_DESC);
+ PROP_DESC,
+ NM_VPN_EDITOR_PLUGIN_DESCRIPTION);
g_object_class_override_property (object_class,
- NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE,
- NM_VPN_PLUGIN_UI_INTERFACE_SERVICE);
+ PROP_SERVICE,
+ NM_VPN_EDITOR_PLUGIN_SERVICE);
}
static void
@@ -769,19 +774,18 @@ pptp_plugin_ui_init (PptpPluginUi *plugin)
}
static void
-pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
+pptp_plugin_ui_interface_init (NMVpnEditorPluginInterface *iface_class)
{
/* interface implementation */
- iface_class->ui_factory = ui_factory;
+ iface_class->get_editor = get_editor;
iface_class->get_capabilities = get_capabilities;
iface_class->import_from_file = import;
iface_class->export_to_file = export;
- iface_class->get_suggested_name = get_suggested_name;
+ iface_class->get_suggested_filename = get_suggested_filename;
}
-
-G_MODULE_EXPORT NMVpnPluginUiInterface *
-nm_vpn_plugin_ui_factory (GError **error)
+G_MODULE_EXPORT NMVpnEditorPlugin *
+nm_vpn_editor_plugin_factory (GError **error)
{
if (error)
g_return_val_if_fail (*error == NULL, NULL);
@@ -789,6 +793,6 @@ nm_vpn_plugin_ui_factory (GError **error)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (PPTP_TYPE_PLUGIN_UI, NULL));
+ return NM_VPN_EDITOR_PLUGIN (g_object_new (PPTP_TYPE_PLUGIN_UI, NULL));
}
diff --git a/src/nm-pptp-pppd-plugin.c b/src/nm-pptp-pppd-plugin.c
index 302274a..ebf2b0b 100644
--- a/src/nm-pptp-pppd-plugin.c
+++ b/src/nm-pptp-pppd-plugin.c
@@ -34,7 +34,7 @@
#include "nm-pptp-service.h"
#include "nm-ppp-status.h"
-#include <nm-utils.h>
+#include <NetworkManager.h>
int plugin_init (void);
diff --git a/src/nm-pptp-service.c b/src/nm-pptp-service.c
index 9a1da0e..a31c5f5 100644
--- a/src/nm-pptp-service.c
+++ b/src/nm-pptp-service.c
@@ -47,8 +47,7 @@
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
-#include <nm-setting-vpn.h>
-#include <nm-utils.h>
+#include <NetworkManager.h>
#include "nm-pptp-service.h"
#include "nm-ppp-status.h"
@@ -227,7 +226,7 @@ _service_cache_credentials (NMPptpPppService *self,
GError **error)
{
NMPptpPppServicePrivate *priv = NM_PPTP_PPP_SERVICE_GET_PRIVATE (self);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
const char *username, *password, *domain;
g_return_val_if_fail (self != NULL, FALSE);
@@ -237,7 +236,7 @@ _service_cache_credentials (NMPptpPppService *self,
if (!s_vpn) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
_("Could not find secrets (connection invalid, no vpn setting)."));
return FALSE;
}
@@ -249,7 +248,7 @@ _service_cache_credentials (NMPptpPppService *self,
if (!username || !*username) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
_("Missing or invalid VPN username."));
return FALSE;
}
@@ -259,7 +258,7 @@ _service_cache_credentials (NMPptpPppService *self,
if (!password || !strlen (password)) {
g_set_error_literal (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
_("Missing or invalid VPN password."));
return FALSE;
}
@@ -416,7 +415,7 @@ impl_pptp_service_need_secrets (NMPptpPppService *self,
if (!strlen (priv->username) || !strlen (priv->password)) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
"%s",
_("No cached credentials."));
goto error;
@@ -463,7 +462,7 @@ impl_pptp_service_set_ip4_config (NMPptpPppService *self,
/* The VPN plugin service */
/********************************************************/
-G_DEFINE_TYPE (NMPptpPlugin, nm_pptp_plugin, NM_TYPE_VPN_PLUGIN)
+G_DEFINE_TYPE (NMPptpPlugin, nm_pptp_plugin, NM_TYPE_VPN_PLUGIN_OLD)
typedef struct {
GPid pid;
@@ -613,7 +612,7 @@ validate_one_property (const char *key, const char *value, gpointer user_data)
}
static gboolean
-nm_pptp_properties_validate (NMSettingVPN *s_vpn,
+nm_pptp_properties_validate (NMSettingVpn *s_vpn,
GError **error)
{
ValidateInfo info = { &valid_properties[0], error, FALSE };
@@ -655,7 +654,7 @@ nm_pptp_properties_validate (NMSettingVPN *s_vpn,
}
static gboolean
-nm_pptp_secrets_validate (NMSettingVPN *s_vpn, GError **error)
+nm_pptp_secrets_validate (NMSettingVpn *s_vpn, GError **error)
{
ValidateInfo info = { &valid_secrets[0], error, FALSE };
@@ -700,21 +699,21 @@ pppd_watch_cb (GPid pid, gint status, gpointer user_data)
case 16:
/* hangup */
// FIXME: better failure reason
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ nm_vpn_plugin_old_failure (NM_VPN_PLUGIN_OLD (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
break;
case 2:
/* Couldn't log in due to bad user/pass */
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
+ nm_vpn_plugin_old_failure (NM_VPN_PLUGIN_OLD (plugin), NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
break;
case 1:
/* Other error (couldn't bind to address, etc) */
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ nm_vpn_plugin_old_failure (NM_VPN_PLUGIN_OLD (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
break;
default:
break;
}
- nm_vpn_plugin_set_state (NM_VPN_PLUGIN (plugin), NM_VPN_SERVICE_STATE_STOPPED);
+ nm_vpn_plugin_old_set_state (NM_VPN_PLUGIN_OLD (plugin), NM_VPN_SERVICE_STATE_STOPPED);
}
static inline const char *
@@ -767,7 +766,7 @@ pppd_timed_out (gpointer user_data)
NMPptpPlugin *plugin = NM_PPTP_PLUGIN (user_data);
g_warning ("Looks like pppd didn't initialize our dbus module");
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT);
+ nm_vpn_plugin_old_failure (NM_VPN_PLUGIN_OLD (plugin),
NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT);
return FALSE;
}
@@ -804,7 +803,7 @@ str_to_int (const char *str, long int *out)
static GPtrArray *
construct_pppd_args (NMPptpPlugin *plugin,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *pppd,
const char *gwaddr,
GError **error)
@@ -834,7 +833,7 @@ construct_pppd_args (NMPptpPlugin *plugin,
if (!gwaddr || !strlen (gwaddr)) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
+ NM_VPN_PLUGIN_ERROR_INVALID_CONNECTION,
"%s",
_("Missing VPN gateway."));
goto error;
@@ -982,7 +981,7 @@ error:
static gboolean
nm_pptp_start_pppd_binary (NMPptpPlugin *plugin,
- NMSettingVPN *s_vpn,
+ NMSettingVpn *s_vpn,
const char *gwaddr,
GError **error)
{
@@ -1045,15 +1044,15 @@ service_ppp_state_cb (NMPptpPppService *service,
guint32 ppp_state,
NMPptpPlugin *plugin)
{
- NMVPNServiceState plugin_state = nm_vpn_plugin_get_state (NM_VPN_PLUGIN (plugin));
+ NMVpnServiceState plugin_state = nm_vpn_plugin_old_get_state (NM_VPN_PLUGIN_OLD (plugin));
switch (ppp_state) {
case NM_PPP_STATUS_DEAD:
case NM_PPP_STATUS_DISCONNECT:
if (plugin_state == NM_VPN_SERVICE_STATE_STARTED)
- nm_vpn_plugin_disconnect (NM_VPN_PLUGIN (plugin), NULL);
+ nm_vpn_plugin_old_disconnect (NM_VPN_PLUGIN_OLD (plugin), NULL);
else if (plugin_state == NM_VPN_SERVICE_STATE_STARTING)
- nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
+ nm_vpn_plugin_old_failure (NM_VPN_PLUGIN_OLD (plugin),
NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
break;
default:
break;
@@ -1061,62 +1060,53 @@ service_ppp_state_cb (NMPptpPppService *service,
}
static void
-nm_gvalue_destroy (gpointer data)
-{
- g_value_unset ((GValue *) data);
- g_slice_free (GValue, data);
-}
-
-static GValue *
-nm_gvalue_dup (const GValue *value)
-{
- GValue *value_dup;
-
- value_dup = g_slice_new0 (GValue);
- g_value_init (value_dup, G_VALUE_TYPE (value));
- g_value_copy (value, value_dup);
-
- return value_dup;
-}
-
-static void
-copy_hash (gpointer key, gpointer value, gpointer user_data)
-{
- g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), nm_gvalue_dup ((GValue *) value));
-}
-
-static void
service_ip4_config_cb (NMPptpPppService *service,
GHashTable *config_hash,
- NMVPNPlugin *plugin)
+ NMVpnPluginOld *plugin)
{
NMPptpPppServicePrivate *priv = NM_PPTP_PPP_SERVICE_GET_PRIVATE (service);
- GHashTable *hash;
+ GHashTableIter iter;
+ char *key;
GValue *value;
+ GVariantBuilder builder;
+ GVariant *new_config;
+ GVariant *tmp;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+ g_hash_table_iter_init (&iter, config_hash);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
+ if (G_VALUE_HOLDS_STRING (value))
+ tmp = g_variant_new_string (g_value_get_string (value));
+ else if (G_VALUE_HOLDS_UINT (value))
+ tmp = g_variant_new_uint32 (g_value_get_uint (value));
+ else if (G_VALUE_HOLDS (value, DBUS_TYPE_G_UINT_ARRAY)) {
+ GArray *arr = g_value_get_boxed (value);
+ tmp = g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32, arr->data, arr->len, sizeof
(guint32));
+ } else
+ tmp = NULL;
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy);
- g_hash_table_foreach (config_hash, copy_hash, hash);
+ if (tmp)
+ g_variant_builder_add (&builder, "{sv}", key, tmp);
+ }
/* Insert the external VPN gateway into the table, which the pppd plugin
* simply doesn't know about.
*/
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_UINT);
- g_value_set_uint (value, priv->naddr);
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_GATEWAY), value);
+ g_variant_builder_add (&builder, "{sv}", NM_PPTP_KEY_GATEWAY, g_variant_new_uint32 (priv->naddr));
+ new_config = g_variant_builder_end (&builder);
+ g_variant_ref_sink (new_config);
- nm_vpn_plugin_set_ip4_config (plugin, hash);
-
- g_hash_table_destroy (hash);
+ nm_vpn_plugin_old_set_ip4_config (plugin, new_config);
+ g_variant_unref (new_config);
}
static gboolean
-real_connect (NMVPNPlugin *plugin,
- NMConnection *connection,
- GError **error)
+real_connect (NMVpnPluginOld *plugin,
+ NMConnection *connection,
+ GError **error)
{
NMPptpPluginPrivate *priv = NM_PPTP_PLUGIN_GET_PRIVATE (plugin);
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
const char *gwaddr;
s_vpn = nm_connection_get_setting_vpn (connection);
@@ -1162,15 +1152,15 @@ real_connect (NMVPNPlugin *plugin,
}
static gboolean
-real_need_secrets (NMVPNPlugin *plugin,
+real_need_secrets (NMVpnPluginOld *plugin,
NMConnection *connection,
- char **setting_name,
+ const char **setting_name,
GError **error)
{
- NMSettingVPN *s_vpn;
+ NMSettingVpn *s_vpn;
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
- g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE);
+ g_return_val_if_fail (NM_IS_VPN_PLUGIN_OLD (plugin), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
s_vpn = nm_connection_get_setting_vpn (connection);
@@ -1202,8 +1192,7 @@ ensure_killed (gpointer data)
}
static gboolean
-real_disconnect (NMVPNPlugin *plugin,
- GError **err)
+real_disconnect (NMVpnPluginOld *plugin, GError **err)
{
NMPptpPluginPrivate *priv = NM_PPTP_PLUGIN_GET_PRIVATE (plugin);
@@ -1224,7 +1213,7 @@ real_disconnect (NMVPNPlugin *plugin,
}
static void
-state_changed_cb (GObject *object, NMVPNServiceState state, gpointer user_data)
+state_changed_cb (GObject *object, NMVpnServiceState state, gpointer user_data)
{
NMPptpPluginPrivate *priv = NM_PPTP_PLUGIN_GET_PRIVATE (object);
@@ -1266,7 +1255,7 @@ static void
nm_pptp_plugin_class_init (NMPptpPluginClass *pptp_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (pptp_class);
- NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS (pptp_class);
+ NMVpnPluginOldClass *parent_class = NM_VPN_PLUGIN_OLD_CLASS (pptp_class);
g_type_class_add_private (object_class, sizeof (NMPptpPluginPrivate));
@@ -1281,13 +1270,19 @@ NMPptpPlugin *
nm_pptp_plugin_new (void)
{
NMPptpPlugin *plugin;
+ GError *error = NULL;
- plugin = g_object_new (NM_TYPE_PPTP_PLUGIN,
- NM_VPN_PLUGIN_DBUS_SERVICE_NAME,
- NM_DBUS_SERVICE_PPTP,
- NULL);
+ plugin = g_initable_new (NM_TYPE_PPTP_PLUGIN, NULL, &error,
+ NM_VPN_PLUGIN_OLD_DBUS_SERVICE_NAME,
+ NM_DBUS_SERVICE_PPTP,
+ NULL);
if (plugin)
g_signal_connect (G_OBJECT (plugin), "state-changed", G_CALLBACK (state_changed_cb), NULL);
+
+ if (debug && error)
+ g_message ("Error: failed to create NMPptpPlugin: %s", error->message);
+ g_clear_error (&error);
+
return plugin;
}
diff --git a/src/nm-pptp-service.h b/src/nm-pptp-service.h
index 135cf4e..7872527 100644
--- a/src/nm-pptp-service.h
+++ b/src/nm-pptp-service.h
@@ -25,7 +25,8 @@
#include <glib.h>
#include <glib-object.h>
-#include <nm-vpn-plugin.h>
+#include <NetworkManager.h>
+#include <nm-vpn-plugin-old.h>
#include "nm-pptp-service-defines.h"
@@ -40,11 +41,11 @@
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
typedef struct {
- NMVPNPlugin parent;
+ NMVpnPluginOld parent;
} NMPptpPlugin;
typedef struct {
- NMVPNPluginClass parent;
+ NMVpnPluginOldClass parent;
} NMPptpPluginClass;
GType nm_pptp_plugin_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]