Author: egon
Date: 2004-10-20 07:07:43 -0400 (Wed, 20 Oct 2004)
New Revision: 400

Added:
   trunk/clients/wxhaver/src/wxHaverConfig.cpp
   trunk/clients/wxhaver/src/wxHaverConfig.h
Modified:
   trunk/clients/wxhaver/src/wxHaverFrame.cpp
   trunk/clients/wxhaver/src/wxHaverFrame.h
   trunk/clients/wxhaver/src/wxHaverWindows.cpp
   trunk/clients/wxhaver/src/wxHaverWindows.h
Log:
wxHaver receives messages.

Added: trunk/clients/wxhaver/src/wxHaverConfig.cpp
===================================================================
--- trunk/clients/wxhaver/src/wxHaverConfig.cpp 2004-10-14 08:06:23 UTC (rev 
399)
+++ trunk/clients/wxhaver/src/wxHaverConfig.cpp 2004-10-20 11:07:43 UTC (rev 
400)
@@ -0,0 +1,31 @@
+/* vim: set ft=cpp ts=4 sw=4:
+ * wxHaver - A client for the Haver chat system that utilises wxWindows.
+ * 
+ * Copyright (C) 2004 Jeremy Cambell Apthorp.
+ *
+ * This software is free; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty if
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Puvlic License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "wxHaverConfig.h"
+#include "wx/config.h"
+
+wxHaverConfig::wxHaverConfig()
+{
+       this = wxConfigBase::Get();
+}
+
+wxHaverConfig::~wxHaverConfig()
+{
+}


Property changes on: trunk/clients/wxhaver/src/wxHaverConfig.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/clients/wxhaver/src/wxHaverConfig.h
===================================================================
--- trunk/clients/wxhaver/src/wxHaverConfig.h   2004-10-14 08:06:23 UTC (rev 
399)
+++ trunk/clients/wxhaver/src/wxHaverConfig.h   2004-10-20 11:07:43 UTC (rev 
400)
@@ -0,0 +1,34 @@
+/* vim: set ft=cpp ts=4 sw=4:
+ * wxHaver - A client for the Haver chat system that utilises wxWindows.
+ * 
+ * Copyright (C) 2004 Jeremy Cambell Apthorp.
+ *
+ * This software is free; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty if
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Puvlic License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef WH_wxHaverConfig_H
+#define WH_wxHaverConfig_H
+
+#include "wxHaver.h"
+#include "wx/config.h"
+
+class wxHaverConfig : public wxConfigBase
+{
+       public:
+               wxHaverConfig();
+               ~wxHaverConfig();
+}
+
+#endif // WH_wxHaverConfig_H


Property changes on: trunk/clients/wxhaver/src/wxHaverConfig.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/clients/wxhaver/src/wxHaverFrame.cpp
===================================================================
--- trunk/clients/wxhaver/src/wxHaverFrame.cpp  2004-10-14 08:06:23 UTC (rev 
399)
+++ trunk/clients/wxhaver/src/wxHaverFrame.cpp  2004-10-20 11:07:43 UTC (rev 
400)
@@ -104,10 +104,13 @@
        s_in = new wxHaverCallback<wxHaverFrame>(this, &wxHaverFrame::OnIn);
        wxHaverCallback<wxHaverFrame> *s_list;
        s_list = new wxHaverCallback<wxHaverFrame>(this, &wxHaverFrame::OnList);
+       wxHaverCallback<wxHaverFrame> *s_msg;
+       s_msg = new wxHaverCallback<wxHaverFrame>(this, &wxHaverFrame::OnMsg);
 
        mParser.AddCommand("WANT",      s_want);
        mParser.AddCommand("IN",        s_in);
        mParser.AddCommand("LIST",      s_list);
+       mParser.AddCommand("MSG",       s_msg);
 
        // {Client Commands}
        wxHaverCallback<wxHaverFrame> *u_join;
@@ -179,14 +182,33 @@
        }
 }
 
-void wxHaverFrame::OnConnect(wxCommandEvent& WXUNUSED(event))
+void wxHaverFrame::OnConnect(wxCommandEvent&)
 {
        wxConfigBase *conf = wxConfigBase::Get();
        wxIPV4address addr;
-       addr.Hostname(conf->Read("server", "localhost"));
-       addr.Service(conf->Read("port", 7070));
+       
+       wxDialog *dialog_connect = new wxDialog(NULL, -1,
+                       wxString("Connect to server"), wxDefaultPosition, 
wxSize(150, 100));
+       wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL);
+       wxBoxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
+       wxStaticText *label = new wxStaticText(dialog_connect, -1,
+                       "Server:", wxDefaultPosition);
+       wxTextCtrl *server = new wxTextCtrl(dialog_connect, -1);
+       *server << conf->Read("server", "localhost") << ":"
+               << conf->Read("port", 7070);
+       hsizer->Add(label);
+       hsizer->Add(server, 1, wxGROW);
+       vsizer->Add(hsizer);
+       vsizer->Add(new wxButton(dialog_connect, wxID_OK, "Connect",
+                               wxDefaultPosition), 0, wxALIGN_CENTER);
+       dialog_connect->SetSizer(vsizer);
+       dialog_connect->ShowModal();
+       dialog_connect->Destroy();
+       
+       addr.Hostname("localhost");
+       addr.Service("7070");
 
-       mServer->AppendText(_T("\nConnecting to ") + addr.Hostname() + 
_("..."));
+       mServer->AppendText(_T("\nConnecting to ") + addr.Hostname() + 
_T("..."));
        mSock->Connect(addr, false);
        mSock->WaitOnConnect(10);
        
@@ -207,7 +229,12 @@
 void wxHaverFrame::OnEnterCommand(wxCommandEvent&)
 {
        wxString cmd = mTextEntry->GetLineText(0);
-       mUserParser.Parse(cmd);
+       if (cmd.GetChar(0) == '/')
+               mUserParser.Parse(cmd);
+       else {
+               *mSock << "MSG" << 
mChannels->GetPageText(mChannels->GetSelection())
+                       << cmd << CRLF;
+       }
        mTextEntry->Clear();
 }
 
@@ -261,6 +288,14 @@
        return;
 }
 
+void wxHaverFrame::OnMsg(vector<wxString> args)
+{
+       wxString channel = args[0];
+       wxString user = args[1];
+       wxString message = args[2];
+       mChannels->Message(channel, _T("<") + user + _T("> ") + message);
+}
+
 //------------------------------------------------------------------------
 //  User Command Callbacks
 //------------------------------------------------------------------------

Modified: trunk/clients/wxhaver/src/wxHaverFrame.h
===================================================================
--- trunk/clients/wxhaver/src/wxHaverFrame.h    2004-10-14 08:06:23 UTC (rev 
399)
+++ trunk/clients/wxhaver/src/wxHaverFrame.h    2004-10-20 11:07:43 UTC (rev 
400)
@@ -42,16 +42,26 @@
                void OnQuit(wxCommandEvent&);
                void OnConnect(wxCommandEvent&);
                
+               //------------------------------
+               //  GUI Events
+               //------------------------------
                void OnSize(wxSizeEvent&);
                void OnSashPosChanged(wxSplitterEvent&);
                void OnSocketEvent(wxSocketEvent&);
                void OnEnterCommand(wxCommandEvent&);
                void OnPageChanged(wxNotebookEvent&);
 
+               //------------------------------
+               //  Server Commands
+               //------------------------------
                void OnWant(std::vector<wxString>);
                void OnIn(std::vector<wxString>);
                void OnList(std::vector<wxString>);
+               void OnMsg(std::vector<wxString>);
 
+               //------------------------------
+               //  User Commands
+               //------------------------------
                void OnUJoin(std::vector<wxString>);
                void OnURaw(std::vector<wxString>);
        private:

Modified: trunk/clients/wxhaver/src/wxHaverWindows.cpp
===================================================================
--- trunk/clients/wxhaver/src/wxHaverWindows.cpp        2004-10-14 08:06:23 UTC 
(rev 399)
+++ trunk/clients/wxhaver/src/wxHaverWindows.cpp        2004-10-20 11:07:43 UTC 
(rev 400)
@@ -67,6 +67,11 @@
                if (GetPageText(i) == title) { DeletePage(i); break; }
 }
 
+void wxHaverWindows::DelWindow(int index)
+{
+       DeletePage(index);
+}
+
 int wxHaverWindows::Join(wxString cid)
 {
        *_sock << "JOIN" << cid << CRLF;
@@ -86,6 +91,12 @@
        return 0;
 }
 
+int wxHaverWindows::Close(int index)
+{
+       DelWindow(index);
+       return 0;
+}
+
 int wxHaverWindows::Part(wxString cid)
 {
        *_sock << "PART" << cid << CRLF;
@@ -95,14 +106,30 @@
 
 void wxHaverWindows::Message(wxString id, wxString message)
 {
+       *Window(id) << "\n" << message;
 }
 
+void wxHaverWindows::Message(int index, wxString message)
+{
+       *Window(index) << "\n" << message;
+}
+
 wxTextCtrl *wxHaverWindows::Window(wxString id)
 {
        return windows[id]->text;
 }
 
+wxTextCtrl *wxHaverWindows::Window(int index)
+{
+       return windows[this->GetPageText(index)]->text;
+}
+
 wxHaverWindows::Page &wxHaverWindows::GetWindow(wxString id)
 {
        return *windows[id];
 }
+
+wxHaverWindows::Page &wxHaverWindows::GetWindow(int index)
+{
+       return *windows[this->GetPageText(index)];
+}

Modified: trunk/clients/wxhaver/src/wxHaverWindows.h
===================================================================
--- trunk/clients/wxhaver/src/wxHaverWindows.h  2004-10-14 08:06:23 UTC (rev 
399)
+++ trunk/clients/wxhaver/src/wxHaverWindows.h  2004-10-20 11:07:43 UTC (rev 
400)
@@ -47,12 +47,17 @@
                int Join(wxString cid);
                int Query(wxString uid);
                int Close(wxString window);
+               int Close(int index);
                int Part(wxString cid);
                void Message(wxString id, wxString message);
+               void Message(int index, wxString message);
                wxTextCtrl *Window(wxString id);
+               wxTextCtrl *Window(int index);
                Page &GetWindow(wxString id);
+               Page &GetWindow(int index);
        private:
                void DelWindow(wxString title);
+               void DelWindow(int index);
                wxHaverSockClient *_sock;
                std::map<wxString, Page*> windows;
 };


Reply via email to