Skip to content

Commit

Permalink
-Add initial version of SEGSAdmin script editor, allowing editing of
Browse files Browse the repository at this point in the history
MOTD.smlx and Tutorial.smlx
-Incorporating @nemerles AdminRPC changes
-Add two more test methods to AdminRPC. helloServer and getVersion.
  • Loading branch information
miles200 committed Oct 20, 2018
1 parent 7977493 commit aed31c8
Show file tree
Hide file tree
Showing 29 changed files with 1,498 additions and 19 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: generic # prevent travis from overriding provided compilers.
cache:
ccache: true # includes $HOME/.ccache and adds /usr/lib/ccache to $PATH
directories:
- 3rd_party
- $HOME/.ccache
dist: trusty

notifications:
Expand Down Expand Up @@ -86,7 +85,7 @@ install:
# fi
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
sudo apt-get install -qq qt59base qt59declarative qt59quickcontrols2; source /opt/qt59/bin/qt59-env.sh;
sudo apt-get install -qq qt59base qt59declarative qt59websockets qt59quickcontrols2; source /opt/qt59/bin/qt59-env.sh;
CMAKE_OPTS="";
else
brew install cppcheck qt;
Expand Down
1 change: 1 addition & 0 deletions 3rd_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ if(ENABLE_SCRIPTING_ENGINE)
include(ExternalProject_LUA.cmake)
include(ExternalProject_SOL2.cmake)
endif()
include(ExternalProject_JCON.cmake)

21 changes: 21 additions & 0 deletions 3rd_party/ExternalProject_JCON.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
libname(jcon jcon)
find_package(Qt5 COMPONENTS Network WebSockets Test REQUIRED)

ExternalProject_Add(
jcon_BUILD
URL ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jcon-cpp
UPDATE_COMMAND ""
INSTALL_DIR ${ThirdParty_Install_Dir}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_STAGING_PREFIX:PATH=${ThirdParty_Install_Dir} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
BUILD_BYPRODUCTS ${jcon_LIBRARY_STATIC}
)
add_library(jcon_IMP STATIC IMPORTED GLOBAL)
add_dependencies(jcon_IMP jcon_BUILD)
#TODO: cmake workaround
file(MAKE_DIRECTORY ${ThirdParty_Install_Dir}/include)
set_property(TARGET jcon_IMP PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ThirdParty_Install_Dir}/include)
SET_PROPERTY(TARGET jcon_IMP APPEND PROPERTY IMPORTED_LOCATION ${jcon_LIBRARY_STATIC} )
set_property(TARGET jcon_IMP APPEND PROPERTY INTERFACE_LINK_LIBRARIES Qt5::Network Qt5::WebSockets Qt5::Test)
12 changes: 7 additions & 5 deletions 3rd_party/jcon-cpp/src/jcon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ set(CMAKE_PREFIX_PATH ${QTDIR})
file(GLOB ${PROJECT_NAME}_headers *.h)
file(GLOB ${PROJECT_NAME}_sources *.cpp)

add_definitions(-DJCON_DLL)
#add_definitions(-DJCON_DLL)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources})
add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_headers} ${${PROJECT_NAME}_sources})
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${${PROJECT_NAME}_headers}")

find_package(Qt5 COMPONENTS Core)
qt5_use_modules(${PROJECT_NAME} Core Network Test WebSockets Widgets)

qt5_use_modules(${PROJECT_NAME} Core Network Test WebSockets)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static)
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/jcon
)
6 changes: 3 additions & 3 deletions 3rd_party/jcon-cpp/src/jcon/jcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <QtGlobal>

#ifndef JCON_DLL
#define JCON_DLL
#endif
//#ifndef JCON_DLL
//#define JCON_DLL
//#endif

// Use the generic helper definitions above to define JCON_API, which is used
// for the public API symbols. It either DLL imports or DLL exports (or does
Expand Down
3 changes: 2 additions & 1 deletion 3rd_party/jcon-cpp/src/jcon/json_rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "jcon_assert.h"
#include "string_util.h"

#include <QSignalSpy>
//#include <QSignalSpy>
#include <QCoreApplication>
#include <QUuid>

#include <memory>
Expand Down
43 changes: 43 additions & 0 deletions Projects/CoX/Servers/AuthServer/AdminRPC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "AdminRPC.h"
#include "jcon/json_rpc_server.h"
#include "jcon/json_rpc_websocket_server.h"

#include "AuthHandler.h"
#include "version.h"

