aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fs/gnunet-fs-gtk.conf6
-rw-r--r--src/fs/gnunet-fs-gtk.conf.in8
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c34
3 files changed, 38 insertions, 10 deletions
diff --git a/src/fs/gnunet-fs-gtk.conf b/src/fs/gnunet-fs-gtk.conf
deleted file mode 100644
index cdb23843..00000000
--- a/src/fs/gnunet-fs-gtk.conf
+++ /dev/null
@@ -1,6 +0,0 @@
1[gnunet-fs-gtk]
2MAX_PARALLEL_DOWNLOADS = 128
3MAX_PARALLEL_REQUESTS = 100000
4
5[uri]
6fs = gnunet-fs-gtk
diff --git a/src/fs/gnunet-fs-gtk.conf.in b/src/fs/gnunet-fs-gtk.conf.in
new file mode 100644
index 00000000..027f3b0f
--- /dev/null
+++ b/src/fs/gnunet-fs-gtk.conf.in
@@ -0,0 +1,8 @@
1[gnunet-fs-gtk]
2MAX_PARALLEL_DOWNLOADS = 128
3MAX_PARALLEL_REQUESTS = 100000
4@ENABLE_ON_W32@ DEFAULT_DOWNLOAD_DIRECTORY = "~/Documents/Downloads"
5@ENABLE_ON_UNIX@ DEFAULT_DOWNLOAD_DIRECTORY = "~/Downloads"
6
7[uri]
8fs = gnunet-fs-gtk
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 6ea99b89..e2a6918c 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -340,20 +340,46 @@ clear_metadata_display ()
340 * This should get the default download directory (so that GNUnet 340 * This should get the default download directory (so that GNUnet
341 * won't offer the user to download files to the 'bin' subdirectory, 341 * won't offer the user to download files to the 'bin' subdirectory,
342 * or whatever is the cwd). Returns NULL on failure (such as 342 * or whatever is the cwd). Returns NULL on failure (such as
343 * non-existend directory). Should also preserve the last setting (so 343 * non-existing directory).
344 * TODO: Should also preserve the last setting (so
344 * if the user saves files somewhere else, next time we default to 345 * if the user saves files somewhere else, next time we default to
345 * somewhere else, at least until application restart, or maybe even 346 * somewhere else, at least until application restart, or maybe even
346 * between application restarts). 347 * between application restarts).
347 * 348 *
348 * Fills the 'buffer' up to 'size' bytes, returns a pointer to it. 349 * Fills the 'buffer' up to 'size' bytes, returns a pointer to it.
350 * Buffer will be NUL-terminated, if not NULL.
349 */ 351 */
350static char * 352static char *
351get_default_download_directory (char *buffer, size_t size) 353get_default_download_directory (char *buffer, size_t size)
352{ 354{
353 /* FIXME-FEATURE: implement... */ 355 const struct GNUNET_CONFIGURATION_Handle *cfg;
354 return NULL; 356 char *dirname;
355} 357 size_t dirname_len;
358 size_t copy_bytes;
359
360 cfg = GNUNET_FS_GTK_get_configuration ();
356 361
362 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gnunet-fs-gtk",
363 "DEFAULT_DOWNLOAD_DIRECTORY",
364 &dirname))
365 return NULL;
366
367 if (GNUNET_YES != GNUNET_DISK_directory_test ((const char *) dirname))
368 {
369 GNUNET_free (dirname);
370 return NULL;
371 }
372
373 dirname_len = strlen (dirname);
374 if (dirname_len >= size)
375 copy_bytes = size - 1;
376 else
377 copy_bytes = dirname_len;
378 memcpy (buffer, dirname, copy_bytes);
379 buffer[copy_bytes] = '\0';
380 GNUNET_free (dirname);
381 return buffer;
382}
357 383
358/** 384/**
359 * Called recursively to build a suggested filename by prepending 385 * Called recursively to build a suggested filename by prepending