[GnomeMeeting-devel-list] Dbus in gnomemeeting
- From: Julien PUYDT <jpuydt free fr>
- To: GnomeMeeting development mailing list <gnomemeeting-devel-list gnome org>
- Subject: [GnomeMeeting-devel-list] Dbus in gnomemeeting
- Date: Mon, 04 Apr 2005 14:02:39 +0200
Hi,
this is the in-progress work on dbus in gnomemeeting. Not fully debugged
yet ;-)
Snark
diff -urN gnomemeeting-cvs-20050323.CVS.orig/configure.in gnomemeeting-cvs-20050323.CVS.patched.clean/configure.in
--- gnomemeeting-cvs-20050323.CVS.orig/configure.in 2005-04-03 09:40:56.000000000 +0200
+++ gnomemeeting-cvs-20050323.CVS.patched.clean/configure.in 2005-04-03 14:27:45.000000000 +0200
@@ -425,7 +425,7 @@
fi
if test x"${enable_dbus}" = xyes ; then
- PKG_CHECK_MODULES(DBUS, dbus-1 = 0.22 dbus-glib-1 = 0.22)
+ PKG_CHECK_MODULES(DBUS, dbus-1 = 0.31 dbus-glib-1 = 0.31)
GNOMEMEETING_CFLAGS="$GNOMEMEETING_CFLAGS $DBUS_CFLAGS -DHAS_DBUS"
GNOMEMEETING_LIBS="$GNOMEMEETING_LIBS $DBUS_LIBS"
fi
diff -urN gnomemeeting-cvs-20050323.CVS.orig/Makefile.am gnomemeeting-cvs-20050323.CVS.patched.clean/Makefile.am
--- gnomemeeting-cvs-20050323.CVS.orig/Makefile.am 2004-12-02 17:45:19.000000000 +0100
+++ gnomemeeting-cvs-20050323.CVS.patched.clean/Makefile.am 2005-04-03 14:28:38.000000000 +0200
@@ -37,7 +37,7 @@
gconftool-2 --shutdown
install-services: gnomemeeting.service
- cp gnomemeeting.service $(libdir)/dbus-1.0/services/
+ cp gnomemeeting.service $(datadir)/dbus-1/services/
if GCONF_SCHEMAS_INSTALL
install-data-local: install-schemas
diff -urN gnomemeeting-cvs-20050323.CVS.orig/src/dbus_component.cpp gnomemeeting-cvs-20050323.CVS.patched.clean/src/dbus_component.cpp
--- gnomemeeting-cvs-20050323.CVS.orig/src/dbus_component.cpp 2005-01-30 17:35:48.000000000 +0100
+++ gnomemeeting-cvs-20050323.CVS.patched.clean/src/dbus_component.cpp 2005-04-03 15:52:55.000000000 +0200
@@ -181,6 +181,8 @@
static void handle_get_call_info_message (DBusConnection *connection,
DBusMessage *message);
+static void handle_get_local_address_message (DBusConnection *connection,
+ DBusMessage *message);
/* definition of some helper DBUS-related data */
@@ -336,20 +338,20 @@
}
}
- if (self->connection != NULL) {
+ if (self->connection != NULL) {
/* we have a contact with the server, check the rest */
if (self->is_registered == FALSE)
- self->is_registered
+ self->is_registered
= dbus_connection_register_object_path (self->connection,
GM_DBUS_OBJECT_PATH,
&call_vtable, self);
-
+
if (self->owns_the_service == FALSE)
- self->owns_the_service
- = (dbus_bus_acquire_service (self->connection,
- GM_DBUS_SERVICE, 0, NULL) >= 0);
-
-
+ self->owns_the_service
+ = (dbus_bus_request_name (self->connection,
+ GM_DBUS_SERVICE, 0, NULL) >= 0);
+
+
}
return self->connection != NULL && self->is_registered && self->owns_the_service;
@@ -378,7 +380,7 @@
GM_DBUS_INTERFACE, "AddCall");
if (dbus_message_append_args (message,
- DBUS_TYPE_STRING, call_token,
+ DBUS_TYPE_STRING, &call_token,
DBUS_TYPE_INVALID)) {
(void)dbus_connection_send (self->connection, message, NULL);
@@ -407,7 +409,7 @@
GM_DBUS_INTERFACE, "DeleteCall");
if (dbus_message_append_args (message,
- DBUS_TYPE_STRING, call_token,
+ DBUS_TYPE_STRING, &call_token,
DBUS_TYPE_INVALID)) {
(void)dbus_connection_send (self->connection, message, NULL);
@@ -424,6 +426,7 @@
{
DBusComponent *self = NULL;
DBusMessage *message = NULL;
+ const gchar *state = NULL;
g_return_if_fail (IS_DBUS_COMPONENT (object));
@@ -435,8 +438,10 @@
message = dbus_message_new_signal (GM_DBUS_OBJECT_PATH,
GM_DBUS_INTERFACE, "StateChanged");
+ state = state_to_string (new_state);
+
if (dbus_message_append_args (message,
- DBUS_TYPE_STRING, state_to_string (new_state),
+ DBUS_TYPE_STRING, &state,
DBUS_TYPE_INVALID)) {
(void)dbus_connection_send (self->connection, message, NULL);
@@ -465,7 +470,7 @@
DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
if (dbus_message_is_signal (message,
- DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL,
+ DBUS_INTERFACE_LOCAL,
"Disconnected"))
{
@@ -526,6 +531,13 @@
handle_get_call_info_message (connection, message);
result = DBUS_HANDLER_RESULT_HANDLED;
}
+ else if (dbus_message_is_method_call (message,
+ GM_DBUS_SERVICE,
+ "GetLocalAddress")) {
+
+ handle_get_local_address_message (connection, message);
+ result = DBUS_HANDLER_RESULT_HANDLED;
+ }
return result;
}
@@ -556,16 +568,18 @@
GMH323EndPoint *ep = NULL;
ep = GnomeMeeting::Process ()->Endpoint ();
-
+
reply = dbus_message_new_method_return (message);
state = state_to_string (ep->GetCallingState ());
+
if (dbus_message_append_args (reply,
- DBUS_TYPE_STRING, state,
+ DBUS_TYPE_STRING, &state,
DBUS_TYPE_INVALID)) {
- (void)dbus_connection_send (connection, reply, NULL);
+ (void)dbus_connection_send (connection, reply, NULL);
dbus_connection_flush (connection);
}
+
dbus_message_unref (reply);
}
@@ -595,11 +609,11 @@
GMH323EndPoint *ep = NULL;
ep = GnomeMeeting::Process ()->Endpoint ();
-
+
reply = dbus_message_new_method_return (message);
call_token = (const char *)ep->GetCurrentCallToken ();
if (dbus_message_append_args (reply,
- DBUS_TYPE_STRING, call_token,
+ DBUS_TYPE_STRING, &call_token,
DBUS_TYPE_INVALID)) {
(void)dbus_connection_send (connection, reply, NULL);
@@ -635,9 +649,9 @@
}
reply = dbus_message_new_method_return (message);
if (dbus_message_append_args (reply,
- DBUS_TYPE_STRING, name,
- DBUS_TYPE_STRING, url,
- DBUS_TYPE_STRING, app,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_STRING, &url,
+ DBUS_TYPE_STRING, &app,
DBUS_TYPE_INVALID)) {
(void)dbus_connection_send (connection, reply, NULL);
@@ -651,6 +665,27 @@
}
+static void
+handle_get_local_address_message (DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusMessage *reply = NULL;
+ const gchar *address = "h323:h323.voxgratia.org";
+
+ reply = dbus_message_new_method_return (message);
+
+ if (dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID)) {
+
+ (void)dbus_connection_send (connection, reply, NULL);
+ dbus_connection_flush (connection);
+ }
+
+ dbus_message_unref (reply);
+}
+
+
/* implementation of the externally-visible api */
@@ -698,11 +733,11 @@
GM_DBUS_INTERFACE, "Call");
dbus_message_set_no_reply (message, TRUE);
-
+
if (dbus_message_append_args (message,
- DBUS_TYPE_STRING, address,
+ DBUS_TYPE_STRING, &address,
DBUS_TYPE_INVALID)) {
-
+
(void)dbus_connection_send (self->connection,
message, NULL);
dbus_connection_flush (self->connection);
diff -urN gnomemeeting-cvs-20050323.CVS.orig/src/dbus_component.h gnomemeeting-cvs-20050323.CVS.patched.clean/src/dbus_component.h
--- gnomemeeting-cvs-20050323.CVS.orig/src/dbus_component.h 2005-01-30 17:35:48.000000000 +0100
+++ gnomemeeting-cvs-20050323.CVS.patched.clean/src/dbus_component.h 2005-04-03 15:48:52.000000000 +0200
@@ -87,6 +87,11 @@
* out : string (name), string (url) and string (application)
* action: none
*
+ * "GetLocalAddress"
+ * in : nil
+ * out : string (local call address)
+ * action: none
+ *
* Signals:
* ========
*
diff -urN gnomemeeting.patched/gnomemeeting.service.in gnomemeeting.patched.patched/gnomemeeting.service.in
--- gnomemeeting.patched/gnomemeeting.service.in 2005-04-04 10:10:34.000000000 +0200
+++ gnomemeeting.patched.patched/gnomemeeting.service.in 2005-04-04 10:11:24.000000000 +0200
@@ -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
diff -urN gnomemeeting.patched/src/dbus-helper.cpp gnomemeeting.patched.patched/src/dbus-helper.cpp
--- gnomemeeting.patched/src/dbus-helper.cpp 1970-01-01 01:00:00.000000000 +0100
+++ gnomemeeting.patched.patched/src/dbus-helper.cpp 2005-04-04 10:12:01.000000000 +0200
@@ -0,0 +1,249 @@
+
+/* 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_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;
+ const gchar *version = VERSION;
+
+ 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;
+ const gchar *h323 = "h323";
+ const gchar *callto = "callto";
+
+ 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_request_name (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.patched/src/Makefile.am gnomemeeting.patched.patched/src/Makefile.am
--- gnomemeeting.patched/src/Makefile.am 2005-04-04 10:10:34.000000000 +0200
+++ gnomemeeting.patched.patched/src/Makefile.am 2005-04-04 10:11:03.000000000 +0200
@@ -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]