libnm: make the the use of GInitable mandatory

Remove _nm_object_ensure_inited(), etc; objects that implement
GInitable are now mandatory-to-init().

Remove constructor() implementations that sometimes return NULL; do
all the relevant checking in init() instead.

Make nm_client_new() and nm_remote_settings_new() take a GCancellable
and a GError**.
This commit is contained in:
Dan Winship
2014-05-15 14:25:07 -04:00
parent 8ca2998d81
commit 258e74eb0c
44 changed files with 224 additions and 527 deletions

View File

@@ -8645,6 +8645,7 @@ do_connections (NmCli *nmc, int argc, char **argv)
{ {
int i = 0; int i = 0;
gboolean real_cmd = FALSE; gboolean real_cmd = FALSE;
GError *error = NULL;
if (argc == 0) if (argc == 0)
real_cmd = TRUE; real_cmd = TRUE;
@@ -8672,8 +8673,9 @@ do_connections (NmCli *nmc, int argc, char **argv)
args_info.argv = argv; args_info.argv = argv;
/* get system settings */ /* get system settings */
if (!(nmc->system_settings = nm_remote_settings_new (NULL))) { if (!(nmc->system_settings = nm_remote_settings_new (NULL, &error))) {
g_string_printf (nmc->return_text, _("Error: Could not get system settings.")); g_string_printf (nmc->return_text, _("Error: Could not get system settings: %s."), error->message);
g_error_free (error);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
nmc->should_wait = FALSE; nmc->should_wait = FALSE;
return nmc->return_value; return nmc->return_value;

View File

@@ -611,8 +611,9 @@ do_general (NmCli *nmc, int argc, char **argv)
} }
/* get system settings */ /* get system settings */
if (!(rem_settings = nm_remote_settings_new (NULL))) { if (!(rem_settings = nm_remote_settings_new (NULL, &error))) {
g_string_printf (nmc->return_text, _("Error: Could not get system settings.")); g_string_printf (nmc->return_text, _("Error: Could not get system settings: %s."), error->message);
g_clear_error (&error);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto finish; goto finish;
} }

View File

@@ -394,10 +394,13 @@ setup_signals (void)
static NMClient * static NMClient *
nmc_get_client (NmCli *nmc) nmc_get_client (NmCli *nmc)
{ {
GError *error = NULL;
if (!nmc->client) { if (!nmc->client) {
nmc->client = nm_client_new (); nmc->client = nm_client_new (NULL, &error);
if (!nmc->client) { if (!nmc->client) {
g_critical (_("Error: Could not create NMClient object.")); g_critical (_("Error: Could not create NMClient object: %s."), error->message);
g_clear_error (&error);
exit (NMC_RESULT_ERROR_UNKNOWN); exit (NMC_RESULT_ERROR_UNKNOWN);
} }
} }

View File

@@ -143,6 +143,7 @@ main (int argc, char *argv[])
NMState state = NM_STATE_UNKNOWN; NMState state = NM_STATE_UNKNOWN;
GMainLoop *loop; GMainLoop *loop;
gint64 remaining_ms; gint64 remaining_ms;
GError *error = NULL;
GOptionEntry options[] = { GOptionEntry options[] = {
{"timeout", 't', 0, G_OPTION_ARG_INT, &t_secs, N_("Time to wait for a connection, in seconds (without the option, default value is 30)"), "<timeout>"}, {"timeout", 't', 0, G_OPTION_ARG_INT, &t_secs, N_("Time to wait for a connection, in seconds (without the option, default value is 30)"), "<timeout>"},
@@ -191,9 +192,10 @@ main (int argc, char *argv[])
g_type_init (); g_type_init ();
#endif #endif
client = nm_client_new (); client = nm_client_new (NULL, &error);
if (!client) { if (!client) {
g_printerr (_("Error: Could not create NMClient object.")); g_printerr (_("Error: Could not create NMClient object: %s."), error->message);
g_error_free (error);
return 2; return 2;
} }

View File

@@ -246,13 +246,23 @@ main (int argc, char **argv)
nm_editor_bindings_init (); nm_editor_bindings_init ();
nm_client = nm_client_new (); nm_client = nm_client_new (NULL, &error);
if (!nm_client) {
g_printerr (_("Could not contact NetworkManager: %s.\n"), error->message);
g_error_free (error);
exit (1);
}
if (!nm_client_get_manager_running (nm_client)) { if (!nm_client_get_manager_running (nm_client)) {
g_printerr ("%s\n", _("NetworkManager is not running.")); g_printerr ("%s\n", _("NetworkManager is not running."));
exit (1); exit (1);
} }
nm_settings = nm_remote_settings_new (NULL); nm_settings = nm_remote_settings_new (NULL, &error);
if (!nm_settings) {
g_printerr (_("Could not contact NetworkManager: %s.\n"), error->message);
g_error_free (error);
exit (1);
}
g_signal_connect (nm_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ, g_signal_connect (nm_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
G_CALLBACK (connections_read), &got_connections); G_CALLBACK (connections_read), &got_connections);
/* coverity[loop_condition] */ /* coverity[loop_condition] */

View File

@@ -24,7 +24,7 @@
* because libnm handles much of the low-level stuff for you. * because libnm handles much of the low-level stuff for you.
* *
* Compile with: * Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm` add-connection-libnm.c -o add-connection-libnm * gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm` add-connection-libnm.c -o add-connection-libnm
*/ */
#include <glib.h> #include <glib.h>
@@ -106,9 +106,9 @@ add_connection (NMRemoteSettings *settings, GMainLoop *loop, const char *con_nam
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
DBusGConnection *bus;
NMRemoteSettings *settings; NMRemoteSettings *settings;
GMainLoop *loop; GMainLoop *loop;
GError *error = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0) #if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */ /* Initialize GType system */
@@ -117,11 +117,13 @@ int main (int argc, char *argv[])
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
/* Get system bus */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
/* Create our proxy for NetworkManager's settings service */ /* Create our proxy for NetworkManager's settings service */
settings = nm_remote_settings_new (bus); settings = nm_remote_settings_new (NULL, &error);
if (!settings) {
g_message ("Error: Could not get system settings: %s.", error->message);
g_error_free (error);
return 1;
}
/* Ask the settings service to add the new connection */ /* Ask the settings service to add the new connection */
if (add_connection (settings, loop, "__Test connection__")) { if (add_connection (settings, loop, "__Test connection__")) {
@@ -132,7 +134,6 @@ int main (int argc, char *argv[])
/* Clean up */ /* Clean up */
g_object_unref (settings); g_object_unref (settings);
dbus_g_connection_unref (bus);
return 0; return 0;
} }

View File

@@ -197,6 +197,7 @@ int main (int argc, char *argv[])
NMClient *client; NMClient *client;
const GPtrArray *devices; const GPtrArray *devices;
int i; int i;
GError *error = NULL;
#if !GLIB_CHECK_VERSION (2, 35, 0) #if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */ /* Initialize GType system */
@@ -204,9 +205,10 @@ int main (int argc, char *argv[])
#endif #endif
/* Get NMClient object */ /* Get NMClient object */
client = nm_client_new (); client = nm_client_new (NULL, &error);
if (!client) { if (!client) {
g_message ("Error: Could not create NMClient."); g_message ("Error: Could not create NMClient: %s.", error->message);
g_error_free (error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@@ -21,11 +21,10 @@
* (that wraps direct D-Bus calls). * (that wraps direct D-Bus calls).
* *
* Compile with: * Compile with:
* gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm` list-connections-libnm.c -o list-connections-libnm * gcc -Wall `pkg-config --libs --cflags glib-2.0 libnm` list-connections-libnm.c -o list-connections-libnm
*/ */
#include <glib.h> #include <glib.h>
#include <dbus/dbus-glib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
@@ -119,13 +118,14 @@ get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
static gboolean static gboolean
list_connections (gpointer data) list_connections (gpointer data)
{ {
DBusGConnection *bus = (DBusGConnection *) data;
NMRemoteSettings *settings; NMRemoteSettings *settings;
gboolean settings_running; gboolean settings_running;
GError *error = NULL;
/* Get system settings */ /* Get system settings */
if (!(settings = nm_remote_settings_new (bus))) { if (!(settings = nm_remote_settings_new (NULL, &error))) {
g_message ("Error: Could not get system settings."); g_message ("Error: Could not get system settings: %s.", error->message);
g_error_free (error);
result = EXIT_FAILURE; result = EXIT_FAILURE;
g_main_loop_quit (loop); g_main_loop_quit (loop);
return FALSE; return FALSE;

View File

@@ -51,7 +51,7 @@ if __name__ == "__main__":
sys.exit('Usage: %s <interface>' % sys.argv[0]) sys.exit('Usage: %s <interface>' % sys.argv[0])
dev_iface = sys.argv[1] dev_iface = sys.argv[1]
c = NM.Client.new() c = NM.Client.new(None)
dev = c.get_device_by_iface(dev_iface) dev = c.get_device_by_iface(dev_iface)
if dev is None: if dev is None:
sys.exit('Device \'%s\' not found' % dev_iface) sys.exit('Device \'%s\' not found' % dev_iface)

View File

@@ -24,7 +24,7 @@
from gi.repository import GLib, NM from gi.repository import GLib, NM
if __name__ == "__main__": if __name__ == "__main__":
client = NM.Client.new() client = NM.Client.new(None)
acons = client.get_active_connections() acons = client.get_active_connections()
for ac in acons: for ac in acons:
print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type()) print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type())

View File

@@ -124,7 +124,7 @@ if __name__ == "__main__":
sys.exit('Usage: %s <interface>' % sys.argv[0]) sys.exit('Usage: %s <interface>' % sys.argv[0])
dev_iface = sys.argv[1] dev_iface = sys.argv[1]
c = NM.Client.new() c = NM.Client.new(None)
dev = c.get_device_by_iface(dev_iface) dev = c.get_device_by_iface(dev_iface)
if dev is None: if dev is None:
sys.exit('Device \'%s\' not found' % dev_iface) sys.exit('Device \'%s\' not found' % dev_iface)

View File

@@ -62,7 +62,7 @@ def print_ap_info(ap):
print print
if __name__ == "__main__": if __name__ == "__main__":
nmc = NM.Client.new() nmc = NM.Client.new(None)
devs = nmc.get_devices() devs = nmc.get_devices()
for dev in devs: for dev in devs:

View File

@@ -1360,19 +1360,12 @@ nm_setting_init (NMSetting *setting)
{ {
} }
static GObject* static void
constructor (GType type, constructed (GObject *object)
guint n_construct_params,
GObjectConstructParam *construct_params)
{ {
GObject *object;
object = G_OBJECT_CLASS (nm_setting_parent_class)->constructor (type,
n_construct_params,
construct_params);
_ensure_setting_info (object, NM_SETTING_GET_PRIVATE (object)); _ensure_setting_info (object, NM_SETTING_GET_PRIVATE (object));
return object;
G_OBJECT_CLASS (nm_setting_parent_class)->constructed (object);
} }
static void static void
@@ -1399,7 +1392,7 @@ nm_setting_class_init (NMSettingClass *setting_class)
g_type_class_add_private (setting_class, sizeof (NMSettingPrivate)); g_type_class_add_private (setting_class, sizeof (NMSettingPrivate));
/* virtual methods */ /* virtual methods */
object_class->constructor = constructor; object_class->constructed = constructed;
object_class->get_property = get_property; object_class->get_property = get_property;
setting_class->update_one_secret = update_one_secret; setting_class->update_one_secret = update_one_secret;

View File

@@ -83,7 +83,6 @@ nm_access_point_get_flags (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_FLAGS_NONE); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_FLAGS_NONE);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->flags; return NM_ACCESS_POINT_GET_PRIVATE (ap)->flags;
} }
@@ -100,7 +99,6 @@ nm_access_point_get_wpa_flags (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->wpa_flags; return NM_ACCESS_POINT_GET_PRIVATE (ap)->wpa_flags;
} }
@@ -118,7 +116,6 @@ nm_access_point_get_rsn_flags (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NM_802_11_AP_SEC_NONE);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->rsn_flags; return NM_ACCESS_POINT_GET_PRIVATE (ap)->rsn_flags;
} }
@@ -136,7 +133,6 @@ nm_access_point_get_ssid (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->ssid; return NM_ACCESS_POINT_GET_PRIVATE (ap)->ssid;
} }
@@ -153,7 +149,6 @@ nm_access_point_get_frequency (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->frequency; return NM_ACCESS_POINT_GET_PRIVATE (ap)->frequency;
} }
@@ -171,7 +166,6 @@ nm_access_point_get_bssid (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->bssid; return NM_ACCESS_POINT_GET_PRIVATE (ap)->bssid;
} }
@@ -188,7 +182,6 @@ nm_access_point_get_mode (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->mode; return NM_ACCESS_POINT_GET_PRIVATE (ap)->mode;
} }
@@ -205,7 +198,6 @@ nm_access_point_get_max_bitrate (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->max_bitrate; return NM_ACCESS_POINT_GET_PRIVATE (ap)->max_bitrate;
} }
@@ -222,7 +214,6 @@ nm_access_point_get_strength (NMAccessPoint *ap)
{ {
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
_nm_object_ensure_inited (NM_OBJECT (ap));
return NM_ACCESS_POINT_GET_PRIVATE (ap)->strength; return NM_ACCESS_POINT_GET_PRIVATE (ap)->strength;
} }
@@ -410,8 +401,6 @@ get_property (GObject *object,
{ {
NMAccessPoint *ap = NM_ACCESS_POINT (object); NMAccessPoint *ap = NM_ACCESS_POINT (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_FLAGS: case PROP_FLAGS:
g_value_set_uint (value, nm_access_point_get_flags (ap)); g_value_set_uint (value, nm_access_point_get_flags (ap));

View File

@@ -199,7 +199,6 @@ nm_active_connection_get_connection (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->connection; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->connection;
} }
@@ -217,7 +216,6 @@ nm_active_connection_get_id (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->id; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->id;
} }
@@ -235,7 +233,6 @@ nm_active_connection_get_uuid (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->uuid; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->uuid;
} }
@@ -253,7 +250,6 @@ nm_active_connection_get_connection_type (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->type; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->type;
} }
@@ -271,7 +267,6 @@ nm_active_connection_get_specific_object (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->specific_object; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->specific_object;
} }
@@ -289,7 +284,6 @@ nm_active_connection_get_devices (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return handle_ptr_array_return (NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices); return handle_ptr_array_return (NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices);
} }
@@ -306,7 +300,6 @@ nm_active_connection_get_state (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NM_ACTIVE_CONNECTION_STATE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->state;
} }
@@ -324,7 +317,6 @@ nm_active_connection_get_default (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default;
} }
@@ -343,7 +335,6 @@ nm_active_connection_get_ip4_config (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->ip4_config; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->ip4_config;
} }
@@ -363,7 +354,6 @@ nm_active_connection_get_dhcp4_config (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->dhcp4_config; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->dhcp4_config;
} }
@@ -381,7 +371,6 @@ nm_active_connection_get_default6 (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default6; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_default6;
} }
@@ -400,7 +389,6 @@ nm_active_connection_get_ip6_config (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->ip6_config; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->ip6_config;
} }
@@ -420,7 +408,6 @@ nm_active_connection_get_dhcp6_config (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->dhcp6_config; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->dhcp6_config;
} }
@@ -437,7 +424,6 @@ nm_active_connection_get_vpn (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), FALSE);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_vpn; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->is_vpn;
} }
@@ -455,7 +441,6 @@ nm_active_connection_get_master (NMActiveConnection *connection)
{ {
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
_nm_object_ensure_inited (NM_OBJECT (connection));
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->master; return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->master;
} }
@@ -508,8 +493,6 @@ get_property (GObject *object,
{ {
NMActiveConnection *self = NM_ACTIVE_CONNECTION (object); NMActiveConnection *self = NM_ACTIVE_CONNECTION (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_CONNECTION: case PROP_CONNECTION:
g_value_set_string (value, nm_active_connection_get_connection (self)); g_value_set_string (value, nm_active_connection_get_connection (self));

View File

@@ -402,8 +402,6 @@ nm_client_get_devices (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
_nm_object_ensure_inited (NM_OBJECT (client));
return handle_ptr_array_return (NM_CLIENT_GET_PRIVATE (client)->devices); return handle_ptr_array_return (NM_CLIENT_GET_PRIVATE (client)->devices);
} }
@@ -823,8 +821,6 @@ nm_client_get_active_connections (NMClient *client)
g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
_nm_object_ensure_inited (NM_OBJECT (client));
priv = NM_CLIENT_GET_PRIVATE (client); priv = NM_CLIENT_GET_PRIVATE (client);
if (!priv->manager_running) if (!priv->manager_running)
return NULL; return NULL;
@@ -845,7 +841,6 @@ nm_client_wireless_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->wireless_enabled; return NM_CLIENT_GET_PRIVATE (client)->wireless_enabled;
} }
@@ -888,7 +883,6 @@ nm_client_wireless_hardware_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->wireless_hw_enabled; return NM_CLIENT_GET_PRIVATE (client)->wireless_hw_enabled;
} }
@@ -905,7 +899,6 @@ nm_client_wwan_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->wwan_enabled; return NM_CLIENT_GET_PRIVATE (client)->wwan_enabled;
} }
@@ -948,7 +941,6 @@ nm_client_wwan_hardware_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->wwan_hw_enabled; return NM_CLIENT_GET_PRIVATE (client)->wwan_hw_enabled;
} }
@@ -965,7 +957,6 @@ nm_client_wimax_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->wimax_enabled; return NM_CLIENT_GET_PRIVATE (client)->wimax_enabled;
} }
@@ -1008,7 +999,6 @@ nm_client_wimax_hardware_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->wimax_hw_enabled; return NM_CLIENT_GET_PRIVATE (client)->wimax_hw_enabled;
} }
@@ -1029,8 +1019,6 @@ nm_client_get_version (NMClient *client)
priv = NM_CLIENT_GET_PRIVATE (client); priv = NM_CLIENT_GET_PRIVATE (client);
_nm_object_ensure_inited (NM_OBJECT (client));
return priv->manager_running ? priv->version : NULL; return priv->manager_running ? priv->version : NULL;
} }
@@ -1047,8 +1035,6 @@ nm_client_get_state (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->state; return NM_CLIENT_GET_PRIVATE (client)->state;
} }
@@ -1066,8 +1052,6 @@ nm_client_get_startup (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->startup; return NM_CLIENT_GET_PRIVATE (client)->startup;
} }
@@ -1084,7 +1068,6 @@ nm_client_networking_get_enabled (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), FALSE); g_return_val_if_fail (NM_IS_CLIENT (client), FALSE);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->networking_enabled; return NM_CLIENT_GET_PRIVATE (client)->networking_enabled;
} }
@@ -1258,7 +1241,6 @@ nm_client_get_primary_connection (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->primary_connection; return NM_CLIENT_GET_PRIVATE (client)->primary_connection;
} }
@@ -1278,7 +1260,6 @@ nm_client_get_activating_connection (NMClient *client)
{ {
g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
_nm_object_ensure_inited (NM_OBJECT (client));
return NM_CLIENT_GET_PRIVATE (client)->activating_connection; return NM_CLIENT_GET_PRIVATE (client)->activating_connection;
} }
@@ -1413,14 +1394,9 @@ proxy_name_owner_changed (DBusGProxy *proxy,
NMConnectivityState NMConnectivityState
nm_client_get_connectivity (NMClient *client) nm_client_get_connectivity (NMClient *client)
{ {
NMClientPrivate *priv;
g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
priv = NM_CLIENT_GET_PRIVATE (client);
_nm_object_ensure_inited (NM_OBJECT (client)); return NM_CLIENT_GET_PRIVATE (client)->connectivity;
return priv->connectivity;
} }
/** /**
@@ -1594,6 +1570,8 @@ nm_client_check_connectivity_finish (NMClient *client,
/** /**
* nm_client_new: * nm_client_new:
* @cancellable: a #GCancellable, or %NULL
* @error: location for a #GError, or %NULL
* *
* Creates a new #NMClient. * Creates a new #NMClient.
* *
@@ -1608,19 +1586,11 @@ nm_client_check_connectivity_finish (NMClient *client,
* Returns: a new #NMClient or NULL on an error * Returns: a new #NMClient or NULL on an error
**/ **/
NMClient * NMClient *
nm_client_new (void) nm_client_new (GCancellable *cancellable,
GError **error)
{ {
NMClient *client; return g_initable_new (NM_TYPE_CLIENT, cancellable, error,
NULL);
client = g_object_new (NM_TYPE_CLIENT, NM_OBJECT_DBUS_PATH, NM_DBUS_PATH, NULL);
/* NMObject's constructor() can fail on a D-Bus connection error. So we can
* get NULL here instead of a valid NMClient object.
*/
if (client)
_nm_object_ensure_inited (NM_OBJECT (client));
return client;
} }
static void static void
@@ -1629,7 +1599,7 @@ client_inited (GObject *source, GAsyncResult *result, gpointer user_data)
GSimpleAsyncResult *simple = user_data; GSimpleAsyncResult *simple = user_data;
GError *error = NULL; GError *error = NULL;
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (source), result, &error)) if (!g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error))
g_simple_async_result_take_error (simple, error); g_simple_async_result_take_error (simple, error);
else else
g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref); g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref);
@@ -1657,21 +1627,13 @@ nm_client_new_async (GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
NMClient *client;
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
client = g_object_new (NM_TYPE_CLIENT, NM_OBJECT_DBUS_PATH, NM_DBUS_PATH, NULL);
/* When client is NULL, do no continue with initialization and run callback
* directly with result == NULL indicating NMClient creation failure.
*/
if (!client) {
callback (NULL, NULL, user_data);
return;
}
simple = g_simple_async_result_new (NULL, callback, user_data, nm_client_new_async); simple = g_simple_async_result_new (NULL, callback, user_data, nm_client_new_async);
g_async_initable_init_async (G_ASYNC_INITABLE (client), G_PRIORITY_DEFAULT,
cancellable, client_inited, simple); g_async_initable_new_async (NM_TYPE_CLIENT, G_PRIORITY_DEFAULT,
cancellable, client_inited, simple,
NULL);
} }
/** /**
@@ -1778,7 +1740,6 @@ constructor (GType type,
guint n_construct_params, guint n_construct_params,
GObjectConstructParam *construct_params) GObjectConstructParam *construct_params)
{ {
GObject *object;
guint i; guint i;
const char *dbus_path; const char *dbus_path;
@@ -1798,24 +1759,14 @@ constructor (GType type,
} }
} }
object = G_OBJECT_CLASS (nm_client_parent_class)->constructor (type, return G_OBJECT_CLASS (nm_client_parent_class)->constructor (type,
n_construct_params, n_construct_params,
construct_params); construct_params);
return object;
} }
static void static void
constructed (GObject *object) constructed (GObject *object)
{ {
GError *error = NULL;
if (!nm_utils_init (&error)) {
g_warning ("Couldn't initilize nm-utils/crypto system: %d %s",
error->code, error->message);
g_clear_error (&error);
}
G_OBJECT_CLASS (nm_client_parent_class)->constructed (object); G_OBJECT_CLASS (nm_client_parent_class)->constructed (object);
g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED, g_signal_connect (object, "notify::" NM_CLIENT_WIRELESS_ENABLED,
@@ -1834,6 +1785,9 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
NMClient *client = NM_CLIENT (initable); NMClient *client = NM_CLIENT (initable);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
if (!nm_utils_init (error))
return FALSE;
if (!nm_client_parent_initable_iface->init (initable, cancellable, error)) if (!nm_client_parent_initable_iface->init (initable, cancellable, error))
return FALSE; return FALSE;
@@ -1948,6 +1902,13 @@ init_async (GAsyncInitable *initable, int io_priority,
{ {
NMClientInitData *init_data; NMClientInitData *init_data;
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (initable); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (initable);
GError *error = NULL;
if (!nm_utils_init (&error)) {
g_simple_async_report_take_gerror_in_idle (G_OBJECT (initable),
callback, user_data, error);
return;
}
init_data = g_slice_new0 (NMClientInitData); init_data = g_slice_new0 (NMClientInitData);
init_data->client = NM_CLIENT (initable); init_data->client = NM_CLIENT (initable);
@@ -2067,8 +2028,6 @@ get_property (GObject *object,
NMClient *self = NM_CLIENT (object); NMClient *self = NM_CLIENT (object);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_VERSION: case PROP_VERSION:
g_value_set_string (value, nm_client_get_version (self)); g_value_set_string (value, nm_client_get_version (self));

View File

@@ -160,7 +160,8 @@ typedef struct {
GType nm_client_get_type (void); GType nm_client_get_type (void);
NMClient *nm_client_new (void); NMClient *nm_client_new (GCancellable *cancellable,
GError **error);
void nm_client_new_async (GCancellable *cancellable, void nm_client_new_async (GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,

View File

@@ -75,7 +75,6 @@ nm_device_adsl_get_carrier (NMDeviceAdsl *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_ADSL (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_ADSL (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ADSL_GET_PRIVATE (device)->carrier; return NM_DEVICE_ADSL_GET_PRIVATE (device)->carrier;
} }

View File

@@ -85,7 +85,6 @@ nm_device_bond_get_hw_address (NMDeviceBond *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BOND (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_BOND (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BOND_GET_PRIVATE (device)->hw_address; return NM_DEVICE_BOND_GET_PRIVATE (device)->hw_address;
} }
@@ -102,7 +101,6 @@ nm_device_bond_get_carrier (NMDeviceBond *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BOND_GET_PRIVATE (device)->carrier; return NM_DEVICE_BOND_GET_PRIVATE (device)->carrier;
} }
@@ -121,7 +119,6 @@ nm_device_bond_get_slaves (NMDeviceBond *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves); return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves);
} }
@@ -235,8 +232,6 @@ get_property (GObject *object,
{ {
NMDeviceBond *device = NM_DEVICE_BOND (object); NMDeviceBond *device = NM_DEVICE_BOND (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_bond_get_hw_address (device)); g_value_set_string (value, nm_device_bond_get_hw_address (device));

View File

@@ -85,7 +85,6 @@ nm_device_bridge_get_hw_address (NMDeviceBridge *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->hw_address; return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->hw_address;
} }
@@ -102,7 +101,6 @@ nm_device_bridge_get_carrier (NMDeviceBridge *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->carrier; return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->carrier;
} }
@@ -121,7 +119,6 @@ nm_device_bridge_get_slaves (NMDeviceBridge *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return handle_ptr_array_return (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves); return handle_ptr_array_return (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves);
} }
@@ -235,8 +232,6 @@ get_property (GObject *object,
{ {
NMDeviceBridge *device = NM_DEVICE_BRIDGE (object); NMDeviceBridge *device = NM_DEVICE_BRIDGE (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_bridge_get_hw_address (device)); g_value_set_string (value, nm_device_bridge_get_hw_address (device));

View File

@@ -84,7 +84,6 @@ nm_device_bt_get_hw_address (NMDeviceBt *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BT_GET_PRIVATE (device)->hw_address; return NM_DEVICE_BT_GET_PRIVATE (device)->hw_address;
} }
@@ -101,7 +100,6 @@ nm_device_bt_get_name (NMDeviceBt *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BT_GET_PRIVATE (device)->name; return NM_DEVICE_BT_GET_PRIVATE (device)->name;
} }
@@ -118,7 +116,6 @@ nm_device_bt_get_capabilities (NMDeviceBt *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_BT (device), NM_BT_CAPABILITY_NONE); g_return_val_if_fail (NM_IS_DEVICE_BT (device), NM_BT_CAPABILITY_NONE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_BT_GET_PRIVATE (device)->bt_capabilities; return NM_DEVICE_BT_GET_PRIVATE (device)->bt_capabilities;
} }
@@ -268,8 +265,6 @@ get_property (GObject *object,
{ {
NMDeviceBt *device = NM_DEVICE_BT (object); NMDeviceBt *device = NM_DEVICE_BT (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_bt_get_hw_address (device)); g_value_set_string (value, nm_device_bt_get_hw_address (device));

View File

@@ -87,7 +87,6 @@ nm_device_ethernet_get_hw_address (NMDeviceEthernet *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->hw_address; return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->hw_address;
} }
@@ -105,7 +104,6 @@ nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->perm_hw_address; return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->perm_hw_address;
} }
@@ -122,7 +120,6 @@ nm_device_ethernet_get_speed (NMDeviceEthernet *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), 0); g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->speed; return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->speed;
} }
@@ -139,7 +136,6 @@ nm_device_ethernet_get_carrier (NMDeviceEthernet *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_ETHERNET (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->carrier; return NM_DEVICE_ETHERNET_GET_PRIVATE (device)->carrier;
} }
@@ -268,8 +264,6 @@ get_property (GObject *object,
{ {
NMDeviceEthernet *device = NM_DEVICE_ETHERNET (object); NMDeviceEthernet *device = NM_DEVICE_ETHERNET (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_ethernet_get_hw_address (device)); g_value_set_string (value, nm_device_ethernet_get_hw_address (device));

View File

@@ -77,7 +77,6 @@ nm_device_generic_get_hw_address (NMDeviceGeneric *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_GENERIC (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address; return NM_DEVICE_GENERIC_GET_PRIVATE (device)->hw_address;
} }
@@ -88,7 +87,6 @@ get_type_description (NMDevice *device)
{ {
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (device);
_nm_object_ensure_inited (NM_OBJECT (device));
return priv->type_description; return priv->type_description;
} }
@@ -185,8 +183,6 @@ get_property (GObject *object,
{ {
NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, priv->hw_address); g_value_set_string (value, priv->hw_address);

View File

@@ -83,7 +83,6 @@ nm_device_infiniband_get_hw_address (NMDeviceInfiniband *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->hw_address; return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->hw_address;
} }
@@ -100,7 +99,6 @@ nm_device_infiniband_get_carrier (NMDeviceInfiniband *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->carrier; return NM_DEVICE_INFINIBAND_GET_PRIVATE (device)->carrier;
} }
@@ -217,8 +215,6 @@ get_property (GObject *object,
{ {
NMDeviceInfiniband *device = NM_DEVICE_INFINIBAND (object); NMDeviceInfiniband *device = NM_DEVICE_INFINIBAND (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_infiniband_get_hw_address (device)); g_value_set_string (value, nm_device_infiniband_get_hw_address (device));

View File

@@ -82,7 +82,6 @@ nm_device_modem_get_modem_capabilities (NMDeviceModem *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE); g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_MODEM_GET_PRIVATE (self)->caps; return NM_DEVICE_MODEM_GET_PRIVATE (self)->caps;
} }
@@ -102,7 +101,6 @@ nm_device_modem_get_current_capabilities (NMDeviceModem *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE); g_return_val_if_fail (NM_IS_DEVICE_MODEM (self), NM_DEVICE_MODEM_CAPABILITY_NONE);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps; return NM_DEVICE_MODEM_GET_PRIVATE (self)->current_caps;
} }
@@ -211,8 +209,6 @@ get_property (GObject *object,
{ {
NMDeviceModem *self = NM_DEVICE_MODEM (object); NMDeviceModem *self = NM_DEVICE_MODEM (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_MODEM_CAPS: case PROP_MODEM_CAPS:
g_value_set_uint (value, nm_device_modem_get_modem_capabilities (self)); g_value_set_uint (value, nm_device_modem_get_modem_capabilities (self));

View File

@@ -83,7 +83,6 @@ nm_device_olpc_mesh_get_hw_address (NMDeviceOlpcMesh *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->hw_address; return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->hw_address;
} }
@@ -100,7 +99,6 @@ nm_device_olpc_mesh_get_companion (NMDeviceOlpcMesh *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->companion; return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->companion;
} }
@@ -117,7 +115,6 @@ nm_device_olpc_mesh_get_active_channel (NMDeviceOlpcMesh *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), 0); g_return_val_if_fail (NM_IS_DEVICE_OLPC_MESH (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->active_channel; return NM_DEVICE_OLPC_MESH_GET_PRIVATE (device)->active_channel;
} }
@@ -216,8 +213,6 @@ get_property (GObject *object,
{ {
NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object); NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_olpc_mesh_get_hw_address (device)); g_value_set_string (value, nm_device_olpc_mesh_get_hw_address (device));

View File

@@ -85,7 +85,6 @@ nm_device_team_get_hw_address (NMDeviceTeam *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_TEAM_GET_PRIVATE (device)->hw_address; return NM_DEVICE_TEAM_GET_PRIVATE (device)->hw_address;
} }
@@ -102,7 +101,6 @@ nm_device_team_get_carrier (NMDeviceTeam *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_TEAM_GET_PRIVATE (device)->carrier; return NM_DEVICE_TEAM_GET_PRIVATE (device)->carrier;
} }
@@ -121,7 +119,6 @@ nm_device_team_get_slaves (NMDeviceTeam *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return handle_ptr_array_return (NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves); return handle_ptr_array_return (NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves);
} }
@@ -235,8 +232,6 @@ get_property (GObject *object,
{ {
NMDeviceTeam *device = NM_DEVICE_TEAM (object); NMDeviceTeam *device = NM_DEVICE_TEAM (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_team_get_hw_address (device)); g_value_set_string (value, nm_device_team_get_hw_address (device));

View File

@@ -84,7 +84,6 @@ nm_device_vlan_get_hw_address (NMDeviceVlan *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address; return NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address;
} }
@@ -101,7 +100,6 @@ nm_device_vlan_get_carrier (NMDeviceVlan *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_VLAN_GET_PRIVATE (device)->carrier; return NM_DEVICE_VLAN_GET_PRIVATE (device)->carrier;
} }
@@ -116,7 +114,6 @@ nm_device_vlan_get_vlan_id (NMDeviceVlan *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id; return NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id;
} }
@@ -245,8 +242,6 @@ get_property (GObject *object,
{ {
NMDeviceVlan *device = NM_DEVICE_VLAN (object); NMDeviceVlan *device = NM_DEVICE_VLAN (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_vlan_get_hw_address (device)); g_value_set_string (value, nm_device_vlan_get_hw_address (device));

View File

@@ -116,7 +116,6 @@ nm_device_wifi_get_hw_address (NMDeviceWifi *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->hw_address; return NM_DEVICE_WIFI_GET_PRIVATE (device)->hw_address;
} }
@@ -134,7 +133,6 @@ nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->perm_hw_address; return NM_DEVICE_WIFI_GET_PRIVATE (device)->perm_hw_address;
} }
@@ -151,7 +149,6 @@ nm_device_wifi_get_mode (NMDeviceWifi *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->mode; return NM_DEVICE_WIFI_GET_PRIVATE (device)->mode;
} }
@@ -182,7 +179,6 @@ nm_device_wifi_get_bitrate (NMDeviceWifi *device)
return 0; return 0;
} }
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->rate; return NM_DEVICE_WIFI_GET_PRIVATE (device)->rate;
} }
@@ -199,7 +195,6 @@ nm_device_wifi_get_capabilities (NMDeviceWifi *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->wireless_caps; return NM_DEVICE_WIFI_GET_PRIVATE (device)->wireless_caps;
} }
@@ -234,7 +229,6 @@ nm_device_wifi_get_active_access_point (NMDeviceWifi *device)
break; break;
} }
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_WIFI_GET_PRIVATE (device)->active_ap; return NM_DEVICE_WIFI_GET_PRIVATE (device)->active_ap;
} }
@@ -253,7 +247,6 @@ nm_device_wifi_get_access_points (NMDeviceWifi *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return handle_ptr_array_return (NM_DEVICE_WIFI_GET_PRIVATE (device)->aps); return handle_ptr_array_return (NM_DEVICE_WIFI_GET_PRIVATE (device)->aps);
} }
@@ -528,8 +521,6 @@ get_property (GObject *object,
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (object); NMDeviceWifi *self = NM_DEVICE_WIFI (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_wifi_get_hw_address (self)); g_value_set_string (value, nm_device_wifi_get_hw_address (self));

View File

@@ -109,7 +109,6 @@ nm_device_wimax_get_hw_address (NMDeviceWimax *wimax)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
_nm_object_ensure_inited (NM_OBJECT (wimax));
return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->hw_address; return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->hw_address;
} }
@@ -144,7 +143,6 @@ nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax)
break; break;
} }
_nm_object_ensure_inited (NM_OBJECT (wimax));
return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->active_nsp; return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->active_nsp;
} }
@@ -163,7 +161,6 @@ nm_device_wimax_get_nsps (NMDeviceWimax *wimax)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
_nm_object_ensure_inited (NM_OBJECT (wimax));
return handle_ptr_array_return (NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps); return handle_ptr_array_return (NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps);
} }
@@ -245,7 +242,6 @@ nm_device_wimax_get_center_frequency (NMDeviceWimax *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->center_freq; return NM_DEVICE_WIMAX_GET_PRIVATE (self)->center_freq;
} }
@@ -265,7 +261,6 @@ nm_device_wimax_get_rssi (NMDeviceWimax *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->rssi; return NM_DEVICE_WIMAX_GET_PRIVATE (self)->rssi;
} }
@@ -284,7 +279,6 @@ nm_device_wimax_get_cinr (NMDeviceWimax *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->cinr; return NM_DEVICE_WIMAX_GET_PRIVATE (self)->cinr;
} }
@@ -303,7 +297,6 @@ nm_device_wimax_get_tx_power (NMDeviceWimax *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->tx_power; return NM_DEVICE_WIMAX_GET_PRIVATE (self)->tx_power;
} }
@@ -320,7 +313,6 @@ nm_device_wimax_get_bsid (NMDeviceWimax *self)
{ {
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL);
_nm_object_ensure_inited (NM_OBJECT (self));
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->bsid; return NM_DEVICE_WIMAX_GET_PRIVATE (self)->bsid;
} }
@@ -404,8 +396,6 @@ get_property (GObject *object,
{ {
NMDeviceWimax *self = NM_DEVICE_WIMAX (object); NMDeviceWimax *self = NM_DEVICE_WIMAX (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_HW_ADDRESS: case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_wimax_get_hw_address (self)); g_value_set_string (value, nm_device_wimax_get_hw_address (self));

View File

@@ -420,8 +420,6 @@ get_property (GObject *object,
NMDevice *device = NM_DEVICE (object); NMDevice *device = NM_DEVICE (object);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_DEVICE_TYPE: case PROP_DEVICE_TYPE:
g_value_set_uint (value, nm_device_get_device_type (device)); g_value_set_uint (value, nm_device_get_device_type (device));
@@ -978,7 +976,6 @@ nm_device_get_iface (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->iface; return NM_DEVICE_GET_PRIVATE (device)->iface;
} }
@@ -997,7 +994,6 @@ nm_device_get_ip_iface (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->ip_iface; return NM_DEVICE_GET_PRIVATE (device)->ip_iface;
} }
@@ -1032,7 +1028,6 @@ nm_device_get_udi (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->udi; return NM_DEVICE_GET_PRIVATE (device)->udi;
} }
@@ -1050,7 +1045,6 @@ nm_device_get_driver (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->driver; return NM_DEVICE_GET_PRIVATE (device)->driver;
} }
@@ -1068,7 +1062,6 @@ nm_device_get_driver_version (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->driver_version; return NM_DEVICE_GET_PRIVATE (device)->driver_version;
} }
@@ -1086,7 +1079,6 @@ nm_device_get_firmware_version (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->firmware_version; return NM_DEVICE_GET_PRIVATE (device)->firmware_version;
} }
@@ -1158,7 +1150,6 @@ nm_device_get_capabilities (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), 0); g_return_val_if_fail (NM_IS_DEVICE (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->capabilities; return NM_DEVICE_GET_PRIVATE (device)->capabilities;
} }
@@ -1175,7 +1166,6 @@ nm_device_get_managed (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), 0); g_return_val_if_fail (NM_IS_DEVICE (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->managed; return NM_DEVICE_GET_PRIVATE (device)->managed;
} }
@@ -1192,7 +1182,6 @@ nm_device_get_autoconnect (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->autoconnect; return NM_DEVICE_GET_PRIVATE (device)->autoconnect;
} }
@@ -1237,7 +1226,6 @@ nm_device_get_firmware_missing (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), 0); g_return_val_if_fail (NM_IS_DEVICE (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->firmware_missing; return NM_DEVICE_GET_PRIVATE (device)->firmware_missing;
} }
@@ -1258,7 +1246,6 @@ nm_device_get_ip4_config (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->ip4_config; return NM_DEVICE_GET_PRIVATE (device)->ip4_config;
} }
@@ -1280,7 +1267,6 @@ nm_device_get_dhcp4_config (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->dhcp4_config; return NM_DEVICE_GET_PRIVATE (device)->dhcp4_config;
} }
@@ -1301,7 +1287,6 @@ nm_device_get_ip6_config (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->ip6_config; return NM_DEVICE_GET_PRIVATE (device)->ip6_config;
} }
@@ -1323,7 +1308,6 @@ nm_device_get_dhcp6_config (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->dhcp6_config; return NM_DEVICE_GET_PRIVATE (device)->dhcp6_config;
} }
@@ -1340,7 +1324,6 @@ nm_device_get_state (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->state; return NM_DEVICE_GET_PRIVATE (device)->state;
} }
@@ -1359,7 +1342,6 @@ nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (device));
if (reason) if (reason)
*reason = NM_DEVICE_GET_PRIVATE (device)->reason; *reason = NM_DEVICE_GET_PRIVATE (device)->reason;
return NM_DEVICE_GET_PRIVATE (device)->state; return NM_DEVICE_GET_PRIVATE (device)->state;
@@ -1379,7 +1361,6 @@ nm_device_get_active_connection (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->active_connection; return NM_DEVICE_GET_PRIVATE (device)->active_connection;
} }
@@ -1399,7 +1380,6 @@ nm_device_get_available_connections (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return handle_ptr_array_return (NM_DEVICE_GET_PRIVATE (device)->available_connections); return handle_ptr_array_return (NM_DEVICE_GET_PRIVATE (device)->available_connections);
} }
@@ -1998,7 +1978,6 @@ nm_device_get_physical_port_id (NMDevice *device)
priv = NM_DEVICE_GET_PRIVATE (device); priv = NM_DEVICE_GET_PRIVATE (device);
_nm_object_ensure_inited (NM_OBJECT (device));
if (priv->physical_port_id && *priv->physical_port_id) if (priv->physical_port_id && *priv->physical_port_id)
return priv->physical_port_id; return priv->physical_port_id;
else else
@@ -2018,7 +1997,6 @@ nm_device_get_mtu (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), 0); g_return_val_if_fail (NM_IS_DEVICE (device), 0);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_GET_PRIVATE (device)->mtu; return NM_DEVICE_GET_PRIVATE (device)->mtu;
} }
@@ -2035,7 +2013,6 @@ nm_device_is_software (NMDevice *device)
{ {
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return !!(NM_DEVICE_GET_PRIVATE (device)->capabilities & NM_DEVICE_CAP_IS_SOFTWARE); return !!(NM_DEVICE_GET_PRIVATE (device)->capabilities & NM_DEVICE_CAP_IS_SOFTWARE);
} }

View File

@@ -47,6 +47,9 @@ enum {
static void static void
nm_dhcp4_config_init (NMDhcp4Config *config) nm_dhcp4_config_init (NMDhcp4Config *config)
{ {
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (config);
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
} }
static gboolean static gboolean
@@ -88,17 +91,6 @@ init_dbus (NMObject *object)
property_info); property_info);
} }
static void
constructed (GObject *object)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);
G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->constructed (object);
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
}
static void static void
finalize (GObject *object) finalize (GObject *object)
{ {
@@ -120,8 +112,6 @@ get_property (GObject *object,
{ {
NMDhcp4Config *self = NM_DHCP4_CONFIG (object); NMDhcp4Config *self = NM_DHCP4_CONFIG (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_OPTIONS: case PROP_OPTIONS:
g_value_set_boxed (value, nm_dhcp4_config_get_options (self)); g_value_set_boxed (value, nm_dhcp4_config_get_options (self));
@@ -141,7 +131,6 @@ nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
g_type_class_add_private (config_class, sizeof (NMDhcp4ConfigPrivate)); g_type_class_add_private (config_class, sizeof (NMDhcp4ConfigPrivate));
/* virtual methods */ /* virtual methods */
object_class->constructed = constructed;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
@@ -178,7 +167,6 @@ nm_dhcp4_config_get_options (NMDhcp4Config *config)
{ {
g_return_val_if_fail (NM_IS_DHCP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_DHCP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_DHCP4_CONFIG_GET_PRIVATE (config)->options; return NM_DHCP4_CONFIG_GET_PRIVATE (config)->options;
} }

View File

@@ -47,6 +47,9 @@ enum {
static void static void
nm_dhcp6_config_init (NMDhcp6Config *config) nm_dhcp6_config_init (NMDhcp6Config *config)
{ {
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (config);
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
} }
static gboolean static gboolean
@@ -88,17 +91,6 @@ init_dbus (NMObject *object)
property_info); property_info);
} }
static void
constructed (GObject *object)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->constructed (object);
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
}
static void static void
finalize (GObject *object) finalize (GObject *object)
{ {
@@ -120,8 +112,6 @@ get_property (GObject *object,
{ {
NMDhcp6Config *self = NM_DHCP6_CONFIG (object); NMDhcp6Config *self = NM_DHCP6_CONFIG (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_OPTIONS: case PROP_OPTIONS:
g_value_set_boxed (value, nm_dhcp6_config_get_options (self)); g_value_set_boxed (value, nm_dhcp6_config_get_options (self));
@@ -141,7 +131,6 @@ nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
g_type_class_add_private (config_class, sizeof (NMDhcp6ConfigPrivate)); g_type_class_add_private (config_class, sizeof (NMDhcp6ConfigPrivate));
/* virtual methods */ /* virtual methods */
object_class->constructed = constructed;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->finalize = finalize; object_class->finalize = finalize;
@@ -178,7 +167,6 @@ nm_dhcp6_config_get_options (NMDhcp6Config *config)
{ {
g_return_val_if_fail (NM_IS_DHCP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_DHCP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_DHCP6_CONFIG_GET_PRIVATE (config)->options; return NM_DHCP6_CONFIG_GET_PRIVATE (config)->options;
} }

View File

@@ -177,8 +177,6 @@ get_property (GObject *object,
NMIP4Config *self = NM_IP4_CONFIG (object); NMIP4Config *self = NM_IP4_CONFIG (object);
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self); NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (self);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_GATEWAY: case PROP_GATEWAY:
g_value_set_string (value, nm_ip4_config_get_gateway (self)); g_value_set_string (value, nm_ip4_config_get_gateway (self));
@@ -319,7 +317,6 @@ nm_ip4_config_get_gateway (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP4_CONFIG_GET_PRIVATE (config)->gateway; return NM_IP4_CONFIG_GET_PRIVATE (config)->gateway;
} }
@@ -337,7 +334,6 @@ nm_ip4_config_get_addresses (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP4_CONFIG_GET_PRIVATE (config)->addresses; return NM_IP4_CONFIG_GET_PRIVATE (config)->addresses;
} }
@@ -356,7 +352,6 @@ nm_ip4_config_get_nameservers (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers; return NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers;
} }
@@ -374,7 +369,6 @@ nm_ip4_config_get_domains (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->domains); return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->domains);
} }
@@ -392,7 +386,6 @@ nm_ip4_config_get_searches (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->searches); return handle_ptr_array_return (NM_IP4_CONFIG_GET_PRIVATE (config)->searches);
} }
@@ -411,7 +404,6 @@ nm_ip4_config_get_wins_servers (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP4_CONFIG_GET_PRIVATE (config)->wins; return NM_IP4_CONFIG_GET_PRIVATE (config)->wins;
} }
@@ -430,6 +422,5 @@ nm_ip4_config_get_routes (NMIP4Config *config)
{ {
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP4_CONFIG_GET_PRIVATE (config)->routes; return NM_IP4_CONFIG_GET_PRIVATE (config)->routes;
} }

View File

@@ -150,7 +150,6 @@ nm_ip6_config_get_gateway (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP6_CONFIG_GET_PRIVATE (config)->gateway; return NM_IP6_CONFIG_GET_PRIVATE (config)->gateway;
} }
@@ -169,7 +168,6 @@ nm_ip6_config_get_addresses (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP6_CONFIG_GET_PRIVATE (config)->addresses; return NM_IP6_CONFIG_GET_PRIVATE (config)->addresses;
} }
@@ -186,7 +184,6 @@ nm_ip6_config_get_num_nameservers (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0);
_nm_object_ensure_inited (NM_OBJECT (config));
return g_slist_length (NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers); return g_slist_length (NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers);
} }
@@ -209,7 +206,6 @@ nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx)
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
priv = NM_IP6_CONFIG_GET_PRIVATE (config); priv = NM_IP6_CONFIG_GET_PRIVATE (config);
for (item = priv->nameservers; item && i < idx; i++) for (item = priv->nameservers; item && i < idx; i++)
@@ -235,7 +231,6 @@ nm_ip6_config_get_nameservers (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers; return NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers;
} }
@@ -253,7 +248,6 @@ nm_ip6_config_get_domains (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->domains); return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->domains);
} }
@@ -271,7 +265,6 @@ nm_ip6_config_get_searches (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->searches); return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->searches);
} }
@@ -290,7 +283,6 @@ nm_ip6_config_get_routes (NMIP6Config *config)
{ {
g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL);
_nm_object_ensure_inited (NM_OBJECT (config));
return NM_IP6_CONFIG_GET_PRIVATE (config)->routes; return NM_IP6_CONFIG_GET_PRIVATE (config)->routes;
} }
@@ -329,8 +321,6 @@ get_property (GObject *object,
NMIP6Config *self = NM_IP6_CONFIG (object); NMIP6Config *self = NM_IP6_CONFIG (object);
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self); NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_GATEWAY: case PROP_GATEWAY:
g_value_set_string (value, nm_ip6_config_get_gateway (self)); g_value_set_string (value, nm_ip6_config_get_gateway (self));

View File

@@ -24,8 +24,6 @@
#include <gio/gio.h> #include <gio/gio.h>
#include "nm-object.h" #include "nm-object.h"
void _nm_object_ensure_inited (NMObject *object);
typedef gboolean (*PropertyMarshalFunc) (NMObject *, GParamSpec *, GValue *, gpointer); typedef gboolean (*PropertyMarshalFunc) (NMObject *, GParamSpec *, GValue *, gpointer);
typedef GObject * (*NMObjectCreatorFunc) (DBusGConnection *, const char *); typedef GObject * (*NMObjectCreatorFunc) (DBusGConnection *, const char *);

View File

@@ -21,6 +21,7 @@
#include <string.h> #include <string.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <glib/gi18n.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <nm-utils.h> #include <nm-utils.h>
@@ -73,7 +74,6 @@ typedef struct {
GSList *notify_props; GSList *notify_props;
guint32 notify_id; guint32 notify_id;
gboolean inited;
GSList *reload_results; GSList *reload_results;
guint reload_remaining; guint reload_remaining;
@@ -139,38 +139,20 @@ nm_object_init (NMObject *object)
{ {
} }
static GObject* static gboolean
constructor (GType type, init_common (NMObject *self, GError **error)
guint n_construct_params,
GObjectConstructParam *construct_params)
{ {
GObject *object; NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
NMObjectPrivate *priv;
object = G_OBJECT_CLASS (nm_object_parent_class)->constructor (type, if (!priv->path) {
n_construct_params, g_set_error_literal (error, NM_OBJECT_ERROR, NM_OBJECT_ERROR_OBJECT_CREATION_FAILURE,
construct_params); _("Caller did not specify D-Bus path for object"));
return FALSE;
priv = NM_OBJECT_GET_PRIVATE (object);
if (priv->connection == NULL || priv->path == NULL) {
g_warn_if_reached ();
g_object_unref (object);
return NULL;
} }
return object;
}
static void
constructed (GObject *object)
{
NMObject *self = NM_OBJECT (object);
if (G_OBJECT_CLASS (nm_object_parent_class)->constructed)
G_OBJECT_CLASS (nm_object_parent_class)->constructed (object);
NM_OBJECT_GET_CLASS (self)->init_dbus (self); NM_OBJECT_GET_CLASS (self)->init_dbus (self);
return TRUE;
} }
static void static void
@@ -202,7 +184,16 @@ init_dbus (NMObject *object)
static gboolean static gboolean
init_sync (GInitable *initable, GCancellable *cancellable, GError **error) init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
{ {
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (initable); NMObject *self = NM_OBJECT (initable);
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
if (!priv->connection) {
priv->connection = _nm_dbus_new_connection (error);
if (!priv->connection)
return FALSE;
}
if (!init_common (self, error))
return FALSE;
if (priv->bus_proxy) { if (priv->bus_proxy) {
if (!dbus_g_proxy_call (priv->bus_proxy, if (!dbus_g_proxy_call (priv->bus_proxy,
@@ -214,8 +205,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
return FALSE; return FALSE;
} }
priv->inited = TRUE; return _nm_object_reload_properties (self, error);
return _nm_object_reload_properties (NM_OBJECT (initable), error);
} }
/* Takes ownership of @error */ /* Takes ownership of @error */
@@ -236,7 +226,6 @@ init_async_got_properties (GObject *object, GAsyncResult *result, gpointer user_
GSimpleAsyncResult *simple = user_data; GSimpleAsyncResult *simple = user_data;
GError *error = NULL; GError *error = NULL;
NM_OBJECT_GET_PRIVATE (object)->inited = TRUE;
if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error)) if (!_nm_object_reload_properties_finish (NM_OBJECT (object), result, &error))
g_assert (error); g_assert (error);
init_async_complete (simple, error); init_async_complete (simple, error);
@@ -258,10 +247,9 @@ init_async_got_manager_running (DBusGProxy *proxy, DBusGProxyCall *call,
G_TYPE_BOOLEAN, &priv->nm_running, G_TYPE_BOOLEAN, &priv->nm_running,
G_TYPE_INVALID)) { G_TYPE_INVALID)) {
init_async_complete (simple, error); init_async_complete (simple, error);
} else if (!priv->nm_running) { } else if (!priv->nm_running)
priv->inited = TRUE;
init_async_complete (simple, NULL); init_async_complete (simple, NULL);
} else else
_nm_object_reload_properties_async (self, init_async_got_properties, simple); _nm_object_reload_properties_async (self, init_async_got_properties, simple);
/* g_async_result_get_source_object() adds a ref */ /* g_async_result_get_source_object() adds a ref */
@@ -273,13 +261,31 @@ init_async (GAsyncInitable *initable, int io_priority,
GCancellable *cancellable, GAsyncReadyCallback callback, GCancellable *cancellable, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (initable); NMObject *self = NM_OBJECT (initable);
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
GError *error = NULL;
simple = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async); simple = g_simple_async_result_new (G_OBJECT (initable), callback, user_data, init_async);
if (_nm_object_is_connection_private (NM_OBJECT (initable))) if (!priv->connection) {
_nm_object_reload_properties_async (NM_OBJECT (initable), init_async_got_properties, simple); priv->connection = _nm_dbus_new_connection (&error);
if (!priv->connection) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
return;
}
}
if (!init_common (self, &error)) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
return;
}
if (_nm_object_is_connection_private (self))
_nm_object_reload_properties_async (self, init_async_got_properties, simple);
else { else {
/* Check if NM is running */ /* Check if NM is running */
dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner", dbus_g_proxy_begin_call (priv->bus_proxy, "NameHasOwner",
@@ -349,8 +355,6 @@ set_property (GObject *object, guint prop_id,
case PROP_DBUS_CONNECTION: case PROP_DBUS_CONNECTION:
/* Construct only */ /* Construct only */
priv->connection = g_value_dup_boxed (value); priv->connection = g_value_dup_boxed (value);
if (!priv->connection)
priv->connection = _nm_dbus_new_connection (NULL);
break; break;
case PROP_DBUS_PATH: case PROP_DBUS_PATH:
/* Construct only */ /* Construct only */
@@ -389,8 +393,6 @@ nm_object_class_init (NMObjectClass *nm_object_class)
g_type_class_add_private (nm_object_class, sizeof (NMObjectPrivate)); g_type_class_add_private (nm_object_class, sizeof (NMObjectPrivate));
/* virtual methods */ /* virtual methods */
object_class->constructor = constructor;
object_class->constructed = constructed;
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;
@@ -585,7 +587,6 @@ _nm_object_create (GType type, DBusGConnection *connection, const char *path)
if (!g_initable_init (G_INITABLE (object), NULL, &error)) { if (!g_initable_init (G_INITABLE (object), NULL, &error)) {
dbgmsg ("Could not create object for %s: %s", path, error->message); dbgmsg ("Could not create object for %s: %s", path, error->message);
g_error_free (error); g_error_free (error);
g_clear_object (&object);
} }
return object; return object;
@@ -620,10 +621,9 @@ nm_object_or_connection_get_path (gpointer instance)
} }
static void static void
async_inited (GObject *source, GAsyncResult *result, gpointer user_data) async_inited (GObject *object, GAsyncResult *result, gpointer user_data)
{ {
NMObjectTypeAsyncData *async_data = user_data; NMObjectTypeAsyncData *async_data = user_data;
GObject *object = G_OBJECT (source);
GError *error = NULL; GError *error = NULL;
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) { if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) {
@@ -631,7 +631,7 @@ async_inited (GObject *source, GAsyncResult *result, gpointer user_data)
nm_object_or_connection_get_path (object), nm_object_or_connection_get_path (object),
error->message); error->message);
g_error_free (error); g_error_free (error);
g_clear_object (&object); object = NULL;
} }
create_async_complete (object, async_data); create_async_complete (object, async_data);
@@ -664,7 +664,6 @@ async_got_type (GType type, gpointer user_data)
NM_OBJECT_DBUS_CONNECTION, async_data->connection, NM_OBJECT_DBUS_CONNECTION, async_data->connection,
NM_OBJECT_DBUS_PATH, async_data->path, NM_OBJECT_DBUS_PATH, async_data->path,
NULL); NULL);
g_warn_if_fail (object != NULL);
if (NM_IS_OBJECT (object)) if (NM_IS_OBJECT (object))
_nm_object_cache_add (NM_OBJECT (object)); _nm_object_cache_add (NM_OBJECT (object));
g_async_initable_init_async (G_ASYNC_INITABLE (object), G_PRIORITY_DEFAULT, g_async_initable_init_async (G_ASYNC_INITABLE (object), G_PRIORITY_DEFAULT,
@@ -1254,26 +1253,6 @@ _nm_object_suppress_property_updates (NMObject *object, gboolean suppress)
} }
void
_nm_object_ensure_inited (NMObject *object)
{
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
GError *error = NULL;
if (!priv->inited) {
if (!g_initable_init (G_INITABLE (object), NULL, &error)) {
dbgmsg ("Could not initialize %s %s: %s",
G_OBJECT_TYPE_NAME (object),
priv->path,
error->message);
g_error_free (error);
/* Only warn once */
priv->inited = TRUE;
}
}
}
void void
_nm_object_reload_property (NMObject *object, _nm_object_reload_property (NMObject *object,
const char *interface, const char *interface,

View File

@@ -82,7 +82,6 @@ typedef struct {
gboolean proxy_is_destroyed; gboolean proxy_is_destroyed;
GSList *calls; GSList *calls;
gboolean inited;
gboolean unsaved; gboolean unsaved;
gboolean visible; gboolean visible;
@@ -109,29 +108,6 @@ nm_remote_connection_error_quark (void)
/****************************************************************/ /****************************************************************/
static void
_nm_remote_connection_ensure_inited (NMRemoteConnection *self)
{
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
GError *error = NULL;
if (!priv->inited) {
if (!g_initable_init (G_INITABLE (self), NULL, &error)) {
/* Don't warn when the call times out because the settings service can't
* be activated or whatever.
*/
if (!g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) {
g_warning ("%s: (NMRemoteConnection) error initializing: %s\n",
__func__, error->message);
}
g_error_free (error);
}
priv->inited = TRUE;
}
}
/****************************************************************/
static void static void
remote_call_dbus_cb (DBusGProxy *proxy, DBusGProxyCall *proxy_call, gpointer user_data) remote_call_dbus_cb (DBusGProxy *proxy, DBusGProxyCall *proxy_call, gpointer user_data)
{ {
@@ -434,7 +410,6 @@ nm_remote_connection_get_unsaved (NMRemoteConnection *connection)
{ {
g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE); g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
_nm_remote_connection_ensure_inited (connection);
return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->unsaved; return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->unsaved;
} }
@@ -542,28 +517,26 @@ properties_changed_cb (DBusGProxy *proxy,
/****************************************************************/ /****************************************************************/
static void static void
constructed (GObject *object) init_common (NMRemoteConnection *self)
{ {
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object); NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
G_OBJECT_CLASS (nm_remote_connection_parent_class)->constructed (object);
g_assert (priv->bus); g_assert (priv->bus);
g_assert (nm_connection_get_path (NM_CONNECTION (object))); g_assert (nm_connection_get_path (NM_CONNECTION (self)));
priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus, priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
nm_connection_get_path (NM_CONNECTION (object)), nm_connection_get_path (NM_CONNECTION (self)),
NM_DBUS_INTERFACE_SETTINGS_CONNECTION); NM_DBUS_INTERFACE_SETTINGS_CONNECTION);
g_assert (priv->proxy); g_assert (priv->proxy);
dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT); dbus_g_proxy_set_default_timeout (priv->proxy, G_MAXINT);
dbus_g_proxy_add_signal (priv->proxy, "Updated", G_TYPE_INVALID); dbus_g_proxy_add_signal (priv->proxy, "Updated", G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Updated", G_CALLBACK (updated_cb), object, NULL); dbus_g_proxy_connect_signal (priv->proxy, "Updated", G_CALLBACK (updated_cb), self, NULL);
dbus_g_proxy_add_signal (priv->proxy, "Removed", G_TYPE_INVALID); dbus_g_proxy_add_signal (priv->proxy, "Removed", G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Removed", G_CALLBACK (removed_cb), object, NULL); dbus_g_proxy_connect_signal (priv->proxy, "Removed", G_CALLBACK (removed_cb), self, NULL);
g_signal_connect (priv->proxy, "destroy", G_CALLBACK (proxy_destroy_cb), object); g_signal_connect (priv->proxy, "destroy", G_CALLBACK (proxy_destroy_cb), self);
/* Monitor properties */ /* Monitor properties */
dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED, dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
@@ -575,11 +548,11 @@ constructed (GObject *object)
G_TYPE_INVALID); G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged", dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
G_CALLBACK (properties_changed_cb), G_CALLBACK (properties_changed_cb),
object, self,
NULL); NULL);
priv->props_proxy = _nm_dbus_new_proxy_for_connection (priv->bus, priv->props_proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
nm_connection_get_path (NM_CONNECTION (object)), nm_connection_get_path (NM_CONNECTION (self)),
DBUS_INTERFACE_PROPERTIES); DBUS_INTERFACE_PROPERTIES);
g_assert (priv->props_proxy); g_assert (priv->props_proxy);
} }
@@ -587,16 +560,19 @@ constructed (GObject *object)
static gboolean static gboolean
init_sync (GInitable *initable, GCancellable *cancellable, GError **error) init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
{ {
NMRemoteConnection *self = NM_REMOTE_CONNECTION (initable);
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable); NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
GHashTable *hash; GHashTable *hash;
init_common (self);
if (!dbus_g_proxy_call (priv->proxy, "GetSettings", error, if (!dbus_g_proxy_call (priv->proxy, "GetSettings", error,
G_TYPE_INVALID, G_TYPE_INVALID,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &hash, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &hash,
G_TYPE_INVALID)) G_TYPE_INVALID))
return FALSE; return FALSE;
priv->visible = TRUE; priv->visible = TRUE;
replace_settings (NM_REMOTE_CONNECTION (initable), hash); replace_settings (self, hash);
g_hash_table_destroy (hash); g_hash_table_destroy (hash);
/* Get properties */ /* Get properties */
@@ -607,7 +583,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
DBUS_TYPE_G_MAP_OF_VARIANT, &hash, DBUS_TYPE_G_MAP_OF_VARIANT, &hash,
G_TYPE_INVALID)) G_TYPE_INVALID))
return FALSE; return FALSE;
properties_changed_cb (priv->props_proxy, hash, NM_REMOTE_CONNECTION (initable)); properties_changed_cb (priv->props_proxy, hash, self);
g_hash_table_destroy (hash); g_hash_table_destroy (hash);
return TRUE; return TRUE;
@@ -623,10 +599,8 @@ init_async_complete (NMRemoteConnectionInitData *init_data, GError *error)
{ {
if (error) if (error)
g_simple_async_result_take_error (init_data->result, error); g_simple_async_result_take_error (init_data->result, error);
else { else
g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE); g_simple_async_result_set_op_res_gboolean (init_data->result, TRUE);
NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->connection)->inited = TRUE;
}
g_simple_async_result_complete (init_data->result); g_simple_async_result_complete (init_data->result);
g_object_unref (init_data->result); g_object_unref (init_data->result);
@@ -687,12 +661,13 @@ init_async (GAsyncInitable *initable, int io_priority,
NMRemoteConnectionInitData *init_data; NMRemoteConnectionInitData *init_data;
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable); NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable);
init_data = g_slice_new0 (NMRemoteConnectionInitData); init_data = g_slice_new0 (NMRemoteConnectionInitData);
init_data->connection = NM_REMOTE_CONNECTION (initable); init_data->connection = NM_REMOTE_CONNECTION (initable);
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback, init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
user_data, init_async); user_data, init_async);
init_common (init_data->connection);
dbus_g_proxy_begin_call (priv->proxy, "GetSettings", dbus_g_proxy_begin_call (priv->proxy, "GetSettings",
init_get_settings_cb, init_data, NULL, init_get_settings_cb, init_data, NULL,
G_TYPE_INVALID); G_TYPE_INVALID);
@@ -755,8 +730,6 @@ static void
get_property (GObject *object, guint prop_id, get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec) GValue *value, GParamSpec *pspec)
{ {
_nm_remote_connection_ensure_inited (NM_REMOTE_CONNECTION (object));
switch (prop_id) { switch (prop_id) {
case PROP_UNSAVED: case PROP_UNSAVED:
g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved); g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved);
@@ -830,7 +803,6 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->dispose = dispose; object_class->dispose = dispose;
object_class->constructed = constructed;
/* Properties */ /* Properties */
/** /**

View File

@@ -131,7 +131,6 @@ G_DEFINE_TYPE_WITH_CODE (NMRemoteSettings, nm_remote_settings, G_TYPE_OBJECT,
typedef struct { typedef struct {
DBusGConnection *bus; DBusGConnection *bus;
gboolean private_bus; gboolean private_bus;
gboolean inited;
DBusGProxy *proxy; DBusGProxy *proxy;
GHashTable *connections; GHashTable *connections;
@@ -191,29 +190,6 @@ nm_remote_settings_error_quark (void)
/**********************************************************************/ /**********************************************************************/
static void
_nm_remote_settings_ensure_inited (NMRemoteSettings *self)
{
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
GError *error = NULL;
if (!priv->inited) {
if (!g_initable_init (G_INITABLE (self), NULL, &error)) {
/* Don't warn when the call times out because the settings service can't
* be activated or whatever.
*/
if (!g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) {
g_warning ("%s: (NMRemoteSettings) error initializing: %s\n",
__func__, error->message);
}
g_error_free (error);
}
priv->inited = TRUE;
}
}
/**********************************************************************/
typedef struct { typedef struct {
NMRemoteSettings *self; NMRemoteSettings *self;
NMRemoteSettingsAddConnectionFunc callback; NMRemoteSettingsAddConnectionFunc callback;
@@ -278,8 +254,6 @@ nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings, const char
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (priv->service_running) { if (priv->service_running) {
GHashTableIter iter; GHashTableIter iter;
NMConnection *candidate; NMConnection *candidate;
@@ -315,8 +289,6 @@ nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, const cha
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
return priv->service_running ? g_hash_table_lookup (priv->connections, path) : NULL; return priv->service_running ? g_hash_table_lookup (priv->connections, path) : NULL;
} }
@@ -342,8 +314,6 @@ nm_remote_settings_get_connection_by_uuid (NMRemoteSettings *settings, const cha
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (priv->service_running) { if (priv->service_running) {
g_hash_table_iter_init (&iter, priv->connections); g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
@@ -529,18 +499,17 @@ new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data)
NM_REMOTE_CONNECTION_BUS, priv->bus, NM_REMOTE_CONNECTION_BUS, priv->bus,
NM_CONNECTION_PATH, path, NM_CONNECTION_PATH, path,
NULL); NULL);
if (connection) { g_async_initable_init_async (G_ASYNC_INITABLE (connection),
g_async_initable_init_async (G_ASYNC_INITABLE (connection), G_PRIORITY_DEFAULT, NULL,
G_PRIORITY_DEFAULT, NULL, connection_inited, self);
connection_inited, self);
/* Add the connection to the pending table to wait for it to retrieve
* it's settings asynchronously over D-Bus. The connection isn't
* really valid until it has all its settings, so hide it until it does.
*/
move_connection (self, connection, NULL, priv->pending);
g_object_unref (connection); /* move_connection() takes a ref */
/* Add the connection to the pending table to wait for it to retrieve
* it's settings asynchronously over D-Bus. The connection isn't
* really valid until it has all its settings, so hide it until it does.
*/
move_connection (self, connection, NULL, priv->pending);
g_object_unref (connection); /* move_connection() takes a ref */
}
return connection; return connection;
} }
@@ -615,8 +584,6 @@ nm_remote_settings_list_connections (NMRemoteSettings *settings)
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (priv->service_running) { if (priv->service_running) {
g_hash_table_iter_init (&iter, priv->connections); g_hash_table_iter_init (&iter, priv->connections);
while (g_hash_table_iter_next (&iter, NULL, &value)) while (g_hash_table_iter_next (&iter, NULL, &value))
@@ -680,8 +647,6 @@ nm_remote_settings_add_connection (NMRemoteSettings *settings,
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (!priv->service_running) if (!priv->service_running)
return FALSE; return FALSE;
@@ -735,8 +700,6 @@ nm_remote_settings_add_connection_unsaved (NMRemoteSettings *settings,
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (!priv->service_running) if (!priv->service_running)
return FALSE; return FALSE;
@@ -797,8 +760,6 @@ nm_remote_settings_load_connections (NMRemoteSettings *settings,
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (!priv->service_running) { if (!priv->service_running) {
g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR, g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR,
NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE, NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE,
@@ -846,8 +807,6 @@ nm_remote_settings_reload_connections (NMRemoteSettings *settings,
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (!priv->service_running) { if (!priv->service_running) {
g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR, g_set_error_literal (error, NM_REMOTE_SETTINGS_ERROR,
NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE, NM_REMOTE_SETTINGS_ERROR_SERVICE_UNAVAILABLE,
@@ -935,8 +894,6 @@ nm_remote_settings_save_hostname (NMRemoteSettings *settings,
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
_nm_remote_settings_ensure_inited (settings);
if (!priv->service_running) if (!priv->service_running)
return FALSE; return FALSE;
@@ -1046,7 +1003,8 @@ name_owner_changed (DBusGProxy *proxy,
/** /**
* nm_remote_settings_new: * nm_remote_settings_new:
* @bus: (allow-none): a valid and connected D-Bus connection * @cancellable: a #GCancellable, or %NULL
* @error: location for a #GError, or %NULL
* *
* Creates a new object representing the remote settings service. * Creates a new object representing the remote settings service.
* *
@@ -1057,13 +1015,11 @@ name_owner_changed (DBusGProxy *proxy,
* Returns: the new remote settings object on success, or %NULL on failure * Returns: the new remote settings object on success, or %NULL on failure
**/ **/
NMRemoteSettings * NMRemoteSettings *
nm_remote_settings_new (DBusGConnection *bus) nm_remote_settings_new (GCancellable *cancellable,
GError **error)
{ {
NMRemoteSettings *self; return g_initable_new (NM_TYPE_REMOTE_SETTINGS, cancellable, error,
NULL);
self = g_object_new (NM_TYPE_REMOTE_SETTINGS, NM_REMOTE_SETTINGS_BUS, bus, NULL);
_nm_remote_settings_ensure_inited (self);
return self;
} }
static void static void
@@ -1072,7 +1028,7 @@ remote_settings_inited (GObject *source, GAsyncResult *result, gpointer user_dat
GSimpleAsyncResult *simple = user_data; GSimpleAsyncResult *simple = user_data;
GError *error = NULL; GError *error = NULL;
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (source), result, &error)) if (!g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error))
g_simple_async_result_take_error (simple, error); g_simple_async_result_take_error (simple, error);
else else
g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref); g_simple_async_result_set_op_res_gpointer (simple, source, g_object_unref);
@@ -1082,7 +1038,6 @@ remote_settings_inited (GObject *source, GAsyncResult *result, gpointer user_dat
/** /**
* nm_remote_settings_new_async: * nm_remote_settings_new_async:
* @bus: (allow-none): a valid and connected D-Bus connection
* @cancellable: a #GCancellable, or %NULL * @cancellable: a #GCancellable, or %NULL
* @callback: callback to call when the settings object is created * @callback: callback to call when the settings object is created
* @user_data: data for @callback * @user_data: data for @callback
@@ -1093,19 +1048,16 @@ remote_settings_inited (GObject *source, GAsyncResult *result, gpointer user_dat
* result. * result.
**/ **/
void void
nm_remote_settings_new_async (DBusGConnection *bus, GCancellable *cancellable, nm_remote_settings_new_async (GCancellable *cancellable,
GAsyncReadyCallback callback, gpointer user_data) GAsyncReadyCallback callback, gpointer user_data)
{ {
NMRemoteSettings *self;
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
simple = g_simple_async_result_new (NULL, callback, user_data, nm_remote_settings_new_async); simple = g_simple_async_result_new (NULL, callback, user_data, nm_remote_settings_new_async);
self = g_object_new (NM_TYPE_REMOTE_SETTINGS, g_async_initable_new_async (NM_TYPE_REMOTE_SETTINGS, G_PRIORITY_DEFAULT, cancellable,
NM_REMOTE_SETTINGS_BUS, bus, remote_settings_inited, simple,
NULL); NULL);
g_async_initable_init_async (G_ASYNC_INITABLE (self), G_PRIORITY_DEFAULT,
cancellable, remote_settings_inited, simple);
} }
/** /**
@@ -1153,11 +1105,9 @@ nm_remote_settings_init (NMRemoteSettings *self)
} }
static void static void
constructed (GObject *object) init_common (NMRemoteSettings *self)
{ {
NMRemoteSettingsPrivate *priv; NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (self);
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
if (priv->private_bus == FALSE) { if (priv->private_bus == FALSE) {
/* D-Bus proxy for clearing connections on NameOwnerChanged */ /* D-Bus proxy for clearing connections on NameOwnerChanged */
@@ -1177,7 +1127,7 @@ constructed (GObject *object)
dbus_g_proxy_connect_signal (priv->dbus_proxy, dbus_g_proxy_connect_signal (priv->dbus_proxy,
"NameOwnerChanged", "NameOwnerChanged",
G_CALLBACK (name_owner_changed), G_CALLBACK (name_owner_changed),
object, NULL); self, NULL);
} }
priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus, priv->proxy = _nm_dbus_new_proxy_for_connection (priv->bus,
@@ -1191,7 +1141,7 @@ constructed (GObject *object)
G_TYPE_INVALID); G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "NewConnection", dbus_g_proxy_connect_signal (priv->proxy, "NewConnection",
G_CALLBACK (new_connection_cb), G_CALLBACK (new_connection_cb),
object, self,
NULL); NULL);
/* D-Bus properties proxy */ /* D-Bus properties proxy */
@@ -1210,7 +1160,7 @@ constructed (GObject *object)
G_TYPE_INVALID); G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged", dbus_g_proxy_connect_signal (priv->proxy, "PropertiesChanged",
G_CALLBACK (properties_changed_cb), G_CALLBACK (properties_changed_cb),
object, self,
NULL); NULL);
} }
@@ -1221,6 +1171,8 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
GHashTable *props; GHashTable *props;
init_common (settings);
if (priv->private_bus == FALSE) { if (priv->private_bus == FALSE) {
if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error, if (!dbus_g_proxy_call (priv->dbus_proxy, "NameHasOwner", error,
G_TYPE_STRING, NM_DBUS_SERVICE, G_TYPE_STRING, NM_DBUS_SERVICE,
@@ -1264,10 +1216,6 @@ typedef struct {
static void static void
init_async_complete (NMRemoteSettingsInitData *init_data) init_async_complete (NMRemoteSettingsInitData *init_data)
{ {
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (init_data->settings);
priv->inited = TRUE;
g_simple_async_result_complete (init_data->result); g_simple_async_result_complete (init_data->result);
g_object_unref (init_data->result); g_object_unref (init_data->result);
g_slice_free (NMRemoteSettingsInitData, init_data); g_slice_free (NMRemoteSettingsInitData, init_data);
@@ -1358,6 +1306,8 @@ init_async (GAsyncInitable *initable, int io_priority,
init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback, init_data->result = g_simple_async_result_new (G_OBJECT (initable), callback,
user_data, init_async); user_data, init_async);
init_common (init_data->settings);
if (priv->private_bus) if (priv->private_bus)
init_get_properties (init_data); init_get_properties (init_data);
else { else {
@@ -1442,8 +1392,6 @@ get_property (GObject *object, guint prop_id,
{ {
NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object); NMRemoteSettingsPrivate *priv = NM_REMOTE_SETTINGS_GET_PRIVATE (object);
_nm_remote_settings_ensure_inited (NM_REMOTE_SETTINGS (object));
switch (prop_id) { switch (prop_id) {
case PROP_BUS: case PROP_BUS:
g_value_set_boxed (value, priv->bus); g_value_set_boxed (value, priv->bus);
@@ -1471,7 +1419,6 @@ nm_remote_settings_class_init (NMRemoteSettingsClass *class)
g_type_class_add_private (class, sizeof (NMRemoteSettingsPrivate)); g_type_class_add_private (class, sizeof (NMRemoteSettingsPrivate));
/* Virtual methods */ /* Virtual methods */
object_class->constructed = constructed;
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;

View File

@@ -23,7 +23,6 @@
#define NM_REMOTE_SETTINGS_H #define NM_REMOTE_SETTINGS_H
#include <gio/gio.h> #include <gio/gio.h>
#include <dbus/dbus-glib.h>
#include <nm-connection.h> #include <nm-connection.h>
#include <nm-remote-connection.h> #include <nm-remote-connection.h>
@@ -105,10 +104,10 @@ struct _NMRemoteSettingsClass {
GType nm_remote_settings_get_type (void); GType nm_remote_settings_get_type (void);
NMRemoteSettings *nm_remote_settings_new (DBusGConnection *bus); NMRemoteSettings *nm_remote_settings_new (GCancellable *cancellable,
GError **error);
void nm_remote_settings_new_async (DBusGConnection *bus, void nm_remote_settings_new_async (GCancellable *cancellable,
GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
NMRemoteSettings *nm_remote_settings_new_finish (GAsyncResult *result, NMRemoteSettings *nm_remote_settings_new_finish (GAsyncResult *result,

View File

@@ -71,9 +71,6 @@ nm_vpn_connection_get_banner (NMVpnConnection *vpn)
priv = NM_VPN_CONNECTION_GET_PRIVATE (vpn); priv = NM_VPN_CONNECTION_GET_PRIVATE (vpn);
/* We need to update vpn_state first in case it's unknown. */
_nm_object_ensure_inited (NM_OBJECT (vpn));
if (priv->vpn_state != NM_VPN_CONNECTION_STATE_ACTIVATED) if (priv->vpn_state != NM_VPN_CONNECTION_STATE_ACTIVATED)
return NULL; return NULL;
@@ -93,7 +90,6 @@ nm_vpn_connection_get_vpn_state (NMVpnConnection *vpn)
{ {
g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), NM_VPN_CONNECTION_STATE_UNKNOWN); g_return_val_if_fail (NM_IS_VPN_CONNECTION (vpn), NM_VPN_CONNECTION_STATE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (vpn));
return NM_VPN_CONNECTION_GET_PRIVATE (vpn)->vpn_state; return NM_VPN_CONNECTION_GET_PRIVATE (vpn)->vpn_state;
} }
@@ -171,8 +167,6 @@ get_property (GObject *object,
{ {
NMVpnConnection *self = NM_VPN_CONNECTION (object); NMVpnConnection *self = NM_VPN_CONNECTION (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_VPN_STATE: case PROP_VPN_STATE:
g_value_set_uint (value, nm_vpn_connection_get_vpn_state (self)); g_value_set_uint (value, nm_vpn_connection_get_vpn_state (self));

View File

@@ -20,6 +20,10 @@
*/ */
#include <signal.h> #include <signal.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include "nm-glib-compat.h" #include "nm-glib-compat.h"
#include "nm-vpn-plugin.h" #include "nm-vpn-plugin.h"
#include "nm-vpn-enum-types.h" #include "nm-vpn-enum-types.h"
@@ -68,7 +72,11 @@ static gboolean impl_vpn_plugin_set_failure (NMVpnPlugin *plugin,
#define NM_VPN_PLUGIN_QUIT_TIMER 20 #define NM_VPN_PLUGIN_QUIT_TIMER 20
G_DEFINE_ABSTRACT_TYPE (NMVpnPlugin, nm_vpn_plugin, G_TYPE_OBJECT) static void nm_vpn_plugin_initable_iface_init (GInitableIface *iface);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMVpnPlugin, nm_vpn_plugin, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_vpn_plugin_initable_iface_init);
)
typedef struct { typedef struct {
NMVpnServiceState state; NMVpnServiceState state;
@@ -729,71 +737,51 @@ nm_vpn_plugin_init (NMVpnPlugin *plugin)
NULL); NULL);
} }
static GObject * static gboolean
constructor (GType type, init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
guint n_construct_params,
GObjectConstructParam *construct_params)
{ {
GObject *object; NMVpnPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (initable);
NMVpnPlugin *plugin; NMVpnPlugin *plugin;
NMVpnPluginPrivate *priv;
DBusGConnection *connection; DBusGConnection *connection;
DBusGProxy *proxy; DBusGProxy *proxy;
guint request_name_result; guint request_name_result;
GError *err = NULL;
object = G_OBJECT_CLASS (nm_vpn_plugin_parent_class)->constructor (type, if (!priv->dbus_service_name) {
n_construct_params, g_set_error_literal (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
construct_params); _("No service name specified"));
if (!object) return FALSE;
return NULL; }
priv = NM_VPN_PLUGIN_GET_PRIVATE (object); connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
if (!priv->dbus_service_name)
goto err;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!connection) if (!connection)
goto err; return FALSE;
proxy = dbus_g_proxy_new_for_name (connection, proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.DBus", "org.freedesktop.DBus",
"/org/freedesktop/DBus", "/org/freedesktop/DBus",
"org.freedesktop.DBus"); "org.freedesktop.DBus");
if (!dbus_g_proxy_call (proxy, "RequestName", &err, if (!dbus_g_proxy_call (proxy, "RequestName", error,
G_TYPE_STRING, priv->dbus_service_name, G_TYPE_STRING, priv->dbus_service_name,
G_TYPE_UINT, 0, G_TYPE_UINT, 0,
G_TYPE_INVALID, G_TYPE_INVALID,
G_TYPE_UINT, &request_name_result, G_TYPE_UINT, &request_name_result,
G_TYPE_INVALID)) { G_TYPE_INVALID)) {
g_object_unref (proxy); g_object_unref (proxy);
goto err; return FALSE;
} }
g_object_unref (proxy); g_object_unref (proxy);
dbus_g_connection_register_g_object (connection, dbus_g_connection_register_g_object (connection,
NM_VPN_DBUS_PLUGIN_PATH, NM_VPN_DBUS_PLUGIN_PATH,
object); G_OBJECT (initable));
plugin = NM_VPN_PLUGIN (object); plugin = NM_VPN_PLUGIN (initable);
nm_vpn_plugin_set_connection (plugin, connection); nm_vpn_plugin_set_connection (plugin, connection);
nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_INIT); nm_vpn_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_INIT);
return object; return TRUE;
err:
if (err) {
g_warning ("Failed to initialize VPN plugin: %s", err->message);
g_error_free (err);
}
if (object)
g_object_unref (object);
return NULL;
} }
static void static void
@@ -805,7 +793,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_DBUS_SERVICE_NAME: case PROP_DBUS_SERVICE_NAME:
/* Construct-only */ /* Construct-only */
priv->dbus_service_name = g_strdup (g_value_get_string (value)); priv->dbus_service_name = g_value_dup_string (value);
break; break;
case PROP_STATE: case PROP_STATE:
nm_vpn_plugin_set_state (NM_VPN_PLUGIN (object), nm_vpn_plugin_set_state (NM_VPN_PLUGIN (object),
@@ -940,7 +928,6 @@ nm_vpn_plugin_class_init (NMVpnPluginClass *plugin_class)
&dbus_glib_nm_vpn_plugin_object_info); &dbus_glib_nm_vpn_plugin_object_info);
/* virtual methods */ /* virtual methods */
object_class->constructor = constructor;
object_class->set_property = set_property; object_class->set_property = set_property;
object_class->get_property = get_property; object_class->get_property = get_property;
object_class->dispose = dispose; object_class->dispose = dispose;
@@ -1062,3 +1049,9 @@ nm_vpn_plugin_class_init (NMVpnPluginClass *plugin_class)
setup_unix_signal_handler (); setup_unix_signal_handler ();
} }
static void
nm_vpn_plugin_initable_iface_init (GInitableIface *iface)
{
iface->init = init_sync;
}

View File

@@ -66,7 +66,6 @@ nm_wimax_nsp_get_name (NMWimaxNsp *nsp)
{ {
g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NULL); g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NULL);
_nm_object_ensure_inited (NM_OBJECT (nsp));
return NM_WIMAX_NSP_GET_PRIVATE (nsp)->name; return NM_WIMAX_NSP_GET_PRIVATE (nsp)->name;
} }
@@ -83,7 +82,6 @@ nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp)
{ {
g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), 0); g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), 0);
_nm_object_ensure_inited (NM_OBJECT (nsp));
return NM_WIMAX_NSP_GET_PRIVATE (nsp)->signal_quality; return NM_WIMAX_NSP_GET_PRIVATE (nsp)->signal_quality;
} }
@@ -100,7 +98,6 @@ nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp)
{ {
g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN); g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN);
_nm_object_ensure_inited (NM_OBJECT (nsp));
return NM_WIMAX_NSP_GET_PRIVATE (nsp)->network_type; return NM_WIMAX_NSP_GET_PRIVATE (nsp)->network_type;
} }
@@ -214,8 +211,6 @@ get_property (GObject *object,
{ {
NMWimaxNsp *nsp = NM_WIMAX_NSP (object); NMWimaxNsp *nsp = NM_WIMAX_NSP (object);
_nm_object_ensure_inited (NM_OBJECT (object));
switch (prop_id) { switch (prop_id) {
case PROP_NAME: case PROP_NAME:
g_value_set_string (value, nm_wimax_nsp_get_name (nsp)); g_value_set_string (value, nm_wimax_nsp_get_name (nsp));

View File

@@ -361,6 +361,7 @@ test_service_running (void)
guint quit_id; guint quit_id;
int running_changed = 0; int running_changed = 0;
gboolean running; gboolean running;
GError *error = NULL;
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
@@ -372,7 +373,11 @@ test_service_running (void)
/* Now kill the test service. */ /* Now kill the test service. */
nm_test_service_cleanup (sinfo); nm_test_service_cleanup (sinfo);
settings2 = nm_remote_settings_new (bus); settings2 = g_initable_new (NM_TYPE_REMOTE_SETTINGS, NULL, &error,
NM_REMOTE_SETTINGS_BUS, bus,
NULL);
g_assert_no_error (error);
g_assert (settings != NULL);
/* settings2 should know that NM is running, but the previously-created /* settings2 should know that NM is running, but the previously-created
* settings hasn't gotten the news yet. * settings hasn't gotten the news yet.
@@ -433,7 +438,10 @@ main (int argc, char **argv)
sinfo = nm_test_service_init (); sinfo = nm_test_service_init ();
settings = nm_remote_settings_new (bus); settings = g_initable_new (NM_TYPE_REMOTE_SETTINGS, NULL, &error,
NM_REMOTE_SETTINGS_BUS, bus,
NULL);
g_assert_no_error (error);
g_assert (settings != NULL); g_assert (settings != NULL);
/* FIXME: these tests assume that they get run in order, but g_test_run() /* FIXME: these tests assume that they get run in order, but g_test_run()