fixed partyline-conference handling
[lcr.git] / admin_client.c
index a7e7f52..9baad71 100644 (file)
@@ -405,6 +405,14 @@ int debug_join(struct admin_message *msg, struct admin_message *m, int line, int
                SPRINT(buffer, "%d\n", m[i].u.j.partyline);
                addstr(buffer);
        }
+       if (m[i].u.j.remote[0])
+       {
+               color(cyan);
+               addstr(" remote=");
+               color(white);
+               SPRINT(buffer, "%s\n", m[i].u.j.remote);
+               addstr(buffer);
+       }
        /* find number of epoints */
        j = msg->u.s.interfaces+msg->u.s.joins;
        jj = j + msg->u.s.epoints;
@@ -455,6 +463,8 @@ char *admin_state(int sock, char *argv[])
        int                     anything;
        int                     enter = 0;
        char                    enter_string[128] = "", ch;
+       fd_set                  select_rfds;
+       struct timeval          select_tv;
 
        /* flush logfile name */
        logfile[0] = '\0';
@@ -485,7 +495,7 @@ char *admin_state(int sock, char *argv[])
                cleanup_curses();
                return("Response not valid. Expecting state response.");
        }
-       num = msg.u.s.interfaces + msg.u.s.joins + msg.u.s.epoints + msg.u.s.ports;
+       num = msg.u.s.interfaces + msg.u.s.remotes + msg.u.s.joins + msg.u.s.epoints + msg.u.s.ports;
        m = (struct admin_message *)MALLOC(num*sizeof(struct admin_message));
        off=0;
        if (num)
@@ -522,13 +532,25 @@ char *admin_state(int sock, char *argv[])
                j++;
        }
        i = 0;
