[GnomeMeeting-devel-list] [PATCH] gnomemeeting-dbus-helper



Hi,

this helper can answer the following questions:
* what version is installed?
* what protocols does it support?
* is protocol $foo supported?

There is something that gnomemeeting itself will have to do, but I don't
think there is support for it yet: there should be some:
gchar *get_local_address (const gchar *protocol);
function somewhere, that the dbus component will use to implement a
GetLocalAddress method.

I made some progress on gossip-gnomemeeting during the holidays (I have
a bunch of pre-patches to submit for discussion), and getting calls
(which surprisingly involves making them!) should work quite soon. But
to make calls (which involves telling the other end where we get them!)
needs these introspection-like features are needed if we want to.

I have a pseudo-gm in python that makes gnomemeeting useless for testing
purposes, but the real thing will certainly be needed at some point!

Snark
diff -urN gnomemeeting/gnomemeeting.service.in gnomemeeting.patched/gnomemeeting.service.in
--- gnomemeeting/gnomemeeting.service.in	2004-12-23 09:04:57 +0100
+++ gnomemeeting.patched/gnomemeeting.service.in	2004-12-30 18:57:40 +0100
@@ -1,4 +1,7 @@
-[D-BUS Service]
+[Gnomemeeting's D-BUS Instance Service]
 Name=org.gnomemeeting.instance
 Exec= prefix@/bin/gnomemeeting
 
+[Gnomemeeting's D-BUS Info Service]
+Name=org.gnomemeeting.info
+Exec= prefix@/bin/gnomemeeting-dbus-helper
\ Pas de fin de ligne à la fin du fichier.
diff -urN gnomemeeting/src/dbus-helper.cpp gnomemeeting.patched/src/dbus-helper.cpp
--- gnomemeeting/src/dbus-helper.cpp	1970-01-01 01:00:00 +0100
+++ gnomemeeting.patched/src/dbus-helper.cpp	2004-12-30 19:00:11 +0100
@@ -0,0 +1,246 @@
+
+/* GnomeMeeting -- A Video-Conferencing application
+ * Copyright (C) 2000-2004 Damien Sandras
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * GnomeMeting is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OpenH323 and Pwlib, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OpenH323 program, as long
+ * as you do follow the requirements of the GNU GPL for all the rest of the
+ * software thus combined.
+ */
+
+/*
+ *                         dbus_component.cpp  -  description
+ *                         --------------------------
+ *   begin                : Fri Dec 31 2004
+ *   copyright            : (C) 2004 by Julien Puydt
+ *   description          : Implementation of a DBUS helper.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "../config.h"
+
+/* Here is the description of method calls that this little program
+ * manages for gnomemeeting:
+ *
+ * "GetVersion"
+ * in: nil
+ * out: string (version)
+ * 
+ * "GetSupportedProtocols"
+ * in: nil
+ * out: list of strings (supported protocols, "h323", "callto" [and "sip"?])
+ *
+ * "IsProtocolSupported"
+ * in: string (protocol)
+ * out: boolean (will gnomemeeting's GetLocalAddress be able to provide one
+ *               of that type?)
+ *
+ */
+
+#define GM_INFO_SERVICE   "org.gnomemeeting.info"
+#define GM_INFO_INTERFACE "org.gnomemeeting.info"
+#define GM_HELPER_OBJECT  "/org/gnomemeeting/helper"
+
+/* this function is called by DBUS when a watched type of message
+ * arrives ; it is only used to know if we're still connected to the bus
+ */
+static DBusHandlerResult filter_func (DBusConnection *connection,
+				      DBusMessage *message,
+				      void *user_data);
+
+
+/* this function dispatches the message to the other helpers */
+static DBusHandlerResult path_message_func (DBusConnection *connection,
+					    DBusMessage *message,
+					    void *user_data);
+
+
+/* those are the helper functions that take care of the actual handling */
+static void handle_get_version (DBusConnection *connection,
+				DBusMessage *message);
+static void handle_get_supported_protocols (DBusConnection *connection,
+					    DBusMessage *message);
+static void handle_is_protocol_supported (DBusConnection *connection,
+					  DBusMessage *message);
+
+static DBusObjectPathVTable call_vtable = {
+  NULL,
+  path_message_func,
+  NULL,
+};
+
+/* real implementation */
+
+static DBusHandlerResult
+filter_func (DBusConnection *connection,
+	     DBusMessage *message,
+	     void *user_data)
+{
+  if (dbus_message_is_signal (message,
+			      DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL,
+			      "Disconnected")) {
+
+    exit (-1);
+  }
+
+  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+
+static DBusHandlerResult
+path_message_func (DBusConnection *connection,
+		   DBusMessage *message,
+		   void *user_data)
+{
+  DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+  if (dbus_message_is_method_call (message,
+				   GM_INFO_SERVICE,
+				   "GetVersion")) {
+
+    handle_get_version (connection, message);
+    result = DBUS_HANDLER_RESULT_HANDLED;
+  }
+  else if (dbus_message_is_method_call (message,
+					GM_INFO_SERVICE,
+					"GetSupportedProtocols")) {
+
+    handle_get_supported_protocols (connection, message);
+    result = DBUS_HANDLER_RESULT_HANDLED;
+  }
+  else if (dbus_message_is_method_call (message, GM_INFO_SERVICE,
+					"IsProtocolSupported")) {
+
+    handle_is_protocol_supported (connection, message);
+    result = DBUS_HANDLER_RESULT_HANDLED;
+  }
+
+  return result;
+}
+
+static void
+handle_get_version (DBusConnection *connection,
+		    DBusMessage *message)
+{
+  DBusMessage *reply = NULL;
+
+  reply = dbus_message_new_method_return (message);
+  (void)dbus_message_append_args (reply,
+				  DBUS_TYPE_STRING, VERSION,
+				  DBUS_TYPE_INVALID);
+  (void)dbus_connection_send (connection, reply, NULL);
+  dbus_connection_flush (connection);
+  dbus_message_unref (reply);
+}
+
+static void
+handle_get_supported_protocols (DBusConnection *connection,
+				DBusMessage *message)
+{
+  DBusMessage *reply = NULL;
+
+  reply = dbus_message_new_method_return (message);
+  (void)dbus_message_append_args (reply,
+				  DBUS_TYPE_STRING, "h323",
+				  DBUS_TYPE_STRING, "callto",
+				  DBUS_TYPE_INVALID);
+  (void)dbus_connection_send (connection, reply, NULL);
+  dbus_connection_flush (connection);
+  dbus_message_unref (reply);
+}
+
+static void
+handle_is_protocol_supported (DBusConnection *connection,
+			      DBusMessage *message)
+{
+  gchar *protocol = NULL;
+  DBusMessage *reply = NULL;
+  gboolean result = FALSE;
+
+  if (dbus_message_get_args (message, NULL,
+			     DBUS_TYPE_STRING, &protocol,
+			     DBUS_TYPE_INVALID)) {
+    
+    reply = dbus_message_new_method_return (message);
+
+    if (strcmp (protocol, "h323") == 0
+	|| strcmp (protocol, "callto") == 0) {
+      
+      result = TRUE;
+    } else {
+
+      result = FALSE;
+    }
+
+    (void)dbus_message_append_args (reply,
+				    DBUS_TYPE_BOOLEAN, result,
+				    DBUS_TYPE_INVALID);
+    (void)dbus_connection_send (connection, reply, NULL);
+    dbus_connection_flush (connection);
+    dbus_message_unref (reply);
+  }
+}
+
+/* well, it's needed anyway */
+int
+main (int argc, char *argv[])
+{
+  DBusConnection *connection = NULL;
+  GMainLoop *loop = NULL;
+
+  connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
+  if (connection == NULL) {
+
+    exit (-1);
+  }
+
+  if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) {
+
+    dbus_connection_disconnect (connection);
+    exit (-1);
+  }
+
+  if (!dbus_connection_register_object_path (connection,
+					     GM_HELPER_OBJECT,
+					     &call_vtable, NULL)) {
+
+    dbus_connection_disconnect (connection);
+    exit (-1);
+  }
+
+  if (dbus_bus_acquire_service (connection,
+				GM_INFO_SERVICE, 0, NULL) == -1) {
+
+    dbus_connection_disconnect (connection);
+    exit (-1);
+  }
+
+  loop = g_main_loop_new (NULL, FALSE);
+  dbus_connection_setup_with_g_main (connection,
+				     g_main_loop_get_context (loop));
+
+  g_main_loop_run (loop);
+}
diff -urN gnomemeeting/src/Makefile.am gnomemeeting.patched/src/Makefile.am
--- gnomemeeting/src/Makefile.am	2004-11-14 08:11:17 +0100
+++ gnomemeeting.patched/src/Makefile.am	2004-12-30 18:58:34 +0100
@@ -63,6 +63,9 @@
 
 if HAS_DBUS 
 gnomemeeting_SOURCES += dbus_component.cpp dbus_component.h
+bin_PROGRAMS += gnomemeeting-dbus-helper
+gnomemeeting_dbus_helper_SOURCES = dbus-helper.cpp
+gnomemeeting_dbus_helper_LDADD = @DBUS_LIBS@
 endif
 
 if HAS_HOWL


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]