gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3552 - gnunet-gtk/src/plugins/fs


From: grothoff
Subject: [GNUnet-SVN] r3552 - gnunet-gtk/src/plugins/fs
Date: Tue, 24 Oct 2006 16:12:23 -0700 (PDT)

Author: grothoff
Date: 2006-10-24 16:12:20 -0700 (Tue, 24 Oct 2006)
New Revision: 3552

Removed:
   gnunet-gtk/src/plugins/fs/download.c
   gnunet-gtk/src/plugins/fs/download.h
Log:
ref

Deleted: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c        2006-10-24 23:12:03 UTC (rev 
3551)
+++ gnunet-gtk/src/plugins/fs/download.c        2006-10-24 23:12:20 UTC (rev 
3552)
@@ -1,858 +0,0 @@
-/*
-     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 "platform.h"
-#include "gnunetgtk_common.h"
-#include "download.h"
-#include "search.h"
-#include "fs.h"
-#include <extractor.h>
-
-typedef struct DL {
-  struct DL * next;
-  struct ECRS_URI * uri;
-  char * filename;
-  char * finalName;
-  GtkTreeRowReference * rr;
-  GtkTreeModel * model;
-} DownloadList;
-
-static DownloadList * head;
-
-static GtkTreeStore * summary;
-
-static struct GE_Context * ectx;
-
-static struct GC_Configuration * cfg;
-
-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 = 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;
-}
-
-typedef struct {
-  struct ECRS_URI * uri;
-  struct ECRS_MetaData * meta;
-  const char * name;
-  const char * mime;
-  char * final_download_destination;
-  unsigned int anon;
-  struct FSUI_SearchList * ret;
-} InitiateDownloadCls;
-
-static void * startSearch(void * cls) {
-  InitiateDownloadCls * idc = cls;
-
-  idc->ret = FSUI_startSearch(ctx,
-                             idc->anon,
-                             1000, /* FIXME: max results */
-                             99 * cronYEARS, /* fixme: timeout */
-                             idc->uri);
-  return NULL;
-}
-
-static void * startDownload(void * cls) {
-  InitiateDownloadCls * idc = cls;
-
-  FSUI_startDownload(ctx,
-                    idc->anon,
-                    NO, /* FIXME: isRecursive */
-                    idc->uri,
-                    idc->final_download_destination);
-  return NULL;
-}
-
-static void initiateDownload(GtkTreeModel * model,
-                             GtkTreePath * path,
-                             GtkTreeIter * iter,
-                             gpointer unused) {
-  char * uri_name;
-  char * final_download_dir;
-  DownloadList * list;
-  GtkTreeIter iiter;
-  GtkWidget * spin;
-  const char * oname;
-  const char * cname;
-  char * dname;
-  GtkTreePath *dirTreePath;
-  char *dirPath;
-  unsigned int dirPathLen;
-  char * size_h;
-  unsigned long long size;
-  InitiateDownloadCls idc;
-#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,
-                     -1);
-  if (idc.uri == NULL) {
-    GE_BREAK(ectx, 0);
-    return;
-  }
-
-  spin = getAnonymityButtonFromTM(model);
-  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 */
-      run_with_save_calls(&startSearch,
-                         &idc);
-      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);
-    
-  /* setup visualization */
-  list = MALLOC(sizeof(DownloadList));
-  list->next = head;
-  list->rr = NULL;
-  list->model = NULL;
-  if (YES == ECRS_isDirectory(idc.meta)) {
-    list->rr = gtk_tree_row_reference_new(model, path);
-    list->model = model;
-  }
-  list->uri = ECRS_dupUri(idc.uri);
-  list->filename = idc.final_download_destination;
-  list->finalName = MALLOC(strlen(final_download_dir) + strlen(dirPath) + 
strlen(idc.name) + 2);  
-  strcpy(list->finalName, final_download_dir);
-  if (final_download_dir[strlen(final_download_dir)-1] != DIR_SEPARATOR)
-    strcat(list->finalName, DIR_SEPARATOR_STR);
-  strcat(list->finalName, dirPath);
-  disk_directory_create(ectx, list->finalName);
-  strcat(list->finalName, idc.name);
-  head = list;
-  size = ECRS_fileSize(idc.uri);
-  size_h = string_get_fancy_byte_size(size);
-  gtk_tree_store_insert(summary,
-                        &iiter,
-                        NULL,
-                        0);
-  gtk_tree_store_set(summary,
-                     &iiter,
-                     DOWNLOAD_FILENAME, idc.final_download_destination,
-                     DOWNLOAD_SHORTNAME, idc.name,
-                     DOWNLOAD_SIZE, size,
-                    DOWNLOAD_HSIZE, size_h,
-                     DOWNLOAD_PROGRESS, 0, /* progress */
-                     DOWNLOAD_URISTRING, uri_name,
-                     DOWNLOAD_URI, ECRS_dupUri(idc.uri),
-                     DOWNLOAD_TREEPATH, list->rr, /* internal: row reference! 
*/
-                     DOWNLOAD_DIRPATH, dirPath,                     
-                     -1);
-  FREE(size_h);
-  FREE(uri_name);
-  FREE(dirPath);
-  FREENONNULL(final_download_dir);
-
-  addLogEntry(_("Downloading `%s'"), idc.name);
-  run_with_save_calls(&startDownload,
-                     &idc);
-#ifdef WINDOWS
-  FREENONNULL(filehash);
-#endif
-
-  DEBUG_END();
-}
-
-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) {
-  InitiateDownloadCls idc;
-  const char * uris;
-  char * urid;
-  GtkWidget * spin;
-  char * final_download_dir;
-  const char * dname;
-  DownloadList * list;
-  GtkTreeIter iiter;
-  char * size_h;
- 
-  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);
-
-  /* setup visualization */
-  list = MALLOC(sizeof(DownloadList));
-  list->next = head;
-  list->rr = NULL;
-  list->model = NULL;
-  list->uri = idc.uri;
-  list->filename = idc.final_download_destination;
-  list->finalName = STRDUP(idc.final_download_destination);
-  head = list;
-  size_h = string_get_fancy_byte_size(ECRS_fileSize(idc.uri));
-  gtk_tree_store_insert(summary,
-                        &iiter,
-                        NULL,
-                        0);
-  gtk_tree_store_set(summary,
-                     &iiter,
-                     DOWNLOAD_FILENAME, idc.final_download_destination,
-                     DOWNLOAD_SHORTNAME, uris,
-                     DOWNLOAD_SIZE, ECRS_fileSize(idc.uri),
-                     DOWNLOAD_HSIZE, size_h,
-                     DOWNLOAD_PROGRESS, 0, /* progress */
-                     DOWNLOAD_URISTRING, uris,
-                     DOWNLOAD_URI, ECRS_dupUri(idc.uri),
-                     DOWNLOAD_TREEPATH, NULL, /* internal: row reference! */
-                     DOWNLOAD_DIRPATH, "",                     
-                     -1);
-  FREE(size_h);
-  /* 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);
-  run_with_save_calls(&startDownload,
-                     &idc);
-  FREE(urid);
-}
-
-
-/**
- */
-void displayDownloadUpdate(const struct ECRS_URI * uri,
-                           unsigned long long completed,
-                           const char * data,
-                           unsigned int size) {
-  GtkTreeIter iter;
-  unsigned int val;
-  unsigned long long total;
-  struct ECRS_URI * u;
-  struct ECRS_MetaData * meta;
-
-  DEBUG_BEGIN();
-  if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary),
-                                    &iter)) {
-    do {
-      gtk_tree_model_get(GTK_TREE_MODEL(summary),
-                         &iter,
-                         DOWNLOAD_SIZE, &total,
-                         DOWNLOAD_URI, &u,
-                         -1);
-      if (u == NULL)
-        return;
-      if (ECRS_equalsUri(u, uri)) {
-        if (total != 0)
-          val = completed * 100 / total;
-        else
-          val = 100;
-        gtk_tree_store_set(summary,
-                           &iter,
-                           DOWNLOAD_PROGRESS, val,
-                           -1);
-        break;
-      }
-    } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
-                                      &iter));
-  }
-  meta = NULL;
-  ECRS_listDirectory(ectx,
-                    data,
-                     size,
-                     &meta,
-                     &addFilesToDirectory,
-                     (void*)uri);
-  if (meta != NULL)
-    ECRS_freeMetaData(meta);
-  DEBUG_END();
-}
-
-/**
- */
-void displayDownloadComplete(const struct ECRS_URI * uri,
-                             const char * filename) {
-  unsigned long long size;
-  char * data;
-  int fd;
-  struct ECRS_MetaData * meta;
-  DownloadList * pos;
-
-  DEBUG_BEGIN();
-  GE_LOG(ectx,
-        GE_STATUS | GE_USER | GE_BULK,
-        _("Download '%s' complete.\n"),
-        filename);
-  pos = head;
-  while (pos != NULL) {
-    if (ECRS_equalsUri(uri,
-                       pos->uri))
-      break;
-    pos = pos->next;
-  }
-  
-  /* Not available for resumed downloads */
-  if (pos != NULL) {
-    if ( (pos->rr != NULL) &&
-         (gtk_tree_row_reference_valid(pos->rr)) ) { 
-      /* update directory view (if applicable!) */
-      if (OK == disk_file_size(ectx,
-                              filename,
-                              &size,
-                              YES)) {
-       GE_LOG(ectx,
-              GE_DEBUG,
-              "Updating directory view of '%s'\n",
-              filename);
-
-       meta = NULL;
-       fd = disk_file_open(ectx,
-                           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",
-                                filename);
-         } else {
-           if (data != NULL) {
-             ECRS_listDirectory(ectx,
-                                data,
-                                size,
-                                &meta,
-                                &addFilesToDirectory,
-                                (void*)uri);
-             MUNMAP(data, size);
-           }
-         }
-         CLOSE(fd);
-       }
-       if (meta != NULL)
-         ECRS_freeMetaData(meta);      
-      }
-    }
-  }
-  DEBUG_END();
-}
-
-static int delDownloadView(void * cls,
-                           const struct FSUI_DownloadList * pos,
-                           const char * filename,
-                           const struct ECRS_URI * uri,
-                           unsigned long long filesize,
-                           unsigned long long bytesCompleted,
-                           int isRecursive,
-                           unsigned int anonymityLevel) {
-  GtkTreeIter iter;
-  char * f;
-  char * fn;
-  struct ECRS_URI * u;
-
-  DEBUG_BEGIN();
-  if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary),
-                                    &iter)) {
-    do {
-      gtk_tree_model_get(GTK_TREE_MODEL(summary),
-                         &iter,
-                         DOWNLOAD_FILENAME, &f,
-                         DOWNLOAD_URI, &u,
-                         -1);
-                         
-      f = strrchr(f, DIR_SEPARATOR);
-      fn = strrchr(filename, DIR_SEPARATOR);
-                         
-      if ( (ECRS_equalsUri(u, uri)) &&
-           (0 == strcmp(f, fn)) ) {
-        gtk_tree_store_remove(summary,
-                              &iter);
-        break;
-      }
-    } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
-                                      &iter));
-  }
-  DEBUG_END();
-  return OK;
-}
-
-static void * clearCompletedDownloads(void * unused) {
-  /* FIXME */
-  return NULL;
-}
-
-void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
-                                                GtkWidget * clearButton) {
-  run_with_save_calls(&clearCompletedDownloads,
-                     NULL);
-}
-
-static void * shutdownCode(void * c) {
-  struct FSUI_DownloadList * pos = c;
-  FSUI_stopDownload(ctx,
-                   pos);
-  return NULL;
-}
-
-static void abortDownloadCallback(GtkTreeModel * model,
-                                  GtkTreePath * path,
-                                  GtkTreeIter * iter,
-                                  GtkTreeStore * tree) {
-  void * c;
-  struct ECRS_URI * u;
-
-  GE_ASSERT(ectx, model == GTK_TREE_MODEL(summary));
-  gtk_tree_model_get(model,
-                     iter,
-                     DOWNLOAD_POS, &c,
-                     DOWNLOAD_URI, &u,
-                     -1);
-  run_with_save_calls(&shutdownCode,
-                      c);
-  gtk_tree_store_remove(summary,
-                        iter);
-  if (u != NULL)
-    ECRS_freeUri(u);
-}
-
-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,
-     (GtkTreeSelectionForeachFunc) &abortDownloadCallback,
-     NULL);
-  DEBUG_END();
-}
-
-int addDownloadView(struct FSUI_DownloadList * pos,
-                   struct FSUI_DownloadList * ppos,
-                   const char * filename,
-                   const struct ECRS_URI * uri,
-                   unsigned long long filesize,
-                   unsigned long long bytesCompleted,
-                   int isRecursive,
-                   unsigned int anonymityLevel) {
-  GtkTreeIter iiter;
-  int progress;
-  char * uriname;
-  const char * sname;
-  char * size_h;
-
-  DEBUG_BEGIN();
-  if (filesize != 0)
-    progress = bytesCompleted * 100 / filesize;
-  else
-    progress = 100;
-  uriname = ECRS_uriToString(uri);
-  gtk_tree_store_insert(summary,
-                        &iiter,
-                        NULL,
-                        0);
-  sname = &filename[strlen(filename)-1];
-  while ( (sname > filename) &&
-         (sname[-1] != '/') &&
-         (sname[-1] != '\\') )
-    sname--;
-  size_h = string_get_fancy_byte_size(filesize);
-  gtk_tree_store_set(summary,
-                     &iiter,
-                     DOWNLOAD_FILENAME, filename,
-                     DOWNLOAD_SHORTNAME, sname,
-                     DOWNLOAD_SIZE, filesize,
-                     DOWNLOAD_HSIZE, size_h,
-                     DOWNLOAD_PROGRESS, progress,
-                     DOWNLOAD_URISTRING, uriname,
-                     DOWNLOAD_URI, ECRS_dupUri(uri),
-                     DOWNLOAD_TREEPATH, NULL,
-                     -1);
-  FREE(size_h);
-  FREE(uriname);
-  DEBUG_END();
-  return OK;
-}
-
-
-void fs_download_start(struct GE_Context * e,
-                      struct GC_Configuration * c) {
-  GtkWidget * downloadList;
-  GtkCellRenderer * renderer;
-  GtkTreeViewColumn * column;
-  int col;
-
-  ectx = e;
-  cfg = c;
-  DEBUG_BEGIN();
-  downloadList = glade_xml_get_widget(getMainXML(),
-                                      "activeDownloadsList");
-  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 */
-                       G_TYPE_POINTER,  /* url */
-                       G_TYPE_POINTER, /* internal: gtk tree path / NULL */
-                       G_TYPE_STRING); /* directory path if file is inside a 
dir */
-  gtk_tree_view_set_model(GTK_TREE_VIEW(downloadList),
-                          GTK_TREE_MODEL(summary));
-  renderer = gtk_cell_renderer_progress_new();
-  col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-                                              -1,
-                                              _("Name"),
-                                              renderer,
-                                              "value", DOWNLOAD_PROGRESS,
-                                              "text", DOWNLOAD_SHORTNAME,
-                                              NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(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(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
-                                              col - 1),
-                                              TRUE);
-  renderer = gtk_cell_renderer_text_new();
-  g_object_set (renderer, "xalign", 1.00, NULL);
-  col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-                                              -1,
-                                              _("Size"),
-                                              renderer,
-                                              "text", DOWNLOAD_HSIZE,
-                                              NULL);
-  
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(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(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
-                                              col - 1),
-                                              TRUE);
-  renderer = gtk_cell_renderer_text_new();
-  col = 
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-                                              -1,
-                                              _("URI"),
-                                              renderer,
-                                              "text", DOWNLOAD_URISTRING,
-                                              NULL);
-  column = gtk_tree_view_get_column(GTK_TREE_VIEW(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(gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
-                                              col - 1),
-                                              TRUE);
-  DEBUG_END();
-}
-
-
-void fs_download_stop() {
-  GtkTreeIter iter;
-  struct ECRS_URI * u;
-  DownloadList * pos;
-  char *dirPath;
-
-  DEBUG_BEGIN();
-  /* free URIs in summary model */
-  if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary),
-                                      &iter))
-    return;
-  do {
-    gtk_tree_model_get(GTK_TREE_MODEL(summary),
-                       &iter,
-                       DOWNLOAD_URI, &u,
-                       DOWNLOAD_DIRPATH, &dirPath,
-                       -1);
-    gtk_tree_store_set(summary,
-                       &iter,
-                       DOWNLOAD_URI, NULL,
-                       -1);
-    if (u != NULL)
-      ECRS_freeUri(u);
-    FREENONNULL(dirPath);
-  } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
-                                    &iter));
-  while (head != NULL) {
-    pos = head->next;
-    ECRS_freeUri(head->uri);
-    FREE(head->filename);
-    gtk_tree_row_reference_free(head->rr);
-    FREE(head);
-    head = pos;
-  }
-  DEBUG_END();
-}
-
-
-/* end of download.c */

Deleted: gnunet-gtk/src/plugins/fs/download.h
===================================================================
--- gnunet-gtk/src/plugins/fs/download.h        2006-10-24 23:12:03 UTC (rev 
3551)
+++ gnunet-gtk/src/plugins/fs/download.h        2006-10-24 23:12:20 UTC (rev 
3552)
@@ -1,32 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2005 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 downloading with gnunet-gtk
- * @author Christian Grothoff
- */
-
-#ifndef GTK_DOWNLOAD_H
-#define GTK_DOWNLOAD_H
-
-#include <GNUnet/gnunet_ecrs_lib.h>
-
-#endif





reply via email to

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