[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3554 - in GNUnet/src: applications/fs/fsui applications/fs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3554 - in GNUnet/src: applications/fs/fsui applications/fs/tools include |
Date: |
Wed, 25 Oct 2006 20:28:50 -0700 (PDT) |
Author: grothoff
Date: 2006-10-25 20:28:16 -0700 (Wed, 25 Oct 2006)
New Revision: 3554
Modified:
GNUnet/src/applications/fs/fsui/deserialize.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/downloadtest.c
GNUnet/src/applications/fs/fsui/fsui.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/fsui/fsuitest.c
GNUnet/src/applications/fs/fsui/searchtest.c
GNUnet/src/applications/fs/fsui/serialize.c
GNUnet/src/applications/fs/tools/gnunet-download.c
GNUnet/src/include/gnunet_fsui_lib.h
Log:
fsui api fix
Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c 2006-10-25 20:41:15 UTC
(rev 3553)
+++ GNUnet/src/applications/fs/fsui/deserialize.c 2006-10-26 03:28:16 UTC
(rev 3554)
@@ -181,14 +181,17 @@
* @return NULL on error AND on read of empty
* list (these two cannot be distinguished)
*/
-static FSUI_DownloadList * readDownloadList(struct GE_Context * ectx,
- int fd,
- FSUI_Context * ctx,
- FSUI_DownloadList * parent) {
+static FSUI_DownloadList *
+readDownloadList(struct GE_Context * ectx,
+ int fd,
+ FSUI_Context * ctx,
+ FSUI_DownloadList * parent) {
FSUI_DownloadList * ret;
+ FSUI_SearchList * pos;
unsigned int big;
int i;
int ok;
+ int soff;
GE_ASSERT(ectx, ctx != NULL);
if ( (OK != read_int(fd, (int*) &big)) ||
@@ -200,6 +203,7 @@
sizeof(FSUI_DownloadList));
ret->ctx = ctx;
if ( (OK != read_int(fd, (int*) &ret->state)) ||
+ (OK != read_int(fd, (int*) &soff)) ||
(OK != read_int(fd, (int*) &ret->is_recursive)) ||
(OK != read_int(fd, (int*) &ret->is_directory)) ||
(OK != read_int(fd, (int*) &ret->anonymityLevel)) ||
@@ -251,6 +255,19 @@
return NULL;
}
ret->parent = parent;
+ if (soff == 0) {
+ ret->search = NULL;
+ } else {
+ pos = ctx->activeSearches;
+ while (--soff > 0)
+ pos = pos->next;
+ ret->search = pos;
+ GROW(pos->my_downloads,
+ pos->my_downloads_size,
+ pos->my_downloads_size + 1);
+ pos->my_downloads[pos->my_downloads_size -1] = ret;
+
+ }
ret->next = readDownloadList(ectx,
fd,
ctx,
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2006-10-25 20:41:15 UTC (rev
3553)
+++ GNUnet/src/applications/fs/fsui/download.c 2006-10-26 03:28:16 UTC (rev
3554)
@@ -43,6 +43,7 @@
const struct ECRS_URI * uri,
const struct ECRS_MetaData * meta,
const char * filename,
+ struct FSUI_SearchList * psearch,
FSUI_DownloadList * parent);
static int triggerRecursiveDownload(const ECRS_FileInfo * fi,
@@ -114,6 +115,7 @@
fi->uri,
fi->meta,
fullName,
+ NULL,
parent);
FREE(fullName);
return OK;
@@ -144,6 +146,8 @@
event.data.DownloadProgress.dc.cctx = dl->cctx;
event.data.DownloadProgress.dc.ppos = dl->parent;
event.data.DownloadProgress.dc.pcctx = dl->parent->cctx;
+ event.data.DownloadProgress.dc.spos = dl->search;
+ event.data.DownloadProgress.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
event.data.DownloadProgress.completed = dl->completed;
event.data.DownloadProgress.total = dl->total;
event.data.DownloadProgress.last_offset = lastBlockOffset;
@@ -239,6 +243,8 @@
event.data.DownloadCompleted.dc.cctx = dl->cctx;
event.data.DownloadCompleted.dc.ppos = dl->parent;
event.data.DownloadCompleted.dc.pcctx = dl->parent->cctx;
+ event.data.DownloadCompleted.dc.spos = dl->search;
+ event.data.DownloadCompleted.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
event.data.DownloadCompleted.total = dl->total;
event.data.DownloadCompleted.filename = dl->filename;
event.data.DownloadCompleted.uri = dl->fi.uri;
@@ -252,6 +258,8 @@
event.data.DownloadError.dc.cctx = dl->cctx;
event.data.DownloadError.dc.ppos = dl->parent;
event.data.DownloadError.dc.pcctx = dl->parent->cctx;
+ event.data.DownloadError.dc.spos = dl->search;
+ event.data.DownloadError.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
event.data.DownloadError.message = _("ECRS download failed (see logs)");
dl->ctx->ecb(dl->ctx->ecbClosure,
&event);
@@ -261,6 +269,8 @@
event.data.DownloadAborted.dc.cctx = dl->cctx;
event.data.DownloadAborted.dc.ppos = dl->parent;
event.data.DownloadAborted.dc.pcctx = dl->parent->cctx;
+ event.data.DownloadAborted.dc.spos = dl->search;
+ event.data.DownloadAborted.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
dl->ctx->ecb(dl->ctx->ecbClosure,
&event);
} else {
@@ -344,6 +354,7 @@
const struct ECRS_URI * uri,
const struct ECRS_MetaData * meta,
const char * filename,
+ struct FSUI_SearchList * psearch,
FSUI_DownloadList * parent) {
FSUI_DownloadList * dl;
FSUI_Event event;
@@ -364,6 +375,7 @@
dl->state = FSUI_PENDING;
dl->is_recursive = is_recursive;
dl->parent = parent;
+ dl->search = psearch;
dl->is_directory = SYSERR; /* don't know */
dl->anonymityLevel = anonymityLevel;
dl->ctx = ctx;
@@ -379,15 +391,23 @@
event.data.DownloadStarted.dc.cctx = NULL;
event.data.DownloadStarted.dc.ppos = dl->parent;
event.data.DownloadStarted.dc.pcctx = dl->parent->cctx;
+ event.data.DownloadStarted.dc.spos = dl->search;
+ event.data.DownloadStarted.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
event.data.DownloadStarted.total = ECRS_fileSize(dl->fi.uri);
event.data.DownloadStarted.filename = dl->filename;
- event.data.DownloadStarted.uri = dl->fi.uri;
- event.data.DownloadStarted.meta = dl->fi.meta;
+ event.data.DownloadStarted.fi.uri = dl->fi.uri;
+ event.data.DownloadStarted.fi.meta = dl->fi.meta;
event.data.DownloadStarted.anonymityLevel = dl->anonymityLevel;
dl->cctx = dl->ctx->ecb(dl->ctx->ecbClosure,
&event);
dl->next = parent->child;
parent->child = dl;
+ if (psearch != NULL) {
+ GROW(psearch->my_downloads,
+ psearch->my_downloads_size,
+ psearch->my_downloads_size + 1);
+ psearch->my_downloads[psearch->my_downloads_size -1] = dl;
+ }
return dl;
}
@@ -404,17 +424,22 @@
int doRecursive,
const struct ECRS_URI * uri,
const struct ECRS_MetaData * meta,
- const char * filename) {
+ const char * filename,
+ struct FSUI_SearchList * psearch,
+ struct FSUI_DownloadList * pdownload) {
struct FSUI_DownloadList * ret;
MUTEX_LOCK(ctx->lock);
+ if (pdownload == NULL)
+ pdownload = &ctx->activeDownloads;
ret = startDownload(ctx,
anonymityLevel,
doRecursive,
uri,
meta,
filename,
- &ctx->activeDownloads);
+ psearch,
+ pdownload);
MUTEX_UNLOCK(ctx->lock);
return ret;
}
@@ -591,8 +616,21 @@
event.data.DownloadStopped.dc.cctx = dl->cctx;
event.data.DownloadStopped.dc.ppos = dl->parent;
event.data.DownloadStopped.dc.pcctx = dl->parent->cctx;
+ event.data.DownloadStopped.dc.spos = dl->search;
+ event.data.DownloadStopped.dc.sctx = dl->search == NULL ? NULL :
dl->search->cctx;
ctx->ecb(ctx->ecbClosure,
&event);
+ if (dl->search != NULL) {
+ for (i=0;i<dl->search->my_downloads_size;i++) {
+ if (dl->search->my_downloads[i] == dl) {
+ dl->search->my_downloads[i] =
+ dl->search->my_downloads[dl->search->my_downloads_size -1];
+ GROW(dl->search->my_downloads,
+ dl->search->my_downloads_size,
+ dl->search->my_downloads_size - 1);
+ }
+ }
+ }
for (i=dl->completedDownloadsCount-1;i>=0;i--)
ECRS_freeUri(dl->completedDownloads[i]);
GROW(dl->completedDownloads,
Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c 2006-10-25 20:41:15 UTC
(rev 3553)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c 2006-10-26 03:28:16 UTC
(rev 3554)
@@ -115,7 +115,9 @@
NO,
event->data.SearchResult.fi.uri,
event->data.SearchResult.fi.meta,
- fn);
+ fn,
+ NULL,
+ NULL);
if (download == NULL) {
GE_BREAK(ectx, 0);
return NULL;
Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c 2006-10-25 20:41:15 UTC (rev
3553)
+++ GNUnet/src/applications/fs/fsui/fsui.c 2006-10-26 03:28:16 UTC (rev
3554)
@@ -72,6 +72,8 @@
event.data.DownloadResumed.dc.cctx = ret->cctx;
event.data.DownloadResumed.dc.ppos = ret->parent;
event.data.DownloadResumed.dc.pcctx = ret->parent->cctx;
+ event.data.DownloadResumed.dc.spos = ret->search;
+ event.data.DownloadResumed.dc.sctx = ret->search == NULL ? NULL :
ret->search->cctx;
event.data.DownloadResumed.completed = ret->completed;
event.data.DownloadResumed.total = ret->total;
now = get_time();
@@ -86,7 +88,8 @@
}
event.data.DownloadResumed.eta = eta;
event.data.DownloadResumed.filename = ret->filename;
- event.data.DownloadResumed.uri = ret->fi.uri;
+ event.data.DownloadResumed.fi.uri = ret->fi.uri;
+ event.data.DownloadResumed.fi.meta = ret->fi.meta;
event.data.DownloadResumed.anonymityLevel = ret->anonymityLevel;
ret->cctx = ctx->ecb(ctx->ecbClosure, &event);
if (ret->child != NULL)
@@ -333,6 +336,8 @@
event.data.DownloadSuspended.dc.cctx = list->cctx;
event.data.DownloadSuspended.dc.ppos = list->parent;
event.data.DownloadSuspended.dc.pcctx = list->parent->cctx;
+ event.data.DownloadSuspended.dc.spos = list->search;
+ event.data.DownloadSuspended.dc.sctx = list->search == NULL ? NULL :
list->search->cctx;
ctx->ecb(ctx->ecbClosure, &event);
}
list = list->next;
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2006-10-25 20:41:15 UTC (rev
3553)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2006-10-26 03:28:16 UTC (rev
3554)
@@ -147,6 +147,11 @@
struct ECRS_URI * uri;
/**
+ * What downloads belong to this search?
+ */
+ struct FSUI_DownloadList ** my_downloads;
+
+ /**
* List of all results found so far.
*/
ECRS_FileInfo * resultsReceived;
@@ -177,6 +182,11 @@
unsigned int sizeResultsReceived;
/**
+ * Number of downloads associated with this search.
+ */
+ unsigned int my_downloads_size;
+
+ /**
* Size of the queue of results that matched at least
* one of the queries in the boolean query, but not
* yet all of them.
@@ -233,6 +243,11 @@
struct FSUI_DownloadList * child;
/**
+ * Search that this download belongs to (maybe NULL)
+ */
+ struct FSUI_SearchList * search;
+
+ /**
* FSUI context for this download.
*/
struct FSUI_Context * ctx;
Modified: GNUnet/src/applications/fs/fsui/fsuitest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest.c 2006-10-25 20:41:15 UTC (rev
3553)
+++ GNUnet/src/applications/fs/fsui/fsuitest.c 2006-10-26 03:28:16 UTC (rev
3554)
@@ -80,7 +80,9 @@
NO,
event->data.SearchResult.fi.uri,
event->data.SearchResult.fi.meta,
- fn);
+ fn,
+ NULL,
+ NULL);
FREE(fn);
break;
case FSUI_upload_completed:
Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c 2006-10-25 20:41:15 UTC
(rev 3553)
+++ GNUnet/src/applications/fs/fsui/searchtest.c 2006-10-26 03:28:16 UTC
(rev 3554)
@@ -230,7 +230,9 @@
NO,
uri,
meta,
- fn);
+ fn,
+ NULL,
+ NULL);
ECRS_freeMetaData(meta);
FREE(fn);
fn = NULL;
Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2006-10-25 20:41:15 UTC (rev
3553)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2006-10-26 03:28:16 UTC (rev
3554)
@@ -103,6 +103,7 @@
FSUI_Context * ctx,
FSUI_DownloadList * list) {
int i;
+ FSUI_SearchList * pos;
if (list == NULL) {
WRITEINT(fd, 0);
@@ -117,6 +118,22 @@
list->total);
#endif
WRITEINT(fd, 1);
+ if (list->search == NULL) {
+ WRITEINT(fd, 0);
+ } else {
+ i = 1;
+ pos = ctx->activeSearches;
+ while (pos != list->search) {
+ i++;
+ pos = pos->next;
+ if (pos == NULL) {
+ GE_BREAK(ectx, 0);
+ i = 0;
+ break;
+ }
+ }
+ WRITEINT(fd, i);
+ }
WRITEINT(fd, list->state);
WRITEINT(fd, list->is_recursive);
WRITEINT(fd, list->is_directory);
@@ -125,6 +142,7 @@
WRITELONG(fd, list->total);
WRITELONG(fd, list->completed);
WRITELONG(fd, get_time() - list->startTime);
+
WRITESTRING(fd, list->filename);
writeFileInfo(ectx,
fd,
Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c 2006-10-25 20:41:15 UTC
(rev 3553)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c 2006-10-26 03:28:16 UTC
(rev 3554)
@@ -213,7 +213,9 @@
do_recursive,
uri,
meta,
- filename);
+ filename,
+ NULL,
+ NULL);
ECRS_freeMetaData(meta);
if (dl == NULL) {
FSUI_stop(ctx);
Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h 2006-10-25 20:41:15 UTC (rev
3553)
+++ GNUnet/src/include/gnunet_fsui_lib.h 2006-10-26 03:28:16 UTC (rev
3554)
@@ -183,6 +183,18 @@
void * pcctx;
+ /**
+ * If this download is associated with a search,
+ * what is the search?
+ */
+ struct FSUI_SearchList * spos;
+
+ /**
+ * If this download is associated with a search,
+ * what is the client context for the search?
+ */
+ void * sctx;
+
} FSUI_DownloadContext;
typedef struct {
@@ -426,13 +438,8 @@
/**
* Original URI.
*/
- const struct ECRS_URI * uri;
+ ECRS_FileInfo fi;
- /**
- * Metadata about the download.
- */
- const struct ECRS_MetaData * meta;
-
unsigned int anonymityLevel;
} DownloadStarted;
@@ -462,16 +469,8 @@
*/
const char * filename;
- /**
- * Metadata about the download.
- */
- const struct ECRS_MetaData * meta;
+ ECRS_FileInfo fi;
- /**
- * Original URI.
- */
- const struct ECRS_URI * uri;
-
unsigned int anonymityLevel;
} DownloadResumed;
@@ -791,7 +790,9 @@
int doRecursive,
const struct ECRS_URI * uri,
const struct ECRS_MetaData * meta,
- const char * filename); /* download.c */
+ const char * filename,
+ struct FSUI_SearchList * parentSearch,
+ struct FSUI_DownloadList * parentDownload); /* download.c */
/**
* Abort a download. If the dl is for a recursive
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3554 - in GNUnet/src: applications/fs/fsui applications/fs/tools include,
grothoff <=