Patch which uses gconf for default SMB domain



I've added support to the SMB method for reading it's default
workgroup/domain from gconf. The 'network' module already uses this to
display machines in 'network://'.

Just wanted to double check that I've done this correctly before I
commit it. Note that there is no reliable way (without assuming things
about the internals of libsmbclient) to change default workgroup in an
SMBCTX on the fly.

Patch attached.

Cheers,
Nate
Index: modules/smb-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/smb-method.c,v
retrieving revision 1.32
diff -U3 -r1.32 smb-method.c
--- modules/smb-method.c	23 May 2005 22:21:55 -0000	1.32
+++ modules/smb-method.c	23 May 2005 22:47:35 -0000
@@ -38,6 +38,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <gconf/gconf-client.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <libgnomevfs/gnome-vfs-mime.h>
 
@@ -51,6 +52,8 @@
 
 #include <libsmbclient.h>
 
+#define PATH_GCONF_GNOME_VFS_SMB_WORKGROUP "/system/smb/workgroup"
+
 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
 
 typedef enum {
@@ -603,6 +606,8 @@
 try_init (void)
 {
 	char *path;
+	GConfClient *gclient;
+	gchar *workgroup;
 	struct stat statbuf;
 
 	LOCK_SMB();
@@ -630,6 +635,20 @@
 		smb_context->callbacks.get_cached_srv_fn    = get_cached_server;
 		smb_context->callbacks.remove_cached_srv_fn = remove_cached_server;
 		smb_context->callbacks.purge_cached_fn      = purge_cached;
+
+		gclient = gconf_client_get_default ();
+		if (gclient) {
+			workgroup = gconf_client_get_string (gclient, 
+					PATH_GCONF_GNOME_VFS_SMB_WORKGROUP, NULL);
+
+			/* libsmbclient frees this on it's own, so make sure 
+			 * to use simple system malloc */
+			if (workgroup && workgroup[0])
+				smb_context->workgroup = strdup (workgroup);
+			
+			g_free (workgroup);
+			g_object_unref (gclient);
+		}
 
 		if (!smbc_init_context (smb_context)) {
 			smbc_free_context (smb_context, FALSE);
Index: schemas/system_smb.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-vfs/schemas/system_smb.schemas.in,v
retrieving revision 1.1
diff -U3 -r1.1 system_smb.schemas.in
--- schemas/system_smb.schemas.in	9 Jan 2004 13:20:44 -0000	1.1
+++ schemas/system_smb.schemas.in	23 May 2005 22:47:36 -0000
@@ -6,9 +6,12 @@
       <applyto>/system/smb/workgroup</applyto>
       <owner>gnome-vfs</owner>
       <type>string</type>
+      <default></default>
       <locale name="C">
         <short>SMB workgroup</short>
-        <long>The window workgroup the user is part of</long>
+        <long>The window workgroup the user is part of. In order for 
+        a new workgroup to fully take effect the user may need to log 
+        out and log back in. </long>
       </locale>
     </schema>
   </schemalist>


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