gnome-user-share r185 - trunk



Author: hadess
Date: Tue Jan 22 10:05:07 2008
New Revision: 185
URL: http://svn.gnome.org/viewvc/gnome-user-share?rev=185&view=rev

Log:
2008-01-22  Bastien Nocera  <hadess hadess net>

	* Makefile.am: update for changes
	* configure.in: update requirements

	* md5.c:
	* md5.h: Remove

	* file-share-properties.c: (password_string_from_setting),
	(write_out_password), (enable_check_toggled):
	Use GChecksum API to get the MD5 version of the password

	* user_share.c: (lookup_public_dir), (get_port), (get_share_name),
	(new_text_record_list), (create_service), (ensure_conf_dir),
	(spawn_httpd): 
	Use g_get_user_special_dir() to get the Public directory,
	Use g_mkdir_with_parents() to create the directory if missing

	(Closes: #511159)



Removed:
   trunk/md5.c
   trunk/md5.h
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/configure.in
   trunk/file-share-properties.c
   trunk/user_share.c

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Tue Jan 22 10:05:07 2008
@@ -54,7 +54,7 @@
 	$(X_LIBS) $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)
 
 gnome_file_share_properties_SOURCES = \
-	file-share-properties.c md5.c md5.h
+	file-share-properties.c
 
 gnome_file_share_properties_LDADD = \
 	$(USER_SHARE_CONFIG_LIBS)

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Jan 22 10:05:07 2008
@@ -69,11 +69,11 @@
   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 $DBUS_MODULES)
+PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.15.2 gconf-2.0 $DBUS_MODULES)
 AC_SUBST(USER_SHARE_CFLAGS)
 AC_SUBST(USER_SHARE_LIBS)
 
-PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.2.0 gtk+-2.0 >= 2.4.0 libglade-2.0 gconf-2.0)
+PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gtk+-2.0 >= 2.4.0 libglade-2.0 gconf-2.0)
 AC_SUBST(USER_SHARE_CONFIG_CFLAGS)
 AC_SUBST(USER_SHARE_CONFIG_LIBS)
 	

Modified: trunk/file-share-properties.c
==============================================================================
--- trunk/file-share-properties.c	(original)
+++ trunk/file-share-properties.c	Tue Jan 22 10:05:07 2008
@@ -31,8 +31,6 @@
 #include <glade/glade.h>
 #include <gconf/gconf-client.h>
 
-#include "md5.h"
-
 #define FILE_SHARING_DIR "/desktop/gnome/file_sharing"
 #define FILE_SHARING_ENABLED "/desktop/gnome/file_sharing/enabled"
 #define FILE_SHARING_REQUIRE_PASSWORD "/desktop/gnome/file_sharing/require_password"
