better submodules integration (hope =))

add --session support to the helper
This commit is contained in:
arcan1s 2014-08-27 17:23:12 +04:00
parent 0c7868536a
commit b909222db9
13 changed files with 68 additions and 24 deletions

12
.gitmodules vendored
View File

@ -1,12 +1,12 @@
[submodule "sources/3rdparty/task"]
path = sources/3rdparty/task
url = https://github.com/arcan1s/qtadds-task.git
[submodule "sources/3rdparty/tasks"]
path = sources/3rdparty/tasks
url = https://github.com/mhogomchungu/tasks.git
[submodule "sources/3rdparty/language"]
path = sources/3rdparty/language
url = https://github.com/arcan1s/qtadds-language.git
[submodule "sources/3rdparty/pdebug"]
path = sources/3rdparty/pdebug
url = https://github.com/arcan1s/qtadds-pdebug.git
[submodule "sources/3rdparty/language"]
path = sources/3rdparty/language
url = https://github.com/arcan1s/qtadds-language.git
[submodule "sources/3rdparty/task"]
path = sources/3rdparty/task
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>680</width>
<height>397</height>
<width>678</width>
<height>395</height>
</rect>
</property>
<property name="windowTitle">
@ -73,7 +73,7 @@
</property>
<property name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
<normaloff>:/icon-helper.png</normaloff>:/icon-helper.png</iconset>
</property>
</item>
<item>
@ -136,8 +136,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>336</height>
<width>462</width>
<height>330</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -218,8 +218,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>256</height>
<width>462</width>
<height>330</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@ -389,7 +389,7 @@
<x>0</x>
<y>0</y>
<width>436</width>
<height>165</height>
<height>173</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -576,7 +576,7 @@
<x>0</x>
<y>0</y>
<width>436</width>
<height>43</height>
<height>45</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@ -646,7 +646,7 @@
<x>0</x>
<y>0</y>
<width>277</width>
<height>190</height>
<height>194</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@ -843,7 +843,7 @@
<x>0</x>
<y>0</y>
<width>436</width>
<height>103</height>
<height>107</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">

View File

