From b30837e852c7ba43ce4372aabe539be2cd565ebc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Oct 2006 19:50:11 +0000 Subject: fixing compile errors --- TODO | 1 + src/include/gnunetgtk_common.h | 8 +- src/plugins/daemon/daemon.c | 2 +- src/plugins/fs/Makefile.am | 1 + src/plugins/fs/download.c | 705 +++++++++++++++++++++++++++++ src/plugins/fs/download.h | 56 +++ src/plugins/fs/fs.c | 176 +++++++- src/plugins/fs/fs.h | 136 +++++- src/plugins/fs/meta.c | 8 +- src/plugins/fs/search.c | 981 +++-------------------------------------- src/plugins/fs/search.h | 59 +-- 11 files changed, 1146 insertions(+), 987 deletions(-) create mode 100644 src/plugins/fs/download.c create mode 100644 src/plugins/fs/download.h diff --git a/TODO b/TODO index f8134666..718334f9 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,7 @@ * update event managements for upload * complete UI options processing for search and download and upload; including recursive download! + * fix thread context switching * test, test, test! * support abort of search/download/upload (without killing it) * check memory leaks! diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h index 86c19913..e33011eb 100644 --- a/src/include/gnunetgtk_common.h +++ b/src/include/gnunetgtk_common.h @@ -27,6 +27,10 @@ #ifndef GTKUI_HELPER_H #define GTKUI_HELPER_H +#include +#include +#include + #define DEBUG_GTK 0 #if DEBUG_GTK @@ -39,10 +43,6 @@ #define DEBUG_END() #endif -#ifndef DATADIR -#include "datadir.h" -#endif - void initGNUnetGTKCommon(struct GE_Context * ectx, struct GC_Configuration * cfg, void * callback); diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c index 3b8bf244..4f7737dc 100644 --- a/src/plugins/daemon/daemon.c +++ b/src/plugins/daemon/daemon.c @@ -101,7 +101,7 @@ static void updateAppModelSafe(void * unused) { "applicationList"); gtk_tree_view_set_model(GTK_TREE_VIEW(w), GTK_TREE_MODEL(model)); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(searchList)), + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(w)), GTK_SELECTION_NONE); connection_destroy(sock); } diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am index b70c3284..fae720d5 100644 --- a/src/plugins/fs/Makefile.am +++ b/src/plugins/fs/Makefile.am @@ -16,6 +16,7 @@ libgnunetgtkmodule_fs_la_SOURCES = \ meta.c meta.h \ namespace.c namespace.h \ search.c search.h \ + download.c download.h \ upload.c upload.h libgnunetgtkmodule_fs_la_LIBADD = \ $(top_builddir)/src/common/libgnunetgtk_common.la \ diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c new file mode 100644 index 00000000..f425a3f7 --- /dev/null +++ b/src/plugins/fs/download.c @@ -0,0 +1,705 @@ +/* + This file is part of GNUnet. + (C) 2005, 2006 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + + +/** + * @file src/plugins/fs/download.c + * @brief code for downloading with gnunet-gtk + * @author Christian Grothoff + */ + +#include "fs.h" +#include "search.h" +#include "meta.h" +#include "platform.h" + +/* ****************** FSUI download events ****************** */ + +/** + * We are iterating over the contents of a + * directory. Add the list of entries to + * the search page at the position indicated + * by the download list. + */ +static int +addFilesToDirectory(const ECRS_FileInfo * fi, + const HashCode512 * key, + int isRoot, + void * closure) { + DownloadList * list = closure; + GtkTreeIter iter; + GtkTreeIter child; + int i; + GtkTreePath * path; + GtkTreeModel * model; + + if (isRoot == YES) + return OK; + if (! gtk_tree_row_reference_valid(list->searchViewRowReference)) + return SYSERR; + model = GTK_TREE_MODEL(list->searchList->tree); + path = gtk_tree_row_reference_get_path(list->searchViewRowReference); + gtk_tree_model_get_iter(model, + &iter, + path); + gtk_tree_path_free(path); + /* check for existing entry -- this function + maybe called multiple times for the same + directory entry */ + for (i=gtk_tree_model_iter_n_children(model, + &iter)-1;i>=0;i--) { + if (TRUE == gtk_tree_model_iter_nth_child(model, + &child, + &iter, + i)) { + struct ECRS_URI * uri; + uri = NULL; + gtk_tree_model_get(model, + &child, + SEARCH_URI, &uri, + -1); + if ( (uri != NULL) && + (ECRS_equalsUri(uri, + fi->uri)) ) + return OK; + } + } + gtk_tree_store_append(GTK_TREE_STORE(model), + &child, + &iter); + addEntryToSearchTree(list->searchList, + list, + fi, + &child); + return OK; +} + +static void +refreshDirectoryViewFromDisk(DownloadList * list) { + unsigned long long size; + char * data; + int fd; + struct ECRS_MetaData * meta; + + if ( (list->is_directory != YES) || + (list->searchList == NULL) || + (list->searchViewRowReference == NULL) || + (! gtk_tree_row_reference_valid(list->searchViewRowReference)) ) + return; + + if (OK != disk_file_size(ectx, + list->filename, + &size, + YES)) + return; + fd = disk_file_open(ectx, + list->filename, + O_RDONLY); + if (fd == -1) + return; + data = MMAP(NULL, + size, + PROT_READ, + MAP_SHARED, + fd, + 0); + if ( (data == MAP_FAILED) || + (data == NULL) ) { + GE_LOG_STRERROR_FILE(ectx, + GE_ERROR | GE_ADMIN | GE_BULK, + "mmap", + list->filename); + CLOSE(fd); + return; + } + meta = NULL; + ECRS_listDirectory(ectx, + data, + size, + &meta, + &addFilesToDirectory, + list); + MUNMAP(data, size); + CLOSE(fd); + if (meta != NULL) + ECRS_freeMetaData(meta); +} + +/** + * A download has been started. Add an entry + * to the search tree view (if applicable) and + * the download summary. + */ +DownloadList * +fs_download_started(struct FSUI_DownloadList * fsui_dl, + DownloadList * dl_parent, + SearchList * sl_parent, + unsigned long long total, + unsigned int anonymityLevel, + const ECRS_FileInfo * fi, + const char * filename, + unsigned long long completed, + cron_t eta) { + DownloadList * list; + GtkTreeIter iter; + GtkTreePath * path; + unsigned long long size; + char * size_h; + const char * sname; + int progress; + char * uri_name; + gboolean valid; + struct ECRS_URI * u; + + /* setup visualization */ + list = MALLOC(sizeof(DownloadList)); + memset(list, + 0, + sizeof(DownloadList)); + list->uri = ECRS_dupUri(fi->uri); + list->filename = STRDUP(filename); + /* FIXME: if we have dl_parent, + we may not want to just append! */ + gtk_tree_store_append(download_summary, + &iter, + NULL); + size = ECRS_fileSize(fi->uri); + size_h = string_get_fancy_byte_size(size); + sname = &filename[strlen(filename)-1]; + while ( (sname > filename) && + (sname[-1] != '/') && + (sname[-1] != '\\') ) + sname--; + if (size != 0) + progress = completed * 100 / size; + else + progress = 100; + uri_name = ECRS_uriToString(fi->uri); + gtk_tree_store_set(download_summary, + &iter, + DOWNLOAD_FILENAME, filename, + DOWNLOAD_SHORTNAME, sname, + DOWNLOAD_SIZE, size, + DOWNLOAD_HSIZE, size_h, + DOWNLOAD_PROGRESS, progress, + DOWNLOAD_URISTRING, uri_name, + DOWNLOAD_INTERNAL, list, + -1); + FREE(uri_name); + FREE(size_h); + path = gtk_tree_model_get_path(GTK_TREE_MODEL(download_summary), + &iter); + list->summaryViewRowReference + = gtk_tree_row_reference_new(GTK_TREE_MODEL(download_summary), + path); + gtk_tree_path_free(path); + list->searchList = sl_parent; + if (sl_parent != NULL) { + if (dl_parent != NULL) { + /* have parent, must be download from + directory inside of search */ + path = gtk_tree_row_reference_get_path(dl_parent->searchViewRowReference); + valid = gtk_tree_model_get_iter(GTK_TREE_MODEL(sl_parent->tree), + &iter, + path); + } else { + /* must be top-level entry in search */ + valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sl_parent->tree), + &iter); + } + if (valid == TRUE) { + valid = FALSE; + /* find matching entry */ + do { + gtk_tree_model_get(GTK_TREE_MODEL(sl_parent->tree), + &iter, + SEARCH_URI, &u, + -1); + if (ECRS_equalsUri(u, + fi->uri)) { + valid = TRUE; + path = gtk_tree_model_get_path(GTK_TREE_MODEL(sl_parent->tree), + &iter); + list->searchViewRowReference + = gtk_tree_row_reference_new(GTK_TREE_MODEL(sl_parent->tree), + path); + gtk_tree_path_free(path); + /* TODO: extend search model with status; + start to indicate active download! */ + break; + } + } while (TRUE == gtk_tree_model_iter_next(GTK_TREE_MODEL(sl_parent->tree), + &iter)); + } + if (valid == FALSE) { + /* did not find matching entry in search list + -- bug! Continue without adding to to + search list! */ + GE_BREAK(ectx, 0); + list->searchList = NULL; + } + } + list->fsui_list = fsui_dl; + list->total = total; + list->is_directory = ECRS_isDirectory(fi->meta); + list->next = download_head; + download_head = list; + if ( (list->is_directory == YES) && + (completed != 0) ) + refreshDirectoryViewFromDisk(list); + return list; +} + +/** + * The download has progressed. Update the + * summary and the preview of the directory + * contents in the search page (if applicable). + */ +void fs_download_update(DownloadList * list, + unsigned long long completed, + const char * data, + unsigned int size) { + GtkTreeIter iter; + GtkTreePath * path; + unsigned int val; + + path = gtk_tree_row_reference_get_path(list->summaryViewRowReference); + gtk_tree_model_get_iter(GTK_TREE_MODEL(download_summary), + &iter, + path); + gtk_tree_path_free(path); + if (list->total != 0) + val = completed * 100 / list->total; + else + val = 100; + gtk_tree_store_set(download_summary, + &iter, + DOWNLOAD_PROGRESS, val, + -1); + if ( (list->is_directory == YES) && + (list->searchList != NULL) && + (list->searchViewRowReference != NULL) ) { + struct ECRS_MetaData * meta; + + meta = NULL; + ECRS_listDirectory(ectx, + data, + size, + &meta, + &addFilesToDirectory, + list); + if (meta != NULL) + ECRS_freeMetaData(meta); + } +} + +/** + * A download has terminated successfully. Update summary and + * possibly refresh directory listing. + */ +void fs_download_completed(DownloadList * downloadContext) { + /* FIXME: update summary? / search list status entry (once added) */ + downloadContext->has_terminated = YES; + refreshDirectoryViewFromDisk(downloadContext); +} + +/** + * A download has been aborted. Update summary and + * possibly refresh directory listing. + */ +void fs_download_aborted(DownloadList * downloadContext) { + /* FIXME: update summary? / search list status entry (once added) */ + downloadContext->has_terminated = YES; + refreshDirectoryViewFromDisk(downloadContext); +} + +/** + * A download has been stopped. Remove from summary + * and free associated resources. + */ +void fs_download_stopped(DownloadList * list) { + GtkTreeIter iter; + GtkTreePath * path; + DownloadList * prev; + + path = gtk_tree_row_reference_get_path(list->summaryViewRowReference); + gtk_tree_model_get_iter(GTK_TREE_MODEL(download_summary), + &iter, + path); + gtk_tree_path_free(path); + gtk_tree_row_reference_free(list->summaryViewRowReference); + list->summaryViewRowReference = NULL; + gtk_tree_store_remove(download_summary, + &iter); + if (list->searchViewRowReference != NULL) { + gtk_tree_row_reference_free(list->searchViewRowReference); + list->searchViewRowReference = NULL; + } + FREE(list->filename); + ECRS_freeUri(list->uri); + + if (download_head == list) + download_head = list->next; + else { + prev = download_head; + while ( (prev != NULL) && + (prev->next != list) ) + prev = prev->next; + if (prev != NULL) + prev->next = list->next; + else + GE_BREAK(ectx, 0); + } + FREE(list); +} + + +/* **************** user download events ******************** */ + +/** + * The user clicked the download button. + * Start the download of the selected entry. + */ +static void +initiateDownload(GtkTreeModel * model, + GtkTreePath * path, + GtkTreeIter * iter, + gpointer unused) { + char * uri_name; + char * final_download_dir; + GtkTreeIter iiter; + const char * oname; + const char * cname; + char * dname; + GtkTreePath *dirTreePath; + char *dirPath; + unsigned int dirPathLen; + struct ECRS_URI * idc_uri; + struct ECRS_MetaData * idc_meta; + const char * idc_name; + const char * idc_mime; + char * idc_final_download_destination; + SearchList * searchContext; + DownloadList * parentContext; + +#ifdef WINDOWS + char *filehash = NULL; +#endif + + DEBUG_BEGIN(); + idc_uri = NULL; + idc_meta = NULL; + idc_name = NULL; + idc_mime = NULL; + searchContext = NULL; + parentContext = NULL; + gtk_tree_model_get(model, + iter, + SEARCH_NAME, &idc_name, + SEARCH_URI, &idc_uri, + SEARCH_META, &idc_meta, + SEARCH_MIME, &idc_mime, + SEARCH_INTERNAL, &searchContext, + SEARCH_INTERNAL_PARENT, &parentContext, + -1); + if ( (idc_uri == NULL) || + (! ECRS_isFileUri(idc_uri)) ) { + GE_BREAK(ectx, 0); + return; + } + uri_name = ECRS_uriToString(idc_uri); + if ( (uri_name == NULL) || + (strlen(uri_name) < + strlen(ECRS_URI_PREFIX) + + strlen(ECRS_FILE_INFIX)) ) { + GE_BREAK(ectx, 0); + FREENONNULL(uri_name); + return; + } + if (idc_name == NULL) { +#ifdef WINDOWS + filehash = STRDUP(uri_name); + filehash[16] = 0; + idc_name = filehash; +#else + idc_name = uri_name; +#endif + } + cname = idc_name; + oname = idc_name; + dname = MALLOC(strlen(idc_name)+1); + dname[0] = '\0'; + while (*idc_name != '\0') { + if ( (*idc_name == DIR_SEPARATOR) && + (idc_name[1] != '\0') ) { + memcpy(dname, oname, idc_name - oname); + dname[idc_name - oname] = '\0'; + cname = &idc_name[1]; + } + idc_name++; + } + if (*cname == '\0') /* name ended in '/' - likely directory */ + cname = oname; + idc_name = cname; + GC_get_configuration_value_filename(cfg, + "FS", + "INCOMINGDIR", + "$HOME/gnunet-downloads/", + &final_download_dir); + if (strlen(dname) > 0) { + char * tmp; + tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); + strcpy(tmp, final_download_dir); + if (tmp[strlen(tmp)] != DIR_SEPARATOR) + strcat(tmp, DIR_SEPARATOR_STR); + if (dname[0] == DIR_SEPARATOR) + strcat(tmp, &dname[1]); + else + strcat(tmp, dname); + FREE(final_download_dir); + final_download_dir = tmp; + } + FREE(dname); + disk_directory_create(ectx, final_download_dir); + + + /* If file is inside a directory, get the full path */ + dirTreePath = gtk_tree_path_copy(path); + dirPath = MALLOC(1); + dirPath[0] = '\0'; + dirPathLen = 0; + while (gtk_tree_path_get_depth(dirTreePath) > 1) { + const char * dirname; + char * new; + + if (! gtk_tree_path_up(dirTreePath)) + break; + + if (!gtk_tree_model_get_iter(model, + &iiter, + dirTreePath)) + break; + gtk_tree_model_get(model, + &iiter, + SEARCH_NAME, &dirname, + -1); + dirPathLen = strlen(dirPath) + strlen(dirname) + strlen(DIR_SEPARATOR_STR) + 1; + new = MALLOC(dirPathLen + 1); + strcpy(new, dirname); + if (new[strlen(new)-1] != DIR_SEPARATOR) + strcat(new, DIR_SEPARATOR_STR); + strcat(new, dirPath); + FREE(dirPath); + dirPath = new; + } + gtk_tree_path_free(dirTreePath); + + + /* construct completed/directory/real-filename */ + idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 + + strlen(idc_name) + strlen(GNUNET_DIRECTORY_EXT) + + strlen(dirPath)); + strcpy(idc_final_download_destination, final_download_dir); + if (idc_final_download_destination[strlen(idc_final_download_destination)-1] != DIR_SEPARATOR) + strcat(idc_final_download_destination, + DIR_SEPARATOR_STR); + strcat(idc_final_download_destination, dirPath); + disk_directory_create(ectx, + idc_final_download_destination); + strcat(idc_final_download_destination, idc_name); + if ( (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '/') || + (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '\\') ) + idc_final_download_destination[strlen(idc_final_download_destination) - 1] = '\0'; + /* append ".gnd" if needed (== directory and .gnd not present) */ + if ( (idc_mime != NULL) && + (0 == strcmp(idc_mime, GNUNET_DIRECTORY_MIME)) && + ( (strlen(idc_final_download_destination) < strlen(GNUNET_DIRECTORY_EXT)) || + (0 != strcmp(&idc_final_download_destination[strlen(idc_final_download_destination) + - strlen(GNUNET_DIRECTORY_EXT)], + GNUNET_DIRECTORY_EXT)) ) ) + strcat(idc_final_download_destination, GNUNET_DIRECTORY_EXT); + + addLogEntry(_("Downloading `%s'"), idc_name); + FSUI_startDownload(ctx, + 0, /* FIXME: anonymity level */ + NO, /* FIXME: isRecursive */ + idc_uri, + idc_meta, + idc_final_download_destination, + searchContext->fsui_list, + (parentContext != NULL) ? parentContext->fsui_list : NULL); + FREE(uri_name); + FREE(dirPath); + FREENONNULL(final_download_dir); +#ifdef WINDOWS + FREENONNULL(filehash); +#endif +} + +/** + * The download button in the search dialog was + * clicked. Download all selected entries. + */ +void on_downloadButton_clicked_fs(GtkWidget * treeview, + GtkWidget * downloadButton) { + GtkTreeSelection * selection; + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + gtk_tree_selection_selected_foreach + (selection, + &initiateDownload, + NULL); +} + + +/** + * User used the URI download entry. Start download + * that is NOT rooted within a search or directory. + * + * TODO: + * - support for recursive downloads + * - support for showing directories (if downloaded like this) + * - support for user-specified filename + */ +void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry, + GtkWidget * downloadButton) { + struct ECRS_URI * idc_uri; + struct ECRS_MetaData * idc_meta; + char * idc_final_download_destination; + const char * uris; + char * urid; + char * final_download_dir; + const char * dname; + + uris = gtk_entry_get_text(GTK_ENTRY(entry)); + urid = STRDUP(uris); + gtk_entry_set_text(GTK_ENTRY(entry), + ECRS_URI_PREFIX); + idc_uri = ECRS_stringToUri(ectx, urid); + if (idc_uri == NULL) { + addLogEntry(_("Invalid URI `%s'"), urid); + FREE(urid); + return; + } + if (ECRS_isKeywordUri(idc_uri)) { + addLogEntry(_("Please use the search function for keyword (KSK) URIs!")); + FREE(urid); + ECRS_freeUri(idc_uri); + return; + } else if (ECRS_isLocationUri(idc_uri)) { + addLogEntry(_("Location URIs are not yet supported")); + FREE(urid); + ECRS_freeUri(idc_uri); + return; + } + GC_get_configuration_value_filename(cfg, + "FS", + "INCOMINGDIR", + "$HOME/gnunet-downloads/", + &final_download_dir); + disk_directory_create(ectx, final_download_dir); + dname = &uris[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]; + idc_final_download_destination = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); + strcpy(idc_final_download_destination, final_download_dir); + FREE(final_download_dir); + if (idc_final_download_destination[strlen(idc_final_download_destination)] != DIR_SEPARATOR) + strcat(idc_final_download_destination, DIR_SEPARATOR_STR); + strcat(idc_final_download_destination, dname); + + addLogEntry(_("Downloading `%s'"), uris); + idc_meta = ECRS_createMetaData(); + FSUI_startDownload(ctx, + getSpinButtonValue(getMainXML(), + "fsstatusAnonymitySpin"), + NO, /* FIXME: isRecursive */ + idc_uri, + idc_meta, + idc_final_download_destination, + NULL, + NULL); + ECRS_freeMetaData(idc_meta); + FREE(urid); +} + + +static void +clearCompletedDownloadCallback(GtkTreeModel * model, + GtkTreePath * path, + GtkTreeIter * iter, + gpointer unused) { + DownloadList * dl; + + GE_ASSERT(ectx, + model == GTK_TREE_MODEL(download_summary)); + gtk_tree_model_get(model, + iter, + DOWNLOAD_INTERNAL, &dl, + -1); + if (dl->has_terminated) + FSUI_stopDownload(ctx, + dl->fsui_list); +} + +void on_clearCompletedDownloadsButton_clicked_fs(void * unused, + GtkWidget * clearButton) { + GtkTreeSelection * selection; + GtkWidget * downloadList; + + downloadList = glade_xml_get_widget(getMainXML(), + "activeDownloadsList"); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(downloadList)); + gtk_tree_selection_selected_foreach + (selection, + &clearCompletedDownloadCallback, + NULL); +} + +static void +abortDownloadCallback(GtkTreeModel * model, + GtkTreePath * path, + GtkTreeIter * iter, + gpointer unused) { + DownloadList * dl; + + GE_ASSERT(ectx, + model == GTK_TREE_MODEL(download_summary)); + gtk_tree_model_get(model, + iter, + DOWNLOAD_INTERNAL, &dl, + -1); + FSUI_abortDownload(ctx, + dl->fsui_list); +} + +void on_abortDownloadButton_clicked_fs(void * unused, + GtkWidget * clearButton) { + GtkTreeSelection * selection; + GtkWidget * downloadList; + + downloadList = glade_xml_get_widget(getMainXML(), + "activeDownloadsList"); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(downloadList)); + gtk_tree_selection_selected_foreach + (selection, + &abortDownloadCallback, + NULL); +} + +/* end of download.c */ diff --git a/src/plugins/fs/download.h b/src/plugins/fs/download.h new file mode 100644 index 00000000..e639b9e7 --- /dev/null +++ b/src/plugins/fs/download.h @@ -0,0 +1,56 @@ +/* + This file is part of GNUnet. + (C) 2005, 2006 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/download.h + * @brief code for searching with gnunet-gtk + * @author Christian Grothoff + */ + +#ifndef GTK_DOWNLOAD_H +#define GTK_DOWNLOAD_H + +#include +#include +#include "fs.h" + +DownloadList * +fs_download_started(struct FSUI_DownloadList * fsui_dl, + DownloadList * dl_parent, + SearchList * sl_parent, + unsigned long long total, + unsigned int anonymityLevel, + const ECRS_FileInfo * fi, + const char * filename, + unsigned long long completed, + cron_t eta); + +void fs_download_update(DownloadList * downloadContext, + unsigned long long completed, + const char * data, + unsigned int size); + +void fs_download_completed(DownloadList * downloadContext); + +void fs_download_aborted(DownloadList * downloadContext); + +void fs_download_stopped(DownloadList * downloadContext); + +#endif diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c index 654d8c82..edd2e045 100644 --- a/src/plugins/fs/fs.c +++ b/src/plugins/fs/fs.c @@ -25,19 +25,26 @@ */ #include "platform.h" -#include "gnunetgtk_common.h" #include "fs.h" +#include "download.h" #include "search.h" #include "upload.h" #include "collection.h" #include "namespace.h" -#include struct FSUI_Context * ctx; -static struct GE_Context * ectx; +struct GE_Context * ectx; -static struct GC_Configuration * cfg; +struct GC_Configuration * cfg; + +SearchList * search_head; + +DownloadList * download_head; + +GtkListStore * search_summary; + +GtkTreeStore * download_summary; typedef struct { const FSUI_Event * event; @@ -112,7 +119,7 @@ static void saveEventProcessor(void * arg) { break; case FSUI_download_started: cls->ret = fs_download_started(event->data.DownloadStarted.dc.pos, - event->data.DownloadStarted.dc.pctx, + event->data.DownloadStarted.dc.pcctx, event->data.DownloadStarted.dc.sctx, event->data.DownloadStarted.total, event->data.DownloadStarted.anonymityLevel, @@ -123,7 +130,7 @@ static void saveEventProcessor(void * arg) { break; case FSUI_download_resumed: cls->ret = fs_download_started(event->data.DownloadResumed.dc.pos, - event->data.DownloadStarted.dc.pctx, + event->data.DownloadStarted.dc.pcctx, event->data.DownloadStarted.dc.sctx, event->data.DownloadResumed.total, event->data.DownloadResumed.anonymityLevel, @@ -185,6 +192,159 @@ static void * eventProcessor(void * unused, return cls.ret; } + + +/** + * Setup the summary views (in particular the models + * and the renderers). + */ +static void fs_summary_start() { + GtkComboBoxEntry * searchCB; + GtkTreeView * searchList; + GtkTreeView * downloadList; + GtkListStore * model; + GtkCellRenderer * renderer; + GtkTreeViewColumn * column; + int col; + + searchCB + = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(), + "fssearchKeywordComboBoxEntry")); + + model = gtk_list_store_new(NS_SEARCH_NUM, + G_TYPE_STRING, /* what we show */ + G_TYPE_STRING, /* EncName of namespace */ + G_TYPE_POINTER, /* ECRS MetaData */ + G_TYPE_POINTER, /* FSUI search list */ + G_TYPE_INT); /* Meta-data about namespace */ + gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB), + GTK_TREE_MODEL(model)); + gtk_combo_box_entry_set_text_column(searchCB, + NS_SEARCH_DESCRIPTION); + searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), + "activeSearchesSummary")); + search_summary = + gtk_list_store_new(SEARCH_SUMMARY_NUM, + G_TYPE_STRING, /* name */ + G_TYPE_INT, /* # results */ + G_TYPE_POINTER); /* internal: search list */ + gtk_tree_view_set_model(searchList, + GTK_TREE_MODEL(search_summary)); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(searchList), + GTK_SELECTION_MULTIPLE); + + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_insert_column_with_attributes(searchList, + -1, + _("Query"), + renderer, + "text", SEARCH_SUMMARY_NAME, + NULL); + column = gtk_tree_view_get_column(searchList, + col - 1); + gtk_tree_view_column_set_resizable(column, TRUE); + gtk_tree_view_column_set_clickable(column, TRUE); + gtk_tree_view_column_set_reorderable(column, TRUE); + gtk_tree_view_column_set_sort_column_id(column, SEARCH_SUMMARY_NAME); + gtk_tree_view_column_set_resizable(column, TRUE); + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_insert_column_with_attributes(searchList, + -1, + _("Results"), + renderer, + "text", SEARCH_SUMMARY_RESULT_COUNT, + NULL); + column = gtk_tree_view_get_column(searchList, + col - 1); + gtk_tree_view_column_set_resizable(column, TRUE); + gtk_tree_view_column_set_clickable(column, TRUE); + gtk_tree_view_column_set_reorderable(column, TRUE); + gtk_tree_view_column_set_sort_column_id(column, SEARCH_SUMMARY_RESULT_COUNT); + gtk_tree_view_column_set_resizable(column, TRUE); + + + downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), + "activeDownloadsList")); + download_summary = + gtk_tree_store_new(DOWNLOAD_NUM, + G_TYPE_STRING, /* name (full-path file name) */ + G_TYPE_STRING, /* name (user-friendly name) */ + G_TYPE_UINT64, /* size */ + G_TYPE_STRING, /* human readable size */ + G_TYPE_INT, /* progress */ + G_TYPE_STRING, /* uri as string */ + G_TYPE_POINTER); /* internal download list ptr */ + gtk_tree_view_set_model(downloadList, + GTK_TREE_MODEL(download_summary)); + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(downloadList), + GTK_SELECTION_MULTIPLE); + renderer = gtk_cell_renderer_progress_new(); + col = gtk_tree_view_insert_column_with_attributes(downloadList, + -1, + _("Name"), + renderer, + "value", DOWNLOAD_PROGRESS, + "text", DOWNLOAD_SHORTNAME, + NULL); + column = gtk_tree_view_get_column(downloadList, + col - 1); + gtk_tree_view_column_set_resizable(column, TRUE); + gtk_tree_view_column_set_clickable(column, TRUE); + gtk_tree_view_column_set_reorderable(column, TRUE); + gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS); + /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ + gtk_tree_view_column_set_resizable(column, TRUE); + renderer = gtk_cell_renderer_text_new(); + g_object_set (renderer, "xalign", 1.00, NULL); + col = gtk_tree_view_insert_column_with_attributes(downloadList, + -1, + _("Size"), + renderer, + "text", DOWNLOAD_HSIZE, + NULL); + + column = gtk_tree_view_get_column(downloadList, + col - 1); + gtk_tree_view_column_set_resizable(column, TRUE); + gtk_tree_view_column_set_clickable(column, TRUE); + gtk_tree_view_column_set_reorderable(column, TRUE); + gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE); + /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ + gtk_tree_view_column_set_resizable(column, TRUE); + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_insert_column_with_attributes(downloadList, + -1, + _("URI"), + renderer, + "text", DOWNLOAD_URISTRING, + NULL); + column = gtk_tree_view_get_column(downloadList, + col - 1); + gtk_tree_view_column_set_resizable(column, TRUE); + gtk_tree_view_column_set_reorderable(column, TRUE); + /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ + gtk_tree_view_column_set_resizable(column, TRUE); +} + +/** + * Shutdown. + */ +static void fs_summary_stop() { + GtkComboBox * searchCB; + GtkListStore * model; + + searchCB + = GTK_COMBO_BOX(glade_xml_get_widget(getMainXML(), + "fssearchKeywordComboBoxEntry")); + model = GTK_LIST_STORE(gtk_combo_box_get_model(searchCB)); + /* FIXME: iterate over model entries + and free URIs and MetaData! */ +} + + + + + void init_fs(struct GE_Context * e, struct GC_Configuration * c) { GtkWidget * tab; @@ -211,7 +371,7 @@ void init_fs(struct GE_Context * e, &eventProcessor, NULL); fs_collection_start(ectx, cfg); - fs_search_start(ectx, cfg); + fs_summary_start(); fs_upload_start(ectx, cfg); fs_namespace_start(ectx, cfg); } @@ -223,7 +383,7 @@ void done_fs() { = glade_xml_get_widget(getMainXML(), "fsnotebook"); gtk_widget_hide(tab); - fs_search_stop(); + fs_summary_stop(); fs_collection_stop(); fs_namespace_stop(); fs_upload_stop(); diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h index 690bf072..24a638a1 100644 --- a/src/plugins/fs/fs.h +++ b/src/plugins/fs/fs.h @@ -29,7 +29,7 @@ #include #include - +#include "gnunetgtk_common.h" /** * On search box, for namespace selection @@ -58,6 +58,7 @@ enum { SEARCH_URI, SEARCH_META, SEARCH_INTERNAL, + SEARCH_INTERNAL_PARENT, SEARCH_NUM, }; @@ -129,6 +130,139 @@ enum { KTYPE_NUM, }; + +/** + * @brief linked list of pages in the search notebook + */ +typedef struct SL { + struct SL * next; + /** + * Reference to the glade XML context that was + * used to create the search page. + */ + GladeXML * searchXML; + + /** + * Reference to the glade XML context that was + * used to create the search label. + */ + GladeXML * labelXML; + + /** + * Tree view widget that is used to display the + * search results. + */ + GtkTreeView * treeview; + + /** + * Model of the tree view. + */ + GtkTreeStore * tree; + + /** + * The label used in the notebook page. + */ + GtkWidget * tab_label; + + /** + * The notebook page that is associated with this + * search. + */ + GtkWidget * searchpage; + + /** + * Path to the entry in the summary list + * for this search. + */ + GtkTreeRowReference * summaryViewRowReference; + + /** + * URI for this search. + */ + struct ECRS_URI * uri; + + /** + * String describing the search. + */ + char * searchString; + + /** + * Number of results received so far. + */ + unsigned int resultsReceived; + + /** + * FSUI search handle. + */ + struct FSUI_SearchList * fsui_list; +} SearchList; + + +typedef struct DL { + struct DL * next; + + /** + * URI of the download. + */ + struct ECRS_URI * uri; + + /** + * Where is the download being saved to? + */ + char * filename; + + /** + * Path in the summary view for this download. + */ + GtkTreeRowReference * summaryViewRowReference; + + /** + * Search that this download belongs to. + * Maybe NULL. + */ + struct SL * searchList; + + /** + * Path in the search view that this + * download is represented by. Maybe NULL + * if search has been closed or if download + * was initiated from URI without search. + */ + GtkTreeRowReference * searchViewRowReference; + + /** + * FSUI reference for the download. + */ + struct FSUI_DownloadList * fsui_list; + + /** + * Total size of the download. + */ + unsigned long long total; + + /** + * Is this a GNUnet directory? (by mime-type) + */ + int is_directory; + + int has_terminated; + +} DownloadList; + extern struct FSUI_Context * ctx; +extern struct GE_Context * ectx; + +extern struct GC_Configuration * cfg; + +extern SearchList * search_head; + +extern DownloadList * download_head; + +extern GtkListStore * search_summary; + +extern GtkTreeStore * download_summary; + + + #endif diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c index 4c53891e..12087f30 100644 --- a/src/plugins/fs/meta.c +++ b/src/plugins/fs/meta.c @@ -498,7 +498,7 @@ char * getMimeTypeFromMetaData(const struct ECRS_MetaData * meta) { char * getFileNameFromMetaData(const struct ECRS_MetaData * meta) { char * name; - name = ECRS_getFirstFromMetaData(info->meta, + name = ECRS_getFirstFromMetaData(meta, EXTRACTOR_FILENAME, EXTRACTOR_TITLE, EXTRACTOR_ARTIST, @@ -522,7 +522,7 @@ char * getFileNameFromMetaData(const struct ECRS_MetaData * meta) { char * getDescriptionFromMetaData(const struct ECRS_MetaData * meta) { char * desc; - desc = ECRS_getFirstFromMetaData(info->meta, + desc = ECRS_getFirstFromMetaData(meta, EXTRACTOR_DESCRIPTION, EXTRACTOR_GENRE, EXTRACTOR_ALBUM, @@ -538,7 +538,7 @@ char * getDescriptionFromMetaData(const struct ECRS_MetaData * meta) { } GdkPixbuf * getThumbnailFromMetaData(const struct ECRS_MetaData * meta) { - GdkPixbuf * pxibuf; + GdkPixbuf * pixbuf; GdkPixbufLoader * loader; size_t ts; unsigned char * thumb; @@ -576,7 +576,7 @@ extractMainWidgetFromWindow(GladeXML * xml, ret = gtk_bin_get_child(GTK_BIN(window)); gtk_widget_ref(ret); gtk_container_remove(window, ret); - gtk_widget_destroy(window); + gtk_widget_destroy(GTK_WIDGET(window)); return ret; } diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index 63d7622c..f026d07e 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c @@ -22,12 +22,6 @@ * @file src/plugins/fs/search.c * @brief code for searching with gnunet-gtk * @author Christian Grothoff - * - * - * TODO: - * - figure out how to handle directories displayed on the - * search page (and how to communicate for downloads that - * they do or do not hang in the search page!) */ #include "platform.h" @@ -40,123 +34,6 @@ #include #include - -/** - * @brief linked list of pages in the search notebook - */ -typedef struct SL { - struct SL * next; - /** - * Reference to the glade XML context that was - * used to create the search page. - */ - GladeXML * searchXML; - - /** - * Reference to the glade XML context that was - * used to create the search label. - */ - GladeXML * labelXML; - - /** - * Tree view widget that is used to display the - * search results. - */ - GtkTreeView * treeview; - - /** - * Model of the tree view. - */ - GtkTreeStore * tree; - - /** - * The label used in the notebook page. - */ - GtkLabel * tab_label; - - /** - * The notebook page that is associated with this - * search. - */ - GtkWidget * searchpage; - - /** - * Path to the entry in the summary list - * for this search. - */ - GtkTreeRowReference * summaryViewRowReference; - - /** - * URI for this search. - */ - struct ECRS_URI * uri; - - /** - * String describing the search. - */ - char * searchString; - - /** - * Number of results received so far. - */ - unsigned int resultsReceived; - - /** - * FSUI search handle. - */ - struct FSUI_SearchList * fsui_list; -} SearchList; - -typedef struct DL { - struct DL * next; - - /** - * URI of the download. - */ - struct ECRS_URI * uri; - - /** - * Where is the download being saved to? - */ - char * filename; - - /** - * Path in the summary view for this download. - */ - GtkTreeRowReference * summaryViewRowReference; - - /** - * Search that this download belongs to. - * Maybe NULL. - */ - struct SL * searchList; - - /** - * Path in the search view that this - * download is represented by. Maybe NULL - * if search has been closed or if download - * was initiated from URI without search. - */ - GtkTreeRowReference * searchViewRowReference; - - /** - * FSUI reference for the download. - */ - struct FSUI_DownloadList * fsui_list; -} DownloadList; - -static SearchList * search_head; - -static DownloadList * download_head; - -static GtkListStore * search_summary; - -static GtkTreeStore * download_summary; - -static struct GE_Context * ectx; - -static struct GC_Configuration * cfg; - /** * The user has clicked the "SEARCH" button. * Initiate a search. @@ -301,7 +178,7 @@ void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, list = search_head; while (list != NULL) { if ( (list->searchpage == searchPage) || - (list->tab_label == searchPage) ) + (list->tab_label == searchPage) ) break; list = list->next; } @@ -332,7 +209,7 @@ static void stopSearch(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer unused) { - struct SL * s; + SearchList * s; s = NULL; gtk_tree_model_get(model, @@ -362,7 +239,7 @@ static void abortSearch(GtkTreeModel * model, GtkTreePath * path, GtkTreeIter * iter, gpointer unused) { - struct SL * s; + SearchList * s; s = NULL; gtk_tree_model_get(model, @@ -392,11 +269,11 @@ void on_abortSearchSummaryButton_clicked_fs(GtkWidget * treeview, * Update the number of results received for the given * search in the summary and in the label of the tab. */ -static void updateSearchSummary(struct SL * searchContext) { +static void updateSearchSummary(SearchList * searchContext) { GtkTreePath * path; GtkTreeIter iter; char * new_title; - GtkWidget * label; + GtkLabel * label; path = gtk_tree_row_reference_get_path(searchContext->summaryViewRowReference); if (TRUE != gtk_tree_model_get_iter(GTK_TREE_MODEL(search_summary), @@ -418,45 +295,35 @@ static void updateSearchSummary(struct SL * searchContext) { g_strdup_printf("%s (%u)", searchContext->searchString, searchContext->resultsReceived); - label = glade_xml_get_widget(searchContext->labelXML, - "searchTabLabel"); + label = GTK_LABEL(glade_xml_get_widget(searchContext->labelXML, + "searchTabLabel")); gtk_label_set(label, new_title); FREE(new_title); } /** - * Add the given result to the model (search result - * list). - * - * @param info the information to add to the model - * @param uri the search URI - * @param searchContext identifies the search page + * Add the given search result to the search + * tree at the specified position. */ -void fs_search_result_received(struct SL * searchContext, - const ECRS_FileInfo * info, - const struct ECRS_URI * uri) { +void addEntryToSearchTree(SearchList * searchContext, + DownloadList * downloadParent, + const ECRS_FileInfo * info, + GtkTreeIter * iter) { char * name; char * mime; char * desc; unsigned long long size; char * size_h; - GtkTreeStore * model; - GtkTreeIter iter; + GdkPixbuf * pixbuf; mime = getMimeTypeFromMetaData(info->meta); desc = getDescriptionFromMetaData(info->meta); name = getFileNameFromMetaData(info->meta); - size = ECRS_isFileUri(info->uri) ? ECRS_fileSize(info->uri) : 0 + size = ECRS_isFileUri(info->uri) ? ECRS_fileSize(info->uri) : 0; pixbuf = getThumbnailFromMetaData(info->meta); size_h = string_get_fancy_byte_size(size); - model = GTK_TREE_STORE - (gtk_tree_view_get_model - (GTK_TREE_VIEW(searchContext->treeview))); - gtk_tree_store_append(model, - &iter, - NULL); - gtk_tree_store_set(model, - &iter, + gtk_tree_store_set(searchContext->tree, + iter, SEARCH_NAME, name, SEARCH_SIZE, size, SEARCH_HSIZE, size_h, @@ -466,12 +333,36 @@ void fs_search_result_received(struct SL * searchContext, SEARCH_URI, ECRS_dupUri(info->uri), SEARCH_META, ECRS_dupMetaData(info->meta), SEARCH_INTERNAL, searchContext, + SEARCH_INTERNAL_PARENT, downloadParent, -1); FREE(size_h); FREE(name); FREE(desc); FREE(mime); - /* UNREF pixbuf? */ +} + +/** + * Add the given result to the model (search result + * list). + * + * @param info the information to add to the model + * @param uri the search URI + * @param searchContext identifies the search page + */ +void fs_search_result_received(SearchList * searchContext, + const ECRS_FileInfo * info, + const struct ECRS_URI * uri) { + GtkTreeStore * model; + GtkTreeIter iter; + + model = GTK_TREE_STORE(gtk_tree_view_get_model(searchContext->treeview)); + gtk_tree_store_append(model, + &iter, + NULL); + addEntryToSearchTree(searchContext, + NULL, + info, + &iter); searchContext->resultsReceived++; updateSearchSummary(searchContext); } @@ -480,23 +371,23 @@ void fs_search_result_received(struct SL * searchContext, * FSUI event: a search was started; create the * tab and add an entry to the summary. */ -struct SL * +SearchList * fs_search_started(struct FSUI_SearchList * fsui_list, const struct ECRS_URI * uri, unsigned int anonymityLevel, unsigned int resultCount, const ECRS_FileInfo * results) { - struct SL * list; + SearchList * list; gint pages; char * description; const char * dhead; - GtkContainer * window; GtkTreeViewColumn * column; GtkCellRenderer * renderer; - int col; GtkNotebook * notebook; GtkTreePath * path; GtkTreeIter iter; + int col; + int i; description = ECRS_uriToString(uri); if (description == NULL) { @@ -515,10 +406,10 @@ fs_search_started(struct FSUI_SearchList * fsui_list, strlen(ECRS_SUBSPACE_INFIX))) dhead = &dhead[strlen(ECRS_SUBSPACE_INFIX)]; list - = MALLOC(sizeof(struct SL)); + = MALLOC(sizeof(SearchList)); memset(list, 0, - sizeof(struct SL)); + sizeof(SearchList)); list->searchString = STRDUP(dhead); FREE(description); @@ -551,7 +442,8 @@ fs_search_started(struct FSUI_SearchList * fsui_list, GDK_TYPE_PIXBUF, /* preview */ G_TYPE_POINTER, /* url */ G_TYPE_POINTER, /* meta */ - G_TYPE_POINTER); /* internal: download info/NULL */ + G_TYPE_POINTER, /* internal: search list */ + G_TYPE_POINTER); /* internal: download parent list */ gtk_tree_view_set_model(list->treeview, GTK_TREE_MODEL(list->tree)); @@ -721,13 +613,12 @@ static void freeIterSubtree(GtkTreeModel * tree, */ void fs_search_stopped(SearchList * list) { GtkNotebook * notebook; - int index; - int i; GtkTreeIter iter; - struct ECRS_URI * euri; SearchList * prev; DownloadList * downloads; GtkTreePath * path; + int index; + int i; /* remove from linked list */ if (search_head == list) { @@ -742,10 +633,10 @@ void fs_search_stopped(SearchList * list) { /* remove links from download views */ downloads = download_head; while (downloads != NULL) { - if (download->searchList == list) { - gtk_tree_row_reference_free(download->searchViewRowReference); - download->searchViewRowReference = NULL; - download->searchList = NULL; + if (downloads->searchList == list) { + gtk_tree_row_reference_free(downloads->searchViewRowReference); + downloads->searchViewRowReference = NULL; + downloads->searchList = NULL; } downloads = downloads->next; } @@ -764,9 +655,9 @@ void fs_search_stopped(SearchList * list) { index); /* recursively free search model */ - if (gtk_tree_model_get_iter_first(list->model, + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list->tree), &iter)) - freeIterSubtree(list->model, + freeIterSubtree(GTK_TREE_MODEL(list->tree), &iter); /* destroy entry in summary */ @@ -788,760 +679,4 @@ void fs_search_stopped(SearchList * list) { } - - - - - - -#if 0 -static int addFilesToDirectory - (const ECRS_FileInfo * fi, - const HashCode512 * key, - int isRoot, - void * closure) { - struct ECRS_URI * uri = closure; - DownloadList * pos; - GtkTreeIter iter; - GtkTreeIter child; - int i; - GtkTreePath * path; - - if (isRoot == YES) - return OK; - DEBUG_BEGIN(); - pos = download_head; - while (pos != NULL) { - if (ECRS_equalsUri(uri, - pos->uri)) - break; - pos = pos->next; - } - if (pos != NULL) { - if (! gtk_tree_row_reference_valid(pos->rr)) - return SYSERR; - path = gtk_tree_row_reference_get_path(pos->rr); - gtk_tree_model_get_iter(GTK_TREE_MODEL(pos->model), - &iter, - path); - gtk_tree_path_free(path); - for (i=gtk_tree_model_iter_n_children(pos->model, - &iter)-1;i>=0;i--) { - if (TRUE == gtk_tree_model_iter_nth_child(pos->model, - &child, - &iter, - i)) { - struct ECRS_URI * uri; - uri = NULL; - gtk_tree_model_get(pos->model, - &child, - SEARCH_URI, &uri, - -1); - if ( (uri != NULL) && - (ECRS_equalsUri(uri, - fi->uri)) ) - return OK; - } - } - gtk_tree_store_append(GTK_TREE_STORE(pos->model), - &child, - &iter); - addEntryToSearchTree(GTK_TREE_STORE(pos->model), - &child, - fi->uri, - fi->meta); - } - DEBUG_END(); - return OK; -} -#endif - - -/** - * A download has been started. Add an entry - * to the search tree view (if applicable) and - * the download summary. - */ -struct DL * -fs_download_started(struct FSUI_DownloadList * fsui_dl, - struct DL * dl_parent, - struct SL * sl_parent, - unsigned long long total, - unsigned int anonymityLevel, - const ECRS_FileInfo * fi, - const char * filename, - unsigned long long completed, - cron_t eta) { - DownloadList * list; - GtkTreeIter iiter; - unsigned long long size; - char * size_h; - const char * sname; - int progress; - char * uri_name; - - /* setup visualization */ - list = MALLOC(sizeof(DownloadList)); - list->fsui_list = fsui_dl; - list->rr = NULL; - list->model = NULL; -#if 0 - if (YES == ECRS_isDirectory(fi->meta)) { - list->rr = gtk_tree_row_reference_new(model, path); - list->model = model; - } -#endif - list->uri = ECRS_dupUri(fi->uri); - list->filename = STRDUP(filename); - size = ECRS_fileSize(fi->uri); - size_h = string_get_fancy_byte_size(size); - sname = &filename[strlen(filename)-1]; - while ( (sname > filename) && - (sname[-1] != '/') && - (sname[-1] != '\\') ) - sname--; - if (size != 0) - progress = completed * 100 / size; - else - progress = 100; - uri_name = ECRS_uriToString(fi->uri); - gtk_tree_store_append(download_summary, - &iiter, - NULL); - gtk_tree_store_set(download_summary, - &iiter, - DOWNLOAD_FILENAME, filename, - DOWNLOAD_SHORTNAME, sname, - DOWNLOAD_SIZE, size, - DOWNLOAD_HSIZE, size_h, - DOWNLOAD_PROGRESS, progress, - DOWNLOAD_URISTRING, uri_name, - DOWNLOAD_URI, ECRS_dupUri(fi->uri), - DOWNLOAD_TREEPATH, list->rr, /* internal: row reference! */ - DOWNLOAD_POS, list, - -1); - FREE(uri_name); - FREE(size_h); - list->next = download_head; - download_head = list; - DEBUG_END(); - return list; -} - - - - -static void initiateDownload(GtkTreeModel * model, - GtkTreePath * path, - GtkTreeIter * iter, - gpointer unused) { - char * uri_name; - char * final_download_dir; - GtkTreeIter iiter; - GtkWidget * spin; - const char * oname; - const char * cname; - char * dname; - GtkTreePath *dirTreePath; - char *dirPath; - unsigned int dirPathLen; - struct ECRS_URI * idc_uri; - struct ECRS_MetaData * idc_meta; - const char * idc_name; - const char * idc_mime; - char * idc_final_download_destination; - unsigned int idc_anon; - struct SL * searchContext; - -#ifdef WINDOWS - char *filehash = NULL; -#endif - - DEBUG_BEGIN(); - idc_uri = NULL; - idc_meta = NULL; - idc_name = NULL; - idc_mime = NULL; - gtk_tree_model_get(model, - iter, - SEARCH_NAME, &idc_name, - SEARCH_URI, &idc_uri, - SEARCH_META, &idc_meta, - SEARCH_MIME, &idc_mime, - SEARCH_INTERNAL, &searchContext, - -1); - if (idc_uri == NULL) { - GE_BREAK(ectx, 0); - return; - } - - spin = searchContext->anonymityButton; - if (spin == NULL) { - GE_BREAK(ectx, 0); - idc_anon = 1; - } else { - idc_anon = gtk_spin_button_get_value_as_int - (GTK_SPIN_BUTTON(spin)); - } - if (! ECRS_isFileUri(idc_uri)) { - if (ECRS_isNamespaceUri(idc_uri)) { - /* start namespace search; would probably be better - to add this as a subtree, but for simplicity - we'll just add it as a new tab for now */ - FSUI_startSearch(ctx, - idc_anon, - 1000, /* FIXME: max results */ - 99 * cronYEARS, /* fixme: timeout */ - idc_uri); - return; - } else { - GE_BREAK(ectx, 0); /* unsupported URI type (i.e. ksk or loc) */ - return; - } - } - - uri_name = ECRS_uriToString(idc_uri); - if ( (uri_name == NULL) || - (strlen(uri_name) < - strlen(ECRS_URI_PREFIX) + - strlen(ECRS_FILE_INFIX)) ) { - GE_BREAK(ectx, 0); - FREENONNULL(uri_name); - return; - } - - if (idc_name == NULL) { -#ifdef WINDOWS - filehash = STRDUP(uri_name); - filehash[16] = 0; - idc_name = filehash; -#else - idc_name = uri_name; -#endif - } - - cname = idc_name; - oname = idc_name; - dname = MALLOC(strlen(idc_name)+1); - dname[0] = '\0'; - while (*idc_name != '\0') { - if ( (*idc_name == DIR_SEPARATOR) && - (idc_name[1] != '\0') ) { - memcpy(dname, oname, idc_name - oname); - dname[idc_name - oname] = '\0'; - cname = &idc_name[1]; - } - idc_name++; - } - if (*cname == '\0') /* name ended in '/' - likely directory */ - cname = oname; - idc_name = cname; - GC_get_configuration_value_filename(cfg, - "FS", - "INCOMINGDIR", - "$HOME/gnunet-downloads/", - &final_download_dir); - if (strlen(dname) > 0) { - char * tmp; - tmp = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); - strcpy(tmp, final_download_dir); - if (tmp[strlen(tmp)] != DIR_SEPARATOR) - strcat(tmp, DIR_SEPARATOR_STR); - if (dname[0] == DIR_SEPARATOR) - strcat(tmp, &dname[1]); - else - strcat(tmp, dname); - FREE(final_download_dir); - final_download_dir = tmp; - } - FREE(dname); - disk_directory_create(ectx, final_download_dir); - - - /* If file is inside a directory, get the full path */ - dirTreePath = gtk_tree_path_copy(path); - dirPath = MALLOC(1); - dirPath[0] = '\0'; - dirPathLen = 0; - while (gtk_tree_path_get_depth(dirTreePath) > 1) { - const char * dirname; - char * new; - - if (! gtk_tree_path_up(dirTreePath)) - break; - - if (!gtk_tree_model_get_iter(model, - &iiter, - dirTreePath)) - break; - gtk_tree_model_get(model, - &iiter, - SEARCH_NAME, &dirname, - -1); - dirPathLen = strlen(dirPath) + strlen(dirname) + strlen(DIR_SEPARATOR_STR) + 1; - new = MALLOC(dirPathLen + 1); - strcpy(new, dirname); - if (new[strlen(new)-1] != DIR_SEPARATOR) - strcat(new, DIR_SEPARATOR_STR); - strcat(new, dirPath); - FREE(dirPath); - dirPath = new; - } - gtk_tree_path_free(dirTreePath); - - - /* construct completed/directory/real-filename */ - idc_final_download_destination = MALLOC(strlen(final_download_dir) + 2 + - strlen(idc_name) + strlen(GNUNET_DIRECTORY_EXT) + - strlen(dirPath)); - strcpy(idc_final_download_destination, final_download_dir); - if (idc_final_download_destination[strlen(idc_final_download_destination)-1] != DIR_SEPARATOR) - strcat(idc_final_download_destination, - DIR_SEPARATOR_STR); - strcat(idc_final_download_destination, dirPath); - disk_directory_create(ectx, - idc_final_download_destination); - strcat(idc_final_download_destination, idc_name); - if ( (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '/') || - (idc_final_download_destination[strlen(idc_final_download_destination) - 1] == '\\') ) - idc_final_download_destination[strlen(idc_final_download_destination) - 1] = '\0'; - /* append ".gnd" if needed (== directory and .gnd not present) */ - if ( (idc_mime != NULL) && - (0 == strcmp(idc_mime, GNUNET_DIRECTORY_MIME)) && - ( (strlen(idc_final_download_destination) < strlen(GNUNET_DIRECTORY_EXT)) || - (0 != strcmp(&idc_final_download_destination[strlen(idc_final_download_destination) - - strlen(GNUNET_DIRECTORY_EXT)], - GNUNET_DIRECTORY_EXT)) ) ) - strcat(idc_final_download_destination, GNUNET_DIRECTORY_EXT); - - addLogEntry(_("Downloading `%s'"), idc_name); - FSUI_startDownload(ctx, - idc_anon, - NO, /* FIXME: isRecursive */ - idc_uri, - idc_meta, - idc_final_download_destination, - NULL, - NULL); - FREE(uri_name); - FREE(dirPath); - FREENONNULL(final_download_dir); -#ifdef WINDOWS - FREENONNULL(filehash); -#endif -} - -void on_downloadButton_clicked_fs(GtkWidget * treeview, - GtkWidget * downloadButton) { - GtkTreeSelection * selection; - - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - gtk_tree_selection_selected_foreach - (selection, - &initiateDownload, - NULL); -} - - -void on_statusDownloadURIEntry_editing_done_fs(GtkWidget * entry, - GtkWidget * downloadButton) { - struct ECRS_URI * idc_uri; - struct ECRS_MetaData * idc_meta; - char * idc_final_download_destination; - unsigned int idc_anon; - const char * uris; - char * urid; - GtkWidget * spin; - char * final_download_dir; - const char * dname; - - uris = gtk_entry_get_text(GTK_ENTRY(entry)); - urid = STRDUP(uris); - gtk_entry_set_text(GTK_ENTRY(entry), - ECRS_URI_PREFIX); - idc_uri = ECRS_stringToUri(ectx, urid); - if (idc_uri == NULL) { - addLogEntry(_("Invalid URI `%s'"), urid); - FREE(urid); - return; - } - if (ECRS_isKeywordUri(idc_uri)) { - addLogEntry(_("Please use the search function for keyword (KSK) URIs!")); - FREE(urid); - ECRS_freeUri(idc_uri); - return; - } else if (ECRS_isLocationUri(idc_uri)) { - addLogEntry(_("Location URIs are not yet supported")); - FREE(urid); - ECRS_freeUri(idc_uri); - return; - } - GC_get_configuration_value_filename(cfg, - "FS", - "INCOMINGDIR", - "$HOME/gnunet-downloads/", - &final_download_dir); - disk_directory_create(ectx, final_download_dir); - dname = &uris[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]; - idc_final_download_destination = MALLOC(strlen(final_download_dir) + strlen(dname) + 2); - strcpy(idc_final_download_destination, final_download_dir); - FREE(final_download_dir); - if (idc_final_download_destination[strlen(idc_final_download_destination)] != DIR_SEPARATOR) - strcat(idc_final_download_destination, DIR_SEPARATOR_STR); - strcat(idc_final_download_destination, dname); - - /* get anonymity level */ - spin = glade_xml_get_widget(getMainXML(), - "fsstatusAnonymitySpin"); - if (spin == NULL) { - GE_BREAK(ectx, 0); - idc_anon = 1; - } else { - idc_anon = gtk_spin_button_get_value_as_int - (GTK_SPIN_BUTTON(spin)); - } - addLogEntry(_("Downloading `%s'"), uris); - idc_meta = ECRS_createMetaData(); - FSUI_startDownload(ctx, - idc_anon, - NO, /* FIXME: isRecursive */ - idc_uri, - idc_meta, - idc_final_download_destination, - NULL, - NULL); - ECRS_freeMetaData(idc_meta); - FREE(urid); -} - - -void fs_download_update(struct DL * downloadContext, - unsigned long long completed, - const char * data, - unsigned int size) { - GtkTreeIter iter; - unsigned int val; - unsigned long long total; - struct DL * p; - - DEBUG_BEGIN(); - if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(download_summary), - &iter)) { - do { - gtk_tree_model_get(GTK_TREE_MODEL(download_summary), - &iter, - DOWNLOAD_SIZE, &total, - DOWNLOAD_POS, &p, - -1); - if (p == downloadContext) { - if (total != 0) - val = completed * 100 / total; - else - val = 100; - gtk_tree_store_set(download_summary, - &iter, - DOWNLOAD_PROGRESS, val, - -1); - break; - } - } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(download_summary), - &iter)); - } -#if 0 - meta = NULL; - ECRS_listDirectory(ectx, - data, - size, - &meta, - &addFilesToDirectory, - downloadContext->uri); - if (meta != NULL) - ECRS_freeMetaData(meta); -#endif - DEBUG_END(); -} - -void fs_download_completed(struct DL * downloadContext) { - unsigned long long size; - char * data; - int fd; - struct ECRS_MetaData * meta; - - DEBUG_BEGIN(); - GE_LOG(ectx, - GE_STATUS | GE_USER | GE_BULK, - _("Download '%s' complete.\n"), - downloadContext->filename); - /* Not available for resumed downloads */ - if ( (downloadContext->rr != NULL) && - (gtk_tree_row_reference_valid(downloadContext->rr)) ) { - /* update directory view (if applicable!) */ - if (OK == disk_file_size(ectx, - downloadContext->filename, - &size, - YES)) { - GE_LOG(ectx, - GE_DEBUG, - "Updating directory view of '%s'\n", - downloadContext->filename); - - meta = NULL; - fd = disk_file_open(ectx, - downloadContext->filename, - O_RDONLY); - if (fd != -1) { - data = MMAP(NULL, - size, - PROT_READ, - MAP_SHARED, - fd, - 0); - if (data == MAP_FAILED) { - GE_LOG_STRERROR_FILE(ectx, - GE_ERROR | GE_ADMIN | GE_BULK, - "mmap", - downloadContext->filename); - } else { -#if 0 - if (data != NULL) { - ECRS_listDirectory(ectx, - data, - size, - &meta, - &addFilesToDirectory, - downloadContext->uri); - MUNMAP(data, size); - } -#endif - } - CLOSE(fd); - } - if (meta != NULL) - ECRS_freeMetaData(meta); - } - } - DEBUG_END(); -} - -void fs_download_stopped(struct DL * downloadContext) { - GtkTreeIter iter; - struct DL * d; - - DEBUG_BEGIN(); - if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(download_summary), - &iter)) { - do { - gtk_tree_model_get(GTK_TREE_MODEL(download_summary), - &iter, - DOWNLOAD_POS, &d, - -1); - if (d == downloadContext) { - gtk_tree_store_remove(download_summary, - &iter); - break; - } - } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(download_summary), - &iter)); - } - DEBUG_END(); - /* FIXME: free dl downloadContext! */ -} - -void on_clearCompletedDownloadsButton_clicked_fs(void * unused, - GtkWidget * clearButton) { - /* FIXME */ -} - -static void abortDownloadCallback(GtkTreeModel * model, - GtkTreePath * path, - GtkTreeIter * iter, - gpointer unused) { - struct DL * dl; - - GE_ASSERT(ectx, model == GTK_TREE_MODEL(download_summary)); - gtk_tree_model_get(model, - iter, - DOWNLOAD_POS, &dl, - -1); - FSUI_abortDownload(ctx, - dl->fsui_list); -} - -void on_abortDownloadButton_clicked_fs(void * unused, - GtkWidget * clearButton) { - GtkTreeSelection * selection; - GtkWidget * downloadList; - - DEBUG_BEGIN(); - downloadList = glade_xml_get_widget(getMainXML(), - "activeDownloadsList"); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(downloadList)); - gtk_tree_selection_selected_foreach - (selection, - &abortDownloadCallback, - NULL); - DEBUG_END(); -} - - - - - - - - - -/* *************** startup/shutdown ****************** */ - -/** - * Setup the summary views (in particular the models - * and the renderers). - */ -void fs_search_start(struct GE_Context * e, - struct GC_Configuration * c) { - GtkComboBoxEntry * searchCB; - GtkTreeView * searchList; - GtkTreeView * downloadList; - GtkListStore * model; - GtkCellRenderer * renderer; - GtkTreeViewColumn * column; - int col; - - ectx = e; - cfg = c; - searchCB - = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget(getMainXML(), - "fssearchKeywordComboBoxEntry")); - - model = gtk_list_store_new(NS_SEARCH_NUM, - G_TYPE_STRING, /* what we show */ - G_TYPE_STRING, /* EncName of namespace */ - G_TYPE_POINTER, /* ECRS MetaData */ - G_TYPE_POINTER, /* FSUI search list */ - G_TYPE_INT); /* Meta-data about namespace */ - gtk_combo_box_set_model(GTK_COMBO_BOX(searchCB), - GTK_TREE_MODEL(model)); - gtk_combo_box_entry_set_text_column(searchCB, - NS_SEARCH_DESCRIPTION); - searchList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), - "activeSearchesSummary")); - search_summary = - gtk_list_store_new(SER_SUM_NUM, - G_TYPE_STRING, /* name */ - G_TYPE_INT, /* # results */ - G_TYPE_POINTER); /* internal: search list */ - gtk_tree_view_set_model(searchList, - GTK_TREE_MODEL(search_summary)); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(searchList), - GTK_SELECTION_MULTIPLE); - - renderer = gtk_cell_renderer_text_new(); - col = gtk_tree_view_insert_column_with_attributes(searchList, - -1, - _("Query"), - renderer, - "text", SERARCH_SUMMARY_NAME, - NULL); - column = gtk_tree_view_get_column(searchList, - col - 1); - gtk_tree_view_column_set_resizable(column, TRUE); - gtk_tree_view_column_set_clickable(column, TRUE); - gtk_tree_view_column_set_reorderable(column, TRUE); - gtk_tree_view_column_set_sort_column_id(column, SER_SUM_NAME); - gtk_tree_view_column_set_resizable(column, TRUE); - renderer = gtk_cell_renderer_text_new(); - col = gtk_tree_view_insert_column_with_attributes(searchList, - -1, - _("Results"), - renderer, - "text", SERARCH_SUMMARY_RESULT_COUNT, - NULL); - column = gtk_tree_view_get_column(searchList, - col - 1); - gtk_tree_view_column_set_resizable(column, TRUE); - gtk_tree_view_column_set_clickable(column, TRUE); - gtk_tree_view_column_set_reorderable(column, TRUE); - gtk_tree_view_column_set_sort_column_id(column, SER_SUM_COUNT); - gtk_tree_view_column_set_resizable(column, TRUE); - - - downloadList = GTK_TREE_VIEW(glade_xml_get_widget(getMainXML(), - "activeDownloadsList")); - download_summary = - gtk_tree_store_new(DOWNLOAD_NUM, - G_TYPE_STRING, /* name (full-path file name) */ - G_TYPE_STRING, /* name (user-friendly name) */ - G_TYPE_UINT64, /* size */ - G_TYPE_STRING, /* human readable size */ - G_TYPE_INT, /* progress */ - G_TYPE_STRING, /* uri as string */ - G_TYPE_POINTER); /* internal download list ptr */ - gtk_tree_view_set_model(downloadList, - GTK_TREE_MODEL(download_summary)); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(downloadList), - GTK_SELECTION_MULTIPLE); - renderer = gtk_cell_renderer_progress_new(); - col = gtk_tree_view_insert_column_with_attributes(downloadList, - -1, - _("Name"), - renderer, - "value", DOWNLOAD_PROGRESS, - "text", DOWNLOAD_SHORTNAME, - NULL); - column = gtk_tree_view_get_column(downloadList, - col - 1); - gtk_tree_view_column_set_resizable(column, TRUE); - gtk_tree_view_column_set_clickable(column, TRUE); - gtk_tree_view_column_set_reorderable(column, TRUE); - gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_PROGRESS); - /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ - gtk_tree_view_column_set_resizable(column, TRUE); - renderer = gtk_cell_renderer_text_new(); - g_object_set (renderer, "xalign", 1.00, NULL); - col = gtk_tree_view_insert_column_with_attributes(downloadList, - -1, - _("Size"), - renderer, - "text", DOWNLOAD_HSIZE, - NULL); - - column = gtk_tree_view_get_column(downloadList, - col - 1); - gtk_tree_view_column_set_resizable(column, TRUE); - gtk_tree_view_column_set_clickable(column, TRUE); - gtk_tree_view_column_set_reorderable(column, TRUE); - gtk_tree_view_column_set_sort_column_id(column, DOWNLOAD_SIZE); - /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ - gtk_tree_view_column_set_resizable(column, TRUE); - renderer = gtk_cell_renderer_text_new(); - col = gtk_tree_view_insert_column_with_attributes(downloadList, - -1, - _("URI"), - renderer, - "text", DOWNLOAD_URISTRING, - NULL); - column = gtk_tree_view_get_column(downloadList, - col - 1); - gtk_tree_view_column_set_resizable(column, TRUE); - gtk_tree_view_column_set_reorderable(column, TRUE); - /*gtk_tree_view_column_set_sort_indicator(column, TRUE);*/ - gtk_tree_view_column_set_resizable(column, TRUE); -} - -/** - * Shutdown. - */ -void fs_search_stop() { - GtkComboBox * searchCB; - GtkListStore * model; - - searchCB - = GTK_COMBO_BOX(glade_xml_get_widget(getMainXML(), - "fssearchKeywordComboBoxEntry")); - model = gtk_combo_box_get_model(searchCB); - /* FIXME: iterate over model entries - and free URIs and MetaData! */ -} - - /* end of search.c */ diff --git a/src/plugins/fs/search.h b/src/plugins/fs/search.h index c161fb35..5b72aafd 100644 --- a/src/plugins/fs/search.h +++ b/src/plugins/fs/search.h @@ -29,33 +29,17 @@ #include #include +#include "fs.h" -struct SL; - -struct DL; - -struct DL * -fs_download_started(struct FSUI_DownloadList * fsui_dl, - struct DL * dl_parent, - struct SL * sl_parent, - unsigned long long total, - unsigned int anonymityLevel, - const ECRS_FileInfo * fi, - const char * filename, - unsigned long long completed, - cron_t eta); - -void fs_download_update(struct DL * downloadContext, - unsigned long long completed, - const char * data, - unsigned int size); - -void fs_download_completed(struct DL * downloadContext); - -void fs_download_aborted(struct DL * downloadContext); - -void fs_download_stopped(struct DL * downloadContext); +/** + * Add the given search result to the search + * tree at the specified position. + */ +void addEntryToSearchTree(SearchList * searchContext, + DownloadList * downloadParent, + const ECRS_FileInfo * info, + GtkTreeIter * iter); /** * Add the given result to the model (search result @@ -65,7 +49,7 @@ void fs_download_stopped(struct DL * downloadContext); * @param path the tree path that selects where to add * the information, NULL for top-level */ -void fs_search_result_received(struct SL * searchContext, +void fs_search_result_received(SearchList * searchContext, const ECRS_FileInfo * info, const struct ECRS_URI * uri); @@ -74,7 +58,7 @@ void fs_search_result_received(struct SL * searchContext, * * @return internal search context */ -struct SL * +SearchList * fs_search_started(struct FSUI_SearchList * list, const struct ECRS_URI * uri, unsigned int anonymityLevel, @@ -84,28 +68,11 @@ fs_search_started(struct FSUI_SearchList * list, /** * A search process has been aborted. Update display. */ -void fs_search_aborted(struct SL * searchContext); +void fs_search_aborted(SearchList * searchContext); /** * A search process has stopped. Clean up. */ -void fs_search_stopped(struct SL * searchContext); - - -/** - * Initialize the search module. - */ -void fs_search_start(struct GE_Context * e, - struct GC_Configuration * c); - -/** - * Shutdown the search module. - */ -void fs_search_stop(void); - - -void on_closeSearchButton_clicked_fs(GtkWidget * searchPage, - GtkWidget * closeButton); - +void fs_search_stopped(SearchList * searchContext); #endif -- cgit v1.2.3