diff options
| author | manuel <manuel@mausz.at> | 2013-03-05 17:39:48 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-03-05 17:39:48 +0100 |
| commit | 310a2c101b32a5e71a616027b6a1b788a341bc02 (patch) | |
| tree | a871e1dda8b1de141ae1400ba666fe3b1de96361 /tsquerythread.h | |
| download | tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.gz tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.bz2 tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.zip | |
Diffstat (limited to 'tsquerythread.h')
| -rw-r--r-- | tsquerythread.h | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/tsquerythread.h b/tsquerythread.h new file mode 100644 index 0000000..c41c535 --- /dev/null +++ b/tsquerythread.h | |||
| @@ -0,0 +1,184 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License as published by | ||
| 4 | * the Free Software Foundation; version 2 of the License. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 14 | * | ||
| 15 | * Authors: Manuel Mausz (manuel@mausz.at) | ||
| 16 | * Christian Raschko (c.raschko@netcore.at) | ||
| 17 | */ | ||
| 18 | |||
| 19 | //Header guard | ||
| 20 | #ifndef TSQUERY_H | ||
| 21 | #define TSQUERY_H | ||
| 22 | |||
| 23 | //Libraries | ||
| 24 | #include <wx/wx.h> | ||
| 25 | #include <wx/socket.h> | ||
| 26 | #include <wx/xml2.h> | ||
| 27 | |||
| 28 | #include "tsheaders.h" | ||
| 29 | |||
| 30 | //! TSQuery | ||
| 31 | /*! TSQuery | ||
| 32 | */ | ||
| 33 | class TSQueryThread : public wxThread | ||
| 34 | { | ||
| 35 | DECLARE_CLASS(TSQueryThread) | ||
| 36 | public: | ||
| 37 | |||
| 38 | /*! thread execution starts here | ||
| 39 | * \return Returns ExitCode. | ||
| 40 | */ | ||
| 41 | virtual ExitCode Entry(); | ||
| 42 | |||
| 43 | /*! and stops here | ||
| 44 | */ | ||
| 45 | virtual void OnExit(); | ||
| 46 | |||
| 47 | /*! Default CTor, Initializes the object. | ||
| 48 | * Creates all necessary member objects. | ||
| 49 | */ | ||
| 50 | TSQueryThread(TSClient *client); | ||
| 51 | |||
| 52 | /*! Default DTor. | ||
| 53 | */ | ||
| 54 | ~TSQueryThread(); | ||
| 55 | |||
| 56 | /*! Sets the password for incomming connections. | ||
| 57 | * \param str Password string. | ||
| 58 | * \return Returns false if fails, check GetLastError for details. | ||
| 59 | * \sa GetLastError() | ||
| 60 | */ | ||
| 61 | bool SetPassword(wxString const &str); | ||
| 62 | |||
| 63 | /*! Sets the allowed Addresses. | ||
| 64 | * You can use either an IP or an URL, seperate with ',' | ||
| 65 | * \param str Server address string. | ||
| 66 | * \return Returns false if fails, check GetLastError for details. | ||
| 67 | * \sa GetLastError() | ||
| 68 | */ | ||
| 69 | bool SetAllowedAddresses(wxString const &str); | ||
| 70 | |||
| 71 | /*! Start thread. | ||
| 72 | * \return Returns false if fails, check GetLastError for details. | ||
| 73 | * \sa GetLastError() | ||
| 74 | */ | ||
| 75 | bool Start(); | ||
| 76 | |||
| 77 | /*! Stop thread. | ||
| 78 | * \return Returns false if fails, check GetLastError for details. | ||
| 79 | * \sa GetLastError() | ||
| 80 | */ | ||
| 81 | bool Stop(); | ||
| 82 | |||
| 83 | /*! Sets the server address. | ||
| 84 | * You can use either an IP or an URL. | ||
| 85 | * \param str Server address string. | ||
| 86 | * \return Returns false if fails, check GetLastError for details. | ||
| 87 | * \sa GetLastError() | ||
| 88 | */ | ||
| 89 | bool SetServerAddress(wxString const &str); | ||
| 90 | |||
| 91 | /*! Sets the connection port. | ||
| 92 | * \param port Connection port. | ||
| 93 | * \return Returns false if fails, check GetLastError for details. | ||
| 94 | * \sa GetLastError() | ||
| 95 | */ | ||
| 96 | bool SetPort(wxUint16 const &port); | ||
| 97 | |||
| 98 | /*! Listen for incomming connections. | ||
| 99 | * \return Returns false if fails, check GetLastError for details. | ||
| 100 | * \sa GetLastError() | ||
| 101 | */ | ||
| 102 | bool Accept(); | ||
| 103 | |||
| 104 | /*! Dumps object. | ||
| 105 | * \param ostrm Stream to write. | ||
| 106 | */ | ||
| 107 | void Dump(wxOutputStream &ostrm) const; | ||
| 108 | |||
| 109 | /*! Gets the server Address. | ||
| 110 | * \return Returns the current password. | ||
| 111 | */ | ||
| 112 | wxString const &GetServerAddress() const | ||
| 113 | { | ||
| 114 | return m_ServerAddress; | ||
| 115 | } | ||
| 116 | /*! Gets the password for incomming connections. | ||
| 117 | * \return Returns the current password. | ||
| 118 | */ | ||
| 119 | wxString const &GetPassword() const | ||
| 120 | { | ||
| 121 | return m_Password; | ||
| 122 | } | ||
| 123 | |||
| 124 | /*! Gets the allowed addresses for incomming connections. | ||
| 125 | * \return Returns the allowed addresses. | ||
| 126 | */ | ||
| 127 | wxString const &GetAllowedAddresses() const | ||
| 128 | { | ||
| 129 | return m_AllowedAddresses; | ||
| 130 | } | ||
| 131 | |||
| 132 | /*! Gets the port for incomming connections. | ||
| 133 | * \return Returns the current port. | ||
| 134 | */ | ||
| 135 | wxUint16 const &GetPort() const | ||
| 136 | { | ||
| 137 | return m_Port; | ||
| 138 | } | ||
| 139 | /*! Gets the LastError message, call this method | ||
| 140 | * to get more information for an error. | ||
| 141 | * \return LastError message. | ||
| 142 | */ | ||
| 143 | wxString const &GetLastError() const | ||
| 144 | { | ||
| 145 | return m_LastError; | ||
| 146 | } | ||
| 147 | |||
| 148 | private: | ||
| 149 | bool CmdGetStatus(wxSocketBase *sock); | ||
| 150 | bool CmdGetChannels(wxSocketBase *sock); | ||
| 151 | bool CmdGetUsers(wxSocketBase *sock); | ||
| 152 | bool CmdCreateChannel(wxSocketBase *sock); | ||
| 153 | bool CmdDeleteChannel(wxSocketBase *sock); | ||
| 154 | bool CmdModifyChannel(wxSocketBase *sock); | ||
| 155 | bool CmdMoveUser(wxSocketBase *sock); | ||
| 156 | bool CmdKickUser(wxSocketBase *sock); | ||
| 157 | bool CmdKill(wxSocketBase *sock); | ||
| 158 | |||
| 159 | bool SendDOM(wxSocketBase *sock); | ||
| 160 | bool ProcessCommand(wxSocketBase *sock); | ||
| 161 | bool SendError(wxString const &cmd, wxString const &str, wxSocketBase *sock); | ||
| 162 | bool IsIPAllowed(wxString const &str); | ||
| 163 | bool IsValidFormat(); | ||
| 164 | wxString GetNodeValue(wxXml2Node &pElemRoot, wxString const &str); | ||
| 165 | |||
| 166 | //Sets the LastError message. | ||
| 167 | void SetLastError(wxString const &str) | ||
| 168 | { | ||
| 169 | m_LastError = str; | ||
| 170 | } | ||
| 171 | |||
| 172 | //Members | ||
| 173 | wxString m_LastError; | ||
| 174 | wxString m_AllowedAddresses; | ||
| 175 | wxString m_Password; | ||
| 176 | wxSocketServer *m_pSocket; | ||
| 177 | wxIPV4address m_ServerAddr; | ||
| 178 | TSClient *m_pClient; | ||
| 179 | wxXml2Document m_pXml; | ||
| 180 | wxUint16 m_Port; | ||
| 181 | wxString m_ServerAddress; | ||
| 182 | }; | ||
| 183 | |||
| 184 | #endif | ||
