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);
+ }
+}
#include <wx/listctrl.h>
#include "citclient.hpp"
#include "who.hpp"
+#include "utils.h"
// ----------------------------------------------------------------------------
// private classes
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);
wxString sendcmd, recvcmd, buf;
wxStringList rwho;
int i;
+ wxString sess, user, room, host;
sendcmd = "RWHO";
if (citsock->serv_trans(sendcmd, recvcmd, rwho) != 1) return;
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);
}
}