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 @@
#include "nm-default.h"
#include "nm-connection.h"
#include <string.h>
#include <arpa/inet.h>
#include "nm-connection.h"
#include "nm-connection-private.h"
#include "nm-utils.h"
#include "nm-setting-private.h"
......@@ -50,6 +51,17 @@
*
*/
/*****************************************************************************/
enum {
SECRETS_UPDATED,
SECRETS_CLEARED,
CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
NMConnection *self;
......@@ -59,19 +71,10 @@ typedef struct {
char *path;
} 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)
enum {
SECRETS_UPDATED,
SECRETS_CLEARED,
CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static NMConnectionPrivate *nm_connection_get_private (NMConnection *connection);
#define NM_CONNECTION_GET_PRIVATE(o) (nm_connection_get_private ((NMConnection *)o))
/*****************************************************************************/
......
......@@ -19,9 +19,20 @@
#include "nm-default.h"
#include "nm-setting-private.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 (
PROP_PARENT,
);
......@@ -43,33 +54,11 @@ struct _NMSetting6LowpanClass {
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)
#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:
......@@ -143,22 +132,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return TRUE;
}
static void
nm_setting_6lowpan_init (NMSetting6Lowpan *setting)
{
}
/*****************************************************************************/
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
switch (prop_id) {
case PROP_PARENT:
g_free (priv->parent);
priv->parent = g_value_dup_string (value);
g_value_set_string (value, priv->parent);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -167,15 +152,16 @@ set_property (GObject *object, guint prop_id,
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
switch (prop_id) {
case PROP_PARENT:
g_value_set_string (value, priv->parent);
g_free (priv->parent);
priv->parent = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -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
finalize (GObject *object)
{
......@@ -202,8 +210,8 @@ nm_setting_6lowpan_class_init (NMSetting6LowpanClass *klass)
g_type_class_add_private (klass, sizeof (NMSetting6LowpanPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
setting_class->verify = verify;
......
......@@ -3369,8 +3369,6 @@ finalize (GObject *object)
NMSetting8021x *self = NM_SETTING_802_1X (object);
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->anonymous_identity);
g_free (priv->ca_path);
......@@ -3416,8 +3414,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *klass)
g_type_class_add_private (klass, sizeof (NMSetting8021xPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
setting_class->verify = verify;
......
......@@ -21,9 +21,10 @@
#include "nm-default.h"
#include "nm-setting-adsl.h"
#include <string.h>
#include "nm-setting-adsl.h"
#include "nm-setting-ppp.h"
#include "nm-setting-private.h"
#include "nm-utils.h"
......@@ -37,9 +38,17 @@
* 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 {
char * username;
......@@ -51,28 +60,11 @@ typedef struct {
guint32 vci;
} NMSettingAdslPrivate;
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_USERNAME,
PROP_PASSWORD,
PROP_PASSWORD_FLAGS,
PROP_PROTOCOL,
PROP_ENCAPSULATION,
PROP_VPI,
PROP_VCI,
);
G_DEFINE_TYPE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING)
/**
* 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);
}
#define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate))
/*****************************************************************************/
/**
* nm_setting_adsl_get_username:
......@@ -247,22 +239,40 @@ need_secrets (NMSetting *setting)
return secrets;
}
static void
nm_setting_adsl_init (NMSettingAdsl *setting)
{
}
/*****************************************************************************/
static void
finalize (GObject *object)
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object);
g_free (priv->username);
g_free (priv->password);
g_free (priv->protocol);
g_free (priv->encapsulation);
NMSettingAdsl *setting = NM_SETTING_ADSL (object);
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
......@@ -306,38 +316,37 @@ set_property (GObject *object, guint prop_id,
}
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
nm_setting_adsl_init (NMSettingAdsl *setting)
{
NMSettingAdsl *setting = NM_SETTING_ADSL (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;
}
/**
* 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);
}
static void
finalize (GObject *object)
{
NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (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);
}
static void
......@@ -348,8 +357,8 @@ nm_setting_adsl_class_init (NMSettingAdslClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingAdslPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
setting_class->verify = verify;
......
......@@ -22,11 +22,12 @@
#include "nm-default.h"
#include "nm-setting-bluetooth.h"
#include <string.h>
#include <net/ethernet.h>
#include "nm-connection-private.h"
#include "nm-setting-bluetooth.h"
#include "nm-setting-cdma.h"
#include "nm-setting-gsm.h"
#include "nm-setting-private.h"
......@@ -43,31 +44,23 @@
* 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 {
char *bdaddr;
char *type;
} NMSettingBluetoothPrivate;
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_BDADDR,
PROP_TYPE,
);
G_DEFINE_TYPE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING)
/**
* 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);
}
#define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate))
/*****************************************************************************/
/**
* nm_setting_bluetooth_get_connection_type:
......@@ -221,20 +214,25 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return TRUE;
}
static void
nm_setting_bluetooth_init (NMSettingBluetooth *setting)
{
}
/*****************************************************************************/
static void
finalize (GObject *object)
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
g_free (priv->bdaddr);
g_free (priv->type);
NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH (object);
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
......@@ -258,23 +256,34 @@ set_property (GObject *object, guint prop_id,
}
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
nm_setting_bluetooth_init (NMSettingBluetooth *setting)
{
NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH (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;
}
/**
* 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);
}
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
......@@ -286,8 +295,8 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingBluetoothPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
setting_class->verify = verify;
......
......@@ -21,13 +21,14 @@
#include "nm-default.h"
#include "nm-setting-bond.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "nm-setting-bond.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-connection-private.h"
......@@ -960,8 +961,8 @@ nm_setting_bond_class_init (NMSettingBondClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingBondPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
setting_class->verify = verify;
......
......@@ -21,11 +21,12 @@
#include "nm-default.h"
#include "nm-setting-bridge-port.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "nm-setting-bridge-port.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-connection-private.h"
......@@ -40,9 +41,13 @@
* optional properties that apply to bridge ports.
**/
G_DEFINE_TYPE (NMSettingBridgePort, nm_setting_bridge_port, NM_TYPE_SETTING)
/*****************************************************************************/
#define NM_SETTING_BRIDGE_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortPrivate))
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_PRIORITY,
PROP_PATH_COST,
PROP_HAIRPIN_MODE,
);
typedef struct {
guint16 priority;
......@@ -50,11 +55,9 @@ typedef struct {
gboolean hairpin_mode;
} NMSettingBridgePortPrivate;
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_PRIORITY,
PROP_PATH_COST,
PROP_HAIRPIN_MODE,
);
G_DEFINE_TYPE (NMSettingBridgePort, nm_setting_bridge_port, NM_TYPE_SETTING)
#define NM_SETTING_BRIDGE_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortPrivate))
/*****************************************************************************/
......@@ -139,39 +142,21 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
/*****************************************************************************/
/**
* nm_setting_bridge_port_new:
*
* Creates a new #NMSettingBridgePort object with default values.
*
* Returns: (transfer full): the new empty #NMSettingBridgePort object
**/
NMSetting *
nm_setting_bridge_port_new (void)
{
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE_PORT, NULL);
}
static void
nm_setting_bridge_port_init (NMSettingBridgePort *setting)
{
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);
switch (prop_id) {
case PROP_PRIORITY:
priv->priority = g_value_get_uint (value);
g_value_set_uint (value, priv->priority);
break;
case PROP_PATH_COST:
priv->path_cost = g_value_get_uint (value);
g_value_set_uint (value, priv->path_cost);
break;
case PROP_HAIRPIN_MODE:
priv->hairpin_mode = g_value_get_boolean (value);
g_value_set_boolean (value, priv->hairpin_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -180,20 +165,20 @@ set_property (GObject *object, guint prop_id,
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);
switch (prop_id) {
case PROP_PRIORITY:
g_value_set_uint (value, priv->priority);
priv->priority = g_value_get_uint (value);
break;
case PROP_PATH_COST:
g_value_set_uint (value, priv->path_cost);
priv->path_cost = g_value_get_uint (value);
break;
case PROP_HAIRPIN_MODE:
g_value_set_boolean (value, priv->hairpin_mode);
priv->hairpin_mode = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -201,6 +186,26 @@ get_property (GObject *object, guint prop_id,
}
}
/*****************************************************************************/
static void
nm_setting_bridge_port_init (NMSettingBridgePort *setting)
{
}
/**
* nm_setting_bridge_port_new:
*
* Creates a new #NMSettingBridgePort object with default values.
*
* Returns: (transfer full): the new empty #NMSettingBridgePort object
**/
NMSetting *
nm_setting_bridge_port_new (void)
{
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE_PORT, NULL);
}
static void
nm_setting_bridge_port_class_init (NMSettingBridgePortClass *klass)
{
......@@ -209,8 +214,8 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *klass)
g_type_class_add_private (klass, sizeof (NMSettingBridgePortPrivate));
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->set_property = set_property;
setting_class->verify = verify;
......