if (sock.IsConnected()) {
serv_gets(ServerReady);
// FIX ... add check for not allowed to log in
+ initialize_session();
return(0);
}
else return(1);
void CitClient::serv_gets(wxString& buf) {
char charbuf[2];
+ buf.Empty();
do {
sock.Read(charbuf, 1);
if (isprint(charbuf[0])) buf.Append(charbuf[0], 1);
wxString junkbuf;
return serv_trans(command, junkbuf);
}
+
+// Set up some things that we do at the beginning of every session
+void CitClient::initialize_session(void) {
+ wxStringList info;
+ wxString sendcmd;
+ wxString recvcmd;
+ int i;
+ wxString *infoptr;
+ wxString infoline;
+
+ sendcmd = "IDEN 0|6|000|Daphne";
+ serv_trans(sendcmd);
+
+ sendcmd = "INFO";
+ if (serv_trans(sendcmd, recvcmd, info)==1) {
+ for (i=0; i<info.Number(); ++i) {
+ infoptr = (wxString *) info.Nth(i)->GetData();
+ infoline.Printf("%s", infoptr);
+ switch(i) {
+ case 0: SessionID = atoi(infoline);
+ case 1: NodeName = infoline;
+ case 2: HumanNode = infoline;
+ case 3: FQDN = infoline;
+ case 4: ServerSoftware = infoline;
+ case 5: ServerRev = atoi(infoline);
+ case 6: GeoLocation = infoline;
+ case 7: SysAdmin = infoline;
+ case 8: ServerType = atoi(infoline);
+ case 9: MorePrompt = infoline;
+ case 10: UseFloors = ((atoi(infoline)>0)
+ ? TRUE : FALSE);
+ case 11: PagingLevel = atoi(infoline);
+ }
+ }
+ }
+}
public:
CitClient(void);
~CitClient(void);
+
+ // High-level Citadel IPC methods
int attach(const wxString& host, const wxString& port);
void detach(void);
bool IsConnected(void);
- void serv_gets(wxString& buf);
- void serv_puts(wxString buf);
int CitClient::serv_trans(
wxString& command,
wxString& response,
);
int CitClient::serv_trans(wxString& command, wxString& response);
int CitClient::serv_trans(wxString& command);
+
+ // Various things we learn about the server
+ int SessionID;
+ wxString NodeName;
+ wxString HumanNode;
+ wxString FQDN;
+ wxString ServerSoftware;
+ int ServerRev;
+ wxString GeoLocation;
+ wxString SysAdmin;
+ int ServerType;
+ wxString MorePrompt;
+ bool UseFloors;
+ int PagingLevel;
+
private:
+ void serv_gets(wxString& buf);
+ void serv_puts(wxString buf);
wxSocketClient sock;
wxIPV4address addr;
+ void CitClient::initialize_session(void);
};
"exit_button"
);
+
+ wxPanel *hnodepanel = new wxPanel(this, -1, wxDefaultPosition,
+ wxDefaultSize, 0L, "");
+ hnodepanel->SetBackgroundColour(wxColour(0x00, 0x00, 0x77));
+ hnodepanel->SetForegroundColour(wxColour(0xFF, 0xFF, 0x00));
+
+ wxStaticText *humannode = new wxStaticText(
+ hnodepanel, -1, citsock->HumanNode,
+ wxDefaultPosition, wxDefaultSize, 0, "");
+ humannode->SetBackgroundColour(wxColour(0x00, 0x00, 0x77));
+ humannode->SetForegroundColour(wxColour(0xFF, 0xFF, 0x00));
+ humannode->SetFont(wxFont(24, wxDEFAULT, wxNORMAL, wxNORMAL,
+ FALSE, ""));
+
+ wxLayoutConstraints *t0 = new wxLayoutConstraints;
+ t0->top.SameAs(this, wxTop, 10);
+ t0->height.SameAs(this, wxTop, 50);
+ t0->left.SameAs(this, wxLeft, 10);
+ t0->right.SameAs(this, wxRight, 10);
+ hnodepanel->SetConstraints(t0);
+
+ wxLayoutConstraints *t1 = new wxLayoutConstraints;
+ t1->top.SameAs(this, wxTop, 10);
+ t1->height.AsIs();
+ //t1->left.SameAs(this, wxLeft, 10);
+ //t1->right.SameAs(this, wxRight, 10);
+ t1->centreX.SameAs(this, wxCentreX);
+ t1->width.AsIs();
+ humannode->SetConstraints(t1);
+
wxLayoutConstraints *c1 = new wxLayoutConstraints;
c1->bottom.SameAs(this, wxBottom, 10); // 10 from the bottom
c1->centreX.SameAs(this, wxCentreX); // in the middle