* Fix the status line not updating with the new wait indicator; rearrange
authorMichael Hampton <io_error@uncensored.citadel.org>
Fri, 25 Oct 2002 09:26:26 +0000 (09:26 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Fri, 25 Oct 2002 09:26:26 +0000 (09:26 +0000)
  the code so network_status_cb is a member function of ipc.

citadel/ChangeLog
citadel/citadel.c
citadel/citadel_ipc.c
citadel/citadel_ipc.h
citadel/screen.c
citadel/screen.h

index 429f993dbecd24f3e4b7fedb4a44e3e4c87ddbef..fbf3b733a3c4a80dd5001e28e92000f5955fb0f6 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 86548b3c5d7cff98b48f5cd0d33421f459969026..68da989e4b57e7b6f47930962ec33fe49076fa79 100644 (file)
@@ -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);
index 1939e802000fe0cb0df9b89b957654751a0f2700..91f41d535ebd8ba9d8f724600cdf25fac44277a7 100644 (file)
@@ -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 */
index aec31b59387a5c446e60d71223a4fed45fd58ac7..590c021e960708288e127311f16e2fb919099a79 100644 (file)
@@ -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));
index 0e15cc441a16658cdf7808a040e77b8453ac9d38..ae799fe9a7630ea39f1c8dee615499e0d4250db6 100644 (file)
@@ -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 */
        {
index b6af74dc376e60c16a329dcfe14ab7fd2df64822..f86422fae216e8e581b58736c1a34a149aefcb1a 100644 (file)
@@ -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);