+       while(i < msg.u.s.remotes)
+       {
+               if (m[j].message != ADMIN_RESPONSE_S_REMOTE)
+               {
+                       FREE(m, 0);
+                       cleanup_curses();
+                       return("Response not valid. Expecting remote application information.");
+               }
+               i++;
+               j++;
+       }
+       i = 0;
        while(i < msg.u.s.joins)
        {
                if (m[j].message != ADMIN_RESPONSE_S_JOIN)
                {
                        FREE(m, 0);
                        cleanup_curses();
-                       return("Response not valid. Expecting call information.");
+                       return("Response not valid. Expecting join information.");
                }
                i++;
                j++;
@@ -692,17 +714,43 @@ char *admin_state(int sock, char *argv[])
                                                        else
                                                                SPRINT(buffer,"B%2d: ", j+1);
                                                        addstr(buffer);
-                                                       if (!m[i].u.i.ptp)
-                                                               goto ptmp;
-                                                       if (m[i].u.i.l2link && m[i].u.i.block==0)
-                                                       {
-                                                               ptmp:
-                                                               color((m[i].u.i.busy[j])?yellow:blue);
-                                                               addstr((m[i].u.i.busy[j])?"busy":"idle");
-                                                       } else
+                                                       switch(m[i].u.i.busy[j])
                                                        {
-                                                               color(red);
-                                                               addstr("blk ");
+                                                               case B_STATE_IDLE:
+                                                               if ((!m[i].u.i.l2link && m[i].u.i.ptp) || m[i].u.i.block)
+                                                               {
+                                                                       color(red);
+                                                                       addstr("blocked ");
+                                                               } else
+                                                               {
+                                                                       color(blue);
+                                                                       addstr("idle    ");
+                                                               }
+                                                               break;
+                                                               case B_STATE_ACTIVATING:
+                                                               color(yellow);
+                                                               addstr("act'ing ");
+                                                               break;
+                                                               case B_STATE_ACTIVE:
+                                                               color(green);
+                                                               addstr("busy    ");
+                                                               break;
+                                                               case B_STATE_DEACTIVATING:
+                                                               color(yellow);
+                                                               addstr("dact'ing");
+                                                               break;
+                                                               case B_STATE_EXPORTING:
+                                                               color(yellow);
+                                                               addstr("exp'ing ");
+                                                               break;
+                                                               case B_STATE_REMOTE:
+                                                               color(green);
+                                                               addstr("remote  ");
+                                                               break;
+                                                               case B_STATE_IMPORTING:
+                                                               color(yellow);
+                                                               addstr("imp'ing ");
+                                                               break;
                                                        }
                                                        if (m[i].u.i.port[j])
                                                        {
@@ -763,6 +811,17 @@ char *admin_state(int sock, char *argv[])
                        i++;
                        anything = 1;
                }
+               i = 0;
+               ii = i + msg.u.s.remotes;
+               while(i < ii)
+               {
+                       /* show remote summary */
+                       move(++line>1?line:1, 0);
+                       color(white);
+                       SPRINT(buffer, "Remote: %s", m[i].u.r.name);
+                       addstr(buffer);
+                       i++;
+               }
                if (anything)
                        line++;
                if (line+2 >= LINES) goto end;
@@ -935,7 +994,7 @@ char *admin_state(int sock, char *argv[])
                        while(l!=ll)
                        {
                                move(line++>1?line-1:1, 0);
-                               if (strlen(logline[l % LOGLINES]) > hoffset)
+                               if ((int)strlen(logline[l % LOGLINES]) > hoffset)
                                        SCPY(buffer, logline[l % LOGLINES] + hoffset);
                                else
                                        buffer[0] = '\0';
@@ -943,7 +1002,7 @@ char *admin_state(int sock, char *argv[])
                                {
                                        buffer[COLS-1] = '\0';
                                        addstr(buffer);
-                                       color(red);
+                                       color(mangenta);
                                        addch('*');
                                        color(white);
                                } else
@@ -960,7 +1019,7 @@ char *admin_state(int sock, char *argv[])
 //     move(0, 0);
 //     hline(' ', COLS);
        move(0, 0);
-       color(white);
+       color(cyan);
        msg.u.s.version_string[sizeof(msg.u.s.version_string)-1] = '\0';
        SPRINT(buffer, "LCR %s", msg.u.s.version_string);
        addstr(buffer);
@@ -992,14 +1051,18 @@ char *admin_state(int sock, char *argv[])
        }
        /* display end */
        move(LINES-2, 0);
-       color(white);
+       color(blue);
        hline(ACS_HLINE, COLS);
        move(LINES-1, 0);
-       color(white);
        if (enter)
+       {
+               color(white);
                SPRINT(buffer, "-> %s", enter_string);
-       else
+       } else
+       {
+               color(cyan);
                SPRINT(buffer, "i=interfaces '%s'  c=calls '%s'  l=log  q=quit  +-*/=scroll  enter", text_interfaces[show_interfaces], text_calls[show_calls]);
+       }
        addstr(buffer);
        refresh();
 
@@ -1015,6 +1078,7 @@ char *admin_state(int sock, char *argv[])
        {
                /* user input in enter mode */
                ch = getch();
+               enter_again:
                if (ch == 10)
                {
                        FILE *fp;
@@ -1060,17 +1124,30 @@ char *admin_state(int sock, char *argv[])
                if (ch>=32 && ch<=126)
                {
                        SCCAT(enter_string, ch);
+                       ch = getch();
+                       if (ch > 0)
+                               goto enter_again;
                        goto again;
                } else
                if (ch==8 || ch==127)
                {
                        if (enter_string[0])
                                enter_string[strlen(enter_string)-1] = '\0';
+                       ch = getch();
+                       if (ch > 0)
+                               goto enter_again;
                        goto again;
                } else
                if (ch != 3)
                {
-                       usleep(250000);
+                       ch = getch();
+                       if (ch > 0)
+                               goto enter_again;
+                       FD_ZERO(&select_rfds);
+                       FD_SET(0, &select_rfds);
+                       select_tv.tv_sec = 0;
+                       select_tv.tv_usec = 250000;
+                       select(1, &select_rfds, NULL, NULL, &select_tv);
                        goto again;
                }
        } else
@@ -1127,7 +1204,11 @@ char *admin_state(int sock, char *argv[])
                        goto again;
 
                        default:
-                       usleep(250000);
+                       FD_ZERO(&select_rfds);
+                       FD_SET(0, &select_rfds);
+                       select_tv.tv_sec = 0;
+                       select_tv.tv_usec = 250000;
+                       select(1, &select_rfds, NULL, NULL, &select_tv);
                        goto again;
                }
        }