rpms/gnome-user-share/devel gnome-user-share-0.11-export-session-id.patch, NONE, 1.1 gnome-user-share.spec, 1.21, 1.22

Owen Taylor (otaylor) fedora-extras-commits at redhat.com
Thu Jul 12 13:28:03 UTC 2007


Author: otaylor

Update of /cvs/extras/rpms/gnome-user-share/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv7790

Modified Files:
	gnome-user-share.spec 
Added Files:
	gnome-user-share-0.11-export-session-id.patch 
Log Message:
* Thu Jul 12 2007 Owen Taylor <otaylor at redhat.com> - 0.11-4
- Add a patch from SVN to export DBUS session ID via Avahi (b.g.o #455307)


gnome-user-share-0.11-export-session-id.patch:

--- NEW FILE gnome-user-share-0.11-export-session-id.patch ---
--- gnome-user-share-0.11/user_share.c.export-session-id	2007-03-06 05:30:27.000000000 -0500
+++ gnome-user-share-0.11/user_share.c	2007-07-12 09:22:35.000000000 -0400
@@ -27,6 +27,10 @@
 #include <glib/gi18n.h>
 #include <X11/Xlib.h>
 
+#ifdef HAVE_DBUS_1_1
+#include <dbus/dbus.h>
+#endif
+
 #ifdef HAVE_AVAHI
 #include <avahi-client/client.h>
 #include <avahi-client/publish.h>
@@ -45,6 +49,7 @@
 
 #include <gconf/gconf-client.h>
 
+#include <stdarg.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -63,6 +68,10 @@
 #define FILE_SHARING_ENABLED "/desktop/gnome/file_sharing/enabled"
 #define FILE_SHARING_REQUIRE_PASSWORD "/desktop/gnome/file_sharing/require_password"
 
+#ifdef HAVE_DBUS_1_1
+static char *dbus_session_id;
+#endif
+
 static GMainLoop *loop = NULL;
 static pid_t httpd_pid = 0;
 static guint disabled_timeout_tag = 0;
@@ -220,6 +229,42 @@ get_share_name (void)
 	return name;
 }
 
+#ifdef HAVE_DBUS_1_1
+static void
+init_dbus() {
+	/* The only use we make of D-BUS is to fetch the session BUS ID so we can export
+	 * it via mDNS, so we connect and then immediately disconnect. If we were using
+	 * the D-BUS session BUS for something persistent, the following code should use
+	 * dbus_bus_get() and skip the shutdown. (Avahi uses the D-BUS  _system_ bus
+	 * internally.)
+	 */
+	
+	DBusError derror;
+	DBusConnection *connection;
+
+	dbus_error_init(&derror);
+	
+	connection = dbus_bus_get_private(DBUS_BUS_SESSION, &derror);
+	if (connection == NULL) {
+        g_printerr("Failed to connect to session bus: %s", derror.message);
+        dbus_error_free(&derror);
+		return;
+	}
+
+    dbus_session_id = dbus_bus_get_id(connection, &derror);
+    if (dbus_session_id == NULL) {
+		/* This can happen if the D-BUS library has been upgraded to 1.1, but the
+		 * user's session hasn't yet been restarted
+		 */
+        g_printerr("Failed to get session BUS ID: %s", derror.message);
+        dbus_error_free(&derror);
+	}
+		
+	dbus_connection_set_exit_on_disconnect(connection, FALSE);
+	dbus_connection_close(connection);
+	dbus_connection_unref(connection);
+}
+#endif
 
 #ifdef HAVE_AVAHI
 
@@ -230,19 +275,64 @@ static int avahi_port = 0;
 static AvahiEntryGroup *entry_group = NULL;
 static char *avahi_name = NULL;
 