#include <QVariant>
#include <QJsonDocument>

using namespace jcon;
AdminRPC::AdminRPC()
{
}

bool AdminRPC::heyServer()
{
qDebug() << "Someone said hello !";
return true;
}

QString AdminRPC::helloServer()
{
QString response = "Hello Web Browser!";
return response;
}

QString AdminRPC::getVersion()
{
QString version = VersionInfo::getAuthVersionNumber() + QString(" ") + VersionInfo::getVersionName();
return version;
}

void startWebSocketServer(const char *addr, int port)
{
static jcon::JsonRpcWebSocketServer *m_server;
if(!m_server)
{
m_server = new JsonRpcWebSocketServer();
}
m_server->registerServices({ new AdminRPC() });
m_server->listen(QHostAddress(addr),port);
}
20 changes: 20 additions & 0 deletions Projects/CoX/Servers/AuthServer/AdminRPC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <QObject>
#include <QVariant>

class AdminRPC : public QObject
{
Q_OBJECT
friend void startWebSocketServer(const char *addr,int port);
class AuthHandler *m_auth_handler;
private:
AdminRPC(); // restrict construction to startWebSocketServer
public:

Q_INVOKABLE bool heyServer();
Q_INVOKABLE QString helloServer();
Q_INVOKABLE QString getVersion();
};

void startWebSocketServer(const char *addr="127.0.0.1",int port=6001);
7 changes: 7 additions & 0 deletions Projects/CoX/Servers/AuthServer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ ${CMAKE_CURRENT_SOURCE_DIR}/AuthHandler.h
${CMAKE_CURRENT_SOURCE_DIR}/AuthServer.h
)
SET (authserver_standaloneSRCS
${CMAKE_CURRENT_SOURCE_DIR}/AdminRPC.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AdminRPC.h
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)

