/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * 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 Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: Manuel Mausz (manuel@mausz.at) * Christian Raschko (c.raschko@netcore.at) */ //Header guard #ifndef TSQUERY_H #define TSQUERY_H //Libraries #include #include #include #include "tsheaders.h" //! TSQuery /*! TSQuery */ class TSQueryThread : public wxThread { DECLARE_CLASS(TSQueryThread) public: /*! thread execution starts here * \return Returns ExitCode. */ virtual ExitCode Entry(); /*! and stops here */ virtual void OnExit(); /*! Default CTor, Initializes the object. * Creates all necessary member objects. */ TSQueryThread(TSClient *client); /*! Default DTor. */ ~TSQueryThread(); /*! Sets the password for incomming connections. * \param str Password string. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool SetPassword(wxString const &str); /*! Sets the allowed Addresses. * You can use either an IP or an URL, seperate with ',' * \param str Server address string. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool SetAllowedAddresses(wxString const &str); /*! Start thread. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool Start(); /*! Stop thread. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool Stop(); /*! Sets the server address. * You can use either an IP or an URL. * \param str Server address string. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool SetServerAddress(wxString const &str); /*! Sets the connection port. * \param port Connection port. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool SetPort(wxUint16 const &port); /*! Listen for incomming connections. * \return Returns false if fails, check GetLastError for details. * \sa GetLastError() */ bool Accept(); /*! Dumps object. * \param ostrm Stream to write. */ void Dump(wxOutputStream &ostrm) const; /*! Gets the server Address. * \return Returns the current password. */ wxString const &GetServerAddress() const { return m_ServerAddress; } /*! Gets the password for incomming connections. * \return Returns the current password. */ wxString const &GetPassword() const { return m_Password; } /*! Gets the allowed addresses for incomming connections. * \return Returns the allowed addresses. */ wxString const &GetAllowedAddresses() const { return m_AllowedAddresses; } /*! Gets the port for incomming connections. * \return Returns the current port. */ wxUint16 const &GetPort() const { return m_Port; } /*! Gets the LastError message, call this method * to get more information for an error. * \return LastError message. */ wxString const &GetLastError() const { return m_LastError; } private: bool CmdGetStatus(wxSocketBase *sock); bool CmdGetChannels(wxSocketBase *sock); bool CmdGetUsers(wxSocketBase *sock); bool CmdCreateChannel(wxSocketBase *sock); bool CmdDeleteChannel(wxSocketBase *sock); bool CmdModifyChannel(wxSocketBase *sock); bool CmdMoveUser(wxSocketBase *sock); bool CmdKickUser(wxSocketBase *sock); bool CmdKill(wxSocketBase *sock); bool SendDOM(wxSocketBase *sock); bool ProcessCommand(wxSocketBase *sock); bool SendError(wxString const &cmd, wxString const &str, wxSocketBase *sock); bool IsIPAllowed(wxString const &str); bool IsValidFormat(); wxString GetNodeValue(wxXml2Node &pElemRoot, wxString const &str); //Sets the LastError message. void SetLastError(wxString const &str) { m_LastError = str; } //Members wxString m_LastError; wxString m_AllowedAddresses; wxString m_Password; wxSocketServer *m_pSocket; wxIPV4address m_ServerAddr; TSClient *m_pClient; wxXml2Document m_pXml; wxUint16 m_Port; wxString m_ServerAddress; }; #endif