]> code.citadel.org Git - citadel.git/commitdiff
Got the wholist working
authorArt Cancro <ajc@citadel.org>
Mon, 1 Mar 1999 02:56:38 +0000 (02:56 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 1 Mar 1999 02:56:38 +0000 (02:56 +0000)
daphne/userlogin.cpp
daphne/utils.c
daphne/utils.h
daphne/who.cpp

index 30c971672f186e61948529ba54c0cb06c8276b9e..c869e5e71170304236f2844c3ac802b6f65dc2b4 100644 (file)
@@ -97,7 +97,7 @@ UserLogin::UserLogin(CitClient *sock, wxMDIParentFrame *MyMDI)
                "",
                wxPoint(10,100),
                wxSize(300,30),
-               0, // no style
+               wxTE_PASSWORD,
                wxDefaultValidator,
                "sendcmd"
                );
index 383a001f415729955c9e2f343913e71e5cf83937..4be5f9c8f3cfb2f5925141d8df679fc9a4fcda08 100644 (file)
@@ -13,3 +13,24 @@ void ListToMultiline(wxString& outputbuf, wxStringList inputlist) {
                outputbuf.Append("\n");
        }
 }
+
+// Extract a field from a string returned by the server
+//
+void extract(wxString& outputbuf, wxString inputbuf, int parmnum) {
+       int a;
+       int p;
+       
+       outputbuf = inputbuf;
+
+       for (a=0; a<parmnum; ++a) {
+               p = outputbuf.First('|');
+               if (p >= 0) {
+                       outputbuf = outputbuf.Mid(p+1, STRING_MAXLEN);
+               }
+       }
+
+       p = outputbuf.First('|');
+       if (p > 0) {
+               outputbuf = outputbuf.Mid(0, p);
+       }
+}
index 529a5847cb508f4d4160ad4e42da39c2d52c5bbe..ad3608189143ca780c4d917e4bc9aa3a1d6a9560 100644 (file)
@@ -1 +1,2 @@
 void ListToMultiline(wxString& outputbuf, wxStringList inputlist);
+void extract(wxString& outputbuf, wxString inputbuf, int parmnum);
index c8509c8959adb014d8e53b697759bafa4517e862..adadb004547ad320a87dfbc746a12fdc501a1cd1 100644 (file)
@@ -7,6 +7,7 @@
 #include <wx/listctrl.h>
 #include "citclient.hpp"
 #include "who.hpp"
+#include "utils.h"
 
 // ----------------------------------------------------------------------------
 // private classes
@@ -74,10 +75,10 @@ who::who(CitClient *sock, wxMDIParentFrame *MyMDI)
        c1->right.SameAs(this, wxRight, 10);
        wholist->SetConstraints(c1);
 
-       wholist->InsertColumn(0, "Session", wxLIST_FORMAT_CENTER, (-1));
-       wholist->InsertColumn(1, "User name", wxLIST_FORMAT_CENTER, (-1));
-       wholist->InsertColumn(2, "Room", wxLIST_FORMAT_CENTER, (-1));
-       wholist->InsertColumn(3, "From host", wxLIST_FORMAT_CENTER, (-1));
+       wholist->InsertColumn(0, "Session", wxLIST_FORMAT_CENTER, 50);
+       wholist->InsertColumn(1, "User name", wxLIST_FORMAT_CENTER, 100);
+       wholist->InsertColumn(2, "Room", wxLIST_FORMAT_CENTER, 100);
+       wholist->InsertColumn(3, "From host", wxLIST_FORMAT_CENTER, 100);
 
        SetAutoLayout(TRUE);
        Show(TRUE);
@@ -91,6 +92,7 @@ void who::LoadWholist(void) {
        wxString sendcmd, recvcmd, buf;
        wxStringList rwho;
        int i;
+       wxString sess, user, room, host;
 
        sendcmd = "RWHO";
        if (citsock->serv_trans(sendcmd, recvcmd, rwho) != 1) return;
@@ -98,9 +100,13 @@ void who::LoadWholist(void) {
 
        for (i=0; i<rwho.Number(); ++i) {
                buf.Printf("%s", (wxString *)rwho.Nth(i)->GetData());
-               wholist->InsertItem(i, buf);
-               wholist->InsertItem(i, buf);
-               wholist->InsertItem(i, buf);
-               wholist->InsertItem(i, buf);
+               extract(sess, buf, 0);
+               extract(user, buf, 1);
+               extract(room, buf, 2);
+               extract(host, buf, 3);
+               wholist->InsertItem(i, sess);
+               wholist->SetItem(i, 1, user);
+               wholist->SetItem(i, 2, room);
+               wholist->SetItem(i, 3, host);
        }
 }