core: remove remaining pre-2.32 GLib compat / deprecated usage
This commit is contained in:
@@ -29,53 +29,6 @@
|
||||
|
||||
#include "nm-gvaluearray-compat.h"
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,31,0)
|
||||
#define g_value_set_schar g_value_set_char
|
||||
#define g_value_get_schar g_value_get_char
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,30,0)
|
||||
#define G_VALUE_INIT { 0, { { 0 } } }
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,28,0)
|
||||
#define g_simple_async_result_take_error(result, error) \
|
||||
G_STMT_START { \
|
||||
GError *__error = error; \
|
||||
g_simple_async_result_set_from_error (result, __error); \
|
||||
g_error_free (__error); \
|
||||
} G_STMT_END
|
||||
|
||||
#define g_clear_object(object_ptr) \
|
||||
G_STMT_START { \
|
||||
GObject **__obj_p = (gpointer) (object_ptr); \
|
||||
if (*__obj_p) { \
|
||||
g_object_unref (*__obj_p); \
|
||||
*__obj_p = NULL; \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef G_DEFINE_BOXED_TYPE
|
||||
#define G_DEFINE_BOXED_TYPE(t,p,d,f) \
|
||||
GType \
|
||||
p##_get_type (void) \
|
||||
{ \
|
||||
static volatile gsize g_define_type_id__volatile = 0; \
|
||||
\
|
||||
if (g_once_init_enter (&g_define_type_id__volatile)) { \
|
||||
GType g_define_type_id = \
|
||||
g_boxed_type_register_static( \
|
||||
g_intern_static_string(#t), \
|
||||
(GBoxedCopyFunc) d, \
|
||||
(GBoxedFreeFunc) f); \
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
|
||||
} \
|
||||
return g_define_type_id__volatile; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,34,0)
|
||||
static inline void
|
||||
g_type_ensure (GType type)
|
||||
|
11
src/main.c
11
src/main.c
@@ -482,18 +482,7 @@ main (int argc, char *argv[])
|
||||
umask (022);
|
||||
|
||||
g_type_init ();
|
||||
|
||||
/*
|
||||
* Threading is always enabled starting from GLib 2.31.0.
|
||||
* See also http://developer.gnome.org/glib/2.31/glib-Deprecated-Thread-APIs.html.
|
||||
*/
|
||||
#if !GLIB_CHECK_VERSION (2,31,0)
|
||||
if (!g_thread_supported ())
|
||||
g_thread_init (NULL);
|
||||
dbus_g_thread_init ();
|
||||
#else
|
||||
dbus_threads_init_default ();
|
||||
#endif
|
||||
|
||||
/* Ensure that non-exported properties don't leak out, and that the
|
||||
* introspection 'access' permissions are respected.
|
||||
|
@@ -3855,9 +3855,7 @@ firmware_dir_changed (GFileMonitor *monitor,
|
||||
switch (event_type) {
|
||||
case G_FILE_MONITOR_EVENT_CREATED:
|
||||
case G_FILE_MONITOR_EVENT_CHANGED:
|
||||
#if GLIB_CHECK_VERSION(2,23,4)
|
||||
case G_FILE_MONITOR_EVENT_MOVED:
|
||||
#endif
|
||||
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
|
||||
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
|
||||
if (!priv->fw_changed_id) {
|
||||
|
@@ -35,20 +35,11 @@
|
||||
#define SD_PATH "/org/freedesktop/login1"
|
||||
#define SD_INTERFACE "org.freedesktop.login1.Manager"
|
||||
|
||||
/* Do we have GDBus (glib >= 2.26) and GUnixFDList (glib >= 2.30) support ? */
|
||||
#if GLIB_CHECK_VERSION(2,30,0)
|
||||
#define IS_GDBUS_UNIXFD_AVAILABLE 1
|
||||
#endif
|
||||
|
||||
|
||||
struct _NMSleepMonitor {
|
||||
GObject parent_instance;
|
||||
|
||||
#if defined(IS_GDBUS_UNIXFD_AVAILABLE)
|
||||
GDBusProxy *sd_proxy;
|
||||
#else
|
||||
DBusGProxy *sd_proxy;
|
||||
#endif
|
||||
gint inhibit_fd;
|
||||
};
|
||||
|
||||
@@ -83,8 +74,6 @@ drop_inhibitor (NMSleepMonitor *self)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(IS_GDBUS_UNIXFD_AVAILABLE)
|
||||
/* Great! We have GDBus (glib >= 2.26) and GUnixFDList (glib >= 2.30) */
|
||||
static void
|
||||
inhibit_done (GObject *source,
|
||||
GAsyncResult *result,
|
||||
@@ -171,136 +160,6 @@ sleep_setup (NMSleepMonitor *self)
|
||||
g_signal_connect (self->sd_proxy, "g-signal", G_CALLBACK (signal_cb), self);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* GDBus nor GUnixFDList available. We have to get by with dbus-glib and libdbus */
|
||||
static void
|
||||
inhibit_done (DBusPendingCall *pending,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSleepMonitor *self = user_data;
|
||||
DBusMessage *reply;
|
||||
DBusError error;
|
||||
int mtype;
|
||||
|
||||
dbus_error_init (&error);
|
||||
reply = dbus_pending_call_steal_reply (pending);
|
||||
g_assert (reply);
|
||||
|
||||
mtype = dbus_message_get_type (reply);
|
||||
switch (mtype) {
|
||||
case DBUS_MESSAGE_TYPE_ERROR:
|
||||
dbus_set_error_from_message (&error, reply);
|
||||
nm_log_warn (LOGD_SUSPEND, "Inhibit() failed: %s", error.message ? error.message : "unknown");
|
||||
break;
|
||||
case DBUS_MESSAGE_TYPE_METHOD_RETURN:
|
||||
if (!dbus_message_get_args (reply,
|
||||
&error,
|
||||
DBUS_TYPE_UNIX_FD, &self->inhibit_fd,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_SUSPEND, "Inhibit() reply parsing failed: %s",
|
||||
error.message ? error.message : "unknown");
|
||||
break;
|
||||
}
|
||||
nm_log_dbg (LOGD_SUSPEND, "Inhibitor fd is %d", self->inhibit_fd);
|
||||
break;
|
||||
default:
|
||||
nm_log_warn (LOGD_SUSPEND, "Invalid Inhibit() reply message type %d", mtype);
|
||||
break;
|
||||
}
|
||||
|
||||
dbus_message_unref (reply);
|
||||
dbus_error_free (&error);
|
||||
}
|
||||
|
||||
static void
|
||||
take_inhibitor (NMSleepMonitor *self)
|
||||
{
|
||||
NMDBusManager *dbus_mgr;
|
||||
DBusConnection *bus;
|
||||
DBusMessage *message = NULL;
|
||||
DBusPendingCall *pending = NULL;
|
||||
const char *arg_what = "sleep";
|
||||
const char *arg_who = g_get_user_name ();
|
||||
const char *arg_why = "inhibited";
|
||||
const char *arg_mode = "delay";
|
||||
|
||||
g_assert (self->inhibit_fd == -1);
|
||||
|
||||
nm_log_dbg (LOGD_SUSPEND, "Taking systemd sleep inhibitor");
|
||||
|
||||
dbus_mgr = nm_dbus_manager_get ();
|
||||
bus = nm_dbus_manager_get_dbus_connection (dbus_mgr);
|
||||
g_assert (bus);
|
||||
g_object_unref (dbus_mgr);
|
||||
|
||||
if (!(message = dbus_message_new_method_call (SD_NAME,
|
||||
SD_PATH,
|
||||
SD_INTERFACE,
|
||||
"Inhibit"))) {
|
||||
nm_log_warn (LOGD_SUSPEND, "Unable to call Inhibit()");
|
||||
return;
|
||||
}
|
||||
if (!dbus_message_append_args (message,
|
||||
DBUS_TYPE_STRING, &arg_what,
|
||||
DBUS_TYPE_STRING, &arg_who,
|
||||
DBUS_TYPE_STRING, &arg_why,
|
||||
DBUS_TYPE_STRING, &arg_mode,
|
||||
DBUS_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_SUSPEND, "Unable to call Inhibit()");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
|
||||
goto done;
|
||||
|
||||
if (!dbus_pending_call_set_notify (pending, inhibit_done, self, NULL)) {
|
||||
dbus_pending_call_cancel (pending);
|
||||
dbus_pending_call_unref (pending);
|
||||
}
|
||||
|
||||
done:
|
||||
if (message)
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
|
||||
static void
|
||||
signal_cb (DBusGProxy *proxy, gboolean about_to_suspend, gpointer data)
|
||||
{
|
||||
NMSleepMonitor *self = data;
|
||||
|
||||
nm_log_dbg (LOGD_SUSPEND, "Received PrepareForSleep signal: %d", about_to_suspend);
|
||||
|
||||
if (about_to_suspend) {
|
||||
g_signal_emit (self, signals[SLEEPING], 0);
|
||||
drop_inhibitor (self);
|
||||
} else {
|
||||
take_inhibitor (self);
|
||||
g_signal_emit (self, signals[RESUMING], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sleep_setup (NMSleepMonitor *self)
|
||||
{
|
||||
NMDBusManager *dbus_mgr;
|
||||
DBusGConnection *bus;
|
||||
|
||||
dbus_mgr = nm_dbus_manager_get ();
|
||||
bus = nm_dbus_manager_get_connection (dbus_mgr);
|
||||
self->sd_proxy = dbus_g_proxy_new_for_name (bus, SD_NAME, SD_PATH, SD_INTERFACE);
|
||||
g_object_unref (dbus_mgr);
|
||||
|
||||
if (self->sd_proxy) {
|
||||
dbus_g_proxy_add_signal (self->sd_proxy, "PrepareForSleep", G_TYPE_BOOLEAN, G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (self->sd_proxy, "PrepareForSleep",
|
||||
G_CALLBACK (signal_cb),
|
||||
self, NULL);
|
||||
} else
|
||||
nm_log_warn (LOGD_SUSPEND, "could not initialize systemd-logind D-Bus proxy");
|
||||
}
|
||||
#endif /* IS_GDBUS_UNIXFD_AVAILABLE */
|
||||
|
||||
static void
|
||||
nm_sleep_monitor_init (NMSleepMonitor *self)
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include "iwmxsdk.h"
|
||||
|
||||
static WIMAX_API_DEVICE_ID g_api;
|
||||
static GStaticMutex add_remove_mutex = G_STATIC_MUTEX_INIT;
|
||||
static GMutex add_remove_mutex;
|
||||
|
||||
/* Misc utilities */
|
||||
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
@@ -132,7 +132,7 @@ typedef struct {
|
||||
void *user_data;
|
||||
} NewSdkCallback;
|
||||
|
||||
GStaticMutex new_callbacks_mutex = G_STATIC_MUTEX_INIT;
|
||||
static GMutex new_callbacks_mutex;
|
||||
static GSList *new_callbacks = NULL;
|
||||
|
||||
void iwmx_sdk_new_callback_register(WimaxNewWmxsdkFunc callback, void *user_data)
|
||||
@@ -144,9 +144,9 @@ void iwmx_sdk_new_callback_register(WimaxNewWmxsdkFunc callback, void *user_data
|
||||
cb->callback = callback;
|
||||
cb->user_data = user_data;
|
||||
|
||||
g_static_mutex_lock (&new_callbacks_mutex);
|
||||
g_mutex_lock (&new_callbacks_mutex);
|
||||
new_callbacks = g_slist_append (new_callbacks, cb);
|
||||
g_static_mutex_unlock (&new_callbacks_mutex);
|
||||
g_mutex_unlock (&new_callbacks_mutex);
|
||||
}
|
||||
|
||||
void iwmx_sdk_new_callback_unregister(WimaxNewWmxsdkFunc callback, void *user_data)
|
||||
@@ -154,7 +154,7 @@ void iwmx_sdk_new_callback_unregister(WimaxNewWmxsdkFunc callback, void *user_da
|
||||
GSList *iter;
|
||||
NewSdkCallback *found = NULL;
|
||||
|
||||
g_static_mutex_lock (&new_callbacks_mutex);
|
||||
g_mutex_lock (&new_callbacks_mutex);
|
||||
for (iter = new_callbacks; iter; iter = g_slist_next (iter)) {
|
||||
NewSdkCallback *cb = iter->data;
|
||||
|
||||
@@ -168,20 +168,20 @@ void iwmx_sdk_new_callback_unregister(WimaxNewWmxsdkFunc callback, void *user_da
|
||||
new_callbacks = g_slist_remove (new_callbacks, found);
|
||||
g_free (found);
|
||||
}
|
||||
g_static_mutex_unlock (&new_callbacks_mutex);
|
||||
g_mutex_unlock (&new_callbacks_mutex);
|
||||
}
|
||||
|
||||
static void iwmx_sdk_call_new_callbacks(struct wmxsdk *wmxsdk)
|
||||
{
|
||||
GSList *iter;
|
||||
|
||||
g_static_mutex_lock (&new_callbacks_mutex);
|
||||
g_mutex_lock (&new_callbacks_mutex);
|
||||
for (iter = new_callbacks; iter; iter = g_slist_next (iter)) {
|
||||
NewSdkCallback *cb = iter->data;
|
||||
|
||||
cb->callback (wmxsdk, cb->user_data);
|
||||
}
|
||||
g_static_mutex_unlock (&new_callbacks_mutex);
|
||||
g_mutex_unlock (&new_callbacks_mutex);
|
||||
}
|
||||
|
||||
/****************************************************************/
|
||||
@@ -760,9 +760,9 @@ WIMAX_API_DEVICE_STATUS iwmxsdk_status_get(struct wmxsdk *wmxsdk)
|
||||
{
|
||||
WIMAX_API_DEVICE_STATUS status;
|
||||
|
||||
g_mutex_lock(wmxsdk->status_mutex);
|
||||
g_mutex_lock(&wmxsdk->status_mutex);
|
||||
status = wmxsdk->status;
|
||||
g_mutex_unlock(wmxsdk->status_mutex);
|
||||
g_mutex_unlock(&wmxsdk->status_mutex);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ int iwmx_sdk_connect(struct wmxsdk *wmxsdk, const char *nsp_name)
|
||||
WIMAX_API_DEVICE_STATUS dev_status;
|
||||
char sdk_name[MAX_SIZE_OF_NSP_NAME];
|
||||
|
||||
g_mutex_lock(wmxsdk->connect_mutex);
|
||||
g_mutex_lock(&wmxsdk->connect_mutex);
|
||||
/* Guess what the current radio state is; if it is ON
|
||||
* already, don't redo it. */
|
||||
dev_status = iwmxsdk_status_get(wmxsdk);
|
||||
@@ -874,7 +874,7 @@ int iwmx_sdk_connect(struct wmxsdk *wmxsdk, const char *nsp_name)
|
||||
|
||||
error_cant_do:
|
||||
error_get_status:
|
||||
g_mutex_unlock(wmxsdk->connect_mutex);
|
||||
g_mutex_unlock(&wmxsdk->connect_mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -924,7 +924,7 @@ int iwmx_sdk_disconnect(struct wmxsdk *wmxsdk)
|
||||
UINT32 errstr_size = sizeof(errstr);
|
||||
WIMAX_API_DEVICE_STATUS dev_status;
|
||||
|
||||
g_mutex_lock(wmxsdk->connect_mutex);
|
||||
g_mutex_lock(&wmxsdk->connect_mutex);
|
||||
/* Guess what the current radio state is; if it is ON
|
||||
* already, don't redo it. */
|
||||
dev_status = iwmx_sdk_get_device_status(wmxsdk);
|
||||
@@ -964,7 +964,7 @@ int iwmx_sdk_disconnect(struct wmxsdk *wmxsdk)
|
||||
result = -EINPROGRESS;
|
||||
error_cant_do:
|
||||
error_get_status:
|
||||
g_mutex_unlock(wmxsdk->connect_mutex);
|
||||
g_mutex_unlock(&wmxsdk->connect_mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1024,10 +1024,10 @@ static void __iwmx_sdk_state_change_cb(WIMAX_API_DEVICE_ID *device_id,
|
||||
status, iwmx_sdk_dev_status_to_str (status),
|
||||
reason, iwmx_sdk_reason_to_str (reason));
|
||||
|
||||
g_mutex_lock(wmxsdk->status_mutex);
|
||||
g_mutex_lock(&wmxsdk->status_mutex);
|
||||
old_status = wmxsdk->status;
|
||||
wmxsdk->status = status;
|
||||
g_mutex_unlock(wmxsdk->status_mutex);
|
||||
g_mutex_unlock(&wmxsdk->status_mutex);
|
||||
|
||||
_schedule_state_change(wmxsdk, status, old_status, reason, pi);
|
||||
}
|
||||
@@ -1044,9 +1044,9 @@ static void __iwmx_sdk_scan_common_cb(WIMAX_API_DEVICE_ID *device_id,
|
||||
{
|
||||
struct wmxsdk *wmxsdk = deviceid_to_wmxsdk(device_id);
|
||||
|
||||
g_static_mutex_lock(&wmxsdk->network_mutex);
|
||||
g_mutex_lock(&wmxsdk->network_mutex);
|
||||
_schedule_scan_result(wmxsdk, nsp_list, nsp_list_size);
|
||||
g_static_mutex_unlock(&wmxsdk->network_mutex);
|
||||
g_mutex_unlock(&wmxsdk->network_mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1210,9 +1210,9 @@ static int iwmx_sdk_setup(struct wmxsdk *wmxsdk)
|
||||
if ((int) status < 0)
|
||||
status = WIMAX_API_DEVICE_STATUS_UnInitialized;
|
||||
|
||||
g_mutex_lock(wmxsdk->status_mutex);
|
||||
g_mutex_lock(&wmxsdk->status_mutex);
|
||||
wmxsdk->status = status;
|
||||
g_mutex_unlock(wmxsdk->status_mutex);
|
||||
g_mutex_unlock(&wmxsdk->status_mutex);
|
||||
|
||||
_schedule_state_change(wmxsdk,
|
||||
status,
|
||||
@@ -1286,14 +1286,12 @@ static struct wmxsdk *wmxsdk_new(void)
|
||||
memset(wmxsdk, 0, sizeof(*wmxsdk));
|
||||
|
||||
wmxsdk->refcount = 1;
|
||||
g_static_mutex_init(&wmxsdk->network_mutex);
|
||||
g_mutex_init(&wmxsdk->network_mutex);
|
||||
|
||||
wmxsdk->status = WIMAX_API_DEVICE_STATUS_UnInitialized;
|
||||
wmxsdk->status_mutex = g_mutex_new();
|
||||
g_assert(wmxsdk->status_mutex);
|
||||
g_mutex_init(&wmxsdk->status_mutex);
|
||||
|
||||
wmxsdk->connect_mutex = g_mutex_new();
|
||||
g_assert(wmxsdk->connect_mutex);
|
||||
g_mutex_init(&wmxsdk->connect_mutex);
|
||||
}
|
||||
return wmxsdk;
|
||||
}
|
||||
@@ -1307,8 +1305,8 @@ struct wmxsdk *wmxsdk_ref(struct wmxsdk *wmxsdk)
|
||||
void wmxsdk_unref(struct wmxsdk *wmxsdk)
|
||||
{
|
||||
if (g_atomic_int_dec_and_test(&wmxsdk->refcount)) {
|
||||
g_mutex_free(wmxsdk->status_mutex);
|
||||
g_mutex_free(wmxsdk->connect_mutex);
|
||||
g_mutex_clear(&wmxsdk->status_mutex);
|
||||
g_mutex_clear(&wmxsdk->connect_mutex);
|
||||
memset(wmxsdk, 0, sizeof(*wmxsdk));
|
||||
free(wmxsdk);
|
||||
}
|
||||
@@ -1394,7 +1392,7 @@ static void iwmx_sdk_addremove_cb(WIMAX_API_DEVICE_ID *devid,
|
||||
char errstr[512];
|
||||
UINT32 errstr_size = sizeof(errstr);
|
||||
|
||||
g_static_mutex_lock(&add_remove_mutex);
|
||||
g_mutex_lock(&add_remove_mutex);
|
||||
|
||||
nm_log_dbg(LOGD_WIMAX, "cb: handle %u index #%u is %d", devid->sdkHandle,
|
||||
devid->deviceIndex, presence);
|
||||
@@ -1438,7 +1436,7 @@ static void iwmx_sdk_addremove_cb(WIMAX_API_DEVICE_ID *devid,
|
||||
}
|
||||
|
||||
out:
|
||||
g_static_mutex_unlock(&add_remove_mutex);
|
||||
g_mutex_unlock(&add_remove_mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -64,13 +64,13 @@ struct wmxsdk {
|
||||
WimaxRemovedFunc removed_cb;
|
||||
void *callback_data;
|
||||
|
||||
GStaticMutex network_mutex;
|
||||
GMutex network_mutex;
|
||||
|
||||
WIMAX_API_DEVICE_STATUS status;
|
||||
WIMAX_API_MEDIA_STATUS media_status;
|
||||
GMutex *status_mutex;
|
||||
GMutex status_mutex;
|
||||
|
||||
GMutex *connect_mutex;
|
||||
GMutex connect_mutex;
|
||||
|
||||
char name[100];
|
||||
char ifname[16];
|
||||
|
Reference in New Issue
Block a user