diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-09-06 10:37:24 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-09-06 10:37:24 +0900 |
commit | 2d49c44c47015d4ccd5aa08b4fe8a2401a513c3c (patch) | |
tree | f71347d3ff3cff2c5924b91a914f98f221907f4d /src | |
parent | 281a7702cf2b83f13eab74d38758893584e7ecb6 (diff) | |
download | universal-indent-gui-tqt-2d49c44c47015d4ccd5aa08b4fe8a2401a513c3c.tar.gz universal-indent-gui-tqt-2d49c44c47015d4ccd5aa08b4fe8a2401a513c3c.zip |
Remove incomplete and useless server code
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src')
-rw-r--r-- | src/__TODO/UiGuiIndentServer.cpp | 175 | ||||
-rw-r--r-- | src/__TODO/UiGuiIndentServer.h | 55 | ||||
-rwxr-xr-x | src/main.cpp | 58 |
3 files changed, 4 insertions, 284 deletions
diff --git a/src/__TODO/UiGuiIndentServer.cpp b/src/__TODO/UiGuiIndentServer.cpp deleted file mode 100644 index 5a39951..0000000 --- a/src/__TODO/UiGuiIndentServer.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * 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 in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "UiGuiIndentServer.h" - -#include <tqtcpserver.h> -#include <tqtcpsocket.h> -#include <tqmessagebox.h> -#include <tqtdebug.h> - -// \defgroup grp_Server All concerning the server component. - -/* - \class UiGuiIndentServer - \ingroup grp_Server - \brief UiGuiIndentServer is in such an early state, that even the communication - protocol isn't completely planned. So this class lacks documentation until - I really know where all this will lead to. - - The plan however is to have a server that receives commands for selecting an - indenter and perhaps load some by the user predefined indenter config file. Then - the client can send a text to it and will receive it formatted. - The idea behind that is to make UiGUIs use as plugin or whatever more flexible. - So the plugin is developed for Eclipse for example and it takes the client role, - making it possible to use UiGUI from within Eclipse. Choosing a network protocol - makes everything platform and programming language independent, so it doesn't - matter for which application the plugin/client is developed. -*/ - -UiGuiIndentServer::UiGuiIndentServer(void) : - TQObject() -{ - _tcpServer = NULL; - _currentClientConnection = NULL; - _readyForHandleRequest = false; -} - -UiGuiIndentServer::~UiGuiIndentServer(void) -{ -} - -void UiGuiIndentServer::startServer() -{ - if (_tcpServer == NULL) - { - _tcpServer = new TQTcpServer(this); - } - - if (!_tcpServer->isListening()) - { - if (!_tcpServer->listen(TQHostAddress::Any, tquint16(84484))) - { - TQMessageBox::critical(NULL, tr("UiGUI Server"), - tr("Unable to start the server: %1.").arg(_tcpServer->errorString())); - return; - } - } - - connect(_tcpServer, TQ_SIGNAL(newConnection()), this, TQ_SLOT(handleNewConnection())); - _readyForHandleRequest = true; - _blockSize = 0; -} - -void UiGuiIndentServer::stopServer() -{ - if (_tcpServer != NULL) - { - _tcpServer->close(); - delete _tcpServer; - _tcpServer = NULL; - } - _currentClientConnection = NULL; - _readyForHandleRequest = false; -} - -void UiGuiIndentServer::handleNewConnection() -{ - TQTcpSocket *clientConnection = _tcpServer->nextPendingConnection(); - connect(clientConnection, TQ_SIGNAL(disconnected()), clientConnection, TQ_SLOT(deleteLater())); - - connect(clientConnection, TQ_SIGNAL(readyRead()), this, TQ_SLOT(handleReceivedData())); -} - -void UiGuiIndentServer::handleReceivedData() -{ - if (!_readyForHandleRequest) - { - return; - } - - _currentClientConnection = qobject_cast<TQTcpSocket*>(sender()); - TQString receivedData = ""; - - if (_currentClientConnection != NULL) - { - TQDataStream in(_currentClientConnection); - in.setVersion(TQDataStream::TQt_4_0); - - if (_blockSize == 0) - { - if (_currentClientConnection->bytesAvailable() < (int)sizeof(tquint32)) - { - return; - } - - in >> _blockSize; - } - - if (_currentClientConnection->bytesAvailable() < _blockSize) - { - return; - } - - TQString receivedMessage; - in >> receivedMessage; - - _blockSize = 0; - - tqDebug() << "receivedMessage: " << receivedMessage; - - if (receivedMessage == "ts") - { - sendMessage("Toll"); - } - else - { - sendMessage("irgendwas"); - } - } -} - -void UiGuiIndentServer::sendMessage(const TQString &message) -{ - _readyForHandleRequest = false; - - _dataToSend = ""; - TQDataStream out(&_dataToSend, TQIODevice::WriteOnly); - out.setVersion(TQDataStream::TQt_4_0); - out << (tquint32)0; - out << message; - out.device()->seek(0); - out << (tquint32)(_dataToSend.size() - sizeof(tquint32)); - - connect(_currentClientConnection, TQ_SIGNAL(bytesWritten(qint64)), this, - TQ_SLOT(checkIfReadyForHandleRequest())); - _currentClientConnection->write(_dataToSend); -} - -void UiGuiIndentServer::checkIfReadyForHandleRequest() -{ - if (_currentClientConnection->bytesToWrite() == 0) - { - TQString dataToSendStr = _dataToSend.right(_dataToSend.size() - sizeof(tquint32)); - tqDebug() << "checkIfReadyForHandleRequest _dataToSend was: " << dataToSendStr; - disconnect(_currentClientConnection, TQ_SIGNAL(bytesWritten(qint64)), this, - TQ_SLOT(checkIfReadyForHandleRequest())); - _readyForHandleRequest = true; - } -} diff --git a/src/__TODO/UiGuiIndentServer.h b/src/__TODO/UiGuiIndentServer.h deleted file mode 100644 index 9bf72d2..0000000 --- a/src/__TODO/UiGuiIndentServer.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2012 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * 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 in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef UIGUIINDENTSERVER_H -#define UIGUIINDENTSERVER_H - -#include <tqobject.h> - -class TQTcpServer; -class TQTcpSocket; - - -class UiGuiIndentServer : public TQObject -{ - TQ_OBJECT - - public: - UiGuiIndentServer(void); - ~UiGuiIndentServer(void); - - public slots: - void startServer(); - void stopServer(); - - private slots: - void handleNewConnection(); - void handleReceivedData(); - void sendMessage(const TQString &message); - void checkIfReadyForHandleRequest(); - - private: - TQTcpServer *_tcpServer; - TQByteArray _dataToSend; - bool _readyForHandleRequest; - TQTcpSocket *_currentClientConnection; - TQ_UINT32 _blockSize; -}; - -#endif // UIGUIINDENTSERVER_H diff --git a/src/main.cpp b/src/main.cpp index 826ddfe..5f58b69 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,6 @@ // -- #include "IndentHandler.h" #include "SettingsPaths.h" -// -- #include "UiGuiIndentServer.h" // -- #include "UiGuiIniFileParser.h" #include "UiGuiVersion.h" @@ -38,21 +37,10 @@ /*! /brief Entry point to UniversalIndentGUI application. - - Evaluates the following parameters: - No parameters starts without server and full gui. - A string without any parameter prefix will be loaded as file on start. - -p --plugin : Run as plugin. Server will be started with a simplified gui. - -s --server : Run as server only, without gui. - If -p and -s are set, -p will be used. - -v --verbose needs a following parameter defining the verbose level as a number from 0 to 3. */ int main(int argc, char *argv[]) { TQString file2OpenOnStart = ""; - int verboseLevel = 1; - bool startAsPlugin = false; - bool startAsServer = false; bool tclapExitExceptionThrown = false; int returnValue = 0; @@ -61,9 +49,7 @@ int main(int argc, char *argv[]) try { // Define the command line object. - TCLAP::CmdLine cmd("If -p and -s are set, -p will be used.\n" - "Giving no parameters starts full gui without server.", - ' ', PROGRAM_VERSION_STRING); + TCLAP::CmdLine cmd("Starts full gui", ' ', PROGRAM_VERSION_STRING); cmd.setExceptionHandling(false); // Define a value argument and add it to the command line. @@ -71,30 +57,11 @@ int main(int argc, char *argv[]) "Opens the by filename defined file on start" , false, "", "filename"); cmd.add(filenameArg); - // Define a switch and add it to the command line. - TCLAP::SwitchArg pluginSwitch("p", "plugin", - "Run as plugin. Server will be started with a simplified gui", false); - cmd.add(pluginSwitch); - - // Define a switch and add it to the command line. - TCLAP::SwitchArg serverSwitch("s", "server", - "Run as server only without gui", false); - cmd.add(serverSwitch); - - // Define a value argument and add it to the command line. - TCLAP::ValueArg<int> verboselevelArg("v", "verbose", - "Sets how many info is written to the log. 0 means with debug info, " - "3 means critical messages only" , false, 1, "int"); - cmd.add(verboselevelArg); - // Parse the args. cmd.parse(argc, argv); // Get the value parsed by each arg. file2OpenOnStart = filenameArg.getValue().c_str(); - startAsPlugin = pluginSwitch.getValue(); - startAsServer = serverSwitch.getValue(); - verboseLevel = verboselevelArg.getValue(); } catch (TCLAP::ArgException &e) { @@ -122,7 +89,6 @@ int main(int argc, char *argv[]) } TQApplication app(argc, argv); -// -- UiGuiIndentServer server; MainWindow *mainWindow = NULL; // -- IndentHandler *indentHandler = NULL; @@ -130,21 +96,8 @@ int main(int argc, char *argv[]) TQTextCodec::setCodecForCStrings(TQTextCodec::codecForName("UTF-8")); TQTextCodec::setCodecForLocale(TQTextCodec::codecForName("UTF-8")); - // Start normal with full gui and without server. - if (!startAsPlugin && !startAsServer) { - mainWindow = new MainWindow(file2OpenOnStart); - mainWindow->show(); - } -// -- // Start as plugin with server. -// -- else if (startAsPlugin) { -// -- server.startServer(); -// -- indentHandler = new IndentHandler(0); -// -- indentHandler->show(); -// -- } -// -- // Start as server only without any gui. -// -- else if (startAsServer) { -// -- server.startServer(); -// -- } + mainWindow = new MainWindow(file2OpenOnStart); + mainWindow->show(); try { @@ -155,10 +108,7 @@ int main(int argc, char *argv[]) { tqDebug(TQString() + __LINE__ + " " + __FUNCTION__ + ": Something went terribly wrong: " + ex.what()); } -// -- -// -- if (startAsPlugin || startAsServer) -// -- server.stopServer(); -// -- + // -- delete indentHandler; delete mainWindow; |