Code cleanup around glib version check (2.28 minimum).
[claws.git] / src / plugins / vcalendar / vcal_dbus.c
index 8cb1854..f609872 100644 (file)
 #include <glib.h>
 #include <glib/gi18n.h>
 
-#include <ical.h>
+#include <libical/ical.h>
 #include <gtk/gtk.h>
 
 #include "utils.h"
 #include "vcal_manager.h"
 #include "vcal_folder.h"
 
-#if(GLIB_CHECK_VERSION(2,26,0))
-
 static guint dbus_own_id;
 
 static void add_event_to_builder_if_match(VCalEvent *event, GVariantBuilder *array,
@@ -125,12 +123,7 @@ static void handle_method_call (GDBusConnection       *connection,
 }
 
 
-static const GDBusInterfaceVTable interface_vtable =
-{
-       handle_method_call,
-       NULL,
-       NULL
-};
+static GDBusInterfaceVTable* interface_vtable = NULL;
 
 static GDBusNodeInfo *introspection_data = NULL;
 static GDBusInterfaceInfo *interface_info = NULL;
@@ -166,23 +159,32 @@ static void bus_acquired(GDBusConnection *connection,
                         gpointer         user_data)
 {
        GError *err = NULL;
+
+       cm_return_if_fail(interface_vtable);
+
        g_dbus_connection_register_object(connection,
                "/org/gnome/Shell/CalendarServer",
                introspection_data->interfaces[0],
-               &interface_vtable, NULL, NULL, &err);
+               (const GDBusInterfaceVTable *)interface_vtable, NULL, NULL, &err);
        if (err != NULL)
                debug_print("Error: %s\n", err->message);
 }
 
 void connect_dbus(void)
 {
+       debug_print("connect_dbus() invoked\n");
+
+       interface_vtable = g_malloc0(sizeof(GDBusInterfaceVTable));
+       cm_return_if_fail(interface_vtable);
+       interface_vtable->method_call = (GDBusInterfaceMethodCallFunc)handle_method_call;
+
        introspection_data = g_dbus_node_info_new_for_xml(
                                introspection_xml, NULL);
        if (introspection_data == NULL) {
-               debug_print("Couldn't figure out XML.");
+               debug_print("Couldn't figure out XML.\n");
                return;
        }
-       
+
        interface_info = g_dbus_node_info_lookup_interface(
                                introspection_data,
                                "org.gnome.Shell.CalendarServer");
@@ -198,16 +200,9 @@ void connect_dbus(void)
 
 void disconnect_dbus(void)
 {
+       debug_print("disconnect_dbus() invoked\n");
        g_bus_unown_name(dbus_own_id);
-}
 
-#else
-void connect_dbus(void)
-{
-       debug_print("DBUS calendar export is not supported with Glib < 2.26\n");
+       g_free(interface_vtable);
+       interface_vtable = NULL;
 }
-void disconnect_dbus(void)
-{
-       debug_print("DBUS calendar export is not supported with Glib < 2.26\n");
-}
-#endif