@@ -88,17 +86,14 @@
 write_out_password (const char *password)
 {
     char *to_hash;
-    unsigned char digest[16];
     char *ascii_digest;
     char *line;
     char *filename;
     FILE *file;
 
     to_hash = g_strdup_printf ("%s:%s:%s", USER, REALM, password);
-    gnome_user_share_md5_string (to_hash, digest);
+    ascii_digest = g_compute_checksum_for_string (G_CHECKSUM_MD5, to_hash, strlen (to_hash));
     g_free (to_hash);
-    
-    ascii_digest = gnome_user_share_md5_digest_to_ascii (digest);
     line = g_strdup_printf ("%s:%s:%s\n", USER, REALM, ascii_digest);
     g_free (ascii_digest);
 

Modified: trunk/user_share.c
==============================================================================
--- trunk/user_share.c	(original)
+++ trunk/user_share.c	Tue Jan 22 10:05:07 2008
@@ -79,87 +79,19 @@
 static char *
 lookup_public_dir (void)
 {
-  FILE *file;
-  char *config_file;
-  char buffer[512];
-  char *user_dir;
-  char *p, *d;
-  int len;
-  int relative;
-  
-  config_file = g_build_filename (g_get_user_config_dir (), "user-dirs.dirs", NULL);
-  file = fopen (config_file, "r");
-  free (config_file);
-  if (file == NULL)
-	  goto error;
-  
-  user_dir = NULL;
-  while (fgets (buffer, sizeof (buffer), file)) {
-	  /* Remove newline at end */
-	  len = strlen (buffer);
-      if (len > 0 && buffer[len-1] == '\n')
-		  buffer[len-1] = 0;
-      
-      p = buffer;
-      while (*p == ' ' || *p == '\t')
-		  p++;
-      
-      if (!g_str_has_prefix (p, "XDG_PUBLICSHARE_DIR"))
-		  continue;
-      p += strlen ("XDG_PUBLICSHARE_DIR");
-	  
-      while (*p == ' ' || *p == '\t')
-		  p++;
-	  
-      if (*p != '=')
-		  continue;
-      p++;
-      
-      while (*p == ' ' || *p == '\t')
-		  p++;
-	  
-      if (*p != '"')
-		  continue;
-      p++;
-      
-      relative = 0;
-      if (strncmp (p, "$HOME/", 6) == 0) {
-		  p += 6;
-		  relative = 1;
-	  }
-      else if (*p != '/')
-		  continue;
-      
-      if (relative)	{
-		  user_dir = g_malloc (strlen (g_get_home_dir()) + 1 + strlen (p) + 1);
-		  strcpy (user_dir, g_get_home_dir ());
-		  strcat (user_dir, "/");
-	  } else {
-		  user_dir = g_malloc (strlen (p) + 1);
-		  *user_dir = 0;
-	  }
-      
-      d = user_dir + strlen (user_dir);
-      while (*p && *p != '"') {
-		  if ((*p == '\\') && (*(p+1) != 0))
-			  p++;
-		  *d++ = *p++;
-	  }
-      *d = 0;
-  }  
-  fclose (file);
-
-  /* Don't export the whole homedir (happens if xdg-user-dirs disabled the dir) */
-  if (user_dir && strcmp (user_dir, g_get_home_dir ()) == 0) {
-	  g_free (user_dir);
-	  user_dir = NULL;
-  }
-  
-  if (user_dir)
-	  return user_dir;
-  
- error:
-  return g_build_filename (g_get_home_dir (), "Public", NULL);
+	const char *public_dir;
+	char *dir;
+
+	public_dir = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
+	if (public_dir != NULL && strcmp (public_dir, g_get_home_dir ()) != 0) {
+		g_mkdir_with_parents (public_dir, 0755);
+		return g_strdup (public_dir);
+	}
+	g_free (public_dir);
+
+	dir = g_build_filename (g_get_home_dir (), "Public", NULL);
+	g_mkdir_with_parents (public_dir, 0755);
+	return dir;
 }
 
 static int
@@ -513,28 +445,12 @@
 
 
 static void
-ensure_public_dir (char *dirname)
-{
-    if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
-		mkdir (dirname, 0755);
-    }
-}
-
-static void
 ensure_conf_dir (void)
 {
     char *dirname;
 
-    dirname = g_build_filename (g_get_home_dir (), ".gnome2", NULL);
-    if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
-		mkdir (dirname, 0755);
-    }
-    g_free (dirname);
-    
     dirname = g_build_filename (g_get_home_dir (), ".gnome2", "user-share", NULL);
-    if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
-		mkdir (dirname, 0755);
-    }
+    g_mkdir_with_parents (dirname, 0755);
     g_free (dirname);
 }
 
@@ -571,11 +487,9 @@
     gboolean got_pidfile;
     GConfClient *client;
     char *str;
-	char *public_dir;
+    char *public_dir;
 
-	public_dir = lookup_public_dir ();
-	
-    ensure_public_dir (public_dir);
+    public_dir = lookup_public_dir ();
     ensure_conf_dir ();
 
     i = 0;
@@ -625,7 +539,7 @@
     g_free (free1);
     g_free (free2);
     g_free (free3);
-	g_free (public_dir);
+    g_free (public_dir);
 
     if (!res) {
 		fprintf (stderr, "error spawning httpd: %s\n",



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