X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwho.c;h=11c68d86c99602c3c8dddf456e01d0e55e3a3925;hb=25220160fc09e185bbf9f13f7565bb568cc5a463;hp=ac30cc72dd2e040fdc4d2ac212ea10bf692649fb;hpb=7974c7b863e396a87e1479525a10db9b9cf93ca9;p=citadel.git diff --git a/webcit/who.c b/webcit/who.c index ac30cc72d..11c68d86c 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -1,10 +1,13 @@ #include "webcit.h" +CtxType CTX_WHO = CTX_NONE; + typedef struct UserStateStruct { StrBuf *UserName; StrBuf *Room; StrBuf *Host; + StrBuf *UserAgent; StrBuf *RealRoom; StrBuf *RealHost; long LastActive; @@ -22,6 +25,7 @@ void DestroyUserStruct(void *vUser) FreeStrBuf(&User->Host); FreeStrBuf(&User->RealRoom); FreeStrBuf(&User->RealHost); + FreeStrBuf(&User->UserAgent); free(User); } @@ -67,7 +71,8 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte User->Host = NewStrBufPlain(NULL, BufLen); StrBufExtract_NextToken(User->Host, Buf, &Pos, '|'); - StrBufSkip_NTokenS(Buf, &Pos, '|', 1); + User->UserAgent = NewStrBufPlain(NULL, BufLen); + StrBufExtract_NextToken(User->UserAgent, Buf, &Pos, '|'); User->LastActive = StrBufExtractNext_long(Buf, &Pos, '|'); StrBufSkip_NTokenS(Buf, &Pos, '|', 3); @@ -137,34 +142,6 @@ void terminate_session(void) } -/* - * Change your session info (fake roomname and hostname) - */ -void edit_me(void) -{ - char buf[SIZ]; - - output_headers(1, 0, 0, 0, 0, 0); - if (havebstr("change_room_name_button")) { - serv_printf("RCHG %s", bstr("fake_roomname")); - serv_getln(buf, sizeof buf); - do_template("who"); - } else if (havebstr("change_host_name_button")) { - serv_printf("HCHG %s", bstr("fake_hostname")); - serv_getln(buf, sizeof buf); - do_template("who"); - } else if (havebstr("change_user_name_button")) { - serv_printf("UCHG %s", bstr("fake_username")); - serv_getln(buf, sizeof buf); - do_template("who"); - } else if (havebstr("cancel_button")) { - do_template("who"); - } else { - do_template("who_edit"); - } - end_burst(); -} - void _terminate_session(void) { slrp_highest(); terminate_session(); @@ -218,6 +195,12 @@ void tmplput_who_username(StrBuf *Target, WCTemplputParams *TP) StrBufAppendTemplate(Target, TP, User->UserName, 0); } +void tmplput_who_UserAgent(StrBuf *Target, WCTemplputParams *TP) +{ + UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO); + StrBufAppendTemplate(Target, TP, User->UserAgent, 0); +} + void tmplput_who_room(StrBuf *Target, WCTemplputParams *TP) { UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO); @@ -298,14 +281,14 @@ void InitModule_WHO (void) { - + RegisterCTX(CTX_WHO); WebcitAddUrlHandler(HKEY("terminate_session"), "", 0, _terminate_session, 0); - WebcitAddUrlHandler(HKEY("edit_me"), "", 0, edit_me, 0); RegisterIterator("WHOLIST", 1, NULL, GetWholistHash, NULL, DeleteWholistHash, CTX_WHO, CTX_NONE, IT_NOFLAG); RegisterNamespace("WHO:NAME", 0, 1, tmplput_who_username, NULL, CTX_WHO); + RegisterNamespace("WHO:USERAGENT", 0, 1, tmplput_who_UserAgent, NULL, CTX_WHO); RegisterNamespace("WHO:ROOM", 0, 1, tmplput_who_room, NULL, CTX_WHO); RegisterNamespace("WHO:HOST", 0, 1, tmplput_who_host, NULL, CTX_WHO); RegisterNamespace("WHO:REALROOM", 0, 1, tmplput_who_realroom, NULL, CTX_WHO); @@ -316,9 +299,9 @@ InitModule_WHO RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO); RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO); - RegisterConditional(HKEY("WHO:IDLE"), 1, conditional_who_idle, CTX_WHO); - RegisterConditional(HKEY("WHO:NSESSIONS"), 1, conditional_who_nsessions, CTX_WHO); - RegisterConditional(HKEY("WHO:ISME"), 1, conditional_who_isme, CTX_WHO); - RegisterConditional(HKEY("WHO:REALROOM"), 1, conditional_who_realroom, CTX_WHO); - RegisterConditional(HKEY("WHO:REALHOST"), 1, conditional_who_realhost, CTX_WHO); + RegisterConditional("WHO:IDLE", 1, conditional_who_idle, CTX_WHO); + RegisterConditional("WHO:NSESSIONS", 1, conditional_who_nsessions, CTX_WHO); + RegisterConditional("WHO:ISME", 1, conditional_who_isme, CTX_WHO); + RegisterConditional("WHO:REALROOM", 1, conditional_who_realroom, CTX_WHO); + RegisterConditional("WHO:REALHOST", 1, conditional_who_realhost, CTX_WHO); }