From 2d49c44c47015d4ccd5aa08b4fe8a2401a513c3c Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 6 Sep 2024 10:37:24 +0900 Subject: [PATCH] Remove incomplete and useless server code Signed-off-by: Michele Calgaro --- readme.html | 46 -------- src/__TODO/UiGuiIndentServer.cpp | 175 ------------------------------- src/__TODO/UiGuiIndentServer.h | 55 ---------- src/main.cpp | 58 +--------- 4 files changed, 4 insertions(+), 330 deletions(-) delete mode 100644 src/__TODO/UiGuiIndentServer.cpp delete mode 100644 src/__TODO/UiGuiIndentServer.h diff --git a/readme.html b/readme.html index f1dca4e..7670e5a 100755 --- a/readme.html +++ b/readme.html @@ -130,12 +130,6 @@ a.external
  • A nice about dialog. Errrmm, ok beneath all the mean stuff this is somehow the programmers playground ;-)
  • -

    - Also a Notepad++ plugin version is available. - The programming project for that is currently only available as Visual Studio C++ 2005 project file. - Also this plugin has some problems with its event handling, because it is running as a DLL inside of Notepad++ event loop. - This will be replaced with the upcoming UiGUI server functionality. See future plans for more about that. -

    Supported and tested platforms

    @@ -189,46 +183,6 @@ a.external and XCode are included.

    -

    Used TQt techniques

    -

    This list shows some selected functionalities that TQt offers and that I use with UiGUI.

    - - -

    Future plans

    - -

    Thanks

    Here I'd like to say "thank you" to all those guys, who helped me improving UiGUI. May it be doing some translations, creating packages for Linux, letting me know about bugs or ways to improve or just saying 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 -#include -#include -#include - -// \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(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 - -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 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;