[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[giFTcurs-commits] giFTcurs/src Makefile.am get.h gift.c gift.h gi...
From: |
Göran Weinholt |
Subject: |
[giFTcurs-commits] giFTcurs/src Makefile.am get.h gift.c gift.h gi... |
Date: |
Wed, 03 Nov 2004 16:35:52 -0500 |
CVSROOT: /cvsroot/giftcurs
Module name: giFTcurs
Branch:
Changes by: Göran Weinholt <address@hidden> 04/11/03 21:30:05
Modified files:
src : Makefile.am get.h gift.c gift.h giftsrv.h
main.c transfer.c transfer.h ui_main.c
ui_transfer.c
Log message:
Removed a bunch of cruft from the old protocol and added some transfer
stuff placeholders.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/Makefile.am.diff?tr1=1.69&tr2=1.70&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/get.h.diff?tr1=1.69&tr2=1.70&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/gift.c.diff?tr1=1.214&tr2=1.215&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/gift.h.diff?tr1=1.83&tr2=1.84&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/giftsrv.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/main.c.diff?tr1=1.143&tr2=1.144&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/transfer.c.diff?tr1=1.147&tr2=1.148&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/transfer.h.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/ui_main.c.diff?tr1=1.358&tr2=1.359&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/giftcurs/giFTcurs/src/ui_transfer.c.diff?tr1=1.259&tr2=1.260&r1=text&r2=text
Patches:
Index: giFTcurs/src/Makefile.am
diff -u giFTcurs/src/Makefile.am:1.69 giFTcurs/src/Makefile.am:1.70
--- giFTcurs/src/Makefile.am:1.69 Wed Apr 28 23:03:01 2004
+++ giFTcurs/src/Makefile.am Wed Nov 3 21:30:05 2004
@@ -10,14 +10,12 @@
giFTcurs_SOURCES = \
main.c giftcurs.h \
ban.c ban.h \
- get.c get.h \
gift.c gift.h \
giftsrv.c giftsrv.h \
events.c events.h \
list.c list.h \
misc.c misc.h \
parse.c parse.h \
- protocol.c protocol.h \
rpc.c rpc.h \
screen.c screen.h \
search.c search.h \
Index: giFTcurs/src/get.h
diff -u giFTcurs/src/get.h:1.69 giFTcurs/src/get.h:1.70
--- giFTcurs/src/get.h:1.69 Tue Jul 22 23:58:37 2003
+++ giFTcurs/src/get.h Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: get.h,v 1.69 2003/07/22 23:58:37 weinholt Exp $
+ * $Id: get.h,v 1.70 2004/11/03 21:30:05 weinholt Exp $
*/
#ifndef _GET_H
#define _GET_H
@@ -32,9 +32,6 @@
* when progress updates */
int download_hit(hit *, subhit *single);
-/* search again for more sources to download */
-int download_search(transfer *);
-
/* remove a download from list (giFT continues to d/l) */
void download_forget(transfer *);
Index: giFTcurs/src/gift.c
diff -u giFTcurs/src/gift.c:1.214 giFTcurs/src/gift.c:1.215
--- giFTcurs/src/gift.c:1.214 Tue Oct 26 08:16:12 2004
+++ giFTcurs/src/gift.c Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: gift.c,v 1.214 2004/10/26 08:16:12 saturn Exp $
+ * $Id: gift.c,v 1.215 2004/11/03 21:30:05 weinholt Exp $
*/
#include "giftcurs.h"
@@ -33,7 +33,6 @@
#include "gift.h"
#include "list.h"
#include "xcommon.h"
-#include "protocol.h"
#include "rpc.h"
#include "giftsrv.h"
#include "events.h"
Index: giFTcurs/src/gift.h
diff -u giFTcurs/src/gift.h:1.83 giFTcurs/src/gift.h:1.84
--- giFTcurs/src/gift.h:1.83 Tue Oct 26 08:16:12 2004
+++ giFTcurs/src/gift.h Wed Nov 3 21:30:05 2004
@@ -18,12 +18,11 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: gift.h,v 1.83 2004/10/26 08:16:12 saturn Exp $
+ * $Id: gift.h,v 1.84 2004/11/03 21:30:05 weinholt Exp $
*/
#ifndef _GIFT_H
#define _GIFT_H
-#include "protocol.h"
#include "rpc.h"
#define GIFTCLI_PROGNUM 20000001
@@ -31,7 +30,6 @@
#define GIFTCLI_SearchResultData_num 11
#define GIFTCLI_SearchFinished_num 12
-typedef int gift_id;
typedef void (*RPCfunc) (struct rpc_msg *msg, gc_xdr_data *data,
gpointer user_data);
Index: giFTcurs/src/giftsrv.h
diff -u giFTcurs/src/giftsrv.h:1.2 giFTcurs/src/giftsrv.h:1.3
--- giFTcurs/src/giftsrv.h:1.2 Fri Apr 30 05:40:14 2004
+++ giFTcurs/src/giftsrv.h Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: giftsrv.h,v 1.2 2004/04/30 05:40:14 weinholt Exp $
+ * $Id: giftsrv.h,v 1.3 2004/11/03 21:30:05 weinholt Exp $
*/
#ifndef _GIFTSRV_H
#define _GIFTSRV_H
@@ -65,6 +65,19 @@
GIFT_METACMP_ENDS_WITH = 6
};
+enum GIFT_xfertype_t {
+ GIFT_TRANSFER_BIDIRECTIONAL = 0,
+ GIFT_TRANSFER_DOWNSTREAM = 1,
+ GIFT_TRANSFER_UPSTREAM = 2
+};
+
+enum GIFT_xferstate_t {
+ GIFT_TRANSFER_ACTIVE = 0,
+ GIFT_TRANSFER_PAUSED = 1,
+ GIFT_TRANSFER_VERIFY = 2
+};
+
+
/* Some structs */
struct GIFT_hash_t {
char *type;
@@ -117,6 +130,17 @@
void GIFTSRV_SearchCancel(RPCfunc callback, gpointer user_data, GString *);
void GIFTSRV_SearchFinish(RPCfunc callback, gpointer user_data, GString *);
+void GIFTSRV_DownloadStart(RPCfunc callback, gpointer user_data,
+ GString *searchobj, GString
*resultobj);
+void GIFTSRV_TransferList(RPCfunc callback, gpointer user_data,
+ enum GIFT_xfertype_t);
+void GIFTSRV_TransferPause(RPCfunc callback, gpointer user_data,
+ GString *xferobj);
+void GIFTSRV_TransferUnpause(RPCfunc callback, gpointer user_data,
+ GString *xferobj);
+void GIFTSRV_TransferCancel(RPCfunc callback, gpointer user_data,
+ GString *xferobj);
+
void GIFT_query_encode(gc_xdr_data *blob, struct GIFT_query_t *query);
#endif
Index: giFTcurs/src/main.c
diff -u giFTcurs/src/main.c:1.143 giFTcurs/src/main.c:1.144
--- giFTcurs/src/main.c:1.143 Wed Apr 28 23:03:01 2004
+++ giFTcurs/src/main.c Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: main.c,v 1.143 2004/04/28 23:03:01 weinholt Exp $
+ * $Id: main.c,v 1.144 2004/11/03 21:30:05 weinholt Exp $
*/
#include "giftcurs.h"
@@ -40,6 +40,7 @@
#include "gift.h"
#include "settings.h"
#include "format.h"
+#include "events.h"
static GMainLoop *loop;
const char *server_host = "localhost";
Index: giFTcurs/src/transfer.c
diff -u giFTcurs/src/transfer.c:1.147 giFTcurs/src/transfer.c:1.148
--- giFTcurs/src/transfer.c:1.147 Tue Nov 2 01:07:41 2004
+++ giFTcurs/src/transfer.c Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: transfer.c,v 1.147 2004/11/02 01:07:41 weinholt Exp $
+ * $Id: transfer.c,v 1.148 2004/11/03 21:30:05 weinholt Exp $
*/
#include "giftcurs.h"
@@ -28,10 +28,10 @@
#include <limits.h>
#include "parse.h"
-#include "get.h"
#include "transfer.h"
#include "gift.h"
#include "settings.h"
+#include "events.h"
/* This should never be used. It's only here so it can be translated. */
static const char *_statuses[] G_GNUC_UNUSED;
@@ -97,9 +97,11 @@
static int source_sort_method;
static guint bandwidth_timer_tag = 0;
+#if 0
static void transfer_change_handle(ntree *packet, transfer *);
static void transfer_add_handle(ntree *packet, transfer_tree *);
static void addsource_parse(ntree *packet, transfer *);
+#endif
static gboolean bandwidth_timer(void *udata);
static void estimate_speed(struct bandwidth_meas *bw, int sizediff, gulong dt,
gulong idle_time);
static void transfer_detach(transfer *);
@@ -142,12 +144,16 @@
/*gift_register("ADDDOWNLOAD", (EventCallback) transfer_add_handle,
&downloads);
gift_register("ADDUPLOAD", (EventCallback) transfer_add_handle,
&uploads);
- gift_register("DETACH", (EventCallback) transfer_detach_all, NULL);
*/
+ event_connect("detach", (EventCallback) transfer_detach_all, NULL);
tree_resort(&uploads);
tree_resort(&downloads);
}
+void download_start(GString *searchobj, GString *resultobj)
+{
+}
+
static void source_destroy(source * s)
{
g_free(s->user);
@@ -191,24 +197,12 @@
{
t->paused = 0;
- if (t->id) {
- //gift_unregister_id(t->id);
- t->id = 0;
-
+ if (t->active)
if (--nr_alive == 0)
g_source_remove(bandwidth_timer_tag);
- }
/*list_destroy_all(&t->sourcen); */
list_foreach(tree_children(t), (LFunc) source_detach);
-
- if (t->search_id) {
- /* We eat the search_id here, because 't' could be long gone
when
- giFT sends us the final word on search_id. */
- //gift_search_stop(t->search_id, "LOCATE");
- //gift_eat_id(t->search_id);
- t->search_id = 0;
- }
}
static void transfer_detach_panic(transfer *t)
@@ -216,12 +210,7 @@
/* This is called when giFT disconnects without a word. */
int pos = tree_hold(t);
- if (t->search_id) {
- //gift_unregister_id(t->search_id);
- t->search_id = 0;
- }
-
- if (t->id)
+ if (t->active)
change_string(&t->status, N_("Unknown status"));
transfer_detach(t);
@@ -242,11 +231,12 @@
transfer_destroy(t);
}
-static transfer *transfer_new(gift_id id, const char *name, unsigned int size)
+static transfer *transfer_new(GString *xferobj, const char *name,
+ gint64 size)
{
transfer *t = NEW_NODE(transfer);
- t->id = id;
+ t->active = 1;
t->filename = convert_to_locale(g_strdup(name));
t->filesize = size;
t->protocol = NULL;
@@ -258,26 +248,18 @@
void transfer_cancel(transfer *t)
{
- ntree *packet = NULL;
-
- if (!t->id)
+ if (!t->active)
return;
- interface_append_int(&packet, "TRANSFER", t->id);
- interface_append(&packet, "action", "cancel");
- gift_write(&packet);
+ /* FIXME: implement */
}
void source_cancel(transfer *t, source * s)
{
- ntree *packet = NULL;
-
- if (!t->id)
+ if (!t->active)
return;
- interface_append_int(&packet, "DELSOURCE", t->id);
- interface_append(&packet, "url", s->href);
- gift_write(&packet);
+ /* FIXME: implement? */
}
void transfer_reset(transfer *t)
@@ -289,26 +271,24 @@
void transfer_suspend(transfer *t)
{
- ntree *packet = NULL;
-
- if (!t->id)
+ if (!t->active)
return;
- interface_append_int(&packet, "TRANSFER", t->id);
- interface_append(&packet, "action", t->paused ? "unpause" : "pause");
- gift_write(&packet);
+ /* FIXME: (if (paused? t)
+ (GIFTSRV_TransferUnpause t)
+ (GIFTSRV_TransferPause t)) */
}
/* Find a (dead) download suitable for reuse */
-transfer *transfer_find(transfer_tree *tr, const char *filename, const char
*hash,
- unsigned int size, gboolean
dead)
+transfer *transfer_find(transfer_tree *tr, const char *filename,
+ const char *hash, unsigned int
size, gboolean dead)
{
int i;
for (i = 0; i < tree_children(tr)->num; i++) {
transfer *t = list_index(tree_children(tr), i);
- if (dead && t->id)
+ if (dead && t->active)
continue;
if (size > 0 && t->filesize != size)
continue;
@@ -321,22 +301,9 @@
return NULL;
}
-static transfer *transfer_find_id(transfer_tree *tr, gift_id id)
-{
- int i;
-
- for (i = 0; i < tree_children(tr)->num; i++) {
- transfer *t = list_index(tree_children(tr), i);
-
- if (t->id == id)
- return t;
- }
- return NULL;
-}
-
int transfer_alive(transfer *t)
{
- return !!t->id;
+ return t->active;
}
source *lookup_source(transfer *t, const char *user, const char *href)
@@ -353,6 +320,7 @@
return NULL;
}
+#if 0
static void source_change_parse(ntree *param, transfer *t)
{
const char *user, *href, *status;
@@ -441,7 +409,9 @@
tree_release(s, pos);
}
+#endif
+#if 0
static void addsource_parse(ntree *param, transfer *t)
{
const char *user, *href, *status;
@@ -474,7 +444,9 @@
t->protocol = g_strndup(href, strchr(href, ':') - href);
tree_insort(t, s);
}
+#endif
+#if 0
static void transfer_update_fields(transfer *t, ntree *param)
{
const char *state = interface_lookup(param, "state");
@@ -492,7 +464,9 @@
memset(&t->bw, 0, sizeof t->bw);
}
}
+#endif
+#if 0
static void transfer_add_handle(ntree *param, transfer_tree *t_tree)
{
gift_id id;
@@ -560,7 +534,9 @@
//gift_register_id(id, (EventCallback) transfer_change_handle, t);
}
+#endif
+#if 0
static void transfer_change_handle(ntree *param, transfer *t)
{
transfer_tree *our_transfer_tree;
@@ -638,6 +614,7 @@
ui_update(our_transfer_tree->update_ui);
}
+#endif
static const int ESTIMATE_TIME = 8000; /* 8 seconds or so */
Index: giFTcurs/src/transfer.h
diff -u giFTcurs/src/transfer.h:1.60 giFTcurs/src/transfer.h:1.61
--- giFTcurs/src/transfer.h:1.60 Sun Jan 11 21:52:53 2004
+++ giFTcurs/src/transfer.h Wed Nov 3 21:30:05 2004
@@ -1,6 +1,6 @@
/* giFTcurs - curses interface to giFT
- * Copyright (C) 2001, 2002, 2003 Göran Weinholt <address@hidden>
- * Copyright (C) 2003 Christian Häggström <address@hidden>
+ * Copyright (C) 2001-2004 Göran Weinholt <address@hidden>
+ * Copyright (C) 2003-2004 Christian Häggström <address@hidden>
*
* This file is part of giFTcurs.
*
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: transfer.h,v 1.60 2004/01/11 21:52:53 saturn Exp $
+ * $Id: transfer.h,v 1.61 2004/11/03 21:30:05 weinholt Exp $
*/
#ifndef _TRANSFER_H
#define _TRANSFER_H
@@ -67,7 +67,7 @@
typedef struct _transfer_t {
tree_node tnode;
- gift_id id;
+ GString *xferobj; /* Used to uniquely identify
the transfer */
char *filename;
char *protocol;
guint64 filesize, transferred;
@@ -79,9 +79,7 @@
unsigned paused:1;
unsigned autodestroy:1;
-
- /* Download specific variables */
- gift_id search_id; /* id receiving search results
from giFT */
+ unsigned active:1;
} transfer;
typedef struct {
@@ -97,6 +95,8 @@
void transfers_init(void);
+void download_start(GString *searchobj, GString *resultobj);
+
transfer *transfer_find(transfer_tree *, const char *filename, const char
*hash, unsigned int size,
gboolean deadness);
source *lookup_source(transfer *t, const char *user, const char *href)
G_GNUC_PURE;
Index: giFTcurs/src/ui_main.c
diff -u giFTcurs/src/ui_main.c:1.358 giFTcurs/src/ui_main.c:1.359
--- giFTcurs/src/ui_main.c:1.358 Wed Nov 3 00:10:19 2004
+++ giFTcurs/src/ui_main.c Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_main.c,v 1.358 2004/11/03 00:10:19 weinholt Exp $
+ * $Id: ui_main.c,v 1.359 2004/11/03 21:30:05 weinholt Exp $
*/
#include "giftcurs.h"
@@ -28,7 +28,6 @@
#include <ctype.h>
#include "parse.h"
-#include "protocol.h"
#include "gift.h"
#include "misc.h"
#include "screen.h"
@@ -37,12 +36,12 @@
#include "ui_draw.h"
#include "ui_main.h"
#include "ui_input.h"
-#include "get.h"
#include "format.h"
#include "settings.h"
-#include "protocol.h"
#include "events.h"
#include "giftsrv.h"
+#include "search.h"
+#include "transfer.h"
#define HITS ((query*)list_selected(&queries))
@@ -481,7 +480,7 @@
}
if (PRESSED(key) || key == 'd' || key == 'D') {
- download_hit(h, sh);
+ download_start(q->searchobj, h->resultobj);
if (tree_flat(q)->sel < tree_flat(q)->num - 1)
tree_flat(q)->sel++;
main_screen_update_results();
@@ -905,10 +904,9 @@
return;
if (INSTANCEOF(h, subhit))
- download_hit(NULL, (subhit *) h);
+ h = (hit *) tree_parent(h);
- else
- download_hit((hit *) h, NULL);
+ download_start(q->searchobj, h->resultobj);
}
static void mouse_buttonclick(int rx, int ry, void *data)
Index: giFTcurs/src/ui_transfer.c
diff -u giFTcurs/src/ui_transfer.c:1.259 giFTcurs/src/ui_transfer.c:1.260
--- giFTcurs/src/ui_transfer.c:1.259 Wed Nov 3 00:10:19 2004
+++ giFTcurs/src/ui_transfer.c Wed Nov 3 21:30:05 2004
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui_transfer.c,v 1.259 2004/11/03 00:10:19 weinholt Exp $
+ * $Id: ui_transfer.c,v 1.260 2004/11/03 21:30:05 weinholt Exp $
*/
#include "giftcurs.h"
@@ -33,7 +33,6 @@
#include "ui.h"
#include "ui_draw.h"
#include "transfer.h"
-#include "get.h"
#include "settings.h"
#include "format.h"
@@ -193,16 +192,6 @@
refresh();
}
return 1;
- case 'S':
- /* Search for new sources on all downloads at once. */
- for (i = 0; i < tree_children(&downloads)->num; i++) {
- t = list_index(tree_children(&downloads), i);
- if (t->transferred != t->filesize)
- download_search(t);
- }
- update_downloads();
- refresh();
- return 1;
}
/* This is getting clearer, but still ugly... */
@@ -280,17 +269,6 @@
update_func();
refresh();
return 1;
- case 's':
- /* Issue a new search if one is not already running. Also
- don't search if the download is finished. */
- if (active_tree == &uploads)
- break;
- if (t->transferred != t->filesize) {
- download_search(t);
- update_func();
- refresh();
- }
- return 1;
case 'T':
case 't':
if (s) {
@@ -555,7 +533,7 @@
if (!strcmp(key, "transferred"))
RETURN_LONG(t->transferred);
if (!strcmp(key, "searching"))
- RETURN_INT(!!t->search_id);
+ RETURN_INT(0); /* FIXME */
if (!strcmp(key, "expanded"))
RETURN_INT(t->tnode.expanded);
if (!strcmp(key, "sources"))
@@ -563,7 +541,7 @@
if (!strcmp(key, "status"))
RETURN_STR(_(t->status));
if (!strcmp(key, "active"))
- RETURN_INT(t->id && !t->paused);
+ RETURN_INT(t->active && !t->paused);
if (!strcmp(key, "eta"))
RETURN_INT(t->bw.bandwidth ? (t->filesize - t->transferred) /
t->bw.bandwidth : 0);
if (!strcmp(key, "upload"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [giFTcurs-commits] giFTcurs/src Makefile.am get.h gift.c gift.h gi...,
Göran Weinholt <=