diff options
author | Jannik Schönartz | 2021-11-24 00:02:55 +0100 |
---|---|---|
committer | Jannik Schönartz | 2021-11-24 00:02:55 +0100 |
commit | 02b89b2caebce935b0b6dad35a4ed5c6c3f56026 (patch) | |
tree | bf896dcab8dd5c28c64516e5e2f8c161459ba612 | |
parent | If lectureID was sent, create an override config file to autostart the lecture (diff) | |
download | slxgreeter-02b89b2caebce935b0b6dad35a4ed5c6c3f56026.tar.gz slxgreeter-02b89b2caebce935b0b6dad35a4ed5c6c3f56026.tar.xz slxgreeter-02b89b2caebce935b0b6dad35a4ed5c6c3f56026.zip |
RPC-login: Add lectureid and editsession id as param and create files needed for the remote edit
-rw-r--r-- | src/loginrpc.cpp | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/src/loginrpc.cpp b/src/loginrpc.cpp index 320cdfd..09f6454 100644 --- a/src/loginrpc.cpp +++ b/src/loginrpc.cpp @@ -46,7 +46,7 @@ void LoginRpc::handleIncoming(QTcpSocket *sock) { void LoginRpc::handleCommandV1(const QString &command) { QStringList lines = command.split('\n'); - while (lines.count() < 4) { + while (lines.count() < 5) { lines.append(QString()); } QString res = lines[2]; @@ -119,6 +119,7 @@ void LoginRpc::handleCommandV1(const QString &command) allOutputs << virtOut; } } + /* Commented, to have a view on the client while debugging TODO REMOVE XXX // Either -1 if we didn't have a virtual one, or != 0 if xrandr setting failed if (ret != 0) { // Play it safe and disable all the outputs @@ -132,24 +133,52 @@ void LoginRpc::handleCommandV1(const QString &command) p.waitForFinished(2000); p.kill(); } + */ } } - // If lectureId was sent, create a file that overrides the SLX_AUTOSTART_UUID + // If lectureId was sent, create a config that overrides the default.desktop xsession config if (lines[3] != "") { - // File will be created at /var/lib/lightdm/config_overrides/SLX_AUTOSTART_UUID - QString path = "config_override/"; - QFile file(path + "SLX_AUTOSTART_UUID"); + // Symlink in /opt/openslx/xsessions/edit.desktop -> /var/lib/lightdm/edit.dekstop is needed to override the config + qDebug() << "Lecture UUID was provided: " << lines[3]; + QFile file("edit.desktop"); - QDir dir; - if (!dir.exists(path)) { - dir.mkdir(path); - } + qDebug() << "Try creating edit config"; + // Create edit.config if (file.open(QIODevice::ReadWrite)) { + file.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | + QFileDevice::ExeOwner | QFileDevice::ReadUser | + QFileDevice::WriteUser | QFileDevice::ExeUser | + QFileDevice::ReadGroup | QFileDevice::ExeGroup | + QFileDevice::ReadOther | QFileDevice::ExeOther); + qDebug() << "edit.config created!"; QTextStream stream(&file); - stream << lines[3] << "\n"; + stream << "[Desktop Entry]" << endl; + stream << "Encoding=UTF-8" << endl; + stream << "Name=virtual machine chooser (autostart/edit mode)" << endl; + stream << "Name[de]=Virtuelle Maschine auswählen" << endl; + stream << "Comment=This session starts the vm session chooser" << endl; + stream << "Exec=/opt/openslx/bin/vmchooser" << " " << "--allow-vm-edit" << " " << "--allow-vm-edit-checked" << " " << "--start-uuid " << lines[3] + << " " << "-c /opt/openslx/vmchooser/config/vmchooser.conf" << endl; + stream << "TryExec=/opt/openslx/bin/vmchooser" << endl; + stream << "Icon=" << endl; + stream << "Type=Application" << endl; file.close(); } + + } + + // Handle edit session id + if (lines[4] != "") { + qDebug() << "Edit session ID was provided: " << lines[4]; + QFile file("editsession.id"); + + if (file.open(QIODevice::ReadWrite)) { + qDebug() << "editsession.id file created!"; + QTextStream stream(&file); + stream << lines[4]; + file.close(); + } } emit loginRequest(lines[0], lines[1], lines[2]); |