@ -25,6 +25,7 @@ _netctlgui_helper_arglist=(
'--nodaemon'
'--replace'
'--restore'
'--session'
'--system'
'-v'
'--version'

View File

@ -23,6 +23,8 @@ do not run as daemon
force replace the existing session
.IP "--restore"
force restore the existing session
.IP "--session"
force create user DBus session
.IP "--system"
do not read user configuration
.IP "-v, --version"

View File

@ -1,9 +1,12 @@
[Unit]
Description=netctlgui-helper daemon
Documentation=man:netctlgui-helper(1) man:netctl-gui.conf(5)
[Service]
Type=forking
ExecStart=/usr/bin/netctlgui-helper --system
Type=dbus
BusName=org.netctlgui.helper
ExecStart=/usr/bin/netctlgui-helper --nodaemon --system
Capabilities=CAP_SETUID
[Install]
WantedBy=multi-user.target

View File

@ -47,14 +47,14 @@ else ()
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations-header COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations-header COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
add_custom_target (translations-helper COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations-helper COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
endif()
add_executable (${SUBPROJECT} ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)
if (USE_CAPABILITIES)
install (CODE "exec_program (setcap ARGS \"cap_setuid=ep\" \"$ENV{DESTDIR}/bin/${SUBPROJECT}\")")
endif ()
# if (USE_CAPABILITIES)
# install (CODE "exec_program (setcap ARGS \"cap_setuid=ep\" \"$ENV{DESTDIR}/bin/${SUBPROJECT}\")")
# endif ()

View File

@ -68,6 +68,9 @@ int main(int argc, char *argv[])
} else if (QString(argv[i]) == QString("--restore")) {
// restore
args[QString("state")] = (int) 2;
} else if (QString(argv[i]) == QString("--session")) {
// session
args[QString("session")] = true;
} else if (QString(argv[i]) == QString("--system")) {
// system
args[QString("system")] = true;
@ -96,6 +99,7 @@ int main(int argc, char *argv[])
.arg(QString::number(geteuid())).toUtf8().data() << endl;
cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.")
.toUtf8().data() << endl;
args[QString("session")] = true;
}
#if QT_VERSION >= 0x050000

View File

@ -37,6 +37,7 @@ QMap<QString, QVariant> getArgs()
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf"));
args[QString("debug")] = false;
args[QString("nodaemon")] = false;
args[QString("session")] = false;
args[QString("state")] = (int) 0;
args[QString("system")] = false;
args[QString("help")] = false;
@ -65,6 +66,8 @@ QString helpMessage()
.arg(QCoreApplication::translate("NetctlHelper", "force replace the existing session"));
helpMessage += QString(" --restore - %1\n")
.arg(QCoreApplication::translate("NetctlHelper", "force restore the existing session"));
helpMessage += QString(" --session - %1\n")
.arg(QCoreApplication::translate("NetctlHelper", "force create user DBus session"));
helpMessage += QString(" --system - %1\n")
.arg(QCoreApplication::translate("NetctlHelper", "do not read user configuration, system-wide only"));
helpMessage += QString(" %1\n").arg(QCoreApplication::translate("NetctlHelper", "Show messages:"));

View File

@ -35,6 +35,7 @@ NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
: QObject(parent),
configPath(args[QString("config")].toString()),
debug(args[QString("debug")].toBool()),
session(args[QString("session")].toBool()),
system(args[QString("system")].toBool())
{
updateConfiguration();
@ -88,6 +89,28 @@ void NetctlHelper::createInterface()
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
return quitHelper();
}
// session bus
if (!session) return;
QDBusConnection sessionBus = QDBusConnection::sessionBus();
if (!sessionBus.registerService(DBUS_HELPER_SERVICE)) {
if (debug) qDebug() << PDEBUG << ":" << "Could not register session service";
if (debug) qDebug() << PDEBUG << ":" << sessionBus.lastError().message();
return quitHelper();
}
if (!sessionBus.registerObject(DBUS_LIB_PATH,
new NetctlAdaptor(this, debug, configuration),
QDBusConnection::ExportAllContents)) {
if (debug) qDebug() << PDEBUG << ":" << "Could not register session library object";
if (debug) qDebug() << PDEBUG << ":" << sessionBus.lastError().message();
return quitHelper();
}
if (!sessionBus.registerObject(DBUS_CTRL_PATH,
new ControlAdaptor(this, debug, configuration),
QDBusConnection::ExportAllContents)) {
if (debug) qDebug() << PDEBUG << ":" << "Could not register session control object";
if (debug) qDebug() << PDEBUG << ":" << sessionBus.lastError().message();
return quitHelper();
}
}
@ -98,6 +121,11 @@ void NetctlHelper::deleteInterface()
QDBusConnection::systemBus().unregisterObject(DBUS_LIB_PATH);
QDBusConnection::systemBus().unregisterObject(DBUS_CTRL_PATH);
QDBusConnection::systemBus().unregisterService(DBUS_HELPER_SERVICE);
// session bus
if (!session) return;
QDBusConnection::sessionBus().unregisterObject(DBUS_LIB_PATH);
QDBusConnection::sessionBus().unregisterObject(DBUS_CTRL_PATH);
QDBusConnection::sessionBus().unregisterService(DBUS_HELPER_SERVICE);
}

View File

@ -41,6 +41,7 @@ private:
QString configPath;
QMap<QString, QString> configuration;
bool debug;
bool session;
bool system;
void createInterface();
void deleteInterface();

View File

@ -24,6 +24,7 @@ _netctlgui_helper_arglist=(
{'--nodaemon','--nodaemon'}'[do not start as daemon]'
{'--replace','--replace'}'[force replace the existing session]'
{'--restore','--restore'}'[force restore the existing session]'
{'--session','--session'}'[force create user DBus session]'
{'--system','--system'}'[do not read user configuration]'
{'(--version)-v','(-v)--version'}'[show version and exit]'
{'(--info)-i','(-i)--info'}'[show build information and exit]'

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -5,6 +5,7 @@
<file>translations/ru.qm</file>
<!-- icons -->
<file>icon.png</file>
<file>icon-helper.png</file>
<file>wifi.png</file>
<file>network-idle-64x64.png</file>
<file>network-offline-64x64.png</file>