[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3577 - GNUnet/src/applications/fs/fsui GNUnet/src/include
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3577 - GNUnet/src/applications/fs/fsui GNUnet/src/include gnunet-gtk/src/plugins/fs |
Date: |
Sun, 29 Oct 2006 22:00:59 -0800 (PST) |
Author: grothoff
Date: 2006-10-29 22:00:52 -0800 (Sun, 29 Oct 2006)
New Revision: 3577
Modified:
GNUnet/src/applications/fs/fsui/deserialize.c
GNUnet/src/applications/fs/fsui/fsui.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/fsui/serialize.c
GNUnet/src/applications/fs/fsui/upload.c
GNUnet/src/include/gnunet_fsui_lib.h
gnunet-gtk/src/plugins/fs/download.c
gnunet-gtk/src/plugins/fs/download.h
gnunet-gtk/src/plugins/fs/fs.c
gnunet-gtk/src/plugins/fs/search.c
gnunet-gtk/src/plugins/fs/search.h
gnunet-gtk/src/plugins/fs/upload.c
gnunet-gtk/src/plugins/fs/upload.h
Log:
bugfixes
Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c 2006-10-30 04:20:28 UTC
(rev 3576)
+++ GNUnet/src/applications/fs/fsui/deserialize.c 2006-10-30 06:00:52 UTC
(rev 3577)
@@ -73,6 +73,7 @@
return NULL;
}
ret = ECRS_stringToUri(ectx, buf);
+ GE_BREAK(ectx, ret != NULL);
FREE(buf);
return ret;
}
@@ -213,6 +214,7 @@
(OK != read_long(fd, (long long*) &ret->runTime)) ||
(OK != read_int(fd, (int*) &big)) ||
(big > 1024 * 1024) ) {
+ GE_BREAK(NULL, 0);
FREE(ret);
return NULL;
}
@@ -228,6 +230,7 @@
if (OK != readFileInfo(ectx,
fd,
&ret->fi)) {
+ GE_BREAK(NULL, 0);
FREE(ret->filename);
FREE(ret);
return NULL;
@@ -239,8 +242,10 @@
ok = YES;
for (i=0;i<ret->completedDownloadsCount;i++) {
ret->completedDownloads[i] = read_uri(ectx, fd);
- if (ret->completedDownloads[i] == NULL)
+ if (ret->completedDownloads[i] == NULL) {
+ GE_BREAK(NULL, 0);
ok = NO;
+ }
}
if (NO == ok) {
FREE(ret->filename);
@@ -252,6 +257,7 @@
}
FREE(ret->completedDownloads);
FREE(ret);
+ GE_BREAK(NULL, 0);
return NULL;
}
ret->parent = parent;
@@ -502,18 +508,30 @@
static int readUploadList(struct FSUI_Context * ctx,
struct FSUI_UploadList * parent,
int fd,
- struct FSUI_UploadShared * shared) {
+ struct FSUI_UploadShared * shared,
+ int top) {
struct FSUI_UploadList * list;
struct FSUI_UploadList l;
unsigned long long stime;
int big;
+ int bag;
struct GE_Context * ectx;
-
+
ectx = ctx->ectx;
+ GE_ASSERT(ectx, shared != NULL);
while (1) {
READINT(big);
if (big == 0)
return OK;
+ if ( (big != 1) && (big != 2) ) {
+ GE_BREAK(NULL, 0);
+ return SYSERR;
+ }
+ READINT(bag);
+ if (bag != 0x34D1F023) {
+ GE_BREAK(NULL, 0);
+ return SYSERR;
+ }
memset(&l,
0,
sizeof(FSUI_UploadList));
@@ -540,12 +558,16 @@
break;
}
list = MALLOC(sizeof(struct FSUI_UploadList));
+ memcpy(list,
+ &l,
+ sizeof(struct FSUI_UploadList));
list->shared = shared;
- memcpy(list, &l, sizeof(struct FSUI_UploadList));
+ list->parent = parent;
if (OK != readUploadList(ctx,
list,
fd,
- shared)) {
+ shared,
+ NO)) {
if (l.uri != NULL)
ECRS_freeUri(l.uri);
FREE(l.filename);
@@ -555,6 +577,8 @@
}
list->next = parent->child;
parent->child = list;
+ if (top == YES)
+ return OK;
}
return SYSERR;
}
@@ -563,6 +587,7 @@
static int readUploads(int fd,
struct FSUI_Context * ctx) {
int big;
+ int bag;
struct FSUI_UploadShared * shared;
struct FSUI_UploadShared sshared;
@@ -577,6 +602,11 @@
GE_BREAK(NULL, 0);
break;
}
+ READINT(bag);
+ if (bag != 0x44D1F024) {
+ GE_BREAK(NULL, 0);
+ return SYSERR;
+ }
memset(&sshared,
0,
sizeof(FSUI_UploadShared));
@@ -587,14 +617,16 @@
READLONG(sshared.expiration);
if (big == 2)
READSTRING(sshared.extractor_config, 1024*1024);
- shared = MALLOC(sizeof(FSUI_UploadShared));
+ shared = MALLOC(sizeof(FSUI_UploadShared));
memcpy(shared,
&sshared,
sizeof(FSUI_UploadShared));
+ shared->ctx = ctx;
if (OK != readUploadList(ctx,
&ctx->activeUploads,
fd,
- shared)) {
+ shared,
+ YES)) {
GE_BREAK(NULL, 0);
#if 0
/* cannot do this, readUploadList
Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c 2006-10-30 04:20:28 UTC (rev
3576)
+++ GNUnet/src/applications/fs/fsui/fsui.c 2006-10-30 06:00:52 UTC (rev
3577)
@@ -66,36 +66,35 @@
cron_t eta;
while (ret != NULL) {
- if (ret->state == FSUI_PENDING) {
- event.type = FSUI_download_resumed;
- event.data.DownloadResumed.dc.pos = ret;
- 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();
- if ( (ret->total == 0) || (ret->completed == 0) ) {
+ event.type = FSUI_download_resumed;
+ event.data.DownloadResumed.dc.pos = ret;
+ 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;
+ event.data.DownloadResumed.state = ret->state;
+ now = get_time();
+ if ( (ret->total == 0) || (ret->completed == 0) ) {
+ eta = now;
+ } else {
+ eta = (cron_t) (now - ret->runTime +
+ (((double)(ret->runTime)/(double)ret->completed))
+ * (double)ret->total);
+ if (eta < now)
eta = now;
- } else {
- eta = (cron_t) (now - ret->runTime +
- (((double)(ret->runTime)/(double)ret->completed))
- * (double)ret->total);
- if (eta < now)
- eta = now;
- }
- event.data.DownloadResumed.eta = eta;
- event.data.DownloadResumed.filename = ret->filename;
- 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)
- signalDownloadResume(ret->child,
- ctx);
}
+ event.data.DownloadResumed.eta = eta;
+ event.data.DownloadResumed.filename = ret->filename;
+ 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)
+ signalDownloadResume(ret->child,
+ ctx);
ret = ret->next;
}
}
@@ -107,32 +106,31 @@
cron_t eta;
while (ret != NULL) {
- if (ret->state == FSUI_ACTIVE) {
- event.type = FSUI_upload_resumed;
- event.data.UploadResumed.uc.pos = ret;
- event.data.UploadResumed.uc.cctx = NULL;
- event.data.UploadResumed.uc.ppos = ret->parent;
- event.data.UploadResumed.uc.pcctx = ret->parent->cctx;
- event.data.UploadResumed.completed = ret->completed;
- event.data.UploadResumed.total = ret->total;
- now = get_time();
- if ( (ret->total == 0) || (ret->completed == 0) ) {
+ event.type = FSUI_upload_resumed;
+ event.data.UploadResumed.uc.pos = ret;
+ event.data.UploadResumed.uc.cctx = NULL;
+ event.data.UploadResumed.uc.ppos = ret->parent;
+ event.data.UploadResumed.uc.pcctx = ret->parent->cctx;
+ event.data.UploadResumed.completed = ret->completed;
+ event.data.UploadResumed.total = ret->total;
+ event.data.UploadResumed.state = ret->state;
+ now = get_time();
+ if ( (ret->total == 0) || (ret->completed == 0) ) {
+ eta = now;
+ } else {
+ eta = (cron_t) (ret->start_time +
+ (((double)(now - ret->start_time)/(double)ret->completed))
+ * (double)ret->total);
+ if (eta < now)
eta = now;
- } else {
- eta = (cron_t) (ret->start_time +
- (((double)(now -
ret->start_time)/(double)ret->completed))
- * (double)ret->total);
- if (eta < now)
- eta = now;
- }
- event.data.UploadResumed.eta = eta;
- event.data.UploadResumed.anonymityLevel = ret->shared->anonymityLevel;
- event.data.UploadResumed.filename = ret->filename;
- ret->cctx = ctx->ecb(ctx->ecbClosure, &event);
- if (ret->child != NULL)
- signalUploadResume(ret->child,
- ctx);
}
+ event.data.UploadResumed.eta = eta;
+ event.data.UploadResumed.anonymityLevel = ret->shared->anonymityLevel;
+ event.data.UploadResumed.filename = ret->filename;
+ ret->cctx = ctx->ecb(ctx->ecbClosure, &event);
+ if (ret->child != NULL)
+ signalUploadResume(ret->child,
+ ctx);
ret = ret->next;
}
}
@@ -240,16 +238,15 @@
/* 2b) signal search restarts */
list = ret->activeSearches;
while (list != NULL) {
- if (list->state == FSUI_PENDING) {
- event.type = FSUI_search_resumed;
- event.data.SearchResumed.sc.pos = list;
- event.data.SearchResumed.sc.cctx = NULL;
- event.data.SearchResumed.fis = list->resultsReceived;
- event.data.SearchResumed.fisSize = list->sizeResultsReceived;
- event.data.SearchResumed.anonymityLevel = list->anonymityLevel;
- event.data.SearchResumed.searchURI = list->uri;
- list->cctx = cb(closure, &event);
- }
+ event.type = FSUI_search_resumed;
+ event.data.SearchResumed.sc.pos = list;
+ event.data.SearchResumed.sc.cctx = NULL;
+ event.data.SearchResumed.fis = list->resultsReceived;
+ event.data.SearchResumed.fisSize = list->sizeResultsReceived;
+ event.data.SearchResumed.anonymityLevel = list->anonymityLevel;
+ event.data.SearchResumed.searchURI = list->uri;
+ event.data.SearchResumed.state = list->state;
+ list->cctx = cb(closure, &event);
list = list->next;
}
/* 2c) signal upload restarts */
@@ -258,16 +255,15 @@
/* 2d) signal unindex restarts */
xlist = ret->unindexOperations;
while (xlist != NULL) {
- if (xlist->state == FSUI_PENDING) {
- event.type = FSUI_unindex_resumed;
- event.data.UnindexResumed.uc.pos = xlist;
- event.data.UnindexResumed.uc.cctx = NULL;
- event.data.UnindexResumed.completed = 0; /* FIXME */
- event.data.UnindexResumed.total = 0; /* FIXME */
- event.data.UnindexResumed.eta = 0; /* FIXME: use start_time for
estimate! */
- event.data.UnindexResumed.filename = xlist->filename;
- xlist->cctx = cb(closure, &event);
- }
+ event.type = FSUI_unindex_resumed;
+ event.data.UnindexResumed.uc.pos = xlist;
+ event.data.UnindexResumed.uc.cctx = NULL;
+ event.data.UnindexResumed.completed = 0; /* FIXME */
+ event.data.UnindexResumed.total = 0; /* FIXME */
+ event.data.UnindexResumed.eta = 0; /* FIXME: use start_time for estimate!
*/
+ event.data.UnindexResumed.filename = xlist->filename;
+ event.data.UnindexResumed.state = xlist->state;
+ xlist->cctx = cb(closure, &event);
xlist = xlist->next;
}
@@ -327,19 +323,17 @@
FSUI_DownloadList * list) {
FSUI_Event event;
while (list != NULL) {
- if (list->state == FSUI_PENDING) {
- signalDownloadSuspend(ectx,
- ctx,
- list->child);
- event.type = FSUI_download_suspended;
- event.data.DownloadSuspended.dc.pos = list;
- 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);
- }
+ signalDownloadSuspend(ectx,
+ ctx,
+ list->child);
+ event.type = FSUI_download_suspended;
+ event.data.DownloadSuspended.dc.pos = list;
+ 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;
}
}
@@ -352,17 +346,15 @@
FSUI_UploadList * upos) {
FSUI_Event event;
while (upos != NULL) {
- if (upos->state == FSUI_PENDING) {
- signalUploadSuspend(ectx,
- ctx,
- upos->child);
- event.type = FSUI_upload_suspended;
- event.data.UploadSuspended.uc.pos = upos;
- event.data.UploadSuspended.uc.cctx = upos->cctx;
- event.data.UploadSuspended.uc.ppos = upos->parent;
- event.data.UploadSuspended.uc.pcctx = upos->parent->cctx;
- ctx->ecb(ctx->ecbClosure, &event);
- }
+ signalUploadSuspend(ectx,
+ ctx,
+ upos->child);
+ event.type = FSUI_upload_suspended;
+ event.data.UploadSuspended.uc.pos = upos;
+ event.data.UploadSuspended.uc.cctx = upos->cctx;
+ event.data.UploadSuspended.uc.ppos = upos->parent;
+ event.data.UploadSuspended.uc.pcctx = upos->parent->cctx;
+ ctx->ecb(ctx->ecbClosure, &event);
upos = upos->next;
}
}
@@ -402,7 +394,8 @@
freeUploadList(ctx, list->child);
next = list->next;
FREE(list->filename);
- ECRS_freeMetaData(list->meta);
+ if (list->meta != NULL)
+ ECRS_freeMetaData(list->meta);
if (list->keywords != NULL)
ECRS_freeUri(list->keywords);
if (list->uri != NULL)
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2006-10-30 04:20:28 UTC (rev
3576)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2006-10-30 06:00:52 UTC (rev
3577)
@@ -32,63 +32,6 @@
#include "gnunet_blockstore.h"
/**
- * Current state of a download (or uploads, or search,
- * or unindex operations).
- *
- * PENDING means that the download is waiting for a thread
- * to be assigned to run it. Downloads start in this state,
- * and during shutdown are serialized in this state.<br>
- *
- * ACTIVE means that there is currently a thread running
- * the download (and that thread is allowed to continue).<br>
- *
- * COMPLETED means that the download is finished (but the
- * thread has not been joined yet). The download thread
- * makes the transition from PENDING to COMPLETED when it
- * is about to terminate.<br>
- *
- * COMPLETED_JOINED means that the download is finished and
- * the thread has been joined.<br>
- *
- * ABORTED means that the user is causing the download to be
- * terminated early (but the thread has not been joined yet). The
- * controller or the download thread make this transition; the
- * download thread is supposed to terminate shortly after the state is
- * moved to ABORTED.<br>
- *
- * ABORTED_JOINED means that the download did not complete
- * successfully, should not be restarted and that the thread
- * has been joined.<br>
- *
- * ERROR means that some fatal error is causing the download to be
- * terminated early (but the thread has not been joined yet). The
- * controller or the download thread make this transition; the
- * download thread is supposed to terminate shortly after the state is
- * moved to ERROR.<br>
- *
- * ERROR_JOINED means that the download did not complete successfully,
- * should not be restarted and that the thread has been joined.<br>
- *
- * SUSPENDING is used to notify the download thread that it
- * should terminate because of an FSUI shutdown. After this
- * termination the code that joins the thread should move
- * the state into PENDING (a new thread would not be started
- * immediately because "threadPoolSize" will be 0 until FSUI
- * resumes).
- */
-typedef enum {
- FSUI_PENDING = 0,
- FSUI_ACTIVE = 1,
- FSUI_COMPLETED = 2,
- FSUI_COMPLETED_JOINED = 3,
- FSUI_ABORTED = 4,
- FSUI_ABORTED_JOINED = 5,
- FSUI_ERROR = 6,
- FSUI_ERROR_JOINED = 7,
- FSUI_SUSPENDING = 8,
-} FSUI_State;
-
-/**
* Track record for a given result.
*/
typedef struct {
Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2006-10-30 04:20:28 UTC (rev
3576)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2006-10-30 06:00:52 UTC (rev
3577)
@@ -240,26 +240,13 @@
WRITEINT(fd, 0);
}
-static void writeUploads(int fd,
- struct FSUI_Context * ctx,
- struct FSUI_UploadList * upos) {
- struct FSUI_UploadShared * shared;
-
+static void writeUploadList(int fd,
+ struct FSUI_Context * ctx,
+ struct FSUI_UploadList * upos,
+ int top) {
while (upos != NULL) {
- if (upos->parent == &ctx->activeUploads) {
- shared = upos->shared;
- WRITEINT(fd, (shared->extractor_config != NULL) ? 2 : 3);
- WRITEINT(fd, shared->doIndex);
- WRITEINT(fd, shared->anonymityLevel);
- WRITEINT(fd, shared->priority);
- WRITEINT(fd, shared->individualKeywords);
- WRITELONG(fd, shared->expiration);
- if (shared->extractor_config != NULL)
- WRITESTRING(fd, shared->extractor_config);
- } else {
- WRITEINT(fd, 1);
- WRITEINT(fd, (upos->uri != NULL) ? 1 : 2);
- }
+ WRITEINT(fd, (upos->uri != NULL) ? 1 : 2);
+ WRITEINT(fd, 0x34D1F023);
WRITEINT(fd, upos->state);
WRITELONG(fd, upos->completed);
WRITELONG(fd, upos->total);
@@ -268,12 +255,40 @@
if (upos->uri != NULL)
writeURI(fd, upos->uri);
WRITESTRING(fd, upos->filename);
- writeUploads(fd, ctx, upos->child);
+ writeUploadList(fd, ctx, upos->child, NO);
+ if (top == YES)
+ break;
upos = upos->next;
}
WRITEINT(fd, 0);
}
+static void writeUploads(int fd,
+ struct FSUI_Context * ctx,
+ struct FSUI_UploadList * upos) {
+ struct FSUI_UploadShared * shared;
+
+ while (upos != NULL) {
+ shared = upos->shared;
+ WRITEINT(fd, (shared->extractor_config != NULL) ? 2 : 3);
+ WRITEINT(fd, 0x44D1F024);
+ WRITEINT(fd, shared->doIndex);
+ WRITEINT(fd, shared->anonymityLevel);
+ WRITEINT(fd, shared->priority);
+ WRITEINT(fd, shared->individualKeywords);
+ WRITELONG(fd, shared->expiration);
+ if (shared->extractor_config != NULL)
+ WRITESTRING(fd,
+ shared->extractor_config);
+ writeUploadList(fd,
+ ctx,
+ upos,
+ YES);
+ upos = upos->next;
+ }
+ WRITEINT(fd, 0);
+}
+
void FSUI_serialize(struct FSUI_Context * ctx) {
int fd;
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2006-10-30 04:20:28 UTC (rev
3576)
+++ GNUnet/src/applications/fs/fsui/upload.c 2006-10-30 06:00:52 UTC (rev
3577)
@@ -350,7 +350,8 @@
ECRS_freeUri(ul->keywords);
if (ul->uri != NULL)
ECRS_freeUri(ul->uri);
- ECRS_freeMetaData(ul->meta);
+ if (ul->meta != NULL)
+ ECRS_freeMetaData(ul->meta);
/* unlink from parent */
next = ul->parent->child;
if (next == NULL) {
@@ -616,8 +617,13 @@
GE_ASSERT(ctx->ectx, ul != NULL);
GE_ASSERT(ctx->ectx, ul->parent == &ctx->activeUploads);
- PTHREAD_JOIN(ul->shared->handle,
- &unused);
+ if ( (ul->state == FSUI_COMPLETED) ||
+ (ul->state == FSUI_ABORTED) ||
+ (ul->state == FSUI_ERROR) ) {
+ PTHREAD_JOIN(ul->shared->handle,
+ &unused);
+ ul->state++; /* add _JOINED */
+ }
signalUploadStopped(ul, 1);
shared = ul->shared;
freeUploadList(ul);
Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h 2006-10-30 04:20:28 UTC (rev
3576)
+++ GNUnet/src/include/gnunet_fsui_lib.h 2006-10-30 06:00:52 UTC (rev
3577)
@@ -158,7 +158,65 @@
FSUI_unindex_resumed,
};
+
/**
+ * Current state of a download (or uploads, or search,
+ * or unindex operations).
+ *
+ * PENDING means that the download is waiting for a thread
+ * to be assigned to run it. Downloads start in this state,
+ * and during shutdown are serialized in this state.<br>
+ *
+ * ACTIVE means that there is currently a thread running
+ * the download (and that thread is allowed to continue).<br>
+ *
+ * COMPLETED means that the download is finished (but the
+ * thread has not been joined yet). The download thread
+ * makes the transition from PENDING to COMPLETED when it
+ * is about to terminate.<br>
+ *
+ * COMPLETED_JOINED means that the download is finished and
+ * the thread has been joined.<br>
+ *
+ * ABORTED means that the user is causing the download to be
+ * terminated early (but the thread has not been joined yet). The
+ * controller or the download thread make this transition; the
+ * download thread is supposed to terminate shortly after the state is
+ * moved to ABORTED.<br>
+ *
+ * ABORTED_JOINED means that the download did not complete
+ * successfully, should not be restarted and that the thread
+ * has been joined.<br>
+ *
+ * ERROR means that some fatal error is causing the download to be
+ * terminated early (but the thread has not been joined yet). The
+ * controller or the download thread make this transition; the
+ * download thread is supposed to terminate shortly after the state is
+ * moved to ERROR.<br>
+ *
+ * ERROR_JOINED means that the download did not complete successfully,
+ * should not be restarted and that the thread has been joined.<br>
+ *
+ * SUSPENDING is used to notify the download thread that it
+ * should terminate because of an FSUI shutdown. After this
+ * termination the code that joins the thread should move
+ * the state into PENDING (a new thread would not be started
+ * immediately because "threadPoolSize" will be 0 until FSUI
+ * resumes).
+ */
+typedef enum {
+ FSUI_PENDING = 0,
+ FSUI_ACTIVE = 1,
+ FSUI_COMPLETED = 2,
+ FSUI_COMPLETED_JOINED = 3,
+ FSUI_ABORTED = 4,
+ FSUI_ABORTED_JOINED = 5,
+ FSUI_ERROR = 6,
+ FSUI_ERROR_JOINED = 7,
+ FSUI_SUSPENDING = 8,
+} FSUI_State;
+
+/**
* @brief Description of a download. Gives the
* identifier of the download for FSUI and
* the client context. For downloads that
@@ -296,6 +354,8 @@
unsigned int fisSize;
+ FSUI_State state;
+
} SearchResumed;
struct {
@@ -473,6 +533,8 @@
unsigned int anonymityLevel;
+ FSUI_State state;
+
} DownloadResumed;
@@ -590,13 +652,15 @@
*/
cron_t eta;
- unsigned int anonymityLevel;
-
/**
* Information about the upload.
*/
const char * filename;
+ unsigned int anonymityLevel;
+
+ FSUI_State state;
+
} UploadResumed;
@@ -658,6 +722,8 @@
const char * filename;
+ FSUI_State state;
+
} UnindexResumed;
struct {
Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c 2006-10-30 04:20:28 UTC (rev
3576)
+++ gnunet-gtk/src/plugins/fs/download.c 2006-10-30 06:00:52 UTC (rev
3577)
@@ -156,7 +156,8 @@
const ECRS_FileInfo * fi,
const char * filename,
unsigned long long completed,
- cron_t eta) {
+ cron_t eta,
+ FSUI_State state) {
DownloadList * list;
GtkTreeIter iter;
GtkTreePath * path;
@@ -265,6 +266,8 @@
list->fsui_list = fsui_dl;
list->total = total;
list->is_directory = ECRS_isDirectory(fi->meta);
+ list->has_terminated = ( (state != FSUI_ACTIVE) &&
+ (state != FSUI_PENDING) );
list->next = download_head;
download_head = list;
if ( (list->is_directory == YES) &&
@@ -658,7 +661,7 @@
return NULL;
}
-static void
+static gboolean
clearCompletedDownloadCallback(GtkTreeModel * model,
GtkTreePath * path,
GtkTreeIter * iter,
@@ -678,21 +681,14 @@
run_with_save_calls(&fsui_callback,
&fcbc);
}
+ return FALSE;
}
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));
-
- ggc_tree_selection_selected_foreach
- (selection,
- &clearCompletedDownloadCallback,
- NULL);
+ gtk_tree_model_foreach(GTK_TREE_MODEL(download_summary),
+ &clearCompletedDownloadCallback,
+ NULL);
}
static void
Modified: gnunet-gtk/src/plugins/fs/download.h
===================================================================
--- gnunet-gtk/src/plugins/fs/download.h 2006-10-30 04:20:28 UTC (rev
3576)
+++ gnunet-gtk/src/plugins/fs/download.h 2006-10-30 06:00:52 UTC (rev
3577)
@@ -40,7 +40,8 @@
const ECRS_FileInfo * fi,
const char * filename,
unsigned long long completed,
- cron_t eta);
+ cron_t eta,
+ FSUI_State state);
void fs_download_update(DownloadList * downloadContext,
unsigned long long completed,
Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c 2006-10-30 04:20:28 UTC (rev 3576)
+++ gnunet-gtk/src/plugins/fs/fs.c 2006-10-30 06:00:52 UTC (rev 3577)
@@ -63,7 +63,8 @@
event->data.SearchStarted.searchURI,
event->data.SearchStarted.anonymityLevel,
0,
- NULL);
+ NULL,
+ FSUI_ACTIVE);
break;
case FSUI_search_result:
fs_search_result_received(event->data.SearchResult.sc.cctx,
@@ -88,7 +89,8 @@
event->data.SearchResumed.searchURI,
event->data.SearchResumed.anonymityLevel,
event->data.SearchResumed.fisSize,
- event->data.SearchResumed.fis);
+ event->data.SearchResumed.fis,
+ event->data.SearchResumed.state);
break;
case FSUI_search_stopped:
fs_search_stopped(event->data.SearchStopped.sc.cctx);
@@ -126,7 +128,8 @@
&event->data.DownloadStarted.fi,
event->data.DownloadStarted.filename,
0,
- get_time());
+ get_time(),
+ FSUI_ACTIVE);
break;
case FSUI_download_resumed:
ret = fs_download_started(event->data.DownloadResumed.dc.pos,
@@ -137,7 +140,8 @@
&event->data.DownloadResumed.fi,
event->data.DownloadResumed.filename,
event->data.DownloadResumed.completed,
- event->data.DownloadResumed.eta);
+ event->data.DownloadResumed.eta,
+ event->data.DownloadResumed.state);
break;
/* upload events */
@@ -173,7 +177,8 @@
event->data.UploadStarted.filename,
NULL,
event->data.UploadStarted.total,
- 0);
+ 0,
+ FSUI_ACTIVE);
break;
case FSUI_upload_resumed:
printf("FSUI: Upload resumed\n");
@@ -182,9 +187,9 @@
event->data.UploadResumed.filename,
NULL, /* FIXME: maybe completed!? */
event->data.UploadResumed.total,
- event->data.UploadResumed.completed);
+ event->data.UploadResumed.completed,
+ event->data.UploadResumed.state);
break;
-
/* TODO: unindex events */
default:
GE_BREAK(ectx, 0);
@@ -374,7 +379,6 @@
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(uploadList,
col - 1),
TRUE);
-
/* upload entry setup */
uploadEntry
= glade_xml_get_widget(getMainXML(),
Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c 2006-10-30 04:20:28 UTC (rev 3576)
+++ gnunet-gtk/src/plugins/fs/search.c 2006-10-30 06:00:52 UTC (rev 3577)
@@ -147,7 +147,8 @@
const struct ECRS_URI * uri,
unsigned int anonymityLevel,
unsigned int resultCount,
- const ECRS_FileInfo * results) {
+ const ECRS_FileInfo * results,
+ FSUI_State state) {
SearchList * list;
gint pages;
char * description;
Modified: gnunet-gtk/src/plugins/fs/search.h
===================================================================
--- gnunet-gtk/src/plugins/fs/search.h 2006-10-30 04:20:28 UTC (rev 3576)
+++ gnunet-gtk/src/plugins/fs/search.h 2006-10-30 06:00:52 UTC (rev 3577)
@@ -63,7 +63,8 @@
const struct ECRS_URI * uri,
unsigned int anonymityLevel,
unsigned int resultCount,
- const ECRS_FileInfo * results);
+ const ECRS_FileInfo * results,
+ FSUI_State state);
/**
* A search process has been aborted. Update display.
Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c 2006-10-30 04:20:28 UTC (rev 3576)
+++ gnunet-gtk/src/plugins/fs/upload.c 2006-10-30 06:00:52 UTC (rev 3577)
@@ -135,7 +135,8 @@
const char * filename,
struct ECRS_URI * uri,
unsigned long long total,
- unsigned long long completed) {
+ unsigned long long completed,
+ FSUI_State state) {
UploadList * ret;
GtkTreeIter iter;
GtkTreePath * path;
@@ -181,6 +182,9 @@
ret->summaryViewRowReference
= gtk_tree_row_reference_new(GTK_TREE_MODEL(upload_summary),
path);
+ ret->has_terminated = ( (state != FSUI_ACTIVE) &&
+ (state != FSUI_PENDING) );
+
ret->next = upload_head;
upload_head = ret;
return ret;
@@ -415,7 +419,7 @@
return NULL;
}
-static void
+static gboolean
clearCompletedUploadCallback(GtkTreeModel * model,
GtkTreePath * path,
GtkTreeIter * iter,
@@ -435,20 +439,14 @@
run_with_save_calls(&fsui_callback,
&fcbc);
}
+ return FALSE;
}
void on_clearCompletedUploadsButton_clicked_fs(void * unused,
GtkWidget * clearButton) {
- GtkTreeSelection * selection;
- GtkWidget * uploadList;
-
- uploadList = glade_xml_get_widget(getMainXML(),
- "activeUploadsList");
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(uploadList));
- ggc_tree_selection_selected_foreach
- (selection,
- &clearCompletedUploadCallback,
- NULL);
+ gtk_tree_model_foreach(GTK_TREE_MODEL(upload_summary),
+ &clearCompletedUploadCallback,
+ NULL);
}
static void
Modified: gnunet-gtk/src/plugins/fs/upload.h
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.h 2006-10-30 04:20:28 UTC (rev 3576)
+++ gnunet-gtk/src/plugins/fs/upload.h 2006-10-30 06:00:52 UTC (rev 3577)
@@ -48,6 +48,7 @@
const char * filename,
struct ECRS_URI * uri,
unsigned long long total,
- unsigned long long completed);
+ unsigned long long completed,
+ FSUI_State state);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3577 - GNUnet/src/applications/fs/fsui GNUnet/src/include gnunet-gtk/src/plugins/fs,
grothoff <=