the code so network_status_cb is a member function of ipc.
$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
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);
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;
}
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
#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);
}
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 */
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 */
};
+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 */
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);
/* 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));
* 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 */
}
if (COLOR_PAIRS > 8)
init_pair(8, COLOR_WHITE, COLOR_BLUE);
-
- setLockHook(wait_indicator);
-
} else
#endif /* HAVE_CURSES_H */
{
int scr_blockread(void);
int is_curses_enabled(void);
RETSIGTYPE scr_winch(int signum);
+void wait_indicator(int state);