Commit a5147463 authored by Ronan's avatar Ronan

feat(Incall): disable screen saver on fullscreen video call (GNU/Linux with DBus & Xdg)

parent 4d68106d
Pipeline #152 failed with stage
in 0 seconds
......@@ -219,7 +219,7 @@ set(HEADERS
src/components/timeline/TimelineModel.hpp
src/components/url-handlers/UrlHandlers.hpp
src/utils/LinphoneUtils.hpp
src/utils/QExifImageHeader.h
src/utils/QExifImageHeader.hpp
src/utils/Utils.hpp
)
......@@ -227,41 +227,43 @@ set(MAIN_FILE src/app/main.cpp)
if (APPLE)
list(APPEND SOURCES
src/app/single-application/SingleApplication.cpp
src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.m
src/components/other/desktop-tools/DesktopToolsMacOs.cpp
)
list(APPEND HEADERS
src/app/single-application/SingleApplicationPrivate.hpp
src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp
src/components/other/desktop-tools/DesktopToolsMacOs.hpp
)
elseif (WIN32)
list(APPEND SOURCES
src/app/single-application/SingleApplication.cpp
src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp
src/components/other/desktop-tools/DesktopToolsWindows.cpp
)
list(APPEND HEADERS
src/app/single-application/SingleApplicationPrivate.hpp
src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp
src/components/other/desktop-tools/DesktopToolsWindows.hpp
)
else ()
list(APPEND SOURCES
src/app/single-application/SingleApplicationDBus.cpp
src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp
src/components/other/desktop-tools/DesktopToolsLinux.cpp
src/components/other/desktop-tools/screen-saver/ScreenSaverDBus.cpp
src/components/other/desktop-tools/screen-saver/ScreenSaverXdg.cpp
)
list(APPEND HEADERS
src/app/single-application/SingleApplicationDBusPrivate.hpp
src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp
src/components/other/desktop-tools/DesktopToolsLinux.hpp
src/components/other/desktop-tools/screen-saver/ScreenSaverDBus.hpp
src/components/other/desktop-tools/screen-saver/ScreenSaverXdg.hpp
)
endif ()
if (UNIX AND NOT APPLE)
list(APPEND SOURCES src/app/single-application/SingleApplicationDBus.cpp)
list(APPEND HEADERS src/app/single-application/SingleApplicationDBusPrivate.hpp)
else ()
list(APPEND SOURCES src/app/single-application/SingleApplication.cpp)
list(APPEND HEADERS src/app/single-application/SingleApplicationPrivate.hpp)
endif ()
set(QRC_RESOURCES resources.qrc)
set(LANGUAGES_DIRECTORY "${ASSETS_DIR}/languages")
......
......@@ -81,7 +81,7 @@ AppController::AppController (int &argc, char *argv[]) {
while (it.hasNext()) {
QFileInfo info(it.next());
if (info.suffix() == "ttf") {
if (info.suffix() == QLatin1String("ttf")) {
QString path = info.absoluteFilePath();
if (path.startsWith(":/assets/fonts/"))
QFontDatabase::addApplicationFont(path);
......
......@@ -106,7 +106,7 @@ static inline string getWritableFilePath (const QString &filename) {
static inline QDir getAppPackageDir () {
QDir dir(QCoreApplication::applicationDirPath());
if (dir.dirName() == "MacOS") {
if (dir.dirName() == QLatin1String("MacOS")) {
dir.cdUp();
dir.cd("Resources");
} else
......@@ -272,7 +272,7 @@ static void migrateConfigurationFile (const QString &oldPath, const QString &new
void Paths::migrate () {
QString newPath = getAppConfigFilePath();
QString oldBaseDir = QSysInfo::productType() == "windows"
QString oldBaseDir = QSysInfo::productType() == QLatin1String("windows")
? QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
: QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
QString oldPath = oldBaseDir + "/.linphonerc";
......
......@@ -32,11 +32,11 @@ DefaultTranslator::DefaultTranslator (QObject *parent) : QTranslator(parent) {
while (it.hasNext()) {
QFileInfo info(it.next());
if (info.suffix() == "qml") {
if (info.suffix() == QLatin1String("qml")) {
QString dir = info.absoluteDir().absolutePath();
// Ignore extra selectors.
// TODO: Remove 5.9 support in July 2018.
// TODO: Remove 5.9 support in July 2019.
for (const auto &selector : { "+linux", "+mac", "+windows", "+5.9" })
if (dir.contains(selector))
goto end;
......
......@@ -36,7 +36,7 @@
#include "components/core/CoreManager.hpp"
#include "components/notifier/Notifier.hpp"
#include "components/settings/SettingsModel.hpp"
#include "utils/QExifImageHeader.h"
#include "utils/QExifImageHeader.hpp"
#include "utils/Utils.hpp"
#include "ChatModel.hpp"
......
......@@ -132,7 +132,7 @@ void VideoCodecsModel::updateCodecs () {
QDirIterator it(Utils::coreStringToAppString(Paths::getCodecsDirPath()));
while (it.hasNext()) {
QFileInfo info(it.next());
if (info.suffix() == "in") {
if (info.suffix() == QLatin1String("in")) {
QString codecName = info.completeBaseName();
if (codecName.endsWith(codecSuffix)) {
QString codecPath = info.dir().path() + QDir::separator() + codecName;
......
......@@ -24,8 +24,6 @@
// =============================================================================
DesktopTools::DesktopTools (QObject *parent) : QObject(parent) {}
DesktopTools::~DesktopTools () {
setScreenSaverStatus(true);
}
......@@ -35,9 +33,12 @@ bool DesktopTools::getScreenSaverStatus () const {
}
void DesktopTools::setScreenSaverStatus (bool status) {
if (status == mScreenSaverStatus)
return;
screenSaverDBus.setScreenSaverStatus(status);
screenSaverXdg.setScreenSaverStatus(status);
// TODO: Deal with me.
emit screenSaverStatusChanged(status);
bool newStatus = screenSaverDBus.getScreenSaverStatus() || screenSaverXdg.getScreenSaverStatus();
if (newStatus != mScreenSaverStatus) {
mScreenSaverStatus = newStatus;
emit screenSaverStatusChanged(mScreenSaverStatus);
}
}
......@@ -23,7 +23,8 @@
#ifndef DESKTOP_TOOLS_LINUX_H_
#define DESKTOP_TOOLS_LINUX_H_
#include <QObject>
#include "components/other/desktop-tools/screen-saver/ScreenSaverDBus.hpp"
#include "components/other/desktop-tools/screen-saver/ScreenSaverXdg.hpp"
// =============================================================================
......@@ -33,7 +34,7 @@ class DesktopTools : public QObject {
Q_PROPERTY(bool screenSaverStatus READ getScreenSaverStatus WRITE setScreenSaverStatus NOTIFY screenSaverStatusChanged);
public:
DesktopTools (QObject *parent = Q_NULLPTR);
DesktopTools (QObject *parent = Q_NULLPTR) : QObject(parent) {}
~DesktopTools ();
bool getScreenSaverStatus () const;
......@@ -44,6 +45,9 @@ signals:
private:
bool mScreenSaverStatus = true;
ScreenSaverDBus screenSaverDBus;
ScreenSaverXdg screenSaverXdg;
};
#endif // DESKTOP_TOOLS_LINUX_H_
......@@ -40,11 +40,11 @@ void DesktopTools::setScreenSaverStatus (bool status) {
if (status == mScreenSaverStatus)
return;
if (!status)
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
else {
if (status)
SetThreadExecutionState(ES_CONTINUOUS);
}
else
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
mScreenSaverStatus = status;
emit screenSaverStatusChanged(status);
}
/*
* ScreenSaverDBusLinux.cpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 21, 2018
* Author: Ronan Abhamon
*/
#include <QCoreApplication>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QDebug>
#include "ScreenSaverDBus.hpp"
// =============================================================================
namespace {
constexpr char ServiceName[] = "org.freedesktop.ScreenSaver";
constexpr char ServicePath[] = "/ScreenSaver";
}
ScreenSaverDBus::ScreenSaverDBus (QObject *parent) : QObject(parent), mBus(ServiceName, ServicePath, ServiceName) {}
ScreenSaverDBus::~ScreenSaverDBus () {
setScreenSaverStatus(true);
}
bool ScreenSaverDBus::getScreenSaverStatus () const {
return mScreenSaverStatus;
}
void ScreenSaverDBus::setScreenSaverStatus (bool status) {
if (status == mScreenSaverStatus)
return;
if (status) {
QDBusMessage reply(mBus.call("UnInhibit", mToken));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << QStringLiteral("Uninhibit screen saver failed: `%1: %2`.")
.arg(reply.errorName()).arg(reply.errorMessage());
return;
}
mToken = uint32_t(reply.arguments().first().toULongLong());
mScreenSaverStatus = false;
emit screenSaverStatusChanged(mScreenSaverStatus);
return;
}
QDBusMessage reply(mBus.call("Inhibit", QCoreApplication::applicationName()));
if (reply.type() == QDBusMessage::ErrorMessage) {
if (reply.errorName() != QLatin1String("org.freedesktop.DBus.Error.ServiceUnknown"))
qWarning() << QStringLiteral("Inhibit screen saver failed: `%1: %2`.")
.arg(reply.errorName()).arg(reply.errorMessage());
return;
}
mScreenSaverStatus = true;
emit screenSaverStatusChanged(mScreenSaverStatus);
}
/*
* ScreenSaverDBus.hpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: July 11, 2018
* Author: Ronan Abhamon
*/
#ifndef SCREEN_SAVER_DBUS_H_
#define SCREEN_SAVER_DBUS_H_
#include <QDBusInterface>
// =============================================================================
class QDBusPendingCallWatcher;
class ScreenSaverDBus : public QObject {
Q_OBJECT;
public:
ScreenSaverDBus (QObject *parent = Q_NULLPTR);
~ScreenSaverDBus ();
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
signals:
void screenSaverStatusChanged (bool status);
private:
bool mScreenSaverStatus = true;
QDBusInterface mBus;
uint32_t mToken;
};
#endif // SCREEN_SAVER_DBUS_H_
/*
* ScreenSaverXdg.cpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 21, 2018
* Author: Ronan Abhamon
*/
#include <QProcess>
#include "ScreenSaverXdg.hpp"
// =============================================================================
namespace {
constexpr char Program[] = "xdg-screensaver";
const QStringList Arguments{"reset"};
constexpr int Interval = 30000;
}
ScreenSaverXdg::ScreenSaverXdg (QObject *parent) : QObject(parent) {
mTimer.setInterval(Interval);
QObject::connect(&mTimer, &QTimer::timeout, []() {
QProcess::startDetached(Program, Arguments);
});
}
bool ScreenSaverXdg::getScreenSaverStatus () const {
return !mTimer.isActive();
}
void ScreenSaverXdg::setScreenSaverStatus (bool status) {
if (status == !mTimer.isActive())
return;
if (status)
mTimer.stop();
else
mTimer.start();
emit screenSaverStatusChanged(status);
}
/*
* ScreenSaverXdg.hpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: July 11, 2018
* Author: Ronan Abhamon
*/
#ifndef SCREEN_SAVER_XDG_H_
#define SCREEN_SAVER_XDG_H_
#include <QTimer>
// =============================================================================
class ScreenSaverXdg : public QObject {
Q_OBJECT;
public:
ScreenSaverXdg (QObject *parent = Q_NULLPTR);
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
signals:
void screenSaverStatusChanged (bool status);
private:
QTimer mTimer;
};
#endif // SCREEN_SAVER_XDG_H_
......@@ -27,11 +27,11 @@
// =============================================================================
linphone::TransportType LinphoneUtils::stringToTransportType (const QString &transport) {
if (transport == "TCP")
if (transport == QLatin1String("TCP"))
return linphone::TransportType::TransportTypeTcp;
if (transport == "UDP")
if (transport == QLatin1String("UDP"))
return linphone::TransportType::TransportTypeUdp;
if (transport == "TLS")
if (transport == QLatin1String("TLS"))
return linphone::TransportType::TransportTypeTls;
return linphone::TransportType::TransportTypeDtls;
......
......@@ -51,7 +51,7 @@
#include "Utils.hpp"
#include "QExifImageHeader.h"
#include "QExifImageHeader.hpp"
/*!
\typedef QExifSRational
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment