gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r24783 - in gnunet-gtk: . src/fs


From: gnunet
Subject: [GNUnet-SVN] r24783 - in gnunet-gtk: . src/fs
Date: Mon, 5 Nov 2012 21:26:14 +0100

Author: LRN
Date: 2012-11-05 21:26:14 +0100 (Mon, 05 Nov 2012)
New Revision: 24783

Added:
   gnunet-gtk/src/fs/gnunet-fs-gtk.conf.in
Removed:
   gnunet-gtk/src/fs/gnunet-fs-gtk.conf
Modified:
   gnunet-gtk/configure.ac
   gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
Log:
Implement get_default_download_directory()

Modified: gnunet-gtk/configure.ac
===================================================================
--- gnunet-gtk/configure.ac     2012-11-05 20:05:38 UTC (rev 24782)
+++ gnunet-gtk/configure.ac     2012-11-05 20:26:14 UTC (rev 24783)
@@ -53,6 +53,9 @@
  CFLAGS="-fno-strict-aliasing $CFLAGS"
 fi
 
+# Default to unix configuration
+ENABLE_ON_UNIX=""
+ENABLE_ON_W32="#"
 # Check system type
 case "$host_os" in
 *darwin* | *rhapsody* | *macosx*)
@@ -88,6 +91,8 @@
      AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
      AC_CHECK_LIB(intl, gettext)
      LDFLAGS="$LDFLAGS -no-undefined"
+     ENABLE_ON_W32=""
+     ENABLE_ON_UNIX="#"
      build_target="cygwin"
      ;;
 *mingw*)
@@ -98,6 +103,8 @@
      LDFLAGS="$LDFLAGS -Wl,-no-undefined -Wl,--export-all-symbols -lws2_32"
      CFLAGS="-mms-bitfields $CFLAGS"
      LIBS="$LIBS -lws2_32 -lplibc -lole32"
+     ENABLE_ON_W32=""
+     ENABLE_ON_UNIX="#"
      build_target="mingw"
      ;;
 *)
@@ -108,6 +115,9 @@
 
 AM_CONDITIONAL(MINGW,   test "$build_target" = "mingw")
 
+AC_SUBST(ENABLE_ON_UNIX)
+AC_SUBST(ENABLE_ON_W32)
+
 GN_LIB_LDFLAGS="-export-dynamic -no-undefined"
 AC_SUBST(GN_LIB_LDFLAGS)
 
@@ -500,6 +510,7 @@
 src/include/Makefile
 src/lib/Makefile
 src/fs/Makefile
+src/fs/gnunet-fs-gtk.conf
 src/peerinfo/Makefile
 src/setup/Makefile
 src/statistics/Makefile

Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk.conf
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.conf        2012-11-05 20:05:38 UTC (rev 
24782)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.conf        2012-11-05 20:26:14 UTC (rev 
24783)
@@ -1,6 +0,0 @@
-[gnunet-fs-gtk]
-MAX_PARALLEL_DOWNLOADS = 128
-MAX_PARALLEL_REQUESTS = 100000
-
-[uri]
-fs = gnunet-fs-gtk

Added: gnunet-gtk/src/fs/gnunet-fs-gtk.conf.in
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.conf.in                             (rev 0)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.conf.in     2012-11-05 20:26:14 UTC (rev 
24783)
@@ -0,0 +1,8 @@
+[gnunet-fs-gtk]
+MAX_PARALLEL_DOWNLOADS = 128
+MAX_PARALLEL_REQUESTS = 100000
address@hidden@ DEFAULT_DOWNLOAD_DIRECTORY = "~/Documents/Downloads"
address@hidden@ DEFAULT_DOWNLOAD_DIRECTORY = "~/Downloads"
+
+[uri]
+fs = gnunet-fs-gtk

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2012-11-05 20:05:38 UTC 
(rev 24782)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c     2012-11-05 20:26:14 UTC 
(rev 24783)
@@ -340,21 +340,47 @@
  * This should get the default download directory (so that GNUnet
  * won't offer the user to download files to the 'bin' subdirectory,
  * or whatever is the cwd).  Returns NULL on failure (such as
- * non-existend directory).  Should also preserve the last setting (so
+ * non-existing directory).  
+ * TODO: Should also preserve the last setting (so
  * if the user saves files somewhere else, next time we default to
  * somewhere else, at least until application restart, or maybe even
  * between application restarts).
  *
  * Fills the 'buffer' up to 'size' bytes, returns a pointer to it.
+ * Buffer will be NUL-terminated, if not NULL.
  */
 static char *
 get_default_download_directory (char *buffer, size_t size)
 {
-  /* FIXME-FEATURE: implement... */
-  return NULL;
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
+  char *dirname;
+  size_t dirname_len;
+  size_t copy_bytes;
+
+  cfg = GNUNET_FS_GTK_get_configuration ();
+
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, 
"gnunet-fs-gtk",
+                                                           
"DEFAULT_DOWNLOAD_DIRECTORY",
+                                                           &dirname))
+    return NULL;
+
+  if (GNUNET_YES != GNUNET_DISK_directory_test ((const char *) dirname))
+  {
+    GNUNET_free (dirname);
+    return NULL;
+  }
+
+  dirname_len = strlen (dirname);
+  if (dirname_len >= size)
+    copy_bytes = size - 1;
+  else
+    copy_bytes = dirname_len;
+  memcpy (buffer, dirname, copy_bytes);
+  buffer[copy_bytes] = '\0';
+  GNUNET_free (dirname);
+  return buffer;
 }
 
-
 /**
  * Called recursively to build a suggested filename by prepending
  * suggested names for its parent directories (if any).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]