Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:rguenther:plgrnd
vncmanager-controller
vncmanager-controller-1.0.2.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File vncmanager-controller-1.0.2.obscpio of Package vncmanager-controller
07070100000000000081A400000000000000000000000164EC8EB100000007000000000000000000000000000000000000002700000000vncmanager-controller-1.0.2/.gitignorebuild/ 07070100000001000081A400000000000000000000000164EC8EB100000498000000000000000000000000000000000000002B00000000vncmanager-controller-1.0.2/CMakeLists.txtcmake_minimum_required(VERSION 2.8.11) project(vncmanager-controller) include(GNUInstallDirs) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Widgets REQUIRED) find_package(Qt5Network REQUIRED) find_package(Qt5X11Extras REQUIRED) add_definitions(-std=c++11) include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) set(vncmanager-controller_SRCS ConfigWindow.cpp StdinConnection.cpp VncConfiguration.cpp ManagerConnection.cpp main.cpp) set(vncmanager-controller_FORMS ConfigWindow.ui) qt5_wrap_ui(vncmanager-controller_FORMS_HEADERS ${vncmanager-controller_FORMS}) add_executable(vncmanager-controller ${vncmanager-controller_SRCS} ${vncmanager-controller_FORMS_HEADERS}) target_link_libraries(vncmanager-controller Qt5::Widgets Qt5::Network Qt5::X11Extras X11 Xvnc) install(TARGETS vncmanager-controller RUNTIME DESTINATION bin) install(FILES vncmanager-controller.desktop DESTINATION /${CMAKE_INSTALL_SYSCONFDIR}/xdg/autostart) install(FILES gnome-shell-extension/extension.js gnome-shell-extension/metadata.json DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gnome-shell/extensions/vncmanager-controller@vncmanager.michalsrb.github.com) 07070100000002000081A400000000000000000000000164EC8EB100000EFE000000000000000000000000000000000000002D00000000vncmanager-controller-1.0.2/ConfigWindow.cpp#include "ConfigWindow.h" #include <QtWidgets/QLabel> #include <QtWidgets/QMenu> #include <QtWidgets/QMenuBar> #include <QtWidgets/QAction> #include <QtGui/QShowEvent> ConfigWindow::ConfigWindow(VncConfiguration &data, bool dontClose) : m_data(data) , m_dontClose(dontClose) { ui.setupUi(this); // Disabled for now: ui.chkSecurityVncAuth->setVisible(false); ui.widgetVncAuth->setVisible(false); // Not supposed to be visible: ui.chkSecurityUnknown->setVisible(false); ui.chkSharingUnknown->setVisible(false); adjustSize(); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonBarClicked(QAbstractButton *))); } ConfigWindow::~ConfigWindow() {} void ConfigWindow::showEvent(QShowEvent *event) { QWidget::showEvent(event); m_data.read(); ui.editSessionName->setText(m_data.getSessionName()); ui.chkPersistencePersistent->setChecked(m_data.getPersistence() == VncConfiguration::Persistence::Persistent); ui.chkPersistenceNonPersistent->setChecked(m_data.getPersistence() == VncConfiguration::Persistence::NonPersistent); ui.chkSecurityUnknown->setChecked(m_data.getSecurity() == VncConfiguration::Security::Unknown); ui.chkSecurityNone-> setChecked(m_data.getSecurity() == VncConfiguration::Security::None); ui.chkSecurityVncAuth->setChecked(m_data.getSecurity() == VncConfiguration::Security::VncAuth); ui.chkSecurityPlain-> setChecked(m_data.getSecurity() == VncConfiguration::Security::Plain); ui.chkSharingUnknown-> setChecked(m_data.getSharing() == VncConfiguration::Sharing::Unknown); ui.chkSharingOneClient-> setChecked(m_data.getSharing() == VncConfiguration::Sharing::OneClient); ui.chkSharingMultipleClients->setChecked(m_data.getSharing() == VncConfiguration::Sharing::MultipleClients); ui.editAllowedUsers->setText(m_data.getPlainUsers().join(",")); } void ConfigWindow::closeEvent(QCloseEvent *event) { if (m_dontClose) { event->ignore(); hide(); } else { event->accept(); } } void ConfigWindow::apply() { m_data.setSessionName(ui.editSessionName->text()); if (ui.chkPersistencePersistent->isChecked()) { m_data.setPersistence(VncConfiguration::Persistence::Persistent); } else if (ui.chkPersistenceNonPersistent->isChecked()) { m_data.setPersistence(VncConfiguration::Persistence::NonPersistent); } if (ui.chkSecurityNone->isChecked()) { m_data.setSecurityNone(); } else if (ui.chkSecurityVncAuth->isChecked()) { m_data.setSecurityVncAuth(ui.editPassword->text(), ui.editViewonlyPassword->text()); } else if (ui.chkSecurityPlain->isChecked()) { m_data.setSecurityPlain(ui.editAllowedUsers->text().split(',')); } if (ui.chkSharingOneClient->isChecked()) { m_data.setSharing(VncConfiguration::Sharing::OneClient); } else if (ui.chkSharingMultipleClients->isChecked()) { m_data.setSharing(VncConfiguration::Sharing::MultipleClients); } m_data.apply(); } void ConfigWindow::done() { if (m_dontClose) { hide(); } else { close(); } } void ConfigWindow::buttonBarClicked(QAbstractButton *button) { switch (ui.buttonBox->buttonRole(button)) { case QDialogButtonBox::AcceptRole: apply(); done(); break; case QDialogButtonBox::ApplyRole: apply(); break; case QDialogButtonBox::RejectRole: done(); break; } } void ConfigWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: toggleVisible(); break; } } void ConfigWindow::toggleVisible() { if (isVisible()) { done(); } else { show(); } } #include "ConfigWindow.moc" 07070100000003000081A400000000000000000000000164EC8EB1000002FC000000000000000000000000000000000000002B00000000vncmanager-controller-1.0.2/ConfigWindow.h#ifndef CONFIGURATION_H #define CONFIGURATION_H #include <QtWidgets/QMainWindow> #include <QtWidgets/QSystemTrayIcon> #include "VncConfiguration.h" #include "ui_ConfigWindow.h" class ConfigWindow : public QMainWindow { Q_OBJECT public: ConfigWindow(VncConfiguration &data, bool dontClose = false); virtual ~ConfigWindow(); virtual void showEvent(QShowEvent *); virtual void closeEvent(QCloseEvent *); private: void apply(); void done(); public slots: void trayActivated(QSystemTrayIcon::ActivationReason reason); void toggleVisible(); private slots: void buttonBarClicked(QAbstractButton *button); private: Ui_ConfigWindow ui; VncConfiguration &m_data; bool m_dontClose; }; #endif // CONFIGURATION_H 07070100000004000081A400000000000000000000000164EC8EB100002F21000000000000000000000000000000000000002C00000000vncmanager-controller-1.0.2/ConfigWindow.ui<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ConfigWindow</class> <widget class="QMainWindow" name="ConfigWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>369</width> <height>614</height> </rect> </property> <property name="windowTitle"> <string>VNC Session</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Persistence and Visibility</string> </property> <property name="flat"> <bool>true</bool> </property> <layout class="QGridLayout" name="gridLayout"> <item row="5" column="0"> <widget class="QLabel" name="label_5"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="text"> <string>The session is visible to others and can be reconnected. It keeps running when you disconnect.</string> </property> <property name="wordWrap"> <bool>true</bool> </property> <property name="indent"> <number>26</number> </property> <property name="buddy"> <cstring>chkPersistencePersistent</cstring> </property> </widget> </item> <item row="1" column="0"> <widget class="QRadioButton" name="chkPersistenceNonPersistent"> <property name="text"> <string>Non-persistent, private</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> <item row="3" column="0"> <widget class="QRadioButton" name="chkPersistencePersistent"> <property name="text"> <string>Persistent, visible</string> </property> </widget> </item> <item row="2" column="0"> <widget class="QLabel" name="label_4"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="text"> <string>The session is not visible to others and will be terminated when you disconnect.</string> </property> <property name="wordWrap"> <bool>true</bool> </property> <property name="indent"> <number>26</number> </property> <property name="buddy"> <cstring>chkPersistenceNonPersistent</cstring> </property> </widget> </item> </layout> </widget> </item> <item> <widget class="QGroupBox" name="groupBox_4"> <property name="enabled"> <bool>false</bool> </property> <property name="title"> <string>Session name</string> </property> <property name="flat"> <bool>true</bool> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QLineEdit" name="editSessionName"/> </item> </layout> </widget> </item> <item> <widget class="QGroupBox" name="groupBox_2"> <property name="enabled"> <bool>false</bool> </property> <property name="title"> <string>Security</string> </property> <property name="flat"> <bool>true</bool> </property> <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> <widget class="QRadioButton" name="chkSecurityUnknown"> <property name="text"> <string>Unknown</string> </property> <property name="checkable"> <bool>true</bool> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> <item row="3" column="0"> <widget class="QWidget" name="widgetVncAuth" native="true"> <layout class="QGridLayout" name="gridLayout_3"> <property name="leftMargin"> <number>35</number> </property> <item row="0" column="0"> <widget class="QLabel" name="label_2"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> <string>Password:</string> </property> <property name="buddy"> <cstring>editPassword</cstring> </property> </widget> </item> <item row="0" column="1"> <widget class="QLineEdit" name="editPassword"> <property name="enabled"> <bool>false</bool> </property> <property name="echoMode"> <enum>QLineEdit::Password</enum> </property> </widget> </item> <item row="1" column="0"> <widget class="QLabel" name="label_3"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> <string>View-only password:</string> </property> <property name="buddy"> <cstring>editViewonlyPassword</cstring> </property> </widget> </item> <item row="1" column="1"> <widget class="QLineEdit" name="editViewonlyPassword"> <property name="enabled"> <bool>false</bool> </property> <property name="echoMode"> <enum>QLineEdit::Password</enum> </property> </widget> </item> </layout> </widget> </item> <item row="1" column="0"> <widget class="QRadioButton" name="chkSecurityNone"> <property name="text"> <string>No password required</string> </property> </widget> </item> <item row="2" column="0"> <widget class="QRadioButton" name="chkSecurityVncAuth"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> <string>Require custom password</string> </property> </widget> </item> <item row="4" column="0"> <widget class="QRadioButton" name="chkSecurityPlain"> <property name="text"> <string>Require user login</string> </property> <property name="checked"> <bool>false</bool> </property> </widget> </item> <item row="5" column="0"> <widget class="QWidget" name="widget_2" native="true"> <layout class="QGridLayout" name="gridLayout_4"> <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> <string>Allowed users:</string> </property> <property name="indent"> <number>26</number> </property> <property name="buddy"> <cstring>editAllowedUsers</cstring> </property> </widget> </item> <item row="0" column="1"> <widget class="QLineEdit" name="editAllowedUsers"> <property name="toolTip"> <string>List of usernames separated by commas.</string> </property> </widget> </item> </layout> </widget> </item> </layout> </widget> </item> <item> <widget class="QGroupBox" name="groupBox_3"> <property name="enabled"> <bool>false</bool> </property> <property name="title"> <string>Sharing</string> </property> <property name="flat"> <bool>true</bool> </property> <layout class="QGridLayout" name="gridLayout_5"> <item row="0" column="0"> <widget class="QRadioButton" name="chkSharingUnknown"> <property name="text"> <string>Unknown</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> <item row="2" column="0"> <widget class="QRadioButton" name="chkSharingMultipleClients"> <property name="text"> <string>Allow multiple clients at time</string> </property> </widget> </item> <item row="1" column="0"> <widget class="QRadioButton" name="chkSharingOneClient"> <property name="text"> <string>Allow one client at time</string> </property> <property name="checked"> <bool>false</bool> </property> </widget> </item> </layout> </widget> </item> <item> <widget class="QDialogButtonBox" name="buttonBox"> <property name="standardButtons"> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> </layout> </widget> </widget> <tabstops> <tabstop>chkPersistenceNonPersistent</tabstop> <tabstop>chkPersistencePersistent</tabstop> <tabstop>editSessionName</tabstop> <tabstop>chkSecurityUnknown</tabstop> <tabstop>chkSecurityNone</tabstop> <tabstop>chkSecurityVncAuth</tabstop> <tabstop>editPassword</tabstop> <tabstop>editViewonlyPassword</tabstop> <tabstop>chkSecurityPlain</tabstop> <tabstop>editAllowedUsers</tabstop> <tabstop>chkSharingUnknown</tabstop> <tabstop>chkSharingOneClient</tabstop> <tabstop>chkSharingMultipleClients</tabstop> <tabstop>buttonBox</tabstop> </tabstops> <resources/> <connections> <connection> <sender>chkPersistencePersistent</sender> <signal>toggled(bool)</signal> <receiver>groupBox_2</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> <x>144</x> <y>103</y> </hint> <hint type="destinationlabel"> <x>202</x> <y>255</y> </hint> </hints> </connection> <connection> <sender>chkPersistencePersistent</sender> <signal>toggled(bool)</signal> <receiver>groupBox_4</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> <x>87</x> <y>102</y> </hint> <hint type="destinationlabel"> <x>81</x> <y>160</y> </hint> </hints> </connection> <connection> <sender>chkPersistencePersistent</sender> <signal>toggled(bool)</signal> <receiver>groupBox_3</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> <x>48</x> <y>102</y> </hint> <hint type="destinationlabel"> <x>57</x> <y>475</y> </hint> </hints> </connection> <connection> <sender>chkSecurityPlain</sender> <signal>toggled(bool)</signal> <receiver>editAllowedUsers</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> <x>108</x> <y>418</y> </hint> <hint type="destinationlabel"> <x>154</x> <y>442</y> </hint> </hints> </connection> <connection> <sender>chkSecurityVncAuth</sender> <signal>toggled(bool)</signal> <receiver>editPassword</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> <x>148</x> <y>333</y> </hint> <hint type="destinationlabel"> <x>195</x> <y>365</y> </hint> </hints> </connection> <connection> <sender>chkSecurityVncAuth</sender> <signal>toggled(bool)</signal> <receiver>editViewonlyPassword</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> <x>129</x> <y>335</y> </hint> <hint type="destinationlabel"> <x>203</x> <y>390</y> </hint> </hints> </connection> </connections> </ui> 07070100000005000081A400000000000000000000000164EC8EB100000435000000000000000000000000000000000000002400000000vncmanager-controller-1.0.2/LICENSEThe MIT License (MIT) Copyright (c) 2016 Michal Srb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 07070100000006000081A400000000000000000000000164EC8EB10000099F000000000000000000000000000000000000003200000000vncmanager-controller-1.0.2/ManagerConnection.cpp#include "ManagerConnection.h" #include <assert.h> #include <QtCore/QFile> #include <QtCore/QIODevice> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/extensions/Xvnc.h> // We don't need this macros and they polute our namespace. #undef None #undef Bool #undef Status ManagerConnection::ManagerConnection(Display *display) : m_display(display) {} bool ManagerConnection::connect() { // Connect to vncmanager's control socket and send our display number m_socket.connectToServer(socketPath); if (!m_socket.waitForConnected()) { return false; } if (m_socket.state() != QLocalSocket::ConnectedState) { return false; } m_stream.setDevice(&m_socket); char *displayName = XDisplayName(nullptr); m_stream << QString(displayName).split(':').last() << '\n'; m_stream.flush(); m_socket.waitForReadyRead(); QString response; m_stream >> response; if (response != "OK") { return false; } // Generate key QFile devrand("/dev/urandom"); devrand.open(QIODevice::ReadOnly); QByteArray key; while (key.size() < keyLength) { key += devrand.read(keyLength - key.size()); } devrand.close(); QByteArray keyBase64 = key.toHex(); // Send the key thru the Xvnc // vncmanager will catch the controller key and won't let it pass to the client, but just to keep things in order, lets remember the original name and set it back after char *originalDesktopName; int originalDesktopNameLength; if (!XVncExtGetParam(m_display, "Desktop", &originalDesktopName, &originalDesktopNameLength)) { return false; } if (!XVncExtSetParam(m_display, (QString("Desktop=CONTROLLER_KEY:") + keyBase64).toLatin1())) { return false; } // Send the key thru the socket m_stream << keyBase64 << '\n'; m_stream.flush(); // Wait for response m_socket.waitForReadyRead(); m_stream >> response; // Set back the original name XVncExtSetParam(m_display, (QString("Desktop=") + QString::fromLatin1(originalDesktopName, originalDesktopNameLength)).toLatin1()); XFree(originalDesktopName); // Check if the response was correct if (response != "OK") { return false; } m_connected = true; return true; } void ManagerConnection::sendSessionInfo(bool visible) { assert(connected()); m_stream << "VISIBLE " << visible << '\n'; m_stream.flush(); } 07070100000007000081A400000000000000000000000164EC8EB100000281000000000000000000000000000000000000003000000000vncmanager-controller-1.0.2/ManagerConnection.h#ifndef MANAGERCONNECTION_H #define MANAGERCONNECTION_H #include <QtCore/QString> #include <QtCore/QTextStream> #include <QtNetwork/QLocalSocket> typedef struct _XDisplay Display; class ManagerConnection { private: const QString socketPath = "/run/vncmanager/control/control"; const std::size_t keyLength = 32; public: ManagerConnection(Display *display); bool connect(); bool connected() const { return m_connected; } void sendSessionInfo(bool visible); private: Display *m_display; bool m_connected = false; QLocalSocket m_socket; QTextStream m_stream; }; #endif // MANAGERCONNECTION_H 07070100000008000081A400000000000000000000000164EC8EB1000000EF000000000000000000000000000000000000002600000000vncmanager-controller-1.0.2/README.md# vncmanager-controller This is a utility to control VNC sessions managed by [vncmanager](https://github.com/openSUSE/vncmanager). ## License The project is open sourced under the [MIT license](https://tldrlegal.com/license/mit-license). 07070100000009000081A400000000000000000000000164EC8EB1000003C0000000000000000000000000000000000000003000000000vncmanager-controller-1.0.2/StdinConnection.cpp#include <QtCore/QSocketNotifier> #include "StdinConnection.h" StdinConnection::StdinConnection(QObject *parent) : QObject(parent) , m_stdin(stdin, QIODevice::ReadOnly) { QSocketNotifier *n1 = new QSocketNotifier(0, QSocketNotifier::Read, this); connect(n1, SIGNAL(activated(int)), this, SLOT(read())); QSocketNotifier *n2 = new QSocketNotifier(0, QSocketNotifier::Exception, this); connect(n2, SIGNAL(activated(int)), this, SIGNAL(close())); QTextStream m_stdout(stdout, QIODevice::WriteOnly); m_stdout << "OK\n"; m_stdout.flush(); } StdinConnection::~StdinConnection() { } void StdinConnection::read() { if (m_stdin.atEnd()) { emit close(); return; } QString cmd; m_stdin >> cmd; if (cmd.isEmpty() || cmd == "QUIT") { emit close(); return; } if (cmd == "TOGGLE") { emit toggleVisible(); return; } } #include "StdinConnection.moc" 0707010000000A000081A400000000000000000000000164EC8EB10000021F000000000000000000000000000000000000002E00000000vncmanager-controller-1.0.2/StdinConnection.h#ifndef CONSOLECONNECTION_H #define CONSOLECONNECTION_H #include <QtCore/QObject> #include <QtCore/QTextStream> /** * This class is meant to be used in connection with gnome-shell extension to compensate for the lack of tray icons in gnome-shell. */ class StdinConnection : public QObject { Q_OBJECT public: StdinConnection(QObject *parent); virtual ~StdinConnection(); signals: void toggleVisible(); void close(); private slots: void read(); private: QTextStream m_stdin; }; #endif // CONSOLECONNECTION_H 0707010000000B000081A400000000000000000000000164EC8EB100001B34000000000000000000000000000000000000003100000000vncmanager-controller-1.0.2/VncConfiguration.cpp#include "VncConfiguration.h" #include <strings.h> #include <unistd.h> #include <iostream> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/extensions/Xvnc.h> // We don't need this macros and they polute our namespace. #undef None #undef Bool #undef Status #include <QtNetwork/QLocalSocket> #include <QtCore/QProcessEnvironment> #include <QtCore/QSettings> VncConfiguration::VncConfiguration(Display *display) : m_display(display) , m_managerConnection(display) {} bool VncConfiguration::connect() { return m_managerConnection.connect(); } void VncConfiguration::read() { int length; char *value; // Persistence if (XVncExtGetParam(m_display, "MaxDisconnectionTime", &value, &length)) { if (length == 1 && value[0] == '0') { m_persistence = Persistence::Persistent; } else { m_persistence = Persistence::NonPersistent; } XFree(value); } // Sharing bool NeverShared = false; if (XVncExtGetParam(m_display, "NeverShared", &value, &length)) { NeverShared = (length == 1 && value[0] == '1'); XFree(value); } bool DisconnectClients = false; if (XVncExtGetParam(m_display, "DisconnectClients", &value, &length)) { DisconnectClients = (length == 1 && value[0] == '1'); XFree(value); } if (NeverShared && DisconnectClients) { m_sharing = Sharing::OneClient; } else if (!NeverShared && !DisconnectClients) { m_sharing = Sharing::MultipleClients; } else { m_sharing = Sharing::Unknown; } // Security m_plainUsers.clear(); if (XVncExtGetParam(m_display, "SecurityTypes", &value, &length)) { if (strcasecmp(value, "None") == 0) { m_security = Security::None; } else if (strcasecmp(value, "VncAuth") == 0) { m_security = Security::VncAuth; } else if (strcasecmp(value, "Plain") == 0) { m_security = Security::Plain; } else { m_security = Security::Unknown; } XFree(value); } // Reading this in no matter what is the current security type if (XVncExtGetParam(m_display, "PasswordFile", &value, &length)) { m_passwordFile = QString::fromLatin1(value, length); // TODO: Verify if it's ascii XFree(value); } // Reading this in no matter what is the current security type if (XVncExtGetParam(m_display, "PlainUsers", &value, &length)) { m_plainUsers = QString::fromLatin1(value, length).split(',', QString::SkipEmptyParts); // TODO: Verify if it's ascii XFree(value); } // Name if (XVncExtGetParam(m_display, "Desktop", &value, &length)) { m_sessionName = QString::fromLatin1(value, length); XFree(value); } } void VncConfiguration::normalizeSettings() { // Persistence if (m_persistence == Persistence::Unknown) { m_persistence = Persistence::NonPersistent; } // Sharing if (m_sharing == Sharing::Unknown) { m_sharing = Sharing::OneClient; } // Security QString possibleUsername = queryUserName(); if (!possibleUsername.isEmpty()) { if (m_security == Security::Unknown || m_security == Security::None) { m_security = Security::Plain; m_plainUsers.clear(); m_plainUsers.append(possibleUsername); } } // Name QString possibleName = querySessionName(); if (!possibleName.isEmpty()) { m_sessionName = possibleName; } } void VncConfiguration::apply() { // Sharing 1 switch (m_sharing) { case Sharing::OneClient: XVncExtSetParam(m_display, "NeverShared=1"); XVncExtSetParam(m_display, "DisconnectClients=1"); break; case Sharing::MultipleClients: // Will be done after setting security break; } // Security switch (m_security) { case Security::None: XVncExtSetParam(m_display, "SecurityTypes=None"); break; case Security::VncAuth: XVncExtSetParam(m_display, "SecurityTypes=VncAuth"); XVncExtSetParam(m_display, (QString("PasswordFile=") + m_passwordFile).toLatin1()); break; case Security::Plain: XVncExtSetParam(m_display, "SecurityTypes=Plain"); XVncExtSetParam(m_display, (QString("PlainUsers=") + m_plainUsers.join(",")).toLatin1()); break; } // Sharing 2 switch (m_sharing) { case Sharing::OneClient: // Was done before setting security break; case Sharing::MultipleClients: XVncExtSetParam(m_display, "DisconnectClients=0"); XVncExtSetParam(m_display, "NeverShared=0"); break; } // Persistence switch (m_persistence) { case Persistence::Persistent: XVncExtSetParam(m_display, "MaxDisconnectionTime=0"); break; case Persistence::NonPersistent: XVncExtSetParam(m_display, "MaxDisconnectionTime=5"); // XXX: Too hardcoded break; } // Name XVncExtSetParam(m_display, ("Desktop=" + m_sessionName).toLatin1()); if (m_managerConnection.connected()) { // Send session info m_managerConnection.sendSessionInfo(m_persistence == Persistence::Persistent); } } void VncConfiguration::setSessionName(QString sessionName) { m_sessionName = sessionName; } void VncConfiguration::setPersistence(VncConfiguration::Persistence persistence) { m_persistence = persistence; } void VncConfiguration::setSharing(VncConfiguration::Sharing sharing) { m_sharing = sharing; } void VncConfiguration::setSecurityNone() { m_security = Security::None; } void VncConfiguration::setSecurityVncAuth(QString password, QString viewonlyPassword) { m_security = Security::VncAuth; throw std::runtime_error("Not implemented."); } void VncConfiguration::setSecurityVncAuth(QString authFilename) { m_security = Security::VncAuth; throw std::runtime_error("Not implemented."); } void VncConfiguration::setSecurityPlain() { m_security = Security::Plain; } void VncConfiguration::setSecurityPlain(QStringList plainUsers) { m_security = Security::Plain; m_plainUsers = plainUsers; } QString VncConfiguration::querySessionName() { QString desktopSession = QProcessEnvironment::systemEnvironment().value("DESKTOP_SESSION"); if (!desktopSession.isEmpty()) { // XXX: Misusing QSettings to read desktop file QSettings desktopFile("/usr/share/xsessions/" + desktopSession + ".desktop", QSettings::IniFormat); if (desktopFile.contains("Desktop Entry/Name")) { return desktopFile.value("Desktop Entry/Name").toString(); } } QString xdg_current_desktop = QProcessEnvironment::systemEnvironment().value("XDG_CURRENT_DESKTOP"); return xdg_current_desktop; } QString VncConfiguration::queryUserName() { return QProcessEnvironment::systemEnvironment().value("USER"); } 0707010000000C000081A400000000000000000000000164EC8EB100000708000000000000000000000000000000000000002F00000000vncmanager-controller-1.0.2/VncConfiguration.h#ifndef DATA_H #define DATA_H #include <QtCore/QStringList> #include "ManagerConnection.h" typedef struct _XDisplay Display; class VncConfiguration { public: enum class Persistence { Unknown, NonPersistent, Persistent }; enum class Security { Unknown, None, VncAuth, Plain }; enum class Sharing { Unknown, OneClient, MultipleClients }; public: VncConfiguration(Display *display); /// Connect to vncmanager's control socket bool connect(); /// Read the current settings from X server void read(); /// Change current settings to reasonable default void normalizeSettings(); /// Apply the settings to X server void apply(); QString getSessionName() const { return m_sessionName; } void setSessionName(QString sessionName); Persistence getPersistence() const { return m_persistence; } void setPersistence(Persistence persistence); Sharing getSharing() const { return m_sharing; } void setSharing(Sharing sharing); Security getSecurity() const { return m_security; } void setSecurityNone(); void setSecurityVncAuth(QString password, QString viewonlyPassword); void setSecurityVncAuth(QString authFilename); QStringList getPlainUsers() const { return m_plainUsers; } void setSecurityPlain(); void setSecurityPlain(QStringList plainUsers); private: QString querySessionName(); QString queryUserName(); private: Display *m_display; ManagerConnection m_managerConnection; QString m_sessionName; Persistence m_persistence = Persistence::Unknown; Sharing m_sharing = Sharing::Unknown; Security m_security = Security::Unknown; QString m_passwordFile; QStringList m_plainUsers; }; #endif // DATA_H 0707010000000D000041ED00000000000000000000000164EC8EB100000000000000000000000000000000000000000000003200000000vncmanager-controller-1.0.2/gnome-shell-extension0707010000000E000081A400000000000000000000000164EC8EB10000069A000000000000000000000000000000000000003F00000000vncmanager-controller-1.0.2/gnome-shell-extension/extension.jsconst Clutter = imports.gi.Clutter; const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const St = imports.gi.St; const CONTROLLER_CMD = ['/usr/bin/vncmanager-controller', '--start-setup', '--stdin' ]; let controller; let stdoutChannel; const VNCController = GObject.registerClass( class VNCController extends PanelMenu.Button { _init() { super._init(St.Align.START); let label = new St.Label({ text: 'VNC', y_expand: true, y_align: Clutter.ActorAlign.CENTER }); this.add_actor(label); this.connect('button-release-event', () => { stdoutChannel.write_chars("TOGGLE\n", 7); stdoutChannel.flush(); }); } }); function enable() { let process = GLib.spawn_async_with_pipes(null, CONTROLLER_CMD, null, GLib.SpawnFlags.DEFAULT, null); if (!process[0]) { log ('Failed to start vncmanager-controller process.'); return; } let stdinChannel = GLib.IOChannel.unix_new(process[3]); let result = stdinChannel.read_line(); stdinChannel.close(); if (result[0] != GLib.IOStatus.NORMAL || result[1] != "OK\n") { log ('The session is not managed by vncmanager: ' + result[0]); stdinChannel.close(); return; } stdoutChannel = GLib.IOChannel.unix_new(process[2]); controller = new VNCController(); Main.panel.addToStatusArea('vnccontroller', controller, 2); } function disable() { if (!controller) return; stdoutChannel.write_chars('QUIT\n', 5); stdoutChannel.close(); controller.destroy(); } 0707010000000F000081A400000000000000000000000164EC8EB1000002D0000000000000000000000000000000000000004000000000vncmanager-controller-1.0.2/gnome-shell-extension/metadata.json{ "shell-version": [ "3.10", "3.11", "3.12", "3.13", "3.14", "3.15", "3.16", "3.17", "3.18", "3.19", "3.20", "3.21", "3.22", "3.23", "3.24", "3.25", "3.26", "3.27", "3.28", "3.29", "3.30", "3.31", "3.32", "3.33", "3.34", "3.35", "3.36", "3.37", "3.38", "3.39", "40", "41" ], "uuid": "vncmanager-controller@vncmanager.michalsrb.github.com", "name": "VNC Session Configuration", "description": "Configure VNC session managed by vncmanager" } 07070100000010000081A400000000000000000000000164EC8EB100000964000000000000000000000000000000000000002500000000vncmanager-controller-1.0.2/main.cpp#include <QtWidgets/QApplication> #include <QtWidgets/QMenu> #include <QtWidgets/QStyle> #include <QtWidgets/QSystemTrayIcon> #include <QtX11Extras/QX11Info> #include "ConfigWindow.h" #include "StdinConnection.h" #include <X11/X.h> #include <X11/Xlib.h> #include <X11/extensions/Xvnc.h> int main(int argc, char **argv) { bool tray = false; bool stdin_connnection = false; bool start_setup = false; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--tray") == 0) { tray = true; } else if (strcmp(argv[i], "--stdin") == 0) { stdin_connnection = true; } else if (strcmp(argv[i], "--start-setup") == 0) { start_setup = true; } } QApplication app(argc, argv); Display *display = QX11Info::display(); if (!display) { qWarning("Not running on X server, quitting."); return 1; } int event_base, error_base; if (!XVncExtQueryExtension(display, &event_base, &error_base)) { qWarning("No VNC extension found, quitting."); return 1; } VncConfiguration configuration(display); configuration.read(); if (!configuration.connect()) { qWarning("VNC not managed by vncmanager, quitting."); return 1; } if (start_setup) { configuration.normalizeSettings(); configuration.apply(); } ConfigWindow window(configuration, tray || stdin_connnection); if (tray) { QSystemTrayIcon *tray = new QSystemTrayIcon(window.style()->standardIcon(QStyle::SP_DesktopIcon), &window); // XXX: Better icon? tray->setToolTip(ConfigWindow::tr("VNC Session Configuration")); QMenu *menu = new QMenu(); QAction *quitAction = menu->addAction("Quit"); QObject::connect(quitAction, SIGNAL(triggered(bool)), &app, SLOT(quit())); tray->setContextMenu(menu); QObject::connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &window, SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); tray->show(); } else if (stdin_connnection) { StdinConnection *connection = new StdinConnection(&window); QObject::connect(connection, SIGNAL(toggleVisible()), &window, SLOT(toggleVisible())); QObject::connect(connection, SIGNAL(close()), &app, SLOT(quit())); } else { window.show(); } return app.exec(); } 07070100000011000081A400000000000000000000000164EC8EB100000127000000000000000000000000000000000000003A00000000vncmanager-controller-1.0.2/vncmanager-controller.desktop[Desktop Entry] Name=VNC Configuration Exec=env QT_QPA_PLATFORM=xcb vncmanager-controller --tray --start-setup Type=Application Terminal=false X-KDE-autostart-after=panel X-KDE-StartupNotify=false # Gnome doesn't show tray icons anymore. Gnome-shell extension is used instead. X-NotShowIn=GNOME 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!80 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor