livewp-astro.c livewp-astro.h \
livewp-rules.c livewp-rules.h \
livewp-settings.c livewp-settings.h livewp-common.h \
- livewp-config.c livewp-config.h
+ livewp-config.c livewp-config.h \
+ livewp-dbus.c livewp-dbus.h
bin_PROGRAMS = livewp
livewp_SOURCES = $(SOURCE_FILES)
-livewp_CFLAGS = -Wall $(EXAMPLE_CFLAGS) $(OSSO_CFLAGS)
+livewp_CFLAGS = -Wall $(EXAMPLE_CFLAGS) $(OSSO_CFLAGS) -DAPPLICATION
livewp_LDADD = $(EXAMPLE_LIBS) $(OSSO_LIBS)
desktoplib_LTLIBRARIES = liblivewp-home-widget.la
desktoplibdir = $(HILDON_DESKTOP_LIB_DIR)
-liblivewp_home_widget_la_SOURCES = livewp-main.c \
- livewp-home-widget.c livewp-home-widget.h \
+liblivewp_home_widget_la_SOURCES = livewp-home-widget.c livewp-home-widget.h \
livewp-astro.c livewp-astro.h \
livewp-rules.c livewp-rules.h \
livewp-settings.c livewp-settings.h livewp-common.h \
- livewp-config.c livewp-config.h
+ livewp-config.c livewp-config.h \
+ livewp-dbus.c livewp-dbus.h
liblivewp_home_widget_la_LIBADD = $(EXAMPLE_LIBS) $(OSSO_LIBS)
AM_CFLAGS = -Wall $(EXAMPLE_CFLAGS) $(OSSO_CFLAGS)
--- /dev/null
+/* vim: set sw=4 ts=4 et: */
+/*
+ * This file is part of Live Wallpaper (livewp)
+ *
+ * Copyright (C) 2010 Vlad Vasiliev
+ * Copyright (C) 2010 Tanya Makova
+ * for the code
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+*/
+
+/*******************************************************************************/
+#include "livewp-common.h"
+#include "livewp-dbus.h"
+/*******************************************************************************/
+void
+livewp_initialize_dbus(Animation_WallpaperPrivate *priv){
+ gchar *tmp;
+ gchar *filter_string;
+ DBusError error;
+
+// if(!priv->dbus_is_initialize){
+ dbus_error_init (&error);
+ /* Add D-BUS signal handler for 'status_changed' */
+#if !defined APPLICATION
+ priv->dbus_conn = (DBusConnection *) osso_get_sys_dbus_connection(priv->osso);
+ priv->dbus_conn_session = (DBusConnection *) osso_get_dbus_connection(priv->osso);
+#else
+ priv->dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ priv->dbus_conn_session = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
+
+ if (priv->dbus_conn_session){
+ filter_string =
+ g_strdup_printf("type='signal', interface='%s'", LIVEWP_SIGNAL_INTERFACE);
+ dbus_bus_add_match(priv->dbus_conn_session, filter_string, &error);
+ if (dbus_error_is_set(&error)){
+ fprintf(stderr,"dbus_bus_add_match failed: %s", error.message);
+ dbus_error_free(&error);
+ }
+ g_free(filter_string);
+ /* add the callback */
+ dbus_connection_add_filter(priv->dbus_conn_session,
+ get_livewp_signal_cb,
+ NULL, NULL);
+ }
+
+ // }
+
+}
+/*******************************************************************************/
+void
+livewp_deinitialize_dbus(Animation_WallpaperPrivate *priv){
+#ifdef DEBUGFUNCTIONCALL
+ START_FUNCTION;
+#endif
+ gchar *filter_string;
+ DBusError error;
+
+ if (priv->dbus_conn){
+#if defined APPLICATION
+ dbus_connection_close(priv->dbus_conn);
+ dbus_connection_unref(priv->dbus_conn);
+#endif
+ }
+ if (priv->dbus_conn_session){
+ filter_string =
+ g_strdup_printf("type='signal', interface='%s'", LIVEWP_SIGNAL_INTERFACE);
+
+ dbus_error_init (&error);
+ dbus_bus_remove_match(priv->dbus_conn_session, filter_string, &error);
+ if (!dbus_error_is_set(&error)){
+ dbus_connection_remove_filter(priv->dbus_conn_session,
+ (DBusHandleMessageFunction)get_livewp_signal_cb,
+ NULL);
+ }else{
+
+ fprintf(stderr,"dbus_bus_add_match failed: %s", error.message);
+ dbus_error_free(&error);
+ }
+
+ g_free(filter_string);
+ }
+
+}
+/*******************************************************************************/
+void
+send_dbus_signal (Animation_WallpaperPrivate *priv,
+ const gchar *interface,
+ const gchar *path,
+ const gchar *member)
+{
+ gboolean success;
+
+ DBusMessage *message = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL);
+ dbus_message_set_interface (message, interface);
+ dbus_message_set_path (message, path);
+ dbus_message_set_member (message, member);
+ success = dbus_connection_send (priv->dbus_conn_session, message, NULL);
+ dbus_message_unref (message);
+
+ fprintf (stderr, "%s '%s' message.\n",
+ success ? "Sent" : "Failed to send",
+ member);
+
+}
+
+/*******************************************************************************/
+DBusHandlerResult
+get_livewp_signal_cb(DBusConnection *conn, DBusMessage *msg, Animation_WallpaperPrivate *priv){
+
+#ifdef DEBUGFUNCTIONCALL
+ START_FUNCTION;
+#endif
+
+#if defined APPLICATION
+ fprintf(stderr,"Application\n");
+#else
+ fprintf(stderr,"Plugin\n");
+#endif
+
+ if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_RELOAD_CONFIG)){
+ if(read_config(priv)){
+ fprintf(stderr, "\nCan not read config file.\n");
+ }else{
+ read_config(priv);
+#ifndef APPLICATION
+ reload_scene(priv->desktop_plugin);
+#endif
+ }
+ }
+#ifndef APPLICATION
+// if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_RELOAD_PLUGIN))
+// reload_livewp_plugin();
+#endif
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+/*******************************************************************************/
+
--- /dev/null
+/* vim: set sw=4 ts=4 et: */
+/*
+ * This file is part of Live Wallpaper (livewp)
+ *
+ * Copyright (C) 2010 Vlad Vasiliev
+ * Copyright (C) 2010 Tanya Makova
+ * for the code
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+*/
+/*******************************************************************************/
+#ifndef _livewp_dbus_h
+#define _livewp_dbus_h 1
+/*******************************************************************************/
+#include "livewp-common.h"
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+/*******************************************************************************/
+void livewp_initialize_dbus(Animation_WallpaperPrivate *priv);
+void livewp_deinitialize_dbus(Animation_WallpaperPrivate *priv);
+DBusHandlerResult
+get_livewp_signal_cb(DBusConnection *conn, DBusMessage *msg, Animation_WallpaperPrivate *priv);
+void send_dbus_signal (Animation_WallpaperPrivate *priv, const gchar *interface, const gchar *path, const gchar *member);
+/*******************************************************************************/
+#endif