+static AvahiStringList*
+new_text_record_list (const char *first_key,
+					  const char *first_value,
+					  ...)
+{
+    va_list args;
+    const char *k;
+    const char *v;
+    AvahiStringList *list;
+
+    if (first_key == NULL)
+        return NULL;
+
+    list = NULL;
+    
+    list = avahi_string_list_add_pair (list, first_key, first_value);
+    
+    va_start (args, first_value);
+    k = va_arg (args, const char*);
+    if (k)
+        v = va_arg (args, const char*);
+    while (k != NULL) {
+        list = avahi_string_list_add_pair (list, k, v);
+        
+        k = va_arg (args, const char*);
+        if (k)
+            v = va_arg (args, const char*);
+    }
+    
+    va_end(args);
+    
+    return list;
+}
 
 static gboolean
 create_service (void) {
     int ret;
+    AvahiStringList *txt_records;
 
 	if (avahi_name == NULL) {
 		avahi_name = g_strdup (get_share_name ());
 	}
 
-	ret = avahi_entry_group_add_service (entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 
-										 AVAHI_PUBLISH_USE_MULTICAST,
-										 avahi_name, "_webdav._tcp", NULL, NULL, 
-										 avahi_port, "u=guest", NULL);
+	txt_records = new_text_record_list ("u", "guest",
+#ifdef HAVE_DBUS_1_1
+										/* This must be last */
+										dbus_session_id != NULL ? "org.freedesktop.od.session" : NULL, dbus_session_id,
+#endif									   
+										NULL);
+	
+	ret = avahi_entry_group_add_service_strlst (entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 
+												 AVAHI_PUBLISH_USE_MULTICAST,
+												 avahi_name, "_webdav._tcp", NULL, NULL, 
+												 avahi_port,
+		                                         txt_records);
+
+	avahi_string_list_free(txt_records);
+	
 	if (ret < 0) {
 		return FALSE;
 	}
@@ -735,6 +825,10 @@ main (int argc, char **argv)
 		    G_IO_IN,
 		    x_input, xdisplay);
     g_io_channel_unref (channel);
+
+#ifdef HAVE_DBUS_1_1
+	init_dbus();
+#endif	
 	
 #ifdef HAVE_AVAHI
 	if (!init_avahi ()) {    
--- gnome-user-share-0.11/configure.in.export-session-id	2007-03-06 04:56:32.000000000 -0500
+++ gnome-user-share-0.11/configure.in	2007-07-12 09:22:35.000000000 -0400
@@ -59,11 +59,17 @@ if test "x$msg_avahi" = "xno" -a "x$enab
 	AC_SUBST(HOWL_LIBS)
 fi
 
+PKG_CHECK_EXISTS(dbus-1 >= 1.1.1, have_dbus_1_1=true, have_dbus_1_1=false)
+if $have_dbus_1_1 ; then
+   DBUS_MODULES=dbus-1
+   AC_DEFINE(HAVE_DBUS_1_1, 1, [Set to true if we have D-BUS 1.1])
+fi
+
 if test "x$msg_avahi" = "xno" -a "x$msg_howl" = "xno"; then
   AC_MSG_ERROR([Neither avahi nor howl detected. Gnome-user-share needs a mDNS implementation.])
 fi
 
-PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.2.0 gconf-2.0)
+PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.2.0 gconf-2.0 $DBUS_MODULES)
 AC_SUBST(USER_SHARE_CFLAGS)
 AC_SUBST(USER_SHARE_LIBS)
 


Index: gnome-user-share.spec
===================================================================
RCS file: /cvs/extras/rpms/gnome-user-share/devel/gnome-user-share.spec,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- gnome-user-share.spec	24 Apr 2007 02:18:06 -0000	1.21
+++ gnome-user-share.spec	12 Jul 2007 13:27:28 -0000	1.22
@@ -1,13 +1,15 @@
 Summary: Gnome user file sharing
 Name: gnome-user-share
 Version: 0.11
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPL
 Group: System Environment/Libraries
 URL: http://www.gnome.org
 Source0: %{name}-%{version}.tar.bz2
 # http://bugzilla.gnome.org/show_bug.cgi?id=422047
 Patch0: gnome-user-share-0.11-invisible-char.patch
+# http://bugzilla.gnome.org/show_bug.cgi?id=455307
+Patch1: gnome-user-share-0.11-export-session-id.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 
 Requires: httpd >= 2.2.0
@@ -38,6 +40,7 @@
 %prep
 %setup -q
 %patch0 -p1 -b .invisible-char
+%patch1 -p1 -b .export-session-id
 
 %build
 %configure
@@ -87,6 +90,9 @@
 %{_sysconfdir}/gconf/schemas/*
 
 %changelog
+* Thu Jul 12 2007 Owen Taylor <otaylor at redhat.com> - 0.11-4
+- Add a patch from SVN to export DBUS session ID via Avahi (b.g.o #455307)
+
 * Mon Apr 23 2007 Matthias Clasen  <mclasen at redhat.com> - 0.11-3
 - Improve %%description (#235677)
 




More information about the scm-commits mailing list