aboutsummaryrefslogtreecommitdiff
path: root/src/main_window_file_publish.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_window_file_publish.c')
-rw-r--r--src/main_window_file_publish.c145
1 files changed, 53 insertions, 92 deletions
diff --git a/src/main_window_file_publish.c b/src/main_window_file_publish.c
index 78a5dd4a..c7ba8cd1 100644
--- a/src/main_window_file_publish.c
+++ b/src/main_window_file_publish.c
@@ -196,16 +196,13 @@ update_selectivity ()
196 * Add a file to the tree model. 196 * Add a file to the tree model.
197 * 197 *
198 * @param filename file to add 198 * @param filename file to add
199 * @param anonymity_level anonymity to use 199 * @param bo block options to use
200 * @param expiration expiration time for the entry
201 * @param do_index should we index or insert? 200 * @param do_index should we index or insert?
202 * @param iter parent entry, or NULL for top-level addition 201 * @param iter parent entry, or NULL for top-level addition
203 */ 202 */
204static void 203static void
205add_file_at_iter (const char *filename, 204add_file_at_iter (const char *filename,
206 uint32_t anonymity_level, 205 const struct GNUNET_FS_BlockOptions *bo,
207 uint32_t priority,
208 struct GNUNET_TIME_Absolute expiration,
209 int do_index, 206 int do_index,
210 GtkTreeIter *iter) 207 GtkTreeIter *iter)
211{ 208{
@@ -275,9 +272,7 @@ add_file_at_iter (const char *filename,
275 ksk_uri, 272 ksk_uri,
276 meta, 273 meta,
277 do_index, 274 do_index,
278 anonymity_level, 275 bo);
279 priority,
280 expiration);
281 GNUNET_CONTAINER_meta_data_destroy (meta); 276 GNUNET_CONTAINER_meta_data_destroy (meta);
282 GNUNET_FS_uri_destroy (ksk_uri); 277 GNUNET_FS_uri_destroy (ksk_uri);
283 if (S_ISDIR (sbuf.st_mode)) 278 if (S_ISDIR (sbuf.st_mode))
@@ -288,8 +283,8 @@ add_file_at_iter (const char *filename,
288 0, file_size_fancy, 283 0, file_size_fancy,
289 1, (gboolean) do_index, 284 1, (gboolean) do_index,
290 2, short_fn, 285 2, short_fn,
291 3, (guint)anonymity_level, 286 3, (guint) bo->anonymity_level,
292 4, (guint) priority, 287 4, (guint) bo->content_priority,
293 5, fi, 288 5, fi,
294 -1); 289 -1);
295 GNUNET_free (file_size_fancy); 290 GNUNET_free (file_size_fancy);
@@ -302,14 +297,13 @@ add_file_at_iter (const char *filename,
302 * Add an empty directory to the tree model. 297 * Add an empty directory to the tree model.
303 * 298 *
304 * @param name name for the directory 299 * @param name name for the directory
300 * @param bo block options
305 * @param iter parent entry, or NULL for top-level addition 301 * @param iter parent entry, or NULL for top-level addition
306 * @param pos iterator to set to the location of the new element 302 * @param pos iterator to set to the location of the new element
307 */ 303 */
308static void 304static void
309create_dir_at_iter (const char *name, 305create_dir_at_iter (const char *name,
310 uint32_t anonymity, 306 const struct GNUNET_FS_BlockOptions *bo,
311 uint32_t priority,
312 struct GNUNET_TIME_Absolute expiration,
313 GtkTreeIter *iter, 307 GtkTreeIter *iter,
314 GtkTreeIter *pos) 308 GtkTreeIter *pos)
315{ 309{
@@ -343,16 +337,14 @@ create_dir_at_iter (const char *name,
343 row_reference, 337 row_reference,
344 NULL, 338 NULL,
345 meta, 339 meta,
346 anonymity, 340 bo);
347 priority,
348 expiration);
349 GNUNET_CONTAINER_meta_data_destroy (meta); 341 GNUNET_CONTAINER_meta_data_destroy (meta);
350 gtk_tree_store_set (ts, pos, 342 gtk_tree_store_set (ts, pos,
351 0, MARKER_DIR_FILE_SIZE, 343 0, MARKER_DIR_FILE_SIZE,
352 1, (gboolean) GNUNET_NO, 344 1, (gboolean) GNUNET_NO,
353 2, name, 345 2, name,
354 3, (guint) anonymity, 346 3, (guint) bo->anonymity_level,
355 4, (guint) priority, 347 4, (guint) bo->content_priority,
356 5, fi, 348 5, fi,
357 -1); 349 -1);
358 update_selectivity (); 350 update_selectivity ();
@@ -451,19 +443,9 @@ struct AddDirContext
451 struct GNUNET_CONTAINER_MetaData *no_ksk; 443 struct GNUNET_CONTAINER_MetaData *no_ksk;
452 444
453 /** 445 /**
454 * Content expiration to use. 446 * Block options to use.
455 */ 447 */
456 struct GNUNET_TIME_Absolute expiration; 448 struct GNUNET_FS_BlockOptions bo;
457
458 /**
459 * Anonymity level to use.
460 */
461 uint32_t anonymity_level;
462
463 /**
464 * Content priority to use.
465 */
466 uint32_t priority;
467 449
468 /** 450 /**
469 * Index or insert? 451 * Index or insert?
@@ -633,8 +615,7 @@ remove_keyword (void *cls,
633 * @param ts tree store to modify 615 * @param ts tree store to modify
634 * @param iter position in the tree store for this file 616 * @param iter position in the tree store for this file
635 * @param filename file to add 617 * @param filename file to add
636 * @param anonymity_level anonymity to use 618 * @param bo block options
637 * @param expiration expiration time for the entry
638 * @param do_index should we index or insert? 619 * @param do_index should we index or insert?
639 * @param md_no_ksk metadata with keywords NOT to add 620 * @param md_no_ksk metadata with keywords NOT to add
640 * @param meta metadata for the file 621 * @param meta metadata for the file
@@ -643,9 +624,7 @@ static void
643add_entry_to_ts (GtkTreeStore *ts, 624add_entry_to_ts (GtkTreeStore *ts,
644 GtkTreeIter *iter, 625 GtkTreeIter *iter,
645 const char *filename, 626 const char *filename,
646 uint32_t anonymity_level, 627 const struct GNUNET_FS_BlockOptions *bo,
647 uint32_t priority,
648 struct GNUNET_TIME_Absolute expiration,
649 int do_index, 628 int do_index,
650 struct GNUNET_CONTAINER_MetaData *md_no_ksk, 629 struct GNUNET_CONTAINER_MetaData *md_no_ksk,
651 struct GNUNET_CONTAINER_MetaData *meta) 630 struct GNUNET_CONTAINER_MetaData *meta)
@@ -705,9 +684,7 @@ add_entry_to_ts (GtkTreeStore *ts,
705 row_reference, 684 row_reference,
706 ksk_uri, 685 ksk_uri,
707 meta, 686 meta,
708 anonymity_level, 687 bo);
709 priority,
710 expiration);
711 } 688 }
712 else 689 else
713 { 690 {
@@ -717,9 +694,7 @@ add_entry_to_ts (GtkTreeStore *ts,
717 ksk_uri, 694 ksk_uri,
718 meta, 695 meta,
719 do_index, 696 do_index,
720 anonymity_level, 697 bo);
721 priority,
722 expiration);
723 } 698 }
724 GNUNET_CONTAINER_meta_data_destroy (meta); 699 GNUNET_CONTAINER_meta_data_destroy (meta);
725 GNUNET_FS_uri_destroy (ksk_uri); 700 GNUNET_FS_uri_destroy (ksk_uri);
@@ -734,8 +709,8 @@ add_entry_to_ts (GtkTreeStore *ts,
734 0, file_size_fancy, 709 0, file_size_fancy,
735 1, (gboolean) do_index, 710 1, (gboolean) do_index,
736 2, short_fn, 711 2, short_fn,
737 3, (guint)anonymity_level, 712 3, (guint) bo->anonymity_level,
738 4, (guint) priority, 713 4, (guint) bo->content_priority,
739 5, fi, 714 5, fi,
740 -1); 715 -1);
741 GNUNET_free (file_size_fancy); 716 GNUNET_free (file_size_fancy);
@@ -766,9 +741,7 @@ publish_entry (void *cls,
766 add_entry_to_ts (adc->ts, 741 add_entry_to_ts (adc->ts,
767 &pd->iter, 742 &pd->iter,
768 filename, 743 filename,
769 adc->anonymity_level, 744 &adc->bo,
770 adc->priority,
771 adc->expiration,
772 adc->do_index, 745 adc->do_index,
773 adc->no_ksk, 746 adc->no_ksk,
774 pd->meta); 747 pd->meta);
@@ -921,9 +894,7 @@ scan_directory (void *cls,
921 add_entry_to_ts (adc->ts, 894 add_entry_to_ts (adc->ts,
922 &pd->iter, 895 &pd->iter,
923 filename, 896 filename,
924 adc->anonymity_level, 897 &adc->bo,
925 adc->priority,
926 adc->expiration,
927 adc->do_index, 898 adc->do_index,
928 NULL, 899 NULL,
929 pd->meta); 900 pd->meta);
@@ -942,13 +913,12 @@ scan_directory (void *cls,
942 * Add a directory to the tree model. 913 * Add a directory to the tree model.
943 * 914 *
944 * @param filename directory name to add 915 * @param filename directory name to add
945 * @param iter parent entry, or NULL for top-level addition 916 * @param bo block options
917 * @param do_index should we index?
946 */ 918 */
947static void 919static void
948add_dir (const char *filename, 920add_dir (const char *filename,
949 uint32_t anonymity_level, 921 const struct GNUNET_FS_BlockOptions *bo,
950 uint32_t priority,
951 struct GNUNET_TIME_Absolute expiration,
952 int do_index) 922 int do_index)
953{ 923{
954 struct stat sbuf; 924 struct stat sbuf;
@@ -962,9 +932,7 @@ add_dir (const char *filename,
962 return; 932 return;
963 } 933 }
964 memset (&scan_ctx, 0, sizeof (scan_ctx)); 934 memset (&scan_ctx, 0, sizeof (scan_ctx));
965 scan_ctx.anonymity_level = anonymity_level; 935 scan_ctx.bo = *bo;
966 scan_ctx.priority = priority;
967 scan_ctx.expiration = expiration;
968 scan_ctx.do_index = do_index; 936 scan_ctx.do_index = do_index;
969 scan_ctx.ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder, 937 scan_ctx.ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder,
970 "GNUNET_GTK_file_sharing_publishing_tree_store")); 938 "GNUNET_GTK_file_sharing_publishing_tree_store"));
@@ -1344,6 +1312,7 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy,
1344 GtkTreeSelection *sel; 1312 GtkTreeSelection *sel;
1345 GtkTreeIter iter; 1313 GtkTreeIter iter;
1346 GtkTreeIter pos; 1314 GtkTreeIter pos;
1315 struct GNUNET_FS_BlockOptions bo;
1347 1316
1348 tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder, 1317 tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder,
1349 "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); 1318 "GNUNET_GTK_master_publish_dialog_file_information_tree_view"));
@@ -1353,21 +1322,21 @@ GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget * dummy,
1353 * to calling this function (currently we 1322 * to calling this function (currently we
1354 * use default values for those). 1323 * use default values for those).
1355 */ 1324 */
1325 bo.anonymity_level = 1;
1326 bo.content_priority = 1000;
1327 bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
1328 bo.replication_level = 1;
1356 if (TRUE != gtk_tree_selection_get_selected (sel, 1329 if (TRUE != gtk_tree_selection_get_selected (sel,
1357 NULL, 1330 NULL,
1358 &iter)) 1331 &iter))
1359 { 1332 {
1360 create_dir_at_iter ("unnamed/", 1333 create_dir_at_iter ("unnamed/",
1361 1 /* anonymity */, 1334 &bo,
1362 1000 /* priority */,
1363 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS) /* expiration */,
1364 NULL, &pos); 1335 NULL, &pos);
1365 return; 1336 return;
1366 } 1337 }
1367 create_dir_at_iter ("unnamed/", 1338 create_dir_at_iter ("unnamed/",
1368 1 /* anonymity */, 1339 &bo,
1369 1000 /* priority */,
1370 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS) /* expiration */,
1371 &iter, &pos); 1340 &iter, &pos);
1372} 1341}
1373 1342
@@ -1379,9 +1348,7 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
1379 GtkWidget *ad; 1348 GtkWidget *ad;
1380 GtkBuilder *builder; 1349 GtkBuilder *builder;
1381 char *filename; 1350 char *filename;
1382 uint32_t anonymity; 1351 struct GNUNET_FS_BlockOptions bo;
1383 uint32_t priority;
1384 struct GNUNET_TIME_Absolute exp;
1385 int do_index; 1352 int do_index;
1386 GtkSpinButton *sb; 1353 GtkSpinButton *sb;
1387 1354
@@ -1401,18 +1368,18 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy,
1401 return; 1368 return;
1402 } 1369 }
1403 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); 1370 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad));
1404 anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1405 "GNUNET_GTK_publish_file_dialog_anonymity_spin_button")));
1406 priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1407 "GNUNET_GTK_publish_file_dialog_priority_spin_button")));
1408 do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
1409 "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")));
1410 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, 1371 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1411 "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); 1372 "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button"));
1412 exp = GNUNET_GTK_get_expiration_time (sb); 1373 bo.anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1413 add_file_at_iter (filename, anonymity, 1374 "GNUNET_GTK_publish_file_dialog_anonymity_spin_button")));
1414 priority, 1375 bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1415 exp, do_index, 1376 "GNUNET_GTK_publish_file_dialog_priority_spin_button")));
1377 bo.expiration_time = GNUNET_GTK_get_expiration_time (sb);
1378 bo.replication_level = 1; /* FIXME... */
1379 do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
1380 "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")));
1381 add_file_at_iter (filename,
1382 &bo, do_index,
1416 NULL); 1383 NULL);
1417 gtk_widget_destroy (ad); 1384 gtk_widget_destroy (ad);
1418 g_object_unref (G_OBJECT (builder)); 1385 g_object_unref (G_OBJECT (builder));
@@ -1479,10 +1446,8 @@ free_fi_row_reference (void *cls,
1479 uint64_t length, 1446 uint64_t length,
1480 struct GNUNET_CONTAINER_MetaData *meta, 1447 struct GNUNET_CONTAINER_MetaData *meta,
1481 struct GNUNET_FS_Uri **uri, 1448 struct GNUNET_FS_Uri **uri,
1482 uint32_t *anonymity, 1449 struct GNUNET_FS_BlockOptions *bo,
1483 uint32_t *priority,
1484 int *do_index, 1450 int *do_index,
1485 struct GNUNET_TIME_Absolute *expirationTime,
1486 void **client_info) 1451 void **client_info)
1487{ 1452{
1488 GtkTreeRowReference *row = *client_info; 1453 GtkTreeRowReference *row = *client_info;
@@ -1538,11 +1503,9 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy,
1538 GtkWidget *ad; 1503 GtkWidget *ad;
1539 GtkBuilder *builder; 1504 GtkBuilder *builder;
1540 char *filename; 1505 char *filename;
1541 uint32_t anonymity;
1542 uint32_t priority;
1543 struct GNUNET_TIME_Absolute exp;
1544 int do_index; 1506 int do_index;
1545 GtkSpinButton *sb; 1507 GtkSpinButton *sb;
1508 struct GNUNET_FS_BlockOptions bo;
1546 1509
1547 builder = GNUNET_GTK_get_new_builder ("publish-directory-dialog.glade"); 1510 builder = GNUNET_GTK_get_new_builder ("publish-directory-dialog.glade");
1548 if (builder == NULL) 1511 if (builder == NULL)
@@ -1560,22 +1523,20 @@ GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget * dummy,
1560 return; 1523 return;
1561 } 1524 }
1562 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); 1525 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad));
1563 anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, 1526 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1564 "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button"))); 1527 "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button"));
1565 priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, 1528 bo.anonymity_level = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1566 "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); 1529 "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button")));
1530 bo.content_priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
1531 "GNUNET_GTK_publish_directory_dialog_priority_spin_button")));
1532 bo.expiration_time = GNUNET_GTK_get_expiration_time (sb);
1567 do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, 1533 do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
1568 "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); 1534 "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton")));
1569 sb = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, 1535
1570 "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button"));
1571
1572 exp = GNUNET_GTK_get_expiration_time (sb);
1573 gtk_widget_destroy (ad); 1536 gtk_widget_destroy (ad);
1574 g_object_unref (G_OBJECT (builder)); 1537 g_object_unref (G_OBJECT (builder));
1575 /* FIXME: open progress dialog here... */ 1538 /* FIXME: open progress dialog here... */
1576 add_dir (filename, anonymity, priority, 1539 add_dir (filename, &bo, do_index);
1577 exp,
1578 do_index);
1579 g_free (filename); 1540 g_free (filename);
1580 update_selectivity (); 1541 update_selectivity ();
1581} 1542}