cheese r789 - in branches/cheese-dbus: . client data src
- From: kaserf svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r789 - in branches/cheese-dbus: . client data src
- Date: Sun, 29 Jun 2008 15:55:49 +0000 (UTC)
Author: kaserf
Date: Sun Jun 29 15:55:49 2008
New Revision: 789
URL: http://svn.gnome.org/viewvc/cheese?rev=789&view=rev
Log:
A client/client-bindings.h A client/dbus_client.c A client/Makefile
Added:
branches/cheese-dbus/acinclude.m4
branches/cheese-dbus/client/
branches/cheese-dbus/client/Makefile
branches/cheese-dbus/client/client-bindings.h
branches/cheese-dbus/client/dbus_client.c
branches/cheese-dbus/data/org.gnome.Cheese.service.in
branches/cheese-dbus/src/cheese-dbus-glue.h
branches/cheese-dbus/src/cheese-dbus-infos.xml
branches/cheese-dbus/src/cheese-dbus.c
branches/cheese-dbus/src/cheese-dbus.h
Modified:
branches/cheese-dbus/ChangeLog
branches/cheese-dbus/configure.ac
branches/cheese-dbus/data/Makefile.am
branches/cheese-dbus/src/Makefile.am
branches/cheese-dbus/src/cheese-webcam.c
branches/cheese-dbus/src/cheese-window.c
Added: branches/cheese-dbus/acinclude.m4
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/acinclude.m4 Sun Jun 29 15:55:49 2008
@@ -0,0 +1,40 @@
+dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
+dnl
+dnl example
+dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
+
+AC_DEFUN([AS_AC_EXPAND],
+[
+ EXP_VAR=[$1]
+ FROM_VAR=[$2]
+
+ dnl first expand prefix and exec_prefix if necessary
+ prefix_save=$prefix
+ exec_prefix_save=$exec_prefix
+
+ dnl if no prefix given, then use /usr/local, the default prefix
+ if test "x$prefix" = "xNONE"; then
+ prefix=$ac_default_prefix
+ fi
+ dnl if no exec_prefix given, then use prefix
+ if test "x$exec_prefix" = "xNONE"; then
+ exec_prefix=$prefix
+ fi
+
+ full_var="$FROM_VAR"
+ dnl loop until it doesn't change anymore
+ while true; do
+ new_full_var="`eval echo $full_var`"
+ if test "x$new_full_var"="x$full_var"; then break; fi
+ full_var=$new_full_var
+ done
+
+ dnl clean up
+ full_var=$new_full_var
+ AC_SUBST([$1], "$full_var")
+
+ dnl restore prefix and exec_prefix
+ prefix=$prefix_save
+ exec_prefix=$exec_prefix_save
+])
Added: branches/cheese-dbus/client/Makefile
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/client/Makefile Sun Jun 29 15:55:49 2008
@@ -0,0 +1,37 @@
+CC = gcc
+
+GTK_CFLAGS = $(shell pkg-config --cflags gtk+-2.0)
+GTK_LIBS = $(shell pkg-config --libs gtk+-2.0)
+
+GLADE_CFLAGS = $(shell pkg-config --cflags libglade-2.0)
+GLADE_LIBS = $(shell pkg-config --libs libglade-2.0)
+
+DBUS_CFLAGS = $(shell pkg-config dbus-1 --cflags)
+DBUS_LIBS = $(shell pkg-config dbus-1 --libs)
+
+GSTREAMER_CFLAGS = $(shell pkg-config --cflags gstreamer-0.10 gstreamer-plugins-base-0.10)
+GSTREAMER_LIBS = $(shell pkg-config --libs gstreamer-0.10 gstreamer-plugins-base-0.10) -lgstinterfaces-0.10
+
+GNOME_VFS_CFLAGS = $(shell pkg-config --cflags gnome-vfs-2.0)
+GNOME_VFS_LIBS = $(shell pkg-config --libs gnome-vfs-2.0)
+
+GDK_CFLAGS = $(shell pkg-config --cflags gdk-2.0)
+GDK_LIBS = $(shell pkg-config --libs gdk-2.0)
+
+CFLAGS = -g -O2 -Wall $(DBUS_CFLAGS) $(GTK_CFLAGS) $(GLADE_CFLAGS) $(GSTREAMER_CFLAGS) $(GNOME_VFS_CFLAGS) $(GDK_CFLAGS)
+LDFLAGS = -lpthread $(DBUS_LIBS) $(GTK_LIBS) $(GLADE_LIBS) $(GSTREAMER_LIBS) $(GNOME_VFS_LIBS) $(GDK_LIBS)
+
+SOURCES = dbus_client.c
+
+OBJS = $(SOURCES:%.c=%.o)
+
+all: dbus_client
+
+dbus_client: $(OBJS) $(LIBS)
+
+dbus_client.o: dbus_client.c
+
+clean:
+ rm -f dbus_server $(OBJS)
+ rm -f dbus_client $(OBJS)
+ rm -f *~
Added: branches/cheese-dbus/client/client-bindings.h
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/client/client-bindings.h Sun Jun 29 15:55:49 2008
@@ -0,0 +1,51 @@
+/* Generated by dbus-binding-tool; do not edit! */
+
+#include <glib/gtypes.h>
+#include <glib/gerror.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_gnome_Cheese
+#define DBUS_GLIB_CLIENT_WRAPPERS_org_gnome_Cheese
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+gboolean
+org_gnome_Cheese_activate (DBusGProxy *proxy, const char * IN_message, GError **error)
+
+{
+ return dbus_g_proxy_call (proxy, "activate", error, G_TYPE_STRING, IN_message, G_TYPE_INVALID, G_TYPE_INVALID);
+}
+
+typedef void (*org_gnome_Cheese_activate_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
+
+static void
+org_gnome_Cheese_activate_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
+{
+ DBusGAsyncData *data = (DBusGAsyncData*) user_data;
+ GError *error = NULL;
+ dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
+ (*(org_gnome_Cheese_activate_reply)data->cb) (proxy, error, data->userdata);
+ return;
+}
+
+static
+#ifdef G_HAVE_INLINE
+inline
+#endif
+DBusGProxyCall*
+org_gnome_Cheese_activate_async (DBusGProxy *proxy, const char * IN_message, org_gnome_Cheese_activate_reply callback, gpointer userdata)
+
+{
+ DBusGAsyncData *stuff;
+ stuff = g_new (DBusGAsyncData, 1);
+ stuff->cb = G_CALLBACK (callback);
+ stuff->userdata = userdata;
+ return dbus_g_proxy_begin_call (proxy, "activate", org_gnome_Cheese_activate_async_callback, stuff, g_free, G_TYPE_STRING, IN_message, G_TYPE_INVALID);
+}
+#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_gnome_Cheese */
+
+G_END_DECLS
Added: branches/cheese-dbus/client/dbus_client.c
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/client/dbus_client.c Sun Jun 29 15:55:49 2008
@@ -0,0 +1,111 @@
+#include "client-bindings.h"
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <glib-object.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+static GMainLoop *loop = NULL;
+
+void
+photo_saved_cb (DBusGProxy *proxy, char *path, gpointer user_data);
+
+static void run_mainloop (void)
+{
+ GMainContext *ctx;
+
+ ctx = g_main_loop_get_context (loop);
+
+ while (g_main_context_pending (ctx))
+ g_main_context_iteration (ctx, FALSE);
+}
+
+int
+main(int argc, char **argv)
+{
+ /* Somewhere in the code, we want to execute EchoString remote method */
+ DBusGProxy *proxy;
+ DBusGConnection *connection;
+ GError *error = NULL;
+
+ g_type_init ();
+ loop = g_main_loop_new (NULL, FALSE);
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+ if (connection == NULL)
+ {
+ g_warning("Unable to connect to dbus: %sn", error->message);
+ g_error_free (error);
+ /* Basically here, there is a problem, since there is no dbus :) */
+ return -1;
+ }
+
+ g_message ("connection established");
+
+ /* This won't trigger activation! */
+ /*proxy = dbus_g_proxy_new_for_name (connection,
+ "org.gnome.dbusTestService",
+ "/org/gnome/dbusTestService",
+ "org.gnome.dbusTestService");*/
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "org.gnome.Cheese",
+ "/org/gnome/cheese",
+ "org.gnome.Cheese");
+ /*proxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);*/
+
+ /*proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.Tracker",
+ "/org/freedesktop/tracker",
+ "org.freedesktop.Tracker");*/
+
+ g_message ("proxy client set");
+
+ /* The method call will trigger activation, more on that later */
+ //if (!org_gnome_dbusTestService_echo_string (proxy, "The string we want echo-ed", &result, &error))
+ //if(!dbus_g_proxy_call (proxy, "EchoString", &error, G_TYPE_STRING, "The string we want echo-ed", G_TYPE_INVALID, G_TYPE_STRING, &result, G_TYPE_INVALID))
+ //if (!dbus_g_proxy_call (proxy, "ListNames", &error, G_TYPE_INVALID, G_TYPE_STRV, &result, G_TYPE_INVALID))
+ //if(!dbus_g_proxy_call (proxy, "GetStatus", &error, G_TYPE_INVALID, G_TYPE_STRING, &result, G_TYPE_INVALID))
+ if(!org_gnome_Cheese_activate (proxy, "activate plz", &error))
+ {
+ /* Method failed, the GError is set, let's warn everyone */
+ g_warning ("Woops remote method failed: %s", error->message);
+ //g_warning ("error in echo string");
+ g_error_free (error);
+ return -1;
+ }
+
+ g_message ("after triggered activation");
+
+
+ //connect to signal and wait...
+ //dbus_g_object_register_marshaller(marshal_VOID__STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (proxy, "photoSaved", G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "photoSaved", G_CALLBACK(photo_saved_cb), connection, NULL);
+
+ //while(TRUE){
+ // sleep (1);
+ //}
+
+ run_mainloop ();
+ dbus_g_connection_flush (connection);
+ g_main_loop_run (loop);
+
+ /* Cleanup */
+ g_object_unref (proxy);
+
+ /* The DBusGConnection should never be unreffed, it lives once and is shared amongst the process */
+
+ return 1;
+}
+
+void
+photo_saved_cb (DBusGProxy *proxy, char *path, gpointer user_data)
+{
+ g_message (path);
+ exit (0);
+}
Modified: branches/cheese-dbus/configure.ac
==============================================================================
--- branches/cheese-dbus/configure.ac (original)
+++ branches/cheese-dbus/configure.ac Sun Jun 29 15:55:49 2008
@@ -35,6 +35,14 @@
$3=`eval echo [$]ac_expand`
])
+
+#dbus
+AS_AC_EXPAND(DATADIR, $datadir)
+
+DBUS_SERVICES_DIR="$DATADIR/dbus-1/services"
+AC_SUBST(DBUS_SERVICES_DIR)
+AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is])
+
# FULL_LIBEXECDIR is used for X-GNOME-Bugzilla-ExtraInfoScript expansion
# in data/cheese.desktop.in.in
CHEESE_FULLPATH(libexecdir, NONE, FULL_LIBEXECDIR)
Modified: branches/cheese-dbus/data/Makefile.am
==============================================================================
--- branches/cheese-dbus/data/Makefile.am (original)
+++ branches/cheese-dbus/data/Makefile.am Sun Jun 29 15:55:49 2008
@@ -25,6 +25,17 @@
bugreportdir = $(libexecdir)/cheese
bugreport_SCRIPTS = cheese-bugreport.sh
+# Dbus service file
+servicedir = $(DBUS_SERVICES_DIR)
+service_in_files = org.gnome.Cheese.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+# Rule to make the service file with bindir expanded
+$(service_DATA): $(service_in_files) Makefile
+ @sed -e "s|@bindir@|$(bindir)|" $<> $@
+
+
+
if GCONF_SCHEMAS_INSTALL
install-data-local:
-GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
Added: branches/cheese-dbus/data/org.gnome.Cheese.service.in
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/data/org.gnome.Cheese.service.in Sun Jun 29 15:55:49 2008
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.Cheese
+Exec=/usr/bin/cheese
Modified: branches/cheese-dbus/src/Makefile.am
==============================================================================
--- branches/cheese-dbus/src/Makefile.am (original)
+++ branches/cheese-dbus/src/Makefile.am Sun Jun 29 15:55:49 2008
@@ -15,6 +15,8 @@
cheese.c \
cheese-countdown.c \
cheese-countdown.h \
+ cheese-dbus.c \
+ cheese-dbus.h \
cheese-effect-chooser.c \
cheese-effect-chooser.h \
cheese-fileutil.c \
@@ -56,3 +58,16 @@
cheese_LDADD += $(HILDON_LIBS)
endif
+
+#dbus
+BUILT_SOURCES = cheese-dbus-glue.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 = cheese-dbus-infos.xml
+
+#Rule to generate the binding headers
+cheese-dbus-glue.h: cheese-dbus-infos.xml
+ dbus-binding-tool --prefix=cheese_dbus --mode=glib-server $<> $@
Added: branches/cheese-dbus/src/cheese-dbus-glue.h
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/src/cheese-dbus-glue.h Sun Jun 29 15:55:49 2008
@@ -0,0 +1,120 @@
+/* Generated by dbus-binding-tool; do not edit! */
+
+
+#ifndef __dbus_glib_marshal_cheese_dbus_MARSHAL_H__
+#define __dbus_glib_marshal_cheese_dbus_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* BOOLEAN:STRING,POINTER (/tmp/dbus-binding-tool-c-marshallers.EVERDU:1) */
+extern void dbus_glib_marshal_cheese_dbus_BOOLEAN__STRING_POINTER (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+dbus_glib_marshal_cheese_dbus_BOOLEAN__STRING_POINTER (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER) (gpointer data1,
+ gpointer arg_1,
+ gpointer arg_2,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__STRING_POINTER callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+ gboolean v_return;
+
+ g_return_if_fail (return_value != NULL);
+ g_return_if_fail (n_param_values == 3);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_BOOLEAN__STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_string (param_values + 1),
+ g_marshal_value_peek_pointer (param_values + 2),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+G_END_DECLS
+
+#endif /* __dbus_glib_marshal_cheese_dbus_MARSHAL_H__ */
+
+#include <dbus/dbus-glib.h>
+static const DBusGMethodInfo dbus_glib_cheese_dbus_methods[] = {
+ { (GCallback) cheese_dbus_activate, dbus_glib_marshal_cheese_dbus_BOOLEAN__STRING_POINTER, 0 },
+};
+
+const DBusGObjectInfo dbus_glib_cheese_dbus_object_info = {
+ 0,
+ dbus_glib_cheese_dbus_methods,
+ 1,
+"org.gnome.Cheese\0activate\0S\0message\0I\0s\0\0\0",
+"org.gnome.Cheese\0photoSaved\0\0",
+"\0"
+};
+
Added: branches/cheese-dbus/src/cheese-dbus-infos.xml
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/src/cheese-dbus-infos.xml Sun Jun 29 15:55:49 2008
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<node name="/org/gnome/cheese">
+ <interface name="org.gnome.Cheese">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="cheese_dbus"/>
+ <method name="activate">
+ <arg type="s" name="message" direction="in" />
+ </method>
+ <signal name="photoSaved">
+ <arg type="s" name="path" />
+ </signal>
+ </interface>
+</node>
Added: branches/cheese-dbus/src/cheese-dbus.c
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/src/cheese-dbus.c Sun Jun 29 15:55:49 2008
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
+ * Copyright (C) 2007,2008 Jaap Haitsma <jaap haitsma org>
+ * Copyright (C) 2008 Felix Kaser <f kaser gmx net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 of the License, or
+ * (at your option) 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 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 <cheese-config.h>
+#endif
+
+#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+#include "cheese-dbus.h"
+#include "cheese-dbus-glue.h"
+#include <glib.h>
+#include <glib-object.h>
+#include <unistd.h>
+#include <gtk/gtk.h>
+
+enum
+{
+ PHOTO_SAVED,
+ LAST_SIGNAL
+};
+
+static guint cheese_dbus_signals [LAST_SIGNAL];
+
+G_DEFINE_TYPE (CheeseDbus, cheese_dbus, G_TYPE_OBJECT);
+
+gboolean
+cheese_dbus_activate (char * message)
+{
+ g_message ("cheese_dbus has been activated with: %s", message);
+ g_print ("blabla");
+ return TRUE;
+}
+
+void
+cheese_dbus_emit_signal (CheeseDbus *server, char *path)
+{
+ g_message ("emit signal: %s", path);
+ g_signal_emit (server, cheese_dbus_signals[PHOTO_SAVED], 0, path);
+}
+
+void
+cheese_dbus_class_init (CheeseDbusClass *klass)
+{
+ GError *error = NULL;
+
+ /* Init the DBus connection, per-klass */
+ klass->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (klass->connection == NULL)
+ {
+ g_warning("Unable to connect to dbus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ cheese_dbus_signals [PHOTO_SAVED] = g_signal_new ("photo_saved", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ dbus_g_object_type_install_info (CHEESE_TYPE_DBUS, &dbus_glib_cheese_dbus_object_info);
+}
+
+void
+cheese_dbus_init (CheeseDbus *server)
+{
+ GError *error = NULL;
+ DBusGProxy *driver_proxy;
+ CheeseDbusClass *klass = CHEESE_DBUS_GET_CLASS (server);
+ int request_ret;
+
+ /* Register DBUS path */
+ dbus_g_connection_register_g_object (klass->connection,
+ "/org/gnome/cheese",
+ G_OBJECT (server));
+
+
+ /* Register the service name, the constant here are defined in dbus-glib-bindings.h */
+ driver_proxy = dbus_g_proxy_new_for_name (klass->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ if(!org_freedesktop_DBus_request_name (driver_proxy,
+ "org.gnome.Cheese",
+ 0, &request_ret, /* See tutorial for more infos about these */
+ &error))
+ {
+ g_warning("Unable to register service: %s", error->message);
+ g_error_free (error);
+ }
+ g_object_unref (driver_proxy);
+
+
+ //connect to photo_saved signal from cheese_webcam
+ //g_signal_connect (cheese_dbus->cheese_webcam, "photo_saved", G_CALLBACK (cheese_dbus_photo_saved_cb), cheese_dbus->cheese_webcam);
+}
+
+CheeseDbus *
+cheese_dbus_new ()
+{
+ CheeseDbus *server;
+ server = g_object_new (CHEESE_TYPE_DBUS, NULL);
+ return server;
+}
Added: branches/cheese-dbus/src/cheese-dbus.h
==============================================================================
--- (empty file)
+++ branches/cheese-dbus/src/cheese-dbus.h Sun Jun 29 15:55:49 2008
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
+ * Copyright (C) 2007,2008 Jaap Haitsma <jaap haitsma org>
+ * Copyright (C) 2008 Felix Kaser <f kaser gmx net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 of the License, or
+ * (at your option) 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 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 _CHEESE_DBUS_H_
+#define _CHEESE_DBUS_H_
+
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+#include "cheese-window.h"
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+ GObjectClass parent_class;
+ DBusGConnection *connection;
+
+ void (* photo_saved) (char * path);
+}CheeseDbusClass;
+
+typedef struct {
+ GObject parent;
+}CheeseDbus;
+
+
+#define CHEESE_TYPE_DBUS (cheese_dbus_get_type ())
+#define CHEESE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_DBUS, CheeseDbus))
+#define CHEESE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_DBUS, CheeseDbusClass))
+#define CHEESE_IS_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_DBUS))
+#define CHEESE_IS_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_DBUS))
+#define CHEESE_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_DBUS, CheeseDbusClass))
+
+
+GType
+cheese_dbus_get_type (void);
+CheeseDbus *
+cheese_dbus_new (void);
+gboolean
+cheese_dbus_activate (char *);
+void
+cheese_dbus_emit_signal (CheeseDbus *, char *);
+
+G_END_DECLS
+
+#endif /* _CHEESE_DBUS_H_ */
Modified: branches/cheese-dbus/src/cheese-webcam.c
==============================================================================
--- branches/cheese-dbus/src/cheese-webcam.c (original)
+++ branches/cheese-dbus/src/cheese-webcam.c Sun Jun 29 15:55:49 2008
@@ -35,6 +35,7 @@
#include "cheese-webcam.h"
#include "cheese-flash.h"
+#include "cheese-dbus.h"
G_DEFINE_TYPE (CheeseWebcam, cheese_webcam, G_TYPE_OBJECT)
@@ -95,7 +96,7 @@
int selected_device;
CheeseVideoFormat *current_format;
GHashTable *supported_resolutions;
-
+
CheeseFlash *flash;
} CheeseWebcamPrivate;
Modified: branches/cheese-dbus/src/cheese-window.c
==============================================================================
--- branches/cheese-dbus/src/cheese-window.c (original)
+++ branches/cheese-dbus/src/cheese-window.c Sun Jun 29 15:55:49 2008
@@ -50,6 +50,7 @@
#include "gedit-message-area.h"
#include "cheese-no-camera.h"
#include "cheese-prefs-dialog.h"
+#include "cheese-dbus.h"
#define SHUTTER_SOUNDS 5
@@ -72,6 +73,7 @@
WebcamMode webcam_mode;
CheeseGConf *gconf;
CheeseFileUtil *fileutil;
+ CheeseDbus *server;
GtkWidget *window;
GtkWidget *notebook;
@@ -205,6 +207,9 @@
static void
cheese_window_photo_saved_cb (CheeseWebcam *webcam, CheeseWindow *cheese_window)
{
+ //notify DBUS
+ cheese_dbus_emit_signal (cheese_window->server, cheese_window->photo_filename);
+
// TODO look at this g_free
g_free (cheese_window->photo_filename);
cheese_window->photo_filename = NULL;
@@ -1450,6 +1455,7 @@
cheese_window = g_new0 (CheeseWindow, 1);
cheese_window->gconf = cheese_gconf_new ();
+ cheese_window->server = cheese_dbus_new ();
cheese_window->audio_play_counter = 0;
cheese_window->rand = g_rand_new ();
cheese_window->fileutil = cheese_fileutil_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]