]> code.citadel.org Git - citadel.git/commitdiff
post messages.....
authorArt Cancro <ajc@citadel.org>
Thu, 8 Apr 1999 04:18:21 +0000 (04:18 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 8 Apr 1999 04:18:21 +0000 (04:18 +0000)
daphne/citclient.cpp
daphne/enter.cpp
daphne/includes.hpp
daphne/utils.cpp

index 2b7b4b7f748aedd12c7c4ef125b0e7003501892e..e430f524bf8536f0950ad1eaa0c150f37bbef44b 100644 (file)
@@ -114,6 +114,7 @@ int CitClient::serv_trans(
        } else if (first_digit == 4) {          // SEND_LISTING
                for (i=0; i<xferbuf.Number(); ++i) {
                        buf.Printf("%s", (wxString *)xferbuf.Nth(i)->GetData());
+                       cout << i << ": " << buf << "\n";
                        serv_puts(buf);
                }
                serv_puts("000");
index ebe976bbde73e9838117b358d6e0735b15e7bada..a2570a700279470be464b080bc663605a15a9726 100644 (file)
@@ -1,12 +1,14 @@
 #include "includes.hpp"
 
 enum {
-       BUTTON_CLOSE
+       BUTTON_SAVE,
+       BUTTON_CANCEL
 };
 
 
 BEGIN_EVENT_TABLE(EnterMessage, wxMDIChildFrame)
-       EVT_BUTTON(BUTTON_CLOSE,        EnterMessage::OnButtonPressed)
+       EVT_BUTTON(BUTTON_CANCEL,       EnterMessage::OnCancel)
+       EVT_BUTTON(BUTTON_SAVE,         EnterMessage::OnSave)
 END_EVENT_TABLE()
 
 
@@ -28,10 +30,10 @@ EnterMessage::EnterMessage(
        citMyMDI = MyMDI;
        ThisRoom = roomname;
 
-        wxButton *close_button = new wxButton(
+        wxButton *cancel_button = new wxButton(
                 this,
-                BUTTON_CLOSE,
-                " Close ",
+                BUTTON_CANCEL,
+                " Cancel ",
                 wxDefaultPosition);
 
         wxLayoutConstraints *c1 = new wxLayoutConstraints;
@@ -39,16 +41,52 @@ EnterMessage::EnterMessage(
         c1->height.AsIs();
         c1->width.AsIs();
         c1->right.SameAs(this, wxRight, 2);
-        close_button->SetConstraints(c1);
+        cancel_button->SetConstraints(c1);
+
+        wxButton *save_button = new wxButton(
+                this,
+                BUTTON_SAVE,
+                " Save ",
+                wxDefaultPosition);
+
+       wxLayoutConstraints *c2 = new wxLayoutConstraints;
+       c2->bottom.SameAs(cancel_button, wxBottom);
+       c2->right.LeftOf(cancel_button, 5);
+       c2->height.SameAs(cancel_button, wxHeight);
+       c2->width.AsIs();
+       save_button->SetConstraints(c2);
+
+       TheMessage = new wxTextCtrl(this, -1, "",
+               wxDefaultPosition, wxDefaultSize,
+               wxTE_MULTILINE);
+
+       wxLayoutConstraints *c9 = new wxLayoutConstraints;
+       c9->top.SameAs(this, wxTop, 2);
+       c9->bottom.Above(cancel_button, -5);
+       c9->left.SameAs(this, wxLeft, 2);
+       c9->right.SameAs(this, wxRight, 2);
+       TheMessage->SetConstraints(c9);
 
        SetAutoLayout(TRUE);
        Show(TRUE);
+
 }
 
 
 
-void EnterMessage::OnButtonPressed(wxCommandEvent& whichbutton) {
-        if (whichbutton.GetId() == BUTTON_CLOSE) {
-                delete this;
+void EnterMessage::OnCancel(wxCommandEvent& whichbutton) {
+       delete this;
+}
+
+
+void EnterMessage::OnSave(wxCommandEvent& whichbutton) {
+       wxString sendcmd, recvcmd;
+       wxStringList msgbuf;
+
+       MultilineToList(msgbuf, TheMessage->GetValue());
+
+       sendcmd = "ENT0 1";
+       if (citsock->serv_trans(sendcmd, recvcmd, msgbuf, ThisRoom) == 4) {
+               delete this;
        }
 }
index 220f2efe7eb14f4d80bb292625321b0f48190114..8aca428e8e09851f9d738b5beb6fe2f781688442 100644 (file)
@@ -233,10 +233,12 @@ public:
        EnterMessage(CitClient *sock, wxMDIParentFrame *MyMDI,
                wxString roomname);
 private:
-       void OnButtonPressed(wxCommandEvent& whichbutton);
+       void OnCancel(wxCommandEvent& whichbutton);
+       void OnSave(wxCommandEvent& whichbutton);
        CitClient *citsock;
        wxMDIParentFrame *citMyMDI;
        wxString ThisRoom;
+       wxTextCtrl *TheMessage;
        DECLARE_EVENT_TABLE()
 };
 
index 0f8405ccbc26249822bf80470d13ae22561e5016..437b0caf67f6b5d1dbdc83ab8a34a5db2ee05c9e 100644 (file)
@@ -22,30 +22,40 @@ void ListToMultiline(wxString& outputbuf, wxStringList inputlist) {
 
 void MultilineToList(wxStringList& outputlist, wxString inputbuf) {
        wxString buf;
-       int pos;
+       int pos, i;
        
        buf = inputbuf;
        outputlist.Clear();
 
        while (buf.Length() > 0) {
+
+               // One line with no breaks...
+               if ((buf.Length() < 250) && (buf.Find('\n', FALSE)<0)) {
+                       outputlist.Add(buf);
+                       goto DONE;
+               }
+
                // First try to locate a line break
                pos = buf.Find('\n', FALSE);
-               if ( (pos >=0) && (pos < 256) ) {
-                       outputlist.Add(buf.Left(pos-1));
+               if ( (pos >=0) && (pos < 250) ) {
+                       outputlist.Add(buf.Left(pos));
                        buf = buf.Mid(pos+1);
                } else {
                // Otherwise, try to find a space
-                       pos = buf.Mid(0, 256).Find(' ', TRUE);
-                       if ( (pos >=0) && (pos < 256) ) {
-                               outputlist.Add(buf.Left(pos-1));
+                       pos = buf.Left(250).Find(' ', TRUE);
+                       if ( (pos >= 0) && (pos < 250) ) {
+                               outputlist.Add(buf.Left(pos));
                                buf = buf.Mid(pos+1);
                        } else {
-                               pos = 255;
-                               outputlist.Add(buf.Left(pos-1));
-                               buf = buf.Mid(pos);
+                               outputlist.Add(buf.Left(250));
+                               buf = buf.Mid(250);
                        }
                }
        }
+DONE:  for (i=0; i<outputlist.Number(); ++i) {
+               buf.Printf("%s", (wxString *)outputlist.Nth(i)->GetData());
+               cout << i << ": " << buf << "\n";
+       }
 }