summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2010-02-20 20:44:01 -0500
committerJason Woodward2010-02-22 22:05:33 -0500
commit2c23c6464850497bd529b2f55334ae8081a29de9 (patch)
treef433e123a6b3caba9cc82bd882a1ec924e7ee45f /src
downloadslapt-update-service-2c23c6464850497bd529b2f55334ae8081a29de9.tar.gz
Initial commit
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am24
-rw-r--r--src/client.c273
-rw-r--r--src/common.h23
-rw-r--r--src/server.c77
-rw-r--r--src/slapt-service.xml13
-rw-r--r--src/slaptService.c165
-rw-r--r--src/slaptService.h66
7 files changed, 641 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..d9b24db
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,24 @@
+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)
+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)
+
+BUILT_SOURCES = server-bindings.h client-bindings.h
+# 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
new file mode 100644
index 0000000..7e471f0
--- /dev/null
+++ b/src/client.c
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2003-2010 Jason Woodward <woodwardj at jaos dot org>
+ *
+ * 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/>
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "client-bindings.h"
+#include "common.h"
+#include <libintl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libnotify/notify.h>
+
+#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 NOTIFICATION_DEFAULT "default"
+#define NOTIFICATION_IGNORE "ignore"
+#define NOTIFICATION_SHOW_UPDATES "show updates"
+
+struct slapt_update_notifier {
+ GtkStatusIcon *tray_icon;
+ GdkPixbuf *running_pixbuf;
+ GdkPixbuf *updates_pixbuf;
+ GtkWidget *menu;
+ DBusGConnection *bus;
+ DBusGProxy *proxy;
+};
+
+static struct slapt_update_notifier *sun = NULL;
+static void hide_sun (void);
+
+static void run_gslapt (const char *action)
+{
+ gchar *argv[4];
+#if defined(HAS_GNOMESU)
+ argv[0] = "/usr/bin/gnomesu";
+ argv[1] = "-c";
+ if ( strcmp(action,"upgrade") == 0 ) {
+ argv[2] = "/usr/sbin/gslapt --upgrade";
+ } else {
+ argv[2] = "/usr/sbin/gslapt";
+ }
+ argv[3] = NULL;
+#elif defined(HAS_GKSU)
+ argv[0] = "/usr/bin/gksu";
+ if ( strcmp(action,"upgrade") == 0 ) {
+ argv[1] = "/usr/sbin/gslapt --upgrade";
+ } else {
+ argv[1] = "/usr/sbin/gslapt";
+ }
+ argv[2] = NULL;
+#elif defined(HAS_KDESU)
+ argv[0] = "/usr/bin/kdesu";
+ if ( strcmp(action,"upgrade") == 0 ) {
+ argv[1] = "/usr/sbin/gslapt --upgrade";
+ } else {
+ argv[1] = "/usr/sbin/gslapt";
+ }
+ argv[2] = NULL;
+#else
+ #error unable to create command to run gslapt
+#endif
+
+ g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL);
+ hide_sun();
+}
+
+void tray_clicked (GtkStatusIcon *status_icon, gpointer data)
+{
+ run_gslapt("upgrade");
+}
+
+void tray_menu (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer data)
+{
+ gtk_menu_popup(
+ GTK_MENU(sun->menu),
+ NULL,NULL,NULL,NULL,
+ button,activate_time
+ );
+}
+
+static void notify_callback(NotifyNotification *handle, const char *action, void *user_data)
+{
+ GMainLoop *loop = (GMainLoop*)user_data;
+
+ if ( strcmp(action,NOTIFICATION_SHOW_UPDATES) == 0 ) {
+ gtk_widget_hide_all(GTK_WIDGET(sun->tray_icon));
+ run_gslapt("upgrade");
+ }
+
+ if (handle != NULL) {
+ GError *error = NULL;
+ if (notify_notification_close(handle, &error) != TRUE) {
+ fprintf(stderr, "failed to send notification: %s\n", error->message);
+ g_error_free (error);
+ }
+ }
+
+ if (loop != NULL)
+ g_main_loop_quit(loop);
+
+}
+
+gboolean show_notification (gpointer data)
+{
+ NotifyNotification *n;
+
+ n = notify_notification_new (
+ _("New updates available"),
+ _("Click on the update icon to see the available updates"),
+ "info", NULL
+ );
+
+ GError *error = NULL;
+ if (notify_notification_show(n, &error) != TRUE)
+ {
+ fprintf(stderr, "failed to send notification: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref(G_OBJECT(n));
+
+ return FALSE;
+}
+
+void tray_destroy (struct slapt_update_notifier *sun)
+{
+
+ if (sun->updates_pixbuf)
+ g_object_unref(G_OBJECT(sun->updates_pixbuf));
+ if (sun->running_pixbuf)
+ g_object_unref(G_OBJECT(sun->running_pixbuf));
+
+ gtk_widget_destroy(GTK_WIDGET(sun->tray_icon));
+}
+
+static void hide_sun (void)
+{
+ NotifyNotification *n = g_object_get_data(G_OBJECT(sun->tray_icon),"notification");
+ GMainLoop *loop = g_object_get_data(G_OBJECT(sun->tray_icon), "notification_loop");
+
+ gtk_status_icon_set_visible(sun->tray_icon, FALSE);
+
+ if ( n != NULL ) {
+ GError *error = NULL;
+ if (notify_notification_close(n, &error) != TRUE) {
+ fprintf(stderr, "failed to send notification: %s\n", error->message);
+ g_error_free (error);
+ }
+ }
+
+ if ( loop != NULL )
+ g_main_loop_quit(loop);
+
+}
+
+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);
+ show_notification(NULL);
+}
+
+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;
+
+ /* 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);
+}
+
+int main (int argc, char *argv[])
+{
+ GError *error = NULL;
+ guint count;
+ GtkWidget *menuitem = NULL;
+
+ gtk_init (&argc, &argv);
+ notify_init("slapt-update-notifier");
+
+ 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);
+ gtk_status_icon_set_tooltip (sun->tray_icon, _("Updates available"));
+ 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);
+
+ sun->menu = gtk_menu_new();
+ 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);
+ g_error_free (error);
+ exit(1);
+ }
+
+ 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);
+
+ gtk_main();
+
+ tray_destroy(sun);
+ g_object_unref (sun->proxy);
+ free(sun);
+
+ notify_uninit();
+
+ return 0;
+}
diff --git a/src/common.h b/src/common.h
new file mode 100644
index 0000000..f963ae6
--- /dev/null
+++ b/src/common.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2003-2010 Jason Woodward <woodwardj at jaos dot org>
+ *
+ * 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/>
+ */
+#ifndef __SLAPT_SERVICE_COMMON_H__
+
+#define SLAPT_SERVICE_NAMESPACE "org.jaos.SlaptService"
+#define SLAPT_SERVICE_PATH "/org/jaos/SlaptService"
+#define SLAPT_SERVICE_DEFAULT_RC "/etc/slapt-get/slapt-getrc"
+
+#endif /*__SLAPT_SERVICE_COMMON_H__ */
diff --git a/src/server.c b/src/server.c
new file mode 100644
index 0000000..a4550f1
--- /dev/null
+++ b/src/server.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2003-2010 Jason Woodward <woodwardj at jaos dot org>
+ *
+ * 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/>
+ */
+#include "slaptService.h"
+#include "common.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <syslog.h>
+
+static GMainLoop *loop;
+
+int main (void)
+{
+ DBusGConnection *bus;
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ guint32 ret;
+ SlaptService *slapt_service = NULL;
+ int saved_stdout = dup(1);
+ FILE *newstdout = NULL;
+
+ g_type_init();
+
+ 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));
+
+
+ /* this is to silence the bad use of stdout in libslapt */
+ newstdout = freopen("/dev/null", "w", stdout);
+ if (newstdout == NULL) {
+ fprintf(stderr,"failed to close stdout\n");
+ }
+
+
+ loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (loop);
+ return 0;
+}
diff --git a/src/slapt-service.xml b/src/slapt-service.xml
new file mode 100644
index 0000000..e564de7
--- /dev/null
+++ b/src/slapt-service.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<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
new file mode 100644
index 0000000..be78f0b
--- /dev/null
+++ b/src/slaptService.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2003-2010 Jason Woodward <woodwardj at jaos dot org>
+ *
+ * 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/>
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include "slaptService.h"
+#include "server-bindings.h"
+#include "common.h"
+#define SLAPT_SERVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SLAPT_TYPE_SERVICE, SlaptServicePrivate))
+
+struct _SlaptServicePrivate
+{
+ int count; /* nothing here yet */
+};
+
+G_DEFINE_TYPE (SlaptService, slapt_service, G_TYPE_OBJECT);
+
+static gboolean slapt_service_real_check_for_updates(SlaptService *self, guint *count, GError **error)
+{
+ unsigned int i;
+ struct slapt_pkg_list *installed_pkgs = NULL;
+ struct slapt_pkg_list *avail_pkgs = NULL;
+ slapt_transaction_t *tran = NULL;
+ slapt_rc_config *rc = NULL;
+
+ g_assert (SLAPT_IS_SERVICE (self));
+
+ *count = 0;
+
+ rc = slapt_read_rc_config(SLAPT_SERVICE_DEFAULT_RC);
+ if ((chdir(rc->working_dir)) == -1)
+ goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+
+ 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->pkg_count == 0 )
+ goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+
+ tran = slapt_init_transaction();
+ if (tran == NULL)
+ goto SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE;
+
+ for (i = 0; i < installed_pkgs->pkg_count; ++i) {
+ slapt_pkg_info_t *installed_pkg = installed_pkgs->pkgs[i];
+ slapt_pkg_info_t *update_pkg = NULL;
+ slapt_pkg_info_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;
+
+ 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 */
+
+ }/* end upgrade pkg found */
+
+ } /* end for installed_pkgs */
+
+ /* count includes new installed as well as package upgrades */
+ *count += tran->upgrade_pkgs->pkg_count + tran->install_pkgs->pkg_count;
+
+SLAPT_SERVICE_REAL_CHECK_FOR_UPDATES_DONE:
+ if (installed_pkgs != NULL)
+ slapt_free_pkg_list(installed_pkgs);
+ if (avail_pkgs != NULL)
+ slapt_free_pkg_list(avail_pkgs);
+ if (tran != NULL)
+ slapt_free_transaction(tran);
+ if (rc != NULL)
+ slapt_free_rc_config(rc);
+
+ return TRUE;
+}
+
+static gboolean slapt_service_real_refresh_cache(SlaptService *self)
+{
+ slapt_rc_config *rc = NULL;
+ int r = 0;
+
+ g_assert (SLAPT_IS_SERVICE (self));
+
+ rc = slapt_read_rc_config(SLAPT_SERVICE_DEFAULT_RC);
+
+ if ((chdir(rc->working_dir)) == -1)
+ return FALSE;
+
+ if (slapt_update_pkg_cache(rc) != 0)
+ fprintf(stderr,"failed to update package cache... handle me\n");
+
+ slapt_free_rc_config(rc);
+
+ return TRUE;
+}
+
+gboolean slapt_service_check_for_updates(SlaptService *self, guint *count, GError **error)
+{
+ g_assert (SLAPT_IS_SERVICE (self));
+
+ return self->check_for_updates (self, count, error);
+}
+
+gboolean slapt_service_refresh_cache(SlaptService *self)
+{
+ g_assert (SLAPT_IS_SERVICE (self));
+
+ return self->refresh_cache (self);
+}
+
+static void slapt_service_class_init (SlaptServiceClass *class)
+{
+ GError *error = NULL;
+
+ g_type_class_add_private (class, sizeof (SlaptServicePrivate));
+
+ class->check_for_updates = NULL;
+ class->refresh_cache = NULL;
+
+ dbus_g_object_type_install_info (SLAPT_TYPE_SERVICE, &dbus_glib_slapt_service_object_info);
+}
+
+static void slapt_service_init (SlaptService *self)
+{
+ SlaptServiceClass *class = SLAPT_SERVICE_GET_CLASS (self);
+ int request_ret;
+
+ SlaptServicePrivate *priv;
+
+ self->check_for_updates = slapt_service_real_check_for_updates;
+ self->refresh_cache = slapt_service_real_refresh_cache;
+
+ self->priv = priv = SLAPT_SERVICE_GET_PRIVATE (self);
+ priv->count = 0;
+}
+
+SlaptService *slapt_service_new (void)
+{
+ return SLAPT_SERVICE (g_object_new (SLAPT_TYPE_SERVICE, NULL));
+}
diff --git a/src/slaptService.h b/src/slaptService.h
new file mode 100644
index 0000000..0546826
--- /dev/null
+++ b/src/slaptService.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2003-2010 Jason Woodward <woodwardj at jaos dot org>
+ *
+ * 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/>
+ */
+#ifndef __SLAPT_SERVICE_H__
+#define __SLAPT_SERVICE_H__
+
+#include <glib-object.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <slapt.h>
+
+#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))
+
+typedef struct _SlaptService SlaptService;
+typedef struct _SlaptServiceClass SlaptServiceClass;
+typedef struct _SlaptServicePrivate SlaptServicePrivate;
+
+struct _SlaptService
+{
+ GObject parent_instance;
+
+ SlaptServicePrivate *priv;
+
+ gboolean (*check_for_updates) (SlaptService *self, guint *count, GError **error);
+ gboolean (*refresh_cache) (SlaptService *self);
+};
+
+struct _SlaptServiceClass
+{
+ GObjectClass parent_class;
+
+ DBusGConnection *connection;
+
+ gboolean (*check_for_updates) (SlaptService *self, guint *count, GError **error);
+ gboolean (*refresh_cache) (SlaptService *self);
+};
+
+/* used by SLAPT_TYPE_SERVICE */
+GType slapt_service_get_type (void);
+
+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);
+
+#endif /* __SLAPT_SERVICE_H__ */
+