SET(target_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
SET(target_DEPENDS "")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

INCLUDE_DIRECTORIES(${target_INCLUDE_DIR})
SET (target_SOURCES
Expand Down Expand Up @@ -38,6 +44,7 @@ IF(BUILD_SEPARATE)
mapserver_lib
Threads::Threads
ace_IMP
jcon_IMP
${CMAKE_DL_LIBS}
)
ADD_DEPENDENCIES(authserver ${target_DEPENDS} authserver_lib)
Expand Down
4 changes: 4 additions & 0 deletions Projects/CoX/Servers/AuthServer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Servers/GameServer/GameServer.h"
#include "Servers/GameDatabase/GameDBSync.h"
#include "Servers/AuthDatabase/AuthDBSync.h"
#include "AdminRPC.h"
//////////////////////////////////////////////////////////////////////////

#include <ace/ACE.h>
Expand Down Expand Up @@ -285,6 +286,9 @@ ACE_INT32 ACE_TMAIN (int argc, ACE_TCHAR *argv[])

qInfo().noquote() << "main";

// Create websocket jsonrpc admin interface
startWebSocketServer();

bool no_err = CreateServers();
if(!no_err)
{
Expand Down
8 changes: 8 additions & 0 deletions Projects/CoX/Utilities/SEGSAdmin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ set(SEGSADMIN_SOURCES
AboutDialog.cpp
AboutDialog.h
AboutDialog.ui
TextEdit.cpp
TextEdit.h
SelectScriptDialog.cpp
SelectScriptDialog.h
SelectScriptDialog.ui
SyntaxHighlighter.cpp
SyntaxHighlighter.h


)
add_executable(SEGSAdmin WIN32 ${SEGSADMIN_SOURCES})
Expand Down
1 change: 1 addition & 0 deletions Projects/CoX/Utilities/SEGSAdmin/Resources/bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Projects/CoX/Utilities/SEGSAdmin/Resources/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Projects/CoX/Utilities/SEGSAdmin/Resources/italic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Projects/CoX/Utilities/SEGSAdmin/Resources/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Projects/CoX/Utilities/SEGSAdmin/Resources/terminal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions Projects/CoX/Utilities/SEGSAdmin/SEGSAdminTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "NetworkManager.h"
#include "UpdateDetailDialog.h"
#include "AboutDialog.h"
#include "SelectScriptDialog.h"
#include "version.h"
#include <QDebug>
#include <QtGlobal>
Expand Down Expand Up @@ -52,12 +53,13 @@ SEGSAdminTool::SEGSAdminTool(QWidget *parent) :
m_network_manager = new NetworkManager();
m_update_dialog = new UpdateDetailDialog(this);
m_about_dialog = new AboutDialog(this);
m_script_dialog = new SelectScriptDialog(this);

// SEGSAdminTool Signals
connect(this,&SEGSAdminTool::checkForDB,this,&SEGSAdminTool::check_db_exist);
connect(this,&SEGSAdminTool::addAdminUser,m_add_user_dialog,&AddNewUserDialog::on_add_admin_user);
connect(this,&SEGSAdminTool::checkForConfigFile,this,&SEGSAdminTool::check_for_config_file);
connect(this,&SEGSAdminTool::getMapsDirConfigCheck,m_settings_dialog,&SettingsDialog::send_maps_dir_config_check);
connect(this,&SEGSAdminTool::getMapsDirConfigCheck,m_settings_dialog,&SettingsDialog::send_maps_dir_config_check); // May be a much better way to do this, but this works for now
connect(this,&SEGSAdminTool::readyToRead,m_settings_dialog,&SettingsDialog::read_config_file);
connect(ui->actionAbout,&QAction::triggered,m_about_dialog,&AboutDialog::show_ui);
connect(ui->update_detail,&QPushButton::clicked,m_update_dialog,&UpdateDetailDialog::show_update);
Expand All @@ -67,6 +69,7 @@ SEGSAdminTool::SEGSAdminTool(QWidget *parent) :
connect(ui->settings_button,&QPushButton::clicked,m_settings_dialog,&SettingsDialog::open_settings_dialog);
connect(ui->gen_config_file,&QPushButton::clicked,m_generate_config_dialog,&GenerateConfigFileDialog::on_generate_config_file);
connect(ui->authserver_start,&QPushButton::clicked,this,&SEGSAdminTool::is_server_running);
connect(ui->motd_editor,&QPushButton::clicked,m_script_dialog,&SelectScriptDialog::show_dialog);

// GenerateConfigFileDialog Signals
connect(m_generate_config_dialog,&GenerateConfigFileDialog::sendInputConfigFile,m_settings_dialog,&SettingsDialog::generate_default_config_file);
Expand Down Expand Up @@ -436,6 +439,7 @@ void SEGSAdminTool::check_for_config_file() // Does this on application start

void SEGSAdminTool::read_release_info(const QString &error)
{
ui->output->appendPlainText("Checking for Updates...");
QString version_number = VersionInfo::getAuthVersionNumber();
version_number.prepend("v");
if (!g_segs_release_info.isEmpty())
Expand All @@ -444,13 +448,15 @@ void SEGSAdminTool::read_release_info(const QString &error)
if (g_segs_release_info[0].tag_name == version_number)
{

qDebug()<<"CURRENT VERSION";
qDebug()<<"Current Version";
ui->output->appendPlainText("No updates available");
ui->update_detail->setText("Up to date");
ui->update_detail->setStyleSheet("color: rgb(0, 200, 0)");
}
else
{
qDebug()<<"NEW VERSION";
qDebug()<<"New Version Available";
ui->output->appendPlainText("New Update Found!");
ui->update_detail->setEnabled(true);
ui->update_detail->setStyleSheet("color: rgb(204, 0, 0)");
ui->update_detail->setText("Update available!");
Expand Down
1 change: 1 addition & 0 deletions Projects/CoX/Utilities/SEGSAdmin/SEGSAdminTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SEGSAdminTool : public QMainWindow
class NetworkManager *m_network_manager;
class UpdateDetailDialog *m_update_dialog;
class AboutDialog *m_about_dialog;
class SelectScriptDialog *m_script_dialog;
bool m_server_running = false;

public:
Expand Down
61 changes: 57 additions & 4 deletions Projects/CoX/Utilities/SEGSAdmin/SEGSAdminTool.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1041</width>
<height>595</height>
<height>632</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -593,8 +593,8 @@
</property>
<property name="maximumSize">
<size>
<width>226</width>
<height>73</height>
<width>500</width>
<height>500</height>
</size>
</property>
<property name="font">
Expand All @@ -605,7 +605,7 @@
<property name="title">
<string>Server Configuration</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QPushButton" name="settings_button">
<property name="minimumSize">
Expand Down Expand Up @@ -659,6 +659,59 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="motd_editor">
<property name="minimumSize">
<size>
<width>167</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>167</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Edit scripts&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string> Script Editor</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/Resources/edit.svg</normaloff>:/icons/Resources/edit.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>26</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down
Loading

0 comments on commit aed31c8

Please sign in to comment.