From: Michael Hampton Date: Fri, 25 Oct 2002 09:26:26 +0000 (+0000) Subject: * Fix the status line not updating with the new wait indicator; rearrange X-Git-Tag: v7.86~6146 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=a551033a10a34a0a0e5b3d7ee833530f670dac21;p=citadel.git * Fix the status line not updating with the new wait indicator; rearrange the code so network_status_cb is a member function of ipc. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 429f993db..fbf3b733a 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 601.50 2002/10/25 09:26:26 error + * Fix the status line not updating with the new wait indicator; rearrange + the code so network_status_cb is a member function of ipc. + Revision 601.49 2002/10/25 04:39:38 ajc * When in fullscreen mode, display an "X" icon in the lower right corner of the screen while waiting for the server. @@ -4155,4 +4159,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.c b/citadel/citadel.c index 86548b3c5..68da989e4 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -1034,6 +1034,9 @@ int main(int argc, char **argv) error_printf("Can't connect: %s\n", strerror(errno)); logoff(NULL, 3); } +#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) + CtdlIPC_SetNetworkStatusCallback(ipc, wait_indicator); +#endif ipc_for_signal_handlers = ipc; /* KLUDGE cover your eyes */ CtdlIPC_getline(ipc, aaa); diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index 1939e8020..91f41d535 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -62,10 +62,8 @@ void setCryptoStatusHook(void (*hook)(char *s)) { status_hook = hook; } -static void (*lock_hook)(int onoff) = NULL; - -void setLockHook(void (*hook)(int onoff)) { - lock_hook = hook; +void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state)) { + ipc->network_status_cb = hook; } @@ -1996,8 +1994,7 @@ int CtdlIPCInternalProgram(CtdlIPC *ipc, int secret, char *cret) inline void CtdlIPC_lock(CtdlIPC *ipc) { - if (lock_hook != NULL) - lock_hook(1); + if (ipc->network_status_cb) ipc->network_status_cb(1); #ifdef THREADED_CLIENT pthread_mutex_lock(&(ipc->mutex)); #endif @@ -2009,8 +2006,7 @@ inline void CtdlIPC_unlock(CtdlIPC *ipc) #ifdef THREADED_CLIENT pthread_mutex_unlock(&(ipc->mutex)); #endif - if (lock_hook != NULL) - lock_hook(0); + if (ipc->network_status_cb) ipc->network_status_cb(0); } @@ -2810,6 +2806,7 @@ CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf) ipc->downloading = 0; ipc->uploading = 0; ipc->last_command_sent = 0L; + ipc->network_status_cb = NULL; strcpy(cithost, DEFAULT_HOST); /* default host */ strcpy(citport, DEFAULT_PORT); /* default port */ diff --git a/citadel/citadel_ipc.h b/citadel/citadel_ipc.h index aec31b593..590c021e9 100644 --- a/citadel/citadel_ipc.h +++ b/citadel/citadel_ipc.h @@ -43,6 +43,8 @@ typedef struct _CtdlIPC { int uploading; /* Time the last command was sent to the server */ time_t last_command_sent; + /* Callback for update on whether the IPC is locked */ + void (*network_status_cb)(int state); } CtdlIPC; /* C constructor */ @@ -104,6 +106,17 @@ struct ctdlipcmessage { }; +struct ctdlipcfile { + char remote_name[PATH_MAX]; /* Filename on server */ + char local_name[PATH_MAX]; /* Filename on client */ + char description[80]; /* Description on server */ + FILE *local_fd; /* Open file on client */ + size_t size; /* Size of file in octets */ + int upload:1; /* uploading? 0 if downloading */ + int complete:1; /* Transfer has finished? */ +}; + + struct ctdlipcmisc { long newmail; /* Number of new Mail messages */ char needregis; /* Nonzero if user needs to register */ @@ -148,6 +161,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret); int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret); int CtdlIPCServerInfo(CtdlIPC *ipc, struct CtdlServInfo *ServInfo, char *cret); +/* int CtdlIPCReadDirectory(CtdlIPC *ipc, struct ctdlipcfile **files, char *cret); */ int CtdlIPCReadDirectory(CtdlIPC *ipc, char **listing, char *cret); int CtdlIPCSetLastRead(CtdlIPC *ipc, long msgnum, char *cret); int CtdlIPCInviteUserToRoom(CtdlIPC *ipc, const char *username, char *cret); @@ -282,7 +296,7 @@ int CtdlIPCGenericCommand(CtdlIPC *ipc, const char *command, /* Internals */ int starttls(CtdlIPC *ipc); void setCryptoStatusHook(void (*hook)(char *s)); -void setLockHook(void (*hook)(int onoff)); +void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state)); /* This is all Ford's doing. FIXME: figure out what it's doing */ extern int (*error_printf)(char *s, ...); void setIPCDeathHook(void (*hook)(void)); diff --git a/citadel/screen.c b/citadel/screen.c index 0e15cc441..ae799fe9a 100644 --- a/citadel/screen.c +++ b/citadel/screen.c @@ -83,16 +83,26 @@ void status_line(const char *humannode, const char *bbs_city, * Display a 3270-style "wait" indicator at the bottom of the screen */ #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) -void wait_indicator(int onoff) { +void wait_indicator(int state) { if (statuswindow) { - mvwinch(statuswindow, 0, 78); - if (onoff) { - waddch(statuswindow, 'X'); - } - else { + mvwinch(statuswindow, 0, screenwidth - 2); + switch (state) { + default: + case 0: /* Idle */ waddch(statuswindow, ' '); + break; + case 1: /* Waiting */ + waddch(statuswindow, 'X'); + break; + case 2: /* Receiving */ + waddch(statuswindow, '<'); + break; + case 3: /* Sending */ + waddch(statuswindow, '>'); + break; } + waddch(statuswindow, '\r'); wrefresh(statuswindow); wrefresh(mainwindow); /* this puts the cursor back */ } @@ -130,9 +140,6 @@ void screen_new(void) if (COLOR_PAIRS > 8) init_pair(8, COLOR_WHITE, COLOR_BLUE); - - setLockHook(wait_indicator); - } else #endif /* HAVE_CURSES_H */ { diff --git a/citadel/screen.h b/citadel/screen.h index b6af74dc3..f86422fae 100644 --- a/citadel/screen.h +++ b/citadel/screen.h @@ -37,3 +37,4 @@ void windows_delete(void); int scr_blockread(void); int is_curses_enabled(void); RETSIGTYPE scr_winch(int signum); +void wait_indicator(int state);