aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-08-13 14:16:32 -0400
committerJason Woodward2019-08-14 17:11:31 -0400
commite4d2c1897850a4e69cfb34fc675565584dfd766b (patch)
treef46fcd8911059f9f2afcab7cd345fa2d5ddd972f
parent0dba320321309295015f6353220a8a5e4749a21f (diff)
downloadslapt-update-service-e4d2c1897850a4e69cfb34fc675565584dfd766b.tar.gz
gdbus port
-rw-r--r--config.h.in8
-rw-r--r--configure.ac5
-rw-r--r--slack-required1
-rw-r--r--src/Makefile.am18
-rw-r--r--src/client.c126
-rw-r--r--src/server.c135
-rw-r--r--src/slapt-service.xml5
-rw-r--r--src/slaptService.c1232
-rw-r--r--src/slaptService.h221
9 files changed, 1464 insertions, 287 deletions
diff --git a/config.h.in b/config.h.in
index b08eeca..ed2c10f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -24,14 +24,6 @@
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#undef HAVE_BIND_TEXTDOMAIN_CODESET
-/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
- CoreFoundation framework. */
-#undef HAVE_CFLOCALECOPYCURRENT
-
-/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
- the CoreFoundation framework. */
-#undef HAVE_CFPREFERENCESCOPYAPPVALUE
-
/* Define to 1 if you have the `dcgettext' function. */
#undef HAVE_DCGETTEXT
diff --git a/configure.ac b/configure.ac
index 8e877eb..4e9a1d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,12 +38,9 @@ AC_CHECK_LIB(gpgme,gpgme_new, [
], [AC_MSG_WARN(gpg support disabled)])
AC_CHECK_LIB(slapt,slapt_vector_t_init, [], [AC_MSG_ERROR(libslapt 0.11.1 or greater is required)])
-PKG_CHECK_MODULES(GLIB, [glib-2.0 gobject-2.0 gthread-2.0])
+PKG_CHECK_MODULES(GLIB, [glib-2.0 gobject-2.0 gthread-2.0 gio-2.0 gio-unix-2.0])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
-PKG_CHECK_MODULES(DBUS, [dbus-1 dbus-glib-1])
-AC_SUBST(DBUS_CFLAGS)
-AC_SUBST(DBUS_LIBS)
gtk2_modules="gtk+-2.0 >= 2.24.0"
gtk3_modules="gtk+-3.0 >= 3.4.0"
diff --git a/slack-required b/slack-required
index 05d22d3..151fcd3 100644
--- a/slack-required
+++ b/slack-required
@@ -1,5 +1,4 @@
gtk+2
-dbus-glib
libnotify
gslapt
libgnomesu | gksu | kdesu
diff --git a/src/Makefile.am b/src/Makefile.am
index d9b24db..10a77ae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,24 +1,16 @@
bin_PROGRAMS = slapt-update-notifier
sbin_PROGRAMS = slaptService
slaptService_SOURCES = server.c slaptService.c slaptService.h common.h
-slaptService_LDADD = $(GLIB_LIBS) $(DBUS_LIBS)
-slaptService_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS)
+slaptService_LDADD = $(GLIB_LIBS)
+slaptService_CPPFLAGS = $(GLIB_CFLAGS)
slapt_update_notifier_SOURCES = client.c slaptService.c slaptService.h common.h
-slapt_update_notifier_LDADD = $(GLIB_LIBS) $(DBUS_LIBS) $(GTK_LIBS) $(NOTIFY_LIBS)
-slapt_update_notifier_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) $(GTK_CFLAGS) $(NOTIFY_CFLAGS)
+slapt_update_notifier_LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(NOTIFY_LIBS)
+slapt_update_notifier_CPPFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) $(NOTIFY_CFLAGS)
-BUILT_SOURCES = server-bindings.h client-bindings.h
+BUILT_SOURCES =
# We don't want to install this header
noinst_HEADERS = $(BUILT_SOURCES)
# Correctly clean the generated headers, but keep the xml description
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = slapt-service.xml
-
-#Rule to generate the binding headers
-server-bindings.h: slapt-service.xml
- dbus-binding-tool --prefix=slapt_service --mode=glib-server $<> $@
-
-client-bindings.h: slapt-service.xml
- dbus-binding-tool --prefix=slapt_service --mode=glib-client $<> $@
-
diff --git a/src/client.c b/src/client.c
index 4bd7728..77b2d87 100644
--- a/src/client.c
+++ b/src/client.c
@@ -18,7 +18,7 @@
#include <config.h>
#endif
-#include "client-bindings.h"
+#include "slaptService.h"
#include "common.h"
#include <libintl.h>
#include <stdio.h>
@@ -33,7 +33,8 @@
#define _(x) gettext(x)
#define SUN_RUNNING_ICON PIXMAPS_DIR "/slapt-update-notifier-idle.png"
#define SUN_UPDATE_ICON PIXMAPS_DIR "/slapt-update-notifier-update.png"
-#define SUN_TIMEOUT_RECHECK 14400000 /* 1000*(4*60*60), 4 hours */
+#define SUN_TIMEOUT_RECHECK 3600000 /* 1000*(1*60*60), 1 hour */
+#define SUN_TIMEOUT_DBUS 300000 /* 1000*(1*5*60), 5 minutes */
#define NOTIFICATION_DEFAULT "default"
#define NOTIFICATION_IGNORE "ignore"
#define NOTIFICATION_SHOW_UPDATES "show updates"
@@ -43,8 +44,7 @@ struct slapt_update_notifier {
GdkPixbuf *running_pixbuf;
GdkPixbuf *updates_pixbuf;
GtkWidget *menu;
- DBusGConnection *bus;
- DBusGProxy *proxy;
+ SlaptService *proxy;
};
static struct slapt_update_notifier *sun = NULL;
@@ -102,8 +102,6 @@ void tray_menu(GtkStatusIcon *status_icon, guint button, guint activate_time, gp
#ifdef USE_LIBNOTIFY
static void notify_callback(NotifyNotification *handle, const char *action, void *user_data)
{
- GMainLoop *loop = (GMainLoop *)user_data;
-
if (strcmp(action, NOTIFICATION_SHOW_UPDATES) == 0) {
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_hide(GTK_WIDGET(sun->tray_icon));
@@ -120,9 +118,6 @@ static void notify_callback(NotifyNotification *handle, const char *action, void
g_error_free(error);
}
}
-
- if (loop != NULL)
- g_main_loop_quit(loop);
}
gboolean show_notification(gpointer data)
@@ -153,19 +148,15 @@ void tray_destroy(struct slapt_update_notifier *sun)
if (sun->running_pixbuf)
g_object_unref(G_OBJECT(sun->running_pixbuf));
- gtk_widget_destroy(GTK_WIDGET(sun->tray_icon));
+ g_object_unref(G_OBJECT(sun->tray_icon));
}
static void hide_sun(void)
{
-#ifdef USE_LIBNOTIFY
- NotifyNotification *n = g_object_get_data(G_OBJECT(sun->tray_icon), "notification");
-#endif
- GMainLoop *loop = g_object_get_data(G_OBJECT(sun->tray_icon), "notification_loop");
-
gtk_status_icon_set_visible(sun->tray_icon, FALSE);
#ifdef USE_LIBNOTIFY
+ NotifyNotification *n = g_object_get_data(G_OBJECT(sun->tray_icon), "notification");
if (n != NULL) {
GError *error = NULL;
if (notify_notification_close(n, &error) != TRUE) {
@@ -174,9 +165,6 @@ static void hide_sun(void)
}
}
#endif
-
- if (loop != NULL)
- g_main_loop_quit(loop);
}
void menuitem_hide_callback(GObject *g, void *data)
@@ -184,99 +172,93 @@ void menuitem_hide_callback(GObject *g, void *data)
hide_sun();
}
-static void check_for_updates_callback(DBusGProxy *proxy, guint OUT_count, GError *error, gpointer userdata)
-{
- if (OUT_count == 0)
- return;
-
- if (error != NULL) {
- g_warning("check for updates failed: %s",
- error->message);
- g_error_free(error);
- }
-
- gtk_status_icon_set_visible(sun->tray_icon, TRUE);
-#ifdef USE_LIBNOTIFY
- show_notification(NULL);
-#endif
-}
-
-static void refresh_cache_callback(DBusGProxy *proxy, GError *error, gpointer userdata)
-{
- if (error != NULL) {
- g_warning("refresh cache failed: %s",
- error->message);
- g_error_free(error);
- }
-
- /* unset working icon */
- gtk_status_icon_set_visible(sun->tray_icon, FALSE);
- gtk_status_icon_set_from_pixbuf(sun->tray_icon, sun->updates_pixbuf);
-}
-
static gboolean check_for_updates(gpointer userdata)
{
- DBusGProxy *proxy = (DBusGProxy *)((struct slapt_update_notifier *)userdata)->proxy;
+ gboolean callback_complete = TRUE;
+ if (userdata != NULL)
+ callback_complete = FALSE;
/* set working icon */
gtk_status_icon_set_from_pixbuf(sun->tray_icon, sun->running_pixbuf);
gtk_status_icon_set_visible(sun->tray_icon, TRUE);
- org_jaos_SlaptService_refresh_cache_async(proxy, refresh_cache_callback, NULL);
- org_jaos_SlaptService_check_for_updates_async(proxy, check_for_updates_callback, NULL);
+ GError *refresh_error = NULL;
+ gboolean r = slapt_service_call_refresh_cache_sync(sun->proxy, NULL, &refresh_error);
+ if (!r) {
+ g_warning("refresh cache failed: %s", refresh_error->message);
+ g_error_free(refresh_error);
+ gtk_status_icon_set_visible(sun->tray_icon, FALSE);
+ return callback_complete;
+ }
+
+ GError *updates_error = NULL;
+ guint count = 0;
+ r = slapt_service_call_check_for_updates_sync(sun->proxy, &count, NULL, &updates_error);
+ if (!r) {
+ g_warning("check for updates failed: %s", updates_error->message);
+ g_error_free(updates_error);
+ return callback_complete;
+ }
+ if (count > 0) {
+ gtk_status_icon_set_from_pixbuf(sun->tray_icon, sun->updates_pixbuf);
+ gtk_status_icon_set_visible(sun->tray_icon, TRUE);
+#ifdef USE_LIBNOTIFY
+ show_notification(NULL);
+#endif
+ } else {
+ gtk_status_icon_set_visible(sun->tray_icon, FALSE);
+ }
+ return callback_complete;
}
int main(int argc, char *argv[])
{
- GError *error = NULL;
- guint count;
- GtkWidget *menuitem = NULL;
-
gtk_init(&argc, &argv);
#ifdef USE_LIBNOTIFY
notify_init("slapt-update-notifier");
#endif
sun = malloc(sizeof *sun);
- sun->tray_icon = gtk_status_icon_new();
sun->updates_pixbuf = gdk_pixbuf_new_from_file(SUN_UPDATE_ICON, NULL);
sun->running_pixbuf = gdk_pixbuf_new_from_file(SUN_RUNNING_ICON, NULL);
- gtk_status_icon_set_from_pixbuf(sun->tray_icon, sun->updates_pixbuf);
+ sun->tray_icon = gtk_status_icon_new_from_pixbuf(sun->running_pixbuf);
#if GTK_CHECK_VERSION(3,0,0)
gtk_status_icon_set_tooltip_text(sun->tray_icon, _("Updates available"));
#else
gtk_status_icon_set_tooltip(sun->tray_icon, _("Updates available"));
#endif
- gtk_status_icon_set_visible(sun->tray_icon, FALSE);
g_signal_connect(G_OBJECT(sun->tray_icon), "activate", G_CALLBACK(tray_clicked), &sun);
g_signal_connect(G_OBJECT(sun->tray_icon), "popup-menu", G_CALLBACK(tray_menu), &sun);
+ gtk_status_icon_set_visible(sun->tray_icon, TRUE);
sun->menu = gtk_menu_new();
- menuitem = gtk_menu_item_new_with_label(_("Hide"));
+ GtkWidget *menuitem = gtk_menu_item_new_with_label(_("Hide"));
gtk_menu_shell_append(GTK_MENU_SHELL(sun->menu), menuitem);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menuitem_hide_callback), sun);
gtk_widget_show_all(sun->menu);
- sun->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
- if (sun->bus == NULL) {
- g_warning("Failed to make connection to system bus: %s",
- error->message);
+ GError *error = NULL;
+ sun->proxy = slapt_service_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
+ SLAPT_SERVICE_NAMESPACE, SLAPT_SERVICE_PATH, NULL, &error);
+ if (!sun->proxy) {
+ g_warning("Failed to initialize DBUS proxy: %s", error->message);
g_error_free(error);
- exit(1);
+ tray_destroy(sun);
+ free(sun);
+#ifdef USE_LIBNOTIFY
+ notify_uninit();
+#endif
+ return -1;
}
+ g_dbus_proxy_set_default_timeout(sun->proxy, SUN_TIMEOUT_DBUS);
- sun->proxy = dbus_g_proxy_new_for_name(sun->bus, "org.jaos.SlaptService", "/org/jaos/SlaptService",
- "org.jaos.SlaptService");
-
- check_for_updates((gpointer)sun);
-
- g_timeout_add(SUN_TIMEOUT_RECHECK, (GSourceFunc)check_for_updates, sun);
-
+ gboolean run_once = TRUE;
+ g_idle_add((GSourceFunc)check_for_updates, &run_once);
+ g_timeout_add(SUN_TIMEOUT_RECHECK, (GSourceFunc)check_for_updates, NULL);
gtk_main();
tray_destroy(sun);
- g_object_unref(sun->proxy);
free(sun);
#ifdef USE_LIBNOTIFY
diff --git a/src/server.c b/src/server.c
index 87f063e..c69e2a9 100644
--- a/src/server.c
+++ b/src/server.c
@@ -22,18 +22,101 @@
#include <string.h>
#include <glib.h>
#include <syslog.h>
+#include <slapt.h>
-static GMainLoop *loop;
+static gboolean handle_refresh_cache(SlaptService *srv, GDBusMethodInvocation *meth, gpointer user_data)
+{
+ slapt_config_t *rc = slapt_config_t_read(SLAPT_SERVICE_DEFAULT_RC);
+ slapt_working_dir_init(rc);
+ if ((chdir(rc->working_dir)) == -1) {
+ slapt_config_t_free(rc);
+ return TRUE;
+ }
+
+ if (slapt_update_pkg_cache(rc) != 0) {
+ slapt_config_t_free(rc);
+ return TRUE;
+ }
+
+ slapt_config_t_free(rc);
+ slapt_service_complete_refresh_cache(srv, meth);
+ return TRUE;
+}
+
+static gboolean handle_check_for_updates(SlaptService *srv, GDBusMethodInvocation *meth, gpointer user_data)
+{
+ guint count = 0;
+ slapt_config_t *rc = slapt_config_t_read(SLAPT_SERVICE_DEFAULT_RC);
+ slapt_working_dir_init(rc);
+ if ((chdir(rc->working_dir)) == -1) {
+ slapt_config_t_free(rc);
+ return TRUE;
+ }
+
+ slapt_vector_t *installed_pkgs = slapt_get_installed_pkgs();
+ slapt_vector_t *avail_pkgs = slapt_get_available_pkgs();
+ if (avail_pkgs == NULL || installed_pkgs == NULL)
+ goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+ if (avail_pkgs->size == 0)
+ goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+
+ slapt_transaction_t *tran = slapt_init_transaction();
+ if (tran == NULL)
+ goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+
+ slapt_vector_t_foreach(slapt_pkg_t *, installed_pkg, installed_pkgs) {
+ slapt_pkg_t *update_pkg = NULL;
+ slapt_pkg_t *newer_installed_pkg = NULL;
+ if (slapt_is_excluded(rc, installed_pkg))
+ continue;
+ if ((newer_installed_pkg = slapt_get_newest_pkg(installed_pkgs, installed_pkg->name)) != NULL) {
+ if (slapt_cmp_pkgs(installed_pkg, newer_installed_pkg) < 0)
+ continue;
+ }
+ update_pkg = slapt_get_newest_pkg(avail_pkgs, installed_pkg->name);
+ if (update_pkg != NULL) {
+ if (slapt_cmp_pkgs(installed_pkg, update_pkg) < 0) {
+ if (slapt_is_excluded(rc, update_pkg))
+ continue;
+ if (slapt_add_deps_to_trans(rc, tran, avail_pkgs, installed_pkgs, update_pkg) == 0)
+ slapt_add_upgrade_to_transaction(tran, installed_pkg, update_pkg);
+ } /* end if newer */
+ } /* end upgrade pkg found */
+ } /* end for installed_pkgs */
+
+ /* count includes new installed as well as package upgrades */
+ count += tran->upgrade_pkgs->size + tran->install_pkgs->size;
+
+SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE:
+ if (installed_pkgs != NULL)
+ slapt_vector_t_free(installed_pkgs);
+ if (avail_pkgs != NULL)
+ slapt_vector_t_free(avail_pkgs);
+ if (tran != NULL)
+ slapt_free_transaction(tran);
+ if (rc != NULL)
+ slapt_config_t_free(rc);
+
+ slapt_service_complete_check_for_updates(srv, meth, count);
+ return TRUE;
+}
+
+static void on_name_lost(GDBusConnection *c, const gchar *name, gpointer user_data)
+{
+ g_warning("server name lost");
+ exit(1);
+}
+
+static void on_name_acquired(GDBusConnection *c, const gchar *name, gpointer user_data)
+{
+ SlaptService *srv = slapt_service_skeleton_new();
+ g_signal_connect(srv, "handle-check-for-updates", G_CALLBACK(handle_check_for_updates), NULL);
+ g_signal_connect(srv, "handle-refresh-cache", G_CALLBACK(handle_refresh_cache), NULL);
+ g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(srv), c, SLAPT_SERVICE_PATH, NULL);
+}
int main(void)
{
- DBusGConnection *bus;
- DBusGProxy *proxy;
- GError *error = NULL;
- guint32 ret;
- SlaptService *slapt_service = NULL;
- int saved_stdout = dup(1);
- FILE *newstdout = NULL;
#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init ();
@@ -44,41 +127,19 @@ int main(void)
gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL));
#endif
#endif
-
- bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- syslog(LOG_DAEMON | LOG_INFO,
- "Failed to make connection to system bus: %s",
- error->message);
- g_error_free(error);
- exit(1);
- }
-
- proxy = dbus_g_proxy_new_for_name(bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- if (!org_freedesktop_DBus_request_name(proxy, SLAPT_SERVICE_NAMESPACE, 0, &ret, &error)) {
- syslog(LOG_DAEMON | LOG_INFO,
- "There was an error requesting the name: %s",
- error->message);
- g_error_free(error);
- exit(1);
- }
-
- if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
- exit(1);
-
- slapt_service = slapt_service_new();
-
- dbus_g_connection_register_g_object(bus,
- SLAPT_SERVICE_PATH,
- G_OBJECT(slapt_service));
+ curl_global_init(CURL_GLOBAL_ALL);
/* this is to silence the bad use of stdout in libslapt */
- newstdout = freopen("/dev/null", "w", stdout);
+ FILE *newstdout = freopen("/dev/null", "w", stdout);
if (newstdout == NULL) {
fprintf(stderr, "failed to close stdout\n");
}
- loop = g_main_loop_new(NULL, FALSE);
+ GMainLoop *loop = g_main_loop_new(NULL, FALSE);
+ guint owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, SLAPT_SERVICE_NAMESPACE, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, on_name_acquired, on_name_lost, NULL, NULL);
g_main_loop_run(loop);
+ g_bus_unown_name(owner_id);
+ g_main_loop_unref (loop);
+
return 0;
}
diff --git a/src/slapt-service.xml b/src/slapt-service.xml
index e564de7..1953766 100644
--- a/src/slapt-service.xml
+++ b/src/slapt-service.xml
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
-
+<?generation gdbus-codegen --interface-prefix org.jaos --generate-c-code slaptService slapt-service.xml ?>
<node name="/org/jaos/SlaptService">
-
<interface name="org.jaos.SlaptService">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="slapt_service"/>
<method name="CheckForUpdates">
<arg type="u" name="count" direction="out" />
</method>
<method name="RefreshCache"/>
</interface>
</node>
-
diff --git a/src/slaptService.c b/src/slaptService.c
index 8bed581..0ea5536 100644
--- a/src/slaptService.c
+++ b/src/slaptService.c
@@ -1,160 +1,1186 @@
/*
- * Copyright (C) 2003-2019 Jason Woodward <woodwardj at jaos dot org>
+ * Generated by gdbus-codegen 2.46.2. DO NOT EDIT.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>
+ * The license of this code is the same as for the source it was derived from.
*/
-#include <stdio.h>
-#include <unistd.h>
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "slaptService.h"
-#include "server-bindings.h"
-#include "common.h"
-struct _SlaptServicePrivate {
- int count; /* nothing here yet */
+#include <string.h>
+#ifdef G_OS_UNIX
+# include <gio/gunixfdlist.h>
+#endif
+
+typedef struct
+{
+ GDBusArgInfo parent_struct;
+ gboolean use_gvariant;
+} _ExtendedGDBusArgInfo;
+
+typedef struct
+{
+ GDBusMethodInfo parent_struct;
+ const gchar *signal_name;
+ gboolean pass_fdlist;
+} _ExtendedGDBusMethodInfo;
+
+typedef struct
+{
+ GDBusSignalInfo parent_struct;
+ const gchar *signal_name;
+} _ExtendedGDBusSignalInfo;
+
+typedef struct
+{
+ GDBusPropertyInfo parent_struct;
+ const gchar *hyphen_name;
+ gboolean use_gvariant;
+} _ExtendedGDBusPropertyInfo;
+
+typedef struct
+{
+ GDBusInterfaceInfo parent_struct;
+ const gchar *hyphen_name;
+} _ExtendedGDBusInterfaceInfo;
+
+typedef struct
+{
+ const _ExtendedGDBusPropertyInfo *info;
+ guint prop_id;
+ GValue orig_value; /* the value before the change */
+} ChangedProperty;
+
+static void
+_changed_property_free (ChangedProperty *data)
+{
+ g_value_unset (&data->orig_value);
+ g_free (data);
+}
+
+static gboolean
+_g_strv_equal0 (gchar **a, gchar **b)
+{
+ gboolean ret = FALSE;
+ guint n;
+ if (a == NULL && b == NULL)
+ {
+ ret = TRUE;
+ goto out;
+ }
+ if (a == NULL || b == NULL)
+ goto out;
+ if (g_strv_length (a) != g_strv_length (b))
+ goto out;
+ for (n = 0; a[n] != NULL; n++)
+ if (g_strcmp0 (a[n], b[n]) != 0)
+ goto out;
+ ret = TRUE;
+out:
+ return ret;
+}
+
+static gboolean
+_g_variant_equal0 (GVariant *a, GVariant *b)
+{
+ gboolean ret = FALSE;
+ if (a == NULL && b == NULL)
+ {
+ ret = TRUE;
+ goto out;
+ }
+ if (a == NULL || b == NULL)
+ goto out;
+ ret = g_variant_equal (a, b);
+out:
+ return ret;
+}
+
+G_GNUC_UNUSED static gboolean
+_g_value_equal (const GValue *a, const GValue *b)
+{
+ gboolean ret = FALSE;
+ g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
+ switch (G_VALUE_TYPE (a))
+ {
+ case G_TYPE_BOOLEAN:
+ ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
+ break;
+ case G_TYPE_UCHAR:
+ ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
+ break;
+ case G_TYPE_INT:
+ ret = (g_value_get_int (a) == g_value_get_int (b));
+ break;
+ case G_TYPE_UINT:
+ ret = (g_value_get_uint (a) == g_value_get_uint (b));
+ break;
+ case G_TYPE_INT64:
+ ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
+ break;
+ case G_TYPE_UINT64:
+ ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
+ break;
+ case G_TYPE_DOUBLE:
+ {
+ /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
+ gdouble da = g_value_get_double (a);
+ gdouble db = g_value_get_double (b);
+ ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
+ }
+ break;
+ case G_TYPE_STRING:
+ ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
+ break;
+ case G_TYPE_VARIANT:
+ ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
+ break;
+ default:
+ if (G_VALUE_TYPE (a) == G_TYPE_STRV)
+ ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
+ else
+ g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
+ break;
+ }
+ return ret;
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.jaos.SlaptService
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:SlaptService
+ * @title: SlaptService
+ * @short_description: Generated C code for the org.jaos.SlaptService D-Bus interface
+ *
+ * This section contains code for working with the <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link> D-Bus interface in C.
+ */
+
+/* ---- Introspection data for org.jaos.SlaptService ---- */
+
+static const _ExtendedGDBusArgInfo _slapt_service_method_info_check_for_updates_OUT_ARG_count =
+{
+ {
+ -1,
+ (gchar *) "count",
+ (gchar *) "u",
+ NULL
+ },
+ FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _slapt_service_method_info_check_for_updates_OUT_ARG_pointers[] =
+{
+ &_slapt_service_method_info_check_for_updates_OUT_ARG_count,
+ NULL
+};
+
+static const _ExtendedGDBusMethodInfo _slapt_service_method_info_check_for_updates =
+{
+ {
+ -1,
+ (gchar *) "CheckForUpdates",
+ NULL,
+ (GDBusArgInfo **) &_slapt_service_method_info_check_for_updates_OUT_ARG_pointers,
+ NULL
+ },
+ "handle-check-for-updates",
+ FALSE
};
-G_DEFINE_TYPE_WITH_CODE(SlaptService, slapt_service, G_TYPE_OBJECT, G_ADD_PRIVATE(SlaptService))
+static const _ExtendedGDBusMethodInfo _slapt_service_method_info_refresh_cache =
+{
+ {
+ -1,
+ (gchar *) "RefreshCache",
+ NULL,
+ NULL,
+ NULL
+ },
+ "handle-refresh-cache",
+ FALSE
+};
+
+static const _ExtendedGDBusMethodInfo * const _slapt_service_method_info_pointers[] =
+{
+ &_slapt_service_method_info_check_for_updates,
+ &_slapt_service_method_info_refresh_cache,
+ NULL
+};
+
+static const _ExtendedGDBusInterfaceInfo _slapt_service_interface_info =
+{
+ {
+ -1,
+ (gchar *) "org.jaos.SlaptService",
+ (GDBusMethodInfo **) &_slapt_service_method_info_pointers,
+ NULL,
+ NULL,
+ NULL
+ },
+ "slapt-service",
+};
+
+
+/**
+ * slapt_service_interface_info:
+ *
+ * Gets a machine-readable description of the <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link> D-Bus interface.
+ *
+ * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
+ */
+GDBusInterfaceInfo *
+slapt_service_interface_info (void)
+{
+ return (GDBusInterfaceInfo *) &_slapt_service_interface_info.parent_struct;
+}
+
+/**
+ * slapt_service_override_properties:
+ * @klass: The class structure for a #GObject<!-- -->-derived class.
+ * @property_id_begin: The property id to assign to the first overridden property.
+ *
+ * Overrides all #GObject properties in the #SlaptService interface for a concrete class.
+ * The properties are overridden in the order they are defined.
+ *
+ * Returns: The last property id.
+ */
+guint
+slapt_service_override_properties (GObjectClass *klass, guint property_id_begin)
+{
+ return property_id_begin - 1;
+}
+
+
+
+/**
+ * SlaptService:
+ *
+ * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link>.
+ */
+
+/**
+ * SlaptServiceIface:
+ * @parent_iface: The parent interface.
+ * @handle_check_for_updates: Handler for the #SlaptService::handle-check-for-updates signal.
+ * @handle_refresh_cache: Handler for the #SlaptService::handle-refresh-cache signal.
+ *
+ * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link>.
+ */
+
+typedef SlaptServiceIface SlaptServiceInterface;
+G_DEFINE_INTERFACE (SlaptService, slapt_service, G_TYPE_OBJECT);
+
+static void
+slapt_service_default_init (SlaptServiceIface *iface)
+{
+ /* GObject signals for incoming D-Bus method calls: */
+ /**
+ * SlaptService::handle-check-for-updates:
+ * @object: A #SlaptService.
+ * @invocation: A #GDBusMethodInvocation.
+ *
+ * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-jaos-SlaptService.CheckForUpdates">CheckForUpdates()</link> D-Bus method.
+ *
+ * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call slapt_service_complete_check_for_updates() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+ *
+ * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+ */
+ g_signal_new ("handle-check-for-updates",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SlaptServiceIface, handle_check_for_updates),
+ g_signal_accumulator_true_handled,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_DBUS_METHOD_INVOCATION);
+
+ /**
+ * SlaptService::handle-refresh-cache:
+ * @object: A #SlaptService.
+ * @invocation: A #GDBusMethodInvocation.
+ *
+ * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-jaos-SlaptService.RefreshCache">RefreshCache()</link> D-Bus method.
+ *
+ * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call slapt_service_complete_refresh_cache() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+ *
+ * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+ */
+ g_signal_new ("handle-refresh-cache",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SlaptServiceIface, handle_refresh_cache),
+ g_signal_accumulator_true_handled,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_DBUS_METHOD_INVOCATION);
+
+}
+
+/**
+ * slapt_service_call_check_for_updates:
+ * @proxy: A #SlaptServiceProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-jaos-SlaptService.CheckForUpdates">CheckForUpdates()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call slapt_service_call_check_for_updates_finish() to get the result of the operation.
+ *
+ * See slapt_service_call_check_for_updates_sync() for the synchronous, blocking version of this method.
+ */
+void
+slapt_service_call_check_for_updates (
+ SlaptService *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "CheckForUpdates",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * slapt_service_call_check_for_updates_finish:
+ * @proxy: A #SlaptServiceProxy.
+ * @out_count: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to slapt_service_call_check_for_updates().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with slapt_service_call_check_for_updates().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+slapt_service_call_check_for_updates_finish (
+ SlaptService *proxy,
+ guint *out_count,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "(u)",
+ out_count);
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * slapt_service_call_check_for_updates_sync:
+ * @proxy: A #SlaptServiceProxy.
+ * @out_count: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-jaos-SlaptService.CheckForUpdates">CheckForUpdates()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See slapt_service_call_check_for_updates() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+slapt_service_call_check_for_updates_sync (
+ SlaptService *proxy,
+ guint *out_count,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "CheckForUpdates",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "(u)",
+ out_count);
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * slapt_service_call_refresh_cache:
+ * @proxy: A #SlaptServiceProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-jaos-SlaptService.RefreshCache">RefreshCache()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call slapt_service_call_refresh_cache_finish() to get the result of the operation.
+ *
+ * See slapt_service_call_refresh_cache_sync() for the synchronous, blocking version of this method.
+ */
+void
+slapt_service_call_refresh_cache (
+ SlaptService *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "RefreshCache",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * slapt_service_call_refresh_cache_finish:
+ * @proxy: A #SlaptServiceProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to slapt_service_call_refresh_cache().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with slapt_service_call_refresh_cache().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+slapt_service_call_refresh_cache_finish (
+ SlaptService *proxy,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * slapt_service_call_refresh_cache_sync:
+ * @proxy: A #SlaptServiceProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-jaos-SlaptService.RefreshCache">RefreshCache()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See slapt_service_call_refresh_cache() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+slapt_service_call_refresh_cache_sync (
+ SlaptService *proxy,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "RefreshCache",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * slapt_service_complete_check_for_updates:
+ * @object: A #SlaptService.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @count: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-jaos-SlaptService.CheckForUpdates">CheckForUpdates()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+slapt_service_complete_check_for_updates (
+ SlaptService *object,
+ GDBusMethodInvocation *invocation,
+ guint count)
+{
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(u)",
+ count));
+}
-static gboolean slapt_service_real_check_for_updates(SlaptService *self, guint *count, GError **error)
+/**
+ * slapt_service_complete_refresh_cache:
+ * @object: A #SlaptService.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-jaos-SlaptService.RefreshCache">RefreshCache()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+slapt_service_complete_refresh_cache (
+ SlaptService *object,
+ GDBusMethodInvocation *invocation)
{
- unsigned int i;
- slapt_vector_t *installed_pkgs = NULL;
- slapt_vector_t *avail_pkgs = NULL;
- slapt_transaction_t *tran = NULL;
- slapt_config_t *rc = NULL;
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("()"));
+}
- g_assert(SLAPT_IS_SERVICE(self));
+/* ------------------------------------------------------------------------ */
- *count = 0;
+/**
+ * SlaptServiceProxy:
+ *
+ * The #SlaptServiceProxy structure contains only private data and should only be accessed using the provided API.
+ */
- rc = slapt_config_t_read(SLAPT_SERVICE_DEFAULT_RC);
- if ((chdir(rc->working_dir)) == -1)
- goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+/**
+ * SlaptServiceProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SlaptServiceProxy.
+ */
+
+struct _SlaptServiceProxyPrivate
+{
+ GData *qdata;
+};
+
+static void slapt_service_proxy_iface_init (SlaptServiceIface *iface);
+
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SlaptServiceProxy, slapt_service_proxy, G_TYPE_DBUS_PROXY,
+ G_ADD_PRIVATE (SlaptServiceProxy)
+ G_IMPLEMENT_INTERFACE (TYPE_SLAPT_SERVICE, slapt_service_proxy_iface_init));
- installed_pkgs = slapt_get_installed_pkgs();
- avail_pkgs = slapt_get_available_pkgs();
- if (avail_pkgs == NULL || installed_pkgs == NULL)
- goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
- if (avail_pkgs->size == 0)
- goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+#else
+G_DEFINE_TYPE_WITH_CODE (SlaptServiceProxy, slapt_service_proxy, G_TYPE_DBUS_PROXY,
+ G_IMPLEMENT_INTERFACE (TYPE_SLAPT_SERVICE, slapt_service_proxy_iface_init));
- tran = slapt_init_transaction();
- if (tran == NULL)
- goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+#endif
+static void
+slapt_service_proxy_finalize (GObject *object)
+{
+ SlaptServiceProxy *proxy = SLAPT_SERVICE_PROXY (object);
+ g_datalist_clear (&proxy->priv->qdata);
+ G_OBJECT_CLASS (slapt_service_proxy_parent_class)->finalize (object);
+}
- slapt_vector_t_foreach(slapt_pkg_t *, installed_pkg, installed_pkgs) {
- slapt_pkg_t *update_pkg = NULL;
- slapt_pkg_t *newer_installed_pkg = NULL;
+static void
+slapt_service_proxy_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec G_GNUC_UNUSED)
+{
+}
- if (slapt_is_excluded(rc, installed_pkg))
- continue;
+static void
+slapt_service_proxy_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec G_GNUC_UNUSED)
+{
+}
- if ((newer_installed_pkg = slapt_get_newest_pkg(installed_pkgs, installed_pkg->name)) != NULL) {
- if (slapt_cmp_pkgs(installed_pkg, newer_installed_pkg) < 0)
- continue;
+static void
+slapt_service_proxy_g_signal (GDBusProxy *proxy,
+ const gchar *sender_name G_GNUC_UNUSED,
+ const gchar *signal_name,
+ GVariant *parameters)
+{
+ _ExtendedGDBusSignalInfo *info;
+ GVariantIter iter;
+ GVariant *child;
+ GValue *paramv;
+ guint num_params;
+ guint n;
+ guint signal_id;
+ info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_slapt_service_interface_info.parent_struct, signal_name);
+ if (info == NULL)
+ return;
+ num_params = g_variant_n_children (parameters);
+ paramv = g_new0 (GValue, num_params + 1);
+ g_value_init (&paramv[0], TYPE_SLAPT_SERVICE);
+ g_value_set_object (&paramv[0], proxy);
+ g_variant_iter_init (&iter, parameters);
+ n = 1;
+ while ((child = g_variant_iter_next_value (&iter)) != NULL)
+ {
+ _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+ if (arg_info->use_gvariant)
+ {
+ g_value_init (&paramv[n], G_TYPE_VARIANT);
+ g_value_set_variant (&paramv[n], child);
+ n++;
}
+ else
+ g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+ g_variant_unref (child);
+ }
+ signal_id = g_signal_lookup (info->signal_name, TYPE_SLAPT_SERVICE);
+ g_signal_emitv (paramv, signal_id, 0, NULL);
+ for (n = 0; n < num_params + 1; n++)
+ g_value_unset (&paramv[n]);
+ g_free (paramv);
+}
- update_pkg = slapt_get_newest_pkg(avail_pkgs, installed_pkg->name);
- if (update_pkg != NULL) {
- if (slapt_cmp_pkgs(installed_pkg, update_pkg) < 0) {
- if (slapt_is_excluded(rc, update_pkg))
- continue;
+static void
+slapt_service_proxy_g_properties_changed (GDBusProxy *_proxy,
+ GVariant *changed_properties,
+ const gchar *const *invalidated_properties)
+{
+ SlaptServiceProxy *proxy = SLAPT_SERVICE_PROXY (_proxy);
+ guint n;
+ const gchar *key;
+ GVariantIter *iter;
+ _ExtendedGDBusPropertyInfo *info;
+ g_variant_get (changed_properties, "a{sv}", &iter);
+ while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+ {
+ info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_slapt_service_interface_info.parent_struct, key);
+ g_datalist_remove_data (&proxy->priv->qdata, key);
+ if (info != NULL)
+ g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+ }
+ g_variant_iter_free (iter);
+ for (n = 0; invalidated_properties[n] != NULL; n++)
+ {
+ info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_slapt_service_interface_info.parent_struct, invalidated_properties[n]);
+ g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
+ if (info != NULL)
+ g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+ }
+}
- slapt_add_deps_to_trans(rc, tran, avail_pkgs, installed_pkgs, update_pkg);
- slapt_add_upgrade_to_transaction(tran, installed_pkg, update_pkg);
- } /* end if newer */
+static void
+slapt_service_proxy_init (SlaptServiceProxy *proxy)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+ proxy->priv = slapt_service_proxy_get_instance_private (proxy);
+#else
+ proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SLAPT_SERVICE_PROXY, SlaptServiceProxyPrivate);
+#endif
- } /* end upgrade pkg found */
+ g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), slapt_service_interface_info ());
+}
- } /* end for installed_pkgs */
+static void
+slapt_service_proxy_class_init (SlaptServiceProxyClass *klass)
+{
+ GObjectClass *gobject_class;
+ GDBusProxyClass *proxy_class;
- /* count includes new installed as well as package upgrades */
- *count += tran->upgrade_pkgs->size + tran->install_pkgs->size;
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = slapt_service_proxy_finalize;
+ gobject_class->get_property = slapt_service_proxy_get_property;
+ gobject_class->set_property = slapt_service_proxy_set_property;
-SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE:
- if (installed_pkgs != NULL)
- slapt_vector_t_free(installed_pkgs);
- if (avail_pkgs != NULL)
- slapt_vector_t_free(avail_pkgs);
- if (tran != NULL)
- slapt_free_transaction(tran);
- if (rc != NULL)
- slapt_config_t_free(rc);
+ proxy_class = G_DBUS_PROXY_CLASS (klass);
+ proxy_class->g_signal = slapt_service_proxy_g_signal;
+ proxy_class->g_properties_changed = slapt_service_proxy_g_properties_changed;
- return TRUE;
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+ g_type_class_add_private (klass, sizeof (SlaptServiceProxyPrivate));
+#endif
}
-static gboolean slapt_service_real_refresh_cache(SlaptService *self)
+static void
+slapt_service_proxy_iface_init (SlaptServiceIface *iface)
{
- slapt_config_t *rc = NULL;
- int r = 0;
+}
- g_assert(SLAPT_IS_SERVICE(self));
+/**
+ * slapt_service_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link>. See g_dbus_proxy_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call slapt_service_proxy_new_finish() to get the result of the operation.
+ *
+ * See slapt_service_proxy_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+slapt_service_proxy_new (
+ GDBusConnection *connection,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_async_initable_new_async (TYPE_SLAPT_SERVICE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.jaos.SlaptService", NULL);
+}
- rc = slapt_config_t_read(SLAPT_SERVICE_DEFAULT_RC);
+/**
+ * slapt_service_proxy_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to slapt_service_proxy_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with slapt_service_proxy_new().
+ *
+ * Returns: (transfer full) (type SlaptServiceProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SlaptService *
+slapt_service_proxy_new_finish (
+ GAsyncResult *res,
+ GError **error)
+{
+ GObject *ret;
+ GObject *source_object;
+ source_object = g_async_result_get_source_object (res);
+ ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+ g_object_unref (source_object);
+ if (ret != NULL)
+ return SLAPT_SERVICE (ret);
+ else
+ return NULL;
+}
- slapt_working_dir_init(rc);
- if ((chdir(rc->working_dir)) == -1)
- return FALSE;
+/**
+ * slapt_service_proxy_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link>. See g_dbus_proxy_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See slapt_service_proxy_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SlaptServiceProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SlaptService *
+slapt_service_proxy_new_sync (
+ GDBusConnection *connection,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GInitable *ret;
+ ret = g_initable_new (TYPE_SLAPT_SERVICE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.jaos.SlaptService", NULL);
+ if (ret != NULL)
+ return SLAPT_SERVICE (ret);
+ else
+ return NULL;
+}
- if (slapt_update_pkg_cache(rc) != 0)
- fprintf(stderr, "failed to update package cache... handle me\n");
- slapt_config_t_free(rc);
+/**
+ * slapt_service_proxy_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like slapt_service_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call slapt_service_proxy_new_for_bus_finish() to get the result of the operation.
+ *
+ * See slapt_service_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+slapt_service_proxy_new_for_bus (
+ GBusType bus_type,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_async_initable_new_async (TYPE_SLAPT_SERVICE_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.jaos.SlaptService", NULL);
+}
+
+/**
+ * slapt_service_proxy_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to slapt_service_proxy_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with slapt_service_proxy_new_for_bus().
+ *
+ * Returns: (transfer full) (type SlaptServiceProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SlaptService *
+slapt_service_proxy_new_for_bus_finish (
+ GAsyncResult *res,
+ GError **error)
+{
+ GObject *ret;
+ GObject *source_object;
+ source_object = g_async_result_get_source_object (res);
+ ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+ g_object_unref (source_object);
+ if (ret != NULL)
+ return SLAPT_SERVICE (ret);
+ else
+ return NULL;
+}
+
+/**
+ * slapt_service_proxy_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like slapt_service_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See slapt_service_proxy_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SlaptServiceProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SlaptService *
+slapt_service_proxy_new_for_bus_sync (
+ GBusType bus_type,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GInitable *ret;
+ ret = g_initable_new (TYPE_SLAPT_SERVICE_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.jaos.SlaptService", NULL);
+ if (ret != NULL)
+ return SLAPT_SERVICE (ret);
+ else
+ return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SlaptServiceSkeleton:
+ *
+ * The #SlaptServiceSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SlaptServiceSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SlaptServiceSkeleton.
+ */
+
+struct _SlaptServiceSkeletonPrivate
+{
+ GValue *properties;
+ GList *changed_properties;
+ GSource *changed_properties_idle_source;
+ GMainContext *context;
+ GMutex lock;
+};
- return TRUE;
+static void
+_slapt_service_skeleton_handle_method_call (
+ GDBusConnection *connection G_GNUC_UNUSED,
+ const gchar *sender G_GNUC_UNUSED,
+ const gchar *object_path G_GNUC_UNUSED,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ SlaptServiceSkeleton *skeleton = SLAPT_SERVICE_SKELETON (user_data);
+ _ExtendedGDBusMethodInfo *info;
+ GVariantIter iter;
+ GVariant *child;
+ GValue *paramv;
+ guint num_params;
+ guint num_extra;
+ guint n;
+ guint signal_id;
+ GValue return_value = G_VALUE_INIT;
+ info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
+ g_assert (info != NULL);
+ num_params = g_variant_n_children (parameters);
+ num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
+ n = 0;
+ g_value_init (&paramv[n], TYPE_SLAPT_SERVICE);
+ g_value_set_object (&paramv[n++], skeleton);
+ g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
+ g_value_set_object (&paramv[n++], invocation);
+ if (info->pass_fdlist)
+ {
+#ifdef G_OS_UNIX
+ g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
+ g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
+#else
+ g_assert_not_reached ();
+#endif
+ }
+ g_variant_iter_init (&iter, parameters);
+ while ((child = g_variant_iter_next_value (&iter)) != NULL)
+ {
+ _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
+ if (arg_info->use_gvariant)
+ {
+ g_value_init (&paramv[n], G_TYPE_VARIANT);
+ g_value_set_variant (&paramv[n], child);
+ n++;
+ }
+ else
+ g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+ g_variant_unref (child);
+ }
+ signal_id = g_signal_lookup (info->signal_name, TYPE_SLAPT_SERVICE);
+ g_value_init (&return_value, G_TYPE_BOOLEAN);
+ g_signal_emitv (paramv, signal_id, 0, &return_value);
+ if (!g_value_get_boolean (&return_value))
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+ g_value_unset (&return_value);
+ for (n = 0; n < num_params + num_extra; n++)
+ g_value_unset (&paramv[n]);
+ g_free (paramv);
+}
+
+static GVariant *
+_slapt_service_skeleton_handle_get_property (
+ GDBusConnection *connection G_GNUC_UNUSED,
+ const gchar *sender G_GNUC_UNUSED,
+ const gchar *object_path G_GNUC_UNUSED,
+ const gchar *interface_name G_GNUC_UNUSED,
+ const gchar *property_name,
+ GError **error,
+ gpointer user_data)
+{
+ SlaptServiceSkeleton *skeleton = SLAPT_SERVICE_SKELETON (user_data);
+ GValue value = G_VALUE_INIT;
+ GParamSpec *pspec;
+ _ExtendedGDBusPropertyInfo *info;
+ GVariant *ret;
+ ret = NULL;
+ info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_slapt_service_interface_info.parent_struct, property_name);
+ g_assert (info != NULL);
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+ if (pspec == NULL)
+ {
+ g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+ }
+ else
+ {
+ g_value_init (&value, pspec->value_type);
+ g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+ ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+ g_value_unset (&value);
+ }
+ return ret;
+}
+
+static gboolean
+_slapt_service_skeleton_handle_set_property (
+ GDBusConnection *connection G_GNUC_UNUSED,
+ const gchar *sender G_GNUC_UNUSED,
+ const gchar *object_path G_GNUC_UNUSED,
+ const gchar *interface_name G_GNUC_UNUSED,
+ const gchar *property_name,
+ GVariant *variant,
+ GError **error,
+ gpointer user_data)
+{
+ SlaptServiceSkeleton *skeleton = SLAPT_SERVICE_SKELETON (user_data);
+ GValue value = G_VALUE_INIT;
+ GParamSpec *pspec;
+ _ExtendedGDBusPropertyInfo *info;
+ gboolean ret;
+ ret = FALSE;
+ info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_slapt_service_interface_info.parent_struct, property_name);
+ g_assert (info != NULL);
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+ if (pspec == NULL)
+ {
+ g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+ }
+ else
+ {
+ if (info->use_gvariant)
+ g_value_set_variant (&value, variant);
+ else
+ g_dbus_gvariant_to_gvalue (variant, &value);
+ g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+ g_value_unset (&value);
+ ret = TRUE;
+ }
+ return ret;
}
-gboolean slapt_service_check_for_updates(SlaptService *self, guint *count, GError **error)
+static const GDBusInterfaceVTable _slapt_service_skeleton_vtable =
{
- g_assert(SLAPT_IS_SERVICE(self));
+ _slapt_service_skeleton_handle_method_call,
+ _slapt_service_skeleton_handle_get_property,
+ _slapt_service_skeleton_handle_set_property,
+ {NULL}
+};
- return self->check_for_updates(self, count, error);
+static GDBusInterfaceInfo *
+slapt_service_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+ return slapt_service_interface_info ();
}
-gboolean slapt_service_refresh_cache(SlaptService *self)
+static GDBusInterfaceVTable *
+slapt_service_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
{
- g_assert(SLAPT_IS_SERVICE(self));
+ return (GDBusInterfaceVTable *) &_slapt_service_skeleton_vtable;
+}
+
+static GVariant *
+slapt_service_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
+{
+ SlaptServiceSkeleton *skeleton = SLAPT_SERVICE_SKELETON (_skeleton);
+
+ GVariantBuilder builder;
+ guint n;
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+ if (_slapt_service_interface_info.parent_struct.properties == NULL)
+ goto out;
+ for (n = 0; _slapt_service_interface_info.parent_struct.properties[n] != NULL; n++)
+ {
+ GDBusPropertyInfo *info = _slapt_service_interface_info.parent_struct.properties[n];
+ if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+ {
+ GVariant *value;
+ value = _slapt_service_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.jaos.SlaptService", info->name, NULL, skeleton);
+ if (value != NULL)
+ {
+ g_variant_take_ref (value);
+ g_variant_builder_add (&builder, "{sv}", info->name, value);
+ g_variant_unref (value);
+ }
+ }
+ }
+out:
+ return g_variant_builder_end (&builder);
+}
- return self->refresh_cache(self);
+static void
+slapt_service_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
+{
}
-static void slapt_service_class_init(SlaptServiceClass *class)
+static void slapt_service_skeleton_iface_init (SlaptServiceIface *iface);
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SlaptServiceSkeleton, slapt_service_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+ G_ADD_PRIVATE (SlaptServiceSkeleton)
+ G_IMPLEMENT_INTERFACE (TYPE_SLAPT_SERVICE, slapt_service_skeleton_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SlaptServiceSkeleton, slapt_service_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+ G_IMPLEMENT_INTERFACE (TYPE_SLAPT_SERVICE, slapt_service_skeleton_iface_init));
+
+#endif
+static void
+slapt_service_skeleton_finalize (GObject *object)
{
- GError *error = NULL;
+ SlaptServiceSkeleton *skeleton = SLAPT_SERVICE_SKELETON (object);
+ g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+ if (skeleton->priv->changed_properties_idle_source != NULL)
+ g_source_destroy (skeleton->priv->changed_properties_idle_source);
+ g_main_context_unref (skeleton->priv->context);
+ g_mutex_clear (&skeleton->priv->lock);
+ G_OBJECT_CLASS (slapt_service_skeleton_parent_class)->finalize (object);
+}
- class->check_for_updates = NULL;
- class->refresh_cache = NULL;
+static void
+slapt_service_skeleton_init (SlaptServiceSkeleton *skeleton)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+ skeleton->priv = slapt_service_skeleton_get_instance_private (skeleton);
+#else
+ skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SLAPT_SERVICE_SKELETON, SlaptServiceSkeletonPrivate);
+#endif
- dbus_g_object_type_install_info(SLAPT_TYPE_SERVICE, &dbus_glib_slapt_service_object_info);
+ g_mutex_init (&skeleton->priv->lock);
+ skeleton->priv->context = g_main_context_ref_thread_default ();
}
-static void slapt_service_init(SlaptService *self)
+static void
+slapt_service_skeleton_class_init (SlaptServiceSkeletonClass *klass)
{
- SlaptServiceClass *class = SLAPT_SERVICE_GET_CLASS(self);
- int request_ret;
+ GObjectClass *gobject_class;
+ GDBusInterfaceSkeletonClass *skeleton_class;
- SlaptServicePrivate *priv = slapt_service_get_instance_private(self);
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = slapt_service_skeleton_finalize;
- self->check_for_updates = slapt_service_real_check_for_updates;
- self->refresh_cache = slapt_service_real_refresh_cache;
+ skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
+ skeleton_class->get_info = slapt_service_skeleton_dbus_interface_get_info;
+ skeleton_class->get_properties = slapt_service_skeleton_dbus_interface_get_properties;
+ skeleton_class->flush = slapt_service_skeleton_dbus_interface_flush;
+ skeleton_class->get_vtable = slapt_service_skeleton_dbus_interface_get_vtable;
- self->priv = priv;
- priv->count = 0;
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+ g_type_class_add_private (klass, sizeof (SlaptServiceSkeletonPrivate));
+#endif
}
-SlaptService *slapt_service_new(void)
+static void
+slapt_service_skeleton_iface_init (SlaptServiceIface *iface)
{
- return SLAPT_SERVICE(g_object_new(SLAPT_TYPE_SERVICE, NULL));
}
+
+/**
+ * slapt_service_skeleton_new:
+ *
+ * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-jaos-SlaptService.top_of_page">org.jaos.SlaptService</link>.
+ *
+ * Returns: (transfer full) (type SlaptServiceSkeleton): The skeleton object.
+ */
+SlaptService *
+slapt_service_skeleton_new (void)
+{
+ return SLAPT_SERVICE (g_object_new (TYPE_SLAPT_SERVICE_SKELETON, NULL));
+}
+
diff --git a/src/slaptService.h b/src/slaptService.h
index d141659..db0b44b 100644
--- a/src/slaptService.h
+++ b/src/slaptService.h
@@ -1,63 +1,194 @@
/*
- * Copyright (C) 2003-2019 Jason Woodward <woodwardj at jaos dot org>
+ * Generated by gdbus-codegen 2.46.2. DO NOT EDIT.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>
+ * The license of this code is the same as for the source it was derived from.
*/
-#ifndef __SLAPT_SERVICE_H__
-#define __SLAPT_SERVICE_H__
-#include <glib-object.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <slapt.h>
+#ifndef __SLAPTSERVICE_H__
+#define __SLAPTSERVICE_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
-#define SLAPT_TYPE_SERVICE (slapt_service_get_type())
-#define SLAPT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SLAPT_TYPE_SERVICE, SlaptService))
-#define SLAPT_IS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SLAPT_TYPE_SERVICE))
-#define SLAPT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SLAPT_TYPE_SERVICE, SlaptServiceClass))
-#define SLAPT_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SLAPT_TYPE_SERVICE))
-#define SLAPT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SLAPT_TYPE_SERVICE, SlaptServiceClass))
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.jaos.SlaptService */
+#define TYPE_SLAPT_SERVICE (slapt_service_get_type ())
+#define SLAPT_SERVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SLAPT_SERVICE, SlaptService))
+#define IS_SLAPT_SERVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SLAPT_SERVICE))
+#define SLAPT_SERVICE_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_SLAPT_SERVICE, SlaptServiceIface))
+
+struct _SlaptService;
typedef struct _SlaptService SlaptService;
-typedef struct _SlaptServiceClass SlaptServiceClass;
-typedef struct _SlaptServicePrivate SlaptServicePrivate;
+typedef struct _SlaptServiceIface SlaptServiceIface;
+
+struct _SlaptServiceIface
+{
+ GTypeInterface parent_iface;
+
+ gboolean (*handle_check_for_updates) (
+ SlaptService *object,
+ GDBusMethodInvocation *invocation);
+
+ gboolean (*handle_refresh_cache) (
+ SlaptService *object,
+ GDBusMethodInvocation *invocation);
+
+};
+
+GType slapt_service_get_type (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *slapt_service_interface_info (void);
+guint slapt_service_override_properties (GObjectClass *klass, guint property_id_begin);
+
+
+/* D-Bus method call completion functions: */
+void slapt_service_complete_check_for_updates (
+ SlaptService *object,
+ GDBusMethodInvocation *invocation,
+ guint count);
+
+void slapt_service_complete_refresh_cache (
+ SlaptService *object,
+ GDBusMethodInvocation *invocation);
+
+
+
+/* D-Bus method calls: */
+void slapt_service_call_check_for_updates (
+ SlaptService *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean slapt_service_call_check_for_updates_finish (
+ SlaptService *proxy,
+ guint *out_count,
+ GAsyncResult *res,
+ GError **error);
-struct _SlaptService {
- GObject parent_instance;
+gboolean slapt_service_call_check_for_updates_sync (
+ SlaptService *proxy,
+ guint *out_count,
+ GCancellable *cancellable,
+ GError **error);
- SlaptServicePrivate *priv;
+void slapt_service_call_refresh_cache (
+ SlaptService *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
- gboolean (*check_for_updates)(SlaptService *self, guint *count, GError **error);
- gboolean (*refresh_cache)(SlaptService *self);
+gboolean slapt_service_call_refresh_cache_finish (
+ SlaptService *proxy,
+ GAsyncResult *res,
+ GError **error);
+
+gboolean slapt_service_call_refresh_cache_sync (
+ SlaptService *proxy,
+ GCancellable *cancellable,
+ GError **error);
+
+
+
+/* ---- */
+
+#define TYPE_SLAPT_SERVICE_PROXY (slapt_service_proxy_get_type ())
+#define SLAPT_SERVICE_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SLAPT_SERVICE_PROXY, SlaptServiceProxy))
+#define SLAPT_SERVICE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SLAPT_SERVICE_PROXY, SlaptServiceProxyClass))
+#define SLAPT_SERVICE_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SLAPT_SERVICE_PROXY, SlaptServiceProxyClass))
+#define IS_SLAPT_SERVICE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SLAPT_SERVICE_PROXY))
+#define IS_SLAPT_SERVICE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SLAPT_SERVICE_PROXY))
+
+typedef struct _SlaptServiceProxy SlaptServiceProxy;
+typedef struct _SlaptServiceProxyClass SlaptServiceProxyClass;
+typedef struct _SlaptServiceProxyPrivate SlaptServiceProxyPrivate;
+
+struct _SlaptServiceProxy
+{
+ /*< private >*/
+ GDBusProxy parent_instance;
+ SlaptServiceProxyPrivate *priv;
};
-struct _SlaptServiceClass {
- GObjectClass parent_class;
+struct _SlaptServiceProxyClass
+{
+ GDBusProxyClass parent_class;
+};
+
+GType slapt_service_proxy_get_type (void) G_GNUC_CONST;
+
+void slapt_service_proxy_new (
+ GDBusConnection *connection,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+SlaptService *slapt_service_proxy_new_finish (
+ GAsyncResult *res,
+ GError **error);
+SlaptService *slapt_service_proxy_new_sync (
+ GDBusConnection *connection,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GError **error);
- DBusGConnection *connection;
+void slapt_service_proxy_new_for_bus (
+ GBusType bus_type,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+SlaptService *slapt_service_proxy_new_for_bus_finish (
+ GAsyncResult *res,
+ GError **error);
+SlaptService *slapt_service_proxy_new_for_bus_sync (
+ GBusType bus_type,
+ GDBusProxyFlags flags,
+ const gchar *name,
+ const gchar *object_path,
+ GCancellable *cancellable,
+ GError **error);
- gboolean (*check_for_updates)(SlaptService *self, guint *count, GError **error);
- gboolean (*refresh_cache)(SlaptService *self);
+
+/* ---- */
+
+#define TYPE_SLAPT_SERVICE_SKELETON (slapt_service_skeleton_get_type ())
+#define SLAPT_SERVICE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SLAPT_SERVICE_SKELETON, SlaptServiceSkeleton))
+#define SLAPT_SERVICE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SLAPT_SERVICE_SKELETON, SlaptServiceSkeletonClass))
+#define SLAPT_SERVICE_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SLAPT_SERVICE_SKELETON, SlaptServiceSkeletonClass))
+#define IS_SLAPT_SERVICE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SLAPT_SERVICE_SKELETON))
+#define IS_SLAPT_SERVICE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SLAPT_SERVICE_SKELETON))
+
+typedef struct _SlaptServiceSkeleton SlaptServiceSkeleton;
+typedef struct _SlaptServiceSkeletonClass SlaptServiceSkeletonClass;
+typedef struct _SlaptServiceSkeletonPrivate SlaptServiceSkeletonPrivate;
+
+struct _SlaptServiceSkeleton
+{
+ /*< private >*/
+ GDBusInterfaceSkeleton parent_instance;
+ SlaptServiceSkeletonPrivate *priv;
+};
+
+struct _SlaptServiceSkeletonClass
+{
+ GDBusInterfaceSkeletonClass parent_class;
};
-/* used by SLAPT_TYPE_SERVICE */
-GType slapt_service_get_type(void);
+GType slapt_service_skeleton_get_type (void) G_GNUC_CONST;
-SlaptService *slapt_service_new(void);
-/*
- * Method definitions.
- */
-gboolean slapt_service_check_for_updates(SlaptService *self, guint *count, GError **error);
-gboolean slapt_service_refresh_cache(SlaptService *self);
+SlaptService *slapt_service_skeleton_new (void);
+
+
+G_END_DECLS
-#endif /* __SLAPT_SERVICE_H__ */
+#endif /* __SLAPTSERVICE_H__ */