X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwho.c;h=abd807705c2da521160562ac6fd838af96e93b11;hb=44c30618e25ce2eb103b87e84e10dcd51dad0879;hp=7eb676c7f72a4c25b9c1a2b8c5974d32fa8d394a;hpb=04f6eb10ab315349157f84b2d5ab2a96a0c091f7;p=citadel.git diff --git a/webcit/who.c b/webcit/who.c index 7eb676c7f..abd807705 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -1,66 +1,34 @@ -/* $Id$ */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/* + * $Id$ + */ +/** + * \defgroup DislpayWho Display a list of all users currently logged on to the Citadel server. + */ +/*@{*/ #include "webcit.h" - - - -/* - * who is on? +/** + * \brief Display inner div of Wholist */ -void whobbs(void) -{ - char buf[SIZ], sess, user[SIZ], room[SIZ], host[SIZ], +void who_inner_div(void) { + char buf[SIZ], user[SIZ], room[SIZ], host[SIZ], realroom[SIZ], realhost[SIZ]; + int sess; time_t last_activity; time_t now; + int bg = 0; - output_headers(7); - - wprintf("\n" - ); - - wprintf("
"); - wprintf("\""); - wprintf("  Users currently on "); - escputs(serv_info.serv_humannode); - wprintf(""); - offer_start_page(); - wprintf("
\n"); - - wprintf("
\n\n"); - wprintf("\n"); - wprintf("\n"); - wprintf(""); - wprintf("\n\n"); + wprintf("
Session IDUser NameRoomFrom host
" + "\n"); + wprintf("\n"); + wprintf("\n", _("User name")); + wprintf("", _("Room")); + wprintf("\n\n", _("From host")); serv_puts("TIME"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '2') { now = extract_long(&buf[4], 0); } @@ -69,158 +37,244 @@ void whobbs(void) } serv_puts("RWHO"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - while (serv_gets(buf), strcmp(buf, "000")) { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { sess = extract_int(buf, 0); - extract(user, buf, 1); - extract(room, buf, 2); - extract(host, buf, 3); - extract(realroom, buf, 9); - extract(realhost, buf, 10); + extract_token(user, buf, 1, '|', sizeof user); + extract_token(room, buf, 2, '|', sizeof room); + extract_token(host, buf, 3, '|', sizeof host); + extract_token(realroom, buf, 9, '|', sizeof realroom); + extract_token(realhost, buf, 10, '|', sizeof realhost); last_activity = extract_long(buf, 5); - wprintf("\n\t", + (bg ? "DDDDDD" : "FFFFFF") + ); + + + wprintf("\n\t"); - /* (link to page this user) */ - wprintf("" - " "); + " "); + wprintf(""); + + /** (idle flag) */ + wprintf("\n\n\t\n\t\n\t\n\t\n"); + wprintf("\n"); } } - wprintf("
%s%s%s
%d", sess); + bg = 1 - bg; + wprintf("
"); if ((WC->is_aide) && - (sess != serv_info.serv_pid)) { - wprintf(" (kill)"); + (sess != WC->ctdl_pid)) { + wprintf(" %s", _("(kill)")); } - if (sess == serv_info.serv_pid) { - wprintf(" (edit)"); + if (sess == WC->ctdl_pid) { + wprintf(" %s", _("(edit)")); } - wprintf(""); + wprintf(""); + if ((now - last_activity) > 900L) { + wprintf(" " + ""); + } + else { + wprintf(" " + ""); + } + wprintf(""); - /* username (link to user bio/photo page) */ - wprintf(""); escputs(user); - wprintf(""); + wprintf(""); - if ((now - last_activity) > 900L) { - wprintf(" " - ""); - } - - /* room */ - wprintf(""); + /** room */ + wprintf(""); escputs(room); if (strlen(realroom) > 0) { - wprintf("
"); + wprintf("
"); escputs(realroom); - wprintf(""); + wprintf("
"); } - wprintf("
"); + wprintf(""); - /* hostname */ + /** hostname */ escputs(host); if (strlen(realhost) > 0) { - wprintf("
"); + wprintf("
"); escputs(realhost); - wprintf(""); + wprintf("
"); } - wprintf("
\n" - "Click on a name to read user info. Click on " - "\"(p)\" to send " - "a page (instant message) to that user.
\n"); - wDumpContent(1); + wprintf(""); } +/** + * \brief who is on? + */ +void who(void) +{ + char title[256]; + + output_headers(1, 1, 2, 0, 0, 0); + + wprintf("\n", _("Do you really want to kill this session?") + ); + + wprintf("
\n"); + wprintf("
"); + wprintf("\""); + wprintf(" "); + + snprintf(title, sizeof title, _("Users currently on %s"), serv_info.serv_humannode); + escputs(title); + + wprintf(""); + offer_start_page(); + wprintf("
\n"); + wprintf("
\n"); + + wprintf("
\n"); + + wprintf("
"); + who_inner_div(); + wprintf("
\n"); + + wprintf("
"); + wprintf(_("Click on a name to read user info. Click on %s " + "to send an instant message to that user."), + "\"(p)\"" + ); + wprintf("
\n"); + + /** + * JavaScript to make the ajax refresh happen: + * See http://www.sergiopereira.com/articles/prototype.js.html for info on Ajax.PeriodicalUpdater + * It wants: 1. The div being updated + * 2. The URL of the update source + * 3. Other flags (such as the HTTP method and the refresh frequency) + */ + wprintf( + " \n" + ); + wDumpContent(1); +} + +/** + * \brief end session \todo what??? does this belong here? + */ void terminate_session(void) { char buf[SIZ]; serv_printf("TERM %s", bstr("which_session")); - serv_gets(buf); - whobbs(); + serv_getln(buf, sizeof buf); + who(); } -/* - * Change your session info (fake roomname and hostname) +/** + * \brief Change your session info (fake roomname and hostname) */ void edit_me(void) { char buf[SIZ]; - if (!strcasecmp(bstr("sc"), "Change room name")) { + if (strlen(bstr("change_room_name_button")) > 0) { serv_printf("RCHG %s", bstr("fake_roomname")); - serv_gets(buf); - http_redirect("/whobbs"); - } else if (!strcasecmp(bstr("sc"), "Change host name")) { + serv_getln(buf, sizeof buf); + http_redirect("who"); + } else if (strlen(bstr("change_host_name_button")) > 0) { serv_printf("HCHG %s", bstr("fake_hostname")); - serv_gets(buf); - http_redirect("/whobbs"); - } else if (!strcasecmp(bstr("sc"), "Change user name")) { + serv_getln(buf, sizeof buf); + http_redirect("who"); + } else if (strlen(bstr("change_user_name_button")) > 0) { serv_printf("UCHG %s", bstr("fake_username")); - serv_gets(buf); - http_redirect("/whobbs"); - } else if (!strcasecmp(bstr("sc"), "Cancel")) { - http_redirect("/whobbs"); + serv_getln(buf, sizeof buf); + http_redirect("who"); + } else if (strlen(bstr("cancel_button")) > 0) { + http_redirect("who"); } else { - - output_headers(3); - - wprintf("
"); - wprintf(""); - wprintf("Edit your session display"); - wprintf("
\n"); - wprintf("This screen allows you to change the way your\n"); - wprintf("session appears in the 'Who is online' listing.\n"); - wprintf("To turn off any 'fake' name you've previously\n"); - wprintf("set, simply click the appropriate 'change' button\n"); - wprintf("without typing anything in the corresponding box.\n"); - wprintf("
\n"); - - wprintf("
\n"); - - wprintf("\n"); - - wprintf("\n\n\n\n"); - - wprintf("
Room name:"); - wprintf("\n"); - wprintf(""); - wprintf(""); - wprintf("
Host name:"); + output_headers(1, 1, 0, 0, 0, 0); + + wprintf("
\n"); + wprintf("
"); + wprintf(""); + wprintf(_("Edit your session display")); + wprintf("
\n"); + wprintf("
\n
\n"); + + wprintf(_("This screen allows you to change the way your " + "session appears in the 'Who is online' listing. " + "To turn off any 'fake' name you've previously " + "set, simply click the appropriate 'change' button " + "without typing anything in the corresponding box. ")); + wprintf("
\n"); + + wprintf("\n"); + + wprintf("\n"); + + wprintf("\n\n\n\n"); + + wprintf("\n\n\n"); if (WC->is_aide) { - wprintf("\n\n\n"); } - wprintf("
"); + wprintf(_("Room name:")); + wprintf(""); + wprintf("\n"); + wprintf(""); + wprintf("", + _("Change room name")); + wprintf("
"); + wprintf(_("Host name:")); + wprintf(""); wprintf("\n"); wprintf(""); - wprintf(""); + wprintf("", + _("Change host name")); wprintf("
User name:"); + wprintf("
"); + wprintf(_("User name:")); + wprintf(""); wprintf("\n"); wprintf(""); - wprintf(""); + wprintf("", + _("Change user name")); wprintf("
  "); - wprintf(""); + wprintf("
"); + wprintf("", + _("Cancel")); wprintf("
\n"); - wprintf("\n"); wDumpContent(1); } } + + +/*@}*/