diff options
-rw-r--r-- | docs/Makefile.am | 22 | ||||
-rw-r--r-- | docs/xdg-hostname-1-docs.xml (renamed from docs/xdg-hostname-docs.xml) | 0 | ||||
-rw-r--r-- | docs/xdg-hostname-1-sections.txt | 43 | ||||
-rw-r--r-- | docs/xdg-hostname-1.types | 2 | ||||
-rw-r--r-- | src/xdg-hostname/xdg-hostname-monitor.c | 294 | ||||
-rw-r--r-- | src/xdg-hostname/xdg-hostname-monitor.h | 132 |
6 files changed, 324 insertions, 169 deletions
diff --git a/docs/Makefile.am b/docs/Makefile.am index e95ccdf..8b820a2 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -6,10 +6,10 @@ NULL = AUTOMAKE_OPTIONS = 1.7 # The name of the module. -DOC_MODULE=xdg-hostname +DOC_MODULE=xdg-hostname-1 # The top-level SGML file. -DOC_MAIN_SGML_FILE=xdg-hostname-docs.xml +DOC_MAIN_SGML_FILE=xdg-hostname-1-docs.xml # Extra options to supply to gtkdoc-scan SCAN_OPTIONS=--ignore-headers=config.h @@ -74,6 +74,24 @@ if ENABLE_GTK_DOC include $(top_srcdir)/gtk-doc.make else EXTRA_DIST = +CLEANFILES = endif EXTRA_DIST += version.xml.in + +CLEANFILES += *~ \ + xdg-hostname-1-scan.* \ + xdg-hostname-1.args \ + xdg-hostname-1.hierarchy \ + xdg-hostname-1.interfaces \ + xdg-hostname-1.prerequisites \ + xdg-hostname-1.signals \ + *.bak \ + xdg-hostname-1-decl-list.txt \ + xdg-hostname-1-decl.txt \ + xdg-hostname-1-overrides.txt \ + xdg-hostname-1-undeclared.txt \ + xdg-hostname-1-undocumented.txt \ + *.stamp \ + -rf html xml \ + $(NULL) diff --git a/docs/xdg-hostname-docs.xml b/docs/xdg-hostname-1-docs.xml index 8857b4f..8857b4f 100644 --- a/docs/xdg-hostname-docs.xml +++ b/docs/xdg-hostname-1-docs.xml diff --git a/docs/xdg-hostname-1-sections.txt b/docs/xdg-hostname-1-sections.txt new file mode 100644 index 0000000..92d353f --- /dev/null +++ b/docs/xdg-hostname-1-sections.txt @@ -0,0 +1,43 @@ +<SECTION> +<FILE>xdg-hostname-monitor</FILE> +XdgHostnameMonitor +xdg_hostname_monitor_get +xdg_hostname_monitor_get_display_hostname +xdg_hostname_monitor_get_hostname +xdg_hostname_monitor_get_icon_name +xdg_hostname_monitor_get_use_transient_data +xdg_hostname_monitor_set_display_hostname +xdg_hostname_monitor_set_display_hostname_finish +xdg_hostname_monitor_set_hostname +xdg_hostname_monitor_set_hostname_finish +xdg_hostname_monitor_set_icon_name +xdg_hostname_monitor_set_icon_name_finish +xdg_hostname_monitor_set_use_transient_data +xdg_hostname_monitor_set_use_transient_data_finish +xdg_hostname_monitor_set_display_hostname_sync +xdg_hostname_monitor_set_hostname_sync +xdg_hostname_monitor_set_icon_name_sync +xdg_hostname_monitor_set_use_transient_data_sync +xdg_hostname_monitor_get_configured_display_hostname +xdg_hostname_monitor_get_configured_hostname +xdg_hostname_monitor_get_configured_icon_name +xdg_hostname_monitor_get_transient_display_hostname +xdg_hostname_monitor_get_transient_hostname +xdg_hostname_monitor_get_transient_icon_name +<SUBSECTION Standard> +XDG_HOSTNAME_MONITOR +XDG_IS_HOSTNAME_MONITOR +XDG_TYPE_HOSTNAME_MONITOR +xdg_hostname_monitor_get_type +XDG_HOSTNAME_MONITOR_CLASS +XDG_IS_HOSTNAME_MONITOR_CLASS +XDG_HOSTNAME_MONITOR_GET_CLASS +</SECTION> + +<SECTION> +<FILE>xdg-hostname-error</FILE> +XDG_HOSTNAME_TYPE_ERROR +XDG_HOSTNAME_ERROR +XdgHostnameErrorEnum +</SECTION> + diff --git a/docs/xdg-hostname-1.types b/docs/xdg-hostname-1.types new file mode 100644 index 0000000..656fd76 --- /dev/null +++ b/docs/xdg-hostname-1.types @@ -0,0 +1,2 @@ +xdg_hostname_error_get_type +xdg_hostname_monitor_get_type diff --git a/src/xdg-hostname/xdg-hostname-monitor.c b/src/xdg-hostname/xdg-hostname-monitor.c index 1900510..52fd118 100644 --- a/src/xdg-hostname/xdg-hostname-monitor.c +++ b/src/xdg-hostname/xdg-hostname-monitor.c @@ -43,19 +43,19 @@ struct _XdgHostnameMonitor { GObject parent_instance; - char *display_hostname; - char *hostname; - char *icon_name; + gchar *display_hostname; + gchar *hostname; + gchar *icon_name; - char *configured_display_hostname; - char *configured_hostname; - char *configured_icon_name; + gchar *configured_display_hostname; + gchar *configured_hostname; + gchar *configured_icon_name; gboolean use_transient_data; - char *transient_display_hostname; - char *transient_hostname; - char *transient_icon_name; + gchar *transient_display_hostname; + gchar *transient_hostname; + gchar *transient_icon_name; DBusGProxy *proxy; DBusGProxy *prop_proxy; @@ -65,7 +65,7 @@ struct _XdgHostnameMonitorClass { GObjectClass parent_class; - void (* changed) (XdgHostnameMonitor *hostname_monitor); + void (* changed) (XdgHostnameMonitor *monitor); }; enum { @@ -97,42 +97,42 @@ G_DEFINE_TYPE (XdgHostnameMonitor, xdg_hostname_monitor, G_TYPE_OBJECT); static void xdg_hostname_monitor_finalize (GObject *object) { - XdgHostnameMonitor *hostname_monitor; + XdgHostnameMonitor *monitor; - hostname_monitor = XDG_HOSTNAME_MONITOR (object); + monitor = XDG_HOSTNAME_MONITOR (object); - if (hostname_monitor->proxy != NULL) - g_object_unref (hostname_monitor->proxy); - if (hostname_monitor->prop_proxy != NULL) - g_object_unref (hostname_monitor->prop_proxy); + if (monitor->proxy != NULL) + g_object_unref (monitor->proxy); + if (monitor->prop_proxy != NULL) + g_object_unref (monitor->prop_proxy); - g_free (hostname_monitor->display_hostname); - g_free (hostname_monitor->hostname); - g_free (hostname_monitor->icon_name); + g_free (monitor->display_hostname); + g_free (monitor->hostname); + g_free (monitor->icon_name); - g_free (hostname_monitor->configured_display_hostname); - g_free (hostname_monitor->configured_hostname); - g_free (hostname_monitor->configured_icon_name); + g_free (monitor->configured_display_hostname); + g_free (monitor->configured_hostname); + g_free (monitor->configured_icon_name); - g_free (hostname_monitor->transient_display_hostname); - g_free (hostname_monitor->transient_hostname); - g_free (hostname_monitor->transient_icon_name); + g_free (monitor->transient_display_hostname); + g_free (monitor->transient_hostname); + g_free (monitor->transient_icon_name); G_OBJECT_CLASS (xdg_hostname_monitor_parent_class)->finalize (object); } static void -xdg_hostname_monitor_init (XdgHostnameMonitor *hostname_monitor) +xdg_hostname_monitor_init (XdgHostnameMonitor *monitor) { } static void xdg_hostname_monitor_constructed (GObject *object) { - XdgHostnameMonitor *hostname_monitor; + XdgHostnameMonitor *monitor; - hostname_monitor = XDG_HOSTNAME_MONITOR (object); + monitor = XDG_HOSTNAME_MONITOR (object); if (G_OBJECT_CLASS (xdg_hostname_monitor_parent_class)->constructed != NULL) G_OBJECT_CLASS (xdg_hostname_monitor_parent_class)->constructed (object); @@ -144,51 +144,51 @@ xdg_hostname_monitor_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - XdgHostnameMonitor *hostname_monitor; + XdgHostnameMonitor *monitor; g_return_if_fail (XDG_IS_HOSTNAME_MONITOR (object)); - hostname_monitor = XDG_HOSTNAME_MONITOR (object); + monitor = XDG_HOSTNAME_MONITOR (object); switch (prop_id) { case PROP_DISPLAY_HOSTNAME: - g_value_set_string (value, hostname_monitor->display_hostname); + g_value_set_string (value, monitor->display_hostname); break; case PROP_HOSTNAME: - g_value_set_string (value, hostname_monitor->hostname); + g_value_set_string (value, monitor->hostname); break; case PROP_ICON_NAME: - g_value_set_string (value, hostname_monitor->icon_name); + g_value_set_string (value, monitor->icon_name); break; case PROP_CONFIGURED_DISPLAY_HOSTNAME: - g_value_set_string (value, hostname_monitor->configured_display_hostname); + g_value_set_string (value, monitor->configured_display_hostname); break; case PROP_CONFIGURED_HOSTNAME: - g_value_set_string (value, hostname_monitor->configured_hostname); + g_value_set_string (value, monitor->configured_hostname); break; case PROP_CONFIGURED_ICON_NAME: - g_value_set_string (value, hostname_monitor->configured_icon_name); + g_value_set_string (value, monitor->configured_icon_name); break; case PROP_USE_TRANSIENT_DATA: - g_value_set_boolean (value, hostname_monitor->use_transient_data); + g_value_set_boolean (value, monitor->use_transient_data); break; case PROP_TRANSIENT_DISPLAY_HOSTNAME: - g_value_set_string (value, hostname_monitor->transient_display_hostname); + g_value_set_string (value, monitor->transient_display_hostname); break; case PROP_TRANSIENT_HOSTNAME: - g_value_set_string (value, hostname_monitor->transient_hostname); + g_value_set_string (value, monitor->transient_hostname); break; case PROP_TRANSIENT_ICON_NAME: - g_value_set_string (value, hostname_monitor->transient_icon_name); + g_value_set_string (value, monitor->transient_icon_name); break; default: @@ -208,9 +208,9 @@ xdg_hostname_monitor_class_init (XdgHostnameMonitorClass *klass) /** * XdgHostnameMonitor::changed: - * @hostname_monitor: a #XdgHostnameMonitor. + * @monitor: a #XdgHostnameMonitor. * - * Emitted when something on @hostname_monitor changes. + * Emitted when something on @monitor changes. */ signals[CHANGED_SIGNAL] = g_signal_new ("changed", XDG_TYPE_HOSTNAME_MONITOR, @@ -305,25 +305,14 @@ xdg_hostname_monitor_class_init (XdgHostnameMonitorClass *klass) /* ---------------------------------------------------------------------------------------------------- */ -static int -safe_strcmp (const char *a, const char *b) -{ - if (a == NULL) - a = ""; - if (b == NULL) - b = ""; - - return strcmp (a, b); -} - static gboolean glob_changed; -#define SET_STRING(member, propname) do {gboolean c = safe_strcmp (h-> member, g_value_get_string (value)) == 0; g_free (h-> member); h-> member = g_strdup (g_value_get_string (value)); if (c) {g_object_notify (G_OBJECT (h), propname); glob_changed = TRUE;}} while (FALSE); +#define SET_STRING(member, propname) do {gboolean c = g_strcmp0 (h-> member, g_value_get_string (value)) == 0; g_free (h-> member); h-> member = g_strdup (g_value_get_string (value)); if (c) {g_object_notify (G_OBJECT (h), propname); glob_changed = TRUE;}} while (FALSE); #define SET_BOOL(member, propname) do {gboolean c = (h-> member != g_value_get_boolean (value)); h-> member = g_value_get_boolean (value); if (c) {g_object_notify (G_OBJECT (h), propname); glob_changed = TRUE;}} while (FALSE); static void -collect_props (const char *key, const GValue *value, XdgHostnameMonitor *h) +collect_props (const gchar *key, const GValue *value, XdgHostnameMonitor *h) { gboolean handled; @@ -368,13 +357,13 @@ collect_props (const char *key, const GValue *value, XdgHostnameMonitor *h) } static void -update_props (XdgHostnameMonitor *hostname_monitor) +update_props (XdgHostnameMonitor *monitor) { GError *error; GHashTable *hash_table; error = NULL; - if (!dbus_g_proxy_call (hostname_monitor->prop_proxy, + if (!dbus_g_proxy_call (monitor->prop_proxy, "GetAll", &error, G_TYPE_STRING, @@ -388,10 +377,10 @@ update_props (XdgHostnameMonitor *hostname_monitor) goto out; } - g_hash_table_foreach (hash_table, (GHFunc) collect_props, hostname_monitor); + g_hash_table_foreach (hash_table, (GHFunc) collect_props, monitor); if (glob_changed) - g_signal_emit (hostname_monitor, signals[CHANGED_SIGNAL], 0); + g_signal_emit (monitor, signals[CHANGED_SIGNAL], 0); g_hash_table_unref (hash_table); out: @@ -400,42 +389,42 @@ update_props (XdgHostnameMonitor *hostname_monitor) static void hostname_monitor_changed_cb (DBusGProxy *proxy, - XdgHostnameMonitor *hostname_monitor) + XdgHostnameMonitor *monitor) { - update_props (hostname_monitor); + update_props (monitor); } static XdgHostnameMonitor * _xdg_hostname_monitor_new (DBusGConnection *connection, - const char *service_name, - const char *object_path) + const gchar *service_name, + const gchar *object_path) { - XdgHostnameMonitor *hostname_monitor; + XdgHostnameMonitor *monitor; - hostname_monitor = XDG_HOSTNAME_MONITOR (g_object_new (XDG_TYPE_HOSTNAME_MONITOR, NULL)); + monitor = XDG_HOSTNAME_MONITOR (g_object_new (XDG_TYPE_HOSTNAME_MONITOR, NULL)); - hostname_monitor->proxy = dbus_g_proxy_new_for_name (connection, + monitor->proxy = dbus_g_proxy_new_for_name (connection, service_name, object_path, "org.freedesktop.Hostname1"); - hostname_monitor->prop_proxy = dbus_g_proxy_new_for_name (connection, + monitor->prop_proxy = dbus_g_proxy_new_for_name (connection, service_name, object_path, "org.freedesktop.DBus.Properties"); - dbus_g_proxy_add_signal (hostname_monitor->proxy, + dbus_g_proxy_add_signal (monitor->proxy, "Changed", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (hostname_monitor->proxy, "Changed", - (GCallback) hostname_monitor_changed_cb, - hostname_monitor, + dbus_g_proxy_connect_signal (monitor->proxy, "Changed", + G_CALLBACK (hostname_monitor_changed_cb), + monitor, NULL); - update_props (hostname_monitor); + update_props (monitor); - return hostname_monitor; + return monitor; } /** @@ -449,12 +438,12 @@ _xdg_hostname_monitor_new (DBusGConnection *connection, XdgHostnameMonitor * xdg_hostname_monitor_get (void) { - XdgHostnameMonitor *hostname_monitor; + XdgHostnameMonitor *monitor; DBusGConnection *bus; GError *error; bus = NULL; - hostname_monitor = NULL; + monitor = NULL; error = NULL; bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); @@ -464,14 +453,14 @@ xdg_hostname_monitor_get (void) goto out; } - hostname_monitor = _xdg_hostname_monitor_new (bus, + monitor = _xdg_hostname_monitor_new (bus, "org.freedesktop.Hostname1", "/org/freedesktop/hostname1"); out: if (bus != NULL) dbus_g_connection_unref (bus); - return hostname_monitor; + return monitor; } /* ---------------------------------------------------------------------------------------------------- */ @@ -493,18 +482,20 @@ generic_async_cb (DBusGProxy *proxy, /* ---------------------------------------------------------------------------------------------------- */ gboolean -xdg_hostname_monitor_set_display_hostname_sync (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_display_hostname_sync (XdgHostnameMonitor *monitor, const gchar *display_hostname, GCancellable *cancellable, GError **error) { - return org_freedesktop_Hostname1_set_display_hostname (hostname_monitor->proxy, + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_return_val_if_fail (display_hostname != NULL, FALSE); + return org_freedesktop_Hostname1_set_display_hostname (monitor->proxy, display_hostname, error); } void -xdg_hostname_monitor_set_display_hostname (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_display_hostname (XdgHostnameMonitor *monitor, const gchar *display_hostname, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -512,23 +503,29 @@ xdg_hostname_monitor_set_display_hostname (XdgHostnameMonitor *hostname_monito { GSimpleAsyncResult *simple; - simple = g_simple_async_result_new (G_OBJECT (hostname_monitor), + g_return_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor)); + g_return_if_fail (display_hostname != NULL); + + simple = g_simple_async_result_new (G_OBJECT (monitor), callback, user_data, xdg_hostname_monitor_set_display_hostname); - org_freedesktop_Hostname1_set_display_hostname_async (hostname_monitor->proxy, + org_freedesktop_Hostname1_set_display_hostname_async (monitor->proxy, display_hostname, generic_async_cb, simple); } gboolean -xdg_hostname_monitor_set_display_hostname_finish (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_display_hostname_finish (XdgHostnameMonitor *monitor, GAsyncResult *res, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); + + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == xdg_hostname_monitor_set_display_hostname); g_simple_async_result_propagate_error (simple, error); return g_simple_async_result_get_op_res_gboolean (simple); @@ -537,18 +534,20 @@ xdg_hostname_monitor_set_display_hostname_finish (XdgHostnameMonitor *hostname_ /* ---------------------------------------------------------------------------------------------------- */ gboolean -xdg_hostname_monitor_set_hostname_sync (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_hostname_sync (XdgHostnameMonitor *monitor, const gchar *hostname, GCancellable *cancellable, GError **error) { - return org_freedesktop_Hostname1_set_hostname (hostname_monitor->proxy, + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_return_val_if_fail (hostname != NULL, FALSE); + return org_freedesktop_Hostname1_set_hostname (monitor->proxy, hostname, error); } void -xdg_hostname_monitor_set_hostname (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_hostname (XdgHostnameMonitor *monitor, const gchar *hostname, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -556,23 +555,29 @@ xdg_hostname_monitor_set_hostname (XdgHostnameMonitor *hostname_monitor, { GSimpleAsyncResult *simple; - simple = g_simple_async_result_new (G_OBJECT (hostname_monitor), + g_return_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor)); + g_return_if_fail (hostname != NULL); + + simple = g_simple_async_result_new (G_OBJECT (monitor), callback, user_data, xdg_hostname_monitor_set_hostname); - org_freedesktop_Hostname1_set_hostname_async (hostname_monitor->proxy, + org_freedesktop_Hostname1_set_hostname_async (monitor->proxy, hostname, generic_async_cb, simple); } gboolean -xdg_hostname_monitor_set_hostname_finish (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_hostname_finish (XdgHostnameMonitor *monitor, GAsyncResult *res, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); + + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == xdg_hostname_monitor_set_hostname); g_simple_async_result_propagate_error (simple, error); return g_simple_async_result_get_op_res_gboolean (simple); @@ -581,18 +586,20 @@ xdg_hostname_monitor_set_hostname_finish (XdgHostnameMonitor *hostname_monitor, /* ---------------------------------------------------------------------------------------------------- */ gboolean -xdg_hostname_monitor_set_icon_name_sync (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_icon_name_sync (XdgHostnameMonitor *monitor, const gchar *icon_name, GCancellable *cancellable, GError **error) { - return org_freedesktop_Hostname1_set_icon_name (hostname_monitor->proxy, + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_return_val_if_fail (icon_name != NULL, FALSE); + return org_freedesktop_Hostname1_set_icon_name (monitor->proxy, icon_name, error); } void -xdg_hostname_monitor_set_icon_name (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_icon_name (XdgHostnameMonitor *monitor, const gchar *icon_name, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -600,23 +607,29 @@ xdg_hostname_monitor_set_icon_name (XdgHostnameMonitor *hostname_monitor, { GSimpleAsyncResult *simple; - simple = g_simple_async_result_new (G_OBJECT (hostname_monitor), + g_return_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor)); + g_return_if_fail (icon_name != NULL); + + simple = g_simple_async_result_new (G_OBJECT (monitor), callback, user_data, xdg_hostname_monitor_set_icon_name); - org_freedesktop_Hostname1_set_icon_name_async (hostname_monitor->proxy, + org_freedesktop_Hostname1_set_icon_name_async (monitor->proxy, icon_name, generic_async_cb, simple); } gboolean -xdg_hostname_monitor_set_icon_name_finish (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_icon_name_finish (XdgHostnameMonitor *monitor, GAsyncResult *res, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); + + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == xdg_hostname_monitor_set_icon_name); g_simple_async_result_propagate_error (simple, error); return g_simple_async_result_get_op_res_gboolean (simple); @@ -625,19 +638,20 @@ xdg_hostname_monitor_set_icon_name_finish (XdgHostnameMonitor *hostname_monit /* ---------------------------------------------------------------------------------------------------- */ gboolean -xdg_hostname_monitor_set_use_transient_data_sync (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_use_transient_data_sync (XdgHostnameMonitor *monitor, gboolean use_transient_data, GCancellable *cancellable, GError **error) { - return org_freedesktop_Hostname1_set_use_transient_data (hostname_monitor->proxy, + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + return org_freedesktop_Hostname1_set_use_transient_data (monitor->proxy, use_transient_data, error); } void -xdg_hostname_monitor_set_use_transient_data (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_use_transient_data (XdgHostnameMonitor *monitor, gboolean use_transient_data, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -645,26 +659,104 @@ xdg_hostname_monitor_set_use_transient_data (XdgHostnameMonitor *hostname_moni { GSimpleAsyncResult *simple; - simple = g_simple_async_result_new (G_OBJECT (hostname_monitor), + g_return_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor)); + + simple = g_simple_async_result_new (G_OBJECT (monitor), callback, user_data, xdg_hostname_monitor_set_use_transient_data); - org_freedesktop_Hostname1_set_use_transient_data_async (hostname_monitor->proxy, + org_freedesktop_Hostname1_set_use_transient_data_async (monitor->proxy, use_transient_data, generic_async_cb, simple); } gboolean -xdg_hostname_monitor_set_use_transient_data_finish (XdgHostnameMonitor *hostname_monitor, +xdg_hostname_monitor_set_use_transient_data_finish (XdgHostnameMonitor *monitor, GAsyncResult *res, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); + + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == xdg_hostname_monitor_set_use_transient_data); g_simple_async_result_propagate_error (simple, error); return g_simple_async_result_get_op_res_gboolean (simple); } /* ---------------------------------------------------------------------------------------------------- */ + +gchar * +xdg_hostname_monitor_get_display_hostname (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->display_hostname); +} + +gchar * +xdg_hostname_monitor_get_hostname (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->hostname); +} + +gchar * +xdg_hostname_monitor_get_icon_name (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->icon_name); +} + +gboolean +xdg_hostname_monitor_get_use_transient_data (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), FALSE); + return monitor->use_transient_data; +} + +gchar * +xdg_hostname_monitor_get_configured_display_hostname (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->configured_display_hostname); +} + +gchar * +xdg_hostname_monitor_get_configured_hostname (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->configured_hostname); +} + +gchar * +xdg_hostname_monitor_get_configured_icon_name (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->configured_icon_name); +} + +gchar * +xdg_hostname_monitor_get_transient_display_hostname (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->transient_display_hostname); +} + +gchar * +xdg_hostname_monitor_get_transient_hostname (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->transient_hostname); +} + +gchar * +xdg_hostname_monitor_get_transient_icon_name (XdgHostnameMonitor *monitor) +{ + g_return_val_if_fail (XDG_IS_HOSTNAME_MONITOR (monitor), NULL); + return g_strdup (monitor->transient_icon_name); +} + + +/* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/xdg-hostname/xdg-hostname-monitor.h b/src/xdg-hostname/xdg-hostname-monitor.h index 335510b..31a585c 100644 --- a/src/xdg-hostname/xdg-hostname-monitor.h +++ b/src/xdg-hostname/xdg-hostname-monitor.h @@ -43,72 +43,72 @@ G_BEGIN_DECLS typedef struct _XdgHostnameMonitor XdgHostnameMonitor; typedef struct _XdgHostnameMonitorClass XdgHostnameMonitorClass; -GType xdg_hostname_monitor_get_type (void) G_GNUC_CONST; - -void xdg_hostname_monitor_set_display_hostname (XdgHostnameMonitor *hostname_monitor, - const gchar *display_hostname, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean xdg_hostname_monitor_set_display_hostname_finish (XdgHostnameMonitor *hostname_monitor, - GAsyncResult *res, - GError **error); - -gboolean xdg_hostname_monitor_set_display_hostname_sync (XdgHostnameMonitor *hostname_monitor, - const gchar *display_hostname, - GCancellable *cancellable, - GError **error); - - -void xdg_hostname_monitor_set_hostname (XdgHostnameMonitor *hostname_monitor, - const gchar *hostname, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean xdg_hostname_monitor_set_hostname_finish (XdgHostnameMonitor *hostname_monitor, - GAsyncResult *res, - GError **error); - -gboolean xdg_hostname_monitor_set_hostname_sync (XdgHostnameMonitor *hostname_monitor, - const gchar *hostname, - GCancellable *cancellable, - GError **error); - - -void xdg_hostname_monitor_set_icon_name (XdgHostnameMonitor *hostname_monitor, - const gchar *icon_name, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean xdg_hostname_monitor_set_icon_name_finish (XdgHostnameMonitor *hostname_monitor, - GAsyncResult *res, - GError **error); - -gboolean xdg_hostname_monitor_set_icon_name_sync (XdgHostnameMonitor *hostname_monitor, - const gchar *icon_name, - GCancellable *cancellable, - GError **error); - - -void xdg_hostname_monitor_set_use_transient_data (XdgHostnameMonitor *hostname_monitor, - gboolean use_transient_data, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean xdg_hostname_monitor_set_use_transient_data_finish (XdgHostnameMonitor *hostname_monitor, - GAsyncResult *res, - GError **error); - -gboolean xdg_hostname_monitor_set_use_transient_data_sync (XdgHostnameMonitor *hostname_monitor, - gboolean use_transient_data, - GCancellable *cancellable, - GError **error); - -XdgHostnameMonitor *xdg_hostname_monitor_get (void); +GType xdg_hostname_monitor_get_type (void) G_GNUC_CONST; +XdgHostnameMonitor *xdg_hostname_monitor_get (void); +gchar *xdg_hostname_monitor_get_display_hostname (XdgHostnameMonitor *monitor); +gchar *xdg_hostname_monitor_get_hostname (XdgHostnameMonitor *monitor); +gchar *xdg_hostname_monitor_get_icon_name (XdgHostnameMonitor *monitor); +gboolean xdg_hostname_monitor_get_use_transient_data (XdgHostnameMonitor *monitor); + +gchar *xdg_hostname_monitor_get_configured_display_hostname (XdgHostnameMonitor *monitor); +gchar *xdg_hostname_monitor_get_configured_hostname (XdgHostnameMonitor *monitor); +gchar *xdg_hostname_monitor_get_configured_icon_name (XdgHostnameMonitor *monitor); + +gchar *xdg_hostname_monitor_get_transient_display_hostname (XdgHostnameMonitor *monitor); +gchar *xdg_hostname_monitor_get_transient_hostname (XdgHostnameMonitor *monitor); +gchar *xdg_hostname_monitor_get_transient_icon_name (XdgHostnameMonitor *monitor); + +void xdg_hostname_monitor_set_display_hostname (XdgHostnameMonitor *monitor, + const gchar *display_hostname, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean xdg_hostname_monitor_set_display_hostname_finish (XdgHostnameMonitor *monitor, + GAsyncResult *res, + GError **error); +gboolean xdg_hostname_monitor_set_display_hostname_sync (XdgHostnameMonitor *monitor, + const gchar *display_hostname, + GCancellable *cancellable, + GError **error); + +void xdg_hostname_monitor_set_hostname (XdgHostnameMonitor *monitor, + const gchar *hostname, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean xdg_hostname_monitor_set_hostname_finish (XdgHostnameMonitor *monitor, + GAsyncResult *res, + GError **error); +gboolean xdg_hostname_monitor_set_hostname_sync (XdgHostnameMonitor *monitor, + const gchar *hostname, + GCancellable *cancellable, + GError **error); + +void xdg_hostname_monitor_set_icon_name (XdgHostnameMonitor *monitor, + const gchar *icon_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean xdg_hostname_monitor_set_icon_name_finish (XdgHostnameMonitor *monitor, + GAsyncResult *res, + GError **error); +gboolean xdg_hostname_monitor_set_icon_name_sync (XdgHostnameMonitor *monitor, + const gchar *icon_name, + GCancellable *cancellable, + GError **error); + +void xdg_hostname_monitor_set_use_transient_data (XdgHostnameMonitor *monitor, + gboolean use_transient_data, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean xdg_hostname_monitor_set_use_transient_data_finish (XdgHostnameMonitor *monitor, + GAsyncResult *res, + GError **error); +gboolean xdg_hostname_monitor_set_use_transient_data_sync (XdgHostnameMonitor *monitor, + gboolean use_transient_data, + GCancellable *cancellable, + GError **error); G_END_DECLS |