mirror of
				https://github.com/arcan1s/netctl-gui.git
				synced 2025-10-27 03:43:42 +00:00 
			
		
		
		
	better submodules integration (hope =))
add --session support to the helper
This commit is contained in:
		| @ -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"> | ||||
|  | ||||
| @ -25,6 +25,7 @@ _netctlgui_helper_arglist=( | ||||
|     '--nodaemon' | ||||
|     '--replace' | ||||
|     '--restore' | ||||
|     '--session' | ||||
|     '--system' | ||||
|     '-v' | ||||
|     '--version' | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 () | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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:")); | ||||
|  | ||||
| @ -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); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -41,6 +41,7 @@ private: | ||||
|     QString configPath; | ||||
|     QMap<QString, QString> configuration; | ||||
|     bool debug; | ||||
|     bool session; | ||||
|     bool system; | ||||
|     void createInterface(); | ||||
|     void deleteInterface(); | ||||
|  | ||||
| @ -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]' | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								sources/resources/icon-helper.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								sources/resources/icon-helper.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 12 KiB | 
| @ -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> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user