diff --git a/src/app/models/connectionsmanager.cpp b/src/app/models/connectionsmanager.cpp index 9782fd6d..f20ff22a 100644 --- a/src/app/models/connectionsmanager.cpp +++ b/src/app/models/connectionsmanager.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "modules/connections-tree/items/serveritem.h" #include "modules/redisclient/connectionconfig.h" #include "modules/value-editor/viewmodel.h" @@ -34,6 +35,17 @@ void ConnectionsManager::addNewConnection(const RedisClient::ConnectionConfig &c //add connection to internal container m_connections.push_back(connection); + //set logger + QObject::connect(connection.data(), &RedisClient::Connection::log, this, [this](const QString& info){ + QString msg = QString("Connection: %1").arg(info); + LOG(INFO) << msg.toStdString(); + }); + + QObject::connect(connection.data(), &RedisClient::Connection::error, this, [this](const QString& error){ + QString msg = QString("Connection: %1").arg(error); + LOG(ERROR) << msg.toStdString(); + }); + //add connection to view container using namespace ConnectionsTree; diff --git a/src/main.cpp b/src/main.cpp index 3ce18f0b..ce0cd249 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,9 @@ #include #include +#ifndef RDM_VERSION #include "version.h" +#endif #include "modules/crashhandler/crashhandler.h" #include "app/dialogs/mainwindow.h" diff --git a/src/modules/console/logtab.h b/src/modules/console/logtab.h index fadfdbcc..4b8cc705 100644 --- a/src/modules/console/logtab.h +++ b/src/modules/console/logtab.h @@ -39,10 +39,9 @@ public: void handle(const el::LogDispatchData* data) { if (m_tab) - m_tab.toStrongRef()->print(QString("%1 : %2 (%3)") + m_tab.toStrongRef()->print(QString("%1 : %2") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) - .arg(QString::fromStdString(data->logMessage()->message())) - .arg(QString::fromStdString(data->logMessage()->func())) + .arg(QString::fromStdString(data->logMessage()->message())) ); } private: diff --git a/src/modules/redisclient/connection.cpp b/src/modules/redisclient/connection.cpp index 28a7bef6..04eb0971 100644 --- a/src/modules/redisclient/connection.cpp +++ b/src/modules/redisclient/connection.cpp @@ -216,7 +216,7 @@ void RedisClient::Connection::commandAddedToTransporter() void RedisClient::Connection::auth() { // todo: check is socket succesufully connected before run this method - m_connected = true; + m_connected = true; if (config.useAuth()) { Command authCmd(QStringList() << "auth" << config.auth()); @@ -232,8 +232,10 @@ void RedisClient::Connection::auth() m_serverInfo = ServerInfo::fromString(infoResult.getValue().toString()); setConnectedState(); + emit log("AUTH OK"); emit authOk(); } else { + emit error("AUTH ERROR"); emit authError("Redis server require password or password invalid"); m_connected = false; } diff --git a/src/rdm.pro b/src/rdm.pro index 40c457fb..80917bdd 100644 --- a/src/rdm.pro +++ b/src/rdm.pro @@ -1,136 +1,137 @@ -#------------------------------------------------- -# -# Redis Desktop Manager -# -#------------------------------------------------- - -QT += core gui network xml concurrent widgets quick quickwidgets - -TARGET = rdm -TEMPLATE = app - -# Skip version file -!exists( $$PWD/version.h ) { - write_file( $$PWD/version.h ) - DEFINES += RDM_VERSION=\\\"0.8.0.0\\\" -} - -SOURCES += \ - $$PWD/main.cpp \ - $$PWD/app/dialogs/*.cpp \ - $$PWD/app/models/*.cpp \ - $$PWD/app/models/key-models/*.cpp \ - $$PWD/app/widgets/*.cpp \ - $$PWD/modules/connections-tree/*.cpp \ - $$PWD/modules/connections-tree/items/*.cpp \ - $$PWD/modules/console/*.cpp \ - $$PWD/modules/value-editor/*.cpp \ - $$PWD/modules/redisclient/*.cpp \ - $$PWD/modules/redisclient/ssh/*.cpp \ - $$PWD/modules/redisclient/transporters/*.cpp \ - $$PWD/modules/crashhandler/*.cpp \ - $$PWD/modules/updater/*.cpp \ - -HEADERS += \ - $$PWD/version.h \ - $$PWD/app/dialogs/*.h \ - $$PWD/app/models/*.h \ - $$PWD/app/models/key-models/*.h \ - $$PWD/app/widgets/*.h \ - $$PWD/modules/connections-tree/*.h \ - $$PWD/modules/connections-tree/items/*.h \ - $$PWD/modules/console/*.h \ - $$PWD/modules/value-editor/*.h \ - $$PWD/modules/redisclient/*.h \ - $$PWD/modules/redisclient/ssh/*.h \ - $$PWD/modules/redisclient/transporters/*.h \ - $$PWD/modules/crashhandler/*.h \ - $$PWD/modules/updater/*.h \ - $$PWD/modules/*.h \ - - - -FORMS += \ - $$PWD/app/forms/*.ui \ - -THIRDPARTYDIR = $$PWD/../3rdparty/ - -include($$THIRDPARTYDIR/3rdparty.pri) - -#win32-msvc* { -win32 { - CONFIG += c++11 - LIBS += -lws2_32 -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 - RC_FILE += $$PWD/resources/rdm.rc - - release: DESTDIR = ./../bin/windows/release - debug: DESTDIR = ./../bin/windows/debug -} - -unix:macx { # OSX - CONFIG += c++11 #release - #CONFIG -= debug - - debug { - CONFIG-=app_bundle - } - - release: DESTDIR = ./../bin/linux/release - debug: DESTDIR = ./../bin/linux/debug - - #deployment - QMAKE_INFO_PLIST = $$PWD/resources/Info.plist - ICON = $$PWD/resources/rdm.icns - - release { - CRASHREPORTER_APP.files = $$DESTDIR/crashreporter - CRASHREPORTER_APP.path = Contents/MacOS - QMAKE_BUNDLE_DATA += CRASHREPORTER_APP - } -} - -unix:!macx { # ubuntu & debian - - CONFIG += static release - CONFIG -= debug - - #Qt static linked on Ubuntu/Debian - QMAKE_LFLAGS += -static-libgcc -static-libstdc++ - - release: DESTDIR = ./../bin/linux/release - debug: DESTDIR = ./../bin/linux/debug - - - #deployment - target.path = /usr/share/redis-desktop-manager/bin - target.files = $$DESTDIR/rdm $$DESTDIR/crashreporter $$PWD/resources/qt.conf $$PWD/resources/rdm.png $$PWD/resources/rdm.sh - INSTALLS += target - - data.path = /usr/share/redis-desktop-manager/lib - data.files = $$PWD/lib/* - INSTALLS += data - - deskicon.path = /usr/share/applications - deskicon.files = $$PWD/resources/rdm.desktop - INSTALLS += deskicon -} - -UI_DIR = $$DESTDIR/ui -OBJECTS_DIR = $$DESTDIR/obj -MOC_DIR = $$DESTDIR/obj -RCC_DIR = $$DESTDIR/obj - -INCLUDEPATH += $$PWD/ \ - $$PWD/modules/ \ - $$UI_DIR/ \ - -RESOURCES += \ - $$PWD/resources/rdm.qrc \ - $$PWD/resources/fonts.qrc \ - -OTHER_FILES += \ - qt.conf \ - Info.plist \ - qml\*.qml \ - - +#------------------------------------------------- +# +# Redis Desktop Manager +# +#------------------------------------------------- + +QT += core gui network xml concurrent widgets quick quickwidgets + +TARGET = rdm +TEMPLATE = app + +# Skip version file +!exists( $$PWD/version.h ) { + DEFINES += RDM_VERSION=\\\"0.8.0.0\\\" +} + +DEFINES += ELPP_QT_LOGGING ELPP_STL_LOGGING + +SOURCES += \ + $$PWD/main.cpp \ + $$PWD/app/dialogs/*.cpp \ + $$PWD/app/models/*.cpp \ + $$PWD/app/models/key-models/*.cpp \ + $$PWD/app/widgets/*.cpp \ + $$PWD/modules/connections-tree/*.cpp \ + $$PWD/modules/connections-tree/items/*.cpp \ + $$PWD/modules/console/*.cpp \ + $$PWD/modules/value-editor/*.cpp \ + $$PWD/modules/redisclient/*.cpp \ + $$PWD/modules/redisclient/ssh/*.cpp \ + $$PWD/modules/redisclient/transporters/*.cpp \ + $$PWD/modules/crashhandler/*.cpp \ + $$PWD/modules/updater/*.cpp \ + +HEADERS += \ + $$PWD/version.h \ + $$PWD/app/dialogs/*.h \ + $$PWD/app/models/*.h \ + $$PWD/app/models/key-models/*.h \ + $$PWD/app/widgets/*.h \ + $$PWD/modules/connections-tree/*.h \ + $$PWD/modules/connections-tree/items/*.h \ + $$PWD/modules/console/*.h \ + $$PWD/modules/value-editor/*.h \ + $$PWD/modules/redisclient/*.h \ + $$PWD/modules/redisclient/ssh/*.h \ + $$PWD/modules/redisclient/transporters/*.h \ + $$PWD/modules/crashhandler/*.h \ + $$PWD/modules/updater/*.h \ + $$PWD/modules/*.h \ + + + +FORMS += \ + $$PWD/app/forms/*.ui \ + +THIRDPARTYDIR = $$PWD/../3rdparty/ + +include($$THIRDPARTYDIR/3rdparty.pri) + +#win32-msvc* { +win32 { + CONFIG += c++11 + LIBS += -lws2_32 -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 + RC_FILE += $$PWD/resources/rdm.rc + + release: DESTDIR = ./../bin/windows/release + debug: DESTDIR = ./../bin/windows/debug +} + +unix:macx { # OSX + CONFIG += c++11 #release + #CONFIG -= debug + + debug { + CONFIG-=app_bundle + } + + release: DESTDIR = ./../bin/linux/release + debug: DESTDIR = ./../bin/linux/debug + + #deployment + QMAKE_INFO_PLIST = $$PWD/resources/Info.plist + ICON = $$PWD/resources/rdm.icns + + release { + CRASHREPORTER_APP.files = $$DESTDIR/crashreporter + CRASHREPORTER_APP.path = Contents/MacOS + QMAKE_BUNDLE_DATA += CRASHREPORTER_APP + } +} + +unix:!macx { # ubuntu & debian + + CONFIG += static release + CONFIG -= debug + + #Qt static linked on Ubuntu/Debian + QMAKE_LFLAGS += -static-libgcc -static-libstdc++ + + release: DESTDIR = ./../bin/linux/release + debug: DESTDIR = ./../bin/linux/debug + + + #deployment + target.path = /usr/share/redis-desktop-manager/bin + target.files = $$DESTDIR/rdm $$DESTDIR/crashreporter $$PWD/resources/qt.conf $$PWD/resources/rdm.png $$PWD/resources/rdm.sh + INSTALLS += target + + data.path = /usr/share/redis-desktop-manager/lib + data.files = $$PWD/lib/* + INSTALLS += data + + deskicon.path = /usr/share/applications + deskicon.files = $$PWD/resources/rdm.desktop + INSTALLS += deskicon +} + +UI_DIR = $$DESTDIR/ui +OBJECTS_DIR = $$DESTDIR/obj +MOC_DIR = $$DESTDIR/obj +RCC_DIR = $$DESTDIR/obj + +INCLUDEPATH += $$PWD/ \ + $$PWD/modules/ \ + $$UI_DIR/ \ + +RESOURCES += \ + $$PWD/resources/rdm.qrc \ + $$PWD/resources/fonts.qrc \ + +OTHER_FILES += \ + qt.conf \ + Info.plist \ + qml\*.qml \ + + diff --git a/tests/unit_tests/testcases/redisclient/test_connection.cpp b/tests/unit_tests/testcases/redisclient/test_connection.cpp index b61519ec..20ae96d3 100644 --- a/tests/unit_tests/testcases/redisclient/test_connection.cpp +++ b/tests/unit_tests/testcases/redisclient/test_connection.cpp @@ -103,7 +103,7 @@ void TestConnection::testRetriveCollection() QCOMPARE(result.canConvert(QMetaType::QVariantList), true); callbackCalled = true; }); - wait(10000); + wait(2000); //then - part 2 QCOMPARE(callbackCalled, true);