Commit 19141ef7 authored by Thomas Haller's avatar Thomas Haller

libnm-core: reorder code in settings

Order the code in our common way. No other changes.

- ensure to include the main header first (directly after
  "nm-default.h").

- reorder function definitions: get_property(), set_property(),
  *_init(), *_new(), finalize(), *_class_init().
parent a3d6976e
Pipeline #14978 passed with stage
in 15 minutes and 15 seconds
...@@ -22,10 +22,11 @@ ...@@ -22,10 +22,11 @@
#include "nm-default.h" #include "nm-default.h"
#include "nm-connection.h"
#include <string.h> #include <string.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "nm-connection.h"
#include "nm-connection-private.h" #include "nm-connection-private.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-setting-private.h" #include "nm-setting-private.h"
...@@ -50,6 +51,17 @@ ...@@ -50,6 +51,17 @@
* *
*/ */
/*****************************************************************************/
enum {
SECRETS_UPDATED,
SECRETS_CLEARED,
CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct { typedef struct {
NMConnection *self; NMConnection *self;
...@@ -59,19 +71,10 @@ typedef struct { ...@@ -59,19 +71,10 @@ typedef struct {
char *path; char *path;
} NMConnectionPrivate; } NMConnectionPrivate;
static NMConnectionPrivate *nm_connection_get_private (NMConnection *connection);
#define NM_CONNECTION_GET_PRIVATE(o) (nm_connection_get_private ((NMConnection *)o))
G_DEFINE_INTERFACE (NMConnection, nm_connection, G_TYPE_OBJECT) G_DEFINE_INTERFACE (NMConnection, nm_connection, G_TYPE_OBJECT)
enum { static NMConnectionPrivate *nm_connection_get_private (NMConnection *connection);
SECRETS_UPDATED, #define NM_CONNECTION_GET_PRIVATE(o) (nm_connection_get_private ((NMConnection *)o))
SECRETS_CLEARED,
CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -19,9 +19,20 @@ ...@@ -19,9 +19,20 @@
#include "nm-default.h" #include "nm-default.h"
#include "nm-setting-private.h"
#include "nm-setting-6lowpan.h" #include "nm-setting-6lowpan.h"
#include "nm-setting-private.h"
/**
* SECTION:nm-setting-6lowpan
* @short_description: Describes connection properties for 6LoWPAN interfaces
*
* The #NMSetting6Lowpan object is a #NMSetting subclass that describes properties
* necessary for connection to 6LoWPAN interfaces.
**/
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE_BASE ( NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_PARENT, PROP_PARENT,
); );
...@@ -43,33 +54,11 @@ struct _NMSetting6LowpanClass { ...@@ -43,33 +54,11 @@ struct _NMSetting6LowpanClass {
NMSettingClass parent; NMSettingClass parent;
}; };
/**
* SECTION:nm-setting-6lowpan
* @short_description: Describes connection properties for 6LoWPAN interfaces
*
* The #NMSetting6Lowpan object is a #NMSetting subclass that describes properties
* necessary for connection to 6LoWPAN interfaces.
**/
G_DEFINE_TYPE (NMSetting6Lowpan, nm_setting_6lowpan, NM_TYPE_SETTING) G_DEFINE_TYPE (NMSetting6Lowpan, nm_setting_6lowpan, NM_TYPE_SETTING)
#define NM_SETTING_6LOWPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_6LOWPAN, NMSetting6LowpanPrivate)) #define NM_SETTING_6LOWPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_6LOWPAN, NMSetting6LowpanPrivate))
/*****************************************************************************/
/**
* nm_setting_6lowpan_new:
*
* Creates a new #NMSetting6Lowpan object with default values.
*
* Returns: (transfer full): the new empty #NMSetting6Lowpan object
*
* Since: 1.14
**/
NMSetting *
nm_setting_6lowpan_new (void)
{
return (NMSetting *) g_object_new (NM_TYPE_SETTING_6LOWPAN, NULL);
}
/** /**
* nm_setting_6lowpan_get_parent: * nm_setting_6lowpan_get_parent:
...@@ -143,22 +132,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) ...@@ -143,22 +132,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return TRUE; return TRUE;
} }
static void /*****************************************************************************/
nm_setting_6lowpan_init (NMSetting6Lowpan *setting)
{
}
static void static void
set_property (GObject *object, guint prop_id, get_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object); NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting); NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
switch (prop_id) { switch (prop_id) {
case PROP_PARENT: case PROP_PARENT:
g_free (priv->parent); g_value_set_string (value, priv->parent);
priv->parent = g_value_dup_string (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -167,15 +152,16 @@ set_property (GObject *object, guint prop_id, ...@@ -167,15 +152,16 @@ set_property (GObject *object, guint prop_id,
} }
static void static void
get_property (GObject *object, guint prop_id, set_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) const GValue *value, GParamSpec *pspec)
{ {
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object); NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting); NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
switch (prop_id) { switch (prop_id) {
case PROP_PARENT: case PROP_PARENT:
g_value_set_string (value, priv->parent); g_free (priv->parent);
priv->parent = g_value_dup_string (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -183,6 +169,28 @@ get_property (GObject *object, guint prop_id, ...@@ -183,6 +169,28 @@ get_property (GObject *object, guint prop_id,
} }
} }
/*****************************************************************************/
static void
nm_setting_6lowpan_init (NMSetting6Lowpan *setting)
{
}
/**
* nm_setting_6lowpan_new:
*
* Creates a new #NMSetting6Lowpan object with default values.
*
* Returns: (transfer full): the new empty #NMSetting6Lowpan object
*
* Since: 1.14
**/
NMSetting *
nm_setting_6lowpan_new (void)
{
return (NMSetting *) g_object_new (NM_TYPE_SETTING_6LOWPAN, NULL);
}
static void static void
finalize (GObject *object) finalize (GObject *object)
{ {
...@@ -202,8 +210,8 @@ nm_setting_6lowpan_class_init (NMSetting6LowpanClass *klass) ...@@ -202,8 +210,8 @@ nm_setting_6lowpan_class_init (NMSetting6LowpanClass *klass)
g_type_class_add_private (klass, sizeof (NMSetting6LowpanPrivate)); g_type_class_add_private (klass, sizeof (NMSetting6LowpanPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize; object_class->finalize = finalize;
setting_class->verify = verify; setting_class->verify = verify;
......
...@@ -3369,8 +3369,6 @@ finalize (GObject *object) ...@@ -3369,8 +3369,6 @@ finalize (GObject *object)
NMSetting8021x *self = NM_SETTING_802_1X (object); NMSetting8021x *self = NM_SETTING_802_1X (object);
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
/* Strings first. g_free() already checks for NULLs so we don't have to */
g_free (priv->identity); g_free (priv->identity);
g_free (priv->anonymous_identity); g_free (priv->anonymous_identity);
g_free (priv->ca_path); g_free (priv->ca_path);
...@@ -3416,8 +3414,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass) ...@@ -3416,8 +3414,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass)
g_type_class_add_private (klass, sizeof (NMSetting8021xPrivate)); g_type_class_add_private (klass, sizeof (NMSetting8021xPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize; object_class->finalize = finalize;
setting_class->verify = verify; setting_class->verify = verify;
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
#include "nm-default.h" #include "nm-default.h"
#include "nm-setting-adsl.h"
#include <string.h> #include <string.h>
#include "nm-setting-adsl.h"
#include "nm-setting-ppp.h" #include "nm-setting-ppp.h"
#include "nm-setting-private.h" #include "nm-setting-private.h"
#include "nm-utils.h" #include "nm-utils.h"
...@@ -37,9 +38,17 @@ ...@@ -37,9 +38,17 @@
* properties of ADSL connections. * properties of ADSL connections.
*/ */
G_DEFINE_TYPE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING) /*****************************************************************************/
#define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate)) NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_USERNAME,
PROP_PASSWORD,
PROP_PASSWORD_FLAGS,
PROP_PROTOCOL,
PROP_ENCAPSULATION,
PROP_VPI,
PROP_VCI,
);
typedef struct { typedef struct {
char * username; char * username;
...@@ -51,28 +60,11 @@ typedef struct { ...@@ -51,28 +60,11 @@ typedef struct {
guint32 vci; guint32 vci;
} NMSettingAdslPrivate; } NMSettingAdslPrivate;
NM_GOBJECT_PROPERTIES_DEFINE_BASE ( G_DEFINE_TYPE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING)
PROP_USERNAME,
PROP_PASSWORD,
PROP_PASSWORD_FLAGS,
PROP_PROTOCOL,
PROP_ENCAPSULATION,
PROP_VPI,
PROP_VCI,
);
/** #define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate))
* nm_setting_adsl_new:
* /*****************************************************************************/
* Creates a new #NMSettingAdsl object with default values.
*
* Returns: the new empty #NMSettingAdsl object
**/
NMSetting *
nm_setting_adsl_new (void)
{
return (NMSetting *) g_object_new (NM_TYPE_SETTING_ADSL, NULL);
}
/** /**
* nm_setting_adsl_get_username: * nm_setting_adsl_get_username:
...@@ -247,22 +239,40 @@ need_secrets (NMSetting *setting) ...@@ -247,22 +239,40 @@ need_secrets (NMSetting *setting)
return secrets; return secrets;
} }
static void /*****************************************************************************/
nm_setting_adsl_init (NMSettingAdsl *setting)
{
}
static void static void
finalize (GObject *object) get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{ {
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object); NMSettingAdsl *setting = NM_SETTING_ADSL (object);
g_free (priv->username);
g_free (priv->password);
g_free (priv->protocol);
g_free (priv->encapsulation);
G_OBJECT_CLASS (nm_setting_adsl_parent_class)->finalize (object); switch (prop_id) {
case PROP_USERNAME:
g_value_set_string (value, nm_setting_adsl_get_username (setting));
break;
case PROP_PASSWORD:
g_value_set_string (value, nm_setting_adsl_get_password (setting));
break;
case PROP_PASSWORD_FLAGS:
g_value_set_flags (value, nm_setting_adsl_get_password_flags (setting));
break;
case PROP_PROTOCOL:
g_value_set_string (value, nm_setting_adsl_get_protocol (setting));
break;
case PROP_ENCAPSULATION:
g_value_set_string (value, nm_setting_adsl_get_encapsulation (setting));
break;
case PROP_VPI:
g_value_set_uint (value, nm_setting_adsl_get_vpi (setting));
break;
case PROP_VCI:
g_value_set_uint (value, nm_setting_adsl_get_vci (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} }
static void static void
...@@ -306,38 +316,37 @@ set_property (GObject *object, guint prop_id, ...@@ -306,38 +316,37 @@ set_property (GObject *object, guint prop_id,
} }
} }
/*****************************************************************************/
static void static void
get_property (GObject *object, guint prop_id, nm_setting_adsl_init (NMSettingAdsl *setting)
GValue *value, GParamSpec *pspec)
{ {
NMSettingAdsl *setting = NM_SETTING_ADSL (object); }
switch (prop_id) { /**
case PROP_USERNAME: * nm_setting_adsl_new:
g_value_set_string (value, nm_setting_adsl_get_username (setting)); *
break; * Creates a new #NMSettingAdsl object with default values.
case PROP_PASSWORD: *
g_value_set_string (value, nm_setting_adsl_get_password (setting)); * Returns: the new empty #NMSettingAdsl object
break; **/
case PROP_PASSWORD_FLAGS: NMSetting *
g_value_set_flags (value, nm_setting_adsl_get_password_flags (setting)); nm_setting_adsl_new (void)
break; {
case PROP_PROTOCOL: return (NMSetting *) g_object_new (NM_TYPE_SETTING_ADSL, NULL);
g_value_set_string (value, nm_setting_adsl_get_protocol (setting)); }
break;
case PROP_ENCAPSULATION: static void
g_value_set_string (value, nm_setting_adsl_get_encapsulation (setting)); finalize (GObject *object)
break; {
case PROP_VPI: NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object);
g_value_set_uint (value, nm_setting_adsl_get_vpi (setting));
break; g_free (priv->username);
case PROP_VCI: g_free (priv->password);
g_value_set_uint (value, nm_setting_adsl_get_vci (setting)); g_free (priv->protocol);
break; g_free (priv->encapsulation);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_CLASS (nm_setting_adsl_parent_class)->finalize (object);
break;
}
} }
static void static void
...@@ -348,8 +357,8 @@ nm_setting_adsl_class_init (NMSettingAdslClass *klass) ...@@ -348,8 +357,8 @@ nm_setting_adsl_class_init (NMSettingAdslClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingAdslPrivate)); g_type_class_add_private (klass, sizeof (NMSettingAdslPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize; object_class->finalize = finalize;
setting_class->verify = verify; setting_class->verify = verify;
......
...@@ -22,11 +22,12 @@ ...@@ -22,11 +22,12 @@
#include "nm-default.h" #include "nm-default.h"
#include "nm-setting-bluetooth.h"
#include <string.h> #include <string.h>
#include <net/ethernet.h> #include <net/ethernet.h>
#include "nm-connection-private.h" #include "nm-connection-private.h"
#include "nm-setting-bluetooth.h"
#include "nm-setting-cdma.h" #include "nm-setting-cdma.h"
#include "nm-setting-gsm.h" #include "nm-setting-gsm.h"
#include "nm-setting-private.h" #include "nm-setting-private.h"
...@@ -43,31 +44,23 @@ ...@@ -43,31 +44,23 @@
* Point (NAP) profiles. * Point (NAP) profiles.
**/ **/
G_DEFINE_TYPE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING) /*****************************************************************************/
#define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate)) NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_BDADDR,
PROP_TYPE,
);
typedef struct { typedef struct {
char *bdaddr; char *bdaddr;
char *type; char *type;
} NMSettingBluetoothPrivate; } NMSettingBluetoothPrivate;
NM_GOBJECT_PROPERTIES_DEFINE_BASE ( G_DEFINE_TYPE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING)
PROP_BDADDR,
PROP_TYPE,
);
/** #define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate))
* nm_setting_bluetooth_new:
* /*****************************************************************************/
* Creates a new #NMSettingBluetooth object with default values.
*
* Returns: (transfer full): the new empty #NMSettingBluetooth object
**/
NMSetting *nm_setting_bluetooth_new (void)
{
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BLUETOOTH, NULL);
}
/** /**
* nm_setting_bluetooth_get_connection_type: * nm_setting_bluetooth_get_connection_type:
...@@ -221,20 +214,25 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) ...@@ -221,20 +214,25 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return TRUE; return TRUE;
} }
static void /*****************************************************************************/
nm_setting_bluetooth_init (NMSettingBluetooth *setting)
{
}
static void static void
finalize (GObject *object) get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{ {
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object); NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH (object);
g_free (priv->bdaddr);
g_free (priv->type);
G_OBJECT_CLASS (nm_setting_bluetooth_parent_class)->finalize (object); switch (prop_id) {
case PROP_BDADDR:
g_value_set_string (value, nm_setting_bluetooth_get_bdaddr (setting));
break;
case PROP_TYPE:
g_value_set_string (value, nm_setting_bluetooth_get_connection_type (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} }
static void static void
...@@ -258,23 +256,34 @@ set_property (GObject *object, guint prop_id, ...@@ -258,23 +256,34 @@ set_property (GObject *object, guint prop_id,
} }
} }
/*****************************************************************************/
static void static void
get_property (GObject *object, guint prop_id, nm_setting_bluetooth_init (NMSettingBluetooth *setting)
GValue *value, GParamSpec *pspec)
{ {
NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH (object); }
switch (prop_id) { /**
case PROP_BDADDR: * nm_setting_bluetooth_new:
g_value_set_string (value, nm_setting_bluetooth_get_bdaddr (setting)); *
break; * Creates a new #NMSettingBluetooth object with default values.
case PROP_TYPE: *
g_value_set_string (value, nm_setting_bluetooth_get_connection_type (setting)); * Returns: (transfer full): the new empty #NMSettingBluetooth object
break; **/
default: NMSetting *nm_setting_bluetooth_new (void)
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); {
break; return (NMSetting *) g_object_new (NM_TYPE_SETTING_BLUETOOTH, NULL);
} }
static void
finalize (GObject *object)
{
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
g_free (priv->bdaddr);
g_free (priv->type);
G_OBJECT_CLASS (nm_setting_bluetooth_parent_class)->finalize (object);
} }
static void static void
...@@ -286,8 +295,8 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *klass) ...@@ -286,8 +295,8 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingBluetoothPrivate)); g_type_class_add_private (klass, sizeof (NMSettingBluetoothPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize; object_class->finalize = finalize;
setting_class->verify = verify; setting_class->verify = verify;
......
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
#include "nm-default.h" #include "nm-default.h"
#include "nm-setting-bond.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include "nm-setting-bond.h"
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-utils-private.h" #include "nm-utils-private.h"
#include "nm-connection-private.h" #include "nm-connection-private.h"
...@@ -960,8 +961,8 @@ nm_setting_bond_class_init (NMSettingBondClass *klass) ...@@ -960,8 +961,8 @@ nm_setting_bond_class_init (NMSettingBondClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingBondPrivate)); g_type_class_add_private (klass, sizeof (NMSettingBondPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize; object_class->finalize = finalize;
setting_class->verify = verify; setting_class->verify = verify;
......
...@@ -21,11 +21,12 @@ ...@@ -21,11 +21,12 @@
#include "nm-default.h" #include "nm-default.h"