mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
do not block gui for dbus requests
This commit is contained in:
parent
82c3690dcb
commit
abbc5641cd
@ -28,12 +28,16 @@ option (BUILD_HELPER "Build helper" ON)
|
|||||||
option (BUILD_LIBRARY "Build library" ON)
|
option (BUILD_LIBRARY "Build library" ON)
|
||||||
option (BUILD_DATAENGINE "Build data engine" ON)
|
option (BUILD_DATAENGINE "Build data engine" ON)
|
||||||
option (BUILD_PLASMOID "Build plasmoid" ON)
|
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||||
|
option (BUILD_TEST "Build unit test for the library" OFF)
|
||||||
if (BUILD_GUI OR BUILD_HELPER)
|
if (BUILD_GUI OR BUILD_HELPER)
|
||||||
set (BUILD_LIBRARY ON)
|
set (BUILD_LIBRARY ON)
|
||||||
endif ()
|
endif ()
|
||||||
if (BUILD_PLASMOID)
|
if (BUILD_PLASMOID)
|
||||||
set (BUILD_DATAENGINE ON)
|
set (BUILD_DATAENGINE ON)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (BUILD_TEST)
|
||||||
|
set (BUILD_LIBRARY ON)
|
||||||
|
endif ()
|
||||||
# documentation
|
# documentation
|
||||||
option (BUILD_DOCS "Build documentation and install headers" ON)
|
option (BUILD_DOCS "Build documentation and install headers" ON)
|
||||||
if (BUILD_DOCS)
|
if (BUILD_DOCS)
|
||||||
@ -66,6 +70,9 @@ endif ()
|
|||||||
if (BUILD_HELPER)
|
if (BUILD_HELPER)
|
||||||
add_subdirectory (helper)
|
add_subdirectory (helper)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (BUILD_TEST)
|
||||||
|
add_subdirectory (test)
|
||||||
|
endif ()
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI)
|
||||||
add_subdirectory (gui)
|
add_subdirectory (gui)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -89,13 +89,13 @@ QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
|||||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||||
if (!args.isEmpty())
|
if (!args.isEmpty())
|
||||||
request.setArguments(args);
|
request.setArguments(args);
|
||||||
response = bus.call(request);
|
response = bus.call(request, QDBus::BlockWithGui);
|
||||||
} else {
|
} else {
|
||||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||||
if (!args.isEmpty())
|
if (!args.isEmpty())
|
||||||
request.setArguments(args);
|
request.setArguments(args);
|
||||||
response = bus.call(request);
|
response = bus.call(request, QDBus::BlockWithGui);
|
||||||
}
|
}
|
||||||
arguments = response.arguments();
|
arguments = response.arguments();
|
||||||
if (arguments.size() == 0)
|
if (arguments.size() == 0)
|
||||||
|
@ -628,7 +628,7 @@ QList<QVariant> Netctl::sendDBusRequest(const QString cmd, const QList<QVariant>
|
|||||||
DBUS_HELPER_INTERFACE, cmd);
|
DBUS_HELPER_INTERFACE, cmd);
|
||||||
if (!args.isEmpty())
|
if (!args.isEmpty())
|
||||||
request.setArguments(args);
|
request.setArguments(args);
|
||||||
QDBusMessage response = bus.call(request);
|
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||||
QList<QVariant> arguments = response.arguments();
|
QList<QVariant> arguments = response.arguments();
|
||||||
if (arguments.size() == 0)
|
if (arguments.size() == 0)
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||||
|
45
sources/test/CMakeLists.txt
Normal file
45
sources/test/CMakeLists.txt
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
enable_testing ()
|
||||||
|
|
||||||
|
# set project name
|
||||||
|
set (SUBPROJECT netctlgui-test)
|
||||||
|
message (STATUS "Subproject ${SUBPROJECT}")
|
||||||
|
|
||||||
|
# set directories
|
||||||
|
set (SUBPROJECT_BINARY_DIR bin)
|
||||||
|
|
||||||
|
# additional targets
|
||||||
|
set (TARGETS "")
|
||||||
|
set (HEADERS "")
|
||||||
|
|
||||||
|
# set files
|
||||||
|
file (GLOB SOURCES *.cpp)
|
||||||
|
file (GLOB HEADERS *.h)
|
||||||
|
|
||||||
|
# include_path
|
||||||
|
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||||
|
|
||||||
|
if (USE_QT5)
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
find_package(Qt5Test REQUIRED)
|
||||||
|
add_definitions(${Qt5Core_DEFINITIONS})
|
||||||
|
add_definitions(${Qt5Test_DEFINITIONS})
|
||||||
|
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS})
|
||||||
|
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5Test_LIBRARIES})
|
||||||
|
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||||
|
else ()
|
||||||
|
find_package (Qt4 COMPONENTS QtCore QtTest REQUIRED)
|
||||||
|
include (${QT_USE_FILE})
|
||||||
|
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
|
||||||
|
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable (${SUBPROJECT} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
|
||||||
|
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||||
|
# install properties
|
||||||
|
add_test (BaseTest ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT})
|
||||||
|
|
63
sources/test/testnetctl.cpp
Normal file
63
sources/test/testnetctl.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui 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, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "testnetctl.h"
|
||||||
|
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
|
||||||
|
void TestNetctl::test_getRecommendedConfiguration()
|
||||||
|
{
|
||||||
|
QStringList original;
|
||||||
|
// original.append(QString("CTRL_DIR==/run/wpa_supplicant_netctl-gui"));
|
||||||
|
// original.append(QString("CTRL_GROUP==network"));
|
||||||
|
original.append(QString("FORCE_SUDO==false"));
|
||||||
|
original.append(QString("IFACE_DIR==/sys/class/net"));
|
||||||
|
original.append(QString("NETCTLAUTO_PATH==/usr/bin/netctl-auto"));
|
||||||
|
original.append(QString("NETCTLAUTO_SERVICE==netctl-auto"));
|
||||||
|
original.append(QString("NETCTL_PATH==/usr/bin/netctl"));
|
||||||
|
// original.append(QString("PID_FILE==/run/wpa_supplicant_netctl-gui.pid"));
|
||||||
|
original.append(QString("PREFERED_IFACE==wifi0"));
|
||||||
|
original.append(QString("PROFILE_DIR==/etc/netctl"));
|
||||||
|
original.append(QString("SUDO_PATH==/usr/bin/sudo"));
|
||||||
|
original.append(QString("SYSTEMCTL_PATH==/usr/bin/systemctl"));
|
||||||
|
// original.append(QString("WPACLI_PATH==/usr/bin/wpa_cli"));
|
||||||
|
// original.append(QString("WPASUP_PATH==/usr/bin/wpa_supplicant"));
|
||||||
|
// original.append(QString("WPA_DRIVERS==nl80211,wext"));
|
||||||
|
QMap<QString, QString> resultMap = Netctl::getRecommendedConfiguration();
|
||||||
|
QStringList result;
|
||||||
|
for (int i=0; i<resultMap.keys().count(); i++)
|
||||||
|
result.append(resultMap.keys()[i] + QString("==") + resultMap[resultMap.keys()[i]]);
|
||||||
|
|
||||||
|
QCOMPARE(result, original);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestNetctl::test_getActiveProfile()
|
||||||
|
{
|
||||||
|
QMap<QString, QString> settings = Netctl::getRecommendedConfiguration();
|
||||||
|
settings[QString("FORCE_SUDO")] = QString("true");
|
||||||
|
Netctl *netctl = new Netctl(false, settings);
|
||||||
|
|
||||||
|
delete netctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTEST_MAIN(TestNetctl)
|
34
sources/test/testnetctl.h
Normal file
34
sources/test/testnetctl.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui 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, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TESTNETCTL_H
|
||||||
|
#define TESTNETCTL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
class TestNetctl : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void test_getRecommendedConfiguration();
|
||||||
|
void test_getActiveProfile();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TESTNETCTL_H */
|
Loading…
Reference in New Issue
Block a user