diff options
author | Christian Grothoff <christian@grothoff.org> | 2006-12-10 06:27:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2006-12-10 06:27:55 +0000 |
commit | 16fdea53d4f80a9e8ced817ec270dd46816e21b8 (patch) | |
tree | 254d414c987222c9efe946529657ec2b032340d8 | |
parent | 738b5eba3f7eb5daadef7c1d19e338a198cb2b48 (diff) | |
download | gnunet-gtk-16fdea53d4f80a9e8ced817ec270dd46816e21b8.tar.gz gnunet-gtk-16fdea53d4f80a9e8ced817ec270dd46816e21b8.zip |
fixing deadlocks
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | src/plugins/fs/download.c | 155 | ||||
-rw-r--r-- | src/plugins/fs/search.c | 53 | ||||
-rw-r--r-- | src/plugins/fs/upload.c | 96 |
4 files changed, 180 insertions, 126 deletions
@@ -1,6 +1,4 @@ | |||
1 | 0.7.1: | 1 | 0.7.1: |
2 | - deadlock: FSUI_startDownload/Upload | ||
3 | must NOT be done in main thread [pre2] | ||
4 | - fix addition of previews for uploads [pre2] | 2 | - fix addition of previews for uploads [pre2] |
5 | - create directory from known file IDs [ medium ] [pre2] | 3 | - create directory from known file IDs [ medium ] [pre2] |
6 | in Assemble Directory's Files Available/Selected | 4 | in Assemble Directory's Files Available/Selected |
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index eab6ed20..1fd31bfb 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -388,7 +388,7 @@ void fs_download_completed(DownloadList * downloadContext) { | |||
388 | * possibly refresh directory listing. | 388 | * possibly refresh directory listing. |
389 | */ | 389 | */ |
390 | void fs_download_aborted(DownloadList * downloadContext) { | 390 | void fs_download_aborted(DownloadList * downloadContext) { |
391 | /* FIXME: update summary? / search list status entry (once added) */ | 391 | /* FIXME: update summary? / search list status entry! */ |
392 | downloadContext->has_terminated = YES; | 392 | downloadContext->has_terminated = YES; |
393 | refreshDirectoryViewFromDisk(downloadContext); | 393 | refreshDirectoryViewFromDisk(downloadContext); |
394 | } | 394 | } |
@@ -479,6 +479,31 @@ check_pending(const char * filename, | |||
479 | return OK; | 479 | return OK; |
480 | } | 480 | } |
481 | 481 | ||
482 | typedef struct { | ||
483 | char * uri_name; | ||
484 | struct ECRS_URI * idc_uri; | ||
485 | struct ECRS_MetaData * idc_meta; | ||
486 | char * idc_final_download_destination; | ||
487 | SearchList * searchContext; | ||
488 | DownloadList * parentContext; | ||
489 | unsigned int anonymity; | ||
490 | int recursive; | ||
491 | } SDC; | ||
492 | |||
493 | static void * init_download_helper(void * cls) { | ||
494 | SDC * sdc = cls; | ||
495 | |||
496 | FSUI_startDownload(ctx, | ||
497 | sdc->anonymity, | ||
498 | sdc->recursive, | ||
499 | sdc->idc_uri, | ||
500 | sdc->idc_meta, | ||
501 | sdc->idc_final_download_destination, | ||
502 | sdc->searchContext->fsui_list, | ||
503 | (sdc->parentContext != NULL) ? sdc->parentContext->fsui_list : NULL); | ||
504 | return NULL; | ||
505 | } | ||
506 | |||
482 | /** | 507 | /** |
483 | * The user clicked the download button. | 508 | * The user clicked the download button. |
484 | * Start the download of the selected entry. | 509 | * Start the download of the selected entry. |
@@ -488,7 +513,7 @@ initiateDownload(GtkTreeModel * model, | |||
488 | GtkTreePath * path, | 513 | GtkTreePath * path, |
489 | GtkTreeIter * iter, | 514 | GtkTreeIter * iter, |
490 | gpointer unused) { | 515 | gpointer unused) { |
491 | char * uri_name; | 516 | SDC sdc; |
492 | char * final_download_dir; | 517 | char * final_download_dir; |
493 | GtkTreeIter iiter; | 518 | GtkTreeIter iiter; |
494 | char * tmp; | 519 | char * tmp; |
@@ -497,43 +522,38 @@ initiateDownload(GtkTreeModel * model, | |||
497 | GtkTreePath *dirTreePath; | 522 | GtkTreePath *dirTreePath; |
498 | char *dirPath; | 523 | char *dirPath; |
499 | unsigned int dirPathLen; | 524 | unsigned int dirPathLen; |
500 | struct ECRS_URI * idc_uri; | ||
501 | struct ECRS_MetaData * idc_meta; | ||
502 | char * idc_name; | 525 | char * idc_name; |
503 | char * idc_mime; | 526 | char * idc_mime; |
504 | char * idc_final_download_destination; | ||
505 | SearchList * searchContext; | ||
506 | DownloadList * parentContext; | ||
507 | 527 | ||
508 | idc_uri = NULL; | 528 | sdc.idc_uri = NULL; |
509 | idc_meta = NULL; | 529 | sdc.idc_meta = NULL; |
510 | idc_name = NULL; | 530 | idc_name = NULL; |
511 | idc_mime = NULL; | 531 | idc_mime = NULL; |
512 | searchContext = NULL; | 532 | sdc.searchContext = NULL; |
513 | parentContext = NULL; | 533 | sdc.parentContext = NULL; |
514 | gtk_tree_model_get(model, | 534 | gtk_tree_model_get(model, |
515 | iter, | 535 | iter, |
516 | SEARCH_NAME, &idc_name, | 536 | SEARCH_NAME, &idc_name, |
517 | SEARCH_URI, &idc_uri, | 537 | SEARCH_URI, &sdc.idc_uri, |
518 | SEARCH_META, &idc_meta, | 538 | SEARCH_META, &sdc.idc_meta, |
519 | SEARCH_MIME, &idc_mime, | 539 | SEARCH_MIME, &idc_mime, |
520 | SEARCH_INTERNAL, &searchContext, | 540 | SEARCH_INTERNAL, &sdc.searchContext, |
521 | SEARCH_INTERNAL_PARENT, &parentContext, | 541 | SEARCH_INTERNAL_PARENT, &sdc.parentContext, |
522 | -1); | 542 | -1); |
523 | if ( (idc_uri == NULL) || | 543 | if ( (sdc.idc_uri == NULL) || |
524 | (! ECRS_isFileUri(idc_uri)) ) { | 544 | (! ECRS_isFileUri(sdc.idc_uri)) ) { |
525 | GE_BREAK(ectx, 0); | 545 | GE_BREAK(ectx, 0); |
526 | FREENONNULL(idc_name); | 546 | FREENONNULL(idc_name); |
527 | FREENONNULL(idc_mime); | 547 | FREENONNULL(idc_mime); |
528 | return; | 548 | return; |
529 | } | 549 | } |
530 | uri_name = ECRS_uriToString(idc_uri); | 550 | sdc.uri_name = ECRS_uriToString(sdc.idc_uri); |
531 | if ( (uri_name == NULL) || | 551 | if ( (sdc.uri_name == NULL) || |
532 | (strlen(uri_name) < | 552 | (strlen(sdc.uri_name) < |
533 | strlen(ECRS_URI_PREFIX) + | 553 | strlen(ECRS_URI_PREFIX) + |
534 | strlen(ECRS_FILE_INFIX)) ) { | 554 | strlen(ECRS_FILE_INFIX)) ) { |
535 | GE_BREAK(ectx, 0); | 555 | GE_BREAK(ectx, 0); |
536 | FREENONNULL(uri_name); | 556 | FREENONNULL(sdc.uri_name); |
537 | FREENONNULL(idc_name); | 557 | FREENONNULL(idc_name); |
538 | FREENONNULL(idc_mime); | 558 | FREENONNULL(idc_mime); |
539 | return; | 559 | return; |
@@ -542,12 +562,12 @@ initiateDownload(GtkTreeModel * model, | |||
542 | #ifdef WINDOWS | 562 | #ifdef WINDOWS |
543 | char * filehash; | 563 | char * filehash; |
544 | 564 | ||
545 | filehash = STRDUP(uri_name); | 565 | filehash = STRDUP(sdc.uri_name); |
546 | filehash[16] = 0; | 566 | filehash[16] = 0; |
547 | idc_name = STRDUP(filehash); | 567 | idc_name = STRDUP(filehash); |
548 | FREENONNULL(filehash); | 568 | FREENONNULL(filehash); |
549 | #else | 569 | #else |
550 | idc_name = STRDUP(uri_name); | 570 | idc_name = STRDUP(sdc.uri_name); |
551 | #endif | 571 | #endif |
552 | } | 572 | } |
553 | 573 | ||
@@ -620,41 +640,35 @@ initiateDownload(GtkTreeModel * model, | |||
620 | gtk_tree_path_free(dirTreePath); | 640 | gtk_tree_path_free(dirTreePath); |
621 | 641 | ||
622 | /* construct completed/directory/real-filename */ | 642 | /* construct completed/directory/real-filename */ |
623 | idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 + | 643 | sdc.idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 + |
624 | strlen(idc_name) + strlen(GNUNET_DIRECTORY_EXT) + | 644 | strlen(idc_name) + strlen(GNUNET_DIRECTORY_EXT) + |
625 | strlen(dirPath)); | 645 | strlen(dirPath)); |
626 | strcpy(idc_final_download_destination, | 646 | strcpy(sdc.idc_final_download_destination, |
627 | final_download_dir); | 647 | final_download_dir); |
628 | if (idc_final_download_destination[strlen(idc_final_download_destination)-1] != DIR_SEPARATOR) | 648 | if (sdc.idc_final_download_destination[strlen(sdc.idc_final_download_destination)-1] != DIR_SEPARATOR) |
629 | strcat(idc_final_download_destination, | 649 | strcat(sdc.idc_final_download_destination, |
630 | DIR_SEPARATOR_STR); | 650 | DIR_SEPARATOR_STR); |
631 | strcat(idc_final_download_destination, | 651 | strcat(sdc.idc_final_download_destination, |
632 | dirPath); | 652 | dirPath); |
633 | strcat(idc_final_download_destination, | 653 | strcat(sdc.idc_final_download_destination, |
634 | idc_name); | 654 | idc_name); |
635 | /* FIXME: check that there is no pending download for idc_name! */ | 655 | sdc.anonymity = getSpinButtonValue(sdc.searchContext->searchXML, |
656 | "downloadAnonymitySpinButton"); | ||
657 | sdc.recursive = getToggleButtonValue(sdc.searchContext->searchXML, | ||
658 | "downloadRecursiveCheckButton"); | ||
636 | if (OK == check_pending(idc_name, | 659 | if (OK == check_pending(idc_name, |
637 | NULL)) { | 660 | NULL)) { |
638 | addLogEntry(_("Downloading `%s'"), | 661 | addLogEntry(_("Downloading `%s'"), |
639 | idc_name); | 662 | idc_name); |
640 | /* FIXME! DEADLOCK! */ | 663 | run_with_save_calls(&init_download_helper, |
641 | FSUI_startDownload(ctx, | 664 | &sdc); |
642 | getSpinButtonValue(searchContext->searchXML, | ||
643 | "downloadAnonymitySpinButton"), | ||
644 | getToggleButtonValue(searchContext->searchXML, | ||
645 | "downloadRecursiveCheckButton"), | ||
646 | idc_uri, | ||
647 | idc_meta, | ||
648 | idc_final_download_destination, | ||
649 | searchContext->fsui_list, | ||
650 | (parentContext != NULL) ? parentContext->fsui_list : NULL); | ||
651 | } else { | 665 | } else { |
652 | addLogEntry(_("ERROR: already downloading `%s'"), | 666 | addLogEntry(_("ERROR: already downloading `%s'"), |
653 | idc_name); | 667 | idc_name); |
654 | } | 668 | } |
655 | FREE(uri_name); | 669 | FREE(sdc.uri_name); |
656 | FREE(dirPath); | 670 | FREE(dirPath); |
657 | FREE(idc_final_download_destination); | 671 | FREE(sdc.idc_final_download_destination); |
658 | FREENONNULL(final_download_dir); | 672 | FREENONNULL(final_download_dir); |
659 | FREENONNULL(idc_name); | 673 | FREENONNULL(idc_name); |
660 | FREENONNULL(idc_mime); | 674 | FREENONNULL(idc_mime); |
@@ -683,36 +697,35 @@ void on_downloadButton_clicked_fs(GtkWidget * treeview, | |||
683 | * TODO: | 697 | * TODO: |
684 | * - support for recursive downloads | 698 | * - support for recursive downloads |
685 | * - support for user-specified filename | 699 | * - support for user-specified filename |
700 | * - enable button only if valid URI is entered | ||
686 | */ | 701 | */ |
687 | void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry, | 702 | void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry, |
688 | GtkWidget * downloadButton) { | 703 | GtkWidget * downloadButton) { |
689 | struct ECRS_URI * idc_uri; | ||
690 | struct ECRS_MetaData * idc_meta; | ||
691 | char * idc_final_download_destination; | ||
692 | const char * uris; | 704 | const char * uris; |
693 | char * urid; | 705 | char * urid; |
694 | char * final_download_dir; | 706 | char * final_download_dir; |
695 | const char * dname; | 707 | const char * dname; |
708 | SDC sdc; | ||
696 | 709 | ||
697 | uris = gtk_entry_get_text(GTK_ENTRY(entry)); | 710 | uris = gtk_entry_get_text(GTK_ENTRY(entry)); |
698 | urid = STRDUP(uris); | 711 | urid = STRDUP(uris); |
699 | gtk_entry_set_text(GTK_ENTRY(entry), | 712 | gtk_entry_set_text(GTK_ENTRY(entry), |
700 | ECRS_URI_PREFIX); | 713 | ECRS_URI_PREFIX); |
701 | idc_uri = ECRS_stringToUri(ectx, urid); | 714 | sdc.idc_uri = ECRS_stringToUri(ectx, urid); |
702 | if (idc_uri == NULL) { | 715 | if (sdc.idc_uri == NULL) { |
703 | addLogEntry(_("Invalid URI `%s'"), urid); | 716 | addLogEntry(_("Invalid URI `%s'"), urid); |
704 | FREE(urid); | 717 | FREE(urid); |
705 | return; | 718 | return; |
706 | } | 719 | } |
707 | if (ECRS_isKeywordUri(idc_uri)) { | 720 | if (ECRS_isKeywordUri(sdc.idc_uri)) { |
708 | addLogEntry(_("Please use the search function for keyword (KSK) URIs!")); | 721 | addLogEntry(_("Please use the search function for keyword (KSK) URIs!")); |
709 | FREE(urid); | 722 | FREE(urid); |
710 | ECRS_freeUri(idc_uri); | 723 | ECRS_freeUri(sdc.idc_uri); |
711 | return; | 724 | return; |
712 | } else if (ECRS_isLocationUri(idc_uri)) { | 725 | } else if (ECRS_isLocationUri(sdc.idc_uri)) { |
713 | addLogEntry(_("Location URIs are not yet supported")); | 726 | addLogEntry(_("Location URIs are not yet supported")); |
714 | FREE(urid); | 727 | FREE(urid); |
715 | ECRS_freeUri(idc_uri); | 728 | ECRS_freeUri(sdc.idc_uri); |
716 | return; | 729 | return; |
717 | } | 730 | } |
718 | GC_get_configuration_value_filename(cfg, | 731 | GC_get_configuration_value_filename(cfg, |
@@ -722,26 +735,28 @@ void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry, | |||
722 | &final_download_dir); | 735 | &final_download_dir); |
723 | disk_directory_create(ectx, final_download_dir); | 736 | disk_directory_create(ectx, final_download_dir); |
724 | dname = &uris[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]; | 737 | dname = &uris[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]; |
725 | idc_final_download_destination = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); | 738 | sdc.idc_final_download_destination = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); |
726 | strcpy(idc_final_download_destination, final_download_dir); | 739 | strcpy(sdc.idc_final_download_destination, |
740 | final_download_dir); | ||
727 | FREE(final_download_dir); | 741 | FREE(final_download_dir); |
728 | if (idc_final_download_destination[strlen(idc_final_download_destination)] != DIR_SEPARATOR) | 742 | if (sdc.idc_final_download_destination[strlen(sdc.idc_final_download_destination)] != DIR_SEPARATOR) |
729 | strcat(idc_final_download_destination, DIR_SEPARATOR_STR); | 743 | strcat(sdc.idc_final_download_destination, |
730 | strcat(idc_final_download_destination, dname); | 744 | DIR_SEPARATOR_STR); |
745 | strcat(sdc.idc_final_download_destination, | ||
746 | dname); | ||
731 | 747 | ||
732 | addLogEntry(_("Downloading `%s'"), | 748 | addLogEntry(_("Downloading `%s'"), |
733 | uris); | 749 | uris); |
734 | idc_meta = ECRS_createMetaData(); | 750 | sdc.idc_meta = ECRS_createMetaData(); |
735 | FSUI_startDownload(ctx, | 751 | sdc.anonymity = getSpinButtonValue(getMainXML(), |
736 | getSpinButtonValue(getMainXML(), | 752 | "fsstatusAnonymitySpin"); |
737 | "fsstatusAnonymitySpin"), | 753 | sdc.recursive = NO; |
738 | NO, /* FIXME: isRecursive */ | 754 | sdc.searchContext = NULL; |
739 | idc_uri, | 755 | sdc.parentContext = NULL; |
740 | idc_meta, | 756 | run_with_save_calls(&init_download_helper, |
741 | idc_final_download_destination, | 757 | &sdc); |
742 | NULL, | 758 | ECRS_freeMetaData(sdc.idc_meta); |
743 | NULL); | 759 | FREE(sdc.idc_final_download_destination); |
744 | ECRS_freeMetaData(idc_meta); | ||
745 | FREE(urid); | 760 | FREE(urid); |
746 | } | 761 | } |
747 | 762 | ||
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index d8521179..6d7504c1 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -511,6 +511,22 @@ void on_fssearchKeywordComboBoxEntry_changed_fs(gpointer dummy2, | |||
511 | strlen(searchString) > 0); | 511 | strlen(searchString) > 0); |
512 | } | 512 | } |
513 | 513 | ||
514 | typedef struct { | ||
515 | unsigned int anonymity; | ||
516 | unsigned int max; | ||
517 | cron_t delay; | ||
518 | struct ECRS_URI * uri; | ||
519 | } FSSS; | ||
520 | |||
521 | static void * search_start_helper(void * cls) { | ||
522 | FSSS * fsss; | ||
523 | FSUI_startSearch(ctx, | ||
524 | fsss->anonymity, | ||
525 | fsss->max, | ||
526 | fsss->delay, | ||
527 | fsss->uri); | ||
528 | return NULL; | ||
529 | } | ||
514 | 530 | ||
515 | /** | 531 | /** |
516 | * The user has clicked the "SEARCH" button. | 532 | * The user has clicked the "SEARCH" button. |
@@ -518,7 +534,7 @@ void on_fssearchKeywordComboBoxEntry_changed_fs(gpointer dummy2, | |||
518 | */ | 534 | */ |
519 | void on_fssearchbutton_clicked_fs(gpointer dummy2, | 535 | void on_fssearchbutton_clicked_fs(gpointer dummy2, |
520 | GtkWidget * searchButton) { | 536 | GtkWidget * searchButton) { |
521 | struct ECRS_URI * uri; | 537 | FSSS fsss; |
522 | const char * searchString; | 538 | const char * searchString; |
523 | gint pages; | 539 | gint pages; |
524 | gint i; | 540 | gint i; |
@@ -554,7 +570,7 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
554 | 0, searchString, | 570 | 0, searchString, |
555 | -1); | 571 | -1); |
556 | } | 572 | } |
557 | uri = NULL; | 573 | fsss.uri = NULL; |
558 | /* check for namespace search */ | 574 | /* check for namespace search */ |
559 | searchNamespaceGtkCB | 575 | searchNamespaceGtkCB |
560 | = glade_xml_get_widget(getMainXML(), | 576 | = glade_xml_get_widget(getMainXML(), |
@@ -593,8 +609,8 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
593 | strcat(ustring, ns); | 609 | strcat(ustring, ns); |
594 | strcat(ustring, "/"); | 610 | strcat(ustring, "/"); |
595 | strcat(ustring, searchString); | 611 | strcat(ustring, searchString); |
596 | uri = ECRS_stringToUri(ectx, ustring); | 612 | fsss.uri = ECRS_stringToUri(ectx, ustring); |
597 | if (uri == NULL) { | 613 | if (fsss.uri == NULL) { |
598 | GE_LOG(ectx, | 614 | GE_LOG(ectx, |
599 | GE_ERROR | GE_BULK | GE_USER, | 615 | GE_ERROR | GE_BULK | GE_USER, |
600 | _("Failed to create namespace URI from `%s'.\n"), | 616 | _("Failed to create namespace URI from `%s'.\n"), |
@@ -607,9 +623,9 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
607 | if (ns != NULL) | 623 | if (ns != NULL) |
608 | free(ns); | 624 | free(ns); |
609 | } | 625 | } |
610 | if (uri == NULL) | 626 | if (fsss.uri == NULL) |
611 | uri = ECRS_parseCharKeywordURI(ectx, searchString); | 627 | fsss.uri = ECRS_parseCharKeywordURI(ectx, searchString); |
612 | if (uri == NULL) { | 628 | if (fsss.uri == NULL) { |
613 | GE_BREAK(ectx, 0); | 629 | GE_BREAK(ectx, 0); |
614 | return; | 630 | return; |
615 | } | 631 | } |
@@ -621,14 +637,14 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
621 | list = search_head; | 637 | list = search_head; |
622 | while (list != NULL) { | 638 | while (list != NULL) { |
623 | if (ECRS_equalsUri(list->uri, | 639 | if (ECRS_equalsUri(list->uri, |
624 | uri)) { | 640 | fsss.uri)) { |
625 | for (i=0;i<pages;i++) { | 641 | for (i=0;i<pages;i++) { |
626 | if (gtk_notebook_get_nth_page(notebook, | 642 | if (gtk_notebook_get_nth_page(notebook, |
627 | i) | 643 | i) |
628 | == list->searchpage) { | 644 | == list->searchpage) { |
629 | gtk_notebook_set_current_page(notebook, | 645 | gtk_notebook_set_current_page(notebook, |
630 | i); | 646 | i); |
631 | ECRS_freeUri(uri); | 647 | ECRS_freeUri(fsss.uri); |
632 | return; | 648 | return; |
633 | } | 649 | } |
634 | } | 650 | } |
@@ -636,16 +652,15 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2, | |||
636 | } | 652 | } |
637 | list = list->next; | 653 | list = list->next; |
638 | } | 654 | } |
639 | /* FIXME: deadlock! */ | 655 | fsss.anonymity = getSpinButtonValue(getMainXML(), |
640 | FSUI_startSearch(ctx, | 656 | "searchAnonymitySelectionSpinButton"); |
641 | getSpinButtonValue(getMainXML(), | 657 | fsss.max = getSpinButtonValue(getMainXML(), |
642 | "searchAnonymitySelectionSpinButton"), | 658 | "maxResultsSpinButton"); |
643 | getSpinButtonValue(getMainXML(), | 659 | fsss.delay = getSpinButtonValue(getMainXML(), |
644 | "maxResultsSpinButton"), | 660 | "searchDelaySpinButton") * cronSECONDS; |
645 | getSpinButtonValue(getMainXML(), | 661 | run_with_save_calls(search_start_helper, |
646 | "searchDelaySpinButton") * cronSECONDS, | 662 | &fsss); |
647 | uri); | 663 | ECRS_freeUri(fsss.uri); |
648 | ECRS_freeUri(uri); | ||
649 | } | 664 | } |
650 | 665 | ||
651 | struct FCBC { | 666 | struct FCBC { |
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c index aa800b34..f5b922f6 100644 --- a/src/plugins/fs/upload.c +++ b/src/plugins/fs/upload.c | |||
@@ -316,16 +316,48 @@ void on_fileInformationKeywordEntry_changed_fs(gpointer dummy2, | |||
316 | strlen(input) > 0); | 316 | strlen(input) > 0); |
317 | } | 317 | } |
318 | 318 | ||
319 | typedef struct { | ||
320 | const char * filename; | ||
321 | unsigned int anonymity; | ||
322 | unsigned int priority; | ||
323 | int index; | ||
324 | int extract; | ||
325 | int deep_index; | ||
326 | cron_t expire; | ||
327 | struct ECRS_MetaData * meta; | ||
328 | struct ECRS_URI * gkeywordURI; | ||
329 | struct ECRS_URI * keywordURI; | ||
330 | } FSUC; | ||
331 | |||
332 | static void * start_upload_helper(void * cls) { | ||
333 | FSUC * fsuc = cls; | ||
334 | |||
335 | FSUI_startUpload(ctx, | ||
336 | fsuc->filename, | ||
337 | (DirectoryScanCallback) &disk_directory_scan, | ||
338 | ectx, | ||
339 | fsuc->anonymity, | ||
340 | fsuc->priority, | ||
341 | fsuc->index, | ||
342 | fsuc->extract, | ||
343 | fsuc->deep_index, | ||
344 | fsuc->expire, | ||
345 | fsuc->meta, | ||
346 | fsuc->gkeywordURI, | ||
347 | fsuc->keywordURI); | ||
348 | return NULL; | ||
349 | } | ||
350 | |||
351 | |||
319 | void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | 352 | void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, |
320 | GtkWidget * uploadButton) { | 353 | GtkWidget * uploadButton) { |
354 | FSUC fsuc; | ||
321 | const char * filenamerest; | 355 | const char * filenamerest; |
322 | const char * filename; | ||
323 | GtkWidget * dialog; | 356 | GtkWidget * dialog; |
324 | EXTRACTOR_ExtractorList * extractors; | 357 | EXTRACTOR_ExtractorList * extractors; |
325 | char * config; | 358 | char * config; |
326 | struct ECRS_URI * keywordURI; | ||
327 | struct ECRS_URI * gkeywordURI; | ||
328 | struct ECRS_MetaData * meta; | 359 | struct ECRS_MetaData * meta; |
360 | struct ECRS_URI * keywordURI; | ||
329 | 361 | ||
330 | extractors = EXTRACTOR_loadDefaultLibraries(); | 362 | extractors = EXTRACTOR_loadDefaultLibraries(); |
331 | config = NULL; | 363 | config = NULL; |
@@ -340,8 +372,8 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | |||
340 | FREE(config); | 372 | FREE(config); |
341 | } | 373 | } |
342 | 374 | ||
343 | filename = getEntryLineValue(getMainXML(), | 375 | fsuc.filename = getEntryLineValue(getMainXML(), |
344 | "uploadFilenameComboBoxEntry"); | 376 | "uploadFilenameComboBoxEntry"); |
345 | metaXML | 377 | metaXML |
346 | = glade_xml_new(getGladeFileName(), | 378 | = glade_xml_new(getGladeFileName(), |
347 | "metaDataDialog", | 379 | "metaDataDialog", |
@@ -352,11 +384,11 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | |||
352 | meta = ECRS_createMetaData(); | 384 | meta = ECRS_createMetaData(); |
353 | ECRS_extractMetaData(ectx, | 385 | ECRS_extractMetaData(ectx, |
354 | meta, | 386 | meta, |
355 | filename, | 387 | fsuc.filename, |
356 | extractors); | 388 | extractors); |
357 | EXTRACTOR_removeAll(extractors); | 389 | EXTRACTOR_removeAll(extractors); |
358 | filenamerest = &filename[strlen(filename)-1]; | 390 | filenamerest = &fsuc.filename[strlen(fsuc.filename)-1]; |
359 | while ( (filenamerest > filename) && | 391 | while ( (filenamerest > fsuc.filename) && |
360 | (filenamerest[-1] != DIR_SEPARATOR) ) | 392 | (filenamerest[-1] != DIR_SEPARATOR) ) |
361 | filenamerest--; | 393 | filenamerest--; |
362 | ECRS_addToMetaData(meta, | 394 | ECRS_addToMetaData(meta, |
@@ -397,36 +429,30 @@ void on_fsinsertuploadbutton_clicked_fs(gpointer dummy, | |||
397 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | 429 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
398 | GTK_RESPONSE_OK); | 430 | GTK_RESPONSE_OK); |
399 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) { | 431 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) { |
400 | meta = getMetaDataFromList(metaXML, | 432 | fsuc.anonymity = getSpinButtonValue(getMainXML(), |
401 | "metaDataDialogMetaDataList", | 433 | "uploadAnonymityLevelSpinButton"); |
402 | "previewImage"); | 434 | fsuc.priority = getSpinButtonValue(getMainXML(), |
403 | keywordURI = getKeywordURIFromList(metaXML, | 435 | "contentPrioritySpinButton"); |
436 | fsuc.index = getToggleButtonValue(getMainXML(), | ||
437 | "indexbutton"); | ||
438 | fsuc.extract = getToggleButtonValue(getMainXML(), | ||
439 | "doExtractCheckButton"); | ||
440 | fsuc.deep_index = getToggleButtonValue(getMainXML(), | ||
441 | "deepIndexCheckButton"); | ||
442 | fsuc.expire = get_time() + 2 * cronYEARS; | ||
443 | fsuc.meta = getMetaDataFromList(metaXML, | ||
444 | "metaDataDialogMetaDataList", | ||
445 | "previewImage"); | ||
446 | fsuc.keywordURI = getKeywordURIFromList(metaXML, | ||
404 | "metaDataDialogKeywordList"); | 447 | "metaDataDialogKeywordList"); |
405 | gkeywordURI = ECRS_stringToUri(ectx, | 448 | fsuc.gkeywordURI = ECRS_stringToUri(ectx, |
406 | ECRS_URI_PREFIX | 449 | ECRS_URI_PREFIX |
407 | ECRS_SEARCH_INFIX); | 450 | ECRS_SEARCH_INFIX); |
408 | /* FIXME: DEADLOCK! */ | 451 | run_with_save_calls(&start_upload_helper, |
409 | FSUI_startUpload(ctx, | 452 | &fsuc); |
410 | filename, | 453 | ECRS_freeMetaData(fsuc.meta); |
411 | (DirectoryScanCallback) &disk_directory_scan, | 454 | ECRS_freeUri(fsuc.gkeywordURI); |
412 | ectx, | 455 | ECRS_freeUri(fsuc.keywordURI); |
413 | getSpinButtonValue(getMainXML(), | ||
414 | "uploadAnonymityLevelSpinButton"), | ||
415 | getSpinButtonValue(getMainXML(), | ||
416 | "contentPrioritySpinButton"), | ||
417 | getToggleButtonValue(getMainXML(), | ||
418 | "indexbutton"), | ||
419 | getToggleButtonValue(getMainXML(), | ||
420 | "doExtractCheckButton"), | ||
421 | getToggleButtonValue(getMainXML(), | ||
422 | "deepIndexCheckButton"), | ||
423 | get_time() + 2 * cronYEARS, | ||
424 | meta, | ||
425 | gkeywordURI, | ||
426 | keywordURI); | ||
427 | ECRS_freeMetaData(meta); | ||
428 | ECRS_freeUri(gkeywordURI); | ||
429 | ECRS_freeUri(keywordURI); | ||
430 | } | 456 | } |
431 | gtk_widget_destroy (dialog); | 457 | gtk_widget_destroy (dialog); |
432 | UNREF(metaXML); | 458 | UNREF(metaXML); |